Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2019
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. Renderer.h
  2.  
  3. #pragma once
  4. #include <SDL.h>
  5. #include <SDL_image.h>
  6. #include <SDL_ttf.h>
  7. #include <SDL_mixer.h>
  8. #include <string.h>
  9. #include <unordered_map>
  10. #include "Types.h"
  11. #include "Constants.h"
  12.  
  13. class Renderer {
  14. private:
  15. SDL_Renderer *m_renderer = nullptr;
  16. SDL_Window *m_window = nullptr;
  17. std::unordered_map<std::string, SDL_Texture*> m_textureData;
  18. std::unordered_map<std::string, TTF_Font*> m_fontData;
  19. static Renderer *renderer;
  20. Renderer();
  21.  
  22. public:
  23. static Renderer *Instance() {
  24. if (renderer == nullptr) {
  25. renderer = new Renderer;
  26.  
  27. }
  28. return renderer;
  29. };
  30.  
  31. ~Renderer();
  32. void Clear();
  33. void Render();
  34. void LoadFont(Font font);
  35. void LoadTexture(const std::string &id, const std::string &path);
  36. void LoadTextureText(const std::string &id, Text text);
  37. Vector2 GetTextureSize(const std::string &id);
  38. void PushImage(const std::string &id, const SDL_Rect &rect);
  39. void PushSprite(const std::string &id, const SDL_Rect &rectSprite, const SDL_Rect &rectPos);
  40. void PushRotateSprite(const std::string &id, const SDL_Rect &rectSprite, const SDL_Rect &RectPos, float angle);
  41. void SetRendererDrawColor(int r, int g, int b);
  42. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement