aboutsummaryrefslogtreecommitdiff
path: root/src/RenderBackend/OpenGL/DeviceMemory.cpp
blob: f16666614c6f4d187e0d05fa38143f27310d6e76 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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);
    }
}