Jump to content
  • Advertisement

Archived

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

kuya

open gl animation question

This topic is 5965 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, this is my first major exercise in open gl, so be gentle. i''m writing a program to produce solutions for the rubik''s cube. i just started, so now i''m writing the gui in none other than...open gl. i used nehe''s lesson 5 as a basecode and modified accordingly. i have a cube class with two of its member functions being: cube.Twist() and cube.RenderCube(). cube.Twist draws the cube animation being twisted on either the top, bottom, front, back, left, or right face. cube.RenderCube() just draws the cube in whatever the current state is. my problem may arise from a lack of understanding of animation in open gl. but anyway, the problem is that i can''t seem to draw the cube being twisted, and then draw the cube in its current state. if i have one Twist function in DrawGLScene followed by one RenderCube function right after that, it draws both at the same time. I realize that''s because DrawGLScene loops until the escape key is hit. so i threw in a boolean variable to check when the twisting animation is done so i can just do that once, and then just render the cube in its current state for the duration of the program. problem is that with that variable intact, the twisting animation seems to go too fast for the program, and it''ll just sit in the renderscene() loop. i know it gets to the twist function, it hits the breakpoint. it just seems that the speed of animation is extremely different if the if(boolean) check is located there. would anyone know how to slow the twisting animation down or what the issue is? the drawgl function is below int DrawGLScene(GLvoid) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); glTranslatef(0.0f,0.0f,-20.0f); glRotatef(45.0, 1.0f, 1.0f, 1.0f ); glBegin(GL_LINES); glVertex3f(0.0f, 0.0f, 0.0f); glVertex3f(0.0f, 15.0f, 0.0f); glVertex3f(0.0f, 0.0f, 0.0f); glVertex3f(15.0f, 0.0f, 0.0f); glVertex3f(0.0f, 0.0f, 0.0f); glVertex3f(0.0f, 0.0f, 15.0f); glEnd(); if( permutations_waiting){ cube.Twist( BOTTOM, CLOCKWISE ); permutations_waiting = FALSE; } else { cube.RenderCube(); } return TRUE; }

Share this post


Link to post
Share on other sites
Advertisement
your rendering everything to a single frame {see the WinMain funtcion where you call the Draw method}, that is why you only get the final output, try inserting glFlush() in the twist method or re-work your code so it adjusts the cube once every time the draw function is called.


Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!