How to display Timer in OpenGL Projects

Rajeev
This tutorial will demonstrate how to have timer in the project of computer graphics using OpenGL. Follow the simple steps and get you timer in the projects. To have timer in the program, OpenGL had provide a library function. This library function is " glutTimerFunc " which need to be called to have the timer displayed. So to have this function work we will define and declare a function called myTimer, whose code is like- void myTimer(int value) { if(j==0) { g_counter = value + 1; } else if(j==1) { g_counter = value + 0; } else { g_counter = 0; } glutPostRedisplay(); glutTimerFunc(GAP, myTimer, g_counter); } You must have g_counter variable declared before you define this function like this. The g_counter, must be declared as a static variable. So you use it like  static int g_counter = 0; where it has been initialized to 0 at first to start from 0, if you wish you can set the other time. Also have another variable J, this too must be static go as  static int j=0; also initialized to 0. The…

2 comments

  1. shalini
    please send the code for this
  2. Rajeev Kumar Singh
    you posted 10 comment by asking the project code but all post have the download link can't u get it from there?