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...
*/
// 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 ) ); \
SetClassLong(fgStructure.Window->Window.Handle,GCL_HCURSOR,(LONG)LoadCursor(NULL,b)); \
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 ); \
SetClassLong(fgStructure.Window->Window.Handle,GCL_HCURSOR,(LONG)NULL); \
break;
@ -132,7 +132,7 @@ void FGAPIENTRY glutSetCursor( int cursorID )
MAP_CURSOR( GLUT_CURSOR_WAIT, IDC_WAIT );
MAP_CURSOR( GLUT_CURSOR_TEXT, IDC_UPARROW );
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 );
default:

View File

@ -75,6 +75,11 @@ void FGAPIENTRY glutSwapBuffers( void )
glFlush();
#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
*/

View File

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

View File

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

View File

@ -540,7 +540,7 @@ void fgJoystickClose( void )
#endif
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:
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 );
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))
SetCursor( NULL );
#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 ) ); \
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 ); \
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_TEXT, IDC_UPARROW );
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 );
default:
@ -1697,7 +1697,7 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPara
if ( window->Callbacks.Display )
window->Callbacks.Display () ;
// lRet = DefWindowProc( hWnd, uMsg, wParam, lParam ) ;
/* lRet = DefWindowProc( hWnd, uMsg, wParam, lParam ) ; */
break ;
/*

View File

@ -209,7 +209,7 @@ void fgAddToWindowDestroyList ( SFG_Window* window, GLboolean needToClose )
void fgCloseWindows ()
{
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 )
{

View File

@ -360,10 +360,36 @@ void fgOpenWindow( SFG_Window* window, const char* title, int x, int y, int w, i
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.
*/
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 );
/*
@ -515,6 +541,15 @@ void fgOpenWindow( SFG_Window* window, const char* title, int x, int y, int w, i
# 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
WNDCLASS wc;