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 SetName(const char *name);
44 void SetType(BufferType bufType);
45 void SetUsage(BufferUsage bufUsage);
47 void *Map(bool read, bool write, bool invalidate);
48 void *MapRange(int offset, int length, bool read, bool write, bool invalidate);
52 void Upload(size_t length, const void *data);
53 void UploadRange(size_t length, intptr_t offset, const void *data);
55 void Resize(size_t length);
56 const size_t GetSize() const { return m_buffer_size; }
60 // WARNING: The buffer handle can change for (almost) no reason.
61 // If you do _anything_ to the buffer, you'll need to call this
62 // again to see if we've recreated it in a vain attempt to outsmart
64 GLuint GetHandle() const { return m_buffer_handle; }
67 void BindRange(size_t start, size_t size) const;
69 bool RecreateBuffer(const void *data = NULL);
70 GLuint m_buffer_handle;
71 BufferType m_buffer_type;
72 BufferUsage m_buffer_usage;
76 bool m_buffer_shape_dirty;