Jump to content


glReadPixels


1 reply to this topic

#1 me_here_me

    New Member

  • Members
  • PipPip
  • 24 posts

Posted 10 July 2007 - 03:52 PM

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_RGBA,pdata);

any hints to the problem

thanks in advance

#2 me_here_me

    New Member

  • Members
  • PipPip
  • 24 posts

Posted 11 July 2007 - 02:21 PM

sorry for bothering, it was a syntax error that I was overlooking all the time:

it should have been:
glReadPixels(0,13,fbWidth,1,GL_RGBA,GL_UNSIGNED_SHORT,pdata);






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users