Having problem with quads

For some dumb reason, I just cannot seem to draw a quad.

Here is the code:

    GL11.glBegin(GL11.GL_LINES);
    GL11.glColor3f(1.0f, 1.0f, 1.0f);
    GL11.glVertex2f(10, 10);
    GL11.glVertex2f(60, 10);
    GL11.glVertex2f(60, 60);
    GL11.glVertex2f(10, 60);
    GL11.glEnd();
    
    GL11.glBegin(GL11.GL_QUADS);
    GL11.glColor3f(1.0f, 1.0f, 1.0f);
    GL11.glVertex2f(10, 10);
    GL11.glVertex2f(60, 10);
    GL11.glVertex2f(60, 60);
    GL11.glVertex2f(10, 60);
    GL11.glEnd();

The lines appear in white, but the quad doesn’t.

What is going on here? Using Mac OS X.

only thing I can think of is that you have it set to not draw backfaces and that the ‘winding’ (order in which you specify your vertices) order is set to clockwise polygons facing forward (you gave vertices in counter-clockwise order, so that would be facing backward with the setup I described). Can’t think of anything else with the information given…

That was it !

I changed the order to clockwise and it works now. Much thanks, it was driving me crazy!

I’m basing my initialization code on the Basic Framework someone posted in the tutorial section. It includes the following code:

    GL11.glShadeModel(GL11.GL_SMOOTH);
    GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
    GL11.glClearDepth(1.0);
            
    GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_NICEST);
    GL11.glHint(GL11.GL_POLYGON_SMOOTH_HINT, GL11.GL_NICEST);
    
    GL11.glCullFace(GL11.GL_FRONT);
    GL11.glEnable(GL11.GL_CULL_FACE);

I assume the GL11.glCullFace(GL11.GL_FRONT) specifies to draw the front face for quads and polygons, and that GL11.glEnable(GL11.GL_CULL_FACE) means to enable the functionality to eliminate back faces, but which command specifies clockwise ordering? Is that the default for OpenGL?

Tx.

this function specifies the ordering: GL11.glCullFace(GL11.GL_FRONT);

[quote]this function specifies the ordering: GL11.glCullFace(GL11.GL_FRONT);
[/quote]
Bzzzt ! That is incorrect :slight_smile:

glCullFace specifys which faces to cull from GL_FRONT and GL_BACK. Although i’ve never had a reason to cull the front faces, Its probably useful for some reason. Stencilling for shadows or outlines or something comes to mind.

The order of the polygon winding is specified by glFrontFace and either GL_CW or GL_CCW. The default is GL_CCW and you’re well advised to leave it at that. For some reason CCW has become the norm for modellers like 3dsMax aswell, so most exported models will be using a CCW winding.

D.

…Although if you do a mirroring transform (like scale(-1, 1, 1)) then you’ll need to flip from CCW to CW.

heh yeah thats right, but if you were to use that function to cull the front faces instead of the back faces, that effectively changes which winding order will give you a visible polygon face. I’m not saying to do this, just explaining my reason for thinking that function would do it :stuck_out_tongue: (I’ve never actually wanted to change the winding order…).