Compare commits

..

No commits in common. "c0a51732d0a54d4a1ae9debe64baf0c8de876f89" and "41c6439b90a6b989a402c2c12e5d06b645086c85" have entirely different histories.

10 changed files with 36 additions and 65 deletions

3
.gitignore vendored
View File

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

View File

@ -7,8 +7,6 @@
#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()
@ -42,7 +40,10 @@ int main(int argc, char* argv[])
int WinMain(int argc, char* argv[])
#endif
{
Nz::Application<Nz::Graphics, Nz::Imgui> nazara(argc, argv);
NazaraUnused(argc);
NazaraUnused(argv);
Nz::Application<Nz::Graphics, Nz::Imgui> nazara;
auto& windowing = nazara.AddComponent<Nz::AppWindowingComponent>();
std::shared_ptr<Nz::RenderDevice> device = Nz::Graphics::Instance()->GetRenderDevice();

View File

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

View File

@ -1,15 +0,0 @@
#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

@ -1,30 +0,0 @@
#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,6 +2,7 @@
#include <Nazara/Core/ModuleBase.hpp>
#include <Nazara/Graphics/Graphics.hpp>
#include <Nazara/Math/Rect.hpp>
#include <NazaraImgui/Config.hpp>
#include <NazaraImgui/ImguiDrawer.hpp>
@ -18,7 +19,11 @@ namespace Nz
class Window;
class WindowEventHandler;
struct ImguiHandler;
struct ImguiHandler
{
public:
virtual void OnRenderImgui() = 0;
};
class NAZARA_IMGUI_API Imgui : public Nz::ModuleBase<Imgui>
{
@ -86,6 +91,23 @@ 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 == nullptr || drawData->CmdListsCount == 0)
if (drawData->CmdListsCount == 0)
return;
ImGuiIO& io = ImGui::GetIO();
@ -123,8 +123,6 @@ 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);
@ -193,7 +191,7 @@ namespace Nz
}
}
void ImguiDrawer::Reset(RenderResources& /*renderFrame*/)
void ImguiDrawer::Reset(RenderResources& renderFrame)
{
m_drawCalls.clear();
}
@ -225,7 +223,7 @@ namespace Nz
textureBinding.setIndex = 1;
textureBinding.bindingIndex = 0;
textureBinding.shaderStageFlags = nzsl::ShaderStageType::Fragment;
textureBinding.type = Nz::ShaderBindingType::Sampler;
textureBinding.type = Nz::ShaderBindingType::Texture;
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,8 +1,6 @@
#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,8 +51,7 @@ elseif is_mode("releasedbg") then
end
target("NazaraImgui")
add_packages("nazara", {public = true, components = "graphics"})
add_packages("nzsl", "imgui", {public = true})
add_packages("nazara", "nzsl", "imgui", {public = true})
set_kind("$(kind)")
set_group("Libraries")
add_headerfiles("include/(NazaraImgui/**.hpp)")