From 044d0183e254d89dd12d0799be6aa8f8f0f979f2 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Fri, 29 Jul 2011 23:38:07 +0000 Subject: Moved material context functions into the State class. --- src/render/state.h | 86 ++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 74 insertions(+), 12 deletions(-) (limited to 'src/render/state.h') diff --git a/src/render/state.h b/src/render/state.h index 6387be8..b614c1b 100644 --- a/src/render/state.h +++ b/src/render/state.h @@ -7,6 +7,7 @@ #ifndef __INCLUDED_RENDER_STATE_H__ #define __INCLUDED_RENDER_STATE_H__ +#include "core/entity.h" #include "render/gl.h" namespace render @@ -15,41 +16,102 @@ 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 material context + * use_material() will alter the current render context according to the settings + * defined by the material. If the material uses primary, secondary or engine color, + * the current material context colors will be used. + **/ + static void use_material(const model::Material * material); + + inline static int width() { - return render_width; + return state_width; } inline static int height() { - return render_height; + return state_height; } inline static float aspect() { - return render_aspect; + return state_aspect; } inline static bool has_generate_mipmaps() { - return render_has_generate_mipmaps; + return state_has_generate_mipmaps; } inline static bool has_vbo() { - return render_has_vbo; + return state_has_vbo; } inline static GLuint vbo() { - return render_vbo; + return state_vbo; } static void set_normalize(const bool enable=true); private: - static int render_width; - static int render_height; + static int state_width; + static int state_height; - static float render_aspect; - static bool render_has_generate_mipmaps; - static bool render_has_vbo; - static GLuint render_vbo; + static float state_aspect; + static bool state_has_generate_mipmaps; + static bool state_has_vbo; + static GLuint state_vbo; + + 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 + }; } // namespace render -- cgit v1.2.3