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 | |
parent | 73334ac8fa330af05dd91906a4e5d1bbda7d5c34 (diff) | |
download | qtlocation-mapboxgl-b9b8657d43aa1172e9ca6be162e915006806ee57.tar.gz |
[core] Put VertexArrayObject in gl namespace
Diffstat (limited to 'src')
-rw-r--r-- | src/mbgl/gl/vao.cpp | 18 | ||||
-rw-r--r-- | src/mbgl/gl/vao.hpp | 36 | ||||
-rw-r--r-- | src/mbgl/renderer/debug_bucket.hpp | 2 | ||||
-rw-r--r-- | src/mbgl/renderer/painter.hpp | 2 | ||||
-rw-r--r-- | src/mbgl/renderer/raster_bucket.cpp | 4 | ||||
-rw-r--r-- | src/mbgl/renderer/raster_bucket.hpp | 9 | ||||
-rw-r--r-- | src/mbgl/shader/shaders.hpp | 8 |
7 files changed, 42 insertions, 37 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 diff --git a/src/mbgl/renderer/debug_bucket.hpp b/src/mbgl/renderer/debug_bucket.hpp index 59c1e315ea..86ccc6a1b7 100644 --- a/src/mbgl/renderer/debug_bucket.hpp +++ b/src/mbgl/renderer/debug_bucket.hpp @@ -39,7 +39,7 @@ public: private: gl::VertexBuffer<PlainVertex> textVertexes; - VertexArrayObject array; + gl::VertexArrayObject array; }; } // namespace mbgl diff --git a/src/mbgl/renderer/painter.hpp b/src/mbgl/renderer/painter.hpp index 55f5c654b9..c33ad47020 100644 --- a/src/mbgl/renderer/painter.hpp +++ b/src/mbgl/renderer/painter.hpp @@ -192,7 +192,7 @@ private: gl::VertexBuffer<PlainVertex> tileLineStripVertexes; gl::VertexBuffer<RasterVertex> rasterVertexes; - VertexArrayObject tileBorderArray; + gl::VertexArrayObject tileBorderArray; }; } // namespace mbgl diff --git a/src/mbgl/renderer/raster_bucket.cpp b/src/mbgl/renderer/raster_bucket.cpp index c8f3987134..80d6dfe8dd 100644 --- a/src/mbgl/renderer/raster_bucket.cpp +++ b/src/mbgl/renderer/raster_bucket.cpp @@ -3,7 +3,7 @@ #include <mbgl/shader/raster_shader.hpp> #include <mbgl/renderer/painter.hpp> #include <mbgl/gl/gl.hpp> - +#include <mbgl/gl/context.hpp> namespace mbgl { @@ -27,7 +27,7 @@ void RasterBucket::render(Painter& painter, void RasterBucket::drawRaster(RasterShader& shader, gl::VertexBuffer<RasterVertex>& vertices, - VertexArrayObject& array, + gl::VertexArrayObject& array, gl::Context& context) { assert(texture); context.bindTexture(*texture, 0, gl::TextureFilter::Linear); diff --git a/src/mbgl/renderer/raster_bucket.hpp b/src/mbgl/renderer/raster_bucket.hpp index 1a23e62133..b0d3ca49c7 100644 --- a/src/mbgl/renderer/raster_bucket.hpp +++ b/src/mbgl/renderer/raster_bucket.hpp @@ -2,17 +2,18 @@ #include <mbgl/renderer/bucket.hpp> #include <mbgl/util/image.hpp> -#include <mbgl/gl/context.hpp> +#include <mbgl/util/optional.hpp> +#include <mbgl/gl/texture.hpp> namespace mbgl { class RasterShader; class RasterVertex; -class StaticRasterVertexBuffer; -class VertexArrayObject; namespace gl { +class Context; template <class> class VertexBuffer; +class VertexArrayObject; } // namespace gl class RasterBucket : public Bucket { @@ -24,7 +25,7 @@ public: bool hasData() const override; bool needsClipping() const override; - void drawRaster(RasterShader&, gl::VertexBuffer<RasterVertex>&, VertexArrayObject&, gl::Context&); + void drawRaster(RasterShader&, gl::VertexBuffer<RasterVertex>&, gl::VertexArrayObject&, gl::Context&); private: PremultipliedImage image; diff --git a/src/mbgl/shader/shaders.hpp b/src/mbgl/shader/shaders.hpp index 0c54631dd1..b263ee8d0e 100644 --- a/src/mbgl/shader/shaders.hpp +++ b/src/mbgl/shader/shaders.hpp @@ -47,10 +47,10 @@ public: CollisionBoxShader collisionBox; CircleShader circle; - VertexArrayObject coveringPlainArray; - VertexArrayObject coveringRasterArray; - VertexArrayObject backgroundPatternArray; - VertexArrayObject backgroundArray; + gl::VertexArrayObject coveringPlainArray; + gl::VertexArrayObject coveringRasterArray; + gl::VertexArrayObject backgroundPatternArray; + gl::VertexArrayObject backgroundArray; }; } // namespace mbgl |