Skip to content

Commit

Permalink
Update ImGuiRenderer.cs (#484)
Browse files Browse the repository at this point in the history
Resetting other rendering state to render 3D Models properly with the default behaviour
  • Loading branch information
soroushJuly authored Jul 8, 2024
1 parent 2997357 commit 42803e7
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/ImGui.NET.SampleProgram.XNA/ImGuiRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,10 @@ private void RenderDrawData(ImDrawDataPtr drawData)
// Setup render state: alpha-blending enabled, no face culling, no depth testing, scissor enabled, vertex/texcoord/color pointers
var lastViewport = _graphicsDevice.Viewport;
var lastScissorBox = _graphicsDevice.ScissorRectangle;
var lastRasterizer = _graphicsDevice.RasterizerState;
var lastDepthStencil = _graphicsDevice.DepthStencilState;
var lastBlendFactor = _graphicsDevice.BlendFactor;
var lastBlendState = _graphicsDevice.BlendState;

_graphicsDevice.BlendFactor = Color.White;
_graphicsDevice.BlendState = BlendState.NonPremultiplied;
Expand All @@ -314,6 +318,10 @@ private void RenderDrawData(ImDrawDataPtr drawData)
// Restore modified state
_graphicsDevice.Viewport = lastViewport;
_graphicsDevice.ScissorRectangle = lastScissorBox;
_graphicsDevice.RasterizerState = lastRasterizer;
_graphicsDevice.DepthStencilState = lastDepthStencil;
_graphicsDevice.BlendState = lastBlendState;
_graphicsDevice.BlendFactor = lastBlendFactor;
}

private unsafe void UpdateBuffers(ImDrawDataPtr drawData)
Expand Down

0 comments on commit 42803e7

Please sign in to comment.