Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
blob: b614c1bf8d0d6d81ca95d321becc0ca6aead5312 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/*
   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 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 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;
	}

	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 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

#endif // __INCLUDED_RENDER_STATE_H__