blob: 802230d1b890506e348d1276cfbfe96f5b5d862e (
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
#pragma once
#include "../../DataView.hpp"
#include "../../utils.hpp"
#include "../../Triangle.hpp"
#include "../../Vec.hpp"
#include <memory>
namespace amalgine {
enum class DeviceMemoryType {
NONE,
VEC2,
VEC3
};
class DeviceMemory {
DISABLE_COPY(DeviceMemory)
friend class ShaderFrame;
friend class std::default_delete<DeviceMemory>;
public:
enum class StorageType
{
// Uploaded once, drawn many times
STATIC,
// Created once, changed from time to time but drawn many times more than that
DYNAMIC,
// Uploaded once, drawn once (for example data that is changed every frame)
STREAM
};
void set(const DataView<vec2f> &texture_coords, StorageType storageType);
void set(const DataView<Triangle2D> &triangles, StorageType storageType);
void set(const DataView<Triangle3D> &triangles, StorageType storageType);
i32 get_num_vertices() const { return num_vertices; }
private:
DeviceMemory(u32 vertex_array_object_id, i32 attrib_location);
~DeviceMemory();
void use();
private:
u32 vertex_array_object_id;
u32 vertex_buffer_object_id;
i32 attrib_location;
i32 num_vertices;
DeviceMemoryType memory_type;
};
}
|