Handmade Hero»Forums»Code
vbo
Vadim Borodin
20 posts
Check out my version of OS X platform layer
Hey guys!

I've just finished the first usable version of my platform layer implementation for OS X. It works for me as a full-featured drop-in replacement for win32 platform layer at least for day 29 - 32 sources (it's where I am now). If you are following along on OS X please check this out and let me know how it works for you.

I've commented the source code as detailed as possible so you can easily read it through and understand what I was thinking. The whole thing is just one .m file and a simple bash script as a "build system". I've also included a hand-coded application bundle so you can launch the game as a normal OS X application, put it in Dock etc.

Here is a link: https://github.com/vbo/handmadehero_osx_platform_layer
Neil Blakey-Milner
45 posts
Check out my version of OS X platform layer
Nice work!

In my own OS X platform layer (not for Handmade Hero, but for something I'm playing with based on the same architecture) I ended up discovering that you _can_ just use C++. The build line for the platform layer part:

clang -std=c++0x ${WARNFLAGS} -framework Cocoa -framework QuartzCore -framework OpenGL -o build/debug/osx source/hajonta/platform/osx.mm ${DEBUG_FLAGS} ${INCLUDES}

The osx.mm file also just #includes a .cpp file for anything that isn't Objective C/Cocoa-specific.

The files in question: https://github.com/nxsy/hajonta/blob/master/source/hajonta/platform/
Lars Hamre
1 posts
Check out my version of OS X platform layer
In reference to your TODO about hanging on resize events:

Try adding the line:
[application updateWindows];
after:
[application sendEvent:event];
in the default case during cocoaFlushEvents().
vbo
Vadim Borodin
20 posts
Check out my version of OS X platform layer
nxsy, thank you! Didn't know about this "Objective-C++" stuff =)

chemecse, [application updateWindows] doesn't work for me. Cocoa actually blocks on [application sendEvent:event] when it goes to so-called LiveResize state. It would be nice to simply disable LiveResize at all but I've not found a way to do it yet.

Looks like other people also have this issue on OS X (e.g. SFML library: http://en.sfml-dev.org/forums/index.php?topic=10404.msg71665#msg71665).