If you find this article contains errors or problems rendering it unreadable (missing images or files, mangled code, improper text formatting, etc) please contact the editor so corrections can be made. Thank you for helping us improve this resource
It is a fact that cross-platform indie game development is on the rise these days. The reason behind porting to Mac is that most indies sell as many copies for PC as for Mac platforms. In addition, several of the most popular indie solutions now support both Windows and Macintosh platforms, such as Torque, BlitzMax, PTK and others.
However, even when using commercial engines, there will be a certain functionality that is not covered by the engine, and that will require native code for each platform.
That is why we have collected the following snippets, which I am sure you will find handy during your next cross-platform development.
Get current desktop resolution
If your game supports different video modes, you can use the current desktop settings to adjust the default resolution and color depth in the first run.
The Mac OS X implementation will give you the exact ammount of video memory of the first valid video adapter found. However, the Windows version, which relies on DirectX 5, will return less memory than is physically installed. For 16MB video cards, it will return about 13MB though. I ignore the purpose of this behaviour, just take it into account.
Requiring DirectX 5 should not be a real problem, being already included in Windows 98. Furthermore, the DirectDraw DLL is dynamically loaded, so the function will just return zero in case of error (still running Windows 95 for instance).
It is unusual to include videos in indie games because they increase the download size noticeably, but just in case you need to, here are a couple of links that will teach you how to render AVI files in OpenGL: