summaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
authorLevent Kaya <levent@dev>2025-11-06 11:49:26 +0300
committerLevent Kaya <levent@dev>2025-11-06 11:49:26 +0300
commitc804988f70ad580b45ab5adda64022f462dc6599 (patch)
tree2568944c8a7d0950a5bff73bd2905109e123a4a3 /src/main.cpp
parentd2bb3c90b4e8dffaabb2315df13a2dbd362bb1b7 (diff)
[feature] global logger implemented
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp148
1 files changed, 76 insertions, 72 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 0a23004..b9a327f 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1,14 +1,12 @@
// src/main.cpp
#include <iostream>
-// spdlog
-#include <spdlog/spdlog.h>
-
// Prevent GLFW from including OpenGL headers (so glad can provide them)
#define GLFW_INCLUDE_NONE
#include <GLFW/glfw3.h>
-// GL loader (glad) - include after GLFW_INCLUDE_NONE so glad can provide GL headers
+// GL loader (glad) - include after GLFW_INCLUDE_NONE so glad can provide GL
+// headers
#if __has_include("glad/glad.h")
#include <glad/glad.h>
#define HAVE_GLAD 1
@@ -16,103 +14,109 @@
#define HAVE_GLAD 0
#endif
-// Now include ImGui and its backends (they expect glfw + GL loader to be present)
+// Now include ImGui and its backends (they expect glfw + GL loader to be
+// present)
#include "imgui.h"
#include "backends/imgui_impl_glfw.h"
#include "backends/imgui_impl_opengl3.h"
-int main(int argc, char** argv) {
- // init logger
- try {
- spdlog::set_level(spdlog::level::info);
- spdlog::info("BoltDBG demo starting (spdlog initialized).");
- } catch (const std::exception &e) {
- std::cerr << "spdlog init failed: " << e.what() << std::endl;
- }
+#include <boltdbg/util/logger.h>
+
+int main(int argc, char **argv)
+{
- if (!glfwInit()) {
- spdlog::error("Failed to initialize GLFW");
- return 1;
+ if(!glfwInit())
+ {
+ LOG_ERROR("Failed to initialize GLFW");
+ return 1;
}
- // GL settings (3.3 core as example)
- const char* glsl_version = "#version 330";
- glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
- glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
+ // GL settings (3.3 core as example)
+ const char *glsl_version = "#version 330";
+ glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
+ glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
#if __APPLE__
- glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
- glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
+ glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
+ glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
#endif
- GLFWwindow* window = glfwCreateWindow(1280, 720, "BoltDBG - ImGui + spdlog demo", NULL, NULL);
- if (!window) {
- spdlog::error("Failed to create GLFW window");
- glfwTerminate();
- return 1;
+ GLFWwindow *window
+ = glfwCreateWindow(1280, 720, "BoltDBG", NULL, NULL);
+ if(!window)
+ {
+ LOG_ERROR("Failed to create GLFW window");
+ glfwTerminate();
+ return 1;
}
- glfwMakeContextCurrent(window);
- glfwSwapInterval(1);
+ glfwMakeContextCurrent(window);
+ glfwSwapInterval(1);
#if HAVE_GLAD
- if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress)) {
- spdlog::error("Failed to initialize GLAD");
- return 1;
+ if(!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress))
+ {
+ LOG_ERROR("Failed to initialize GLAD");
+ return 1;
}
#else
- spdlog::warn("GLAD not detected at compile-time. If you experience GL symbol errors, add glad.");
+ LOG_WARN("GLAD not detected at compile-time. If you experience GL "
+ "symbol errors, add glad.");
#endif
- // ImGui init
- IMGUI_CHECKVERSION();
- ImGui::CreateContext();
- ImGuiIO &io = ImGui::GetIO(); (void)io;
- ImGui::StyleColorsDark();
+ // ImGui init
+ IMGUI_CHECKVERSION();
+ ImGui::CreateContext();
+ ImGuiIO &io = ImGui::GetIO();
+ (void)io;
+ ImGui::StyleColorsDark();
- ImGui_ImplGlfw_InitForOpenGL(window, true);
- ImGui_ImplOpenGL3_Init(glsl_version);
+ ImGui_ImplGlfw_InitForOpenGL(window, true);
+ ImGui_ImplOpenGL3_Init(glsl_version);
- spdlog::info("Entering main loop.");
+ LOG_INFO("Entering main loop.");
- bool show_demo = false;
- int click_count = 0;
+ bool show_demo = false;
+ int click_count = 0;
- while (!glfwWindowShouldClose(window)) {
- glfwPollEvents();
+ while(!glfwWindowShouldClose(window))
+ {
+ glfwPollEvents();
- ImGui_ImplOpenGL3_NewFrame();
- ImGui_ImplGlfw_NewFrame();
- ImGui::NewFrame();
+ ImGui_ImplOpenGL3_NewFrame();
+ ImGui_ImplGlfw_NewFrame();
+ ImGui::NewFrame();
- ImGui::Begin("BoltDBG - Demo");
- ImGui::Text("Hello from BoltDBG demo!");
- if (ImGui::Button("Log info with spdlog")) {
- click_count++;
- spdlog::info("Button clicked {} times", click_count);
+ ImGui::Begin("BoltDBG - Demo");
+ ImGui::Text("Hello from BoltDBG demo!");
+ if(ImGui::Button("Log info with spdlog"))
+ {
+ click_count++;
+ LOG_INFO("Button clicked {} times", click_count);
}
- ImGui::Text("Click count: %d", click_count);
- ImGui::End();
+ ImGui::Text("Click count: %d", click_count);
+ ImGui::End();
- if (show_demo) ImGui::ShowDemoWindow(&show_demo);
+ if(show_demo)
+ ImGui::ShowDemoWindow(&show_demo);
- ImGui::Render();
- int display_w, display_h;
- glfwGetFramebufferSize(window, &display_w, &display_h);
- glViewport(0, 0, display_w, display_h);
- glClearColor(0.1f, 0.12f, 0.14f, 1.0f);
- glClear(GL_COLOR_BUFFER_BIT);
- ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
+ ImGui::Render();
+ int display_w, display_h;
+ glfwGetFramebufferSize(window, &display_w, &display_h);
+ glViewport(0, 0, display_w, display_h);
+ glClearColor(0.1f, 0.12f, 0.14f, 1.0f);
+ glClear(GL_COLOR_BUFFER_BIT);
+ ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
- glfwSwapBuffers(window);
+ glfwSwapBuffers(window);
}
- // cleanup
- ImGui_ImplOpenGL3_Shutdown();
- ImGui_ImplGlfw_Shutdown();
- ImGui::DestroyContext();
+ // cleanup
+ ImGui_ImplOpenGL3_Shutdown();
+ ImGui_ImplGlfw_Shutdown();
+ ImGui::DestroyContext();
- glfwDestroyWindow(window);
- glfwTerminate();
+ glfwDestroyWindow(window);
+ glfwTerminate();
- spdlog::info("BoltDBG demo exiting.");
- return 0;
+ LOG_INFO("BoltDBG demo exiting.");
+ return 0;
}