public RenderEngine() { // check if VBO are supported string vboCoreStr = "GL_vertex_buffer_object"; string vboARBStr = "GL_ARB_vertex_buffer_object"; _vbotype = VBOType.No; string exts = GL.GetString(StringName.Extensions); if (exts.Contains(vboCoreStr)) { _vbotype = VBOType.Core; } else if (exts.Contains(vboARBStr)) { _vbotype = VBOType.ARB; } }
public IndexBuffer(VBOType vbo, int numIndicies, BufferUsage usage, DrawMode dmode) { _vbo = -1; _useVbo = vbo; _usage = usage; _indicies = null; _idxNum = numIndicies; _dmode = dmode; int sizeInBytes = Marshal.SizeOf(typeof(ushort)) * numIndicies; if (_useVbo == VBOType.Core) { BufferUsageHint buh = BufferUsageHint.StaticDraw; if (_usage == BufferUsage.DYNAMIC) buh = BufferUsageHint.DynamicDraw; GL.GenBuffers (1, out _vbo); GL.BindBuffer (BufferTarget.ElementArrayBuffer, _vbo); GL.BufferData (BufferTarget.ElementArrayBuffer, new IntPtr (sizeInBytes), IntPtr.Zero, buh); } else if (_useVbo == VBOType.ARB) { BufferUsageArb buh = BufferUsageArb.StaticDraw; if (_usage == BufferUsage.DYNAMIC) buh = BufferUsageArb.DynamicDraw; GL.Arb.GenBuffers (1, out _vbo); GL.Arb.BindBuffer (BufferTargetArb.ElementArrayBuffer, _vbo); GL.Arb.BufferData (BufferTargetArb.ElementArrayBuffer, new IntPtr (sizeInBytes), IntPtr.Zero, buh); } else { _vbo = _gSWIBuffer++; _indicies = new ushort[numIndicies]; } }
public VertexBuffer(VBOType vbo, int numVertices, BufferUsage usage) { _vbo = -1; _useVbo = vbo; _usage = usage; _vertices = null; _vertsNum = numVertices; int sizeInBytes = Marshal.SizeOf (typeof(Vertex)) * numVertices; if (_useVbo == VBOType.Core) { BufferUsageHint buh = BufferUsageHint.StaticDraw; if (_usage == BufferUsage.DYNAMIC) buh = BufferUsageHint.DynamicDraw; GL.GenBuffers (1, out _vbo); GL.BindBuffer (BufferTarget.ArrayBuffer, _vbo); GL.BufferData (BufferTarget.ArrayBuffer, new IntPtr (sizeInBytes), IntPtr.Zero, buh); } else if (_useVbo == VBOType.ARB) { BufferUsageArb buh = BufferUsageArb.StaticDraw; if (_usage == BufferUsage.DYNAMIC) buh = BufferUsageArb.DynamicDraw; GL.Arb.GenBuffers (1, out _vbo); GL.Arb.BindBuffer (BufferTargetArb.ArrayBuffer, _vbo); GL.Arb.BufferData (BufferTargetArb.ArrayBuffer, new IntPtr (sizeInBytes), IntPtr.Zero, buh); } else { _vbo = _gSWVBuffer++; _vertices = new Vertex[numVertices]; } }