Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillermo S. Romero <gsr.b3d@infernal-iceberg.com>2010-01-11 01:52:40 +0300
committerGuillermo S. Romero <gsr.b3d@infernal-iceberg.com>2010-01-11 01:52:40 +0300
commit5074a4c30748d281d04f8c54ccfc43ae2360e764 (patch)
treed4409525b57de80b00721aed686ebb444e312bc2 /intern/ghost
parent1cb013f8771990542dc5ab72bcc285e5942605b6 (diff)
Request different OpenGL oversampling levels before giving up.
Diffstat (limited to 'intern/ghost')
-rw-r--r--intern/ghost/intern/GHOST_WindowX11.cpp59
1 files changed, 32 insertions, 27 deletions
diff --git a/intern/ghost/intern/GHOST_WindowX11.cpp b/intern/ghost/intern/GHOST_WindowX11.cpp
index c500055c280..efde9005fe4 100644
--- a/intern/ghost/intern/GHOST_WindowX11.cpp
+++ b/intern/ghost/intern/GHOST_WindowX11.cpp
@@ -169,7 +169,7 @@ GHOST_WindowX11(
// Set up the minimum atrributes that we require and see if
// X can find us a visual matching those requirements.
- int attributes[40], i = 0, i_pre_aa;
+ int attributes[40], i, samples;
Atom atoms[2];
int natom;
int glxVersionMajor, glxVersionMinor; // As in GLX major.minor
@@ -179,39 +179,44 @@ GHOST_WindowX11(
return;
}
- if(m_stereoVisual)
- attributes[i++] = GLX_STEREO;
-
- attributes[i++] = GLX_RGBA;
- attributes[i++] = GLX_DOUBLEBUFFER;
- attributes[i++] = GLX_RED_SIZE; attributes[i++] = 1;
- attributes[i++] = GLX_BLUE_SIZE; attributes[i++] = 1;
- attributes[i++] = GLX_GREEN_SIZE; attributes[i++] = 1;
- attributes[i++] = GLX_DEPTH_SIZE; attributes[i++] = 1;
- i_pre_aa= i;
- /* GLX 1.4+, multi-sample */
- if(m_numOfAASamples && (glxVersionMajor >= 1) && (glxVersionMinor >= 4)) {
- attributes[i++] = GLX_SAMPLE_BUFFERS; attributes[i++] = 1;
- attributes[i++] = GLX_SAMPLES; attributes[i++] = m_numOfAASamples;
- }
- attributes[i] = None;
-
- m_visual = glXChooseVisual(m_display, DefaultScreen(m_display), attributes);
+ /* Find the display with highest samples, starting at level requested */
+ for (samples = m_numOfAASamples; samples >= 0; samples--) {
+ i = 0; /* Reusing attributes array, so reset counter */
+
+ if(m_stereoVisual)
+ attributes[i++] = GLX_STEREO;
+
+ attributes[i++] = GLX_RGBA;
+ attributes[i++] = GLX_DOUBLEBUFFER;
+ attributes[i++] = GLX_RED_SIZE; attributes[i++] = 1;
+ attributes[i++] = GLX_BLUE_SIZE; attributes[i++] = 1;
+ attributes[i++] = GLX_GREEN_SIZE; attributes[i++] = 1;
+ attributes[i++] = GLX_DEPTH_SIZE; attributes[i++] = 1;
+ /* GLX >= 1.4 required for multi-sample */
+ if(samples && (glxVersionMajor >= 1) && (glxVersionMinor >= 4)) {
+ attributes[i++] = GLX_SAMPLE_BUFFERS; attributes[i++] = 1;
+ attributes[i++] = GLX_SAMPLES; attributes[i++] = samples;
+ }
+ attributes[i] = None;
- if (m_visual == NULL) {
- /* possibly the X Server does not support GLX_SAMPLE_BUFFERS */
- attributes[i_pre_aa] = None;
m_visual = glXChooseVisual(m_display, DefaultScreen(m_display), attributes);
+ /* Any sample level or even zero, which means oversampling disabled, is good
+ but we need a valid visual to continue */
if (m_visual == NULL) {
- // barf : no visual meeting these requirements could be found.
- printf("%s:%d: X11 glXChooseVisual() failed, verify working openGL system!\n", __FILE__, __LINE__);
- return;
+ if (samples == 0) {
+ /* All options exhausted, cannot continue */
+ printf("%s:%d: X11 glXChooseVisual() failed, verify working openGL system!\n", __FILE__, __LINE__);
+ return;
+ }
} else {
- printf("%s:%d: X11 glXChooseVisual() multi-sample failed, continue with multisample disabled\n", __FILE__, __LINE__);
+ if (m_numOfAASamples && (m_numOfAASamples > samples)) {
+ printf("%s:%d: oversampling requested %i but using %i samples\n", __FILE__, __LINE__, m_numOfAASamples, samples);
+ }
+ break;
}
}
-
+
memset(&m_xtablet, 0, sizeof(m_xtablet));
// Create a bunch of attributes needed to create an X window.