diff --git a/include/shadertoy/ToyBuffer.hpp b/include/shadertoy/ToyBuffer.hpp
index ace943571a1c09505f1f60c58a5f38378309b499..f8dc691676fba325b23c4737e7e306e24b08ecbe 100644
--- a/include/shadertoy/ToyBuffer.hpp
+++ b/include/shadertoy/ToyBuffer.hpp
@@ -90,8 +90,8 @@ public:
 	{ return targetTex; }
 
 private:
-	std::shared_ptr<oglplus::Texture> InitializeRenderTexture(int width,
-															  int height);
+	void InitializeRenderTexture(std::shared_ptr<oglplus::Texture> &texptr,
+								 int width, int height);
 };
 
 }
diff --git a/src/ToyBuffer.cpp b/src/ToyBuffer.cpp
index 2610be5c5ba15979ccd59313982bf260dc5664af..b8ef3e325b4190fc1b68af1104fc355bfb8f1f27 100644
--- a/src/ToyBuffer.cpp
+++ b/src/ToyBuffer.cpp
@@ -48,8 +48,8 @@ void ToyBuffer::Initialize(int width, int height)
 void ToyBuffer::AllocateTextures(int width, int height)
 {
 	// Initialize buffer textures
-	sourceTex = InitializeRenderTexture(width, height);
-	targetTex = InitializeRenderTexture(width, height);
+	InitializeRenderTexture(sourceTex, width, height);
+	InitializeRenderTexture(targetTex, width, height);
 
 	// Setup render buffers
 	targetTex->Bind(TextureTarget::_2D);
@@ -102,9 +102,13 @@ void ToyBuffer::Render()
 	swap(sourceTex, targetTex);
 }
 
-shared_ptr<Texture> ToyBuffer::InitializeRenderTexture(int width, int height)
+void ToyBuffer::InitializeRenderTexture(shared_ptr<Texture> &texptr, int width, int height)
 {
-	auto texptr = make_shared<Texture>();
+	// Only create a texture object if it is necessary
+	if (!texptr)
+		texptr = make_shared<Texture>();
+
+	// Allocate texture storage according to width/height
 	gl.DirectEXT(TextureTarget::_2D, *texptr)
 		.MinFilter(TextureMinFilter::Nearest)
 		.MagFilter(TextureMagFilter::Nearest)
@@ -115,13 +119,10 @@ shared_ptr<Texture> ToyBuffer::InitializeRenderTexture(int width, int height)
 				 PixelDataType::UnsignedByte, nullptr);
 
 	// Clear the frame accumulator so it doesn't contain garbage
-	float black[4];
-	memset(black, 0, sizeof(black));
+	float black[4] = {0.f};
 	glClearTexImage(GetName(*texptr),
 		0,
 		GL_BGRA,
 		GL_FLOAT,
 		black);
-
-	return texptr;
 }