disablez缓冲无法使用directxtk
disable z buffering is not working using directxtk
我试图禁用和启用z缓冲区,但skydome仍然向zbuffer写入。我使用DirectXTK是为了这个目的,但它似乎可能不起作用。
CommonStates states(m_Graphics.getDevice());
m_Graphics.getContext()->RSSetState(states.CullNone());
XMMATRIX sphereWorld;
XMMATRIX sphereScale = XMMatrixScaling(200.0f, 200.0f, 200.0f);
XMMATRIX Translation = XMMatrixTranslation(m_Camera.Position().x,
m_Camera.Position().y, m_Camera.Position().z);
sphereWorld = sphereScale*Translation;
m_Graphics.getContext()->OMSetDepthStencilState(states.DepthNone(), 1);
m_shape->Draw(sphereWorld,m_Camera.ViewMatrix(), m_Camera.ProjectionMatrix(), Colors::White, m_texture.Get());
m_Graphics.getContext()->OMSetDepthStencilState(states.DepthDefault(),1);
XMMATRIX cameraInverse = XMMatrixInverse(nullptr, m_Graphics.getViewMatrix());
XMMATRIX translate = XMMatrixTranslation( 2.0f, -3.0f, 2.0f);
XMMATRIX rotation = XMMatrixRotationRollPitchYaw((float)XM_PI/9.0f, (float)XM_PI/0.2f, (float)XM_PI/0.1f);
XMMATRIX world = rotation *translate *cameraInverse;
m_Tiny->Draw(m_Graphics.getContext(), states, world, m_Graphics.getViewMatrix(), m_Graphics.getProjectionMatrix());
m_Graphics.getContext()->RSSetState(states.CullCounterClockwise());
m_Graphics.getContext()->RSSetState(states.Wireframe());
m_Grid.DrawGrid();
GeometricPrimitive
和Model
都在内部设置所需的渲染状态,包括作为其API一部分的深度/模具状态。
对于GeometricPrimitive,可以使用setCustomState
回调来覆盖默认状态设置。例如,这里有一个使用lambda:的例子
m_shape->Draw(sphereWorld,m_Camera.ViewMatrix(), m_Camera.ProjectionMatrix(),
Colors::White, m_texture.Get(), false, [=]
{
m_Graphics.getContext()->RSSetState(states.CullNone());
m_Graphics.getContext()->OMSetDepthStencilState(states.DepthNone(), 1);
});
对于"模型",可以在Draw
方法上使用相同的setCustomState
回调进行快速调整,也可以仅实现"高级绘图"模式。请参阅wiki
相关文章:
- 如何使用原子指针执行双缓冲
- 消费者和生产者问题的双重缓冲
- 如何检测是否在缓冲绘画动画中绘制最后一帧?
- 我似乎无法修改帧缓冲
- 如何在C++中写入 1000 个文件时有效地缓冲
- 帧缓冲纹理变为白色(片段着色器不会影响它)
- 我是否使用双缓冲?
- OpenGL:使用实例化绘图与我正在绘制的帧缓冲进行绘制
- 如何强制文件描述符缓冲我的输出
- Qt双缓冲行为
- 如何在没有缓冲的情况下使用 parquet-cpp 写入面向流/行的数据?
- MySQL 事务和缓冲的请求列表
- 使用 std::stringbuf 进行缓冲的效果,同时通过插入运算符'<<'执行写入
- Qt 帧缓冲对象甚至不渲染顶点
- MySQL连接器C 结果集被缓冲
- w/ w/结构带char缓冲液的静态初始化[]
- 在 Linux 中禁用 USB 大容量存储设备的读取缓冲
- 是否有一种缓冲方法进行同步
- 双缓冲的waveoutwrite()像地狱一样口吃
- disablez缓冲无法使用directxtk