I’m doing a program about lights in OpenGL. I built the interface using Interface Builder, but I’m now completely at a loss as to how make my ANSI C code interact with Interface Builder objects. I mean: my C codes creates a scene that can be rotated, etc. How do I make my scene appear in IB? How do I make my IB sliders use my C event handling function?
There is a good OpenGL in Cocoa demo on Apple’s site. Strangely enough they don’t use the OpenGL view from the palette, instead the subclass NSOpenGLView and put a custom view into the window using IB and then tell it that the custom view is of type “whatever your subclass is”.
I’m not sure why they did this, however, I ran into problems using the palette as well, so I followed the same technique and it works just fine.
If you want to manipulate with sliders, add a couple of IBAction’s to your subclass and then load the .h file into IB so that you can use the cool hold-control-and-drag-between-items method to hook stuff up.
You can then have your IBActions send getFloat messages to <sender> and that will get the value for you and you can call your C code with the updated values and then [self setNeedsDisplay: true].