Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: Crash when initing texture with glTexImage2D
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Crash when initing texture with glTexImage2D



On 30/4/09 1:35 PM, Erik Harg wrote:
bytesToAllocate = texSizeH * texSizeV * sizeof(GLuint);
...
bytesToAllocate = width x height x 4
...
If you only allocate width*height*sizeof(GLuint), either the way you're
doing now, or the way I believe Nicolas suggested
...
aren't you missing the "x 4" part to get enough space for 4 bytes per
pixel? And that you would really need

No, he's not because sizeof(GLuint) is pretty much guaranteed to be >= 4 on current systems. Unless maybe if he's using OpenGL on an 8-bit micro-controller in which case I WANT ONE TOO! :-D


GLuint bytesPerPixel = 4;
size_t bytesToAllocate = texSizeV * texSizeH * bytesPerPixel;

bytesPerChannel = sizeof(unsigned char); // GL_UNSIGNED_BYTE channelsPerPixel = 4; // GL_RGBA bytesPerPixel = bytesPerChannel * channelsPerPixel; bytesToAllocate = width * height * bytesPerPixel;

but that is identical to:

= width * height * sizeof(GLuint)
= width * height * 4

Cheers,
/uli
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Mac-opengl mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Crash when initing texture with glTexImage2D (From: Mark Coniglio <email@hidden>)
 >Re: Crash when initing texture with glTexImage2D (From: Nicolas Goy <email@hidden>)
 >Re: Crash when initing texture with glTexImage2D (From: Erik Harg <email@hidden>)



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

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.