displaying a saved buffer in OpenGL ES

Posted by Adam on Stack Overflow See other posts from Stack Overflow or by Adam
Published on 2010-06-02T00:45:59Z Indexed on 2010/06/02 1:13 UTC
Read the original article Hit count: 253

Filed under:
|
|
|

Hi everyone, So basically I have a screenshot that I've saved that I want to later display on the screen. I've saved it with:

glReadPixels(0, 0, self.bounds.size.width, self.bounds.size.height, GL_RGBA, GL_UNSIGNED_BYTE, savedBuffer);

And later I'm trying to write it to the screen with:

GLuint RenderedTex; 
glGenTextures(1, &RenderedTex); 

glEnable(GL_TEXTURE_2D); 
glBindTexture(GL_TEXTURE_2D, RenderedTex);
glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, self.bounds.size.width, self.bounds.size.height, 0, GL_RGBA, GL_UNSIGNED_BYTE, savedBuffer);
glDisable(GL_TEXTURE_2D);

I'm pretty new to OpenGL so I don't know if I'm doing things right... actually I know I'm not, because nothing shows up. Also not sure how to dispose of the texture when I'm done with it. Anyone know the correct way to do this?

Edit: I think I might be having a problem loading the texture because it's not a power of 2, it's 320x480... also, I think this code is just loading the texture, but not drawing it, I'd need a call to glDrawArrays(GL_TRIANGLE_STRIP, 0, 4) in there somewhere...

© Stack Overflow or respective owner

Related posts about opengl

Related posts about opengl-es