1 #pragma once
2 
3 #include "OpenGLStateLess.h"
4 
5 #include <map>
6 
7 class OpenGLState;
8 class OpenGLShaderPass;
9 
10 namespace render {
11 
12 /**
13  * A sorted map of OpenGL states, maintained by the OpenGLStateManager. The sort
14  * function intelligently sorts OpenGL states in an order which will allow them
15  * to rendered as efficiently as possible, reducing the number of unnecessary
16  * context switches.
17  */
18 typedef std::map<OpenGLState*, OpenGLShaderPass*, OpenGLStateLess> OpenGLStates;
19 
20 /**
21  * \brief
22  * Interface for an object which can manage sorted GL states. This is
23  * implemented by the OpenGLRenderSystem.
24  */
25 class OpenGLStateManager {
26 	public:
~OpenGLStateManager()27 		virtual ~OpenGLStateManager() {}
28 
29 		/**
30 		 * \brief
31 		 * Insert a new OpenGL state into the map.
32 		 */
33 		virtual void insertSortedState(const OpenGLStates::value_type& val) = 0;
34 
35 		/**
36 		 * \brief
37 		 * Remove a given OpenGL state from the map.
38 		 */
39 		virtual void eraseSortedState(const OpenGLStates::key_type& key) = 0;
40 
41 };
42 
43 }
44