Compare commits
10 Commits
41c6439b90
...
c0a51732d0
| Author | SHA1 | Date |
|---|---|---|
|
|
c0a51732d0 | |
|
|
1befc1a3d4 | |
|
|
e3f4b74a66 | |
|
|
ae70760305 | |
|
|
fe6dec9934 | |
|
|
8cb4290a4f | |
|
|
635b9a58bb | |
|
|
37b35051f7 | |
|
|
9e4d157792 | |
|
|
1accd86a9c |
|
|
@ -193,3 +193,6 @@ DocProject/Help/*.hhk
|
||||||
DocProject/Help/*.hhp
|
DocProject/Help/*.hhp
|
||||||
DocProject/Help/Html2
|
DocProject/Help/Html2
|
||||||
DocProject/Help/html
|
DocProject/Help/html
|
||||||
|
|
||||||
|
# Ignore Imgui files
|
||||||
|
imgui.ini
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,8 @@
|
||||||
#include <Nazara/Renderer/GpuSwitch.hpp>
|
#include <Nazara/Renderer/GpuSwitch.hpp>
|
||||||
#include <Nazara/Renderer/WindowSwapchain.hpp>
|
#include <Nazara/Renderer/WindowSwapchain.hpp>
|
||||||
|
|
||||||
|
#include <NazaraImgui/ImguiHandler.hpp>
|
||||||
|
#include <NazaraImgui/ImguiWidgets.hpp>
|
||||||
#include <NazaraImgui/NazaraImgui.hpp>
|
#include <NazaraImgui/NazaraImgui.hpp>
|
||||||
|
|
||||||
NAZARA_REQUEST_DEDICATED_GPU()
|
NAZARA_REQUEST_DEDICATED_GPU()
|
||||||
|
|
@ -40,10 +42,7 @@ int main(int argc, char* argv[])
|
||||||
int WinMain(int argc, char* argv[])
|
int WinMain(int argc, char* argv[])
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
NazaraUnused(argc);
|
Nz::Application<Nz::Graphics, Nz::Imgui> nazara(argc, argv);
|
||||||
NazaraUnused(argv);
|
|
||||||
|
|
||||||
Nz::Application<Nz::Graphics, Nz::Imgui> nazara;
|
|
||||||
auto& windowing = nazara.AddComponent<Nz::AppWindowingComponent>();
|
auto& windowing = nazara.AddComponent<Nz::AppWindowingComponent>();
|
||||||
std::shared_ptr<Nz::RenderDevice> device = Nz::Graphics::Instance()->GetRenderDevice();
|
std::shared_ptr<Nz::RenderDevice> device = Nz::Graphics::Instance()->GetRenderDevice();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,8 @@
|
||||||
#include <Nazara/Renderer.hpp>
|
#include <Nazara/Renderer.hpp>
|
||||||
#include <Nazara/Utility.hpp>
|
#include <Nazara/Utility.hpp>
|
||||||
|
|
||||||
|
#include <NazaraImgui/ImguiHandler.hpp>
|
||||||
|
#include <NazaraImgui/ImguiWidgets.hpp>
|
||||||
#include <NazaraImgui/NazaraImgui.hpp>
|
#include <NazaraImgui/NazaraImgui.hpp>
|
||||||
|
|
||||||
NAZARA_REQUEST_DEDICATED_GPU()
|
NAZARA_REQUEST_DEDICATED_GPU()
|
||||||
|
|
@ -38,10 +40,7 @@ int main(int argc, char* argv[])
|
||||||
int WinMain(int argc, char* argv[])
|
int WinMain(int argc, char* argv[])
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
NazaraUnused(argc);
|
Nz::Application<Nz::Graphics, Nz::Imgui> nazara(argc, argv);
|
||||||
NazaraUnused(argv);
|
|
||||||
|
|
||||||
Nz::Application<Nz::Graphics, Nz::Imgui> nazara;
|
|
||||||
auto& windowing = nazara.AddComponent<Nz::AppWindowingComponent>();
|
auto& windowing = nazara.AddComponent<Nz::AppWindowingComponent>();
|
||||||
std::shared_ptr<Nz::RenderDevice> device = Nz::Graphics::Instance()->GetRenderDevice();
|
std::shared_ptr<Nz::RenderDevice> device = Nz::Graphics::Instance()->GetRenderDevice();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -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);
|
||||||
|
}
|
||||||
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
#include <Nazara/Core/ModuleBase.hpp>
|
#include <Nazara/Core/ModuleBase.hpp>
|
||||||
#include <Nazara/Graphics/Graphics.hpp>
|
#include <Nazara/Graphics/Graphics.hpp>
|
||||||
#include <Nazara/Math/Rect.hpp>
|
|
||||||
#include <NazaraImgui/Config.hpp>
|
#include <NazaraImgui/Config.hpp>
|
||||||
#include <NazaraImgui/ImguiDrawer.hpp>
|
#include <NazaraImgui/ImguiDrawer.hpp>
|
||||||
|
|
||||||
|
|
@ -19,11 +18,7 @@ namespace Nz
|
||||||
class Window;
|
class Window;
|
||||||
class WindowEventHandler;
|
class WindowEventHandler;
|
||||||
|
|
||||||
struct ImguiHandler
|
struct ImguiHandler;
|
||||||
{
|
|
||||||
public:
|
|
||||||
virtual void OnRenderImgui() = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
class NAZARA_IMGUI_API Imgui : public Nz::ModuleBase<Imgui>
|
class NAZARA_IMGUI_API Imgui : public Nz::ModuleBase<Imgui>
|
||||||
{
|
{
|
||||||
|
|
@ -91,23 +86,6 @@ namespace Nz
|
||||||
|
|
||||||
namespace ImGui
|
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()
|
inline void EnsureContextOnThisThread()
|
||||||
{
|
{
|
||||||
auto* context = Nz::Imgui::GetCurrentContext();
|
auto* context = Nz::Imgui::GetCurrentContext();
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,7 @@ namespace Nz
|
||||||
m_drawCalls.clear();
|
m_drawCalls.clear();
|
||||||
|
|
||||||
ImDrawData* drawData = ImGui::GetDrawData();
|
ImDrawData* drawData = ImGui::GetDrawData();
|
||||||
if (drawData->CmdListsCount == 0)
|
if (drawData == nullptr || drawData->CmdListsCount == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
|
@ -123,6 +123,8 @@ namespace Nz
|
||||||
m_drawCalls.push_back(std::move(drawCall));
|
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
|
// now that we have macro buffers, allocate them on gpu
|
||||||
size_t size = vertices.size() * sizeof(Nz::VertexStruct_XYZ_Color_UV);
|
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();
|
m_drawCalls.clear();
|
||||||
}
|
}
|
||||||
|
|
@ -223,7 +225,7 @@ namespace Nz
|
||||||
textureBinding.setIndex = 1;
|
textureBinding.setIndex = 1;
|
||||||
textureBinding.bindingIndex = 0;
|
textureBinding.bindingIndex = 0;
|
||||||
textureBinding.shaderStageFlags = nzsl::ShaderStageType::Fragment;
|
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));
|
std::shared_ptr<Nz::RenderPipelineLayout> renderPipelineLayout = m_renderDevice.InstantiateRenderPipelineLayout(std::move(pipelineLayoutInfo));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
namespace Nz
|
namespace Nz
|
||||||
{
|
{
|
||||||
ImguiPipelinePass::ImguiPipelinePass(PassData& passData, std::string passName, const ParameterList& /*parameters*/) :
|
ImguiPipelinePass::ImguiPipelinePass(PassData& /*passData*/, std::string passName, const ParameterList& /*parameters*/) :
|
||||||
FramePipelinePass({})
|
FramePipelinePass({})
|
||||||
, m_passName(std::move(passName))
|
, m_passName(std::move(passName))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
#include <NazaraImgui/NazaraImgui.hpp>
|
#include <NazaraImgui/NazaraImgui.hpp>
|
||||||
#include <NazaraImgui/ImguiPipelinePass.hpp>
|
#include <NazaraImgui/ImguiPipelinePass.hpp>
|
||||||
#include <NazaraImgui/ImguiDrawer.hpp>
|
#include <NazaraImgui/ImguiDrawer.hpp>
|
||||||
|
#include <NazaraImgui/ImguiHandler.hpp>
|
||||||
|
#include <NazaraImgui/ImguiWidgets.hpp>
|
||||||
|
|
||||||
#include <Nazara/Core/DynLib.hpp>
|
#include <Nazara/Core/DynLib.hpp>
|
||||||
#include <Nazara/Core/Log.hpp>
|
#include <Nazara/Core/Log.hpp>
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,8 @@ elseif is_mode("releasedbg") then
|
||||||
end
|
end
|
||||||
|
|
||||||
target("NazaraImgui")
|
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_kind("$(kind)")
|
||||||
set_group("Libraries")
|
set_group("Libraries")
|
||||||
add_headerfiles("include/(NazaraImgui/**.hpp)")
|
add_headerfiles("include/(NazaraImgui/**.hpp)")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue