SDL_gpu  0.11.0
A hardware-accelerated, cross-platform 2D graphics API
SDL_gpu_OpenGL_4.h
Go to the documentation of this file.
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;
100  unsigned int last_shape;
106 
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;
112  unsigned short* index_buffer; // Indexes into the blit buffer so we can use 4 vertices for every 2 triangles (1 quad)
115 
116  // Tier 3 rendering
117  unsigned int blit_VAO;
118  unsigned int blit_VBO[2]; // For double-buffering
119  unsigned int blit_IBO;
121 
123  unsigned int attribute_VBO[16];
125 
126 typedef struct ImageData_OpenGL_4
127 {
128  int refcount;
130  Uint32 handle;
131  Uint32 format;
133 
134 typedef struct TargetData_OpenGL_4
135 {
136  int refcount;
137  Uint32 handle;
138  Uint32 format;
140 
141 
142 
143 #endif
unsigned int index_buffer_num_vertices
GPU_BlendMode last_blend_mode
unsigned int blit_VBO[2]
unsigned int attribute_VBO[16]
unsigned int index_buffer_max_num_vertices
unsigned short * index_buffer
GPU_AttributeSource shader_attributes[16]
unsigned short blit_buffer_num_vertices
unsigned short blit_buffer_max_num_vertices
#define GPU_bool
Definition: SDL_gpu.h:59