Use GL_TEXTURE_2D_ARRAY to enable multiple texture atlases

This commit is contained in:
Dan Paulat 2023-09-02 13:44:56 -05:00
parent 922e875b07
commit 7198d1c7af
8 changed files with 36 additions and 15 deletions

View file

@ -92,8 +92,8 @@ void GeoLine::Initialize()
{
gl::OpenGLFunctions& gl = p->context_->gl();
p->shaderProgram_ = p->context_->GetShaderProgram(":/gl/geo_line.vert",
":/gl/texture2d.frag");
p->shaderProgram_ = p->context_->GetShaderProgram(
":/gl/geo_line.vert", ":/gl/texture2d_array.frag");
p->uMVPMatrixLocation_ =
gl.glGetUniformLocation(p->shaderProgram_->id(), "uMVPMatrix");

View file

@ -151,7 +151,7 @@ void PlacefileIcons::Initialize()
p->shaderProgram_ = p->context_->GetShaderProgram(
{{GL_VERTEX_SHADER, ":/gl/geo_texture2d.vert"},
{GL_GEOMETRY_SHADER, ":/gl/threshold.geom"},
{GL_FRAGMENT_SHADER, ":/gl/texture2d.frag"}});
{GL_FRAGMENT_SHADER, ":/gl/texture2d_array.frag"}});
p->uMVPMatrixLocation_ = p->shaderProgram_->GetUniformLocation("uMVPMatrix");
p->uMapMatrixLocation_ = p->shaderProgram_->GetUniformLocation("uMapMatrix");
@ -261,8 +261,8 @@ void PlacefileIcons::Render(
}
// Interpolate texture coordinates
gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
gl.glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
gl.glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
// Draw icons
gl.glDrawArrays(GL_TRIANGLES, 0, p->numVertices_);

View file

@ -129,7 +129,7 @@ void PlacefileImages::Initialize()
p->shaderProgram_ = p->context_->GetShaderProgram(
{{GL_VERTEX_SHADER, ":/gl/geo_texture2d.vert"},
{GL_GEOMETRY_SHADER, ":/gl/threshold.geom"},
{GL_FRAGMENT_SHADER, ":/gl/texture2d.frag"}});
{GL_FRAGMENT_SHADER, ":/gl/texture2d_array.frag"}});
p->uMVPMatrixLocation_ = p->shaderProgram_->GetUniformLocation("uMVPMatrix");
p->uMapMatrixLocation_ = p->shaderProgram_->GetUniformLocation("uMapMatrix");
@ -230,8 +230,8 @@ void PlacefileImages::Render(
}
// Interpolate texture coordinates
gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
gl.glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
gl.glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
// Draw images
gl.glDrawArrays(GL_TRIANGLES, 0, p->numVertices_);