diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2016-10-26 17:19:19 -0700 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2016-11-01 18:41:52 +0100 |
commit | 358701f475b2c04c4681d70435bc76370b371285 (patch) | |
tree | 7ab5d170957eb8d209716f695aec428a44d4ddf2 /src/mbgl/gl/context.hpp | |
parent | 9e3839781fdf1b1c6a2d61a5de9b2c7ddd68e9ed (diff) | |
download | qtlocation-mapboxgl-358701f475b2c04c4681d70435bc76370b371285.tar.gz |
[core] add ability to upload alpha-only textures + images
Diffstat (limited to 'src/mbgl/gl/context.hpp')
-rw-r--r-- | src/mbgl/gl/context.hpp | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/mbgl/gl/context.hpp b/src/mbgl/gl/context.hpp index ae2b71994f..4e9320f7d1 100644 --- a/src/mbgl/gl/context.hpp +++ b/src/mbgl/gl/context.hpp @@ -65,18 +65,22 @@ public: // Create a texture from an image with data. template <typename Image> Texture createTexture(const Image& image, TextureUnit unit = 0) { - return { image.size, createTexture(image.size, image.data.get(), unit) }; + auto format = image.channels == 4 ? TextureFormat::RGBA : TextureFormat::Alpha; + return { image.size, createTexture(image.size, image.data.get(), format, unit) }; } template <typename Image> void updateTexture(Texture& obj, const Image& image, TextureUnit unit = 0) { - updateTexture(obj.texture.get(), image.size, image.data.get(), unit); + auto format = image.channels == 4 ? TextureFormat::RGBA : TextureFormat::Alpha; + updateTexture(obj.texture.get(), image.size, image.data.get(), format, unit); obj.size = image.size; } // Creates an empty texture with the specified dimensions. - Texture createTexture(const Size size, TextureUnit unit = 0) { - return { size, createTexture(size, nullptr, unit) }; + Texture createTexture(const Size size, + TextureFormat format = TextureFormat::RGBA, + TextureUnit unit = 0) { + return { size, createTexture(size, nullptr, format, unit) }; } void bindTexture(Texture&, @@ -153,8 +157,8 @@ private: UniqueBuffer createVertexBuffer(const void* data, std::size_t size); UniqueBuffer createIndexBuffer(const void* data, std::size_t size); - UniqueTexture createTexture(Size size, const void* data, TextureUnit); - void updateTexture(TextureID, Size size, const void* data, TextureUnit); + UniqueTexture createTexture(Size size, const void* data, TextureFormat, TextureUnit); + void updateTexture(TextureID, Size size, const void* data, TextureFormat, TextureUnit); UniqueFramebuffer createFramebuffer(); UniqueRenderbuffer createRenderbuffer(RenderbufferType, Size size); |