mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 14:10:06 +00:00
Define draw item shaders in draw items, not the generic draw layer
This commit is contained in:
parent
d84a618d3d
commit
224d36bae5
8 changed files with 88 additions and 83 deletions
|
|
@ -2,12 +2,6 @@
|
|||
#include <scwx/qt/gl/shader_program.hpp>
|
||||
#include <scwx/util/logger.hpp>
|
||||
|
||||
#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
|
||||
|
|
@ -21,17 +15,9 @@ static const auto logger_ = scwx::util::Logger::Create(logPrefix_);
|
|||
class DrawLayerImpl
|
||||
{
|
||||
public:
|
||||
explicit DrawLayerImpl(std::shared_ptr<MapContext> context) :
|
||||
shaderProgram_ {nullptr}, uMVPMatrixLocation_(GL_INVALID_INDEX)
|
||||
{
|
||||
}
|
||||
|
||||
explicit DrawLayerImpl(std::shared_ptr<MapContext> context) {}
|
||||
~DrawLayerImpl() {}
|
||||
|
||||
std::shared_ptr<gl::ShaderProgram> shaderProgram_;
|
||||
|
||||
GLint uMVPMatrixLocation_;
|
||||
|
||||
std::vector<std::shared_ptr<gl::draw::DrawItem>> drawList_;
|
||||
};
|
||||
|
||||
|
|
@ -43,20 +29,6 @@ DrawLayer::~DrawLayer() = default;
|
|||
|
||||
void DrawLayer::Initialize()
|
||||
{
|
||||
gl::OpenGLFunctions& gl = context()->gl();
|
||||
|
||||
p->shaderProgram_ =
|
||||
context()->GetShaderProgram(":/gl/color.vert", ":/gl/color.frag");
|
||||
|
||||
p->uMVPMatrixLocation_ =
|
||||
gl.glGetUniformLocation(p->shaderProgram_->id(), "uMVPMatrix");
|
||||
if (p->uMVPMatrixLocation_ == -1)
|
||||
{
|
||||
logger_->warn("Could not find uMVPMatrix");
|
||||
}
|
||||
|
||||
p->shaderProgram_->Use();
|
||||
|
||||
for (auto& item : p->drawList_)
|
||||
{
|
||||
item->Initialize();
|
||||
|
|
@ -65,21 +37,9 @@ void DrawLayer::Initialize()
|
|||
|
||||
void DrawLayer::Render(const QMapbox::CustomLayerRenderParameters& params)
|
||||
{
|
||||
gl::OpenGLFunctions& gl = context()->gl();
|
||||
|
||||
p->shaderProgram_->Use();
|
||||
|
||||
glm::mat4 projection = glm::ortho(0.0f,
|
||||
static_cast<float>(params.width),
|
||||
0.0f,
|
||||
static_cast<float>(params.height));
|
||||
|
||||
gl.glUniformMatrix4fv(
|
||||
p->uMVPMatrixLocation_, 1, GL_FALSE, glm::value_ptr(projection));
|
||||
|
||||
for (auto& item : p->drawList_)
|
||||
{
|
||||
item->Render();
|
||||
item->Render(params);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -37,9 +37,9 @@ public:
|
|||
textShader_(context),
|
||||
font_(util::Font::Create(":/res/fonts/din1451alt.ttf")),
|
||||
texture_ {GL_INVALID_INDEX},
|
||||
activeBoxOuter_ {std::make_shared<gl::draw::Rectangle>(context->gl())},
|
||||
activeBoxInner_ {std::make_shared<gl::draw::Rectangle>(context->gl())},
|
||||
timeBox_ {std::make_shared<gl::draw::Rectangle>(context->gl())},
|
||||
activeBoxOuter_ {std::make_shared<gl::draw::Rectangle>(context)},
|
||||
activeBoxInner_ {std::make_shared<gl::draw::Rectangle>(context)},
|
||||
timeBox_ {std::make_shared<gl::draw::Rectangle>(context)},
|
||||
sweepTimeString_ {},
|
||||
sweepTimeNeedsUpdate_ {true}
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue