File tree Expand file tree Collapse file tree 2 files changed +6
-2
lines changed
libopenage/renderer/opengl Expand file tree Collapse file tree 2 files changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -424,8 +424,11 @@ void GlShaderProgram::update_uniforms(std::shared_ptr<GlUniformInput> const &uni
424424 glBindTexture (GL_TEXTURE_2D, tex);
425425 // TODO: maybe call this at a more appropriate position
426426 glUniform1i (loc, tex_unit_id);
427- auto &tex_value = *this ->textures_per_texunits [tex_unit_id];
428- tex_value = tex;
427+ ENSURE (tex_unit_id < this ->textures_per_texunits .size (),
428+ " Tried to assign texture to non-existant texture unit at index "
429+ << tex_unit_id
430+ << " (max: " << this ->textures_per_texunits .size () << " )." );
431+ this ->textures_per_texunits [tex_unit_id] = tex;
429432 break ;
430433 }
431434 default :
Original file line number Diff line number Diff line change @@ -195,6 +195,7 @@ class GlShaderProgram final : public ShaderProgram
195195 std::unordered_map<std::string, GlVertexAttrib> attribs;
196196
197197 // / Store which texture handles are currently bound to the shader's texture units.
198+ // / A value of std::nullopt means the texture unit is unbound (no texture assigned).
198199 std::vector<std::optional<GLuint>> textures_per_texunits;
199200
200201 // / Whether this program has been validated.
You can’t perform that action at this time.
0 commit comments