Compare commits

...

10 Commits

Author SHA1 Message Date
SweetId c0a51732d0 fix crash 2023-12-12 12:38:01 +01:00
SweetId 1befc1a3d4 release buffers properly 2023-12-08 16:10:52 +01:00
SweetId e3f4b74a66 minimize nazara dependencies 2023-11-28 19:00:53 +05:30
SweetId ae70760305 fix invalide binding type 2023-11-28 19:00:03 +05:30
SweetId fe6dec9934 Fix arguments order 2023-11-28 18:59:49 +05:30
SweetId 8cb4290a4f passing args to application 2023-11-28 18:39:55 +05:30
SweetId 635b9a58bb passing args as params to Nz::Application 2023-11-28 18:32:31 +05:30
SweetId 37b35051f7 ignore imgui.ini file 2023-11-24 16:05:33 +05:30
SweetId 9e4d157792 fix warnings 2023-11-24 16:04:05 +05:30
SweetId 1accd86a9c split NazaraImgui.hpp into multiples files to speed up compilation 2023-11-24 16:03:56 +05:30
10 changed files with 65 additions and 36 deletions

3
.gitignore vendored
View File

@ -193,3 +193,6 @@ DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Ignore Imgui files
imgui.ini

View File

@ -7,6 +7,8 @@
#include <Nazara/Renderer/GpuSwitch.hpp>
#include <Nazara/Renderer/WindowSwapchain.hpp>
#include <NazaraImgui/ImguiHandler.hpp>
#include <NazaraImgui/ImguiWidgets.hpp>
#include <NazaraImgui/NazaraImgui.hpp>
NAZARA_REQUEST_DEDICATED_GPU()
@ -40,10 +42,7 @@ int main(int argc, char* argv[])
int WinMain(int argc, char* argv[])
#endif
{
NazaraUnused(argc);
NazaraUnused(argv);
Nz::Application<Nz::Graphics, Nz::Imgui> nazara;
Nz::Application<Nz::Graphics, Nz::Imgui> nazara(argc, argv);
auto& windowing = nazara.AddComponent<Nz::AppWindowingComponent>();
std::shared_ptr<Nz::RenderDevice> device = Nz::Graphics::Instance()->GetRenderDevice();

View File

@ -5,6 +5,8 @@
#include <Nazara/Renderer.hpp>
#include <Nazara/Utility.hpp>
#include <NazaraImgui/ImguiHandler.hpp>
#include <NazaraImgui/ImguiWidgets.hpp>
#include <NazaraImgui/NazaraImgui.hpp>
NAZARA_REQUEST_DEDICATED_GPU()
@ -38,10 +40,7 @@ int main(int argc, char* argv[])
int WinMain(int argc, char* argv[])
#endif
{
NazaraUnused(argc);
NazaraUnused(argv);
Nz::Application<Nz::Graphics, Nz::Imgui> nazara;
Nz::Application<Nz::Graphics, Nz::Imgui> nazara(argc, argv);
auto& windowing = nazara.AddComponent<Nz::AppWindowingComponent>();
std::shared_ptr<Nz::RenderDevice> device = Nz::Graphics::Instance()->GetRenderDevice();

View File

@ -0,0 +1,15 @@
#pragma once
/*
ImguiHandler.hpp
Inherit from this base class for your Imgui code to be called by the Imgui renderer
*/
namespace Nz
{
struct ImguiHandler
{
public:
virtual void OnRenderImgui() = 0;
};
}

View File

@ -0,0 +1,30 @@
#pragma once
#include <NazaraImgui/Config.hpp>
#include <Nazara/Math/Rect.hpp>
namespace Nz
{
class Texture;
}
namespace ImGui
{
// custom ImGui widgets for Nazara
// Image overloads
NAZARA_IMGUI_API void Image(const Nz::Texture* texture, const Nz::Color& tintColor = Nz::Color::White(), const Nz::Color& borderColor = Nz::Color(0, 0, 0, 0));
NAZARA_IMGUI_API void Image(const Nz::Texture* texture, const Nz::Vector2f& size, const Nz::Color& tintColor = Nz::Color::White(), const Nz::Color& borderColor = Nz::Color(0, 0, 0, 0));
NAZARA_IMGUI_API void Image(const Nz::Texture* texture, const Nz::Rectf& textureRect, const Nz::Color& tintColor = Nz::Color::White(), const Nz::Color& borderColor = Nz::Color(0, 0, 0, 0));
NAZARA_IMGUI_API void Image(const Nz::Texture* texture, const Nz::Vector2f& size, const Nz::Rectf& textureRect, const Nz::Color& tintColor = Nz::Color::White(), const Nz::Color& borderColor = Nz::Color(0, 0, 0, 0));
// ImageButton overloads
NAZARA_IMGUI_API bool ImageButton(const Nz::Texture* texture, const int framePadding = -1, const Nz::Color& bgColor = Nz::Color(0, 0, 0, 0), const Nz::Color& tintColor = Nz::Color::White());
NAZARA_IMGUI_API bool ImageButton(const Nz::Texture* texture, const Nz::Vector2f& size, const int framePadding = -1, const Nz::Color& bgColor = Nz::Color(0, 0, 0, 0), const Nz::Color& tintColor = Nz::Color::White());
// Draw_list overloads. All positions are in relative coordinates (relative to top-left of the current window)
NAZARA_IMGUI_API void DrawLine(const Nz::Vector2f& a, const Nz::Vector2f& b, const Nz::Color& col, float thickness = 1.0f);
NAZARA_IMGUI_API void DrawRect(const Nz::Rectf& rect, const Nz::Color& color, float rounding = 0.0f, int rounding_corners = 0x0F, float thickness = 1.0f);
NAZARA_IMGUI_API void DrawRectFilled(const Nz::Rectf& rect, const Nz::Color& color, float rounding = 0.0f, int rounding_corners = 0x0F);
}

View File

@ -2,7 +2,6 @@
#include <Nazara/Core/ModuleBase.hpp>
#include <Nazara/Graphics/Graphics.hpp>
#include <Nazara/Math/Rect.hpp>
#include <NazaraImgui/Config.hpp>
#include <NazaraImgui/ImguiDrawer.hpp>
@ -19,11 +18,7 @@ namespace Nz
class Window;
class WindowEventHandler;
struct ImguiHandler
{
public:
virtual void OnRenderImgui() = 0;
};
struct ImguiHandler;
class NAZARA_IMGUI_API Imgui : public Nz::ModuleBase<Imgui>
{
@ -91,23 +86,6 @@ namespace Nz
namespace ImGui
{
// custom ImGui widgets for Nazara
// Image overloads
NAZARA_IMGUI_API void Image(const Nz::Texture* texture, const Nz::Color& tintColor = Nz::Color::White(), const Nz::Color& borderColor = Nz::Color(0, 0, 0, 0));
NAZARA_IMGUI_API void Image(const Nz::Texture* texture, const Nz::Vector2f& size, const Nz::Color& tintColor = Nz::Color::White(), const Nz::Color& borderColor = Nz::Color(0, 0, 0, 0));
NAZARA_IMGUI_API void Image(const Nz::Texture* texture, const Nz::Rectf& textureRect, const Nz::Color& tintColor = Nz::Color::White(), const Nz::Color& borderColor = Nz::Color(0, 0, 0, 0));
NAZARA_IMGUI_API void Image(const Nz::Texture* texture, const Nz::Vector2f& size, const Nz::Rectf& textureRect, const Nz::Color& tintColor = Nz::Color::White(), const Nz::Color& borderColor = Nz::Color(0, 0, 0, 0));
// ImageButton overloads
NAZARA_IMGUI_API bool ImageButton(const Nz::Texture* texture, const int framePadding = -1, const Nz::Color& bgColor = Nz::Color(0,0,0,0), const Nz::Color& tintColor = Nz::Color::White());
NAZARA_IMGUI_API bool ImageButton(const Nz::Texture* texture, const Nz::Vector2f& size, const int framePadding = -1, const Nz::Color& bgColor = Nz::Color(0,0,0,0), const Nz::Color& tintColor = Nz::Color::White());
// Draw_list overloads. All positions are in relative coordinates (relative to top-left of the current window)
NAZARA_IMGUI_API void DrawLine(const Nz::Vector2f& a, const Nz::Vector2f& b, const Nz::Color& col, float thickness = 1.0f);
NAZARA_IMGUI_API void DrawRect(const Nz::Rectf& rect, const Nz::Color& color, float rounding = 0.0f, int rounding_corners = 0x0F, float thickness = 1.0f);
NAZARA_IMGUI_API void DrawRectFilled(const Nz::Rectf& rect, const Nz::Color& color, float rounding = 0.0f, int rounding_corners = 0x0F);
inline void EnsureContextOnThisThread()
{
auto* context = Nz::Imgui::GetCurrentContext();

View File

@ -69,7 +69,7 @@ namespace Nz
m_drawCalls.clear();
ImDrawData* drawData = ImGui::GetDrawData();
if (drawData->CmdListsCount == 0)
if (drawData == nullptr || drawData->CmdListsCount == 0)
return;
ImGuiIO& io = ImGui::GetIO();
@ -123,6 +123,8 @@ namespace Nz
m_drawCalls.push_back(std::move(drawCall));
}
frame.PushForRelease(std::move(m_vertexBuffer));
frame.PushForRelease(std::move(m_indexBuffer));
// now that we have macro buffers, allocate them on gpu
size_t size = vertices.size() * sizeof(Nz::VertexStruct_XYZ_Color_UV);
@ -191,7 +193,7 @@ namespace Nz
}
}
void ImguiDrawer::Reset(RenderResources& renderFrame)
void ImguiDrawer::Reset(RenderResources& /*renderFrame*/)
{
m_drawCalls.clear();
}
@ -223,7 +225,7 @@ namespace Nz
textureBinding.setIndex = 1;
textureBinding.bindingIndex = 0;
textureBinding.shaderStageFlags = nzsl::ShaderStageType::Fragment;
textureBinding.type = Nz::ShaderBindingType::Texture;
textureBinding.type = Nz::ShaderBindingType::Sampler;
std::shared_ptr<Nz::RenderPipelineLayout> renderPipelineLayout = m_renderDevice.InstantiateRenderPipelineLayout(std::move(pipelineLayoutInfo));

View File

@ -7,7 +7,7 @@
namespace Nz
{
ImguiPipelinePass::ImguiPipelinePass(PassData& passData, std::string passName, const ParameterList& /*parameters*/) :
ImguiPipelinePass::ImguiPipelinePass(PassData& /*passData*/, std::string passName, const ParameterList& /*parameters*/) :
FramePipelinePass({})
, m_passName(std::move(passName))
{

View File

@ -1,6 +1,8 @@
#include <NazaraImgui/NazaraImgui.hpp>
#include <NazaraImgui/ImguiPipelinePass.hpp>
#include <NazaraImgui/ImguiDrawer.hpp>
#include <NazaraImgui/ImguiHandler.hpp>
#include <NazaraImgui/ImguiWidgets.hpp>
#include <Nazara/Core/DynLib.hpp>
#include <Nazara/Core/Log.hpp>

View File

@ -51,7 +51,8 @@ elseif is_mode("releasedbg") then
end
target("NazaraImgui")
add_packages("nazara", "nzsl", "imgui", {public = true})
add_packages("nazara", {public = true, components = "graphics"})
add_packages("nzsl", "imgui", {public = true})
set_kind("$(kind)")
set_group("Libraries")
add_headerfiles("include/(NazaraImgui/**.hpp)")