Jump to content
  • Advertisement
Sign in to follow this  

[DirectX 10 / SlimDX] Basic mesh won't show up

This topic is 2826 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


I'm quite new to SlimDX and DirectX 10 and I stumbled upon a problem. Up to now I used Vertex Buffers to store and render things (a single triangle actually).
Out of interest I wanted to switch to the DirectX 10 meshes which seem to me as a nice wrapper for all the stuff I have to do manually with VBs.
However, after I read some samples and tutorials and made the necessary changes to the code, my triangle won't show up any longer. I went back to reading things but can't figure out what's missing from my code.

I compiled a sample application doing only the most basic things. The code is as follows:

        public Form1()

SlimDX.DXGI.Factory factory = new SlimDX.DXGI.Factory();
device = new SlimDX.Direct3D10.Device(factory.GetAdapter(0), SlimDX.Direct3D10.DriverType.Hardware, DeviceCreationFlags.None);

swapChain = new SlimDX.DXGI.SwapChain(factory, device, new SlimDX.DXGI.SwapChainDescription
BufferCount = 1,
Flags = SlimDX.DXGI.SwapChainFlags.None,
IsWindowed = true,
ModeDescription = new SlimDX.DXGI.ModeDescription(this.Width, this.Height, new Rational(60, 1), SlimDX.DXGI.Format.R8G8B8A8_UNorm),
OutputHandle = this.Handle,
SampleDescription = new SlimDX.DXGI.SampleDescription(1, 0),
SwapEffect = SlimDX.DXGI.SwapEffect.Sequential,
Usage = SlimDX.DXGI.Usage.RenderTargetOutput

Texture2D texture = Texture2D.FromSwapChain<Texture2D>(swapChain, 0);
renderTargetView = new RenderTargetView( device, texture );

effect = Effect.FromFile(device, "basic.fx", "fx_4_0", ShaderFlags.None, EffectFlags.None, null, null);
ShaderSignature signature = effect.GetTechniqueByIndex(0).GetPassByIndex(0).Description.Signature;
inputLayout = new InputLayout(device, signature, new[] {
new InputElement("POSITION", 0, SlimDX.DXGI.Format.R32G32B32A32_Float, 0, 0),
new InputElement("COLOR", 0, SlimDX.DXGI.Format.R32G32B32A32_Float, 16, 0)

testMesh = new Mesh(device, new[] {
new InputElement("POSITION", 0, SlimDX.DXGI.Format.R32G32B32A32_Float, 0, 0),
new InputElement("COLOR", 0, SlimDX.DXGI.Format.R32G32B32A32_Float, 16, 0)
}, "POSITION", 3, 1, MeshFlags.Has32BitIndices);

DataStream meshstream = new DataStream(3 * 32, true, true);
meshstream.WriteRange(new[] {
new Vector4(0.0f, 0.5f, 1f, 1.0f), new Vector4(0.0f, 0.0f, 0.0f, 1.0f),
new Vector4(0.5f, -0.5f, 1f, 1.0f), new Vector4(0.0f, 0.0f, 0.0f, 1.0f),
new Vector4(-0.5f, -0.5f, 1f, 1.0f), new Vector4(0.0f, 0.0f, 0.0f, 1.0f)

DataStream meshIstream = new DataStream(12, true, true);
meshIstream.WriteRange(new uint[] { 0, 1, 2 });

testMesh.SetVertexData(0, meshstream);
testMesh.SetIndexData(meshIstream, 3);


device.Rasterizer.SetViewports(new Viewport(0, 0, this.Width, this.Height, 0.0f, 10.0f));


And the rendering function:

        public void render()
device.ClearRenderTargetView(renderTargetView, new Color4(0.3f, 0.3f, 0.3f));


swapChain.Present(0, SlimDX.DXGI.PresentFlags.None);

When I exchange the mesh with a vertex buffer while leaving everything else as is, the triangle is shown.

Anyone can give me a hint as to what might be missing to show the triangle as a mesh as well?

Thanks in advance and greetings :)

[Edited by - cc_zero on October 22, 2010 8:16:51 AM]

Share this post

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