summaryrefslogtreecommitdiff
path: root/src/mbgl/gl/context.hpp
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2016-10-04 12:45:11 +0200
committerJohn Firebaugh <john.firebaugh@gmail.com>2016-10-04 14:00:30 -0700
commit07315711d6b191a5812065bb76ab5beb33d995d9 (patch)
tree89afc1b90ac64660596ffb94512bbd23adbf80cc /src/mbgl/gl/context.hpp
parente103d92b1814fc3a735c05ce9be70be3409c201a (diff)
downloadqtlocation-mapboxgl-07315711d6b191a5812065bb76ab5beb33d995d9.tar.gz
[core] remove Raster object in favor of a more low-level Texture object
Diffstat (limited to 'src/mbgl/gl/context.hpp')
-rw-r--r--src/mbgl/gl/context.hpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/mbgl/gl/context.hpp b/src/mbgl/gl/context.hpp
index 04089c2000..0ec846033a 100644
--- a/src/mbgl/gl/context.hpp
+++ b/src/mbgl/gl/context.hpp
@@ -3,6 +3,7 @@
#include <mbgl/gl/object.hpp>
#include <mbgl/gl/state.hpp>
#include <mbgl/gl/value.hpp>
+#include <mbgl/gl/texture.hpp>
#include <mbgl/util/noncopyable.hpp>
#include <memory>
@@ -28,6 +29,23 @@ public:
void uploadBuffer(BufferType, size_t, void*);
+ // Create a texture from an image with data.
+ template <typename Image>
+ Texture createTexture(const Image& image, TextureUnit unit = 0) {
+ return { {{ image.width, image.height }},
+ createTexture(image.width, image.height, image.data.get(), unit) };
+ }
+
+ // Creates an empty texture with the specified dimensions.
+ Texture createTexture(const std::array<uint16_t, 2>& size, TextureUnit unit = 0) {
+ return { size, createTexture(size[0], size[1], nullptr, unit) };
+ }
+
+ void bindTexture(Texture&,
+ TextureUnit = 0,
+ TextureFilter = TextureFilter::Nearest,
+ TextureMipMap = TextureMipMap::No);
+
// Actually remove the objects we marked as abandoned with the above methods.
// Only call this while the OpenGL context is exclusive to this thread.
void performCleanup();
@@ -80,6 +98,9 @@ public:
State<value::BindVertexArray> vertexArrayObject;
private:
+ UniqueTexture createTexture(uint16_t width, uint16_t height, const void* data, TextureUnit);
+
+private:
friend detail::ProgramDeleter;
friend detail::ShaderDeleter;
friend detail::BufferDeleter;