summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--video.cpp80
1 files changed, 39 insertions, 41 deletions
diff --git a/video.cpp b/video.cpp
index 2425b10..47d5756 100644
--- a/video.cpp
+++ b/video.cpp
@@ -12,6 +12,45 @@ extern "C" {
using namespace wsdl2;
+/* class renderer */
+
+renderer::renderer() {
+ npdebug("warning: created uninitialized renderer object");
+}
+
+SDL_Renderer * renderer::sdl() {
+#ifndef DEBUG
+ if (m_renderer == NULL) {
+ throw std::runtime_error(
+ "attempted to call renderer::sdl() when m_renderer is NULL"
+ );
+ }
+#endif
+
+ return m_renderer;
+}
+
+void renderer::create_sdl_renderer(SDL_Window *win) {
+ // create a rendering contest
+ m_renderer = SDL_CreateRenderer(
+ win, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC
+ );
+
+ if (m_renderer == NULL) {
+ throw std::runtime_error("failed to create SDL renderer");
+ }
+}
+
+renderer::renderer(window& w) {
+ create_sdl_renderer(w.sdl());
+}
+
+renderer::~renderer() {
+ if (m_renderer != NULL)
+ SDL_DestroyRenderer(m_renderer);
+ else
+ npdebug("warning: m_renderer is NULL")
+}
/* class window */
@@ -78,44 +117,3 @@ SDL_Window * window::sdl() {
return m_window;
}
-
-
-/* class renderer */
-
-renderer::renderer() {
- npdebug("warning: created uninitialized renderer object");
-}
-
-SDL_Renderer * renderer::sdl() {
-#ifndef DEBUG
- if (m_renderer == NULL) {
- throw std::runtime_error(
- "attempted to call renderer::sdl() when m_renderer is NULL"
- );
- }
-#endif
-
- return m_renderer;
-}
-
-void renderer::create_sdl_renderer(SDL_Window *win) {
- // create a rendering contest
- m_renderer = SDL_CreateRenderer(
- win, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC
- );
-
- if (m_renderer == NULL) {
- throw std::runtime_error("failed to create SDL renderer");
- }
-}
-
-renderer::renderer(window& w) {
- create_sdl_renderer(w.sdl());
-}
-
-renderer::~renderer() {
- if (m_renderer != NULL)
- SDL_DestroyRenderer(m_renderer);
- else
- npdebug("warning: m_renderer is NULL")
-} \ No newline at end of file