From d20c12019ba639033e2f65bc5ed8881321991f13 Mon Sep 17 00:00:00 2001 From: Mark de Wever Date: Thu, 8 May 2014 10:08:08 +0200 Subject: [PATCH] Add a clear function to the window. Also clear the window in the constructor. --- src/sdl/window.cpp | 10 ++++++++++ src/sdl/window.hpp | 3 +++ 2 files changed, 13 insertions(+) diff --git a/src/sdl/window.cpp b/src/sdl/window.cpp index cd90251a0360..a1beafd3aa6d 100644 --- a/src/sdl/window.cpp +++ b/src/sdl/window.cpp @@ -54,6 +54,8 @@ twindow::twindow(const std::string& title, } pixel_format_ = info.texture_formats[0]; + + clear(); } twindow::~twindow() @@ -73,6 +75,14 @@ void twindow::full_screen() /** @todo Implement. */ } +void twindow::clear() +{ + if(SDL_RenderClear(*this) != 0) { + throw texception("Failed to clear the SDL_Renderer object.", + true); + } +} + void twindow::render() { SDL_RenderPresent(*this); diff --git a/src/sdl/window.hpp b/src/sdl/window.hpp index 6ec5d9f76df0..ef21fc89d215 100644 --- a/src/sdl/window.hpp +++ b/src/sdl/window.hpp @@ -98,6 +98,9 @@ class twindow : private boost::noncopyable */ void full_screen(); + /** Clears the contents of the window. */ + void clear(); + /** Renders the contents of the window. */ void render();