Texture.cc 2.21 KB
Newer Older
Robert Menzel's avatar
Robert Menzel committed
1 2 3 4 5
////////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2011, Computer Graphics Group RWTH Aachen University         //
// All rights reserved.                                                       //
////////////////////////////////////////////////////////////////////////////////

Robert Menzel's avatar
Robert Menzel committed
6
#include <ACGL/OpenGL/Objects/Texture.hh>
Robert Menzel's avatar
Robert Menzel committed
7

Robert Menzel's avatar
Robert Menzel committed
8
using namespace ACGL::OpenGL;
Robert Menzel's avatar
Robert Menzel committed
9

10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
void Texture::setWrapS( GLenum _wrapS ) 
{
	glBindTexture(mTarget, mObjectName);
	mWrapS = _wrapS;
    glTexParameteri(mTarget, GL_TEXTURE_WRAP_S, mWrapS);
}

void Texture::setWrapT( GLenum _wrapT )
{
	glBindTexture(mTarget, mObjectName);
	mWrapT = _wrapT;
    glTexParameteri(mTarget, GL_TEXTURE_WRAP_T, mWrapT);
}

void Texture::setWrapR( GLenum _wrapR )
{
	glBindTexture(mTarget, mObjectName);
	mWrapR = _wrapR;
    glTexParameteri(mTarget, GL_TEXTURE_WRAP_R, mWrapR);
}


Robert Menzel's avatar
Robert Menzel committed
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
void Texture::setWrap( GLenum _wrapS, GLenum _wrapT, GLenum _wrapR )
{
    glBindTexture(mTarget, mObjectName);

    mWrapS = _wrapS;
    glTexParameteri(mTarget, GL_TEXTURE_WRAP_S, mWrapS);

    if(_wrapT != 0)
    {
        mWrapT = _wrapT;
        glTexParameteri(mTarget, GL_TEXTURE_WRAP_T, mWrapT);
    }

    if(_wrapR != 0)
    {
        mWrapR = _wrapR;
        glTexParameteri(mTarget, GL_TEXTURE_WRAP_R, mWrapR);
    }

    openGLRareError();
}

void Texture::setAnisotropicFilter( GLfloat _sampleCount )
{
#ifdef ACGL_USE_GLEW
    if (GLEW_EXT_texture_filter_anisotropic) {
		// anisotrophic filtering is supported:
        GLfloat maxAnisotropicSamples;
        glGetFloatv( GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &maxAnisotropicSamples );
        _sampleCount = std::max( 1.0f, _sampleCount );
        _sampleCount = std::min( maxAnisotropicSamples, _sampleCount );
        glBindTexture( mTarget, mObjectName );
        glTexParameterf( mTarget, GL_TEXTURE_MAX_ANISOTROPY_EXT, _sampleCount );
        openGLRareError();
    } else
#endif
    {
		if (_sampleCount != 1.0f ) {
			// anisotropic filtering will just increase the image quality, so this is just
			// a warning and no error, 1 sample is equal to no anisotrophic filtering, so ignore
			// that case entirely!
			ACGL::Utils::warning() << "Anisotropic filtering is not supported, ignored" << std::endl;
		}
    }
}