diff --git a/Source/Core/Data/DataManager.cs b/Source/Core/Data/DataManager.cs index b5e480ca..88efde5e 100755 --- a/Source/Core/Data/DataManager.cs +++ b/Source/Core/Data/DataManager.cs @@ -3425,7 +3425,7 @@ namespace CodeImp.DoomBuilder.Data // Make custom rendertarget const int cubemaptexsize = 1024; - Texture rendertarget = new Texture(cubemaptexsize, cubemaptexsize, 1, Usage.RenderTarget, Format.A8R8G8B8, Pool.Default); + Texture rendertarget = new Texture(cubemaptexsize, cubemaptexsize, 1, Format.A8R8G8B8); // Start rendering General.Map.Graphics.StartRendering(true, new Color4(), rendertarget, true); @@ -3453,7 +3453,7 @@ namespace CodeImp.DoomBuilder.Data yscale *= 1.65f; // Make cubemap texture - CubeTexture cubemap = new CubeTexture(cubemaptexsize, 1, Usage.None, Format.A8R8G8B8, Pool.Managed); + CubeTexture cubemap = new CubeTexture(cubemaptexsize, 1, Format.A8R8G8B8); // Set render settings... General.Map.Graphics.SetRenderState(RenderState.ZEnable, false); @@ -3653,7 +3653,7 @@ namespace CodeImp.DoomBuilder.Data // sides[] must contain 6 square Po2 images in this order: North, East, South, West, Top, Bottom private static CubeTexture MakeSkyBox(Bitmap[] sides, int targetsize, bool fliptop) { - CubeTexture cubemap = new CubeTexture(targetsize, 1, Usage.None, Format.A8R8G8B8, Pool.Managed); + CubeTexture cubemap = new CubeTexture(targetsize, 1, Format.A8R8G8B8); // Draw faces sides[3].RotateFlip(RotateFlipType.Rotate90FlipNone); @@ -3679,21 +3679,7 @@ namespace CodeImp.DoomBuilder.Data private static void DrawCubemapFace(CubeTexture texture, CubeMapFace face, Bitmap image) { - DataRectangle rect = texture.LockRectangle(face, 0, LockFlags.None); - - if(rect.Data.CanWrite) - { - BitmapData data = image.LockBits(new Rectangle(0, 0, image.Width, image.Height), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb); - int len = Math.Abs(data.Stride) * image.Height; - rect.Data.WriteRange(data.Scan0, len); - image.UnlockBits(data); - } - else - { - General.ErrorLogger.Add(ErrorType.Error, "Skybox creation failed: CubeTexture is unwritable..."); - } - - texture.UnlockRectangle(face, 0); + texture.SetPixels(face, image); } private static Bitmap ResizeImage(Image image, int width, int height) @@ -3774,7 +3760,7 @@ namespace CodeImp.DoomBuilder.Data // Classic skies textures can be NPo2 (and D3D Texture is resized to Po2 by default), // so we need to explicitly specify the size - return Texture.FromStream(ms, (int) ms.Length, image.Size.Width, image.Size.Height, 0, Usage.None, Format.Unknown, Pool.Managed); + return Texture.FromStream(ms, (int) ms.Length, image.Size.Width, image.Size.Height, 0, Format.Unknown); } } diff --git a/Source/Core/Data/ImageData.cs b/Source/Core/Data/ImageData.cs index 3a9de68c..663ff8e7 100755 --- a/Source/Core/Data/ImageData.cs +++ b/Source/Core/Data/ImageData.cs @@ -474,11 +474,11 @@ namespace CodeImp.DoomBuilder.Data memstream.Seek(0, SeekOrigin.Begin); if(dynamictexture) { - texture = Texture.FromStream(memstream, (int)memstream.Length, img.Size.Width, img.Size.Height, mipmaplevels, Usage.Dynamic, Format.A8R8G8B8, Pool.Default); + texture = Texture.FromStream(memstream, (int)memstream.Length, img.Size.Width, img.Size.Height, mipmaplevels, Format.A8R8G8B8); } else { - texture = Texture.FromStream(memstream, (int)memstream.Length, img.Size.Width, img.Size.Height, mipmaplevels, Usage.None, Format.Unknown, Pool.Managed); + texture = Texture.FromStream(memstream, (int)memstream.Length, img.Size.Width, img.Size.Height, mipmaplevels, Format.Unknown); } memstream.Dispose(); @@ -505,30 +505,7 @@ namespace CodeImp.DoomBuilder.Data { if((texture != null) && !texture.Disposed) { - // Lock the bitmap and texture - BitmapData bmpdata = bitmap.LockBits(new Rectangle(0, 0, bitmap.Size.Width, bitmap.Size.Height), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb); - DataRectangle texdata = texture.LockRectangle(0, LockFlags.Discard); - - // Copy data - int* bp = (int*)bmpdata.Scan0.ToPointer(); - int* tp = (int*)texdata.Data.DataPointer.ToPointer(); - for(int y = 0; y < bmpdata.Height; y++) - { - for(int x = 0; x < bmpdata.Width; x++) - { - *tp = *bp; - bp++; - tp++; - } - - // Skip extra data in texture - int extrapitch = (texdata.Pitch >> 2) - bmpdata.Width; - tp += extrapitch; - } - - // Unlock - texture.UnlockRectangle(0); - bitmap.UnlockBits(bmpdata); + texture.SetPixels(bitmap); } } } diff --git a/Source/Core/GZBuilder/md3/ModelReader.cs b/Source/Core/GZBuilder/md3/ModelReader.cs index a7dee252..9373df98 100755 --- a/Source/Core/GZBuilder/md3/ModelReader.cs +++ b/Source/Core/GZBuilder/md3/ModelReader.cs @@ -991,17 +991,17 @@ namespace CodeImp.DoomBuilder.GZBuilder.MD3 //mesh Mesh mesh = new Mesh(polyIndecesList.Count / 3, vertList.Count, MeshFlags.Use32Bit | MeshFlags.IndexBufferManaged | MeshFlags.VertexBufferManaged, vertexElements); - using(DataStream stream = mesh.LockVertexBuffer(LockFlags.None)) + using(DataStream stream = mesh.VertexBuffer.Lock(LockFlags.None)) { stream.WriteRange(vertList.ToArray()); } - mesh.UnlockVertexBuffer(); + mesh.VertexBuffer.Unlock(); - using(DataStream stream = mesh.LockIndexBuffer(LockFlags.None)) + using(DataStream stream = mesh.IndexBuffer.Lock(LockFlags.None)) { stream.WriteRange(polyIndecesList.ToArray()); } - mesh.UnlockIndexBuffer(); + mesh.IndexBuffer.Unlock(); //store in result result.Meshes.Add(mesh); @@ -1177,7 +1177,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.MD3 using(Bitmap bmp = CreateVoxelTexture(palette)) bmp.Save(memstream, ImageFormat.Bmp); memstream.Seek(0, SeekOrigin.Begin); - Texture texture = Texture.FromStream(memstream, (int)memstream.Length, 64, 64, 0, Usage.None, Format.Unknown, Pool.Managed); + Texture texture = Texture.FromStream(memstream, (int)memstream.Length, 64, 64, 0, Format.Unknown); memstream.Dispose(); // Add texture @@ -1189,11 +1189,11 @@ namespace CodeImp.DoomBuilder.GZBuilder.MD3 Mesh mesh = new Mesh(facescount, verts.Count, meshflags, vertexElements); - DataStream mstream = mesh.VertexBuffer.Lock(0, 0, LockFlags.None); + DataStream mstream = mesh.VertexBuffer.Lock(LockFlags.None); mstream.WriteRange(verts.ToArray()); mesh.VertexBuffer.Unlock(); - mstream = mesh.IndexBuffer.Lock(0, 0, LockFlags.None); + mstream = mesh.IndexBuffer.Lock(LockFlags.None); if(indices.Count > ushort.MaxValue - 1) mstream.WriteRange(indices.ToArray()); @@ -1703,14 +1703,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.MD3 if(bitmap != null) { - BitmapData bmlock = bitmap.LockBits(new Rectangle(0, 0, bitmap.Width, bitmap.Height), ImageLockMode.ReadOnly, bitmap.PixelFormat); - texture = new Texture(bitmap.Width, bitmap.Height, 1, Usage.None, Format.A8R8G8B8, Pool.Managed); - - DataRectangle textureLock = texture.LockRectangle(0, LockFlags.None); - textureLock.Data.WriteRange(bmlock.Scan0, bmlock.Height * bmlock.Stride); - - bitmap.UnlockBits(bmlock); - texture.UnlockRectangle(0); + texture.SetPixels(bitmap); } } else @@ -1728,17 +1721,17 @@ namespace CodeImp.DoomBuilder.GZBuilder.MD3 //create mesh Mesh mesh = new Mesh(indices.Count / 3, verts.Count, MeshFlags.Use32Bit | MeshFlags.IndexBufferManaged | MeshFlags.VertexBufferManaged, vertexElements); - using (DataStream stream = mesh.LockVertexBuffer(LockFlags.None)) + using (DataStream stream = mesh.VertexBuffer.Lock(LockFlags.None)) { stream.WriteRange(verts.ToArray()); } - mesh.UnlockVertexBuffer(); + mesh.VertexBuffer.Unlock(); - using(DataStream stream = mesh.LockIndexBuffer(LockFlags.None)) + using(DataStream stream = mesh.IndexBuffer.Lock(LockFlags.None)) { stream.WriteRange(indices.ToArray()); } - mesh.UnlockIndexBuffer(); + mesh.IndexBuffer.Unlock(); //store in result result.Meshes.Add(mesh); diff --git a/Source/Core/Rendering/D3DDevice.cs b/Source/Core/Rendering/D3DDevice.cs index 14c81e83..49fd3557 100755 --- a/Source/Core/Rendering/D3DDevice.cs +++ b/Source/Core/Rendering/D3DDevice.cs @@ -36,11 +36,6 @@ namespace CodeImp.DoomBuilder.Rendering 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() { } @@ -53,7 +48,6 @@ namespace CodeImp.DoomBuilder.Rendering 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() { } @@ -86,8 +80,9 @@ namespace CodeImp.DoomBuilder.Rendering #region Buffer objects public class VertexBuffer { - public VertexBuffer(int sizeInBytes, Usage usage, Pool pool) { } + public VertexBuffer(int sizeInBytes) { } + public DataStream Lock(LockFlags flags) { return null; } public DataStream Lock(int offset, int size, LockFlags flags) { return null; } public void Unlock() { } @@ -99,72 +94,69 @@ namespace CodeImp.DoomBuilder.Rendering public class IndexBuffer { - public DataStream Lock(int offset, int size, LockFlags flags) { return null; } + public DataStream Lock(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() { } + } + #endregion - public void ReadRange(Array data, long offset, long size) { } + #region Textures + public class BaseTexture + { + public bool Disposed { get; private set; } + public void Dispose() { Disposed = true; } + } - public bool CanRead { get; private set; } - public bool CanWrite { get; private set; } - public long Length { get; private set; } - public IntPtr DataPointer { get; private set; } + public class Texture : BaseTexture + { + public Texture(int width, int height, int levels, Format format) { } + + public int Width { get; private set; } + public int Height { get; private set; } + + public object Tag { get; set; } + + public void SetPixels(System.Drawing.Bitmap bitmap) + { + /* + BitmapData bmpdata = bitmap.LockBits(new Rectangle(0, 0, bitmap.Size.Width, bitmap.Size.Height), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb); + + DataRectangle textureLock = texture.LockRectangle(0, LockFlags.None); + textureLock.Data.WriteRange(bmlock.Scan0, bmlock.Height * bmlock.Stride); + texture.UnlockRectangle(0); + + bitmap.UnlockBits(bmpdata); + */ + } + + internal Plotter LockPlotter(int visibleWidth, int visibleHeight) + { + //return new Plotter((PixelColor*)plotlocked.Data.DataPointer.ToPointer(), plotlocked.Pitch / sizeof(PixelColor), Height, visibleWidth, visibleHeight); + return null; + } + + public void UnlockPlotter() { } + + 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, Format format) { return null; } + } + + public class CubeTexture : BaseTexture + { + public CubeTexture(int size, int levels, Format format) { } + + public void SetPixels(CubeMapFace face, System.Drawing.Bitmap bitmap) { } } #endregion @@ -197,8 +189,6 @@ namespace CodeImp.DoomBuilder.Rendering 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 } diff --git a/Source/Core/Rendering/D3DShader.cs b/Source/Core/Rendering/D3DShader.cs index 23925c56..2f22811f 100755 --- a/Source/Core/Rendering/D3DShader.cs +++ b/Source/Core/Rendering/D3DShader.cs @@ -143,9 +143,6 @@ namespace CodeImp.DoomBuilder.Rendering fxdata.Dispose(); - // Set the technique to use - fx.Technique = manager.ShaderTechnique; - // Return result return fx; } diff --git a/Source/Core/Rendering/Renderer2D.cs b/Source/Core/Rendering/Renderer2D.cs index 4e4f79e2..78a08db3 100755 --- a/Source/Core/Rendering/Renderer2D.cs +++ b/Source/Core/Rendering/Renderer2D.cs @@ -67,9 +67,6 @@ namespace CodeImp.DoomBuilder.Rendering private Texture overlaytex; private Texture surfacetex; - // Locking data - private DataRectangle plotlocked; - // Rendertarget sizes private Size windowsize; private Size structsize; @@ -365,11 +362,11 @@ namespace CodeImp.DoomBuilder.Rendering windowsize.Height = graphics.RenderTarget.ClientSize.Height; // Create rendertargets textures - plottertex = new Texture(windowsize.Width, windowsize.Height, 1, Usage.None, Format.A8R8G8B8, Pool.Managed); - thingstex = new Texture(windowsize.Width, windowsize.Height, 1, Usage.RenderTarget, Format.A8R8G8B8, Pool.Default); - backtex = new Texture(windowsize.Width, windowsize.Height, 1, Usage.None, Format.A8R8G8B8, Pool.Managed); - overlaytex = new Texture(windowsize.Width, windowsize.Height, 1, Usage.RenderTarget, Format.A8R8G8B8, Pool.Default); - surfacetex = new Texture(windowsize.Width, windowsize.Height, 1, Usage.RenderTarget, Format.A8R8G8B8, Pool.Default); + plottertex = new Texture(windowsize.Width, windowsize.Height, 1, Format.A8R8G8B8); + thingstex = new Texture(windowsize.Width, windowsize.Height, 1, Format.A8R8G8B8); + backtex = new Texture(windowsize.Width, windowsize.Height, 1, Format.A8R8G8B8); + overlaytex = new Texture(windowsize.Width, windowsize.Height, 1, Format.A8R8G8B8); + surfacetex = new Texture(windowsize.Width, windowsize.Height, 1, Format.A8R8G8B8); // Get the real surface sizes structsize.Width = plottertex.Width; @@ -391,11 +388,11 @@ 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, Pool.Default); - thingsvertices = new VertexBuffer(THING_BUFFER_SIZE * 12 * sizeof(FlatVertex), Usage.Dynamic | Usage.WriteOnly, Pool.Default); + screenverts = new VertexBuffer(4 * sizeof(FlatVertex)); + thingsvertices = new VertexBuffer(THING_BUFFER_SIZE * 12 * sizeof(FlatVertex)); // Make screen vertices - DataStream stream = screenverts.Lock(0, 4 * sizeof(FlatVertex), LockFlags.Discard); + DataStream stream = screenverts.Lock(LockFlags.Discard); FlatVertex[] verts = CreateScreenVerts(structsize); stream.WriteRange(verts); screenverts.Unlock(); @@ -636,11 +633,8 @@ namespace CodeImp.DoomBuilder.Rendering // Rendertargets available? if(plottertex != null) { - // Lock structures rendertarget memory - plotlocked = plottertex.LockRectangle(0, LockFlags.None); - // Create structures plotter - plotter = new Plotter((PixelColor*)plotlocked.Data.DataPointer.ToPointer(), plotlocked.Pitch / sizeof(PixelColor), structsize.Height, structsize.Width, structsize.Height); + plotter = plottertex.LockPlotter(structsize.Width, structsize.Height); // Redraw grid when structures image was cleared if(clear) @@ -726,8 +720,7 @@ namespace CodeImp.DoomBuilder.Rendering // Clean up plotter if(renderlayer == RenderLayers.Plotter) { - if(plottertex != null) plottertex.UnlockRectangle(0); - if(plotlocked.Data != null) plotlocked.Data.Dispose(); + if(plottertex != null) plottertex.UnlockPlotter(); plotter = null; } @@ -795,11 +788,8 @@ namespace CodeImp.DoomBuilder.Rendering if(lastgridsize != General.Map.Grid.GridSizeF || lastgridscale != scale || lastgridx != offsetx || lastgridy != offsety || drawmapcenter != lastdrawmapcenter) { - // Lock background rendertarget memory - DataRectangle lockedrect = backtex.LockRectangle(0, LockFlags.None); - // Create a plotter - Plotter gridplotter = new Plotter((PixelColor*)lockedrect.Data.DataPointer.ToPointer(), lockedrect.Pitch / sizeof(PixelColor), backsize.Height, backsize.Width, backsize.Height); + Plotter gridplotter = backtex.LockPlotter(backsize.Width, backsize.Height); gridplotter.Clear(); if(General.Settings.RenderGrid) //mxd @@ -853,8 +843,7 @@ namespace CodeImp.DoomBuilder.Rendering } // Done - backtex.UnlockRectangle(0); - lockedrect.Data.Dispose(); + backtex.UnlockPlotter(); lastgridscale = scale; lastgridsize = General.Map.Grid.GridSizeF; lastgridx = offsetx; @@ -2008,8 +1997,8 @@ namespace CodeImp.DoomBuilder.Rendering } // Write to buffer - 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); + VertexBuffer vb = new VertexBuffer(FlatVertex.Stride * verts.Length); + DataStream s = vb.Lock(LockFlags.Discard); s.WriteRange(verts); vb.Unlock(); s.Dispose(); diff --git a/Source/Core/Rendering/Renderer3D.cs b/Source/Core/Rendering/Renderer3D.cs index 59707c3d..d4ac647b 100755 --- a/Source/Core/Rendering/Renderer3D.cs +++ b/Source/Core/Rendering/Renderer3D.cs @@ -720,8 +720,8 @@ namespace CodeImp.DoomBuilder.Rendering } } - 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); + VertexBuffer vb = new VertexBuffer(WorldVertex.Stride * verts.Length); + DataStream s = vb.Lock(LockFlags.Discard); s.WriteRange(verts); vb.Unlock(); s.Dispose(); diff --git a/Source/Core/Rendering/ShaderManager.cs b/Source/Core/Rendering/ShaderManager.cs index e0efb40d..4a8325f2 100755 --- a/Source/Core/Rendering/ShaderManager.cs +++ b/Source/Core/Rendering/ShaderManager.cs @@ -30,9 +30,6 @@ namespace CodeImp.DoomBuilder.Rendering #region ================== Variables - // Settings - private readonly string shadertechnique; - // Shaders private Display2DShader display2dshader; private Things2DShader things2dshader; @@ -48,7 +45,6 @@ namespace CodeImp.DoomBuilder.Rendering #region ================== Properties - public string ShaderTechnique { get { return shadertechnique; } } public Display2DShader Display2D { get { return display2dshader; } } public Things2DShader Things2D { get { return things2dshader; } } public World3DShader World3D { get { return world3dshader; } } @@ -64,7 +60,6 @@ namespace CodeImp.DoomBuilder.Rendering { // Initialize this.device = device; - shadertechnique = "SM20"; //mxd // Load ReloadResource(); diff --git a/Source/Core/Rendering/SurfaceManager.cs b/Source/Core/Rendering/SurfaceManager.cs index e63973ba..30a6a3dd 100755 --- a/Source/Core/Rendering/SurfaceManager.cs +++ b/Source/Core/Rendering/SurfaceManager.cs @@ -140,10 +140,10 @@ 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, Pool.Default); + VertexBuffer b = new VertexBuffer(FlatVertex.Stride * set.Value.buffersizes[i]); // Start refilling the buffer with sector geometry - DataStream bstream = b.Lock(0, FlatVertex.Stride * set.Value.buffersizes[i], LockFlags.Discard); + DataStream bstream = b.Lock(LockFlags.Discard); foreach(SurfaceEntry e in set.Value.entries) { if(e.bufferindex == i) @@ -280,7 +280,7 @@ namespace CodeImp.DoomBuilder.Rendering if(!resourcesunloaded) { // Make the new buffer! - vb = new VertexBuffer(FlatVertex.Stride * buffernumvertices, Usage.WriteOnly | Usage.Dynamic, Pool.Default); + vb = new VertexBuffer(FlatVertex.Stride * buffernumvertices); // Add it. set.buffers.Add(vb); @@ -331,8 +331,8 @@ namespace CodeImp.DoomBuilder.Rendering if(!resourcesunloaded) { // Make the new buffer and lock it - vb = new VertexBuffer(FlatVertex.Stride * buffernumvertices, Usage.WriteOnly | Usage.Dynamic, Pool.Default); - bstream = vb.Lock(0, FlatVertex.Stride * theseentries.Count * verticesperentry, LockFlags.Discard); + vb = new VertexBuffer(FlatVertex.Stride * buffernumvertices); + bstream = vb.Lock(LockFlags.Discard); } // Start refilling the buffer with sector geometry diff --git a/Source/Core/Rendering/TextLabel.cs b/Source/Core/Rendering/TextLabel.cs index f7b17afe..1ef8cf4b 100755 --- a/Source/Core/Rendering/TextLabel.cs +++ b/Source/Core/Rendering/TextLabel.cs @@ -336,17 +336,17 @@ namespace CodeImp.DoomBuilder.Rendering img.Save(memstream, ImageFormat.Bmp); memstream.Seek(0, SeekOrigin.Begin); - texture = Texture.FromStream(memstream, (int)memstream.Length, img.Size.Width, img.Size.Height, 1, Usage.None, Format.Unknown, Pool.Managed); + texture = Texture.FromStream(memstream, (int)memstream.Length, img.Size.Width, img.Size.Height, 1, Format.Unknown); } //mxd. Create the buffer if(textbuffer == null || textbuffer.Disposed) { - textbuffer = new VertexBuffer(4 * FlatVertex.Stride, Usage.Dynamic | Usage.WriteOnly, Pool.Default); + textbuffer = new VertexBuffer(4 * FlatVertex.Stride); } //mxd. Lock the buffer - using(DataStream stream = textbuffer.Lock(0, 4 * FlatVertex.Stride, LockFlags.Discard)) + using(DataStream stream = textbuffer.Lock(LockFlags.Discard)) { FlatQuad quad = new FlatQuad(PrimitiveType.TriangleStrip, beginx, beginy, beginx + texturesize.Width, beginy + texturesize.Height); stream.WriteRange(quad.Vertices); diff --git a/Source/Core/Rendering/VisualVertexHandle.cs b/Source/Core/Rendering/VisualVertexHandle.cs index f8e87efe..01908a3a 100755 --- a/Source/Core/Rendering/VisualVertexHandle.cs +++ b/Source/Core/Rendering/VisualVertexHandle.cs @@ -84,8 +84,8 @@ namespace CodeImp.DoomBuilder.Rendering v2, v3, v3, v0 }; - 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 = new VertexBuffer(WorldVertex.Stride * vu.Length); + upper.Lock(LockFlags.None).WriteRange(vu); upper.Unlock(); WorldVertex[] vl = new[]{ c, v4, @@ -98,8 +98,8 @@ namespace CodeImp.DoomBuilder.Rendering v6, v7, v7, v4 }; - 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 = new VertexBuffer(WorldVertex.Stride * vl.Length); + lower.Lock(LockFlags.None).WriteRange(vl); lower.Unlock(); } diff --git a/Source/Core/VisualModes/VisualSector.cs b/Source/Core/VisualModes/VisualSector.cs index 95c3c73a..253e9a9b 100755 --- a/Source/Core/VisualModes/VisualSector.cs +++ b/Source/Core/VisualModes/VisualSector.cs @@ -138,10 +138,10 @@ namespace CodeImp.DoomBuilder.VisualModes if(numverts > 0) { // Make a new buffer - geobuffer = new VertexBuffer(WorldVertex.Stride * numverts, Usage.WriteOnly | Usage.Dynamic, Pool.Default); + geobuffer = new VertexBuffer(WorldVertex.Stride * numverts); // Fill the buffer - DataStream bufferstream = geobuffer.Lock(0, WorldVertex.Stride * numverts, LockFlags.Discard); + DataStream bufferstream = geobuffer.Lock(LockFlags.Discard); foreach(VisualGeometry g in allgeometry) { if((g.Vertices != null) && (g.Vertices.Length > 0)) diff --git a/Source/Core/VisualModes/VisualThing.cs b/Source/Core/VisualModes/VisualThing.cs index 60e66f65..1fa4bb04 100755 --- a/Source/Core/VisualModes/VisualThing.cs +++ b/Source/Core/VisualModes/VisualThing.cs @@ -526,10 +526,10 @@ 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, Pool.Default); + geobuffers[i] = new VertexBuffer(WorldVertex.Stride * vertices[i].Length); // Fill the buffer - DataStream bufferstream = geobuffers[i].Lock(0, WorldVertex.Stride * vertices[i].Length, LockFlags.Discard); + DataStream bufferstream = geobuffers[i].Lock(LockFlags.Discard); bufferstream.WriteRange(vertices[i]); geobuffers[i].Unlock(); bufferstream.Dispose(); @@ -616,8 +616,8 @@ 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, Pool.Default); - cagebuffer.Lock(0, WorldVertex.Stride * cv.Length, LockFlags.None).WriteRange(cv); + cagebuffer = new VertexBuffer(WorldVertex.Stride * cv.Length); + cagebuffer.Lock(LockFlags.None).WriteRange(cv); cagebuffer.Unlock(); // Done