Jump to content
  • Advertisement
Sign in to follow this  
DarkCybo1

OpenGL What is the fastest way of taking a screenshot in OpenGL?

This topic is 4838 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

GLuint GetPixelBuffer(int x, int y, int w, int h) { unsigned char* pixels = new unsigned char[w * h * 4]; glReadPixels(x, y, w, h, GL_RGBA, GL_UNSIGNED_BYTE, pixels); GLuint texture; glGenTextures(1, &texture); glBindTexture(GL_TEXTURE_2D, texture); gluBuild2DMipmaps(GL_TEXTURE_2D, 4, w, h, GL_RGBA, GL_UNSIGNED_BYTE, pixels); delete [] pixels; return texture; } That's my current method, but it's slow as heck and returns the texture upside down.

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
glCopyTexImage2D() is the fastest copy way to do it. No mipmaps though.

If you want it to be fast, use ARB_framebuffer_object extension and do a render to texture (Setup with teximage2D, then attach texture to a framebuffer object with TextureFramebuffer(), bind back the default frame buffer object, and render with texture).

Share this post


Link to post
Share on other sites
If you ever need to save the screeshot to a file, I think you will need the first one. If you don't, I recommend the anony poster's method.

Share this post


Link to post
Share on other sites
gluBuild2DMipmaps is a very slow function GSIS_GENERATE_MIPMAP is about 10x quicker
but yeah as the AP saiz FBO is the fastest way

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!