Results 1 to 7 of 7

Thread: Problem about glReadPixels()

  1. #1
    Junior Member Newbie
    Join Date
    Sep 2004
    Posts
    22

    Problem about glReadPixels()

    Hi, in my code, I have:

    glBegin()
    ...
    glEnd()

    glutSwapBuffers();

    //get the framebuffer

    GLfloat tmpBuffer[800][800][4];
    glReadPixels(0,0,800,800, GL_RGBA ,GL_FLOAT ,tmpBuffer);
    //-------------------------------

    I got the stack overflow problem...

    What's wrong with my code?

    Thanks...

  2. #2
    Guest

    Re: Problem about glReadPixels()

    hey powervr, try allocating the buffer memory on the heap, or move the array outside the function. under msvc, for example, the default stack size is 1 meg. 800x800x4 = 2.5 megs, just a hair too high

  3. #3
    Junior Member Newbie
    Join Date
    Sep 2004
    Posts
    22

    Re: Problem about glReadPixels()

    Bingo! I have solved the problem by moving the array outside the function()

    Thanks!

  4. #4
    Junior Member Newbie
    Join Date
    Sep 2004
    Posts
    22

    Re: Problem about glReadPixels()

    another problem, here is my code:

    ...
    GLuint tmpBuffer[200][200];
    ...
    glBegin(GL_POLYGON)
    ...
    glEnd()
    ...
    glReadPixels(0, 0, 200, 200, GL_RGBA, GL_BITMAP, tmpBuffer);
    ------------------------------
    Why the tmpBuffer return no value?

    If I replace GL_BITMAP with GL_UNSIGNED_BYTE
    , it is okay.

    any suggestion?

    Thanks

  5. #5
    Senior Member OpenGL Guru
    Join Date
    Feb 2000
    Location
    Sweden
    Posts
    2,978

    Re: Problem about glReadPixels()

    GL_BITMAP is not a valid type unless you're in indexed color mode.

  6. #6
    Junior Member Newbie
    Join Date
    Sep 2004
    Posts
    22

    Re: Problem about glReadPixels()

    So if i am now in RGBA , double buffer mode,

    what should i do in order to get the buffer as?

    e.g.
    000001111111111100000
    000001000000000100000
    000001000000000100000
    000001000000000100000
    000001000000000100000
    000001000000000100000
    000001111111111100000

    (i don't care the values in RGB format, i just care if any pixel is draw on the screen.)

    Thanks

  7. #7
    Senior Member OpenGL Guru
    Join Date
    Feb 2000
    Location
    Sweden
    Posts
    2,978

    Re: Problem about glReadPixels()

    Then I suggest you use the stencil buffer to mark pixels as drawn, and read it back. If you need a bitmask of all pixels, then I'm afraid you have to build the mask yourself from the individual pixels.

Similar Threads

  1. Problem with glReadPixels using FBO
    By nimelord in forum OpenGL: Basic Coding
    Replies: 24
    Last Post: 02-03-2018, 02:53 PM
  2. Problem with glReadPixels
    By Michael Breitung in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 12-05-2012, 01:44 AM
  3. Problem with glReadPixels
    By Amx90 in forum OpenGL: Basic Coding
    Replies: 6
    Last Post: 07-02-2009, 07:27 AM
  4. problem of glReadPixels
    By weicao in forum OpenGL: Advanced Coding
    Replies: 1
    Last Post: 01-04-2004, 06:21 AM
  5. problem with glReadPixels
    By jbreedlove in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 10-16-2001, 11:26 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