]> git.tdb.fi Git - libs/gl.git/blobdiff - source/bufferable.h
Check for non-null buffer in Bufferable's refresh function
[libs/gl.git] / source / bufferable.h
index f157c6281d2197d17b56bd78a7d61cd1754ee186..f47ef4cabf17c1664838195778910886fcda778b 100644 (file)
@@ -37,7 +37,6 @@ private:
 protected:
        mutable bool dirty;
 
-protected:
        Bufferable();
 public:
        virtual ~Bufferable();
@@ -47,16 +46,20 @@ public:
        void use_buffer(Buffer *buf, Bufferable *prev = 0);
 
        /** Uploads new data into the buffer if necessary. */
-       void refresh() const { if(dirty) update_buffer(); }
+       void refresh() const { if(buffer && dirty) update_buffer(); }
 
        AsyncUpdater *refresh_async() const;
 
 private:
        void unlink_from_buffer();
 
+public:
+       /** Returns the buffer in which the data is stored. */
+       const Buffer *get_buffer() const { return buffer; }
+
 protected:
        /** Returns the buffer in which the data is stored. */
-       Buffer *get_buffer() const { return buffer; }
+       Buffer *get_mutable_buffer() const { return buffer; }
 
        /** Returns the amount of data to be stored in the buffer, in bytes. */
        virtual unsigned get_data_size() const = 0;