me_here_me
07-10-2007, 08:52 AM
I am producing an image through a fragment shader and then I want to read the 13th line of the produced image into an array using glReadPixels() method. Somehow this does not work and at the end of my program all the elements of the array called pdata are set to 52685.
This is how I am setting up the texture and the FB:
glGenTextures(1, &txRayProfile);
glGenFramebuffersEXT(1, &fbRayProfile);
glBindTexture(GL_TEXTURE_2D, txRayProfile);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA,
fbWidth, fbHeight, 0, GL_RGBA, GL_UNSIGNED_SHORT, 0);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbRayProfile);
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
GL_TEXTURE_2D, txRayProfile, 0);
I am writing on the FB from the fragment shader using: gl_FragCoord(r,g,b,a) method
the image when displayed onto the screen shows the right image. BUT, When I try to read in the 13 line of the image in an array, it does not retrieve that. The code is as below:
unsigned short* pdata = new unsigned short[fbWidth * 4]; // 4 is for RGBA
glReadPixels(0,13,fbWidth,1,GL_UNSIGNED_SHORT,GL_R GBA,pdata);
any hints to the problem
thanks in advance
This is how I am setting up the texture and the FB:
glGenTextures(1, &txRayProfile);
glGenFramebuffersEXT(1, &fbRayProfile);
glBindTexture(GL_TEXTURE_2D, txRayProfile);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA,
fbWidth, fbHeight, 0, GL_RGBA, GL_UNSIGNED_SHORT, 0);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbRayProfile);
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
GL_TEXTURE_2D, txRayProfile, 0);
I am writing on the FB from the fragment shader using: gl_FragCoord(r,g,b,a) method
the image when displayed onto the screen shows the right image. BUT, When I try to read in the 13 line of the image in an array, it does not retrieve that. The code is as below:
unsigned short* pdata = new unsigned short[fbWidth * 4]; // 4 is for RGBA
glReadPixels(0,13,fbWidth,1,GL_UNSIGNED_SHORT,GL_R GBA,pdata);
any hints to the problem
thanks in advance