]> git.tdb.fi Git - libs/gl.git/commitdiff
Make a const pointer to a Bufferable's buffer publicly accessible
authorMikko Rasa <tdb@tdb.fi>
Mon, 17 Jun 2019 20:29:59 +0000 (23:29 +0300)
committerMikko Rasa <tdb@tdb.fi>
Mon, 17 Jun 2019 20:29:59 +0000 (23:29 +0300)
source/batch.cpp
source/bufferable.h
source/uniformblock.cpp
source/vertexarray.cpp

index 89b8f48f4d44920d4b63a3829a44f81f9c2f44e8..37e4801ec82a6356a595a4dea62de926bf790d3e 100644 (file)
@@ -242,7 +242,7 @@ void Batch::draw() const
        else if(restart_index && restart_index<=max_index)
                set_restart_index(0);
 
-       Buffer *ibuf = get_buffer();
+       const Buffer *ibuf = get_buffer();
        const void *data_ptr;
        BindRestore _bind_ibuf(ibuf, ELEMENT_ARRAY_BUFFER);
        if(ibuf)
index a88f7b07a719535d426e262157fc8ef10879bd80..66a6db1871952a2a7e7940bd5f9f931cd88eb808 100644 (file)
@@ -53,9 +53,13 @@ public:
 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;
index be30ce5b101420364b5bcba45722f00842e16099..ff8033a0ffdd9d7ddaa270f1699307754b59b9da 100644 (file)
@@ -51,7 +51,7 @@ void UniformBlock::offset_changed()
 void UniformBlock::upload_data(char *target) const
 {
        if(!buf_range)
-               buf_range = new BufferRange(*get_buffer(), get_offset(), size);
+               buf_range = new BufferRange(*get_mutable_buffer(), get_offset(), size);
 
        if(target)
                copy(data.begin(), data.end(), target);
index 0ebd4f0fef4e9855a650b53280ddfbac1ffbcd99..a4dffbb7bae4876af7c9535a1f965e8431b64f7b 100644 (file)
@@ -135,7 +135,7 @@ void VertexArray::apply(bool use_legacy) const
        if(!set_current(this) && !dirty)
                return;
 
-       Buffer *vbuf = get_buffer();
+       const Buffer *vbuf = get_buffer();
        Bind _bind_vbuf(vbuf, ARRAY_BUFFER);
        if(vbuf && dirty)
                update_buffer();