[core] Put VertexArrayObject in gl namespace
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -39,7 +39,7 @@ public:
|
||||
|
||||
private:
|
||||
gl::VertexBuffer<PlainVertex> textVertexes;
|
||||
VertexArrayObject array;
|
||||
gl::VertexArrayObject array;
|
||||
};
|
||||
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -192,7 +192,7 @@ private:
|
||||
gl::VertexBuffer<PlainVertex> tileLineStripVertexes;
|
||||
gl::VertexBuffer<RasterVertex> rasterVertexes;
|
||||
|
||||
VertexArrayObject tileBorderArray;
|
||||
gl::VertexArrayObject tileBorderArray;
|
||||
};
|
||||
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user