Esempio n. 1
0
Str getMillisecsDiff(double originalTime)
{
    char buf[20];
    // getMillisecs() is in platform.cpp
    sprintf(buf, "%.3f", getMillisecs() - originalTime);
    return Str(buf);
}
Esempio n. 2
0
void onTimer(int lastMillisecs)
{
	int currentMillisecs = getMillisecs();
	int deltaMullisecs = currentMillisecs - lastMillisecs;
	float seconds = deltaMullisecs / 1000.0;

	square.angle += square.rotationSpeedPerSeconds * seconds;

	glutTimerFunc(getFpsMilisecs(), onTimer, currentMillisecs);	// set animation callback to execute at fps rate
	glutPostRedisplay();
}
Esempio n. 3
0
eFlag Tree::parse(Sit S, DataLine *d)
{
    Log1(S, L1_PARSING, getURI());
    double time_was = getMillisecs();
    TreeConstructer tc(S);
    eFlag retval = tc.parseDataLineUsingExpat(S, this, d);
    if (!retval)
    {
        Log1(S, L1_PARSE_DONE, getMillisecsDiff(time_was));
    }
    return retval;
}
Esempio n. 4
0
/*  
    Declare initial window size, position, and display mode (single buffer and RGBA). 
    Open window with “Hello GLUT“ in its title bar. 
    Call initialization routines. 
    Register callback function to display graphics. 
    Enter main loop and process events. 
*/
int main(int argc, char** argv)
{
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
    glutInitWindowSize(250, 250);
    glutInitWindowPosition(400, 100);
    glutCreateWindow("OpenGL Square");

    init();							// initialize application (openGL)
    glutDisplayFunc(onDisplay);		// set display callback function
	glutSpecialFunc(onSpecialKey);	// set key up callback function (for special keys LEFT, ...)
	glutKeyboardFunc(onKeyboardKey);
	
	glutTimerFunc(getFpsMilisecs(), onTimer, getMillisecs());	// set animation callback to execute at fps rate

	// HELP (minimalist)
	printf("================================================================\n");
	printf("HELP\n");
	printf("----------------------------------------------------------------\n");
	printf("  Q: increase frame-rate\n");
	printf("  A: decrease frame-rate\n");
	printf("\n");
	printf("  W: increase rotation speed\n");
	printf("  S: decrease rotation speed\n");
	printf("\n");
	printf("  LEFT:  move square position to the left\n");
	printf("  RIGHT: move square position to the right\n");
	printf("  UP:    move square position to the up\n");
	printf("  DOWN:  move square position to the down\n");
	printf("================================================================\n");


	glutMainLoop();					// application loop

	return 0;
}