From 6931979b8e54c47917a98bd5029e28ff73e8558d Mon Sep 17 00:00:00 2001 From: whitequark Date: Sat, 14 Jan 2017 06:06:55 +0000 Subject: [PATCH] Fix an OpenGL initialization glitch. Before this commit, the first time NewFrame() is called, the background color would not be filled, leading to interference with whatever the GUI toolkit decided to put there. --- src/draw.cpp | 4 ++-- src/render/rendergl2.cpp | 5 ++++- src/textwin.cpp | 4 ++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/draw.cpp b/src/draw.cpp index 46f664d4..7d316cea 100644 --- a/src/draw.cpp +++ b/src/draw.cpp @@ -829,9 +829,9 @@ void GraphicsWindow::Paint() { auto renderStartTime = std::chrono::high_resolution_clock::now(); - canvas->NewFrame(); - canvas->SetCamera(camera); canvas->SetLighting(lighting); + canvas->SetCamera(camera); + canvas->NewFrame(); Draw(canvas.get()); canvas->FlushFrame(); diff --git a/src/render/rendergl2.cpp b/src/render/rendergl2.cpp index aae81d8f..5aa7110d 100644 --- a/src/render/rendergl2.cpp +++ b/src/render/rendergl2.cpp @@ -433,6 +433,7 @@ void OpenGl2Renderer::Init() { glGenVertexArrays(1, &array); glBindVertexArray(array); #endif + UpdateProjection(); } void OpenGl2Renderer::DrawLine(const Vector &a, const Vector &b, hStroke hcs) { @@ -675,7 +676,9 @@ void OpenGl2Renderer::GetIdent(const char **vendor, const char **renderer, const void OpenGl2Renderer::SetCamera(const Camera &c) { camera = c; - UpdateProjection(); + if(initialized) { + UpdateProjection(); + } } void OpenGl2Renderer::SetLighting(const Lighting &l) { diff --git a/src/textwin.cpp b/src/textwin.cpp index 0e014188..9397d404 100644 --- a/src/textwin.cpp +++ b/src/textwin.cpp @@ -870,9 +870,9 @@ void TextWindow::Paint() { Lighting lighting = {}; lighting.backgroundColor = RGBi(0, 0, 0); - canvas->NewFrame(); - canvas->SetCamera(camera); canvas->SetLighting(lighting); + canvas->SetCamera(camera); + canvas->NewFrame(); UiCanvas uiCanvas = {}; uiCanvas.canvas = canvas;