]> git.tdb.fi Git - libs/gl.git/commitdiff
Add blending and clipping support
authorMikko Rasa <tdb@tdb.fi>
Sat, 19 Jul 2008 11:19:01 +0000 (11:19 +0000)
committerMikko Rasa <tdb@tdb.fi>
Sat, 19 Jul 2008 11:19:01 +0000 (11:19 +0000)
Add name stack management functions

source/blend.cpp [new file with mode: 0644]
source/blend.h [new file with mode: 0644]
source/clip.cpp [new file with mode: 0644]
source/clip.h [new file with mode: 0644]
source/select.cpp
source/select.h

diff --git a/source/blend.cpp b/source/blend.cpp
new file mode 100644 (file)
index 0000000..c9407c2
--- /dev/null
@@ -0,0 +1,25 @@
+/* $Id$
+
+This file is part of libmspgl
+Copyright © 2008  Mikko Rasa, Mikkosoft Productions
+Distributed under the LGPL
+*/
+
+#define GL_GLEXT_PROTOTYPES
+#include "blend.h"
+
+namespace Msp {
+namespace GL {
+
+void blend_equation(BlendEquation eq)
+{
+       glBlendEquation(eq);
+}
+
+void blend_func(BlendFactor src, BlendFactor dst)
+{
+       glBlendFunc(src, dst);
+}
+
+} // namespace GL
+} // namespace Msp
diff --git a/source/blend.h b/source/blend.h
new file mode 100644 (file)
index 0000000..37fc56e
--- /dev/null
@@ -0,0 +1,49 @@
+/* $Id$
+
+This file is part of libmspgl
+Copyright © 2008  Mikko Rasa, Mikkosoft Productions
+Distributed under the LGPL
+*/
+
+#ifndef MSP_GL_BLEND_H_
+#define MSP_GL_BLEND_H_
+
+#include "gl.h"
+
+namespace Msp {
+namespace GL {
+
+enum BlendEquation
+{
+       ADD              = GL_FUNC_ADD,
+       SUBTRACT         = GL_FUNC_SUBTRACT,
+       REVERSE_SUBTRACT = GL_FUNC_REVERSE_SUBTRACT,
+       MIN              = GL_MIN,
+       MAX              = GL_MAX
+};
+
+enum BlendFactor
+{
+       ZERO = GL_ZERO,
+       ONE = GL_ONE,
+       SRC_COLOR = GL_SRC_COLOR,
+       ONE_MINUS_SRC_COLOR = GL_ONE_MINUS_SRC_COLOR,
+       SRC_ALPHA = GL_SRC_ALPHA,
+       ONE_MINUS_SRC_ALPHA = GL_ONE_MINUS_SRC_ALPHA,
+       DST_COLOR = GL_DST_COLOR,
+       ONE_MINUS_DST_COLOR = GL_ONE_MINUS_DST_COLOR,
+       DST_ALPHA = GL_DST_ALPHA,
+       ONE_MINUS_DST_ALPHA = GL_ONE_MINUS_DST_ALPHA,
+       CONSTANT_COLOR = GL_CONSTANT_COLOR,
+       ONE_MINUS_CONSTANT_COLOR = GL_ONE_MINUS_CONSTANT_COLOR,
+       CONSTANT_ALPHA = GL_CONSTANT_ALPHA,
+       ONE_MINUS_CONSTANT_ALPHA = GL_ONE_MINUS_CONSTANT_ALPHA
+};
+
+void blend_equation(BlendEquation eq);
+void blend_func(BlendFactor src, BlendFactor dst);
+
+} // namespace GL
+} // namespace Msp
+
+#endif
diff --git a/source/clip.cpp b/source/clip.cpp
new file mode 100644 (file)
index 0000000..ca1b742
--- /dev/null
@@ -0,0 +1,34 @@
+/* $Id$
+
+This file is part of libmspgl
+Copyright © 2008  Mikko Rasa, Mikkosoft Productions
+Distributed under the LGPL
+*/
+
+#include "clip.h"
+#include "gl.h"
+
+namespace Msp {
+namespace GL {
+
+ClipPlane::ClipPlane(double a, double b, double c, double d)
+{
+       eq[0]=a;
+       eq[1]=b;
+       eq[2]=c;
+       eq[3]=d;
+}
+
+void ClipPlane::apply_to(unsigned n)
+{
+       glClipPlane(GL_CLIP_PLANE0+n, eq);
+       glEnable(GL_CLIP_PLANE0+n);
+}
+
+void ClipPlane::disable(unsigned n)
+{
+       glDisable(GL_CLIP_PLANE0+n);
+}
+
+} // namespace GL
+} // namespace Msp
diff --git a/source/clip.h b/source/clip.h
new file mode 100644 (file)
index 0000000..bd8b1c5
--- /dev/null
@@ -0,0 +1,28 @@
+/* $Id$
+
+This file is part of libmspgl
+Copyright © 2008  Mikko Rasa, Mikkosoft Productions
+Distributed under the LGPL
+*/
+
+#ifndef MSP_GL_CLIP_H_
+#define MSP_GL_CLIP_H_
+
+namespace Msp {
+namespace GL {
+
+class ClipPlane
+{
+public:
+       double eq[4];
+
+       ClipPlane(double, double, double, double);
+       void apply_to(unsigned);
+
+       static void disable(unsigned);
+};
+
+} // namespace GL
+} // namespace Msp
+
+#endif
index e7037cbfb6e59137c36418da552106acbce7f496..51fe0b60525c3ec829bb09136ae0a12d1da27da8 100644 (file)
@@ -28,6 +28,26 @@ void select_buffer(vector<SelectRecord> &buf)
        select_buf=&buf;
 }
 
+void init_names()
+{
+       glInitNames();
+}
+
+void push_name(uint n)
+{
+       glPushName(n);
+}
+
+void pop_name()
+{
+       glPopName();
+}
+
+void load_name(uint n)
+{
+       glLoadName(n);
+}
+
 void parse_select_records(const uint *buf, uint count, vector<SelectRecord> &tbuf)
 {
        uint i=0;
index 3964b89414e415f17bb712b802de8239419bf1c4..680334f4e5688335a49ee23d3c5448d3b82203d9 100644 (file)
@@ -22,6 +22,11 @@ struct SelectRecord
 };
 
 void select_buffer(std::vector<SelectRecord> &);
+void init_names();
+void push_name(uint);
+void pop_name();
+void load_name(uint);
+
 void parse_select_records(const uint *buf, uint, std::vector<SelectRecord> &);
 
 void _parse_internal_select_records(uint);