Removed stricter Unix visual requirements for now and increased Windows pixel format array size from 256 to 512 to make sure all pixel formats are taken into consideration on systems that support that many.
This commit is contained in:
parent
ac3a5394ca
commit
53f61e9596
@ -308,42 +308,25 @@ XVisualInfo GlxContext::selectBestVisual(::Display* display, unsigned int bitsPe
|
|||||||
XVisualInfo* visuals = XGetVisualInfo(display, 0, NULL, &count);
|
XVisualInfo* visuals = XGetVisualInfo(display, 0, NULL, &count);
|
||||||
if (visuals)
|
if (visuals)
|
||||||
{
|
{
|
||||||
// There are no GLX versions prior to 1.0
|
|
||||||
int major = 0;
|
|
||||||
int minor = 0;
|
|
||||||
|
|
||||||
if (!glXQueryVersion(display, &major, &minor))
|
|
||||||
err() << "Failed to query GLX version" << std::endl;
|
|
||||||
|
|
||||||
// Evaluate all the returned visuals, and pick the best one
|
// Evaluate all the returned visuals, and pick the best one
|
||||||
int bestScore = 0x7FFFFFFF;
|
int bestScore = 0x7FFFFFFF;
|
||||||
XVisualInfo bestVisual;
|
XVisualInfo bestVisual;
|
||||||
for (int i = 0; i < count; ++i)
|
for (int i = 0; i < count; ++i)
|
||||||
{
|
{
|
||||||
// Check mandatory attributes
|
// Check mandatory attributes
|
||||||
int useGL, doubleBuffer, rgba;
|
int doubleBuffer;
|
||||||
glXGetConfig(display, &visuals[i], GLX_USE_GL, &useGL);
|
|
||||||
glXGetConfig(display, &visuals[i], GLX_DOUBLEBUFFER, &doubleBuffer);
|
glXGetConfig(display, &visuals[i], GLX_DOUBLEBUFFER, &doubleBuffer);
|
||||||
glXGetConfig(display, &visuals[i], GLX_RGBA, &rgba);
|
if (!doubleBuffer)
|
||||||
if (!useGL || !doubleBuffer || !rgba)
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (major > 1 || minor >= 3)
|
|
||||||
{
|
|
||||||
int drawableType;
|
|
||||||
glXGetConfig(display, &visuals[i], GLX_DRAWABLE_TYPE, &drawableType);
|
|
||||||
if (!(drawableType & GLX_WINDOW_BIT))
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Extract the components of the current visual
|
// Extract the components of the current visual
|
||||||
int red, green, blue, alpha, depth, stencil, multiSampling, samples;
|
int red, green, blue, alpha, depth, stencil, multiSampling, samples;
|
||||||
glXGetConfig(display, &visuals[i], GLX_RED_SIZE, &red);
|
glXGetConfig(display, &visuals[i], GLX_RED_SIZE, &red);
|
||||||
glXGetConfig(display, &visuals[i], GLX_GREEN_SIZE, &green);
|
glXGetConfig(display, &visuals[i], GLX_GREEN_SIZE, &green);
|
||||||
glXGetConfig(display, &visuals[i], GLX_BLUE_SIZE, &blue);
|
glXGetConfig(display, &visuals[i], GLX_BLUE_SIZE, &blue);
|
||||||
glXGetConfig(display, &visuals[i], GLX_ALPHA_SIZE, &alpha);
|
glXGetConfig(display, &visuals[i], GLX_ALPHA_SIZE, &alpha);
|
||||||
glXGetConfig(display, &visuals[i], GLX_DEPTH_SIZE, &depth);
|
glXGetConfig(display, &visuals[i], GLX_DEPTH_SIZE, &depth);
|
||||||
glXGetConfig(display, &visuals[i], GLX_STENCIL_SIZE, &stencil);
|
glXGetConfig(display, &visuals[i], GLX_STENCIL_SIZE, &stencil);
|
||||||
|
|
||||||
if (sfglx_ext_ARB_multisample == sfglx_LOAD_SUCCEEDED)
|
if (sfglx_ext_ARB_multisample == sfglx_LOAD_SUCCEEDED)
|
||||||
{
|
{
|
||||||
@ -356,14 +339,8 @@ XVisualInfo GlxContext::selectBestVisual(::Display* display, unsigned int bitsPe
|
|||||||
samples = 0;
|
samples = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Replace this with proper acceleration detection
|
||||||
bool accelerated = true;
|
bool accelerated = true;
|
||||||
if (major > 1 || minor >= 3)
|
|
||||||
{
|
|
||||||
int caveat;
|
|
||||||
glXGetConfig(display, &visuals[i], GLX_CONFIG_CAVEAT, &caveat);
|
|
||||||
if (caveat == GLX_SLOW_CONFIG)
|
|
||||||
accelerated = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Evaluate the visual
|
// Evaluate the visual
|
||||||
int color = red + green + blue + alpha;
|
int color = red + green + blue + alpha;
|
||||||
|
@ -231,9 +231,9 @@ int WglContext::selectBestPixelFormat(HDC deviceContext, unsigned int bitsPerPix
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Let's check how many formats are supporting our requirements
|
// Let's check how many formats are supporting our requirements
|
||||||
int formats[256];
|
int formats[512];
|
||||||
UINT nbFormats;
|
UINT nbFormats;
|
||||||
bool isValid = wglChoosePixelFormatARB(deviceContext, intAttributes, NULL, 256, formats, &nbFormats) != 0;
|
bool isValid = wglChoosePixelFormatARB(deviceContext, intAttributes, NULL, 512, formats, &nbFormats) != 0;
|
||||||
|
|
||||||
// Get the best format among the returned ones
|
// Get the best format among the returned ones
|
||||||
if (isValid && (nbFormats > 0))
|
if (isValid && (nbFormats > 0))
|
||||||
|
Loading…
Reference in New Issue
Block a user