Renderer: RenderWindow now requires a RenderDevice

This commit is contained in:
Lynix
2021-05-16 23:13:00 +02:00
parent 40772f2137
commit 13feaf4aab
30 changed files with 132 additions and 107 deletions

View File

@@ -41,11 +41,11 @@ namespace Nz
DummySurface* dummySurface = static_cast<DummySurface*>(surface);
OpenGLRenderer* glRenderer = static_cast<OpenGLRenderer*>(renderer);
m_device = std::static_pointer_cast<OpenGLDevice>(glRenderer->InstanciateRenderDevice(0));
OpenGLDevice& device = static_cast<OpenGLDevice&>(*m_owner.GetRenderDevice());
GL::ContextParams contextParams;
m_context = m_device->CreateContext(contextParams, dummySurface->GetWindowHandle());
m_context = device.CreateContext(contextParams, dummySurface->GetWindowHandle());
if (!m_context)
return false;
@@ -75,11 +75,6 @@ namespace Nz
return m_renderPass;
}
std::shared_ptr<RenderDevice> OpenGLRenderWindow::GetRenderDevice()
{
return m_device;
}
void OpenGLRenderWindow::Present()
{
m_context->SwapBuffers();

View File

@@ -24,6 +24,13 @@
namespace Nz
{
OpenGLRenderer::OpenGLRenderer()
{
auto& dummyDevice = m_deviceInfos.emplace_back();
dummyDevice.name = "OpenGL Default Device";
dummyDevice.type = RenderDeviceType::Unknown;
}
OpenGLRenderer::~OpenGLRenderer()
{
m_device.reset();
@@ -107,13 +114,8 @@ namespace Nz
return 300;
}
std::vector<RenderDeviceInfo> OpenGLRenderer::QueryRenderDevices() const
const std::vector<RenderDeviceInfo>& OpenGLRenderer::QueryRenderDevices() const
{
std::vector<RenderDeviceInfo> devices;
auto& dummyDevice = devices.emplace_back();
dummyDevice.name = "OpenGL Default Device";
dummyDevice.type = RenderDeviceType::Unknown;
return devices;
return m_deviceInfos;
}
}