diff options
Diffstat (limited to 'src/RenderBackend')
-rw-r--r-- | src/RenderBackend/OpenGL/DeviceMemory.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/RenderBackend/OpenGL/DeviceMemory.cpp b/src/RenderBackend/OpenGL/DeviceMemory.cpp index faf2943..fb9dec5 100644 --- a/src/RenderBackend/OpenGL/DeviceMemory.cpp +++ b/src/RenderBackend/OpenGL/DeviceMemory.cpp @@ -49,7 +49,7 @@ namespace amalgine // TODO: Bind vao here? glBindBuffer(GL_ARRAY_BUFFER, vertexBufferObjectId); } - + /* void DeviceMemory::copy(const DataView<f32> &data, StorageType storageType, PrimitiveType primitiveType) { glBindBuffer(GL_ARRAY_BUFFER, vertexBufferObjectId); @@ -57,11 +57,19 @@ namespace amalgine this->primitiveType = getOpenglPrimitiveType(primitiveType); numVertices = getPrimitiveTypePointsPerVertices(primitiveType); } + */ + void DeviceMemory::copy(const DataView<Triangle2D> &triangles, StorageType storageType) + { + glBindBuffer(GL_ARRAY_BUFFER, vertexBufferObjectId); + glBufferData(GL_ARRAY_BUFFER, triangles.getByteSize(), triangles.data, getOpenglStorageType(storageType)); + primitiveType = GL_TRIANGLES; + numVertices = triangles.size * 3; + } void DeviceMemory::draw() { if(primitiveType == 0) throw DeviceMemoryEmpty("Unable to draw buffer as no data has been copied to device memory"); - glDrawArrays(primitiveType, 0, 3); + glDrawArrays(primitiveType, 0, numVertices); } } |