Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tex unit assignment to std::optional type #1695

Merged
merged 1 commit into from
Oct 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions libopenage/renderer/opengl/shader_program.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -424,8 +424,11 @@ void GlShaderProgram::update_uniforms(std::shared_ptr<GlUniformInput> const &uni
glBindTexture(GL_TEXTURE_2D, tex);
// TODO: maybe call this at a more appropriate position
glUniform1i(loc, tex_unit_id);
auto &tex_value = *this->textures_per_texunits[tex_unit_id];
tex_value = tex;
ENSURE(tex_unit_id < this->textures_per_texunits.size(),
"Tried to assign texture to non-existant texture unit at index "
<< tex_unit_id
<< " (max: " << this->textures_per_texunits.size() << ").");
this->textures_per_texunits[tex_unit_id] = tex;
break;
}
default:
Expand Down
1 change: 1 addition & 0 deletions libopenage/renderer/opengl/shader_program.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ class GlShaderProgram final : public ShaderProgram
std::unordered_map<std::string, GlVertexAttrib> attribs;

/// Store which texture handles are currently bound to the shader's texture units.
/// A value of std::nullopt means the texture unit is unbound (no texture assigned).
std::vector<std::optional<GLuint>> textures_per_texunits;

/// Whether this program has been validated.
Expand Down
Loading