void glutSetOption( GLenum eWhat , int value );
This is great, but what if you want to change things temporarily and you don't know what the original settings are? This could happen, for example, if you're writing a library function that sits between GLUT and the rest of your application.
What you need is a reading analogue to glutSetOption, something like a glutGetOption. Unfortunately, there is no glutGetOption.
Fortunately, there is a gluttonGetOption in the extended GLUT-like library I'm working on, glutton.
To make this function, I first added the declaration in freeglut_ext.h (glutton is based upon the marvelous freeglut library):
int FGAPIENTRY gluttonGetOption( GLenum eWhat );
Then, in freeglut_state.c, I copied the glutSetOption implementation and reversed the data flow:
int FGAPIENTRY gluttonGetOption( GLenum eWhat ) { FREEGLUT_EXIT_IF_NOT_INITIALISED ( "gluttonGetOption" ); switch( eWhat ) { case GLUT_INIT_WINDOW_X: return fgState.Position.X; break; case GLUT_INIT_WINDOW_Y: return fgState.Position.Y; break; case GLUT_INIT_WINDOW_WIDTH: return fgState.Size.X; break; case GLUT_INIT_WINDOW_HEIGHT: return fgState.Size.Y; break; case GLUT_INIT_DISPLAY_MODE: return (int)fgState.DisplayMode; break; case GLUT_ACTION_ON_WINDOW_CLOSE: return fgState.ActionOnWindowClose; break; case GLUT_RENDERING_CONTEXT: return fgState.UseCurrentContext; break; case GLUT_DIRECT_RENDERING: return fgState.DirectContext; break; case GLUT_WINDOW_CURSOR: return fgStructure.CurrentWindow->State.Cursor; break; case GLUT_AUX: return fgState.AuxiliaryBufferNumber; break; case GLUT_MULTISAMPLE: return fgState.SampleNumber; break; default: fgWarning( "glutGetOption(): missing enum handle %d", eWhat ); return 0xDeadBeef; break; } }
It doesn't get much easier than that.