1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield 2 * 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. 7 * 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. 12*/ 13 14#ifndef OSG_PATCHPARAMETER 15#define OSG_PATCHPARAMETER 1 16 17#include <osg/Vec2> 18#include <osg/Vec4> 19#include <osg/StateAttribute> 20 21namespace osg { 22 23/** Class which encapsulates glPatchParameter(..). 24*/ 25class OSG_EXPORT PatchParameter : public StateAttribute 26{ 27 public : 28 29 PatchParameter(GLint vertices=3); 30 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) {} 37 38 39 META_StateAttribute(osg, PatchParameter, PATCH_PARAMETER); 40 41 /** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/ 42 virtual int compare(const StateAttribute& sa) const 43 { 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) 47 48 // compare each parameter in turn against the rhs. 49 COMPARE_StateAttribute_Parameter(_vertices) 50 COMPARE_StateAttribute_Parameter(_patchDefaultInnerLevel) 51 COMPARE_StateAttribute_Parameter(_patchDefaultOuterLevel) 52 53 return 0; // passed all the above comparison macros, must be equal. 54 } 55 56 /** Set GL_PATCH_VERTICES parameter.*/ 57 void setVertices(GLint vertices) { _vertices = vertices; } 58 59 /** Get GL_PATCH_VERTICES parameter.*/ 60 GLint getVertices() const { return _vertices; } 61 62 /** Set GL_PATCH_DEFAULT_INNER_LEVEL parameter.*/ 63 void setPatchDefaultInnerLevel(const osg::Vec2& level) { _patchDefaultInnerLevel = level; } 64 65 /** Get GL_PATCH_DEFAULT_INNER_LEVEL parameter.*/ 66 const osg::Vec2& getPatchDefaultInnerLevel() const { return _patchDefaultInnerLevel; } 67 68 /** Set GL_PATCH_DEFAULT_OUTER_LEVEL parameter.*/ 69 void setPatchDefaultOuterLevel(const osg::Vec4& level) { _patchDefaultOuterLevel = level; } 70 71 /** Get GL_PATCH_DEFAULT_INNER_LEVEL parameter.*/ 72 const osg::Vec4& getPatchDefaultOuterLevel() const { return _patchDefaultOuterLevel; } 73 74 virtual void apply(State& state) const; 75 76 protected: 77 78 virtual ~PatchParameter(); 79 80 GLint _vertices; 81 osg::Vec2 _patchDefaultInnerLevel; 82 osg::Vec4 _patchDefaultOuterLevel; 83}; 84 85} 86 87#endif 88