Base *binder;
public:
+ template<typename T>
+ Bind(const T &o, bool r = false):
+ binder(r ? create(&o, T::current()) : create(&o))
+ { }
+
template<typename T>
Bind(const T *o, bool r = false):
binder(r ? create(o, T::current()) : create(o))
{ }
+ template<typename T>
+ Bind(T *o, bool r = false):
+ binder(r ? create(o, T::current()) : create(o))
+ { }
+
private:
Bind(const Bind &);
Bind &operator=(const Bind &);
if(set_current(this))
{
glEnable(GL_BLEND);
- // XXX Don't try to set equation if version < 1.2
- glBlendEquation(eq);
+ if(glBlendEquation)
+ glBlendEquation(eq);
glBlendFunc(src_factor, dst_factor);
}
}
-const Blend &Blend::alpha()
-{
- static Blend blend(SRC_ALPHA, ONE_MINUS_SRC_ALPHA);
- return blend;
-}
-
void Blend::unbind()
{
if(set_current(0))
glDisable(GL_BLEND);
}
-
-void blend_equation(BlendEquation eq)
-{
- static RequireVersion _ver(1, 2);
- glBlendEquation(eq);
-}
-
-void blend_func(BlendFactor src, BlendFactor dst)
+const Blend &Blend::alpha()
{
- glBlendFunc(src, dst);
+ static Blend blend(SRC_ALPHA, ONE_MINUS_SRC_ALPHA);
+ return blend;
}
} // namespace GL
namespace Msp {
namespace GL {
-enum
-{
- BLEND = GL_BLEND
-};
-
enum BlendEquation
{
ADD = GL_FUNC_ADD,
void bind() const;
- static const Blend &alpha();
static void unbind();
-};
-void blend_equation(BlendEquation eq);
-void blend_func(BlendFactor src, BlendFactor dst);
+ static const Blend &alpha();
+};
} // namespace GL
} // namespace Msp
*/
#include <msp/datafile/collection.h>
+#include "bindable.h"
#include "gl.h"
#include "font.h"
#include "immediate.h"
if(!tex)
throw InvalidState("No texture");
- tex->bind();
+ Bind bind_tex(tex, true);
float x = 0;
unsigned count = 0;