PDA

View Full Version : N sided Polygon, N+1 Vertices



ibm1130
01-10-2002, 04:16 AM
I'm drawing an n sided polygon using the usual

glBegin( GL_POLYGON );
loop through vertices ( glVertex2f( ... ) )
glEnd();

Initially the code was running with N+1 points for N sided polygons. ( Polygons were defined from a separate free standing app )
As I read the info on polygon drawing I infer that this may result in undefined behaviour.

Running the same code base on 3 machines ( 2 of which are identical with Oxygen GVX420 vidcards, one is newer and has has a Wildcat II 5110 ).

The two Oxygen board equipped machines had no problems with the polygons as defined, however the Wildcat II equiped machine crashed the drawing app regularly.

The solution was to not draw the last point since it was in fact identical to the first point in the polygon.

The conclusion we came to regarding the difference in behaviour was that mayhap the standard does not define what happens in such an instance and that the newer board has driver that is less forgiving of out of spec conditions than the older driver.

Anybody have a better explanation off the top of their head.
I tried fiddling with a free standing app to force the error but haven't been able to get it to fail as yet.

Thanx.

Rob The Bloke
01-10-2002, 04:24 AM
a polygon will always be created with n sides, n vertices (gl will automatically join the first and last vertices drawn). Dont draw the last vertex. Presumably the crash occurs due to a zero length edge.

[This message has been edited by Rob The Bloke (edited 01-10-2002).]

ibm1130
01-10-2002, 07:12 AM
Hmmmm....
I understand that the spec calls for N vertices to draw an n sided polygon. What I'm curious about is the different behaviour of the two machines. It isn't critical I'm just puzzled.