View Full Version : glDrawPixels affected from texturing?

11-03-2008, 12:13 AM
I observed that, on some OpenGL drivers when texturing is enabled pixel level draw functions (glDrawPixels, glBitmap and probably the others) are textured with the active texture.

The below code draws a blue drawpixels rectangle, regardless of the pixels parameter glDrawPixels takes.

// set the first pixel color to blue



glDrawPixels(256,256,GL_RGB,GL_UNSIGNED_BYTE,bitma p);

However, this is not a common behaviour.
On Windows platform,
Intel 965 draws both glBitmap and glDrawPixels as textured,
MESA (soft renderer) just draws glBitmap as textured,
ATI 4850 draws none of them as textured

I thought only primitives are textured in OpenGL. However, I could not find any documentation about this behaviour. It does not seem to be a part of a functionality with purpose maybe a bug.

Is it possible that those pixel level functions implicitly using textures to transfer data? or
Is there any idea for the usage of the textured pixels on the field?

11-03-2008, 09:01 AM
do you use glColor() function somewhere? this modifies any color. before drawing your objects try setting it to glColor3f(1.0f,1.0f,1.0f);

11-03-2008, 09:55 AM
See the DrawPixels man page (http://opengl.org/sdk/docs/man/xhtml/glDrawPixels.xml), where it says:

"These pixel fragments are then treated just like the fragments generated by rasterizing points, lines, or polygons. Texture mapping, fog, and all the fragment operations are applied before the fragments are written to the frame buffer."

11-04-2008, 03:35 AM
I use glColor. However I also GL_DECAL tex. env. mode. Therefore, texture color is not affected from the current color.

Yeah I know it is written like that in Bluebook.
However it still doesn't make sense. Because if pixels drawn by glDrawPixels can be textured then how can you map a texture with the correct tex. coordinates. I mean you cannot change the tex. coordinates inside the glDrawPixels call (cannot map edge coordinates of a 2D texture).

Therefore, I just want to understand if there is a practical use for the textured glDrawPixels.

Anyone has a suggestion for the use of the textured glDrawPixels in practice?

11-04-2008, 05:17 AM
OpenGL is a state machine so the last texture coordinate is used, no interpolation.

11-04-2008, 07:05 AM
Maybe the pixels of glDrawPixels are used as the texture. In this case, no texture coordinates are needed.

11-04-2008, 08:41 PM
In practice, no, I don't think this is very useful at all.

I can see people using fog, and raster ops like depth test with drawpixel'd labels in 3D graphing applications.

The state machine allows you to leave shaders and texturing enabled, so you could use a constant texel value to i.e. tint, or maybe animate a glow over the drawpixel data, but that's stretching it-- I've never seen an app use textured drawpixels on purpose ;)

And you can certainly do this much more efficiently with regular textured quads.

12-17-2008, 12:12 AM
I figured out that glDrawPixels is implemented in our driver (an embedded system ATI driver) by drawing a set of point vertices on the given coordinates. Therefore, this behaviour makes sense even if it does not have an intended usage. This is a side effect.

12-18-2008, 09:29 PM
It should apply texturing to glDrawPixels for sure. I'm not so sure about glBitmap. Basically, glDrawPixels takes the pixel data and generates a fragment for each incoming pixel. The color of the pixel is the gl_Color for the fragment.