diff --git a/Engine/Rendering/graphics_device.c b/Engine/Rendering/graphics_device.c index 14fc43f..9ffe3b9 100644 --- a/Engine/Rendering/graphics_device.c +++ b/Engine/Rendering/graphics_device.c @@ -65,6 +65,18 @@ int graphics_device_init(GraphicsDevice* d, void* hwnd, uint32_t w, uint32_t h, vp.Width = (float)w; vp.Height = (float)h; vp.MaxDepth = 1.0f; d->context->lpVtbl->RSSetViewports(d->context, 1, &vp); + + // 设置默认深度状态 (避免 UILayer init 破坏) + D3D11_DEPTH_STENCIL_DESC dsd = {0}; + dsd.DepthEnable = TRUE; + dsd.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ALL; + dsd.DepthFunc = D3D11_COMPARISON_LESS_EQUAL; + ID3D11DepthStencilState* default_dss = NULL; + d->device->lpVtbl->CreateDepthStencilState(d->device, &dsd, &default_dss); + if (default_dss) { + d->context->lpVtbl->OMSetDepthStencilState(d->context, default_dss, 0); + default_dss->lpVtbl->Release(default_dss); + } return 1; }