Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: mac-opengl digest, Vol 2 #54 - 3 msgs



On 12/29/00 1:48 AM, email@hidden wrote:

>Hi,
> I've just tried to use glReadPixels and all I get are hard crashes...
>I'm on
>linux but I'm pretty sure my problem comes from OpenGL, so there should be no
>problem to help me...
>
>here's the code:
>GLbyte *thePixels;
>glReadBuffer(GL_FRONT_LEFT); // Is this necessary since I read from the
>default
>buffer?
>glReadPixels(10,10, 10,10, GL_RGBA, GL_BYTE, &thePixels);
>cout << (int)thePixels[0] << endl;

You didn't initialize thePixels. You need to allocate enough space for
the pixel values to be copied into it. It's copying the pixels into a
random memory location which would explain the hard crash.

-Ben

+--------------------------+-----------------------------------+
| Ben Spees | Ambrosia Software, Inc. |
| Coding Boffin | http://www.AmbrosiaSW.com/ |
+--------------------------+-----------------------------------+




Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.