PDA

View Full Version : simple 2d



05-27-2002, 06:42 AM
OpenGL is a great lib for 3d-stuff, but is it possible to simply draw a pixel on the screen? I could create a triangle like (1,1,1)(1,1,1)(1,1,1) but I think it's quite uneffective.

Thanks for your help

Morglum
05-27-2002, 08:42 AM
If you only want to draw 1 point, just do a GL_POINT. If you want to draw many, it would be more efficient to prepare an offscreen bitmap and to display it as a textured quad or with glBitmap or glDrawPixels (don't know which one is faster-just try). But then, of course, you don't get hardware acceleration while preparing the bitmap.

Jambolo
05-27-2002, 12:58 PM
OpenGL is not meant to work on the pixel level, but you can -- by setting the size of the view window to be the same as the viewport. There is a small complication in the precise location of a pixel but you should be able to figure that out.

[This message has been edited by Jambolo (edited 05-28-2002).]

05-27-2002, 04:12 PM
The way to go to do pixelgraphics is generally to draw textured quads . Use your own bitmap to draw onto and upload the bitmap changes to the textures.

If you look up the specs(something like glTexparameteri) you will find that you can specify where from a bitmap you will send the texture data.

Draw the Quads using orthographic projection(set it up to the screen dimensions)
to achieve a texel to pixel match. If i remember correctly you will have to adjust the coordinates of the quads by -0.5.

mikael_aronsson
05-27-2002, 11:32 PM
Nope, it's 0.3...something, the FAQ on this website has the correct value.

Mikael