Handmade Hero » Forums » Code » Platforms API examples
nesdavid
David Roguin
15 posts
#76 Platforms API examples
4 years, 9 months ago

Hi!

You can see examples of the first Platform API shown by Casey in SDL and cocos2dx code.

SDL has a function called SDL_CreateWindow that internally calls the platform dependant functions to create the window: https://hg.libsdl.org/SDL/file/6c469ea796e4/src/video
You can see that for every different platform there's dedicated folder that do the actual code (SDL_video.c has that function)

In cocos2dx, there's the FileUtils class that the actual implementation is picked at compile time. https://github.com/cocos2d/cocos2d-x/tree/v3/cocos/platform

Actually cocos2dx uses both techniques, they have a platform layer that calls the init part of your game but then you have to call other parts of the platform api yourself.

Cheers!
Pseudonym
Andrew Bromage
184 posts / 1 project

Research engineer, resident maths nerd (Erdős number 3).

#90 Platforms API examples
4 years, 9 months ago

Another one worth mentioning is Burgerlib. I wouldn't normally mention stuff randomly found on Github, however:

  1. This has been used in over 30 shipped games and applications.
  2. It supports lots of platforms, including most mobile platforms, most previous-gen consoles (even the OUYA) and at least one current-gen (PS4).

sub f{($f)[email protected]_;print"$f(q{$f});";}f(q{sub f{($f)[email protected]_;print"$f(q{$f});";}f});