Something went wrong. Try again.
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667//// Created by kam on 20.7.2025.//
#include "Snail.h"#include <iostream>
using namespace Snail;
Window make_window(s32 width, s32 height, GLFWwindow* handle);
Window Snail::init() { glfwInit(); glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GL_TRUE);
GLFWwindow* main_window; try { main_window = glfwCreateWindow(800, 600, "Main Window", nullptr, nullptr); } catch (std::runtime_error& e) { cleanup(); throw; }
glfwMakeContextCurrent(main_window);
// Load GLAD if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress)) { std::cout << "Failed to initialize GLAD" << std::endl; throw std::runtime_error("Failed to initialize GLAD"); }
#ifdef HI_DPI const s32 dpi = 2;#else const s32 dpi = 1;#endif
// Create viewport glViewport(0, 0, 800 * dpi, 600 * dpi); // Set resize callback glfwSetFramebufferSizeCallback(main_window, framebuffer_size_callback); glEnable(GL_DEPTH_TEST); glEnable(GL_PROGRAM_POINT_SIZE); glProvokingVertex(GL_FIRST_VERTEX_CONVENTION);
return make_window(800, 600, main_window);}
void Snail::cleanup() { glfwTerminate();}
void Snail::framebuffer_size_callback(GLFWwindow* window, s32 width, s32 height){ glViewport(0, 0, width, height);}