#include "renderer.hpp" #include #include #include #include #include #include #include #include "glclasses.hpp" #include "game.hpp" #include "state/explosion.hpp" #include "state/missile.hpp" #include "state/object.hpp" #include "state/planet.hpp" #include "state/player.hpp" #include "state/ship.hpp" #include "state/trace.hpp" #include "image_texture.hpp" #include "particle_batch.hpp" #include "polygon_model.hpp" namespace endofthejedi { class RendererPolygon3d : public Renderer { public: void setup(); void render(const game::State *state) override; void setWindowSize(int px, int py); void setCameraMatrix(const glm::mat4 &cam); private: void renderPlanets(); void renderMissiles(); void renderShips(); void renderParticles(); void renderText(const char *text, float x, float y, float sx, float sy); void addModel(const std::string &filename, PolygonModel **dest); void addExplosionEffect( size_t id, const glm::vec2 &pos, const glm::vec2 &missileVelocity, bool hitPlanet, size_t n, float duration); void advanceGraphicObjects(float dt); // shortcuts which use the lower versions glm::mat4 computeModelMatrix(const game::Planet *planet); glm::mat4 computeModelMatrix(const game::Missile *missile); glm::mat4 computeModelMatrix(const game::Ship *ship); // do the actual computation with these values glm::mat4 computeModelMatrix(const glm::vec2 &pos, float scale, float angle=0.0); void renderTraces(); void configureLightningInShader(Shader *shader) const; void renderBackgroundImage(); void loadBackgroundTexture(); private: // all models are also here (for easy reloading etc.) std::vector m_models; // and with a specific variable name here PolygonModel *m_missileModel; PolygonModel *m_planetModel; PolygonModel *m_shipModel; // for rendering everything Shader m_shader_background; Shader m_shader_game_objects; Shader m_shader_particles; // for accessing const game::State *m_state; std::list m_particles; // time value for last rendering cycle (-1 after setup/startup) float m_lastTime; float m_aspectRatio; // TODO: put representation specialized for rendering in here std::list m_missiles; std::list m_ships; std::string m_backgroundTexturePath; ImageTexture *m_texture; Shader m_postprocess_shader; Shader m_multitexture_shader; Texture m_postprocess_tex0; Texture m_postprocess_tex1; Framebuffer m_postprocess_fbo; int m_w; int m_h; }; }