Main Page
Modules
Classes
Files
File List
All
Classes
Functions
Variables
Typedefs
Enumerations
Groups
include
SDL_gpu_GLES_2.h
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
#define glMapBuffer glMapBufferOES
26
#define glUnmapBuffer glUnmapBufferOES
27
#define GL_WRITE_ONLY GL_WRITE_ONLY_OES
28
#endif
29
30
31
32
#define GPU_CONTEXT_DATA ContextData_GLES_2
33
#define GPU_IMAGE_DATA ImageData_GLES_2
34
#define GPU_TARGET_DATA TargetData_GLES_2
35
36
37
#define GPU_DEFAULT_TEXTURED_VERTEX_SHADER_SOURCE \
38
"#version 100\n\
39
precision highp float;\n\
40
precision mediump int;\n\
41
\
42
attribute vec2 gpu_Vertex;\n\
43
attribute vec2 gpu_TexCoord;\n\
44
attribute mediump vec4 gpu_Color;\n\
45
uniform mat4 gpu_ModelViewProjectionMatrix;\n\
46
\
47
varying mediump vec4 color;\n\
48
varying vec2 texCoord;\n\
49
\
50
void main(void)\n\
51
{\n\
52
color = gpu_Color;\n\
53
texCoord = vec2(gpu_TexCoord);\n\
54
gl_Position = gpu_ModelViewProjectionMatrix * vec4(gpu_Vertex, 0.0, 1.0);\n\
55
}"
56
57
// Tier 3 uses shader attributes to send position, texcoord, and color data for each vertex.
58
#define GPU_DEFAULT_UNTEXTURED_VERTEX_SHADER_SOURCE \
59
"#version 100\n\
60
precision highp float;\n\
61
precision mediump int;\n\
62
\
63
attribute vec2 gpu_Vertex;\n\
64
attribute mediump vec4 gpu_Color;\n\
65
uniform mat4 gpu_ModelViewProjectionMatrix;\n\
66
\
67
varying mediump vec4 color;\n\
68
\
69
void main(void)\n\
70
{\n\
71
color = gpu_Color;\n\
72
gl_Position = gpu_ModelViewProjectionMatrix * vec4(gpu_Vertex, 0.0, 1.0);\n\
73
}"
74
75
76
#define GPU_DEFAULT_TEXTURED_FRAGMENT_SHADER_SOURCE \
77
"#version 100\n\
78
#ifdef GL_FRAGMENT_PRECISION_HIGH\n\
79
precision highp float;\n\
80
#else\n\
81
precision mediump float;\n\
82
#endif\n\
83
precision mediump int;\n\
84
\
85
varying mediump vec4 color;\n\
86
varying vec2 texCoord;\n\
87
\
88
uniform sampler2D tex;\n\
89
\
90
void main(void)\n\
91
{\n\
92
gl_FragColor = texture2D(tex, texCoord) * color;\n\
93
}"
94
95
#define GPU_DEFAULT_UNTEXTURED_FRAGMENT_SHADER_SOURCE \
96
"#version 100\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
varying mediump vec4 color;\n\
105
\
106
void main(void)\n\
107
{\n\
108
gl_FragColor = color;\n\
109
}"
110
111
112
113
114
typedef
struct
ContextData_GLES_2
115
{
116
SDL_Color last_color;
117
GPU_bool last_use_texturing;
118
unsigned
int
last_shape;
119
GPU_bool last_use_blending;
120
GPU_BlendMode
last_blend_mode;
121
GPU_Rect
last_viewport;
122
GPU_Camera
last_camera;
123
GPU_bool last_camera_inverted;
124
125
GPU_Image
* last_image;
126
GPU_Target
* last_target;
127
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, ...]).
128
unsigned
short
blit_buffer_num_vertices;
129
unsigned
short
blit_buffer_max_num_vertices;
130
unsigned
short
* index_buffer;
// Indexes into the blit buffer so we can use 4 vertices for every 2 triangles (1 quad)
131
unsigned
int
index_buffer_num_vertices;
132
unsigned
int
index_buffer_max_num_vertices;
133
134
// Tier 3 rendering
135
unsigned
int
blit_VBO[2];
// For double-buffering
136
unsigned
int
blit_IBO;
137
GPU_bool blit_VBO_flop;
138
139
GPU_AttributeSource
shader_attributes[16];
140
unsigned
int
attribute_VBO[16];
141
}
ContextData_GLES_2
;
142
143
typedef
struct
ImageData_GLES_2
144
{
145
int
refcount;
146
GPU_bool owns_handle;
147
Uint32 handle;
148
Uint32 format;
149
}
ImageData_GLES_2
;
150
151
typedef
struct
TargetData_GLES_2
152
{
153
int
refcount;
154
Uint32 handle;
155
Uint32 format;
156
}
TargetData_GLES_2
;
157
158
159
160
#endif
TargetData_GLES_2
Definition:
SDL_gpu_GLES_2.h:151
GPU_AttributeSource
Definition:
SDL_gpu.h:578
GPU_Camera
Definition:
SDL_gpu.h:300
ImageData_GLES_2
Definition:
SDL_gpu_GLES_2.h:143
ContextData_GLES_2
Definition:
SDL_gpu_GLES_2.h:114
GPU_BlendMode
Definition:
SDL_gpu.h:159
GPU_Target
Definition:
SDL_gpu.h:398
GPU_Image
Definition:
SDL_gpu.h:263
GPU_Rect
Definition:
SDL_gpu.h:89
Generated by
1.8.6