From 2d8b61bf9fc36e933a0091e1098e62faf143412c Mon Sep 17 00:00:00 2001 From: dec05eba Date: Wed, 27 Dec 2017 21:52:21 +0100 Subject: Add triangle type --- src/RenderBackend/OpenGL/DeviceMemory.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/RenderBackend/OpenGL') 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 &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 &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); } } -- cgit v1.2.3