PDA

View Full Version : Draw a rectangular polygon...



powervr
10-31-2004, 09:56 PM
Hi, in my codes below, I cannot draw a rectangular polygon as i expected. What I have drawn is just seems to be a "half of a cube"

--------------------------------------------
glBegin(GL_POLYGON);

// Front Face

glVertex3f(-1.0f, -1.0f, 1.0f); // Bottom Left Of The Texture and Quad
glVertex3f( 1.0f, -1.0f, 1.0f); // Bottom Right Of The Texture and Quad
glVertex3f( 1.0f, 0.01f, 1.0f); // Top Right Of The Texture and Quad
glVertex3f(-1.0f, 0.01f, 1.0f); // Top Left Of The Texture and Quad

// Back Face
glVertex3f(-1.0f, -1.0f, -1.0f); // Bottom Right Of The Texture and Quad
glVertex3f(-1.0f, 0.01f, -1.0f); // Top Right Of The Texture and Quad
glVertex3f( 1.0f, 0.01f, -1.0f); // Top Left Of The Texture and Quad
glVertex3f( 1.0f, -1.0f, -1.0f); // Bottom Left Of The Texture and Quad

// Top Face
glVertex3f(-1.0f, 0.01f, -1.0f); // Top Left Of The Texture and Quad
glVertex3f(-1.0f, 0.01f, 1.0f); // Bottom Left Of The Texture and Quad
glVertex3f( 1.0f, 0.01f, 1.0f); // Bottom Right Of The Texture and Quad
glVertex3f( 1.0f, 0.01f, -1.0f); // Top Right Of The Texture and Quad

// Bottom Face
glVertex3f(-1.0f, -1.0f, -1.0f); // Top Right Of The Texture and Quad
glVertex3f( 1.0f, -1.0f, -1.0f); // Top Left Of The Texture and Quad
glVertex3f( 1.0f, -1.0f, 1.0f); // Bottom Left Of The Texture and Quad
glVertex3f(-1.0f, -1.0f, 1.0f); // Bottom Right Of The Texture and Quad

// Right face
glVertex3f( 1.0f, -1.0f, -1.0f); // Bottom Right Of The Texture and Quad
glVertex3f( 1.0f, 0.01f, -1.0f); // Top Right Of The Texture and Quad
glVertex3f( 1.0f, 0.01f, 1.0f); // Top Left Of The Texture and Quad
glVertex3f( 1.0f, -1.0f, 1.0f); // Bottom Left Of The Texture and Quad

// Left Face
glVertex3f(-1.0f, -1.0f, -1.0f); // Bottom Left Of The Texture and Quad
glVertex3f(-1.0f, -1.0f, 1.0f); // Bottom Right Of The Texture and Quad
glVertex3f(-1.0f, 0.01f, 1.0f); // Top Right Of The Texture and Quad
glVertex3f(-1.0f, 0.01f, -1.0f); // Top Left Of The Texture and Quad

glEnd();
--------------------------------------------

mikael_aronsson
11-01-2004, 03:47 AM
Make sure you get the winding order correct, if the get it wrong direction (clockwise normally) you might only see the polygons facing the viewer unless you render both sides of the polygons.

Mikael

powervr
11-01-2004, 04:14 AM
Yes, I can get the polygon rendered, but I expect the "height" is 0.01

but the result's height seems to be 0.5, I means it is thicker than i expect!

thanks anyway :)

mikael_aronsson
11-02-2004, 06:22 AM
Hi !

That's what you did render, it is half a cube, look at the vertices, X goes from -1 to 1, Z goes from -1 to 1 but Y goes from -1 to 0, if you want a cube you should use -1 to 1 for the Y corrdinates also.

Mikael