|
| 1 | +/* |
| 2 | + Simple DirectMedia Layer |
| 3 | + Copyright (C) 1997-2023 Sam Lantinga <[email protected]> |
| 4 | +
|
| 5 | + This software is provided 'as-is', without any express or implied |
| 6 | + warranty. In no event will the authors be held liable for any damages |
| 7 | + arising from the use of this software. |
| 8 | +
|
| 9 | + Permission is granted to anyone to use this software for any purpose, |
| 10 | + including commercial applications, and to alter it and redistribute it |
| 11 | + freely, subject to the following restrictions: |
| 12 | +
|
| 13 | + 1. The origin of this software must not be misrepresented; you must not |
| 14 | + claim that you wrote the original software. If you use this software |
| 15 | + in a product, an acknowledgment in the product documentation would be |
| 16 | + appreciated but is not required. |
| 17 | + 2. Altered source versions must be plainly marked as such, and must not be |
| 18 | + misrepresented as being the original software. |
| 19 | + 3. This notice may not be removed or altered from any source distribution. |
| 20 | +*/ |
| 21 | +#include "../../SDL_internal.h" |
| 22 | + |
| 23 | +#if defined(SDL_VIDEO_DRIVER_OGC) && defined(SDL_VIDEO_OPENGL) |
| 24 | + |
| 25 | +#include "../SDL_sysvideo.h" |
| 26 | + |
| 27 | +#include "SDL_ogcgl.h" |
| 28 | +#include "SDL_ogcvideo.h" |
| 29 | + |
| 30 | +#include <opengx.h> |
| 31 | + |
| 32 | +typedef struct |
| 33 | +{ |
| 34 | + SDL_Window *window; |
| 35 | + int swap_interval; |
| 36 | +} OGC_GL_Context; |
| 37 | + |
| 38 | +int SDL_OGC_GL_LoadLibrary(_THIS, const char *path) |
| 39 | +{ |
| 40 | + return 0; |
| 41 | +} |
| 42 | + |
| 43 | +void *SDL_OGC_GL_GetProcAddress(_THIS, const char *proc) |
| 44 | +{ |
| 45 | + return ogx_get_proc_address(proc); |
| 46 | +} |
| 47 | + |
| 48 | +void SDL_OGC_GL_UnloadLibrary(_THIS) |
| 49 | +{ |
| 50 | + // nothing to do |
| 51 | +} |
| 52 | + |
| 53 | +SDL_GLContext SDL_OGC_GL_CreateContext(_THIS, SDL_Window * window) |
| 54 | +{ |
| 55 | + OGC_GL_Context *context = SDL_calloc(1, sizeof(*context)); |
| 56 | + context->window = window; |
| 57 | + context->swap_interval = 1; |
| 58 | + ogx_initialize(); |
| 59 | + return context; |
| 60 | +} |
| 61 | + |
| 62 | +int SDL_OGC_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context) |
| 63 | +{ |
| 64 | + return 0; |
| 65 | +} |
| 66 | + |
| 67 | +int SDL_OGC_GL_SetSwapInterval(_THIS, int interval) |
| 68 | +{ |
| 69 | + OGC_GL_Context *context = _this->current_glctx; |
| 70 | + context->swap_interval = interval; |
| 71 | + return 0; |
| 72 | +} |
| 73 | + |
| 74 | +int SDL_OGC_GL_GetSwapInterval(_THIS) |
| 75 | +{ |
| 76 | + OGC_GL_Context *context = _this->current_glctx; |
| 77 | + return context->swap_interval; |
| 78 | +} |
| 79 | + |
| 80 | +int SDL_OGC_GL_SwapWindow(_THIS, SDL_Window * window) |
| 81 | +{ |
| 82 | + OGC_GL_Context *context = _this->current_glctx; |
| 83 | + |
| 84 | + bool vsync = context->swap_interval == 1; |
| 85 | + OGC_video_flip(_this, vsync); |
| 86 | + return 0; |
| 87 | +} |
| 88 | + |
| 89 | +void SDL_OGC_GL_DeleteContext(_THIS, SDL_GLContext context) |
| 90 | +{ |
| 91 | + SDL_free(context); |
| 92 | +} |
| 93 | + |
| 94 | +void SDL_OGC_GL_DefaultProfileConfig(_THIS, int *mask, int *major, int *minor) |
| 95 | +{ |
| 96 | + *mask = SDL_GL_CONTEXT_PROFILE_COMPATIBILITY; |
| 97 | + *major = 1; |
| 98 | + *minor = 1; |
| 99 | +} |
| 100 | + |
| 101 | +#endif /* SDL_VIDEO_DRIVER_OGC */ |
0 commit comments