Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImGui: Add callNewFrame parameter to constructor #467

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
25 changes: 25 additions & 0 deletions src/Veldrid.ImGui/ImGuiRenderer.cs
Expand Up @@ -64,6 +64,18 @@ public ImGuiRenderer(GraphicsDevice gd, OutputDescription outputDescription, int
/// <param name="height">The initial height of the rendering target. Can be resized.</param>
/// <param name="colorSpaceHandling">Identifies how the renderer should treat vertex colors.</param>
public ImGuiRenderer(GraphicsDevice gd, OutputDescription outputDescription, int width, int height, ColorSpaceHandling colorSpaceHandling)
: this(gd, outputDescription, width, height, ColorSpaceHandling.Legacy, callNewFrame: true) { }

/// <summary>
/// Constructs a new ImGuiRenderer.
/// </summary>
/// <param name="gd">The GraphicsDevice used to create and update resources.</param>
/// <param name="outputDescription">The output format.</param>
/// <param name="width">The initial width of the rendering target. Can be resized.</param>
/// <param name="height">The initial height of the rendering target. Can be resized.</param>
/// <param name="colorSpaceHandling">Identifies how the renderer should treat vertex colors.</param>
/// <param name="callNewFrame">Whether a new frame should be started. If false you have to call ManualNewFrame() yourself.</param>
public ImGuiRenderer(GraphicsDevice gd, OutputDescription outputDescription, int width, int height, ColorSpaceHandling colorSpaceHandling, bool callNewFrame)
{
_gd = gd;
_assembly = typeof(ImGuiRenderer).GetTypeInfo().Assembly;
Expand All @@ -81,6 +93,19 @@ public ImGuiRenderer(GraphicsDevice gd, OutputDescription outputDescription, int

SetPerFrameImGuiData(1f / 60f);

if (callNewFrame)
{
ManualNewFrame();
}
}

public void ManualNewFrame()
{
if (_frameBegun)
{
ImGui.EndFrame();
}

ImGui.NewFrame();
_frameBegun = true;
}
Expand Down