|
|
@@ -23,14 +23,22 @@ class GlStateMachine
|
|
|
|
|
|
bool isBlendingEnabled() const {return getFlag(GL_BLEND, blendingEnabledFlag);}
|
|
|
void setBlendingEnabled(bool enable) {setFlag(GL_BLEND, enable, blendingEnabledFlag);}
|
|
|
+
|
|
|
+ void useShaderProg(GLuint id);
|
|
|
/// @}
|
|
|
|
|
|
private:
|
|
|
+ /// @name The GL state
|
|
|
+ /// @{
|
|
|
bool depthTestEnabledFlag;
|
|
|
bool blendingEnabledFlag;
|
|
|
+ GLuint sProgGlId;
|
|
|
+ /// @}
|
|
|
|
|
|
static bool getFlag(GLenum glFlag, bool myFlag);
|
|
|
static void setFlag(GLenum glFlag, bool enable, bool& myFlag);
|
|
|
+
|
|
|
+ static GLuint getCurrentProgramGlId();
|
|
|
};
|
|
|
|
|
|
|
|
|
@@ -38,13 +46,6 @@ class GlStateMachine
|
|
|
// Inlines =
|
|
|
//======================================================================================================================
|
|
|
|
|
|
-inline void GlStateMachine::sync()
|
|
|
-{
|
|
|
- depthTestEnabledFlag = glIsEnabled(GL_DEPTH_TEST);
|
|
|
- blendingEnabledFlag = glIsEnabled(GL_BLEND);
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
inline bool GlStateMachine::getFlag(GLenum glFlag, bool myFlag)
|
|
|
{
|
|
|
ASSERT(glIsEnabled(glFlag) == myFlag);
|
|
|
@@ -71,6 +72,26 @@ inline void GlStateMachine::setFlag(GLenum glFlag, bool enable, bool& myFlag)
|
|
|
}
|
|
|
|
|
|
|
|
|
+inline void GlStateMachine::useShaderProg(GLuint id)
|
|
|
+{
|
|
|
+ ASSERT(getCurrentProgramGlId() == sProgGlId);
|
|
|
+
|
|
|
+ if(sProgGlId != id)
|
|
|
+ {
|
|
|
+ glUseProgram(id);
|
|
|
+ sProgGlId = id;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+inline GLuint GlStateMachine::getCurrentProgramGlId()
|
|
|
+{
|
|
|
+ int i;
|
|
|
+ glGetIntegerv(GL_CURRENT_PROGRAM, &i);
|
|
|
+ return i;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
//======================================================================================================================
|
|
|
// Other =
|
|
|
//======================================================================================================================
|