View Full Version : Vertices not always being clipped to view frustum

01-26-2012, 09:54 AM

I encountered some very strange behavior and I'm trying to figure out why it's happening. I was under the impression that OpenGL always clips vertices to the view frustum, but that's not what I'm seeing.

In my application, I found that if depth test is enabled, the far plane properly clips vertices too far away. If depth test is disabled, or depthfunc is set to GL_ALWAYS, or depth range keeps depth values small, nothing gets clipped.
I hate having to clear the whole depth buffer just to get proper clipping, when I don't want any depth testing at all. I suppose I could enable a clip plane and see if that works as another workaround.

I modified an old NeHe tutorial to see if I could reproduce the issue with a small example program but I couldn't.

Our application is rendering to an off-screen multisampled buffer through an FBO and perhaps that's related. I'm on Windows 7 (64-bit application) using an nVidia Quadro 5000 with recent drivers (two different versions had the same issue). We're using a compatibility profile context.

Can anyone here think of any other OpenGL state that might affect this? Could it possibly be an overlooked driver bug? It sure seems wrong to me.

- LoopinFool

01-26-2012, 10:07 AM
Enabled GL_DEPTH_CLAMP would be the obvious candidate.

01-26-2012, 10:25 AM
Yes, that's the obvious candidate, especially after reading its description.
And, yes, that was the issue. We generally leave it enabled because it's so useful, and we didn't think of it.

Thanks so much for the help,
- LoopinFool