Skip to main content
gamedev.net
🔒 Locked

glDrawPixels

Started by SteQve 5 replies 2.9k views
Original Post
SteQve
SteQve
I load a bitmap from file, and when i render it with glDrawPixels it is upside down. I guess that's because I have set the ortho "upsidedown", although I need that ortho setup. Is there any glEnable or other setting that causes glDrawPixels to decrease y instead of increase? Best regards Stefan (SteQve)
Brother Bob
Brother Bob
OpenGL assumes that the data is stored bottom up, and you have probably loaded you image top down. Meaning, OpenGL expectes the first row in memory to be the bottom row of the image, while the first row of your image data is the top row of the image.

So either load the image bottom up, or flip the image using glPixelZoom(1, -1).
SteQve
SteQve

Okay, thanks for all help guys! So..of course there is just one little problem left. The image I have loaded is a 8bpp 256colour bitmap. I just can't figure out which format constant to use to get it right. For now I use GL_BLUE...and all is blue =)

How can I solve the problem?
Kalidor
Kalidor
Try GL_LUMINANCE?
Brother Bob
Brother Bob
That depends on what 8-bit format it is. If it'a a greyscale image, then GL_LUMINANCE is what you want. If it's a paletted image, you can either reconstruct an RGB image yourself, or look into the color lookup step in the imaging subset. Check out the specification, section 3.6, for information about the pixel path and it's steps in OpenGL.
SteQve
SteQve


Is it possible to change the form ov the picture? Like a texturemapper. Say that I wan't to draw the bitmap (rectangle) in a triangle.

Is it possible or do I have to bind it as a texture and then display it?
Brother Bob
Brother Bob
If it's a simple shape like a triangle, then a texture mapped triangle is probably the easiest way. You can also use the stencil buffer as a mask if you can get the shape into the stencil buffer.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.