aboutsummaryrefslogtreecommitdiff
path: root/src/RenderBackend
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2017-12-27 21:52:21 +0100
committerdec05eba <dec05eba@protonmail.com>2021-11-18 15:21:48 +0100
commit2d8b61bf9fc36e933a0091e1098e62faf143412c (patch)
tree6b82990f2f61e0c55085ef65ebaa21e41e55dd43 /src/RenderBackend
parentce271c4c6d0f9c440d90397c07eaa96b0443ff47 (diff)
Add triangle type
Diffstat (limited to 'src/RenderBackend')
-rw-r--r--src/RenderBackend/OpenGL/DeviceMemory.cpp12
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);
}
}