load VAO extension

This commit is contained in:
Konstantin Käfer
2014-11-07 18:17:24 +01:00
parent 7e65c88b46
commit 582d616deb
10 changed files with 118 additions and 51 deletions

View File

@@ -1,20 +1,30 @@
#include <mbgl/geometry/vao.hpp>
#include <mbgl/platform/log.hpp>
namespace mbgl {
#if GL_ARB_vertex_array_object
VertexArrayObject::~VertexArrayObject() {
if (!gl::DeleteVertexArrays) return;
if (vao) {
glDeleteVertexArrays(1, &vao);
gl::DeleteVertexArrays(1, &vao);
}
}
void VertexArrayObject::bindVertexArrayObject() {
if (!vao) {
glGenVertexArrays(1, &vao);
if (!gl::GenVertexArrays || !gl::BindVertexArray) {
static bool reported = false;
if (!reported) {
Log::Warning(Event::OpenGL, "Not using Vertex Array Objects");
reported = true;
}
return;
}
glBindVertexArray(vao);
if (!vao) {
gl::GenVertexArrays(1, &vao);
}
gl::BindVertexArray(vao);
}
void VertexArrayObject::verifyBinding(Shader &shader, GLuint vertexBuffer, GLuint elementsBuffer,
@@ -41,6 +51,4 @@ void VertexArrayObject::storeBinding(Shader &shader, GLuint vertexBuffer, GLuint
bound_elements_buffer = elementsBuffer;
}
#endif
}