blob: c37acfbbc2324d8afaabdded0fed6a54d2d25103 (
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
51
52
|
#pragma once
#include "../../DataView.hpp"
#include "../../utils.hpp"
#include "../../Triangle2D.hpp"
#include <stdexcept>
namespace amalgine
{
class DeviceMemoryEmpty : public std::runtime_error
{
public:
DeviceMemoryEmpty(const std::string &errMsg) : std::runtime_error(errMsg) {}
};
class DeviceMemory
{
DISABLE_COPY(DeviceMemory)
friend class DeviceFrame;
friend class ShaderInputVec2;
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
};
enum class PrimitiveType
{
TRIANGLE
};
~DeviceMemory();
//void copy(const DataView<f32> &data, StorageType storageType, PrimitiveType primitiveType = PrimitiveType::TRIANGLE);
void copy(const DataView<Triangle2D> &triangles, StorageType storageType);
void draw();
private:
DeviceMemory();
void operator delete(void *data);
void use() const;
private:
u32 vertexBufferObjectId;
u32 primitiveType;
u32 numVertices;
};
}
|