Page 1 of 1

OpenGL Quad Rendering

Posted: Wed Dec 23, 2009 11:43 pm
by dejai
I was watching your video on Quad rendering (Rectangles) with opengl which inspired me to try and clone it. I was just wondering how exactly you derived your vector positions from the scale, width, height and position of the rectangle. And do you have to constantly update this? Any information would be great.

Re: OpenGL Quad Rendering

Posted: Thu Dec 24, 2009 5:29 am
by RyanPridgeon
You can use the glScale, glRotate and glTranslate functions with glPushMatrix and glPopMatrix to do this.

Re: OpenGL Quad Rendering

Posted: Sat Dec 26, 2009 11:32 am
by Ginto8
dejai wrote:I was watching your video on Quad rendering (Rectangles) with opengl which inspired me to try and clone it. I was just wondering how exactly you derived your vector positions from the scale, width, height and position of the rectangle. And do you have to constantly update this? Any information would be great.
well for rendering I completely agree with RyanPridgeon, but if you are trying to find those coordinates for collision detection or the sort, avansc's "Separating Axis Theorem for the Rest of Us" has an algorithm: (Taken from cRect::calc_World_Coords())

Code: Select all

   /*
    x' = cos(theta)*x - sin(theta)*y 
    y' = sin(theta)*x + cos(theta)*y
    */
where theta is the angle of rotation, x and y are the coords of the original vertex, and x' and y' are the coords of the rotated vertex