Not logged in, Join Here! or Log In Below:  
 
News Articles Search    
 

 Home / Game Design & Programming / OpenGL C++ - getting the content of a texture Account Manager
 
Archive Notice: This thread is old and no longer active. It is here for reference purposes. This thread was created on an older version of the flipcode forums, before the site closed in 2005. Please keep that in mind as you view this thread, as many of the topics and opinions may be outdated.
 
leo77

February 25, 2005, 12:41 PM

Hi all...

I gess this is kind of a newbie question, but here is my problem:

I am making a program that uses the result of another program (built by someone else, that I am adding to my one, copying the classes and changing it if I need) to draw pixels as a final result. The program (the one built by someone else) "sends me" only a texture id - actually, it originally displays this texture in a polygon - and I want to get the values of each pixel of this texture without display it (and without using vertex or fragment shaders).
If it makes more clear, I want to acsses this texture as if it was a matrix of bytes without display it... How can I do that?

thanks in advance

Leo

 
Nico

February 25, 2005, 03:31 PM

Try

glBindTexture(GL_TEXTURE_2D, texture);

//get texture size
GLint width, height, border;
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &width);
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &height);
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_BORDER, &border);
width -= border; height -= border;

//get texture as rgba
char* buff = new char[width*height*4];
glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, buff);

hope this works...

 
Nico

February 25, 2005, 04:03 PM

Leave the border stuff out, it is wrong...just get width and height (border is 0 for most cases anyway, so most of the time it won't matter :-|)

 
Reedbeta

February 25, 2005, 04:27 PM

That should be
width += 2*border; height += 2*border;

 
This thread contains 4 messages.
 
 
Hosting by Solid Eight Studios, maker of PhotoTangler Collage Maker.