Commit 98b64e11 authored by Robert Menzel's avatar Robert Menzel

added missing sampling parameters to TextureBase

parent 2ec9c2eb
......@@ -40,6 +40,8 @@ namespace OpenGL{
*
* Multiple states, e.g. the sampling mode gets stored in a texture as getting this infos back from
* GL is not trivial (at least if the currently bound texture should not change).
*
* WARNING: All setter bind the texture to the currently active texture unit!
*/
class TextureBase
{
......@@ -65,7 +67,12 @@ public:
mMagFilter(GL_LINEAR),
mWrapS(GL_REPEAT),
mWrapT(GL_REPEAT),
mWrapR(GL_REPEAT)
mWrapR(GL_REPEAT),
mMinLod(-1000),
mMaxLod(1000),
mLodBias(0.0f),
mCompareMode(GL_NONE),
mCompareFunc(GL_LEQUAL)
{
glGenTextures(1, &mObjectName);
if (openGLCriticalErrorOccured() ) {
......@@ -92,6 +99,11 @@ public:
inline GLenum getType (void) const { return mType; }
inline GLint getMinFilter (void) const { return mMinFilter; }
inline GLint getMagFilter (void) const { return mMagFilter; }
inline GLint getMinLOD (void) const { return mMinLod; }
inline GLint getMaxLOD (void) const { return mMaxLod; }
inline GLfloat getLODBias (void) const { return mLodBias; }
inline GLenum getCompareMode (void) const { return mCompareMode; }
inline GLenum getCompareFunc (void) const { return mCompareFunc; }
#ifndef ACGL_OPENGLES_VERSION_20
inline GLenum getWrapS (void) const { return mWrapS; }
......@@ -147,6 +159,21 @@ public:
void setWrap(GLenum _wrapS, GLenum _wrapT = 0, GLenum _wrapR = 0);
#endif
//! lowest mipmap level to use
void setMinLOD( GLint _lod = -1000 );
//! highest mipmap level to use
void setMaxLOD( GLint _lod = 1000 );
//! offset to add to the mipmap level calculation
void setLODBias( GLfloat _bias = 0.0f );
//! for usage of a texture with depth data
void setCompareMode( GLenum _mode = GL_NONE );
//! for usage of a texture with depth data
void setCompareFunc( GLenum _func = GL_LEQUAL );
//! _sampleCount = 1.0 to deactivate anisotrop filtering, maximum is often 16. If a value is too high it will get clamped to the maximum
void setAnisotropicFilter( GLfloat _sampleCount );
......@@ -174,6 +201,11 @@ protected:
GLenum mWrapS;
GLenum mWrapT;
GLenum mWrapR;
GLint mMinLod;
GLint mMaxLod;
GLfloat mLodBias;
GLenum mCompareMode;
GLenum mCompareFunc;
};
ACGL_SMARTPOINTER_TYPEDEFS(TextureBase)
......
......@@ -54,6 +54,42 @@ void TextureBase::setWrap( GLenum _wrapS, GLenum _wrapT, GLenum _wrapR )
}
#endif // ACGL_OPENGLES_VERSION_20
void TextureBase::setMinLOD( GLint _lod )
{
glBindTexture(mTarget, mObjectName);
mMinLod = _lod;
glTexParameteri( mTarget, GL_TEXTURE_MIN_LOD, _lod);
}
void TextureBase::setMaxLOD( GLint _lod )
{
glBindTexture(mTarget, mObjectName);
mMaxLod = _lod;
glTexParameteri( mTarget, GL_TEXTURE_MAX_LOD, _lod);
}
void TextureBase::setLODBias( GLfloat _bias )
{
glBindTexture(mTarget, mObjectName);
mLodBias = _bias;
glTexParameterf( mTarget, GL_TEXTURE_LOD_BIAS, _bias);
}
void TextureBase::setCompareMode( GLenum _mode )
{
glBindTexture(mTarget, mObjectName);
mCompareMode = _mode;
glTexParameteri( mTarget, GL_TEXTURE_COMPARE_MODE, _mode);
}
void TextureBase::setCompareFunc( GLenum _func )
{
glBindTexture(mTarget, mObjectName);
mCompareFunc = _func;
glTexParameteri( mTarget, GL_TEXTURE_COMPARE_FUNC, _func);
}
void TextureBase::setAnisotropicFilter( GLfloat _sampleCount )
{
if ( ACGL_EXT_texture_filter_anisotrophic() ) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment