Hi.
I have problem with rendering multiple objects in DirectX. From logic engine I'm getting vertices, indices and also some constant data per object. All data from logic engine is valid so this is not the problem.
To draw this objects I'm using this scenario:
- RSSetViewports() to set viewport
- Set OMSetRenderTargets() to proper target view
- Clearing render target view
- Clearing stencil and depth buffer. (with D3D11_CLEAR_DEPTH | D3D11_CLEAR_STENCIL)
- Drawing an actual object (methods from dx in order) - i'm repeating this point for every single object that I have
- IASetIndexBuffer()
- VSSetConstantBuffers()
- VSSetShader() - for each object can be used other vertex shader
- PSSetShader() - for each object can be used other pixel shader
- IASetVertexBuffers() - stride is set to size of used data in vertex shader
- IASetPrimitiveTopology() - it can change for every object
- IASetInputLayout() - respectively to used vertex shader
- Mapping data to indices buffer (using Map() with WRITE_DISCARD)
- Mapping constant data to constant buffer (also Map() with WRITE_DISCARD)
- Mapping data to verticles buffer (also Map() with WRITE_DISCARD)
- DrawIndexed() to draw
First rendering works just fine - all objects are visible on display. But when I need to update objects something is not ok - on display there are no objects at all or I see only some parts of objects (in general only those in top left corner).
I have one instance of ID3D11Buffer for vertices, one for constant, and one for indices. All buffers are set with DYNAMIC flag. Objects are drawn to Texture2d buffer and after rendering this texture is displayed on the screen. I don't have access to SwapChain because I'm using combined project (UI is in C# and dx engine in is c++). From the system I'm receiving 3 different render target view so that's the reason why I'm using Texture2D buffer. There is no need to render objects every single time so I'm just drawing Texture2D when I get new render target view. Of course when I'm drawing "on" texture I use my own render target view which is connected to texture2d. When I receive target view from the system I'm drawing texture on it.
Do You have any ideas why after first drawing objects are not drawing (or displaying) properly?
I've spent a lot of time to overcome this problem but with no luck.
I really need help. I appreciate any suggestions.
Please forgive me any grammar/spelling mistakes.
Thanks,
Artur