# [SlimDX] Nothing is being rendered

This topic is 2598 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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), 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); }

##### Share on other sites
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.

##### Share on other sites
Hidden
I used PIX to see the information, and the pictures of the triangle I try to render and it looks just as I expected and right in the viewport etc. I see this in the Pre-VS, Post-VS and Viewport images in PIX but what I don't understand is how nothing still isn't showed on the screen/buffer. I thought the color of the triangle is the same as the backbuffer clear color, but I changed the material in SlimDX and set ambient to white and backbuffer clear color to black (and also tried a lot other colors) but no luck. I also took a look at the depthbuffer but nothing is there.

This is confusing to me. I'm all lost right now, any help would be GREATLY appreciated, thanks!

1. 1
2. 2
3. 3
4. 4
5. 5
frob
11

• 16
• 13
• 20
• 12
• 19
• ### Forum Statistics

• Total Topics
632172
• Total Posts
3004569

×