Howdy,
Well, in my quest for knowledge, I've seen several threads on various forums where there's a discussion of wrapping C++ to Cocoa to be able to create C++ GUI applications on Mac OS. Most of the answers pointed to using Cocoa for the GUI parts (possibly Objective-C++ with .mm files) and C++ for the rest, but not many examples of how to actually do something like that.
I did, however, find this old thread here that gave me inspiration:
https://forums.macrumors.com/threads/246143/
... and got the ball rolling.
According to the Application Kit Framework Reference:
https://developer.apple.com/library...ssic/_index.html#//apple_ref/doc/uid/20001093
AppKit.framework is really all you need to create a GUI application:
So, with that in mind, I set out to learn how to mix C++, Objective-C and OpenGL using the AppKit.framework. There isn't much information readily available for this kind of task. Most of the tutorials available for Mac programming are about Cocoa with Interface Builder, and are basically "do this, do that and bang! You're done." kind of tutorials. So, I had to really do my research to come up with a workable solution.
Here's my project so far:
http://www.cactus3d.com/CPPAppKitTest.zip
Since most of my experience is with C/C++ (started learning C on a 68K Centris 650), Objective-C is a bit foreign to me, so I tried to keep the Objective-C code to a minimum. I reckon what I'm asking is if someone could look over the code in the above project and tell me if the Objective-C code is done correctly (specifically the memory management) and possibly offer any suggestions for improvements. It seems to work fine and running it with the debugger console doesn't report any issues.
Adios,
Cactus Dan
Well, in my quest for knowledge, I've seen several threads on various forums where there's a discussion of wrapping C++ to Cocoa to be able to create C++ GUI applications on Mac OS. Most of the answers pointed to using Cocoa for the GUI parts (possibly Objective-C++ with .mm files) and C++ for the rest, but not many examples of how to actually do something like that.
I did, however, find this old thread here that gave me inspiration:
https://forums.macrumors.com/threads/246143/
... and got the ball rolling.
According to the Application Kit Framework Reference:
https://developer.apple.com/library...ssic/_index.html#//apple_ref/doc/uid/20001093
AppKit.framework is really all you need to create a GUI application:
The Application Kit is a framework containing all the objects you need to implement your graphical, event-driven user interface: windows, panels, buttons, menus, scrollers, and text fields.
So, with that in mind, I set out to learn how to mix C++, Objective-C and OpenGL using the AppKit.framework. There isn't much information readily available for this kind of task. Most of the tutorials available for Mac programming are about Cocoa with Interface Builder, and are basically "do this, do that and bang! You're done." kind of tutorials. So, I had to really do my research to come up with a workable solution.
Here's my project so far:
http://www.cactus3d.com/CPPAppKitTest.zip
Since most of my experience is with C/C++ (started learning C on a 68K Centris 650), Objective-C is a bit foreign to me, so I tried to keep the Objective-C code to a minimum. I reckon what I'm asking is if someone could look over the code in the above project and tell me if the Objective-C code is done correctly (specifically the memory management) and possibly offer any suggestions for improvements. It seems to work fine and running it with the debugger console doesn't report any issues.
Adios,
Cactus Dan