【问题标题】:How to disable the depth buffer?如何禁用深度缓冲区?
【发布时间】:2023-04-10 20:38:01
【问题描述】:

我没有看到 RenderStateGraphicsDevice 类中的成员,这是用于禁用深度缓冲区的函数的位置。有人知道这个新的 4.0 API 是如何做到的吗?

如果我能以某种方式访问​​类似 RenderState 的完整课程,那就太好了。GraphicsDevice 似乎已经获得了一些,但不是几乎全部!

【问题讨论】:

    标签: c# windows-phone-7 xna xna-4.0 depth-buffer


    【解决方案1】:

    啊.. 我会将GraphicsDevice.DepthStencilState 设置为DepthStencilState 的实例,并设置任意数量的属性。似乎RenderState 被分成了许多其他状态。我之前在 GraphicsDevice 内部的各个属性中寻找,但现在它们似乎组织得更好,以便于状态管理。

    depthState = new DepthStencilState();
    depthState.DepthBufferEnable = true; /* Enable the depth buffer */
    depthState.DepthBufferWriteEnable = true; /* When drawing to the screen, write to the depth buffer */
    
    GraphicsDevice.DepthStencilState = depthState;
    

    【讨论】:

    • 是的。但请确保您创建一次状态对象(而不是在您的 draw 方法中)。阅读 Shawn 了解详情blogs.msdn.com/b/shawnhar/archive/2010/04/02/…
    • 另外请记住,有许多预构建的状态对象涵盖了许多常见场景。在这种情况下,您可以使用 DepthStencilState.None 禁用深度缓冲,并使用 DepthStencilState.Default 启用写入(如您在此处的示例)。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-04-12
    • 1970-01-01
    • 1970-01-01
    • 2016-09-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多