Jump to content
  • Advertisement
Sign in to follow this  
rtclawson

Changing Rasterizer State

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

So far, this is the best way I can think of for modifying the current RasterizerStateDescription:

 

class Renderer

...

public bool Wireframe

{

set

{

RasterizerStateDescription curr = _device.ImmediateContext.Rasterizer.State.Description;

RasterizerStateDescription description = new RasterizerStateDescription

{

CullMode = curr.CullMode,

DepthBias = curr.DepthBias,

DepthBiasClamp = curr.DepthBiasClamp,

FillMode = (value ? FillMode.Wireframe : FillMode.Solid),

IsAntialiasedLineEnabled = curr.IsAntialiasedLineEnabled,

IsDepthClipEnabled = curr.IsDepthClipEnabled,

IsFrontCounterclockwise = curr.IsFrontCounterclockwise,

IsMultisampleEnabled = curr.IsMultisampleEnabled,

IsScissorEnabled = curr.IsScissorEnabled,

SlopeScaledDepthBias = curr.SlopeScaledDepthBias,

};

RasterizerState rs = RasterizerState.FromDescription(_device, description);

_device.ImmediateContext.Rasterizer.State = rs;

}

}

 

This seems necessary because the ImmediateContext's Rasterizer.State.Description is read only. Is there a simpler method for modifying one part of the state at a time, or do I have the right idea?

 

Alternatively, should I keep track of state in my code, and then just set the RasterizerStateDescription once?

 

Thanks.

Share this post


Link to post
Share on other sites
Advertisement

You should definitely set the entire rasterizer state as a block. That's why Direct3D 11 has its render states grouped; there's a performance overheard to changing states, so grouping them lets you pay that cost just once while setting a whole bunch of states.

 

Certainly if you need wireframe rendering you should create a rasterizer state that represents that combination of states. However, you should store it somewhere, and try to render all of your wireframe meshes at once each frame.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!