--- a/src/glcontext.c Sun May 24 16:48:51 2026 +0200 +++ b/src/glcontext.c Sun May 24 17:26:24 2026 +0200 @@ -29,7 +29,7 @@ #include "ascension/shader.h" #include "ascension/error.h" -#include <GL/glew.h> +#include "glad.h" #include <cx/array_list.h> static void asc_gl_debug_callback( @@ -74,34 +74,28 @@ } } -AscGLContextSettings asc_gl_context_settings_default(int gl_major_version, int gl_minor_version) { - return (AscGLContextSettings) { - .gl_major_version = gl_major_version, - .gl_minor_version = gl_minor_version, - .depth_size = 24, - .vsync = true, - .fullscreen = false, - }; -} +bool asc_gl_context_initialize(AscGLContext *ctx, SDL_Window *window) { + const int gl_major_version = 4; + const int gl_minor_version = 3; -bool asc_gl_context_initialize( - AscGLContext *ctx, - SDL_Window *window, - const AscGLContextSettings *settings -) { SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE); - SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, settings->gl_major_version); - SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, settings->gl_minor_version); - SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, settings->depth_size); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, gl_major_version); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, gl_minor_version); + SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24); SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); ctx->glctx = SDL_GL_CreateContext(window); if (ctx->glctx == NULL) return false; ctx->window = window; - glewExperimental = GL_TRUE; - GLenum err = glewInit(); - if (err == GLEW_OK) { - SDL_GL_SetSwapInterval(settings->vsync ? 1 : 0); + int version = gladLoadGL(SDL_GL_GetProcAddress); + asc_dprintf("Loaded OpenGL %d.%d\n", GLAD_VERSION_MAJOR(version), GLAD_VERSION_MINOR(version)); + if (version == 0) { + asc_error("Loading OpenGL failed."); + SDL_GL_DestroyContext(ctx->glctx); + return false; + } else { + // Enable vsync by default (can be changed by the user later) + SDL_GL_SetSwapInterval(1); glClearColor(0.0f, 0.0f, 0.0f, 1.0f); glEnable(GL_DEBUG_OUTPUT); @@ -117,10 +111,6 @@ ctx->active_program = 0; return true; - } else { - asc_error("glewInit failed: %s", glewGetErrorString(err)); - SDL_GL_DestroyContext(ctx->glctx); - return false; } }