blob: 1c50564dd5322da83f3608bfa8b38b2906655667 (
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
#pragma once
#include "drape/index_buffer_mutator.hpp"
#include "drape/attribute_buffer_mutator.hpp"
#include "drape/pointers.hpp"
#include "drape/index_buffer.hpp"
#include "drape/data_buffer.hpp"
#include "drape/binding_info.hpp"
#include "drape/gpu_program.hpp"
#include "std/map.hpp"
namespace dp
{
class VertexArrayBuffer
{
typedef map<BindingInfo, MasterPointer<DataBuffer> > TBuffersMap;
public:
VertexArrayBuffer(uint32_t indexBufferSize, uint32_t dataBufferSize);
~VertexArrayBuffer();
/// This method must be call on reading thread, before VAO will be transfer on render thread
void Preflush();
///{@
/// On devices where implemented OES_vertex_array_object extensions we use it for build VertexArrayBuffer
/// OES_vertex_array_object create OpenGL resource that belong only one GL context (which was created by)
/// by this reason Build/Bind and Render must be called only on Frontendrendere thread
void Render();
void Build(RefPointer<GpuProgram> program);
///@}
uint16_t GetAvailableVertexCount() const;
uint16_t GetAvailableIndexCount() const;
uint16_t GetStartIndexValue() const;
uint16_t GetDynamicBufferOffset(BindingInfo const & bindingInfo);
bool IsFilled() const;
void UploadData(BindingInfo const & bindingInfo, void const * data, uint16_t count);
void UploadIndexes(uint16_t const * data, uint16_t count);
void ApplyMutation(RefPointer<IndexBufferMutator> indexMutator,
RefPointer<AttributeBufferMutator> attrMutator);
private:
RefPointer<DataBuffer> GetOrCreateStaticBuffer(BindingInfo const & bindingInfo);
RefPointer<DataBuffer> GetOrCreateDynamicBuffer(BindingInfo const & bindingInfo);
RefPointer<DataBuffer> GetDynamicBuffer(BindingInfo const & bindingInfo) const;
RefPointer<DataBuffer> GetOrCreateBuffer(BindingInfo const & bindingInfo, bool isDynamic);
RefPointer<DataBuffer> GetBuffer(BindingInfo const & bindingInfo, bool isDynamic) const;
void Bind() const;
void BindStaticBuffers() const;
void BindDynamicBuffers() const;
void BindBuffers(TBuffersMap const & buffers) const;
private:
int m_VAO;
TBuffersMap m_staticBuffers;
TBuffersMap m_dynamicBuffers;
MasterPointer<IndexBuffer> m_indexBuffer;
uint32_t m_dataBufferSize;
RefPointer<GpuProgram> m_program;
};
} // namespace dp
|