mirror of
https://github.com/SFML/SFML.git
synced 2024-11-24 20:31:05 +08:00
Implemented proper video mode depth detection on Linux
git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/trunk@1045 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
parent
b2c751d0b2
commit
3b1abf635e
@ -5,6 +5,7 @@
|
||||
#include <SFML/Window.hpp>
|
||||
#include <fstream>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Entry point of application
|
||||
@ -15,7 +16,7 @@
|
||||
int main()
|
||||
{
|
||||
// Create the main window
|
||||
sf::Window App(sf::VideoMode(640, 480, 32), "SFML Window");
|
||||
sf::Window App(sf::VideoMode(640, 480, 1), "SFML Window");
|
||||
|
||||
// Create a clock for measuring the time elapsed
|
||||
sf::Clock Clock;
|
||||
|
@ -63,15 +63,24 @@ void VideoModeSupport::GetSupportedVideoModes(std::vector<VideoMode>& Modes)
|
||||
XRRScreenSize* Sizes = XRRConfigSizes(Config, &NbSizes);
|
||||
if (Sizes && (NbSizes > 0))
|
||||
{
|
||||
// Add them to the video modes array
|
||||
for (int i = 0; i < NbSizes; ++i)
|
||||
// Get the list of supported depths
|
||||
int NbDepths = 0;
|
||||
int* Depths = XListDepths(Disp, Screen, &NbDepths);
|
||||
if (Depths && (NbDepths > 0))
|
||||
{
|
||||
// Convert to sfVideoMode
|
||||
VideoMode Mode(Sizes[i].width, Sizes[i].height, 32);
|
||||
|
||||
// Add it only if it is not already in the array
|
||||
if (std::find(Modes.begin(), Modes.end(), Mode) == Modes.end())
|
||||
Modes.push_back(Mode);
|
||||
// Combine depths and sizes to fill the array of supported modes
|
||||
for (int i = 0; i < NbDepths; ++i)
|
||||
{
|
||||
for (int j = 0; j < NbSizes; ++j)
|
||||
{
|
||||
// Convert to sfVideoMode
|
||||
VideoMode Mode(Sizes[j].width, Sizes[j].height, Depths[i]);
|
||||
|
||||
// Add it only if it is not already in the array
|
||||
if (std::find(Modes.begin(), Modes.end(), Mode) == Modes.end())
|
||||
Modes.push_back(Mode);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -120,7 +129,7 @@ VideoMode VideoModeSupport::GetDesktopVideoMode()
|
||||
int NbSizes;
|
||||
XRRScreenSize* Sizes = XRRConfigSizes(Config, &NbSizes);
|
||||
if (Sizes && (NbSizes > 0))
|
||||
DesktopMode = VideoMode(Sizes[CurrentMode].width, Sizes[CurrentMode].height, 32);
|
||||
DesktopMode = VideoMode(Sizes[CurrentMode].width, Sizes[CurrentMode].height, DefaultDepth(Disp, Screen));
|
||||
|
||||
// Free the configuration instance
|
||||
XRRFreeScreenConfigInfo(Config);
|
||||
|
@ -659,6 +659,8 @@ bool WindowImplX11::CreateContext(const VideoMode& Mode, XVisualInfo& ChosenVisu
|
||||
glXGetConfig(ourDisplay, &Visuals[i], GLX_SAMPLE_BUFFERS_ARB, &MultiSampling);
|
||||
glXGetConfig(ourDisplay, &Visuals[i], GLX_SAMPLES_ARB, &Samples);
|
||||
|
||||
std::cout << "Red = " << Red << " Green = " << Green << " Blue = " << Blue << std::endl;
|
||||
|
||||
// First check the mandatory parameters
|
||||
if ((RGBA == 0) || (DoubleBuffer == 0))
|
||||
continue;
|
||||
|
Loading…
Reference in New Issue
Block a user