X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Ffreeglut_state.c;fp=src%2Ffreeglut_state.c;h=cca7b9226d45aef68c43b00c441a4f9da876ec31;hb=30971e75717f3d7b826714fbbb1171dfaf9164cf;hp=07539b04d8f465e0487d04337b23316d89ed9a8f;hpb=c18b61ab4c42e28172ba4fb18b72e7c8af1eb98b;p=freeglut diff --git a/src/freeglut_state.c b/src/freeglut_state.c index 07539b0..cca7b92 100644 --- a/src/freeglut_state.c +++ b/src/freeglut_state.c @@ -116,6 +116,14 @@ void FGAPIENTRY glutSetOption( GLenum eWhat, int value ) 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; @@ -720,4 +728,114 @@ int FGAPIENTRY glutLayerGet( GLenum eWhat ) 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 ***/