Move Drawable draw call recording logic out of renderer
This commit is contained in:
42
openVulkanoCpp/Scene/DrawEncoder.cpp
Normal file
42
openVulkanoCpp/Scene/DrawEncoder.cpp
Normal file
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#include "DrawEncoder.hpp"
|
||||
#include <map>
|
||||
#include <stdexcept>
|
||||
|
||||
namespace openVulkanoCpp::Scene
|
||||
{
|
||||
namespace
|
||||
{
|
||||
auto& GetDrawEncoderRegistry()
|
||||
{
|
||||
static std::map<const std::type_info*, DrawEncoder> drawEncoderRegistry;
|
||||
return drawEncoderRegistry;
|
||||
}
|
||||
|
||||
template<class... args>
|
||||
void EncoderNotImplementedFunction(args... ignored)
|
||||
{
|
||||
throw std::runtime_error("No implementation for encoder!");
|
||||
}
|
||||
}
|
||||
|
||||
void* DrawEncoder::RegisterVulkanEncodeFunction(const std::type_info* type, DrawEncoder::VkEncodeFunc func)
|
||||
{
|
||||
GetDrawEncoderRegistry()[type].vulkan = func;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
DrawEncoder& DrawEncoder::GetDrawEncoder(const std::type_info* type)
|
||||
{
|
||||
return GetDrawEncoderRegistry()[type];
|
||||
}
|
||||
|
||||
DrawEncoder::DrawEncoder()
|
||||
: vulkan(&EncoderNotImplementedFunction)
|
||||
{}
|
||||
}
|
||||
Reference in New Issue
Block a user