Accessing Texels..

Started by
2 comments, last by V-man 16 years, 4 months ago
Hi, Suppose I use FBO to render the resulting color to a texture (because of some reasons, I am unable to use RenderBuffer), how do I access each texel of the resulting texture ? Thanks.
Advertisement
Use the FBO as a render to texture. Access the texture in your shader with
vec4 texel = texture2D(tex, gl_TexCoord[0].xy);


or if you want to read back the FBO use glReadPixels
or to read back from the texture glGetTexImage
Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);
Thanks.
BTW, last question, can I access and modify the interpolated depth value in the fragment shader of Cg ?
You should be able to since it is available in GLSL. I don't use Cg.
Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);

This topic is closed to new replies.

Advertisement