/* SPDX-License-Identifier:BSD-3-Clause */ #include "gl.h" #define RGFW_EXPORT #define RGFW_IMPLEMENTATION #define RGFW_OPENGL #include "../../rgfw.h" #include "../renderer.h" #include "../../core/log.h" /* * This function is the entrypoint for the whole game. Its role is to * initialize OpenGL, create the renderer and start the game loop. */ int platform_run(i32 argc, u8 **argv) { (void)argc; (void)argv; log_info("Using OpenGL as rendering backend.\n"); RGFW_glHints *hints = RGFW_getGlobalHints_OpenGL(); hints->major = 3; hints->minor = 3; RGFW_setGlobalHints_OpenGL(hints); RGFW_window *win = RGFW_createWindow("topaz", 0, 0, 800, 600, RGFW_windowCenter | RGFW_windowNoResize | RGFW_windowHide); RGFW_window_createContext_OpenGL(win, hints); int glad_version = gladLoadGL(RGFW_getProcAddress_OpenGL); if (glad_version == 0) { log_error("Failed to initialize OpenGL context.\n"); return -1; } RGFW_window_show(win); RGFW_window_setExitKey(win, RGFW_escape); log_info("OpenGL initialized.\n"); struct renderer_context *context = renderer_context_init(win); while (RGFW_window_shouldClose(win) == RGFW_FALSE) { RGFW_event event; while (RGFW_window_checkEvent(win, &event)); renderer_present(context); } renderer_context_deinit(context); RGFW_window_close(win); return 0; }