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/BlendFunci> 14 #include <osg/GLExtensions> 15 #include <osg/State> 16 17 using namespace osg; 18 19 BlendFunci::BlendFunci(): BlendFunc()20 _index(0) 21 { 22 } 23 24 25 BlendFunci::~BlendFunci() 26 { 27 } BlendFunc(GLenum source,GLenum destination)28 29 void BlendFunci::apply(State& state) const 30 { 31 const GLExtensions* extensions = state.get<GLExtensions>(); 32 if (_source_factor != _source_factor_alpha || 33 _destination_factor != _destination_factor_alpha) 34 { 35 if (extensions->glBlendFuncSeparatei) 36 { 37 extensions->glBlendFuncSeparatei(static_cast<GLuint>(_index), _source_factor, _destination_factor, _source_factor_alpha, _destination_factor_alpha); 38 } 39 else 40 { 41 OSG_WARN<<"Warning: BlendFunc::apply(..) failed, BlendFuncSeparatei is not support by OpenGL driver."<<std::endl; 42 } 43 } 44 else 45 { 46 if (extensions->glBlendFunci) 47 { 48 extensions->glBlendFunci(static_cast<GLuint>(_index), _source_factor, _destination_factor); 49 } 50 else 51 { 52 OSG_WARN<<"Warning: BlendFunc::apply(..) failed, BlendFunci is not support by OpenGL driver."<<std::endl; 53 } 54 } 55 } 56 57