Original Post
🔒 Locked
quad sizing
Advertisement
glPushMatrix();
glTranslatef(Pos.x, Pos.y, 0);
glBegin(GL_QUADS);
// Quad x/y coords are it''s top left corner
glVertex3f(0.0f, 0.0f, 0.0f);
glVertex3f(QuadWidth, 0.0f, 0.0f);
glVertex3f(QuadWidth, -QuadHeight, 0.0f);
glVertex3f(0.0f, -QuadHeight, 0.0f);
// Or it''s center
glVertex3f(-Width * 0.5f, Height * 0.5f, 0.0f);
glVertex3f( Width * 0.5f, Height * 0.5f, 0.0f);
glVertex3f( Width * 0.5f, -Height * 0.5f, 0.0f);
glVertex3f(-Width * 0.5f, -Height * 0.5f, 0.0f);
// Optimized to
Width *= 0.5f;
Height *= 0.5f;
glVertex2f(-Width, Height, 0.0f);
glVertex2f( Width, Height, 0.0f);
glVertex2f( Width, -Height, 0.0f);
glVertex2f(-Width, -Height, 0.0f);
glEnd();
glPopMatrix();
This could also do the trick: Let's say you want to make the quad one half the normal size:
glPushMatrix();
glTranslatef(xPos, yPos);
glScalef(0.5, 0.5, 1); //scale it to one half the size.
glBegin(GL_QUADS);
glVertex3f(-1.0f, 1.0f, 0.0f);
glVertex3f( 1.0f, 1.0f, 0.0f);
glVertex3f( 1.0f,-1.0f, 0.0f);
glVertex3f(-1.0f,-1.0f, 0.0f);
glEnd();
glPopMatrix();
Of course, you could use variables for the width/height factors in glScalef: glScalef(scale_x, scale_y, 1);
[edited by - EGD Eric on January 10, 2004 3:58:21 PM]
glPushMatrix();
glTranslatef(xPos, yPos);
glScalef(0.5, 0.5, 1); //scale it to one half the size.
glBegin(GL_QUADS);
glVertex3f(-1.0f, 1.0f, 0.0f);
glVertex3f( 1.0f, 1.0f, 0.0f);
glVertex3f( 1.0f,-1.0f, 0.0f);
glVertex3f(-1.0f,-1.0f, 0.0f);
glEnd();
glPopMatrix();
Of course, you could use variables for the width/height factors in glScalef: glScalef(scale_x, scale_y, 1);
[edited by - EGD Eric on January 10, 2004 3:58:21 PM]
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement