#include "renderer.h" Renderer::Renderer(){ renderer_ = nullptr; } Renderer::~Renderer(){ SDL_DestroyRenderer(renderer_); } void Renderer::init( SDL_Window* win ) { if (renderer_){ SDL_DestroyRenderer(renderer_); } renderer_ = SDL_CreateRenderer( win, -1, SDL_RENDERER_ACCELERATED); if (renderer_ == NULL){ printf("Unable to create rendering context: %s", SDL_GetError()); } } void Renderer::clear(){ SDL_RenderClear(renderer_); } void Renderer::update(){ SDL_RenderPresent(renderer_); } SDL_Renderer * Renderer::renderer(){ return renderer_; } void Renderer::setScale(int scaleX, int scaleY){ if( SDL_RenderSetScale(renderer_, scaleX, scaleY) < 0){ printf("Unable to set scale in renderer: %s", SDL_GetError()); } }