Пример #1
0
int main( int argc, char *argv[] )
{
    int pargc = argc;

    /* Initialize the random number generator */
    srand(( int )time( NULL ) );

    /* Set up the OpenGL parameters */
    glEnable( GL_DEPTH_TEST );
    glClearColor( 0.0, 0.0, 0.0, 0.0 );
    glClearDepth( 1.0 );

    /* Initialize GLUT */
    glutInitWindowSize( 600, 600 );
    glutInit( &pargc, argv );
    glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH );

    /* Create the window */
    glutCreateWindow( "Lorenz Attractor" );
    glutKeyboardFunc( key_cb );
    glutMouseFunc( mouse_cb );
    glutSpecialFunc( special_cb );
    glutDisplayFunc( display_cb );
    glutReshapeFunc( reshape_cb );
    glutTimerFunc( 30, timer_cb, 0 );

    /*
     *  Initialize the attractor:
     *  The easiest way is to call the keyboard callback with an
     *  argument of 'r' for Reset.
     */
    key_cb( 'r', 0, 0 );

    /* Enter the GLUT main loop */
    glutMainLoop( );

#ifdef MSC_VER
    _CrtDumpMemoryLeaks( );  /* DUMP MEMORY LEAK INFORMATION */
#endif

    return EXIT_SUCCESS;
}
Пример #2
0
int main(int argc, char **argv)
{
	struct game_state *gs = init_window(125000);
	SDL_Event ev;
	int mods;
	
	draw_cb(gs);
	while (1) {
		SDL_RenderPresent(gs->surface);
		SDL_WaitEvent(&ev);

		switch (ev.type) {
		case SDL_QUIT:
			end_cb(gs);
			break;
		case SDL_KEYDOWN:
			mods = SDL_GetModState();
			key_cb(ev.key.keysym.sym, mods & KMOD_SHIFT, gs);
			break;
		}
	}

	return 0;
}