Switch to ANSI C comments. Removed always true tests on unsigned char. Single buffering fix..

git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@53 7f0cb862-5218-0410-a997-914c9d46530a
This commit is contained in:
dheyse 2003-03-12 14:38:47 +00:00
parent 69bc01309f
commit 33e68949df
9 changed files with 83 additions and 49 deletions

View File

@ -111,11 +111,11 @@ void FGAPIENTRY glutSetCursor( int cursorID )
/* /*
* This is a temporary solution only... * This is a temporary solution only...
*/ */
// Set the cursor AND change it for this window class. /* Set the cursor AND change it for this window class. */
# define MAP_CURSOR(a,b) case a: SetCursor( LoadCursor( NULL, b ) ); \ # define MAP_CURSOR(a,b) case a: SetCursor( LoadCursor( NULL, b ) ); \
SetClassLong(fgStructure.Window->Window.Handle,GCL_HCURSOR,(LONG)LoadCursor(NULL,b)); \ SetClassLong(fgStructure.Window->Window.Handle,GCL_HCURSOR,(LONG)LoadCursor(NULL,b)); \
break; break;
// Nuke the cursor AND change it for this window class. /* Nuke the cursor AND change it for this window class. */
# define ZAP_CURSOR(a,b) case a: SetCursor( NULL ); \ # define ZAP_CURSOR(a,b) case a: SetCursor( NULL ); \
SetClassLong(fgStructure.Window->Window.Handle,GCL_HCURSOR,(LONG)NULL); \ SetClassLong(fgStructure.Window->Window.Handle,GCL_HCURSOR,(LONG)NULL); \
break; break;
@ -132,7 +132,7 @@ void FGAPIENTRY glutSetCursor( int cursorID )
MAP_CURSOR( GLUT_CURSOR_WAIT, IDC_WAIT ); MAP_CURSOR( GLUT_CURSOR_WAIT, IDC_WAIT );
MAP_CURSOR( GLUT_CURSOR_TEXT, IDC_UPARROW ); MAP_CURSOR( GLUT_CURSOR_TEXT, IDC_UPARROW );
MAP_CURSOR( GLUT_CURSOR_CROSSHAIR, IDC_CROSS ); MAP_CURSOR( GLUT_CURSOR_CROSSHAIR, IDC_CROSS );
//MAP_CURSOR( GLUT_CURSOR_NONE, IDC_NO ); /* MAP_CURSOR( GLUT_CURSOR_NONE, IDC_NO ); */
ZAP_CURSOR( GLUT_CURSOR_NONE, NULL ); ZAP_CURSOR( GLUT_CURSOR_NONE, NULL );
default: default:

View File

@ -75,6 +75,11 @@ void FGAPIENTRY glutSwapBuffers( void )
glFlush(); glFlush();
#if TARGET_HOST_UNIX_X11 #if TARGET_HOST_UNIX_X11
/*
* If it's single-buffered, we shouldn't be here.
*/
if ( ! fgStructure.Window->Window.DoubleBuffered ) return ;
/* /*
* Issue the glXSwapBuffers call and be done with it * Issue the glXSwapBuffers call and be done with it
*/ */

View File

@ -208,8 +208,6 @@ void FGAPIENTRY glutBitmapString( void* fontID, const char *string )
* start of the line and down one line. * start of the line and down one line.
*/ */
for( c = 0; c < numchar; c++ ) for( c = 0; c < numchar; c++ )
{
if ( ( string[ c ] >= 0 ) && ( string[ c ] < 256 ) )
{ {
if ( string[c] == '\n' ) if ( string[c] == '\n' )
{ {
@ -231,7 +229,6 @@ void FGAPIENTRY glutBitmapString( void* fontID, const char *string )
) ; ) ;
} }
} }
}
/* /*
* Restore the old pixel store settings * Restore the old pixel store settings
@ -277,8 +274,6 @@ int FGAPIENTRY glutBitmapLength( void* fontID, const char* string )
*/ */
int numchar = strlen ( string ) ; int numchar = strlen ( string ) ;
for( c = 0; c < numchar; c++ ) for( c = 0; c < numchar; c++ )
{
if ( ( string[ c ] >= 0 ) && ( string[ c ] < 256 ) )
{ {
if ( string[ c ] == '\n' ) /* Carriage return, reset the length of this line */ if ( string[ c ] == '\n' ) /* Carriage return, reset the length of this line */
{ {
@ -288,7 +283,6 @@ int FGAPIENTRY glutBitmapLength( void* fontID, const char* string )
else /* Not a carriage return, increment the length of this line */ else /* Not a carriage return, increment the length of this line */
this_line_length += *(font->Characters[ string[ c ] - 1 ]) ; this_line_length += *(font->Characters[ string[ c ] - 1 ]) ;
} }
}
if ( length < this_line_length ) length = this_line_length ; if ( length < this_line_length ) length = this_line_length ;

View File

@ -205,7 +205,7 @@ void FGAPIENTRY glutSolidSphere( GLdouble dRadius, GLint slices, GLint stacks )
float cphi, sphi, cpsi, spsi ; float cphi, sphi, cpsi, spsi ;
glPushMatrix(); glPushMatrix();
//glScalef( radius, radius, radius ); /* glScalef( radius, radius, radius ); */
row = calloc( sizeof(float), slices * 3 ); row = calloc( sizeof(float), slices * 3 );
next = calloc( sizeof(float), slices * 3 ); next = calloc( sizeof(float), slices * 3 );
@ -984,7 +984,7 @@ void FGAPIENTRY glutWireSierpinskiSponge ( int num_levels, GLfloat offset[3], GL
} }
else else
{ {
GLfloat local_offset[3] ; // Use a local variable to avoid buildup of roundoff errors GLfloat local_offset[3] ; /* Use a local variable to avoid buildup of roundoff errors */
num_levels -- ; num_levels -- ;
scale /= 2.0 ; scale /= 2.0 ;
local_offset[0] = offset[0] + scale * tetrahedron_v[0][0] ; local_offset[0] = offset[0] + scale * tetrahedron_v[0][0] ;
@ -1026,7 +1026,7 @@ void FGAPIENTRY glutSolidSierpinskiSponge ( int num_levels, GLfloat offset[3], G
} }
else else
{ {
GLfloat local_offset[3] ; // Use a local variable to avoid buildup of roundoff errors GLfloat local_offset[3] ; /* Use a local variable to avoid buildup of roundoff errors */
num_levels -- ; num_levels -- ;
scale /= 2.0 ; scale /= 2.0 ;
local_offset[0] = offset[0] + scale * tetrahedron_v[0][0] ; local_offset[0] = offset[0] + scale * tetrahedron_v[0][0] ;

View File

@ -84,10 +84,9 @@
#include <X11/Xatom.h> #include <X11/Xatom.h>
#include <X11/keysym.h> #include <X11/keysym.h>
/* #ifndef __sgi
* This will generate errors, but I don't have any idea how to fix it (will autoconf help?)
*/
#include <X11/extensions/xf86vmode.h> #include <X11/extensions/xf86vmode.h>
#endif
#endif #endif
/* /*
@ -292,6 +291,7 @@ struct tagSFG_Context
Window Handle; /* The window's handle */ Window Handle; /* The window's handle */
GLXContext Context; /* The OpenGL context */ GLXContext Context; /* The OpenGL context */
XVisualInfo* VisualInfo; /* The window's visual information */ XVisualInfo* VisualInfo; /* The window's visual information */
int DoubleBuffered; /* Treat the window as double-buffered */
#elif TARGET_HOST_WIN32 #elif TARGET_HOST_WIN32
HWND Handle; /* The window's handle */ HWND Handle; /* The window's handle */

View File

@ -540,7 +540,7 @@ void fgJoystickClose( void )
#endif #endif
free ( fgJoystick ) ; free ( fgJoystick ) ;
fgJoystick = NULL ; // show joystick has been deinitialized fgJoystick = NULL ; /* show joystick has been deinitialized */
} }
/* /*

View File

@ -1189,7 +1189,7 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPara
case WM_ACTIVATE: case WM_ACTIVATE:
if (LOWORD(wParam) != WA_INACTIVE) if (LOWORD(wParam) != WA_INACTIVE)
{ {
//glutSetCursor( fgStructure.Window->State.Cursor ); /* glutSetCursor( fgStructure.Window->State.Cursor ); */
printf("WM_ACTIVATE: glutSetCursor( %p, %d)\n", window, window->State.Cursor ); printf("WM_ACTIVATE: glutSetCursor( %p, %d)\n", window, window->State.Cursor );
glutSetCursor( window->State.Cursor ); glutSetCursor( window->State.Cursor );
@ -1208,10 +1208,10 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPara
(fgStructure.Window->State.Cursor == GLUT_CURSOR_NONE)) (fgStructure.Window->State.Cursor == GLUT_CURSOR_NONE))
SetCursor( NULL ); SetCursor( NULL );
#else #else
// Set the cursor AND change it for this window class. /* Set the cursor AND change it for this window class. */
# define MAP_CURSOR(a,b) case a: SetCursor( LoadCursor( NULL, b ) ); \ # define MAP_CURSOR(a,b) case a: SetCursor( LoadCursor( NULL, b ) ); \
break; break;
// Nuke the cursor AND change it for this window class. /* Nuke the cursor AND change it for this window class. */
# define ZAP_CURSOR(a,b) case a: SetCursor( NULL ); \ # define ZAP_CURSOR(a,b) case a: SetCursor( NULL ); \
break; break;
@ -1228,7 +1228,7 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPara
MAP_CURSOR( GLUT_CURSOR_WAIT, IDC_WAIT ); MAP_CURSOR( GLUT_CURSOR_WAIT, IDC_WAIT );
MAP_CURSOR( GLUT_CURSOR_TEXT, IDC_UPARROW ); MAP_CURSOR( GLUT_CURSOR_TEXT, IDC_UPARROW );
MAP_CURSOR( GLUT_CURSOR_CROSSHAIR, IDC_CROSS ); MAP_CURSOR( GLUT_CURSOR_CROSSHAIR, IDC_CROSS );
//MAP_CURSOR( GLUT_CURSOR_NONE, IDC_NO ); /* MAP_CURSOR( GLUT_CURSOR_NONE, IDC_NO ); */
ZAP_CURSOR( GLUT_CURSOR_NONE, NULL ); ZAP_CURSOR( GLUT_CURSOR_NONE, NULL );
default: default:
@ -1697,7 +1697,7 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPara
if ( window->Callbacks.Display ) if ( window->Callbacks.Display )
window->Callbacks.Display () ; window->Callbacks.Display () ;
// lRet = DefWindowProc( hWnd, uMsg, wParam, lParam ) ; /* lRet = DefWindowProc( hWnd, uMsg, wParam, lParam ) ; */
break ; break ;
/* /*

View File

@ -209,7 +209,7 @@ void fgAddToWindowDestroyList ( SFG_Window* window, GLboolean needToClose )
void fgCloseWindows () void fgCloseWindows ()
{ {
SFG_WindowList *window_ptr = WindowsToDestroy ; SFG_WindowList *window_ptr = WindowsToDestroy ;
WindowsToDestroy = (SFG_WindowList*)NULL ; // In case the destroy callbacks cause more windows to be closed WindowsToDestroy = (SFG_WindowList*)NULL ; /* In case the destroy callbacks cause more windows to be closed */
while ( window_ptr ) while ( window_ptr )
{ {

View File

@ -360,10 +360,36 @@ void fgOpenWindow( SFG_Window* window, const char* title, int x, int y, int w, i
freeglut_assert_ready; freeglut_assert_ready;
/*
* Save the window's single- or double-buffering state
*/
window->Window.DoubleBuffered = ( fgState.DisplayMode & GLUT_DOUBLE ) ? 1 : 0 ;
/* /*
* Here we are upon the stage. Have the visual selected. * Here we are upon the stage. Have the visual selected.
*/ */
window->Window.VisualInfo = fgChooseVisual(); window->Window.VisualInfo = fgChooseVisual();
if ( ! window->Window.VisualInfo )
{
/*
* The "fgChooseVisual" returned a null meaning that the visual context is not available.
* Try a couple of variations to see if they will work.
*/
if ( ! ( fgState.DisplayMode & GLUT_DOUBLE ) )
{
/*
* Single buffering--try it doubled
*/
fgState.DisplayMode |= GLUT_DOUBLE ;
window->Window.VisualInfo = fgChooseVisual();
}
/*
* GLUT also checks for multi-sampling, but I don't see that anywhere else in FREEGLUT
* so I won't bother with it for the moment.
*/
}
assert( window->Window.VisualInfo != NULL ); assert( window->Window.VisualInfo != NULL );
/* /*
@ -515,6 +541,15 @@ void fgOpenWindow( SFG_Window* window, const char* title, int x, int y, int w, i
# endif # endif
} }
/*
* If it's not double-buffered, make sure the rendering is done to the front buffer.
*/
if ( ! window->Window.DoubleBuffered )
{
glDrawBuffer ( GL_FRONT ) ;
glReadBuffer ( GL_FRONT ) ;
}
#elif TARGET_HOST_WIN32 #elif TARGET_HOST_WIN32
WNDCLASS wc; WNDCLASS wc;