View Full Version : ImageIO texture loader crashing - Cocoa
mahalis
2006.07.31, 01:54 PM
I'm trying to use the code from here (http://gamewiki.evolpenguin.com/index.php?title=ImageIO_Texture_Loading) to load a png image (obtained from the screencapture command-line thing).
Trouble is, I can't figure out how to -use- the code in the first place. It's in an Obj-C class "Texturer", inside the @implementation block; if I wrap it in a -(GLuint)getTexture:(CFStringRef)name I get "unknown symbol: _AssertNonNull"; if I leave it as-is, then call Texturer *txtr = [[Texturer alloc] init];
GLuint tex = txtr.LoadTexture();
it won't even build: "error: request for member 'LoadTexture' in something not a structure or union".
Seems like I'm missing some fundamental C thing... anyone know what I'm doing wrong? :(
unknown
2006.07.31, 02:25 PM
Texturer *txtr = [[Texturer alloc] init];
GLuint tex = txtr.LoadTexture();
looks like you are using a C++ function call on an objC class, are you sure the second line shouldn't be
GLuint tex = [txtr LoadTexture];
or somthing similar.
mahalis
2006.07.31, 02:40 PM
Well, the function in the objC class is declared as a regular C function - "GLuint loadTexture(CFStringRef name)"...
I might just separate that function out into a C class, if I can figure out how to instantiate it and call its methods... any advice on that?
Edit - problem solved.. sort of. Put the loadTexture C function in the Obj-C class and made an accessor method that called that internally. Now a whole new problem.
Cochrane
2006.08.01, 10:06 PM
I'm not certain whether pure C functions in Objective-C classes are allowed at all, but they are certainly not useful. To define a class method, you use the Objective-C syntax:
- (returntype)doSomethingWithArg1:(arg1type)argument
and you call it with Objective-C syntax:
foo = [something doSomethingWithArg1:somethingElse];
There is no such thing as a "C class", are you talking about C++? It ought to work if you change the method definition and call to what Objective-C does, or call the function like any normal C function. As long as you are not using Objective-C++, there is not really any other option.
djork
2006.08.16, 11:33 AM
This isn't really a texture loading question. You really need to go back and learn the fundamentals of C, and then Objective-C. You seem to be confusing C structs with Objective-C methods, and who knows what else is going on in your code.
I use that sample code to implement my texture loading too. I modified it a bit to take a NSString for the file name and a pre-glGenTextures'ed integer texture name. It is an instance method (not a class method) so I call it within other methods of my class that wants to load textures via [self loadImageNamed:@"whatever" intoTexture:textureVariable];
vBulletin® v3.6.8, Copyright ©2000-2008, Jelsoft Enterprises Ltd.