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 #include <osg/ColorMaski>
14 #include <osg/GLExtensions>
15 #include <osg/State>
16 
17 using namespace osg;
18 
ColorMaski()19 ColorMaski::ColorMaski():
20     _index(0)
21 {
22 }
23 
~ColorMaski()24 ColorMaski::~ColorMaski()
25 {
26 }
27 
setIndex(unsigned int buf)28 void ColorMaski::setIndex(unsigned int buf)
29 {
30     if (_index==buf) return;
31 
32     ReassignToParents needToReassingToParentsWhenMemberValueChanges(this);
33 
34     _index = buf;
35 }
36 
apply(State & state) const37 void ColorMaski::apply(State& state) const
38 {
39     const GLExtensions* extensions = state.get<GLExtensions>();
40     if (extensions->glColorMaski)
41     {
42         extensions->glColorMaski((GLuint)_index, (GLboolean)_red,(GLboolean)_green,(GLboolean)_blue,(GLboolean)_alpha);
43     }
44     else
45     {
46         OSG_WARN<<"Warning: ColorMaski::apply(..) failed, glColorMaski is not support by OpenGL driver."<<std::endl;
47     }
48 }
49 
50