X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=progs%2Fdemos%2FOne%2Fone.c;h=24ce7a7f5c57e15ee89ad255cfbb215a96df8c54;hb=85fe5ac7b6efe580eab22820aa740a4b2dcafb0c;hp=b5d9732213d9630da10d0d0a9785b6761a0f804e;hpb=84bbdfc8e7dfb2e220a4d155159be91e88ea9433;p=freeglut diff --git a/progs/demos/One/one.c b/progs/demos/One/one.c index b5d9732..24ce7a7 100644 --- a/progs/demos/One/one.c +++ b/progs/demos/One/one.c @@ -12,10 +12,6 @@ * Creation date: czw gru 2 11:58:41 CET 1999 */ -#ifdef HAVE_CONFIG_H -#include -#endif - #include #include @@ -23,7 +19,7 @@ int g_LeaveGameMode = 0; int g_InGameMode = 0; -int g_mainwin, g_sw1, g_sw2, g_gamemodewin; +int g_mainwin1, g_mainwin2, g_sw1, g_sw2, g_gamemodewin; /* * Call this function to have some text drawn at given coordinates @@ -99,9 +95,9 @@ void SampleDisplay( void ) int win = glutGetWindow(); if (g_InGameMode && win!=g_gamemodewin) - /* Dont draw other windows when in gamemode, those aren't visible - * anyway. Drawing them continuously anyway can cause flicker trouble - * on my machine. This only seems to occur when there are child windows + /* Don't draw other windows when in gamemode, those aren't visible + * anyway. Drawing them continuously nonetheless can cause flicker trouble + * on my machine. This only seems to occur only when there are child windows * among the non-visible windows */ return; @@ -113,16 +109,16 @@ void SampleDisplay( void ) */ glClearColor(0.7f,0.7f,0.7f,1); glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); - glutPostWindowRedisplay(g_mainwin); + glutPostWindowRedisplay(g_mainwin2); } else if (win==g_sw2) { /* - * Clear the screen - */ + * Clear the screen + */ glClearColor(0.3f,0.3f,0.3f,1); glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); - glutPostWindowRedisplay(g_mainwin); + glutPostWindowRedisplay(g_mainwin2); } else { @@ -184,9 +180,14 @@ void SampleIdle( void ) if( g_LeaveGameMode == 1 ) { /* One could do all this just as well in SampleGameModeKeyboard... */ + printf("leaving gamemode...\n"); glutLeaveGameMode( ); g_LeaveGameMode = 0; g_InGameMode = 0; + glutPostWindowRedisplay(g_mainwin1); + glutPostWindowRedisplay(g_mainwin2); + glutPostWindowRedisplay(g_sw1); + glutPostWindowRedisplay(g_sw2); } } @@ -277,13 +278,18 @@ void SampleSpecial( int nSpecial, int nMouseX, int nMouseY ) */ void SampleMenu( int menuID ) { - /* - * Just print something funny - */ printf( "SampleMenu() callback executed, menuID is %i\n", menuID ); } /* + * A sample menu status callback + */ +void SampleMenuStatus( int status, int x, int y ) +{ + printf ( "SampleMenu() callback executed, MenuStatus is %i at (%i,%i)\n", status, x, y ); +} + +/* * The sample's entry point */ int main( int argc, char** argv ) @@ -297,6 +303,8 @@ int main( int argc, char** argv ) glutInit( &argc, argv ); glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE,GLUT_ACTION_GLUTMAINLOOP_RETURNS); + glutMenuStatusFunc( SampleMenuStatus ); + glutIdleFunc( SampleIdle ); subMenuA = glutCreateMenu( SampleMenu ); glutAddMenuEntry( "Sub menu A1 (01)", 1 ); @@ -318,27 +326,26 @@ int main( int argc, char** argv ) glutAddSubMenu( "Enter sub menu A", subMenuA ); glutAddSubMenu( "Enter sub menu B", subMenuB ); - glutCreateWindow( "Hello world!" ); + g_mainwin1 = glutCreateWindow( "Hello world!" ); glutDisplayFunc( SampleDisplay ); glutReshapeFunc( SampleReshape ); glutKeyboardFunc( SampleKeyboard ); glutSpecialFunc( SampleSpecial ); - glutIdleFunc( SampleIdle ); glutEntryFunc( SampleEntry ); glutAttachMenu( GLUT_LEFT_BUTTON ); glutInitWindowPosition( 200, 200 ); - g_mainwin = glutCreateWindow( "I am not Jan B." ); + g_mainwin2 = glutCreateWindow( "I am not Jan B." ); glutDisplayFunc( SampleDisplay ); glutReshapeFunc( SampleReshape ); glutKeyboardFunc( SampleKeyboard ); glutSpecialFunc( SampleSpecial ); - glutIdleFunc( SampleIdle ); + glutEntryFunc( SampleEntry ); glutAttachMenu( GLUT_LEFT_BUTTON ); glutSetMenu(subMenuA); glutAttachMenu( GLUT_RIGHT_BUTTON ); - g_sw1=glutCreateSubWindow(g_mainwin,200,0,100,100); + g_sw1=glutCreateSubWindow(g_mainwin2,200,0,100,100); glutDisplayFunc( SampleDisplay ); glutSetMenu(subMenuB); glutAttachMenu( GLUT_LEFT_BUTTON ); @@ -366,7 +373,7 @@ int main( int argc, char** argv ) glutDisplayFunc( SampleDisplay ); glutReshapeFunc( SampleReshape ); glutKeyboardFunc( SampleGameModeKeyboard ); - glutIdleFunc( SampleIdle ); + glutEntryFunc( SampleEntry ); glutSetMenu(menuID); glutAttachMenu( GLUT_LEFT_BUTTON ); @@ -376,6 +383,12 @@ int main( int argc, char** argv ) ); /* + * Describe pixel format + */ + printf("The current window has %i red bits, %i green bits, %i blue bits and %i alpha bits for a total buffer size of %i bits\n",glutGet(GLUT_WINDOW_RED_SIZE),glutGet(GLUT_WINDOW_GREEN_SIZE),glutGet(GLUT_WINDOW_BLUE_SIZE),glutGet(GLUT_WINDOW_ALPHA_SIZE),glutGet(GLUT_WINDOW_BUFFER_SIZE)); + printf("It furthermore has %i depth bits and %i stencil bits\n",glutGet(GLUT_WINDOW_DEPTH_SIZE),glutGet(GLUT_WINDOW_STENCIL_SIZE)); + + /* * Enter the main FreeGLUT processing loop */ glutMainLoop(); @@ -389,4 +402,4 @@ int main( int argc, char** argv ) return EXIT_SUCCESS; } -/*** END OF FILE ***/ \ No newline at end of file +/*** END OF FILE ***/