PDA

View Full Version : Problem with glPolygonMode



Lidestro
01-11-2007, 03:22 AM
I want my program to start in GL_FRONT rendering mode but it always starts in GL_FRONT_AND_BACK mode.

I try calling "glPolygonMode(GL_FRONT, GL_FILL);" at different location in the code, before the first glBegin(), with no result. But I seem to de able to chance the later in to program, under some circumstances...

glPolygonMode(GL_FRONT, GL_FILL); //First call, no effect
glBegin (GL_QUADS);
PlotBorders(MAX_X + 1, MIN_X, MAX_Y + 1, MIN_Y, MAX_Z + 1, MIN_Z);
plot_apple(apple_ptr);
plot_snake(snake_ptr);
glEnd();

SwapBuffers(g_hDC); // Swap the backbuffers to the foreground
glPolygonMode(GL_FRONT, GL_FILL); // Calling second time, no effect


If anyone has any idea why, id be gratefull...


/Lidestro

Bruce Merry
01-11-2007, 04:43 AM
The first parameter to glPolygonMode isn't a mode, it just specifies which of (or both of) the two polygon modes is changed. The glPolygonMode calls you're making have no effect on the default state, because for both front and back, the default is GL_FILL.

When you say GL_FRONT rendering mode, I assume you mean that you want back-facing polygons to be culled. You can do that with glEnable(GL_CULL_FACE).

Lidestro
01-12-2007, 07:52 AM
That make things a hole lot more comprehensible!
Cheers!


What I wanted to do was:

glPolygonMode(GL_BACK, GL_LINE);

to make back facing polygons appear as wire frames.

/Jens