PDA

View Full Version : is there any metho to save a texture into an image



shapeare
06-20-2011, 11:39 PM
I used glTexImage2D to construct a texture from a matrix:



float myMatrix[Height][Width][4];
... ...
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
GL_LINE );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,
GL_LINE );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );

glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, Width, Height,
0, GL_RGBA, GL_FLOAT, myMatrix);




How can I check if the values of myMatrix have been correctly saved into this texture?

BTW, is there any wrong with the parameters for glTexParameteri?

fenbf
06-21-2011, 02:32 AM
What is purpose of the code? what is that matrix?

- MIN & MAG Filter: it should be GL_LINEAR... or meybe GL_NEAREST if you are performing some computation not rendering

how can you check values?
- just render that texture and by its coulour you coul gess are those values are good or wrong. That is simple method.
- you can use gEDebugger to check data that you have on the GPU

shapeare
06-21-2011, 02:41 AM
What is purpose of the code? what is that matrix?
that matrix saves the values of a 2D function, I want to send that texture to a shader and do some computation there.


And I have difficulty in understanding the internal format and format, which indicates the format of the texture?

fenbf
06-21-2011, 03:54 AM
so maybe you should use OpenCL instead of OpenGL. They both work well with each other.