ID3D10Device::RSSetState 每帧都被调用?
我正在尝试使用 direct3D10 创建 ID3D10RasterizerState,然后
ID3D10Device::RSSetState()
使用正确的信息进行调用。但是,每当窗口重新缩放时,或者当应用程序进入全屏时,光栅化器状态似乎会重置为默认状态。 我尝试使用 WM_SIZE 消息设置状态,但尴尬的是,似乎没有发生任何事情......
当我每帧调用 RSSetState() 时它都能正常工作,但这似乎效率很低。
有谁知道这个问题的解决方案吗? msdn 上似乎没有很好的记录。
代码:
bool TestGameApp::InitGame()
{
D3D10_RASTERIZER_DESC desc;
desc.AntialiasedLineEnable = TRUE;
desc.CullMode = D3D10_CULL_NONE;
desc.DepthBias = 0;
desc.DepthBiasClamp = 0.0f;
desc.FillMode = D3D10_FILL_SOLID;
desc.FrontCounterClockwise = false;
desc.MultisampleEnable = true;
desc.ScissorEnable = FALSE;
desc.SlopeScaledDepthBias = 0.0f;
m_pD3DDevice->CreateRasterizerState(&desc,m_pRSState);
m_pD3DDevice->RSSetState(m_pRSState);
//...more code
}
WndProc:
switch( message )
{
case WM_SIZE:
{
m_pD3DDevice->RSSetState(m_pRSState);
break;
}
}
I am trying to create a ID3D10RasterizerState with direct3D10, and then call
ID3D10Device::RSSetState()
with the proper information. However, whenever the window get rescaled, or when the app goes fullscreen, the rasterizerstate seems to reset to the default state.
I have tried to set the state with WM_SIZE messages, but awkwardly, nothing seems to happen...
It works properly when I call RSSetState() every frame, but that seems highly inefficient.
Does anyone know a solution to this?
It seems to be poorly documented on msdn.
Code:
bool TestGameApp::InitGame()
{
D3D10_RASTERIZER_DESC desc;
desc.AntialiasedLineEnable = TRUE;
desc.CullMode = D3D10_CULL_NONE;
desc.DepthBias = 0;
desc.DepthBiasClamp = 0.0f;
desc.FillMode = D3D10_FILL_SOLID;
desc.FrontCounterClockwise = false;
desc.MultisampleEnable = true;
desc.ScissorEnable = FALSE;
desc.SlopeScaledDepthBias = 0.0f;
m_pD3DDevice->CreateRasterizerState(&desc,m_pRSState);
m_pD3DDevice->RSSetState(m_pRSState);
//...more code
}
WndProc:
switch( message )
{
case WM_SIZE:
{
m_pD3DDevice->RSSetState(m_pRSState);
break;
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
每一帧都设置一下就可以了。一般来说,您希望最大程度地减少帧中渲染状态更改的数量,但无需担心每帧设置一次光栅化器状态对性能的影响。每帧设置它还可以让您执行诸如启用和禁用线框渲染以进行调试之类的操作。
Just set it every frame. In general you want to minimize the number of render state changes in a frame but you don't need to worry about the performance impact of setting the rasterizer state once a frame. Setting it every frame also lets you do things like enable and disable wireframe rendering for debugging.