سؤال

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?

هل كانت مفيدة؟

المحلول

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.

نصائح أخرى

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

device.SetRenderState<FillMode>(RenderState.FillMode, FillMode.Wireframe);
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top