this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

at master 168 lines 3.9 kB view raw
1#ifndef _SDL_GPU_GLES_3_H__ 2#define _SDL_GPU_GLES_3_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_3) 8 9#ifdef __IPHONEOS__ 10 #include <OpenGLES/ES3/gl.h> 11 #include <OpenGLES/ES3/glext.h> 12#elif defined(SDL_GPU_DYNAMIC_GLES_3) 13 #include "gl3stub.h" 14#else 15 #include "GLES3/gl3.h" 16 #include "GLES2/gl2ext.h" 17#endif 18 19 #define glVertexAttribI1i glVertexAttrib1f 20 #define glVertexAttribI2i glVertexAttrib2f 21 #define glVertexAttribI3i glVertexAttrib3f 22 #define glVertexAttribI1ui glVertexAttrib1f 23 #define glVertexAttribI2ui glVertexAttrib2f 24 #define glVertexAttribI3ui glVertexAttrib3f 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_3 33#define GPU_IMAGE_DATA ImageData_GLES_3 34#define GPU_TARGET_DATA TargetData_GLES_3 35 36 37#define GPU_DEFAULT_TEXTURED_VERTEX_SHADER_SOURCE \ 38"#version 300 es\n\ 39precision highp float;\n\ 40precision mediump int;\n\ 41\ 42in vec2 gpu_Vertex;\n\ 43in vec2 gpu_TexCoord;\n\ 44in mediump vec4 gpu_Color;\n\ 45uniform mat4 gpu_ModelViewProjectionMatrix;\n\ 46\ 47out mediump vec4 color;\n\ 48out vec2 texCoord;\n\ 49\ 50void 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 300 es\n\ 60precision highp float;\n\ 61precision mediump int;\n\ 62\ 63in vec2 gpu_Vertex;\n\ 64in mediump vec4 gpu_Color;\n\ 65uniform mat4 gpu_ModelViewProjectionMatrix;\n\ 66\ 67out mediump vec4 color;\n\ 68\ 69void 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 300 es\n\ 78#ifdef GL_FRAGMENT_PRECISION_HIGH\n\ 79precision highp float;\n\ 80#else\n\ 81precision mediump float;\n\ 82#endif\n\ 83precision mediump int;\n\ 84\ 85in mediump vec4 color;\n\ 86in vec2 texCoord;\n\ 87\ 88uniform sampler2D tex;\n\ 89\ 90out vec4 fragColor;\n\ 91\ 92void main(void)\n\ 93{\n\ 94 fragColor = texture(tex, texCoord) * color;\n\ 95}" 96 97#define GPU_DEFAULT_UNTEXTURED_FRAGMENT_SHADER_SOURCE \ 98"#version 300 es\n\ 99#ifdef GL_FRAGMENT_PRECISION_HIGH\n\ 100precision highp float;\n\ 101#else\n\ 102precision mediump float;\n\ 103#endif\n\ 104precision mediump int;\n\ 105\ 106in mediump vec4 color;\n\ 107\ 108out vec4 fragColor;\n\ 109\ 110void main(void)\n\ 111{\n\ 112 fragColor = color;\n\ 113}" 114 115 116 117 118typedef struct ContextData_GLES_3 119{ 120 SDL_Color last_color; 121 GPU_bool last_use_texturing; 122 unsigned int last_shape; 123 GPU_bool last_use_blending; 124 GPU_BlendMode last_blend_mode; 125 GPU_Rect last_viewport; 126 GPU_Camera last_camera; 127 GPU_bool last_camera_inverted; 128 129 GPU_bool last_depth_test; 130 GPU_bool last_depth_write; 131 GPU_ComparisonEnum last_depth_function; 132 133 GPU_Image* last_image; 134 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, ...]). 135 unsigned short blit_buffer_num_vertices; 136 unsigned short blit_buffer_max_num_vertices; 137 unsigned short* index_buffer; // Indexes into the blit buffer so we can use 4 vertices for every 2 triangles (1 quad) 138 unsigned int index_buffer_num_vertices; 139 unsigned int index_buffer_max_num_vertices; 140 141 // Tier 3 rendering 142 unsigned int blit_VAO; 143 unsigned int blit_VBO[2]; // For double-buffering 144 unsigned int blit_IBO; 145 GPU_bool blit_VBO_flop; 146 147 GPU_AttributeSource shader_attributes[16]; 148 unsigned int attribute_VBO[16]; 149} ContextData_GLES_3; 150 151typedef struct ImageData_GLES_3 152{ 153 int refcount; 154 GPU_bool owns_handle; 155 Uint32 handle; 156 Uint32 format; 157} ImageData_GLES_3; 158 159typedef struct TargetData_GLES_3 160{ 161 int refcount; 162 Uint32 handle; 163 Uint32 format; 164} TargetData_GLES_3; 165 166 167 168#endif