namespace Msp {
namespace GL {
+GLenum get_gl_predicate(Predicate pred)
+{
+ switch(pred)
+ {
+ case NEVER: return GL_NEVER;
+ case ALWAYS: return GL_ALWAYS;
+ case LESS: return GL_LESS;
+ case LEQUAL: return GL_LEQUAL;
+ case EQUAL: return GL_EQUAL;
+ case GREATER: return GL_GREATER;
+ case GEQUAL: return GL_GEQUAL;
+ case NOTEQUAL: return GL_NOTEQUAL;
+ default: throw invalid_argument("get_gl_predicate");
+ }
+}
+
void operator>>(const LexicalConverter &conv, Predicate &pred)
{
const string &str = conv.get();
enum Predicate
{
- NEVER = GL_NEVER,
- ALWAYS = GL_ALWAYS,
- LESS = GL_LESS,
- LEQUAL = GL_LEQUAL,
- EQUAL = GL_EQUAL,
- GREATER = GL_GREATER,
- GEQUAL = GL_GEQUAL,
- NOTEQUAL = GL_NOTEQUAL
+ NEVER,
+ ALWAYS,
+ LESS,
+ LEQUAL,
+ EQUAL,
+ GREATER,
+ GEQUAL,
+ NOTEQUAL
};
+GLenum get_gl_predicate(Predicate);
+
void operator>>(const LexicalConverter &, Predicate &);
void operator<<(LexicalConverter &, Predicate);
{
glSamplerParameteri(id, GL_TEXTURE_COMPARE_MODE, (compare ? GL_COMPARE_R_TO_TEXTURE : GL_NONE));
if(compare)
- glSamplerParameteri(id, GL_TEXTURE_COMPARE_FUNC, cmp_func);
+ glSamplerParameteri(id, GL_TEXTURE_COMPARE_FUNC, get_gl_predicate(cmp_func));
}
dirty_params = 0;
void stencil_func(Predicate func, int ref, unsigned mask)
{
- glStencilFunc(func, ref, mask);
+ glStencilFunc(get_gl_predicate(func), ref, mask);
}
void stencil_op(StencilOp sfail, StencilOp dfail, StencilOp dpass)
if(set_current(this))
{
glEnable(GL_DEPTH_TEST);
- glDepthFunc(pred);
+ glDepthFunc(get_gl_predicate(pred));
glDepthMask(write);
}
}