diff options
author | Nao Pross <naopross@thearcway.org> | 2019-01-25 13:15:29 +0100 |
---|---|---|
committer | Nao Pross <naopross@thearcway.org> | 2019-01-25 13:15:29 +0100 |
commit | ffd6d847526561f03b47c7cb8895cca31f00ee25 (patch) | |
tree | fda782165b7535b65f8933aee1d13cd3409ed140 | |
parent | Interface basic renderer drawing functions (diff) | |
download | libwsdl2-ffd6d847526561f03b47c7cb8895cca31f00ee25.tar.gz libwsdl2-ffd6d847526561f03b47c7cb8895cca31f00ee25.zip |
Move renderer code in video.cpp to reflect header decl order
-rw-r--r-- | video.cpp | 80 |
1 files changed, 39 insertions, 41 deletions
@@ -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 |