Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Slowdown with the glDrawPixels function

This topic is 6089 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, the usage of the glDrawPixels function really slows down my program. If I call only this function I get only 6 frames/second. It draws only a small 256x256 RGB image. Does anyone of you know if this is normal? If it is normal, I''ve a possible explanation. Every time I call this function the data has to be transfered from the main memory to the graphic card, while if you use a texture instead, it is hold in the texture memory of the card. But could that be !so! slow?? I mean, it are only 192kB that must be transfered. If that slows down so much, the drawPixels routine isn''t a good thing to do frequently, is it? I could use the accumulation buffer to speed up things I think, but that would restrickt me to only a few images. I''ve tried to use texturing on a quad instead of glDrawPixels, and the framerate jumped to 960!! Little difference, isn''t it? An ideas, solutions, comments or questions are welcome. Greetings Ben P.S. I''ve a AMD 1GHz, with an ATI Radeon 32 MB DDR, the image is loaded from the hard disk only in the init function, and it isn''t scaled rotated or anything else. P.P.S a funny thing is that after I''ve added some more drawing stuff, that does something that is expensive, like blending, and a little bit scaling, the framerate raised to 10 frames, even so the code completly appeared after the drawing of the bitmap

Share this post

Link to post
Share on other sites
Is the card fully DX8.0a compatable? Does it have new drivers? Some else I''ve found on the net:

OpenGL pixel operations have a much richer set of features than
IrisGL, and if any of those features are enabled, then image transfer
can be significantly slower. Always disable the features that you
don''t need. The following code fragment disables features that are
likely to make glDrawPixels slow:

* Disable stuff that''s likely to slow down glDrawPixels.
* (Omit as much of this as possible, when you know in advance
* that the OpenGL state will already be set correctly.)
glPixelTransferi(GL_MAP_COLOR, GL_FALSE);
glPixelTransferi(GL_RED_SCALE, 1);
glPixelTransferi(GL_RED_BIAS, 0);
glPixelTransferi(GL_GREEN_SCALE, 1);
glPixelTransferi(GL_GREEN_BIAS, 0);
glPixelTransferi(GL_BLUE_SCALE, 1);
glPixelTransferi(GL_BLUE_BIAS, 0);
glPixelTransferi(GL_ALPHA_SCALE, 1);
glPixelTransferi(GL_ALPHA_BIAS, 0);

* Disable extensions that could slow down glDrawPixels.
* (Actually, you should check for the presence of the proper
* extension before making these calls. I''ve omitted that
* code for simplicity.)

#ifdef GL_EXT_convolution

#ifdef GL_EXT_histogram

#ifdef GL_EXT_texture3D

Share this post

Link to post
Share on other sites
anything with the word "pixel" in it in opengl is slow. there is an old myth that says that opengl uses a glColor and a glVertex call (in point mode) for every pixel, but i''m not sure how truthful that is though. still, 256*256*3 color and vertex calls would definatly slow things down a bit


Share this post

Link to post
Share on other sites
My advice : forget glDrawPixels(). Just use textured quads to display your images. This will be much faster, even with cool effects (blending, linear interpolation, etc...) done by the 3D card.

Share this post

Link to post
Share on other sites
The OGL pixel functions are damn slow, there are many better ways to go about doing things! So... as MENTAL stated... DON''T USE ANYTHING WITH THE WORD ''pixel'' IN IT! Well... any glPixel type calls that is.

Trent (ShiningKnight)
E-mail me
ShiningKnight Games

Share this post

Link to post
Share on other sites

sorry for not replying until now, but my network was down :-(
Thanks for your answers. So I now know that this not my mistake, that''s very much.
And to Bump Lens, I don''t know if my card is fully DX8 compatible. I''ve shortly installed the DX8 drivers, together with the newest drivers of my card. This slowed down my TV capturing stuff so much that I''ve decided to reinstall the old drivers, but keeping DX8.

Thanks Ben

Share this post

Link to post
Share on other sites
Hello Bump Lens,

I''ve tested your changes, but it seems it didn''t raised the framerate at all :-(
The ext stuff is not known by the standard gl library, and cause I didn''t had anything else I couldn''t test that part of code, but I guess it wouldn''t make a difference either.
I''ve replaced the code by drawing a textured square in an ortho view, that has the same result, and is 100times faster (not exaggerated).

Greetings Ben

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!