Sign in to follow this  
Halma

OpenGL OpenGL Culling going crazy

Recommended Posts

I've got a very strange problem with a game I'm making. When I enable backface culling, everything starts out looking OK. But sometimes, for some reason (or for no reason! ;)), the culling is reversed. I only enable culling in one location of my program, so it's not a situation with different functions messing up the culling state variables. Why on earth would this happen? I enable culling, set the culling to GL_BACK, set the front face to GL_CCW, and it still reverses itself and starts showing the opposite side of everything every once in a while.

Share this post


Link to post
Share on other sites
If you are definately not changing the winding order yourself then the problem could lie with buggy old drivers [smile] Have you tried upgrading your graphics card drivers to the latest version?

You could also stick...
GLint i;
glGetIntegerv(GL_CULL_FACE_MODE, &i);
into your render function and slap a break point on it if the cull mode is gl_front (the same could be done for GL_FRONT_FACE). Then run through your program with the debugger attached.

All the best,
ViLiO

Share this post


Link to post
Share on other sites
Quote:
Original post by Halma
When I enable backface culling, everything starts out looking OK. But sometimes, for some reason (or for no reason! ;)), the culling is reversed.

Some transformations will cause this, the most common one would be using a negative scale (for reflections and the like). If you're doing that you need to invert the culling for the reflection and put it back again afterwards.

Share this post


Link to post
Share on other sites
Thanks for the replies.

I don't think the problem is with drivers; I have an NVIDIA GeForce 6600, and my drivers are at worst, about a year old. Besides, I've seen my program do the same thing on at least one other computer.

I don't have any reflections, and I hardly have any scaling at all, so I don't think the problem is with negative scaling. In any case, I glPopMatrix after my transforms.

I'll try the breakpoint thing; I'll tell you how it goes.

Share this post


Link to post
Share on other sites
I guess it's due to Orthographics projection.

It once happenned with me, and I had no time to check the reason with it because I had to deliver my program before the deadline. Anyway, I have done all in reverse in order to find a short term solution, and since that time, I havn't had the chance to dedicate some time to Graphics...

Best Regards,
Ali B

Share this post


Link to post
Share on other sites
Are you by any chance using wglUseFont functions to draw text? I don't know why the hell they change the winding, but they do. I have to reset the winding to glFrontFace(GL_CCW) right after I'm done drawing text, or else the culling gets screwed up.

Share this post


Link to post
Share on other sites
Quote:
Original post by mikeman
Are you by any chance using wglUseFont functions to draw text? I don't know why the hell they change the winding, but they do. I have to reset the winding to glFrontFace(GL_CCW) right after I'm done drawing text, or else the culling gets screwed up.


YES!! I love you!

Thanks a lot, that fixed it!

What kind of $#% programmer changes the global states without changing them back??!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this