c++ - Depth Buffer in Direct3D isn't working -


i can't seem depth buffer working. i've been following rastertek tutorials, models rendered after other models appear closer me, though they're farther away.

this have far:

depth buffer:

zeromemory(&depthbufferdesc, sizeof(depthbufferdesc));  depthbufferdesc.width = screenwidth; depthbufferdesc.height= screenheight; depthbufferdesc.miplevels = 1; depthbufferdesc.arraysize = 1; depthbufferdesc.format = dxgi_format_d24_unorm_s8_uint; depthbufferdesc.sampledesc.count = 1; depthbufferdesc.sampledesc.quality = 0; depthbufferdesc.usage = d3d10_usage_default; depthbufferdesc.bindflags = d3d10_bind_depth_stencil; depthbufferdesc.cpuaccessflags = null; depthbufferdesc.miscflags = null;  result = m_device->createtexture2d(&depthbufferdesc, null, &m_depthstencilbuffer); if(failed(result)) {     throw "could not create 2d texture"; } 

depth stencil:

zeromemory(&depthstencildesc, sizeof(depthstencildesc));  depthstencildesc.depthenable = true; depthstencildesc.depthwritemask = d3d10_depth_write_mask_all; depthstencildesc.depthfunc = d3d10_comparison_less;  depthstencildesc.stencilenable = true; depthstencildesc.stencilreadmask = 0xff; depthstencildesc.stencilwritemask = 0xff;  depthstencildesc.frontface.stencilfailop = d3d10_stencil_op_keep; depthstencildesc.frontface.stencildepthfailop = d3d10_stencil_op_incr; depthstencildesc.frontface.stencilpassop = d3d10_stencil_op_keep; depthstencildesc.frontface.stencilfunc = d3d10_comparison_always;  depthstencildesc.backface.stencilfailop = d3d10_stencil_op_keep; depthstencildesc.backface.stencildepthfailop = d3d10_stencil_op_decr; depthstencildesc.backface.stencilpassop = d3d10_stencil_op_keep; depthstencildesc.backface.stencilfunc = d3d10_comparison_always;  result = m_device->createdepthstencilstate(&depthstencildesc, &m_depthstencilstate); if(failed(result)) {     throw "could not create depth stencil state"; }  m_device->omsetrendertargets(1, &m_rendertargetview, m_depthstencilview); 

depth stencil view:

zeromemory(&depthstencilviewdesc, sizeof(depthstencilviewdesc));  depthstencilviewdesc.format = dxgi_format_d24_unorm_s8_uint; depthstencilviewdesc.viewdimension = d3d10_dsv_dimension_texture2d; depthstencilviewdesc.texture2d.mipslice = 0;  result = m_device->createdepthstencilview(m_depthstencilbuffer, &depthstencilviewdesc, &m_depthstencilview); if(failed(result)) {     throw "could not create depth stencil view"; } 

raster:

rasterdesc.antialiasedlineenable = false; rasterdesc.cullmode = d3d10_cull_none; rasterdesc.depthbias = 0; rasterdesc.depthbiasclamp = 0.0f; rasterdesc.depthclipenable = true; rasterdesc.fillmode = d3d10_fill_solid; rasterdesc.frontcounterclockwise = false;rasterdesc.multisampleenable = false; rasterdesc.scissorenable = false; rasterdesc.slopescaleddepthbias = 0.0f;  result = m_device->createrasterizerstate(&rasterdesc, &m_rasterstate); if(failed(result)) {     throw "could not create rasterizer state"; }  m_device->rssetstate(m_rasterstate); 

any highly appreciated, in advance


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -