diff --git a/Build/Builder.cfg b/Build/Builder.cfg index 77e37139..f05d0086 100644 --- a/Build/Builder.cfg +++ b/Build/Builder.cfg @@ -15,9 +15,9 @@ shortcuts mainwindow { positionx = 124; - sizewidth = 739; sizeheight = 572; - windowstate = 2; positiony = 35; + windowstate = 2; + sizewidth = 739; } diff --git a/Source/Builder.csproj b/Source/Builder.csproj index abfec404..5433bb1c 100644 --- a/Source/Builder.csproj +++ b/Source/Builder.csproj @@ -118,9 +118,7 @@ - - - + diff --git a/Source/Map/Linedef.cs b/Source/Map/Linedef.cs index f8ea6f47..fd6552d0 100644 --- a/Source/Map/Linedef.cs +++ b/Source/Map/Linedef.cs @@ -23,7 +23,7 @@ using System.Globalization; using System.Text; using CodeImp.DoomBuilder.Geometry; using CodeImp.DoomBuilder.Rendering; -using Microsoft.DirectX.Direct3D; +using SlimDX.Direct3D; #endregion diff --git a/Source/Rendering/Graphics.cs b/Source/Rendering/Graphics.cs index b231dd4b..32c8a7b0 100644 --- a/Source/Rendering/Graphics.cs +++ b/Source/Rendering/Graphics.cs @@ -25,10 +25,10 @@ using System.Windows.Forms; using System.IO; using System.Reflection; using System.Drawing; -using Microsoft.DirectX.Direct3D; +using SlimDX.Direct3D; using System.ComponentModel; -using Microsoft.DirectX; using CodeImp.DoomBuilder.Geometry; +using SlimDX; #endregion @@ -50,7 +50,7 @@ namespace CodeImp.DoomBuilder.Rendering // Main objects private Control rendertarget; - private Caps devicecaps; + private Capabilities devicecaps; private Device device; private Renderer2D renderer2d; private Renderer3D renderer3d; @@ -107,60 +107,61 @@ namespace CodeImp.DoomBuilder.Rendering private void SetupSettings() { // Setup renderstates - device.SetRenderState(RenderStates.AntialiasedLineEnable, false); - device.SetRenderState(RenderStates.Ambient, Color.White.ToArgb()); - device.SetRenderState(RenderStates.AmbientMaterialSource, (int)ColorSource.Material); - device.SetRenderState(RenderStates.ColorVertex, false); - device.SetRenderState(RenderStates.DiffuseMaterialSource, (int)ColorSource.Color1); - device.SetRenderState(RenderStates.FillMode, (int)FillMode.Solid); - device.SetRenderState(RenderStates.FogEnable, false); - device.SetRenderState(RenderStates.Lighting, false); - device.SetRenderState(RenderStates.LocalViewer, false); - device.SetRenderState(RenderStates.NormalizeNormals, false); - device.SetRenderState(RenderStates.SpecularEnable, false); - device.SetRenderState(RenderStates.StencilEnable, false); - device.SetRenderState(RenderStates.PointSpriteEnable, false); - device.SetRenderState(RenderStates.DitherEnable, true); - device.SetRenderState(RenderStates.AlphaBlendEnable, false); - device.SetRenderState(RenderStates.ZEnable, false); - device.SetRenderState(RenderStates.ZBufferWriteEnable, false); - device.SetRenderState(RenderStates.Clipping, true); - device.SetRenderState(RenderStates.CullMode, (int)Cull.None); + device.SetRenderState(RenderState.AntialiasedLineEnable, false); + device.SetRenderState(RenderState.Ambient, Color.White.ToArgb()); + device.SetRenderState(RenderState.AmbientMaterialSource, (int)ColorSource.Material); + device.SetRenderState(RenderState.ColorVertex, false); + device.SetRenderState(RenderState.DiffuseMaterialSource, (int)ColorSource.Color1); + device.SetRenderState(RenderState.FillMode, (int)FillMode.Solid); + device.SetRenderState(RenderState.FogEnable, false); + device.SetRenderState(RenderState.Lighting, false); + device.SetRenderState(RenderState.LocalViewer, false); + device.SetRenderState(RenderState.NormalizeNormals, false); + device.SetRenderState(RenderState.SpecularEnable, false); + device.SetRenderState(RenderState.StencilEnable, false); + device.SetRenderState(RenderState.PointSpriteEnable, false); + device.SetRenderState(RenderState.DitherEnable, true); + device.SetRenderState(RenderState.AlphaBlendEnable, false); + device.SetRenderState(RenderState.ZEnable, false); + device.SetRenderState(RenderState.ZWriteEnable, false); + device.SetRenderState(RenderState.Clipping, true); + device.SetRenderState(RenderState.CullMode, (int)Cull.None); device.VertexFormat = PTVertex.Format; // Sampler settings - device.SamplerState[0].MagFilter = TextureFilter.Linear; - device.SamplerState[0].MinFilter = TextureFilter.Linear; - device.SamplerState[0].MipFilter = TextureFilter.Linear; + device.SetSamplerState(0, SamplerState.MagFilter, (int)TextureFilter.Linear); + device.SetSamplerState(0, SamplerState.MinFilter, (int)TextureFilter.Linear); + device.SetSamplerState(0, SamplerState.MipFilter, (int)TextureFilter.Linear); // Texture addressing - device.SamplerState[0].AddressU = TextureAddress.Wrap; - device.SamplerState[0].AddressV = TextureAddress.Wrap; - device.SamplerState[0].AddressW = TextureAddress.Wrap; + // TODO: SlimDX is missing TextureAddress enum + //device.SetSamplerState(0, SamplerState.AddressU, (int)TextureAddress.Wrap); + //device.SetSamplerState(0, SamplerState.AddressV, (int)TextureAddress.Wrap); + //device.SetSamplerState(0, SamplerState.AddressW, (int)TextureAddress.Wrap); // First texture stage - device.TextureState[0].ColorOperation = TextureOperation.Modulate; - device.TextureState[0].ColorArgument1 = TextureArgument.Current; - device.TextureState[0].ColorArgument2 = TextureArgument.TFactor; - device.TextureState[0].ResultArgument = TextureArgument.Current; - device.TextureState[0].TextureCoordinateIndex = 0; + device.SetTextureStageState(0, TextureStage.ColorOp, (int)TextureOperation.Modulate); + device.SetTextureStageState(0, TextureStage.ColorArg1, (int)TextureArgument.Current); + device.SetTextureStageState(0, TextureStage.ColorArg2, (int)TextureArgument.TFactor); + device.SetTextureStageState(0, TextureStage.ResultArg, (int)TextureArgument.Current); + device.SetTextureStageState(0, TextureStage.TexCoordIndex, 0); // No more further stages - device.TextureState[1].ColorOperation = TextureOperation.Disable; + device.SetTextureStageState(1, TextureStage.ColorOp, (int)TextureOperation.Disable); // First alpha stage - device.TextureState[0].AlphaOperation = TextureOperation.Modulate; - device.TextureState[0].AlphaArgument1 = TextureArgument.TextureColor; - device.TextureState[0].AlphaArgument2 = TextureArgument.TFactor; + device.SetTextureStageState(0, TextureStage.AlphaOp, (int)TextureOperation.Modulate); + device.SetTextureStageState(0, TextureStage.AlphaArg1, (int)TextureArgument.Texture); + device.SetTextureStageState(0, TextureStage.AlphaArg2, (int)TextureArgument.TFactor); // No more further stages - device.TextureState[1].AlphaOperation = TextureOperation.Disable; + device.SetTextureStageState(1, TextureStage.AlphaOp, (int)TextureOperation.Disable); // Setup material Material material = new Material(); - material.Ambient = Color.White; - material.Diffuse = Color.White; - material.Specular = Color.White; + material.Ambient = ColorValue.FromColor(Color.White); + material.Diffuse = ColorValue.FromColor(Color.White); + material.Specular = ColorValue.FromColor(Color.White); device.Material = material; } @@ -175,33 +176,33 @@ namespace CodeImp.DoomBuilder.Rendering DeviceType devtype; // Use default adapter - this.adapter = Manager.Adapters.Default.Adapter; + this.adapter = 0; // Manager.Adapters.Default.Adapter; // Make present parameters displaypp = CreatePresentParameters(adapter); // Determine device type for compatability with NVPerfHUD - if(Manager.Adapters[adapter].Information.Description.EndsWith(NVPERFHUD_ADAPTER)) + if(Direct3D.Adapters[adapter].Details.Description.EndsWith(NVPERFHUD_ADAPTER)) devtype = DeviceType.Reference; else devtype = DeviceType.Hardware; // Get the device capabilities - devicecaps = Manager.GetDeviceCaps(adapter, devtype); + devicecaps = Direct3D.GetDeviceCaps(adapter, devtype); try { // Check if this adapter supports TnL - if(devicecaps.DeviceCaps.SupportsHardwareTransformAndLight) + if((devicecaps.DeviceCaps & DeviceCaps.HWTransformAndLight) != 0) { // Initialize with hardware TnL - device = new Device(adapter, devtype, rendertarget, + device = new Device(adapter, devtype, rendertarget.Handle, CreateFlags.HardwareVertexProcessing, displaypp); } else { // Initialize with software TnL - device = new Device(adapter, devtype, rendertarget, + device = new Device(adapter, devtype, rendertarget.Handle, CreateFlags.SoftwareVertexProcessing, displaypp); } } @@ -213,7 +214,7 @@ namespace CodeImp.DoomBuilder.Rendering } // Add event to cancel resize event - device.DeviceResizing += new CancelEventHandler(CancelResize); + //device.DeviceResizing += new CancelEventHandler(CancelResize); // Initialize settings SetupSettings(); @@ -240,7 +241,7 @@ namespace CodeImp.DoomBuilder.Rendering DisplayMode currentmode; // Get current display mode - currentmode = Manager.Adapters[adapter].CurrentDisplayMode; + currentmode = Direct3D.Adapters[adapter].CurrentDisplayMode; // Make present parameters displaypp.Windowed = true; @@ -250,7 +251,7 @@ namespace CodeImp.DoomBuilder.Rendering displaypp.BackBufferWidth = rendertarget.ClientSize.Width; displaypp.BackBufferHeight = rendertarget.ClientSize.Height; displaypp.EnableAutoDepthStencil = true; - displaypp.AutoDepthStencilFormat = DepthFormat.D16; + displaypp.AutoDepthStencilFormat = Format.D16; // SLimDX is missing DepthFormat enum displaypp.MultiSample = MultiSampleType.None; displaypp.PresentationInterval = PresentInterval.Immediate; @@ -299,22 +300,22 @@ namespace CodeImp.DoomBuilder.Rendering // This begins a drawing session public bool StartRendering() { - int coopresult; + CooperativeLevel coopresult; // When minimized, do not render anything if(General.MainWindow.WindowState != FormWindowState.Minimized) { // Test the cooperative level - device.CheckCooperativeLevel(out coopresult); - + coopresult = device.CheckCooperativeLevel(); + // Check if device must be reset - if(coopresult == (int)ResultCode.DeviceNotReset) + if(coopresult == CooperativeLevel.DeviceNotReset) { // Device is lost and must be reset now return Reset(); } // Check if device is lost - else if(coopresult == (int)ResultCode.DeviceLost) + else if(coopresult == CooperativeLevel.DeviceLost) { // Device is lost and cannot be reset now return false; diff --git a/Source/Rendering/PTVertex.cs b/Source/Rendering/PTVertex.cs index e61de3cd..16e17508 100644 --- a/Source/Rendering/PTVertex.cs +++ b/Source/Rendering/PTVertex.cs @@ -25,7 +25,7 @@ using System.Windows.Forms; using System.IO; using System.Reflection; using System.Drawing; -using Microsoft.DirectX.Direct3D; +using SlimDX.Direct3D; using System.ComponentModel; #endregion @@ -36,7 +36,7 @@ namespace CodeImp.DoomBuilder.Rendering public struct PTVertex { // Vertex format - public static readonly VertexFormats Format = VertexFormats.Position | VertexFormats.Diffuse | VertexFormats.Texture1; + public static readonly VertexFormat Format = VertexFormat.Position | VertexFormat.Diffuse | VertexFormat.Texture1; public static readonly int Stride = 6 * 4; // Members diff --git a/Source/Rendering/Renderer2D.cs b/Source/Rendering/Renderer2D.cs index 59dd5f47..49ae6da3 100644 --- a/Source/Rendering/Renderer2D.cs +++ b/Source/Rendering/Renderer2D.cs @@ -25,10 +25,10 @@ using System.Windows.Forms; using System.IO; using System.Reflection; using System.Drawing; -using Microsoft.DirectX.Direct3D; using System.ComponentModel; using CodeImp.DoomBuilder.Map; -using Microsoft.DirectX; +using SlimDX.Direct3D; +using SlimDX; #endregion @@ -109,9 +109,9 @@ namespace CodeImp.DoomBuilder.Rendering proj = Matrix.OrthoOffCenterLH(left, right, top, bottom, -1f, 1f); // Apply matrices - graphics.Device.Transform.Projection = proj; - graphics.Device.Transform.View = Matrix.Identity; - graphics.Device.Transform.World = Matrix.Identity; + graphics.Device.SetTransform(TransformState.Projection, proj); + graphics.Device.SetTransform(TransformState.View, Matrix.Identity); + graphics.Device.SetTransform(TransformState.World, Matrix.Identity); } // This begins a drawing session @@ -164,7 +164,7 @@ namespace CodeImp.DoomBuilder.Rendering // Any linedefs? if(linedefs.Count > 0) { - graphics.Device.RenderState.TextureFactor = -1; + graphics.Device.SetRenderState(RenderState.TextureFactor, -1); // Go for all linedefs foreach(Linedef l in linedefs) @@ -177,7 +177,7 @@ namespace CodeImp.DoomBuilder.Rendering } // Draw lines - graphics.Device.DrawUserPrimitives(PrimitiveType.LineList, linedefs.Count * 2, verts); + graphics.Device.DrawUserPrimitives(PrimitiveType.LineList, 0, linedefs.Count * 2, verts); } } diff --git a/Source/Rendering/Renderer3D.cs b/Source/Rendering/Renderer3D.cs index 6fc2f065..6d21f249 100644 --- a/Source/Rendering/Renderer3D.cs +++ b/Source/Rendering/Renderer3D.cs @@ -25,7 +25,7 @@ using System.Windows.Forms; using System.IO; using System.Reflection; using System.Drawing; -using Microsoft.DirectX.Direct3D; +using SlimDX.Direct3D; using System.ComponentModel; #endregion