X-Git-Url: https://git.ucc.asn.au/?p=ipdf%2Fcode.git;a=blobdiff_plain;f=src%2Fgraphicsbuffer.h;h=466534531d8e5ab1b665d37aa5414a6e2e71de38;hp=d74d344ac6563bae3da9773fe41ebea3dc964f2f;hb=2efd51d686e0dd911f0220ab2d595c0b3b0e18be;hpb=bdda0103bf26d215d41093316ca0e15cd67fec1d diff --git a/src/graphicsbuffer.h b/src/graphicsbuffer.h index d74d344..4665345 100644 --- a/src/graphicsbuffer.h +++ b/src/graphicsbuffer.h @@ -2,14 +2,13 @@ #define _GRAPHICSBUFFER_H #include -#define GL_GLEXT_PROTOTYPES -#include +#include "gl_core44.h" namespace IPDF { - /* - * The "Screen" class handles managing the OS window (using SDL2). + /** + * Implementation of an OpenGL buffer, with some extra cleverness. */ class GraphicsBuffer { @@ -21,7 +20,8 @@ namespace IPDF BufferTypePixelPack, // Pixel Pack buffer BufferTypePixelUnpack, BufferTypeUniform, // Uniform/Constant buffer - BufferTypeDrawIndirect, + BufferTypeTexture, // I was hoping to avoid this one. + BufferTypeDrawIndirect }; enum BufferUsage @@ -53,15 +53,26 @@ namespace IPDF void Resize(size_t length); const size_t GetSize() const { return m_buffer_size; } + + void Invalidate(); + + // WARNING: The buffer handle can change for (almost) no reason. + // If you do _anything_ to the buffer, you'll need to call this + // again to see if we've recreated it in a vain attempt to outsmart + // the driver. + GLuint GetHandle() const { return m_buffer_handle; } - void Bind(); + void Bind() const; private: + bool RecreateBuffer(const void *data = NULL); GLuint m_buffer_handle; BufferType m_buffer_type; BufferUsage m_buffer_usage; void *m_map_pointer; size_t m_buffer_size; bool m_invalidated; + bool m_buffer_shape_dirty; + bool m_faking_map; }; }