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 2009-04-30, at 09:09, Mark Coniglio wrote:

Hi All,

I'm experiencing a difficult to track crash with glTexImage2D. (It shows up as a crash in the XCode debugger... things like "Can't unwind stack" etc.)

I allocate a "black" (i.e., all zeros) texture using these calls

UInt32 bytesToAllocate = texSizeH * texSizeV * sizeof(GLuint);
GLuint* data = (GLuint*) calloc(bytesToAllocate, 1);

and init the texture like this:

glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texSizeH, texSizeV, 0, GL_RGBA, GL_UNSIGNED_BYTE, data );

You should use size_t and not UInt32 for the number of byte to allocate, and you should not cast calloc return value, you should check the returned value of calloc for NULL and it's also best to passe sizeof(GLuint) as second calloc argument. All this is to make the code cleaner, it shouuld not make a difference for that particular problem.


Now, did you check the value of bytesToAllocate? What are the types of texSizeX ?

Are you sure data is not tempered with (I mean the pointer, not the content)?

Regards

--
Nicolas Goy
Crazy Programmer and Optimization Bear

http://goyman.com
http://kuon.goyman.com



Attachment: smime.p7s
Description: S/MIME cryptographic signature

 _______________________________________________
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>)



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.