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 #include <osg/ClipControl>
14
15 #include <osg/GLExtensions>
16 #include <osg/State>
17
18 using namespace osg;
19
ClipControl(Origin origin,DepthMode depthMode)20 ClipControl::ClipControl(Origin origin, DepthMode depthMode):
21 _origin(origin),
22 _depthMode(depthMode)
23 {
24 }
25
ClipControl(const ClipControl & clipControl,const CopyOp & copyop)26 ClipControl::ClipControl(const ClipControl& clipControl, const CopyOp& copyop):
27 StateAttribute(clipControl, copyop),
28 _origin(clipControl._origin),
29 _depthMode(clipControl._depthMode)
30 {
31 }
32
~ClipControl()33 ClipControl::~ClipControl()
34 {
35 }
36
apply(State & state) const37 void ClipControl::apply(State& state) const
38 {
39 const GLExtensions* extensions = state.get<GLExtensions>();
40
41 if (!extensions->isClipControlSupported) return;
42
43 extensions->glClipControl((GLenum)_origin, (GLenum)_depthMode);
44 }
45