added spdlog library
This commit is contained in:
parent
09500da9b3
commit
a8d0054c9d
4 changed files with 58 additions and 87 deletions
|
@ -91,7 +91,6 @@ FetchContent_Declare(
|
||||||
GIT_REPOSITORY "https://github.com/marovira/lua"
|
GIT_REPOSITORY "https://github.com/marovira/lua"
|
||||||
GIT_TAG "5.4.4"
|
GIT_TAG "5.4.4"
|
||||||
)
|
)
|
||||||
|
|
||||||
FetchContent_MakeAvailable(lua)
|
FetchContent_MakeAvailable(lua)
|
||||||
|
|
||||||
set(LUA_BUILD_INTERPRETER ON CACHE BOOL "Build the Lua interpreter" FORCE)
|
set(LUA_BUILD_INTERPRETER ON CACHE BOOL "Build the Lua interpreter" FORCE)
|
||||||
|
@ -144,8 +143,6 @@ if (NOT raylib_FOUND) # If there's none, fetch and build raylib
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
put_targets_into_folder(FOLDER "raylib" TARGETS raylib uninstall)
|
|
||||||
|
|
||||||
target_link_libraries(${GUI_TARGET_NAME} PRIVATE raylib)
|
target_link_libraries(${GUI_TARGET_NAME} PRIVATE raylib)
|
||||||
|
|
||||||
# Checks if OSX and links appropriate frameworks (Only required on MacOS)
|
# Checks if OSX and links appropriate frameworks (Only required on MacOS)
|
||||||
|
@ -157,11 +154,50 @@ endif()
|
||||||
|
|
||||||
set_common_properties(${GUI_TARGET_NAME})
|
set_common_properties(${GUI_TARGET_NAME})
|
||||||
|
|
||||||
|
# =============
|
||||||
|
# spdlog
|
||||||
|
# =============
|
||||||
|
set(SPDLOG_NO_EXCEPTIONS ON CACHE BOOL "" FORCE)
|
||||||
|
|
||||||
|
FetchContent_Declare(
|
||||||
|
spdlog
|
||||||
|
GIT_REPOSITORY https://github.com/gabime/spdlog.git
|
||||||
|
GIT_TAG v1.15.0
|
||||||
|
)
|
||||||
|
FetchContent_MakeAvailable(spdlog)
|
||||||
|
target_link_libraries(${GUI_TARGET_NAME} PRIVATE spdlog)
|
||||||
|
|
||||||
|
put_targets_into_folder(
|
||||||
|
FOLDER "ThirdParty/spdlog"
|
||||||
|
TARGETS
|
||||||
|
spdlog
|
||||||
|
)
|
||||||
|
|
||||||
|
put_targets_into_folder(
|
||||||
|
FOLDER "ThirdParty/raylib"
|
||||||
|
TARGETS
|
||||||
|
raylib uninstall
|
||||||
|
)
|
||||||
|
|
||||||
|
put_targets_into_folder(
|
||||||
|
FOLDER "ThirdParty/lua"
|
||||||
|
TARGETS
|
||||||
|
lua lua_lib
|
||||||
|
)
|
||||||
|
|
||||||
|
put_targets_into_folder(
|
||||||
|
FOLDER "ThirdParty/glfw"
|
||||||
|
TARGETS
|
||||||
|
glfw update_mappings
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Option to create an includes target
|
# Option to create an includes target
|
||||||
set(SVA_CREATE_INCLUDES_TARGET ON CACHE BOOL "Create an includes target")
|
set(SVA_CREATE_INCLUDES_TARGET ON CACHE BOOL "Create an includes target")
|
||||||
|
|
||||||
if(${SVA_CREATE_INCLUDES_TARGET})
|
if(${SVA_CREATE_INCLUDES_TARGET})
|
||||||
set(INCLUDES_TARGET_NAME "${GUI_TARGET_NAME}_includes")
|
set(INCLUDES_TARGET_NAME "includes")
|
||||||
set(INCLUDE_FILES)
|
set(INCLUDE_FILES)
|
||||||
find_files(
|
find_files(
|
||||||
INCLUDE_FILES
|
INCLUDE_FILES
|
||||||
|
@ -173,11 +209,4 @@ if(${SVA_CREATE_INCLUDES_TARGET})
|
||||||
SOURCES
|
SOURCES
|
||||||
${INCLUDE_FILES}
|
${INCLUDE_FILES}
|
||||||
)
|
)
|
||||||
set_target_properties(${INCLUDES_TARGET_NAME} PROPERTIES FOLDER "sva")
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
put_targets_into_folder(
|
|
||||||
FOLDER "sva"
|
|
||||||
TARGETS
|
|
||||||
${TEST_TARGET_NAME}
|
|
||||||
)
|
|
||||||
|
|
|
@ -1,56 +0,0 @@
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <iostream>
|
|
||||||
#include <unordered_map>
|
|
||||||
|
|
||||||
namespace sva
|
|
||||||
{
|
|
||||||
class Logging
|
|
||||||
{
|
|
||||||
std::unordered_map<size_t, std::string> m_Level_Names;
|
|
||||||
size_t m_Active_Level;
|
|
||||||
std::ostream& m_Stream;
|
|
||||||
public:
|
|
||||||
Logging(std::ostream& stream);
|
|
||||||
|
|
||||||
template<typename T> requires std::is_enum_v<T>
|
|
||||||
std::string& levelName(const T lvl)
|
|
||||||
{
|
|
||||||
return m_Level_Names[static_cast<size_t>(lvl)];
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename ...Args>
|
|
||||||
Logging& logln(Args&& ...args)
|
|
||||||
{
|
|
||||||
m_Stream << " [" << m_Level_Names[m_Active_Level] << "] " << (std::forward<Args>(args) << ...) << std::endl;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T> requires std::is_enum_v<T>
|
|
||||||
Logging& operator()(const T lvl)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
std::string& lvn = m_Level_Names.at(static_cast<size_t>(lvl));
|
|
||||||
}
|
|
||||||
catch (...)
|
|
||||||
{
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
m_Active_Level = static_cast<size_t>(lvl);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef SVA_LOGGING_IMPLEMENTATION
|
|
||||||
#undef SVA_LOGGING_IMPLEMENTATION
|
|
||||||
|
|
||||||
sva::Logging::Logging(std::ostream& stream) : m_Active_Level(0), m_Stream(stream)
|
|
||||||
{
|
|
||||||
m_Level_Names[0] = "General";
|
|
||||||
}
|
|
||||||
#endif
|
|
|
@ -1,5 +1,2 @@
|
||||||
#define RAYGUI_IMPLEMENTATION
|
#define RAYGUI_IMPLEMENTATION
|
||||||
#include <raylibs/raygui.h>
|
#include <raylibs/raygui.h>
|
||||||
|
|
||||||
#define SVA_LOGGING_IMPLEMENTATION
|
|
||||||
#include <logger.hpp>
|
|
33
src/main.cpp
33
src/main.cpp
|
@ -15,15 +15,16 @@
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
// sva logger
|
|
||||||
#include <logger.hpp>
|
|
||||||
|
|
||||||
/* raylib includes */
|
/* raylib includes */
|
||||||
#include <raylib.h>
|
#include <raylib.h>
|
||||||
|
#include <sol/debug.hpp>
|
||||||
|
|
||||||
#include "gui/ComponentStack.hpp"
|
#include "gui/ComponentStack.hpp"
|
||||||
#include "gui/CoreComponents.hpp"
|
#include "gui/CoreComponents.hpp"
|
||||||
|
|
||||||
|
#include <spdlog/spdlog.h>
|
||||||
|
|
||||||
constexpr int window_width = 800;
|
constexpr int window_width = 800;
|
||||||
constexpr int window_height = 650;
|
constexpr int window_height = 650;
|
||||||
constexpr char window_title[] = "Sortiva";
|
constexpr char window_title[] = "Sortiva";
|
||||||
|
@ -39,14 +40,12 @@ enum class logerr_level
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
std::cout << "Darling, I'm Home!\n";
|
#ifdef _DEBUG
|
||||||
|
spdlog::set_level(spdlog::level::debug);
|
||||||
sva::Logging logerr = sva::Logging(std::cerr);
|
spdlog::set_pattern("\n\t%^%v%$\n");
|
||||||
logerr.levelName(logerr_level::Debug) = "Debug";
|
#endif
|
||||||
logerr.levelName(logerr_level::Window) = "Window";
|
spdlog::debug("Darling, I'm Home");
|
||||||
logerr.levelName(logerr_level::SVA) = "SVA";
|
spdlog::set_pattern("[%T %z] [%^%l%$] [thread %t] %v");
|
||||||
|
|
||||||
logerr(logerr_level::Debug);
|
|
||||||
|
|
||||||
/* Window and rendering */
|
/* Window and rendering */
|
||||||
|
|
||||||
|
@ -54,7 +53,7 @@ int main(void)
|
||||||
|
|
||||||
if (!IsWindowReady())
|
if (!IsWindowReady())
|
||||||
{
|
{
|
||||||
logerr(logerr_level::Window).logln("Window could not be created...");
|
spdlog::critical("Window could not be created...");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,9 +62,11 @@ int main(void)
|
||||||
|
|
||||||
SetWindowFocused();
|
SetWindowFocused();
|
||||||
|
|
||||||
|
spdlog::debug("Window created successfully.");
|
||||||
|
|
||||||
bool m_Running = true;
|
|
||||||
ComponentStack::s_WndRunning = &m_Running;
|
bool is_running = true;
|
||||||
|
ComponentStack::s_WndRunning = &is_running;
|
||||||
|
|
||||||
ComponentStack::s_WndWidth = GetRenderWidth();
|
ComponentStack::s_WndWidth = GetRenderWidth();
|
||||||
ComponentStack::s_WndHeight = GetRenderHeight();
|
ComponentStack::s_WndHeight = GetRenderHeight();
|
||||||
|
@ -76,11 +77,11 @@ int main(void)
|
||||||
|
|
||||||
// always on top...
|
// always on top...
|
||||||
SafeClosePopup safe_close_popup;
|
SafeClosePopup safe_close_popup;
|
||||||
safe_close_popup.attach(&m_Running);
|
safe_close_popup.attach(&is_running);
|
||||||
safe_close_popup.wndrsize(ComponentStack::s_WndWidth, ComponentStack::s_WndHeight);
|
safe_close_popup.wndrsize(ComponentStack::s_WndWidth, ComponentStack::s_WndHeight);
|
||||||
|
|
||||||
|
|
||||||
while (m_Running) {
|
while (is_running) {
|
||||||
|
|
||||||
|
|
||||||
if (IsWindowResized())
|
if (IsWindowResized())
|
||||||
|
@ -113,7 +114,7 @@ int main(void)
|
||||||
switch (run_result)
|
switch (run_result)
|
||||||
{
|
{
|
||||||
case 2:
|
case 2:
|
||||||
logerr(logerr_level::SVA).logln("Program exiting abnormally.");
|
spdlog::warn("Program exiting abnormally.");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue