Main Page
Modules
Classes
Files
File List
All
Classes
Functions
Variables
Typedefs
Enumerations
Groups
include
SDL_gpu_OpenGL_4.h
1
#ifndef _SDL_GPU_OPENGL_4_H__
2
#define _SDL_GPU_OPENGL_4_H__
3
4
#include "SDL_gpu.h"
5
6
#if !defined(SDL_GPU_DISABLE_OPENGL) && !defined(SDL_GPU_DISABLE_OPENGL_4)
7
8
// Hacks to fix compile errors due to polluted namespace
9
#ifdef _WIN32
10
#define _WINUSER_H
11
#define _WINGDI_H
12
#endif
13
14
#include "glew.h"
15
16
#if defined(GL_EXT_bgr) && !defined(GL_BGR)
17
#define GL_BGR GL_BGR_EXT
18
#endif
19
#if defined(GL_EXT_bgra) && !defined(GL_BGRA)
20
#define GL_BGRA GL_BGRA_EXT
21
#endif
22
#if defined(GL_EXT_abgr) && !defined(GL_ABGR)
23
#define GL_ABGR GL_ABGR_EXT
24
#endif
25
#endif
26
27
28
#define GPU_CONTEXT_DATA ContextData_OpenGL_4
29
#define GPU_IMAGE_DATA ImageData_OpenGL_4
30
#define GPU_TARGET_DATA TargetData_OpenGL_4
31
32
33
34
#define GPU_DEFAULT_TEXTURED_VERTEX_SHADER_SOURCE \
35
"#version 400\n\
36
\
37
in vec2 gpu_Vertex;\n\
38
in vec2 gpu_TexCoord;\n\
39
in vec4 gpu_Color;\n\
40
uniform mat4 gpu_ModelViewProjectionMatrix;\n\
41
\
42
out vec4 color;\n\
43
out vec2 texCoord;\n\
44
\
45
void main(void)\n\
46
{\n\
47
color = gpu_Color;\n\
48
texCoord = vec2(gpu_TexCoord);\n\
49
gl_Position = gpu_ModelViewProjectionMatrix * vec4(gpu_Vertex, 0.0, 1.0);\n\
50
}"
51
52
#define GPU_DEFAULT_UNTEXTURED_VERTEX_SHADER_SOURCE \
53
"#version 400\n\
54
\
55
in vec2 gpu_Vertex;\n\
56
in vec4 gpu_Color;\n\
57
uniform mat4 gpu_ModelViewProjectionMatrix;\n\
58
\
59
out vec4 color;\n\
60
\
61
void main(void)\n\
62
{\n\
63
color = gpu_Color;\n\
64
gl_Position = gpu_ModelViewProjectionMatrix * vec4(gpu_Vertex, 0.0, 1.0);\n\
65
}"
66
67
68
#define GPU_DEFAULT_TEXTURED_FRAGMENT_SHADER_SOURCE \
69
"#version 400\n\
70
\
71
in vec4 color;\n\
72
in vec2 texCoord;\n\
73
\
74
uniform sampler2D tex;\n\
75
\
76
out vec4 fragColor;\n\
77
\
78
void main(void)\n\
79
{\n\
80
fragColor = texture(tex, texCoord) * color;\n\
81
}"
82
83
#define GPU_DEFAULT_UNTEXTURED_FRAGMENT_SHADER_SOURCE \
84
"#version 400\n\
85
\
86
in vec4 color;\n\
87
\
88
out vec4 fragColor;\n\
89
\
90
void main(void)\n\
91
{\n\
92
fragColor = color;\n\
93
}"
94
95
96
typedef
struct
ContextData_OpenGL_4
97
{
98
SDL_Color last_color;
99
GPU_bool last_use_texturing;
100
unsigned
int
last_shape;
101
GPU_bool last_use_blending;
102
GPU_BlendMode
last_blend_mode;
103
GPU_Rect
last_viewport;
104
GPU_Camera
last_camera;
105
GPU_bool last_camera_inverted;
106
107
GPU_Image
* last_image;
108
GPU_Target
* last_target;
109
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, ...]).
110
unsigned
short
blit_buffer_num_vertices;
111
unsigned
short
blit_buffer_max_num_vertices;
112
unsigned
short
* index_buffer;
// Indexes into the blit buffer so we can use 4 vertices for every 2 triangles (1 quad)
113
unsigned
int
index_buffer_num_vertices;
114
unsigned
int
index_buffer_max_num_vertices;
115
116
// Tier 3 rendering
117
unsigned
int
blit_VAO;
118
unsigned
int
blit_VBO[2];
// For double-buffering
119
unsigned
int
blit_IBO;
120
GPU_bool blit_VBO_flop;
121
122
GPU_AttributeSource
shader_attributes[16];
123
unsigned
int
attribute_VBO[16];
124
}
ContextData_OpenGL_4
;
125
126
typedef
struct
ImageData_OpenGL_4
127
{
128
int
refcount;
129
GPU_bool owns_handle;
130
Uint32 handle;
131
Uint32 format;
132
}
ImageData_OpenGL_4
;
133
134
typedef
struct
TargetData_OpenGL_4
135
{
136
int
refcount;
137
Uint32 handle;
138
Uint32 format;
139
}
TargetData_OpenGL_4
;
140
141
142
143
#endif
ContextData_OpenGL_4
Definition:
SDL_gpu_OpenGL_4.h:96
GPU_AttributeSource
Definition:
SDL_gpu.h:578
ImageData_OpenGL_4
Definition:
SDL_gpu_OpenGL_4.h:126
GPU_Camera
Definition:
SDL_gpu.h:300
TargetData_OpenGL_4
Definition:
SDL_gpu_OpenGL_4.h:134
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