aboutsummaryrefslogtreecommitdiff
path: root/src/RenderBackend/OpenGL/DeviceMemory.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/RenderBackend/OpenGL/DeviceMemory.cpp')
-rw-r--r--src/RenderBackend/OpenGL/DeviceMemory.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/RenderBackend/OpenGL/DeviceMemory.cpp b/src/RenderBackend/OpenGL/DeviceMemory.cpp
new file mode 100644
index 0000000..f166666
--- /dev/null
+++ b/src/RenderBackend/OpenGL/DeviceMemory.cpp
@@ -0,0 +1,31 @@
+#include "../../../include/RenderBackend/OpenGL/DeviceMemory.hpp"
+#include "../../../include/RenderBackend/OpenGL/opengl.hpp"
+
+namespace amalgine
+{
+ DeviceMemory::DeviceMemory()
+ {
+ glGenBuffers(1, &vertexBufferObjectId);
+ }
+
+ void DeviceMemory::copyStatic(const DataView<f32> &data)
+ {
+ copy(data, GL_STATIC_DRAW);
+ }
+
+ void DeviceMemory::copyDynamic(const DataView<f32> &data)
+ {
+ copy(data, GL_DYNAMIC_DRAW);
+ }
+
+ void DeviceMemory::copyStream(const DataView<f32> &data)
+ {
+ copy(data, GL_STREAM_DRAW);
+ }
+
+ void DeviceMemory::copy(const DataView<f32> &data, i32 storageType)
+ {
+ glBindBuffer(GL_ARRAY_BUFFER, vertexBufferObjectId);
+ glBufferData(GL_ARRAY_BUFFER, data.getByteSize(), data.data, storageType);
+ }
+}