Skip to content

Commit

Permalink
detect OpenGL compatibility mode
Browse files Browse the repository at this point in the history
  • Loading branch information
pkdawson committed Jan 10, 2023
1 parent 33687e0 commit 06b34e5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
6 changes: 6 additions & 0 deletions addons/imgui-godot/ImGuiGodot/ImGuiGD.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ public static void Init(float? scale = null, RendererType renderer = RendererTyp
_scale = scale.Value;
}

// fall back to Canvas in OpenGL compatibility mode
if (renderer == RendererType.RenderingDevice && RenderingServer.GetRenderingDevice() == null)
{
renderer = RendererType.Canvas;
}

Internal.State.Init(renderer switch
{
RendererType.Dummy => new Internal.DummyRenderer(),
Expand Down
4 changes: 4 additions & 0 deletions addons/imgui-godot/ImGuiGodot/Internal/RdRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ internal class RdRenderer : IRenderer
public RdRenderer()
{
RD = RenderingServer.GetRenderingDevice();
if (RD is null)
{
throw new PlatformNotSupportedException("failed to get RenderingDevice");
}

// set up everything to match the official Vulkan backend as closely as possible

Expand Down

0 comments on commit 06b34e5

Please sign in to comment.