1 module evael.renderer.graphics_buffer; 2 3 import evael.renderer.enums.buffer_type; 4 5 import evael.lib.memory; 6 7 alias VertexBuffer = GraphicsBuffer!(BufferType.Vertex); 8 alias IndexBuffer = GraphicsBuffer!(BufferType.Index); 9 alias UniformBuffer = GraphicsBuffer!(BufferType.Uniform); 10 11 abstract class GraphicsBuffer(BufferType t) : NoGCClass 12 { 13 protected BufferType m_type = t; 14 protected uint m_internalType; 15 16 protected uint m_id; 17 protected string m_name; 18 protected size_t m_size; 19 20 /* 21 * Buffer constructor. 22 */ 23 @nogc 24 public this(in size_t size) 25 { 26 this.m_size = size; 27 } 28 29 /* 30 * Buffer destructor. 31 */ 32 @nogc 33 public ~this() 34 { 35 36 } 37 38 /** 39 * Updates a subset of a buffer object's data store. 40 * Params: 41 * offet : offset into the buffer object's data store where data replacement will begin, measured in bytes 42 * size : size in bytes of the data store region being replaced 43 * data : pointer to the new data that will be copied into the data store 44 */ 45 @nogc 46 public abstract void update(in ptrdiff_t offset, in ptrdiff_t size, in void* data) const nothrow; 47 48 @nogc 49 @property nothrow 50 { 51 public BufferType type() const 52 { 53 return this.m_type; 54 } 55 56 public uint internalType() const 57 { 58 return this.m_internalType; 59 } 60 61 public uint id() const 62 { 63 return this.m_id; 64 } 65 66 public string name() const 67 { 68 return this.m_name; 69 } 70 71 public size_t size() const 72 { 73 return this.m_size; 74 } 75 } 76 }