X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=progs%2Fdemos%2FOne%2Fone.c;h=93e51447030ea62fb548a26a69b3311154e11dd6;hb=0a2aab2b7a6b7551c718922876d89db1c23520e0;hp=696a6e0b89214b63ca360e437876c9980ce19496;hpb=606a38afdaac34405bd59668c34dc97d30657ae2;p=freeglut diff --git a/progs/demos/One/one.c b/progs/demos/One/one.c index 696a6e0..93e5144 100644 --- a/progs/demos/One/one.c +++ b/progs/demos/One/one.c @@ -1,7 +1,7 @@ /* * one.c * - * Hey! This was the original file where freeglut development started. Just + * Hey! This was the original file where freeglut development started. Just * note what I have written here at the time. And see the creation date :) * * : This is a wrapper. I still have to figure out @@ -31,21 +31,22 @@ void PrintText( int nX, int nY, char* pszText ) { int lines; char *p; - + /* * Prepare the OpenGL state */ - glDisable( GL_DEPTH_TEST ); + glDisable( GL_LIGHTING ); + glDisable( GL_DEPTH_TEST ); glMatrixMode( GL_PROJECTION ); glPushMatrix(); glLoadIdentity(); - + /* * Have an orthogonal projection matrix set */ glOrtho( 0, glutGet( GLUT_WINDOW_WIDTH ), - 0, glutGet( GLUT_WINDOW_HEIGHT ), - -1, +1 + 0, glutGet( GLUT_WINDOW_HEIGHT ), + -1, +1 ); /* @@ -54,39 +55,40 @@ void PrintText( int nX, int nY, char* pszText ) glMatrixMode( GL_MODELVIEW ); glPushMatrix(); glLoadIdentity(); - + /* - * Now the main text + * Now the main text */ - glColor3ub( 0, 0, 0 ); - glRasterPos2i( nX, nY ); + glColor3ub( 0, 0, 0 ); + glRasterPos2i( nX, nY ); for( p=pszText, lines=0; *p; p++ ) { - if( *p == '\n' ) - { - lines++; - glRasterPos2i( nX, nY-(lines*18) ); - } - - glutBitmapCharacter( GLUT_BITMAP_HELVETICA_18, *p ); + if( *p == '\n' ) + { + lines++; + glRasterPos2i( nX, nY-(lines*18) ); + } + + glutBitmapCharacter( GLUT_BITMAP_HELVETICA_18, *p ); } - + /* * Revert to the old matrix modes - */ + */ glMatrixMode( GL_PROJECTION ); glPopMatrix(); - + glMatrixMode( GL_MODELVIEW ); glPopMatrix(); - + /* * Restore the old OpenGL states */ glColor4f( 1.0f, 1.0f, 1.0f, 1.0f ); glEnable( GL_DEPTH_TEST ); -} + glEnable( GL_LIGHTING ); +} /* * This is the display routine for our sample FreeGLUT windows @@ -115,8 +117,8 @@ void SampleDisplay( void ) * And then drawn... */ glColor3f( 1, 1, 0 ); - //glutWireCube( 20.0 ); - glutWireTeapot( 20.0 ); + //glutWireCube( 20.0 ); + glutWireTeapot( 20.0 ); //glutWireSpher( 15.0, 15, 15 ); //glColor3f( 0, 1, 0 ); //glutWireCube( 30.0 ); @@ -125,20 +127,20 @@ void SampleDisplay( void ) /* * Don't forget about the model-view matrix */ - glPopMatrix(); + glPopMatrix( ); /* * Draw a silly text */ - if( g_InGameMode == 0 ) - PrintText( 20, 20, "Hello there cruel world!" ); + if( g_InGameMode == 0 ) + PrintText( 20, 20, "Hello there cruel world!" ); else - PrintText( 20, 20, "Press ESC to leave the game mode!" ); + PrintText( 20, 20, "Press ESC to leave the game mode!" ); /* * And swap this context's buffers */ - glutSwapBuffers(); + glutSwapBuffers( ); } /* @@ -150,11 +152,11 @@ void SampleIdle( void ) if( g_LeaveGameMode == 1 ) { - glutLeaveGameMode(); + glutLeaveGameMode( ); g_LeaveGameMode = 0; - g_InGameMode = 0; + g_InGameMode = 0; } -} +} /* * The reshape function @@ -181,7 +183,7 @@ void SampleReshape( int nWidth, int nHeight ) * Move back the camera a bit */ glMatrixMode( GL_MODELVIEW ); - glLoadIdentity(); + glLoadIdentity( ); glTranslatef( 0.0, 0.0, -40.0f ); /* @@ -209,7 +211,8 @@ void SampleReshape( int nWidth, int nHeight ) */ void SampleKeyboard( unsigned char cChar, int nMouseX, int nMouseY ) { - printf( "SampleKeyboard(): keypress '%c' at (%i,%i)\n", cChar, nMouseX, nMouseY ); + printf( "SampleKeyboard(): keypress '%c' at (%i,%i)\n", + cChar, nMouseX, nMouseY ); } /* @@ -218,7 +221,7 @@ void SampleKeyboard( unsigned char cChar, int nMouseX, int nMouseY ) void SampleGameModeKeyboard( unsigned char cChar, int nMouseX, int nMouseY ) { if( cChar == 27 ) - g_LeaveGameMode = 1; + g_LeaveGameMode = 1; } @@ -227,7 +230,8 @@ void SampleGameModeKeyboard( unsigned char cChar, int nMouseX, int nMouseY ) */ void SampleSpecial( int nSpecial, int nMouseX, int nMouseY ) { - printf( "SampleSpecial(): special keypress %i at (%i,%i)\n", nSpecial, nMouseX, nMouseY ); + printf( "SampleSpecial(): special keypress %i at (%i,%i)\n", + nSpecial, nMouseX, nMouseY ); } /* @@ -238,7 +242,7 @@ void SampleMenu( int menuID ) /* * Just print something funny */ - printf( "SampleMenu() callback executed, menuID is %i\n", menuID ); + printf( "SampleMenu() callback executed, menuID is %i\n", menuID ); } /* @@ -248,17 +252,17 @@ int main( int argc, char** argv ) { int menuID, subMenuA, subMenuB; - glutInit( &argc, argv ); - glutInitDisplayString( "stencil~2 rgb double depth>=16 samples" ); glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH ); glutInitWindowPosition( 100, 100 ); + glutInit( &argc, argv ); + subMenuA = glutCreateMenu( SampleMenu ); glutAddMenuEntry( "Sub menu A1 (01)", 1 ); glutAddMenuEntry( "Sub menu A2 (02)", 2 ); glutAddMenuEntry( "Sub menu A3 (03)", 3 ); - + subMenuB = glutCreateMenu( SampleMenu ); glutAddMenuEntry( "Sub menu B1 (04)", 4 ); glutAddMenuEntry( "Sub menu B2 (05)", 5 ); @@ -296,7 +300,7 @@ int main( int argc, char** argv ) glutGameModeString( "640x480:16@72" ); glutGameModeString( "1024x768" ); glutGameModeString( ":32@120" ); - glutGameModeString( "Toudi glupcze, Danwin bedzie moj!" ); + glutGameModeString( "Toudi glupcze, Danwin bedzie moj!" ); glutGameModeString( "640x480:16@72" ); glutEnterGameMode(); @@ -307,9 +311,9 @@ int main( int argc, char** argv ) glutAttachMenu( GLUT_LEFT_BUTTON ); printf( "current window is %ix%i+%i+%i", - glutGet( GLUT_WINDOW_X ), glutGet( GLUT_WINDOW_Y ), - glutGet( GLUT_WINDOW_WIDTH ), glutGet( GLUT_WINDOW_HEIGHT ) - ); + glutGet( GLUT_WINDOW_X ), glutGet( GLUT_WINDOW_Y ), + glutGet( GLUT_WINDOW_WIDTH ), glutGet( GLUT_WINDOW_HEIGHT ) + ); /* * Enter the main FreeGLUT processing loop @@ -321,7 +325,7 @@ int main( int argc, char** argv ) /* * This is never reached in FreeGLUT. Is that good? */ - return( EXIT_SUCCESS ); + return EXIT_SUCCESS; } /*** END OF FILE ***/