Josh Sanford Josh Sanford - 2 months ago 18
Linux Question

Need to port simple framebuffer code from Linux to OS X

I am developing code for an embedded target which uses the Linux framebuffer for all of its output, but it would be easier if I could debug most of my development from Xcode. Everything other than the framebuffer code and the event processing compiles properly under Xcode, and I can live without event processing for now.

At present I find myself thwarted at the gates of Objective-C and Swift and the overabundance of iOS information. I was extremely familiar with the Mac Toolbox back in the day, but that doesn't help here.

What am I looking for? I need a pointer to memory for a 1920 x 1080 framebuffer that can be displayed in a window. 32-bit RGBA organization would be nice, but I can accommodate other packed pixel schemes and other color depths.

I have done a fair amount of searching for framebuffer examples on the Mac, but almost invariably the results have to do with OpenGL (which sounds like severe overkill), or offscreen drawing (which doesn't directly help me), and/or pertain specifically to iOS (which seems to have slightly different frameworks than OS X). I am sure that Core Graphics can do what I need, but the documentation is so replete with background information that I can't find what I am actually looking for.

Can anybody suggest an approach or point me to sample code, or even to appropriate non-iOS documentation for this? I'm also open to other options if it sounds like I'm taking the wrong approach.


As a simple alternative to having to learn the intricacies of Cocoa/Objective-C to get a FrameBuffer style window to work with, there is a good alternative in the SDL Framework, which is a cross-platform library for providing simple access to low-level features such as graphics, sound, etc.

It is available for Linux and the Mac, and should provide a a way of at least emulating a FrameBuffer for developer testing.

Depending on the embedded linux that you're using; you may be able to compile a version of SDL that talks to the frame buffer directly on the physical hardware - the SDL installation instructions mentions direct display support for the raspberry Pi, as well as at least one blog entry detailing building it on their system.