diff options
author | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2016-05-27 18:33:32 +0300 |
---|---|---|
committer | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2016-06-01 13:53:39 +0300 |
commit | 1b0683b94c070d14bc9f2cf357e551cdbbf3043a (patch) | |
tree | ef8557e284a9a0edb860a49ce3565b7bf622de2d /src/mbgl/sprite/sprite_atlas.cpp | |
parent | 2038a21cb5d67890acafbd34bc55e365ed0043fe (diff) | |
download | qtlocation-mapboxgl-1b0683b94c070d14bc9f2cf357e551cdbbf3043a.tar.gz |
[core] Use unique_resource for GL objects
Source: https://github.com/okdshin/unique_resource
These replace the complexity of manually handling moveable-RAII objects
with a type specific for that purpose.
As suggested in https://github.com/mapbox/mapbox-gl-native/pull/5141#issuecomment-221719872.
Diffstat (limited to 'src/mbgl/sprite/sprite_atlas.cpp')
-rw-r--r-- | src/mbgl/sprite/sprite_atlas.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/mbgl/sprite/sprite_atlas.cpp b/src/mbgl/sprite/sprite_atlas.cpp index d4d462b339..5d7d01deb3 100644 --- a/src/mbgl/sprite/sprite_atlas.cpp +++ b/src/mbgl/sprite/sprite_atlas.cpp @@ -142,9 +142,9 @@ void SpriteAtlas::copy(const Holder& holder, const bool wrap) { dirty = true; } -void SpriteAtlas::upload(gl::ObjectStore& store) { +void SpriteAtlas::upload(gl::ObjectStore& objectStore) { if (dirty) { - bind(false, store); + bind(false, objectStore); } } @@ -179,14 +179,14 @@ void SpriteAtlas::updateDirty() { } } -void SpriteAtlas::bind(bool linear, gl::ObjectStore& store) { +void SpriteAtlas::bind(bool linear, gl::ObjectStore& objectStore) { if (!data) { return; // Empty atlas } - if (!texture.created()) { - texture.create(store); - MBGL_CHECK_ERROR(glBindTexture(GL_TEXTURE_2D, texture.getID())); + if (!texture) { + texture = objectStore.createTexture(); + MBGL_CHECK_ERROR(glBindTexture(GL_TEXTURE_2D, *texture)); #ifndef GL_ES_VERSION_2_0 MBGL_CHECK_ERROR(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0)); #endif @@ -196,7 +196,7 @@ void SpriteAtlas::bind(bool linear, gl::ObjectStore& store) { MBGL_CHECK_ERROR(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE)); fullUploadRequired = true; } else { - MBGL_CHECK_ERROR(glBindTexture(GL_TEXTURE_2D, texture.getID())); + MBGL_CHECK_ERROR(glBindTexture(GL_TEXTURE_2D, *texture)); } GLuint filter_val = linear ? GL_LINEAR : GL_NEAREST; |