Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Page 2 of 2 FirstFirst 12
Results 11 to 14 of 14

Thread: glReadPixels

  1. #11
    Junior Member Regular Contributor
    Join Date
    Dec 2000
    Location
    montreal
    Posts
    227

    Re: glReadPixels

    The problem is the parameters you pass to glReadPixels.

    Try

    glReadPixels(1, 1, x, y, ...)

    assuming x and y are higher than 1. I already answered this exact question in the gl ng. Are you that same person?

    Besides, why not do
    glReadPixels(0, 0, x, y, ....)

    V-man
    V--man

  2. #12
    Junior Member Newbie
    Join Date
    Jul 2001
    Location
    Longueuil, Qc, Canada
    Posts
    5

    Re: glReadPixels

    I think my depth buffer is enable!?! glEnable(GL_DEPTH) does not exist. Only GL_DEPTH_TEST. If is what you're talking about I try it and nothing change, and I verify whit glIsEnable(...)! glReadPixels always return 1 in my Z variable.

    Does anybody know how to calculate by myself the z of a mouse point?

    Originally posted by Sebb:
    I assure that I don't take you for a dummy but are you sure your depth buffer is enabled when you are drawing your scene ? (glEnable(GL_DEPTH)) And Are you sure your clear it at the beginning of each new frame ?

  3. #13
    Junior Member Newbie
    Join Date
    Jul 2001
    Location
    Longueuil, Qc, Canada
    Posts
    5

    Re: glReadPixels

    No I am not the same person! I try this but my program crash.. :0 But the parameter of the glReadPixels is not glReadPixels(mouse.x, mouse.y, width of a pixels, height of a pixels, format, type, return value)??

    If I do what you tell me, I'm not doing a big rectangle starting at the bottom, left corner? I have a picture made of points and I want the user to be able to draw a rectangle with the mouse, I translate this window coordinate in glCoordinate and take all the points inside of this region for finally made a croping of my picture.

    Originally posted by V--man:
    The problem is the parameters you pass to glReadPixels.

    Try

    glReadPixels(1, 1, x, y, ...)

    assuming x and y are higher than 1. I already answered this exact question in the gl ng. Are you that same person?

    Besides, why not do
    glReadPixels(0, 0, x, y, ....)

    V-man

  4. #14
    Senior Member OpenGL Guru zed's Avatar
    Join Date
    Jul 2000
    Location
    S41.16.25 E173.16.21
    Posts
    2,609

    Re: glReadPixels

    glClear ( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );

    glEnable( GL_DEPTH_TEST );
    glDepthMask( GL_TRUE );
    glBegin( GL_POINTS );
    glVertex3f( 10,10,0 );
    glEnd();

    GLfloat z;
    glReadPixels( 10, 10, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &z);
    printf("%f\n", z );

    gives me about 0.499 using glOrtho( 0, window_Width, 0 , window_Height, -1.0, 1.0 );

Posting Permissions

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