diff options
| author | Abhinav Prasai <abhinav.prsai@gmail.com> | 2025-11-22 21:06:11 +0000 |
|---|---|---|
| committer | Abhinav Prasai <abhinav.prsai@gmail.com> | 2025-11-22 23:45:16 +0000 |
| commit | 1b53cc099c2b218479e0aaa585e2251b6365cb08 (patch) | |
| tree | eb9003de3ed8748a2397b8bc33841c02b3600e43 /src/sdl.c | |
| parent | b0c0105d6373bc762ab535550ff186b0f0b2063d (diff) | |
create window + draw in context
.
Diffstat (limited to 'src/sdl.c')
| -rw-r--r-- | src/sdl.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/sdl.c b/src/sdl.c new file mode 100644 index 0000000..4614969 --- /dev/null +++ b/src/sdl.c @@ -0,0 +1,32 @@ +#include <stdbool.h> + +#include <SDL2/SDL.h> + +#include "quark.h" +#include "sdl.h" + +SDL_Window* sdl_create_window(const char* title, int w, int h) +{ + return SDL_CreateWindow(title, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, w, h, SDL_WINDOW_RESIZABLE | SDL_WINDOW_OPENGL); +} + +bool sdl_init(void) +{ + if (SDL_Init(SDL_INIT_VIDEO) != 0) { + LOG_ERROR("SDL_Init failed: %s", SDL_GetError()); + return false; + } + + SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0); + SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); + SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24); + + return true; +} + +void sdl_quit(void) +{ + SDL_Quit(); +} |
