[core] rename gl::Config to gl::Context
This commit is contained in:
committed by
John Firebaugh
parent
21386b3146
commit
ce42d22984
@@ -77,11 +77,10 @@ set(MBGL_CORE_FILES
|
||||
|
||||
# gl
|
||||
include/mbgl/gl/gl.hpp
|
||||
include/mbgl/gl/gl_helper.hpp
|
||||
src/mbgl/gl/context.hpp
|
||||
src/mbgl/gl/debugging.cpp
|
||||
src/mbgl/gl/debugging.hpp
|
||||
src/mbgl/gl/gl.cpp
|
||||
src/mbgl/gl/gl_config.hpp
|
||||
src/mbgl/gl/object_store.cpp
|
||||
src/mbgl/gl/object_store.hpp
|
||||
src/mbgl/gl/state.hpp
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
#include <mbgl/gl/gl.hpp>
|
||||
#include <mbgl/gl/object_store.hpp>
|
||||
#include <mbgl/gl/gl_config.hpp>
|
||||
#include <mbgl/gl/context.hpp>
|
||||
#include <mbgl/platform/log.hpp>
|
||||
#include <mbgl/util/noncopyable.hpp>
|
||||
#include <mbgl/util/optional.hpp>
|
||||
@@ -40,16 +40,16 @@ public:
|
||||
}
|
||||
|
||||
// Transfers this buffer to the GPU and binds the buffer to the GL context.
|
||||
void bind(gl::ObjectStore& store, gl::Config& config) {
|
||||
void bind(gl::ObjectStore& store, gl::Context& context) {
|
||||
const bool initialized { buffer };
|
||||
if (!initialized) {
|
||||
buffer = store.createBuffer();
|
||||
}
|
||||
|
||||
if (target == GL_ARRAY_BUFFER) {
|
||||
config.vertexBuffer = *buffer;
|
||||
context.vertexBuffer = *buffer;
|
||||
} else {
|
||||
config.elementBuffer = *buffer;
|
||||
context.elementBuffer = *buffer;
|
||||
}
|
||||
|
||||
if (!initialized) {
|
||||
@@ -76,9 +76,9 @@ public:
|
||||
}
|
||||
|
||||
// Uploads the buffer to the GPU to be available when we need it.
|
||||
void upload(gl::ObjectStore& store, gl::Config& config) {
|
||||
void upload(gl::ObjectStore& store, gl::Context& context) {
|
||||
if (!buffer) {
|
||||
bind(store, config);
|
||||
bind(store, context);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include <mbgl/geometry/line_atlas.hpp>
|
||||
#include <mbgl/gl/gl.hpp>
|
||||
#include <mbgl/gl/object_store.hpp>
|
||||
#include <mbgl/gl/gl_config.hpp>
|
||||
#include <mbgl/gl/context.hpp>
|
||||
#include <mbgl/platform/log.hpp>
|
||||
#include <mbgl/platform/platform.hpp>
|
||||
|
||||
@@ -121,30 +121,30 @@ LinePatternPos LineAtlas::addDash(const std::vector<float>& dasharray, LinePatte
|
||||
return position;
|
||||
}
|
||||
|
||||
void LineAtlas::upload(gl::ObjectStore& store, gl::Config& config, uint32_t unit) {
|
||||
void LineAtlas::upload(gl::ObjectStore& store, gl::Context& context, uint32_t unit) {
|
||||
if (dirty) {
|
||||
bind(store, config, unit);
|
||||
bind(store, context, unit);
|
||||
}
|
||||
}
|
||||
|
||||
void LineAtlas::bind(gl::ObjectStore& store, gl::Config& config, uint32_t unit) {
|
||||
void LineAtlas::bind(gl::ObjectStore& store, gl::Context& context, uint32_t unit) {
|
||||
bool first = false;
|
||||
if (!texture) {
|
||||
texture = store.createTexture();
|
||||
config.activeTexture = unit;
|
||||
config.texture[unit] = *texture;
|
||||
context.activeTexture = unit;
|
||||
context.texture[unit] = *texture;
|
||||
MBGL_CHECK_ERROR(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR));
|
||||
MBGL_CHECK_ERROR(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR));
|
||||
MBGL_CHECK_ERROR(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT));
|
||||
MBGL_CHECK_ERROR(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE));
|
||||
first = true;
|
||||
} else if (config.texture[unit] != *texture) {
|
||||
config.activeTexture = unit;
|
||||
config.texture[unit] = *texture;
|
||||
} else if (context.texture[unit] != *texture) {
|
||||
context.activeTexture = unit;
|
||||
context.texture[unit] = *texture;
|
||||
}
|
||||
|
||||
if (dirty) {
|
||||
config.activeTexture = unit;
|
||||
context.activeTexture = unit;
|
||||
if (first) {
|
||||
MBGL_CHECK_ERROR(glTexImage2D(
|
||||
GL_TEXTURE_2D, // GLenum target
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
namespace mbgl {
|
||||
|
||||
namespace gl {
|
||||
class Config;
|
||||
class Context;
|
||||
} // namespace gl
|
||||
|
||||
typedef struct {
|
||||
@@ -30,11 +30,11 @@ public:
|
||||
~LineAtlas();
|
||||
|
||||
// Binds the atlas texture to the GPU, and uploads data if it is out of date.
|
||||
void bind(gl::ObjectStore&, gl::Config&, uint32_t unit);
|
||||
void bind(gl::ObjectStore&, gl::Context&, uint32_t unit);
|
||||
|
||||
// Uploads the texture to the GPU to be available when we need it. This is a lazy operation;
|
||||
// the texture is only bound when the data is out of date (=dirty).
|
||||
void upload(gl::ObjectStore&, gl::Config&, uint32_t unit);
|
||||
void upload(gl::ObjectStore&, gl::Context&, uint32_t unit);
|
||||
|
||||
LinePatternPos getDashPosition(const std::vector<float>&, LinePatternCap);
|
||||
LinePatternPos addDash(const std::vector<float>& dasharray, LinePatternCap);
|
||||
|
||||
@@ -10,7 +10,7 @@ VertexArrayObject::VertexArrayObject() {
|
||||
|
||||
VertexArrayObject::~VertexArrayObject() = default;
|
||||
|
||||
void VertexArrayObject::bindVertexArrayObject(gl::ObjectStore& store, gl::Config& config) {
|
||||
void VertexArrayObject::bindVertexArrayObject(gl::ObjectStore& store, gl::Context& context) {
|
||||
if (!gl::GenVertexArrays || !gl::BindVertexArray) {
|
||||
static bool reported = false;
|
||||
if (!reported) {
|
||||
@@ -22,11 +22,11 @@ void VertexArrayObject::bindVertexArrayObject(gl::ObjectStore& store, gl::Config
|
||||
|
||||
if (!vao) {
|
||||
vao = store.createVAO();
|
||||
config.vertexBuffer.setDirty();
|
||||
config.elementBuffer.setDirty();
|
||||
context.vertexBuffer.setDirty();
|
||||
context.elementBuffer.setDirty();
|
||||
}
|
||||
|
||||
config.vertexArrayObject = *vao;
|
||||
context.vertexArrayObject = *vao;
|
||||
}
|
||||
|
||||
void VertexArrayObject::verifyBinding(Shader& shader, GLuint vertexBuffer, GLuint elementsBuffer,
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include <mbgl/shader/shader.hpp>
|
||||
#include <mbgl/gl/gl.hpp>
|
||||
#include <mbgl/gl/object_store.hpp>
|
||||
#include <mbgl/gl/gl_config.hpp>
|
||||
#include <mbgl/gl/context.hpp>
|
||||
#include <mbgl/util/noncopyable.hpp>
|
||||
#include <mbgl/util/optional.hpp>
|
||||
|
||||
@@ -21,10 +21,10 @@ public:
|
||||
VertexBuffer& vertexBuffer,
|
||||
GLbyte* offset,
|
||||
gl::ObjectStore& store,
|
||||
gl::Config& config) {
|
||||
bindVertexArrayObject(store, config);
|
||||
gl::Context& context) {
|
||||
bindVertexArrayObject(store, context);
|
||||
if (bound_shader == 0) {
|
||||
vertexBuffer.bind(store, config);
|
||||
vertexBuffer.bind(store, context);
|
||||
shader.bind(offset);
|
||||
if (vao) {
|
||||
storeBinding(shader, vertexBuffer.getID(), 0, offset);
|
||||
@@ -40,11 +40,11 @@ public:
|
||||
ElementsBuffer& elementsBuffer,
|
||||
GLbyte* offset,
|
||||
gl::ObjectStore& store,
|
||||
gl::Config& config) {
|
||||
bindVertexArrayObject(store, config);
|
||||
gl::Context& context) {
|
||||
bindVertexArrayObject(store, context);
|
||||
if (bound_shader == 0) {
|
||||
vertexBuffer.bind(store, config);
|
||||
elementsBuffer.bind(store, config);
|
||||
vertexBuffer.bind(store, context);
|
||||
elementsBuffer.bind(store, context);
|
||||
shader.bind(offset);
|
||||
if (vao) {
|
||||
storeBinding(shader, vertexBuffer.getID(), elementsBuffer.getID(), offset);
|
||||
@@ -59,7 +59,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
void bindVertexArrayObject(gl::ObjectStore&, gl::Config&);
|
||||
void bindVertexArrayObject(gl::ObjectStore&, gl::Context&);
|
||||
void storeBinding(Shader &shader, GLuint vertexBuffer, GLuint elementsBuffer, GLbyte *offset);
|
||||
void verifyBinding(Shader &shader, GLuint vertexBuffer, GLuint elementsBuffer, GLbyte *offset);
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
namespace mbgl {
|
||||
namespace gl {
|
||||
|
||||
class Config {
|
||||
class Context {
|
||||
public:
|
||||
void resetState() {
|
||||
stencilFunc.reset();
|
||||
@@ -17,7 +17,7 @@ class RenderTile;
|
||||
|
||||
namespace gl {
|
||||
class ObjectStore;
|
||||
class Config;
|
||||
class Context;
|
||||
} // namespace gl
|
||||
|
||||
namespace style {
|
||||
@@ -30,7 +30,7 @@ public:
|
||||
|
||||
// As long as this bucket has a Prepare render pass, this function is getting called. Typically,
|
||||
// this only happens once when the bucket is being rendered for the first time.
|
||||
virtual void upload(gl::ObjectStore&, gl::Config&) = 0;
|
||||
virtual void upload(gl::ObjectStore&, gl::Context&) = 0;
|
||||
|
||||
// Every time this bucket is getting rendered, this function is called. This happens either
|
||||
// once or twice (for Opaque and Transparent render passes).
|
||||
|
||||
@@ -16,9 +16,9 @@ CircleBucket::~CircleBucket() {
|
||||
// Do not remove. header file only contains forward definitions to unique pointers.
|
||||
}
|
||||
|
||||
void CircleBucket::upload(gl::ObjectStore& store, gl::Config& config) {
|
||||
vertexBuffer_.upload(store, config);
|
||||
elementsBuffer_.upload(store, config);
|
||||
void CircleBucket::upload(gl::ObjectStore& store, gl::Context& context) {
|
||||
vertexBuffer_.upload(store, context);
|
||||
elementsBuffer_.upload(store, context);
|
||||
uploaded = true;
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ void CircleBucket::addGeometry(const GeometryCollection& geometryCollection) {
|
||||
}
|
||||
}
|
||||
|
||||
void CircleBucket::drawCircles(CircleShader& shader, gl::ObjectStore& store, gl::Config& config) {
|
||||
void CircleBucket::drawCircles(CircleShader& shader, gl::ObjectStore& store, gl::Context& context) {
|
||||
GLbyte* vertexIndex = BUFFER_OFFSET(0);
|
||||
GLbyte* elementsIndex = BUFFER_OFFSET(0);
|
||||
|
||||
@@ -91,7 +91,7 @@ void CircleBucket::drawCircles(CircleShader& shader, gl::ObjectStore& store, gl:
|
||||
|
||||
if (!group->elements_length) continue;
|
||||
|
||||
group->array[0].bind(shader, vertexBuffer_, elementsBuffer_, vertexIndex, store, config);
|
||||
group->array[0].bind(shader, vertexBuffer_, elementsBuffer_, vertexIndex, store, context);
|
||||
|
||||
MBGL_CHECK_ERROR(glDrawElements(GL_TRIANGLES, group->elements_length * 3, GL_UNSIGNED_SHORT, elementsIndex));
|
||||
|
||||
|
||||
@@ -18,14 +18,14 @@ public:
|
||||
CircleBucket(const MapMode);
|
||||
~CircleBucket() override;
|
||||
|
||||
void upload(gl::ObjectStore&, gl::Config&) override;
|
||||
void upload(gl::ObjectStore&, gl::Context&) override;
|
||||
void render(Painter&, PaintParameters&, const style::Layer&, const RenderTile&) override;
|
||||
|
||||
bool hasData() const override;
|
||||
bool needsClipping() const override;
|
||||
void addGeometry(const GeometryCollection&);
|
||||
|
||||
void drawCircles(CircleShader&, gl::ObjectStore&, gl::Config&);
|
||||
void drawCircles(CircleShader&, gl::ObjectStore&, gl::Context&);
|
||||
|
||||
private:
|
||||
CircleVertexBuffer vertexBuffer_;
|
||||
|
||||
@@ -38,16 +38,16 @@ DebugBucket::DebugBucket(const OverscaledTileID& id,
|
||||
}
|
||||
}
|
||||
|
||||
void DebugBucket::drawLines(PlainShader& shader, gl::ObjectStore& store, gl::Config& config) {
|
||||
void DebugBucket::drawLines(PlainShader& shader, gl::ObjectStore& store, gl::Context& context) {
|
||||
if (!fontBuffer.empty()) {
|
||||
array.bind(shader, fontBuffer, BUFFER_OFFSET_0, store, config);
|
||||
array.bind(shader, fontBuffer, BUFFER_OFFSET_0, store, context);
|
||||
MBGL_CHECK_ERROR(glDrawArrays(GL_LINES, 0, (GLsizei)(fontBuffer.index())));
|
||||
}
|
||||
}
|
||||
|
||||
void DebugBucket::drawPoints(PlainShader& shader, gl::ObjectStore& store, gl::Config& config) {
|
||||
void DebugBucket::drawPoints(PlainShader& shader, gl::ObjectStore& store, gl::Context& context) {
|
||||
if (!fontBuffer.empty()) {
|
||||
array.bind(shader, fontBuffer, BUFFER_OFFSET_0, store, config);
|
||||
array.bind(shader, fontBuffer, BUFFER_OFFSET_0, store, context);
|
||||
MBGL_CHECK_ERROR(glDrawArrays(GL_POINTS, 0, (GLsizei)(fontBuffer.index())));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ class PlainShader;
|
||||
|
||||
namespace gl {
|
||||
class ObjectStore;
|
||||
class Config;
|
||||
class Context;
|
||||
} // namespace gl
|
||||
|
||||
class DebugBucket : private util::noncopyable {
|
||||
@@ -24,8 +24,8 @@ public:
|
||||
optional<Timestamp> expires,
|
||||
MapDebugOptions);
|
||||
|
||||
void drawLines(PlainShader&, gl::ObjectStore&, gl::Config&);
|
||||
void drawPoints(PlainShader&, gl::ObjectStore&, gl::Config&);
|
||||
void drawLines(PlainShader&, gl::ObjectStore&, gl::Context&);
|
||||
void drawPoints(PlainShader&, gl::ObjectStore&, gl::Context&);
|
||||
|
||||
const bool renderable;
|
||||
const bool complete;
|
||||
|
||||
@@ -95,10 +95,10 @@ void FillBucket::addGeometry(const GeometryCollection& geometry) {
|
||||
}
|
||||
}
|
||||
|
||||
void FillBucket::upload(gl::ObjectStore& store, gl::Config& config) {
|
||||
vertexBuffer.upload(store, config);
|
||||
triangleElementsBuffer.upload(store, config);
|
||||
lineElementsBuffer.upload(store, config);
|
||||
void FillBucket::upload(gl::ObjectStore& store, gl::Context& context) {
|
||||
vertexBuffer.upload(store, context);
|
||||
triangleElementsBuffer.upload(store, context);
|
||||
lineElementsBuffer.upload(store, context);
|
||||
|
||||
// From now on, we're going to render during the opaque and translucent pass.
|
||||
uploaded = true;
|
||||
@@ -121,14 +121,14 @@ bool FillBucket::needsClipping() const {
|
||||
|
||||
void FillBucket::drawElements(PlainShader& shader,
|
||||
gl::ObjectStore& store,
|
||||
gl::Config& config,
|
||||
gl::Context& context,
|
||||
PaintMode paintMode) {
|
||||
GLbyte* vertex_index = BUFFER_OFFSET(0);
|
||||
GLbyte* elements_index = BUFFER_OFFSET(0);
|
||||
for (auto& group : triangleGroups) {
|
||||
assert(group);
|
||||
group->array[paintMode == PaintMode::Overdraw ? 1 : 0].bind(
|
||||
shader, vertexBuffer, triangleElementsBuffer, vertex_index, store, config);
|
||||
shader, vertexBuffer, triangleElementsBuffer, vertex_index, store, context);
|
||||
MBGL_CHECK_ERROR(glDrawElements(GL_TRIANGLES, group->elements_length * 3, GL_UNSIGNED_SHORT,
|
||||
elements_index));
|
||||
vertex_index += group->vertex_length * vertexBuffer.itemSize;
|
||||
@@ -138,14 +138,14 @@ void FillBucket::drawElements(PlainShader& shader,
|
||||
|
||||
void FillBucket::drawElements(PatternShader& shader,
|
||||
gl::ObjectStore& store,
|
||||
gl::Config& config,
|
||||
gl::Context& context,
|
||||
PaintMode paintMode) {
|
||||
GLbyte* vertex_index = BUFFER_OFFSET(0);
|
||||
GLbyte* elements_index = BUFFER_OFFSET(0);
|
||||
for (auto& group : triangleGroups) {
|
||||
assert(group);
|
||||
group->array[paintMode == PaintMode::Overdraw ? 3 : 2].bind(
|
||||
shader, vertexBuffer, triangleElementsBuffer, vertex_index, store, config);
|
||||
shader, vertexBuffer, triangleElementsBuffer, vertex_index, store, context);
|
||||
MBGL_CHECK_ERROR(glDrawElements(GL_TRIANGLES, group->elements_length * 3, GL_UNSIGNED_SHORT,
|
||||
elements_index));
|
||||
vertex_index += group->vertex_length * vertexBuffer.itemSize;
|
||||
@@ -155,14 +155,14 @@ void FillBucket::drawElements(PatternShader& shader,
|
||||
|
||||
void FillBucket::drawVertices(OutlineShader& shader,
|
||||
gl::ObjectStore& store,
|
||||
gl::Config& config,
|
||||
gl::Context& context,
|
||||
PaintMode paintMode) {
|
||||
GLbyte* vertex_index = BUFFER_OFFSET(0);
|
||||
GLbyte* elements_index = BUFFER_OFFSET(0);
|
||||
for (auto& group : lineGroups) {
|
||||
assert(group);
|
||||
group->array[paintMode == PaintMode::Overdraw ? 1 : 0].bind(
|
||||
shader, vertexBuffer, lineElementsBuffer, vertex_index, store, config);
|
||||
shader, vertexBuffer, lineElementsBuffer, vertex_index, store, context);
|
||||
MBGL_CHECK_ERROR(glDrawElements(GL_LINES, group->elements_length * 2, GL_UNSIGNED_SHORT,
|
||||
elements_index));
|
||||
vertex_index += group->vertex_length * vertexBuffer.itemSize;
|
||||
@@ -172,14 +172,14 @@ void FillBucket::drawVertices(OutlineShader& shader,
|
||||
|
||||
void FillBucket::drawVertices(OutlinePatternShader& shader,
|
||||
gl::ObjectStore& store,
|
||||
gl::Config& config,
|
||||
gl::Context& context,
|
||||
PaintMode paintMode) {
|
||||
GLbyte* vertex_index = BUFFER_OFFSET(0);
|
||||
GLbyte* elements_index = BUFFER_OFFSET(0);
|
||||
for (auto& group : lineGroups) {
|
||||
assert(group);
|
||||
group->array[paintMode == PaintMode::Overdraw ? 3 : 2].bind(
|
||||
shader, vertexBuffer, lineElementsBuffer, vertex_index, store, config);
|
||||
shader, vertexBuffer, lineElementsBuffer, vertex_index, store, context);
|
||||
MBGL_CHECK_ERROR(glDrawElements(GL_LINES, group->elements_length * 2, GL_UNSIGNED_SHORT,
|
||||
elements_index));
|
||||
vertex_index += group->vertex_length * vertexBuffer.itemSize;
|
||||
|
||||
@@ -20,17 +20,17 @@ public:
|
||||
FillBucket();
|
||||
~FillBucket() override;
|
||||
|
||||
void upload(gl::ObjectStore&, gl::Config&) override;
|
||||
void upload(gl::ObjectStore&, gl::Context&) override;
|
||||
void render(Painter&, PaintParameters&, const style::Layer&, const RenderTile&) override;
|
||||
bool hasData() const override;
|
||||
bool needsClipping() const override;
|
||||
|
||||
void addGeometry(const GeometryCollection&);
|
||||
|
||||
void drawElements(PlainShader&, gl::ObjectStore&, gl::Config&, PaintMode);
|
||||
void drawElements(PatternShader&, gl::ObjectStore&, gl::Config&, PaintMode);
|
||||
void drawVertices(OutlineShader&, gl::ObjectStore&, gl::Config&, PaintMode);
|
||||
void drawVertices(OutlinePatternShader&, gl::ObjectStore&, gl::Config&, PaintMode);
|
||||
void drawElements(PlainShader&, gl::ObjectStore&, gl::Context&, PaintMode);
|
||||
void drawElements(PatternShader&, gl::ObjectStore&, gl::Context&, PaintMode);
|
||||
void drawVertices(OutlineShader&, gl::ObjectStore&, gl::Context&, PaintMode);
|
||||
void drawVertices(OutlinePatternShader&, gl::ObjectStore&, gl::Context&, PaintMode);
|
||||
|
||||
private:
|
||||
FillVertexBuffer vertexBuffer;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include <mbgl/renderer/frame_history.hpp>
|
||||
#include <mbgl/math/minmax.hpp>
|
||||
#include <mbgl/gl/gl_config.hpp>
|
||||
#include <mbgl/gl/context.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
@@ -58,11 +58,11 @@ bool FrameHistory::needsAnimation(const Duration& duration) const {
|
||||
return (time - previousTime) < duration;
|
||||
}
|
||||
|
||||
void FrameHistory::upload(gl::ObjectStore& store, gl::Config& config, uint32_t unit) {
|
||||
void FrameHistory::upload(gl::ObjectStore& store, gl::Context& context, uint32_t unit) {
|
||||
|
||||
if (changed) {
|
||||
const bool first = !texture;
|
||||
bind(store, config, unit);
|
||||
bind(store, context, unit);
|
||||
|
||||
if (first) {
|
||||
MBGL_CHECK_ERROR(glTexImage2D(
|
||||
@@ -95,11 +95,11 @@ void FrameHistory::upload(gl::ObjectStore& store, gl::Config& config, uint32_t u
|
||||
}
|
||||
}
|
||||
|
||||
void FrameHistory::bind(gl::ObjectStore& store, gl::Config& config, uint32_t unit) {
|
||||
void FrameHistory::bind(gl::ObjectStore& store, gl::Context& context, uint32_t unit) {
|
||||
if (!texture) {
|
||||
texture = store.createTexture();
|
||||
config.activeTexture = unit;
|
||||
config.texture[unit] = *texture;
|
||||
context.activeTexture = unit;
|
||||
context.texture[unit] = *texture;
|
||||
#ifndef GL_ES_VERSION_2_0
|
||||
MBGL_CHECK_ERROR(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0));
|
||||
#endif
|
||||
@@ -107,9 +107,9 @@ void FrameHistory::bind(gl::ObjectStore& store, gl::Config& config, uint32_t uni
|
||||
MBGL_CHECK_ERROR(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE));
|
||||
MBGL_CHECK_ERROR(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST));
|
||||
MBGL_CHECK_ERROR(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST));
|
||||
} else if (config.texture[unit] != *texture) {
|
||||
config.activeTexture = unit;
|
||||
config.texture[unit] = *texture;
|
||||
} else if (context.texture[unit] != *texture) {
|
||||
context.activeTexture = unit;
|
||||
context.texture[unit] = *texture;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
namespace mbgl {
|
||||
|
||||
namespace gl {
|
||||
class Config;
|
||||
class Context;
|
||||
} // namespace gl
|
||||
|
||||
class FrameHistory {
|
||||
@@ -19,8 +19,8 @@ public:
|
||||
void record(const TimePoint&, float zoom, const Duration&);
|
||||
|
||||
bool needsAnimation(const Duration&) const;
|
||||
void bind(gl::ObjectStore&, gl::Config&, uint32_t);
|
||||
void upload(gl::ObjectStore&, gl::Config&, uint32_t);
|
||||
void bind(gl::ObjectStore&, gl::Context&, uint32_t);
|
||||
void upload(gl::ObjectStore&, gl::Context&, uint32_t);
|
||||
|
||||
private:
|
||||
const int width = 256;
|
||||
|
||||
@@ -437,9 +437,9 @@ void LineBucket::addPieSliceVertex(const GeometryCoordinate& currentVertex,
|
||||
}
|
||||
}
|
||||
|
||||
void LineBucket::upload(gl::ObjectStore& store, gl::Config& config) {
|
||||
vertexBuffer.upload(store, config);
|
||||
triangleElementsBuffer.upload(store, config);
|
||||
void LineBucket::upload(gl::ObjectStore& store, gl::Context& context) {
|
||||
vertexBuffer.upload(store, context);
|
||||
triangleElementsBuffer.upload(store, context);
|
||||
|
||||
// From now on, we're only going to render during the translucent pass.
|
||||
uploaded = true;
|
||||
@@ -462,7 +462,7 @@ bool LineBucket::needsClipping() const {
|
||||
|
||||
void LineBucket::drawLines(LineShader& shader,
|
||||
gl::ObjectStore& store,
|
||||
gl::Config& config,
|
||||
gl::Context& context,
|
||||
PaintMode paintMode) {
|
||||
GLbyte* vertex_index = BUFFER_OFFSET(0);
|
||||
GLbyte* elements_index = BUFFER_OFFSET(0);
|
||||
@@ -472,7 +472,7 @@ void LineBucket::drawLines(LineShader& shader,
|
||||
continue;
|
||||
}
|
||||
group->array[paintMode == PaintMode::Overdraw ? 1 : 0].bind(
|
||||
shader, vertexBuffer, triangleElementsBuffer, vertex_index, store, config);
|
||||
shader, vertexBuffer, triangleElementsBuffer, vertex_index, store, context);
|
||||
MBGL_CHECK_ERROR(glDrawElements(GL_TRIANGLES, group->elements_length * 3, GL_UNSIGNED_SHORT,
|
||||
elements_index));
|
||||
vertex_index += group->vertex_length * vertexBuffer.itemSize;
|
||||
@@ -482,7 +482,7 @@ void LineBucket::drawLines(LineShader& shader,
|
||||
|
||||
void LineBucket::drawLineSDF(LineSDFShader& shader,
|
||||
gl::ObjectStore& store,
|
||||
gl::Config& config,
|
||||
gl::Context& context,
|
||||
PaintMode paintMode) {
|
||||
GLbyte* vertex_index = BUFFER_OFFSET(0);
|
||||
GLbyte* elements_index = BUFFER_OFFSET(0);
|
||||
@@ -492,7 +492,7 @@ void LineBucket::drawLineSDF(LineSDFShader& shader,
|
||||
continue;
|
||||
}
|
||||
group->array[paintMode == PaintMode::Overdraw ? 3 : 2].bind(
|
||||
shader, vertexBuffer, triangleElementsBuffer, vertex_index, store, config);
|
||||
shader, vertexBuffer, triangleElementsBuffer, vertex_index, store, context);
|
||||
MBGL_CHECK_ERROR(glDrawElements(GL_TRIANGLES, group->elements_length * 3, GL_UNSIGNED_SHORT,
|
||||
elements_index));
|
||||
vertex_index += group->vertex_length * vertexBuffer.itemSize;
|
||||
@@ -502,7 +502,7 @@ void LineBucket::drawLineSDF(LineSDFShader& shader,
|
||||
|
||||
void LineBucket::drawLinePatterns(LinepatternShader& shader,
|
||||
gl::ObjectStore& store,
|
||||
gl::Config& config,
|
||||
gl::Context& context,
|
||||
PaintMode paintMode) {
|
||||
GLbyte* vertex_index = BUFFER_OFFSET(0);
|
||||
GLbyte* elements_index = BUFFER_OFFSET(0);
|
||||
@@ -512,7 +512,7 @@ void LineBucket::drawLinePatterns(LinepatternShader& shader,
|
||||
continue;
|
||||
}
|
||||
group->array[paintMode == PaintMode::Overdraw ? 5 : 4].bind(
|
||||
shader, vertexBuffer, triangleElementsBuffer, vertex_index, store, config);
|
||||
shader, vertexBuffer, triangleElementsBuffer, vertex_index, store, context);
|
||||
MBGL_CHECK_ERROR(glDrawElements(GL_TRIANGLES, group->elements_length * 3, GL_UNSIGNED_SHORT,
|
||||
elements_index));
|
||||
vertex_index += group->vertex_length * vertexBuffer.itemSize;
|
||||
|
||||
@@ -24,7 +24,7 @@ public:
|
||||
LineBucket(uint32_t overscaling);
|
||||
~LineBucket() override;
|
||||
|
||||
void upload(gl::ObjectStore&, gl::Config&) override;
|
||||
void upload(gl::ObjectStore&, gl::Context&) override;
|
||||
void render(Painter&, PaintParameters&, const style::Layer&, const RenderTile&) override;
|
||||
bool hasData() const override;
|
||||
bool needsClipping() const override;
|
||||
@@ -32,9 +32,9 @@ public:
|
||||
void addGeometry(const GeometryCollection&);
|
||||
void addGeometry(const GeometryCoordinates& line);
|
||||
|
||||
void drawLines(LineShader&, gl::ObjectStore&, gl::Config&, PaintMode);
|
||||
void drawLineSDF(LineSDFShader&, gl::ObjectStore&, gl::Config&, PaintMode);
|
||||
void drawLinePatterns(LinepatternShader&, gl::ObjectStore&, gl::Config&, PaintMode);
|
||||
void drawLines(LineShader&, gl::ObjectStore&, gl::Context&, PaintMode);
|
||||
void drawLineSDF(LineSDFShader&, gl::ObjectStore&, gl::Context&, PaintMode);
|
||||
void drawLinePatterns(LinepatternShader&, gl::ObjectStore&, gl::Context&, PaintMode);
|
||||
|
||||
private:
|
||||
struct TriangleElement {
|
||||
|
||||
@@ -48,8 +48,8 @@ Painter::Painter(const TransformState& state_,
|
||||
#endif
|
||||
|
||||
// Reset GL values
|
||||
config.setDirtyState();
|
||||
config.resetState();
|
||||
context.setDirtyState();
|
||||
context.resetState();
|
||||
}
|
||||
|
||||
Painter::~Painter() = default;
|
||||
@@ -61,12 +61,12 @@ bool Painter::needsAnimation() const {
|
||||
void Painter::setClipping(const ClipID& clip) {
|
||||
const GLint ref = (GLint)clip.reference.to_ulong();
|
||||
const GLuint mask = (GLuint)clip.mask.to_ulong();
|
||||
config.stencilFunc = { GL_EQUAL, ref, mask };
|
||||
context.stencilFunc = { GL_EQUAL, ref, mask };
|
||||
}
|
||||
|
||||
void Painter::render(const Style& style, const FrameData& frame_, SpriteAtlas& annotationSpriteAtlas) {
|
||||
if (frame.framebufferSize != frame_.framebufferSize) {
|
||||
config.viewport.setDefaultValue(
|
||||
context.viewport.setDefaultValue(
|
||||
{ { 0, 0, frame_.framebufferSize[0], frame_.framebufferSize[1] } });
|
||||
}
|
||||
frame = frame_;
|
||||
@@ -104,18 +104,18 @@ void Painter::render(const Style& style, const FrameData& frame_, SpriteAtlas& a
|
||||
{
|
||||
MBGL_DEBUG_GROUP("upload");
|
||||
|
||||
tileStencilBuffer.upload(store, config);
|
||||
rasterBoundsBuffer.upload(store, config);
|
||||
tileBorderBuffer.upload(store, config);
|
||||
spriteAtlas->upload(store, config, 0);
|
||||
lineAtlas->upload(store, config, 0);
|
||||
glyphAtlas->upload(store, config, 0);
|
||||
frameHistory.upload(store, config, 0);
|
||||
annotationSpriteAtlas.upload(store, config, 0);
|
||||
tileStencilBuffer.upload(store, context);
|
||||
rasterBoundsBuffer.upload(store, context);
|
||||
tileBorderBuffer.upload(store, context);
|
||||
spriteAtlas->upload(store, context, 0);
|
||||
lineAtlas->upload(store, context, 0);
|
||||
glyphAtlas->upload(store, context, 0);
|
||||
frameHistory.upload(store, context, 0);
|
||||
annotationSpriteAtlas.upload(store, context, 0);
|
||||
|
||||
for (const auto& item : order) {
|
||||
if (item.bucket && item.bucket->needsUpload()) {
|
||||
item.bucket->upload(store, config);
|
||||
item.bucket->upload(store, context);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -125,26 +125,26 @@ void Painter::render(const Style& style, const FrameData& frame_, SpriteAtlas& a
|
||||
// tiles whatsoever.
|
||||
{
|
||||
MBGL_DEBUG_GROUP("clear");
|
||||
config.bindFramebuffer.reset();
|
||||
config.viewport.reset();
|
||||
config.stencilFunc.reset();
|
||||
config.stencilTest = GL_TRUE;
|
||||
config.stencilMask = 0xFF;
|
||||
config.depthTest = GL_FALSE;
|
||||
config.depthMask = GL_TRUE;
|
||||
config.colorMask = { GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE };
|
||||
context.bindFramebuffer.reset();
|
||||
context.viewport.reset();
|
||||
context.stencilFunc.reset();
|
||||
context.stencilTest = GL_TRUE;
|
||||
context.stencilMask = 0xFF;
|
||||
context.depthTest = GL_FALSE;
|
||||
context.depthMask = GL_TRUE;
|
||||
context.colorMask = { GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE };
|
||||
|
||||
if (paintMode() == PaintMode::Overdraw) {
|
||||
config.blend = GL_TRUE;
|
||||
config.blendFunc = { GL_CONSTANT_COLOR, GL_ONE };
|
||||
context.blend = GL_TRUE;
|
||||
context.blendFunc = { GL_CONSTANT_COLOR, GL_ONE };
|
||||
const float overdraw = 1.0f / 8.0f;
|
||||
config.blendColor = { overdraw, overdraw, overdraw, 0.0f };
|
||||
config.clearColor = Color::black();
|
||||
context.blendColor = { overdraw, overdraw, overdraw, 0.0f };
|
||||
context.clearColor = Color::black();
|
||||
} else {
|
||||
config.clearColor = background;
|
||||
context.clearColor = background;
|
||||
}
|
||||
config.clearStencil = 0;
|
||||
config.clearDepth = 1;
|
||||
context.clearStencil = 0;
|
||||
context.clearDepth = 1;
|
||||
MBGL_CHECK_ERROR(glClear(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT | GL_DEPTH_BUFFER_BIT));
|
||||
}
|
||||
|
||||
@@ -216,16 +216,16 @@ void Painter::render(const Style& style, const FrameData& frame_, SpriteAtlas& a
|
||||
{
|
||||
MBGL_DEBUG_GROUP("cleanup");
|
||||
|
||||
config.activeTexture = 1;
|
||||
config.texture[1] = 0;
|
||||
config.activeTexture = 0;
|
||||
config.texture[0] = 0;
|
||||
context.activeTexture = 1;
|
||||
context.texture[1] = 0;
|
||||
context.activeTexture = 0;
|
||||
context.texture[0] = 0;
|
||||
|
||||
config.vertexArrayObject = 0;
|
||||
context.vertexArrayObject = 0;
|
||||
}
|
||||
|
||||
if (frame.contextMode == GLContextMode::Shared) {
|
||||
config.setDirtyState();
|
||||
context.setDirtyState();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -253,32 +253,32 @@ void Painter::renderPass(PaintParameters& parameters,
|
||||
continue;
|
||||
|
||||
if (paintMode() == PaintMode::Overdraw) {
|
||||
config.blend = GL_TRUE;
|
||||
context.blend = GL_TRUE;
|
||||
} else if (pass == RenderPass::Translucent) {
|
||||
config.blendFunc.reset();
|
||||
config.blend = GL_TRUE;
|
||||
context.blendFunc.reset();
|
||||
context.blend = GL_TRUE;
|
||||
} else {
|
||||
config.blend = GL_FALSE;
|
||||
context.blend = GL_FALSE;
|
||||
}
|
||||
|
||||
config.colorMask = { GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE };
|
||||
config.stencilMask = 0x0;
|
||||
context.colorMask = { GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE };
|
||||
context.stencilMask = 0x0;
|
||||
|
||||
if (layer.is<BackgroundLayer>()) {
|
||||
MBGL_DEBUG_GROUP("background");
|
||||
renderBackground(parameters, *layer.as<BackgroundLayer>());
|
||||
} else if (layer.is<CustomLayer>()) {
|
||||
MBGL_DEBUG_GROUP(layer.baseImpl->id + " - custom");
|
||||
config.vertexArrayObject = 0;
|
||||
config.depthFunc.reset();
|
||||
config.depthTest = GL_TRUE;
|
||||
config.depthMask = GL_FALSE;
|
||||
config.stencilTest = GL_FALSE;
|
||||
context.vertexArrayObject = 0;
|
||||
context.depthFunc.reset();
|
||||
context.depthTest = GL_TRUE;
|
||||
context.depthMask = GL_FALSE;
|
||||
context.stencilTest = GL_FALSE;
|
||||
setDepthSublayer(0);
|
||||
layer.as<CustomLayer>()->impl->render(state);
|
||||
config.setDirtyState();
|
||||
config.bindFramebuffer.reset();
|
||||
config.viewport.reset();
|
||||
context.setDirtyState();
|
||||
context.bindFramebuffer.reset();
|
||||
context.viewport.reset();
|
||||
} else {
|
||||
MBGL_DEBUG_GROUP(layer.baseImpl->id + " - " + util::toString(item.tile->id));
|
||||
if (item.bucket->needsClipping()) {
|
||||
@@ -296,7 +296,7 @@ void Painter::renderPass(PaintParameters& parameters,
|
||||
void Painter::setDepthSublayer(int n) {
|
||||
float nearDepth = ((1 + currentLayer) * numSublayers + n) * depthEpsilon;
|
||||
float farDepth = nearDepth + depthRangeSize;
|
||||
config.depthRange = { nearDepth, farDepth };
|
||||
context.depthRange = { nearDepth, farDepth };
|
||||
}
|
||||
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include <mbgl/geometry/vao.hpp>
|
||||
#include <mbgl/geometry/static_vertex_buffer.hpp>
|
||||
|
||||
#include <mbgl/gl/gl_config.hpp>
|
||||
#include <mbgl/gl/context.hpp>
|
||||
#include <mbgl/gl/gl.hpp>
|
||||
|
||||
#include <mbgl/style/style.hpp>
|
||||
@@ -125,7 +125,7 @@ private:
|
||||
float scaleDivisor,
|
||||
std::array<float, 2> texsize,
|
||||
SDFShader& sdfShader,
|
||||
void (SymbolBucket::*drawSDF)(SDFShader&, gl::ObjectStore&, gl::Config&, PaintMode),
|
||||
void (SymbolBucket::*drawSDF)(SDFShader&, gl::ObjectStore&, gl::Context&, PaintMode),
|
||||
|
||||
// Layout
|
||||
style::AlignmentType rotationAlignment,
|
||||
@@ -172,7 +172,7 @@ private:
|
||||
|
||||
int indent = 0;
|
||||
|
||||
gl::Config config;
|
||||
gl::Context context;
|
||||
|
||||
RenderPass pass = RenderPass::Opaque;
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ void Painter::renderBackground(PaintParameters& parameters, const BackgroundLaye
|
||||
if (!imagePosA || !imagePosB)
|
||||
return;
|
||||
|
||||
config.program = patternShader.getID();
|
||||
context.program = patternShader.getID();
|
||||
patternShader.u_matrix = identityMatrix;
|
||||
patternShader.u_pattern_tl_a = imagePosA->tl;
|
||||
patternShader.u_pattern_br_a = imagePosA->br;
|
||||
@@ -44,21 +44,21 @@ void Painter::renderBackground(PaintParameters& parameters, const BackgroundLaye
|
||||
patternShader.u_mix = properties.backgroundPattern.value.t;
|
||||
patternShader.u_opacity = properties.backgroundOpacity;
|
||||
|
||||
spriteAtlas->bind(true, store, config, 0);
|
||||
arrayBackgroundPattern.bind(patternShader, tileStencilBuffer, BUFFER_OFFSET(0), store, config);
|
||||
spriteAtlas->bind(true, store, context, 0);
|
||||
arrayBackgroundPattern.bind(patternShader, tileStencilBuffer, BUFFER_OFFSET(0), store, context);
|
||||
|
||||
} else {
|
||||
config.program = plainShader.getID();
|
||||
context.program = plainShader.getID();
|
||||
plainShader.u_color = properties.backgroundColor;
|
||||
plainShader.u_opacity = properties.backgroundOpacity;
|
||||
|
||||
arrayBackground.bind(plainShader, tileStencilBuffer, BUFFER_OFFSET(0), store, config);
|
||||
arrayBackground.bind(plainShader, tileStencilBuffer, BUFFER_OFFSET(0), store, context);
|
||||
}
|
||||
|
||||
config.stencilTest = GL_FALSE;
|
||||
config.depthFunc.reset();
|
||||
config.depthTest = GL_TRUE;
|
||||
config.depthMask = GL_FALSE;
|
||||
context.stencilTest = GL_FALSE;
|
||||
context.depthFunc.reset();
|
||||
context.depthTest = GL_TRUE;
|
||||
context.depthMask = GL_FALSE;
|
||||
setDepthSublayer(0);
|
||||
|
||||
for (const auto& tileID : util::tileCover(state, state.getIntegerZoom())) {
|
||||
|
||||
@@ -19,16 +19,16 @@ void Painter::renderCircle(PaintParameters& parameters,
|
||||
// Abort early.
|
||||
if (pass == RenderPass::Opaque) return;
|
||||
|
||||
config.stencilTest = frame.mapMode == MapMode::Still ? GL_TRUE : GL_FALSE;
|
||||
config.depthFunc.reset();
|
||||
config.depthTest = GL_TRUE;
|
||||
config.depthMask = GL_FALSE;
|
||||
context.stencilTest = frame.mapMode == MapMode::Still ? GL_TRUE : GL_FALSE;
|
||||
context.depthFunc.reset();
|
||||
context.depthTest = GL_TRUE;
|
||||
context.depthMask = GL_FALSE;
|
||||
setDepthSublayer(0);
|
||||
|
||||
const CirclePaintProperties& properties = layer.impl->paint;
|
||||
auto& circleShader = parameters.shaders.circle;
|
||||
|
||||
config.program = circleShader.getID();
|
||||
context.program = circleShader.getID();
|
||||
|
||||
circleShader.u_matrix = tile.translatedMatrix(properties.circleTranslate,
|
||||
properties.circleTranslateAnchor,
|
||||
@@ -51,7 +51,7 @@ void Painter::renderCircle(PaintParameters& parameters,
|
||||
circleShader.u_blur = properties.circleBlur;
|
||||
circleShader.u_opacity = properties.circleOpacity;
|
||||
|
||||
bucket.drawCircles(circleShader, store, config);
|
||||
bucket.drawCircles(circleShader, store, context);
|
||||
}
|
||||
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -18,15 +18,15 @@ void Painter::drawClippingMasks(PaintParameters& parameters, const std::map<Unwr
|
||||
mat4 matrix;
|
||||
const GLuint mask = 0b11111111;
|
||||
|
||||
config.program = plainShader.getID();
|
||||
config.stencilOp.reset();
|
||||
config.stencilTest = GL_TRUE;
|
||||
config.depthTest = GL_FALSE;
|
||||
config.depthMask = GL_FALSE;
|
||||
config.colorMask = { GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE };
|
||||
config.stencilMask = mask;
|
||||
context.program = plainShader.getID();
|
||||
context.stencilOp.reset();
|
||||
context.stencilTest = GL_TRUE;
|
||||
context.depthTest = GL_FALSE;
|
||||
context.depthMask = GL_FALSE;
|
||||
context.colorMask = { GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE };
|
||||
context.stencilMask = mask;
|
||||
|
||||
arrayCoveringPlain.bind(plainShader, tileStencilBuffer, BUFFER_OFFSET_0, store, config);
|
||||
arrayCoveringPlain.bind(plainShader, tileStencilBuffer, BUFFER_OFFSET_0, store, context);
|
||||
|
||||
for (const auto& stencil : stencils) {
|
||||
const auto& id = stencil.first;
|
||||
@@ -38,7 +38,7 @@ void Painter::drawClippingMasks(PaintParameters& parameters, const std::map<Unwr
|
||||
plainShader.u_matrix = matrix;
|
||||
|
||||
const GLint ref = (GLint)(clip.reference.to_ulong());
|
||||
config.stencilFunc = { GL_ALWAYS, ref, mask };
|
||||
context.stencilFunc = { GL_ALWAYS, ref, mask };
|
||||
MBGL_CHECK_ERROR(glDrawArrays(GL_TRIANGLES, 0, (GLsizei)tileStencilBuffer.index()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ void Painter::renderTileDebug(const RenderTile& tile) {
|
||||
void Painter::renderDebugText(Tile& tile, const mat4 &matrix) {
|
||||
MBGL_DEBUG_GROUP("debug text");
|
||||
|
||||
config.depthTest = GL_FALSE;
|
||||
context.depthTest = GL_FALSE;
|
||||
|
||||
if (!tile.debugBucket || tile.debugBucket->renderable != tile.isRenderable() ||
|
||||
tile.debugBucket->complete != tile.isComplete() ||
|
||||
@@ -39,28 +39,28 @@ void Painter::renderDebugText(Tile& tile, const mat4 &matrix) {
|
||||
}
|
||||
|
||||
auto& plainShader = shaders->plain;
|
||||
config.program = plainShader.getID();
|
||||
context.program = plainShader.getID();
|
||||
plainShader.u_matrix = matrix;
|
||||
plainShader.u_opacity = 1.0f;
|
||||
|
||||
// Draw white outline
|
||||
plainShader.u_color = Color::white();
|
||||
config.lineWidth = 4.0f * frame.pixelRatio;
|
||||
tile.debugBucket->drawLines(plainShader, store, config);
|
||||
context.lineWidth = 4.0f * frame.pixelRatio;
|
||||
tile.debugBucket->drawLines(plainShader, store, context);
|
||||
|
||||
#ifndef GL_ES_VERSION_2_0
|
||||
// Draw line "end caps"
|
||||
MBGL_CHECK_ERROR(glPointSize(2));
|
||||
tile.debugBucket->drawPoints(plainShader, store, config);
|
||||
tile.debugBucket->drawPoints(plainShader, store, context);
|
||||
#endif
|
||||
|
||||
// Draw black text.
|
||||
plainShader.u_color = Color::black();
|
||||
config.lineWidth = 2.0f * frame.pixelRatio;
|
||||
tile.debugBucket->drawLines(plainShader, store, config);
|
||||
context.lineWidth = 2.0f * frame.pixelRatio;
|
||||
tile.debugBucket->drawLines(plainShader, store, context);
|
||||
|
||||
config.depthFunc.reset();
|
||||
config.depthTest = GL_TRUE;
|
||||
context.depthFunc.reset();
|
||||
context.depthTest = GL_TRUE;
|
||||
}
|
||||
|
||||
void Painter::renderDebugFrame(const mat4 &matrix) {
|
||||
@@ -69,32 +69,32 @@ void Painter::renderDebugFrame(const mat4 &matrix) {
|
||||
// Disable depth test and don't count this towards the depth buffer,
|
||||
// but *don't* disable stencil test, as we want to clip the red tile border
|
||||
// to the tile viewport.
|
||||
config.depthTest = GL_FALSE;
|
||||
config.stencilOp.reset();
|
||||
config.stencilTest = GL_TRUE;
|
||||
context.depthTest = GL_FALSE;
|
||||
context.stencilOp.reset();
|
||||
context.stencilTest = GL_TRUE;
|
||||
|
||||
auto& plainShader = shaders->plain;
|
||||
config.program = plainShader.getID();
|
||||
context.program = plainShader.getID();
|
||||
plainShader.u_matrix = matrix;
|
||||
plainShader.u_opacity = 1.0f;
|
||||
|
||||
// draw tile outline
|
||||
tileBorderArray.bind(plainShader, tileBorderBuffer, BUFFER_OFFSET_0, store, config);
|
||||
tileBorderArray.bind(plainShader, tileBorderBuffer, BUFFER_OFFSET_0, store, context);
|
||||
plainShader.u_color = { 1.0f, 0.0f, 0.0f, 1.0f };
|
||||
config.lineWidth = 4.0f * frame.pixelRatio;
|
||||
context.lineWidth = 4.0f * frame.pixelRatio;
|
||||
MBGL_CHECK_ERROR(glDrawArrays(GL_LINE_STRIP, 0, (GLsizei)tileBorderBuffer.index()));
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
void Painter::renderClipMasks() {
|
||||
config.stencilTest = GL_FALSE;
|
||||
config.depthTest = GL_FALSE;
|
||||
config.program = 0;
|
||||
config.colorMask = { GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE };
|
||||
context.stencilTest = GL_FALSE;
|
||||
context.depthTest = GL_FALSE;
|
||||
context.program = 0;
|
||||
context.colorMask = { GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE };
|
||||
|
||||
#ifndef GL_ES_VERSION_2_0
|
||||
config.pixelZoom = { 1, 1 };
|
||||
config.rasterPos = {{ -1, -1, 0, 0 }};
|
||||
context.pixelZoom = { 1, 1 };
|
||||
context.rasterPos = {{ -1, -1, 0, 0 }};
|
||||
|
||||
// Read the stencil buffer
|
||||
const auto& fbSize = frame.framebufferSize;
|
||||
@@ -125,14 +125,14 @@ void Painter::renderClipMasks() {
|
||||
|
||||
#ifndef NDEBUG
|
||||
void Painter::renderDepthBuffer() {
|
||||
config.stencilTest = GL_FALSE;
|
||||
config.depthTest = GL_FALSE;
|
||||
config.program = 0;
|
||||
config.colorMask = { GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE };
|
||||
context.stencilTest = GL_FALSE;
|
||||
context.depthTest = GL_FALSE;
|
||||
context.program = 0;
|
||||
context.colorMask = { GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE };
|
||||
|
||||
#ifndef GL_ES_VERSION_2_0
|
||||
config.pixelZoom = { 1, 1 };
|
||||
config.rasterPos = {{ -1, -1, 0, 0 }};
|
||||
context.pixelZoom = { 1, 1 };
|
||||
context.rasterPos = {{ -1, -1, 0, 0 }};
|
||||
|
||||
// Read the stencil buffer
|
||||
const auto& fbSize = frame.framebufferSize;
|
||||
|
||||
@@ -33,12 +33,12 @@ void Painter::renderFill(PaintParameters& parameters,
|
||||
bool outline = properties.fillAntialias && !pattern && isOutlineColorDefined;
|
||||
bool fringeline = properties.fillAntialias && !pattern && !isOutlineColorDefined;
|
||||
|
||||
config.stencilOp.reset();
|
||||
config.stencilTest = GL_TRUE;
|
||||
config.depthFunc.reset();
|
||||
config.depthTest = GL_TRUE;
|
||||
config.depthMask = GL_TRUE;
|
||||
config.lineWidth = 2.0f; // This is always fixed and does not depend on the pixelRatio!
|
||||
context.stencilOp.reset();
|
||||
context.stencilTest = GL_TRUE;
|
||||
context.depthFunc.reset();
|
||||
context.depthTest = GL_TRUE;
|
||||
context.depthMask = GL_TRUE;
|
||||
context.lineWidth = 2.0f; // This is always fixed and does not depend on the pixelRatio!
|
||||
|
||||
auto& outlineShader = parameters.shaders.outline;
|
||||
auto& patternShader = parameters.shaders.pattern;
|
||||
@@ -48,7 +48,7 @@ void Painter::renderFill(PaintParameters& parameters,
|
||||
// Because we're drawing top-to-bottom, and we update the stencil mask
|
||||
// befrom, we have to draw the outline first (!)
|
||||
if (outline && pass == RenderPass::Translucent) {
|
||||
config.program = outlineShader.getID();
|
||||
context.program = outlineShader.getID();
|
||||
outlineShader.u_matrix = vertexMatrix;
|
||||
|
||||
outlineShader.u_outline_color = strokeColor;
|
||||
@@ -69,7 +69,7 @@ void Painter::renderFill(PaintParameters& parameters,
|
||||
// the (non-antialiased) fill.
|
||||
setDepthSublayer(0); // OK
|
||||
}
|
||||
bucket.drawVertices(outlineShader, store, config, paintMode());
|
||||
bucket.drawVertices(outlineShader, store, context, paintMode());
|
||||
}
|
||||
|
||||
if (pattern) {
|
||||
@@ -80,7 +80,7 @@ void Painter::renderFill(PaintParameters& parameters,
|
||||
|
||||
// Image fill.
|
||||
if (pass == RenderPass::Translucent && imagePosA && imagePosB) {
|
||||
config.program = patternShader.getID();
|
||||
context.program = patternShader.getID();
|
||||
patternShader.u_matrix = vertexMatrix;
|
||||
patternShader.u_pattern_tl_a = imagePosA->tl;
|
||||
patternShader.u_pattern_br_a = imagePosA->br;
|
||||
@@ -101,14 +101,14 @@ void Painter::renderFill(PaintParameters& parameters,
|
||||
patternShader.u_pixel_coord_upper = {{ float(pixelX >> 16), float(pixelY >> 16) }};
|
||||
patternShader.u_pixel_coord_lower = {{ float(pixelX & 0xFFFF), float(pixelY & 0xFFFF) }};
|
||||
|
||||
spriteAtlas->bind(true, store, config, 0);
|
||||
spriteAtlas->bind(true, store, context, 0);
|
||||
|
||||
// Draw the actual triangles into the color & stencil buffer.
|
||||
setDepthSublayer(0);
|
||||
bucket.drawElements(patternShader, store, config, paintMode());
|
||||
bucket.drawElements(patternShader, store, context, paintMode());
|
||||
|
||||
if (properties.fillAntialias && !isOutlineColorDefined) {
|
||||
config.program = outlinePatternShader.getID();
|
||||
context.program = outlinePatternShader.getID();
|
||||
outlinePatternShader.u_matrix = vertexMatrix;
|
||||
|
||||
outlinePatternShader.u_pattern_tl_a = imagePosA->tl;
|
||||
@@ -129,10 +129,10 @@ void Painter::renderFill(PaintParameters& parameters,
|
||||
// Draw the entire line
|
||||
outlinePatternShader.u_world = worldSize;
|
||||
|
||||
spriteAtlas->bind(true, store, config, 0);
|
||||
spriteAtlas->bind(true, store, context, 0);
|
||||
|
||||
setDepthSublayer(2);
|
||||
bucket.drawVertices(outlinePatternShader, store, config, paintMode());
|
||||
bucket.drawVertices(outlinePatternShader, store, context, paintMode());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -142,21 +142,21 @@ void Painter::renderFill(PaintParameters& parameters,
|
||||
// fragments or when it's translucent and we're drawing translucent
|
||||
// fragments
|
||||
// Draw filling rectangle.
|
||||
config.program = plainShader.getID();
|
||||
context.program = plainShader.getID();
|
||||
plainShader.u_matrix = vertexMatrix;
|
||||
plainShader.u_color = fillColor;
|
||||
plainShader.u_opacity = opacity;
|
||||
|
||||
// Draw the actual triangles into the color & stencil buffer.
|
||||
setDepthSublayer(1);
|
||||
bucket.drawElements(plainShader, store, config, paintMode());
|
||||
bucket.drawElements(plainShader, store, context, paintMode());
|
||||
}
|
||||
}
|
||||
|
||||
// Because we're drawing top-to-bottom, and we update the stencil mask
|
||||
// below, we have to draw the outline first (!)
|
||||
if (fringeline && pass == RenderPass::Translucent) {
|
||||
config.program = outlineShader.getID();
|
||||
context.program = outlineShader.getID();
|
||||
outlineShader.u_matrix = vertexMatrix;
|
||||
|
||||
outlineShader.u_outline_color = fillColor;
|
||||
@@ -166,7 +166,7 @@ void Painter::renderFill(PaintParameters& parameters,
|
||||
outlineShader.u_world = worldSize;
|
||||
|
||||
setDepthSublayer(2);
|
||||
bucket.drawVertices(outlineShader, store, config, paintMode());
|
||||
bucket.drawVertices(outlineShader, store, context, paintMode());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,11 +20,11 @@ void Painter::renderLine(PaintParameters& parameters,
|
||||
// Abort early.
|
||||
if (pass == RenderPass::Opaque) return;
|
||||
|
||||
config.stencilOp.reset();
|
||||
config.stencilTest = GL_TRUE;
|
||||
config.depthFunc.reset();
|
||||
config.depthTest = GL_TRUE;
|
||||
config.depthMask = GL_FALSE;
|
||||
context.stencilOp.reset();
|
||||
context.stencilTest = GL_TRUE;
|
||||
context.depthFunc.reset();
|
||||
context.depthTest = GL_TRUE;
|
||||
context.depthMask = GL_FALSE;
|
||||
|
||||
const auto& properties = layer.impl->paint;
|
||||
const auto& layout = bucket.layout;
|
||||
@@ -61,7 +61,7 @@ void Painter::renderLine(PaintParameters& parameters,
|
||||
auto& lineShader = parameters.shaders.line;
|
||||
|
||||
if (!properties.lineDasharray.value.from.empty()) {
|
||||
config.program = linesdfShader.getID();
|
||||
context.program = linesdfShader.getID();
|
||||
|
||||
linesdfShader.u_matrix = vtxMatrix;
|
||||
linesdfShader.u_linewidth = properties.lineWidth / 2;
|
||||
@@ -96,9 +96,9 @@ void Painter::renderLine(PaintParameters& parameters,
|
||||
linesdfShader.u_antialiasingmatrix = antialiasingMatrix;
|
||||
|
||||
linesdfShader.u_image = 0;
|
||||
lineAtlas->bind(store, config, 0);
|
||||
lineAtlas->bind(store, context, 0);
|
||||
|
||||
bucket.drawLineSDF(linesdfShader, store, config, paintMode());
|
||||
bucket.drawLineSDF(linesdfShader, store, context, paintMode());
|
||||
|
||||
} else if (!properties.linePattern.value.from.empty()) {
|
||||
optional<SpriteAtlasPosition> imagePosA = spriteAtlas->getPosition(
|
||||
@@ -109,7 +109,7 @@ void Painter::renderLine(PaintParameters& parameters,
|
||||
if (!imagePosA || !imagePosB)
|
||||
return;
|
||||
|
||||
config.program = linepatternShader.getID();
|
||||
context.program = linepatternShader.getID();
|
||||
|
||||
linepatternShader.u_matrix = vtxMatrix;
|
||||
linepatternShader.u_linewidth = properties.lineWidth / 2;
|
||||
@@ -139,12 +139,12 @@ void Painter::renderLine(PaintParameters& parameters,
|
||||
linepatternShader.u_antialiasingmatrix = antialiasingMatrix;
|
||||
|
||||
linepatternShader.u_image = 0;
|
||||
spriteAtlas->bind(true, store, config, 0);
|
||||
spriteAtlas->bind(true, store, context, 0);
|
||||
|
||||
bucket.drawLinePatterns(linepatternShader, store, config, paintMode());
|
||||
bucket.drawLinePatterns(linepatternShader, store, context, paintMode());
|
||||
|
||||
} else {
|
||||
config.program = lineShader.getID();
|
||||
context.program = lineShader.getID();
|
||||
|
||||
lineShader.u_matrix = vtxMatrix;
|
||||
lineShader.u_linewidth = properties.lineWidth / 2;
|
||||
@@ -159,7 +159,7 @@ void Painter::renderLine(PaintParameters& parameters,
|
||||
lineShader.u_color = color;
|
||||
lineShader.u_opacity = opacity;
|
||||
|
||||
bucket.drawLines(lineShader, store, config, paintMode());
|
||||
bucket.drawLines(lineShader, store, context, paintMode());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ void Painter::renderRaster(PaintParameters& parameters,
|
||||
auto& rasterShader = parameters.shaders.raster;
|
||||
auto& rasterVAO = parameters.shaders.coveringRasterArray;
|
||||
|
||||
config.program = rasterShader.getID();
|
||||
context.program = rasterShader.getID();
|
||||
rasterShader.u_matrix = tile.matrix;
|
||||
rasterShader.u_buffer_scale = 1.0f;
|
||||
rasterShader.u_opacity0 = properties.rasterOpacity;
|
||||
@@ -35,19 +35,19 @@ void Painter::renderRaster(PaintParameters& parameters,
|
||||
rasterShader.u_contrast_factor = contrastFactor(properties.rasterContrast);
|
||||
rasterShader.u_spin_weights = spinWeights(properties.rasterHueRotate);
|
||||
|
||||
config.stencilTest = GL_FALSE;
|
||||
context.stencilTest = GL_FALSE;
|
||||
|
||||
rasterShader.u_image0 = 0; // GL_TEXTURE0
|
||||
rasterShader.u_image1 = 1; // GL_TEXTURE1
|
||||
rasterShader.u_tl_parent = {{ 0.0f, 0.0f }};
|
||||
rasterShader.u_scale_parent = 1.0f;
|
||||
|
||||
config.depthFunc.reset();
|
||||
config.depthTest = GL_TRUE;
|
||||
config.depthMask = GL_FALSE;
|
||||
context.depthFunc.reset();
|
||||
context.depthTest = GL_TRUE;
|
||||
context.depthMask = GL_FALSE;
|
||||
setDepthSublayer(0);
|
||||
|
||||
bucket.drawRaster(rasterShader, rasterBoundsBuffer, rasterVAO, config, store);
|
||||
bucket.drawRaster(rasterShader, rasterBoundsBuffer, rasterVAO, context, store);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ void Painter::renderSDF(SymbolBucket& bucket,
|
||||
float sdfFontSize,
|
||||
std::array<float, 2> texsize,
|
||||
SDFShader& sdfShader,
|
||||
void (SymbolBucket::*drawSDF)(SDFShader&, gl::ObjectStore&, gl::Config&, PaintMode),
|
||||
void (SymbolBucket::*drawSDF)(SDFShader&, gl::ObjectStore&, gl::Context&, PaintMode),
|
||||
|
||||
// Layout
|
||||
AlignmentType rotationAlignment,
|
||||
@@ -60,7 +60,7 @@ void Painter::renderSDF(SymbolBucket& bucket,
|
||||
}};
|
||||
}
|
||||
|
||||
config.program = sdfShader.getID();
|
||||
context.program = sdfShader.getID();
|
||||
sdfShader.u_matrix = vtxMatrix;
|
||||
sdfShader.u_extrude_scale = extrudeScale;
|
||||
sdfShader.u_texsize = texsize;
|
||||
@@ -76,7 +76,7 @@ void Painter::renderSDF(SymbolBucket& bucket,
|
||||
|
||||
sdfShader.u_zoom = (state.getZoom() - zoomAdjust) * 10; // current zoom level
|
||||
|
||||
frameHistory.bind(store, config, 1);
|
||||
frameHistory.bind(store, context, 1);
|
||||
sdfShader.u_fadetexture = 1;
|
||||
|
||||
// The default gamma value has to be adjust for the current pixelratio so that we're not
|
||||
@@ -94,7 +94,7 @@ void Painter::renderSDF(SymbolBucket& bucket,
|
||||
sdfShader.u_color = haloColor;
|
||||
sdfShader.u_opacity = opacity;
|
||||
sdfShader.u_buffer = (haloOffset - haloWidth / fontScale) / sdfPx;
|
||||
(bucket.*drawSDF)(sdfShader, store, config, paintMode());
|
||||
(bucket.*drawSDF)(sdfShader, store, context, paintMode());
|
||||
}
|
||||
|
||||
// Then, we draw the text/icon over the halo
|
||||
@@ -103,7 +103,7 @@ void Painter::renderSDF(SymbolBucket& bucket,
|
||||
sdfShader.u_color = color;
|
||||
sdfShader.u_opacity = opacity;
|
||||
sdfShader.u_buffer = (256.0f - 64.0f) / 256.0f;
|
||||
(bucket.*drawSDF)(sdfShader, store, config, paintMode());
|
||||
(bucket.*drawSDF)(sdfShader, store, context, paintMode());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -119,7 +119,7 @@ void Painter::renderSymbol(PaintParameters& parameters,
|
||||
const auto& paint = layer.impl->paint;
|
||||
const auto& layout = bucket.layout;
|
||||
|
||||
config.depthMask = GL_FALSE;
|
||||
context.depthMask = GL_FALSE;
|
||||
|
||||
// TODO remove the `true ||` when #1673 is implemented
|
||||
const bool drawAcrossEdges = (frame.mapMode == MapMode::Continuous) && (true || !(layout.textAllowOverlap || layout.iconAllowOverlap ||
|
||||
@@ -131,20 +131,20 @@ void Painter::renderSymbol(PaintParameters& parameters,
|
||||
// layers are sorted in the y direction, and to draw the correct ordering near
|
||||
// tile edges the icons are included in both tiles and clipped when drawing.
|
||||
if (drawAcrossEdges) {
|
||||
config.stencilTest = GL_FALSE;
|
||||
context.stencilTest = GL_FALSE;
|
||||
} else {
|
||||
config.stencilOp.reset();
|
||||
config.stencilTest = GL_TRUE;
|
||||
context.stencilOp.reset();
|
||||
context.stencilTest = GL_TRUE;
|
||||
}
|
||||
|
||||
setDepthSublayer(0);
|
||||
|
||||
if (bucket.hasIconData()) {
|
||||
if (layout.iconRotationAlignment == AlignmentType::Map) {
|
||||
config.depthFunc.reset();
|
||||
config.depthTest = GL_TRUE;
|
||||
context.depthFunc.reset();
|
||||
context.depthTest = GL_TRUE;
|
||||
} else {
|
||||
config.depthTest = GL_FALSE;
|
||||
context.depthTest = GL_FALSE;
|
||||
}
|
||||
|
||||
bool sdf = bucket.sdfIcons;
|
||||
@@ -160,7 +160,7 @@ void Painter::renderSymbol(PaintParameters& parameters,
|
||||
SpriteAtlas* activeSpriteAtlas = layer.impl->spriteAtlas;
|
||||
const bool iconScaled = fontScale != 1 || frame.pixelRatio != activeSpriteAtlas->getPixelRatio() || bucket.iconsNeedLinear;
|
||||
const bool iconTransformed = layout.iconRotationAlignment == AlignmentType::Map || angleOffset != 0 || state.getPitch() != 0;
|
||||
activeSpriteAtlas->bind(sdf || state.isChanging() || iconScaled || iconTransformed, store, config, 0);
|
||||
activeSpriteAtlas->bind(sdf || state.isChanging() || iconScaled || iconTransformed, store, context, 0);
|
||||
|
||||
if (sdf) {
|
||||
renderSDF(bucket,
|
||||
@@ -201,7 +201,7 @@ void Painter::renderSymbol(PaintParameters& parameters,
|
||||
|
||||
auto& iconShader = parameters.shaders.icon;
|
||||
|
||||
config.program = iconShader.getID();
|
||||
context.program = iconShader.getID();
|
||||
iconShader.u_matrix = vtxMatrix;
|
||||
iconShader.u_extrude_scale = extrudeScale;
|
||||
iconShader.u_texsize = {{ float(activeSpriteAtlas->getWidth()) / 4.0f, float(activeSpriteAtlas->getHeight()) / 4.0f }};
|
||||
@@ -213,22 +213,22 @@ void Painter::renderSymbol(PaintParameters& parameters,
|
||||
iconShader.u_zoom = (state.getZoom() - zoomAdjust) * 10; // current zoom level
|
||||
iconShader.u_opacity = paint.iconOpacity;
|
||||
|
||||
frameHistory.bind(store, config, 1);
|
||||
frameHistory.bind(store, context, 1);
|
||||
iconShader.u_fadetexture = 1;
|
||||
|
||||
bucket.drawIcons(iconShader, store, config, paintMode());
|
||||
bucket.drawIcons(iconShader, store, context, paintMode());
|
||||
}
|
||||
}
|
||||
|
||||
if (bucket.hasTextData()) {
|
||||
if (layout.textPitchAlignment == AlignmentType::Map) {
|
||||
config.depthFunc.reset();
|
||||
config.depthTest = GL_TRUE;
|
||||
context.depthFunc.reset();
|
||||
context.depthTest = GL_TRUE;
|
||||
} else {
|
||||
config.depthTest = GL_FALSE;
|
||||
context.depthTest = GL_FALSE;
|
||||
}
|
||||
|
||||
glyphAtlas->bind(store, config, 0);
|
||||
glyphAtlas->bind(store, context, 0);
|
||||
|
||||
renderSDF(bucket,
|
||||
tile,
|
||||
@@ -250,19 +250,19 @@ void Painter::renderSymbol(PaintParameters& parameters,
|
||||
}
|
||||
|
||||
if (bucket.hasCollisionBoxData()) {
|
||||
config.stencilOp.reset();
|
||||
config.stencilTest = GL_TRUE;
|
||||
context.stencilOp.reset();
|
||||
context.stencilTest = GL_TRUE;
|
||||
|
||||
auto& collisionBoxShader = shaders->collisionBox;
|
||||
config.program = collisionBoxShader.getID();
|
||||
context.program = collisionBoxShader.getID();
|
||||
collisionBoxShader.u_matrix = tile.matrix;
|
||||
// TODO: This was the overscaled z instead of the canonical z.
|
||||
collisionBoxShader.u_scale = std::pow(2, state.getZoom() - tile.id.canonical.z);
|
||||
collisionBoxShader.u_zoom = state.getZoom() * 10;
|
||||
collisionBoxShader.u_maxzoom = (tile.id.canonical.z + 1) * 10;
|
||||
config.lineWidth = 1.0f;
|
||||
context.lineWidth = 1.0f;
|
||||
|
||||
bucket.drawCollisionBoxes(collisionBoxShader, store, config);
|
||||
bucket.drawCollisionBoxes(collisionBoxShader, store, context);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,9 +7,9 @@ namespace mbgl {
|
||||
|
||||
using namespace style;
|
||||
|
||||
void RasterBucket::upload(gl::ObjectStore& store, gl::Config& config) {
|
||||
void RasterBucket::upload(gl::ObjectStore& store, gl::Context& context) {
|
||||
if (hasData()) {
|
||||
raster.upload(store, config, 0);
|
||||
raster.upload(store, context, 0);
|
||||
uploaded = true;
|
||||
}
|
||||
}
|
||||
@@ -28,11 +28,11 @@ void RasterBucket::setImage(PremultipliedImage image) {
|
||||
void RasterBucket::drawRaster(RasterShader& shader,
|
||||
StaticRasterVertexBuffer& vertices,
|
||||
VertexArrayObject& array,
|
||||
gl::Config& config,
|
||||
gl::Context& context,
|
||||
gl::ObjectStore& store) {
|
||||
raster.bind(store, config, 0, Raster::Scaling::Linear);
|
||||
raster.bind(store, config, 1, Raster::Scaling::Linear);
|
||||
array.bind(shader, vertices, BUFFER_OFFSET_0, store, config);
|
||||
raster.bind(store, context, 0, Raster::Scaling::Linear);
|
||||
raster.bind(store, context, 1, Raster::Scaling::Linear);
|
||||
array.bind(shader, vertices, BUFFER_OFFSET_0, store, context);
|
||||
MBGL_CHECK_ERROR(glDrawArrays(GL_TRIANGLE_STRIP, 0, (GLsizei)vertices.index()));
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
#include <mbgl/renderer/bucket.hpp>
|
||||
#include <mbgl/util/raster.hpp>
|
||||
#include <mbgl/gl/gl_config.hpp>
|
||||
#include <mbgl/gl/context.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
@@ -12,14 +12,14 @@ class VertexArrayObject;
|
||||
|
||||
class RasterBucket : public Bucket {
|
||||
public:
|
||||
void upload(gl::ObjectStore&, gl::Config&) override;
|
||||
void upload(gl::ObjectStore&, gl::Context&) override;
|
||||
void render(Painter&, PaintParameters&, const style::Layer&, const RenderTile&) override;
|
||||
bool hasData() const override;
|
||||
bool needsClipping() const override;
|
||||
|
||||
void setImage(PremultipliedImage);
|
||||
|
||||
void drawRaster(RasterShader&, StaticRasterVertexBuffer&, VertexArrayObject&, gl::Config&, gl::ObjectStore&);
|
||||
void drawRaster(RasterShader&, StaticRasterVertexBuffer&, VertexArrayObject&, gl::Context&, gl::ObjectStore&);
|
||||
|
||||
Raster raster;
|
||||
};
|
||||
|
||||
@@ -19,14 +19,14 @@ SymbolBucket::SymbolBucket(const MapMode mode_,
|
||||
iconsNeedLinear(iconsNeedLinear_) {
|
||||
}
|
||||
|
||||
void SymbolBucket::upload(gl::ObjectStore& store, gl::Config& config) {
|
||||
void SymbolBucket::upload(gl::ObjectStore& store, gl::Context& context) {
|
||||
if (hasTextData()) {
|
||||
text.vertices.upload(store, config);
|
||||
text.triangles.upload(store, config);
|
||||
text.vertices.upload(store, context);
|
||||
text.triangles.upload(store, context);
|
||||
}
|
||||
if (hasIconData()) {
|
||||
icon.vertices.upload(store, config);
|
||||
icon.triangles.upload(store, config);
|
||||
icon.vertices.upload(store, context);
|
||||
icon.triangles.upload(store, context);
|
||||
}
|
||||
|
||||
uploaded = true;
|
||||
@@ -62,14 +62,14 @@ bool SymbolBucket::needsClipping() const {
|
||||
|
||||
void SymbolBucket::drawGlyphs(SDFShader& shader,
|
||||
gl::ObjectStore& store,
|
||||
gl::Config& config,
|
||||
gl::Context& context,
|
||||
PaintMode paintMode) {
|
||||
GLbyte* vertex_index = BUFFER_OFFSET_0;
|
||||
GLbyte* elements_index = BUFFER_OFFSET_0;
|
||||
for (auto& group : text.groups) {
|
||||
assert(group);
|
||||
group->array[paintMode == PaintMode::Overdraw ? 1 : 0].bind(
|
||||
shader, text.vertices, text.triangles, vertex_index, store, config);
|
||||
shader, text.vertices, text.triangles, vertex_index, store, context);
|
||||
MBGL_CHECK_ERROR(glDrawElements(GL_TRIANGLES, group->elements_length * 3, GL_UNSIGNED_SHORT,
|
||||
elements_index));
|
||||
vertex_index += group->vertex_length * text.vertices.itemSize;
|
||||
@@ -79,14 +79,14 @@ void SymbolBucket::drawGlyphs(SDFShader& shader,
|
||||
|
||||
void SymbolBucket::drawIcons(SDFShader& shader,
|
||||
gl::ObjectStore& store,
|
||||
gl::Config& config,
|
||||
gl::Context& context,
|
||||
PaintMode paintMode) {
|
||||
GLbyte* vertex_index = BUFFER_OFFSET_0;
|
||||
GLbyte* elements_index = BUFFER_OFFSET_0;
|
||||
for (auto& group : icon.groups) {
|
||||
assert(group);
|
||||
group->array[paintMode == PaintMode::Overdraw ? 1 : 0].bind(
|
||||
shader, icon.vertices, icon.triangles, vertex_index, store, config);
|
||||
shader, icon.vertices, icon.triangles, vertex_index, store, context);
|
||||
MBGL_CHECK_ERROR(glDrawElements(GL_TRIANGLES, group->elements_length * 3, GL_UNSIGNED_SHORT,
|
||||
elements_index));
|
||||
vertex_index += group->vertex_length * icon.vertices.itemSize;
|
||||
@@ -96,14 +96,14 @@ void SymbolBucket::drawIcons(SDFShader& shader,
|
||||
|
||||
void SymbolBucket::drawIcons(IconShader& shader,
|
||||
gl::ObjectStore& store,
|
||||
gl::Config& config,
|
||||
gl::Context& context,
|
||||
PaintMode paintMode) {
|
||||
GLbyte* vertex_index = BUFFER_OFFSET_0;
|
||||
GLbyte* elements_index = BUFFER_OFFSET_0;
|
||||
for (auto& group : icon.groups) {
|
||||
assert(group);
|
||||
group->array[paintMode == PaintMode::Overdraw ? 3 : 2].bind(
|
||||
shader, icon.vertices, icon.triangles, vertex_index, store, config);
|
||||
shader, icon.vertices, icon.triangles, vertex_index, store, context);
|
||||
MBGL_CHECK_ERROR(glDrawElements(GL_TRIANGLES, group->elements_length * 3, GL_UNSIGNED_SHORT,
|
||||
elements_index));
|
||||
vertex_index += group->vertex_length * icon.vertices.itemSize;
|
||||
@@ -113,10 +113,10 @@ void SymbolBucket::drawIcons(IconShader& shader,
|
||||
|
||||
void SymbolBucket::drawCollisionBoxes(CollisionBoxShader& shader,
|
||||
gl::ObjectStore& store,
|
||||
gl::Config& config) {
|
||||
gl::Context& context) {
|
||||
GLbyte* vertex_index = BUFFER_OFFSET_0;
|
||||
for (auto& group : collisionBox.groups) {
|
||||
group->array[0].bind(shader, collisionBox.vertices, vertex_index, store, config);
|
||||
group->array[0].bind(shader, collisionBox.vertices, vertex_index, store, context);
|
||||
MBGL_CHECK_ERROR(glDrawArrays(GL_LINES, 0, group->vertex_length));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ public:
|
||||
bool sdfIcons,
|
||||
bool iconsNeedLinear);
|
||||
|
||||
void upload(gl::ObjectStore&, gl::Config&) override;
|
||||
void upload(gl::ObjectStore&, gl::Context&) override;
|
||||
void render(Painter&, PaintParameters&, const style::Layer&, const RenderTile&) override;
|
||||
bool hasData() const override;
|
||||
bool hasTextData() const;
|
||||
@@ -33,10 +33,10 @@ public:
|
||||
bool hasCollisionBoxData() const;
|
||||
bool needsClipping() const override;
|
||||
|
||||
void drawGlyphs(SDFShader&, gl::ObjectStore&, gl::Config&, PaintMode);
|
||||
void drawIcons(SDFShader&, gl::ObjectStore&, gl::Config&, PaintMode);
|
||||
void drawIcons(IconShader&, gl::ObjectStore&, gl::Config&, PaintMode);
|
||||
void drawCollisionBoxes(CollisionBoxShader&, gl::ObjectStore&, gl::Config&);
|
||||
void drawGlyphs(SDFShader&, gl::ObjectStore&, gl::Context&, PaintMode);
|
||||
void drawIcons(SDFShader&, gl::ObjectStore&, gl::Context&, PaintMode);
|
||||
void drawIcons(IconShader&, gl::ObjectStore&, gl::Context&, PaintMode);
|
||||
void drawCollisionBoxes(CollisionBoxShader&, gl::ObjectStore&, gl::Context&);
|
||||
|
||||
const MapMode mode;
|
||||
const style::SymbolLayoutProperties layout;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#include <mbgl/sprite/sprite_atlas_observer.hpp>
|
||||
#include <mbgl/sprite/sprite_parser.hpp>
|
||||
#include <mbgl/gl/gl.hpp>
|
||||
#include <mbgl/gl/gl_config.hpp>
|
||||
#include <mbgl/gl/context.hpp>
|
||||
#include <mbgl/platform/log.hpp>
|
||||
#include <mbgl/platform/platform.hpp>
|
||||
#include <mbgl/util/math.hpp>
|
||||
@@ -282,9 +282,9 @@ void SpriteAtlas::copy(const Holder& holder, const SpritePatternMode mode) {
|
||||
dirtyFlag = true;
|
||||
}
|
||||
|
||||
void SpriteAtlas::upload(gl::ObjectStore& objectStore, gl::Config& config, uint32_t unit) {
|
||||
void SpriteAtlas::upload(gl::ObjectStore& objectStore, gl::Context& context, uint32_t unit) {
|
||||
if (dirtyFlag) {
|
||||
bind(false, objectStore, config, unit);
|
||||
bind(false, objectStore, context, unit);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -316,15 +316,15 @@ void SpriteAtlas::updateDirty() {
|
||||
dirtySprites.clear();
|
||||
}
|
||||
|
||||
void SpriteAtlas::bind(bool linear, gl::ObjectStore& objectStore, gl::Config& config, uint32_t unit) {
|
||||
void SpriteAtlas::bind(bool linear, gl::ObjectStore& objectStore, gl::Context& context, uint32_t unit) {
|
||||
if (!data) {
|
||||
return; // Empty atlas
|
||||
}
|
||||
|
||||
if (!texture) {
|
||||
texture = objectStore.createTexture();
|
||||
config.activeTexture = unit;
|
||||
config.texture[unit] = *texture;
|
||||
context.activeTexture = unit;
|
||||
context.texture[unit] = *texture;
|
||||
#ifndef GL_ES_VERSION_2_0
|
||||
MBGL_CHECK_ERROR(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0));
|
||||
#endif
|
||||
@@ -333,14 +333,14 @@ void SpriteAtlas::bind(bool linear, gl::ObjectStore& objectStore, gl::Config& co
|
||||
MBGL_CHECK_ERROR(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE));
|
||||
MBGL_CHECK_ERROR(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE));
|
||||
fullUploadRequired = true;
|
||||
} else if (config.texture[unit] != *texture) {
|
||||
config.activeTexture = unit;
|
||||
config.texture[unit] = *texture;
|
||||
} else if (context.texture[unit] != *texture) {
|
||||
context.activeTexture = unit;
|
||||
context.texture[unit] = *texture;
|
||||
}
|
||||
|
||||
GLuint filter_val = linear ? GL_LINEAR : GL_NEAREST;
|
||||
if (filter_val != filter) {
|
||||
config.activeTexture = unit;
|
||||
context.activeTexture = unit;
|
||||
MBGL_CHECK_ERROR(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter_val));
|
||||
MBGL_CHECK_ERROR(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter_val));
|
||||
filter = filter_val;
|
||||
@@ -349,7 +349,7 @@ void SpriteAtlas::bind(bool linear, gl::ObjectStore& objectStore, gl::Config& co
|
||||
if (dirtyFlag) {
|
||||
std::lock_guard<std::recursive_mutex> lock(mtx);
|
||||
|
||||
config.activeTexture = unit;
|
||||
context.activeTexture = unit;
|
||||
if (fullUploadRequired) {
|
||||
MBGL_CHECK_ERROR(glTexImage2D(
|
||||
GL_TEXTURE_2D, // GLenum target
|
||||
|
||||
@@ -21,7 +21,7 @@ class FileSource;
|
||||
class SpriteAtlasObserver;
|
||||
|
||||
namespace gl {
|
||||
class Config;
|
||||
class Context;
|
||||
} // namespace gl
|
||||
|
||||
class SpriteImage;
|
||||
@@ -83,14 +83,14 @@ public:
|
||||
SpritePatternMode mode = SpritePatternMode::Single);
|
||||
|
||||
// Binds the atlas texture to the GPU, and uploads data if it is out of date.
|
||||
void bind(bool linear, gl::ObjectStore&, gl::Config&, uint32_t unit);
|
||||
void bind(bool linear, gl::ObjectStore&, gl::Context&, uint32_t unit);
|
||||
|
||||
// Updates sprites in the atlas texture that may have changed.
|
||||
void updateDirty();
|
||||
|
||||
// Uploads the texture to the GPU to be available when we need it. This is a lazy operation;
|
||||
// the texture is only bound when the data is out of date (=dirty).
|
||||
void upload(gl::ObjectStore&, gl::Config&, uint32_t unit);
|
||||
void upload(gl::ObjectStore&, gl::Context&, uint32_t unit);
|
||||
|
||||
dimension getWidth() const { return width; }
|
||||
dimension getHeight() const { return height; }
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include <mbgl/text/glyph_pbf.hpp>
|
||||
#include <mbgl/gl/gl.hpp>
|
||||
#include <mbgl/gl/object_store.hpp>
|
||||
#include <mbgl/gl/gl_config.hpp>
|
||||
#include <mbgl/gl/context.hpp>
|
||||
#include <mbgl/platform/log.hpp>
|
||||
#include <mbgl/platform/platform.hpp>
|
||||
|
||||
@@ -204,14 +204,14 @@ void GlyphAtlas::removeGlyphs(uintptr_t tileUID) {
|
||||
}
|
||||
}
|
||||
|
||||
void GlyphAtlas::upload(gl::ObjectStore& store, gl::Config& config, uint32_t unit) {
|
||||
void GlyphAtlas::upload(gl::ObjectStore& store, gl::Context& context, uint32_t unit) {
|
||||
if (dirty) {
|
||||
const bool first = !texture;
|
||||
bind(store, config, unit);
|
||||
bind(store, context, unit);
|
||||
|
||||
std::lock_guard<std::mutex> lock(mtx);
|
||||
|
||||
config.activeTexture = unit;
|
||||
context.activeTexture = unit;
|
||||
if (first) {
|
||||
MBGL_CHECK_ERROR(glTexImage2D(
|
||||
GL_TEXTURE_2D, // GLenum target
|
||||
@@ -242,11 +242,11 @@ void GlyphAtlas::upload(gl::ObjectStore& store, gl::Config& config, uint32_t uni
|
||||
}
|
||||
}
|
||||
|
||||
void GlyphAtlas::bind(gl::ObjectStore& store, gl::Config& config, uint32_t unit) {
|
||||
void GlyphAtlas::bind(gl::ObjectStore& store, gl::Context& context, uint32_t unit) {
|
||||
if (!texture) {
|
||||
texture = store.createTexture();
|
||||
config.activeTexture = unit;
|
||||
config.texture[unit] = *texture;
|
||||
context.activeTexture = unit;
|
||||
context.texture[unit] = *texture;
|
||||
#ifndef GL_ES_VERSION_2_0
|
||||
MBGL_CHECK_ERROR(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0));
|
||||
#endif
|
||||
@@ -254,9 +254,9 @@ void GlyphAtlas::bind(gl::ObjectStore& store, gl::Config& config, uint32_t unit)
|
||||
MBGL_CHECK_ERROR(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR));
|
||||
MBGL_CHECK_ERROR(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE));
|
||||
MBGL_CHECK_ERROR(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE));
|
||||
} else if (config.texture[unit] != *texture) {
|
||||
config.activeTexture = unit;
|
||||
config.texture[unit] = *texture;
|
||||
} else if (context.texture[unit] != *texture) {
|
||||
context.activeTexture = unit;
|
||||
context.texture[unit] = *texture;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ class GlyphPBF;
|
||||
class GlyphAtlasObserver;
|
||||
|
||||
namespace gl {
|
||||
class Config;
|
||||
class Context;
|
||||
} // namespace gl
|
||||
|
||||
class GlyphAtlas : public util::noncopyable {
|
||||
@@ -61,11 +61,11 @@ public:
|
||||
void removeGlyphs(uintptr_t tileUID);
|
||||
|
||||
// Binds the atlas texture to the GPU, and uploads data if it is out of date.
|
||||
void bind(gl::ObjectStore&, gl::Config&, uint32_t unit);
|
||||
void bind(gl::ObjectStore&, gl::Context&, uint32_t unit);
|
||||
|
||||
// Uploads the texture to the GPU to be available when we need it. This is a lazy operation;
|
||||
// the texture is only bound when the data is out of date (=dirty).
|
||||
void upload(gl::ObjectStore&, gl::Config&, uint32_t unit);
|
||||
void upload(gl::ObjectStore&, gl::Context&, uint32_t unit);
|
||||
|
||||
const GLsizei width;
|
||||
const GLsizei height;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include <mbgl/gl/gl_config.hpp>
|
||||
#include <mbgl/gl/context.hpp>
|
||||
#include <mbgl/util/offscreen_texture.hpp>
|
||||
|
||||
#include <cassert>
|
||||
@@ -6,18 +6,18 @@
|
||||
namespace mbgl {
|
||||
|
||||
void OffscreenTexture::bind(gl::ObjectStore& store,
|
||||
gl::Config& config,
|
||||
gl::Context& context,
|
||||
std::array<uint16_t, 2> size) {
|
||||
assert(size[0] > 0 && size[1] > 0);
|
||||
|
||||
if (raster.getSize() != size) {
|
||||
raster.load(PremultipliedImage(size[0], size[1], nullptr));
|
||||
raster.upload(store, config, 0);
|
||||
raster.upload(store, context, 0);
|
||||
}
|
||||
|
||||
if (!fbo) {
|
||||
fbo = store.createFBO();
|
||||
config.bindFramebuffer = *fbo;
|
||||
context.bindFramebuffer = *fbo;
|
||||
MBGL_CHECK_ERROR(glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
|
||||
raster.getID(), 0));
|
||||
|
||||
@@ -49,10 +49,10 @@ void OffscreenTexture::bind(gl::ObjectStore& store,
|
||||
}
|
||||
}
|
||||
} else {
|
||||
config.bindFramebuffer = *fbo;
|
||||
context.bindFramebuffer = *fbo;
|
||||
}
|
||||
|
||||
config.viewport = { { 0, 0, static_cast<GLint>(size[0]), static_cast<GLint>(size[1]) } };
|
||||
context.viewport = { { 0, 0, static_cast<GLint>(size[0]), static_cast<GLint>(size[1]) } };
|
||||
}
|
||||
|
||||
Raster& OffscreenTexture::getTexture() {
|
||||
|
||||
@@ -5,12 +5,12 @@
|
||||
namespace mbgl {
|
||||
|
||||
namespace gl {
|
||||
class Config;
|
||||
class Context;
|
||||
} // namespace gl
|
||||
|
||||
class OffscreenTexture {
|
||||
public:
|
||||
void bind(gl::ObjectStore&, gl::Config&, std::array<uint16_t, 2> size);
|
||||
void bind(gl::ObjectStore&, gl::Context&, std::array<uint16_t, 2> size);
|
||||
|
||||
Raster& getTexture();
|
||||
std::array<uint16_t, 2> getSize() const;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include <mbgl/platform/platform.hpp>
|
||||
#include <mbgl/gl/gl.hpp>
|
||||
#include <mbgl/gl/gl_config.hpp>
|
||||
#include <mbgl/gl/context.hpp>
|
||||
#include <mbgl/platform/log.hpp>
|
||||
|
||||
#include <mbgl/util/raster.hpp>
|
||||
@@ -32,7 +32,7 @@ void Raster::load(PremultipliedImage image, uint32_t mipmapLevel) {
|
||||
}
|
||||
|
||||
void Raster::bind(gl::ObjectStore& store,
|
||||
gl::Config& config,
|
||||
gl::Context& context,
|
||||
uint32_t unit,
|
||||
Scaling newFilter,
|
||||
MipMap newMipMap) {
|
||||
@@ -43,13 +43,13 @@ void Raster::bind(gl::ObjectStore& store,
|
||||
Log::Error(Event::OpenGL, "trying to bind texture without images");
|
||||
return;
|
||||
} else {
|
||||
upload(store, config, unit);
|
||||
upload(store, context, unit);
|
||||
filterNeedsUpdate = true;
|
||||
}
|
||||
} else {
|
||||
if (config.texture[unit] != *texture) {
|
||||
config.activeTexture = unit;
|
||||
config.texture[unit] = *texture;
|
||||
if (context.texture[unit] != *texture) {
|
||||
context.activeTexture = unit;
|
||||
context.texture[unit] = *texture;
|
||||
}
|
||||
filterNeedsUpdate = (filter != newFilter || mipmap != newMipMap);
|
||||
}
|
||||
@@ -71,11 +71,11 @@ void Raster::updateFilter() {
|
||||
filter == Scaling::Linear ? GL_LINEAR : GL_NEAREST));
|
||||
}
|
||||
|
||||
void Raster::upload(gl::ObjectStore& store, gl::Config& config, uint32_t unit) {
|
||||
void Raster::upload(gl::ObjectStore& store, gl::Context& context, uint32_t unit) {
|
||||
if (!images.empty() && !texture) {
|
||||
texture = store.createTexture();
|
||||
config.activeTexture = unit;
|
||||
config.texture[unit] = *texture;
|
||||
context.activeTexture = unit;
|
||||
context.texture[unit] = *texture;
|
||||
updateFilter();
|
||||
#ifndef GL_ES_VERSION_2_0
|
||||
MBGL_CHECK_ERROR(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, images.size()));
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
namespace mbgl {
|
||||
|
||||
namespace gl {
|
||||
class Config;
|
||||
class Context;
|
||||
} // namespace gl
|
||||
|
||||
class Raster {
|
||||
@@ -23,13 +23,13 @@ public:
|
||||
|
||||
// bind current texture
|
||||
void bind(gl::ObjectStore&,
|
||||
gl::Config&,
|
||||
gl::Context&,
|
||||
uint32_t unit,
|
||||
Scaling = Scaling::Nearest,
|
||||
MipMap = MipMap::No);
|
||||
|
||||
// uploads the texture if it hasn't been uploaded yet.
|
||||
void upload(gl::ObjectStore&, gl::Config&, uint32_t unit);
|
||||
void upload(gl::ObjectStore&, gl::Context&, uint32_t unit);
|
||||
|
||||
// loaded status
|
||||
bool isLoaded() const;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include <mbgl/platform/default/headless_view.hpp>
|
||||
|
||||
#include <mbgl/gl/gl.hpp>
|
||||
#include <mbgl/gl/gl_config.hpp>
|
||||
#include <mbgl/gl/context.hpp>
|
||||
#include <mbgl/gl/object_store.hpp>
|
||||
|
||||
#include <memory>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include <mbgl/test/util.hpp>
|
||||
|
||||
#include <mbgl/gl/gl_config.hpp>
|
||||
#include <mbgl/gl/context.hpp>
|
||||
#include <mbgl/platform/default/headless_view.hpp>
|
||||
|
||||
#include <mbgl/util/offscreen_texture.hpp>
|
||||
@@ -67,7 +67,7 @@ struct Buffer {
|
||||
TEST(OffscreenTexture, RenderToTexture) {
|
||||
HeadlessView view(1.0f, 512, 256);
|
||||
view.activate();
|
||||
gl::Config config;
|
||||
gl::Context context;
|
||||
gl::ObjectStore store;
|
||||
|
||||
|
||||
@@ -108,18 +108,18 @@ void main() {
|
||||
// Make sure the texture gets destructed before we call store.reset();
|
||||
{
|
||||
// First, draw red to the bound FBO.
|
||||
config.clearColor = { 1, 0, 0, 1 };
|
||||
context.clearColor = { 1, 0, 0, 1 };
|
||||
MBGL_CHECK_ERROR(glClear(GL_COLOR_BUFFER_BIT));
|
||||
|
||||
// Then, create a texture, bind it, and render yellow to that texture. This should not
|
||||
// affect the originally bound FBO.
|
||||
OffscreenTexture texture;
|
||||
texture.bind(store, config, {{ 128, 128 }});
|
||||
texture.bind(store, context, {{ 128, 128 }});
|
||||
|
||||
config.clearColor = { 0, 0, 0, 0 };
|
||||
context.clearColor = { 0, 0, 0, 0 };
|
||||
MBGL_CHECK_ERROR(glClear(GL_COLOR_BUFFER_BIT));
|
||||
|
||||
config.program = paintShader.program;
|
||||
context.program = paintShader.program;
|
||||
MBGL_CHECK_ERROR(glBindBuffer(GL_ARRAY_BUFFER, triangleBuffer.buffer));
|
||||
MBGL_CHECK_ERROR(glEnableVertexAttribArray(paintShader.a_pos));
|
||||
MBGL_CHECK_ERROR(
|
||||
@@ -130,14 +130,14 @@ void main() {
|
||||
test::checkImage("test/fixtures/offscreen_texture/render-to-texture", image, 0, 0);
|
||||
|
||||
// Now reset the FBO back to normal and retrieve the original (restored) framebuffer.
|
||||
config.resetState();
|
||||
context.resetState();
|
||||
|
||||
image = view.readStillImage();
|
||||
test::checkImage("test/fixtures/offscreen_texture/render-to-fbo", image, 0, 0);
|
||||
|
||||
// Now, composite the Framebuffer texture we've rendered to onto the main FBO.
|
||||
config.program = compositeShader.program;
|
||||
texture.getTexture().bind(store, config, 0, Raster::Scaling::Linear);
|
||||
context.program = compositeShader.program;
|
||||
texture.getTexture().bind(store, context, 0, Raster::Scaling::Linear);
|
||||
MBGL_CHECK_ERROR(glUniform1i(u_texture, 0));
|
||||
MBGL_CHECK_ERROR(glBindBuffer(GL_ARRAY_BUFFER, viewportBuffer.buffer));
|
||||
MBGL_CHECK_ERROR(glEnableVertexAttribArray(compositeShader.a_pos));
|
||||
|
||||
Reference in New Issue
Block a user