Advertisement

Problems with timing in openGL

Started by December 22, 2001 08:00 AM
4 comments, last by ironhell3 23 years, 2 months ago
Hello, i am a beginner openGL programmer, and i have the following problem: I want to draw a triangle in the screen, keep it there for 5 seconds, make it dissapear and then draw another polygon.I use the following code: glTranslatef(-2.5f,-4.0f,-18.0f); static int scene=0; static DWORD change=GetTickCount()+5000; if (change < GetTickCount()) { change+=5000; scene++; } switch(scene) { case 0:{glRotatef(rquad,0.0f,0.2f,0.0f);} case 1:{text2();glRotatef(rquad,0.0f,0.4f,0.0f);} case 2:{text1();glRotatef(rquad,0.0f,0.6f,0.0f);} } the problem is that text1() appears in screen, but after 5 seconds text2() also appears,whithout text1() been cleared. How can i make first clear text1() and then draw text2() ???
You''re missing some breaks:


switch(scene)
{
case 0:{glRotatef(rquad,0.0f,0.2f,0.0f);}break;

case 1:{text2();glRotatef(rquad,0.0f,0.4f,0.0f);}break;

case 2:{text1();glRotatef(rquad,0.0f,0.6f,0.0f);}break;
}


baumep
baumep
Advertisement
thanks, this really works...But what if we want to keep the last command in case for ever? this is because EVERY thing will stay in the screen for 5 seconds.How can we say to stop this sequence and keep the last polygon drawn for ever?Maybe with another break?
Nope u should use a default: . Instead of doing another "case #": blabal, do "default: show_scene_forever;break;"

@mikaelbauer

Super Sportmatchen - A retro multiplayer competitive sports game project!

default: ??? what is ithis?this is the first time i heard about it.Can you give me some help on what that''s doing? Can i find it in one of NeHe''s tutorials?
switch(pfft)
{
case 1: something; break;
case 2: some other thing; break;
default: something else; break;}

if pfft is something other than one or two, whats in the default thing will be executed.

This topic is closed to new replies.

Advertisement