public BaseGizmo(GraphicsDevice device, Effect effect) { _effect = effect; _device = device; // Create the gizmo geometry _rotationHelperGeometry = Buffer.Vertex.New <SolidVertex>(device, _rotationTrianglesCount * 3 + 2); _cylinder = GeometricPrimitive.Cylinder.New(_device, 1.0f, 1.0f, _lineRadiusTesselation); _cube = GeometricPrimitive.Cube.New(_device, 1.0f); _cone = GeometricPrimitive.Cone.New(_device, 1.0f, 1.3f, 16); // Create the rasterizer state for wireframe drawing var renderStateDesc = new SharpDX.Direct3D11.RasterizerStateDescription { CullMode = SharpDX.Direct3D11.CullMode.None, DepthBias = 0, DepthBiasClamp = 0, FillMode = SharpDX.Direct3D11.FillMode.Wireframe, IsAntialiasedLineEnabled = true, IsDepthClipEnabled = true, IsFrontCounterClockwise = false, IsMultisampleEnabled = true, IsScissorEnabled = false, SlopeScaledDepthBias = 0 }; _rasterizerWireframe = RasterizerState.New(_device, renderStateDesc); }
public override void InitializeRendering(RenderingDevice device, bool antialias = false) { base.InitializeRendering(device, antialias); _textureAllocator = device.CreateTextureAllocator(new RenderingTextureAllocator.Description { Size = new VectorInt3(1024, 1024, 1) }); // Legacy rendering state { // Reset scrollbar _legacyDevice = DeviceManager.DefaultDeviceManager.___LegacyDevice; _wadRenderer = new WadRenderer(DeviceManager.DefaultDeviceManager.___LegacyDevice, true); ResetCamera(); // Initialize the rasterizer state for wireframe drawing SharpDX.Direct3D11.RasterizerStateDescription renderStateDesc = new SharpDX.Direct3D11.RasterizerStateDescription { CullMode = SharpDX.Direct3D11.CullMode.None, DepthBias = 0, DepthBiasClamp = 0, FillMode = SharpDX.Direct3D11.FillMode.Wireframe, IsAntialiasedLineEnabled = true, IsDepthClipEnabled = true, IsFrontCounterClockwise = false, IsMultisampleEnabled = true, IsScissorEnabled = false, SlopeScaledDepthBias = 0 }; } }
internal void PlatformApplyState(GraphicsDevice device) { if (_state == null) { // We're now bound to a device... no one should // be changing the state of this object now! GraphicsDevice = device; // Build the description. var desc = new SharpDX.Direct3D11.RasterizerStateDescription(); switch ( CullMode ) { case Graphics.CullMode.CullClockwiseFace: desc.CullMode = SharpDX.Direct3D11.CullMode.Front; break; case Graphics.CullMode.CullCounterClockwiseFace: desc.CullMode = SharpDX.Direct3D11.CullMode.Back; break; case Graphics.CullMode.None: desc.CullMode = SharpDX.Direct3D11.CullMode.None; break; } desc.IsScissorEnabled = ScissorTestEnable; desc.IsMultisampleEnabled = MultiSampleAntiAlias; desc.DepthBias = (int)DepthBias; desc.SlopeScaledDepthBias = SlopeScaleDepthBias; if (FillMode == Graphics.FillMode.WireFrame) desc.FillMode = SharpDX.Direct3D11.FillMode.Wireframe; else desc.FillMode = SharpDX.Direct3D11.FillMode.Solid; // These are new DX11 features we should consider exposing // as part of the extended MonoGame API. desc.IsFrontCounterClockwise = false; desc.IsAntialiasedLineEnabled = false; // To support feature level 9.1 these must // be set to these exact values. desc.DepthBiasClamp = 0.0f; desc.IsDepthClipEnabled = true; // Create the state. _state = new SharpDX.Direct3D11.RasterizerState(GraphicsDevice._d3dDevice, desc); } Debug.Assert(GraphicsDevice == device, "The state was created for a different device!"); // NOTE: We make the assumption here that the caller has // locked the d3dContext for us to use. // Apply the state! device._d3dContext.Rasterizer.State = _state; }
internal void PlatformApplyState(GraphicsDevice device) { if (_state == null) { // Build the description. var desc = new SharpDX.Direct3D11.RasterizerStateDescription(); switch (CullMode) { case Graphics.CullMode.CullClockwiseFace: desc.CullMode = SharpDX.Direct3D11.CullMode.Front; break; case Graphics.CullMode.CullCounterClockwiseFace: desc.CullMode = SharpDX.Direct3D11.CullMode.Back; break; case Graphics.CullMode.None: desc.CullMode = SharpDX.Direct3D11.CullMode.None; break; } desc.IsScissorEnabled = ScissorTestEnable; desc.IsMultisampleEnabled = MultiSampleAntiAlias; desc.DepthBias = (int)DepthBias; desc.SlopeScaledDepthBias = SlopeScaleDepthBias; if (FillMode == Graphics.FillMode.WireFrame) { desc.FillMode = SharpDX.Direct3D11.FillMode.Wireframe; } else { desc.FillMode = SharpDX.Direct3D11.FillMode.Solid; } // These are new DX11 features we should consider exposing // as part of the extended MonoGame API. desc.IsFrontCounterClockwise = false; desc.IsAntialiasedLineEnabled = false; // To support feature level 9.1 these must // be set to these exact values. desc.DepthBiasClamp = 0.0f; desc.IsDepthClipEnabled = true; // Create the state. _state = new SharpDX.Direct3D11.RasterizerState(GraphicsDevice._d3dDevice, desc); } Debug.Assert(GraphicsDevice == device, "The state was created for a different device!"); // NOTE: We make the assumption here that the caller has // locked the d3dContext for us to use. // Apply the state! device._d3dContext.Rasterizer.State = _state; }
public void InitializeRendering(AnimationEditor editor, DeviceManager deviceManager, WadMoveable skin) { if (LicenseManager.UsageMode != LicenseUsageMode.Runtime) { return; } base.InitializeRendering(deviceManager.Device, Configuration.RenderingItem_Antialias); ResetCamera(); _editor = editor; _wadRenderer = new WadRenderer(deviceManager.___LegacyDevice); _model = _wadRenderer.GetMoveable(editor.Moveable); Configuration = _editor.Tool.Configuration; if (skin != null) { _skinModel = _wadRenderer.GetMoveable(skin); } // Actual "InitializeRendering" _fontTexture = Device.CreateTextureAllocator(new RenderingTextureAllocator.Description { Size = new VectorInt3(512, 512, 2) }); _fontDefault = Device.CreateFont(new RenderingFont.Description { FontName = "Segoe UI", FontSize = 24, FontIsBold = true, TextureAllocator = _fontTexture }); // Legacy rendering { _device = deviceManager.___LegacyDevice; _deviceManager = deviceManager; new BasicEffect(_device); // This effect is used for editor special meshes like sinks, cameras, light meshes, etc SharpDX.Direct3D11.RasterizerStateDescription renderStateDesc = new SharpDX.Direct3D11.RasterizerStateDescription { CullMode = SharpDX.Direct3D11.CullMode.None, DepthBias = 0, DepthBiasClamp = 0, FillMode = SharpDX.Direct3D11.FillMode.Wireframe, IsAntialiasedLineEnabled = true, IsDepthClipEnabled = true, IsFrontCounterClockwise = false, IsMultisampleEnabled = true, IsScissorEnabled = false, SlopeScaledDepthBias = 0 }; _rasterizerWireframe = RasterizerState.New(deviceManager.___LegacyDevice, renderStateDesc); _gizmo = new GizmoAnimationEditor(editor, _device, _deviceManager.___LegacyEffects["Solid"], this); _plane = GeometricPrimitive.GridPlane.New(_device, 8, 4); } }
private SharpDX.Toolkit.Graphics.RasterizerState GetState() { if (state == null) { SharpDX.Direct3D11.RasterizerStateDescription desc = new SharpDX.Direct3D11.RasterizerStateDescription(); desc.CullMode = SharpDX.Direct3D11.CullMode.Front; desc.DepthBias = 36000; desc.DepthBiasClamp = 0.0f; desc.FillMode = SharpDX.Direct3D11.FillMode.Solid; desc.IsAntialiasedLineEnabled = false; desc.IsDepthClipEnabled = true; desc.IsFrontCounterClockwise = false; desc.IsMultisampleEnabled = false; desc.IsScissorEnabled = false; desc.SlopeScaledDepthBias = 1.7f; state = SharpDX.Toolkit.Graphics.RasterizerState.New(device, desc); } return(state); }
public RasterizerState(SharpDX.Direct3D11.RasterizerStateDescription desc) { _description = desc; }
internal void PlatformApplyState(GraphicsDevice device) { if (_state == null) { // Build the description. var desc = new SharpDX.Direct3D11.RasterizerStateDescription(); switch (CullMode) { case CullMode.CullClockwiseFace: desc.CullMode = SharpDX.Direct3D11.CullMode.Front; break; case CullMode.CullCounterClockwiseFace: desc.CullMode = SharpDX.Direct3D11.CullMode.Back; break; case CullMode.None: desc.CullMode = SharpDX.Direct3D11.CullMode.None; break; } desc.IsScissorEnabled = ScissorTestEnable; desc.IsMultisampleEnabled = MultiSampleAntiAlias; // discussion and explanation in https://github.com/MonoGame/MonoGame/issues/4826 int depthMul; switch (device.ActiveDepthFormat) { case DepthFormat.None: depthMul = 0; break; case DepthFormat.Depth16: depthMul = 1 << 16 - 1; break; case DepthFormat.Depth24: case DepthFormat.Depth24Stencil8: depthMul = 1 << 24 - 1; break; default: throw new ArgumentOutOfRangeException(); } desc.DepthBias = (int)(DepthBias * depthMul); desc.SlopeScaledDepthBias = SlopeScaleDepthBias; if (FillMode == FillMode.WireFrame) { desc.FillMode = SharpDX.Direct3D11.FillMode.Wireframe; } else { desc.FillMode = SharpDX.Direct3D11.FillMode.Solid; } desc.IsDepthClipEnabled = DepthClipEnable; // These are new DX11 features we should consider exposing // as part of the extended MonoGame API. desc.IsFrontCounterClockwise = false; desc.IsAntialiasedLineEnabled = false; // To support feature level 9.1 these must // be set to these exact values. desc.DepthBiasClamp = 0.0f; // Create the state. _state = new SharpDX.Direct3D11.RasterizerState(GraphicsDevice._d3dDevice, desc); } Debug.Assert(GraphicsDevice == device, "The state was created for a different device!"); // NOTE: We make the assumption here that the caller has // locked the d3dContext for us to use. // Apply the state! device._d3dContext.Rasterizer.State = _state; }