From: Mikko Rasa Date: Sat, 19 Jul 2008 11:19:01 +0000 (+0000) Subject: Add blending and clipping support X-Git-Tag: 0.9~4 X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=1bff68e595a66f3755743a7ee0f974eb876f3520;p=libs%2Fgl.git Add blending and clipping support Add name stack management functions --- diff --git a/source/blend.cpp b/source/blend.cpp new file mode 100644 index 00000000..c9407c21 --- /dev/null +++ b/source/blend.cpp @@ -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 index 00000000..37fc56e1 --- /dev/null +++ b/source/blend.h @@ -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 index 00000000..ca1b7420 --- /dev/null +++ b/source/clip.cpp @@ -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 index 00000000..bd8b1c57 --- /dev/null +++ b/source/clip.h @@ -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 diff --git a/source/select.cpp b/source/select.cpp index e7037cbf..51fe0b60 100644 --- a/source/select.cpp +++ b/source/select.cpp @@ -28,6 +28,26 @@ void select_buffer(vector &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 &tbuf) { uint i=0; diff --git a/source/select.h b/source/select.h index 3964b894..680334f4 100644 --- a/source/select.h +++ b/source/select.h @@ -22,6 +22,11 @@ struct SelectRecord }; void select_buffer(std::vector &); +void init_names(); +void push_name(uint); +void pop_name(); +void load_name(uint); + void parse_select_records(const uint *buf, uint, std::vector &); void _parse_internal_select_records(uint);