TDME2 1.9.121
ObjectBuffer.cpp
Go to the documentation of this file.
2
3#include <vector>
4
5#include <tdme/tdme.h>
10
12
13using std::vector;
14
19
20vector<ByteBuffer*> ObjectBuffer::byteBuffers;
21
22void ObjectBuffer::initialize() {
23 auto renderer = Engine::renderer;
24 byteBuffers.resize(renderer->isSupportingMultithreadedRendering() == true?Engine::getThreadCount():1);
25}
26
28 for (auto byteBuffer: byteBuffers) {
29 delete byteBuffer;
30 }
31 byteBuffers.clear();
32}
33
34ByteBuffer* ObjectBuffer::getByteBuffer(int contextIdx, int32_t bytes)
35{
36 auto renderer = Engine::renderer;
37 if (byteBuffers[contextIdx] == nullptr || bytes > byteBuffers[contextIdx]->getCapacity()) {
38 if (byteBuffers[contextIdx] != nullptr) {
39 delete byteBuffers[contextIdx];
40 }
41 byteBuffers[contextIdx] = ByteBuffer::allocate(bytes);
42 } else {
43 byteBuffers[contextIdx]->clear();
44 }
45 return byteBuffers[contextIdx];
46}
Engine main class.
Definition: Engine.h:122
static STATIC_DLL_IMPEXT Renderer * renderer
Definition: Engine.h:184
static int getThreadCount()
Definition: Engine.h:579
Buffers used to transfer data between main memory to graphics board memory.
Definition: ObjectBuffer.h:23
static ByteBuffer * getByteBuffer(int contextIdx, int32_t bytes)
Get byte buffer for given context.
static void dispose()
Disposes object buffer per thread.
static STATIC_DLL_IMPEXT vector< ByteBuffer * > byteBuffers
Definition: ObjectBuffer.h:35
Byte buffer class.
Definition: ByteBuffer.h:24
Console class.
Definition: Console.h:26