summaryrefslogtreecommitdiff
path: root/src/mbgl/renderer
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2016-09-29 15:32:48 +0200
committerJohn Firebaugh <john.firebaugh@gmail.com>2016-09-29 10:17:47 -0700
commitcc78b74098e02311cc646fe5b82c13641ff705fa (patch)
treeaf0219d5611f0984bf3b244a336fbc6074a44cb4 /src/mbgl/renderer
parent15aece8a30dcc1f1f97e28180edda46d05641a2d (diff)
downloadqtlocation-mapboxgl-cc78b74098e02311cc646fe5b82c13641ff705fa.tar.gz
[core] remove dependence on gl.h types
Diffstat (limited to 'src/mbgl/renderer')
-rw-r--r--src/mbgl/renderer/bucket.hpp3
-rw-r--r--src/mbgl/renderer/circle_bucket.cpp1
-rw-r--r--src/mbgl/renderer/frame_history.cpp3
-rw-r--r--src/mbgl/renderer/line_bucket.cpp8
-rw-r--r--src/mbgl/renderer/line_bucket.hpp10
-rw-r--r--src/mbgl/renderer/painter.cpp43
-rw-r--r--src/mbgl/renderer/painter.hpp5
-rw-r--r--src/mbgl/renderer/painter_background.cpp9
-rw-r--r--src/mbgl/renderer/painter_circle.cpp8
-rw-r--r--src/mbgl/renderer/painter_clipping.cpp15
-rw-r--r--src/mbgl/renderer/painter_debug.cpp41
-rw-r--r--src/mbgl/renderer/painter_fill.cpp13
-rw-r--r--src/mbgl/renderer/painter_line.cpp11
-rw-r--r--src/mbgl/renderer/painter_raster.cpp8
-rw-r--r--src/mbgl/renderer/painter_symbol.cpp26
-rw-r--r--src/mbgl/renderer/raster_bucket.cpp2
-rw-r--r--src/mbgl/renderer/symbol_bucket.cpp1
17 files changed, 112 insertions, 95 deletions
diff --git a/src/mbgl/renderer/bucket.hpp b/src/mbgl/renderer/bucket.hpp
index 48f6747447..2c3c7a6e47 100644
--- a/src/mbgl/renderer/bucket.hpp
+++ b/src/mbgl/renderer/bucket.hpp
@@ -1,12 +1,11 @@
#pragma once
-#include <mbgl/gl/gl.hpp>
#include <mbgl/renderer/render_pass.hpp>
#include <mbgl/util/noncopyable.hpp>
#include <atomic>
-#define BUFFER_OFFSET_0 ((GLbyte*)nullptr)
+#define BUFFER_OFFSET_0 ((int8_t*)nullptr)
#define BUFFER_OFFSET(i) ((BUFFER_OFFSET_0) + (i))
namespace mbgl {
diff --git a/src/mbgl/renderer/circle_bucket.cpp b/src/mbgl/renderer/circle_bucket.cpp
index 2dcc71fd4b..7b10fafc93 100644
--- a/src/mbgl/renderer/circle_bucket.cpp
+++ b/src/mbgl/renderer/circle_bucket.cpp
@@ -1,5 +1,6 @@
#include <mbgl/renderer/circle_bucket.hpp>
#include <mbgl/renderer/painter.hpp>
+#include <mbgl/gl/gl.hpp>
#include <mbgl/shader/circle_shader.hpp>
#include <mbgl/style/layers/circle_layer.hpp>
diff --git a/src/mbgl/renderer/frame_history.cpp b/src/mbgl/renderer/frame_history.cpp
index bd35cbc090..daf24c8c37 100644
--- a/src/mbgl/renderer/frame_history.cpp
+++ b/src/mbgl/renderer/frame_history.cpp
@@ -1,6 +1,7 @@
#include <mbgl/renderer/frame_history.hpp>
#include <mbgl/math/minmax.hpp>
#include <mbgl/gl/context.hpp>
+#include <mbgl/gl/gl.hpp>
namespace mbgl {
@@ -100,7 +101,7 @@ void FrameHistory::bind(gl::Context& context, uint32_t unit) {
texture = context.createTexture();
context.activeTexture = unit;
context.texture[unit] = *texture;
-#ifndef GL_ES_VERSION_2_0
+#if not MBGL_USE_GLES2
MBGL_CHECK_ERROR(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0));
#endif
MBGL_CHECK_ERROR(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE));
diff --git a/src/mbgl/renderer/line_bucket.cpp b/src/mbgl/renderer/line_bucket.cpp
index f9693ee538..17a92ad3d8 100644
--- a/src/mbgl/renderer/line_bucket.cpp
+++ b/src/mbgl/renderer/line_bucket.cpp
@@ -101,7 +101,7 @@ void LineBucket::addGeometry(const GeometryCoordinates& vertices) {
nextNormal = util::perp(util::unit(convertPoint<double>(firstVertex - *currentVertex)));
}
- const GLint startVertex = vertexBuffer.index();
+ const int32_t startVertex = vertexBuffer.index();
std::vector<TriangleElement> triangleStore;
for (GLsizei i = 0; i < len; ++i) {
@@ -379,7 +379,7 @@ void LineBucket::addCurrentVertex(const GeometryCoordinate& currentVertex,
double endLeft,
double endRight,
bool round,
- GLint startVertex,
+ int32_t startVertex,
std::vector<TriangleElement>& triangleStore) {
int8_t tx = round ? 1 : 0;
@@ -419,8 +419,8 @@ void LineBucket::addPieSliceVertex(const GeometryCoordinate& currentVertex,
double distance,
const Point<double>& extrude,
bool lineTurnsLeft,
- GLint startVertex,
- std::vector<TriangleElement>& triangleStore) {
+ int32_t startVertex,
+ std::vector<TriangleElement>& triangleStore) {
int8_t ty = lineTurnsLeft;
Point<double> flippedExtrude = extrude * (lineTurnsLeft ? -1.0 : 1.0);
diff --git a/src/mbgl/renderer/line_bucket.hpp b/src/mbgl/renderer/line_bucket.hpp
index 112e5bd8c5..5ddaca8ae8 100644
--- a/src/mbgl/renderer/line_bucket.hpp
+++ b/src/mbgl/renderer/line_bucket.hpp
@@ -43,9 +43,9 @@ private:
};
void addCurrentVertex(const GeometryCoordinate& currentVertex, double& distance,
const Point<double>& normal, double endLeft, double endRight, bool round,
- GLint startVertex, std::vector<LineBucket::TriangleElement>& triangleStore);
+ int32_t startVertex, std::vector<LineBucket::TriangleElement>& triangleStore);
void addPieSliceVertex(const GeometryCoordinate& currentVertex, double distance,
- const Point<double>& extrude, bool lineTurnsLeft, GLint startVertex,
+ const Point<double>& extrude, bool lineTurnsLeft, int32_t startVertex,
std::vector<TriangleElement>& triangleStore);
public:
@@ -55,9 +55,9 @@ private:
LineVertexBuffer vertexBuffer;
TriangleElementsBuffer triangleElementsBuffer;
- GLint e1;
- GLint e2;
- GLint e3;
+ int32_t e1;
+ int32_t e2;
+ int32_t e3;
std::vector<std::unique_ptr<TriangleGroup>> triangleGroups;
diff --git a/src/mbgl/renderer/painter.cpp b/src/mbgl/renderer/painter.cpp
index 3d257c21f9..42f883cef9 100644
--- a/src/mbgl/renderer/painter.cpp
+++ b/src/mbgl/renderer/painter.cpp
@@ -6,6 +6,7 @@
#include <mbgl/style/source_impl.hpp>
#include <mbgl/platform/log.hpp>
+#include <mbgl/gl/gl.hpp>
#include <mbgl/gl/debugging.hpp>
#include <mbgl/style/style.hpp>
@@ -59,7 +60,7 @@ 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();
- context.stencilFunc = { GL_EQUAL, ref, mask };
+ context.stencilFunc = { gl::StencilTestFunction::Equal, ref, mask };
}
void Painter::cleanup() {
@@ -69,7 +70,7 @@ void Painter::cleanup() {
void Painter::render(const Style& style, const FrameData& frame_, SpriteAtlas& annotationSpriteAtlas) {
if (frame.framebufferSize != frame_.framebufferSize) {
context.viewport.setDefaultValue(
- { { 0, 0, frame_.framebufferSize[0], frame_.framebufferSize[1] } });
+ { 0, 0, frame_.framebufferSize[0], frame_.framebufferSize[1] });
}
frame = frame_;
@@ -130,15 +131,16 @@ void Painter::render(const Style& style, const FrameData& frame_, SpriteAtlas& a
context.bindFramebuffer.reset();
context.viewport.reset();
context.stencilFunc.reset();
- context.stencilTest = GL_TRUE;
+ context.stencilTest = true;
context.stencilMask = 0xFF;
- context.depthTest = GL_FALSE;
- context.depthMask = GL_TRUE;
- context.colorMask = { GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE };
+ context.depthTest = false;
+ context.depthMask = true;
+ context.colorMask = { true, true, true, true };
if (paintMode() == PaintMode::Overdraw) {
- context.blend = GL_TRUE;
- context.blendFunc = { GL_CONSTANT_COLOR, GL_ONE };
+ context.blend = true;
+ context.blendFunc = { gl::BlendSourceFactor::ConstantColor,
+ gl::BlendDestinationFactor::One };
const float overdraw = 1.0f / 8.0f;
context.blendColor = { overdraw, overdraw, overdraw, 0.0f };
context.clearColor = Color::black();
@@ -164,7 +166,7 @@ void Painter::render(const Style& style, const FrameData& frame_, SpriteAtlas& a
drawClippingMasks(parameters, generator.getStencils());
}
-#ifndef NDEBUG
+#if not MBGL_USE_GLES2 and not defined(NDEBUG)
if (frame.debugOptions & MapDebugOptions::StencilClip) {
renderClipMasks();
return;
@@ -207,7 +209,7 @@ void Painter::render(const Style& style, const FrameData& frame_, SpriteAtlas& a
}
}
-#ifndef NDEBUG
+#if not MBGL_USE_GLES2 and not defined(NDEBUG)
if (frame.debugOptions & MapDebugOptions::DepthBuffer) {
renderDepthBuffer();
}
@@ -235,7 +237,7 @@ template <class Iterator>
void Painter::renderPass(PaintParameters& parameters,
RenderPass pass_,
Iterator it, Iterator end,
- GLsizei i, int8_t increment) {
+ uint32_t i, int8_t increment) {
pass = pass_;
MBGL_DEBUG_GROUP(pass == RenderPass::Opaque ? "opaque" : "translucent");
@@ -255,15 +257,16 @@ void Painter::renderPass(PaintParameters& parameters,
continue;
if (paintMode() == PaintMode::Overdraw) {
- context.blend = GL_TRUE;
+ context.blend = true;
} else if (pass == RenderPass::Translucent) {
- context.blendFunc.reset();
- context.blend = GL_TRUE;
+ context.blend = true;
+ context.blendFunc = { gl::BlendSourceFactor::One,
+ gl::BlendDestinationFactor::OneMinusSrcAlpha };
} else {
- context.blend = GL_FALSE;
+ context.blend = false;
}
- context.colorMask = { GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE };
+ context.colorMask = { true, true, true, true };
context.stencilMask = 0x0;
if (layer.is<BackgroundLayer>()) {
@@ -272,10 +275,10 @@ void Painter::renderPass(PaintParameters& parameters,
} else if (layer.is<CustomLayer>()) {
MBGL_DEBUG_GROUP(layer.baseImpl->id + " - custom");
context.vertexArrayObject = 0;
- context.depthFunc.reset();
- context.depthTest = GL_TRUE;
- context.depthMask = GL_FALSE;
- context.stencilTest = GL_FALSE;
+ context.depthFunc = gl::DepthTestFunction::LessEqual;
+ context.depthTest = true;
+ context.depthMask = false;
+ context.stencilTest = false;
setDepthSublayer(0);
layer.as<CustomLayer>()->impl->render(state);
context.setDirtyState();
diff --git a/src/mbgl/renderer/painter.hpp b/src/mbgl/renderer/painter.hpp
index 6e11dd2599..2159881ffd 100644
--- a/src/mbgl/renderer/painter.hpp
+++ b/src/mbgl/renderer/painter.hpp
@@ -12,7 +12,6 @@
#include <mbgl/geometry/static_vertex_buffer.hpp>
#include <mbgl/gl/context.hpp>
-#include <mbgl/gl/gl.hpp>
#include <mbgl/style/style.hpp>
@@ -114,7 +113,7 @@ private:
void renderPass(PaintParameters&,
RenderPass,
Iterator it, Iterator end,
- GLsizei i, int8_t increment);
+ uint32_t i, int8_t increment);
void setClipping(const ClipID&);
@@ -174,7 +173,7 @@ private:
RenderPass pass = RenderPass::Opaque;
int numSublayers = 3;
- GLsizei currentLayer;
+ uint32_t currentLayer;
float depthRangeSize;
const float depthEpsilon = 1.0f / (1 << 16);
diff --git a/src/mbgl/renderer/painter_background.cpp b/src/mbgl/renderer/painter_background.cpp
index d8bb3f9218..af92f17c97 100644
--- a/src/mbgl/renderer/painter_background.cpp
+++ b/src/mbgl/renderer/painter_background.cpp
@@ -1,5 +1,6 @@
#include <mbgl/renderer/painter.hpp>
#include <mbgl/renderer/paint_parameters.hpp>
+#include <mbgl/gl/gl.hpp>
#include <mbgl/style/layers/background_layer.hpp>
#include <mbgl/style/layers/background_layer_impl.hpp>
@@ -55,10 +56,10 @@ void Painter::renderBackground(PaintParameters& parameters, const BackgroundLaye
arrayBackground.bind(plainShader, tileStencilBuffer, BUFFER_OFFSET(0), context);
}
- context.stencilTest = GL_FALSE;
- context.depthFunc.reset();
- context.depthTest = GL_TRUE;
- context.depthMask = GL_FALSE;
+ context.stencilTest = false;
+ context.depthFunc = gl::DepthTestFunction::LessEqual;
+ context.depthTest = true;
+ context.depthMask = false;
setDepthSublayer(0);
for (const auto& tileID : util::tileCover(state, state.getIntegerZoom())) {
diff --git a/src/mbgl/renderer/painter_circle.cpp b/src/mbgl/renderer/painter_circle.cpp
index 0894e9b261..327011d03e 100644
--- a/src/mbgl/renderer/painter_circle.cpp
+++ b/src/mbgl/renderer/painter_circle.cpp
@@ -19,10 +19,10 @@ void Painter::renderCircle(PaintParameters& parameters,
// Abort early.
if (pass == RenderPass::Opaque) return;
- context.stencilTest = frame.mapMode == MapMode::Still ? GL_TRUE : GL_FALSE;
- context.depthFunc.reset();
- context.depthTest = GL_TRUE;
- context.depthMask = GL_FALSE;
+ context.stencilTest = frame.mapMode == MapMode::Still;
+ context.depthFunc = gl::DepthTestFunction::LessEqual;
+ context.depthTest = true;
+ context.depthMask = false;
setDepthSublayer(0);
const CirclePaintProperties& properties = layer.impl->paint;
diff --git a/src/mbgl/renderer/painter_clipping.cpp b/src/mbgl/renderer/painter_clipping.cpp
index 7e9fb1c737..03402a2695 100644
--- a/src/mbgl/renderer/painter_clipping.cpp
+++ b/src/mbgl/renderer/painter_clipping.cpp
@@ -1,5 +1,7 @@
#include <mbgl/renderer/painter.hpp>
#include <mbgl/renderer/paint_parameters.hpp>
+#include <mbgl/gl/gl.hpp>
+
#include <mbgl/style/source.hpp>
#include <mbgl/shader/shaders.hpp>
#include <mbgl/util/clip_id.hpp>
@@ -19,11 +21,12 @@ void Painter::drawClippingMasks(PaintParameters& parameters, const std::map<Unwr
const GLuint mask = 0b11111111;
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.stencilOp = { gl::StencilTestOperation::Keep, gl::StencilTestOperation::Keep,
+ gl::StencilTestOperation::Replace };
+ context.stencilTest = true;
+ context.depthTest = false;
+ context.depthMask = false;
+ context.colorMask = { false, false, false, false };
context.stencilMask = mask;
arrayCoveringPlain.bind(plainShader, tileStencilBuffer, BUFFER_OFFSET_0, context);
@@ -38,7 +41,7 @@ void Painter::drawClippingMasks(PaintParameters& parameters, const std::map<Unwr
plainShader.u_matrix = matrix;
const GLint ref = (GLint)(clip.reference.to_ulong());
- context.stencilFunc = { GL_ALWAYS, ref, mask };
+ context.stencilFunc = { gl::StencilTestFunction::Always, ref, mask };
MBGL_CHECK_ERROR(glDrawArrays(GL_TRIANGLES, 0, (GLsizei)tileStencilBuffer.index()));
}
}
diff --git a/src/mbgl/renderer/painter_debug.cpp b/src/mbgl/renderer/painter_debug.cpp
index 09cf676b49..f19b77462a 100644
--- a/src/mbgl/renderer/painter_debug.cpp
+++ b/src/mbgl/renderer/painter_debug.cpp
@@ -26,7 +26,7 @@ void Painter::renderTileDebug(const RenderTile& tile) {
void Painter::renderDebugText(Tile& tile, const mat4 &matrix) {
MBGL_DEBUG_GROUP("debug text");
- context.depthTest = GL_FALSE;
+ context.depthTest = false;
if (!tile.debugBucket || tile.debugBucket->renderable != tile.isRenderable() ||
tile.debugBucket->complete != tile.isComplete() ||
@@ -48,19 +48,19 @@ void Painter::renderDebugText(Tile& tile, const mat4 &matrix) {
context.lineWidth = 4.0f * frame.pixelRatio;
tile.debugBucket->drawLines(plainShader, context);
-#ifndef GL_ES_VERSION_2_0
+#if not MBGL_USE_GLES2
// Draw line "end caps"
MBGL_CHECK_ERROR(glPointSize(2));
tile.debugBucket->drawPoints(plainShader, context);
-#endif
+#endif // MBGL_USE_GLES2
// Draw black text.
plainShader.u_color = Color::black();
context.lineWidth = 2.0f * frame.pixelRatio;
tile.debugBucket->drawLines(plainShader, context);
- context.depthFunc.reset();
- context.depthTest = GL_TRUE;
+ context.depthFunc = gl::DepthTestFunction::LessEqual;
+ context.depthTest = true;
}
void Painter::renderDebugFrame(const mat4 &matrix) {
@@ -69,9 +69,10 @@ 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.
- context.depthTest = GL_FALSE;
- context.stencilOp.reset();
- context.stencilTest = GL_TRUE;
+ context.depthTest = false;
+ context.stencilOp = { gl::StencilTestOperation::Keep, gl::StencilTestOperation::Keep,
+ gl::StencilTestOperation::Replace };
+ context.stencilTest = true;
auto& plainShader = shaders->plain;
context.program = plainShader.getID();
@@ -87,14 +88,14 @@ void Painter::renderDebugFrame(const mat4 &matrix) {
#ifndef NDEBUG
void Painter::renderClipMasks() {
- context.stencilTest = GL_FALSE;
- context.depthTest = GL_FALSE;
+ context.stencilTest = false;
+ context.depthTest = false;
context.program = 0;
- context.colorMask = { GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE };
+ context.colorMask = { true, true, true, true };
-#ifndef GL_ES_VERSION_2_0
+#if not MBGL_USE_GLES2
context.pixelZoom = { 1, 1 };
- context.rasterPos = {{ -1, -1, 0, 0 }};
+ context.rasterPos = { -1, -1, 0, 0 };
// Read the stencil buffer
const auto& fbSize = frame.framebufferSize;
@@ -119,20 +120,20 @@ void Painter::renderClipMasks() {
MBGL_CHECK_ERROR(glWindowPos2i(0, 0));
MBGL_CHECK_ERROR(glDrawPixels(fbSize[0], fbSize[1], GL_LUMINANCE, GL_UNSIGNED_BYTE, pixels.get()));
-#endif // GL_ES_VERSION_2_0
+#endif // MBGL_USE_GLES2
}
#endif // NDEBUG
#ifndef NDEBUG
void Painter::renderDepthBuffer() {
- context.stencilTest = GL_FALSE;
- context.depthTest = GL_FALSE;
+ context.stencilTest = false;
+ context.depthTest = false;
context.program = 0;
- context.colorMask = { GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE };
+ context.colorMask = { true, true, true, true };
-#ifndef GL_ES_VERSION_2_0
+#if not MBGL_USE_GLES2
context.pixelZoom = { 1, 1 };
- context.rasterPos = {{ -1, -1, 0, 0 }};
+ context.rasterPos = { -1, -1, 0, 0 };
// Read the stencil buffer
const auto& fbSize = frame.framebufferSize;
@@ -154,7 +155,7 @@ void Painter::renderDepthBuffer() {
MBGL_CHECK_ERROR(glWindowPos2i(0, 0));
MBGL_CHECK_ERROR(glDrawPixels(fbSize[0], fbSize[1], GL_LUMINANCE, GL_UNSIGNED_BYTE, pixels.get()));
-#endif // GL_ES_VERSION_2_0
+#endif // MBGL_USE_GLES2
}
#endif // NDEBUG
diff --git a/src/mbgl/renderer/painter_fill.cpp b/src/mbgl/renderer/painter_fill.cpp
index 57db012b0c..6d6ae4df61 100644
--- a/src/mbgl/renderer/painter_fill.cpp
+++ b/src/mbgl/renderer/painter_fill.cpp
@@ -1,5 +1,7 @@
#include <mbgl/renderer/painter.hpp>
#include <mbgl/renderer/paint_parameters.hpp>
+#include <mbgl/gl/gl.hpp>
+
#include <mbgl/renderer/fill_bucket.hpp>
#include <mbgl/renderer/render_tile.hpp>
#include <mbgl/style/layers/fill_layer.hpp>
@@ -33,11 +35,12 @@ void Painter::renderFill(PaintParameters& parameters,
bool outline = properties.fillAntialias && !pattern && isOutlineColorDefined;
bool fringeline = properties.fillAntialias && !pattern && !isOutlineColorDefined;
- context.stencilOp.reset();
- context.stencilTest = GL_TRUE;
- context.depthFunc.reset();
- context.depthTest = GL_TRUE;
- context.depthMask = GL_TRUE;
+ context.stencilOp = { gl::StencilTestOperation::Keep, gl::StencilTestOperation::Keep,
+ gl::StencilTestOperation::Replace };
+ context.stencilTest = true;
+ context.depthFunc = gl::DepthTestFunction::LessEqual;
+ context.depthTest = true;
+ context.depthMask = true;
context.lineWidth = 2.0f; // This is always fixed and does not depend on the pixelRatio!
auto& outlineShader = parameters.shaders.outline;
diff --git a/src/mbgl/renderer/painter_line.cpp b/src/mbgl/renderer/painter_line.cpp
index 4658812ef3..ee749746b9 100644
--- a/src/mbgl/renderer/painter_line.cpp
+++ b/src/mbgl/renderer/painter_line.cpp
@@ -20,11 +20,12 @@ void Painter::renderLine(PaintParameters& parameters,
// Abort early.
if (pass == RenderPass::Opaque) return;
- context.stencilOp.reset();
- context.stencilTest = GL_TRUE;
- context.depthFunc.reset();
- context.depthTest = GL_TRUE;
- context.depthMask = GL_FALSE;
+ context.stencilOp = { gl::StencilTestOperation::Keep, gl::StencilTestOperation::Keep,
+ gl::StencilTestOperation::Replace };
+ context.stencilTest = true;
+ context.depthFunc = gl::DepthTestFunction::LessEqual;
+ context.depthTest = true;
+ context.depthMask = false;
const auto& properties = layer.impl->paint;
const auto& layout = bucket.layout;
diff --git a/src/mbgl/renderer/painter_raster.cpp b/src/mbgl/renderer/painter_raster.cpp
index bb956cce8b..8a05456927 100644
--- a/src/mbgl/renderer/painter_raster.cpp
+++ b/src/mbgl/renderer/painter_raster.cpp
@@ -35,16 +35,16 @@ void Painter::renderRaster(PaintParameters& parameters,
rasterShader.u_contrast_factor = contrastFactor(properties.rasterContrast);
rasterShader.u_spin_weights = spinWeights(properties.rasterHueRotate);
- context.stencilTest = GL_FALSE;
+ context.stencilTest = 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;
- context.depthFunc.reset();
- context.depthTest = GL_TRUE;
- context.depthMask = GL_FALSE;
+ context.depthFunc = gl::DepthTestFunction::LessEqual;
+ context.depthTest = true;
+ context.depthMask = false;
setDepthSublayer(0);
bucket.drawRaster(rasterShader, rasterBoundsBuffer, rasterVAO, context);
diff --git a/src/mbgl/renderer/painter_symbol.cpp b/src/mbgl/renderer/painter_symbol.cpp
index 74cdcb4b08..a91329d003 100644
--- a/src/mbgl/renderer/painter_symbol.cpp
+++ b/src/mbgl/renderer/painter_symbol.cpp
@@ -119,7 +119,7 @@ void Painter::renderSymbol(PaintParameters& parameters,
const auto& paint = layer.impl->paint;
const auto& layout = bucket.layout;
- context.depthMask = GL_FALSE;
+ context.depthMask = false;
// TODO remove the `true ||` when #1673 is implemented
const bool drawAcrossEdges = (frame.mapMode == MapMode::Continuous) && (true || !(layout.textAllowOverlap || layout.iconAllowOverlap ||
@@ -131,20 +131,21 @@ 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) {
- context.stencilTest = GL_FALSE;
+ context.stencilTest = false;
} else {
- context.stencilOp.reset();
- context.stencilTest = GL_TRUE;
+ context.stencilOp = { gl::StencilTestOperation::Keep, gl::StencilTestOperation::Keep,
+ gl::StencilTestOperation::Replace };
+ context.stencilTest = true;
}
setDepthSublayer(0);
if (bucket.hasIconData()) {
if (layout.iconRotationAlignment == AlignmentType::Map) {
- context.depthFunc.reset();
- context.depthTest = GL_TRUE;
+ context.depthFunc = gl::DepthTestFunction::LessEqual;
+ context.depthTest = true;
} else {
- context.depthTest = GL_FALSE;
+ context.depthTest = false;
}
bool sdf = bucket.sdfIcons;
@@ -222,10 +223,10 @@ void Painter::renderSymbol(PaintParameters& parameters,
if (bucket.hasTextData()) {
if (layout.textPitchAlignment == AlignmentType::Map) {
- context.depthFunc.reset();
- context.depthTest = GL_TRUE;
+ context.depthFunc = gl::DepthTestFunction::LessEqual;
+ context.depthTest = true;
} else {
- context.depthTest = GL_FALSE;
+ context.depthTest = false;
}
glyphAtlas->bind(context, 0);
@@ -250,8 +251,9 @@ void Painter::renderSymbol(PaintParameters& parameters,
}
if (bucket.hasCollisionBoxData()) {
- context.stencilOp.reset();
- context.stencilTest = GL_TRUE;
+ context.stencilOp = { gl::StencilTestOperation::Keep, gl::StencilTestOperation::Keep,
+ gl::StencilTestOperation::Replace };
+ context.stencilTest = true;
auto& collisionBoxShader = shaders->collisionBox;
context.program = collisionBoxShader.getID();
diff --git a/src/mbgl/renderer/raster_bucket.cpp b/src/mbgl/renderer/raster_bucket.cpp
index f40bfcf27c..0f902880de 100644
--- a/src/mbgl/renderer/raster_bucket.cpp
+++ b/src/mbgl/renderer/raster_bucket.cpp
@@ -2,6 +2,8 @@
#include <mbgl/style/layers/raster_layer.hpp>
#include <mbgl/shader/raster_shader.hpp>
#include <mbgl/renderer/painter.hpp>
+#include <mbgl/gl/gl.hpp>
+
namespace mbgl {
diff --git a/src/mbgl/renderer/symbol_bucket.cpp b/src/mbgl/renderer/symbol_bucket.cpp
index 694e77d45b..3ef0686e4d 100644
--- a/src/mbgl/renderer/symbol_bucket.cpp
+++ b/src/mbgl/renderer/symbol_bucket.cpp
@@ -4,6 +4,7 @@
#include <mbgl/shader/sdf_shader.hpp>
#include <mbgl/shader/icon_shader.hpp>
#include <mbgl/shader/collision_box_shader.hpp>
+#include <mbgl/gl/gl.hpp>
namespace mbgl {