I’m tying to use polygon offset.
I’m using gl4java and what I do is:
- draw a GL_LINE_LOOP (the outline of the polygon)
- draw a GL_POLYGON
But even with offset enabled, the outline is still shown wrong
This is my code:
gl.glPolygonOffset(1.0f, 2.0f); // (this is in my init() code
gl.glEnable(GL_POLYGON_OFFSET_FILL);
gl.glColor3f(1.0f, 1.0f, 1.0f);
gl.glBegin(GL_LINE_LOOP);
gl.glVertex3f(-h/2, -b/2, 0.f);
gl.glVertex3f(h/2, -b/2, 0.f);
.glVertex3f(h/2, b/2, 0.f);
gl.glVertex3f(-h/2, b/2, 0.f);
gl.glEnd();
gl.glColor4f(1.0f, 0.0f, 0.0f, 1.0f);
gl.glMatrixMode( GL_TEXTURE );
gl.glLoadIdentity();
gl.glBegin(GL_POLYGON);
gl.glTexCoord2f(0.f, 0.f); gl.glVertex3f(-h/2, -b/2, 0.f);
gl.glTexCoord2f(0.f, y); gl.glVertex3f(h/2, -b/2, 0.f);
gl.glTexCoord2f(x, y); gl.glVertex3f(h/2, b/2, 0.f);
gl.glTexCoord2f(x, 0.f); gl.glVertex3f(-h/2, b/2, 0.f);
gl.glEnd();
gl.glMatrixMode( GL_MODELVIEW );
gl.glDisable(GL_POLYGON_OFFSET_FILL);
Does anyone know what is wrong?
Thx!