logger inject
This commit is contained in:
@@ -48,6 +48,13 @@ set(SRC
|
|||||||
${imgui_DIR}/backends/imgui_impl_opengl3.cpp
|
${imgui_DIR}/backends/imgui_impl_opengl3.cpp
|
||||||
${imgui_DIR}/backends/imgui_impl_glfw.cpp)
|
${imgui_DIR}/backends/imgui_impl_glfw.cpp)
|
||||||
|
|
||||||
|
#====================
|
||||||
|
# needed for the spdlogger implemntation
|
||||||
|
# this is not nice, but it won't work when, e.g. doing it from lower level cmake files
|
||||||
|
add_compile_options("$<$<C_COMPILER_ID:MSVC>:/utf-8>")
|
||||||
|
add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/utf-8>")
|
||||||
|
#====================
|
||||||
|
|
||||||
add_executable(${PROJECT_NAME} ${SRC})
|
add_executable(${PROJECT_NAME} ${SRC})
|
||||||
|
|
||||||
message(STATUS "Linking " pixelariumimagelib)
|
message(STATUS "Linking " pixelariumimagelib)
|
||||||
|
|||||||
@@ -5,8 +5,14 @@ set(UTILSLIBSRC
|
|||||||
|
|
||||||
add_library(${UTILSLIBNAME} STATIC ${UTILSLIBSRC})
|
add_library(${UTILSLIBNAME} STATIC ${UTILSLIBSRC})
|
||||||
|
|
||||||
|
# won't work
|
||||||
|
# target_compile_options(${UTILSLIBNAME}
|
||||||
|
# PRIVATE
|
||||||
|
# "$<$<C_COMPILER_ID:MSVC>:/utf-8>"
|
||||||
|
# "$<$<CXX_COMPILER_ID:MSVC>:/utf-8>")
|
||||||
|
|
||||||
target_include_directories(${UTILSLIBNAME}
|
target_include_directories(${UTILSLIBNAME}
|
||||||
PRIVATE ${spdlog_DIR}/include)
|
PRIVATE ${spdlog_DIR}/include)
|
||||||
|
|
||||||
target_link_libraries(${UTILSLIBNAME}
|
target_link_libraries(${UTILSLIBNAME}
|
||||||
PRIVATE spdlog::spdlog_header_only)
|
PRIVATE spdlog::spdlog_header_only)
|
||||||
|
|||||||
+1
-86
@@ -32,92 +32,7 @@ using namespace pixelarium::imaging;
|
|||||||
return ImVec2(img.GetImage().cols * fact, img.GetImage().rows * fact);
|
return ImVec2(img.GetImage().cols * fact, img.GetImage().rows * fact);
|
||||||
}
|
}
|
||||||
|
|
||||||
pixelarium::ui::AppGLFW::AppGLFW(std::unique_ptr<utils::log::ILog>& log) : _logger(log.get())
|
void pixelarium::ui::AppGLFW::InitMainWindow()
|
||||||
{
|
|
||||||
glfwSetErrorCallback(glfw_error_callback);
|
|
||||||
if (!glfwInit())
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Decide GL+GLSL versions
|
|
||||||
#if defined(IMGUI_IMPL_OPENGL_ES2)
|
|
||||||
// GL ES 2.0 + GLSL 100
|
|
||||||
const char* glsl_version = "#version 100";
|
|
||||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2);
|
|
||||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0);
|
|
||||||
glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_ES_API);
|
|
||||||
#elif defined(__APPLE__)
|
|
||||||
// GL 3.2 + GLSL 150
|
|
||||||
const char* glsl_version = "#version 150";
|
|
||||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
|
|
||||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2);
|
|
||||||
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); // 3.2+ only
|
|
||||||
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); // Required on Mac
|
|
||||||
#else
|
|
||||||
// GL 3.0 + GLSL 130
|
|
||||||
#ifdef __linux__
|
|
||||||
const char* glsl_version = "#version 130";
|
|
||||||
#else
|
|
||||||
const char* glsl_version = reinterpret_cast<const char*>("#version 130");
|
|
||||||
#endif
|
|
||||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
|
|
||||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0);
|
|
||||||
// glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); // 3.2+
|
|
||||||
// only glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); // 3.0+ only
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// int count;
|
|
||||||
// GLFWmonitor** monitors = glfwGetMonitors(&count); // at [0] is always the
|
|
||||||
// main monitor GLFWmonitor* monitor = monitors[1];
|
|
||||||
GLFWmonitor* monitor = glfwGetPrimaryMonitor();
|
|
||||||
int xpos, ypos, width, height;
|
|
||||||
glfwGetMonitorWorkarea(monitor, &xpos, &ypos, &width, &height);
|
|
||||||
|
|
||||||
// lg::Logger::Info("screen width " + std::to_string(width) +
|
|
||||||
// " screen heigth " + std::to_string(height));
|
|
||||||
|
|
||||||
// Create window with graphics context
|
|
||||||
window = glfwCreateWindow(1200, 800, PIXELARIUM_TITLE, nullptr, nullptr);
|
|
||||||
if (window == nullptr)
|
|
||||||
{
|
|
||||||
// lg::Logger::Error("no window");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
glfwMakeContextCurrent(window);
|
|
||||||
glfwSwapInterval(1); // Enable vsync
|
|
||||||
|
|
||||||
// Setup Dear ImGui context
|
|
||||||
IMGUI_CHECKVERSION();
|
|
||||||
ImGui::CreateContext();
|
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
|
||||||
(void)io;
|
|
||||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
|
||||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
|
|
||||||
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
|
|
||||||
io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable; // Enable Multi-Viewport / Platform
|
|
||||||
// Windows
|
|
||||||
// io.ConfigViewportsNoAutoMerge = true;
|
|
||||||
// io.ConfigViewportsNoTaskBarIcon = true;
|
|
||||||
|
|
||||||
// Setup Dear ImGui style
|
|
||||||
ImGui::StyleColorsDark();
|
|
||||||
|
|
||||||
ImGuiStyle& style = ImGui::GetStyle();
|
|
||||||
|
|
||||||
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
|
||||||
{
|
|
||||||
style.WindowRounding = 0.0f;
|
|
||||||
style.Colors[ImGuiCol_WindowBg].w = 1.0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Setup Platform/Renderer backends
|
|
||||||
ImGui_ImplGlfw_InitForOpenGL(window, true);
|
|
||||||
ImGui_ImplOpenGL3_Init(glsl_version);
|
|
||||||
}
|
|
||||||
|
|
||||||
pixelarium::ui::AppGLFW::AppGLFW()
|
|
||||||
{
|
{
|
||||||
glfwSetErrorCallback(glfw_error_callback);
|
glfwSetErrorCallback(glfw_error_callback);
|
||||||
if (!glfwInit())
|
if (!glfwInit())
|
||||||
|
|||||||
+3
-2
@@ -27,11 +27,12 @@ enum LogLevelSelection
|
|||||||
class AppGLFW
|
class AppGLFW
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
AppGLFW();
|
AppGLFW() { this->InitMainWindow(); }
|
||||||
AppGLFW(std::unique_ptr<utils::log::ILog>& log);
|
AppGLFW(std::unique_ptr<utils::log::ILog>& log) : _logger(log.get()) { this->InitMainWindow(); }
|
||||||
int Run();
|
int Run();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void InitMainWindow();
|
||||||
void MenuBar();
|
void MenuBar();
|
||||||
void LoadImageProt();
|
void LoadImageProt();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user