2

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;
    }
}
xcrypt
  • 3,276
  • 5
  • 39
  • 63
  • I think it's partially described [here](http://msdn.microsoft.com/en-us/library/windows/desktop/bb205075\(v=vs.85\).aspx#Care_and_Feeding_of_the_Swap_Chain). It at least details how to respond to a WM_SIZE message. – user786653 Nov 09 '11 at 16:40
  • @user786653 doesn't really solve the problem – xcrypt Nov 09 '11 at 17:24

1 Answers1

2

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.

mattnewport
  • 13,728
  • 2
  • 35
  • 39
  • 1
    I'm still curious if there's a way around. Maybe the performance increase would be small, but it definitely would be there. I don't like to write abundant code, not matter how small the benefits are. – xcrypt Nov 14 '11 at 18:50