/*
* Copyright (C) 2023 Christopher J. Howard
*
* This file is part of Antkeeper source code.
*
* Antkeeper source code is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Antkeeper source code is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Antkeeper source code. If not, see .
*/
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
namespace render {
renderer::renderer(gl::rasterizer& rasterizer, ::resource_manager& resource_manager)
{
m_light_probe_stage = std::make_unique(rasterizer, resource_manager);
m_culling_stage = std::make_unique();
m_queue_stage = std::make_unique();
}
void renderer::render(float t, float dt, float alpha, scene::collection& collection)
{
// Init render context
m_ctx.collection = &collection;
m_ctx.t = t;
m_ctx.dt = dt;
m_ctx.alpha = alpha;
// Execute light probe stage
m_light_probe_stage->execute(m_ctx);
// Get list of cameras to be sorted
const auto& cameras = collection.get_objects(scene::camera::object_type_id);
// Process cameras in order
for (scene::object_base* camera_object: cameras)
{
scene::camera& camera = static_cast(*camera_object);
// Skip cameras with no compositors
compositor* compositor = camera.get_compositor();
if (!compositor)
{
continue;
}
// Update render context camera
m_ctx.camera = &camera;
// Clear render queues
m_ctx.objects.clear();
m_ctx.operations.clear();
// Execute culling stage
m_culling_stage->execute(m_ctx);
// Execute queue stage
m_queue_stage->execute(m_ctx);
// Pass render context to the camera's compositor
compositor->composite(m_ctx);
}
}
} // namespace render