summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2022-10-30 17:08:59 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2022-10-30 17:08:59 +0000
commitd63f393b7bcabd7f6569b87a2dedbc8333c47554 (patch)
treea34b8f2cb32381f912f85d9cd6fb2c0dfd8a3e6f
parentEditNetworkOf constructor may have single param, should be explicit (diff)
downloadilt-d63f393b7bcabd7f6569b87a2dedbc8333c47554.tar.bz2
ilt-d63f393b7bcabd7f6569b87a2dedbc8333c47554.tar.xz
ilt-d63f393b7bcabd7f6569b87a2dedbc8333c47554.zip
Setting texture unit on bind
Always sets the target unit before binding, allows specifying the unit
-rw-r--r--game/network/network.impl.h2
-rw-r--r--game/terrain.cpp4
-rw-r--r--game/vehicles/railVehicleClass.cpp2
-rw-r--r--gfx/models/texture.cpp3
-rw-r--r--gfx/models/texture.h2
-rw-r--r--ui/editNetwork.cpp2
6 files changed, 8 insertions, 7 deletions
diff --git a/game/network/network.impl.h b/game/network/network.impl.h
index 5b1649d..597e3aa 100644
--- a/game/network/network.impl.h
+++ b/game/network/network.impl.h
@@ -8,7 +8,7 @@ NetworkOf<T>::render(const Shader & shader) const
{
if constexpr (std::is_base_of_v<Renderable, T>) {
shader.setModel(Location {}, Shader::Program::StaticPos);
- texture->Bind();
+ texture->bind();
links.apply(&Renderable::render, shader);
}
}
diff --git a/game/terrain.cpp b/game/terrain.cpp
index 10a6215..3a35c42 100644
--- a/game/terrain.cpp
+++ b/game/terrain.cpp
@@ -86,11 +86,11 @@ void
Terrain::render(const Shader & shader) const
{
shader.setModel(Location {}, Shader::Program::LandMass);
- grass->Bind();
+ grass->bind();
meshes.apply(&Mesh::Draw);
shader.setModel(Location {}, Shader::Program::Water);
shader.setUniform("waves", {waveCycle, 0, 0});
- water->Bind();
+ water->bind();
meshes.apply(&Mesh::Draw);
}
diff --git a/game/vehicles/railVehicleClass.cpp b/game/vehicles/railVehicleClass.cpp
index 689e1e6..7eb4495 100644
--- a/game/vehicles/railVehicleClass.cpp
+++ b/game/vehicles/railVehicleClass.cpp
@@ -41,7 +41,7 @@ RailVehicleClass::RailVehicleClass(std::unique_ptr<ObjParser> o, std::shared_ptr
void
RailVehicleClass::render(const Shader & shader, const Location & location, const std::array<Location, 2> & bl) const
{
- texture->Bind();
+ texture->bind();
for (auto b = 0U; b < bogies.size(); ++b) {
shader.setModel(bl[b]);
bogies[b]->Draw();
diff --git a/gfx/models/texture.cpp b/gfx/models/texture.cpp
index 60e4045..ab04f4f 100644
--- a/gfx/models/texture.cpp
+++ b/gfx/models/texture.cpp
@@ -31,7 +31,8 @@ Texture::Texture(GLsizei width, GLsizei height, const void * data)
}
void
-Texture::Bind() const
+Texture::bind(GLenum unit) const
{
+ glActiveTexture(unit);
glBindTexture(GL_TEXTURE_2D, m_texture);
}
diff --git a/gfx/models/texture.h b/gfx/models/texture.h
index c3deb7b..2bbf1f4 100644
--- a/gfx/models/texture.h
+++ b/gfx/models/texture.h
@@ -15,7 +15,7 @@ public:
static Cache<Texture, std::filesystem::path> cachedTexture;
- void Bind() const;
+ void bind(GLenum unit = GL_TEXTURE0) const;
private:
glTexture m_texture;
diff --git a/ui/editNetwork.cpp b/ui/editNetwork.cpp
index df1be8f..277407f 100644
--- a/ui/editNetwork.cpp
+++ b/ui/editNetwork.cpp
@@ -50,7 +50,7 @@ void
EditNetwork::render(const Shader & shader) const
{
if (builder) {
- blue.Bind();
+ blue.bind();
shader.setModel(Location {}, Shader::Program::StaticPos);
builder->render(shader);
}