View Full Version : glDrawElements not drawing

10-11-2010, 08:10 AM
Hey, real newbie to OpenGL so please bear with me.

I'm trying to make a checkered floor with data generated from the code. The generation part seems to be working, the vertex, index and color arrays all contain the correct data. However, when calling glDrawElements on them nothing appears. It is working for another object drawn in this method.

void drawFloor()
glPolygonMode(GL_FRONT, GL_FILL);
glPolygonMode(GL_BACK, GL_FILL);

glColorPointer(3, GL_FLOAT, 0, colorsFloor);
glVertexPointer(3, GL_FLOAT, 0, verticesFloor);

glDrawElements(GL_QUADS, 16, GL_UNSIGNED_BYTE, indicesFloor);


This is just a portion of the code, but it seems to be the only relevant part. If you need any more information please tell me.

Dark Photon
10-11-2010, 09:08 AM
To help get a line on your problem, try one or more of:

glDisable ( GL_CULL_FACE )
glPolygonMode ( GL_FRONT_AND_BACK, GL_LINE ) ;

and possibly:

glDisable( GL_LIGHTING )
glDisable( GL_TEXTURE_2D );
glColor4f( 1,1,1,1 );

to see if maybe your geometry is really in view but its back-facing, badly connected, has a problematic texture or lighting problem, or something (no normals so shouldn't be lighting anyway).

10-11-2010, 10:06 AM
Seems like i figured it out. Forgot that it's not 16 elements i wanted to draw, it was 48 vertices. The back-face culling was turned on too.

Sorry for wasting your time!