Skip to content

Instantly share code, notes, and snippets.

@Trass3r
Created September 26, 2013 12:13
Show Gist options
  • Save Trass3r/6713302 to your computer and use it in GitHub Desktop.
Save Trass3r/6713302 to your computer and use it in GitHub Desktop.
quickly dump OpenGL texture
glBindTexture(GL_TEXTURE_2D, textureID);
glPixelStorei(GL_PACK_ALIGNMENT, 1);
GLint width, height, level = 0;
glGetTexLevelParameteriv(GL_TEXTURE_2D, level, GL_TEXTURE_WIDTH, &width);
glGetTexLevelParameteriv(GL_TEXTURE_2D, level, GL_TEXTURE_HEIGHT, &height);
std::unique_ptr<unsigned short[]> data(new unsigned short[width * height]);
glGetTexImage(GL_TEXTURE_2D, level, GL_RED, GL_UNSIGNED_SHORT, data.get());
glPixelStorei(GL_PACK_ALIGNMENT, 4);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment