From fa1ad903864e0a5bbd05bba49fc12699f400df38 Mon Sep 17 00:00:00 2001 From: hogliux Date: Wed, 3 Feb 2016 13:19:01 +0000 Subject: [PATCH] Fix black teapot issue --- examples/Demo/Source/Demos/OpenGLDemo.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/examples/Demo/Source/Demos/OpenGLDemo.cpp b/examples/Demo/Source/Demos/OpenGLDemo.cpp index b0a1a3359d..71a9f00f8d 100644 --- a/examples/Demo/Source/Demos/OpenGLDemo.cpp +++ b/examples/Demo/Source/Demos/OpenGLDemo.cpp @@ -589,7 +589,7 @@ struct OpenGLDemoClasses OpenGLDemo() : doBackgroundDrawing (false), scale (0.5f), rotationSpeed (0.0f), rotation (0.0f), - textureToUse (nullptr) + textureToUse (nullptr), lastTexture (nullptr) { if (MainAppWindow* mw = MainAppWindow::getMainAppWindow()) mw->setRenderingEngine (0); @@ -624,6 +624,9 @@ struct OpenGLDemoClasses // When the context is about to close, you must use this callback to delete // any GPU resources while the context is still current. freeAllContextObjects(); + + if (lastTexture != nullptr) + setTexture (lastTexture); } void freeAllContextObjects() @@ -719,7 +722,7 @@ struct OpenGLDemoClasses void setTexture (DemoTexture* t) { - textureToUse = t; + lastTexture = textureToUse = t; } void setShaderProgram (const String& vertexShader, const String& fragmentShader) @@ -789,7 +792,7 @@ struct OpenGLDemoClasses ScopedPointer uniforms; OpenGLTexture texture; - DemoTexture* textureToUse; + DemoTexture* textureToUse, *lastTexture; String newVertexShader, newFragmentShader;