-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
203 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
#if GODOT_PC | ||
using Godot; | ||
using System; | ||
|
||
namespace ImGuiGodot.Internal; | ||
|
||
internal interface IRenderer | ||
internal interface IRenderer : IDisposable | ||
{ | ||
public string Name { get; } | ||
public void InitViewport(Rid vprid); | ||
public void CloseViewport(Rid vprid); | ||
public void RenderDrawData(); | ||
public void Render(); | ||
public void OnHide(); | ||
public void Shutdown(); | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#include "CanvasRenderer.h" | ||
#include "common.h" | ||
#include <godot_cpp/classes/rendering_server.hpp> | ||
#include <unordered_map> | ||
#include <vector> | ||
|
||
using namespace godot; | ||
|
||
namespace ImGui::Godot { | ||
|
||
struct CanvasRenderer::Impl | ||
{ | ||
struct ViewportData | ||
{ | ||
RID canvas; | ||
RID rootCanvasItem; | ||
}; | ||
|
||
std::unordered_map<RID, std::vector<RID>> canvasItemPools; | ||
std::unordered_map<RID, ViewportData> vpData; | ||
}; | ||
|
||
CanvasRenderer::CanvasRenderer() | ||
{ | ||
} | ||
|
||
CanvasRenderer::~CanvasRenderer() | ||
{ | ||
} | ||
|
||
void CanvasRenderer::InitViewport(RID vprid) | ||
{ | ||
RenderingServer* RS = RenderingServer::get_singleton(); | ||
RID canvas = RS->canvas_create(); | ||
RID canvasItem = RS->canvas_item_create(); | ||
RS->viewport_attach_canvas(vprid, canvas); | ||
RS->canvas_item_set_parent(canvasItem, canvas); | ||
|
||
impl->vpData[vprid] = {canvas, canvasItem}; | ||
} | ||
|
||
void CanvasRenderer::CloseViewport(RID vprid) | ||
{ | ||
} | ||
|
||
void CanvasRenderer::Render() | ||
{ | ||
} | ||
|
||
void CanvasRenderer::OnHide() | ||
{ | ||
} | ||
|
||
} // namespace ImGui::Godot |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#pragma once | ||
#include "Renderer.h" | ||
#include <imgui.h> | ||
#include <memory> | ||
|
||
#pragma warning(push, 0) | ||
#include <godot_cpp/variant/rid.hpp> | ||
#pragma warning(pop) | ||
|
||
using godot::RID; | ||
|
||
namespace ImGui::Godot { | ||
|
||
class CanvasRenderer : public Renderer | ||
{ | ||
public: | ||
CanvasRenderer(); | ||
virtual ~CanvasRenderer(); | ||
|
||
virtual const char* Name() override | ||
{ | ||
return "godot4_canvas"; | ||
} | ||
|
||
void InitViewport(RID vprid) override; | ||
void CloseViewport(RID vprid) override; | ||
void Render() override; | ||
void OnHide() override; | ||
|
||
private: | ||
struct Impl; | ||
std::unique_ptr<Impl> impl; | ||
}; | ||
|
||
} // namespace ImGui::Godot |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.