this repo has no description
0
fork

Configure Feed

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

at master 163 lines 4.0 kB view raw
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\ 39precision highp float;\n\ 40precision mediump int;\n\ 41\ 42attribute vec2 gpu_Vertex;\n\ 43attribute vec2 gpu_TexCoord;\n\ 44attribute mediump vec4 gpu_Color;\n\ 45uniform mat4 gpu_ModelViewProjectionMatrix;\n\ 46\ 47varying mediump vec4 color;\n\ 48varying 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 100\n\ 60precision highp float;\n\ 61precision mediump int;\n\ 62\ 63attribute vec2 gpu_Vertex;\n\ 64attribute mediump vec4 gpu_Color;\n\ 65uniform mat4 gpu_ModelViewProjectionMatrix;\n\ 66\ 67varying 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 100\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\ 85varying mediump vec4 color;\n\ 86varying vec2 texCoord;\n\ 87\ 88uniform sampler2D tex;\n\ 89\ 90void 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\ 98precision highp float;\n\ 99#else\n\ 100precision mediump float;\n\ 101#endif\n\ 102precision mediump int;\n\ 103\ 104varying mediump vec4 color;\n\ 105\ 106void main(void)\n\ 107{\n\ 108 gl_FragColor = color;\n\ 109}" 110 111 112 113 114typedef 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_bool last_depth_test; 126 GPU_bool last_depth_write; 127 GPU_ComparisonEnum last_depth_function; 128 129 GPU_Image* last_image; 130 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, ...]). 131 unsigned short blit_buffer_num_vertices; 132 unsigned short blit_buffer_max_num_vertices; 133 unsigned short* index_buffer; // Indexes into the blit buffer so we can use 4 vertices for every 2 triangles (1 quad) 134 unsigned int index_buffer_num_vertices; 135 unsigned int index_buffer_max_num_vertices; 136 137 // Tier 3 rendering 138 unsigned int blit_VBO[2]; // For double-buffering 139 unsigned int blit_IBO; 140 GPU_bool blit_VBO_flop; 141 142 GPU_AttributeSource shader_attributes[16]; 143 unsigned int attribute_VBO[16]; 144} ContextData_GLES_2; 145 146typedef struct ImageData_GLES_2 147{ 148 int refcount; 149 GPU_bool owns_handle; 150 Uint32 handle; 151 Uint32 format; 152} ImageData_GLES_2; 153 154typedef struct TargetData_GLES_2 155{ 156 int refcount; 157 Uint32 handle; 158 Uint32 format; 159} TargetData_GLES_2; 160 161 162 163#endif