OpenGL Quad Rendering

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

Post Reply
User avatar
dejai
Chaos Rift Junior
Chaos Rift Junior
Posts: 207
Joined: Fri Apr 11, 2008 8:44 pm

OpenGL Quad Rendering

Post 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.
User avatar
RyanPridgeon
Chaos Rift Maniac
Chaos Rift Maniac
Posts: 447
Joined: Sun Sep 21, 2008 1:34 pm
Current Project: "Triangle"
Favorite Gaming Platforms: PC
Programming Language of Choice: C/C++
Location: UK
Contact:

Re: OpenGL Quad Rendering

Post by RyanPridgeon »

You can use the glScale, glRotate and glTranslate functions with glPushMatrix and glPopMatrix to do this.
Ryan Pridgeon
C, C++, C#, Java, ActionScript 3, HaXe, PHP, VB.Net, Pascal
Music | Blog
User avatar
Ginto8
ES Beta Backer
ES Beta Backer
Posts: 1064
Joined: Tue Jan 06, 2009 4:12 pm
Programming Language of Choice: C/C++, Java

Re: OpenGL Quad Rendering

Post 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
Quit procrastinating and make something awesome.
Ducky wrote:Give a man some wood, he'll be warm for the night. Put him on fire and he'll be warm for the rest of his life.
Post Reply