Improved RenderWindow context creation

Former-commit-id: a744a433603e4f14ce6d7e7c269d5ff659b1a0f7
This commit is contained in:
Lynix 2014-04-26 12:58:07 +02:00
parent beb1879aca
commit b899ff294b
1 changed files with 14 additions and 14 deletions

View File

@ -149,14 +149,14 @@ bool NzRenderWindow::CopyToTexture(NzTexture* texture) const
bool NzRenderWindow::Create(NzVideoMode mode, const NzString& title, nzUInt32 style, const NzContextParameters& parameters) bool NzRenderWindow::Create(NzVideoMode mode, const NzString& title, nzUInt32 style, const NzContextParameters& parameters)
{ {
m_parameters = parameters; m_parameters = parameters;
return NzWindow::Create(mode, title, style); return NzWindow::Create(mode, title, style);
} }
bool NzRenderWindow::Create(NzWindowHandle handle, const NzContextParameters& parameters) bool NzRenderWindow::Create(NzWindowHandle handle, const NzContextParameters& parameters)
{ {
m_parameters = parameters; m_parameters = parameters;
return NzWindow::Create(handle); return NzWindow::Create(handle);
} }
void NzRenderWindow::Display() void NzRenderWindow::Display()
@ -284,21 +284,21 @@ void NzRenderWindow::EnsureTargetUpdated() const
bool NzRenderWindow::OnWindowCreated() bool NzRenderWindow::OnWindowCreated()
{ {
m_parameters.doubleBuffered = true; m_parameters.doubleBuffered = true;
m_parameters.window = GetHandle(); m_parameters.window = GetHandle();
m_context = new NzContext; std::unique_ptr<NzContext> context(new NzContext);
if (!m_context->Create(m_parameters)) if (!context->Create(m_parameters))
{ {
NazaraError("Failed not create context"); NazaraError("Failed not create context");
delete m_context; return false;
}
return false; m_context = context.release();
}
if (!SetActive(true)) // Les fenêtres s'activent à la création if (!SetActive(true)) // Les fenêtres s'activent à la création
NazaraWarning("Failed to activate window"); NazaraWarning("Failed to activate window");
EnableVerticalSync(false); EnableVerticalSync(false);
NzVector2ui size = GetSize(); NzVector2ui size = GetSize();
@ -312,7 +312,7 @@ bool NzRenderWindow::OnWindowCreated()
m_clock.Restart(); m_clock.Restart();
return true; return true;
} }
void NzRenderWindow::OnWindowDestroy() void NzRenderWindow::OnWindowDestroy()