glRasterPos() woes

I’m creating a bitmap-drawing function and I want it to draw just the part of the bitmap that’s in my window when it’s partially offscreen. It works fine on the top and right sides but not on the left or bottom. If I give glRasterPos() values that are offscreen it simply doesn’t draw the bitmap. Is there any way around this?

Clamp the raster pos to the edge of the screen, then offset the texture coordinates (or pixel coordinates) to compensate?

Originally posted by Tokage:
If I give glRasterPos() values that are offscreen it simply doesn’t draw the bitmap.

That’s exactly the behaviour specified in OpenGL.

Originally posted by Tokage:
Is there any way around this?

Yes, first setup a valid raster position, that is inside the frustum. Then call glBitmap(0, 0, 0, 0, offset_x, offset_y, NULL);
This will offset the raster position is screen coordinates. If that offset leads the position outside the screen, the bitmap rasterization will NOT be discarded (though it may be partially clipped obviously).

It’s explained better in the OpenGL FAQs. Check out the FAQs section at www.opengl.org

Or use http://oss.sgi.com/projects/ogl-sample/registry/IBM/rasterpos_clip.txt if available.

glWindowPos will set the raster position in window coordinated, and keep it valid if it’s outside view viewport.