2 #include "SDL_platform.h" 8 #define __func__ __FUNCTION__ 11 #define GPU_MAX_ACTIVE_RENDERERS 20 12 #define GPU_MAX_REGISTERED_RENDERERS 10 29 static int _gpu_renderer_order_size = 0;
53 if(_gpu_renderer_map[i] != NULL)
69 if(_gpu_renderer_map[i] != NULL)
71 renderers_array[count] = _gpu_renderer_map[i]->
id;
88 if(_gpu_renderer_register[i].
id.renderer != GPU_RENDERER_UNKNOWN)
104 if(_gpu_renderer_register[i].
id.renderer != GPU_RENDERER_UNKNOWN)
106 renderers_array[count] = _gpu_renderer_register[i].
id;
121 if(_gpu_renderer_register[i].
id.renderer == renderer)
122 return _gpu_renderer_register[i].
id;
152 if(
id.renderer == GPU_RENDERER_UNKNOWN)
157 if(create_renderer == NULL)
162 if(free_renderer == NULL)
168 _gpu_renderer_register[i].
id =
id;
169 _gpu_renderer_register[i].
createFn = create_renderer;
170 _gpu_renderer_register[i].
freeFn = free_renderer;
175 #ifndef SDL_GPU_DISABLE_OPENGL 176 #ifndef SDL_GPU_DISABLE_OPENGL_1_BASE 178 &GPU_CreateRenderer_OpenGL_1_BASE,
182 #ifndef SDL_GPU_DISABLE_OPENGL_1 184 &GPU_CreateRenderer_OpenGL_1,
188 #ifndef SDL_GPU_DISABLE_OPENGL_2 190 &GPU_CreateRenderer_OpenGL_2,
194 #ifndef SDL_GPU_DISABLE_OPENGL_3 198 &GPU_CreateRenderer_OpenGL_3,
202 &GPU_CreateRenderer_OpenGL_3,
207 #ifndef SDL_GPU_DISABLE_OPENGL_4 210 &GPU_CreateRenderer_OpenGL_4,
214 &GPU_CreateRenderer_OpenGL_4,
220 #ifndef SDL_GPU_DISABLE_GLES 221 #ifndef SDL_GPU_DISABLE_GLES_1 223 &GPU_CreateRenderer_GLES_1,
226 #ifndef SDL_GPU_DISABLE_GLES_2 228 &GPU_CreateRenderer_GLES_2,
231 #ifndef SDL_GPU_DISABLE_GLES_3 233 &GPU_CreateRenderer_GLES_3,
244 if(_gpu_renderer_register_is_initialized)
249 _gpu_renderer_register[i].
id.
name =
"Unknown";
250 _gpu_renderer_register[i].
id.
renderer = GPU_RENDERER_UNKNOWN;
251 _gpu_renderer_register[i].
createFn = NULL;
252 _gpu_renderer_register[i].
freeFn = NULL;
256 _gpu_renderer_map[i] = NULL;
261 _gpu_renderer_register_is_initialized = 1;
272 _gpu_renderer_register[i].
id.
name =
"Unknown";
273 _gpu_renderer_register[i].
id.
renderer = GPU_RENDERER_UNKNOWN;
274 _gpu_renderer_register[i].
createFn = NULL;
275 _gpu_renderer_register[i].
freeFn = NULL;
279 _gpu_renderer_map[i] = NULL;
282 _gpu_renderer_register_is_initialized = 0;
283 _gpu_renderer_order_size = 0;
289 if(order_size != NULL)
290 *order_size = _gpu_renderer_order_size;
292 if(order != NULL && _gpu_renderer_order_size > 0)
293 memcpy(order, _gpu_renderer_order, _gpu_renderer_order_size*
sizeof(
GPU_RendererID));
317 memcpy(_gpu_renderer_order, order, order_size*
sizeof(
GPU_RendererID));
318 _gpu_renderer_order_size = order_size;
328 #ifndef SDL_GPU_DISABLE_GLES 329 #ifndef SDL_GPU_DISABLE_GLES3 332 #ifndef SDL_GPU_DISABLE_GLES2 335 #ifndef SDL_GPU_DISABLE_GLES1 340 #ifndef SDL_GPU_DISABLE_OPENGL 347 #ifndef SDL_GPU_DISABLE_OPENGL_4 350 #ifndef SDL_GPU_DISABLE_OPENGL_3 356 #ifndef SDL_GPU_DISABLE_OPENGL_4 359 #ifndef SDL_GPU_DISABLE_OPENGL_3 365 #ifndef SDL_GPU_DISABLE_OPENGL_2 368 #ifndef SDL_GPU_DISABLE_OPENGL_1 374 if(order_size != NULL)
377 if(order != NULL && count > 0)
388 if(_gpu_renderer_register[i].
id.renderer == GPU_RENDERER_UNKNOWN)
391 if(
id.renderer == _gpu_renderer_register[i].
id.renderer)
393 if(_gpu_renderer_register[i].
createFn != NULL)
396 id.name = _gpu_renderer_register[i].
id.
name;
397 result = _gpu_renderer_register[i].
createFn(
id);
417 if(
id.renderer == GPU_RENDERER_UNKNOWN)
422 if(_gpu_renderer_map[i] == NULL)
425 if(
id.renderer == _gpu_renderer_map[i]->
id.renderer)
426 return _gpu_renderer_map[i];
438 if(_gpu_renderer_map[i] == NULL)
449 _gpu_renderer_map[i] = renderer;
468 if(_gpu_renderer_register[i].
id.renderer == GPU_RENDERER_UNKNOWN)
473 _gpu_renderer_register[i].
freeFn(renderer);
489 if(current_renderer == renderer)
494 if(renderer == _gpu_renderer_map[i])
497 _gpu_renderer_map[i] = NULL;
void GPU_FreeRenderer(GPU_Renderer *renderer)
void GPU_FreeRenderer_OpenGL_2(GPU_Renderer *renderer)
#define GPU_RENDERER_CUSTOM_0
void GPU_RegisterRenderer(GPU_RendererID id, GPU_Renderer *(*create_renderer)(GPU_RendererID request), void(*free_renderer)(GPU_Renderer *renderer))
GPU_RendererID GPU_GetRendererID(GPU_RendererEnum renderer)
void GPU_FreeRenderer_GLES_1(GPU_Renderer *renderer)
void GPU_GetRendererOrder(int *order_size, GPU_RendererID *order)
GPU_Renderer *(* createFn)(GPU_RendererID request)
GPU_RendererEnum GPU_ReserveNextRendererEnum(void)
void GPU_SetRendererOrder(int order_size, GPU_RendererID *order)
int GPU_GetNumActiveRenderers(void)
void gpu_init_renderer_register(void)
void GPU_FreeRenderer_OpenGL_1_BASE(GPU_Renderer *renderer)
void GPU_GetActiveRendererList(GPU_RendererID *renderers_array)
GPU_Renderer * GPU_CreateRenderer_OpenGL_4(GPU_RendererID request)
GPU_Renderer * GPU_CreateRenderer_OpenGL_1(GPU_RendererID request)
GPU_Renderer * GPU_CreateRenderer_GLES_3(GPU_RendererID request)
void gpu_free_renderer_memory(GPU_Renderer *renderer)
GPU_Renderer * GPU_GetRenderer(GPU_RendererID id)
int GPU_GetNumRegisteredRenderers(void)
#define GPU_MAX_REGISTERED_RENDERERS
GPU_Renderer * GPU_CreateRenderer_OpenGL_1_BASE(GPU_RendererID request)
void GPU_GetDefaultRendererOrder(int *order_size, GPU_RendererID *order)
DECLSPEC GPU_RendererID SDLCALL GPU_MakeRendererID(const char *name, GPU_RendererEnum renderer, int major_version, int minor_version)
GPU_Renderer * GPU_CreateRenderer_OpenGL_3(GPU_RendererID request)
#define GPU_MAX_ACTIVE_RENDERERS
DECLSPEC void SDLCALL GPU_SetCurrentRenderer(GPU_RendererID id)
void gpu_register_built_in_renderers(void)
void GPU_FreeRenderer_GLES_3(GPU_Renderer *renderer)
void gpu_free_renderer_register(void)
void GPU_FreeRenderer_OpenGL_4(GPU_Renderer *renderer)
GPU_Renderer * GPU_CreateRenderer_OpenGL_2(GPU_RendererID request)
GPU_Renderer * GPU_CreateRenderer_GLES_1(GPU_RendererID request)
void GPU_FreeRenderer_OpenGL_3(GPU_Renderer *renderer)
GPU_RendererEnum renderer
DECLSPEC void SDLCALL GPU_PushErrorCode(const char *function, GPU_ErrorEnum error, const char *details,...)
void(* freeFn)(GPU_Renderer *)
void GPU_FreeRenderer_GLES_2(GPU_Renderer *renderer)
GPU_Renderer * GPU_CreateRenderer_GLES_2(GPU_RendererID request)
void GPU_FreeRenderer_OpenGL_1(GPU_Renderer *renderer)
GPU_Renderer * GPU_CreateRenderer(GPU_RendererID id)
#define GPU_RENDERER_ORDER_MAX
DECLSPEC GPU_Renderer *SDLCALL GPU_GetCurrentRenderer(void)
void GPU_GetRegisteredRendererList(GPU_RendererID *renderers_array)
GPU_Renderer * gpu_create_and_add_renderer(GPU_RendererID id)