Files
comaps/drape_frontend/render_node.hpp
Konstantin Pastbin e3e4a1985a Organic Maps sources as of 02.04.2025 (fad26bbf22ac3da75e01e62aa01e5c8e11861005)
To expand with full Organic Maps and Maps.ME commits history run:
  git remote add om-historic [om-historic.git repo url]
  git fetch --tags om-historic
  git replace squashed-history historic-commits
2025-05-08 21:10:51 +07:00

69 lines
1.8 KiB
C++

#pragma once
#include "drape_frontend/render_state_extension.hpp"
#include "shaders/program_manager.hpp"
#include "drape/graphics_context.hpp"
#include "drape/vertex_array_buffer.hpp"
#include "drape/pointers.hpp"
#include "geometry/point2d.hpp"
namespace df
{
class RenderNode
{
public:
RenderNode(dp::RenderState const & state, drape_ptr<dp::VertexArrayBuffer> && buffer)
: m_state(state)
, m_buffer(std::move(buffer))
{}
template <typename ParamsType>
void Render(ref_ptr<dp::GraphicsContext> context, ref_ptr<gpu::ProgramManager> mng,
ParamsType const & params, dp::IndicesRange const & range)
{
Apply(context, mng, params);
m_buffer->RenderRange(context, m_state.GetDrawAsLine(), range);
}
template <typename ParamsType>
void Render(ref_ptr<dp::GraphicsContext> context, ref_ptr<gpu::ProgramManager> mng,
ParamsType const & params)
{
Apply(context, mng, params);
m_buffer->Render(context, m_state.GetDrawAsLine());
}
void SetPivot(m2::PointD const & pivot) { m_pivot = pivot; }
m2::PointD const & GetPivot() const { return m_pivot; }
void SetBoundingBox(m2::RectD const & bbox) { m_boundingBox = bbox; }
m2::RectD const & GetBoundingBox() const { return m_boundingBox; }
private:
template <typename ParamsType>
void Apply(ref_ptr<dp::GraphicsContext> context, ref_ptr<gpu::ProgramManager> mng,
ParamsType const & params)
{
auto prg = mng->GetProgram(m_state.GetProgram<gpu::Program>());
prg->Bind();
if (!m_isBuilt)
{
m_buffer->Build(context, prg);
m_isBuilt = true;
}
dp::ApplyState(context, prg, m_state);
mng->GetParamsSetter()->Apply(context, prg, params);
}
dp::RenderState m_state;
drape_ptr<dp::VertexArrayBuffer> m_buffer;
bool m_isBuilt = false;
m2::PointD m_pivot;
m2::RectD m_boundingBox;
};
} // namespace df