@@ -259,11 +259,6 @@ void Scene::render(math::Size<2, int> aBackbufferResolution)
259259
260260void Scene::renderTo (const graphics::FrameBuffer & aFramebuffer, math::Size<2 , int > aBackbufferResolution)
261261{
262- glBindFramebuffer (GL_DRAW_FRAMEBUFFER, aFramebuffer);
263- glViewport (0 , 0 , aBackbufferResolution.width (), aBackbufferResolution.height ());
264- glClearColor (0 .1f , 0 .2f , 0 .3f , 1 .f );
265- glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
266-
267262 //
268263 // Entities
269264 //
@@ -316,6 +311,11 @@ void Scene::renderTo(const graphics::FrameBuffer & aFramebuffer, math::Size<2, i
316311 //
317312 mGraph .renderFrame (mSceneTree , mEnvironment );
318313
314+ glBindFramebuffer (GL_DRAW_FRAMEBUFFER, aFramebuffer);
315+ glViewport (0 , 0 , aBackbufferResolution.width (), aBackbufferResolution.height ());
316+ glClearColor (0 .1f , 0 .2f , 0 .3f , 1 .f );
317+ glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
318+
319319 if (mSceneControl .mShowTexture )
320320 {
321321 mGraph .passShowTexture (mOrbitalCamera .mCamera ,
@@ -466,7 +466,7 @@ void Scene::presentUi(bool * aOpen)
466466 onFramebufferResize (resolution);
467467 graphics::FrameBuffer fbo;
468468 graphics::ScopedBind{fbo}; // Just to create it
469- graphics::Texture colorTarget{ GL_TEXTURE_2D };
469+ graphics::Texture colorTarget{GL_TEXTURE_2D};
470470 graphics::ScopedBind{colorTarget}; // Just to create it
471471 glTextureStorage2D (colorTarget,
472472 1 ,
@@ -478,7 +478,7 @@ void Scene::presentUi(bool * aOpen)
478478 colorTarget,
479479 /* mip map level*/ 0 );
480480 renderTo (fbo, resolution);
481- ad::serializeTexture<math::sdr::Rgb>(mGraph . mFinalFrame , 0 , GL_RGB,
481+ ad::serializeTexture<math::sdr::Rgb>(colorTarget , 0 , GL_RGB,
482482 arte::ImageFormat::Png, outFile,
483483 arte::ImageOrientation::InvertVerticalAxis);
484484 onFramebufferResize (savedSize);
0 commit comments