c++ - Direct3D 11 depth buffer result in black screen -
i tried implement depth buffer in direct3d 11, turns out not easy fought. here's problem : whenever i'm calling function :
m_devicecontext->omsetrendertargets(1, &m_rtv, m_depthstencilview);
with 3rd parameter depth stencil view, see nothing in window ; black. if put nullptr geometries rendered without depth testing (like before atempt implement depth). here's how i'm creating depth buffer , depth stencil view :
d3d11_texture2d_desc depthbufferdesc; zeromemory(&depthbufferdesc, sizeof(d3d11_texture2d_desc)); depthbufferdesc.width = iwidth; depthbufferdesc.height = iheight; depthbufferdesc.miplevels = 1; depthbufferdesc.arraysize = 1; depthbufferdesc.format = dxgi_format_d24_unorm_s8_uint; depthbufferdesc.sampledesc.count = 1; depthbufferdesc.sampledesc.quality = 0; depthbufferdesc.usage = d3d11_usage_default; depthbufferdesc.bindflags = d3d11_bind_depth_stencil; hr = m_device->createtexture2d(&depthbufferdesc, nullptr, &m_depthstencilbuffer); hr = m_device->createdepthstencilview(m_depthstencilbuffer, nullptr, &m_depthstencilview);
i search quite time find solution didn't me. checked viewport doesn't work. clean view every frame.
can me out please ? i'll appreciate :) thanks.
you forgot clear depth buffer 1.0 before trying use it.
Comments
Post a Comment