/* Now clear it so that any callback generated by the actions below can set work again */\r
window->State.WorkMask = 0;\r
\r
+ if (workMask&~GLUT_DISPLAY_WORK) /* Display work is the common case, skip all the below at once */\r
+ {\r
/* This is before the first display callback: call a few callbacks to inform user of window size, position, etc\r
* we know this is before the first display callback of a window as for all windows GLUT_INIT_WORK is set when\r
* they are opened, and work is done before displaying in the mainloop.\r
break;\r
}\r
}\r
+ }\r
+\r
+ if (workMask & GLUT_DISPLAY_WORK)\r
+ {\r
+ if( window->State.Visible )\r
+ fghRedrawWindow ( window );\r
+\r
+ /* Strip out display work that might have ended up on work list now as some of the above genereates callbacks */\r
+ window->State.WorkMask &= ~GLUT_DISPLAY_WORK;\r
+ }\r
}\r
\r
" with no current window defined.", "glutPostRedisplay" ) ;
}
- fgStructure.CurrentWindow->State.Redisplay = GL_TRUE;
+ fgStructure.CurrentWindow->State.WorkMask |= GLUT_DISPLAY_WORK;
}
/*
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutPostWindowRedisplay" );
window = fgWindowByID( windowID );
freeglut_return_if_fail( window );
- window->State.Redisplay = GL_TRUE;
+ window->State.WorkMask |= GLUT_DISPLAY_WORK;
}
/*** END OF FILE ***/
#define GLUT_SIZE_WORK (1<<3)
#define GLUT_ZORDER_WORK (1<<4)
#define GLUT_FULL_SCREEN_WORK (1<<5)
+#define GLUT_DISPLAY_WORK (1<<6)
/*
* An enumeration containing the state of the GLUT execution:
int DesiredZOrder; /* desired window Z Order position */
fgDesiredVisibility DesiredVisibility;/* desired visibility (hidden, iconic, shown/normal) */
-
SFG_PlatformWindowState pWState; /* Window width/height (X11) or rectangle/style (Windows) from before a resize, and other stuff only needed on specific platforms */
- GLboolean Redisplay; /* Do we have to redisplay? */
-
-
long JoystickPollRate; /* The joystick polling rate */
fg_time_t JoystickLastPoll; /* When the last poll happened */
* window.
* DN: Hmm.. the above sounds like a concern only in single buffered mode...
*/
- glutPostRedisplay( );
+ window->State.WorkMask |= GLUT_DISPLAY_WORK;
if( window->IsMenu )
fgSetWindow( saved_window );
}
fgEnumWindows( fghcbProcessWork, &enumerator );
}
-
-static void fghcbDisplayWindow( SFG_Window *window,
- SFG_Enumerator *enumerator )
-{
- if( window->State.Redisplay &&
- window->State.Visible )
- {
- window->State.Redisplay = GL_FALSE;
- fghRedrawWindow ( window );
- }
-
- fgEnumSubWindows( window, fghcbDisplayWindow, enumerator );
-}
-
-/*
- * Make all windows perform a display call
- */
-static void fghDisplayAll( void )
-{
- SFG_Enumerator enumerator;
-
- enumerator.found = GL_FALSE;
- enumerator.data = NULL;
-
- fgEnumWindows( fghcbDisplayWindow, &enumerator );
-}
-
/*
* Window enumerator callback to check for the joystick polling code
*/
/*
- * Indicates whether a redisplay is pending for ANY window.
+ * Indicates whether work is pending for ANY window.
*
* The current mechanism is to walk all of the windows and ask if
- * a redisplay is pending. We have a short-circuit early
- * return if we find any.
+ * work is pending. We have a short-circuit early return if we find any.
*/
-static void fghHavePendingRedisplaysCallback( SFG_Window* w, SFG_Enumerator* e)
+static void fghHavePendingWorkCallback( SFG_Window* w, SFG_Enumerator* e)
{
- if( w->State.Redisplay && w->State.Visible )
+ if( w->State.WorkMask )
{
e->found = GL_TRUE;
e->data = w;
return;
}
- fgEnumSubWindows( w, fghHavePendingRedisplaysCallback, e );
+ fgEnumSubWindows( w, fghHavePendingWorkCallback, e );
}
-static int fghHavePendingRedisplays (void)
+static int fghHavePendingWork (void)
{
SFG_Enumerator enumerator;
enumerator.found = GL_FALSE;
enumerator.data = NULL;
- fgEnumWindows( fghHavePendingRedisplaysCallback, &enumerator );
+ fgEnumWindows( fghHavePendingWorkCallback, &enumerator );
return !!enumerator.data;
}
{
fg_time_t msec;
- if( fghHavePendingRedisplays( ) )
+ if( fghHavePendingWork( ) )
return;
msec = fghNextTimer( );
if (fgState.NumActiveJoysticks>0) /* If zero, don't poll joysticks */
fghCheckJoystickPolls( );
- /* Perform work on the window (position, reshape, etc) */
+ /* Perform work on the window (position, reshape, display, etc) */
fghProcessWork( );
- /* Display */
- fghDisplayAll( );
-
fgCloseWindows( );
}
if( menuEntry != menu->ActiveEntry )
{
- menu->Window->State.Redisplay = GL_TRUE;
+ menu->Window->State.WorkMask |= GLUT_DISPLAY_WORK;
if( menu->ActiveEntry )
menu->ActiveEntry->IsActive = GL_FALSE;
}
( !menu->ActiveEntry->SubMenu ||
!menu->ActiveEntry->SubMenu->IsActive ) )
{
- menu->Window->State.Redisplay = GL_TRUE;
+ menu->Window->State.WorkMask |= GLUT_DISPLAY_WORK;
menu->ActiveEntry->IsActive = GL_FALSE;
menu->ActiveEntry = NULL;
}
fgStructure.CurrentWindow->State.WorkMask |= GLUT_VISIBILITY_WORK;
fgStructure.CurrentWindow->State.DesiredVisibility = DesireNormalState;
- fgStructure.CurrentWindow->State.Redisplay = GL_TRUE;
+ fgStructure.CurrentWindow->State.WorkMask |= GLUT_DISPLAY_WORK;
}
/*
fgStructure.CurrentWindow->State.WorkMask |= GLUT_VISIBILITY_WORK;
fgStructure.CurrentWindow->State.DesiredVisibility = DesireHiddenState;
- fgStructure.CurrentWindow->State.Redisplay = GL_FALSE;
+ fgStructure.CurrentWindow->State.WorkMask &= ~GLUT_DISPLAY_WORK;
}
/*
fgStructure.CurrentWindow->State.WorkMask |= GLUT_VISIBILITY_WORK;
fgStructure.CurrentWindow->State.DesiredVisibility = DesireIconicState;
- fgStructure.CurrentWindow->State.Redisplay = GL_FALSE;
+ fgStructure.CurrentWindow->State.WorkMask &= ~GLUT_DISPLAY_WORK;
}
/*
* force redisplay so display keeps running during dragging.
* Screen still wont update when not moving the cursor though...
*/
- /* PRECT prect = (PRECT) lParam; */
RECT rect;
- /* printf("WM_SIZING: nc-area: %i,%i\n",prect->right-prect->left,prect->bottom-prect->top); */
+ /* PRECT prect = (PRECT) lParam;
+ printf("WM_SIZING: nc-area: %i,%i\n",prect->right-prect->left,prect->bottom-prect->top); */
/* Get client area, the rect in lParam is including non-client area. */
fghGetClientArea(&rect,window,FALSE);
if (wParam)
{
fghPlatformOnWindowStatusNotify(window, GL_TRUE, GL_FALSE);
- window->State.Redisplay = GL_TRUE;
+ window->State.WorkMask |= GLUT_DISPLAY_WORK;
}
else
{
fghPlatformOnWindowStatusNotify(window, GL_FALSE, GL_FALSE);
- window->State.Redisplay = GL_FALSE;
+ window->State.WorkMask &= ~GLUT_DISPLAY_WORK;
}
break;
BeginPaint( hWnd, &ps );
EndPaint( hWnd, &ps );
- window->State.Redisplay = GL_TRUE;
+ window->State.WorkMask |= GLUT_DISPLAY_WORK;
}
lRet = 0; /* As per docs, should return 0 */
}
#if !defined(_WIN32_WCE)
case WM_SYNCPAINT: /* 0x0088 */
/* Another window has moved, need to update this one */
- window->State.Redisplay = GL_TRUE;
+ window->State.WorkMask |= GLUT_DISPLAY_WORK;
lRet = DefWindowProc( hWnd, uMsg, wParam, lParam );
/* Help screen says this message must be passed to "DefWindowProc" */
break;
/* Now clear it so that any callback generated by the actions below can set work again */
window->State.WorkMask = 0;
+ if (workMask&~GLUT_DISPLAY_WORK) /* Display work is the common case, skip all the below at once */
+ {
/* This is before the first display callback: call a few callbacks to inform user of window size, position, etc
* we know this is before the first display callback of a window as for all windows GLUT_INIT_WORK is set when
* they are opened, and work is done before displaying in the mainloop.
ShowWindow( win->Window.Handle, cmdShow );
}
+ }
+
+ if (workMask & GLUT_DISPLAY_WORK)
+ {
+ if( window->State.Visible )
+ fghRedrawWindow ( window );
+
+ /* Strip out display work that might have ended up on work list now as some of the above genereates callbacks */
+ window->State.WorkMask &= ~GLUT_DISPLAY_WORK;
+ }
}
\ No newline at end of file
if( event.xexpose.count == 0 )
{
GETWINDOW( xexpose );
- window->State.Redisplay = GL_TRUE;
+ window->State.WorkMask |= GLUT_DISPLAY_WORK;
}
break;
/* Now clear it so that any callback generated by the actions below can set work again */
window->State.WorkMask = 0;
+ if (workMask&~GLUT_DISPLAY_WORK) /* Display work is the common case, skip all the below at once */
+ {
/* This is before the first display callback: call a few callbacks to inform user of window size, position, etc
* we know this is before the first display callback of a window as for all windows GLUT_INIT_WORK is set when
* they are opened, and work is done before displaying in the mainloop.
break;
}
}
+ }
+
+ if (workMask & GLUT_DISPLAY_WORK)
+ {
+ if( window->State.Visible )
+ fghRedrawWindow ( window );
+
+ /* Strip out display work that might have ended up on work list now as some of the above genereates callbacks */
+ window->State.WorkMask &= ~GLUT_DISPLAY_WORK;
+ }
}