mirror of
https://github.com/love2d/love.git
synced 2026-08-17 11:00:31 +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;
|
std::vector<int> ShaderEffect::_texture_id_counters;
|
||||||
|
|
||||||
ShaderEffect::ShaderEffect(const std::vector<ShaderSource> &shadersources)
|
ShaderEffect::ShaderEffect(const std::vector<ShaderSource> &shadersources)
|
||||||
: _program(0)
|
: _shadersources(shadersources)
|
||||||
|
, _program(0)
|
||||||
{
|
{
|
||||||
if (shadersources.size() == 0)
|
if (shadersources.size() == 0)
|
||||||
throw love::Exception("Cannot create shader effect: no source code!");
|
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;
|
GLint maxtextureunits;
|
||||||
glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &maxtextureunits);
|
glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &maxtextureunits);
|
||||||
_max_texture_units = std::max(maxtextureunits - 1, 0);
|
_max_texture_units = std::max(maxtextureunits - 1, 0);
|
||||||
@@ -193,9 +189,9 @@ bool ShaderEffect::loadVolatile()
|
|||||||
|
|
||||||
std::vector<GLuint> shaderids;
|
std::vector<GLuint> shaderids;
|
||||||
|
|
||||||
std::vector<ShaderSource>::const_iterator curshader;
|
std::vector<ShaderSource>::const_iterator cursource;
|
||||||
for (curshader = _shaders.begin(); curshader != _shaders.end(); ++curshader)
|
for (cursource = _shadersources.begin(); cursource != _shadersources.end(); ++cursource)
|
||||||
shaderids.push_back(createShader(*curshader));
|
shaderids.push_back(createShader(*cursource));
|
||||||
|
|
||||||
if (shaderids.size() == 0)
|
if (shaderids.size() == 0)
|
||||||
throw love::Exception("Cannot create shader effect: no valid source code!");
|
throw love::Exception("Cannot create shader effect: no valid source code!");
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ private:
|
|||||||
GLuint createShader(const ShaderSource &source);
|
GLuint createShader(const ShaderSource &source);
|
||||||
void createProgram(const std::vector<GLuint> &shaders);
|
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
|
GLuint _program; // volatile
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user