Sign in to follow this  

[SlimDX] Nothing is being rendered

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.
[code]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);

Share this post

Link to post
Share on other sites
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!

Share this post

Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this