glutDisplayFunc() - "Objective-C"

Posts: 1
Joined: 2009.11
Post: #1
Hoping this is the right place to post this. If not my apologies up front and please direct accordingly Blush

I'm trying to convert some Opengl code from C to Objective-c . So far syntax wise things appear to be OK but I'm running into an error I cant figure out.

"invalid use of void expression"

// @implementation
@interface myOGL : NSObject  [b]//Possible culprit? OGL Object?[/b]
-(void) DrawGLScene {



// Main Code
int main(int argc, char * argv[]) {

myOGL *OGL = [[myOGL alloc] init];

glutDisplayFunc([OGL DrawGLScene]); [b]//Error here *Invalid use of void expression[/b]

return 0;
I'm sure it's my lack of knowledge in Obj C at this stage and not knowing how to do proper C Callbacks most likely...still learning. Regardless, I was hoping that some of the more savvy verterans my be able to help me out.

FWIW, the implementation of the glutDisplayFunc is glutDisplayFunc(void (*func) (void));

With that in mind, I'm supecting that this allocation "myOGL *OGL = [[myOGL alloc] init];" maybe causing an issue since the OGL func is looking to receive a func pointer and/or that my Obj-C func (DrawGLScene) signature does not have (void) as a parameter of which I dont think is possible in Obj-C?

Anyway, any help or suggestions are most welcome and for the sake of space I only listed the most relative parts of the code. If you need to see more I can post the whole thing but I figured initially it would be more noise than anything else. Thanks Wink
Quote this message in a reply
Posts: 869
Joined: 2003.01
Post: #2
glutDisplayFunc() takes a C function as a parameter, not an ObjC method call, nor an ObjC method at all. You need to write a wrapper function.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  glutDisplayFunc fps limit? SummerLand 2 6,395 Nov 21, 2002 02:27 PM
Last Post: Steven