Results 1 to 4 of 4

Thread: glReadPixels gives only black...

  1. #1
    Member Newbie
    Join Date
    Nov 2002
    Posts
    33

    glReadPixels gives only black...

    Hi!
    I want to make screenshots in my engine and I'm trying this via glReadPixels. The thing is, that when I call the function, my buffer only gets filled black pixels. I tried glReadBuffer with back and front, as well as calling the function at different rendering stages (i.e. after or before calling swapbuffers) - to no avail.
    I use this:
    BYTE *pData = new BYTE[m_cx * m_cy * 3];
    glReadPixels(0, m_cy-1, m_cx, m_cy, GL_RGB, GL_UNSIGNED_BYTE, pData);

    with m_cx and m_cy being the window sizes.

    What am I doing wrong?
    Thanks,
    Nick

  2. #2
    Senior Member Regular Contributor
    Join Date
    Jun 2002
    Location
    Philadelphia, PA, US
    Posts
    108

    Re: glReadPixels gives only black...

    try

    glReadPixels(0, 0, m_cx, m_cy, GL_RGB, GL_UNSIGNED_BYTE, pData);

    you should be reading from the front buffer.

  3. #3
    Member Newbie
    Join Date
    Nov 2002
    Posts
    33

    Re: glReadPixels gives only black...

    Thanks! That did the trick.
    Very strange - I had systematically tried all possible combinations, including your proposition, before posting but I still got a blank screen - I guess I messed something different up while testing. *shrug*
    Anyway, it works now...

    So the "lower left corner" in the red book is to be interpreted thus, that the lower left corner of the image is (0,0) - the origin of the picture - and, in effect, if I read any picture data from the framebuffer, I get it upside down?

    Thanks
    Nick

  4. #4
    Senior Member Regular Contributor
    Join Date
    Mar 2002
    Location
    Melbourne, Australia
    Posts
    224

    Re: glReadPixels gives only black...

    Probably you're running in software, not hardware.
    Test the result of GL_RENDERER, "Generic..." means you're running in software.

Similar Threads

  1. All textures are black
    By neon29 in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 11-18-2016, 01:38 PM
  2. [HELP]Getting a black screen(C#-GL.glReadPixels)
    By unSeen in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 07-25-2009, 02:53 AM
  3. black object?
    By in forum OpenGL: Basic Coding
    Replies: 6
    Last Post: 09-03-2005, 02:05 PM
  4. Black surfaces
    By in forum OpenGL: Basic Coding
    Replies: 10
    Last Post: 09-29-2003, 10:13 AM
  5. my view is black
    By Yoramo in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 12-23-2002, 06:25 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean