1 #ifndef _GRAPHICSBUFFER_H
2 #define _GRAPHICSBUFFER_H
11 * Implementation of an OpenGL buffer, with some extra cleverness.
18 BufferTypeVertex, // A Vertex Buffer
19 BufferTypeIndex, // An Index Buffer
20 BufferTypePixelPack, // Pixel Pack buffer
21 BufferTypePixelUnpack,
22 BufferTypeUniform, // Uniform/Constant buffer
23 BufferTypeTexture, // I was hoping to avoid this one.
24 BufferTypeDrawIndirect
29 BufferUsageStaticDraw,
30 BufferUsageStaticRead,
31 BufferUsageStaticCopy,
32 BufferUsageDynamicDraw,
33 BufferUsageDynamicRead,
34 BufferUsageDynamicCopy,
35 BufferUsageStreamDraw,
36 BufferUsageStreamRead,
43 void SetType(BufferType bufType);
44 void SetUsage(BufferUsage bufUsage);
46 void *Map(bool read, bool write, bool invalidate);
47 void *MapRange(int offset, int length, bool read, bool write, bool invalidate);
51 void Upload(size_t length, const void *data);
52 void UploadRange(size_t length, intptr_t offset, const void *data);
54 void Resize(size_t length);
55 const size_t GetSize() const { return m_buffer_size; }
59 // WARNING: The buffer handle can change for (almost) no reason.
60 // If you do _anything_ to the buffer, you'll need to call this
61 // again to see if we've recreated it in a vain attempt to outsmart
63 GLuint GetHandle() const { return m_buffer_handle; }
67 bool RecreateBuffer(const void *data = NULL);
68 GLuint m_buffer_handle;
69 BufferType m_buffer_type;
70 BufferUsage m_buffer_usage;
74 bool m_buffer_shape_dirty;