#define IMPLEMENT_CALLBACK_FUNC(a) IMPLEMENT_CALLBACK_FUNC_2NAME(a,a)
/* Implement all these callback setter functions... */
-IMPLEMENT_CALLBACK_FUNC(Reshape);
IMPLEMENT_CALLBACK_FUNC(Position);
IMPLEMENT_CALLBACK_FUNC(Keyboard);
IMPLEMENT_CALLBACK_FUNC(KeyboardUp);
SET_CALLBACK( Display );
}
+void fghDefaultReshape(int width, int height)
+{
+ glViewport( 0, 0, width, height );
+}
+
+void FGAPIENTRY glutReshapeFunc( FGCBReshape callback )
+{
+ FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutReshapeFunc" );
+
+ if( !callback )
+ callback = fghDefaultReshape;
+
+ SET_CALLBACK( Reshape );
+}
+
/*
* Sets the Visibility callback for the current window.
* NB: the Visibility func is deprecated in favor of the WindowStatus func,
fgPlatformReshapeWindow ( window, width, height );
- if( FETCH_WCB( *window, Reshape ) )
- INVOKE_WCB( *window, Reshape, ( width, height ) );
- else
- {
- fgSetWindow( window );
- glViewport( 0, 0, width, height );
- }
+ INVOKE_WCB( *window, Reshape, ( width, height ) );
/*
* Force a window redraw. In Windows at least this is only a partial
/* -- PRIVATE FUNCTIONS ---------------------------------------------------- */
extern void fgPlatformCreateWindow ( SFG_Window *window );
+extern void fghDefaultReshape(int width, int height);
static void fghClearCallBacks( SFG_Window *window )
{
fgPlatformCreateWindow ( window );
fghClearCallBacks( window );
+ SET_WCB( *window, Reshape, fghDefaultReshape);
/* Initialize the object properties */
window->ID = ++fgStructure.WindowID;
window->State.Cursor = GLUT_CURSOR_INHERIT;
/* Mark window as menu if a menu is to be created */
- window->IsMenu = isMenu;
+ window->IsMenu = isMenu;
/*
* Open the window now. The fgOpenWindow() function is system
void fgPlatformDisplayWindow ( SFG_Window *window )
{
+ /* This immediately generates a WM_PAINT message upon which we call the display callbacks to redraw the window */
RedrawWindow(
window->Window.Handle, NULL, NULL,
RDW_NOERASE | RDW_INTERNALPAINT | RDW_INVALIDATE | RDW_UPDATENOW
window->State.pWState.OldWidth = width;
window->State.pWState.OldHeight = height;
- if( FETCH_WCB( *window, Reshape ) )
- INVOKE_WCB( *window, Reshape, ( width, height ) );
- else
- {
- fgSetWindow( window );
- glViewport( 0, 0, width, height );
- }
+ INVOKE_WCB( *window, Reshape, ( width, height ) );
glutPostRedisplay( );
if( window->IsMenu )
fgSetWindow( current_window );