Commit ff726547 authored by Robert Menzel's avatar Robert Menzel
Browse files

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

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