Jump to content

View more

Image of the Day

Adding some finishing touches...
Follow us for more
#screenshotsaturday #indiedev... by #MakeGoodGames https://t.co/Otbwywbm3a
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

Changing Rasterizer State

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
1 reply to this topic

#1 rtclawson   Members   

168
Like
0Likes
Like

Posted 22 January 2013 - 11:06 AM

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.



#2 Mike.Popoloski   Members   

3257
Like
0Likes
Like

Posted 22 January 2013 - 11:09 AM

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.


Mike Popoloski | Journal | SlimDX




Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.