/*
* TODO BEFORE THE STABLE RELEASE:
*
- * glutGet() -- X11 tests passed, but check if all enums handled (what about Win32?)
- * glutDeviceGet() -- X11 tests passed, but check if all enums handled (what about Win32?)
+ * glutGet() -- X11 tests passed, but check if all enums
+ * handled (what about Win32?)
+ * glutDeviceGet() -- X11 tests passed, but check if all enums
+ * handled (what about Win32?)
* glutGetModifiers() -- OK, but could also remove the limitation
* glutLayerGet() -- what about GLUT_NORMAL_DAMAGED?
*
*/
static int fghGetConfig( int attribute )
{
- int returnValue ;
-
- /*
- * Return nothing if there is no current window set
- */
- if( fgStructure.Window == NULL )
- return( 0 );
+ int returnValue = 0;
- /*
- * glXGetConfig should work fine
- */
- glXGetConfig( fgDisplay.Display, fgStructure.Window->Window.VisualInfo, attribute, &returnValue );
+ if( fgStructure.Window )
+ glXGetConfig( fgDisplay.Display, fgStructure.Window->Window.VisualInfo,
+ attribute, &returnValue );
-
- /*
- * Have the query results returned
- */
- return ( returnValue ) ;
+ return returnValue;
}
#endif
*/
switch( eWhat )
{
- case GLUT_INIT_WINDOW_X: fgState.Position.X = (GLint)value ;
- break ;
- case GLUT_INIT_WINDOW_Y: fgState.Position.Y = (GLint)value ;
- break ;
- case GLUT_INIT_WINDOW_WIDTH: fgState.Size.X = (GLint)value ;
- break ;
- case GLUT_INIT_WINDOW_HEIGHT: fgState.Size.Y = (GLint)value ;
- break ;
- case GLUT_INIT_DISPLAY_MODE: fgState.DisplayMode = (unsigned int)value ;
- break ;
-
- case GLUT_ACTION_ON_WINDOW_CLOSE: fgState.ActionOnWindowClose = value ;
- break ;
-
- case GLUT_RENDERING_CONTEXT: fgState.UseCurrentContext = ( value == GLUT_USE_CURRENT_CONTEXT ) ? TRUE : FALSE ;
- break ;
+ case GLUT_INIT_WINDOW_X:
+ fgState.Position.X = (GLint)value;
+ break;
+
+ case GLUT_INIT_WINDOW_Y:
+ fgState.Position.Y = (GLint)value;
+ break;
+
+ case GLUT_INIT_WINDOW_WIDTH:
+ fgState.Size.X = (GLint)value;
+ break;
+
+ case GLUT_INIT_WINDOW_HEIGHT:
+ fgState.Size.Y = (GLint)value;
+ break;
+
+ case GLUT_INIT_DISPLAY_MODE:
+ fgState.DisplayMode = (unsigned int)value;
+ break;
+
+ case GLUT_ACTION_ON_WINDOW_CLOSE:
+ fgState.ActionOnWindowClose = value;
+ break;
+
+ case GLUT_RENDERING_CONTEXT:
+ fgState.UseCurrentContext =
+ ( value == GLUT_USE_CURRENT_CONTEXT ) ? TRUE : FALSE;
+ break;
case GLUT_WINDOW_CURSOR:
- if( fgStructure.Window != NULL ) fgStructure.Window->State.Cursor = value ;
- break ;
+ if( fgStructure.Window != NULL )
+ fgStructure.Window->State.Cursor = value;
+ break;
default:
/*
*/
case GLUT_WINDOW_X:
case GLUT_WINDOW_Y:
+ case GLUT_WINDOW_BORDER_WIDTH:
+ case GLUT_WINDOW_HEADER_HEIGHT:
{
int x, y;
Window w;
case GLUT_WINDOW_X: return x;
case GLUT_WINDOW_Y: return y;
}
+
+ if ( w == 0 )
+ return( 0 ); /* Just in case */
+
+ XTranslateCoordinates(
+ fgDisplay.Display,
+ fgStructure.Window->Window.Handle,
+ w, 0, 0, &x, &y, &w);
+
+ switch ( eWhat )
+ {
+ case GLUT_WINDOW_BORDER_WIDTH: return x;
+ case GLUT_WINDOW_HEADER_HEIGHT: return y;
+ }
}
case GLUT_WINDOW_WIDTH:
case GLUT_WINDOW_HEIGHT:
- case GLUT_WINDOW_BORDER_WIDTH :
- case GLUT_WINDOW_HEADER_HEIGHT :
{
XWindowAttributes winAttributes;
{
case GLUT_WINDOW_WIDTH: return winAttributes.width ;
case GLUT_WINDOW_HEIGHT: return winAttributes.height ;
- case GLUT_WINDOW_BORDER_WIDTH : return winAttributes.border_width ;
- case GLUT_WINDOW_HEADER_HEIGHT : return winAttributes.border_width * 3 ; /* a kludge for now */
}
}
* Handle the OpenGL inquiries
*/
case GLUT_WINDOW_RGBA:
- glGetBooleanv ( GL_RGBA_MODE, &boolValue ) ; /* True if color buffers store RGBA */
+ glGetBooleanv ( GL_RGBA_MODE, &boolValue ) ;
returnValue = boolValue ? 1 : 0 ;
return ( returnValue ) ;
case GLUT_WINDOW_DOUBLEBUFFER:
- glGetBooleanv ( GL_DOUBLEBUFFER, &boolValue ) ; /* True if front and back buffers exist */
+ glGetBooleanv ( GL_DOUBLEBUFFER, &boolValue ) ;
returnValue = boolValue ? 1 : 0 ;
return ( returnValue ) ;
case GLUT_WINDOW_STEREO:
- glGetBooleanv ( GL_STEREO, &boolValue ) ; /* True if left and right buffers exist */
+ glGetBooleanv ( GL_STEREO, &boolValue ) ;
returnValue = boolValue ? 1 : 0 ;
return ( returnValue ) ;
case GLUT_WINDOW_RED_SIZE:
- glGetIntegerv ( GL_RED_BITS, &returnValue ) ; /* Number of bits per red component in color buffers */
+ glGetIntegerv ( GL_RED_BITS, &returnValue ) ;
return ( returnValue ) ;
case GLUT_WINDOW_GREEN_SIZE:
- glGetIntegerv ( GL_GREEN_BITS, &returnValue ) ; /* Number of bits per green component in color buffers */
+ glGetIntegerv ( GL_GREEN_BITS, &returnValue ) ;
return ( returnValue ) ;
case GLUT_WINDOW_BLUE_SIZE:
- glGetIntegerv ( GL_BLUE_BITS, &returnValue ) ; /* Number of bits per blue component in color buffers */
+ glGetIntegerv ( GL_BLUE_BITS, &returnValue ) ;
return ( returnValue ) ;
case GLUT_WINDOW_ALPHA_SIZE:
- glGetIntegerv ( GL_ALPHA_BITS, &returnValue ) ; /* Number of bits per alpha component in color buffers */
+ glGetIntegerv ( GL_ALPHA_BITS, &returnValue ) ;
return ( returnValue ) ;
case GLUT_WINDOW_ACCUM_RED_SIZE:
- glGetIntegerv ( GL_ACCUM_RED_BITS, &returnValue ) ; /* Number of bits per red component in the accumulation buffer */
+ glGetIntegerv ( GL_ACCUM_RED_BITS, &returnValue ) ;
return ( returnValue ) ;
case GLUT_WINDOW_ACCUM_GREEN_SIZE:
- glGetIntegerv ( GL_ACCUM_GREEN_BITS, &returnValue ) ; /* Number of bits per green component in the accumulation buffer */
+ glGetIntegerv ( GL_ACCUM_GREEN_BITS, &returnValue ) ;
return ( returnValue ) ;
case GLUT_WINDOW_ACCUM_BLUE_SIZE:
- glGetIntegerv ( GL_ACCUM_BLUE_BITS, &returnValue ) ; /* Number of bits per blue component in the accumulation buffer */
+ glGetIntegerv ( GL_ACCUM_BLUE_BITS, &returnValue ) ;
return ( returnValue ) ;
case GLUT_WINDOW_ACCUM_ALPHA_SIZE:
- glGetIntegerv ( GL_ACCUM_ALPHA_BITS, &returnValue ) ; /* Number of bits per alpha component in the accumulation buffer */
+ glGetIntegerv ( GL_ACCUM_ALPHA_BITS, &returnValue ) ;
return ( returnValue ) ;
case GLUT_WINDOW_DEPTH_SIZE:
- glGetIntegerv ( GL_DEPTH_BITS, &returnValue ) ; /* Number of depth-buffer bitplanes */
+ glGetIntegerv ( GL_DEPTH_BITS, &returnValue ) ;
return ( returnValue ) ;
case GLUT_WINDOW_BUFFER_SIZE:
case GLUT_WINDOW_HEIGHT:
{
/*
- * There is considerable confusion about the "right thing to do" concerning window
- * size and position. GLUT itself is not consistent between Windows and Linux; since
- * platform independence is a virtue for "freeglut", we decided to break with GLUT's
- * behaviour.
- * Under Linux, it is apparently not possible to get the window border sizes in order
- * to subtract them off the window's initial position until some time after the window
- * has been created. Therefore we decided on the following behaviour, both under
- * Windows and under Linux:
- * - When you create a window with position (x,y) and size (w,h), the upper left hand
- * corner of the outside of the window is at (x,y) and the size of the drawable area
- * is (w,h).
- * - When you query the size and position of the window--as is happening here for
- * Windows--"freeglut" will return the size of the drawable area--the (w,h) that you
- * specified when you created the window--and the coordinates of the upper left hand
- * corner of the drawable area--which is NOT the (x,y) you specified.
+ * There is considerable confusion about the "right thing to
+ * do" concerning window size and position. GLUT itself is
+ * not consistent between Windows and UNIX/X11; since
+ * platform independence is a virtue for "freeglut", we
+ * decided to break with GLUT's behaviour.
+ *
+ * Under UNIX/X11, it is apparently not possible to get the
+ * window border sizes in order to subtract them off the
+ * window's initial position until some time after the window
+ * has been created. Therefore we decided on the following
+ * behaviour, both under Windows and under UNIX/X11:
+ * - When you create a window with position (x,y) and size
+ * (w,h), the upper left hand corner of the outside of the
+ * window is at (x,y) and the size of the drawable area is
+ * (w,h).
+ * - When you query the size and position of the window--as
+ * is happening here for Windows--"freeglut" will return
+ * the size of the drawable area--the (w,h) that you
+ * specified when you created the window--and the coordinates
+ * of the upper left hand corner of the drawable
+ * area--which is NOT the (x,y) you specified.
*/
RECT winRect;
- /*
- * Check if there is a window to be queried for dimensions:
- */
freeglut_return_val_if_fail( fgStructure.Window != NULL, 0 );
/*
winRect.bottom -= GetSystemMetrics( SM_CYSIZEFRAME );
}
- /*
- * ...and finally return the caller the desired value:
- */
switch( eWhat )
{
case GLUT_WINDOW_X: return( winRect.left );
return ( GetSystemMetrics( SM_CYCAPTION ) ) ;
case GLUT_DISPLAY_MODE_POSSIBLE:
- /*
- * Check if the current display mode is possible
- */
return( fgSetupPixelFormat( fgStructure.Window, TRUE, PFD_MAIN_PLANE ) );
case GLUT_WINDOW_FORMAT_ID:
- /*
- * Return the pixel format of the current window
- */
if( fgStructure.Window != NULL )
return( GetPixelFormat( fgStructure.Window->Window.Device ) );