GlDrawPixels
lastmod 2021-05-08created 2021-05-083 edits
Speeding up glDrawPixels or glCopyPixels
- http://cafe.naver.com/javacircle/27681
- http://personal.redestb.es/jmovill/opengl/openglonwin-31.html#MARKER-9-76
When I tried the glDrawPixels function, its speed varied with the computer's hardware specs (graphics card). Apparently this is because every call to glDrawPixels reads the pixel data passed as an argument into memory and then outputs it to the video card again. (It doesn't seem to be cached internally in a graphics buffer or anything...) Searching Google turned up the tip below, but when I actually tried it, I couldn't really notice a speedup.
/*
* 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 is
* already set correctly.)
*/
glDisable(GL_ALPHA_TEST);
glDisable(GL_BLEND);
glDisable(GL_DEPTH_TEST);
glDisable(GL_DITHER);
glDisable(GL_FOG);
glDisable(GL_LIGHTING);
glDisable(GL_LOGIC_OP);
glDisable(GL_STENCIL_TEST);
glDisable(GL_TEXTURE_1D);
glDisable(GL_TEXTURE_2D);
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 omitted that code for simplicity.)
*/
#if GL_SGI_index_func
glDisable(GL_INDEX_TEST_SGI);
#endif
See also
- OpenGL
- glCopyPixels