[gl] Added mbgl::gl::ProgramHolder

This commit is contained in:
Bruno de Oliveira Abinader
2016-02-14 17:55:39 +02:00
parent bfafc360a7
commit 69fa8fe3c0
4 changed files with 59 additions and 30 deletions

View File

@@ -1,5 +1,5 @@
#include <mbgl/gl/gl_object_store.hpp>
#include <mbgl/util/thread_context.hpp>
#include <mbgl/util/thread.hpp>
#include <mbgl/geometry/vao.hpp>
#include <mbgl/gl/gl.hpp>
@@ -9,6 +9,19 @@
namespace mbgl {
namespace gl {
void ProgramHolder::create() {
if (id) return;
assert(util::ThreadContext::currentlyOn(util::ThreadType::Map));
id = MBGL_CHECK_ERROR(glCreateProgram());
}
void ProgramHolder::reset() {
if (!id) return;
assert(util::ThreadContext::currentlyOn(util::ThreadType::Map));
MBGL_CHECK_ERROR(glDeleteProgram(id));
id = 0;
}
void GLObjectStore::abandonVAO(GLuint vao) {
assert(util::ThreadContext::currentlyOn(util::ThreadType::Map));
abandonedVAOs.emplace_back(vao);