-
-
Notifications
You must be signed in to change notification settings - Fork 11.1k
Closed
Description
Version/Branch of Dear ImGui:
master
Back-ends:
Any
Compiler, OS:
Default
Full config/build information:
Default
Details:
Guys... how about implementing generic RAII
for basic backend aspects... for example:
namespace ImGui {
namespace RAII {
struct Frame {
Frame() {
NewFrame();
}
~Frame() {
Render();
}
};
namespace Backend {
template<void (*NewFrame)()>
struct Frame {
Frame() {
NewFrame();
}
};
template<void (*NewFrame)(), void (*RenderDrawData)(ImDrawData*)>
struct FrameWithRender : public Frame<NewFrame> {
~FrameWithRender() {
RenderDrawData(GetDrawData());
}
};
} // namespace Backend
} // namespace RAII
Then instantiating it... example:
namespace ImGui {
using OpenGL2Frame = Backend::FrameWithRender<
ImGui_ImplOpenGL2_NewFrame, ImGui_ImplOpenGL2_RenderDrawData>;
using Win32Frame = Backend::Frame<
ImGui_ImplWin32_NewFrame>;
}
Using it would be as easy. as:
int main() {
while (/* condition */) {
{
Win32Frame imw32Frame;
OpenGL2Frame imglFrame;
ImGui::Frame imFrame;
/*User Imgui Code Here*/
}
// Platform Present
}
}
Screenshots/Video:
No response
Minimal, Complete and Verifiable Example code:
No response
Metadata
Metadata
Assignees
Labels
No labels