OpenGL ES SDK for Android ARM Developer Center
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Platform.h
Go to the documentation of this file.
1 /* Copyright (c) 2012-2017, ARM Limited and Contributors
2  *
3  * SPDX-License-Identifier: MIT
4  *
5  * Permission is hereby granted, free of charge,
6  * to any person obtaining a copy of this software and associated documentation files (the "Software"),
7  * to deal in the Software without restriction, including without limitation the rights to
8  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
9  * and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
12  *
13  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
14  * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
16  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
17  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19  */
20 
21 #ifndef PLATFORM_H
22 #define PLATFORM_H
23 
24 #if !defined(ANDROID)
25 
26 #include "EGLRuntime.h"
27 #include "VectorTypes.h"
28 
29 #include <cstdio>
30 
31 namespace MaliSDK
32 {
36  class Platform
37  {
38  public:
42  enum WindowStatus {
49  /*
50  * The following variables are platform specific handles/pointers to
51  * displays/devices/windows. Used to create and manage the window
52  * to which OpenGL ES 2.0 graphics are rendered.
53  */
54  #if defined(_WIN32)
55  HWND window;
56  HDC deviceContext;
57  #elif defined(__arm__) && defined(__linux__)
58  fbdev_window *window;
59  #elif defined(__linux__)
60  Window window;
61  Display* display;
62  #endif
63 
68  virtual void createWindow(int width, int height) = 0;
69 
74  virtual WindowStatus checkWindow(void) = 0;
75 
79  virtual void destroyWindow(void) = 0;
80 
86  static void log(const char* format, ...);
87 
92  static Platform* getInstance(void);
93  };
94 }
95 #if defined(_WIN32)
96 #include "WindowsPlatform.h"
97 
98 #elif defined(__arm__) && defined(__linux__)
99 #include "LinuxOnARMPlatform.h"
100 
101 #elif defined(__linux__)
102 #include "DesktopLinuxPlatform.h"
103 
104 #endif
105 
106 #define GL_CHECK(x) \
107  x; \
108  { \
109  GLenum glError = glGetError(); \
110  if(glError != GL_NO_ERROR) { \
111  LOGD("glGetError() = %i (0x%.8x) at %s:%i\n", glError, glError, __FILE__, __LINE__); \
112  exit(1); \
113  } \
114  }
115 
116 #define LOGI Platform::log
117 #define LOGE fprintf (stderr, "Error: "); Platform::log
118 #ifdef DEBUG
119 #define LOGD fprintf (stderr, "Debug: "); Platform::log
120 #else
121 #define LOGD
122 #endif
123 
124 #else
125 #include "AndroidPlatform.h"
126 #endif /* !defined(__android__) */
127 #endif /* PLATFORM_H */
Vector types.
GLint GLsizei GLsizei height
Definition: gl2ext.h:179
virtual WindowStatus checkWindow(void)=0
Check status of the window.
struct WindowProperties window
GLint GLsizei GLsizei GLenum format
Definition: gl2ext.h:179
static Platform * getInstance(void)
Definition: Platform.cpp:28
A 2D integer vector.
Definition: VectorTypes.h:38
WindowStatus
An enum to define the status of a window.
Definition: Platform.h:42
Abstract class to hide the complexity of multiple build targets.
Definition: Platform.h:36
virtual void destroyWindow(void)=0
Close and clean-up the native window.
static void log(const char *format,...)
Print a log message to the terminal.
Definition: Platform.cpp:39
GLint GLsizei width
Definition: gl2ext.h:179
virtual void createWindow(int width, int height)=0
Create a native window on the target device.