From c15bf532ae8bb6307a6e6ee83d593b3d1cb84b25 Mon Sep 17 00:00:00 2001 From: antopilo Date: Wed, 27 Sep 2023 01:48:05 -0400 Subject: [PATCH] Compilation succesful on Linux Ubuntu Probably broke a lot of things --- Editor/src/Misc/PopupHelper.cpp | 7 ++ Editor/src/Misc/ThumbnailManager.cpp | 2 +- Editor/src/Misc/WindowTheming.cpp | 6 -- Editor/src/Windows/EditorInterface.cpp | 2 +- Nuake/dependencies/glfw_p5.lua | 27 +++++- Nuake/dependencies/jolt_p5.lua | 11 ++- Nuake/dependencies/soloud_p5.lua | 26 ++++-- Nuake/src/Audio/AudioManager.h | 1 + Nuake/src/Core/FileSystem.cpp | 12 ++- Nuake/src/Core/Input.cpp | 2 +- Nuake/src/Core/Logger.cpp | 10 +++ Nuake/src/Core/Maths.cpp | 12 +-- Nuake/src/Core/OS.cpp | 24 +++++- Nuake/src/Core/Physics/DynamicWorld.h | 2 +- Nuake/src/Rendering/Buffers/Framebuffer.cpp | 2 +- .../src/Rendering/Buffers/MSAAFramebuffer.cpp | 2 +- .../Rendering/Buffers/VertexBufferLayout.h | 72 ++++++++++------ Nuake/src/Rendering/Mesh/Mesh.cpp | 2 +- Nuake/src/Rendering/Mesh/Mesh.h | 2 +- Nuake/src/Rendering/Mesh/SkinnedMesh.cpp | 2 +- Nuake/src/Rendering/Mesh/SkinnedMesh.h | 2 +- Nuake/src/Rendering/PostFX/SSAO.cpp | 2 +- Nuake/src/Rendering/PostFX/Volumetric.h | 2 +- Nuake/src/Rendering/RenderList.h | 4 +- Nuake/src/Rendering/Renderer.cpp | 2 +- Nuake/src/Rendering/SceneRenderer.cpp | 2 +- Nuake/src/Rendering/Shaders/Shader.cpp | 3 +- Nuake/src/Rendering/Shaders/ShaderManager.cpp | 1 - Nuake/src/Rendering/Textures/Cubemap.cpp | 2 +- Nuake/src/Rendering/Textures/HDR.cpp | 2 +- .../Textures/MultiSampledTexture.cpp | 2 +- Nuake/src/Rendering/Textures/Texture.cpp | 2 +- .../src/Rendering/Textures/TextureManager.cpp | 2 +- Nuake/src/Resource/FGD/FGDSerializer.cpp | 2 +- Nuake/src/Resource/UUID.h | 2 +- Nuake/src/Scene/Components/LightComponent.cpp | 2 +- Nuake/src/Scene/Components/TriggerZone.h | 6 +- Nuake/src/Scene/Environment/Skybox.cpp | 2 +- Nuake/src/Scene/Environment/SkyboxHDR.cpp | 6 +- Nuake/src/Scene/Systems/Particle.h | 1 - Nuake/src/Scene/Systems/ParticleEmitter.cpp | 1 - Nuake/src/Scripting/Modules/InputModule.h | 2 +- Nuake/src/UI/Nodes/Node.cpp | 3 - Nuake/src/UI/Styling/Style.h | 2 +- Nuake/src/UI/Styling/StyleSheetParser.cpp | 1 - Nuake/src/Vendors/katana-parser/foundation.c | 21 ++++- Nuake/src/Vendors/katana-parser/katana.lex.c | 4 + Nuake/src/Vendors/katana-parser/katana.lex.h | 4 + Nuake/src/Vendors/katana-parser/selector.c | 5 ++ Nuake/src/Vendors/libmap/c/map_data.c | 10 +++ Nuake/src/Vendors/libmap/h/map_data.h | 15 ++-- Runtime/Runtime.cpp | 4 +- premake5.lua | 82 ++++++++++++++----- 53 files changed, 303 insertions(+), 126 deletions(-) diff --git a/Editor/src/Misc/PopupHelper.cpp b/Editor/src/Misc/PopupHelper.cpp index ad22b8b6..29ca007f 100644 --- a/Editor/src/Misc/PopupHelper.cpp +++ b/Editor/src/Misc/PopupHelper.cpp @@ -44,7 +44,14 @@ bool PopupHelper::DefineTextDialog(const std::string& id, std::string& currentTe char buffer[256]; memset(buffer, 0, sizeof(buffer)); + + #ifdef NK_WIN std::strncpy(buffer, currentText.c_str(), sizeof(buffer)); + #endif + + #ifdef NK_LINUX + strncpy(buffer, currentText.c_str(), sizeof(buffer)); + #endif if (ImGui::InputText("##label", buffer, sizeof(buffer))) { currentText = std::string(buffer); diff --git a/Editor/src/Misc/ThumbnailManager.cpp b/Editor/src/Misc/ThumbnailManager.cpp index 3aed3082..33d0316b 100644 --- a/Editor/src/Misc/ThumbnailManager.cpp +++ b/Editor/src/Misc/ThumbnailManager.cpp @@ -3,7 +3,7 @@ #include #include #include -#include +#include ThumbnailManager::ThumbnailManager() diff --git a/Editor/src/Misc/WindowTheming.cpp b/Editor/src/Misc/WindowTheming.cpp index ff461abc..6607b69f 100644 --- a/Editor/src/Misc/WindowTheming.cpp +++ b/Editor/src/Misc/WindowTheming.cpp @@ -1,11 +1,5 @@ #include "WindowTheming.h" -#include - -#define GLFW_EXPOSE_NATIVE_WIN32 -#include - -#include namespace WindowTheming { diff --git a/Editor/src/Windows/EditorInterface.cpp b/Editor/src/Windows/EditorInterface.cpp index 56a790c1..a355bcda 100644 --- a/Editor/src/Windows/EditorInterface.cpp +++ b/Editor/src/Windows/EditorInterface.cpp @@ -20,7 +20,7 @@ #include "src/Vendors/glm/gtx/matrix_decompose.hpp" #include "src/Resource/FontAwesome5.h" -#include "Dependencies/GLEW/include/GL/glew.h" +#include "dependencies/GLEW/include/GL/glew.h" #include "src/Scene/Scene.h" #include "src/Scene/Components/Components.h" diff --git a/Nuake/dependencies/glfw_p5.lua b/Nuake/dependencies/glfw_p5.lua index 7c95833e..d5472985 100644 --- a/Nuake/dependencies/glfw_p5.lua +++ b/Nuake/dependencies/glfw_p5.lua @@ -10,7 +10,7 @@ project "GLFW" files { "glfw/include/GLFW/glfw3.h", - "glfw/include/GLFW/glfw3native.h", + --"glfw/include/GLFW/glfw3native.h", "glfw/src/glfw_config.h", "glfw/src/context.c", "glfw/src/init.c", @@ -41,6 +41,31 @@ project "GLFW" "_GLFW_WIN32", } + + filter "system:linux" + staticruntime "On" + pic "On" + + files + { + "glfw/src/x11_init.c", + "glfw/src/x11_monitor.c", + "glfw/src/x11_window.c", + "glfw/src/xkb_unicode.c", + "glfw/src/posix_time.c", + "glfw/src/posix_thread.c", + "glfw/src/glx_context.c", + "glfw/src/egl_context.c", + "glfw/src/osmesa_context.c", + "glfw/src/linux_joystick.c" + } + + defines + { + "_GLFW_X11" + } + + filter "configurations:Debug" runtime "Debug" symbols "on" diff --git a/Nuake/dependencies/jolt_p5.lua b/Nuake/dependencies/jolt_p5.lua index 6961997d..1b44b759 100644 --- a/Nuake/dependencies/jolt_p5.lua +++ b/Nuake/dependencies/jolt_p5.lua @@ -26,10 +26,15 @@ project 'JoltPhysics' "JoltPhysics/Jolt.cpp", } - prebuildcommands { - "{COPY} %{prj.location}../Jolt.cpp %{prj.location}" - } + filter "system:windows" + prebuildcommands { + "{COPY} %{prj.location}../Jolt.cpp %{prj.location}" + } + filter "system:not windows" + prebuildcommands { + "cp %{prj.location}./Jolt.cpp %{prj.location}/" + } filter "configurations:Debug" cppdialect "C++17" runtime "Debug" diff --git a/Nuake/dependencies/soloud_p5.lua b/Nuake/dependencies/soloud_p5.lua index a9467c35..d5a980a7 100644 --- a/Nuake/dependencies/soloud_p5.lua +++ b/Nuake/dependencies/soloud_p5.lua @@ -9,9 +9,7 @@ project 'Soloud' targetdir ("soloud/bin/" .. outputdir .. "/%{prj.name}") objdir ("soloud/bin-obj/" .. outputdir .. "/%{prj.name}") - defines { - "WITH_WASAPI" - } + includedirs { "soloud/include" @@ -20,14 +18,32 @@ project 'Soloud' files { "soloud/src/**.h", "soloud/src/core/**.cpp", - "soloud/src/audiosource/**.c*", - "soloud/src/backend/wasapi/**.c*" + "soloud/src/audiosource/**.c*" } prebuildcommands { } + filter "system:windows" + defines { + "WITH_WASAPI" + } + + files + { + "soloud/src/backend/wasapi/**.c*" + } + + filter "system:linux" + defines { + "WITH_OSS" + } + files + { + "soloud/src/backend/oss/soloud_oss.cpp" + } + filter "configurations:Debug" cppdialect "C++17" runtime "Debug" diff --git a/Nuake/src/Audio/AudioManager.h b/Nuake/src/Audio/AudioManager.h index b6c1c189..93d0eaad 100644 --- a/Nuake/src/Audio/AudioManager.h +++ b/Nuake/src/Audio/AudioManager.h @@ -2,6 +2,7 @@ #include "src/Core/Core.h" #include +#include #include #include diff --git a/Nuake/src/Core/FileSystem.cpp b/Nuake/src/Core/FileSystem.cpp index 63ce27e4..974269c3 100644 --- a/Nuake/src/Core/FileSystem.cpp +++ b/Nuake/src/Core/FileSystem.cpp @@ -2,11 +2,15 @@ #include "Engine.h" +#include + +#ifdef NK_WIN #define GLFW_EXPOSE_NATIVE_WIN32 -#include #include "GLFW/glfw3native.h" #include + +#endif #include #include @@ -16,6 +20,7 @@ namespace Nuake std::string FileDialog::OpenFile(const char* filter) { +#ifdef NK_WIN OPENFILENAMEA ofn; CHAR szFile[260] = { 0 }; ZeroMemory(&ofn, sizeof(OPENFILENAME)); @@ -30,12 +35,14 @@ namespace Nuake { return ofn.lpstrFile; } +#endif return std::string(); } std::string FileDialog::SaveFile(const char* filter) { +#ifdef NK_WIN OPENFILENAMEA ofn; CHAR szFile[260] = { 0 }; ZeroMemory(&ofn, sizeof(OPENFILENAME)); @@ -50,8 +57,9 @@ namespace Nuake { return ofn.lpstrFile; } - return std::string(); +#endif + return std::string(); } std::string FileSystem::Root = ""; diff --git a/Nuake/src/Core/Input.cpp b/Nuake/src/Core/Input.cpp index 47e8e115..4d4b1d74 100644 --- a/Nuake/src/Core/Input.cpp +++ b/Nuake/src/Core/Input.cpp @@ -1,7 +1,7 @@ #include "Input.h" #include "src/Window.h" -#include +#include #include namespace Nuake diff --git a/Nuake/src/Core/Logger.cpp b/Nuake/src/Core/Logger.cpp index 3ab41527..f3a17571 100644 --- a/Nuake/src/Core/Logger.cpp +++ b/Nuake/src/Core/Logger.cpp @@ -14,8 +14,18 @@ namespace Nuake char buff[100]; time_t now = time(0); struct tm timeinfo; + +#ifdef NK_WIN + localtime_s(&timeinfo, &now); strftime(buff, 100, "%H:%M:%S", &timeinfo); +#endif + +#ifdef NK_LINUX + time_t timeinfo2; + localtime_r(&timeinfo2, &timeinfo); + strftime(buff, 100, "%H:%M:%S", localtime(&now)); +#endif LogEntry newLog = { type, diff --git a/Nuake/src/Core/Maths.cpp b/Nuake/src/Core/Maths.cpp index e2402703..6996e46d 100644 --- a/Nuake/src/Core/Maths.cpp +++ b/Nuake/src/Core/Maths.cpp @@ -2,7 +2,7 @@ namespace Nuake { - Quat Nuake::LookAt(Vector3 sourcePoint, Vector3 destPoint) + Quat LookAt(Vector3 sourcePoint, Vector3 destPoint) { Vector3 forwardVector = glm::normalize(destPoint - sourcePoint); @@ -23,7 +23,7 @@ namespace Nuake } // just in case you need that function also - Quat Nuake::CreateFromAxisAngle(Vector3 axis, float angle) + Quat CreateFromAxisAngle(Vector3 axis, float angle) { float halfAngle = angle * .5f; float s = sin(halfAngle); @@ -35,7 +35,7 @@ namespace Nuake return q; } - Quat Nuake::QuatFromEuler(float x, float y, float z) + Quat QuatFromEuler(float x, float y, float z) { Quat pitchQuat = glm::angleAxis(Rad(x), Vector3(1.0f, 0.0f, 0.0f)); Quat yawQuat = glm::angleAxis(Rad(y), Vector3(0.0f, 1.0f, 0.0f)); @@ -45,12 +45,12 @@ namespace Nuake return glm::normalize(orientation); } - Vector3 Nuake::QuatToDirection(const Quat& quat) + Vector3 QuatToDirection(const Quat& quat) { return glm::normalize(quat * Vector3(0, 0, -1)); } - void Nuake::Decompose(const Matrix4& m, Vector3& pos, Quat& rot, Vector3& scale) + void Decompose(const Matrix4& m, Vector3& pos, Quat& rot, Vector3& scale) { pos = m[3]; for (int i = 0; i < 3; i++) @@ -62,7 +62,7 @@ namespace Nuake rot = glm::quat_cast(rotMtx); } - const Matrix4& Nuake::TransformToCameraTransform(const Matrix4& mat) + const Matrix4& TransformToCameraTransform(const Matrix4& mat) { return mat; } diff --git a/Nuake/src/Core/OS.cpp b/Nuake/src/Core/OS.cpp index a9210672..e44711c5 100644 --- a/Nuake/src/Core/OS.cpp +++ b/Nuake/src/Core/OS.cpp @@ -2,27 +2,36 @@ #include "src/Window.h" #include "Engine.h" -#define GLFW_EXPOSE_NATIVE_WIN32 +#ifdef NK_WIN + #define GLFW_EXPOSE_NATIVE_WIN32 + + #include +#endif + #include "GLFW/glfw3.h" #include "GLFW/glfw3native.h" -#include + #include #include namespace Nuake { + void OS::CopyToClipboard(const std::string& value) { + #ifdef NK_WIN auto glob = GlobalAlloc(GMEM_FIXED, 512); memcpy(glob, value.data(), value.size()); OpenClipboard(glfwGetWin32Window(Window::Get()->GetHandle())); EmptyClipboard(); SetClipboardData(CF_TEXT, glob); CloseClipboard(); + #endif } std::string OS::GetFromClipboard() { + #ifdef NK_WIN OpenClipboard(nullptr); HANDLE hData = GetClipboardData(CF_TEXT); @@ -33,6 +42,9 @@ namespace Nuake { CloseClipboard(); return text; + #endif + + return ""; } int OS::GetTime() @@ -42,7 +54,9 @@ namespace Nuake { void OS::OpenIn(const std::string& filePath) { + #ifdef NK_WIN ShellExecuteA(nullptr, "open", filePath.c_str(), nullptr, nullptr, SW_SHOWDEFAULT); + #endif } int OS::RenameFile(const Ref& file, const std::string& newName) @@ -66,16 +80,22 @@ namespace Nuake { void OS::ShowInFileExplorer(const std::string& filePath) { + #ifdef NK_WIN ShellExecuteA(nullptr, "open", "explorer.exe", ("/select," + std::string(filePath)).c_str(), nullptr, SW_SHOWDEFAULT); + #endif } void OS::OpenTrenchbroomMap(const std::string& filePath) { + #ifdef NK_WIN ShellExecuteA(nullptr, nullptr, Engine::GetProject()->TrenchbroomPath.c_str(), filePath.c_str(), nullptr, SW_SHOW); + #endif } void OS::OpenURL(const std::string& url) { + #ifdef NK_WIN ShellExecute(nullptr, nullptr, std::wstring(url.begin(), url.end()).c_str(), 0, 0, SW_SHOW); + #endif } } diff --git a/Nuake/src/Core/Physics/DynamicWorld.h b/Nuake/src/Core/Physics/DynamicWorld.h index 21986f6f..a050e768 100644 --- a/Nuake/src/Core/Physics/DynamicWorld.h +++ b/Nuake/src/Core/Physics/DynamicWorld.h @@ -10,7 +10,7 @@ #include #include "CharacterController.h" -#include +#include "Jolt/Jolt.h" namespace JPH diff --git a/Nuake/src/Rendering/Buffers/Framebuffer.cpp b/Nuake/src/Rendering/Buffers/Framebuffer.cpp index 0c559944..e171336d 100644 --- a/Nuake/src/Rendering/Buffers/Framebuffer.cpp +++ b/Nuake/src/Rendering/Buffers/Framebuffer.cpp @@ -1,5 +1,5 @@ #include "Framebuffer.h" -#include +#include "GL/glew.h" namespace Nuake { diff --git a/Nuake/src/Rendering/Buffers/MSAAFramebuffer.cpp b/Nuake/src/Rendering/Buffers/MSAAFramebuffer.cpp index 85ab0aa0..a8681fb9 100644 --- a/Nuake/src/Rendering/Buffers/MSAAFramebuffer.cpp +++ b/Nuake/src/Rendering/Buffers/MSAAFramebuffer.cpp @@ -1,5 +1,5 @@ #include "MSAAFramebuffer.h" -#include +#include namespace Nuake { diff --git a/Nuake/src/Rendering/Buffers/VertexBufferLayout.h b/Nuake/src/Rendering/Buffers/VertexBufferLayout.h index ab3db790..baaeb617 100644 --- a/Nuake/src/Rendering/Buffers/VertexBufferLayout.h +++ b/Nuake/src/Rendering/Buffers/VertexBufferLayout.h @@ -29,43 +29,63 @@ namespace Nuake { unsigned int m_Stride; public: - VertexBufferLayout() : m_Stride(0) {}; + VertexBufferLayout() : m_Stride(0) {} template void Push(unsigned int count) { - } - - template<> - void Push(unsigned int count) - { - m_Elements.push_back({ RendererEnum::FLOAT, count, false }); - m_Stride += VertexBufferElement::GetSizeOfType(RendererEnum::FLOAT) * count; - } - - template<> - void Push(unsigned int count) - { - m_Elements.push_back({ RendererEnum::UINT, count, false }); + if constexpr (std::is_same_v) + { + m_Elements.push_back({ RendererEnum::FLOAT, count, false }); + m_Stride += VertexBufferElement::GetSizeOfType(RendererEnum::FLOAT) * count; + } + + if constexpr (std::is_same_v) + { + m_Elements.push_back({ RendererEnum::UINT, count, false }); m_Stride += VertexBufferElement::GetSizeOfType(RendererEnum::UINT) * count; - } + } - template<> - void Push(unsigned int count) - { - m_Elements.push_back({ RendererEnum::INT, count, false }); - m_Stride += VertexBufferElement::GetSizeOfType(RendererEnum::INT) * count; - } + if constexpr (std::is_same_v) + { + m_Elements.push_back({ RendererEnum::INT, count, false }); + m_Stride += VertexBufferElement::GetSizeOfType(RendererEnum::INT) * count; + } - template<> - void Push(unsigned int count) - { - m_Elements.push_back({ RendererEnum::UBYTE, count, true }); - m_Stride += VertexBufferElement::GetSizeOfType(RendererEnum::UBYTE) * count; + if constexpr (std::is_same_v) + { + m_Elements.push_back({ RendererEnum::UBYTE, count, true }); + m_Stride += VertexBufferElement::GetSizeOfType(RendererEnum::UBYTE) * count; + } } inline const std::vector& GetElements() const { return m_Elements; } inline unsigned int GetStride() const { return m_Stride; } }; + + + +#ifdef NK_WIN + template<> + void VertexBufferLayout::Push(unsigned int count) + { + m_Elements.push_back({ RendererEnum::UINT, count, false }); + m_Stride += VertexBufferElement::GetSizeOfType(RendererEnum::UINT) * count; + }; + + template<> + void VertexBufferLayout::Push(unsigned int count) + { + m_Elements.push_back({ RendererEnum::INT, count, false }); + m_Stride += VertexBufferElement::GetSizeOfType(RendererEnum::INT) * count; + }; + + template<> + void VertexBufferLayout::Push(unsigned int count) + { + m_Elements.push_back({ RendererEnum::UBYTE, count, true }); + m_Stride += VertexBufferElement::GetSizeOfType(RendererEnum::UBYTE) * count; + }; + #endif } \ No newline at end of file diff --git a/Nuake/src/Rendering/Mesh/Mesh.cpp b/Nuake/src/Rendering/Mesh/Mesh.cpp index d097dc45..856af9a8 100644 --- a/Nuake/src/Rendering/Mesh/Mesh.cpp +++ b/Nuake/src/Rendering/Mesh/Mesh.cpp @@ -42,7 +42,7 @@ namespace Nuake return m_Indices; } - Ref Mesh::GetMaterial() inline const + Ref Mesh::GetMaterial() const { return m_Material; } diff --git a/Nuake/src/Rendering/Mesh/Mesh.h b/Nuake/src/Rendering/Mesh/Mesh.h index 3433e2a3..1345a3a2 100644 --- a/Nuake/src/Rendering/Mesh/Mesh.h +++ b/Nuake/src/Rendering/Mesh/Mesh.h @@ -22,7 +22,7 @@ namespace Nuake std::vector& GetVertices(); std::vector& GetIndices(); - Ref GetMaterial() inline const; + Ref GetMaterial() const; void SetMaterial(Ref material); void Bind() const; diff --git a/Nuake/src/Rendering/Mesh/SkinnedMesh.cpp b/Nuake/src/Rendering/Mesh/SkinnedMesh.cpp index 8d97a2d4..619b3f7e 100644 --- a/Nuake/src/Rendering/Mesh/SkinnedMesh.cpp +++ b/Nuake/src/Rendering/Mesh/SkinnedMesh.cpp @@ -40,7 +40,7 @@ namespace Nuake return m_Indices; } - Ref SkinnedMesh::GetMaterial() inline const + Ref SkinnedMesh::GetMaterial() const { return m_Material; } diff --git a/Nuake/src/Rendering/Mesh/SkinnedMesh.h b/Nuake/src/Rendering/Mesh/SkinnedMesh.h index c8af79f7..7cb49f80 100644 --- a/Nuake/src/Rendering/Mesh/SkinnedMesh.h +++ b/Nuake/src/Rendering/Mesh/SkinnedMesh.h @@ -27,7 +27,7 @@ namespace Nuake std::vector& GetVertices(); std::vector& GetIndices(); - Ref GetMaterial() inline const; + Ref GetMaterial() const; void SetMaterial(Ref material); void Bind() const; diff --git a/Nuake/src/Rendering/PostFX/SSAO.cpp b/Nuake/src/Rendering/PostFX/SSAO.cpp index 1310773e..543a668b 100644 --- a/Nuake/src/Rendering/PostFX/SSAO.cpp +++ b/Nuake/src/Rendering/PostFX/SSAO.cpp @@ -5,7 +5,7 @@ #include "src/Rendering/Shaders/ShaderManager.h" #include "src/Rendering/Renderer.h" -#include +#include #include #include diff --git a/Nuake/src/Rendering/PostFX/Volumetric.h b/Nuake/src/Rendering/PostFX/Volumetric.h index 9b366ae7..04aa5b93 100644 --- a/Nuake/src/Rendering/PostFX/Volumetric.h +++ b/Nuake/src/Rendering/PostFX/Volumetric.h @@ -1,7 +1,7 @@ #pragma once #include "src/Core/Core.h" #include "src/Core/Maths.h" -#include "src/Rendering/Buffers/FrameBuffer.h" +#include "src/Rendering/Buffers/Framebuffer.h" #include "src/Scene/Components/LightComponent.h" #include diff --git a/Nuake/src/Rendering/RenderList.h b/Nuake/src/Rendering/RenderList.h index 54afb605..fe6d176a 100644 --- a/Nuake/src/Rendering/RenderList.h +++ b/Nuake/src/Rendering/RenderList.h @@ -12,7 +12,7 @@ namespace Nuake { struct RenderMesh { - Ref Mesh; + Ref mesh; Matrix4 transform; int32_t entityId; }; @@ -62,7 +62,7 @@ namespace Nuake } shader->SetUniformMat4f(modelMatrixUniformLocation, m.transform); - m.Mesh->Draw(shader, false); + m.mesh->Draw(shader, false); } } diff --git a/Nuake/src/Rendering/Renderer.cpp b/Nuake/src/Rendering/Renderer.cpp index b9c4e6bc..649a4ffa 100644 --- a/Nuake/src/Rendering/Renderer.cpp +++ b/Nuake/src/Rendering/Renderer.cpp @@ -1,6 +1,6 @@ #include "Renderer.h" -#include +#include #include "RenderCommand.h" diff --git a/Nuake/src/Rendering/SceneRenderer.cpp b/Nuake/src/Rendering/SceneRenderer.cpp index 1080a7a8..da4c25b7 100644 --- a/Nuake/src/Rendering/SceneRenderer.cpp +++ b/Nuake/src/Rendering/SceneRenderer.cpp @@ -5,7 +5,7 @@ #include "src/Scene/Components/SpriteComponent.h" #include "src/Scene/Components/ParticleEmitterComponent.h" -#include +#include #include #include diff --git a/Nuake/src/Rendering/Shaders/Shader.cpp b/Nuake/src/Rendering/Shaders/Shader.cpp index b77a074e..d61f669a 100644 --- a/Nuake/src/Rendering/Shaders/Shader.cpp +++ b/Nuake/src/Rendering/Shaders/Shader.cpp @@ -1,11 +1,10 @@ -#pragma once #include "src/Core/Core.h" #include "Shader.h" #include "src/Core/FileSystem.h" #include "src/Core/Logger.h" #include -#include +#include namespace Nuake diff --git a/Nuake/src/Rendering/Shaders/ShaderManager.cpp b/Nuake/src/Rendering/Shaders/ShaderManager.cpp index d331fb69..2ef32d4d 100644 --- a/Nuake/src/Rendering/Shaders/ShaderManager.cpp +++ b/Nuake/src/Rendering/Shaders/ShaderManager.cpp @@ -1,4 +1,3 @@ -#pragma once #include "ShaderManager.h" #include "src/Core/Logger.h" diff --git a/Nuake/src/Rendering/Textures/Cubemap.cpp b/Nuake/src/Rendering/Textures/Cubemap.cpp index 1d491455..c8291512 100644 --- a/Nuake/src/Rendering/Textures/Cubemap.cpp +++ b/Nuake/src/Rendering/Textures/Cubemap.cpp @@ -1,5 +1,5 @@ #include "Cubemap.h" -#include +#include #include #include "HDR.h" diff --git a/Nuake/src/Rendering/Textures/HDR.cpp b/Nuake/src/Rendering/Textures/HDR.cpp index 8e35acd5..6ebdf99b 100644 --- a/Nuake/src/Rendering/Textures/HDR.cpp +++ b/Nuake/src/Rendering/Textures/HDR.cpp @@ -1,5 +1,5 @@ #include "HDR.h" -#include +#include #include #include "src/Rendering/Renderer.h" diff --git a/Nuake/src/Rendering/Textures/MultiSampledTexture.cpp b/Nuake/src/Rendering/Textures/MultiSampledTexture.cpp index 6634b608..985588bb 100644 --- a/Nuake/src/Rendering/Textures/MultiSampledTexture.cpp +++ b/Nuake/src/Rendering/Textures/MultiSampledTexture.cpp @@ -1,5 +1,5 @@ #include "MultiSampledTexture.h" -#include +#include #include namespace Nuake diff --git a/Nuake/src/Rendering/Textures/Texture.cpp b/Nuake/src/Rendering/Textures/Texture.cpp index bd518695..76e99368 100644 --- a/Nuake/src/Rendering/Textures/Texture.cpp +++ b/Nuake/src/Rendering/Textures/Texture.cpp @@ -1,6 +1,6 @@ #include "Texture.h" #include "src/Core/Logger.h" -#include +#include #include #include diff --git a/Nuake/src/Rendering/Textures/TextureManager.cpp b/Nuake/src/Rendering/Textures/TextureManager.cpp index 256edfa8..c6677c41 100644 --- a/Nuake/src/Rendering/Textures/TextureManager.cpp +++ b/Nuake/src/Rendering/Textures/TextureManager.cpp @@ -2,7 +2,7 @@ #include "src/Rendering/Textures/Texture.h" #include "src/Resource/StaticResources.h" -#include +#include namespace Nuake { diff --git a/Nuake/src/Resource/FGD/FGDSerializer.cpp b/Nuake/src/Resource/FGD/FGDSerializer.cpp index dd4a2463..a254646b 100644 --- a/Nuake/src/Resource/FGD/FGDSerializer.cpp +++ b/Nuake/src/Resource/FGD/FGDSerializer.cpp @@ -1,5 +1,5 @@ #include "FDGSerializer.h" -#include +#include namespace Nuake { bool FGDSerializer::BeginFGDFile(const std::string path) diff --git a/Nuake/src/Resource/UUID.h b/Nuake/src/Resource/UUID.h index 7b51c22d..cdce983d 100644 --- a/Nuake/src/Resource/UUID.h +++ b/Nuake/src/Resource/UUID.h @@ -1,6 +1,6 @@ #pragma once #include -#include +#include namespace Nuake { diff --git a/Nuake/src/Scene/Components/LightComponent.cpp b/Nuake/src/Scene/Components/LightComponent.cpp index 939240ca..e55d8ad6 100644 --- a/Nuake/src/Scene/Components/LightComponent.cpp +++ b/Nuake/src/Scene/Components/LightComponent.cpp @@ -3,7 +3,7 @@ #include "LightComponent.h" #include "src/Rendering/Renderer.h" -#include +#include #include "src/Core/Core.h" #include diff --git a/Nuake/src/Scene/Components/TriggerZone.h b/Nuake/src/Scene/Components/TriggerZone.h index 706474b8..ed1aea09 100644 --- a/Nuake/src/Scene/Components/TriggerZone.h +++ b/Nuake/src/Scene/Components/TriggerZone.h @@ -5,7 +5,7 @@ namespace Nuake { class TriggerZone { public: - Ref GhostObject; + Ref m_GhostObject; std::string target = ""; std::vector Targets; @@ -20,7 +20,7 @@ namespace Nuake { { if (!Enabled) return 0; - return GhostObject->OverlappingCount(); + return m_GhostObject->OverlappingCount(); } std::vector GetTargets() { @@ -32,7 +32,7 @@ namespace Nuake { if (!Enabled) return std::vector(); - return GhostObject->GetOverlappingEntities(); + return m_GhostObject->GetOverlappingEntities(); } }; } diff --git a/Nuake/src/Scene/Environment/Skybox.cpp b/Nuake/src/Scene/Environment/Skybox.cpp index 72e79a01..be11f8f8 100644 --- a/Nuake/src/Scene/Environment/Skybox.cpp +++ b/Nuake/src/Scene/Environment/Skybox.cpp @@ -1,5 +1,5 @@ #include "Skybox.h" -#include +#include #include "src/Rendering/Renderer.h" #include "src/Rendering/Textures/Cubemap.h" diff --git a/Nuake/src/Scene/Environment/SkyboxHDR.cpp b/Nuake/src/Scene/Environment/SkyboxHDR.cpp index 3e555a8f..2a1a7037 100644 --- a/Nuake/src/Scene/Environment/SkyboxHDR.cpp +++ b/Nuake/src/Scene/Environment/SkyboxHDR.cpp @@ -1,5 +1,5 @@ #include "SkyboxHDR.h" -#include +#include #include "src/Rendering/Renderer.h" #include "src/Rendering/Textures/Cubemap.h" @@ -294,8 +294,8 @@ namespace Nuake { for (unsigned int mip = 0; mip < maxMipLevels; ++mip) { // reisze framebuffer according to mip-level size. - unsigned int mipWidth = unsigned int(1024 * std::pow(0.5f, mip)); - unsigned int mipHeight = unsigned int(1024 * std::pow(0.5f, mip)); + uint32_t mipWidth = 1024 * std::pow(0.5f, mip); + uint32_t mipHeight = 1024 * std::pow(0.5f, mip); glBindRenderbuffer(GL_RENDERBUFFER, captureRBO); glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT24, mipWidth, mipHeight); glViewport(0, 0, mipWidth, mipHeight); diff --git a/Nuake/src/Scene/Systems/Particle.h b/Nuake/src/Scene/Systems/Particle.h index 113a9c86..ae5dc09c 100644 --- a/Nuake/src/Scene/Systems/Particle.h +++ b/Nuake/src/Scene/Systems/Particle.h @@ -8,7 +8,6 @@ namespace Nuake Vector3 Position; Vector3 Velocity; float Scale; - Color Color; float Life; }; } diff --git a/Nuake/src/Scene/Systems/ParticleEmitter.cpp b/Nuake/src/Scene/Systems/ParticleEmitter.cpp index 9f57cfd9..d207f358 100644 --- a/Nuake/src/Scene/Systems/ParticleEmitter.cpp +++ b/Nuake/src/Scene/Systems/ParticleEmitter.cpp @@ -48,7 +48,6 @@ namespace Nuake initialPosition, initialVelocity, Scale, - initialColor, initialLife }); diff --git a/Nuake/src/Scripting/Modules/InputModule.h b/Nuake/src/Scripting/Modules/InputModule.h index 468bb9d1..64784d1c 100644 --- a/Nuake/src/Scripting/Modules/InputModule.h +++ b/Nuake/src/Scripting/Modules/InputModule.h @@ -19,7 +19,7 @@ namespace Nuake { void RegisterModule(WrenVM* vm) override { - RegisterMethod("GetMouseX()", GetMouseX); + RegisterMethod("GetMouseX()", (void*)GetMouseX); RegisterMethod("GetMouseY()", (void*)GetMouseY); RegisterMethod("IsKeyDown_(_)", (void*)IsKeyDown); diff --git a/Nuake/src/UI/Nodes/Node.cpp b/Nuake/src/UI/Nodes/Node.cpp index d76f740f..aed4bec0 100644 --- a/Nuake/src/UI/Nodes/Node.cpp +++ b/Nuake/src/UI/Nodes/Node.cpp @@ -116,9 +116,6 @@ namespace Nuake style.Position.Bottom.mUnit = (Layout::Unit)s.second.type; style.Position.Bottom.Value = s.second.value.Number; break; - case PropType::BACKGROUND_COLOR: - style.BackgroundColor = s.second.value.Color; - break; } } diff --git a/Nuake/src/UI/Styling/Style.h b/Nuake/src/UI/Styling/Style.h index 4bd6075b..5d68c23f 100644 --- a/Nuake/src/UI/Styling/Style.h +++ b/Nuake/src/UI/Styling/Style.h @@ -84,7 +84,7 @@ namespace Nuake union Value { float Number; - Color Color; + Color Color_; int Enum; }; struct PropValue diff --git a/Nuake/src/UI/Styling/StyleSheetParser.cpp b/Nuake/src/UI/Styling/StyleSheetParser.cpp index 3a35d477..1f9056a1 100644 --- a/Nuake/src/UI/Styling/StyleSheetParser.cpp +++ b/Nuake/src/UI/Styling/StyleSheetParser.cpp @@ -72,7 +72,6 @@ namespace Nuake PropValueType::COLOR, {0}, }; - data.value.Color = Color(r, g, b, a); return data; } } diff --git a/Nuake/src/Vendors/katana-parser/foundation.c b/Nuake/src/Vendors/katana-parser/foundation.c index cc9feb11..ac210140 100644 --- a/Nuake/src/Vendors/katana-parser/foundation.c +++ b/Nuake/src/Vendors/katana-parser/foundation.c @@ -12,9 +12,18 @@ #include #include #include -strncasecmp(const char* a, const char* b) +#ifdef _WIN32 +#include // for _stricmp on Windows +#else +#include // for strcasecmp on non-Windows platforms +#endif +int strncasecmp(const char* a, const char* b, size_t n) { - return _stricmp(a, b); +#ifdef _WIN32 + return _strnicmp(a, b, n); // Case-insensitive comparison on Windows +#else + return strncasecmp(a, b, n); // Case-insensitive comparison on non-Windows platforms +#endif } //#undef assert //#define assert(x) @@ -87,7 +96,13 @@ bool katana_string_has_prefix(const char* str, const char* prefix) { size_t pre_len = strlen(prefix); size_t str_len = strlen(str); - return pre_len <= str_len && strncasecmp(prefix, str, pre_len); + + // Ensure that the prefix length is less than or equal to the string length + if (pre_len <= str_len) { + return strncmp(prefix, str, pre_len) == 0; + } + + return false; } void katana_string_to_lowercase(struct KatanaInternalParser* parser, diff --git a/Nuake/src/Vendors/katana-parser/katana.lex.c b/Nuake/src/Vendors/katana-parser/katana.lex.c index 97c34af0..1b60230d 100644 --- a/Nuake/src/Vendors/katana-parser/katana.lex.c +++ b/Nuake/src/Vendors/katana-parser/katana.lex.c @@ -1927,7 +1927,11 @@ extern int katanalex \ * down here because we want the user's section 1 to have been scanned first. * The user has a chance to override it with an option. */ +#ifdef _WIN32 #include +#else +#include +#endif #endif #ifndef YY_EXTRA_TYPE diff --git a/Nuake/src/Vendors/katana-parser/katana.lex.h b/Nuake/src/Vendors/katana-parser/katana.lex.h index c496e348..e7008c9a 100644 --- a/Nuake/src/Vendors/katana-parser/katana.lex.h +++ b/Nuake/src/Vendors/katana-parser/katana.lex.h @@ -235,7 +235,11 @@ void katanafree (void * ,yyscan_t yyscanner ); * down here because we want the user's section 1 to have been scanned first. * The user has a chance to override it with an option. */ +#ifdef _WIN32 #include +#else +#include +#endif #endif #ifndef YY_EXTRA_TYPE diff --git a/Nuake/src/Vendors/katana-parser/selector.c b/Nuake/src/Vendors/katana-parser/selector.c index 7bb53978..957650da 100644 --- a/Nuake/src/Vendors/katana-parser/selector.c +++ b/Nuake/src/Vendors/katana-parser/selector.c @@ -26,7 +26,12 @@ #include strcasecmp(const char* a, const char* b) { + #ifdef NK_WIN return _stricmp(a, b); + #endif + #ifdef NK_LINUX + return strcasecmp(a, b); + #endif } #undef assert #define assert(x) diff --git a/Nuake/src/Vendors/libmap/c/map_data.c b/Nuake/src/Vendors/libmap/c/map_data.c index 67e5e065..2d66af84 100644 --- a/Nuake/src/Vendors/libmap/c/map_data.c +++ b/Nuake/src/Vendors/libmap/c/map_data.c @@ -8,6 +8,16 @@ #include #include +int entity_count; +entity *entities; +entity_geometry *entity_geo; + +int texture_count; +texture_data *textures; + +int worldspawn_layer_count; +worldspawn_layer *worldspawn_layers; + void map_data_reset() { if (entities != NULL) diff --git a/Nuake/src/Vendors/libmap/h/map_data.h b/Nuake/src/Vendors/libmap/h/map_data.h index 1d8a5af4..f1924e3b 100644 --- a/Nuake/src/Vendors/libmap/h/map_data.h +++ b/Nuake/src/Vendors/libmap/h/map_data.h @@ -1,3 +1,4 @@ +#pragma once #ifndef MAP_DATA_H #define MAP_DATA_H @@ -18,15 +19,15 @@ typedef struct worldspawn_layer bool build_visuals; } worldspawn_layer; -int entity_count; -entity *entities; -entity_geometry *entity_geo; +extern int entity_count; +extern entity *entities; +extern entity_geometry *entity_geo; -int texture_count; -texture_data *textures; +extern int texture_count; +extern texture_data *textures; -int worldspawn_layer_count; -worldspawn_layer *worldspawn_layers; +extern int worldspawn_layer_count; +extern worldspawn_layer *worldspawn_layers; void map_data_reset(); diff --git a/Runtime/Runtime.cpp b/Runtime/Runtime.cpp index 92a6294a..098b98da 100644 --- a/Runtime/Runtime.cpp +++ b/Runtime/Runtime.cpp @@ -1,6 +1,6 @@ #include -#include +//#include #include #include @@ -45,7 +45,7 @@ int ApplicationMain(int argc, char* argv[]) Engine::Draw(); const auto& WindowSize = window->GetSize(); - glViewport(0, 0, WindowSize.x, WindowSize.y); + //glViewport(0, 0, WindowSize.x, WindowSize.y); Nuake::Renderer2D::BeginDraw(WindowSize); ImGuiViewport* viewport = ImGui::GetMainViewport(); diff --git a/premake5.lua b/premake5.lua index b1f69cd6..69c462f7 100644 --- a/premake5.lua +++ b/premake5.lua @@ -56,17 +56,17 @@ project "Nuake" { "%{prj.name}/../Nuake", "%{prj.name}/../Nuake/src/Vendors", - "%{prj.name}/../Nuake/Dependencies/GLEW/include", - "%{prj.name}/../Nuake/Dependencies/GLFW/include", - "%{prj.name}/../Nuake/Dependencies/assimp/include", - "%{prj.name}/../Nuake/Dependencies/JoltPhysics", + "%{prj.name}/../Nuake/dependencies/GLEW/include", + "%{prj.name}/../Nuake/dependencies/glfw/include", + "%{prj.name}/../Nuake/dependencies/assimp/include", + "%{prj.name}/../Nuake/dependencies/JoltPhysics", "%{prj.name}/../Nuake/src/Vendors/msdfgen/include", "%{prj.name}/../Nuake/src/Vendors/msdfgen/freetype/include", "%{prj.name}/../Nuake/src/Vendors/msdfgen", "%{prj.name}/../Nuake/src/Vendors/wren/src/include", "%{prj.name}/../Nuake/src/Vendors/incbin", - "%{prj.name}/../Nuake/Dependencies/build", - "%{prj.name}/../Nuake/Dependencies/soloud/include" + "%{prj.name}/../Nuake/dependencies/build", + "%{prj.name}/../Nuake/dependencies/soloud/include" } links @@ -75,12 +75,22 @@ project "Nuake" "soloud" } + filter "system:linux" + cppdialect "C++20" + staticruntime "On" + defines { + "NK_LINUX", + "GLFW_STATIC", + "GLEW_NO_GLU" + } filter "system:windows" cppdialect "C++20" staticruntime "On" defines { "NK_WIN" } + + buildoptions { "-permissive", "-cxxflags"} filter "configurations:Debug" runtime "Debug" @@ -133,6 +143,7 @@ project "NuakeRuntime" libdirs { "%{prj.name}/../Nuake/dependencies/GLEW/lib/Release/x64", + "%{prj.name}/../Nuake/dependencies/GLEW/lib/Release/Linux", "%{prj.name}/../Nuake/dependencies/assimp/lib/", "%{prj.name}/../Nuake/dependencies/freetype-windows-binaries/release static/win64", "%{prj.name}/../bin/%{cfg.buildcfg}-%{cfg.system}-%{cfg.architecture}/Nuake/", @@ -149,8 +160,6 @@ project "NuakeRuntime" "Nuake", "GLFW", "assimp", - "glew32s.lib", - "opengl32.lib", "Freetype", "JoltPhysics", "soloud" @@ -162,6 +171,17 @@ project "NuakeRuntime" defines { "NK_WIN" } + links + { + "opengl32.lib" + } + + filter "system:linux" + links + { + "GL", + "GLEW" + } filter "configurations:Debug" runtime "Debug" @@ -209,23 +229,21 @@ project "Editor" { "%{prj.name}/Editor.cpp", "%{prj.name}/src/**.cpp", - "%{prj.name}/src/**.h", - "%{prj.name}/resources/*.rc", - "%{prj.name}/resources/**.ico" + "%{prj.name}/src/**.h" } includedirs { "%{prj.name}/../Nuake", "%{prj.name}/../Nuake/src/Vendors", - "%{prj.name}/../Nuake/Dependencies/GLEW/include", - "%{prj.name}/../Nuake/Dependencies/GLFW/include", - "%{prj.name}/../Nuake/Dependencies/assimp/include", - "%{prj.name}/../Nuake/Dependencies/build", + "%{prj.name}/../Nuake/dependencies/GLEW/include", + "%{prj.name}/../Nuake/dependencies/glfw/include", + "%{prj.name}/../Nuake/dependencies/assimp/include", + "%{prj.name}/../Nuake/dependencies/build", "%{prj.name}/../Nuake/src/Vendors/msdfgen", - "%{prj.name}/../Nuake/Dependencies/JoltPhysics", - "%{prj.name}/../Nuake/Dependencies/build", - "%{prj.name}/../Nuake/Dependencies/soloud/include" + "%{prj.name}/../Nuake/dependencies/JoltPhysics", + "%{prj.name}/../Nuake/dependencies/build", + "%{prj.name}/../Nuake/dependencies/soloud/include" } libdirs @@ -244,11 +262,10 @@ project "Editor" links { - "Nuake", + "Nuake", + "GLEW", "GLFW", "assimp", - "glew32s.lib", - "opengl32.lib", "Freetype", "JoltPhysics", "soloud" @@ -257,6 +274,29 @@ project "Editor" filter "system:windows" cppdialect "C++20" staticruntime "On" + links + { + "OpenGL32" + } + files + { + "%{prj.name}/resources/*.rc", + "%{prj.name}/resources/**.ico" + } + + filter "system:linux" + links + { + "GL", + "GLEW", + "X11" + } + cppdialect "C++20" + staticruntime "On" + defines { + "NK_LINUX", + "GLFW_STATIC" + } filter "configurations:Debug" runtime "Debug"