From 7d3a0c36235187760d88e2e97676aabee12f066a Mon Sep 17 00:00:00 2001 From: spanne Date: Mon, 16 Mar 2009 17:53:54 +0000 Subject: [PATCH] Set the default number of samples per pixel to 4 and actually use the value set with glutSetOption(GLUT_MULTISAMPLE,...) in Windows code. Previously the Windows code used a hardwired value of 4 and the GLX code had a default of 0, neither made much sense. Similarly, set the default number of auxiliary buffers to 1 and use that value when GLUT_AUX is used. Note: There latter token has the same value as GLUT_AUX1, and for historical reasons we seem to have 2 APIs to set the number of auxiliary buffers: Explicitly using GLUT_AUX1 ... GLUT_AUX4, and using a combination of GLUT_AUX with glutSetOption. The default of 1 ensures consistent behaviour in both cases. git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@802 7f0cb862-5218-0410-a997-914c9d46530a --- freeglut/freeglut/ChangeLog | 11 +++++++++ freeglut/freeglut/src/freeglut_init.c | 4 ++-- freeglut/freeglut/src/freeglut_window.c | 30 ++++++++++++++++--------- 3 files changed, 32 insertions(+), 13 deletions(-) diff --git a/freeglut/freeglut/ChangeLog b/freeglut/freeglut/ChangeLog index 70f4b9e..fb23f5f 100644 --- a/freeglut/freeglut/ChangeLog +++ b/freeglut/freeglut/ChangeLog @@ -1,5 +1,16 @@ 2009-03-16 Sven Panne + * src/freeglut_init.c,src/freeglut_window.c: Set the default number of + samples per pixel to 4 and actually use the value set with + glutSetOption(GLUT_MULTISAMPLE,...) in Windows code. Previously the + Windows code used a hardwired value of 4 and the GLX code had a + default of 0, neither made much sense. Similarly, set the default + number of auxiliary buffers to 1 and use that value when GLUT_AUX is + used. Note: There latter token has the same value as GLUT_AUX1, and + for historical reasons we seem to have 2 APIs to set the number of + auxiliary buffers: Explicitly using GLUT_AUX1 ... GLUT_AUX4, and using + a combination of GLUT_AUX with glutSetOption. The default of 1 ensures + consistent behaviour in both cases. * src/freeglut_state.c: Added GLUT_AUX and GLUT_MULTISAMPLE as possible parameters for glutGet, making things more symmetric with glutSetOption. diff --git a/freeglut/freeglut/src/freeglut_init.c b/freeglut/freeglut/src/freeglut_init.c index bf5b5ac..768f89e 100644 --- a/freeglut/freeglut/src/freeglut_init.c +++ b/freeglut/freeglut/src/freeglut_init.c @@ -84,8 +84,8 @@ SFG_State fgState = { { -1, -1, GL_FALSE }, /* Position */ NULL, /* ProgramName */ GL_FALSE, /* JoysticksInitialised */ GL_FALSE, /* InputDevsInitialised */ - 0, /* AuxiliaryBufferNumber */ - 0, /* SampleNumber */ + 1, /* AuxiliaryBufferNumber */ + 4, /* SampleNumber */ 1, /* MajorVersion */ 0, /* MajorVersion */ 0 /* ContextFlags */ diff --git a/freeglut/freeglut/src/freeglut_window.c b/freeglut/freeglut/src/freeglut_window.c index cc73b88..005074b 100644 --- a/freeglut/freeglut/src/freeglut_window.c +++ b/freeglut/freeglut/src/freeglut_window.c @@ -132,14 +132,22 @@ GLXFBConfig* fgChooseFBConfig( void ) ATTRIB_VAL( GLX_ACCUM_ALPHA_SIZE, 1 ); } - if ((fgState.DisplayMode & GLUT_AUX) - || (fgState.DisplayMode & GLUT_AUX1) - || (fgState.DisplayMode & GLUT_AUX2) - || (fgState.DisplayMode & GLUT_AUX3) - || (fgState.DisplayMode & GLUT_AUX4)) - { - ATTRIB_VAL(GLX_AUX_BUFFERS, fgState.AuxiliaryBufferNumber) - } + if( fgState.DisplayMode & GLUT_AUX4 ) + { + ATTRIB_VAL(GLX_AUX_BUFFERS, 4); + } + else if( fgState.DisplayMode & GLUT_AUX3 ) + { + ATTRIB_VAL(GLX_AUX_BUFFERS, 3); + } + else if( fgState.DisplayMode & GLUT_AUX2 ) + { + ATTRIB_VAL(GLX_AUX_BUFFERS, 2); + } + else if( fgState.DisplayMode & GLUT_AUX1 ) /* NOTE: Same as GLUT_AUX! */ + { + ATTRIB_VAL(GLX_AUX_BUFFERS, fgState.AuxiliaryBufferNumber); + } if (fgState.DisplayMode & GLUT_MULTISAMPLE) { @@ -427,8 +435,8 @@ GLboolean fgSetupPixelFormat( SFG_Window* window, GLboolean checkOnly, pfd.cAuxBuffers = 3; else if( fgState.DisplayMode & GLUT_AUX2 ) pfd.cAuxBuffers = 2; - else if( fgState.DisplayMode & GLUT_AUX1 ) - pfd.cAuxBuffers = 1; + else if( fgState.DisplayMode & GLUT_AUX1 ) /* NOTE: Same as GLUT_AUX! */ + pfd.cAuxBuffers = fgState.AuxiliaryBufferNumber; else pfd.cAuxBuffers = 0; @@ -497,7 +505,7 @@ GLboolean fgSetupPixelFormat( SFG_Window* window, GLboolean checkOnly, pAttributes[iCounter++]=WGL_DOUBLE_BUFFER_ARB; pAttributes[iCounter++]=(fgState.DisplayMode & GLUT_DOUBLE)!=0; pAttributes[iCounter++]=WGL_SAMPLE_BUFFERS_ARB; pAttributes[iCounter++]=GL_TRUE; - pAttributes[iCounter++]=WGL_SAMPLES_ARB; pAttributes[iCounter++]=4; + pAttributes[iCounter++]=WGL_SAMPLES_ARB; pAttributes[iCounter++]=fgState.SampleNumber; pAttributes[iCounter++]=0; pAttributes[iCounter++]=0; /* terminator */ bValid = wglChoosePixelFormatARBProc(window->Window.Device,pAttributes,fAttributes,1,&iPixelFormat,&numFormats);