I'm trying to render the primitives in a normal fill mode, then as a wire frame.
Render Code:
glClear(GL_COLOR_BUFFER_BIT);
glClearColor(0.9f, 0.9f, 0.9f, 1);
// reset matrix
glLoadIdentity();
// fill display list
glColor3c(150, 255, 255);
glCallList(lDList);
// wireframe display list
glColor3f(0, 0, 0);
glLineWidth(10);
glPolygonMode(GL_FRONT_AND_BACK, GL_LINES);
glCallList(lDList);
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
Display List Creation Code:
lDList = glGenLists(1);
glNewList(lDList, GL_COMPILE);
glBegin(GL_QUADS);
glVertex3i(-1, -1, 0);
glVertex3i(1, -1, 0);
glVertex3i(1, -1, -25);
glVertex3i(-1, -1, -25);
glEnd();
glEndList();
glColor3c Macro:
#define glColor3c(r, g, b) glColor3f(r / 255, g / 255, b / 255)
I'm expecting to get a cyan colored plane drawn with a black frame around it, but all that's happening is that the second time I render the display list, it's simply filling and drawing the entire thing, overwriting the pixels for the other primitive. I end up with the plane I want drawn, but its just black (the color I specified for the line "version").
Any other information that might be useful is that I'm using SDL, on Windows 7 with MSVC++ 2010. I do not make any calls to glEnable, so I have no weird settings enabled that would mess it up, or, perhaps solve the problem. My only OpenGL setup code sets up the projection and modelview matrix and then creates the display list.
Obviously my question is why is the second time I draw the display list is it filling the primitive instead of creating lines? How do I fix this?
According to the docs for glPolygonMode
in OpenGL 4.0, the second argument, mode
, may only be one of GL_FILL
, GL_POINT
, or GL_LINE
. In your example, you are passing GL_LINES
, which is an entirely different enum value.
I suspect that passing GL_LINES
is handled by OpenGL such that it defaults back to GL_FILL
if the received mode is not what it expects.
Also note: the specification for glPolygonMode
is the same back through OpenGL 2.1.