ColorRace/engine/src/renderer/MeshRenderer.cpp
2026-08-02 10:17:38 +02:00

30 lines
924 B
C++

//
// Created by sebastian on 29.07.26.
//
#include "MeshRenderer.h"
#include "entities/PointLight.h"
void engine::MeshRenderer::render(RenderQueue &queue, const Camera &camera, const PointLight& light) {
m_shader->start();
m_shader->loadViewMatrix(camera.getViewMatrix());
m_shader->loadProjectionMatrix(camera.getProjectionMatrix());
m_shader->loadCameraPosition(camera.getPosition());
m_shader->loadLight(light.position, light.color);
for (const auto&[mesh, transformationMatrix] : queue.getRenderCommands()) {
m_shader->loadTransformationMatrix(transformationMatrix);
mesh->bind();
for (const auto& section : mesh->getSections()) {
m_shader->loadMaterial(*section.material);
section.material->bind();
mesh->drawSectionRange(section.indexOffset, section.indexCount);
}
mesh->unbind();
}
m_shader->stop();
}