Use initializer list copy constructor instead of per-element copying for shader source list in ShaderEffect constructor

This commit is contained in:
Alexander Szpakowski
2012-12-23 00:29:23 -04:00
parent 83204c5dc5
commit 3047321e71
2 changed files with 6 additions and 10 deletions
+5 -9
View File
@@ -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!");
+1 -1
View File
@@ -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