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:
laurentgom 2009-03-12 21:01:50 +00:00
parent b2c751d0b2
commit 3b1abf635e
3 changed files with 22 additions and 10 deletions

View File

@ -5,6 +5,7 @@
#include <SFML/Window.hpp> #include <SFML/Window.hpp>
#include <fstream> #include <fstream>
#include <iostream>
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Entry point of application /// Entry point of application
@ -15,7 +16,7 @@
int main() int main()
{ {
// Create the main window // 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 // Create a clock for measuring the time elapsed
sf::Clock Clock; sf::Clock Clock;

View File

@ -63,15 +63,24 @@ void VideoModeSupport::GetSupportedVideoModes(std::vector<VideoMode>& Modes)
XRRScreenSize* Sizes = XRRConfigSizes(Config, &NbSizes); XRRScreenSize* Sizes = XRRConfigSizes(Config, &NbSizes);
if (Sizes && (NbSizes > 0)) if (Sizes && (NbSizes > 0))
{ {
// Add them to the video modes array // Get the list of supported depths
for (int i = 0; i < NbSizes; ++i) int NbDepths = 0;
int* Depths = XListDepths(Disp, Screen, &NbDepths);
if (Depths && (NbDepths > 0))
{ {
// Convert to sfVideoMode // Combine depths and sizes to fill the array of supported modes
VideoMode Mode(Sizes[i].width, Sizes[i].height, 32); for (int i = 0; i < NbDepths; ++i)
{
// Add it only if it is not already in the array for (int j = 0; j < NbSizes; ++j)
if (std::find(Modes.begin(), Modes.end(), Mode) == Modes.end()) {
Modes.push_back(Mode); // 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; int NbSizes;
XRRScreenSize* Sizes = XRRConfigSizes(Config, &NbSizes); XRRScreenSize* Sizes = XRRConfigSizes(Config, &NbSizes);
if (Sizes && (NbSizes > 0)) 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 // Free the configuration instance
XRRFreeScreenConfigInfo(Config); XRRFreeScreenConfigInfo(Config);

View File

@ -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_SAMPLE_BUFFERS_ARB, &MultiSampling);
glXGetConfig(ourDisplay, &Visuals[i], GLX_SAMPLES_ARB, &Samples); glXGetConfig(ourDisplay, &Visuals[i], GLX_SAMPLES_ARB, &Samples);
std::cout << "Red = " << Red << " Green = " << Green << " Blue = " << Blue << std::endl;
// First check the mandatory parameters // First check the mandatory parameters
if ((RGBA == 0) || (DoubleBuffer == 0)) if ((RGBA == 0) || (DoubleBuffer == 0))
continue; continue;