Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Mar 13, 2012, 03:08 PM   #1
Cactus Dan
macrumors newbie
 
Join Date: Aug 2010
Using C++, Objective-C and OpenGL

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:
http://forums.macrumors.com/showthre...th+objective+c
... and got the ball rolling.

According to the Application Kit Framework Reference:
https://developer.apple.com/library/...c/uid/20001093

AppKit.framework is really all you need to create a GUI application:
Quote:
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
Cactus Dan is offline   0 Reply With Quote
Old Mar 19, 2012, 09:56 AM   #2
Cactus Dan
Thread Starter
macrumors newbie
 
Join Date: Aug 2010
Howdy,

Hmmmm, a week later with 250+ views and no replies, is it safe to assume the Objective-C code in the project is fine?

Adios,
Cactus Dan
Cactus Dan is offline   0 Reply With Quote
Old Mar 21, 2012, 09:45 AM   #3
Nimbuz
macrumors newbie
 
Join Date: Dec 2009
.. or maybe you're asking at the wrong place. Try stackoverflow or some other forums where the visitors are mainly developers.
Nimbuz is offline   0 Reply With Quote
Old Mar 21, 2012, 11:03 AM   #4
chown33
macrumors 603
 
Join Date: Aug 2009
Quote:
Originally Posted by Nimbuz View Post
.. or maybe you're asking at the wrong place. Try stackoverflow or some other forums where the visitors are mainly developers.
Or maybe dumping an entire project and basically saying "Please review this and point out any bugs or design flaws" is asking for more than anyone is willing to do.

Also, since the OP specifically asked about memory management: There are memory tools (zombies and leaks) in Instruments that specifically address memory mgmt.
chown33 is offline   0 Reply With Quote
Old Mar 21, 2012, 01:43 PM   #5
Cactus Dan
Thread Starter
macrumors newbie
 
Join Date: Aug 2010
Howdy,

Ah, thanks for the tip. I wasn't aware of Instruments. It works great and no memory leaks in the project.

Adios,
Cactus Dan
Cactus Dan is offline   0 Reply With Quote
Old Feb 14, 2013, 04:34 PM   #6
oatman13
macrumors member
 
Join Date: Feb 2013
I find this absolutely fascinating! Have you done anything new or having any new updates to share? Shoot, something like this should be placed into GIT and a team should be assembled to work on it. I absolutely love it!
oatman13 is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
OpenGL 4.0 MagnusVonMagnum OS X Mavericks (10.9) 2 Jan 1, 2014 09:44 PM
OpenGL 3.2?! Itzamna OS X 10.8 Mountain Lion 1 Jun 10, 2013 05:37 PM
OS X OpenGL 4 foijord Wasteland 7 Jul 19, 2012 06:09 PM
OpenGL Versioning? Michael Goff OS X 16 Jul 13, 2012 08:36 PM

Forum Jump

All times are GMT -5. The time now is 07:28 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC