#ifndef MAPSCENE_H #define MAPSCENE_H #include "map.h" #include #include #include #include #include struct MapScene : public Map, public BasicScene { public: MapScene(int n, int w, int h=0) : Map(n, w, h), m_teamColors(new TeamColor[n]),m_vao(0),m_vbo(0) {} ~MapScene(); /** * @brief updatePixel marks a pixel coordinate as changed, * duplicates are removed and the pixel will be updated * only once on the next draw with the latest map pixel information. */ void updatePixel(const Coord &c); void setColors(int teamId, const glm::vec3 &spawnColor, const glm::vec3 &dudeColor); void initDraw(); bool updateNecessary() { return !m_pixels.empty(); } void draw(); glm::vec3 getColor(const Pixel &px) const; private: struct TeamColor { glm::vec3 spawn; glm::vec3 dude; TeamColor() : spawn(glm::vec3(0, 0, 1)), dude(glm::vec3(0, 0, 0.8f)) {} }; TeamColor* m_teamColors; unsigned int m_vao; unsigned int m_vbo; QMutex m_mutex; struct Pix { glm::vec2 pos; glm::vec3 color; Pix(glm::vec2 p, glm::vec3 c) : pos(p), color(c) {} }; std::vector m_pixels; std::map m_updatedCoordMap; }; #endif // MAPSCENE_H