From 3047321e71f81d846dbe45c0d7637e5e9208ea92 Mon Sep 17 00:00:00 2001 From: Alexander Szpakowski Date: Sun, 23 Dec 2012 00:29:23 -0400 Subject: [PATCH] Use initializer list copy constructor instead of per-element copying for shader source list in ShaderEffect constructor --- src/modules/graphics/opengl/ShaderEffect.cpp | 14 +++++--------- src/modules/graphics/opengl/ShaderEffect.h | 2 +- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/modules/graphics/opengl/ShaderEffect.cpp b/src/modules/graphics/opengl/ShaderEffect.cpp index d4a37272c..d57f15e60 100644 --- a/src/modules/graphics/opengl/ShaderEffect.cpp +++ b/src/modules/graphics/opengl/ShaderEffect.cpp @@ -60,16 +60,12 @@ GLint ShaderEffect::_max_texture_units = 0; std::vector ShaderEffect::_texture_id_counters; ShaderEffect::ShaderEffect(const std::vector &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::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 shaderids; - std::vector::const_iterator curshader; - for (curshader = _shaders.begin(); curshader != _shaders.end(); ++curshader) - shaderids.push_back(createShader(*curshader)); + std::vector::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!"); diff --git a/src/modules/graphics/opengl/ShaderEffect.h b/src/modules/graphics/opengl/ShaderEffect.h index 3f35d4307..421ffd9a7 100644 --- a/src/modules/graphics/opengl/ShaderEffect.h +++ b/src/modules/graphics/opengl/ShaderEffect.h @@ -82,7 +82,7 @@ private: GLuint createShader(const ShaderSource &source); void createProgram(const std::vector &shaders); - std::vector _shaders; // all shader code attached to this ShaderEffect + std::vector _shadersources; // list of all shader code attached to this ShaderEffect GLuint _program; // volatile