Jump to content

  • Log In with Google      Sign In   
  • Create Account


animation errors


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 Crusable   Members   -  Reputation: 592

Like
0Likes
Like

Posted 13 May 2012 - 01:05 PM

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 :)

Attached Files


"C spilled his beer all over C++'s shirt. Outraged, C++ shouted, "Good god, man! Have you no class?"

"Your mother is so fat that the recursive function that was used to calculate her mass created a stack overflow"

 

 


Sponsor:

#2 CurtisJC   Members   -  Reputation: 112

Like
0Likes
Like

Posted 16 May 2012 - 12:51 PM

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, 16 May 2012 - 12:54 PM.

Curtis Clark
Software Engineer
Aerospace and Defence Industry

#3 Crusable   Members   -  Reputation: 592

Like
0Likes
Like

Posted 18 May 2012 - 10:11 PM

what i ment my almost identical is that i changed the colors of the background and the square

"C spilled his beer all over C++'s shirt. Outraged, C++ shouted, "Good god, man! Have you no class?"

"Your mother is so fat that the recursive function that was used to calculate her mass created a stack overflow"

 

 


#4 Goran Milovanovic   Members   -  Reputation: 1103

Like
0Likes
Like

Posted 19 May 2012 - 10:41 AM

You have to set windowWidth and windowHeight:

	if (w<=h){
		windowWidth = 100;
		windowHeight = 100 / aspectRatio;
	}else{
		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.

+---------------------------------------------------------------------+

| Need a programmer?        ->   http://www.nilunder.com/protoblend   |

| Want to become one?       ->   http://www.nilunder.com/tutoring     |
| Game Dev video tutorials  ->   http://www.youtube.com/goranmilovano |
+---------------------------------------------------------------------+




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS