Jump to content
  • Advertisement
Sign in to follow this  

animation errors

This topic is 2372 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

hello, i have been reading opengl superbible version 4 and im confused about one of the projects. Aside from the colors used my project is almost identical to the code in the book and im getting a weird resault. the yellow square is supposed to bounce around the edges but instead it rapidly flips over the oragin. i have no idea whats wrong and would like some help. ive included the code. thanks for any responces :)

Share this post

Link to post
Share on other sites
Almost identical? If you look for what you have done differently that could be your answer!

As far as I can see, what you got looks good... I haven't touched much graphics code in the last 6 months mind you! The only thing I would say that looks out of place is this:

if (x1 > windowWidth - rsize || x1 < -windowWidth)
xstep = -xstep;

-windowWidth (in a few places). As far as I'm aware, in OpenGL the origin is bottom left, so -windowWidth would be off the screen! I believe this should be 0.

Also it seems that the rect is initially being drawn off the screen with y - rsize: 0 - 25 = -25 which is below the window.

Hope this is helpful! Edited by CurtisJC

Share this post

Link to post
Share on other sites
You have to set windowWidth and windowHeight:

if (w<=h){
windowWidth = 100;
windowHeight = 100 / aspectRatio;
windowWidth = 100 * aspectRatio;
windowHeight = 100;

glOrtho (-windowWidth, windowWidth, -windowHeight, windowHeight, 1.0, -1.0 );

That said: I don't think that "windowWidth" and "windowHeight" are proper variable names in this case, because their values represent the limits of your visible coordinate system.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • 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!