World of Might and Magic  0.2.0
Open reimplementation of Might and Magic 6 7 8 game engine
MemBuffer.cpp
См. документацию.
1 #include "src/tools/MemBuffer.h"
2 
3 #include <memory>
4 
5 class MemBuffer : public IMemBuffer {
6  public:
7  explicit MemBuffer(size_t size) : size(size) { data = malloc(size); }
8  virtual ~MemBuffer() { free(data); }
9 
10  virtual const void *GetData() const { return data; }
11  virtual size_t GetSize() const { return size; }
12 
13  virtual void *GetWritableData() const { return data; }
14 
15  public:
16  void *data;
17  size_t size;
18 };
19 
21  std::shared_ptr<MemBuffer> buffer = std::make_shared<MemBuffer>(size);
22  return std::dynamic_pointer_cast<IMemBuffer, MemBuffer>(buffer);
23 }
MemBuffer::size
size_t size
Definition: MemBuffer.cpp:17
IMemBuffer
Definition: MemBuffer.h:5
MemBuffer.h
MemBuffer::GetSize
virtual size_t GetSize() const
Definition: MemBuffer.cpp:11
MemBuffer::GetData
virtual const void * GetData() const
Definition: MemBuffer.cpp:10
buffer
EGLContext EGLenum EGLClientBuffer buffer
Definition: SDL_egl.h:952
AllocMemBuffer
PMemBuffer AllocMemBuffer(size_t size)
Definition: MemBuffer.cpp:20
MemBuffer::data
void * data
Definition: MemBuffer.cpp:16
data
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: SDL_opengl.h:1974
MemBuffer::MemBuffer
MemBuffer(size_t size)
Definition: MemBuffer.cpp:7
MemBuffer::GetWritableData
virtual void * GetWritableData() const
Definition: MemBuffer.cpp:13
MemBuffer::~MemBuffer
virtual ~MemBuffer()
Definition: MemBuffer.cpp:8
MemBuffer
Definition: MemBuffer.cpp:5
size
GLsizeiptr size
Definition: SDL_opengl_glext.h:540
PMemBuffer
std::shared_ptr< IMemBuffer > PMemBuffer
Definition: MemBuffer.h:13