[core] Ensure GL state is set to necessary values in more places
This commit is contained in:
@@ -215,22 +215,28 @@ void Painter::renderPass(RenderPass pass_,
|
||||
pass == RenderPass::Opaque ? "opaque" : "translucent");
|
||||
}
|
||||
|
||||
if (pass == RenderPass::Translucent) {
|
||||
config.blendFunc.reset();
|
||||
config.blend = GL_TRUE;
|
||||
} else {
|
||||
config.blend = GL_FALSE;
|
||||
}
|
||||
|
||||
for (; it != end; ++it, i += increment) {
|
||||
currentLayer = i;
|
||||
const auto& item = *it;
|
||||
|
||||
if (!item.layer.hasRenderPass(pass))
|
||||
continue;
|
||||
|
||||
if (pass == RenderPass::Translucent) {
|
||||
config.blendFunc.reset();
|
||||
config.blend = GL_TRUE;
|
||||
} else {
|
||||
config.blend = GL_FALSE;
|
||||
}
|
||||
|
||||
config.colorMask = { GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE };
|
||||
config.stencilMask = 0x0;
|
||||
config.viewport = { 0, 0, frame.framebufferSize[0], frame.framebufferSize[1] };
|
||||
|
||||
if (item.bucket && item.tile) {
|
||||
if (item.layer.hasRenderPass(pass)) {
|
||||
MBGL_DEBUG_GROUP(item.layer.id + " - " + std::string(item.tile->id));
|
||||
prepareTile(*item.tile);
|
||||
item.bucket->render(*this, item.layer, item.tile->id, item.tile->matrix);
|
||||
}
|
||||
MBGL_DEBUG_GROUP(item.layer.id + " - " + std::string(item.tile->id));
|
||||
prepareTile(*item.tile);
|
||||
item.bucket->render(*this, item.layer, item.tile->id, item.tile->matrix);
|
||||
} else {
|
||||
MBGL_DEBUG_GROUP("background");
|
||||
renderBackground(*item.layer.template as<BackgroundLayer>());
|
||||
@@ -251,7 +257,7 @@ void Painter::renderBackground(const BackgroundLayer& layer) {
|
||||
mapbox::util::optional<SpriteAtlasPosition> imagePosA = spriteAtlas->getPosition(properties.pattern.value.from, true);
|
||||
mapbox::util::optional<SpriteAtlasPosition> imagePosB = spriteAtlas->getPosition(properties.pattern.value.to, true);
|
||||
|
||||
if ((properties.opacity >= 1.0f) != (pass == RenderPass::Opaque) || !imagePosA || !imagePosB)
|
||||
if (!imagePosA || !imagePosB)
|
||||
return;
|
||||
|
||||
float zoomFraction = state.getZoomFraction();
|
||||
@@ -309,6 +315,7 @@ void Painter::renderBackground(const BackgroundLayer& layer) {
|
||||
config.stencilTest = GL_FALSE;
|
||||
config.depthFunc.reset();
|
||||
config.depthTest = GL_TRUE;
|
||||
config.depthMask = GL_FALSE;
|
||||
config.depthRange = { 1.0f, 1.0f };
|
||||
|
||||
MBGL_CHECK_ERROR(glDrawArrays(GL_TRIANGLE_STRIP, 0, 4));
|
||||
|
||||
@@ -18,6 +18,10 @@ void Painter::renderCircle(CircleBucket& bucket,
|
||||
if (pass == RenderPass::Opaque) return;
|
||||
|
||||
config.stencilTest = GL_FALSE;
|
||||
config.depthFunc.reset();
|
||||
config.depthTest = GL_TRUE;
|
||||
config.depthMask = GL_FALSE;
|
||||
setDepthSublayer(0);
|
||||
|
||||
const CirclePaintProperties& properties = layer.paint;
|
||||
mat4 vtxMatrix = translatedMatrix(matrix, properties.translate, id, properties.translateAnchor);
|
||||
|
||||
@@ -23,10 +23,6 @@ void Painter::drawClippingMasks(const std::set<Source*>& sources) {
|
||||
for (const auto& source : sources) {
|
||||
source->drawClippingMasks(*this);
|
||||
}
|
||||
|
||||
config.colorMask = { GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE };
|
||||
config.depthMask = GL_TRUE;
|
||||
config.stencilMask = 0x0;
|
||||
}
|
||||
|
||||
void Painter::drawClippingMask(const mat4& matrix, const ClipID &clip) {
|
||||
|
||||
@@ -39,6 +39,7 @@ void Painter::renderFill(FillBucket& bucket, const FillLayer& layer, const TileI
|
||||
config.stencilTest = GL_TRUE;
|
||||
config.depthFunc.reset();
|
||||
config.depthTest = GL_TRUE;
|
||||
config.depthMask = GL_TRUE;
|
||||
|
||||
// Because we're drawing top-to-bottom, and we update the stencil mask
|
||||
// befrom, we have to draw the outline first (!)
|
||||
@@ -93,7 +94,6 @@ void Painter::renderFill(FillBucket& bucket, const FillLayer& layer, const TileI
|
||||
spriteAtlas->bind(true);
|
||||
|
||||
// Draw the actual triangles into the color & stencil buffer.
|
||||
config.depthMask = GL_TRUE;
|
||||
setDepthSublayer(0);
|
||||
bucket.drawElements(*patternShader);
|
||||
}
|
||||
@@ -110,7 +110,6 @@ void Painter::renderFill(FillBucket& bucket, const FillLayer& layer, const TileI
|
||||
plainShader->u_color = fill_color;
|
||||
|
||||
// Draw the actual triangles into the color & stencil buffer.
|
||||
config.depthMask = GL_TRUE;
|
||||
setDepthSublayer(1);
|
||||
bucket.drawElements(*plainShader);
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ void Painter::renderRaster(RasterBucket& bucket, const RasterLayer& layer, const
|
||||
config.stencilTest = GL_TRUE;
|
||||
config.depthFunc.reset();
|
||||
config.depthTest = GL_TRUE;
|
||||
config.depthMask = GL_FALSE;
|
||||
setDepthSublayer(0);
|
||||
bucket.drawRaster(*rasterShader, tileStencilBuffer, coveringRasterArray);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user