Jump to content
  • Advertisement
Sign in to follow this  

[SlimDX] Nothing is being rendered

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

If you intended to correct an error in the post then please contact us.

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 this post

Link to post
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 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
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!