Renderer.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. //
  2. // Created by jovian on 18/07/17.
  3. //
  4. #ifndef TINYSHOOTER_RENDERER_H
  5. #define TINYSHOOTER_RENDERER_H
  6. #include <SDL2/SDL.h>
  7. #include <vector>
  8. #include "Visual.h"
  9. class Renderer {
  10. public :
  11. Renderer();
  12. virtual ~Renderer();
  13. bool initialize(int nbPlayers = 1); // Initialize SDL and load features (return false if error)
  14. void clearWindow(); // Clear all content
  15. void renderScene(std::vector<Visual *> &scope, const b2Vec2 &center, float zoom, int which = 0); // Displays a view
  16. void presentWindow(); // Refresh window
  17. SDL_Window *getWindow() const;
  18. /**
  19. * Compute a useful distance for AABB sculling query
  20. * @param zoom : Current zoom level
  21. * @param which : Which viewport
  22. * @return b2Vec2 double positive semi diagonale
  23. */
  24. b2Vec2 computeDiago(float zoom, int which = 0);
  25. private:
  26. bool loadPicture(std::string name); // Load a single picture
  27. bool loadEveryPicture(); // Load all contents needed in the game
  28. void locateViews(int nbPlayers); // Locate viewports for splitscreen
  29. protected:
  30. int m_screenWidth;
  31. int m_screenHeight;
  32. SDL_Window *m_window; // SDL main window
  33. SDL_Renderer *m_renderer; // SDL main renderer
  34. std::vector<SDL_Texture *> m_pictureTab; // Every game texture
  35. const int m_border; // Split screen offset
  36. SDL_Rect m_viewPort[4]; // Screen partition
  37. };
  38. #endif //TINYSHOOTER_RENDERER_H