X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=progs%2Fdemos%2FOne%2Fone.c;h=cf2cb1483fd017e9c7aea5e4e7e80fcebde16ab2;hb=d9b0989056a1c2267b68f01317d4641c70e48719;hp=1b35f43b73c2e3cb525837d960490c4d34da8810;hpb=ae105c8b50dd565e9222125434f7706f0429cca9;p=freeglut diff --git a/progs/demos/One/one.c b/progs/demos/One/one.c index 1b35f43..cf2cb14 100644 --- a/progs/demos/One/one.c +++ b/progs/demos/One/one.c @@ -23,6 +23,7 @@ int g_LeaveGameMode = 0; int g_InGameMode = 0; +int g_mainwin, g_sw1, g_sw2; /* * Call this function to have some text drawn at given coordinates @@ -97,50 +98,74 @@ static float g_fTime = 0.0f; void SampleDisplay( void ) { - /* - * 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 ); + int win = glutGetWindow(); - /* - * 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!" ); + if (win==g_sw1) + { + /* + * Clear the screen + */ + glClearColor(0.7f,0.7f,0.7f,1); + glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); + glutPostWindowRedisplay(g_mainwin); + } + else if (win==g_sw2) + { + /* + * Clear the screen + */ + glClearColor(0.3f,0.3f,0.3f,1); + glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); + glutPostWindowRedisplay(g_mainwin); + } 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 */ glutSwapBuffers( ); + glutPostWindowRedisplay(win); } /* @@ -158,6 +183,12 @@ void SampleIdle( void ) } } +void SampleEntry(int state) +{ + int window = glutGetWindow () ; + printf ( "Window %d Entry Callback: %d\n", window, state ) ; +} + /* * The reshape function */ @@ -286,16 +317,29 @@ int main( int argc, char** argv ) glutKeyboardFunc( SampleKeyboard ); glutSpecialFunc( SampleSpecial ); glutIdleFunc( SampleIdle ); + glutEntryFunc( SampleEntry ); glutAttachMenu( GLUT_LEFT_BUTTON ); glutInitWindowPosition( 200, 200 ); - glutCreateWindow( "I am not Jan B." ); + g_mainwin = glutCreateWindow( "I am not Jan B." ); glutDisplayFunc( SampleDisplay ); glutReshapeFunc( SampleReshape ); glutKeyboardFunc( SampleKeyboard ); glutSpecialFunc( SampleSpecial ); glutIdleFunc( SampleIdle ); glutAttachMenu( GLUT_LEFT_BUTTON ); + glutSetMenu(subMenuA); + glutAttachMenu( GLUT_RIGHT_BUTTON ); + + g_sw1=glutCreateSubWindow(g_mainwin,200,0,100,100); + glutDisplayFunc( SampleDisplay ); + glutSetMenu(subMenuB); + glutAttachMenu( GLUT_LEFT_BUTTON); + + g_sw2=glutCreateSubWindow(g_sw1,50,0,50,50); + glutDisplayFunc( SampleDisplay ); + glutSetMenu(menuID); + glutAttachMenu( GLUT_RIGHT_BUTTON ); printf( "Testing game mode string parsing, don't panic!\n" ); glutGameModeString( "320x240:32@100" ); @@ -316,7 +360,6 @@ int main( int argc, char** argv ) glutReshapeFunc( SampleReshape ); glutKeyboardFunc( SampleGameModeKeyboard ); glutIdleFunc( SampleIdle ); - glutAttachMenu( GLUT_LEFT_BUTTON ); printf( "current window is %ix%i at (%i,%i)\n", glutGet( GLUT_WINDOW_WIDTH ), glutGet( GLUT_WINDOW_HEIGHT ),