The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
SDL_gpu_GLES_2.h
Go to the documentation of this file.
1 #ifndef _SDL_GPU_GLES_2_H__
2 #define _SDL_GPU_GLES_2_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_2)
8 
9 #ifdef __IPHONEOS__
10  #include <OpenGLES/ES2/gl.h>
11  #include <OpenGLES/ES2/glext.h>
12 #else
13  #include "GLES2/gl2.h"
14  #include "GLES2/gl2ext.h"
15 #endif
16 
17  #define glVertexAttribI1i glVertexAttrib1f
18  #define glVertexAttribI2i glVertexAttrib2f
19  #define glVertexAttribI3i glVertexAttrib3f
20  #define glVertexAttribI4i glVertexAttrib4f
21  #define glVertexAttribI1ui glVertexAttrib1f
22  #define glVertexAttribI2ui glVertexAttrib2f
23  #define glVertexAttribI3ui glVertexAttrib3f
24  #define glVertexAttribI4ui glVertexAttrib4f
25 #endif
26 
27 
28 
29 #define GPU_CONTEXT_DATA ContextData_GLES_2
30 #define GPU_IMAGE_DATA ImageData_GLES_2
31 #define GPU_TARGET_DATA TargetData_GLES_2
32 
33 
34 #define GPU_DEFAULT_TEXTURED_VERTEX_SHADER_SOURCE \
35 "#version 100\n\
36 precision mediump float;\n\
37 precision mediump int;\n\
38 \
39 attribute vec2 gpu_Vertex;\n\
40 attribute vec2 gpu_TexCoord;\n\
41 attribute vec4 gpu_Color;\n\
42 uniform mat4 gpu_ModelViewProjectionMatrix;\n\
43 \
44 varying vec4 color;\n\
45 varying vec2 texCoord;\n\
46 \
47 void main(void)\n\
48 {\n\
49  color = gpu_Color;\n\
50  texCoord = vec2(gpu_TexCoord);\n\
51  gl_Position = gpu_ModelViewProjectionMatrix * vec4(gpu_Vertex, 0.0, 1.0);\n\
52 }"
53 
54 // Tier 3 uses shader attributes to send position, texcoord, and color data for each vertex.
55 #define GPU_DEFAULT_UNTEXTURED_VERTEX_SHADER_SOURCE \
56 "#version 100\n\
57 precision mediump float;\n\
58 precision mediump int;\n\
59 \
60 attribute vec2 gpu_Vertex;\n\
61 attribute vec4 gpu_Color;\n\
62 uniform mat4 gpu_ModelViewProjectionMatrix;\n\
63 \
64 varying vec4 color;\n\
65 \
66 void main(void)\n\
67 {\n\
68  color = gpu_Color;\n\
69  gl_Position = gpu_ModelViewProjectionMatrix * vec4(gpu_Vertex, 0.0, 1.0);\n\
70 }"
71 
72 
73 #define GPU_DEFAULT_TEXTURED_FRAGMENT_SHADER_SOURCE \
74 "#version 100\n\
75 precision mediump float;\n\
76 precision mediump int;\n\
77 \
78 varying vec4 color;\n\
79 varying vec2 texCoord;\n\
80 \
81 uniform sampler2D tex;\n\
82 \
83 void main(void)\n\
84 {\n\
85  gl_FragColor = texture2D(tex, texCoord) * color;\n\
86 }"
87 
88 #define GPU_DEFAULT_UNTEXTURED_FRAGMENT_SHADER_SOURCE \
89 "#version 100\n\
90 precision mediump float;\n\
91 precision mediump int;\n\
92 \
93 varying vec4 color;\n\
94 \
95 void main(void)\n\
96 {\n\
97  gl_FragColor = color;\n\
98 }"
99 
100 
101 
102 
103 typedef struct ContextData_GLES_2
104 {
105  SDL_Color last_color;
107  unsigned int last_shape;
113 
116  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, ...]).
117  unsigned short blit_buffer_num_vertices;
119  unsigned short* index_buffer; // Indexes into the blit buffer so we can use 4 vertices for every 2 triangles (1 quad)
122 
123  // Tier 3 rendering
124  unsigned int blit_VBO[2]; // For double-buffering
128 
130  unsigned int attribute_VBO[16];
132 
133 typedef struct ImageData_GLES_2
134 {
135  int refcount;
136  Uint32 handle;
137  Uint32 format;
139 
140 typedef struct TargetData_GLES_2
141 {
142  int refcount;
143  Uint32 handle;
144  Uint32 format;
146 
147 
148 
149 #endif
GPU_Target * last_target
unsigned int index_buffer_num_vertices
struct TargetData_GLES_2 TargetData_GLES_2
unsigned short blit_buffer_num_vertices
GPU_ShaderBlock shader_block[2]
GPU_Camera last_camera
unsigned int blit_VBO[2]
GPU_AttributeSource shader_attributes[16]
unsigned short * index_buffer
GPU_Image * last_image
unsigned short blit_buffer_max_num_vertices
GPU_ShaderBlock current_shader_block
struct ContextData_GLES_2 ContextData_GLES_2
struct ImageData_GLES_2 ImageData_GLES_2
GPU_BlendMode last_blend_mode
unsigned int last_shape
unsigned int attribute_VBO[16]
unsigned int index_buffer_max_num_vertices