Multi-platform considerations

Home / Support / Tutorials / Getting Started / Multi-platform considerations

Handling multiple workspaces with one source

When developing multi-platform applications, create a workspace for every target platform and keep one source folder. A multi-platform development folder structure could look like this:

Folder structure
Folder structure

There are several workspace folders containing a project for each target platform, a shared resource folder, a setup folder for windows mobile, and a shared code folder. External resources like graphics, sound and music can be stored in a subfolder like: C:\projects\helloworld\res\graphics\symbian_s60.

A multi-platform source code

When programming a multi-platform C++ source file, there are little differences between different platforms. Symbian applications don't include resources in the source code. These lines of code should be disabled by using the #ifdef macro's. Keep in mind that some non-EDGELIB functions may not be supported by each platform. Try to use as much EDGELIB functions as possible. A multi-platform helloworld.cpp file would look like this:

helloworld.cpp (96 lines)
  1. /////////////////////////////////////////////////////////////////////
  2. // Code/helloworld.cpp
  3. // One of the EDGELIB tutorial samples (multi-platform)
  4. //
  5. // Copyright (c) 2006-2017 Elements Interactive Mobile B.V.
  6. // http://www.edgelib.com
  7. //
  8. // Show "hello world" on the screen and exit by clicking/tapping the
  9. // window or hitting a key
  10. /////////////////////////////////////////////////////////////////////
  11.  
  12. /////////////////////////////////////////////////////////////////////
  13. // Include and link the library                                    //
  14. /////////////////////////////////////////////////////////////////////
  15.  
  16. //Include EDGELIB
  17. #include "edgemain.h"
  18.  
  19. //Link the EDGELIB static library
  20. #pragma comment(lib, "edge.lib")
  21.  
  22. #if defined(DEVICE_WIN32) && !defined(__EDGEIDE__)
  23.  
  24. //Include internal resources for native Win32 builds
  25. #include "resource.h"
  26.  
  27. #else
  28.  
  29. #define IDI_MAIN  0
  30.  
  31. #endif
  32.  
  33. /////////////////////////////////////////////////////////////////////
  34. // Class definition                                                //
  35. /////////////////////////////////////////////////////////////////////
  36.  
  37. //The main class
  38. class ClassMain : public ClassEdge
  39. {
  40.     public:
  41.         ClassMain(void);
  42.         ~ClassMain(void);
  43.         ERESULT OnDisplayConfig(EDISPLAYCONFIG *config);
  44.         ERESULT OnNextFrame(ClassEDisplay *display, unsigned long timedelta);
  45.         void OnButtonDown(unsigned long bnr, EBUTTONLIST *blist);
  46.         void OnStylusDown(POINT pnt);
  47. };
  48.  
  49.  
  50. /////////////////////////////////////////////////////////////////////
  51. // ClassMain: public                                               //
  52. /////////////////////////////////////////////////////////////////////
  53.  
  54. //ClassMain: constructor
  55. ClassMain::ClassMain(void)
  56. {
  57. }
  58.  
  59. //ClassMain: destructor
  60. ClassMain::~ClassMain(void)
  61. {
  62. }
  63.  
  64. //Configure display
  65. ERESULT ClassMain::OnDisplayConfig(EDISPLAYCONFIG *config)
  66. {
  67.     ClassEStd::StrCpy(config->caption, "Hello World!");
  68.     config->icon = IDI_MAIN;
  69.     return(E_OK);
  70. }
  71.  
  72. //Callback: Called every frame
  73. ERESULT ClassMain::OnNextFrame(ClassEDisplay *display, unsigned long timedelta)
  74. {
  75.     display->buffer.DrawFont(0, 0, &display->fontinternal, "Hello World!");
  76.     return(E_OK);
  77. }
  78.  
  79. //Callback: Called when the user pressed a key or button
  80. void ClassMain::OnButtonDown(unsigned long bnr, EBUTTONLIST *blist)
  81. {
  82.     Quit();
  83. }
  84.  
  85. //Callback: Called when the user points the stylus down or clicks the left mouse button
  86. void ClassMain::OnStylusDown(POINT pnt)
  87. {
  88.     Quit();
  89. }
  90.  
  91.  
  92. /////////////////////////////////////////////////////////////////////
  93. // The program entry point                                         //
  94. /////////////////////////////////////////////////////////////////////
  95.  
  96. ClassEdge *EdgeMain(EDGESTARTUP *data){ return(new ClassMain); }

Notes

When developing a multi-platform application, you need to understand the limits of these platforms to ensure the code actually works on each platform. Each platform has a different type of input and a different resolution. The input problem can be solved by mapping a maximum of three actions buttons to in-game actions. These key mappings would be set for each platform separately. The graphics problem can be fixed by using a dynamic screen layout with one set of graphics, or by using a different set of graphics for each platform (and defining screen layouts separately).

A good way to handle programming definitions separately for each platform, is to add a def_platf.h header file into each workspace folder, instead of adding it to the shared source folder. More suggestions on how to get started with multi-platform EDGELIB projects can be found in our multi-platform development tutorial.

Download tutorial project

Here is a sample that can be downloaded which contains the result of this tutorial.

Getting started tutorials

Latest forum posts