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.


bool TestGameApp::InitGame()
    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;


    //...more code


switch( message )
    case WM_SIZE:

Go ahead and call it every frame. It's not inefficient; that's the way you're supposed to do it. Game engines often call it (and other SetState methods) many times per frame in order to switch render states for different parts of the frame.

| improve this answer | |
  • \$\begingroup\$ Since I don't need to change it every frame, it seems inefficient to me. If you need to change it every frame, I agree, but this is not the case. Is there no way around? \$\endgroup\$ – xcrypt Nov 10 '11 at 12:05
  • \$\begingroup\$ @xcrypt, it's such an insignificant cost it's seriously not worth worrying about! \$\endgroup\$ – Nathan Reed Nov 10 '11 at 17:39
  • \$\begingroup\$ It's more of an attitude :) Maybe the benefits are really small and not noticeable, but I still try to avoid writing abundant code. Your reply is great side-information, but unfortunately it's not an answer to my question. \$\endgroup\$ – xcrypt Nov 14 '11 at 18:53
  • \$\begingroup\$ @xcrypt: I think that Nathan DID give you the solution- it's designed to be called every frame. You WILL find lots of places to optimize, but you're wasting your time here. (If it's an attitude it's a poor one. :P codinghorror.com/blog/2005/01/the-real-cost-of-performance.html ) \$\endgroup\$ – KTF Dec 16 '11 at 16:25
  • \$\begingroup\$ @KTF your opinion is invalid. But more importantly, The question is not about design principles or standards. It's a pure technical question. I do not need lectures about why minimal performance gains may or may not be a good thing. This is how I like to code. And yes, I am aware of all the quotes / lectures in the world telling me not to do it, I know why people consider it a bad thing in an 'economically efficient environment'. That does not mean it's not a great exercise. \$\endgroup\$ – xcrypt Dec 16 '11 at 21:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.