mirror of https://github.com/auygun/kaliber.git
Renderer(base::Closure context_lost_cb)
This commit is contained in:
parent
98e7e5f107
commit
231efe1c92
|
@ -203,19 +203,18 @@ void Engine::CreateRenderer(bool vulkan) {
|
|||
return;
|
||||
|
||||
if (vulkan)
|
||||
renderer_ = std::make_unique<RendererVulkan>();
|
||||
renderer_ =
|
||||
std::make_unique<RendererVulkan>(std::bind(&Engine::ContextLost, this));
|
||||
else
|
||||
renderer_ = std::make_unique<RendererOpenGL>();
|
||||
renderer_->SetContextLostCB(std::bind(&Engine::ContextLost, this));
|
||||
renderer_ =
|
||||
std::make_unique<RendererOpenGL>(std::bind(&Engine::ContextLost, this));
|
||||
|
||||
bool result = renderer_->Initialize(platform_);
|
||||
LOG_IF(!result) << "Failed to initialize " << renderer_->GetDebugName()
|
||||
<< " renderer.";
|
||||
if (!result && vulkan) {
|
||||
LOG << "Failed to initialize " << renderer_->GetDebugName() << " renderer.";
|
||||
LOG << "Fallback to OpenGL renderer.";
|
||||
renderer_ = std::make_unique<RendererOpenGL>();
|
||||
renderer_->SetContextLostCB(std::bind(&Engine::ContextLost, this));
|
||||
result = renderer_->Initialize(platform_);
|
||||
CreateRenderer(false);
|
||||
return;
|
||||
}
|
||||
CHECK(result) << "Failed to initialize " << renderer_->GetDebugName()
|
||||
<< " renderer.";
|
||||
|
|
|
@ -40,8 +40,9 @@ const std::string kAttributeNames[eng::kAttribType_Max] = {
|
|||
namespace eng {
|
||||
|
||||
#ifdef THREADED_RENDERING
|
||||
RendererOpenGL::RendererOpenGL()
|
||||
: main_thread_task_runner_(TaskRunner::GetThreadLocalTaskRunner()) {}
|
||||
RendererOpenGL::RendererOpenGL(base::Closure context_lost_cb)
|
||||
: Renderer(context_lost_cb),
|
||||
main_thread_task_runner_(TaskRunner::GetThreadLocalTaskRunner()) {}
|
||||
#else
|
||||
RendererOpenGL::RendererOpenGL() = default;
|
||||
#endif // THREADED_RENDERING
|
||||
|
|
|
@ -37,7 +37,7 @@ struct RenderCommand;
|
|||
|
||||
class RendererOpenGL final : public Renderer {
|
||||
public:
|
||||
RendererOpenGL();
|
||||
RendererOpenGL(base::Closure context_lost_cb);
|
||||
~RendererOpenGL() final;
|
||||
|
||||
virtual bool Initialize(Platform* platform) final;
|
||||
|
|
|
@ -19,11 +19,10 @@ class Renderer {
|
|||
public:
|
||||
const unsigned kInvalidId = 0;
|
||||
|
||||
Renderer() = default;
|
||||
Renderer(base::Closure context_lost_cb)
|
||||
: context_lost_cb_{std::move(context_lost_cb)} {}
|
||||
virtual ~Renderer() = default;
|
||||
|
||||
void SetContextLostCB(base::Closure cb) { context_lost_cb_ = std::move(cb); }
|
||||
|
||||
virtual bool Initialize(Platform* platform) = 0;
|
||||
virtual void Shutdown() = 0;
|
||||
|
||||
|
|
|
@ -370,7 +370,8 @@ std::pair<int, int> GetNumBlocksForImageFormat(VkFormat format,
|
|||
|
||||
namespace eng {
|
||||
|
||||
RendererVulkan::RendererVulkan() = default;
|
||||
RendererVulkan::RendererVulkan(base::Closure context_lost_cb)
|
||||
: Renderer(context_lost_cb) {}
|
||||
|
||||
RendererVulkan::~RendererVulkan() {
|
||||
Shutdown();
|
||||
|
|
|
@ -20,7 +20,7 @@ namespace eng {
|
|||
|
||||
class RendererVulkan final : public Renderer {
|
||||
public:
|
||||
RendererVulkan();
|
||||
RendererVulkan(base::Closure context_lost_cb);
|
||||
~RendererVulkan() final;
|
||||
|
||||
virtual bool Initialize(Platform* platform) final;
|
||||
|
|
Loading…
Reference in New Issue