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:
parent
d2991524cb
commit
b3b678a2f7
@ -121,7 +121,6 @@ void FGAPIENTRY glut##a##Func( FGCB##b callback ) \
|
|||||||
#define IMPLEMENT_CALLBACK_FUNC(a) IMPLEMENT_CALLBACK_FUNC_2NAME(a,a)
|
#define IMPLEMENT_CALLBACK_FUNC(a) IMPLEMENT_CALLBACK_FUNC_2NAME(a,a)
|
||||||
|
|
||||||
/* Implement all these callback setter functions... */
|
/* Implement all these callback setter functions... */
|
||||||
IMPLEMENT_CALLBACK_FUNC(Reshape);
|
|
||||||
IMPLEMENT_CALLBACK_FUNC(Position);
|
IMPLEMENT_CALLBACK_FUNC(Position);
|
||||||
IMPLEMENT_CALLBACK_FUNC(Keyboard);
|
IMPLEMENT_CALLBACK_FUNC(Keyboard);
|
||||||
IMPLEMENT_CALLBACK_FUNC(KeyboardUp);
|
IMPLEMENT_CALLBACK_FUNC(KeyboardUp);
|
||||||
@ -163,6 +162,21 @@ void FGAPIENTRY glutDisplayFunc( FGCBDisplay callback )
|
|||||||
SET_CALLBACK( Display );
|
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.
|
* Sets the Visibility callback for the current window.
|
||||||
* NB: the Visibility func is deprecated in favor of the WindowStatus func,
|
* NB: the Visibility func is deprecated in favor of the WindowStatus func,
|
||||||
|
@ -74,13 +74,7 @@ static void fghReshapeWindow ( SFG_Window *window, int width, int height )
|
|||||||
|
|
||||||
fgPlatformReshapeWindow ( window, width, height );
|
fgPlatformReshapeWindow ( window, width, height );
|
||||||
|
|
||||||
if( FETCH_WCB( *window, Reshape ) )
|
|
||||||
INVOKE_WCB( *window, Reshape, ( width, height ) );
|
INVOKE_WCB( *window, Reshape, ( width, height ) );
|
||||||
else
|
|
||||||
{
|
|
||||||
fgSetWindow( window );
|
|
||||||
glViewport( 0, 0, width, height );
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Force a window redraw. In Windows at least this is only a partial
|
* Force a window redraw. In Windows at least this is only a partial
|
||||||
|
@ -49,6 +49,7 @@ SFG_Structure fgStructure = { { NULL, NULL }, /* The list of windows */
|
|||||||
/* -- PRIVATE FUNCTIONS ---------------------------------------------------- */
|
/* -- PRIVATE FUNCTIONS ---------------------------------------------------- */
|
||||||
|
|
||||||
extern void fgPlatformCreateWindow ( SFG_Window *window );
|
extern void fgPlatformCreateWindow ( SFG_Window *window );
|
||||||
|
extern void fghDefaultReshape(int width, int height);
|
||||||
|
|
||||||
static void fghClearCallBacks( SFG_Window *window )
|
static void fghClearCallBacks( SFG_Window *window )
|
||||||
{
|
{
|
||||||
@ -77,6 +78,7 @@ SFG_Window* fgCreateWindow( SFG_Window* parent, const char* title,
|
|||||||
fgPlatformCreateWindow ( window );
|
fgPlatformCreateWindow ( window );
|
||||||
|
|
||||||
fghClearCallBacks( window );
|
fghClearCallBacks( window );
|
||||||
|
SET_WCB( *window, Reshape, fghDefaultReshape);
|
||||||
|
|
||||||
/* Initialize the object properties */
|
/* Initialize the object properties */
|
||||||
window->ID = ++fgStructure.WindowID;
|
window->ID = ++fgStructure.WindowID;
|
||||||
|
@ -742,6 +742,7 @@ void fgPlatformOpenWindow( SFG_Window* window, const char* title,
|
|||||||
|
|
||||||
void fgPlatformDisplayWindow ( SFG_Window *window )
|
void fgPlatformDisplayWindow ( SFG_Window *window )
|
||||||
{
|
{
|
||||||
|
/* This immediately generates a WM_PAINT message upon which we call the display callbacks to redraw the window */
|
||||||
RedrawWindow(
|
RedrawWindow(
|
||||||
window->Window.Handle, NULL, NULL,
|
window->Window.Handle, NULL, NULL,
|
||||||
RDW_NOERASE | RDW_INTERNALPAINT | RDW_INVALIDATE | RDW_UPDATENOW
|
RDW_NOERASE | RDW_INTERNALPAINT | RDW_INVALIDATE | RDW_UPDATENOW
|
||||||
|
@ -662,13 +662,7 @@ void fgPlatformProcessSingleEvent ( void )
|
|||||||
|
|
||||||
window->State.pWState.OldWidth = width;
|
window->State.pWState.OldWidth = width;
|
||||||
window->State.pWState.OldHeight = height;
|
window->State.pWState.OldHeight = height;
|
||||||
if( FETCH_WCB( *window, Reshape ) )
|
|
||||||
INVOKE_WCB( *window, Reshape, ( width, height ) );
|
INVOKE_WCB( *window, Reshape, ( width, height ) );
|
||||||
else
|
|
||||||
{
|
|
||||||
fgSetWindow( window );
|
|
||||||
glViewport( 0, 0, width, height );
|
|
||||||
}
|
|
||||||
glutPostRedisplay( );
|
glutPostRedisplay( );
|
||||||
if( window->IsMenu )
|
if( window->IsMenu )
|
||||||
fgSetWindow( current_window );
|
fgSetWindow( current_window );
|
||||||
|
Reference in New Issue
Block a user