now have a default reshape callback function that is used if the user didn't set any, instead of having what to do spread out over the code

git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@1557 7f0cb862-5218-0410-a997-914c9d46530a
This commit is contained in:
dcnieho 2013-03-06 09:17:13 +00:00
parent d2991524cb
commit b3b678a2f7
5 changed files with 21 additions and 16 deletions

View File

@ -121,7 +121,6 @@ void FGAPIENTRY glut##a##Func( FGCB##b callback ) \
#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);
@ -163,6 +162,21 @@ void FGAPIENTRY glutDisplayFunc( FGCBDisplay callback )
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,

View File

@ -74,13 +74,7 @@ static void fghReshapeWindow ( SFG_Window *window, int width, int height )
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

View File

@ -49,6 +49,7 @@ SFG_Structure fgStructure = { { NULL, NULL }, /* The list of windows */
/* -- PRIVATE FUNCTIONS ---------------------------------------------------- */
extern void fgPlatformCreateWindow ( SFG_Window *window );
extern void fghDefaultReshape(int width, int height);
static void fghClearCallBacks( SFG_Window *window )
{
@ -77,6 +78,7 @@ SFG_Window* fgCreateWindow( SFG_Window* parent, const char* title,
fgPlatformCreateWindow ( window );
fghClearCallBacks( window );
SET_WCB( *window, Reshape, fghDefaultReshape);
/* Initialize the object properties */
window->ID = ++fgStructure.WindowID;
@ -94,7 +96,7 @@ SFG_Window* fgCreateWindow( SFG_Window* parent, const char* title,
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

View File

@ -742,6 +742,7 @@ void fgPlatformOpenWindow( SFG_Window* window, const char* title,
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

View File

@ -662,13 +662,7 @@ void fgPlatformProcessSingleEvent ( void )
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 );