2

I am trying to render a wireframe 3D Model using SlimDX.

After googling I only found advanced topics, not how to draw wireframe in SlimDX. They say I have to use a shader to do it.

Since I am new to DirectX, I do not really understand HLSL.

How can I draw it? If it really requires to use a shader, can anyone give me an example or hints?

pb2q
  • 58,613
  • 19
  • 146
  • 147
user1418759
  • 59
  • 1
  • 2
  • 8
  • 1
    Look up "Rasterizer State" as keywords - it allows you to select your fillmode (solid, wireframe, point) and can be set either from the shader or from code. You should have better luck now :) – Thomas Sep 23 '12 at 12:30

2 Answers2

3

Since you use Direct3D 11, you will need to use shaders to draw anything (fixed function got removed from directx10).

For wireframe you indeed need to set rasterizer state, here is an example (i also removed culling in there:

RasterizerStateDescription rsd = new RasterizerStateDescription()
{
    CullMode = CullMode.None,
    DepthBias = 0,
    DepthBiasClamp = 0.0f,
    FillMode = FillMode.Wireframe,
    IsAntialiasedLineEnabled = false,
    IsDepthClipEnabled = false,
    IsFrontCounterclockwise = false,
    IsMultisampleEnabled = false,
    IsScissorEnabled = false,
    SlopeScaledDepthBias = 0.0f             
};

Then to apply this state,

RasterizerState rs = RasterizerState.FromDescription(device, rsd);
device.ImmediateContext.Rasterizer.State = rs;

After I admit there's not that many tutorials for SlimDX, for c++ there is

http://www.rastertek.com/tutdx11.html

You'll at least be able to find some basic shader examples in there.

mrvux
  • 8,523
  • 1
  • 27
  • 61
0

Here is what I have found and it works for me:

device.SetRenderState<FillMode>(RenderState.FillMode, FillMode.Wireframe);
zionpi
  • 2,593
  • 27
  • 38