View Full Version : glDrawPixels problem
07-04-2005, 03:25 AM
Bottom left of my bitmap falls out of the viewport and glDrawPixels does not draw the image. Is there any workaround for this problem?
07-04-2005, 03:41 AM
This is normal. The raster position is invalid and the whole pixel operation is omitted.
The simple workaround is to look for the availability of the extension
If it's there, you can disable the clipping and raster positions outside the view will still render and the part which comes into view will be drawn.
If it's not there, you need to do your own clipping calculations or use screen aligned textured quads.
07-04-2005, 04:07 AM
Thanks for the tip. I will check that. I have another question:
What I am trying to do is to draw the visible portion of a tiled tiff on the screen. The user will be able to pan, zoom. I am currently doing this by drawing each tile on a quad. I am curios about the performance. If I use glDrawPixels, will it be faster? Because building the texture from the buffer takes some time (I use gluBuild2DMipmaps). Are there any other options to increase the performance?
07-04-2005, 04:24 AM
glDrawPixels is a 2D operation which sources data from the system memory. You should disable depth test to make sure it doesn't use the glRasterPos's z value.
It is a pixel operation and will not be able to filter your image if you want to zoom in and out, but just behaves like nearest filtering textures.
That said, downloading the whole image as texture tiles and stitching them together with tiled quads will probably be much faster once the texture data is downloaded.
I wouldn't use gluBuild2DMipmap in a performance critical path. It's all software scaling.
You can use autogeneration of mipmaps by the driver with the extension
Enable it and download the level of detail 0 and it the driver should do it for you.
In your case mipmaps are only useful if you zoom out and want to get better quality.
When tiling images together with textured quads, you should make sure you don't sample outside of the texture. You could use nearest filtering for pixel operations like this.
If you use linear filtering you need to either set the wrap modes to GL_CLAMP_TO_EDGE or download texture border texels (some implementations don't support borders in hardware!) to avoid filtering the texture border color (default black). Otherwise you will get ugly stitch marks between your tiles.
For a glDrawPixels like behavior download only the LOD 0 of the texture and use GL_NEAREST filtering for min and mag filters.
07-04-2005, 10:45 AM
How can I use this SGIS_generate_mipmap extension? I am new to OpenGL. Do I have to install something? Any sample code available?
Call this when specifying your texture, before calling glTexImage2D (target).
GL_TEXTURE_2D, // Texture target (no rects!)
GL_GENERATE_MIPMAP_SGIS, // Only need this enum
true or false // Bool on or off
07-04-2005, 09:57 PM
You can use this if the extension is advertised in the glGetString(GL_EXTENSIONS) or if you have an OpenGL 1.4 or better glGetString(GL_VERSION).
It went into the core functionality with version 1.4 and the parameter is just named GL_GENERATE_MIPMAP then.
If you don't have gl.h or glext.h headers containing these, get an OpenGL SDK from your graphics board vendor's developer support site or download official headers from
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.