12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- //
- // Created by jovian on 18/07/17.
- //
- #ifndef TINYSHOOTER_RENDERER_H
- #define TINYSHOOTER_RENDERER_H
- #include <SDL2/SDL.h>
- #include <vector>
- #include "Visual.h"
- class Renderer {
- public :
- Renderer();
- virtual ~Renderer();
- bool initialize(int nbPlayers = 1); // Initialize SDL and load features (return false if error)
- void clearWindow(); // Clear all content
- void renderScene(std::vector<Visual *> &scope, const b2Vec2 ¢er, float zoom, int which = 0); // Displays a view
- void presentWindow(); // Refresh window
- SDL_Window *getWindow() const;
- /**
- * Compute a useful distance for AABB sculling query
- * @param zoom : Current zoom level
- * @param which : Which viewport
- * @return b2Vec2 double positive semi diagonale
- */
- b2Vec2 computeDiago(float zoom, int which = 0);
- private:
- bool loadPicture(std::string name); // Load a single picture
- bool loadEveryPicture(); // Load all contents needed in the game
- void locateViews(int nbPlayers); // Locate viewports for splitscreen
- protected:
- int m_screenWidth;
- int m_screenHeight;
- SDL_Window *m_window; // SDL main window
- SDL_Renderer *m_renderer; // SDL main renderer
- std::vector<SDL_Texture *> m_pictureTab; // Every game texture
- const int m_border; // Split screen offset
- SDL_Rect m_viewPort[4]; // Screen partition
- };
- #endif //TINYSHOOTER_RENDERER_H
|