Inflict Qt4 upon the codebase
[ipdf/code.git] / src / graphicsbuffer.h
index 15e5b42..4053f90 100644 (file)
@@ -1,15 +1,14 @@
 #ifndef _GRAPHICSBUFFER_H
 #define _GRAPHICSBUFFER_H
 
 #ifndef _GRAPHICSBUFFER_H
 #define _GRAPHICSBUFFER_H
 
-#include <SDL.h>
-#define GL_GLEXT_PROTOTYPES
-#include <SDL_opengl.h>
+#include "SDL.h"
+#include "gl_core44.h"
 
 
 namespace IPDF
 {
 
 
 namespace IPDF
 {
-       /*
-        * The "Screen" class handles managing the OS window (using SDL2).
+       /**
+        * Implementation of an OpenGL buffer, with some extra cleverness.
         */
        class GraphicsBuffer
        {
         */
        class GraphicsBuffer
        {
@@ -21,7 +20,8 @@ namespace IPDF
                        BufferTypePixelPack,            // Pixel Pack buffer
                        BufferTypePixelUnpack,
                        BufferTypeUniform,              // Uniform/Constant buffer
                        BufferTypePixelPack,            // Pixel Pack buffer
                        BufferTypePixelUnpack,
                        BufferTypeUniform,              // Uniform/Constant buffer
-                       BufferTypeDrawIndirect,
+                       BufferTypeTexture,              // I was hoping to avoid this one.
+                       BufferTypeDrawIndirect
                };
                
                enum BufferUsage
                };
                
                enum BufferUsage
@@ -40,6 +40,7 @@ namespace IPDF
                GraphicsBuffer();
                ~GraphicsBuffer();
                
                GraphicsBuffer();
                ~GraphicsBuffer();
                
+               void SetName(const char *name);
                void SetType(BufferType bufType);
                void SetUsage(BufferUsage bufUsage);
                
                void SetType(BufferType bufType);
                void SetUsage(BufferUsage bufUsage);
                
@@ -52,15 +53,29 @@ namespace IPDF
                void UploadRange(size_t length, intptr_t offset, const void *data);
 
                void Resize(size_t length);
                void UploadRange(size_t length, intptr_t offset, const void *data);
 
                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;
+               void BindRange(size_t start, size_t size) const;
        private:
        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;
                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;
+               const char *m_name;
        };
 
 }
        };
 
 }

UCC git Repository :: git.ucc.asn.au