Results 1 to 7 of 7

Thread: a problem with glreadpixel

  1. #1
    Junior Member Newbie
    Join Date
    Jul 2002
    Location
    Tehran, Iran
    Posts
    8

    a problem with glreadpixel

    Hi
    I want to use glReadPixel to catch pixels color and map them on the plane. In other words I want to make a plane like a monitor that be able to show framebuffer realtime. But when I use it the returned data is nil.
    I use Delphi for programming.

    var Data:Pointer;

    glDrawBuffer(GL_BACK);
    ....drawing
    glFlush;
    glreadPixel(0,0,100,100,GL_RGBA,GL_BITMAP,Data)

    Data is Nil after this command. Why?
    I try some of other Option. But either make an exception error or Data=Nil.

    please help me.
    thanks a lot

  2. #2
    Senior Member Frequent Contributor
    Join Date
    Oct 2001
    Posts
    595

    Re: a problem with glreadpixel

    GL_BITMAP is for black and white..

    replace it with GL_UNSIGNED_BYTE and test again.

  3. #3
    Junior Member Newbie
    Join Date
    Jul 2002
    Location
    Tehran, Iran
    Posts
    8

    Re: a problem with glreadpixel

    Hi,
    I test it to. But it gives Exeption Error.
    I dont Know why?
    Is there any source code too help me?

    thanks

  4. #4
    Senior Member OpenGL Pro
    Join Date
    Feb 2002
    Location
    Bonn, Germany
    Posts
    1,633

    Re: a problem with glreadpixel

    'Data' must be a <u>pointer</u> to 100*100*4=40000 bytes of memory, which you must allocate beforehand.

    I don't know how to do that in VB, but many people had trouble with pointers and VB.

  5. #5
    Senior Member OpenGL Pro
    Join Date
    Oct 2000
    Location
    Fargo, ND
    Posts
    1,753

    Re: a problem with glreadpixel

    Yes, you need to allocate the memory for your array. Never worked with Delphi so I'm not sure how to do that.

    If you were working with VB as zeckensack mistakenly thought, you would use the redim command.

    Dim array() as float

    Redim array(size)

    Or something like that.
    Deiussum
    Software Engineer and OpenGL enthusiast

  6. #6
    Senior Member OpenGL Pro
    Join Date
    Feb 2002
    Location
    Bonn, Germany
    Posts
    1,633

    Re: a problem with glreadpixel

    Yes, thanks for the correction.

  7. #7
    Senior Member Frequent Contributor
    Join Date
    Aug 2000
    Location
    Cardiff University
    Posts
    653

    Re: a problem with glreadpixel

    I have forgotten off my head, but will post the code for delphi later..

Similar Threads

  1. how to use glreadpixel() ?
    By M77ATTAR in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 11-15-2012, 05:59 AM
  2. Where does glreadpixel go?
    By rechmbrs in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 03-11-2006, 04:50 PM
  3. glReadPixel
    By starter in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 10-31-2002, 11:55 PM
  4. How to use glReadPixel problem...
    By Mat in forum OpenGL: Basic Coding
    Replies: 12
    Last Post: 07-17-2002, 01:10 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