From a7c2f5bb29954f0f6f342580688d250ef5daab13 Mon Sep 17 00:00:00 2001 From: David Allemang Date: Sun, 26 Feb 2017 23:17:21 -0500 Subject: [PATCH] Rename Buffer to GLBuffer to prevent name conflict. --- Diamond/Buffers/{Buffer.cs => GLBuffer.cs} | 4 +-- Diamond/Diamond.csproj | 2 +- Diamond/Shaders/Program.cs | 3 +-- hexworld/HexRender.cs | 30 +++++++++------------- 4 files changed, 16 insertions(+), 23 deletions(-) rename Diamond/Buffers/{Buffer.cs => GLBuffer.cs} (89%) diff --git a/Diamond/Buffers/Buffer.cs b/Diamond/Buffers/GLBuffer.cs similarity index 89% rename from Diamond/Buffers/Buffer.cs rename to Diamond/Buffers/GLBuffer.cs index b917bbf..6537e4b 100644 --- a/Diamond/Buffers/Buffer.cs +++ b/Diamond/Buffers/GLBuffer.cs @@ -8,12 +8,12 @@ using OpenTK.Graphics.OpenGL4; namespace Diamond.Buffers { - public class Buffer : GLObject + public class GLBuffer : GLObject { public readonly BufferTarget Target; public readonly BufferUsageHint Usage; - public Buffer(BufferTarget target, BufferUsageHint usage = BufferUsageHint.StaticDraw) + public GLBuffer(BufferTarget target, BufferUsageHint usage = BufferUsageHint.StaticDraw) : base((uint) GL.GenBuffer()) { Target = target; diff --git a/Diamond/Diamond.csproj b/Diamond/Diamond.csproj index f73a22d..e1c428f 100644 --- a/Diamond/Diamond.csproj +++ b/Diamond/Diamond.csproj @@ -44,7 +44,7 @@ - + diff --git a/Diamond/Shaders/Program.cs b/Diamond/Shaders/Program.cs index 7a000e5..ffec477 100644 --- a/Diamond/Shaders/Program.cs +++ b/Diamond/Shaders/Program.cs @@ -4,7 +4,6 @@ using System.Runtime.InteropServices; using System.Text; using Diamond.Buffers; using OpenTK.Graphics.OpenGL4; -using Buffer = Diamond.Buffers.Buffer; namespace Diamond.Shaders { @@ -88,7 +87,7 @@ namespace Diamond.Shaders return id; } - public void SetAttribPointers(Buffer buff, Type vertexType) + public void SetAttribPointers(GLBuffer buff, Type vertexType) { if (vertexType.GetCustomAttributes(typeof(VertexDataAttribute), false).Length == 0) { diff --git a/hexworld/HexRender.cs b/hexworld/HexRender.cs index fbe520d..606ef32 100644 --- a/hexworld/HexRender.cs +++ b/hexworld/HexRender.cs @@ -1,12 +1,7 @@ using System; -using System.Collections.Generic; using System.Diagnostics; using System.Drawing; using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Diamond; using Diamond.Buffers; using Diamond.Shaders; using Diamond.Textures; @@ -14,7 +9,6 @@ using Newtonsoft.Json; using OpenTK; using OpenTK.Graphics; using OpenTK.Graphics.OpenGL4; -using Buffer = Diamond.Buffers.Buffer; namespace hexworld { @@ -40,8 +34,8 @@ namespace hexworld private Tile[] _allTiles; private Vertex[] _allVertices; - private Buffer _tileBuffer; - private Buffer _vertexBuffer; + private GLBuffer _tileGLBuffer; + private GLBuffer _vertexGLBuffer; private double _time; @@ -97,14 +91,14 @@ namespace hexworld _allTiles = SubArray.Join(_stoneTiles, _grassTiles, _grayTiles); _allVertices = SubArray.Join(_panelVertices, _cubeVertices, _sidesVertices); - _tileBuffer = new Buffer(BufferTarget.ArrayBuffer, BufferUsageHint.DynamicDraw); - _tileBuffer.Data(_allTiles); + _tileGLBuffer = new GLBuffer(BufferTarget.ArrayBuffer, BufferUsageHint.DynamicDraw); + _tileGLBuffer.Data(_allTiles); - _vertexBuffer = new Buffer(BufferTarget.ArrayBuffer, BufferUsageHint.StaticDraw); - _vertexBuffer.Data(_allVertices); + _vertexGLBuffer = new GLBuffer(BufferTarget.ArrayBuffer, BufferUsageHint.StaticDraw); + _vertexGLBuffer.Data(_allVertices); - _pgm.SetAttribPointers(_tileBuffer, typeof(Tile)); - _pgm.SetAttribPointers(_vertexBuffer, typeof(Vertex)); + _pgm.SetAttribPointers(_tileGLBuffer, typeof(Tile)); + _pgm.SetAttribPointers(_vertexGLBuffer, typeof(Vertex)); _grass = Texture.FromBitmap(new Bitmap("grass.png")); _stone = Texture.FromBitmap(new Bitmap("stone.png")); @@ -127,9 +121,9 @@ namespace hexworld (float) (Math.Sin((_time + ti.Position.X - ti.Position.Y / 1.5) / 1.5) * .25); } - _tileBuffer.SubData(_grassTiles); + _tileGLBuffer.SubData(_grassTiles); - _tileBuffer.Bind(); + _tileGLBuffer.Bind(); GL.BufferSubData(BufferTarget.ArrayBuffer, (IntPtr) (5 * 3 * sizeof(float)), (IntPtr) (16 * 3 * sizeof(float)), _grassTiles.ToArray()); } @@ -192,8 +186,8 @@ namespace hexworld _pgm.Dispose(); - _tileBuffer.Dispose(); - _vertexBuffer.Dispose(); + _tileGLBuffer.Dispose(); + _vertexGLBuffer.Dispose(); _grass.Dispose(); _stone.Dispose();