diff --git a/GLFramework/CMakeLists.txt b/GLFramework/CMakeLists.txt index 55ffe08..63e48b7 100644 --- a/GLFramework/CMakeLists.txt +++ b/GLFramework/CMakeLists.txt @@ -4,15 +4,10 @@ cmake_minimum_required (VERSION 3.8) # Add source to this project's executable. -add_library (GLFramework "alibi.cpp" "window.cpp") - -file(GLOB vendor_SRC - "${CMAKE_SOURCE_DIR}/vendor/src/*.cpp" - "${CMAKE_SOURCE_DIR}/vendor/src/*.c" -) +add_library (GLFramework "alibi.cpp") target_sources(GLFramework PRIVATE - ${vendor_SRC} + ${CMAKE_SOURCE_DIR}/vendor/src ) target_include_directories(GLFramework PRIVATE diff --git a/GLFramework/include/glf.hpp b/GLFramework/include/glf.hpp index 72e0aea..8791b29 100644 --- a/GLFramework/include/glf.hpp +++ b/GLFramework/include/glf.hpp @@ -1,24 +1,2 @@ -#include - #include -#include - -#ifndef glfInit - -void _glfInit() -{ - // Initialize GLFW - int result = glfwInit(); - if (result == GLFW_FALSE) - throw std::exception("Failed to initialize GLFW"); - - glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4); - glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 6); - glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); -} - -#define glfInit _glfInit - -#endif // glfInit - -#include "window.hpp" +#include \ No newline at end of file diff --git a/GLFramework/include/window.hpp b/GLFramework/include/window.hpp deleted file mode 100644 index 32ceaff..0000000 --- a/GLFramework/include/window.hpp +++ /dev/null @@ -1,31 +0,0 @@ -#pragma once - -#include -#include - -namespace glf -{ -#define USER_CALLBACK virtual void -#define LIB_CALLBACK static void - - class IWindow - { - public: - void Create(int width, int height, const char* title, bool fullscreen = false, GLFWwindow* share = nullptr); - void Close() noexcept; - - int ShouldClose(); - - void Display(); - void PollEvents(); // TODO: needed? - - protected: - IWindow(); - - protected: - GLFWwindow* window; - - GLFWmonitor* monitor; - GLFWwindow* share; - }; -} \ No newline at end of file diff --git a/GLFramework/window.cpp b/GLFramework/window.cpp deleted file mode 100644 index 4e4b324..0000000 --- a/GLFramework/window.cpp +++ /dev/null @@ -1,59 +0,0 @@ -#include "window.hpp" - -#include - -namespace glf -{ - IWindow::IWindow() : - window(nullptr), monitor(nullptr), share(nullptr) - { - - } - - void IWindow::Create(int width, int height, const char* title, bool fullscreen /*= false*/, GLFWwindow* share /*= nullptr*/) - { - // Create window - if (window == nullptr) - { - if (fullscreen) - true; // TODO: Implement monitor stuff - - this->share = share; - window = glfwCreateWindow(width, height, title, monitor, share); - if (window == nullptr) - { - throw std::exception("Failed to create GLFWwindow"); - } - - glfwMakeContextCurrent(window); - - // Initialize GLAD - if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress)) - throw std::exception("Failed to initialize GLAD"); - - // Set viewport - glViewport(0, 0, width, height); - } - } - - void IWindow::Close() noexcept - { - glfwDestroyWindow(window); - } - - int IWindow::ShouldClose() - { - return glfwWindowShouldClose(window); - } - - void IWindow::Display() - { - glfwSwapBuffers(window); - } - - void IWindow::PollEvents() - { - glfwPollEvents(); - } - -} \ No newline at end of file diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt index d114e27..e5f535c 100644 --- a/example/CMakeLists.txt +++ b/example/CMakeLists.txt @@ -1,7 +1,7 @@ add_executable(example "main.cpp" - "MyWindow.hpp") +) target_include_directories(example PRIVATE ${CMAKE_SOURCE_DIR}/GLFramework/include diff --git a/example/MyWindow.hpp b/example/MyWindow.hpp deleted file mode 100644 index 9b60b5a..0000000 --- a/example/MyWindow.hpp +++ /dev/null @@ -1,22 +0,0 @@ -#include "glf.hpp" - -using namespace glf; - -class MyWindow : - public IWindow -{ -public: - MyWindow() : - IWindow() - { - Create(800, 600, "Example Window"); - - glfwSetFramebufferSizeCallback(window, FramebufferSizeCallback); - } - -private: - static void FramebufferSizeCallback(GLFWwindow* window, int width, int height) - { - glViewport(0, 0, width, height); - } -}; \ No newline at end of file diff --git a/example/main.cpp b/example/main.cpp index eb28d69..83d3542 100644 --- a/example/main.cpp +++ b/example/main.cpp @@ -1,27 +1,8 @@ #include "glf.hpp" -#include "MyWindow.hpp" int main(int argc, char** argv) { - MyWindow* window = nullptr; - try { - glfInit(); - window = new MyWindow; - } - catch (std::exception e) - { - std::cout << e.what() << std::endl; - return 1; - } - - while (!window->ShouldClose()) - { - glfwPollEvents(); - window->Display(); - } - - window->Close(); - glfwTerminate(); + glfwInit(); return 0; } \ No newline at end of file