Skip to main content
gamedev.net
🔒 Locked

Texture reading

Started by Promag 2 replies 450+ views
Original Post
Promag
Promag
I have set a frame buffer object with a color attachment and depth attachment as textures. All worked fine but when I try to read back (glGetTexImage) the texture (color attachment) pixels it returns all black. I also try to read the pixels from the binded read buffer witch I've set as being the same as the color attachment. Furthermore, i render a quad with the texture binded and it works fine. My questios is why can't I read back the pixels. Texture creation: glBindTexture(GL_TEXTURE_2D, textures); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16, width, height, 0, GL_RGBA, GL_FLOAT, NULL); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, attachments, GL_TEXTURE_2D, textures, 0); Texture fetch: glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, textures); glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_FLOAT, pixels); glDisable(GL_TEXTURE_2D); Thanks! João Barbosa
Gorax
Gorax
Assuming 'pixels' is an array of type 'GLfloat', with the length being 'width' * 'height' * 4, it should work fine. If that's not the problem, and you're not changing Open GL contexts, there shouldn't be any problems...
Promag
Promag
Well i had it like you said.. :S only had float instead of GLfloat but anyway it still showing all black.. Btw, im showing with:

glRasterPos2f(50,100);
glDrawPixels(640,480, GL_RGBA, GL_FLOAT, pixels);

What do you mean by "changing Open GL contexts"? because i thing i'm not doing it.

Thanks!
João Barbosa
_the_phantom_
_the_phantom_
It does say in the various things I've read about it to avoid using glGetTexImage() and related functions. I'm guessing the drivers dont have that corner case implimented yet.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.