PDA

View Full Version : Rasterization in OpenGL



StoneRose
10-21-2004, 12:12 PM
In all of my dabbling in OpenGL Ive only ever used the opengl commands for drawing lines, etc. Recently it has came to my attention that it is possible to manipulate individual pixels through rasterization and wonderful things like the bresenham algorithim. My only problem is Im find near 0 resources/tutorials/guides on rasterization. The section int he red book seems to be little help at all and even google is not turning up much. Anyone know of any good resources/tutorials/guides on rasterization in OpenGL?

Maybe I should clarify more: Im talking along the lines of calling openGL to draw
individual pixels one at a time, or creating a pixmap in memory without calling OpenGL, and then putting the pixmap in the screen buffers with a single OpenGL call.

MikeC
10-21-2004, 03:18 PM
OpenGL isn't really suitable for what you want to do; it doesn't support direct access to the framebuffer. There are good reasons for this. Early versions of D3D did provide such access, but it hampered implementors so much (the linear memory layout assumed by most pixel-poking isn't the best format for hardware acceleration) and Microsoft had to take it out.

If you're really set on the idea, the two main approaches would be

a) Set up an orthographic projection matrix mapping viewport coords 1:1 to pixels, then send pixels as GL_POINTS, or

b) Write to local (non-GL) buffers, then draw them using either glBitmap or one of the texturing commands.

Either way, though, you'll be spending considerable effort trying to bash a square peg into a round hole. Maybe you'd be better off with something like OpenPTC instead.

Deiussum
10-26-2004, 07:03 AM
Another option might be to draw stuff like your Bressenham's algorithm to a texture, and then display it as a texture mapped quad.

Edit: Oops.. maybe I should have read option b a bit closer. :)