Oxygine  1
2g game engine
oxgl.h
1 #pragma once
2 #include "oxygine-include.h"
3 
4 
5 #if __S3E__
6 # include "IwImage.h"
7 # include "IwGL.h"
8 # include "GLES/gl.h"
9 # define GL_GLEXT_PROTOTYPES
10 # include "GLES/glext.h"
11 # include <gles/egl.h>
12 #else
13 # include "SDL_config.h"
14 
15 #if _WIN32
16 # define GL_GLEXT_PROTOTYPES
17 # include "SDL_opengl.h"
18 
19 # define GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG 0x8C00
20 # define GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG 0x8C01
21 # define GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG 0x8C02
22 # define GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG 0x8C03
23 
24 # define GL_ETC1_RGB8_OES 0x8D64
25 
26 extern "C"
27 {
29  extern PFNGLSHADERSOURCEPROC _glShaderSource;
30  extern PFNGLUSEPROGRAMPROC _glUseProgram;
31  extern PFNGLVERTEXATTRIBPOINTERPROC _glVertexAttribPointer;
32  extern PFNGLACTIVETEXTUREPROC _glActiveTexture;
33  extern PFNGLENABLEVERTEXATTRIBARRAYPROC _glEnableVertexAttribArray;
34  extern PFNGLDISABLEVERTEXATTRIBARRAYPROC _glDisableVertexAttribArray;
35  extern PFNGLDELETEPROGRAMPROC _glDeleteProgram;
36  extern PFNGLGETSHADERIVPROC _glGetShaderiv;
37  extern PFNGLGETSHADERINFOLOGPROC _glGetShaderInfoLog;
38  extern PFNGLCREATESHADERPROC _glCreateShader;
39  extern PFNGLCREATEPROGRAMPROC _glCreateProgram;
40  extern PFNGLATTACHSHADERPROC _glAttachShader;
41  extern PFNGLCOMPILESHADERPROC _glCompileShader;
42  extern PFNGLDETACHSHADERPROC _glDetachShader;
43  extern PFNGLBINDATTRIBLOCATIONPROC _glBindAttribLocation;
44  extern PFNGLLINKPROGRAMPROC _glLinkProgram;
45  extern PFNGLUNIFORM1IPROC _glUniform1i;
46  extern PFNGLUNIFORM2FPROC _glUniform2f;
47  extern PFNGLUNIFORM2FVPROC _glUniform2fv;
48  extern PFNGLUNIFORM3FVPROC _glUniform3fv;
49  extern PFNGLUNIFORM4FVPROC _glUniform4fv;
50  extern PFNGLUNIFORM1FPROC _glUniform1f;
51  extern PFNGLUNIFORMMATRIX4FVPROC _glUniformMatrix4fv;
52  extern PFNGLBINDFRAMEBUFFERPROC _glBindFramebuffer;
53  extern PFNGLGENFRAMEBUFFERSPROC _glGenFramebuffers;
54  extern PFNGLCHECKFRAMEBUFFERSTATUSPROC _glCheckFramebufferStatus;
55  extern PFNGLDELETEFRAMEBUFFERSPROC _glDeleteFramebuffers;
56  extern PFNGLGETUNIFORMLOCATIONPROC _glGetUniformLocation;
57  extern PFNGLFRAMEBUFFERTEXTURE2DPROC _glFramebufferTexture2D;
58  extern PFNGLCOMPRESSEDTEXIMAGE2DPROC _glCompressedTexImage2D;
59  extern PFNGLBINDBUFFERPROC _glBindBuffer;
60  extern PFNGLGENBUFFERSPROC _glGenBuffers;
61  extern PFNGLBUFFERDATAPROC _glBufferData;
62  extern PFNGLGETPROGRAMIVPROC _glGetProgramiv;
63  extern PFNGLGENERATEMIPMAPPROC _glGenerateMipmap;
64  extern PFNGLSTENCILOPSEPARATEPROC _glStencilOpSeparate;
65  extern PFNGLGENRENDERBUFFERSPROC _glGenRenderbuffers;
66  extern PFNGLBINDRENDERBUFFERPROC _glBindRenderbuffer;
67  extern PFNGLRENDERBUFFERSTORAGEPROC _glRenderbufferStorage;
68  extern PFNGLFRAMEBUFFERRENDERBUFFERPROC _glFramebufferRenderbuffer;
69  extern PFNGLDELETERENDERBUFFERSPROC _glDeleteRenderbuffers;
70  extern PFNGLDELETESHADERPROC _glDeleteShader;
71  extern PFNGLDELETEBUFFERSPROC _glDeleteBuffers;
72  extern PFNGLGETPROGRAMINFOLOGPROC _glGetProgramInfoLog;
73  extern PFNGLBLENDEQUATIONPROC _glBlendEquation;
74  extern PFNGLBLENDFUNCSEPARATEPROC _glBlendFuncSeparate;
75  extern PFNGLBLENDEQUATIONSEPARATEPROC _glBlendEquationSeparate;
76  extern PFNGLGETATTRIBLOCATIONPROC _glGetAttribLocation;
78 }
79 
80 #elif __ANDROID__
81 # include "GLES2/gl2.h"
82 # define GL_GLEXT_PROTOTYPES
83 # include "GLES2/gl2ext.h"
84 
85 #elif __APPLE__
86 # include <TargetConditionals.h>
87 # if TARGET_OS_IPHONE
88 # define GL_ETC1_RGB8_OES 0x8D64
89 # include <OpenGLES/ES2/gl.h>
90 # include <OpenGLES/ES2/glext.h>
91 # include <OpenGLES/ES1/gl.h>
92 # include <OpenGLES/ES1/glext.h>
93 # else
94 # define GL_GLEXT_PROTOTYPES
95 # include "SDL_opengl.h"
96 
97 # define GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG 0x8C00
98 # define GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG 0x8C01
99 # define GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG 0x8C02
100 # define GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG 0x8C03
101 
102 # define GL_ETC1_RGB8_OES 0x8D64
103 # endif
104 #elif EMSCRIPTEN
105 # include "GLES2/gl2.h"
106 # define GL_GLEXT_PROTOTYPES
107 # include "GLES2/gl2ext.h"
108 #elif __unix__
109 # define GL_GLEXT_PROTOTYPES
110 # include "SDL_opengl.h"
111 
112 # define GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG 0x8C00
113 # define GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG 0x8C01
114 # define GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG 0x8C02
115 # define GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG 0x8C03
116 
117 # define GL_ETC1_RGB8_OES 0x8D64
118 #endif
119 #endif
120 
121 
122 
123 #if _WIN32
124 # define GLPREF _
125 #else
126 # define GLPREF
127 #endif
128 
129 #define PASTER(x,y) x ## y
130 #define EVALUATOR(x,y) PASTER(x,y)
131 #define DECLARE_GLEXT(y) EVALUATOR(GLPREF,y)
132 
134 #define oxglShaderSource DECLARE_GLEXT(glShaderSource)
135 #define oxglUseProgram DECLARE_GLEXT(glUseProgram)
136 #define oxglVertexAttribPointer DECLARE_GLEXT(glVertexAttribPointer)
137 #define oxglActiveTexture DECLARE_GLEXT(glActiveTexture)
138 #define oxglEnableVertexAttribArray DECLARE_GLEXT(glEnableVertexAttribArray)
139 #define oxglDisableVertexAttribArray DECLARE_GLEXT(glDisableVertexAttribArray)
140 #define oxglDeleteProgram DECLARE_GLEXT(glDeleteProgram)
141 #define oxglGetShaderiv DECLARE_GLEXT(glGetShaderiv)
142 #define oxglGetShaderInfoLog DECLARE_GLEXT(glGetShaderInfoLog)
143 #define oxglCreateShader DECLARE_GLEXT(glCreateShader)
144 #define oxglCreateProgram DECLARE_GLEXT(glCreateProgram)
145 #define oxglAttachShader DECLARE_GLEXT(glAttachShader)
146 #define oxglCompileShader DECLARE_GLEXT(glCompileShader)
147 #define oxglDetachShader DECLARE_GLEXT(glDetachShader)
148 #define oxglBindAttribLocation DECLARE_GLEXT(glBindAttribLocation)
149 #define oxglLinkProgram DECLARE_GLEXT(glLinkProgram)
150 #define oxglUniform1i DECLARE_GLEXT(glUniform1i)
151 #define oxglUniform2f DECLARE_GLEXT(glUniform2f)
152 #define oxglUniform2fv DECLARE_GLEXT(glUniform2fv)
153 #define oxglUniform3fv DECLARE_GLEXT(glUniform3fv)
154 #define oxglUniform4fv DECLARE_GLEXT(glUniform4fv)
155 #define oxglUniform1f DECLARE_GLEXT(glUniform1f)
156 #define oxglUniformMatrix4fv DECLARE_GLEXT(glUniformMatrix4fv)
157 #define oxglBindFramebuffer DECLARE_GLEXT(glBindFramebuffer)
158 #define oxglGenFramebuffers DECLARE_GLEXT(glGenFramebuffers)
159 #define oxglCheckFramebufferStatus DECLARE_GLEXT(glCheckFramebufferStatus)
160 #define oxglDeleteFramebuffers DECLARE_GLEXT(glDeleteFramebuffers)
161 #define oxglGetUniformLocation DECLARE_GLEXT(glGetUniformLocation)
162 #define oxglFramebufferTexture2D DECLARE_GLEXT(glFramebufferTexture2D)
163 #define oxglCompressedTexImage2D DECLARE_GLEXT(glCompressedTexImage2D)
164 #define oxglBindBuffer DECLARE_GLEXT(glBindBuffer)
165 #define oxglGenBuffers DECLARE_GLEXT(glGenBuffers)
166 #define oxglBufferData DECLARE_GLEXT(glBufferData)
167 #define oxglGetProgramiv DECLARE_GLEXT(glGetProgramiv)
168 #define oxglGenerateMipmap DECLARE_GLEXT(glGenerateMipmap)
169 #define oxglStencilOpSeparate DECLARE_GLEXT(glStencilOpSeparate)
170 #define oxglGenRenderbuffers DECLARE_GLEXT(glGenRenderbuffers)
171 #define oxglBindRenderbuffer DECLARE_GLEXT(glBindRenderbuffer)
172 #define oxglRenderbufferStorage DECLARE_GLEXT(glRenderbufferStorage)
173 #define oxglFramebufferRenderbuffer DECLARE_GLEXT(glFramebufferRenderbuffer)
174 #define oxglDeleteRenderbuffers DECLARE_GLEXT(glDeleteRenderbuffers)
175 #define oxglDeleteShader DECLARE_GLEXT(glDeleteShader)
176 #define oxglDeleteBuffers DECLARE_GLEXT(glDeleteBuffers)
177 #define oxglGetProgramInfoLog DECLARE_GLEXT(glGetProgramInfoLog)
178 #define oxglBlendEquation DECLARE_GLEXT(glBlendEquation)
179 #define oxglBlendFuncSeparate DECLARE_GLEXT(glBlendFuncSeparate)
180 #define oxglBlendEquationSeparate DECLARE_GLEXT(glBlendEquationSeparate)
181 #define oxglGetAttribLocation DECLARE_GLEXT(glGetAttribLocation)
182 
184 
185 //#undef PASTER
186 //#undef EVALUATOR
187 
188 namespace oxygine {void checkGLError();}
189 #define CHECKGL() checkGLError()
190 //#define CHECKGL() {}
191 
192 typedef void* (*myGetProcAdress)(const char*);
194 int initGLExtensions(myGetProcAdress);
–oxgl-end–!
Definition: Actor.h:14