SDL_gpu  0.11.0
A hardware-accelerated, cross-platform 2D graphics API
renderer_GLES_3.c
Go to the documentation of this file.
1 #include "SDL_gpu_GLES_3.h"
2 #include "SDL_gpu_RendererImpl.h"
3 
4 
5 #if defined(SDL_GPU_DISABLE_GLES) || defined(SDL_GPU_DISABLE_GLES_3)
6 
7 // Dummy implementations
9 void GPU_FreeRenderer_GLES_3(GPU_Renderer* renderer) {}
10 
11 #else
12 
13 #if defined(SDL_GPU_DYNAMIC_GLES_3)
14  #include "gl3stub.c"
15 #endif
16 
17 // Most of the code pulled in from here...
18 #define SDL_GPU_USE_GLES
19 #define SDL_GPU_GL_TIER 3
20 #define SDL_GPU_GLES_MAJOR_VERSION 3
21 #define SDL_GPU_GLSL_VERSION 300
22 
23 #define SDL_GPU_USE_BUFFER_PIPELINE
24 #define SDL_GPU_SKIP_ENABLE_TEXTURE_2D
25 #define SDL_GPU_ASSUME_SHADERS
26 #define SDL_GPU_ASSUME_CORE_FBO
27 // TODO: Make this dynamic because GLES 3.1 supports it
28 #define SDL_GPU_DISABLE_TEXTURE_GETS
29 
30 #include "renderer_GL_common.inl"
32 
33 
35 {
36  GPU_Renderer* renderer;
37  #ifdef SDL_GPU_DYNAMIC_GLES_3
38  if(!gl3stubInit())
39  return NULL;
40  #endif
41 
42  renderer = (GPU_Renderer*)SDL_malloc(sizeof(GPU_Renderer));
43  if(renderer == NULL)
44  return NULL;
45 
46  memset(renderer, 0, sizeof(GPU_Renderer));
47 
48  renderer->id = request;
49  renderer->id.renderer = GPU_RENDERER_GLES_3;
51  renderer->min_shader_version = 100;
53 
54  renderer->default_image_anchor_x = 0.5f;
55  renderer->default_image_anchor_y = 0.5f;
56 
57  renderer->current_context_target = NULL;
58 
59  renderer->impl = (GPU_RendererImpl*)SDL_malloc(sizeof(GPU_RendererImpl));
60  memset(renderer->impl, 0, sizeof(GPU_RendererImpl));
61  SET_COMMON_FUNCTIONS(renderer->impl);
62 
63  return renderer;
64 }
65 
67 {
68  if(renderer == NULL)
69  return;
70 
71  SDL_free(renderer->impl);
72  SDL_free(renderer);
73 }
74 
75 
76 #endif
GPU_RendererID id
Definition: SDL_gpu.h:656
int max_shader_version
Definition: SDL_gpu.h:663
GPU_Target * current_context_target
Definition: SDL_gpu.h:667
GPU_ShaderLanguageEnum shader_language
Definition: SDL_gpu.h:661
#define SET_COMMON_FUNCTIONS(impl)
void GPU_FreeRenderer_GLES_3(GPU_Renderer *renderer)
float default_image_anchor_y
Definition: SDL_gpu.h:674
int min_shader_version
Definition: SDL_gpu.h:662
struct GPU_RendererImpl * impl
Definition: SDL_gpu.h:676
#define SDL_GPU_GLSL_VERSION
float default_image_anchor_x
Definition: SDL_gpu.h:673
GPU_RendererEnum renderer
Definition: SDL_gpu.h:122
GPU_Renderer * GPU_CreateRenderer_GLES_3(GPU_RendererID request)