Jump to content

  • Log In with Google      Sign In   
  • Create Account

[SlimDX] Nothing is being rendered


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 hannesnisula   Members   -  Reputation: 1025

Like
0Likes
Like

Posted 08 July 2011 - 02:46 PM

The device is initialized and the clear and present functions work and I also call Begin and End before and after the the renderTriangle function. I suspect I've missed something obvious but I can't come up with what that would be. I've initialized the vertexbuffer and filled it with the data for a single triangle, set the FVF, matrices (I've tried both having the camera at 0,0,-10 and 0,0,10 because I got tired and didn't bother thinking about from which way I should see the triangle because of culling) and I render it but nothing shows on screen.
public void initializeTriangle()
		{
			testVertices = new float[9];
			vb = new VertexBuffer(device, sizeof(float) * 9, Usage.WriteOnly, VertexFormat.Position, Pool.Managed);

			testVertices[0] = 1.0f;
			testVertices[1] = testVertices[2] = 0.0f;
			testVertices[3] = -1.0f;
			testVertices[4] = testVertices[5] = 0.0f;
			testVertices[6] = testVertices[8] = 0.0f;
			testVertices[7] = 1.0f;

			Matrix view = Matrix.LookAtLH(new Vector3(0.0f, 0.0f, 10.0f), new Vector3(0.0f, 0.0f, 0.0f), new Vector3(0.0f, 1.0f, 0.0f));
			Matrix projection = Matrix.PerspectiveFovLH(2.0f, 1.0f, 1.0f, 100.0f);
			Matrix world = Matrix.Identity;

			device.SetTransform(TransformState.Projection, projection);
			device.SetTransform(TransformState.View, view);
			device.SetTransform(TransformState.World, world);

			device.VertexFormat = VertexFormat.Position;

			DataStream stream = vb.Lock(0, 0, LockFlags.Discard);
			for(int i = 0; i < 9; ++i)
				stream.Write(BitConverter.GetBytes(testVertices[i]), 0, sizeof(float));
			vb.Unlock();		}

public void renderTriangle()
		{
			Result res = device.SetStreamSource(0, vb, 0, sizeof(float) * 3);
			res  = device.DrawPrimitives(PrimitiveType.TriangleList, 0, 1);
		}


Sponsor:

#2 James Leighe   Members   -  Reputation: 222

Like
0Likes
Like

Posted 09 July 2011 - 05:34 PM

If you installed the DirectX SDK (which I'm assuming you did), use PIX to debug your application.

You will be able to find the bug easily once you get a little used to PIX.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS