   opengl PBUFFER + Copy to texture
  hihi ok, i was playing with the pbuffer today.i tried to use it to get a color value from a Cg fragment program.1)activate pbuffer2)i created a blank texture(using GL_TEXTURE_RECTANGLE_NV)  using the pbuffer    GLuint __pin* tex = &m_textureID;glGenTextures(1, tex);glBindTexture(GL_TEXTURE_RECTANGLE_NV, m_textureID);glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_MIN_FILTER, GL_LINEAR);glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_MAG_FILTER, GL_LINEAR);glTexImage2D(GL_TEXTURE_RECTANGLE_NV, 0, GL_FLOAT_RGBA_NV, 16, 16, 0, GL_RGBA, GL_FLOAT, NULL);3)setup usual projection...4)deactivate pbufferthen during the first render,1)i activate pbuffer2)bind fragment programs + draw geometry3)copied to blank texture using pbuffer glBindTexture(GL_TEXTURE_RECTANGLE_NV, m_textureID);glCopyTexSubImage2D(GL_TEXTURE_RECTANGLE_NV, 0, 0, 0, 0, 0, m_width, m_height);//here: HOW do i get the copied image out?float testdata[256];glBindTexture(GL_TEXTURE_RECTANGLE_NV, m_textureID);glGetTexImage(GL_TEXTURE_RECTANGLE_NV, 0, GL_RGBA, GL_FLOAT, testdata);How to inspect the data inside of the copied image?readpixels crashes, somehow i need to obtain a pointer to the copied image, so i tried GetTexImage, but it crashes as well.Any suggestions?thx!Edwinz[edited by - edwinnie on May 26, 2004 9:05:04 AM][edited by - edwinnie on May 26, 2004 9:05:44 AM]
  I''ve been experimenting with per-pixel special effects, and as far as I can tell, glReadPixels works best. First of all, your testdata variable needs to be a pointer to an array of the size you''re wanting. The size you''re wanting also needs to be the size of:IMAGE WIDTH * IMAGE HEIGHT * PIXEL DEPTH * sizeof(DATA FORMAT)You''re also best off (in my experience) storing the data as GLubytes, so each color value only takes up 0-255 (depending on the color depth, that is it for 32-bit anyway). So in this case, it would be:GLubyte *testdata = new GLubyte[16*16*4*sizeof(GLubyte)];glReadPixels (0, 0, 16, 16, GL_RGBA, GL_UNSIGNED_BYTE, testdata);That should create a pointer to an array large enough to hold the image''s data. Basically, I think you''re just forgetting to include the number of color values too (red, green, blue, alpha = 4). You''re allocating enough space for just one component (thus 3 components too small!) So in the case of your code, the size of the testdata array should be 1,024, not 256.  hope this helps!-= soniCron =- ;  hi there!thx fer replying! actually i did managed to figure that out...too small an array was allocated, and somehow using breakpoints screws up, even though i can jus log the values obtained by glReadPixels.then in end, i jus use the image debugger.thx!Edwinz 