Rename Buffer to GLBuffer to prevent name conflict.

This commit is contained in:
2017-02-26 23:17:21 -05:00
parent df6965c003
commit a7c2f5bb29
4 changed files with 16 additions and 23 deletions

View File

@@ -8,12 +8,12 @@ using OpenTK.Graphics.OpenGL4;
namespace Diamond.Buffers namespace Diamond.Buffers
{ {
public class Buffer : GLObject public class GLBuffer : GLObject
{ {
public readonly BufferTarget Target; public readonly BufferTarget Target;
public readonly BufferUsageHint Usage; public readonly BufferUsageHint Usage;
public Buffer(BufferTarget target, BufferUsageHint usage = BufferUsageHint.StaticDraw) public GLBuffer(BufferTarget target, BufferUsageHint usage = BufferUsageHint.StaticDraw)
: base((uint) GL.GenBuffer()) : base((uint) GL.GenBuffer())
{ {
Target = target; Target = target;

View File

@@ -44,7 +44,7 @@
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Buffers\Buffer.cs" /> <Compile Include="Buffers\GLBuffer.cs" />
<Compile Include="Buffers\SubArray.cs" /> <Compile Include="Buffers\SubArray.cs" />
<Compile Include="Buffers\VertexDataAttribute.cs" /> <Compile Include="Buffers\VertexDataAttribute.cs" />
<Compile Include="GLObject.cs" /> <Compile Include="GLObject.cs" />

View File

@@ -4,7 +4,6 @@ using System.Runtime.InteropServices;
using System.Text; using System.Text;
using Diamond.Buffers; using Diamond.Buffers;
using OpenTK.Graphics.OpenGL4; using OpenTK.Graphics.OpenGL4;
using Buffer = Diamond.Buffers.Buffer;
namespace Diamond.Shaders namespace Diamond.Shaders
{ {
@@ -88,7 +87,7 @@ namespace Diamond.Shaders
return id; return id;
} }
public void SetAttribPointers(Buffer buff, Type vertexType) public void SetAttribPointers(GLBuffer buff, Type vertexType)
{ {
if (vertexType.GetCustomAttributes(typeof(VertexDataAttribute), false).Length == 0) if (vertexType.GetCustomAttributes(typeof(VertexDataAttribute), false).Length == 0)
{ {

View File

@@ -1,12 +1,7 @@
using System; using System;
using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Drawing; using System.Drawing;
using System.IO; using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Diamond;
using Diamond.Buffers; using Diamond.Buffers;
using Diamond.Shaders; using Diamond.Shaders;
using Diamond.Textures; using Diamond.Textures;
@@ -14,7 +9,6 @@ using Newtonsoft.Json;
using OpenTK; using OpenTK;
using OpenTK.Graphics; using OpenTK.Graphics;
using OpenTK.Graphics.OpenGL4; using OpenTK.Graphics.OpenGL4;
using Buffer = Diamond.Buffers.Buffer;
namespace hexworld namespace hexworld
{ {
@@ -40,8 +34,8 @@ namespace hexworld
private Tile[] _allTiles; private Tile[] _allTiles;
private Vertex[] _allVertices; private Vertex[] _allVertices;
private Buffer _tileBuffer; private GLBuffer _tileGLBuffer;
private Buffer _vertexBuffer; private GLBuffer _vertexGLBuffer;
private double _time; private double _time;
@@ -97,14 +91,14 @@ namespace hexworld
_allTiles = SubArray<Tile>.Join(_stoneTiles, _grassTiles, _grayTiles); _allTiles = SubArray<Tile>.Join(_stoneTiles, _grassTiles, _grayTiles);
_allVertices = SubArray<Vertex>.Join(_panelVertices, _cubeVertices, _sidesVertices); _allVertices = SubArray<Vertex>.Join(_panelVertices, _cubeVertices, _sidesVertices);
_tileBuffer = new Buffer(BufferTarget.ArrayBuffer, BufferUsageHint.DynamicDraw); _tileGLBuffer = new GLBuffer(BufferTarget.ArrayBuffer, BufferUsageHint.DynamicDraw);
_tileBuffer.Data(_allTiles); _tileGLBuffer.Data(_allTiles);
_vertexBuffer = new Buffer(BufferTarget.ArrayBuffer, BufferUsageHint.StaticDraw); _vertexGLBuffer = new GLBuffer(BufferTarget.ArrayBuffer, BufferUsageHint.StaticDraw);
_vertexBuffer.Data(_allVertices); _vertexGLBuffer.Data(_allVertices);
_pgm.SetAttribPointers(_tileBuffer, typeof(Tile)); _pgm.SetAttribPointers(_tileGLBuffer, typeof(Tile));
_pgm.SetAttribPointers(_vertexBuffer, typeof(Vertex)); _pgm.SetAttribPointers(_vertexGLBuffer, typeof(Vertex));
_grass = Texture.FromBitmap(new Bitmap("grass.png")); _grass = Texture.FromBitmap(new Bitmap("grass.png"));
_stone = Texture.FromBitmap(new Bitmap("stone.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); (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)), GL.BufferSubData(BufferTarget.ArrayBuffer, (IntPtr) (5 * 3 * sizeof(float)),
(IntPtr) (16 * 3 * sizeof(float)), _grassTiles.ToArray()); (IntPtr) (16 * 3 * sizeof(float)), _grassTiles.ToArray());
} }
@@ -192,8 +186,8 @@ namespace hexworld
_pgm.Dispose(); _pgm.Dispose();
_tileBuffer.Dispose(); _tileGLBuffer.Dispose();
_vertexBuffer.Dispose(); _vertexGLBuffer.Dispose();
_grass.Dispose(); _grass.Dispose();
_stone.Dispose(); _stone.Dispose();