Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


Changing Rasterizer State


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   -  Reputation: 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.



Sponsor:

#2 Mike.Popoloski   Crossbones+   -  Reputation: 2931

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.



PARTNERS