diff --git a/CMakeLists.txt b/CMakeLists.txt index f42221f..4a66c26 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -54,12 +54,7 @@ elseif (${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") set(LINKER_OPTIMIZED_OPTIONS ${LINKER_OPTIMIZED_OPTIONS} -fdevirtualize-at-ltrans) endif () -add_library(${PROJECT_NAME} SHARED - src/window.cpp - src/context_window.cpp - src/opengl_context.cpp - include/opengl_context.hpp -) +add_library(${PROJECT_NAME} SHARED src/window.cpp src/context_window.cpp) target_precompile_headers(${PROJECT_NAME} PUBLIC include/window.hpp include/basic_data.hpp include/context_window.hpp) target_include_directories(${PROJECT_NAME} PUBLIC $ @@ -97,13 +92,7 @@ configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/windowGlfwGlLibTargets ) -install(FILES - include/window.hpp - include/basic_data.hpp - include/context_window.hpp - include/opengl_context.hpp - DESTINATION include/windowGlfwGlLib -) +install(FILES include/window.hpp include/basic_data.hpp DESTINATION include/windowGlfwGlLib) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/windowGlfwGlLibTargetsConfig.cmake" diff --git a/include/opengl_context.hpp b/include/opengl_context.hpp deleted file mode 100644 index a673fd6..0000000 --- a/include/opengl_context.hpp +++ /dev/null @@ -1,16 +0,0 @@ -// -// Created by postaron on 05/01/2026. -// - -#ifndef WINDOWGLFWGLLIB_OPENGL_CONTEXT_HPP -#define WINDOWGLFWGLLIB_OPENGL_CONTEXT_HPP - -namespace gui { - class Window; -} - -namespace opengl { - [[nodiscard]] bool init_glew(const gui::Window &win) noexcept; -} - -#endif //WINDOWGLFWGLLIB_OPENGL_CONTEXT_HPP diff --git a/include/window.hpp b/include/window.hpp index 5f006a1..c847bd7 100644 --- a/include/window.hpp +++ b/include/window.hpp @@ -16,8 +16,6 @@ namespace gui { public: using modulesType = std::unordered_map; using windowPtr = GLFWwindow *; - static constexpr int default_width{ 1280 }; - static constexpr int default_height{ 720 }; private: static void key_callback(GLFWwindow *window, int key, int scancode, int action, int mods); @@ -34,6 +32,8 @@ namespace gui { modulesType modules; + bool valid{ false }; + explicit Window(const bool debugOpengl, const GLFWframebuffersizefun framebufferCallback, GLFWwindow *shared, @@ -76,7 +76,7 @@ namespace gui { void color_10_bits() noexcept; - [[nodiscard]] bool check_color_depth(int color_depth) noexcept; + bool check_color_depth(int color_depth) noexcept; void opengl_debug() noexcept; } diff --git a/src/opengl_context.cpp b/src/opengl_context.cpp deleted file mode 100644 index 043da1b..0000000 --- a/src/opengl_context.cpp +++ /dev/null @@ -1,33 +0,0 @@ -// -// Created by postaron on 05/01/2026. -// - -#include - -#if defined( _WIN32 ) - -#include - -#endif - -#include "opengl_context.hpp" -#include - -#include "window.hpp" - - -bool opengl::init_glew(const gui::Window &win) noexcept { - win.get_context(); - if (const GLenum error = glewInit(); error != GLEW_OK) { - if (const auto error_callback = glfwSetErrorCallback(nullptr); error_callback != nullptr) { - error_callback(0, reinterpret_cast(glewGetErrorString(error))); - glfwSetErrorCallback(error_callback); - } else { - std::cerr << "Error initializing glew: " - << reinterpret_cast(glewGetErrorString(error)) - << std::endl; - } - return false; - } - return true; -} diff --git a/src/window.cpp b/src/window.cpp index 56eaa5f..acf152f 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -19,10 +19,23 @@ namespace gui { glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0); glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, debugOpengl ? GLFW_TRUE : GLFW_FALSE); wwindow = std::unique_ptr( - glfwCreateWindow(1280, 720, "Billy Sheet tracker", nullptr, shared), + glfwCreateWindow(720, 1280, "Billy Sheet tracker", nullptr, shared), glfwDestroyWindow); - + if (!wwindow) { + valid = false; + return; + } glfwMakeContextCurrent(wwindow.get()); + glewExperimental = true; + if (const GLenum error = glewInit(); error != GLEW_OK) { + valid = false; + if (const auto error_callback = glfwSetErrorCallback(nullptr); error_callback != nullptr) { + error_callback(0, reinterpret_cast(glewGetErrorString(error))); + glfwSetErrorCallback(error_callback); + } + return; + } + valid = true; glfwSetFramebufferSizeCallback(wwindow.get(), framebufferCallback != nullptr ? framebufferCallback : internalFramebufferCallback);