Search code examples
c++directx-10

How can you force DirectX to restore your previous render state?


I have a program that draws text and draws a primitive triangle. Both functions work independently. However, when I call them in a row my triangle does not draw and I then receive this error:

D3D10: ERROR: ID3D10Device::Draw: Input Assembler - Vertex Shader linkage error: Signatures between stages are incompatible. The reason is that the input stage requires Semantic/Index (POSITION,0) as input, but it is not provided by the output stage. [ EXECUTION ERROR #342: DEVICE_SHADER_LINKAGE_SEMANTICNAME_NOT_FOUND ]

I've done some research and it looks like it's caused by ID3DXFont changing the state when it renders. Sc4Freak on this thread:

http://www.gamedev.net/topic/487280-dx10-render-question/

Recommends passing a D3DX10_SPRITE_SAVE_STATE, but I don't exactly understand the relationship between spirtes and direct text, or where I should be calling it. Can anyone explain why this happens?


Solution

  • I figured this out. The way you do this is by calling a:

    pSprite->begin(D3DX10_SPRITE_SAVE_STATE);
    //your text drawtext method stuff here
    pSprite->end();
    

    Note that you'll need to initialize the sprite object. You can do this with a D3DX10CreateSprite function, which is very similar to the createtext function.

    http://msdn.microsoft.com/en-us/library/bb172670(v=VS.85).aspx