PDA

View Full Version : Clipping oddness...



kabir
04-17-2002, 12:57 AM
So I've been having a problem for a while now (with multiple pieces of code) where the left hand edge of my vieport seems to be clipping weirdly. The clear color fills in just fine, but anything that I render close to the edge of the viewport dissapears. Sometimes. Resizing the window changes the amount that is clipped oddly, but it's not a uniform change. One movement will have no effect, the same movement again might make the problem go away (or become unnoticably small...).

I have a picture of what I'm talking about at http://www.geocities.com/hloew/edge.html

That particular example happens to be an Ortho projection into a pane of an MFC app, but it could just as well be perpective in a normal window.

I've done some searches looking for similar problems on the forum, but honestly I'm not even sure what to call this... At first I thought I might be doing my viewport sizing calculations wrong (in some very odd way) but I've confirmed all of them as good. I also figure that if it were a vieport size issue then the clear color wouldn't be drawn into the "dead" spot.

Edit:
Oh... this only happens on the left edge. I've never seen it anywhere else, and believe me, I've been looking!
End of Edit

Anyone have any ideas what the heck this might be?

[This message has been edited by kabir (edited 04-17-2002).]

JML
04-17-2002, 05:58 AM
This looks like bitmaps getting clipped as soon as the current rasterposition is outside the viewing volume. That's how OpenGL is supposed to work.

Jean-Marc.

kabir
04-17-2002, 07:36 AM
Originally posted by JML:
This looks like bitmaps getting clipped as soon as the current rasterposition is outside the viewing volume. That's how OpenGL is supposed to work.

Jean-Marc.

But they're being drawn, rather specifically, _inside_ the current viewing volume. I'm also confused about the resizing: If the window is size X initially, and I resize it some number of times until the problem goes away, then return it to size X the problem doesn't necessarily come back... this doesn't seem to indicate viewing volume issues.... or am I missing something?

Furrage
04-17-2002, 09:12 AM
Following up on JML. Are they bitmap images? When you resize are you resizing exactly with some thing like a MoveWindow() call, or are you sizing the box with a mouse. If the latter, even though you think you've gotten it back to the same size it more than likely will be a pixel or two off and that is enough to make your raster position valid or invalid.

kabir
04-17-2002, 09:29 AM
Originally posted by Furrage:
Following up on JML. Are they bitmap images? When you resize are you resizing exactly with some thing like a MoveWindow() call, or are you sizing the box with a mouse. If the latter, even though you think you've gotten it back to the same size it more than likely will be a pixel or two off and that is enough to make your raster position valid or invalid.

I'm sorry, perhaps I chose a bad example to show the problem... this same thing happens if I render a quad which covers the entire viewport... it gets drawn everywhere except in the "dead" area along the left.

Also, when using bitmaps (as in the font example the picture is of) there are plenty of cases where half of the 0 is missing rather than the whole thing... I thought that when raster positions are invalidated that the whole bitmap would always dissapear...

kabir
04-22-2002, 03:31 PM
Ok, so I've done some more investigating into this problem.

For reference, I'm doing this in my window resize function:





glViewport( 0, 0, w, h );

fRange = m_fFarClipPlane - m_fNearClipPlane;
if (w <= h) {
glOrtho (-fRange, fRange, -fRange*h/w, fRange*h/w, -fRange, fRange);
}
else {
glOrtho (-fRange*w/h, fRange*w/h, -fRange, fRange, -fRange, fRange);
}


Edit: w & h come to me from the low & high words of the lParam associated with the WM_RESIZE message. /Edit

Which is pretty much right out of the OpenGL Superbible.

So at this point I'm using an orthographic projection, and drawing a quad at the near clip plane with dimensions larger than the viewport.

When this first draws I have again a dead strip along the left (filled with my clear color though). This time, though, rather than resizing the window I just move it (drag the title bar). For some reason that changes the dimensions of the dead strip in a non-uniform way (as well as making an additional dead strip along the top)

?!?

I've enabled super verbose debugging and sure enough the window resizing function isn't getting called when I move the window, so now I'm very, very unclear on what the
heck is going on.

BTW - I'm on WinME with a GeForce3 card (so I'm pretty sure it's not this: http://support.microsoft.com/default.aspx?scid=kb;ES-VE;q272222) if that will make any difference.

[This message has been edited by kabir (edited 04-22-2002).]

JML
04-23-2002, 12:59 AM
...
So at this point I'm using an orthographic projection, and drawing a quad at the near clip plane with dimensions larger than the viewport.
...


Have you tried drawing the quad slightly away from the near plane? Perhaps you are not experiencing left-side clipping but front-side clipping...

HTH

Jean-Marc

Furrage
04-23-2002, 06:17 AM
If your window resizing function isn't being called then it has to do with message handleing. So start by tracing the path from your WM_SIZE event and see if it leads to your resize code. Also check to see what causes a WM_SIZE event (just in case something really screwy is happeing). Alterantively, post your full resize and message handleing code.

kabir
04-23-2002, 09:52 AM
No, no, no....

The fact that the window resize function isn't being called is _expected_ and _correct_. Re-read the post: I'm not resizing the window. I'm _moving_ the window, as a whole unit. I just added that the resize function wasn't being called in order to firmly eliminate it from the discussion, because it's not an issue.

As for near plane clipping: The quad I'm drawing isn't being competely clipped, and is paralell with the viewport, so that shouldn't be an issue. Just to double check though, I drew it furthur into the view volume and still have the same issue.

kabir
04-23-2002, 10:40 AM
Solution!

So it was a driver problem. It would seem that the nVidia/Hercules drivers that shipped with my GeForce 3 card (3D Prophet III) had a bug in them, or something, as upgrading to the latest and greatest has _completely_ eliminated my problem.

It's nice to know I'm not insane http://www.opengl.org/discussion_boards/ubb/wink.gif