/*
- * freeglut_main.c
+ * fg_main.c
*
* The windows message processing methods.
*
#include <GL/freeglut.h>
#include "fg_internal.h"
-#ifdef HAVE_ERRNO_H
-# include <errno.h>
-#endif
+#include <errno.h>
#include <stdarg.h>
-#ifdef HAVE_VFPRINTF
-# define VFPRINTF(s,f,a) vfprintf((s),(f),(a))
-#elif defined(HAVE__DOPRNT)
-# define VFPRINTF(s,f,a) _doprnt((f),(a),(s))
-#else
-# define VFPRINTF(s,f,a)
-#endif
/*
* Try to get the maximum value allowed for ints, falling back to the minimum
# define MIN(a,b) (((a)<(b)) ? (a) : (b))
#endif
-extern void fgPlatformProcessWork ( SFG_Window *window );
+extern void fgProcessWork ( SFG_Window *window );
extern fg_time_t fgPlatformSystemTime ( void );
extern void fgPlatformSleepForEvents( fg_time_t msec );
extern void fgPlatformProcessSingleEvent ( void );
SFG_Enumerator *enumerator )
{
if( window->State.WorkMask )
- fgPlatformProcessWork ( window );
+ fgProcessWork ( window );
fgEnumSubWindows( window, fghcbProcessWork, enumerator );
}
fprintf( stderr, "freeglut ");
if( fgState.ProgramName )
fprintf( stderr, "(%s): ", fgState.ProgramName );
- VFPRINTF( stderr, fmt, ap );
+ vfprintf( stderr, fmt, ap );
fprintf( stderr, "\n" );
va_end( ap );
fprintf( stderr, "freeglut ");
if( fgState.ProgramName )
fprintf( stderr, "(%s): ", fgState.ProgramName );
- VFPRINTF( stderr, fmt, ap );
+ vfprintf( stderr, fmt, ap );
fprintf( stderr, "\n" );
va_end( ap );
/* Step through the work list */
-void fgPlatformProcessWork(SFG_Window *window)
+void fgProcessWork(SFG_Window *window)
{
unsigned int workMask = window->State.WorkMask;
/* Now clear it so that any callback generated by the actions below can set work again */
}
}
- if (workMask & GLUT_DISPLAY_WORK)
+ /* check window state's workmask as well as some of the above callbacks might have generated redisplay requests. We can deal with those right now instead of wait for the next mainloop iteration. */
+ if (workMask & GLUT_DISPLAY_WORK || window->State.WorkMask & GLUT_DISPLAY_WORK)
{
if( window->State.Visible )
+ {
+ /* Strip out display work from the work list */
+ /* NB: do this before the display callback is called as user might call postredisplay in his display callback */
+ window->State.WorkMask &= ~GLUT_DISPLAY_WORK;
+
fghRedrawWindow ( window );
+ }
}
}
/* Perform work on the window (position, reshape, display, etc) */
fghProcessWork( );
+ /* Check OpenGL error state if requested.
+ * Don't call if no more open windows (can happen if user closes window from
+ * title bar), would lead to infinite error loop in glutReportErrors
+ */
+ if (fgState.GLDebugSwitch && fgStructure.CurrentWindow)
+ glutReportErrors( );
+
fgCloseWindows( );
}