Compare commits
3 Commits
2095152251
...
d373951d91
Author | SHA1 | Date | |
---|---|---|---|
|
d373951d91 | ||
|
99d99280cc | ||
|
6d356f5597 |
35
imgui.ini
35
imgui.ini
@ -1,6 +1,6 @@
|
|||||||
[Window][DockSpace]
|
[Window][DockSpace]
|
||||||
Pos=0,0
|
Pos=0,0
|
||||||
Size=1920,1177
|
Size=1280,720
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
|
|
||||||
[Window][Debug##Default]
|
[Window][Debug##Default]
|
||||||
@ -80,8 +80,8 @@ Collapsed=0
|
|||||||
DockId=0x0000001F,0
|
DockId=0x0000001F,0
|
||||||
|
|
||||||
[Window][Performance##performance]
|
[Window][Performance##performance]
|
||||||
Pos=8,581
|
Pos=8,360
|
||||||
Size=335,588
|
Size=335,352
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x0000001C,0
|
DockId=0x0000001C,0
|
||||||
|
|
||||||
@ -105,7 +105,7 @@ DockId=0x0000000F,0
|
|||||||
|
|
||||||
[Window][Scene Window##SceneWindow]
|
[Window][Scene Window##SceneWindow]
|
||||||
Pos=8,28
|
Pos=8,28
|
||||||
Size=335,551
|
Size=335,330
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x0000001B,0
|
DockId=0x0000001B,0
|
||||||
|
|
||||||
@ -134,29 +134,35 @@ Collapsed=0
|
|||||||
DockId=0x0000001E,0
|
DockId=0x0000001E,0
|
||||||
|
|
||||||
[Window][ Logger##logger]
|
[Window][ Logger##logger]
|
||||||
Pos=345,739
|
Pos=345,282
|
||||||
Size=586,430
|
Size=265,430
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000021,0
|
DockId=0x00000021,0
|
||||||
|
|
||||||
[Window][ Editor##EditorWindow]
|
[Window][ Editor##EditorWindow]
|
||||||
Pos=345,28
|
Pos=345,28
|
||||||
Size=1170,709
|
Size=530,252
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x0000001F,0
|
DockId=0x0000001F,0
|
||||||
|
|
||||||
[Window][ Inspector##InspectorWindow]
|
[Window][ Inspector##InspectorWindow]
|
||||||
Pos=1517,28
|
Pos=877,28
|
||||||
Size=395,1141
|
Size=395,684
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000022,0
|
DockId=0x00000022,0
|
||||||
|
|
||||||
[Window][ Profiler]
|
[Window][ Profiler]
|
||||||
Pos=933,739
|
Pos=612,282
|
||||||
Size=582,430
|
Size=263,430
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000023,0
|
DockId=0x00000023,0
|
||||||
|
|
||||||
|
[Window][Logger Window]
|
||||||
|
Pos=345,282
|
||||||
|
Size=530,430
|
||||||
|
Collapsed=0
|
||||||
|
DockId=0x00000023,1
|
||||||
|
|
||||||
[Table][0xE9E836E4,4]
|
[Table][0xE9E836E4,4]
|
||||||
Column 0 Weight=1.2999
|
Column 0 Weight=1.2999
|
||||||
Column 1 Weight=1.0439
|
Column 1 Weight=1.0439
|
||||||
@ -169,8 +175,13 @@ Column 1 Weight=0.9086
|
|||||||
Column 2 Weight=0.9665
|
Column 2 Weight=0.9665
|
||||||
Column 3 Weight=0.6950
|
Column 3 Weight=0.6950
|
||||||
|
|
||||||
|
[Table][0x801835C4,2]
|
||||||
|
RefScale=16
|
||||||
|
Column 0 Width=30
|
||||||
|
Column 1 Weight=1.0000
|
||||||
|
|
||||||
[Docking][Data]
|
[Docking][Data]
|
||||||
DockSpace ID=0x14621557 Window=0x3DA2F1DE Pos=8,51 Size=1904,1141 Split=X Selected=0xF7365A5A
|
DockSpace ID=0x14621557 Window=0x3DA2F1DE Pos=146,189 Size=1264,684 Split=X Selected=0xF7365A5A
|
||||||
DockNode ID=0x00000020 Parent=0x14621557 SizeRef=884,684 Split=X
|
DockNode ID=0x00000020 Parent=0x14621557 SizeRef=884,684 Split=X
|
||||||
DockNode ID=0x00000013 Parent=0x00000020 SizeRef=335,1142 Split=Y Selected=0x818D04BB
|
DockNode ID=0x00000013 Parent=0x00000020 SizeRef=335,1142 Split=Y Selected=0x818D04BB
|
||||||
DockNode ID=0x0000001B Parent=0x00000013 SizeRef=264,551 HiddenTabBar=1 Selected=0x1D5D92B6
|
DockNode ID=0x0000001B Parent=0x00000013 SizeRef=264,551 HiddenTabBar=1 Selected=0x1D5D92B6
|
||||||
|
@ -166,8 +166,8 @@ Entities:
|
|||||||
ScriptComponent:
|
ScriptComponent:
|
||||||
ScriptPath: assets/scripts/camera.lua
|
ScriptPath: assets/scripts/camera.lua
|
||||||
Transform:
|
Transform:
|
||||||
Position: [578.542908, 200, -169.946655]
|
Position: [881.214233, 200, -162.832016]
|
||||||
Rotation: [0, 160.221146, 0]
|
Rotation: [0, 170.205078, 0]
|
||||||
Scale: [1, 1, 1]
|
Scale: [1, 1, 1]
|
||||||
CameraComponent:
|
CameraComponent:
|
||||||
IsPerspective: true
|
IsPerspective: true
|
||||||
@ -177,13 +177,16 @@ Entities:
|
|||||||
NearPlane: 0.100000001
|
NearPlane: 0.100000001
|
||||||
FarPlane: 7000
|
FarPlane: 7000
|
||||||
- ID: 2
|
- ID: 2
|
||||||
Name: New GameObject 2
|
Name: Grey Cube
|
||||||
Components:
|
Components:
|
||||||
Mesh:
|
Mesh:
|
||||||
MeshPath: assets/models/DefaultMesh.obj
|
MeshPath: assets/models/DefaultMesh.obj
|
||||||
submeshes_len: 0
|
submeshes_len: 1
|
||||||
submeshes: ~
|
submeshes:
|
||||||
|
- vao: 53
|
||||||
|
indexCount: 36
|
||||||
|
textures: ~
|
||||||
Transform:
|
Transform:
|
||||||
Position: [0, 0, 0]
|
Position: [-3.43110847, 248.891235, 0]
|
||||||
Rotation: [0, 0, 0]
|
Rotation: [0, -0, 0]
|
||||||
Scale: [1, 1, 1]
|
Scale: [25, 25, 25]
|
@ -140,7 +140,7 @@ void MeshComponent::Deserialize(const YAML::Node &node)
|
|||||||
|
|
||||||
if (submeshes_len != static_cast<int>(model->submeshes.size()))
|
if (submeshes_len != static_cast<int>(model->submeshes.size()))
|
||||||
{
|
{
|
||||||
g_LoggerWindow->AddLog("[Mesh] Size Mismatch [%d:%d]: Check for Curupted Scene Files", submeshes_len, static_cast<int>(submeshes.size()));
|
g_LoggerWindow->AddLog(LogLevel::Error, "[Mesh] Size Mismatch [%d:%d]: Check for Curupted Scene Files", submeshes_len, static_cast<int>(submeshes.size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Assign submeshes
|
// Assign submeshes
|
||||||
@ -182,7 +182,7 @@ void MeshComponent::Deserialize(const YAML::Node &node)
|
|||||||
}
|
}
|
||||||
if (submeshes_len != static_cast<int>(submeshes.size()))
|
if (submeshes_len != static_cast<int>(submeshes.size()))
|
||||||
{
|
{
|
||||||
g_LoggerWindow->AddLog("[Mesh] Size Mismatch [%d:%d]: Check for Curupted Scene Files", submeshes_len, static_cast<int>(submeshes.size()));
|
g_LoggerWindow->AddLog(LogLevel::Error,"[Mesh] Size Mismatch [%d:%d]: Check for Curupted Scene Files", submeshes_len, static_cast<int>(submeshes.size()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -118,6 +118,7 @@ bool MyEngine::Init(int width, int height, const std::string &title)
|
|||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
ImGui::GetIO().ConfigFlags |= ImGuiConfigFlags_DockingEnable | ImGuiConfigFlags_ViewportsEnable;
|
ImGui::GetIO().ConfigFlags |= ImGuiConfigFlags_DockingEnable | ImGuiConfigFlags_ViewportsEnable;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Path to your font files
|
// Path to your font files
|
||||||
@ -184,13 +185,17 @@ bool MyEngine::Init(int width, int height, const std::string &title)
|
|||||||
// Optionally, call 'onInit' Lua function
|
// Optionally, call 'onInit' Lua function
|
||||||
|
|
||||||
// Some initial logs
|
// Some initial logs
|
||||||
m_LoggerWindow->AddLog("Engine initialized.");
|
|
||||||
m_LoggerWindow->AddLog("Welcome to Tesseract Engine!");
|
m_LoggerWindow->AddLog("Welcome to Tesseract Engine!");
|
||||||
|
|
||||||
m_Running = true;
|
m_Running = true;
|
||||||
m_LastTime = glfwGetTime();
|
m_LastTime = glfwGetTime();
|
||||||
DEBUG_PRINT("[OK] Engine Init ");
|
DEBUG_PRINT("[OK] Engine Init ");
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
g_LoggerWindow->AddLog(LogLevel::Warning, "Warning: You are in Debug Mode. Switch to Releace for more performance");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,8 +6,9 @@
|
|||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include "Icons.h"
|
#include "Icons.h"
|
||||||
#include "Engine/ScopedTimer.h"
|
#include "Engine/ScopedTimer.h"
|
||||||
|
#include "Icons.h"
|
||||||
|
|
||||||
|
|
||||||
// Helper function to format strings
|
|
||||||
static std::string FormatString(const char *fmt, va_list args)
|
static std::string FormatString(const char *fmt, va_list args)
|
||||||
{
|
{
|
||||||
char buffer[1024];
|
char buffer[1024];
|
||||||
@ -15,6 +16,48 @@ static std::string FormatString(const char *fmt, va_list args)
|
|||||||
return std::string(buffer);
|
return std::string(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Choose a default icon for each LogLevel
|
||||||
|
static const char* GetIconForLevel(LogLevel level)
|
||||||
|
{
|
||||||
|
switch (level)
|
||||||
|
{
|
||||||
|
case LogLevel::Warning: return ICON_FA_TRIANGLE_EXCLAMATION;
|
||||||
|
case LogLevel::Error: return ICON_FA_CIRCLE_EXCLAMATION;
|
||||||
|
case LogLevel::Info:
|
||||||
|
default: return ICON_FA_INFO;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Choose a default color for each LogLevel if none is specified.
|
||||||
|
static ImVec4 GetDefaultColorForLevel(LogLevel level)
|
||||||
|
{
|
||||||
|
switch (level)
|
||||||
|
{
|
||||||
|
case LogLevel::Warning: return ImVec4(1.0f, 0.8f, 0.0f, 1.0f); // Yellow-ish
|
||||||
|
case LogLevel::Error: return ImVec4(1.0f, 0.2f, 0.2f, 1.0f); // Reddish
|
||||||
|
case LogLevel::Info:
|
||||||
|
default: return ImVec4(0.8f, 0.8f, 0.8f, 1.0f); // Light gray
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void LoggerWindow::AddLog(const char *fmt, std::optional<ImVec4> color, ...)
|
||||||
|
{
|
||||||
|
va_list args;
|
||||||
|
va_start(args, fmt);
|
||||||
|
std::string formatted = FormatString(fmt, args);
|
||||||
|
va_end(args);
|
||||||
|
|
||||||
|
LogEntry entry;
|
||||||
|
entry.text = formatted;
|
||||||
|
entry.level = LogLevel::Info;
|
||||||
|
entry.color = color;
|
||||||
|
entry.icon = GetIconForLevel(entry.level);
|
||||||
|
|
||||||
|
m_Logs.emplace_back(entry);
|
||||||
|
m_ScrollToBottom = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 1) Existing method (no LogLevel) — default to Info
|
||||||
void LoggerWindow::AddLog(const char *fmt, ...)
|
void LoggerWindow::AddLog(const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list args;
|
va_list args;
|
||||||
@ -22,27 +65,62 @@ void LoggerWindow::AddLog(const char *fmt, ...)
|
|||||||
std::string formatted = FormatString(fmt, args);
|
std::string formatted = FormatString(fmt, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
|
|
||||||
m_Logs.emplace_back(formatted);
|
LogEntry entry;
|
||||||
|
entry.text = formatted;
|
||||||
|
entry.level = LogLevel::Info;
|
||||||
|
entry.color = std::nullopt; // We'll use the default color
|
||||||
|
entry.icon = GetIconForLevel(entry.level);
|
||||||
|
|
||||||
|
m_Logs.emplace_back(entry);
|
||||||
m_ScrollToBottom = true;
|
m_ScrollToBottom = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoggerWindow::AddLog(const char *fmt, std::optional<ImVec4> color, ...)
|
// 2) New method for specifying LogLevel
|
||||||
|
void LoggerWindow::AddLog(LogLevel level, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, color);
|
va_start(args, fmt);
|
||||||
std::string formatted = FormatString(fmt, args);
|
std::string formatted = FormatString(fmt, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
|
|
||||||
m_Logs.emplace_back(formatted, color);
|
LogEntry entry;
|
||||||
|
entry.text = formatted;
|
||||||
|
entry.level = level;
|
||||||
|
entry.color = std::nullopt; // Use default color for this level
|
||||||
|
entry.icon = GetIconForLevel(level);
|
||||||
|
|
||||||
|
m_Logs.emplace_back(entry);
|
||||||
m_ScrollToBottom = true;
|
m_ScrollToBottom = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 3) New method for specifying LogLevel + an explicit color override
|
||||||
|
void LoggerWindow::AddLog(LogLevel level, const ImVec4 &color, const char *fmt, ...)
|
||||||
|
{
|
||||||
|
va_list args;
|
||||||
|
va_start(args, fmt);
|
||||||
|
std::string formatted = FormatString(fmt, args);
|
||||||
|
va_end(args);
|
||||||
|
|
||||||
|
LogEntry entry;
|
||||||
|
entry.text = formatted;
|
||||||
|
entry.level = level;
|
||||||
|
entry.color = color; // Explicit color override
|
||||||
|
entry.icon = GetIconForLevel(level);
|
||||||
|
|
||||||
|
m_Logs.emplace_back(entry);
|
||||||
|
m_ScrollToBottom = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void LoggerWindow::Show()
|
void LoggerWindow::Show()
|
||||||
{
|
{
|
||||||
SCOPE_TIMER("LoggerWindow::Show");
|
SCOPE_TIMER("LoggerWindow::Show");
|
||||||
|
|
||||||
|
// Window with an icon in the title
|
||||||
ImGui::Begin(ICON_FA_TERMINAL " Logger##logger");
|
ImGui::Begin(ICON_FA_TERMINAL " Logger##logger");
|
||||||
|
|
||||||
|
// Clear button
|
||||||
if (ImGui::Button("Clear"))
|
if (ImGui::Button("Clear"))
|
||||||
{
|
{
|
||||||
m_Logs.clear();
|
m_Logs.clear();
|
||||||
@ -50,24 +128,54 @@ void LoggerWindow::Show()
|
|||||||
|
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
|
|
||||||
// Begin a child region to enable scrolling
|
// Child region for scrollable area
|
||||||
ImGui::BeginChild("LoggerScrollRegion", ImVec2(0, 0), false, ImGuiWindowFlags_HorizontalScrollbar);
|
ImGui::BeginChild("LoggerScrollRegion", ImVec2(0, 0), false,
|
||||||
|
ImGuiWindowFlags_HorizontalScrollbar);
|
||||||
|
|
||||||
for (const auto &logEntry : m_Logs)
|
// Optional: tweak cell-padding or other style before beginning the table
|
||||||
|
// ImGui::PushStyleVar(ImGuiStyleVar_CellPadding, ImVec2(4.0f, 4.0f));
|
||||||
|
|
||||||
|
// Begin the table with 2 columns
|
||||||
|
// - RowBg flag for striped rows
|
||||||
|
// - Borders for a neat grid
|
||||||
|
// - SizingFixedFit or SizingStretch can be chosen per preference
|
||||||
|
if (ImGui::BeginTable("LogTable", 2,
|
||||||
|
ImGuiTableFlags_SizingFixedFit |
|
||||||
|
ImGuiTableFlags_Borders |
|
||||||
|
ImGuiTableFlags_RowBg |
|
||||||
|
ImGuiTableFlags_Resizable))
|
||||||
{
|
{
|
||||||
if (logEntry.color.has_value())
|
// Optionally set up columns (width, name, etc.)
|
||||||
{
|
ImGui::TableSetupColumn("Icon", ImGuiTableColumnFlags_WidthFixed, 30.0f);
|
||||||
ImGui::PushStyleColor(ImGuiCol_Text, logEntry.color.value());
|
ImGui::TableSetupColumn("Message", ImGuiTableColumnFlags_WidthStretch);
|
||||||
ImGui::TextUnformatted(logEntry.text.c_str());
|
|
||||||
ImGui::PopStyleColor();
|
// If you want a header row (not strictly needed for a log)
|
||||||
}
|
// ImGui::TableHeadersRow();
|
||||||
else
|
|
||||||
|
// Loop over your log entries
|
||||||
|
for (const auto &logEntry : m_Logs)
|
||||||
{
|
{
|
||||||
|
ImVec4 color = logEntry.color.value_or(GetDefaultColorForLevel(logEntry.level));
|
||||||
|
|
||||||
|
// Start a new row
|
||||||
|
ImGui::TableNextRow();
|
||||||
|
|
||||||
|
// Column 0: Icon
|
||||||
|
ImGui::TableNextColumn();
|
||||||
|
ImGui::TextColored(color, "%s", logEntry.icon.c_str());
|
||||||
|
|
||||||
|
// Column 1: Text
|
||||||
|
ImGui::TableNextColumn();
|
||||||
ImGui::TextUnformatted(logEntry.text.c_str());
|
ImGui::TextUnformatted(logEntry.text.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ImGui::EndTable();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Auto-scroll to bottom if new logs are added
|
// If you used PushStyleVar above, pop it here:
|
||||||
|
// ImGui::PopStyleVar();
|
||||||
|
|
||||||
|
// Auto-scroll to bottom if needed
|
||||||
if (m_ScrollToBottom)
|
if (m_ScrollToBottom)
|
||||||
{
|
{
|
||||||
ImGui::SetScrollHereY(1.0f);
|
ImGui::SetScrollHereY(1.0f);
|
||||||
@ -75,6 +183,6 @@ void LoggerWindow::Show()
|
|||||||
}
|
}
|
||||||
|
|
||||||
ImGui::EndChild();
|
ImGui::EndChild();
|
||||||
|
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,19 +6,31 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
#include <imgui.h>
|
#include <imgui.h>
|
||||||
|
#include "Icons.h"
|
||||||
|
|
||||||
struct LogEntry {
|
// Example: Different severity levels
|
||||||
std::string text;
|
enum class LogLevel
|
||||||
std::optional<ImVec4> color;
|
{
|
||||||
|
Info,
|
||||||
|
Warning,
|
||||||
|
Error
|
||||||
|
};
|
||||||
|
|
||||||
LogEntry(const std::string& msg, std::optional<ImVec4> col = std::nullopt)
|
struct LogEntry
|
||||||
: text(msg), color(col) {}
|
{
|
||||||
|
std::string text ;
|
||||||
|
LogLevel level;
|
||||||
|
std::optional<ImVec4> color;
|
||||||
|
std::string icon ;
|
||||||
};
|
};
|
||||||
|
|
||||||
class LoggerWindow {
|
class LoggerWindow {
|
||||||
public:
|
public:
|
||||||
void AddLog(const char* fmt, ...);
|
void AddLog(const char* fmt, ...);
|
||||||
void AddLog(const char* fmt, std::optional<ImVec4> color, ...);
|
void AddLog(const char* fmt, std::optional<ImVec4> color, ...);
|
||||||
|
void AddLog(LogLevel level, const char *fmt, ...);
|
||||||
|
void AddLog(LogLevel level, const ImVec4 &color, const char *fmt, ...);
|
||||||
|
|
||||||
void Show();
|
void Show();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -29,6 +29,13 @@ std::shared_ptr<GameObject> CreateDefaultCube()
|
|||||||
void SceneWindow::Show()
|
void SceneWindow::Show()
|
||||||
{
|
{
|
||||||
SCOPE_TIMER("SceneWindow::Show");
|
SCOPE_TIMER("SceneWindow::Show");
|
||||||
|
|
||||||
|
if (g_SelectedObject) {
|
||||||
|
if (ImGui::IsKeyPressed(ImGuiKey_Escape)) {
|
||||||
|
g_SelectedObject = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (ImGui::Begin("Scene Window##SceneWindow"))
|
if (ImGui::Begin("Scene Window##SceneWindow"))
|
||||||
{
|
{
|
||||||
// Add Button
|
// Add Button
|
||||||
|
Loading…
Reference in New Issue
Block a user