X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Fbufferable.h;h=66a6db1871952a2a7e7940bd5f9f931cd88eb808;hp=d7d7e45fe2183fa606395bda73f184a1f3ace282;hb=b59c47a7ed2ed3f69a3349a2d76ef02891f0c685;hpb=98cc25ffe956bc162c053c96df659ba40dfe2d6e diff --git a/source/bufferable.h b/source/bufferable.h index d7d7e45f..66a6db18 100644 --- a/source/bufferable.h +++ b/source/bufferable.h @@ -14,6 +14,21 @@ uploading fresh data to the buffer. */ class Bufferable { +public: + class AsyncUpdater + { + private: + const Bufferable &bufferable; + char *mapped_address; + bool buffer_resized; + + public: + AsyncUpdater(const Bufferable &); + ~AsyncUpdater(); + + void upload_data(); + }; + private: Buffer *buffer; unsigned offset; @@ -22,7 +37,6 @@ private: protected: mutable bool dirty; -protected: Bufferable(); public: virtual ~Bufferable(); @@ -34,12 +48,18 @@ public: /** Uploads new data into the buffer if necessary. */ void refresh() const { if(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; @@ -69,8 +89,9 @@ protected: /** Resizes the buffer if necessary and calls upload_data(). */ void update_buffer() const; - /** Uploads data to the buffer. */ - virtual void upload_data() const; + /** Uploads data to the buffer. Receives pointer to mapped buffer memory as + parameter. If null, buffer interface should be used instead. */ + virtual void upload_data(char *) const; }; } // namespace GL