Hi,

I am trying to get texture coordinate that be mapped into that pixel as output to FBO.
This is what I do ,
1. Gen FBO and bind with a texture RGBA32F format and GL_COLOR_ATTACHMENT0.
2. When rendering,
Code :
glCullFace(GL_BACK);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LESS);
glClearDepth(1.0f);
glClearColor(1.0f,1.0f,1.0f,0.0f);
glClear(GL_COLOR_BUFFER_BIT |  GL_DEPTH_BUFFER_BIT);
glBindFramebuffer(GL_FRAMEBUFFER, m_fboUVMap);	
glUseProgram(m_program);	
DRAW();
glUseProgram(0);	
 
while (glCheckFramebufferStatus(GL_FRAMEBUFFER) !=  GL_FRAMEBUFFER_COMPLETE )
{
 
}
float result[4] = {0.0f,0.0f,0.0f,0.0f};
glReadPixels(x,y,1, 1, GL_RGBA,GL_FLOAT,result);

Code :
//Vertex Shader 
void main(void)
{
   gl_TexCoord[0] = gl_MultiTexCoord0;
   gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
}
 
//Fragment Shader
void main(void)
{
  gl_FragColor = vec4(gl_TexCoord[0].x,gl_TexCoord[0].y, 0.5 ,1.0);
}


The output "float result[4]" looks fine mostly.
The problem is sometimes I got texture coordinates from a polygon that should be behind others, some kinds of depth test problem.
(every vertex has unique texture coordinates)
Do you have any idea , what I am doing wrong?

Thank you