Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Don't forget to read Tuesday's email newsletter for your chance to win a free copy of Construct 2!


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: 2923

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