ViewportIndexed 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2014 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. #ifndef OSG_VIEWPORTINDEXED
  14. #define OSG_VIEWPORTINDEXED 1
  15. #include <osg/Viewport>
  16. namespace osg {
  17. /** Encapsulates glViewportIndexed function : the index version of glViewport for multiple render target.
  18. */
  19. class OSG_EXPORT ViewportIndexed : public Viewport
  20. {
  21. public :
  22. ViewportIndexed();
  23. ViewportIndexed(unsigned int index, value_type x,value_type y,value_type width,value_type height):
  24. Viewport(x,y,width,height),
  25. _index(index) {}
  26. /** Copy constructor using CopyOp to manage deep vs shallow copy. */
  27. ViewportIndexed(const ViewportIndexed& cm,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
  28. Viewport(cm,copyop),
  29. _index(cm._index) {}
  30. META_StateAttribute(osg, ViewportIndexed, VIEWPORTINDEXED);
  31. /** Return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs. */
  32. virtual int compare(const StateAttribute& sa) const
  33. {
  34. // Check for equal types, then create the rhs variable
  35. // used by the COMPARE_StateAttribute_Parameter macros below.
  36. COMPARE_StateAttribute_Types(ViewportIndexed,sa)
  37. COMPARE_StateAttribute_Parameter(_index);
  38. return Viewport::compare(sa);
  39. }
  40. /** Return the buffer index as the member identifier.*/
  41. virtual unsigned int getMember() const { return _index; }
  42. /** Set the index of the ViewportIndexed. */
  43. void setIndex(unsigned int index);
  44. /** Get the index of the ViewportIndexed. */
  45. unsigned int getIndex() const { return _index; }
  46. virtual void apply(State& state) const;
  47. protected:
  48. virtual ~ViewportIndexed();
  49. unsigned int _index;
  50. };
  51. }
  52. #endif