Jump to content
  • Advertisement
Sign in to follow this  

OpenGL Reading Pixel Data From Texture

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

Anyone know how to read pixel data from a textureId? I have a texture that I've created from the current frame buffer like so:
// Create OpenGL textures
glGenTextures( 1, &textureId );
imageData = ( GLubyte* )malloc( width * height * 4 );
memset( imageData, 0, ( width * height * 4 ) );
if( imageData )
    glBindTexture( GL_TEXTURE_2D, textureId );
    glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, imageData );
    free( imageData );
    glBindTexture( GL_TEXTURE_2D, textureId );
    glCopyTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, 0, 0, width, height );

Once I've copied my current framebufer image to this texture, is it possible to then grab the pixel data at a later time using textureId? Thanks!

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!