diff --git a/Editor/src/UI/GUIRenderer.h b/Editor/src/UI/GUIRenderer.h index 7005e31..ba24536 100644 --- a/Editor/src/UI/GUIRenderer.h +++ b/Editor/src/UI/GUIRenderer.h @@ -20,7 +20,10 @@ public: ImGui::StyleColorsDark(); ImGui_ImplGlfw_InitForOpenGL(window.GetGLFWHandle(), true); - ImGui_ImplOpenGL3_Init("#version 440"); + ImGui_ImplOpenGL3_Init("#version 450"); + + ImGuizmo::SetOrthographic(true); + } void Begin () @@ -29,20 +32,19 @@ public: ImGui_ImplOpenGL3_NewFrame(); ImGui::NewFrame(); - - ImGuizmo::SetOrthographic(true); ImGuizmo::BeginFrame(); - } void End() - { + { + ImGui::EndFrame(); ImGui::Render(); ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData()); + if (ImGui::GetIO().ConfigFlags & ImGuiConfigFlags_ViewportsEnable) { GLFWwindow* last_context = glfwGetCurrentContext(); @@ -50,15 +52,19 @@ public: ImGui::RenderPlatformWindowsDefault(); glfwMakeContextCurrent(last_context); } + + } ~GUIRenderer(){ + ImGui_ImplOpenGL3_Shutdown(); ImGui_ImplGlfw_Shutdown(); ImGui::DestroyContext(); + } }; diff --git a/Editor/src/UI/widgets.h b/Editor/src/UI/widgets.h index c8ee35f..6d1e27d 100644 --- a/Editor/src/UI/widgets.h +++ b/Editor/src/UI/widgets.h @@ -172,6 +172,8 @@ private: class AssetFinder : EditorWindow { public: AssetFinder() : EditorWindow("Assets") { + + ImGui::DragInt("IconSize", &iconSize, 1, 30, 90); @@ -195,14 +197,14 @@ public: if (asset.isFolder) { ImGui::ImageButton( - (ImTextureID)folderIcon.GetID(), + (ImTextureID)(Texture("rsc/folderIcon.png")).GetID(), ImVec2{ (float)iconSize,(float)iconSize }); ImGui::Text(asset.GetName(), row); } else { ImGui::ImageButton( - (ImTextureID)AssetIcon.GetID(), + (ImTextureID)(Texture("rsc/assetIcon.png")).GetID(), ImVec2{ (float)iconSize, (float)iconSize }); ImGui::Text(asset.GetName(), row); @@ -220,7 +222,7 @@ public: } private: - Texture folderIcon = Texture("rsc/folderIcon.png"); - Texture AssetIcon = Texture("rsc/assetIcon.png"); + static Texture folderIcon; + static Texture AssetIcon; int iconSize = 60; }; \ No newline at end of file diff --git a/Editor/src/app.cpp b/Editor/src/app.cpp index 3b913f4..f875845 100644 --- a/Editor/src/app.cpp +++ b/Editor/src/app.cpp @@ -66,10 +66,13 @@ public: } // submit DrawCommands for all render3DComponents + auto group = ActiveScene.getReg().view(); group.each([&renderer](auto enity, TransformComponent& t, Render3DComponent& renderComponent) { renderer.Submit(renderComponent, t); }); + + renderer.Render(); @@ -127,7 +130,7 @@ public: } { - // AssetFinder assetsView = AssetFinder(); + AssetFinder assetsView = AssetFinder(); } diff --git a/YoggieEngine/premake5.lua b/YoggieEngine/premake5.lua index 82de4f2..5f3fc49 100644 --- a/YoggieEngine/premake5.lua +++ b/YoggieEngine/premake5.lua @@ -24,7 +24,8 @@ project "YoggieEngine" "../libs/assimp/include", "../libs/entt/src", - + + "../libs/physx/pxshared/include", "../libs/physx/physx/include", "../libs/lua/include", @@ -32,7 +33,6 @@ project "YoggieEngine" "../libs/GorillaAudio/include", "../libs/steam-audio/include", - "../libs/ImGui", } @@ -44,6 +44,14 @@ project "YoggieEngine" "assimp-vc143-mtd", "glfw3", "ImGui", + + "PhysX_64", + "PhysXCooking_64", + "PhysXCommon_64", + "PhysXFoundation_64", + "PhysXPvdSDK_static_64", + "PhysXExtensions_static_64" + } @@ -53,6 +61,8 @@ project "YoggieEngine" "../libs/spdlog/build/Release", "../libs/assimp/lib/Debug", "../libs/glfw/build/src/Debug", + "../libs/physx/physx/bin/win.x86_64.vc142.md/debug" + } files { diff --git a/YoggieEngine/src/Application.cpp b/YoggieEngine/src/Application.cpp index 6087c79..6cbdcd0 100644 --- a/YoggieEngine/src/Application.cpp +++ b/YoggieEngine/src/Application.cpp @@ -1,11 +1,45 @@ #include #include "Application.h" +#include +#define PVD_HOST "127.0.0.1" + +using namespace physx; namespace YoggieEngine { + + static PxDefaultErrorCallback gDefaultErrorCallback; + static PxDefaultAllocator gDefaultAllocatorCallback; + static PxFoundation* mFoundation; + static PxPvd* mPvd; + static PxPvdTransport* transport; + static PxPhysics* mPhysics; + bool recordMemoryAllocations = true; + + Application::Application(const std::string& name ) : m_AppName(name) { EngineInstrumentation::PerfomanceSamplerInit(); + + // startup PhysX + mFoundation = PxCreateFoundation(PX_PHYSICS_VERSION, gDefaultAllocatorCallback, gDefaultErrorCallback); + if (!mFoundation) { + spdlog::critical("PxCreateFoundation failed!"); + } + + mPvd = physx::PxCreatePvd(*mFoundation); + if (!mPvd) { + spdlog::critical("pxCreatPvd failed!"); + } + transport = PxDefaultPvdSocketTransportCreate(PVD_HOST, 5425, 10); + mPvd->connect(*transport, PxPvdInstrumentationFlag::eALL); + + + mPhysics = PxCreatePhysics(PX_PHYSICS_VERSION, *mFoundation, PxTolerancesScale(), recordMemoryAllocations, mPvd); + if (!mPhysics) { + spdlog::critical("pxCreatePhysics failed!"); + } + } @@ -14,4 +48,24 @@ namespace YoggieEngine { } + Application::~Application(){ + + if (mPhysics) + mPhysics->release(); + + if (mPvd) { + if (mPvd->isConnected()) { + mPvd->disconnect(); + } + mPvd->release(); + } + + if (transport) + transport->release(); + + + if (mFoundation) + mFoundation->release(); + } + } \ No newline at end of file diff --git a/YoggieEngine/src/Application.h b/YoggieEngine/src/Application.h index 2acb565..47b2db9 100644 --- a/YoggieEngine/src/Application.h +++ b/YoggieEngine/src/Application.h @@ -1,10 +1,13 @@ #pragma once #include "YoggieEngine.h" + namespace YoggieEngine { + class Application { public: Application(const std::string& name); + ~Application(); virtual void Run(); diff --git a/YoggieEngine/src/Graphics/Memory/FrameBuffer.cpp b/YoggieEngine/src/Graphics/Memory/FrameBuffer.cpp index f2cfef2..0066b07 100644 --- a/YoggieEngine/src/Graphics/Memory/FrameBuffer.cpp +++ b/YoggieEngine/src/Graphics/Memory/FrameBuffer.cpp @@ -47,10 +47,6 @@ namespace YoggieEngine { */ - - - - if (!glCheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE) { std::cout << "Framebuffer is incomplete!" << std::endl; diff --git a/YoggieEngine/src/Graphics/Primitives/DrawCommand.h b/YoggieEngine/src/Graphics/Primitives/DrawCommand.h index db713c3..4a50b58 100644 --- a/YoggieEngine/src/Graphics/Primitives/DrawCommand.h +++ b/YoggieEngine/src/Graphics/Primitives/DrawCommand.h @@ -5,8 +5,8 @@ namespace YoggieEngine { unsigned int VAO_identifier; unsigned int num_elements; unsigned int IBO_identifier; - TransformComponent transform; - Shader shader; + TransformComponent& transform; + Shader& shader; // Material }; }; diff --git a/YoggieEngine/src/Graphics/Renderer.cpp b/YoggieEngine/src/Graphics/Renderer.cpp index 65f8228..496a619 100644 --- a/YoggieEngine/src/Graphics/Renderer.cpp +++ b/YoggieEngine/src/Graphics/Renderer.cpp @@ -74,9 +74,6 @@ void Renderer::Render() glClearColor(m_clearColor.r, m_clearColor.g, m_clearColor.b, 1.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - std::cout << "Draw commands this frame:" << commands.size() << std::endl; - - for (const DrawCommand& command : commands) { glBindVertexArray(command.VAO_identifier); diff --git a/YoggieEngine/src/YoggieEngine.h b/YoggieEngine/src/YoggieEngine.h index 01f3cd5..fb8dd97 100644 --- a/YoggieEngine/src/YoggieEngine.h +++ b/YoggieEngine/src/YoggieEngine.h @@ -19,6 +19,8 @@ #include #include + + extern "C" { #include "lauxlib.h" diff --git a/libs/physx b/libs/physx index c3d5537..9414174 160000 --- a/libs/physx +++ b/libs/physx @@ -1 +1 @@ -Subproject commit c3d5537bdebd6f5cd82fcaf87474b838fe6fd5fa +Subproject commit 9414174ec0140ac6b13f4834f16eea93f435a4e7