Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 7 of 7

Thread: glReadPixels problems again

  1. #1
    Junior Member Newbie
    Join Date
    Feb 2000
    Location
    The Netherlands
    Posts
    16

    glReadPixels problems again

    I have a textured scene and I read the frame buffer using:

    glReadPixels (0, 0, winWidth, winHeight, GL_RGB, GL_UNSIGNED_BYTE,
    frameBuffer);

    Than I write them in TGA format and mostly everything is OK. Mainly I
    get the correct images.

    Anyway if I change only the texture files - sometimes only rotate a
    texture image in an external program- I get distorted images (starting
    from below some parts are good and than some are shifted in horizontal
    direction).
    1. something strange is happening inside glReadPixels?
    2. it is hardware-dependent - I get differently distorted images on
    different computers

    Thank you for your wish to help me but it doesn't work!
    1. glFlush has nothing to do with it but I
    tried it anyway!
    2. the same for glPixelTransfer!

    Two more conclusion from the tests I made:
    1. The problem occures ONLY for textured images (and not always as I
    have already described)!
    2. The glCopyPixels is working properly so the problem is in transfering
    the data into the processor memory!
    I have set GL_PACK_ALIGNMENT to 1 (glPixel Store) but that doesn't help
    also!
    I don't see any solution ?

    Please HELP!!!

  2. #2
    Advanced Member Frequent Contributor
    Join Date
    Feb 2000
    Location
    London
    Posts
    503

    Re: glReadPixels problems again

    Just to clarify something - are you sure that it's the glReadPixels causing the problem, rather than the TGA writing code? If you write the pixels straight back to the framebuffer, do you see the same distortion?

  3. #3
    Junior Member Newbie
    Join Date
    Feb 2000
    Location
    The Netherlands
    Posts
    16

    Re: glReadPixels problems again

    The problem occurs also undes some other views at the scene.
    As I wrote , the glCopyPixels works perfectly so the problem is in transfering
    the data to processor memory. Somehow some values from the framebuffer can not
    be properly converted and transfered to the memory? Also not the whole image is
    distorted but only parts of the image.

    I have just tried to do glReadPixels and than glWritepixels - the image is not
    distorted but it gets darker. I have to think about that.

  4. #4
    Junior Member Newbie
    Join Date
    Feb 2000
    Location
    The Netherlands
    Posts
    16

    Re: glReadPixels problems again

    Look Mike, as I wrote the problem can occur when I just rotate a texture image that is loaded and don't change the program. I mainly get good images so it doesn't seem logical to that there is a problem is saving the TGA file since it mostly works good.

  5. #5
    Intern Contributor
    Join Date
    Feb 2000
    Location
    Italy
    Posts
    77

    Re: glReadPixels problems again

    Do you wear glasses??

    What you said isn't comprehensible to my knowledge...
    --
    Paolo M.

  6. #6
    Junior Member Newbie
    Join Date
    Feb 2000
    Location
    The Netherlands
    Posts
    16

    Re: glReadPixels problems again

    OK, maybe I was not completely clear but I'll continue.
    If I do

    glReadPixels
    glDisable(GL_TEXTURE_2D)
    glWritePixels
    glEnable..

    It works fine...
    So the problem is somewhere in saving it to disk. But I can't see what could that be, and why it should not work only sometimes.
    Finally, I think that problems occur only when I use GL_MODULATE for the texture mapping (and of couse some lights).
    It seams like there are some pixels that are converted into some format known only for the openGL (for example something like Not aNumber) and that when I write it to disk (a simple proces - there can't be many errors here) it is distorted because I expect 3 GLBytes for per pixel.

  7. #7
    Guest

    Re: glReadPixels problems again

    maybe you were getting 4?

    ie..

    glReadPixels(0,0,640,480,GL_RGBA,GL_UNSIGNED_BYTE, surface);

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •