Beginning writing gui and window wrapper for GLFW
This commit is contained in:
parent
10cb797084
commit
9dfe0faa56
@ -1,11 +1,62 @@
|
||||
cmake_minimum_required(VERSION 3.19 FATAL_ERROR)
|
||||
project(BillySheet)
|
||||
project(BillySheet LANGUAGES CXX C)
|
||||
|
||||
add_executable(BillySheet src/main.cpp)
|
||||
set(SOURCE_HEADERS
|
||||
include/imgui/imconfig.h
|
||||
include/imgui/imgui.h
|
||||
include/imgui/imgui_impl_glfw.h
|
||||
include/imgui/imgui_impl_opengl3.h
|
||||
include/imgui/imgui_impl_opengl3_loader.h
|
||||
include/imgui/imgui_internal.h
|
||||
include/gui.hpp
|
||||
include/gui_data.hpp
|
||||
include/window.hpp)
|
||||
|
||||
set_target_properties(BillySheet PROPERTIES
|
||||
set(SOURCE_FILES
|
||||
src/imgui/imgui.cpp
|
||||
src/imgui/imgui_draw.cpp
|
||||
src/imgui/imgui_impl_glfw.cpp
|
||||
src/imgui/imgui_impl_opengl3.cpp
|
||||
src/imgui/imgui_tables.cpp
|
||||
src/imgui/imgui_widgets.cpp
|
||||
src/main.cpp
|
||||
src/gui.cpp
|
||||
src/gui_data.cpp
|
||||
src/window.cpp)
|
||||
|
||||
set(SOURCES
|
||||
${SOURCE_HEADERS}
|
||||
${SOURCE_FILES})
|
||||
|
||||
option(BUILD_SHARED_LIBS "Build shared libraries" OFF)
|
||||
option(GLFW_BUILD_EXAMPLES "Build the GLFW example programs" OFF)
|
||||
option(GLFW_BUILD_TESTS "Build the GLFW test programs" OFF)
|
||||
option(GLFW_BUILD_DOCS "Build the GLFW documentation" OFF)
|
||||
option(GLFW_INSTALL "Generate installation target" OFF)
|
||||
option(GLFW_VULKAN_STATIC "Assume the Vulkan loader is linked with the application" OFF)
|
||||
add_subdirectory(external/glfw)
|
||||
|
||||
option(SPDLOG_ENABLE_PCH "Build static or shared library using precompiled header to speed up compilation time" ON)
|
||||
option(SPDLOG_BUILD_WARNINGS "Enable compiler warnings" ON)
|
||||
option(SPDLOG_PREVENT_CHILD_FD "Prevent from child processes to inherit log file descriptors" ON)
|
||||
option(SPDLOG_NO_THREAD_ID "prevent spdlog from querying the thread id on each log call if thread id is not needed" ON)
|
||||
option(SPDLOG_NO_TLS "prevent spdlog from using thread local storage" ON)
|
||||
option(SPDLOG_NO_ATOMIC_LEVELS "prevent spdlog from using of std::atomic log levels (use only if your code never modifies log levels concurrently" ON)
|
||||
add_subdirectory(external/spdlog)
|
||||
|
||||
add_executable(BillySheet ${SOURCES})
|
||||
|
||||
target_include_directories(BillySheet PRIVATE include)
|
||||
|
||||
set_target_properties(BillySheet spdlog glfw PROPERTIES
|
||||
CXX_STANDARD 17
|
||||
CXX_STANDARD_REQUIRED ON
|
||||
CXX_EXTENSIONS OFF
|
||||
INTERPROCEDURAL_OPTIMIZATION ON
|
||||
UNITY_BUILD ON)
|
||||
target_precompile_headers(BillySheet PRIVATE ${SOURCE_HEADERS})
|
||||
target_compile_definitions(BillySheet PRIVATE
|
||||
$<$<CONFIG:Debug>:_GLIBCXX_DEBUG>
|
||||
$<$<CONFIG:Debug>:SPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_DEBUG>
|
||||
$<$<CONFIG:Release>:SPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_ERROR>)
|
||||
target_link_libraries(BillySheet glfw spdlog)
|
||||
|
18
include/gui.hpp
Normal file
18
include/gui.hpp
Normal file
@ -0,0 +1,18 @@
|
||||
#ifndef BILLYSHEET_GUI_HPP
|
||||
#define BILLYSHEET_GUI_HPP
|
||||
|
||||
|
||||
namespace gui {
|
||||
class Gui final {
|
||||
private:
|
||||
|
||||
public:
|
||||
Gui() = delete;
|
||||
|
||||
|
||||
|
||||
~Gui() noexcept;
|
||||
};
|
||||
}
|
||||
|
||||
#endif //BILLYSHEET_GUI_HPP
|
16
include/gui_data.hpp
Normal file
16
include/gui_data.hpp
Normal file
@ -0,0 +1,16 @@
|
||||
#ifndef BILLYSHEET_GUI_DATA_HPP
|
||||
#define BILLYSHEET_GUI_DATA_HPP
|
||||
|
||||
namespace gui {
|
||||
class GuiData final {
|
||||
private:
|
||||
// GLFWwindow *window{ nullptr };
|
||||
|
||||
public:
|
||||
GuiData() = delete;
|
||||
~GuiData() noexcept = default;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
#endif //BILLYSHEET_GUI_DATA_HPP
|
25
include/window.hpp
Normal file
25
include/window.hpp
Normal file
@ -0,0 +1,25 @@
|
||||
#ifndef BILLYSHEET_WINDOW_HPP
|
||||
#define BILLYSHEET_WINDOW_HPP
|
||||
|
||||
#include <memory>
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
namespace gui {
|
||||
class Window final {
|
||||
private:
|
||||
static void delete_glfw_window(GLFWwindow *glfWwindow) {
|
||||
glfwDestroyWindow(glfWwindow);
|
||||
glfwTerminate();
|
||||
}
|
||||
|
||||
std::unique_ptr<GLFWwindow, decltype(&delete_glfw_window)> wwindow{ nullptr, delete_glfw_window };
|
||||
|
||||
public:
|
||||
Window();
|
||||
|
||||
~Window() noexcept = default;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
#endif //BILLYSHEET_WINDOW_HPP
|
5
src/gui.cpp
Normal file
5
src/gui.cpp
Normal file
@ -0,0 +1,5 @@
|
||||
#include "gui.hpp"
|
||||
|
||||
gui::Gui::~Gui() noexcept {
|
||||
|
||||
}
|
5
src/gui_data.cpp
Normal file
5
src/gui_data.cpp
Normal file
@ -0,0 +1,5 @@
|
||||
//
|
||||
// Created by postaron on 08/01/2022.
|
||||
//
|
||||
|
||||
#include "gui_data.hpp"
|
@ -1,6 +1,10 @@
|
||||
#include <iostream>
|
||||
#include <spdlog/spdlog.h>
|
||||
#include <spdlog/sinks/stdout_sinks.h>
|
||||
|
||||
int main() {
|
||||
std::cout << "Hello, World!" << std::endl;
|
||||
std::ios::sync_with_stdio(false);
|
||||
spdlog::set_default_logger(spdlog::stdout_logger_st("console"));
|
||||
SPDLOG_WARN("Hello world !");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
13
src/window.cpp
Normal file
13
src/window.cpp
Normal file
@ -0,0 +1,13 @@
|
||||
#include <stdexcept>
|
||||
#include "window.hpp"
|
||||
|
||||
gui::Window::Window() {
|
||||
glfwSetErrorCallback(nullptr);
|
||||
if (glfwInit() == GLFW_FALSE) {
|
||||
throw std::runtime_error("GLFW init failed.");
|
||||
}
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0);
|
||||
wwindow = std::unique_ptr<GLFWwindow, decltype(&delete_glfw_window)>(glfwCreateWindow(600, 800, "Billy Sheet tracker", nullptr, nullptr),
|
||||
delete_glfw_window);
|
||||
}
|
Loading…
Reference in New Issue
Block a user