openscenegraph
Outline
Go to the documentation of this file.
1// -*-c++-*-
2
3/*
4 * OpenSceneGraph - Copyright (C) 1998-2009 Robert Osfield
5 *
6 * This library is open source and may be redistributed and/or modified under
7 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
8 * (at your option) any later version. The full license is in LICENSE file
9 * included with this distribution, and on the openscenegraph.org website.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * OpenSceneGraph Public License for more details.
15 */
16
17/*
18 * osgFX::Outline - Copyright (C) 2004,2009 Ulrich Hertlein
19 */
20
21#ifndef OSGFX_OUTLINE_
22#define OSGFX_OUTLINE_
23
24#include <osgFX/Export>
25#include <osgFX/Effect>
26
27namespace osgFX
28{
29 /**
30 * Outline effect.
31 * This effect draws a stencil buffer-based outline around an object.
32 * Color and width of the outline can be modified.
33 * To function correctly the context must be setup with a stencil buffer
34 * and the stencil buffer must be cleared to zero before each render.
35 *
36 * osg::DisplaySettings::instance()->setMinimumNumStencilBits(1);
37 * camera->setClearMask(clearMask | GL_STENCIL_BUFFER_BIT);
38 * camera->setClearStencil(0);
39 */
40 class OSGFX_EXPORT Outline : public Effect
41 {
42 public:
43 /// Constructor.
44 Outline();
45
46 /// Copy constructor.
47 Outline(const Outline& copy, const osg::CopyOp& op = osg::CopyOp::SHALLOW_COPY) : Effect(copy, op) {
48 _width = copy._width;
49 _color = copy._color;
50 _technique = copy._technique;
51 }
52
53 // Effect class info
54 META_Effect(osgFX, Outline, "Outline",
55 "Stencil buffer based object outline effect.\n"
56 "This effect needs a properly setup stencil buffer.",
57 "Ulrich Hertlein");
58
59 /// Set outline width.
60 void setWidth(float w);
61
62 /// Get outline width.
63 float getWidth() const {
64 return _width;
65 }
66
67 /// Set outline color.
68 void setColor(const osg::Vec4& color);
69
70 /// Get outline color.
71 const osg::Vec4& getColor() const {
72 return _color;
73 }
74
75 protected:
76 /// Destructor.
77 virtual ~Outline() {
78 }
79
80 /// Define available techniques.
81 bool define_techniques();
82
83 private:
84 /// Outline width.
85 float _width;
86
87 /// Outline color.
88 osg::Vec4 _color;
89
90 /// Technique.
91 class OutlineTechnique;
92 OutlineTechnique* _technique;
93 };
94
95}
96
97#endif