My Project
Loading...
Searching...
No Matches
SDL_gpu_OpenGL_2.h
1#ifndef _SDL_GPU_OPENGL_2_H__
2#define _SDL_GPU_OPENGL_2_H__
3
4#include "SDL_gpu.h"
5
6#if !defined(SDL_GPU_DISABLE_OPENGL) && !defined(SDL_GPU_DISABLE_OPENGL_2)
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
26#endif
27
28
29#define GPU_CONTEXT_DATA ContextData_OpenGL_2
30#define GPU_IMAGE_DATA ImageData_OpenGL_2
31#define GPU_TARGET_DATA TargetData_OpenGL_2
32
33
34
35#define GPU_DEFAULT_TEXTURED_VERTEX_SHADER_SOURCE \
36"#version 120\n\
37\
38attribute vec2 gpu_Vertex;\n\
39attribute vec2 gpu_TexCoord;\n\
40attribute vec4 gpu_Color;\n\
41uniform mat4 gpu_ModelViewProjectionMatrix;\n\
42\
43varying vec4 color;\n\
44varying vec2 texCoord;\n\
45\
46void main(void)\n\
47{\n\
48 color = gpu_Color;\n\
49 texCoord = vec2(gpu_TexCoord);\n\
50 gl_Position = gpu_ModelViewProjectionMatrix * vec4(gpu_Vertex, 0.0, 1.0);\n\
51}"
52
53// Tier 3 uses shader attributes to send position, texcoord, and color data for each vertex.
54#define GPU_DEFAULT_UNTEXTURED_VERTEX_SHADER_SOURCE \
55"#version 120\n\
56\
57attribute vec2 gpu_Vertex;\n\
58attribute vec4 gpu_Color;\n\
59uniform mat4 gpu_ModelViewProjectionMatrix;\n\
60\
61varying vec4 color;\n\
62\
63void main(void)\n\
64{\n\
65 color = gpu_Color;\n\
66 gl_Position = gpu_ModelViewProjectionMatrix * vec4(gpu_Vertex, 0.0, 1.0);\n\
67}"
68
69
70#define GPU_DEFAULT_TEXTURED_FRAGMENT_SHADER_SOURCE \
71"#version 120\n\
72\
73varying vec4 color;\n\
74varying vec2 texCoord;\n\
75\
76uniform sampler2D tex;\n\
77\
78void main(void)\n\
79{\n\
80 gl_FragColor = texture2D(tex, texCoord) * color;\n\
81}"
82
83#define GPU_DEFAULT_UNTEXTURED_FRAGMENT_SHADER_SOURCE \
84"#version 120\n\
85\
86varying vec4 color;\n\
87\
88void main(void)\n\
89{\n\
90 gl_FragColor = color;\n\
91}"
92
93
94
96{
97 SDL_Color last_color;
98 GPU_bool last_use_texturing;
99 unsigned int last_shape;
100 GPU_bool last_use_blending;
101 GPU_BlendMode last_blend_mode;
102 GPU_Rect last_viewport;
103 GPU_Camera last_camera;
104 GPU_bool last_camera_inverted;
105
106 GPU_bool last_depth_test;
107 GPU_bool last_depth_write;
108 GPU_ComparisonEnum last_depth_function;
109
110 GPU_Image* last_image;
111 float* blit_buffer; // Holds sets of 4 vertices and 4 tex coords interleaved (e.g. [x0, y0, z0, s0, t0, ...]).
112 unsigned short blit_buffer_num_vertices;
113 unsigned short blit_buffer_max_num_vertices;
114 unsigned short* index_buffer; // Indexes into the blit buffer so we can use 4 vertices for every 2 triangles (1 quad)
115 unsigned int index_buffer_num_vertices;
116 unsigned int index_buffer_max_num_vertices;
117
118
119 unsigned int blit_VBO[2]; // For double-buffering
120 unsigned int blit_IBO;
121 GPU_bool blit_VBO_flop;
122
123 GPU_AttributeSource shader_attributes[16];
124 unsigned int attribute_VBO[16];
126
127typedef struct ImageData_OpenGL_2
128{
129 int refcount;
130 GPU_bool owns_handle;
131 Uint32 handle;
132 Uint32 format;
134
136{
137 int refcount;
138 Uint32 handle;
139 Uint32 format;
141
142
143
144#endif
GPU_ComparisonEnum
Definition: SDL_gpu.h:183
Definition: SDL_gpu_OpenGL_2.h:96
Definition: SDL_gpu.h:710
Definition: SDL_gpu.h:227
Definition: SDL_gpu.h:380
Definition: SDL_gpu.h:334
Definition: SDL_gpu.h:138
Definition: SDL_gpu_OpenGL_2.h:128
Definition: SDL_gpu_OpenGL_2.h:136