diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2016-09-30 12:29:39 -0700 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2016-10-05 10:52:19 -0700 |
commit | b9b8657d43aa1172e9ca6be162e915006806ee57 (patch) | |
tree | 5b6db500e346f68f11cb0ad1b9333d32b1054099 /src/mbgl/gl | |
parent | 73334ac8fa330af05dd91906a4e5d1bbda7d5c34 (diff) | |
download | qtlocation-mapboxgl-b9b8657d43aa1172e9ca6be162e915006806ee57.tar.gz |
[core] Put VertexArrayObject in gl namespace
Diffstat (limited to 'src/mbgl/gl')
-rw-r--r-- | src/mbgl/gl/vao.cpp | 18 | ||||
-rw-r--r-- | src/mbgl/gl/vao.hpp | 36 |
2 files changed, 29 insertions, 25 deletions
diff --git a/src/mbgl/gl/vao.cpp b/src/mbgl/gl/vao.cpp index 26a03a8a16..87c03ac23e 100644 --- a/src/mbgl/gl/vao.cpp +++ b/src/mbgl/gl/vao.cpp @@ -5,14 +5,15 @@ #include <mbgl/gl/gl.hpp> namespace mbgl { +namespace gl { VertexArrayObject::VertexArrayObject() { } VertexArrayObject::~VertexArrayObject() = default; -void VertexArrayObject::bindVertexArrayObject(gl::Context& context) { - if (!gl::GenVertexArrays || !gl::BindVertexArray) { +void VertexArrayObject::bindVertexArrayObject(Context& context) { + if (!GenVertexArrays || !BindVertexArray) { static bool reported = false; if (!reported) { Log::Warning(Event::OpenGL, "Not using Vertex Array Objects"); @@ -30,9 +31,9 @@ void VertexArrayObject::bindVertexArrayObject(gl::Context& context) { context.vertexArrayObject = *vertexArray; } -void VertexArrayObject::verifyBinding(gl::Shader& shader, - gl::BufferID vertexBuffer, - gl::BufferID elementsBuffer, +void VertexArrayObject::verifyBinding(Shader& shader, + BufferID vertexBuffer, + BufferID elementsBuffer, int8_t* offset) { if (bound_shader != shader.getID()) { throw std::runtime_error(std::string("trying to rebind VAO to another shader from " + @@ -47,9 +48,9 @@ void VertexArrayObject::verifyBinding(gl::Shader& shader, } } -void VertexArrayObject::storeBinding(gl::Shader& shader, - gl::BufferID vertexBuffer, - gl::BufferID elementsBuffer, +void VertexArrayObject::storeBinding(Shader& shader, + BufferID vertexBuffer, + BufferID elementsBuffer, int8_t* offset) { bound_shader = shader.getID(); bound_shader_name = shader.name; @@ -58,4 +59,5 @@ void VertexArrayObject::storeBinding(gl::Shader& shader, bound_elements_buffer = elementsBuffer; } +} // namespace gl } // namespace mbgl diff --git a/src/mbgl/gl/vao.hpp b/src/mbgl/gl/vao.hpp index bedc3abbc7..3fe307ed4d 100644 --- a/src/mbgl/gl/vao.hpp +++ b/src/mbgl/gl/vao.hpp @@ -9,6 +9,7 @@ #include <stdexcept> namespace mbgl { +namespace gl { class VertexArrayObject : public util::noncopyable { public: @@ -17,9 +18,9 @@ public: template <typename Shader, typename T> void bind(Shader& shader, - const gl::VertexBuffer<T>& vertexBuffer, + const VertexBuffer<T>& vertexBuffer, int8_t* offset, - gl::Context& context) { + Context& context) { bindVertexArrayObject(context); if (bound_shader == 0) { context.vertexBuffer = vertexBuffer.buffer; @@ -34,10 +35,10 @@ public: template <typename Shader, typename T, typename P> void bind(Shader& shader, - const gl::VertexBuffer<T>& vertexBuffer, - const gl::IndexBuffer<P>& indexBuffer, + const VertexBuffer<T>& vertexBuffer, + const IndexBuffer<P>& indexBuffer, int8_t* offset, - gl::Context& context) { + Context& context) { bindVertexArrayObject(context); if (bound_shader == 0) { context.vertexBuffer = vertexBuffer.buffer; @@ -51,30 +52,31 @@ public: } } - gl::VertexArrayID getID() const { + VertexArrayID getID() const { return *vertexArray; } private: - void bindVertexArrayObject(gl::Context&); - void storeBinding(gl::Shader& shader, - gl::BufferID vertexBuffer, - gl::BufferID elementsBuffer, + void bindVertexArrayObject(Context&); + void storeBinding(Shader& shader, + BufferID vertexBuffer, + BufferID elementsBuffer, int8_t* offset); - void verifyBinding(gl::Shader& shader, - gl::BufferID vertexBuffer, - gl::BufferID elementsBuffer, + void verifyBinding(Shader& shader, + BufferID vertexBuffer, + BufferID elementsBuffer, int8_t* offset); - mbgl::optional<gl::UniqueVertexArray> vertexArray; + optional<UniqueVertexArray> vertexArray; // For debug reasons, we're storing the bind information so that we can // detect errors and report - gl::ProgramID bound_shader = 0; + ProgramID bound_shader = 0; const char* bound_shader_name = ""; - gl::BufferID bound_vertex_buffer = 0; - gl::BufferID bound_elements_buffer = 0; + BufferID bound_vertex_buffer = 0; + BufferID bound_elements_buffer = 0; int8_t *bound_offset = nullptr; }; +} // namespace gl } // namespace mbgl |