#ifndef HEADER_ARRAS_RENDER_H #define HEADER_ARRAS_RENDER_H extern "C" { #include #include } #include "2d.h" #include #include #include #include namespace arras { struct Color { uint8_t r, g, b, a; Color(); Color(uint8_t r, uint8_t g, uint8_t b, uint8_t a); }; std::shared_ptr makeRect(int x, int y, int w, int h); std::shared_ptr makeFRect(const arras::Vec2& pos, const arras::Vec2& size); class RenderSurface { public: RenderSurface(RenderSurface&& rs); RenderSurface(const RenderSurface& rs); explicit RenderSurface(SDL_RWops* src); RenderSurface(int width, int height); ~RenderSurface(); SDL_Surface* nativeHandle() const noexcept; int width() const noexcept; int height() const noexcept; private: SDL_Surface* s; }; class RenderWindow; class RenderTexture { RenderTexture(const RenderTexture&) = delete; RenderTexture& operator=(const RenderTexture&) = delete; public: RenderTexture(RenderTexture&& rt); RenderTexture(const RenderWindow& rd, SDL_RWops* src); RenderTexture(const RenderWindow& rd, const RenderSurface& rs); ~RenderTexture(); SDL_Texture* nativeHandle() const noexcept; int width() const noexcept; int height() const noexcept; std::pair calcRenderSize(int w, int h) const noexcept; private: SDL_Texture* t; int w, h; }; class RenderWindow { RenderWindow(const RenderWindow&) = delete; RenderWindow& operator=(const RenderWindow&) = delete; public: RenderWindow(RenderWindow&& rd); RenderWindow(int w, int h); ~RenderWindow(); SDL_Renderer* nativeHandle() const noexcept; void renderTextureAt(const RenderTexture& t, const Vec2& pos) const; void renderTextureAt(const RenderTexture& t, const Vec2& pos, const Vec2& direction) const; void present() const noexcept; void clear(const Color& c = {}) const; int width() const noexcept; int height() const noexcept; private: int w, h; SDL_Window* window; SDL_Renderer* renderer; }; } // namespace arras #endif