All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Graphics.h
1 // Copyright eeGeo Ltd (2012-2014), All Rights Reserved
2 
3 #pragma once
4 
5 #include "Types.h"
6 
7 #if defined (EEGEO_DROID)
8 #define GL_GLEXT_PROTOTYPES
9 #include <EGL/egl.h>
10 #include <GLES2/gl2.h>
11 #include <GLES2/gl2ext.h>
12 #elif defined (EEGEO_IOS)
13 #include <OpenGLES/ES1/gl.h>
14 #include <OpenGLES/ES1/glext.h>
15 #include <OpenGLES/ES2/gl.h>
16 #include <OpenGLES/ES2/glext.h>
17 #elif defined (EEGEO_OSX)
18 #include <OpenGL/gl.h>
19 #include <OpenGL/glu.h>
20 #elif defined (EMSCRIPTEN)
21 #include <EGL/egl.h>
22 #include <GLES2/gl2.h>
23 #include <GLES2/gl2ext.h>
24 #include <emscripten.h>
25 #elif defined (EEGEO_WIN)
26 #include "EegeoWindowsGuard.h"
27 #include <EGL/egl.h>
28 #include <GLES2/gl2.h>
29 #include <GLES2/gl2ext.h>
30 #endif
31 
32 #include "VideoMemoryMonitor.h"
33 
34 #if defined(EEGEO_UNITY)
35  #define Eegeo_GL_GET(default_valued_variable, getter)
36  #define Eegeo_GL(x)
37 #else
38  #define Eegeo_GL_GET(default_valued_variable, getter) ((default_valued_variable) = (getter))
39 
40 #if defined (EEGEO_DEBUG_GL)
41  #if defined (EEGEO_DROID)
42  #define Eegeo_GL(x) { \
43  (x); \
44  EGLint eglError = eglGetError(); \
45  while(eglError!=EGL_SUCCESS) \
46  { \
47  Eegeo_TTY("eglError (0x%x) at %s (%d)\n", eglError, __FILE__, __LINE__);\
48  eglError = eglGetError(); \
49  } \
50  \
51  GLint glError = glGetError(); \
52  while(glError!=0) \
53  { \
54  Eegeo_TTY("glError (0x%x) at %s (%d)\n", glError, __FILE__, __LINE__); \
55  glError = glGetError(); \
56  } \
57  }
58  #elif defined (EMSCRIPTEN)
59  #define Eegeo_GL(x) { \
60  (x); \
61  EGLint eglError = eglGetError(); \
62  while(eglError!=EGL_SUCCESS) \
63  { \
64  emscripten_log(EM_LOG_ERROR, "eglError (0x%x) at %s (%d)\n", eglError, __FILE__, __LINE__);\
65  eglError = eglGetError(); \
66  } \
67  \
68  GLint glError = glGetError(); \
69  while(glError!=0) \
70  { \
71  emscripten_log(EM_LOG_ERROR, "glError (0x%x) at %s (%d)\n", glError, __FILE__, __LINE__); \
72  glError = glGetError(); \
73  } \
74  }
75  #elif defined (EEGEO_IOS)
76  #define Eegeo_GL(x) { \
77  (x); \
78  GLint glError = glGetError(); \
79  while(glError!=0) \
80  { \
81  Eegeo_TTY("glError (0x%x) at %s (%d)\n", glError, __FILE__, __LINE__); \
82  Eegeo_ASSERT(false); \
83  glError = glGetError(); \
84  } \
85  }
86 
87  #elif defined (EEGEO_OSX) || defined (EEGEO_WIN)
88  #define Eegeo_GL(x) { \
89  (x); \
90  GLint glError = glGetError(); \
91  while(glError!=0) \
92  { \
93  Eegeo_TTY("glError (0x%x) at %s (%d)\n", glError, __FILE__, __LINE__); \
94  glError = glGetError(); \
95  } \
96  }
97  #endif
98 
99 #else
100  #define Eegeo_GL(x) {(x);}
101 #endif
102 #endif