[.net] Problem rendering Mesh in Managed DirectX and C#

Started by
2 comments, last by GoodFun 19 years, 2 months ago
I've been toying around with C# and Managed DirectX for a bit and I've come across a problem that I'm not sure how to solve... when I setup a vertex buffer and index buffer and then render it using device.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, WIDTH * HEIGHT, 0, numberVerts * 6); it renders fine, if I put the vertex buffer and the index buffer in a mesh, then it looks like the index buffer is not being rendered as a TriangleList... basically all triangles connect to the first vertex... as if it was a TriangleFan... Does anyone know if there is a way to set the PrimitiveType for a Mesh? Thanks for your help and let me know if you need to see more code or screenshots of what is wrong.
Advertisement
I do not know how to change the primitive type used by mesh, but I build meshes all the time with triangle lists and they work fine. It could be a problem with the index data itself. Are you using a 16bit or 32bit index? If you are using a 32bit index you must specify the Use32Bit mesh flag on creation.
Sorry, the AP was me.
The index data itself is fine as it renders ok when I do DrawIndexedPrimities... I was able to get it to work with the mesh by increasing the heightfield from 256x256 to 257x257... though performance of the mesh is terrible compared to using a vertex and index buffer... and yes, when I use larger datasets I am using 32bit indexes...

I will have to look into dynamically splitting the landscape into smaller pieces... hopefully that will solve the performance issue...

Thanks for your reply

Marcel Isler
aka GoodFun
aka ShadowHawk

This topic is closed to new replies.

Advertisement