| globjects 1.0.0.000000000000 Strict OpenGL objects wrapper.

State.h
Go to the documentation of this file.
1
2 #pragma once
3
4 #include <unordered_map>
5 #include <vector>
6
7 #include <glbinding/gl/types.h>
8
9 #include <globjects/base/Referenced.h>
10
11 #include <globjects/globjects_api.h>
12 #include <globjects/AbstractState.h>
13
14
15 namespace globjects
16 {
17
18
19 class StateSetting;
20 class Capability;
21
22 class GLOBJECTS_API State : public AbstractState, public Referenced
23 {
24 public:
25 enum Mode
26 {
27 DeferredMode,
28 ImmediateMode
29 };
30
31 public:
32 State(Mode = ImmediateMode);
33
34 static State * currentState();
35
36 void setMode(Mode mode);
37 Mode mode() const;
38
39 void apply();
40
41 virtual void enable(gl::GLenum capability) override;
42 virtual void disable(gl::GLenum capability) override;
43 virtual bool isEnabled(gl::GLenum capability) const override;
44 virtual void enable(gl::GLenum capability, int index) override;
45 virtual void disable(gl::GLenum capability, int index) override;
46 virtual bool isEnabled(gl::GLenum capability, int index) const override;
47
48 virtual void add(StateSetting * setting) override;
49
50 Capability * capability(gl::GLenum capability);
51 const Capability * capability(gl::GLenum capability) const;
52 std::vector<Capability *> capabilities() const;
53
54 StateSetting * setting(const StateSettingType & type);
55 const StateSetting * setting(const StateSettingType & type) const;
56 std::vector<StateSetting *> settings();
57 std::vector<const StateSetting *> settings() const;
58
59 protected:
60 void addCapability(Capability * capability);
61 Capability * getCapability(gl::GLenum capability);
62 const Capability * getCapability(gl::GLenum capability) const;
63
64 protected:
65 virtual ~State();
66
67 Mode m_mode;
68 std::unordered_map<gl::GLenum, Capability *> m_capabilities;
69 std::unordered_map<StateSettingType, StateSetting *> m_settings;
70 };
71
72
73 } // namespace globjects
Referenced.h
globjects::State
Definition: State.h:22
globjects::State::m_capabilities
std::unordered_map< gl::GLenum, Capability * > m_capabilities
Definition: State.h:68
globjects::isEnabled
GLOBJECTS_API bool isEnabled(gl::GLenum capability)
globjects::StateSetting
Definition: StateSetting.h:36
globjects::State::m_settings
std::unordered_map< StateSettingType, StateSetting * > m_settings
Definition: State.h:69
globjects::disable
GLOBJECTS_API void disable(gl::GLenum capability)
globjects
Contains all the classes that wrap OpenGL functionality.
globjects::StateSettingType
Definition: StateSetting.h:19
globjects::State::Mode
Mode
Definition: State.h:25
globjects::Capability
Definition: Capability.h:15
globjects::State::m_mode
Mode m_mode
Definition: State.h:67
AbstractState.h
globjects::AbstractState
Definition: AbstractState.h:17
globjects::enable
GLOBJECTS_API void enable(gl::GLenum capability)
globjects::State::DeferredMode
Definition: State.h:27
globjects::Referenced
Superclass for all classes that use reference counting in globjects.
Definition: Referenced.h:22