mirror of
https://github.com/love2d/love.git
synced 2026-08-19 04:06:17 +02:00
Prevent redundant glBindBuffer calls.
--HG-- branch : minor
This commit is contained in:
@@ -56,10 +56,10 @@ public:
|
||||
* Constructor.
|
||||
*
|
||||
* @param size The size of the GLBuffer in bytes.
|
||||
* @param target The target GLBuffer object, e.g. GL_ARRAY_BUFFER.
|
||||
* @param type The type of the buffer object.
|
||||
* @param usage Usage hint, e.g. GL_DYNAMIC_DRAW.
|
||||
*/
|
||||
GLBuffer(size_t size, const void *data, GLenum target, GLenum usage, uint32 mapflags = 0);
|
||||
GLBuffer(size_t size, const void *data, BufferType type, GLenum usage, uint32 mapflags = 0);
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
@@ -77,13 +77,11 @@ public:
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the target buffer object.
|
||||
*
|
||||
* @return The target buffer object, e.g. GL_ARRAY_BUFFER.
|
||||
* Get the type of the buffer object.
|
||||
*/
|
||||
GLenum getTarget() const
|
||||
BufferType getType() const
|
||||
{
|
||||
return target;
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -96,11 +94,6 @@ public:
|
||||
return usage;
|
||||
}
|
||||
|
||||
bool isBound() const
|
||||
{
|
||||
return is_bound;
|
||||
}
|
||||
|
||||
bool isMapped() const
|
||||
{
|
||||
return is_mapped;
|
||||
@@ -112,8 +105,6 @@ public:
|
||||
* This can be faster for large changes to the buffer. For smaller
|
||||
* changes, see fill().
|
||||
*
|
||||
* The GLBuffer must be bound to use this function.
|
||||
*
|
||||
* @return A pointer to memory which represents the buffer.
|
||||
*/
|
||||
void *map();
|
||||
@@ -121,8 +112,6 @@ public:
|
||||
/**
|
||||
* Unmap a previously mapped GLBuffer. The buffer must be unmapped
|
||||
* when used to draw elements.
|
||||
*
|
||||
* The GLBuffer must be bound to use this function.
|
||||
*/
|
||||
void unmap();
|
||||
|
||||
@@ -138,16 +127,9 @@ public:
|
||||
*/
|
||||
void bind();
|
||||
|
||||
/**
|
||||
* Unbind a prevously bound GLBuffer.
|
||||
*/
|
||||
void unbind();
|
||||
|
||||
/**
|
||||
* Fill a portion of the buffer with data and marks the range as modified.
|
||||
*
|
||||
* The GLBuffer must be bound to use this function.
|
||||
*
|
||||
* @param offset The offset in the GLBuffer to store the data.
|
||||
* @param size The size of the incoming data.
|
||||
* @param data Pointer to memory to copy data from.
|
||||
@@ -171,38 +153,6 @@ public:
|
||||
bool loadVolatile() override;
|
||||
void unloadVolatile() override;
|
||||
|
||||
/**
|
||||
* This helper class can bind a GLBuffer temporarily, and
|
||||
* automatically un-bind when it's destroyed.
|
||||
*/
|
||||
class Bind
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Bind a GLBuffer.
|
||||
*/
|
||||
Bind(GLBuffer &buf)
|
||||
: buf(buf)
|
||||
{
|
||||
buf.bind();
|
||||
}
|
||||
|
||||
/**
|
||||
* Unbinds a GLBuffer.
|
||||
*/
|
||||
~Bind()
|
||||
{
|
||||
buf.unbind();
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
// GLBuffer to work on.
|
||||
GLBuffer &buf;
|
||||
|
||||
}; // Bind
|
||||
|
||||
class Mapper
|
||||
{
|
||||
public:
|
||||
@@ -253,16 +203,14 @@ private:
|
||||
void unmapStatic(size_t offset, size_t size);
|
||||
void unmapStream();
|
||||
|
||||
// Whether the buffer is currently bound.
|
||||
bool is_bound;
|
||||
|
||||
// Whether the buffer is currently mapped to main memory.
|
||||
bool is_mapped;
|
||||
|
||||
// The size of the buffer, in bytes.
|
||||
size_t size;
|
||||
|
||||
// The target buffer object. (GL_ARRAY_BUFFER, GL_ELEMENT_ARRAY_BUFFER).
|
||||
// The type of the buffer object.
|
||||
BufferType type;
|
||||
GLenum target;
|
||||
|
||||
// Usage hint. GL_[DYNAMIC, STATIC, STREAM]_DRAW.
|
||||
|
||||
Reference in New Issue
Block a user