2012-03-22 01:36:20 +08:00
|
|
|
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
|
2004-10-14 03:52:39 +08:00
|
|
|
*
|
2012-03-22 01:36:20 +08:00
|
|
|
* This library is open source and may be redistributed and/or modified under
|
|
|
|
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
|
2004-10-14 03:52:39 +08:00
|
|
|
* (at your option) any later version. The full license is in LICENSE file
|
|
|
|
* included with this distribution, and on the openscenegraph.org website.
|
2012-03-22 01:36:20 +08:00
|
|
|
*
|
2004-10-14 03:52:39 +08:00
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2012-03-22 01:36:20 +08:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2004-10-14 03:52:39 +08:00
|
|
|
* OpenSceneGraph Public License for more details.
|
|
|
|
*/
|
|
|
|
#include <osg/GLExtensions>
|
|
|
|
#include <osg/TexEnvFilter>
|
2005-04-26 21:15:27 +08:00
|
|
|
#include <osg/State>
|
2010-02-20 04:11:14 +08:00
|
|
|
#include <osg/Notify>
|
2004-10-14 03:52:39 +08:00
|
|
|
|
|
|
|
using namespace osg;
|
|
|
|
|
|
|
|
TexEnvFilter::TexEnvFilter(float lodBias) :
|
|
|
|
_lodBias(lodBias)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TexEnvFilter::~TexEnvFilter()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2005-04-26 21:15:27 +08:00
|
|
|
void TexEnvFilter::apply(State& state) const
|
2004-10-14 03:52:39 +08:00
|
|
|
{
|
2009-10-23 21:19:57 +08:00
|
|
|
#ifdef OSG_GL_FIXED_FUNCTION_AVAILABLE
|
2004-10-14 03:52:39 +08:00
|
|
|
// note from RO, need to adapt to do testing per graphics context.
|
2008-11-24 21:19:01 +08:00
|
|
|
static float glVersion = asciiToFloat( (const char *)glGetString( GL_VERSION ) );
|
2005-04-26 21:15:27 +08:00
|
|
|
static bool s_isTexLodBias = glVersion>=1.4 || isGLExtensionSupported(state.getContextID(),"GL_EXT_texture_lod_bias");
|
2004-10-14 03:52:39 +08:00
|
|
|
|
|
|
|
if (s_isTexLodBias)
|
|
|
|
{
|
|
|
|
glTexEnvf(GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, _lodBias);
|
|
|
|
}
|
2009-10-23 21:19:57 +08:00
|
|
|
#else
|
2010-02-20 04:11:14 +08:00
|
|
|
OSG_NOTICE<<"Warning: TexEnvFilter::apply(State&) - not supported."<<std::endl;
|
2009-10-23 21:19:57 +08:00
|
|
|
#endif
|
2004-10-14 03:52:39 +08:00
|
|
|
}
|