[core] Modern C++ bindings for OpenGL

This commit is contained in:
John Firebaugh
2016-09-26 12:53:32 -07:00
parent a4c82b8a3b
commit 0e57d10d77
97 changed files with 2233 additions and 1857 deletions

View File

@@ -1,11 +1,11 @@
#include <mbgl/renderer/painter.hpp>
#include <mbgl/renderer/paint_parameters.hpp>
#include <mbgl/renderer/render_tile.hpp>
#include <mbgl/gl/gl.hpp>
#include <mbgl/renderer/raster_bucket.hpp>
#include <mbgl/style/layers/raster_layer.hpp>
#include <mbgl/style/layers/raster_layer_impl.hpp>
#include <mbgl/shader/shaders.hpp>
#include <mbgl/shader/raster_uniforms.hpp>
namespace mbgl {
@@ -43,40 +43,39 @@ void Painter::renderRaster(PaintParameters& parameters,
RasterBucket& bucket,
const RasterLayer& layer,
const RenderTile& tile) {
if (pass != RenderPass::Translucent) return;
if (pass != RenderPass::Translucent)
return;
if (!bucket.hasData())
return;
const RasterPaintProperties& properties = layer.impl->paint;
if (bucket.hasData()) {
auto& rasterShader = parameters.shaders.raster;
auto& rasterVAO = parameters.shaders.coveringRasterArray;
assert(bucket.texture);
context.bindTexture(*bucket.texture, 0, gl::TextureFilter::Linear);
context.bindTexture(*bucket.texture, 1, gl::TextureFilter::Linear);
context.program = rasterShader.getID();
rasterShader.u_matrix = tile.matrix;
rasterShader.u_buffer_scale = 1.0f;
rasterShader.u_opacity0 = properties.rasterOpacity;
rasterShader.u_opacity1 = 0;
rasterShader.u_brightness_low = properties.rasterBrightnessMin;
rasterShader.u_brightness_high = properties.rasterBrightnessMax;
rasterShader.u_saturation_factor = saturationFactor(properties.rasterSaturation);
rasterShader.u_contrast_factor = contrastFactor(properties.rasterContrast);
rasterShader.u_spin_weights = spinWeights(properties.rasterHueRotate);
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 = gl::DepthTestFunction::LessEqual;
context.depthTest = true;
context.depthMask = false;
setDepthSublayer(0);
bucket.drawRaster(rasterShader, rasterVertexBuffer, rasterVAO, context);
}
context.draw({
depthModeForSublayer(0, gl::DepthMode::ReadOnly),
gl::StencilMode::disabled(),
colorModeForRenderPass(),
parameters.shaders.raster,
RasterUniforms::values(
tile.matrix,
0,
1,
properties.rasterOpacity.value,
0,
properties.rasterBrightnessMin.value,
properties.rasterBrightnessMax.value,
saturationFactor(properties.rasterSaturation.value),
contrastFactor(properties.rasterContrast.value),
spinWeights(properties.rasterHueRotate.value),
1.0f,
1.0f,
std::array<float, 2> {{ 0.0f, 0.0f }}
),
gl::Unindexed<gl::TriangleStrip>(rasterVertexBuffer)
});
}
} // namespace mbgl