Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


We're also offering banner ads on our site from just $5! 1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


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

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