1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
3 * This library is open source and may be redistributed and/or modified under
4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5 * (at your option) any later version. The full license is in LICENSE file
6 * included with this distribution, and on the openscenegraph.org website.
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * OpenSceneGraph Public License for more details.
14#ifndef OSG_PATCHPARAMETER
15#define OSG_PATCHPARAMETER 1
19#include <osg/StateAttribute>
23/** Class which encapsulates glPatchParameter(..).
25class OSG_EXPORT PatchParameter : public StateAttribute
29 PatchParameter(GLint vertices=3);
31 /** Copy constructor using CopyOp to manage deep vs shallow copy.*/
32 PatchParameter(const PatchParameter& rhs,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
33 StateAttribute(rhs,copyop),
34 _vertices(rhs._vertices),
35 _patchDefaultInnerLevel(rhs._patchDefaultInnerLevel),
36 _patchDefaultOuterLevel(rhs._patchDefaultOuterLevel) {}
39 META_StateAttribute(osg, PatchParameter, PATCH_PARAMETER);
41 /** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
42 virtual int compare(const StateAttribute& sa) const
44 // check the types are equal and then create the rhs variable
45 // used by the COMPARE_StateAttribute_Parameter macros below.
46 COMPARE_StateAttribute_Types(PatchParameter,sa)
48 // compare each parameter in turn against the rhs.
49 COMPARE_StateAttribute_Parameter(_vertices)
50 COMPARE_StateAttribute_Parameter(_patchDefaultInnerLevel)
51 COMPARE_StateAttribute_Parameter(_patchDefaultOuterLevel)
53 return 0; // passed all the above comparison macros, must be equal.
56 /** Set GL_PATCH_VERTICES parameter.*/
57 void setVertices(GLint vertices) { _vertices = vertices; }
59 /** Get GL_PATCH_VERTICES parameter.*/
60 GLint getVertices() const { return _vertices; }
62 /** Set GL_PATCH_DEFAULT_INNER_LEVEL parameter.*/
63 void setPatchDefaultInnerLevel(const osg::Vec2& level) { _patchDefaultInnerLevel = level; }
65 /** Get GL_PATCH_DEFAULT_INNER_LEVEL parameter.*/
66 const osg::Vec2& getPatchDefaultInnerLevel() const { return _patchDefaultInnerLevel; }
68 /** Set GL_PATCH_DEFAULT_OUTER_LEVEL parameter.*/
69 void setPatchDefaultOuterLevel(const osg::Vec4& level) { _patchDefaultOuterLevel = level; }
71 /** Get GL_PATCH_DEFAULT_INNER_LEVEL parameter.*/
72 const osg::Vec4& getPatchDefaultOuterLevel() const { return _patchDefaultOuterLevel; }
74 virtual void apply(State& state) const;
78 virtual ~PatchParameter();
81 osg::Vec2 _patchDefaultInnerLevel;
82 osg::Vec4 _patchDefaultOuterLevel;