PDA

View Full Version : Help!!



fox
10-10-2000, 02:13 AM
I have a cuboid - why does the back face block the front when you look directly at it but disappear when you zoom out and look from above - also why are some of the sides missing or transparent - I did apply
glCullFace (GL_BACK);
glEnable (GL_CULL_FACE);

which took away the top and back faces of all the objects rather than just the one I wanted so I removed the line and now the back face of cuboid overlap with the front face when rotating the scene

Any ideas?

Thanx

dans
10-10-2000, 02:45 AM
make sure your polygon winding is the same across all faces.(The order you specify your verts) Counter-clockwise seems to be popular, if your unsure on how do do this then glDisable(GL_CULL_FACE) should stop your faces disapearing.

check you have this consistant, and for a hack you could do the example.

void glPolygonMode(
GLenum face, //GL_FRONT, GL_BACK, GL_FRONT_AND_BACK
GLenum mode //GL_FILL, GL_LINE, GL_POINT
);

so... (example)

glPolygonMode(GL_FRONT_AND_BACK, GL_LINE)
should also help your polys to be displayed from all angles.

fox
10-10-2000, 04:03 AM
I've checked the polygon winding - it's fine - I tried glDisable(GL_CULL_FACE) - it doesn't seem to make a difference
This is my code in Onsize()
{
.
.
glMatrixMode (GL_PROJECTION);
glLoadIdentity();
gluPerspective(60, aspect, 0.0,300);//60,aspect, 0.0, 300
glMatrixMode (GL_MODELVIEW);
glLoadIdentity ();
//glCullFace (GL_BACK);
//glDisable (GL_CULL_FACE);
glEnable (GL_LIGHTING);
glEnable (GL_DEPTH_TEST);
.
.
}

I also tried glPolygonMode(GL_FRONT, GL_LINE);

placing it just before drawing each face - and i get a blank screen

Teofuzz
10-10-2000, 04:47 AM
I encountered a similar problem some time ago... while rotating a cube I could see faces appear and disappear in a strange way, and it was a mix of these errors:
- I didn't set up properly normals
- I didn't ordered poly vertex counter-clockwise
- I was applying an incorrect transformation

Try to check these...

Punchey
10-10-2000, 07:09 AM
Yes, you must be sure to wind your polys in the right direction. Also make sure you've got depth testing turned on. I believe by default, if you looked at one side of the poly and from that perspective you saw it wound in a counter-clockwise direction, that side is considered the "front" of the poly and the other side is the backface. You can change this default behaviour with an OpenGL call the name of which escapes me at the moment. Anyway, make sure you wind your polys in the right direction. I've heard people say it doesn't matter which way you wind as long as it is consistent and from what I know, if you're using backface culling, this is dead wrong. It does matter which way if you aren't specifying to OpenGL which way you're winding because the way you wind it determines which side is the front and which is the back.

fox
10-11-2000, 01:07 AM
I've re-examined the polygon windings and made a few changes but get the same result

When added the back-face culling - in onpaint I added the line below

glDepthFunc(GL_LEQUAL);

- I think this may be the problem - removing it gives a blank screen I'm not sure why because I already have glEnable(GL_LIGHTING); glEnable(GL_DEPTH_TEST); and glEnable(GL_LIGHT0);

any ideas

I can submit some code if that helps
Thanx


[This message has been edited by fox (edited 10-11-2000).]

DFrey
10-11-2000, 04:05 AM
The problem only happens when you zoom out?
If so, then I'd tend to think you have a problem with your farplane:nearplane ratio.

fox
10-11-2000, 04:13 AM
Hey it works it works - yes it work ha ha ha ha ha ha ha ha ha ha ha ha