Define draw item shaders in draw items, not the generic draw layer

This commit is contained in:
Dan Paulat 2022-10-03 00:11:39 -05:00
parent d84a618d3d
commit 224d36bae5
8 changed files with 88 additions and 83 deletions

View file

@ -2,6 +2,12 @@
#include <string>
#pragma warning(push, 0)
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/type_ptr.hpp>
#pragma warning(pop)
namespace scwx
{
namespace qt
@ -13,20 +19,33 @@ namespace draw
static const std::string logPrefix_ = "scwx::qt::gl::draw::draw_item";
class DrawItemImpl
class DrawItem::Impl
{
public:
explicit DrawItemImpl() {}
explicit Impl(OpenGLFunctions& gl) : gl_ {gl} {}
~Impl() {}
~DrawItemImpl() {}
OpenGLFunctions& gl_;
};
DrawItem::DrawItem() : p(std::make_unique<DrawItemImpl>()) {}
DrawItem::DrawItem(OpenGLFunctions& gl) : p(std::make_unique<Impl>(gl)) {}
DrawItem::~DrawItem() = default;
DrawItem::DrawItem(DrawItem&&) noexcept = default;
DrawItem::DrawItem(DrawItem&&) noexcept = default;
DrawItem& DrawItem::operator=(DrawItem&&) noexcept = default;
void DrawItem::UseDefaultProjection(
const QMapbox::CustomLayerRenderParameters& params, GLint uMVPMatrixLocation)
{
glm::mat4 projection = glm::ortho(0.0f,
static_cast<float>(params.width),
0.0f,
static_cast<float>(params.height));
p->gl_.glUniformMatrix4fv(
uMVPMatrixLocation, 1, GL_FALSE, glm::value_ptr(projection));
}
} // namespace draw
} // namespace gl
} // namespace qt