6 #ifndef TB_RENDERER_GL_H
7 #define TB_RENDERER_GL_H
11 #if defined(TB_RENDERER_GL)
13 #if defined(TB_RENDERER_GLES_1) && defined(TB_RENDERER_GLES_2)
14 #error "Both GLES_1 and GLES_2 defined"
15 #elif defined(TB_RENDERER_GLES_1) && defined(TB_RENDERER_GL3)
16 #error "Both GLES_1 and GL3 defined"
17 #elif defined(TB_RENDERER_GLES_2) && defined(TB_RENDERER_GL3)
18 #error "Both GLES_2 and GL3 defined"
21 #ifdef TB_RENDERER_GLES_1
23 #if defined(ANDROID) || defined(__ANDROID__)
30 #elif defined(TB_RENDERER_GLES_2)
32 #ifndef GL_GLEXT_PROTOTYPES
33 #define GL_GLEXT_PROTOTYPES 1
35 #if defined(__APPLE__)
36 #include <OpenGLES/ES2/gl.h>
37 #include <OpenGLES/ES2/glext.h>
38 #elif defined(__ANDROID__) || defined (__EMSCRIPTEN__)
39 #include <GLES2/gl2.h>
40 #include <GLES2/gl2ext.h>
45 #include <android/ndk-version.h>
47 #if defined(ANDROID) && __NDK_MAJOR__ < 19
48 extern PFNGLBINDVERTEXARRAYOESPROC glBindVertexArrayOESEXT;
49 extern PFNGLDELETEVERTEXARRAYSOESPROC glDeleteVertexArraysOESEXT;
50 extern PFNGLGENVERTEXARRAYSOESPROC glGenVertexArraysOESEXT;
51 #define glDeleteVertexArrays glDeleteVertexArraysOESEXT
52 #define glGenVertexArrays glGenVertexArraysOESEXT
53 #define glBindVertexArray glBindVertexArrayOESEXT
55 #define glGenVertexArrays glGenVertexArraysOES
56 #define glBindVertexArray glBindVertexArrayOES
57 #define glDeleteVertexArrays glDeleteVertexArraysOES
58 #define glIsVertexArray glIsVertexArrayOES
61 #elif defined(TB_RENDERER_GL3)
63 #if defined(__APPLE__)
64 #include <OpenGL/gl3.h>
65 #elif defined (_WIN32)
67 #error "GLEW_STATIC NOT DEFINED!!!"
69 #define GL3_PROTOTYPES 1
73 #define GL_GLEXT_PROTOTYPES 1
77 #else // Standard GL1.1 Renderer
83 #elif defined(TB_SYSTEM_MACOSX) || defined(TB_SYSTEM_IOS)
84 #include <OpenGL/gl.h>
91 #include "renderers/tb_renderer_batcher.h"
97 class TBBitmapGL :
public TBBitmap
100 TBBitmapGL(TBRendererGL *renderer);
102 bool Init(
int width,
int height, uint32_t *data);
103 virtual int Width() {
return m_w; }
104 virtual int Height() {
return m_h; }
105 virtual void SetData(uint32_t *data);
107 TBRendererGL *m_renderer;
112 class TBRendererGL :
public TBRendererBatcher
116 virtual ~TBRendererGL();
120 virtual void BeginPaint(
int render_target_w,
int render_target_h);
121 virtual void EndPaint();
123 virtual TBBitmap *CreateBitmap(
int width,
int height, uint32_t *data);
127 virtual void RenderBatch(Batch *batch);
128 virtual void SetClipRect(
const TBRect &rect);
130 #if defined(TB_RENDERER_GLES_2) || defined(TB_RENDERER_GL3)
132 static const GLuint _NUM_VBOS = 256;
133 GLuint LoadShader(GLenum type,
const GLchar * shaderSrc);
136 GLuint m_vao[_NUM_VBOS];
137 GLuint m_vbo[_NUM_VBOS];
148 #endif // TB_RENDERER_GL
149 #endif // TB_RENDERER_GL_H