added a child window to one demo, added different menus attached to
different mouse buttons, for testing Also added missing post redisplay to keep animation going git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@1355 7f0cb862-5218-0410-a997-914c9d46530a
This commit is contained in:
parent
233d93d550
commit
4a14f60a4e
@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
int g_LeaveGameMode = 0;
|
int g_LeaveGameMode = 0;
|
||||||
int g_InGameMode = 0;
|
int g_InGameMode = 0;
|
||||||
|
int g_mainwin, g_sw1;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Call this function to have some text drawn at given coordinates
|
* Call this function to have some text drawn at given coordinates
|
||||||
@ -97,50 +98,65 @@ static float g_fTime = 0.0f;
|
|||||||
|
|
||||||
void SampleDisplay( void )
|
void SampleDisplay( void )
|
||||||
{
|
{
|
||||||
/*
|
int win = glutGetWindow();
|
||||||
* Clear the screen
|
|
||||||
*/
|
|
||||||
glClearColor( 0, 0.5, 1, 1 );
|
|
||||||
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
|
|
||||||
|
|
||||||
/*
|
if (win==g_sw1)
|
||||||
* Have the cube rotated
|
{
|
||||||
*/
|
/*
|
||||||
glMatrixMode( GL_MODELVIEW );
|
* Clear the screen
|
||||||
glPushMatrix();
|
*/
|
||||||
|
glClearColor(0.7f,0.7f,0.7f,1);
|
||||||
glRotatef( g_fTime, 0, 0, 1 );
|
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
|
||||||
glRotatef( g_fTime, 0, 1, 0 );
|
glutPostWindowRedisplay(g_mainwin);
|
||||||
glRotatef( g_fTime, 1, 0, 0 );
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* And then drawn...
|
|
||||||
*/
|
|
||||||
glColor3f( 1, 1, 0 );
|
|
||||||
/* glutWireCube( 20.0 ); */
|
|
||||||
glutWireTeapot( 20.0 );
|
|
||||||
/* glutWireSpher( 15.0, 15, 15 ); */
|
|
||||||
/* glColor3f( 0, 1, 0 ); */
|
|
||||||
/* glutWireCube( 30.0 ); */
|
|
||||||
/* glutSolidCone( 10, 20, 10, 2 ); */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Don't forget about the model-view matrix
|
|
||||||
*/
|
|
||||||
glPopMatrix( );
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Draw a silly text
|
|
||||||
*/
|
|
||||||
if( g_InGameMode == 0 )
|
|
||||||
PrintText( 20, 20, "Hello there cruel world!" );
|
|
||||||
else
|
else
|
||||||
PrintText( 20, 20, "Press ESC to leave the game mode!" );
|
{
|
||||||
|
/*
|
||||||
|
* Clear the screen
|
||||||
|
*/
|
||||||
|
glClearColor( 0, 0.5, 1, 1 );
|
||||||
|
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Have the cube rotated
|
||||||
|
*/
|
||||||
|
glMatrixMode( GL_MODELVIEW );
|
||||||
|
glPushMatrix();
|
||||||
|
|
||||||
|
glRotatef( g_fTime, 0, 0, 1 );
|
||||||
|
glRotatef( g_fTime, 0, 1, 0 );
|
||||||
|
glRotatef( g_fTime, 1, 0, 0 );
|
||||||
|
|
||||||
|
/*
|
||||||
|
* And then drawn...
|
||||||
|
*/
|
||||||
|
glColor3f( 1, 1, 0 );
|
||||||
|
/* glutWireCube( 20.0 ); */
|
||||||
|
glutWireTeapot( 20.0 );
|
||||||
|
/* glutWireSpher( 15.0, 15, 15 ); */
|
||||||
|
/* glColor3f( 0, 1, 0 ); */
|
||||||
|
/* glutWireCube( 30.0 ); */
|
||||||
|
/* glutSolidCone( 10, 20, 10, 2 ); */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Don't forget about the model-view matrix
|
||||||
|
*/
|
||||||
|
glPopMatrix( );
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Draw a silly text
|
||||||
|
*/
|
||||||
|
if( g_InGameMode == 0 )
|
||||||
|
PrintText( 20, 20, "Hello there cruel world!" );
|
||||||
|
else
|
||||||
|
PrintText( 20, 20, "Press ESC to leave the game mode!" );
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* And swap this context's buffers
|
* And swap this context's buffers
|
||||||
*/
|
*/
|
||||||
glutSwapBuffers( );
|
glutSwapBuffers( );
|
||||||
|
glutPostWindowRedisplay(win);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -289,7 +305,7 @@ int main( int argc, char** argv )
|
|||||||
glutAttachMenu( GLUT_LEFT_BUTTON );
|
glutAttachMenu( GLUT_LEFT_BUTTON );
|
||||||
|
|
||||||
glutInitWindowPosition( 200, 200 );
|
glutInitWindowPosition( 200, 200 );
|
||||||
glutCreateWindow( "I am not Jan B." );
|
g_mainwin = glutCreateWindow( "I am not Jan B." );
|
||||||
glutDisplayFunc( SampleDisplay );
|
glutDisplayFunc( SampleDisplay );
|
||||||
glutReshapeFunc( SampleReshape );
|
glutReshapeFunc( SampleReshape );
|
||||||
glutKeyboardFunc( SampleKeyboard );
|
glutKeyboardFunc( SampleKeyboard );
|
||||||
@ -299,6 +315,11 @@ int main( int argc, char** argv )
|
|||||||
glutSetMenu(subMenuA);
|
glutSetMenu(subMenuA);
|
||||||
glutAttachMenu( GLUT_RIGHT_BUTTON);
|
glutAttachMenu( GLUT_RIGHT_BUTTON);
|
||||||
|
|
||||||
|
g_sw1=glutCreateSubWindow(g_mainwin,200,0,100,100);
|
||||||
|
glutDisplayFunc( SampleDisplay );
|
||||||
|
glutSetMenu(subMenuB);
|
||||||
|
glutAttachMenu( GLUT_LEFT_BUTTON);
|
||||||
|
|
||||||
printf( "Testing game mode string parsing, don't panic!\n" );
|
printf( "Testing game mode string parsing, don't panic!\n" );
|
||||||
glutGameModeString( "320x240:32@100" );
|
glutGameModeString( "320x240:32@100" );
|
||||||
glutGameModeString( "640x480:16@72" );
|
glutGameModeString( "640x480:16@72" );
|
||||||
|
Reference in New Issue
Block a user