Applying code standard new window, job, jobsystem and imui

This commit is contained in:
Antoine Pilote
2024-09-04 00:51:43 -04:00
parent dc3c993962
commit 10b8c862e7
8 changed files with 585 additions and 587 deletions

View File

@@ -1,7 +1,8 @@
#pragma once
#include "../Core/Timestep.h"
#include "../Rendering/Camera.h"
#include "src/Core/Core.h"
#include "src/Core/Timestep.h"
#include "src/Rendering/Camera.h"
namespace Nuake
{

View File

@@ -1,27 +1,24 @@
#include "Job.h"
#include <Tracy.hpp>
namespace Nuake {
using namespace Nuake;
Job::Job(std::function<void()> job, std::function<void()> end)
: m_Job(job)
, m_End(end)
Job::Job(std::function<void()> logic, std::function<void()> endLogic) :
job(logic),
end(endLogic)
{
this->thread = std::thread([this, logic]()
{
m_End = end;
ZoneScoped;
job();
isDone = true;
});
}
m_Thread = std::thread([this, job]()
{
ZoneScoped;
job();
m_IsDone = true;
});
}
void Job::End()
void Job::End()
{
if (end)
{
if (m_End)
{
m_End();
}
end();
}
}

View File

@@ -9,17 +9,20 @@ namespace Nuake {
class Job
{
public:
Job(std::function<void()> job, std::function<void()> end);
Job(std::function<void()> logic, std::function<void()> endLogic);
Job(const Job&) = delete;
Job& operator=(const Job&) = delete;
~Job() { m_Thread.join(); }
bool IsDone() { return m_IsDone; }
~Job() { thread.join(); }
public:
bool IsDone() { return isDone; }
void End();
private:
std::thread m_Thread;
std::atomic<bool> m_IsDone;
std::function<void()> m_Job;
std::function<void()> m_End;
std::thread thread;
std::atomic<bool> isDone;
std::function<void()> job;
std::function<void()> end;
};
}

View File

@@ -2,23 +2,22 @@
#include <Tracy.hpp>
namespace Nuake {
using namespace Nuake;
void JobSystem::Update()
void JobSystem::Update()
{
ZoneScoped;
for(auto it = jobs.begin(); it != jobs.end();)
{
ZoneScoped;
for(auto it = m_Jobs.begin(); it != m_Jobs.end();)
if(it->get()->IsDone())
{
if(it->get()->IsDone())
{
it->get()->End();
it = m_Jobs.erase(it);
}
else
{
++it;
}
it->get()->End();
it = jobs.erase(it);
}
else
{
++it;
}
}
}

View File

@@ -5,11 +5,7 @@ namespace Nuake {
class JobSystem
{
private:
std::vector<std::unique_ptr<Job>> m_Jobs;
public:
JobSystem() = default;
~JobSystem() = default;
@@ -19,11 +15,15 @@ namespace Nuake {
return instance;
}
public:
void Dispatch(std::function<void()> job, std::function<void()> end)
{
m_Jobs.push_back(std::make_unique<Job>(job, end));
jobs.push_back(std::make_unique<Job>(job, end));
}
void Update();
private:
std::vector<std::unique_ptr<Job>> jobs;
};
}

View File

@@ -4,192 +4,190 @@
#include <imgui/imgui_internal.h>
namespace Nuake {
using namespace Nuake
namespace UI {
using namespace UI
void BeginWindow(const std::string& name)
{
ImGui::Begin(name.c_str());
}
void BeginWindow(const std::string& name)
{
ImGui::Begin(name.c_str());
}
void EndWindow()
{
ImGui::End();
}
void EndWindow()
{
ImGui::End();
}
bool PrimaryButton(const std::string& name, const Vector2& size, Color color)
{
if (Nuake::Engine::GetProject())
{
color = Nuake::Engine::GetProject()->Settings.PrimaryColor;
}
bool PrimaryButton(const std::string& name, const Vector2& size, Color color)
{
if (Nuake::Engine::GetProject())
{
color = Nuake::Engine::GetProject()->Settings.PrimaryColor;
}
ImGui::PushStyleColor(ImGuiCol_Button, IM_COL32(color.r * 255.0f, color.g * 255.0f, color.b * 255.0f, 255));
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, IM_COL32(color.r * 255.0f, color.g * 255.0f, color.b * 255.0f, 200));
ImGui::PushStyleColor(ImGuiCol_ButtonActive, IM_COL32(color.r * 255.0f, color.g * 255.0f, color.b * 255.0f, 255));
ImGui::PushStyleColor(ImGuiCol_Button, IM_COL32(color.r * 255.0f, color.g * 255.0f, color.b * 255.0f, 255));
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, IM_COL32(color.r * 255.0f, color.g * 255.0f, color.b * 255.0f, 200));
ImGui::PushStyleColor(ImGuiCol_ButtonActive, IM_COL32(color.r * 255.0f, color.g * 255.0f, color.b * 255.0f, 255));
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 4.0f);
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ButtonPadding);
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 4.0f);
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ButtonPadding);
UIFont boldFont(Bold);
const bool buttonPressed = ImGui::Button(name.c_str(), ImVec2(size.x, size.y));
UIFont boldFont(Bold);
const bool buttonPressed = ImGui::Button(name.c_str(), ImVec2(size.x, size.y));
ImGui::PopStyleColor(3);
ImGui::PopStyleColor(3);
ImGui::PopStyleVar(2);
ImGui::PopStyleVar(2);
return buttonPressed;
}
return buttonPressed;
}
bool SecondaryButton(const std::string& name, const Vector2& size)
bool SecondaryButton(const std::string& name, const Vector2& size)
{
Color color = Color(97.0f / 255.0f, 0, 1.0f, 1.0f);
if (Nuake::Engine::GetProject())
{
color = Nuake::Engine::GetProject()->Settings.PrimaryColor;
}
ImGui::PushStyleColor(ImGuiCol_Button, IM_COL32(0, 0, 0, 0));
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, IM_COL32(color.r * 255.0f, color.g * 255.0f, color.b * 255.0f, 200));
ImGui::PushStyleColor(ImGuiCol_ButtonActive, IM_COL32(color.r * 255.0f, color.g * 255.0f, color.b * 255.0f, 255));
ImGui::PushStyleColor(ImGuiCol_Border, PrimaryCol);
ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 2.0f);
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 4.0f);
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ButtonPadding);
UIFont boldFont(Bold);
const bool buttonPressed = ImGui::Button(name.c_str(), ImVec2(size.x, size.y));
ImGui::PopStyleVar(3);
ImGui::PopStyleColor(4);
return buttonPressed;
}
bool IconButton(const std::string& icon)
{
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 4.0f);
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, IconButtonPadding);
const float height = ImGui::GetTextLineHeight() + ButtonPadding.y * 2.0f;
const bool isPressed = ImGui::Button(icon.c_str(), ImVec2(height, height));
ImGui::PopStyleVar(2);
return isPressed;
}
bool FloatSlider(const std::string& name, float& input, float min, float max, float speed)
{
//ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, { 0, ImGui::GetStyle().ItemSpacing.y });
//IconButton(ICON_FA_ANGLE_UP);
//
//ImGui::SameLine();
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 4.0f);
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ButtonPadding);
const bool isUsing = ImGui::DragFloat(("##" + name).c_str(), &input, speed, min, max);
ImGui::PopStyleVar(2);
//ImGui::PopStyleColor();
return isUsing;
}
bool CheckBox(const std::string& name, bool& value)
{
const float height = ImGui::GetTextLineHeight() + ButtonPadding.y * 2.0f;
if (!value)
{
ImGui::PushStyleColor(ImGuiCol_Button, IM_COL32(0, 0, 0, 0));
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, IM_COL32(97, 0, 255, 200));
ImGui::PushStyleColor(ImGuiCol_ButtonActive, PrimaryCol);
ImGui::PushStyleColor(ImGuiCol_Border, PrimaryCol);
ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 2.0f);
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 4.0f);
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ButtonPadding);
const bool buttonPressed = ImGui::Button(("##" + name).c_str(), ImVec2(height, height));
ImGui::PopStyleVar(3);
ImGui::PopStyleColor(4);
if (buttonPressed)
{
Color color = Color(97.0f / 255.0f, 0, 1.0f, 1.0f);
if (Nuake::Engine::GetProject())
{
color = Nuake::Engine::GetProject()->Settings.PrimaryColor;
}
ImGui::PushStyleColor(ImGuiCol_Button, IM_COL32(0, 0, 0, 0));
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, IM_COL32(color.r * 255.0f, color.g * 255.0f, color.b * 255.0f, 200));
ImGui::PushStyleColor(ImGuiCol_ButtonActive, IM_COL32(color.r * 255.0f, color.g * 255.0f, color.b * 255.0f, 255));
ImGui::PushStyleColor(ImGuiCol_Border, PrimaryCol);
ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 2.0f);
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 4.0f);
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ButtonPadding);
UIFont boldFont(Bold);
const bool buttonPressed = ImGui::Button(name.c_str(), ImVec2(size.x, size.y));
ImGui::PopStyleVar(3);
ImGui::PopStyleColor(4);
return buttonPressed;
}
bool IconButton(const std::string& icon)
{
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 4.0f);
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, IconButtonPadding);
const float height = ImGui::GetTextLineHeight() + ButtonPadding.y * 2.0f;
const bool isPressed = ImGui::Button(icon.c_str(), ImVec2(height, height));
ImGui::PopStyleVar(2);
return isPressed;
}
bool FloatSlider(const std::string& name, float& input, float min, float max, float speed)
{
//ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, { 0, ImGui::GetStyle().ItemSpacing.y });
//IconButton(ICON_FA_ANGLE_UP);
//
//ImGui::SameLine();
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 4.0f);
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ButtonPadding);
const bool isUsing = ImGui::DragFloat(("##" + name).c_str(), &input, speed, min, max);
ImGui::PopStyleVar(2);
//ImGui::PopStyleColor();
return isUsing;
}
bool CheckBox(const std::string& name, bool& value)
{
const float height = ImGui::GetTextLineHeight() + ButtonPadding.y * 2.0f;
if (!value)
{
ImGui::PushStyleColor(ImGuiCol_Button, IM_COL32(0, 0, 0, 0));
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, IM_COL32(97, 0, 255, 200));
ImGui::PushStyleColor(ImGuiCol_ButtonActive, PrimaryCol);
ImGui::PushStyleColor(ImGuiCol_Border, PrimaryCol);
ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 2.0f);
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 4.0f);
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ButtonPadding);
const bool buttonPressed = ImGui::Button(("##" + name).c_str(), ImVec2(height, height));
ImGui::PopStyleVar(3);
ImGui::PopStyleColor(4);
if (buttonPressed)
{
value = !value;
}
}
else
{
ImGui::PushStyleColor(ImGuiCol_Button, PrimaryCol);
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, PrimaryCol);
ImGui::PushStyleColor(ImGuiCol_ButtonActive, PrimaryCol);
ImGui::PushStyleColor(ImGuiCol_Border, IM_COL32(97, 0, 255, 200));
ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 2.0f);
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 4.0f);
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ButtonPadding);
const bool buttonPressed = ImGui::Button(("##" + name).c_str(), ImVec2(height, height));
ImGui::PopStyleVar(3);
ImGui::PopStyleColor(4);
if (buttonPressed)
{
value = !value;
}
}
return value;
}
void ToggleButton(const char* str_id, bool* v)
{
ImVec4* colors = ImGui::GetStyle().Colors;
ImVec2 p = ImGui::GetCursorScreenPos();
ImDrawList* draw_list = ImGui::GetWindowDrawList();
float height = ImGui::GetFrameHeight();
float width = height * 1.55f;
float radius = height * 0.50f;
ImGui::InvisibleButton(str_id, ImVec2(width, height));
if (ImGui::IsItemClicked()) *v = !*v;
ImGuiContext& gg = *GImGui;
float ANIM_SPEED = 0.085f;
if (gg.LastActiveId == gg.CurrentWindow->GetID(str_id))// && g.LastActiveIdTimer < ANIM_SPEED)
float t_anim = ImSaturate(gg.LastActiveIdTimer / ANIM_SPEED);
if (ImGui::IsItemHovered())
draw_list->AddRectFilled(p, ImVec2(p.x + width, p.y + height), ImGui::GetColorU32(*v ? colors[ImGuiCol_ButtonActive] : ImVec4(0.78f, 0.78f, 0.78f, 1.0f)), height * 0.5f);
else
draw_list->AddRectFilled(p, ImVec2(p.x + width, p.y + height), ImGui::GetColorU32(*v ? colors[ImGuiCol_Button] : ImVec4(0.85f, 0.85f, 0.85f, 1.0f)), height * 0.50f);
draw_list->AddCircleFilled(ImVec2(p.x + radius + (*v ? 1 : 0) * (width - radius * 2.0f), p.y + radius), radius - 1.5f, IM_COL32(255, 255, 255, 255));
}
void Tooltip(const std::string& message)
{
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(4, 4));
if (ImGui::IsItemHovered(ImGuiHoveredFlags_DelayNormal))
{
ImGui::BeginTooltip();
ImGui::PushTextWrapPos(450.0f);
ImGui::TextUnformatted(message.c_str());
ImGui::PopTextWrapPos();
ImGui::EndTooltip();
}
ImGui::PopStyleVar(2);
value = !value;
}
}
}
else
{
ImGui::PushStyleColor(ImGuiCol_Button, PrimaryCol);
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, PrimaryCol);
ImGui::PushStyleColor(ImGuiCol_ButtonActive, PrimaryCol);
ImGui::PushStyleColor(ImGuiCol_Border, IM_COL32(97, 0, 255, 200));
ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 2.0f);
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 4.0f);
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ButtonPadding);
const bool buttonPressed = ImGui::Button(("##" + name).c_str(), ImVec2(height, height));
ImGui::PopStyleVar(3);
ImGui::PopStyleColor(4);
if (buttonPressed)
{
value = !value;
}
}
return value;
}
void ToggleButton(const char* str_id, bool* v)
{
ImVec4* colors = ImGui::GetStyle().Colors;
ImVec2 p = ImGui::GetCursorScreenPos();
ImDrawList* draw_list = ImGui::GetWindowDrawList();
float height = ImGui::GetFrameHeight();
float width = height * 1.55f;
float radius = height * 0.50f;
ImGui::InvisibleButton(str_id, ImVec2(width, height));
if (ImGui::IsItemClicked()) *v = !*v;
ImGuiContext& gg = *GImGui;
float ANIM_SPEED = 0.085f;
if (gg.LastActiveId == gg.CurrentWindow->GetID(str_id))// && g.LastActiveIdTimer < ANIM_SPEED)
float t_anim = ImSaturate(gg.LastActiveIdTimer / ANIM_SPEED);
if (ImGui::IsItemHovered())
draw_list->AddRectFilled(p, ImVec2(p.x + width, p.y + height), ImGui::GetColorU32(*v ? colors[ImGuiCol_ButtonActive] : ImVec4(0.78f, 0.78f, 0.78f, 1.0f)), height * 0.5f);
else
draw_list->AddRectFilled(p, ImVec2(p.x + width, p.y + height), ImGui::GetColorU32(*v ? colors[ImGuiCol_Button] : ImVec4(0.85f, 0.85f, 0.85f, 1.0f)), height * 0.50f);
draw_list->AddCircleFilled(ImVec2(p.x + radius + (*v ? 1 : 0) * (width - radius * 2.0f), p.y + radius), radius - 1.5f, IM_COL32(255, 255, 255, 255));
}
void Tooltip(const std::string& message)
{
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(4, 4));
if (ImGui::IsItemHovered(ImGuiHoveredFlags_DelayNormal))
{
ImGui::BeginTooltip();
ImGui::PushTextWrapPos(450.0f);
ImGui::TextUnformatted(message.c_str());
ImGui::PopTextWrapPos();
ImGui::EndTooltip();
}
ImGui::PopStyleVar(2);
}

View File

@@ -19,406 +19,403 @@
#include <imgui/imgui_impl_opengl3.h>
#include <Tracy.hpp>
namespace Nuake
using namespace Nuake;
Window::Window() :
title(DEFAULT_TITLE),
width(DEFAULT_WIDTH),
height(DEFAULT_HEIGHT)
{
Window::Window()
{
m_Title = DEFAULT_TITLE;
m_Width = DEFAULT_WIDTH;
m_Height = DEFAULT_HEIGHT;
Init();
Renderer::Init();
}
Init();
Renderer::Init();
Ref<Window> Window::Get()
{
static Ref<Window> instance;
if (instance == nullptr)
{
instance = CreateRef<Window>();
}
Ref<Window> Window::Get()
{
static Ref<Window> instance;
if (instance == nullptr)
{
instance = CreateRef<Window>();
}
return instance;
}
return instance;
GLFWwindow* Window::GetHandle()
{
return this->window;
}
bool Window::ShouldClose()
{
return glfwWindowShouldClose(this->window);
}
int Window::Init()
{
if (!glfwInit())
{
Logger::Log("GLFW initialization failed", "window", CRITICAL);
return -1;
}
GLFWwindow* Window::GetHandle()
this->window = glfwCreateWindow(width, height, title.c_str(), NULL, NULL);
if (!this->window)
{
return m_Window;
Logger::Log("Window creation failed", "window", CRITICAL);
return -1;
}
bool Window::ShouldClose()
SetWindowIcon("resources/Images/nuake-logo.png");
glfwMakeContextCurrent(this->window);
SetVSync(false);
if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress))
{
return glfwWindowShouldClose(m_Window);
Logger::Log("glad initialization failed!", "window", CRITICAL);
return -1;
}
int Window::Init()
Logger::Log("Driver detected " + std::string(((char*)glGetString(GL_VERSION))), "renderer");
if (glfwRawMouseMotionSupported())
glfwSetInputMode(this->window, GLFW_RAW_MOUSE_MOTION, GLFW_TRUE);
// TODO: Move this to renderer init. The window shouldnt have to do gl calls.
glfwWindowHint(GLFW_SAMPLES, 4);
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); // To make MacOS happy; should not be needed
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
// TODO: have clear color in environnement.
glClearColor(0.f, 0.f, 0.f, 1.0f);
glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS);
glEnable(GL_DEPTH_TEST);
glEnable(GL_MULTISAMPLE);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
//glEnable(GL_CULL_FACE);
// Create viewports
const Vector2 defaultResolution = Vector2(1, 1);
this->framebuffer = CreateRef<FrameBuffer>(true, defaultResolution);
Ref<Texture> outputTexture = CreateRef<Texture>(defaultResolution, GL_RGB);
outputTexture->SetParameter(GL_TEXTURE_MIN_FILTER, GL_NEAREST);
outputTexture->SetParameter(GL_TEXTURE_MAG_FILTER, GL_NEAREST);
this->framebuffer->SetTexture(outputTexture);
this->framebuffer->SetTexture(CreateRef<Texture>(defaultResolution, GL_RED_INTEGER, GL_R32I, GL_INT), GL_COLOR_ATTACHMENT1); // Entity ID
InitImgui();
Logger::Log("ImGui initialized ", "renderer");
return 0;
}
void Window::Update(Timestep ts)
{
this->scene->Update(ts);
}
void Window::FixedUpdate(Timestep ts)
{
this->scene->FixedUpdate(ts);
}
void Window::Draw()
{
ZoneScoped;
// Dont render if no scene is loaded.
if (!this->scene)
{
if (!glfwInit())
{
Logger::Log("GLFW initialization failed", "window", CRITICAL);
return -1;
}
m_Window = glfwCreateWindow(m_Width, m_Height, m_Title.c_str(), NULL, NULL);
if (!m_Window)
{
Logger::Log("Window creation failed", "window", CRITICAL);
return -1;
}
SetWindowIcon("resources/Images/nuake-logo.png");
glfwMakeContextCurrent(m_Window);
SetVSync(false);
if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress))
{
Logger::Log("glad initialization failed!", "window", CRITICAL);
return -1;
}
Logger::Log("Driver detected " + std::string(((char*)glGetString(GL_VERSION))), "renderer");
if (glfwRawMouseMotionSupported())
glfwSetInputMode(m_Window, GLFW_RAW_MOUSE_MOTION, GLFW_TRUE);
// TODO: Move this to renderer init. The window shouldnt have to do gl calls.
glfwWindowHint(GLFW_SAMPLES, 4);
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); // To make MacOS happy; should not be needed
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
// TODO: have clear color in environnement.
glClearColor(0.f, 0.f, 0.f, 1.0f);
glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS);
glEnable(GL_DEPTH_TEST);
glEnable(GL_MULTISAMPLE);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
//glEnable(GL_CULL_FACE);
// Create viewports
const Vector2 defaultResolution = Vector2(1, 1);
m_Framebuffer = CreateRef<FrameBuffer>(true, defaultResolution);
Ref<Texture> outputTexture = CreateRef<Texture>(defaultResolution, GL_RGB);
outputTexture->SetParameter(GL_TEXTURE_MIN_FILTER, GL_NEAREST);
outputTexture->SetParameter(GL_TEXTURE_MAG_FILTER, GL_NEAREST);
m_Framebuffer->SetTexture(outputTexture);
m_Framebuffer->SetTexture(CreateRef<Texture>(defaultResolution, GL_RED_INTEGER, GL_R32I, GL_INT), GL_COLOR_ATTACHMENT1); // Entity ID
InitImgui();
Logger::Log("ImGui initialized ", "renderer");
return 0;
return;
}
void Window::Update(Timestep ts)
// Dont render if no cam is found.
Ref<Camera> cam = this->scene->GetCurrentCamera();
if (!cam)
{
m_Scene->Update(ts);
return;
}
void Window::FixedUpdate(Timestep ts)
// We cannot render to a framebuffer that is smaller than 1x1.
Vector2 size = this->framebuffer->GetSize();
size.x = std::max(size.x, 1.0f);
size.y = std::max(size.y, 1.0f);
cam->AspectRatio = size.x / size.y;
float resolutionScale = glm::clamp(Engine::GetProject()->Settings.ResolutionScale, 0.5f, 2.0f);
this->scene->m_EditorCamera->OnWindowResize(size.x * resolutionScale, size.y * resolutionScale);
if (Engine::IsPlayMode())
{
m_Scene->FixedUpdate(ts);
ZoneScopedN("PIE Draw");
this->scene->Draw(*this->framebuffer.get());
}
else
{
ZoneScopedN("Non-playmode Draw");
this->scene->Draw(*this->framebuffer.get(), this->scene->m_EditorCamera->GetPerspective(), this->scene->m_EditorCamera->GetTransform());
}
void Window::Draw()
glEnable(GL_DEPTH_TEST);
Renderer::EndDraw();
}
void Window::EndDraw()
{
{
ZoneScoped;
// Dont render if no scene is loaded.
if (!m_Scene)
{
return;
}
// Dont render if no cam is found.
Ref<Camera> cam = m_Scene->GetCurrentCamera();
if (!cam)
{
return;
}
// We cannot render to a framebuffer that is smaller than 1x1.
Vector2 size = m_Framebuffer->GetSize();
size.x = std::max(size.x, 1.0f);
size.y = std::max(size.y, 1.0f);
cam->AspectRatio = size.x / size.y;
float resolutionScale = glm::clamp(Engine::GetProject()->Settings.ResolutionScale, 0.5f, 2.0f);
m_Scene->m_EditorCamera->OnWindowResize(size.x * resolutionScale, size.y * resolutionScale);
if (Engine::IsPlayMode())
{
ZoneScopedN("PIE Draw");
m_Scene->Draw(*m_Framebuffer.get());
}
else
{
ZoneScopedN("Non-playmode Draw");
m_Scene->Draw(*m_Framebuffer.get(), m_Scene->m_EditorCamera->GetPerspective(), m_Scene->m_EditorCamera->GetTransform());
}
glEnable(GL_DEPTH_TEST);
Renderer::EndDraw();
ZoneScopedN("ImGui::EndFrame");
ImGui::EndFrame();
}
void Window::EndDraw()
{
{
ZoneScopedN("ImGui::EndFrame");
ImGui::EndFrame();
}
{
ZoneScopedN("ImGui::Render");
ImGui::Render();
}
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
if (ImGui::GetIO().ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
{
GLFWwindow* backup_current_context = glfwGetCurrentContext();
ImGui::UpdatePlatformWindows();
ImGui::RenderPlatformWindowsDefault();
glfwMakeContextCurrent(backup_current_context);
}
{
ZoneScopedN("SwapBuffers");
glfwSwapBuffers(m_Window);
}
ZoneScopedN("glfwPollEvents");
glfwPollEvents();
ZoneScopedN("ImGui::Render");
ImGui::Render();
}
Ref<FrameBuffer> Window::GetFrameBuffer() const
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
if (ImGui::GetIO().ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
{
return m_Framebuffer;
GLFWwindow* backup_current_context = glfwGetCurrentContext();
ImGui::UpdatePlatformWindows();
ImGui::RenderPlatformWindowsDefault();
glfwMakeContextCurrent(backup_current_context);
}
Vector2 Window::GetSize() const
{
int w, h = 0;
glfwGetWindowSize(m_Window, &w, &h);
return Vector2(w, h);
ZoneScopedN("SwapBuffers");
glfwSwapBuffers(this->window);
}
void Window::SetSize(const Vector2& size)
ZoneScopedN("glfwPollEvents");
glfwPollEvents();
}
Ref<FrameBuffer> Window::GetFrameBuffer() const
{
return this->framebuffer;
}
Vector2 Window::GetSize() const
{
int w, h = 0;
glfwGetWindowSize(this->window, &w, &h);
return Vector2(w, h);
}
void Window::SetSize(const Vector2& size)
{
this->width = static_cast<int32_t>(size.x);
this->height = static_cast<int32_t>(size.y);
glfwSetWindowSize(this->window, this->width, this->height);
}
void Window::SetPosition(const Vector2& position)
{
this->position = position;
glfwSetWindowPos(this->window, static_cast<int>(position.x), static_cast<int>(position.y));
}
void Window::SetMonitor(int monitorIdx)
{
int monitorCount;
GLFWmonitor** monitors = glfwGetMonitors(&monitorCount);
if (monitorIdx <= monitorCount)
{
m_Width = static_cast<int32_t>(size.x);
m_Height = static_cast<int32_t>(size.y);
glfwSetWindowSize(m_Window, m_Width, m_Height);
}
void Window::SetPosition(const Vector2& position)
{
m_Position = position;
glfwSetWindowPos(m_Window, static_cast<int>(position.x), static_cast<int>(position.y));
}
void Window::SetMonitor(int monitorIdx)
{
int monitorCount;
GLFWmonitor** monitors = glfwGetMonitors(&monitorCount);
if (monitorIdx <= monitorCount)
{
const auto monitor = *(monitors + monitorIdx);
const GLFWvidmode* mode = glfwGetVideoMode(monitor);
int monitorX, monitorY;
glfwGetMonitorPos(monitor, &monitorX, &monitorY);
// Calculate the center of the monitor
int monitorWidth, monitorHeight;
glfwGetMonitorPhysicalSize(monitor, &monitorWidth, &monitorHeight);
// Convert physical size to pixels (assuming a DPI scale factor of 1.0)
monitorWidth = static_cast<int>(monitorWidth * 96.0f / 25.4f);
monitorHeight = static_cast<int>(monitorHeight * 96.0f / 25.4f);
// Center the window on the new monitor
int windowX = monitorX + (monitorWidth - m_Width) / 2;
int windowY = monitorY + (monitorHeight - m_Height) / 2;
glfwSetWindowMonitor(m_Window, nullptr, windowX, windowY, m_Width, m_Height, GLFW_DONT_CARE);
}
}
void Window::Center()
{
const int windowWidth = 640;
const int windowHeight = 360;
// Get the primary monitor's video mode
const GLFWvidmode* mode = glfwGetVideoMode(glfwGetPrimaryMonitor());
// Calculate the position to center the window
const int xPos = (mode->width - m_Width) / 2;
const int yPos = (mode->height - m_Height) / 2;
// Set the window's position
Nuake::Window::Get()->SetSize({ m_Width, m_Height });
Nuake::Window::Get()->SetPosition({ xPos, yPos });
}
Ref<Scene> Window::GetScene()
{
return m_Scene;
}
bool Window::SetScene(Ref<Scene> scene)
{
m_Scene = scene;
return true;
}
void Window::SetTitle(const std::string& title)
{
m_Title = title;
glfwSetWindowTitle(m_Window, m_Title.c_str());
}
std::string Window::GetTitle()
{
return m_Title;
}
void Window::SetWindowIcon(const std::string& path)
{
GLFWimage images[1];
images[0].pixels = stbi_load_from_memory(StaticResources::Resources_Images_nuake_logo_png, StaticResources::Resources_Images_nuake_logo_png_len, &images[0].width, &images[0].height, 0, 4);
glfwSetWindowIcon(m_Window, 1, images);
stbi_image_free(images[0].pixels);
}
void Window::SetVSync(bool enabled)
{
glfwSwapInterval(enabled ? 1 : 0);
}
void Window::SetDecorated(bool enabled)
{
glfwSetWindowAttrib(m_Window, GLFW_DECORATED, enabled);
}
void Window::SetFullScreen(bool enabled)
{
const auto monitor = glfwGetPrimaryMonitor();
const auto monitor = *(monitors + monitorIdx);
const GLFWvidmode* mode = glfwGetVideoMode(monitor);
glfwSetWindowMonitor(m_Window, monitor, 0, 0, mode->width, mode->height, GLFW_DONT_CARE);
}
void Window::Maximize()
{
const auto monitor = glfwGetPrimaryMonitor();
const GLFWvidmode* mode = glfwGetVideoMode(monitor);
SetSize({mode->width, mode->height});
Center();
glfwMaximizeWindow(m_Window);
}
int monitorX, monitorY;
glfwGetMonitorPos(monitor, &monitorX, &monitorY);
void Window::InitImgui()
{
ImGui::CreateContext();
ImGuiIO& io = ImGui::GetIO(); (void)io;
io.Fonts->AddFontFromMemoryTTF(StaticResources::Resources_Fonts_Poppins_Regular_ttf, StaticResources::Resources_Fonts_Poppins_Regular_ttf_len, 16.0);
// Calculate the center of the monitor
int monitorWidth, monitorHeight;
glfwGetMonitorPhysicalSize(monitor, &monitorWidth, &monitorHeight);
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable;
//io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable;
ImGui::StyleColorsDark();
// Convert physical size to pixels (assuming a DPI scale factor of 1.0)
monitorWidth = static_cast<int>(monitorWidth * 96.0f / 25.4f);
monitorHeight = static_cast<int>(monitorHeight * 96.0f / 25.4f);
ImGuiStyle& s = ImGui::GetStyle();
s.WindowMenuButtonPosition = ImGuiDir_None;
s.GrabRounding = 2.0f;
s.CellPadding = ImVec2(8, 8);
s.WindowPadding = ImVec2(4, 4);
s.ScrollbarRounding = 9.0f;
s.ScrollbarSize = 15.0f;
s.GrabMinSize = 32.0f;
s.TabRounding = 0;
s.WindowRounding = 4.0f;
s.ChildRounding = 4.0f;
s.FrameRounding = 4.0f;
s.GrabRounding = 0;
s.FramePadding = ImVec2(8, 4);
s.ItemSpacing = ImVec2(8, 4);
s.ItemInnerSpacing = ImVec2(4, 4);
s.TabRounding = 4.0f;
s.WindowBorderSize = 0.0f;
s.IndentSpacing = 12.0f;
s.ChildBorderSize = 0.0f;
s.PopupRounding = 4.0f;
s.FrameBorderSize = 0.0f;
// Center the window on the new monitor
int windowX = monitorX + (monitorWidth - this->width) / 2;
int windowY = monitorY + (monitorHeight - this->height) / 2;
ImVec4* colors = ImGui::GetStyle().Colors;
colors[ImGuiCol_Text] = ImVec4(1.00f, 1.00f, 1.00f, 1.00f);
colors[ImGuiCol_TextDisabled] = ImVec4(0.50f, 0.50f, 0.50f, 1.00f);
colors[ImGuiCol_WindowBg] = ImVec4(0.148f, 0.148f, 0.148f, 1.00f);
colors[ImGuiCol_ChildBg] = ImVec4(0.15f, 0.15f, 0.15f, 1.00f);
colors[ImGuiCol_PopupBg] = ImVec4(0.08f, 0.08f, 0.08f, 0.94f);
colors[ImGuiCol_Border] = ImVec4(0.11f, 0.11f, 0.11f, 1.00f);
colors[ImGuiCol_BorderShadow] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f);
colors[ImGuiCol_FrameBg] = ImVec4(0.08f, 0.08f, 0.08f, 1.00f);
colors[ImGuiCol_FrameBgHovered] = ImVec4(0.09f, 0.09f, 0.09f, 1.00f);
colors[ImGuiCol_FrameBgActive] = ImVec4(0.13f, 0.13f, 0.13f, 1.00f);
colors[ImGuiCol_TitleBg] = ImVec4(0.08f, 0.08f, 0.08f, 1.00f);
colors[ImGuiCol_TitleBgActive] = ImVec4(0.078f, 0.078f, 0.078f, 1.00f);
colors[ImGuiCol_TitleBgCollapsed] = ImVec4(0.00f, 0.00f, 0.00f, 0.51f);
colors[ImGuiCol_MenuBarBg] = ImVec4(0.08f, 0.08f, 0.08f, 1.00f);
colors[ImGuiCol_ScrollbarBg] = ImVec4(0.08f, 0.08f, 0.08f, 0.00f);
colors[ImGuiCol_ScrollbarGrab] = ImVec4(0.34f, 0.34f, 0.34f, 1.00f);
colors[ImGuiCol_ScrollbarGrabHovered] = ImVec4(0.29f, 0.29f, 0.29f, 1.00f);
colors[ImGuiCol_ScrollbarGrabActive] = ImVec4(0.16f, 0.16f, 0.16f, 1.00f);
colors[ImGuiCol_CheckMark] = ImVec4(0.55f, 0.76f, 0.29f, 1.00f);
colors[ImGuiCol_SliderGrab] = ImVec4(0.55f, 0.76f, 0.29f, 1.00f);
colors[ImGuiCol_SliderGrabActive] = ImVec4(0.55f, 0.76f, 0.29f, 1.00f);
colors[ImGuiCol_Button] = ImVec4(0.22f, 0.22f, 0.22f, 1.00f);
colors[ImGuiCol_ButtonHovered] = ImVec4(0.19f, 0.19f, 0.19f, 1.00f);
colors[ImGuiCol_ButtonActive] = ImVec4(0.16f, 0.16f, 0.16f, 1.00f);
colors[ImGuiCol_Header] = ImVec4(0.18f, 0.18f, 0.18f, 1.00f);
colors[ImGuiCol_HeaderHovered] = ImVec4(0.16f, 0.16f, 0.16f, 1.00f);
colors[ImGuiCol_HeaderActive] = ImVec4(0.12f, 0.12f, 0.12f, 1.00f);
colors[ImGuiCol_Separator] = ImVec4(0.08f, 0.08f, 0.08f, 1.00f);
colors[ImGuiCol_SeparatorHovered] = ImVec4(0.10f, 0.10f, 0.10f, 0.78f);
colors[ImGuiCol_SeparatorActive] = ImVec4(0.00f, 0.00f, 0.00f, 1.00f);
colors[ImGuiCol_ResizeGrip] = ImVec4(0.26f, 0.59f, 0.98f, 0.00f);
colors[ImGuiCol_ResizeGripHovered] = ImVec4(0.26f, 0.59f, 0.98f, 0.00f);
colors[ImGuiCol_ResizeGripActive] = ImVec4(0.26f, 0.59f, 0.98f, 0.00f);
colors[ImGuiCol_Tab] = ImVec4(0.08f, 0.08f, 0.08f, 1.00f);
colors[ImGuiCol_TabHovered] = ImVec4(0.19f, 0.19f, 0.19f, 1.00f);
colors[ImGuiCol_TabActive] = ImVec4(0.15f, 0.15f, 0.15f, 1.00f);
colors[ImGuiCol_TabUnfocused] = ImVec4(0.08f, 0.08f, 0.08f, 1.00f);
colors[ImGuiCol_TabUnfocusedActive] = ImVec4(0.15f, 0.15f, 0.15f, 1.00f);
colors[ImGuiCol_DockingPreview] = ImVec4(0.55f, 0.76f, 0.29f, 1.00f);
colors[ImGuiCol_DockingEmptyBg] = ImVec4(0.20f, 0.20f, 0.20f, 1.00f);
colors[ImGuiCol_PlotLines] = ImVec4(0.61f, 0.61f, 0.61f, 1.00f);
colors[ImGuiCol_PlotLinesHovered] = ImVec4(1.00f, 0.43f, 0.35f, 1.00f);
colors[ImGuiCol_PlotHistogram] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f);
colors[ImGuiCol_PlotHistogramHovered] = ImVec4(1.00f, 0.60f, 0.00f, 1.00f);
colors[ImGuiCol_Border] = ImVec4(0.078f, 0.078f, 0.078f, 1.00f);
colors[ImGuiCol_TableHeaderBg] = ImVec4(0.19f, 0.19f, 0.19f, 1.00f);
colors[ImGuiCol_TableBorderStrong] = ImVec4(0.11f, 0.11f, 0.11f, 1.00f);
colors[ImGuiCol_TableBorderLight] = ImVec4(0.11f, 0.11f, 0.11f, 1.00f);
colors[ImGuiCol_TableRowBg] = ImVec4(0.11f, 0.11f, 0.11f, 1.00f);
colors[ImGuiCol_TableRowBgAlt] = ImVec4(0.93f, 0.27f, 0.27f, 0.00f);
colors[ImGuiCol_TextSelectedBg] = ImVec4(0.08f, 0.49f, 0.97f, 0.28f);
colors[ImGuiCol_DragDropTarget] = ImVec4(0.55f, 0.76f, 0.29f, 1.00f);
colors[ImGuiCol_NavHighlight] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f);
colors[ImGuiCol_NavWindowingHighlight] = ImVec4(1.00f, 1.00f, 1.00f, 0.70f);
colors[ImGuiCol_NavWindowingDimBg] = ImVec4(0.80f, 0.80f, 0.80f, 0.20f);
colors[ImGuiCol_ModalWindowDimBg] = ImVec4(0.80f, 0.80f, 0.80f, 0.35f);
ImGui_ImplGlfw_InitForOpenGL(m_Window, true);
ImGui_ImplOpenGL3_Init("#version 330");
glfwSetWindowMonitor(this->window, nullptr, windowX, windowY, this->width, this->height, GLFW_DONT_CARE);
}
}
void Window::Center()
{
const int windowWidth = 640;
const int windowHeight = 360;
// Get the primary monitor's video mode
const GLFWvidmode* mode = glfwGetVideoMode(glfwGetPrimaryMonitor());
// Calculate the position to center the window
const int xPos = (mode->width - this->width) / 2;
const int yPos = (mode->height - this->height) / 2;
// Set the window's position
Nuake::Window::Get()->SetSize({ this->width, this->height });
Nuake::Window::Get()->SetPosition({ xPos, yPos });
}
Ref<Scene> Window::GetScene()
{
return this->scene;
}
bool Window::SetScene(Ref<Scene> scene)
{
this->scene = scene;
return true;
}
void Window::SetTitle(const std::string& title)
{
this->title = title;
glfwSetWindowTitle(this->window, this->title.c_str());
}
std::string Window::GetTitle()
{
return this->title;
}
void Window::SetWindowIcon(const std::string& path)
{
GLFWimage images[1];
images[0].pixels = stbi_load_from_memory(StaticResources::Resources_Images_nuake_logo_png, StaticResources::Resources_Images_nuake_logo_png_len, &images[0].width, &images[0].height, 0, 4);
glfwSetWindowIcon(this->window, 1, images);
stbi_image_free(images[0].pixels);
}
void Window::SetVSync(bool enabled)
{
glfwSwapInterval(enabled ? 1 : 0);
}
void Window::SetDecorated(bool enabled)
{
glfwSetWindowAttrib(this->window, GLFW_DECORATED, enabled);
}
void Window::SetFullScreen(bool enabled)
{
const auto monitor = glfwGetPrimaryMonitor();
const GLFWvidmode* mode = glfwGetVideoMode(monitor);
glfwSetWindowMonitor(this->window, monitor, 0, 0, mode->width, mode->height, GLFW_DONT_CARE);
}
void Window::Maximize()
{
const auto monitor = glfwGetPrimaryMonitor();
const GLFWvidmode* mode = glfwGetVideoMode(monitor);
SetSize({mode->width, mode->height});
Center();
glfwMaximizeWindow(this->window);
}
void Window::InitImgui()
{
ImGui::CreateContext();
ImGuiIO& io = ImGui::GetIO(); (void)io;
io.Fonts->AddFontFromMemoryTTF(StaticResources::Resources_Fonts_Poppins_Regular_ttf, StaticResources::Resources_Fonts_Poppins_Regular_ttf_len, 16.0);
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable;
//io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable;
ImGui::StyleColorsDark();
ImGuiStyle& s = ImGui::GetStyle();
s.WindowMenuButtonPosition = ImGuiDir_None;
s.GrabRounding = 2.0f;
s.CellPadding = ImVec2(8, 8);
s.WindowPadding = ImVec2(4, 4);
s.ScrollbarRounding = 9.0f;
s.ScrollbarSize = 15.0f;
s.GrabMinSize = 32.0f;
s.TabRounding = 0;
s.WindowRounding = 4.0f;
s.ChildRounding = 4.0f;
s.FrameRounding = 4.0f;
s.GrabRounding = 0;
s.FramePadding = ImVec2(8, 4);
s.ItemSpacing = ImVec2(8, 4);
s.ItemInnerSpacing = ImVec2(4, 4);
s.TabRounding = 4.0f;
s.WindowBorderSize = 0.0f;
s.IndentSpacing = 12.0f;
s.ChildBorderSize = 0.0f;
s.PopupRounding = 4.0f;
s.FrameBorderSize = 0.0f;
ImVec4* colors = ImGui::GetStyle().Colors;
colors[ImGuiCol_Text] = ImVec4(1.00f, 1.00f, 1.00f, 1.00f);
colors[ImGuiCol_TextDisabled] = ImVec4(0.50f, 0.50f, 0.50f, 1.00f);
colors[ImGuiCol_WindowBg] = ImVec4(0.148f, 0.148f, 0.148f, 1.00f);
colors[ImGuiCol_ChildBg] = ImVec4(0.15f, 0.15f, 0.15f, 1.00f);
colors[ImGuiCol_PopupBg] = ImVec4(0.08f, 0.08f, 0.08f, 0.94f);
colors[ImGuiCol_Border] = ImVec4(0.11f, 0.11f, 0.11f, 1.00f);
colors[ImGuiCol_BorderShadow] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f);
colors[ImGuiCol_FrameBg] = ImVec4(0.08f, 0.08f, 0.08f, 1.00f);
colors[ImGuiCol_FrameBgHovered] = ImVec4(0.09f, 0.09f, 0.09f, 1.00f);
colors[ImGuiCol_FrameBgActive] = ImVec4(0.13f, 0.13f, 0.13f, 1.00f);
colors[ImGuiCol_TitleBg] = ImVec4(0.08f, 0.08f, 0.08f, 1.00f);
colors[ImGuiCol_TitleBgActive] = ImVec4(0.078f, 0.078f, 0.078f, 1.00f);
colors[ImGuiCol_TitleBgCollapsed] = ImVec4(0.00f, 0.00f, 0.00f, 0.51f);
colors[ImGuiCol_MenuBarBg] = ImVec4(0.08f, 0.08f, 0.08f, 1.00f);
colors[ImGuiCol_ScrollbarBg] = ImVec4(0.08f, 0.08f, 0.08f, 0.00f);
colors[ImGuiCol_ScrollbarGrab] = ImVec4(0.34f, 0.34f, 0.34f, 1.00f);
colors[ImGuiCol_ScrollbarGrabHovered] = ImVec4(0.29f, 0.29f, 0.29f, 1.00f);
colors[ImGuiCol_ScrollbarGrabActive] = ImVec4(0.16f, 0.16f, 0.16f, 1.00f);
colors[ImGuiCol_CheckMark] = ImVec4(0.55f, 0.76f, 0.29f, 1.00f);
colors[ImGuiCol_SliderGrab] = ImVec4(0.55f, 0.76f, 0.29f, 1.00f);
colors[ImGuiCol_SliderGrabActive] = ImVec4(0.55f, 0.76f, 0.29f, 1.00f);
colors[ImGuiCol_Button] = ImVec4(0.22f, 0.22f, 0.22f, 1.00f);
colors[ImGuiCol_ButtonHovered] = ImVec4(0.19f, 0.19f, 0.19f, 1.00f);
colors[ImGuiCol_ButtonActive] = ImVec4(0.16f, 0.16f, 0.16f, 1.00f);
colors[ImGuiCol_Header] = ImVec4(0.18f, 0.18f, 0.18f, 1.00f);
colors[ImGuiCol_HeaderHovered] = ImVec4(0.16f, 0.16f, 0.16f, 1.00f);
colors[ImGuiCol_HeaderActive] = ImVec4(0.12f, 0.12f, 0.12f, 1.00f);
colors[ImGuiCol_Separator] = ImVec4(0.08f, 0.08f, 0.08f, 1.00f);
colors[ImGuiCol_SeparatorHovered] = ImVec4(0.10f, 0.10f, 0.10f, 0.78f);
colors[ImGuiCol_SeparatorActive] = ImVec4(0.00f, 0.00f, 0.00f, 1.00f);
colors[ImGuiCol_ResizeGrip] = ImVec4(0.26f, 0.59f, 0.98f, 0.00f);
colors[ImGuiCol_ResizeGripHovered] = ImVec4(0.26f, 0.59f, 0.98f, 0.00f);
colors[ImGuiCol_ResizeGripActive] = ImVec4(0.26f, 0.59f, 0.98f, 0.00f);
colors[ImGuiCol_Tab] = ImVec4(0.08f, 0.08f, 0.08f, 1.00f);
colors[ImGuiCol_TabHovered] = ImVec4(0.19f, 0.19f, 0.19f, 1.00f);
colors[ImGuiCol_TabActive] = ImVec4(0.15f, 0.15f, 0.15f, 1.00f);
colors[ImGuiCol_TabUnfocused] = ImVec4(0.08f, 0.08f, 0.08f, 1.00f);
colors[ImGuiCol_TabUnfocusedActive] = ImVec4(0.15f, 0.15f, 0.15f, 1.00f);
colors[ImGuiCol_DockingPreview] = ImVec4(0.55f, 0.76f, 0.29f, 1.00f);
colors[ImGuiCol_DockingEmptyBg] = ImVec4(0.20f, 0.20f, 0.20f, 1.00f);
colors[ImGuiCol_PlotLines] = ImVec4(0.61f, 0.61f, 0.61f, 1.00f);
colors[ImGuiCol_PlotLinesHovered] = ImVec4(1.00f, 0.43f, 0.35f, 1.00f);
colors[ImGuiCol_PlotHistogram] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f);
colors[ImGuiCol_PlotHistogramHovered] = ImVec4(1.00f, 0.60f, 0.00f, 1.00f);
colors[ImGuiCol_Border] = ImVec4(0.078f, 0.078f, 0.078f, 1.00f);
colors[ImGuiCol_TableHeaderBg] = ImVec4(0.19f, 0.19f, 0.19f, 1.00f);
colors[ImGuiCol_TableBorderStrong] = ImVec4(0.11f, 0.11f, 0.11f, 1.00f);
colors[ImGuiCol_TableBorderLight] = ImVec4(0.11f, 0.11f, 0.11f, 1.00f);
colors[ImGuiCol_TableRowBg] = ImVec4(0.11f, 0.11f, 0.11f, 1.00f);
colors[ImGuiCol_TableRowBgAlt] = ImVec4(0.93f, 0.27f, 0.27f, 0.00f);
colors[ImGuiCol_TextSelectedBg] = ImVec4(0.08f, 0.49f, 0.97f, 0.28f);
colors[ImGuiCol_DragDropTarget] = ImVec4(0.55f, 0.76f, 0.29f, 1.00f);
colors[ImGuiCol_NavHighlight] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f);
colors[ImGuiCol_NavWindowingHighlight] = ImVec4(1.00f, 1.00f, 1.00f, 0.70f);
colors[ImGuiCol_NavWindowingDimBg] = ImVec4(0.80f, 0.80f, 0.80f, 0.20f);
colors[ImGuiCol_ModalWindowDimBg] = ImVec4(0.80f, 0.80f, 0.80f, 0.35f);
ImGui_ImplGlfw_InitForOpenGL(this->window, true);
ImGui_ImplOpenGL3_Init("#version 330");
}

View File

@@ -17,6 +17,8 @@ namespace Nuake
~Window() = default;
static Ref<Window> Get(); // Get the window instance
public:
GLFWwindow* GetHandle();
bool ShouldClose();
@@ -49,20 +51,21 @@ namespace Nuake
void SetDecorated(bool enabled);
void SetFullScreen(bool enabled);
void Maximize();
private:
const std::string DEFAULT_TITLE = "Untitled Window";
const uint32_t DEFAULT_WIDTH = 1280;
const uint32_t DEFAULT_HEIGHT = 720;
GLFWwindow* m_Window;
GLFWwindow* window;
std::string m_Title;
uint32_t m_Width;
uint32_t m_Height;
Vector2 m_Position;
std::string title;
uint32_t width;
uint32_t height;
Vector2 position;
Ref<FrameBuffer> m_Framebuffer;
Ref<Scene> m_Scene;
Ref<FrameBuffer> framebuffer;
Ref<Scene> scene;
void InitImgui();
};