mirror of
https://github.com/love2d/love.git
synced 2026-08-17 19:23:38 +02:00
Only update the shader point size in OpenGL ES 2 when it's been modified, rather than before every draw.
This commit is contained in:
@@ -331,7 +331,7 @@ void OpenGL::prepareDraw()
|
|||||||
Matrix tp_matrix(curproj * curxform);
|
Matrix tp_matrix(curproj * curxform);
|
||||||
shader->sendBuiltinMatrix(Shader::BUILTIN_TRANSFORM_PROJECTION_MATRIX, 4, tp_matrix.getElements(), 1);
|
shader->sendBuiltinMatrix(Shader::BUILTIN_TRANSFORM_PROJECTION_MATRIX, 4, tp_matrix.getElements(), 1);
|
||||||
|
|
||||||
shader->sendBuiltinFloat(Shader::BUILTIN_POINT_SIZE, 1, &state.pointSize, 1);
|
shader->checkSetPointSize(state.pointSize);
|
||||||
}
|
}
|
||||||
else if (GLAD_VERSION_1_0)
|
else if (GLAD_VERSION_1_0)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -75,6 +75,7 @@ Shader::Shader(const ShaderSource &source)
|
|||||||
, builtinAttributes()
|
, builtinAttributes()
|
||||||
, lastCanvas((Canvas *) -1)
|
, lastCanvas((Canvas *) -1)
|
||||||
, lastViewport()
|
, lastViewport()
|
||||||
|
, lastPointSize(0.0f)
|
||||||
{
|
{
|
||||||
if (source.vertex.empty() && source.pixel.empty())
|
if (source.vertex.empty() && source.pixel.empty())
|
||||||
throw love::Exception("Cannot create shader: no source code!");
|
throw love::Exception("Cannot create shader: no source code!");
|
||||||
@@ -216,6 +217,8 @@ bool Shader::loadVolatile()
|
|||||||
lastCanvas = (Canvas *) -1;
|
lastCanvas = (Canvas *) -1;
|
||||||
lastViewport = OpenGL::Viewport();
|
lastViewport = OpenGL::Viewport();
|
||||||
|
|
||||||
|
lastPointSize = 0.0f;
|
||||||
|
|
||||||
// zero out active texture list
|
// zero out active texture list
|
||||||
activeTexUnits.clear();
|
activeTexUnits.clear();
|
||||||
activeTexUnits.insert(activeTexUnits.begin(), gl.getMaxTextureUnits() - 1, 0);
|
activeTexUnits.insert(activeTexUnits.begin(), gl.getMaxTextureUnits() - 1, 0);
|
||||||
@@ -709,6 +712,16 @@ void Shader::checkSetScreenParams()
|
|||||||
lastViewport = view;
|
lastViewport = view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Shader::checkSetPointSize(float size)
|
||||||
|
{
|
||||||
|
if (size == lastPointSize)
|
||||||
|
return;
|
||||||
|
|
||||||
|
sendBuiltinFloat(BUILTIN_POINT_SIZE, 1, &size, 1);
|
||||||
|
|
||||||
|
lastPointSize = size;
|
||||||
|
}
|
||||||
|
|
||||||
const std::map<std::string, Object *> &Shader::getBoundRetainables() const
|
const std::map<std::string, Object *> &Shader::getBoundRetainables() const
|
||||||
{
|
{
|
||||||
return boundRetainables;
|
return boundRetainables;
|
||||||
|
|||||||
@@ -182,6 +182,7 @@ public:
|
|||||||
bool sendBuiltinMatrix(BuiltinUniform builtin, int size, const GLfloat *m, int count);
|
bool sendBuiltinMatrix(BuiltinUniform builtin, int size, const GLfloat *m, int count);
|
||||||
bool sendBuiltinFloat(BuiltinUniform builtin, int size, const GLfloat *m, int count);
|
bool sendBuiltinFloat(BuiltinUniform builtin, int size, const GLfloat *m, int count);
|
||||||
void checkSetScreenParams();
|
void checkSetScreenParams();
|
||||||
|
void checkSetPointSize(float size);
|
||||||
|
|
||||||
const std::map<std::string, Object *> &getBoundRetainables() const;
|
const std::map<std::string, Object *> &getBoundRetainables() const;
|
||||||
|
|
||||||
@@ -250,6 +251,8 @@ private:
|
|||||||
Canvas *lastCanvas;
|
Canvas *lastCanvas;
|
||||||
OpenGL::Viewport lastViewport;
|
OpenGL::Viewport lastViewport;
|
||||||
|
|
||||||
|
float lastPointSize;
|
||||||
|
|
||||||
// Counts total number of textures bound to each texture unit in all shaders
|
// Counts total number of textures bound to each texture unit in all shaders
|
||||||
static std::vector<int> textureCounters;
|
static std::vector<int> textureCounters;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user