Nimbin[12]?SDL & Graphics / sdl3_opengl / main.cpp

sdl3_opengl files

SDL3 + OpenGL function loading

sdl3 opengl c · oldest file 2026-10-05 · last change 2026-10-05 (4 days ago) · synced 3 days ago

C 98.9% Makefile 1.1%
wget https://git.christianimmanuel.de/sdl-graphics/sdl3_opengl/archive/sdl3_opengl.tar.gz
main.cpp 595 B · 25 lines raw
#include <SDL3/SDL.h>
#include <GLES2/gl2.h>
#include <iostream>
#include <memory>
#include <string_view>

int main(int argc, char* argv[]) {
    SDL_Init(SDL_INIT_VIDEO);

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_Window* win = SDL_CreateWindow(
    "GLES2 test",
    640, 480,
    SDL_WINDOW_OPENGL
);

SDL_GLContext ctx = SDL_GL_CreateContext(win);
SDL_GL_MakeCurrent(win, ctx);

SDL_Log("GL_VERSION: %s", glGetString(GL_VERSION));
return 0;
}