#include #define GLFW_INCLUDE_NONE #include "GLFW/glfw3.h" #include "fmt/std.h" #include "glad/glad.h" #include "cbt/opengl/context.hpp" namespace cbt::opengl { auto context::setup_gl() -> bool { if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress)) { fmt::print("Failed to initialize GLAD\n"); return false; } print_info(); return true; } auto context::print_info() -> void { fmt::print("OpenGL Info:\n"); fmt::print(" vendor | {}\n", std::string_view(reinterpret_cast(glGetString(GL_VENDOR)))); fmt::print(" renderer| {}\n", std::string_view(reinterpret_cast(glGetString(GL_RENDERER)))); fmt::print(" version | {}\n", std::string_view(reinterpret_cast(glGetString(GL_VERSION)))); fmt::print(" glsl | {}\n", std::string_view(reinterpret_cast(glGetString(GL_SHADING_LANGUAGE_VERSION)))); fmt::print("\n"); } context::context(window const& win) { glfwMakeContextCurrent(win.raw()); if (!setup_gl()) { return; } m_valid = true; } context::~context() {} auto context::valid() const -> bool { return m_valid; } }