mirror of
https://github.com/love2d/love.git
synced 2026-08-19 04:06:17 +02:00
Added 'VertexBuffer' abstraction. SpriteBatches are now always supported.
Also improved memory usage in SpriteBatch. (No need to retain full copy of sprites in memory. Can read that data back later to save data from OpenGL context destruction).
This commit is contained in:
@@ -46,8 +46,9 @@ namespace opengl
|
||||
// Forward declarations.
|
||||
class Image;
|
||||
class Quad;
|
||||
class VertexBuffer;
|
||||
|
||||
class SpriteBatch : public Drawable, public Volatile
|
||||
class SpriteBatch : public Drawable
|
||||
{
|
||||
private:
|
||||
|
||||
@@ -59,25 +60,15 @@ namespace opengl
|
||||
// The next free element.
|
||||
int next;
|
||||
|
||||
GLuint vbo[2];
|
||||
|
||||
// Vertex Buffer.
|
||||
vertex * vertices;
|
||||
|
||||
// Index buffer.
|
||||
GLushort * indices;
|
||||
|
||||
// The uage hint for the vertex buffer.
|
||||
int usage;
|
||||
int gl_usage;
|
||||
|
||||
// If the buffer is locked, this pointer is nonzero.
|
||||
vertex * lockp;
|
||||
vertex sprite[4];
|
||||
|
||||
// Current color. This color, if present, will be applied to the next
|
||||
// added quad.
|
||||
Color * color;
|
||||
|
||||
VertexBuffer *array_buf;
|
||||
VertexBuffer *element_buf;
|
||||
|
||||
public:
|
||||
|
||||
enum UsageHint
|
||||
@@ -90,12 +81,6 @@ namespace opengl
|
||||
SpriteBatch(Image * image, int size, int usage);
|
||||
virtual ~SpriteBatch();
|
||||
|
||||
static bool isSupported();
|
||||
|
||||
// Implements Volatile.
|
||||
bool loadVolatile();
|
||||
void unloadVolatile();
|
||||
|
||||
void add(float x, float y, float a, float sx, float sy, float ox, float oy, float kx, float ky);
|
||||
void addq(Quad * quad, float x, float y, float a, float sx, float sy, float ox, float oy, float kx, float ky);
|
||||
void clear();
|
||||
|
||||
Reference in New Issue
Block a user