All Classes Functions Variables Typedefs Enumerations Groups
SDL_gpu_GLES_3.h
1 #ifndef _SDL_GPU_GLES_3_H__
2 #define _SDL_GPU_GLES_3_H__
3 
4 #include "SDL_gpu.h"
5 #include "SDL_platform.h"
6 
7 #if !defined(SDL_GPU_DISABLE_GLES) && !defined(SDL_GPU_DISABLE_GLES_3)
8 
9 #ifdef __IPHONEOS__
10  #include <OpenGLES/ES3/gl.h>
11  #include <OpenGLES/ES3/glext.h>
12 #else
13  #include "GLES3/gl3.h"
14  #include "GLES2/gl2ext.h"
15 #endif
16 
17  #define glVertexAttribI1i glVertexAttrib1f
18  #define glVertexAttribI2i glVertexAttrib2f
19  #define glVertexAttribI3i glVertexAttrib3f
20  #define glVertexAttribI1ui glVertexAttrib1f
21  #define glVertexAttribI2ui glVertexAttrib2f
22  #define glVertexAttribI3ui glVertexAttrib3f
23  #define glMapBuffer glMapBufferOES
24  #define glUnmapBuffer glUnmapBufferOES
25  #define GL_WRITE_ONLY GL_WRITE_ONLY_OES
26 #endif
27 
28 
29 
30 #define GPU_CONTEXT_DATA ContextData_GLES_3
31 #define GPU_IMAGE_DATA ImageData_GLES_3
32 #define GPU_TARGET_DATA TargetData_GLES_3
33 
34 
35 #define GPU_DEFAULT_TEXTURED_VERTEX_SHADER_SOURCE \
36 "#version 300 es\n\
37 precision highp float;\n\
38 precision mediump int;\n\
39 \
40 in vec2 gpu_Vertex;\n\
41 in vec2 gpu_TexCoord;\n\
42 in mediump vec4 gpu_Color;\n\
43 uniform mat4 gpu_ModelViewProjectionMatrix;\n\
44 \
45 out mediump vec4 color;\n\
46 out vec2 texCoord;\n\
47 \
48 void main(void)\n\
49 {\n\
50  color = gpu_Color;\n\
51  texCoord = vec2(gpu_TexCoord);\n\
52  gl_Position = gpu_ModelViewProjectionMatrix * vec4(gpu_Vertex, 0.0, 1.0);\n\
53 }"
54 
55 // Tier 3 uses shader attributes to send position, texcoord, and color data for each vertex.
56 #define GPU_DEFAULT_UNTEXTURED_VERTEX_SHADER_SOURCE \
57 "#version 300 es\n\
58 precision highp float;\n\
59 precision mediump int;\n\
60 \
61 in vec2 gpu_Vertex;\n\
62 in mediump vec4 gpu_Color;\n\
63 uniform mat4 gpu_ModelViewProjectionMatrix;\n\
64 \
65 out mediump vec4 color;\n\
66 \
67 void main(void)\n\
68 {\n\
69  color = gpu_Color;\n\
70  gl_Position = gpu_ModelViewProjectionMatrix * vec4(gpu_Vertex, 0.0, 1.0);\n\
71 }"
72 
73 
74 #define GPU_DEFAULT_TEXTURED_FRAGMENT_SHADER_SOURCE \
75 "#version 300 es\n\
76 #ifdef GL_FRAGMENT_PRECISION_HIGH\n\
77 precision highp float;\n\
78 #else\n\
79 precision mediump float;\n\
80 #endif\n\
81 precision mediump int;\n\
82 \
83 in mediump vec4 color;\n\
84 in vec2 texCoord;\n\
85 \
86 uniform sampler2D tex;\n\
87 \
88 out vec4 fragColor;\n\
89 \
90 void main(void)\n\
91 {\n\
92  fragColor = texture(tex, texCoord) * color;\n\
93 }"
94 
95 #define GPU_DEFAULT_UNTEXTURED_FRAGMENT_SHADER_SOURCE \
96 "#version 300 es\n\
97 #ifdef GL_FRAGMENT_PRECISION_HIGH\n\
98 precision highp float;\n\
99 #else\n\
100 precision mediump float;\n\
101 #endif\n\
102 precision mediump int;\n\
103 \
104 in mediump vec4 color;\n\
105 \
106 out vec4 fragColor;\n\
107 \
108 void main(void)\n\
109 {\n\
110  fragColor = color;\n\
111 }"
112 
113 
114 
115 
116 typedef struct ContextData_GLES_3
117 {
118  SDL_Color last_color;
119  GPU_bool last_use_texturing;
120  unsigned int last_shape;
121  GPU_bool last_use_blending;
122  GPU_BlendMode last_blend_mode;
123  GPU_Rect last_viewport;
124  GPU_Camera last_camera;
125  GPU_bool last_camera_inverted;
126 
127  GPU_Image* last_image;
128  GPU_Target* last_target;
129  float* blit_buffer; // Holds sets of 4 vertices, each with interleaved position, tex coords, and colors (e.g. [x0, y0, z0, s0, t0, r0, g0, b0, a0, ...]).
130  unsigned short blit_buffer_num_vertices;
131  unsigned short blit_buffer_max_num_vertices;
132  unsigned short* index_buffer; // Indexes into the blit buffer so we can use 4 vertices for every 2 triangles (1 quad)
133  unsigned int index_buffer_num_vertices;
134  unsigned int index_buffer_max_num_vertices;
135 
136  // Tier 3 rendering
137  unsigned int blit_VAO;
138  unsigned int blit_VBO[2]; // For double-buffering
139  unsigned int blit_IBO;
140  GPU_bool blit_VBO_flop;
141 
142  GPU_AttributeSource shader_attributes[16];
143  unsigned int attribute_VBO[16];
145 
146 typedef struct ImageData_GLES_3
147 {
148  int refcount;
149  GPU_bool owns_handle;
150  Uint32 handle;
151  Uint32 format;
153 
154 typedef struct TargetData_GLES_3
155 {
156  int refcount;
157  Uint32 handle;
158  Uint32 format;
160 
161 
162 
163 #endif
Definition: SDL_gpu.h:578
Definition: SDL_gpu.h:300
Definition: SDL_gpu_GLES_3.h:146
Definition: SDL_gpu.h:159
Definition: SDL_gpu.h:398
Definition: SDL_gpu_GLES_3.h:116
Definition: SDL_gpu.h:263
Definition: SDL_gpu.h:89
Definition: SDL_gpu_GLES_3.h:154