Advertisement Jump to content


This topic is now archived and is closed to further replies.


show something on screen after certain time has elapsed

This topic is 6181 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I am trying to render a shape after some time has elapsed. Instead of using a timer i am trying to use a simple counter. This is the code i have so far
static int counter = 0;
GLfloat tri_x, tri_y, tri_z;


glColor3f(1.0f, 1.0f, 1.0f);
for(int i = 0; i <= 1024; i++)
	glVertex3f(stars1[i].x, stars1[i].y, stars1[i].z);

glColor3f(1.0f, 1.0f, 1.0f);
for(i = 0; i <= 1024; i++) {
	glVertex3f(stars2[i].x, stars2[i].y, stars2[i].z);

if(counter == 10) {
	glColor3f(1.0f, 0.3f, 0.2f);		
	for(i = 0; i <= 2.0f * 3.14 * 3; i++) {
		tri_x = 2.0f * cos(i) * 3;
		tri_y = 2.0f * sin(i) * 3;
		tri_z = -1000.0f;
		glVertex3f(tri_x, tri_y, tri_z);



if(counter >= 10)
    counter = 10;


Now the code in if never gets executed. I think I am going wrong somewhere but what am I doing wrong ? I am doing it the same way as the following is done. Without the if however it does draw to screen.
glRotatef(angle, 1.0, 0.0, 0.0); 
if(angle >= 360.0f) 
      angle = 0.0; 

Hope someone can help. Thank you.

Share this post

Link to post
Share on other sites
You clamp the counter to 10, then increment, for an eventual count of 11.

You should increment, then clamp.

And/or change your display query from (==10) to (>=10).

Or chuck the whole idea and do it right, track the real time.

I use glut, so a simple:

int millisecTime=glutGet(GLUT_ELAPSED_TIME);

zin - 3d graphics & more or less

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!