From Sohey Yamamoto, added support for GL_TEXTURE_FILTER_CONTROL/GL_TEXTURE_LOD_BIAS.
This commit is contained in:
parent
9a393bfd5d
commit
cecaec4ed8
@ -424,6 +424,10 @@ SOURCE=..\..\src\osg\TexEnvCombine.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\src\osg\TexEnvFilter.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\src\osg\TexGen.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@ -869,6 +873,10 @@ SOURCE=..\..\Include\Osg\TexEnvCombine
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Include\Osg\TexEnvFilter
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Include\Osg\TexGen
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
@ -136,6 +136,7 @@ class SG_EXPORT StateAttribute : public Object
|
||||
POLYGONSTIPPLE,
|
||||
SHADEMODEL,
|
||||
TEXENV,
|
||||
TEXENVFILTER,
|
||||
TEXGEN,
|
||||
TEXMAT,
|
||||
LIGHTMODEL,
|
||||
|
70
include/osg/TexEnvFilter
Normal file
70
include/osg/TexEnvFilter
Normal file
@ -0,0 +1,70 @@
|
||||
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield
|
||||
*
|
||||
* 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
|
||||
* (at your option) any later version. The full license is in LICENSE file
|
||||
* included with this distribution, and on the openscenegraph.org website.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* OpenSceneGraph Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef OSG_TEXENVFILTER
|
||||
#define OSG_TEXENVFILTER 1
|
||||
|
||||
#include <osg/GL>
|
||||
#include <osg/StateAttribute>
|
||||
|
||||
namespace osg {
|
||||
|
||||
#ifndef GL_EXT_texture_lod_bias
|
||||
#define GL_MAX_TEXTURE_LOD_BIAS_EXT 0x84FD
|
||||
#define GL_TEXTURE_FILTER_CONTROL_EXT 0x8500
|
||||
#define GL_TEXTURE_LOD_BIAS_EXT 0x8501
|
||||
#endif
|
||||
|
||||
/** TexEnvFilter - encapsulates the OpenGL glTexEnv (GL_TEXTURE_FILTER_CONTROL) state.*/
|
||||
class SG_EXPORT TexEnvFilter : public StateAttribute
|
||||
{
|
||||
public:
|
||||
TexEnvFilter(float lodBias = 0.0f);
|
||||
|
||||
/** Copy constructor using CopyOp to manage deep vs shallow copy.*/
|
||||
TexEnvFilter(const TexEnvFilter& texenv,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
|
||||
StateAttribute(texenv,copyop),
|
||||
_lodBias(texenv._lodBias) {}
|
||||
|
||||
META_StateAttribute(osg, TexEnvFilter, TEXENVFILTER);
|
||||
|
||||
virtual bool isTextureAttribute() const { return true; }
|
||||
|
||||
/** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
|
||||
virtual int compare(const StateAttribute& sa) const
|
||||
{
|
||||
// check the types are equal and then create the rhs variable
|
||||
// used by the COMPARE_StateAttribute_Paramter macro's below.
|
||||
COMPARE_StateAttribute_Types(TexEnvFilter, sa)
|
||||
|
||||
// compare each paramter in turn against the rhs.
|
||||
COMPARE_StateAttribute_Parameter(_lodBias)
|
||||
|
||||
return 0; // passed all the above comparison macro's, must be equal.
|
||||
}
|
||||
|
||||
void setLodBias( float lodBias ) { _lodBias = lodBias; }
|
||||
|
||||
float getLodBias() const { return _lodBias; }
|
||||
|
||||
virtual void apply(State& state) const;
|
||||
|
||||
protected:
|
||||
virtual ~TexEnvFilter();
|
||||
|
||||
float _lodBias;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
@ -85,6 +85,7 @@ CXXFILES =\
|
||||
Switch.cpp\
|
||||
TexEnv.cpp\
|
||||
TexEnvCombine.cpp\
|
||||
TexEnvFilter.cpp\
|
||||
TexGen.cpp\
|
||||
TexGenNode.cpp\
|
||||
TexMat.cpp\
|
||||
|
38
src/osg/TexEnvFilter.cpp
Normal file
38
src/osg/TexEnvFilter.cpp
Normal file
@ -0,0 +1,38 @@
|
||||
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield
|
||||
*
|
||||
* 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
|
||||
* (at your option) any later version. The full license is in LICENSE file
|
||||
* included with this distribution, and on the openscenegraph.org website.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* OpenSceneGraph Public License for more details.
|
||||
*/
|
||||
#include <osg/GLExtensions>
|
||||
#include <osg/TexEnvFilter>
|
||||
|
||||
using namespace osg;
|
||||
|
||||
TexEnvFilter::TexEnvFilter(float lodBias) :
|
||||
_lodBias(lodBias)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
TexEnvFilter::~TexEnvFilter()
|
||||
{
|
||||
}
|
||||
|
||||
void TexEnvFilter::apply(State&) const
|
||||
{
|
||||
// note from RO, need to adapt to do testing per graphics context.
|
||||
static float glVersion = atof( (const char *)glGetString( GL_VERSION ) );
|
||||
static bool s_isTexLodBias = glVersion>=1.4 || isGLExtensionSupported("GL_EXT_texture_lod_bias");
|
||||
|
||||
if (s_isTexLodBias)
|
||||
{
|
||||
glTexEnvf(GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, _lodBias);
|
||||
}
|
||||
}
|
@ -7,6 +7,12 @@
|
||||
#include <osg/TextureRectangle>
|
||||
#include <osg/TextureCubeMap>
|
||||
|
||||
|
||||
// #define COMPILE_TEXENVFILTER_USAGE
|
||||
#if COMPILE_TEXENVFILTER_USAGE
|
||||
#include <osg/TexEnvFilter>
|
||||
#endif
|
||||
|
||||
using namespace osg;
|
||||
using namespace osgGA;
|
||||
|
||||
@ -111,6 +117,21 @@ bool StateSetManipulator::handle(const GUIEventAdapter& ea,GUIActionAdapter& aa)
|
||||
}
|
||||
}
|
||||
break;
|
||||
#if COMPILE_TEXENVFILTER_USAGE
|
||||
case 'm' :
|
||||
{
|
||||
osg::TexEnvFilter* texenvfilter = dynamic_cast<osg::TexEnvFilter*>(_drawState->getTextureAttribute(0,osg::StateAttribute::TEXENVFILTER));
|
||||
if (!texenvfilter)
|
||||
{
|
||||
texenvfilter = new osg::TexEnvFilter;
|
||||
_drawState->setTextureAttribute(0,texenvfilter);
|
||||
}
|
||||
|
||||
// cycle through the available modes.
|
||||
texenvfilter->setLodBias(texenvfilter->getLodBias()+0.1);
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
Loading…
Reference in New Issue
Block a user