/* render/state.h This file is part of the Osirion project and is distributed under the terms of the GNU General Public License version 2 */ #ifndef __INCLUDED_RENDER_STATE_H__ #define __INCLUDED_RENDER_STATE_H__ #include "core/entity.h" #include "render/gl.h" namespace render { class State { public: /* ---- render context ------------------------------------- */ /** * @brief Initialize the render state **/ static void init(int width, int height); /** * @brief Initialize the render state **/ static void shutdown(); /** * @brief Resize the render context **/ static void resize(int width, int height); /** * @brief Clear the render context state **/ static void clear(); /* ---- material context ----------------------------------- */ /** * @brief Reset the material context **/ static void reset(); /** * @brief Set the primary color of the material context * set_color() should be used before calling set_material(). **/ static void set_color(const math::Color & color); /** * @brief Set the secondary color of the material context * set_color_second() should be used before calling set_material(). **/ static void set_color_second(const math::Color & color); /** * @brief Set the engine color of the material context * set_color_engine() should be used before calling set_material(). **/ static void set_color_engine(const math::Color & color); /** * @brief Copy primary, secondary and engine color from an entity * set_color() should be used before calling set_material(). **/ static void set_color(const core::Entity *entity); /** * @brief set the power state for materials with Bright and Engine flags */ static void set_power(const bool power); /** * @brief set the material layer context * use_material_layer() will alter the current render context according to the settings * defined by the material layer. If the material uses primary, secondary or engine color, * the current state context colors will be used. **/ static void use_material_layer(const model::Material * material, const model::Layer *layer); inline static int width() { return state_width; } inline static int height() { return state_height; } inline static float aspect() { return state_aspect; } inline static bool has_generate_mipmaps() { return state_has_generate_mipmaps; } inline static bool has_vbo() { return state_has_vbo; } inline static GLuint vbo() { return state_vbo; } inline static int max_lights() { return state_maxlights; } inline static int max_textureunits() { return state_maxtextureunits; } static void set_normalize(const bool enable=true); private: static int state_width; static int state_height; static float state_aspect; static bool state_has_generate_mipmaps; static bool state_has_vbo; static GLuint state_vbo; static int state_maxlights; static int state_maxtextureunits; static size_t state_logo_texture_id; static math::Color state_color_primary; // current primary color static math::Color state_color_secondary; // current secondary color static math::Color state_color_engine; // current secondary color static bool state_power; // power state indicator }; } // namespace render #endif // __INCLUDED_RENDER_STATE_H__