@@ -26,7 +26,8 @@ static ID3D10Blob * g_pPixelShaderBlob = NULL;
26
26
static ID3D11PixelShader* g_pPixelShader = NULL ;
27
27
static ID3D11SamplerState* g_pFontSampler = NULL ;
28
28
static ID3D11ShaderResourceView*g_pFontTextureView = NULL ;
29
- static ID3D11BlendState* g_blendState = NULL ;
29
+ static ID3D11RasterizerState* g_pRasterizerState = NULL ;
30
+ static ID3D11BlendState* g_pBlendState = NULL ;
30
31
static int VERTEX_BUFFER_SIZE = 30000 ; // TODO: Make vertex buffer smaller and grow dynamically as needed.
31
32
32
33
struct VERTEX_CONSTANT_BUFFER
@@ -100,7 +101,8 @@ static void ImGui_ImplDX11_RenderDrawLists(ImDrawList** const cmd_lists, int cmd
100
101
101
102
// Setup render state
102
103
const float blendFactor[4 ] = { 0 .f , 0 .f , 0 .f , 0 .f };
103
- g_pd3dDeviceContext->OMSetBlendState (g_blendState, blendFactor, 0xffffffff );
104
+ g_pd3dDeviceContext->OMSetBlendState (g_pBlendState, blendFactor, 0xffffffff );
105
+ g_pd3dDeviceContext->RSSetState (g_pRasterizerState);
104
106
105
107
// Render command lists
106
108
int vtx_offset = 0 ;
@@ -339,19 +341,30 @@ bool ImGui_ImplDX11_CreateDeviceObjects()
339
341
desc.RenderTarget [0 ].DestBlendAlpha = D3D11_BLEND_ZERO;
340
342
desc.RenderTarget [0 ].BlendOpAlpha = D3D11_BLEND_OP_ADD;
341
343
desc.RenderTarget [0 ].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL;
342
- g_pd3dDevice->CreateBlendState (&desc, &g_blendState);
344
+ g_pd3dDevice->CreateBlendState (&desc, &g_pBlendState);
345
+ }
346
+
347
+ // Create the rasterizer state
348
+ {
349
+ D3D11_RASTERIZER_DESC desc;
350
+ ZeroMemory (&desc, sizeof (desc));
351
+ desc.FillMode = D3D11_FILL_SOLID;
352
+ desc.CullMode = D3D11_CULL_NONE;
353
+ desc.ScissorEnable = true ;
354
+ desc.DepthClipEnable = true ;
355
+ g_pd3dDevice->CreateRasterizerState (&desc, &g_pRasterizerState);
343
356
}
344
357
345
358
// Create the vertex buffer
346
359
{
347
- D3D11_BUFFER_DESC bufferDesc ;
348
- memset (&bufferDesc , 0 , sizeof (D3D11_BUFFER_DESC));
349
- bufferDesc .Usage = D3D11_USAGE_DYNAMIC;
350
- bufferDesc .ByteWidth = VERTEX_BUFFER_SIZE * sizeof (ImDrawVert);
351
- bufferDesc .BindFlags = D3D11_BIND_VERTEX_BUFFER;
352
- bufferDesc .CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
353
- bufferDesc .MiscFlags = 0 ;
354
- if (g_pd3dDevice->CreateBuffer (&bufferDesc , NULL , &g_pVB) < 0 )
360
+ D3D11_BUFFER_DESC desc ;
361
+ memset (&desc , 0 , sizeof (D3D11_BUFFER_DESC));
362
+ desc .Usage = D3D11_USAGE_DYNAMIC;
363
+ desc .ByteWidth = VERTEX_BUFFER_SIZE * sizeof (ImDrawVert);
364
+ desc .BindFlags = D3D11_BIND_VERTEX_BUFFER;
365
+ desc .CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
366
+ desc .MiscFlags = 0 ;
367
+ if (g_pd3dDevice->CreateBuffer (&desc , NULL , &g_pVB) < 0 )
355
368
return false ;
356
369
}
357
370
@@ -369,7 +382,8 @@ void ImGui_ImplDX11_InvalidateDeviceObjects()
369
382
if (g_pFontTextureView) { g_pFontTextureView->Release (); ImGui::GetIO ().Fonts ->TexID = 0 ; }
370
383
if (g_pVB) { g_pVB->Release (); g_pVB = NULL ; }
371
384
372
- if (g_blendState) { g_blendState->Release (); g_blendState = NULL ; }
385
+ if (g_pBlendState) { g_pBlendState->Release (); g_pBlendState = NULL ; }
386
+ if (g_pRasterizerState) { g_pRasterizerState->Release (); g_pRasterizerState = NULL ; }
373
387
if (g_pPixelShader) { g_pPixelShader->Release (); g_pPixelShader = NULL ; }
374
388
if (g_pPixelShaderBlob) { g_pPixelShaderBlob->Release (); g_pPixelShaderBlob = NULL ; }
375
389
if (g_pVertexConstantBuffer) { g_pVertexConstantBuffer->Release (); g_pVertexConstantBuffer = NULL ; }
0 commit comments