summaryrefslogtreecommitdiff
path: root/src/sdl.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/sdl.c')
-rw-r--r--src/sdl.c32
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();
+}