mirror of
https://github.com/love2d/love.git
synced 2026-08-17 11:00:31 +02:00
Implement automatic batching for points, lines, shapes, and images/quads.
The above are batched together into a single draw call when called without other drawing calls in between, as long as the following criteria are met: - The texture is the same. - The primitive type is the same (points cannot be batched with non-points). - The love.graphics state is the same (aside from the current color - i.e. setColor - and the transform state). - The active shader’s uniform values are the same. You can examine the ‘drawcalls’ field of love.graphics.getStats() to help determine if your code is allowing for optimum batching. --HG-- branch : minor
This commit is contained in:
@@ -27,6 +27,7 @@
|
||||
#include "common/math.h"
|
||||
#include "graphics/Color.h"
|
||||
#include "graphics/Texture.h"
|
||||
#include "graphics/vertex.h"
|
||||
#include "common/Matrix.h"
|
||||
|
||||
// GLAD
|
||||
@@ -70,13 +71,6 @@ enum VertexAttribFlags
|
||||
ATTRIBFLAG_CONSTANTCOLOR = 1 << ATTRIB_CONSTANTCOLOR
|
||||
};
|
||||
|
||||
enum BufferType
|
||||
{
|
||||
BUFFER_VERTEX = 0,
|
||||
BUFFER_INDEX,
|
||||
BUFFER_MAX_ENUM
|
||||
};
|
||||
|
||||
/**
|
||||
* Thin layer between OpenGL and the rest of the program.
|
||||
* Internally shadows some OpenGL context state for improved efficiency and
|
||||
@@ -119,36 +113,6 @@ public:
|
||||
GLenum type = 0;
|
||||
};
|
||||
|
||||
struct
|
||||
{
|
||||
std::vector<Matrix4> transform;
|
||||
Matrix4 projection;
|
||||
} matrices;
|
||||
|
||||
class TempTransform
|
||||
{
|
||||
public:
|
||||
|
||||
TempTransform(OpenGL &gl)
|
||||
: gl(gl)
|
||||
{
|
||||
gl.pushTransform();
|
||||
}
|
||||
|
||||
~TempTransform()
|
||||
{
|
||||
gl.popTransform();
|
||||
}
|
||||
|
||||
Matrix4 &get()
|
||||
{
|
||||
return gl.getTransform();
|
||||
}
|
||||
|
||||
private:
|
||||
OpenGL ≷
|
||||
};
|
||||
|
||||
class TempDebugGroup
|
||||
{
|
||||
public:
|
||||
@@ -242,10 +206,6 @@ public:
|
||||
**/
|
||||
void deInitContext();
|
||||
|
||||
void pushTransform();
|
||||
void popTransform();
|
||||
Matrix4 &getTransform();
|
||||
|
||||
/**
|
||||
* Set up necessary state (LOVE-provided shader uniforms, etc.) for drawing.
|
||||
* This *MUST* be called directly before OpenGL drawing functions.
|
||||
@@ -359,6 +319,7 @@ public:
|
||||
* @param restoreprev Restore previously bound texture unit when done.
|
||||
**/
|
||||
void bindTextureToUnit(GLuint texture, int textureunit, bool restoreprev);
|
||||
void bindTextureToUnit(Texture *texture, int textureunit, bool restoreprev);
|
||||
|
||||
/**
|
||||
* Helper for deleting an OpenGL texture.
|
||||
@@ -440,7 +401,6 @@ private:
|
||||
void initVendor();
|
||||
void initOpenGLFunctions();
|
||||
void initMaxValues();
|
||||
void initMatrices();
|
||||
void createDefaultTexture();
|
||||
|
||||
bool contextInitialized;
|
||||
|
||||
Reference in New Issue
Block a user