PDA

View Full Version : glPointSize and clipping volume



cbpetro
07-05-2007, 09:50 PM
When I use glPointSize it seems to invalidate the clipping volume. I use the glPointSize in a function that displays my scene correctly prior to the function but after, the clipping within the viewport is no longer working. Can someone help?


virtual void DrawVertex()
{
glPointSize(5.0);
glBegin(GL_POINTS);
glVertex2f(p1.x, p1.y);
glVertex2f(p2.x, p2.y);
glVertex2f(p3.x, p3.y);
glEnd();
}

dorbie
07-11-2007, 01:11 AM
Technically you should glScissor to guarantee fragments remain within the viewport. Points with size are an interesting issue in the spec due to center clipping not fragment level clipping and the obvious issues this causes.

But clipping should not break (it may be a side effect of the clip path for points being fudged to handle size elegantly).

You may incur a significant performance penalty falling off the clip path, so this sounds potentially nasty.

If it's just points then this is normal and correct behavior and you should use glScissor in addition to glViewport.

You don't provide a lot of info .... :-/

thinks
07-16-2007, 04:21 PM
Out of curiosity, if points are clipped according to their centre, the how does the glScissoring help? If the points are clipped, there will be no fragments at all? Or did I misunderstand the whole point? (hehe)

ZbuffeR
07-17-2007, 01:29 AM
Use a larger viewport, and glScissor to cut precisely where you want.
EDIT: because scissor works on individual pixels.

remdul
07-17-2007, 05:48 AM
Perhaps an alternative workaround would be to draw view aligned GL_QUADS instead of GL_POINTS, or use point sprites (though I'm not sure how those are clipped).

cbpetro
07-17-2007, 10:42 AM
I'm not trying to clip the points I'm trying to maintain the viewport that I've defined prior to rendering and which appears to be invalidated by using glPointSize.

I'm using glOrtho to define my viewing volume...


glViewport(VIEWPORTP[0], VIEWPORTP[1], VIEWPORTP[2], VIEWPORTP[3]);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho( xMin, xMax, yMin, yMax, -1, 1);
glMatrixMode( GL_MODELVIEW );
glLoadIdentity(); I can call all my drawing functions and the viewing volume remains. However when I call my function that contains the glPointSize my viewing volume changes beyond the limits I have defined.
If I comment out glPointSize, the viewing volume is maintained.

Is this normal behavior of glPointSize?

Komat
07-17-2007, 02:03 PM
Look at Common OpenGL Pitfalls (http://www.opengl.org/resources/features/KilgardTechniques/oglpitfall/) pitfall number 10

cbpetro
07-18-2007, 12:31 AM
Look at Common OpenGL Pitfalls pitfall number 10 Thanks. That explains it.