Results 1 to 3 of 3

Thread: how to use glreadpixel() ?

  1. #1
    Junior Member Newbie
    Join Date
    Nov 2012
    Posts
    8

    how to use glreadpixel() ?

    hello,

    I just draw a rectangle as follows:

    glColor3f(1.0,.0,.0);
    glBegin(GL_POLYGON);
    glVertex2f(.0,.0);
    glVertex2f(0.2,.0);
    glVertex2f(0.2,1.0);
    glVertex2f(.0,1.0);
    glEnd();

    my questions is:

    -- what is the x,y, width and height adequate for glReadPixels(x,y, width,height,GL_RGB,GL_UNSIGNED_BYTE,data);
    to retrieve only the color red (rectangle) knowing that the points of the rectangle are of type float?

    --how to retrieve the values ​​of the parameter data, and save them in a text file ?

    cordially

  2. #2
    Senior Member Regular Contributor uwi2k2's Avatar
    Join Date
    Mar 2011
    Posts
    138
    hi,

    Quote Originally Posted by M77ATTAR View Post
    -- what is the x,y, width and height adequate for glReadPixels(x,y, width,height,GL_RGB,GL_UNSIGNED_BYTE,data);
    to retrieve only the color red (rectangle) knowing that the points of the rectangle are of type float?
    you canīt do a 1 to 1 merging from the vertex data to screen coordinates.
    there are complex math forms that can do that.
    sorry i cant help you more, but you may search for 'world coordinates to screen coordinates'.

    cu
    uwi
    uwi2k2 - OpenGL Trainer: www.opengl-trainer.com
    ---------------------------------------------------------
    The OpenGL and VULKAN Podcast ( OpenGL2GO ) : OpenGL & Vulkan Podcast
    ---------------------------------------------------------
    timbling.com - Indie TeamUp

  3. #3
    V-man
    Guest
    Use gluProject. It gives window's space coordinates for each vertex.

Similar Threads

  1. Where does glreadpixel go?
    By rechmbrs in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 03-11-2006, 04:50 PM
  2. glBlendFunc & glReadPixel
    By vmh5 in forum OpenGL: Advanced Coding
    Replies: 3
    Last Post: 06-23-2003, 01:36 PM
  3. glReadPixel
    By starter in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 10-31-2002, 11:55 PM
  4. glReadPixel?
    By perdue in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 08-18-2002, 02:46 AM
  5. glReadPixel
    By guju in forum OpenGL: Advanced Coding
    Replies: 2
    Last Post: 06-05-2002, 03:08 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