Mali OpenGL ES SDK  2.0.0
A simple framework to aid development of OpenGL ES applications targeting ARM Mali platforms.
 All Classes Files Functions Variables Enumerations Enumerator
Platform.h
1 /*
2  * This confidential and proprietary software may be used only as
3  * authorised by a licensing agreement from ARM Limited
4  * (C) COPYRIGHT 2012 ARM Limited
5  * ALL RIGHTS RESERVED
6  * The entire notice above must be reproduced on all authorised
7  * copies and copies may only be made to the extent permitted
8  * by a licensing agreement from ARM Limited.
9  */
10 
11 #ifndef PLATFORM_H
12 #define PLATFORM_H
13 
14 #if !defined(__android__)
15 
16 #include "EGLRuntime.h"
17 #include "VectorTypes.h"
18 
19 #include <cstdio>
20 
21 namespace MaliSDK
22 {
26  class Platform
27  {
28  public:
32  enum WindowStatus {
38  Vec2 mouseClick;
39  /*
40  * The following variables are platform specific handles/pointers to
41  * displays/devices/windows. Used to create and manage the window
42  * to which OpenGL ES 2.0 graphics are rendered.
43  */
44  #if defined(_WIN32)
45  HWND window;
46  HDC deviceContext;
47  #elif defined(__arm__) && defined(__linux__)
48  fbdev_window *window;
49  #elif defined(__linux__)
50  Window window;
51  Display* display;
52  #endif
53 
58  virtual void createWindow(int width, int height) = 0;
59 
64  virtual WindowStatus checkWindow(void) = 0;
65 
69  virtual void destroyWindow(void) = 0;
70 
76  static void log(const char* format, ...);
77 
82  static Platform* getInstance(void);
83  };
84 }
85 #if defined(_WIN32)
86 #include "WindowsPlatform.h"
87 
88 #elif defined(__arm__) && defined(__linux__)
89 #include "LinuxOnARMPlatform.h"
90 
91 #elif defined(__linux__)
92 #include "DesktopLinuxPlatform.h"
93 
94 #endif
95 
96 #define GL_CHECK(x) \
97  x; \
98  { \
99  GLenum glError = glGetError(); \
100  if(glError != GL_NO_ERROR) { \
101  LOGD("glGetError() = %i (0x%.8x) at %s:%i\n", glError, glError, __FILE__, __LINE__); \
102  exit(1); \
103  } \
104  }
105 
106 #define LOGI Platform::log
107 #define LOGE fprintf (stderr, "Error: "); Platform::log
108 #ifdef DEBUG
109 #define LOGD fprintf (stderr, "Debug: "); Platform::log
110 #else
111 #define LOGD
112 #endif
113 
114 #else
115 #include "AndroidPlatform.h"
116 #endif /* !defined(__android__) */
117 #endif /* PLATFORM_H */