I'm having a really hard time debugging this crash. My data seems straight forward, the variables all seem to line up, but it doesn't seem to matter who ends up calling the method, it always crashes.
Here is the crashing thread from the debugger
#1 0x00022dfe in -[Texture2D initWithData:pixelFormat:pixelsWide:pixelsHigh:contentSize:] at Texture2D.m:94
#2 0x00023cf4 in -[Texture2D(Image) initWithImage:] at Texture2D.m:308
#3 0x000263bf in -[TextureMgr addImage:] at TextureMgr.m:186
#4 0x0001fd80 in -[Sprite initWithFile:] at Sprite.m:40
#5 0x0001fcea in +[Sprite spriteWithFile:] at Sprite.m:32
Debugger has me breaking here
- (id) initWithData:(const void*)data pixelFormat:(Texture2DPixelFormat)pixelFormat pixelsWide:(NSUInteger)width pixelsHigh:(NSUInteger)height contentSize:(CGSize)size
{
// GLint saveName;
if((self = [super init])) {
glGenTextures(1, &_name); <--------- this is where I39;m "crashing"
And here is the method as I step through it...
+ (id) spriteWithFile:(NSString*) filename
{
return [[[self alloc] initWithFile:filename] autorelease];
}
(gdb) po filename
joystickbackground3.png
-(Texture2D*) addImage: (NSString*) path
{
NSAssert(path != nil, @"TextureMgr: fileimage MUST not be nill");
Texture2D * tex = nil;
...
(gdb) po path
joystickbackground3.png
tex = [ [Texture2D alloc] initWithImage: [UIImage imageWithContentsOfFile: fullpath ] ];
(gdb) po fullpath
/Users/Sama7/Library/Application Support/iPhone Simulator/User/Applications/DD116DAD-1064-461A-B309-40381BE48F93/MyApp.app/joystickbackground3.png
And then finally to
- (id) initWithData:(const void*)data pixelFormat:(Texture2DPixelFormat)pixelFormat pixelsWide:(NSUInteger)width pixelsHigh:(NSUInteger)height contentSize:(CGSize)size
{
Where we end up with the following values
(gdb) p pixelFormat
$5 = kTexture2DPixelFormat_RGBA8888
(gdb) p data
$6 = (const void *) 0x534000
(gdb) p width
$7 = 256
(gdb) p height
$8 = 256
(gdb) p size
$9 = {
width = 256,
height = 256
}
(gdb) p &_name
$10 = (GLuint *) 0x1023604
(gdb) p _name
$11 = 0
And then poof, EXC_BAD_ACCESS
The only thing that has been modified is I moved the project into a more Model/Controller style. In this particular sprite class, its the exact same .h and .m as it was when it did work, and its calling "spriteWithFile" inside the .m, so this code did not change in transition, but this call is crashing now, it didn't before. I diff'd the file from before & after my svn checkin of the controller changes etc, this class, joystick.h and joystick.m, did not change.
I'm totally at a loss and any clues as towards a direction to look would be great, I can't think of a stone to look under right now.