I need some help. I am using the GPGPU basic_math_tutorial_cg tutorial from dom as a basis to develop a multipass rendering algorithm. The issue I am having is on the 3rd rendering pass the texture coordinates that are generated are wrong. To fetch the information from the GPU I store texture.x, texture.y, wpos.x, wpos.y in the four color components and then use a glReadPixels to retrieve the information. Some of the contents are (format: (x,y) = (r,g,b,a) –
(1,255) = [130.422,126.755,1.5,255.5]
(2,255) = [130.407,126.755,2.5,255.5]
...
(15,255) = [130.209,126.755,15.5,255.5]
(16,255) = [130.194,126.755,16.5,255.5]
I specify the texture mapping to be 1 to 1 texel to pixel. In the previous rendering pass I get the correct texture coordinates.
On the third rendering pass I changed the ModelView and Projection matrix so I can merge 3 textures together. The viewport stays the same.
The pertinent code is:
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glOrtho(-m_pixelWidth/2, m_pixelWidth/2, -m_pixelHeight/2, m_pixelHeight/2, -10.0, 10.0);
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// merge the results from the three textures
// 1 texel = 1 pixel mapping
glColor3f(5.0,0.0,0.0);
glBegin(GL_QUADS);
glTexCoord2f(0, 0);
glVertex2f(-m_pixelWidth, -m_pixelHeight);
glTexCoord2f(m_pixelWidth, 0);
glVertex2f(m_pixelWidth, -m_pixelHeight);
glTexCoord2f(m_pixelWidth, m_pixelHeight);
glVertex2f(m_pixelWidth, m_pixelHeight);
glTexCoord2f(0, m_pixelHeight);
glVertex2f(-m_pixelWidth, m_pixelHeight);
glEnd();
glFinish();
Thanks for reading this. I am stumped as to why the texcoord are off. Any insight will be greatly appreciated?
Thanks,
Aaron