The Problem
I have this problem where I have this singleton `RenderingEngine` but I have added a template to `RenderingEngine` so now the singleton declaration is:
template <class ClockworkT>
using RenderingEngine = ACPPL::Singleton<Private::RenderingEngine<ClockworkT>>;
And it will be up to the user of RenderingEngine
to specify ClockworkT
. The problem is that there are other parts of the library that call upon the RenderingEngine
singleton like so:
ClockworkCanvas::RenderingEngine<ClockworkT>::Instance();
You might be thinking at this point, why not just template anything that uses RenderingEngine
? But there is a callback function that get in the way of that idea:
template <class ClockworkT>
static void framebufferResizeCallback(GLFWwindow* window, int width, int height) {
ClockworkCanvas::RenderingEngine<ClockworkT>::Instance().frameBufferResized();
}
Throws the compiler error
error: no matches converting function 'framebufferResizeCallback' to type 'GLFWframebuffersizefun' {aka 'void (*)(struct GLFWwindow*, int, int)'
Potential Solutions
What I was wondering is whether it would be possible to set `ClockworkT` to a default type which is then overrided by the end user so that I could go back to `ClockworkCanvas::RenderingEngine::Instance();` with out the template. Also this solution would get round the potential to have multiple running RenderingEngine singletons.
clockworkcanvas is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.