Commit ff726547 authored by Robert Menzel's avatar Robert Menzel

only query runtime limits that are used more often inside of ACGL once

parent acd92f84
......@@ -18,6 +18,10 @@
namespace ACGL{
namespace OpenGL{
//! queries some limits of the runtime which are used in ACGL internally. Client apps should not rely on these values, they are subject to changes. Gets called by ACGL::init()
void initRuntimeDependentLimits();
extern GLfloat ACGL_MAX_TEXTURE_MAX_ANISOTROPY;
//! returns the size in bytes of the common gl types named by there GLenums.
inline GLint getGLTypeSize ( GLenum _type )
{
......
......@@ -59,6 +59,9 @@ bool init(void)
return false;
}
// gets runtime limits to be used internally:
OpenGL::initRuntimeDependentLimits();
//
// Register file types for loading. This has to be done if the library is
// linked statically, because otherwise, the static registration of the
......
......@@ -31,10 +31,8 @@ void Sampler::setMaxAnisotropy( GLfloat _sampleCount )
{
if ( ACGL_EXT_texture_filter_anisotrophic() ) {
// 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 );
_sampleCount = std::max( _sampleCount, 1.0f );
_sampleCount = std::min( _sampleCount, ACGL_MAX_TEXTURE_MAX_ANISOTROPY );
glSamplerParameterf( mObjectName, GL_TEXTURE_MAX_ANISOTROPY_EXT, _sampleCount );
openGLRareError();
} else
......
......@@ -60,10 +60,8 @@ void Texture::setAnisotropicFilter( GLfloat _sampleCount )
{
if ( ACGL_EXT_texture_filter_anisotrophic() ) {
// 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 );
_sampleCount = std::max( _sampleCount, 1.0f );
_sampleCount = std::min( _sampleCount, ACGL_MAX_TEXTURE_MAX_ANISOTROPY );
glBindTexture( mTarget, mObjectName );
glTexParameterf( mTarget, GL_TEXTURE_MAX_ANISOTROPY_EXT, _sampleCount );
openGLRareError();
......
......@@ -12,6 +12,16 @@
namespace ACGL{
namespace OpenGL{
GLfloat ACGL_MAX_TEXTURE_MAX_ANISOTROPY = -1.0f;
void initRuntimeDependentLimits()
{
if ( ACGL_EXT_texture_filter_anisotrophic() ) {
glGetFloatv( GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &ACGL_MAX_TEXTURE_MAX_ANISOTROPY );
} else {
ACGL_MAX_TEXTURE_MAX_ANISOTROPY = 0.0f;
}
}
//
// This is a "private" function that should not be called from outside of this file.
//
......
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