Pixel data from texture?
Does anyone know how/if I can read the pixel data of a texture in OpenGL?
I want to check my render-to-texture stuff is working, but all the commands I can see are for putting data *into* textures..?
If you want the pixel data without passing the texture to the graphics card and wasting space you can take the data pointer (from whatever you use to load the texture) and then iterate through it and delete it before passing it on.
Ah, the FBO stuff did it... ta!
umm not too sure what you meant there, daniel...
glReadBuffer(GL_COLOR_ATTACHMENT0_EXT);char readBuff[texSize*texSize*3];glReadPixels(0,0,texSize,texSize,GL_RGB,GL_UNSIGNED_BYTE,readBuff);
umm not too sure what you meant there, daniel...
Quote:Original post by Nathan Baum
You can also use glGetTexImage
Tsk - I actually looked through the Red Book for something like this and never saw it :o
Must prioritise sleep over gamedev some time :-/
[Edited by - Aph3x on March 5, 2007 5:10:56 AM]
Quote:Original post by Aph3x
umm not too sure what you meant there, daniel...
When you load a texture you call the following commands:
GLuint texture;Texture = LoadPicture("pic.bmp"); //whatever you load the pic withglGenTextures(1, &texture); glBindTexture(GL_TEXTURE_2D, texture);glTexImage2D(GL_TEXTURE_2D, 0, 3, Texture->sizeX, Texture->sizeY, 0, GL_RGB,GL_UNSIGNED_BYTE, Texture->data);free(Texture->data);
Now if you only want the data without actually generating a texture you can skip everything except the first line and use TextureData->data and the free it.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement