diff --git a/D3D11Control.cs b/D3D11Control.cs
index be4d612..b8a7dc4 100644
--- a/D3D11Control.cs
+++ b/D3D11Control.cs
@@ -2,7 +2,7 @@
using SlimDX.DXGI;
using System;
using System.ComponentModel;
-using System.Diagnostics;
+using System.Diagnostics.CodeAnalysis;
using System.Drawing;
using System.Windows.Forms;
using Device = SlimDX.Direct3D11.Device;
@@ -206,7 +206,7 @@ namespace SlimDX.Windows {
const int CS_HREDRAW = 0x2;
const int CS_OWNDC = 0x20;
- CreateParams cp = base.CreateParams;
+ var cp = base.CreateParams;
// Setup necessary class style on windows.
cp.ClassStyle |= CS_VREDRAW | CS_HREDRAW | CS_OWNDC;
return cp;
@@ -269,11 +269,11 @@ namespace SlimDX.Windows {
///
public void ResizeViewport(Size s) {
var current = Context.Rasterizer.GetViewports();
- var viewport = new Viewport(0, 0, ClientSize.Width, ClientSize.Height);
+ var viewport = new Viewport(0, 0, s.Width, s.Height);
Context.Rasterizer.SetViewports(viewport);
// See if we need to raise an AspectRatioChanged event.
if (current.Length > 0) {
- float oldAspectRatio = current[0].Width / (float)current[0].Height;
+ var oldAspectRatio = current[0].Width / current[0].Height;
if (!NearlyEqual(AspectRatio, oldAspectRatio)) {
OnAspectRatioChanged(EventArgs.Empty);
}
@@ -354,13 +354,9 @@ namespace SlimDX.Windows {
///
protected override void OnResize(EventArgs e) {
base.OnResize(e);
- // FIXME: If the form is minimized, OnResize is triggered with a client-size of (0,0),
- // so handle that here. Otherwise Texture2D will, for whatever reason (???)
- // invoke the parent form's Run method. It must have something to do with the
- // MessagePump and PeekMessage but I can't figure it out.
+ // If the form is minimized, OnResize is triggered with a client-size of (0,0).
if (ClientSize.IsEmpty)
return;
-
if (swapChain == null)
return;
ReleaseCOMObjects(false);
@@ -445,19 +441,20 @@ namespace SlimDX.Windows {
///
/// true if the values are considered equal; otherwise, false.
///
+ [SuppressMessage("ReSharper", "CompareOfFloatsByEqualityOperator")]
static bool NearlyEqual(float a, float b, float epsilon = .0000001f) {
- float absA = Math.Abs(a);
- float absB = Math.Abs(b);
- float diff = Math.Abs(a - b);
- if (a == b) { // shortcut, handles infinities
+ var absA = Math.Abs(a);
+ var absB = Math.Abs(b);
+ var diff = Math.Abs(a - b);
+ if (a == b) // shortcut, handles infinities
return true;
- } else if (a == 0 || b == 0 || diff < float.MinValue) {
+ if (a == 0 || b == 0 || diff < float.Epsilon) {
// a or b is zero or both are extremely close to it
// relative error is less meaningful here
- return diff < (epsilon * float.MinValue);
- } else { // use relative error
- return diff / (absA + absB) < epsilon;
+ return diff < epsilon;
}
+ // use relative error
+ return diff / (absA + absB) < epsilon;
}
///
@@ -498,8 +495,8 @@ namespace SlimDX.Windows {
/// Updates the rasterizer state for the rasterizer stage of the pipeline.
///
void UpdateRasterizerState() {
- RasterizerState rs = RasterizerState.FromDescription(device, rsDescription);
- RasterizerState oldRs = Context.Rasterizer.State;
+ var rs = RasterizerState.FromDescription(device, rsDescription);
+ var oldRs = Context.Rasterizer.State;
Context.Rasterizer.State = rs;
if (oldRs != null) {
oldRs.Dispose();
diff --git a/README.md b/README.md
index 51e4eae..bbc60f1 100644
--- a/README.md
+++ b/README.md
@@ -26,5 +26,4 @@ This library is copyright © 2014-2015 Torben Könke.
### License
-This library is released under the [MIT license](https://github.com/qwert9001/SlimDX.D3D11Control/blob/master/LICENSE).
-
+This library is released under the [MIT license](https://github.com/smiley22/SlimDX.D3D11Control/blob/master/LICENSE).
\ No newline at end of file