Skip to content

Commit 42803e7

Browse files
authored
Update ImGuiRenderer.cs (#484)
Resetting other rendering state to render 3D Models properly with the default behaviour
1 parent 2997357 commit 42803e7

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/ImGui.NET.SampleProgram.XNA/ImGuiRenderer.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,10 @@ private void RenderDrawData(ImDrawDataPtr drawData)
295295
// Setup render state: alpha-blending enabled, no face culling, no depth testing, scissor enabled, vertex/texcoord/color pointers
296296
var lastViewport = _graphicsDevice.Viewport;
297297
var lastScissorBox = _graphicsDevice.ScissorRectangle;
298+
var lastRasterizer = _graphicsDevice.RasterizerState;
299+
var lastDepthStencil = _graphicsDevice.DepthStencilState;
300+
var lastBlendFactor = _graphicsDevice.BlendFactor;
301+
var lastBlendState = _graphicsDevice.BlendState;
298302

299303
_graphicsDevice.BlendFactor = Color.White;
300304
_graphicsDevice.BlendState = BlendState.NonPremultiplied;
@@ -314,6 +318,10 @@ private void RenderDrawData(ImDrawDataPtr drawData)
314318
// Restore modified state
315319
_graphicsDevice.Viewport = lastViewport;
316320
_graphicsDevice.ScissorRectangle = lastScissorBox;
321+
_graphicsDevice.RasterizerState = lastRasterizer;
322+
_graphicsDevice.DepthStencilState = lastDepthStencil;
323+
_graphicsDevice.BlendState = lastBlendState;
324+
_graphicsDevice.BlendFactor = lastBlendFactor;
317325
}
318326

319327
private unsafe void UpdateBuffers(ImDrawDataPtr drawData)

0 commit comments

Comments
 (0)