Topic/drawable 2 (#1029)

This commit is contained in:
Tim Sylvester
2023-04-17 15:34:47 -07:00
committed by Bart Louwers
parent 14b53e54ec
commit e2bc75289c
16 changed files with 190 additions and 109 deletions

View File

@@ -1,4 +1,5 @@
#include <mbgl/gl/context.hpp>
#include <mbgl/gl/drawable_gl.hpp>
#include <mbgl/gl/enum.hpp>
#include <mbgl/gl/renderer_backend.hpp>
#include <mbgl/gl/texture_resource.hpp>
@@ -9,6 +10,7 @@
#include <mbgl/gl/command_encoder.hpp>
#include <mbgl/gl/debugging_extension.hpp>
#include <mbgl/gl/defines.hpp>
#include <mbgl/shaders/gl/shader_program_gl.hpp>
#include <mbgl/util/traits.hpp>
#include <mbgl/util/std.hpp>
#include <mbgl/util/logging.hpp>
@@ -445,7 +447,34 @@ void Context::setDirtyState() {
globalVertexArrayState.setDirty();
}
void Context::clear(std::optional<mbgl::Color> color, std::optional<float> depth, std::optional<int32_t> stencil) {
void Context::setupDraw(const gfx::Drawable& drawable) {
if (auto &shader = drawable.getShader()) {
if (shader != currentShader) {
setCurrentShader(shader);
}
}
auto& drawableGL = static_cast<const DrawableGL&>(drawable);
auto& vao = drawableGL.getVertexArray();
if (vao.isValid()) {
bindVertexArray = vao.getID(); // glBindVertexArray
} else {
bindVertexArray = value::BindVertexArray::Default;
}
}
void Context::setCurrentShader(gfx::ShaderProgramBasePtr value) {
if ((currentShader = std::move(value))) {
auto& shaderGL = static_cast<ShaderProgramGL&>(*currentShader);
this->program = shaderGL.getGLProgramID();
} else {
this->program = value::Program::Default;
}
}
void Context::clear(std::optional<mbgl::Color> color,
std::optional<float> depth,
std::optional<int32_t> stencil) {
GLbitfield mask = 0;
if (color) {