* Only one GLUT_AUXn bit may be used at a time.
* Value 0x0400 is defined in OpenGLUT.
*/
+#define GLUT_AUX 0x1000
+
#define GLUT_AUX1 0x1000
#define GLUT_AUX2 0x2000
#define GLUT_AUX3 0x4000
#define GLUT_AUX4 0x8000
+
/*
* Process loop function, see freeglut_main.c
*/
* State setting and retrieval functions, see freeglut_state.c
*/
FGAPI void FGAPIENTRY glutSetOption ( GLenum option_flag, int value );
+FGAPI int * FGAPIENTRY glutGetModeValues(GLenum mode, int * size);
/* A.Donev: User-data manipulation */
FGAPI void* FGAPIENTRY glutGetWindowData( void );
FGAPI void FGAPIENTRY glutSetWindowData(void* data);
CHECK_NAME(glutWMCloseFunc);
CHECK_NAME(glutMenuDestroyFunc);
CHECK_NAME(glutSetOption);
+ CHECK_NAME(glutGetModeValues);
CHECK_NAME(glutSetWindowData);
CHECK_NAME(glutGetWindowData);
CHECK_NAME(glutSetMenuData);
GLUT_EXEC_STATE_INIT, /* ExecState */
NULL, /* ProgramName */
GL_FALSE, /* JoysticksInitialised */
- GL_FALSE /* InputDevsInitialised */
+ GL_FALSE, /* InputDevsInitialised */
+ 0, /* AuxiliaryBufferNumber */
+ 0 /* SampleNumber */
};
break ;
case 36 : /* "aux": some number of aux buffers */
- glut_state_flag |= GLUT_AUX1;
+ glut_state_flag |= GLUT_AUX;
break ;
case 37 : /* Unrecognized */
char *ProgramName; /* Name of the invoking program */
GLboolean JoysticksInitialised; /* Only initialize if application calls for them */
GLboolean InputDevsInitialised; /* Only initialize if application calls for them */
+
+ int AuxiliaryBufferNumber; /* Number of auxiliary buffers */
+ int SampleNumber; /* Number of samples per pixel */
};
/* The structure used by display initialization in freeglut_init.c */
fgStructure.CurrentWindow->State.Cursor = value;
break;
+ case GLUT_AUX:
+ fgState.AuxiliaryBufferNumber = value;
+ break;
+
+ case GLUT_MULTISAMPLE:
+ fgState.SampleNumber = value;
+ break;
+
default:
fgWarning( "glutSetOption(): missing enum handle %d", eWhat );
break;
return -1;
}
+int * FGAPIENTRY glutGetModeValues(GLenum eWhat, int * size)
+{
+ int * array;
+
+#if TARGET_HOST_POSIX_X11
+ int attributes[9];
+ GLXFBConfig * fbconfigArray; /* Array of FBConfigs */
+ int fbconfigArraySize; /* Number of FBConfigs in the array */
+ int attribute_name = 0;
+#endif
+
+ FREEGLUT_EXIT_IF_NOT_INITIALISED("glutGetModeValues");
+
+ array = NULL;
+ *size = 0;
+
+ switch (eWhat)
+ {
+#if TARGET_HOST_POSIX_X11
+ case GLUT_AUX:
+ case GLUT_MULTISAMPLE:
+
+ attributes[0] = GLX_BUFFER_SIZE;
+ attributes[1] = GLX_DONT_CARE;
+
+ switch (eWhat)
+ {
+ case GLUT_AUX:
+ /*
+ FBConfigs are now sorted by increasing number of auxiliary
+ buffers. We want at least one buffer.
+ */
+ attributes[2] = GLX_AUX_BUFFERS;
+ attributes[3] = 1;
+ attributes[4] = None;
+
+ attribute_name = GLX_AUX_BUFFERS;
+
+ break;
+
+
+ case GLUT_MULTISAMPLE:
+ attributes[2] = GLX_AUX_BUFFERS;
+ attributes[3] = GLX_DONT_CARE;
+ attributes[4] = GLX_SAMPLE_BUFFERS;
+ attributes[5] = 1;
+ /*
+ FBConfigs are now sorted by increasing number of samples per
+ pixel. We want at least one sample.
+ */
+ attributes[6] = GLX_SAMPLES;
+ attributes[7] = 1;
+ attributes[8] = None;
+
+ attribute_name = GLX_SAMPLES;
+
+ break;
+ }
+
+ fbconfigArray = glXChooseFBConfig(fgDisplay.Display,
+ fgDisplay.Screen,
+ attributes,
+ &fbconfigArraySize);
+
+ if (fbconfigArray != NULL)
+ {
+ int * temp_array;
+ int result; /* Returned by glXGetFBConfigAttrib. Not checked. */
+ int previous_value;
+ int i;
+
+ temp_array = malloc(sizeof(int) * fbconfigArraySize);
+ previous_value = 0;
+
+ for (i = 0; i < fbconfigArraySize; i++)
+ {
+ int value;
+
+ result = glXGetFBConfigAttrib(fgDisplay.Display,
+ fbconfigArray[i],
+ attribute_name,
+ &value);
+ if (value > previous_value)
+ {
+ temp_array[*size] = value;
+ previous_value = value;
+ (*size)++;
+ }
+ }
+
+ array = malloc(sizeof(int) * (*size));
+ for (i = 0; i < *size; i++)
+ {
+ array[i] = temp_array[i];
+ }
+
+ free(temp_array);
+ XFree(fbconfigArray);
+ }
+
+ break;
+#endif
+
+ default:
+ break;
+ }
+
+ return array;
+}
+
/*** END OF FILE ***/
fghClearCallBacks( window );
fgCloseWindow( window );
-#if TARGET_HOST_UNIX_X11
- if (window->Window.FBConfig != NULL)
- {
- XFree( window->Window.FBConfig );
- }
-#endif
free( window );
if( fgStructure.CurrentWindow == window )
fgStructure.CurrentWindow = NULL;
ATTRIB_VAL( GLX_ACCUM_ALPHA_SIZE, 1 );
}
- if( fgState.DisplayMode & GLUT_AUX1 )
- ATTRIB_VAL( GLX_AUX_BUFFERS, 1 );
- if( fgState.DisplayMode & GLUT_AUX2 )
- ATTRIB_VAL( GLX_AUX_BUFFERS, 2 );
- if( fgState.DisplayMode & GLUT_AUX3 )
- ATTRIB_VAL( GLX_AUX_BUFFERS, 3 );
- if( fgState.DisplayMode & GLUT_AUX4 )
- ATTRIB_VAL( GLX_AUX_BUFFERS, 4 );
- if ( fgState.DisplayMode & GLUT_MULTISAMPLE )
- {
- ATTRIB_VAL( GLX_SAMPLE_BUFFERS, 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_MULTISAMPLE)
+ {
+ ATTRIB_VAL(GLX_SAMPLE_BUFFERS, 1)
+ ATTRIB_VAL(GLX_SAMPLES, fgState.SampleNumber)
+ }
/* Push a null at the end of the list */
ATTRIB( None );
glXDestroyContext( fgDisplay.Display, window->Window.Context );
XFree( window->Window.FBConfig );
XDestroyWindow( fgDisplay.Display, window->Window.Handle );
- XFlush( fgDisplay.Display ); /* XXX Shouldn't need this */
+ /* XFlush( fgDisplay.Display ); */ /* XXX Shouldn't need this */
#elif TARGET_HOST_MS_WINDOWS