mirror of
https://github.com/love2d/love.git
synced 2026-08-15 07:41:11 +02:00
Use initializer list copy constructor instead of per-element copying for shader source list in ShaderEffect constructor
This commit is contained in:
@@ -60,16 +60,12 @@ GLint ShaderEffect::_max_texture_units = 0;
|
||||
std::vector<int> ShaderEffect::_texture_id_counters;
|
||||
|
||||
ShaderEffect::ShaderEffect(const std::vector<ShaderSource> &shadersources)
|
||||
: _program(0)
|
||||
: _shadersources(shadersources)
|
||||
, _program(0)
|
||||
{
|
||||
if (shadersources.size() == 0)
|
||||
throw love::Exception("Cannot create shader effect: no source code!");
|
||||
|
||||
// copy shader sources from list to this ShaderEffect
|
||||
std::vector<ShaderSource>::const_iterator it;
|
||||
for (it = shadersources.begin(); it != shadersources.end(); ++it)
|
||||
_shaders.push_back(*it);
|
||||
|
||||
GLint maxtextureunits;
|
||||
glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &maxtextureunits);
|
||||
_max_texture_units = std::max(maxtextureunits - 1, 0);
|
||||
@@ -193,9 +189,9 @@ bool ShaderEffect::loadVolatile()
|
||||
|
||||
std::vector<GLuint> shaderids;
|
||||
|
||||
std::vector<ShaderSource>::const_iterator curshader;
|
||||
for (curshader = _shaders.begin(); curshader != _shaders.end(); ++curshader)
|
||||
shaderids.push_back(createShader(*curshader));
|
||||
std::vector<ShaderSource>::const_iterator cursource;
|
||||
for (cursource = _shadersources.begin(); cursource != _shadersources.end(); ++cursource)
|
||||
shaderids.push_back(createShader(*cursource));
|
||||
|
||||
if (shaderids.size() == 0)
|
||||
throw love::Exception("Cannot create shader effect: no valid source code!");
|
||||
|
||||
@@ -82,7 +82,7 @@ private:
|
||||
GLuint createShader(const ShaderSource &source);
|
||||
void createProgram(const std::vector<GLuint> &shaders);
|
||||
|
||||
std::vector<ShaderSource> _shaders; // all shader code attached to this ShaderEffect
|
||||
std::vector<ShaderSource> _shadersources; // list of all shader code attached to this ShaderEffect
|
||||
|
||||
GLuint _program; // volatile
|
||||
|
||||
|
||||
Reference in New Issue
Block a user