this repo has no description
0
fork

Configure Feed

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

at master 146 lines 3.2 kB view raw
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\ 37in vec2 gpu_Vertex;\n\ 38in vec2 gpu_TexCoord;\n\ 39in vec4 gpu_Color;\n\ 40uniform mat4 gpu_ModelViewProjectionMatrix;\n\ 41\ 42out vec4 color;\n\ 43out vec2 texCoord;\n\ 44\ 45void 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\ 55in vec2 gpu_Vertex;\n\ 56in vec4 gpu_Color;\n\ 57uniform mat4 gpu_ModelViewProjectionMatrix;\n\ 58\ 59out vec4 color;\n\ 60\ 61void 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\ 71in vec4 color;\n\ 72in vec2 texCoord;\n\ 73\ 74uniform sampler2D tex;\n\ 75\ 76out vec4 fragColor;\n\ 77\ 78void 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\ 86in vec4 color;\n\ 87\ 88out vec4 fragColor;\n\ 89\ 90void main(void)\n\ 91{\n\ 92 fragColor = color;\n\ 93}" 94 95 96typedef 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_bool last_depth_test; 108 GPU_bool last_depth_write; 109 GPU_ComparisonEnum last_depth_function; 110 111 GPU_Image* last_image; 112 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, ...]). 113 unsigned short blit_buffer_num_vertices; 114 unsigned short blit_buffer_max_num_vertices; 115 unsigned short* index_buffer; // Indexes into the blit buffer so we can use 4 vertices for every 2 triangles (1 quad) 116 unsigned int index_buffer_num_vertices; 117 unsigned int index_buffer_max_num_vertices; 118 119 // Tier 3 rendering 120 unsigned int blit_VAO; 121 unsigned int blit_VBO[2]; // For double-buffering 122 unsigned int blit_IBO; 123 GPU_bool blit_VBO_flop; 124 125 GPU_AttributeSource shader_attributes[16]; 126 unsigned int attribute_VBO[16]; 127} ContextData_OpenGL_4; 128 129typedef struct ImageData_OpenGL_4 130{ 131 int refcount; 132 GPU_bool owns_handle; 133 Uint32 handle; 134 Uint32 format; 135} ImageData_OpenGL_4; 136 137typedef struct TargetData_OpenGL_4 138{ 139 int refcount; 140 Uint32 handle; 141 Uint32 format; 142} TargetData_OpenGL_4; 143 144 145 146#endif