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