• Advertisement


  • Content count

  • Joined

  • Last visited

Community Reputation

122 Neutral

About joergz

  • Rank
  1. That was the error, thank you!! Edit: damn you're right. Edited once again :-)
  2. I got stuck to draw a triangle using an index and DrawIndexed(), the triangle is not drawn. The windows just renders the blue background. While looking at other tutorials I think I did everything necessary to use an index, but maybe I am missing something?! Edit: Solved (thx Unbird), the array data type did not match the format in SetIndexBuffer, changing it back to int to match the format did the trick. I updated the code below for the next one using indices for SharpDX 1) Index array and buffer at the class variables // Vertices private VertexPositionColor[] vertices = new VertexPositionColor[] { new VertexPositionColor(new Vector3(-0.5f, 0.5f, 0.0f), SharpDX.Color.Red), new VertexPositionColor(new Vector3(0.5f, 0.5f, 0.0f), SharpDX.Color.Green), new VertexPositionColor(new Vector3(-0.5f, -0.5f, 0.0f), SharpDX.Color.Blue), }; // Indices private uint[] indices = new uint[] { 0, 1, 2 }; // Vertice-Buffer / Index-Buffer private D3D11.Buffer vertexBuffer; private D3D11.Buffer indexBuffer; 2) Set the indexbuffer private void InitializeTriangle() { vertexBuffer = D3D11.Buffer.Create(d3dDevice, D3D11.BindFlags.VertexBuffer, vertices); indexBuffer = D3D11.Buffer.Create(d3dDevice, D3D11.BindFlags.IndexBuffer, indices); } 3) Draw-Method: /// <summary> /// Draw the scene. /// </summary> private void Draw() { //Re-Initialize triangle InitializeTriangle(); // Set back buffer as current render target view d3dDeviceContext.OutputMerger.SetRenderTargets(renderTargetView); // Clear the screen d3dDeviceContext.ClearRenderTargetView(renderTargetView, new SharpDX.Color(32, 103, 178)); // Draw the triangle on the screen d3dDeviceContext.InputAssembler.PrimitiveTopology = PrimitiveTopology.TriangleList; d3dDeviceContext.InputAssembler.SetVertexBuffers(0, new D3D11.VertexBufferBinding(vertexBuffer, Utilities.SizeOf<VertexPositionColor>(), 0)); d3dDeviceContext.InputAssembler.SetIndexBuffer(indexBuffer, Format.R32_UInt, 0); d3dDeviceContext.DrawIndexed(3, 0, 0); // Swap front and back buffer swapChain.Present(1, PresentFlags.None); } . SharpDX_Tutorial_5_(using_an_index).zip
  3. Asteroids

    Very interesting article, thank you for the description! And: It looks frightning real! The motion blur of the cam adds a lot to the asteroids i think. Cant wait to have a little look at it in motion. Well done!
  • Advertisement