Commit 415799cc authored by Janis Born's avatar Janis Born
Browse files

add getters / setters for texture border color

parent 5d288260
...@@ -102,27 +102,28 @@ public: ...@@ -102,27 +102,28 @@ public:
// ============================================================================================ GETTERS \/ // ============================================================================================ GETTERS \/
// ==================================================================================================== \/ // ==================================================================================================== \/
public: public:
inline GLuint getObjectName (void) const { return mObjectName; } inline GLuint getObjectName (void) const { return mObjectName; }
inline GLenum getTarget (void) const { return mTarget; } inline GLenum getTarget (void) const { return mTarget; }
inline GLsizei getWidth (void) const { return mWidth; } inline GLsizei getWidth (void) const { return mWidth; }
inline GLsizei getHeight (void) const { return mHeight; } inline GLsizei getHeight (void) const { return mHeight; }
inline GLsizei getDepth (void) const { return mDepth; } inline GLsizei getDepth (void) const { return mDepth; }
inline GLenum getInternalFormat (void) const { return mInternalFormat; } inline GLenum getInternalFormat (void) const { return mInternalFormat; }
inline GLint getMinFilter (void) const { return getParameterI(GL_TEXTURE_MIN_FILTER); } inline GLint getMinFilter (void) const { return getParameterI(GL_TEXTURE_MIN_FILTER); }
inline GLint getMagFilter (void) const { return getParameterI(GL_TEXTURE_MAG_FILTER); } inline GLint getMagFilter (void) const { return getParameterI(GL_TEXTURE_MAG_FILTER); }
inline GLint getBaseLevel (void) const { return getParameterI(GL_TEXTURE_BASE_LEVEL); } inline GLint getBaseLevel (void) const { return getParameterI(GL_TEXTURE_BASE_LEVEL); }
inline GLint getMaxLevel (void) const { return getParameterI(GL_TEXTURE_MAX_LEVEL); } inline GLint getMaxLevel (void) const { return getParameterI(GL_TEXTURE_MAX_LEVEL); }
inline GLint getMinLOD (void) const { return getParameterI(GL_TEXTURE_MIN_LOD); } inline GLint getMinLOD (void) const { return getParameterI(GL_TEXTURE_MIN_LOD); }
inline GLint getMaxLOD (void) const { return getParameterI(GL_TEXTURE_MAX_LOD); } inline GLint getMaxLOD (void) const { return getParameterI(GL_TEXTURE_MAX_LOD); }
inline GLfloat getLODBias (void) const { return getParameterF(GL_TEXTURE_LOD_BIAS); } inline GLfloat getLODBias (void) const { return getParameterF(GL_TEXTURE_LOD_BIAS); }
inline GLenum getCompareMode (void) const { return (GLenum) getParameterI(GL_TEXTURE_COMPARE_MODE); } inline GLenum getCompareMode (void) const { return (GLenum) getParameterI(GL_TEXTURE_COMPARE_MODE); }
inline GLenum getCompareFunc (void) const { return (GLenum) getParameterI(GL_TEXTURE_COMPARE_FUNC); } inline GLenum getCompareFunc (void) const { return (GLenum) getParameterI(GL_TEXTURE_COMPARE_FUNC); }
inline glm::vec4 getBorderColor (void) const { return getParameter4F(GL_TEXTURE_BORDER_COLOR); }
#ifndef ACGL_OPENGLES_VERSION_20 #ifndef ACGL_OPENGLES_VERSION_20
inline GLenum getWrapS (void) const { return (GLenum) getParameterI(GL_TEXTURE_WRAP_S); } inline GLenum getWrapS (void) const { return (GLenum) getParameterI(GL_TEXTURE_WRAP_S); }
inline GLenum getWrapT (void) const { return (GLenum) getParameterI(GL_TEXTURE_WRAP_T); } inline GLenum getWrapT (void) const { return (GLenum) getParameterI(GL_TEXTURE_WRAP_T); }
inline GLenum getWrapR (void) const { return (GLenum) getParameterI(GL_TEXTURE_WRAP_R); } inline GLenum getWrapR (void) const { return (GLenum) getParameterI(GL_TEXTURE_WRAP_R); }
#endif // ACGL_OPENGLES_VERSION_20 #endif // ACGL_OPENGLES_VERSION_20
inline glm::uvec3 getSize (void) const { return glm::uvec3( mWidth, mHeight, mDepth ); } inline glm::uvec3 getSize (void) const { return glm::uvec3( mWidth, mHeight, mDepth ); }
// ===================================================================================================== \/ // ===================================================================================================== \/
// ============================================================================================ WRAPPERS \/ // ============================================================================================ WRAPPERS \/
...@@ -179,6 +180,9 @@ public: ...@@ -179,6 +180,9 @@ public:
//! for usage of a texture with depth data //! for usage of a texture with depth data
void setCompareFunc( GLenum _func = GL_LEQUAL ); void setCompareFunc( GLenum _func = GL_LEQUAL );
//! color that is sampled outside range if wrap is set to GL_CLAMP_TO_BORDER
void setBorderColor(const glm::vec4& _color = glm::vec4(0.0));
//! _sampleCount = 1.0 to deactivate anisotrop filtering, maximum is often 16. If a value is too high it will get clamped to the maximum //! _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 ); void setAnisotropicFilter( GLfloat _sampleCount );
...@@ -216,8 +220,9 @@ protected: ...@@ -216,8 +220,9 @@ protected:
GLuint bindAndGetOldTexture() const; GLuint bindAndGetOldTexture() const;
// generic get parameter functions: // generic get parameter functions:
GLfloat getParameterF( GLenum _name ) const; GLint getParameterI ( GLenum _name ) const;
GLint getParameterI( GLenum _name ) const; GLfloat getParameterF ( GLenum _name ) const;
glm::vec4 getParameter4F( GLenum _name ) const;
//! returns a format compatible with the internal, only used to //! returns a format compatible with the internal, only used to
//! reserve memory, not to upload actual data! //! reserve memory, not to upload actual data!
......
...@@ -111,6 +111,13 @@ void TextureBase::setCompareFunc( GLenum _func ) ...@@ -111,6 +111,13 @@ void TextureBase::setCompareFunc( GLenum _func )
glBindTexture(mTarget, prevTexture); glBindTexture(mTarget, prevTexture);
} }
void TextureBase::setBorderColor(const glm::vec4& _color)
{
GLuint prevTexture = bindAndGetOldTexture();
glTexParameterfv( mTarget, GL_TEXTURE_BORDER_COLOR, (GLfloat*)&_color);
glBindTexture(mTarget, prevTexture);
}
void TextureBase::setAnisotropicFilter( GLfloat _sampleCount ) void TextureBase::setAnisotropicFilter( GLfloat _sampleCount )
{ {
...@@ -177,6 +184,16 @@ GLfloat TextureBase::getParameterF( GLenum _name ) const ...@@ -177,6 +184,16 @@ GLfloat TextureBase::getParameterF( GLenum _name ) const
return param; return param;
} }
glm::vec4 TextureBase::getParameter4F( GLenum _name ) const
{
GLuint prevTexture = bindAndGetOldTexture();
glm::vec4 param;
glGetTexParameterfv( mTarget, _name, (GLfloat*)&param );
glBindTexture(mTarget, prevTexture);
openGLRareError();
return param;
}
GLuint TextureBase::bindAndGetOldTexture() const GLuint TextureBase::bindAndGetOldTexture() const
{ {
GLint prevTexture = 0; GLint prevTexture = 0;
......
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