From 3cff90d7165f59d9228afd729f309397bb8ae0ec Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Thu, 8 Aug 2019 03:51:21 +0200 Subject: [PATCH] - remove SlimDX.Direct3D9 namespace --- Source/Core/Data/DataManager.cs | 1 - Source/Core/Data/ImageData.cs | 1 - Source/Core/GZBuilder/Data/ModelData.cs | 1 - Source/Core/GZBuilder/md3/GZModel.cs | 2 +- Source/Core/GZBuilder/md3/ModelReader.cs | 10 +- Source/Core/General/General.cs | 1 - Source/Core/Rendering/CustomTextLabel.cs | 1 - Source/Core/Rendering/D3DDevice.cs | 186 ++++++++++++++++- Source/Core/Rendering/D3DShader.cs | 1 - Source/Core/Rendering/Display2DShader.cs | 8 +- Source/Core/Rendering/FlatQuad.cs | 1 - Source/Core/Rendering/Renderer2D.cs | 7 +- Source/Core/Rendering/Renderer3D.cs | 3 +- Source/Core/Rendering/SurfaceBufferSet.cs | 1 - Source/Core/Rendering/SurfaceManager.cs | 7 +- Source/Core/Rendering/TextLabel.cs | 3 +- Source/Core/Rendering/Things2DShader.cs | 8 +- Source/Core/Rendering/VisualVertexHandle.cs | 5 +- Source/Core/Rendering/World3DShader.cs | 10 +- Source/Core/SlimDX.cs | 215 +------------------- Source/Core/VisualModes/VisualSector.cs | 3 +- Source/Core/VisualModes/VisualThing.cs | 5 +- 22 files changed, 215 insertions(+), 265 deletions(-) diff --git a/Source/Core/Data/DataManager.cs b/Source/Core/Data/DataManager.cs index 2949f609..cb48a200 100755 --- a/Source/Core/Data/DataManager.cs +++ b/Source/Core/Data/DataManager.cs @@ -37,7 +37,6 @@ using CodeImp.DoomBuilder.Rendering; using CodeImp.DoomBuilder.Windows; using CodeImp.DoomBuilder.ZDoom; using SlimDX; -using SlimDX.Direct3D9; using Matrix = SlimDX.Matrix; using CodeImp.DoomBuilder.Controls; diff --git a/Source/Core/Data/ImageData.cs b/Source/Core/Data/ImageData.cs index 134261d5..3a9de68c 100755 --- a/Source/Core/Data/ImageData.cs +++ b/Source/Core/Data/ImageData.cs @@ -27,7 +27,6 @@ using CodeImp.DoomBuilder.IO; using CodeImp.DoomBuilder.Rendering; using CodeImp.DoomBuilder.Windows; using SlimDX; -using SlimDX.Direct3D9; #endregion diff --git a/Source/Core/GZBuilder/Data/ModelData.cs b/Source/Core/GZBuilder/Data/ModelData.cs index d5b6c7af..720283c8 100755 --- a/Source/Core/GZBuilder/Data/ModelData.cs +++ b/Source/Core/GZBuilder/Data/ModelData.cs @@ -4,7 +4,6 @@ using System.Collections.Generic; using CodeImp.DoomBuilder.GZBuilder.MD3; using CodeImp.DoomBuilder.Rendering; using SlimDX; -using SlimDX.Direct3D9; #endregion diff --git a/Source/Core/GZBuilder/md3/GZModel.cs b/Source/Core/GZBuilder/md3/GZModel.cs index b1889a9e..7d32d78e 100755 --- a/Source/Core/GZBuilder/md3/GZModel.cs +++ b/Source/Core/GZBuilder/md3/GZModel.cs @@ -1,5 +1,5 @@ using System.Collections.Generic; -using SlimDX.Direct3D9; +using CodeImp.DoomBuilder.Rendering; namespace CodeImp.DoomBuilder.GZBuilder.MD3 { diff --git a/Source/Core/GZBuilder/md3/ModelReader.cs b/Source/Core/GZBuilder/md3/ModelReader.cs index a1382803..b017e2c9 100755 --- a/Source/Core/GZBuilder/md3/ModelReader.cs +++ b/Source/Core/GZBuilder/md3/ModelReader.cs @@ -11,7 +11,6 @@ using CodeImp.DoomBuilder.Data; using CodeImp.DoomBuilder.Rendering; using CodeImp.DoomBuilder.GZBuilder.Data; using SlimDX; -using SlimDX.Direct3D9; using CodeImp.DoomBuilder.Geometry; #endregion @@ -38,11 +37,10 @@ namespace CodeImp.DoomBuilder.GZBuilder.MD3 private static readonly VertexElement[] vertexElements = new[] { - new VertexElement(0, 0, DeclarationType.Float3, DeclarationMethod.Default, DeclarationUsage.Position, 0), - new VertexElement(0, 12, DeclarationType.Color, DeclarationMethod.Default, DeclarationUsage.Color, 0), - new VertexElement(0, 16, DeclarationType.Float2, DeclarationMethod.Default, DeclarationUsage.TextureCoordinate, 0), - new VertexElement(0, 24, DeclarationType.Float3, DeclarationMethod.Default, DeclarationUsage.Normal, 0), - VertexElement.VertexDeclarationEnd + new VertexElement(0, 0, DeclarationType.Float3, DeclarationUsage.Position), + new VertexElement(0, 12, DeclarationType.Color, DeclarationUsage.Color), + new VertexElement(0, 16, DeclarationType.Float2, DeclarationUsage.TextureCoordinate), + new VertexElement(0, 24, DeclarationType.Float3, DeclarationUsage.Normal) }; #endregion diff --git a/Source/Core/General/General.cs b/Source/Core/General/General.cs index 1a306f3b..62cb7bfa 100755 --- a/Source/Core/General/General.cs +++ b/Source/Core/General/General.cs @@ -40,7 +40,6 @@ using CodeImp.DoomBuilder.Plugins; using CodeImp.DoomBuilder.Rendering; using CodeImp.DoomBuilder.Types; using CodeImp.DoomBuilder.Windows; -using SlimDX.Direct3D9; #endregion diff --git a/Source/Core/Rendering/CustomTextLabel.cs b/Source/Core/Rendering/CustomTextLabel.cs index 9320d38a..d500e1a6 100755 --- a/Source/Core/Rendering/CustomTextLabel.cs +++ b/Source/Core/Rendering/CustomTextLabel.cs @@ -1,5 +1,4 @@ using System.Drawing; -using SlimDX.Direct3D9; using Font = System.Drawing.Font; namespace CodeImp.DoomBuilder.Rendering diff --git a/Source/Core/Rendering/D3DDevice.cs b/Source/Core/Rendering/D3DDevice.cs index f6f2c098..14c81e83 100755 --- a/Source/Core/Rendering/D3DDevice.cs +++ b/Source/Core/Rendering/D3DDevice.cs @@ -23,12 +23,193 @@ using System.Windows.Forms; using CodeImp.DoomBuilder.Controls; using CodeImp.DoomBuilder.Geometry; using SlimDX; -using SlimDX.Direct3D9; #endregion namespace CodeImp.DoomBuilder.Rendering { + #region High level mesh rendering + public class Mesh + { + public Mesh(int indexCount, int vertexCount, MeshFlags flags, VertexElement[] elements) { } + + public VertexBuffer VertexBuffer { get; private set; } + public IndexBuffer IndexBuffer { get; private set; } + + public DataStream LockVertexBuffer(LockFlags flags) { return null; } + public DataStream LockIndexBuffer(LockFlags flags) { return null; } + public void UnlockVertexBuffer() { } + public void UnlockIndexBuffer() { } + + public void DrawSubset(int index) { } + + public void Dispose() { } + } + + public class Effect + { + public static Effect FromStream(System.IO.Stream stream, ShaderFlags flags, out string errors) { errors = ""; return null; } + + public void SetTexture(EffectHandle handle, BaseTexture texture) { } + public void SetValue(EffectHandle handle, T value) where T : struct { } + public EffectHandle GetParameter(EffectHandle parameter, string name) { return null; } + public string Technique { set; private get; } + public void CommitChanges() { } + + public void Begin() { } + public void BeginPass(int index) { } + public void EndPass() { } + public void End() { } + + public void Dispose() { } + } + + public class EffectHandle + { + public void Dispose() { } + } + #endregion + + #region Vertex buffer format / Input assembly + public class VertexDeclaration + { + public VertexDeclaration(VertexElement[] elements) { } + public void Dispose() { } + } + + public struct VertexElement + { + public VertexElement(short stream, short offset, DeclarationType type, DeclarationUsage usage) { } + } + #endregion + + #region Buffer objects + public class VertexBuffer + { + public VertexBuffer(int sizeInBytes, Usage usage, Pool pool) { } + + public DataStream Lock(int offset, int size, LockFlags flags) { return null; } + public void Unlock() { } + + public object Tag { get; set; } + + public bool Disposed { get; private set; } + public void Dispose() { Disposed = true; } + } + + public class IndexBuffer + { + public DataStream Lock(int offset, int size, LockFlags flags) { return null; } + public void Unlock() { } + + public object Tag { get; set; } + + public bool Disposed { get; private set; } + public void Dispose() { Disposed = true; } + } + #endregion + + #region Textures + public class BaseTexture + { + public bool Disposed { get; } + public void Dispose() { } + } + + public class Texture : BaseTexture + { + public Texture(int width, int height, int levels, Usage usage, Format format, Pool pool) { } + + public int Width { get; private set; } + public int Height { get; private set; } + + public object Tag { get; set; } + + public DataRectangle LockRectangle(int level, LockFlags flags) { return null; } + public void UnlockRectangle(int level) { } + + public static Texture FromStream(System.IO.Stream stream) { return null; } + public static Texture FromStream(System.IO.Stream stream, int length, int width, int height, int levels, Usage usage, Format format, Pool pool) { return null; } + } + + public class CubeTexture : BaseTexture + { + public CubeTexture(int size, int levels, Usage usage, Format format, Pool pool) { } + + public DataRectangle LockRectangle(CubeMapFace face, int level, LockFlags flags) { return null; } + public void UnlockRectangle(CubeMapFace face, int level) { } + } + #endregion + + #region Locked buffer writing and reading + public class DataRectangle + { + public DataRectangle(int pitch, DataStream s) { Data = s; Pitch = pitch; } + public DataStream Data { get; private set; } + public int Pitch { get; private set; } + } + + public class DataStream : IDisposable + { + public void Seek(long offset, System.IO.SeekOrigin origin) { } + public void Write(ushort v) { } + public void Write(Array data, long offset, long size) { } + public void WriteRange(Array data) { } + public void WriteRange(Array data, long offset, long size) { } + public void WriteRange(IntPtr data, long size) { } + public void Dispose() { } + + public void ReadRange(Array data, long offset, long size) { } + + public bool CanRead { get; private set; } + public bool CanWrite { get; private set; } + public long Length { get; private set; } + public IntPtr DataPointer { get; private set; } + } + #endregion + + #region Enumerations + public enum RenderState + { + AlphaBlendEnable, + AlphaRef, + AlphaTestEnable, + CullMode, + BlendOperation, + SourceBlend, + DestinationBlend, + FillMode, + FogEnable, + FogColor, + FogStart, + FogEnd, + MultisampleAntialias, + TextureFactor, + ZEnable, + ZWriteEnable + } + + public enum Cull { None, Counterclockwise } + public enum Blend { InverseSourceAlpha, SourceAlpha, One, BlendFactor } + public enum BlendOperation { Add, ReverseSubtract } + public enum FillMode { Solid, Wireframe } + public enum TransformState { World, View, Projection } + public enum SamplerState { AddressU, AddressV, AddressW } + public enum TextureAddress { Wrap, Clamp } + public enum Format { Unknown, A8R8G8B8 } + public enum Usage { None, WriteOnly, Dynamic, RenderTarget } + public enum Pool { Default, Managed, SystemMemory } + public enum LockFlags { None, Discard } + public enum MeshFlags { Use32Bit, IndexBufferManaged, VertexBufferManaged, Managed } + public enum ShaderFlags { None, Debug } + public enum PrimitiveType { LineList, TriangleList, TriangleStrip } + public enum CubeMapFace { PositiveX, PositiveY, PositiveZ, NegativeX, NegativeY, NegativeZ } + public enum TextureFilter { None, Point, Linear, Anisotropic } + public enum DeclarationType { Float2, Float3, Color } + public enum DeclarationUsage { Position, Color, TextureCoordinate, Normal } + #endregion + + #region Device context internal class D3DDevice : IDisposable { internal D3DDevice(RenderTargetControl rendertarget) @@ -42,7 +223,6 @@ namespace CodeImp.DoomBuilder.Rendering public void SetRenderState(RenderState state, float v) { } public void SetRenderState(RenderState state, bool v) { } public void SetRenderState(RenderState state, int v) { } - public void SetRenderState(RenderState state, Compare v) { } public void SetRenderState(RenderState state, Cull v) { } public void SetRenderState(RenderState state, Blend v) { } public void SetRenderState(RenderState state, BlendOperation v) { } @@ -87,7 +267,6 @@ namespace CodeImp.DoomBuilder.Rendering { // Setup renderstates SetRenderState(RenderState.AlphaBlendEnable, false); - SetRenderState(RenderState.AlphaFunc, Compare.GreaterEqual); SetRenderState(RenderState.AlphaRef, 0x0000007E); SetRenderState(RenderState.AlphaTestEnable, false); SetRenderState(RenderState.CullMode, Cull.None); @@ -153,4 +332,5 @@ namespace CodeImp.DoomBuilder.Rendering return new Vector2D(v2.X, v2.Y); } } + #endregion } diff --git a/Source/Core/Rendering/D3DShader.cs b/Source/Core/Rendering/D3DShader.cs index a1f035d3..23925c56 100755 --- a/Source/Core/Rendering/D3DShader.cs +++ b/Source/Core/Rendering/D3DShader.cs @@ -18,7 +18,6 @@ using System; using System.IO; -using SlimDX.Direct3D9; #endregion diff --git a/Source/Core/Rendering/Display2DShader.cs b/Source/Core/Rendering/Display2DShader.cs index 63481acb..40fdab36 100755 --- a/Source/Core/Rendering/Display2DShader.cs +++ b/Source/Core/Rendering/Display2DShader.cs @@ -17,7 +17,6 @@ #region ================== Namespaces using System; -using SlimDX.Direct3D9; using SlimDX; #endregion @@ -79,10 +78,9 @@ namespace CodeImp.DoomBuilder.Rendering // Initialize world vertex declaration VertexElement[] elements = new[] { - new VertexElement(0, 0, DeclarationType.Float3, DeclarationMethod.Default, DeclarationUsage.Position, 0), - new VertexElement(0, 12, DeclarationType.Color, DeclarationMethod.Default, DeclarationUsage.Color, 0), - new VertexElement(0, 16, DeclarationType.Float2, DeclarationMethod.Default, DeclarationUsage.TextureCoordinate, 0), - VertexElement.VertexDeclarationEnd + new VertexElement(0, 0, DeclarationType.Float3, DeclarationUsage.Position), + new VertexElement(0, 12, DeclarationType.Color, DeclarationUsage.Color), + new VertexElement(0, 16, DeclarationType.Float2, DeclarationUsage.TextureCoordinate) }; vertexdecl = new VertexDeclaration(elements); diff --git a/Source/Core/Rendering/FlatQuad.cs b/Source/Core/Rendering/FlatQuad.cs index 7c493a8f..4d54b8d4 100755 --- a/Source/Core/Rendering/FlatQuad.cs +++ b/Source/Core/Rendering/FlatQuad.cs @@ -18,7 +18,6 @@ using System; using System.Drawing; -using SlimDX.Direct3D9; #endregion diff --git a/Source/Core/Rendering/Renderer2D.cs b/Source/Core/Rendering/Renderer2D.cs index d0c61a7c..4e4f79e2 100755 --- a/Source/Core/Rendering/Renderer2D.cs +++ b/Source/Core/Rendering/Renderer2D.cs @@ -21,7 +21,6 @@ using System.Collections.Generic; using System.Drawing; using System.Net; using CodeImp.DoomBuilder.Map; -using SlimDX.Direct3D9; using SlimDX; using CodeImp.DoomBuilder.Geometry; using CodeImp.DoomBuilder.Data; @@ -392,8 +391,8 @@ namespace CodeImp.DoomBuilder.Rendering graphics.ClearTexture(General.Colors.Background.WithAlpha(0).ToColorValue(), overlaytex); // Create vertex buffers - screenverts = new VertexBuffer(4 * sizeof(FlatVertex), Usage.Dynamic | Usage.WriteOnly, VertexFormat.None, Pool.Default); - thingsvertices = new VertexBuffer(THING_BUFFER_SIZE * 12 * sizeof(FlatVertex), Usage.Dynamic | Usage.WriteOnly, VertexFormat.None, Pool.Default); + screenverts = new VertexBuffer(4 * sizeof(FlatVertex), Usage.Dynamic | Usage.WriteOnly, Pool.Default); + thingsvertices = new VertexBuffer(THING_BUFFER_SIZE * 12 * sizeof(FlatVertex), Usage.Dynamic | Usage.WriteOnly, Pool.Default); // Make screen vertices DataStream stream = screenverts.Lock(0, 4 * sizeof(FlatVertex), LockFlags.Discard); @@ -2009,7 +2008,7 @@ namespace CodeImp.DoomBuilder.Rendering } // Write to buffer - VertexBuffer vb = new VertexBuffer(FlatVertex.Stride * verts.Length, Usage.WriteOnly | Usage.Dynamic, VertexFormat.None, Pool.Default); + VertexBuffer vb = new VertexBuffer(FlatVertex.Stride * verts.Length, Usage.WriteOnly | Usage.Dynamic, Pool.Default); DataStream s = vb.Lock(0, FlatVertex.Stride * verts.Length, LockFlags.Discard); s.WriteRange(verts); vb.Unlock(); diff --git a/Source/Core/Rendering/Renderer3D.cs b/Source/Core/Rendering/Renderer3D.cs index 11941159..59707c3d 100755 --- a/Source/Core/Rendering/Renderer3D.cs +++ b/Source/Core/Rendering/Renderer3D.cs @@ -26,7 +26,6 @@ using CodeImp.DoomBuilder.GZBuilder.MD3; using CodeImp.DoomBuilder.Map; using CodeImp.DoomBuilder.VisualModes; using SlimDX; -using SlimDX.Direct3D9; using CodeImp.DoomBuilder.GZBuilder; #endregion @@ -721,7 +720,7 @@ namespace CodeImp.DoomBuilder.Rendering } } - VertexBuffer vb = new VertexBuffer(WorldVertex.Stride * verts.Length, Usage.WriteOnly | Usage.Dynamic, VertexFormat.None, Pool.Default); + VertexBuffer vb = new VertexBuffer(WorldVertex.Stride * verts.Length, Usage.WriteOnly | Usage.Dynamic, Pool.Default); DataStream s = vb.Lock(0, WorldVertex.Stride * verts.Length, LockFlags.Discard); s.WriteRange(verts); vb.Unlock(); diff --git a/Source/Core/Rendering/SurfaceBufferSet.cs b/Source/Core/Rendering/SurfaceBufferSet.cs index bdc49bc4..5586a098 100755 --- a/Source/Core/Rendering/SurfaceBufferSet.cs +++ b/Source/Core/Rendering/SurfaceBufferSet.cs @@ -17,7 +17,6 @@ #region ================== Namespaces using System.Collections.Generic; -using SlimDX.Direct3D9; #endregion diff --git a/Source/Core/Rendering/SurfaceManager.cs b/Source/Core/Rendering/SurfaceManager.cs index 18617b21..e63973ba 100755 --- a/Source/Core/Rendering/SurfaceManager.cs +++ b/Source/Core/Rendering/SurfaceManager.cs @@ -23,7 +23,6 @@ using System.IO; using CodeImp.DoomBuilder.Data; using CodeImp.DoomBuilder.Map; using SlimDX; -using SlimDX.Direct3D9; #endregion @@ -141,7 +140,7 @@ namespace CodeImp.DoomBuilder.Rendering for(int i = 0; i < set.Value.buffersizes.Count; i++) { // Make the new buffer! - VertexBuffer b = new VertexBuffer(FlatVertex.Stride * set.Value.buffersizes[i], Usage.WriteOnly | Usage.Dynamic, VertexFormat.None, Pool.Default); + VertexBuffer b = new VertexBuffer(FlatVertex.Stride * set.Value.buffersizes[i], Usage.WriteOnly | Usage.Dynamic, Pool.Default); // Start refilling the buffer with sector geometry DataStream bstream = b.Lock(0, FlatVertex.Stride * set.Value.buffersizes[i], LockFlags.Discard); @@ -281,7 +280,7 @@ namespace CodeImp.DoomBuilder.Rendering if(!resourcesunloaded) { // Make the new buffer! - vb = new VertexBuffer(FlatVertex.Stride * buffernumvertices, Usage.WriteOnly | Usage.Dynamic, VertexFormat.None, Pool.Default); + vb = new VertexBuffer(FlatVertex.Stride * buffernumvertices, Usage.WriteOnly | Usage.Dynamic, Pool.Default); // Add it. set.buffers.Add(vb); @@ -332,7 +331,7 @@ namespace CodeImp.DoomBuilder.Rendering if(!resourcesunloaded) { // Make the new buffer and lock it - vb = new VertexBuffer(FlatVertex.Stride * buffernumvertices, Usage.WriteOnly | Usage.Dynamic, VertexFormat.None, Pool.Default); + vb = new VertexBuffer(FlatVertex.Stride * buffernumvertices, Usage.WriteOnly | Usage.Dynamic, Pool.Default); bstream = vb.Lock(0, FlatVertex.Stride * theseentries.Count * verticesperentry, LockFlags.Discard); } diff --git a/Source/Core/Rendering/TextLabel.cs b/Source/Core/Rendering/TextLabel.cs index d3ec9eca..f7b17afe 100755 --- a/Source/Core/Rendering/TextLabel.cs +++ b/Source/Core/Rendering/TextLabel.cs @@ -22,7 +22,6 @@ using System.Drawing.Imaging; using System.Drawing.Text; using System.IO; using System.Drawing; -using SlimDX.Direct3D9; using SlimDX; using CodeImp.DoomBuilder.Geometry; using Font = System.Drawing.Font; @@ -343,7 +342,7 @@ namespace CodeImp.DoomBuilder.Rendering //mxd. Create the buffer if(textbuffer == null || textbuffer.Disposed) { - textbuffer = new VertexBuffer(4 * FlatVertex.Stride, Usage.Dynamic | Usage.WriteOnly, VertexFormat.None, Pool.Default); + textbuffer = new VertexBuffer(4 * FlatVertex.Stride, Usage.Dynamic | Usage.WriteOnly, Pool.Default); } //mxd. Lock the buffer diff --git a/Source/Core/Rendering/Things2DShader.cs b/Source/Core/Rendering/Things2DShader.cs index b7304f75..dd4667eb 100755 --- a/Source/Core/Rendering/Things2DShader.cs +++ b/Source/Core/Rendering/Things2DShader.cs @@ -17,7 +17,6 @@ #region ================== Namespaces using System; -using SlimDX.Direct3D9; using SlimDX; #endregion @@ -94,10 +93,9 @@ namespace CodeImp.DoomBuilder.Rendering // Initialize world vertex declaration VertexElement[] elements = new[] { - new VertexElement(0, 0, DeclarationType.Float3, DeclarationMethod.Default, DeclarationUsage.Position, 0), - new VertexElement(0, 12, DeclarationType.Color, DeclarationMethod.Default, DeclarationUsage.Color, 0), - new VertexElement(0, 16, DeclarationType.Float2, DeclarationMethod.Default, DeclarationUsage.TextureCoordinate, 0), - VertexElement.VertexDeclarationEnd + new VertexElement(0, 0, DeclarationType.Float3, DeclarationUsage.Position), + new VertexElement(0, 12, DeclarationType.Color, DeclarationUsage.Color), + new VertexElement(0, 16, DeclarationType.Float2, DeclarationUsage.TextureCoordinate) }; vertexdecl = new VertexDeclaration(elements); diff --git a/Source/Core/Rendering/VisualVertexHandle.cs b/Source/Core/Rendering/VisualVertexHandle.cs index 68cd81b7..f8e87efe 100755 --- a/Source/Core/Rendering/VisualVertexHandle.cs +++ b/Source/Core/Rendering/VisualVertexHandle.cs @@ -2,7 +2,6 @@ using System; using CodeImp.DoomBuilder.VisualModes; -using SlimDX.Direct3D9; #endregion @@ -85,7 +84,7 @@ namespace CodeImp.DoomBuilder.Rendering v2, v3, v3, v0 }; - upper = new VertexBuffer(WorldVertex.Stride * vu.Length, Usage.WriteOnly | Usage.Dynamic, VertexFormat.None, Pool.Default); + upper = new VertexBuffer(WorldVertex.Stride * vu.Length, Usage.WriteOnly | Usage.Dynamic, Pool.Default); upper.Lock(0, WorldVertex.Stride * vu.Length, LockFlags.None).WriteRange(vu); upper.Unlock(); @@ -99,7 +98,7 @@ namespace CodeImp.DoomBuilder.Rendering v6, v7, v7, v4 }; - lower = new VertexBuffer(WorldVertex.Stride * vl.Length, Usage.WriteOnly | Usage.Dynamic, VertexFormat.None, Pool.Default); + lower = new VertexBuffer(WorldVertex.Stride * vl.Length, Usage.WriteOnly | Usage.Dynamic, Pool.Default); lower.Lock(0, WorldVertex.Stride * vl.Length, LockFlags.None).WriteRange(vl); lower.Unlock(); } diff --git a/Source/Core/Rendering/World3DShader.cs b/Source/Core/Rendering/World3DShader.cs index c860ca5d..172ea939 100755 --- a/Source/Core/Rendering/World3DShader.cs +++ b/Source/Core/Rendering/World3DShader.cs @@ -17,7 +17,6 @@ #region ================== Namespaces using System; -using SlimDX.Direct3D9; using SlimDX; #endregion @@ -305,11 +304,10 @@ namespace CodeImp.DoomBuilder.Rendering // Initialize world vertex declaration VertexElement[] ve = { - new VertexElement(0, 0, DeclarationType.Float3, DeclarationMethod.Default, DeclarationUsage.Position, 0), - new VertexElement(0, 12, DeclarationType.Color, DeclarationMethod.Default, DeclarationUsage.Color, 0), - new VertexElement(0, 16, DeclarationType.Float2, DeclarationMethod.Default, DeclarationUsage.TextureCoordinate, 0), - new VertexElement(0, 24, DeclarationType.Float3, DeclarationMethod.Default, DeclarationUsage.Normal, 0), //mxd - VertexElement.VertexDeclarationEnd + new VertexElement(0, 0, DeclarationType.Float3, DeclarationUsage.Position), + new VertexElement(0, 12, DeclarationType.Color, DeclarationUsage.Color), + new VertexElement(0, 16, DeclarationType.Float2, DeclarationUsage.TextureCoordinate), + new VertexElement(0, 24, DeclarationType.Float3, DeclarationUsage.Normal) }; vertexdecl = new VertexDeclaration(ve); diff --git a/Source/Core/SlimDX.cs b/Source/Core/SlimDX.cs index fc5c6800..bc7d3b52 100644 --- a/Source/Core/SlimDX.cs +++ b/Source/Core/SlimDX.cs @@ -2,208 +2,6 @@ namespace SlimDX { - #region High level mesh rendering - namespace Direct3D9 - { - public class Mesh - { - public Mesh(int indexCount, int vertexCount, MeshFlags flags, VertexElement[] elements) { } - - public VertexBuffer VertexBuffer { get; private set; } - public IndexBuffer IndexBuffer { get; private set; } - - public DataStream LockVertexBuffer(LockFlags flags) { return null; } - public DataStream LockIndexBuffer(LockFlags flags) { return null; } - public void UnlockVertexBuffer() { } - public void UnlockIndexBuffer() { } - - public void DrawSubset(int index) { } - - public void Dispose() { } - } - - public class Effect - { - public static Effect FromStream(System.IO.Stream stream, ShaderFlags flags, out string errors) { errors = ""; return null; } - - public void SetTexture(EffectHandle handle, BaseTexture texture) { } - public void SetValue(EffectHandle handle, T value) where T : struct { } - public EffectHandle GetParameter(EffectHandle parameter, string name) { return null; } - public string Technique { set; private get; } - public void CommitChanges() { } - - public void Begin() { } - public void BeginPass(int index) { } - public void EndPass() { } - public void End() { } - - public void Dispose() { } - } - - public class EffectHandle - { - public void Dispose() { } - } - } - #endregion - - #region Vertex buffer format / Input assembly - namespace Direct3D9 - { - public class VertexDeclaration - { - public VertexDeclaration(VertexElement[] elements) { } - public void Dispose() { } - } - - public struct VertexElement - { - public VertexElement(short stream, short offset, DeclarationType type, DeclarationMethod method, DeclarationUsage usage, byte usageIndex) { } - public static readonly VertexElement VertexDeclarationEnd; - } - } - #endregion - - #region Buffer objects - namespace Direct3D9 - { - public class VertexBuffer - { - public VertexBuffer(int sizeInBytes, Usage usage, VertexFormat format, Pool pool) { } - - public DataStream Lock(int offset, int size, LockFlags flags) { return null; } - public void Unlock() { } - - public object Tag { get; set; } - - public bool Disposed { get; private set; } - public void Dispose() { Disposed = true; } - } - - public class IndexBuffer - { - public DataStream Lock(int offset, int size, LockFlags flags) { return null; } - public void Unlock() { } - - public object Tag { get; set; } - - public bool Disposed { get; private set; } - public void Dispose() { Disposed = true; } - } - } - #endregion - - #region Images (textures and surfaces) - namespace Direct3D9 - { - public class BaseTexture - { - public bool Disposed { get; } - public void Dispose() { } - } - - public class Texture : BaseTexture - { - public Texture(int width, int height, int levels, Usage usage, Format format, Pool pool) { } - - public int Width { get; private set; } - public int Height { get; private set; } - - public object Tag { get; set; } - - public DataRectangle LockRectangle(int level, LockFlags flags) { return null; } - public void UnlockRectangle(int level) { } - - public static Texture FromStream(System.IO.Stream stream) { return null; } - public static Texture FromStream(System.IO.Stream stream, int length, int width, int height, int levels, Usage usage, Format format, Pool pool) { return null; } - } - - public class CubeTexture : BaseTexture - { - public CubeTexture(int size, int levels, Usage usage, Format format, Pool pool) { } - - public DataRectangle LockRectangle(CubeMapFace face, int level, LockFlags flags) { return null; } - public void UnlockRectangle(CubeMapFace face, int level) { } - } - } - #endregion - - #region Locked buffer writing and reading - public class DataRectangle - { - public DataRectangle(int pitch, DataStream s) { Data = s; Pitch = pitch; } - public DataStream Data { get; private set; } - public int Pitch { get; private set; } - } - - public class DataStream : IDisposable - { - public void Seek(long offset, System.IO.SeekOrigin origin) { } - public void Write(ushort v) { } - public void Write(Array data, long offset, long size) { } - public void WriteRange(Array data) { } - public void WriteRange(Array data, long offset, long size) { } - public void WriteRange(IntPtr data, long size) { } - public void Dispose() { } - - public void ReadRange(Array data, long offset, long size) { } - - public bool CanRead { get; private set; } - public bool CanWrite { get; private set; } - public long Length { get; private set; } - public IntPtr DataPointer { get; private set; } - } - #endregion - - #region Enumerations - namespace Direct3D9 - { - public enum RenderState - { - AlphaBlendEnable, - AlphaFunc, - AlphaRef, - AlphaTestEnable, - CullMode, - BlendOperation, - SourceBlend, - DestinationBlend, - FillMode, - FogEnable, - FogColor, - FogStart, - FogEnd, - MultisampleAntialias, - TextureFactor, - ZEnable, - ZWriteEnable - } - - public enum Compare { GreaterEqual } - public enum Cull { None, Counterclockwise } - public enum Blend { InverseSourceAlpha, SourceAlpha, One, BlendFactor } - public enum BlendOperation { Add, ReverseSubtract } - public enum FillMode { Solid, Wireframe } - public enum TransformState { World, View, Projection } - public enum SamplerState { AddressU, AddressV, AddressW } - public enum TextureAddress { Wrap, Clamp } - public enum ClearFlags { Target, ZBuffer } - public enum Format { Unknown, A8R8G8B8 } - public enum Usage { None, WriteOnly, Dynamic, RenderTarget } - public enum VertexFormat { None } - public enum Pool { Default, Managed, SystemMemory } - public enum LockFlags { None, Discard } - public enum MeshFlags { Use32Bit, IndexBufferManaged, VertexBufferManaged, Managed } - public enum ShaderFlags { None, Debug } - public enum PrimitiveType { LineList, TriangleList, TriangleStrip } - public enum CubeMapFace { PositiveX, PositiveY, PositiveZ, NegativeX, NegativeY, NegativeZ } - public enum TextureFilter { None, Point, Linear, Anisotropic } - public enum DeclarationType { Float2, Float3, Color } - public enum DeclarationMethod { Default } - public enum DeclarationUsage { Position, Color, TextureCoordinate, Normal } - } - #endregion - #region Matrix, vector, color public struct Matrix { @@ -502,6 +300,10 @@ namespace SlimDX public MouseState GetCurrentState() { return null; } public void Dispose() { } } + + public class DirectInputException : ApplicationException + { + } } #endregion @@ -519,13 +321,4 @@ namespace SlimDX public static StopWatch Timer { get; set; } } #endregion - - #region Exceptions - namespace DirectInput - { - public class DirectInputException : ApplicationException - { - } - } - #endregion } diff --git a/Source/Core/VisualModes/VisualSector.cs b/Source/Core/VisualModes/VisualSector.cs index dc29185a..95c3c73a 100755 --- a/Source/Core/VisualModes/VisualSector.cs +++ b/Source/Core/VisualModes/VisualSector.cs @@ -19,7 +19,6 @@ using System; using System.Collections.Generic; using CodeImp.DoomBuilder.Map; -using SlimDX.Direct3D9; using SlimDX; using CodeImp.DoomBuilder.Rendering; @@ -139,7 +138,7 @@ namespace CodeImp.DoomBuilder.VisualModes if(numverts > 0) { // Make a new buffer - geobuffer = new VertexBuffer(WorldVertex.Stride * numverts, Usage.WriteOnly | Usage.Dynamic, VertexFormat.None, Pool.Default); + geobuffer = new VertexBuffer(WorldVertex.Stride * numverts, Usage.WriteOnly | Usage.Dynamic, Pool.Default); // Fill the buffer DataStream bufferstream = geobuffer.Lock(0, WorldVertex.Stride * numverts, LockFlags.Discard); diff --git a/Source/Core/VisualModes/VisualThing.cs b/Source/Core/VisualModes/VisualThing.cs index 26601e7c..60e66f65 100755 --- a/Source/Core/VisualModes/VisualThing.cs +++ b/Source/Core/VisualModes/VisualThing.cs @@ -25,7 +25,6 @@ using CodeImp.DoomBuilder.GZBuilder.Data; //mxd using CodeImp.DoomBuilder.Map; using CodeImp.DoomBuilder.Rendering; using SlimDX; -using SlimDX.Direct3D9; using Plane = CodeImp.DoomBuilder.Geometry.Plane; using CodeImp.DoomBuilder.GZBuilder; @@ -527,7 +526,7 @@ namespace CodeImp.DoomBuilder.VisualModes for(int i = 0; i < vertices.Length; i++) { // Make a new buffer - geobuffers[i] = new VertexBuffer(WorldVertex.Stride * vertices[i].Length, Usage.WriteOnly | Usage.Dynamic, VertexFormat.None, Pool.Default); + geobuffers[i] = new VertexBuffer(WorldVertex.Stride * vertices[i].Length, Usage.WriteOnly | Usage.Dynamic, Pool.Default); // Fill the buffer DataStream bufferstream = geobuffers[i].Lock(0, WorldVertex.Stride * vertices[i].Length, LockFlags.Discard); @@ -617,7 +616,7 @@ namespace CodeImp.DoomBuilder.VisualModes // Create buffer WorldVertex[] cv = cageverts.ToArray(); cagelength = cv.Length / 2; - cagebuffer = new VertexBuffer(WorldVertex.Stride * cv.Length, Usage.WriteOnly | Usage.Dynamic, VertexFormat.None, Pool.Default); + cagebuffer = new VertexBuffer(WorldVertex.Stride * cv.Length, Usage.WriteOnly | Usage.Dynamic, Pool.Default); cagebuffer.Lock(0, WorldVertex.Stride * cv.Length, LockFlags.None).WriteRange(cv); cagebuffer.Unlock();