mirror of
https://github.com/antopilo/Nuake.git
synced 2026-09-15 20:08:54 +03:00
Merge branch 'main' of https://github.com/antopilo/Nuake
This commit is contained in:
@@ -32,111 +32,127 @@
|
||||
#include <src/Core/Maths.h>
|
||||
#include <src/Rendering/SceneRenderer.h>
|
||||
|
||||
#include "src/Misc/WindowTheming.h"
|
||||
|
||||
std::string WindowTitle = "Nuake Editor ";
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
struct LaunchSettings
|
||||
{
|
||||
int32_t monitor = -1;
|
||||
Vector2 resolution = { 1920, 1080 };
|
||||
std::string windowTitle = "Nuake Editor ";
|
||||
std::string projectPath;
|
||||
};
|
||||
|
||||
std::vector<std::string> ParseArguments(int argc, char* argv[])
|
||||
{
|
||||
std::vector<std::string> args;
|
||||
for (uint32_t i = 0; i < argc; i++)
|
||||
{
|
||||
args.push_back(std::string(argv[i]));
|
||||
}
|
||||
return args;
|
||||
}
|
||||
|
||||
LaunchSettings ParseLaunchSettings(const std::vector<std::string>& arguments)
|
||||
{
|
||||
LaunchSettings launchSettings;
|
||||
|
||||
const auto argumentSize = arguments.size();
|
||||
size_t i = 0;
|
||||
for (const auto& arg : arguments)
|
||||
{
|
||||
const size_t nextArgumentIndex = i + 1;
|
||||
const bool containsAnotherArgument = nextArgumentIndex <= argumentSize;
|
||||
if (arg == "--project")
|
||||
{
|
||||
if (!containsAnotherArgument)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Load project on start
|
||||
std::string projectPath = arguments[i + 1];
|
||||
launchSettings.projectPath = projectPath;
|
||||
|
||||
}
|
||||
else if (arg == "--resolution")
|
||||
{
|
||||
if (!containsAnotherArgument)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Set editor window resolution
|
||||
std::string resString = arguments[i + 1];
|
||||
const auto& resSplits = String::Split(resString, 'x');
|
||||
if (resSplits.size() == 2)
|
||||
{
|
||||
int width = stoi(resSplits[0]);
|
||||
int height = stoi(resSplits[1]);
|
||||
launchSettings.resolution = Vector2(width, height);
|
||||
}
|
||||
}
|
||||
else if (arg == "--monitor")
|
||||
{
|
||||
// Set editor window monitor
|
||||
if (containsAnotherArgument)
|
||||
{
|
||||
launchSettings.monitor = stoi(arguments[i + 1]);
|
||||
}
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
return launchSettings;
|
||||
}
|
||||
|
||||
int ApplicationMain(int argc, char* argv[])
|
||||
{
|
||||
using namespace Nuake;
|
||||
|
||||
std::string projectPath = "";
|
||||
|
||||
Vector2 editorResolution = Vector2(1280, 720);
|
||||
int monitorIdx = -1;
|
||||
for (uint32_t i = 0; i < argc; i++)
|
||||
{
|
||||
char* arg = argv[i];
|
||||
std::string args = std::string(arg);
|
||||
|
||||
if (args == "--resolution")
|
||||
{
|
||||
if (argc >= i + 1)
|
||||
{
|
||||
std::string resString = std::string(argv[i + 1]);
|
||||
const auto& resSplits = String::Split(resString, 'x');
|
||||
if (resSplits.size() == 2)
|
||||
{
|
||||
int width = stoi(resSplits[0]);
|
||||
int height = stoi(resSplits[1]);
|
||||
editorResolution = Vector2(width, height);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (args == "--monitor")
|
||||
{
|
||||
if (argc >= i + 1)
|
||||
{
|
||||
std::string monitorIdxString = std::string(argv[i + 1]);
|
||||
monitorIdx = stoi(monitorIdxString);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool shouldLoadProject = false;
|
||||
if (argc > 1)
|
||||
{
|
||||
shouldLoadProject = true;
|
||||
projectPath = std::string(argv[1]);
|
||||
}
|
||||
|
||||
Nuake::Engine::Init();
|
||||
Engine::GetCurrentWindow()->SetSize(editorResolution);
|
||||
|
||||
Nuake::EditorInterface editor;
|
||||
editor.BuildFonts();
|
||||
// Parse launch arguments
|
||||
const auto& arguments = ParseArguments(argc, argv);
|
||||
LaunchSettings launchSettings = ParseLaunchSettings(arguments);
|
||||
|
||||
#ifdef NK_DEBUG
|
||||
WindowTitle += "(DEBUG)";
|
||||
#endif
|
||||
#ifdef NK_RELEASE
|
||||
WindowTitle += "(RELEASE)";
|
||||
#endif
|
||||
launchSettings.windowTitle += "(DEBUG BUILD)";
|
||||
#endif // NK_DEBUG
|
||||
|
||||
Ref<Nuake::Window> window = Nuake::Engine::GetCurrentWindow();
|
||||
window->SetTitle(WindowTitle);
|
||||
// Initialize Engine & Window
|
||||
Engine::Init();
|
||||
auto& window = Engine::GetCurrentWindow();
|
||||
window->SetSize(launchSettings.resolution);
|
||||
window->SetTitle(launchSettings.windowTitle);
|
||||
|
||||
if (monitorIdx != -1)
|
||||
if (launchSettings.monitor >= 0)
|
||||
{
|
||||
window->SetMonitor(monitorIdx);
|
||||
window->SetMonitor(launchSettings.monitor);
|
||||
}
|
||||
WindowTheming::SetWindowDarkMode(window);
|
||||
|
||||
// Initialize Editor
|
||||
Nuake::EditorInterface editor;
|
||||
|
||||
// Load project in argument
|
||||
if (!launchSettings.projectPath.empty())
|
||||
{
|
||||
editor.LoadProject(launchSettings.projectPath);
|
||||
}
|
||||
|
||||
// Start application main loop
|
||||
GizmoDrawer gizmoDrawer = GizmoDrawer();
|
||||
|
||||
if (shouldLoadProject)
|
||||
{
|
||||
FileSystem::SetRootDirectory(FileSystem::GetParentPath(projectPath));
|
||||
|
||||
auto project = Project::New();
|
||||
auto projectFileData = FileSystem::ReadFile(projectPath, true);
|
||||
try
|
||||
{
|
||||
project->Deserialize(json::parse(projectFileData));
|
||||
project->FullPath = projectPath;
|
||||
|
||||
Engine::LoadProject(project);
|
||||
|
||||
editor.filesystem->m_CurrentDirectory = Nuake::FileSystem::RootDirectory;
|
||||
}
|
||||
catch (std::exception exception)
|
||||
{
|
||||
Logger::Log("Error loading project: " + projectPath, "editor", CRITICAL);
|
||||
Logger::Log(exception.what());
|
||||
}
|
||||
}
|
||||
|
||||
while (!window->ShouldClose())
|
||||
{
|
||||
Nuake::Engine::Tick();
|
||||
Nuake::Engine::Draw();
|
||||
|
||||
Timestep ts = Nuake::Engine::GetTimestep();
|
||||
|
||||
Nuake::Engine::Tick(); // Update
|
||||
Nuake::Engine::Draw(); // Render
|
||||
|
||||
// Render editor
|
||||
Nuake::Vector2 WindowSize = window->GetSize();
|
||||
glViewport(0, 0, WindowSize.x, WindowSize.y);
|
||||
Nuake::Renderer2D::BeginDraw(WindowSize);
|
||||
|
||||
// Draw gizmos
|
||||
auto sceneFramebuffer = window->GetFrameBuffer();
|
||||
sceneFramebuffer->Bind();
|
||||
{
|
||||
@@ -164,12 +180,32 @@ int main(int argc, char* argv[])
|
||||
}
|
||||
sceneFramebuffer->Unbind();
|
||||
|
||||
editor.Update(ts);
|
||||
// Update & Draw editor
|
||||
editor.Update(Nuake::Engine::GetTimestep());
|
||||
editor.Draw();
|
||||
|
||||
Nuake::Engine::EndDraw();
|
||||
}
|
||||
|
||||
|
||||
// Shutdown
|
||||
Nuake::Engine::Close();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef NK_DIST
|
||||
|
||||
#include "windows.h"
|
||||
|
||||
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hInstPrev, LPSTR cdmline, int cmdshow)
|
||||
{
|
||||
return ApplicationMain(__argc, __argv);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
return ApplicationMain(argc, argv);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
16
Editor/src/Misc/WindowTheming.cpp
Normal file
16
Editor/src/Misc/WindowTheming.cpp
Normal file
@@ -0,0 +1,16 @@
|
||||
#include "WindowTheming.h"
|
||||
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
#define GLFW_EXPOSE_NATIVE_WIN32
|
||||
#include <GLFW/glfw3native.h>
|
||||
|
||||
#include <dwmapi.h>
|
||||
|
||||
namespace WindowTheming
|
||||
{
|
||||
void SetWindowDarkMode(Ref<Nuake::Window> window)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
8
Editor/src/Misc/WindowTheming.h
Normal file
8
Editor/src/Misc/WindowTheming.h
Normal file
@@ -0,0 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include "src/Window.h"
|
||||
|
||||
namespace WindowTheming
|
||||
{
|
||||
void SetWindowDarkMode(Ref<Nuake::Window> window);
|
||||
}
|
||||
@@ -49,6 +49,8 @@
|
||||
#include "UIDemoWindow.h"
|
||||
#include <src/Audio/AudioManager.h>
|
||||
|
||||
#include <src/UI/ImUI.h>
|
||||
|
||||
namespace Nuake {
|
||||
Ref<UI::UserInterface> userInterface;
|
||||
ImFont* normalFont;
|
||||
@@ -60,6 +62,8 @@ namespace Nuake {
|
||||
filesystem = new FileSystemUI(this);
|
||||
_WelcomeWindow = new WelcomeWindow(this);
|
||||
_audioWindow = new AudioWindow();
|
||||
|
||||
BuildFonts();
|
||||
}
|
||||
|
||||
void EditorInterface::Init()
|
||||
@@ -1053,39 +1057,19 @@ namespace Nuake {
|
||||
ImGui::End();
|
||||
|
||||
std::string title = ICON_FA_TREE + std::string(" Hierarchy");
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0, 0));
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_CellPadding, ImVec2(4, 0));
|
||||
if (ImGui::Begin(title.c_str()))
|
||||
{
|
||||
// Buttons to add and remove entity.
|
||||
if(ImGui::BeginChild("Buttons", ImVec2(ImGui::GetContentRegionAvail().x, 30), false))
|
||||
{
|
||||
// Add entity.
|
||||
if (ImGui::Button(ICON_FA_PLUS, ImVec2(30, 30)))
|
||||
Engine::GetCurrentScene()->CreateEntity("Entity");
|
||||
|
||||
//// Remove Entity
|
||||
//if (ImGui::Button("Remove"))
|
||||
//{
|
||||
// scene->DestroyEntity(m_SelectedEntity);
|
||||
//
|
||||
// // Unselect delted entity.
|
||||
// m_SelectedEntity = scene->GetAllEntities().at(0);
|
||||
//}
|
||||
}
|
||||
ImGui::EndChild();
|
||||
// Draw a tree of entities.
|
||||
ImGui::PushStyleColor(ImGuiCol_ChildBg, ImVec4(26.f / 255.0f, 26.f / 255.0f, 26.f / 255.0f, 1));
|
||||
|
||||
if (ImGui::BeginChild("Scene tree", ImGui::GetContentRegionAvail(), false))
|
||||
{
|
||||
if (ImGui::BeginTable("entity_table", 3, ImGuiTableFlags_BordersInnerV | ImGuiTableFlags_SizingStretchProp))
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_CellPadding, { 8, 4 });
|
||||
if (ImGui::BeginTable("entity_table", 3, ImGuiTableFlags_BordersInnerV | ImGuiTableFlags_SizingStretchProp | ImGuiTableFlags_NoPadInnerX | ImGuiTableFlags_NoPadOuterX))
|
||||
{
|
||||
ImGui::TableSetupColumn("Label", ImGuiTableColumnFlags_IndentEnable);
|
||||
ImGui::TableSetupColumn("Type", ImGuiTableColumnFlags_IndentEnable);
|
||||
ImGui::TableSetupColumn("Visibility", ImGuiTableColumnFlags_NoResize | ImGuiTableColumnFlags_IndentDisable | ImGuiTableColumnFlags_WidthFixed);
|
||||
ImGui::TableHeadersRow();
|
||||
ImGui::TableNextRow();
|
||||
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_CellPadding, ImVec2(0, 0));
|
||||
std::vector<Entity> entities = scene->GetAllEntities();
|
||||
@@ -1116,8 +1100,8 @@ namespace Nuake {
|
||||
}
|
||||
ImGui::PopStyleVar();
|
||||
}
|
||||
|
||||
ImGui::EndTable();
|
||||
ImGui::PopStyleVar();
|
||||
|
||||
}
|
||||
ImGui::EndChild();
|
||||
@@ -1147,8 +1131,6 @@ namespace Nuake {
|
||||
}
|
||||
}
|
||||
ImGui::End();
|
||||
ImGui::PopStyleVar();
|
||||
ImGui::PopStyleVar();
|
||||
}
|
||||
|
||||
bool EditorInterface::EntityContainsItself(Entity source, Entity target)
|
||||
@@ -1703,4 +1685,30 @@ namespace Nuake {
|
||||
|
||||
return entityTypeName;
|
||||
}
|
||||
|
||||
bool EditorInterface::LoadProject(const std::string& projectPath)
|
||||
{
|
||||
FileSystem::SetRootDirectory(FileSystem::GetParentPath(projectPath));
|
||||
|
||||
auto project = Project::New();
|
||||
auto projectFileData = FileSystem::ReadFile(projectPath, true);
|
||||
try
|
||||
{
|
||||
project->Deserialize(json::parse(projectFileData));
|
||||
project->FullPath = projectPath;
|
||||
|
||||
Engine::LoadProject(project);
|
||||
|
||||
filesystem->m_CurrentDirectory = Nuake::FileSystem::RootDirectory;
|
||||
}
|
||||
catch (std::exception exception)
|
||||
{
|
||||
Logger::Log("Error loading project: " + projectPath, "editor", CRITICAL);
|
||||
Logger::Log(exception.what());
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -61,6 +61,7 @@ namespace Nuake
|
||||
|
||||
bool ShouldDrawAxis() const { return m_DrawAxis; }
|
||||
bool ShouldDrawCollision() const { return m_DebugCollisions; }
|
||||
bool LoadProject(const std::string& projectPath);
|
||||
|
||||
private:
|
||||
std::string GetEntityTypeName(const Entity& entity) const;
|
||||
|
||||
@@ -131,10 +131,8 @@ namespace Nuake
|
||||
ImGui::SameLine();
|
||||
DrawRecentProjectsSection();
|
||||
}
|
||||
|
||||
ImGui::End();
|
||||
ImGui::PopStyleVar();
|
||||
ImGui::PopStyleVar();
|
||||
ImGui::PopStyleVar(2);
|
||||
}
|
||||
|
||||
void WelcomeWindow::DrawRecentProjectsSection()
|
||||
|
||||
@@ -68,10 +68,15 @@ project "Freetype"
|
||||
|
||||
filter "configurations:Debug"
|
||||
files { "freetype/src/base/ftdebug.c" }
|
||||
runtime "Debug"
|
||||
symbols "on"
|
||||
runtime "Debug"
|
||||
symbols "on"
|
||||
|
||||
filter "configurations:Release"
|
||||
files { "freetype/src/base/ftdebug.c" }
|
||||
runtime "Release"
|
||||
optimize "on"
|
||||
runtime "Release"
|
||||
optimize "on"
|
||||
|
||||
filter "configurations:Dist"
|
||||
files { "freetype/src/base/ftdebug.c" }
|
||||
runtime "Release"
|
||||
optimize "on"
|
||||
@@ -36,6 +36,11 @@ project 'JoltPhysics'
|
||||
symbols "on"
|
||||
|
||||
filter "configurations:Release"
|
||||
cppdialect "C++17"
|
||||
runtime "Release"
|
||||
optimize "on"
|
||||
|
||||
filter "configurations:Dist"
|
||||
cppdialect "C++17"
|
||||
runtime "Release"
|
||||
optimize "on"
|
||||
@@ -10,72 +10,72 @@
|
||||
#include <chrono>
|
||||
#include <imgui/imgui.h>
|
||||
|
||||
using namespace Nuake;
|
||||
namespace Nuake {
|
||||
void OS::CopyToClipboard(const std::string& value)
|
||||
{
|
||||
auto glob = GlobalAlloc(GMEM_FIXED, 512);
|
||||
memcpy(glob, value.data(), value.size());
|
||||
OpenClipboard(glfwGetWin32Window(Window::Get()->GetHandle()));
|
||||
EmptyClipboard();
|
||||
SetClipboardData(CF_TEXT, glob);
|
||||
CloseClipboard();
|
||||
}
|
||||
|
||||
void OS::CopyToClipboard(const std::string& value)
|
||||
{
|
||||
auto glob = GlobalAlloc(GMEM_FIXED, 512);
|
||||
memcpy(glob, value.data(), value.size());
|
||||
OpenClipboard(glfwGetWin32Window(Window::Get()->GetHandle()));
|
||||
EmptyClipboard();
|
||||
SetClipboardData(CF_TEXT, glob);
|
||||
CloseClipboard();
|
||||
std::string OS::GetFromClipboard()
|
||||
{
|
||||
OpenClipboard(nullptr);
|
||||
HANDLE hData = GetClipboardData(CF_TEXT);
|
||||
|
||||
char* pszText = static_cast<char*>(GlobalLock(hData));
|
||||
std::string text(pszText);
|
||||
|
||||
GlobalUnlock(hData);
|
||||
CloseClipboard();
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
int OS::GetTime()
|
||||
{
|
||||
return static_cast<int>(std::chrono::system_clock::now().time_since_epoch().count());
|
||||
}
|
||||
|
||||
void OS::OpenIn(const std::string& filePath)
|
||||
{
|
||||
ShellExecuteA(nullptr, "open", filePath.c_str(), nullptr, nullptr, SW_SHOWDEFAULT);
|
||||
}
|
||||
|
||||
int OS::RenameFile(const Ref<File>& file, const std::string& newName)
|
||||
{
|
||||
std::string extension = !String::EndsWith(newName, file->GetExtension().c_str()) ? file->GetExtension() : "";
|
||||
std::string newFilePath = file->GetParent()->fullPath + newName + extension;
|
||||
|
||||
std::error_code resultError;
|
||||
std::filesystem::rename(file->GetAbsolutePath().c_str(), newFilePath.c_str(), resultError);
|
||||
return resultError.value() == 0;
|
||||
}
|
||||
|
||||
int OS::RenameDirectory(const Ref<Directory>& dir, const std::string& newName)
|
||||
{
|
||||
std::string newDirPath = dir->Parent->fullPath + newName;
|
||||
|
||||
std::error_code resultError;
|
||||
std::filesystem::rename(dir->fullPath.c_str(), newDirPath.c_str(), resultError);
|
||||
return resultError.value() == 0;
|
||||
}
|
||||
|
||||
void OS::ShowInFileExplorer(const std::string& filePath)
|
||||
{
|
||||
ShellExecuteA(nullptr, "open", "explorer.exe", ("/select," + std::string(filePath)).c_str(), nullptr, SW_SHOWDEFAULT);
|
||||
}
|
||||
|
||||
void OS::OpenTrenchbroomMap(const std::string& filePath)
|
||||
{
|
||||
ShellExecuteA(nullptr, nullptr, Engine::GetProject()->TrenchbroomPath.c_str(), filePath.c_str(), nullptr, SW_SHOW);
|
||||
}
|
||||
|
||||
void OS::OpenURL(const std::string& url)
|
||||
{
|
||||
ShellExecute(nullptr, nullptr, std::wstring(url.begin(), url.end()).c_str(), 0, 0, SW_SHOW);
|
||||
}
|
||||
}
|
||||
|
||||
std::string OS::GetFromClipboard()
|
||||
{
|
||||
OpenClipboard(nullptr);
|
||||
HANDLE hData = GetClipboardData(CF_TEXT);
|
||||
|
||||
char* pszText = static_cast<char*>(GlobalLock(hData));
|
||||
std::string text(pszText);
|
||||
|
||||
GlobalUnlock(hData);
|
||||
CloseClipboard();
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
int OS::GetTime()
|
||||
{
|
||||
return static_cast<int>(std::chrono::system_clock::now().time_since_epoch().count());
|
||||
}
|
||||
|
||||
void OS::OpenIn(const std::string& filePath)
|
||||
{
|
||||
ShellExecuteA(nullptr, "open", filePath.c_str(), nullptr, nullptr, SW_SHOWDEFAULT);
|
||||
}
|
||||
|
||||
int OS::RenameFile(const Ref<File>& file, const std::string& newName)
|
||||
{
|
||||
std::string extension = !String::EndsWith(newName, file->GetExtension().c_str()) ? file->GetExtension() : "";
|
||||
std::string newFilePath = file->GetParent()->fullPath + newName + extension;
|
||||
|
||||
std::error_code resultError;
|
||||
std::filesystem::rename(file->GetAbsolutePath().c_str(), newFilePath.c_str(), resultError);
|
||||
return resultError.value() == 0;
|
||||
}
|
||||
|
||||
int OS::RenameDirectory(const Ref<Directory>& dir, const std::string& newName)
|
||||
{
|
||||
std::string newDirPath = dir->Parent->fullPath + newName;
|
||||
|
||||
std::error_code resultError;
|
||||
std::filesystem::rename(dir->fullPath.c_str(), newDirPath.c_str(), resultError);
|
||||
return resultError.value() == 0;
|
||||
}
|
||||
|
||||
void OS::ShowInFileExplorer(const std::string& filePath)
|
||||
{
|
||||
ShellExecuteA(nullptr, "open", "explorer.exe", ("/select," + std::string(filePath)).c_str(), nullptr, SW_SHOWDEFAULT);
|
||||
}
|
||||
|
||||
void OS::OpenTrenchbroomMap(const std::string& filePath)
|
||||
{
|
||||
ShellExecuteA(nullptr, nullptr, Engine::GetProject()->TrenchbroomPath.c_str(), filePath.c_str(), nullptr, SW_SHOW);
|
||||
}
|
||||
|
||||
void OS::OpenURL(const std::string& url)
|
||||
{
|
||||
ShellExecute(nullptr, nullptr, std::wstring(url.begin(), url.end()).c_str(), 0, 0, SW_SHOW);
|
||||
}
|
||||
@@ -18,6 +18,8 @@
|
||||
|
||||
namespace Nuake
|
||||
{
|
||||
uint32_t Renderer::MAX_LIGHT = 32;
|
||||
|
||||
unsigned int depthTexture;
|
||||
unsigned int depthFBO;
|
||||
|
||||
@@ -137,8 +139,10 @@ namespace Nuake
|
||||
|
||||
void Renderer::RegisterDeferredLight(TransformComponent transform, LightComponent light)
|
||||
{
|
||||
if (m_Lights.size() == 20)
|
||||
if (m_Lights.size() == MAX_LIGHT)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Shader* deferredShader = ShaderManager::GetShader("resources/Shaders/deferred.shader");
|
||||
deferredShader->Bind();
|
||||
@@ -173,7 +177,6 @@ namespace Nuake
|
||||
deferredShader->SetUniform1i("Lights[" + std::to_string(idx - 1) + "].Volumetric", light.IsVolumetric);
|
||||
|
||||
m_LightsUniformBuffer->Bind();
|
||||
//m_LightsUniformBuffer->UpdateData()
|
||||
}
|
||||
|
||||
void Renderer::DrawLine(Vector3 start, Vector3 end, Color color, Matrix4 transform)
|
||||
|
||||
@@ -33,6 +33,7 @@ namespace Nuake
|
||||
{
|
||||
private:
|
||||
static RenderList m_RenderList;
|
||||
static uint32_t MAX_LIGHT;
|
||||
|
||||
public:
|
||||
static VertexArray* QuadVertexArray;
|
||||
|
||||
141
Nuake/src/UI/ImUI.cpp
Normal file
141
Nuake/src/UI/ImUI.cpp
Normal file
@@ -0,0 +1,141 @@
|
||||
#include "ImUI.h"
|
||||
|
||||
namespace Nuake {
|
||||
|
||||
namespace UI {
|
||||
|
||||
void BeginWindow(const std::string& name)
|
||||
{
|
||||
ImGui::Begin(name.c_str());
|
||||
}
|
||||
|
||||
void EndWindow()
|
||||
{
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
bool PrimaryButton(const std::string& name)
|
||||
{
|
||||
ImGui::PushStyleColor(ImGuiCol_Button, IM_COL32(97, 0, 255, 255));
|
||||
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, IM_COL32(97, 0, 255, 200));
|
||||
ImGui::PushStyleColor(ImGuiCol_ButtonActive, IM_COL32(97, 0, 255, 255));
|
||||
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 4.0f);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ButtonPadding);
|
||||
|
||||
UIFont boldFont(Bold);
|
||||
const bool buttonPressed = ImGui::Button(name.c_str());
|
||||
|
||||
ImGui::PopStyleColor(3);
|
||||
|
||||
ImGui::PopStyleVar(2);
|
||||
|
||||
return buttonPressed;
|
||||
}
|
||||
|
||||
bool SecondaryButton(const std::string& name)
|
||||
{
|
||||
ImGui::PushStyleColor(ImGuiCol_Button, IM_COL32(0, 0, 0, 0));
|
||||
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, IM_COL32(97, 0, 255, 200));
|
||||
ImGui::PushStyleColor(ImGuiCol_ButtonActive, IM_COL32(97, 0, 255, 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());
|
||||
|
||||
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.0;
|
||||
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.0;
|
||||
|
||||
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 = false;
|
||||
}
|
||||
}
|
||||
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 = true;
|
||||
}
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,138 +17,18 @@ namespace Nuake
|
||||
static ImVec2 ButtonPadding = ImVec2(16.0f, 8.0f);
|
||||
static ImVec2 IconButtonPadding = ImVec2(8.0f, 8.0f);
|
||||
|
||||
void BeginWindow(const std::string& name)
|
||||
{
|
||||
ImGui::Begin(name.c_str());
|
||||
}
|
||||
void BeginWindow(const std::string& name);
|
||||
|
||||
void EndWindow()
|
||||
{
|
||||
ImGui::End();
|
||||
}
|
||||
void EndWindow();
|
||||
|
||||
bool PrimaryButton(const std::string& name)
|
||||
{
|
||||
ImGui::PushStyleColor(ImGuiCol_Button, IM_COL32(97, 0, 255, 255));
|
||||
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, IM_COL32(97, 0, 255, 200));
|
||||
ImGui::PushStyleColor(ImGuiCol_ButtonActive, IM_COL32(97, 0, 255, 255));
|
||||
bool PrimaryButton(const std::string& name);
|
||||
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 4.0f);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ButtonPadding);
|
||||
bool SecondaryButton(const std::string& name);
|
||||
|
||||
UIFont boldFont(Bold);
|
||||
const bool buttonPressed = ImGui::Button(name.c_str());
|
||||
bool IconButton(const std::string& icon);
|
||||
|
||||
ImGui::PopStyleColor(3);
|
||||
bool FloatSlider(const std::string& name, float& input, float min = 0.0f, float max = 1.0f, float speed = 0.01f);
|
||||
|
||||
ImGui::PopStyleVar(2);
|
||||
|
||||
return buttonPressed;
|
||||
}
|
||||
|
||||
bool SecondaryButton(const std::string& name)
|
||||
{
|
||||
ImGui::PushStyleColor(ImGuiCol_Button, IM_COL32(0, 0, 0, 0));
|
||||
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, IM_COL32(97, 0, 255, 200));
|
||||
ImGui::PushStyleColor(ImGuiCol_ButtonActive, IM_COL32(97, 0, 255, 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());
|
||||
|
||||
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.0;
|
||||
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 = 0.0f, float max = 1.0f, float speed = 0.01f)
|
||||
{
|
||||
//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.0;
|
||||
|
||||
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 = false;
|
||||
}
|
||||
}
|
||||
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 = true;
|
||||
}
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
bool CheckBox(const std::string& name, bool& value);
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
void main(int argc, char* argv[])
|
||||
int ApplicationMain(int argc, char* argv[])
|
||||
{
|
||||
using namespace Nuake;
|
||||
|
||||
@@ -73,3 +73,26 @@ void main(int argc, char* argv[])
|
||||
Engine::EndDraw();
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef NK_DIST
|
||||
|
||||
#include "windows.h"
|
||||
|
||||
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hInstPrev, LPSTR cdmline, int cmdshow)
|
||||
{
|
||||
BOOL USE_DARK_MODE = true;
|
||||
BOOL SET_IMMERSIVE_DARK_MODE_SUCCESS = SUCCEEDED(DwmSetWindowAttribute(
|
||||
WINhWnd, DWMWINDOWATTRIBUTE::DWMWA_USE_IMMERSIVE_DARK_MODE,
|
||||
&USE_DARK_MODE, sizeof(USE_DARK_MODE)));
|
||||
|
||||
return ApplicationMain(__argc, __argv);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void main(int argc, char* argv[])
|
||||
{
|
||||
return ApplicationMain(argc, argv);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
54
premake5.lua
54
premake5.lua
@@ -4,7 +4,8 @@ workspace "Nuake"
|
||||
configurations
|
||||
{
|
||||
"Debug",
|
||||
"Release"
|
||||
"Release",
|
||||
"Dist"
|
||||
}
|
||||
|
||||
outputdir = "%{cfg.buildcfg}-%{cfg.system}-%{cfg.architecture}"
|
||||
@@ -14,6 +15,7 @@ include "Nuake/dependencies/assimp_p5.lua"
|
||||
include "Nuake/dependencies/freetype_p5.lua"
|
||||
include "Nuake/dependencies/jolt_p5.lua"
|
||||
include "Nuake/dependencies/soloud_p5.lua"
|
||||
include "Nuake/dependencies/optick_p5.lua"
|
||||
|
||||
project "Nuake"
|
||||
location "Nuake"
|
||||
@@ -26,6 +28,7 @@ project "Nuake"
|
||||
"_MBCS"
|
||||
}
|
||||
|
||||
|
||||
targetdir ("bin/" .. outputdir .. "/%{prj.name}")
|
||||
objdir ("bin-int/" .. outputdir .. "/%{prj.name}")
|
||||
|
||||
@@ -72,15 +75,30 @@ project "Nuake"
|
||||
filter "system:windows"
|
||||
cppdialect "C++17"
|
||||
staticruntime "On"
|
||||
defines {
|
||||
"NK_WIN"
|
||||
}
|
||||
|
||||
filter "configurations:Debug"
|
||||
runtime "Debug"
|
||||
symbols "on"
|
||||
defines
|
||||
{
|
||||
"NK_DEBUG"
|
||||
}
|
||||
|
||||
filter "configurations:Release"
|
||||
runtime "Release"
|
||||
optimize "on"
|
||||
|
||||
filter "configurations:Dist"
|
||||
runtime "Release"
|
||||
optimize "on"
|
||||
defines
|
||||
{
|
||||
"NK_DIST"
|
||||
}
|
||||
|
||||
project "NuakeRuntime"
|
||||
location "Runtime"
|
||||
kind "ConsoleApp"
|
||||
@@ -138,14 +156,28 @@ project "NuakeRuntime"
|
||||
filter "system:windows"
|
||||
cppdialect "C++17"
|
||||
staticruntime "On"
|
||||
defines {
|
||||
"NK_WIN"
|
||||
}
|
||||
|
||||
filter "configurations:Debug"
|
||||
runtime "Debug"
|
||||
symbols "on"
|
||||
defines {
|
||||
"NK_DEBUG"
|
||||
}
|
||||
|
||||
filter "configurations:Release"
|
||||
kind "WindowedApp"
|
||||
runtime "Release"
|
||||
optimize "on"
|
||||
defines {
|
||||
"NK_DIST",
|
||||
"WIN32_LEAN_AND_MEAN"
|
||||
}
|
||||
entrypoint "WinMainCRTStartup"
|
||||
flags { "WinMain" }
|
||||
buildoptions { "-mwindows"}
|
||||
|
||||
-- copy a file from the objects directory to the target directory
|
||||
postbuildcommands {
|
||||
@@ -161,11 +193,6 @@ project "Editor"
|
||||
objdir ("bin-int/" .. outputdir .. "/%{prj.name}")
|
||||
debugdir ("%{prj.name}")
|
||||
|
||||
defines
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
files
|
||||
{
|
||||
"%{prj.name}/Editor.cpp",
|
||||
@@ -222,11 +249,26 @@ project "Editor"
|
||||
filter "configurations:Debug"
|
||||
runtime "Debug"
|
||||
symbols "on"
|
||||
defines {
|
||||
"NK_DEBUG",
|
||||
"WIN32_LEAN_AND_MEAN"
|
||||
}
|
||||
|
||||
filter "configurations:Release"
|
||||
runtime "Release"
|
||||
optimize "on"
|
||||
|
||||
filter "configurations:Dist"
|
||||
kind "WindowedApp"
|
||||
runtime "Release"
|
||||
optimize "on"
|
||||
defines {
|
||||
"NK_DIST",
|
||||
"WIN32_LEAN_AND_MEAN"
|
||||
}
|
||||
entrypoint "WinMainCRTStartup"
|
||||
flags { "WinMain" }
|
||||
|
||||
-- copy a file from the objects directory to the target directory
|
||||
postbuildcommands {
|
||||
--"{COPY} "Nuake/dependencies/GLFW/lib-vc2019/glfw3.dll" " .. "./bin/" .. outputdir .. "/%{prj.name}/glfw3.dll"
|
||||
|
||||
Reference in New Issue
Block a user