Renderer.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. //
  2. // Created by jovian on 18/07/17.
  3. //
  4. #ifndef TINYSHOOTER_RENDERER_H
  5. #define TINYSHOOTER_RENDERER_H
  6. #include <SDL.h>
  7. #include <vector>
  8. #include <map>
  9. #include <SDL_ttf.h>
  10. #include "Visual.h"
  11. #include "../Contents/PlanetDef.h"
  12. class Renderer {
  13. public :
  14. Renderer();
  15. virtual ~Renderer();
  16. bool initialize(); // Initialize SDL and load features (return false if error)
  17. void clearWindow(); // Clear all content
  18. void renderScene(std::vector<Visual *> &scope, const b2Vec2 &center, float zoom); // Displays a view
  19. void renderPlanetHUD(PlanetDef def);
  20. void renderName(SDL_Rect &dst, std::string name);
  21. void renderBar(int y, const int &value);
  22. void presentWindow(); // Refresh window
  23. SDL_Window *getWindow() const;
  24. private:
  25. bool loadPicture(std::string name); // Load a single picture
  26. bool loadStringTexture(std::string name); // Load a texture from a string
  27. bool loadEveryPicture(); // Load all contents needed in the game
  28. protected:
  29. int m_screenWidth;
  30. int m_screenHeight;
  31. SDL_Window *m_window; // SDL main window
  32. SDL_Renderer *m_renderer; // SDL main renderer
  33. TTF_Font *m_font; // TTF main font
  34. std::vector<SDL_Texture *> m_pictureTab; // Every game texture
  35. std::map<std::string, SDL_Texture *> m_stringTab; // Every game name texture
  36. };
  37. #endif //TINYSHOOTER_RENDERER_H