Archived

This topic is now archived and is closed to further replies.

show array as polygon?

This topic is 5108 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

i''m sitting here and trying to show my array named test[3][3][3] as polygons... i tried this but it doesn''t work
glBegin(GL_POLYGON);									
		glColor3f(0.0f,1.0f,0.0f);						
		glVertex3f( test[0][0][0], test[0][0][0], test[0][0][0]);
		glVertex3f( test[0][0][1], test[0][1][0], test[1][0][0]);
		glVertex3f( test[0][0][2], test[0][2][0], test[2][0][0]);
		

	glEnd();

Share this post


Link to post
Share on other sites
glVertex3f(test[0][0][0], test[0][0][1], test[0][0][2]);
glVertex3f(test[0][1][0], test[0][1][1], test[0][1][2]);
glVertex3f(test[0][2][0], test[0][2][1], test[0][2][2]);

maybe...

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
You must call glBegin(GL_POLYGONS) (plural) not glBegin(GL_POLYGON)

Share this post


Link to post
Share on other sites
quote:
Original post by Anonymous Poster
You must call glBegin(GL_POLYGONS) (plural) not glBegin(GL_POLYGON)


no..
quote:

Platform SDK: OpenGL:

...

void glBegin(
GLenum mode
);

...

Parameters
mode

..

GL_POLYGON
Draws a single, convex polygon. Vertices 1 through N define this polygon.




yeah.

you might have culling enabled. try drawing the polygon in different winding. (swap 2 last glvertex calls)

or it simply may not be on screen. This is most likly.

[edited by - RipTorn on December 17, 2003 10:17:35 PM]

Share this post


Link to post
Share on other sites
It seems like there is more than one way to display a polygon in a 3x3x3 array, but the way you are doing it will make a triangle with a few of the values from your array as vertex points, as you only have 3 calls to glVertex3f.

The way POLYGON mode works is that you specify the initial vertex, and then a line is drawn to the next vertex specified, and so on until the last vertex is specified, when a line is drawn back to the first vertex. (Note: it doesn''t actually draw these lines, I saw draw as in drawing a mental picture of what the polygon would look like).

If you want more than one polygon, you are going to have to change the code a little to use a for loop perhaps or another GL primitive that I am forgetting about. If you are only interested in making triangles, you can use the TRIANGLES mode to draw a bunch of triangles (where every 3 vertices specifies one triangle).

Share this post


Link to post
Share on other sites