diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2016-10-26 18:06:36 -0700 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2016-11-01 18:41:52 +0100 |
commit | ed155460d3ec3777bfd95ce3d40c809e583b07de (patch) | |
tree | ce362d4154cc300b75d78ff8051ebf782834f044 /src/mbgl/gl | |
parent | 7b50cac49f353524457e16d3f342299e0886e963 (diff) | |
download | qtlocation-mapboxgl-ed155460d3ec3777bfd95ce3d40c809e583b07de.tar.gz |
[core] convert LineAtlas to use managed texture handling
Diffstat (limited to 'src/mbgl/gl')
-rw-r--r-- | src/mbgl/gl/context.cpp | 41 | ||||
-rw-r--r-- | src/mbgl/gl/context.hpp | 4 | ||||
-rw-r--r-- | src/mbgl/gl/texture.hpp | 2 | ||||
-rw-r--r-- | src/mbgl/gl/types.hpp | 1 |
4 files changed, 36 insertions, 12 deletions
diff --git a/src/mbgl/gl/context.cpp b/src/mbgl/gl/context.cpp index 41f02b6364..fc35028473 100644 --- a/src/mbgl/gl/context.cpp +++ b/src/mbgl/gl/context.cpp @@ -211,19 +211,38 @@ void Context::updateTexture( void Context::bindTexture(Texture& obj, TextureUnit unit, TextureFilter filter, - TextureMipMap mipmap) { - if (filter != obj.filter || mipmap != obj.mipmap) { + TextureMipMap mipmap, + TextureWrap wrapX, + TextureWrap wrapY) { + if (filter != obj.filter || mipmap != obj.mipmap || wrapX != obj.wrapX || wrapY != obj.wrapY) { activeTexture = unit; texture[unit] = obj.texture; - MBGL_CHECK_ERROR(glTexParameteri( - GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, - filter == TextureFilter::Linear - ? (mipmap == TextureMipMap::Yes ? GL_LINEAR_MIPMAP_NEAREST : GL_LINEAR) - : (mipmap == TextureMipMap::Yes ? GL_NEAREST_MIPMAP_NEAREST : GL_NEAREST))); - MBGL_CHECK_ERROR(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, - filter == TextureFilter::Linear ? GL_LINEAR : GL_NEAREST)); - obj.filter = filter; - obj.mipmap = mipmap; + + if (filter != obj.filter || mipmap != obj.mipmap) { + MBGL_CHECK_ERROR(glTexParameteri( + GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, + filter == TextureFilter::Linear + ? (mipmap == TextureMipMap::Yes ? GL_LINEAR_MIPMAP_NEAREST : GL_LINEAR) + : (mipmap == TextureMipMap::Yes ? GL_NEAREST_MIPMAP_NEAREST : GL_NEAREST))); + MBGL_CHECK_ERROR( + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, + filter == TextureFilter::Linear ? GL_LINEAR : GL_NEAREST)); + obj.filter = filter; + obj.mipmap = mipmap; + } + if (wrapX != obj.wrapX) { + + MBGL_CHECK_ERROR( + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, + wrapX == TextureWrap::Clamp ? GL_CLAMP_TO_EDGE : GL_REPEAT)); + obj.wrapX = wrapX; + } + if (wrapY != obj.wrapY) { + MBGL_CHECK_ERROR( + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, + wrapY == TextureWrap::Clamp ? GL_CLAMP_TO_EDGE : GL_REPEAT)); + obj.wrapY = wrapY; + } } else if (texture[unit] != obj.texture) { // We are checking first to avoid setting the active texture without a subsequent // texture bind. diff --git a/src/mbgl/gl/context.hpp b/src/mbgl/gl/context.hpp index 4e9320f7d1..e0f9b871cc 100644 --- a/src/mbgl/gl/context.hpp +++ b/src/mbgl/gl/context.hpp @@ -86,7 +86,9 @@ public: void bindTexture(Texture&, TextureUnit = 0, TextureFilter = TextureFilter::Nearest, - TextureMipMap = TextureMipMap::No); + TextureMipMap = TextureMipMap::No, + TextureWrap wrapX = TextureWrap::Clamp, + TextureWrap wrapY = TextureWrap::Clamp); void clear(optional<mbgl::Color> color, optional<float> depth, diff --git a/src/mbgl/gl/texture.hpp b/src/mbgl/gl/texture.hpp index 802dac9eb2..5330689ac2 100644 --- a/src/mbgl/gl/texture.hpp +++ b/src/mbgl/gl/texture.hpp @@ -12,6 +12,8 @@ public: UniqueTexture texture; TextureFilter filter = TextureFilter::Nearest; TextureMipMap mipmap = TextureMipMap::No; + TextureWrap wrapX = TextureWrap::Clamp; + TextureWrap wrapY = TextureWrap::Clamp; }; } // namespace gl diff --git a/src/mbgl/gl/types.hpp b/src/mbgl/gl/types.hpp index 10cf0a9730..16a37d58c1 100644 --- a/src/mbgl/gl/types.hpp +++ b/src/mbgl/gl/types.hpp @@ -46,6 +46,7 @@ enum class RenderbufferType : uint32_t { enum class TextureMipMap : bool { No = false, Yes = true }; enum class TextureFilter : bool { Nearest = false, Linear = true }; +enum class TextureWrap : bool { Clamp, Repeat }; enum class TextureFormat : uint32_t { RGBA = 0x1908, Alpha = 0x1906, |