Commit 374ea7f9 authored by Janis Born's avatar Janis Born
Browse files

Added ability to access texture wrapping to Texture, TextureControl

parent 60d3caf0
......@@ -31,7 +31,10 @@ public:
mFormat(GL_RGBA),
mType(GL_UNSIGNED_BYTE),
mMinFilter(0),
mMagFilter(0)
mMagFilter(0),
mWrapS(GL_REPEAT),
mWrapT(0),
mWrapR(0)
{}
virtual ~TextureControl(void) {}
......@@ -47,6 +50,14 @@ public:
return *this;
}
inline TextureControl& wrap (GLenum _wrapS, GLenum _wrapT = 0, GLenum _wrapR = 0)
{
mWrapS = _wrapS;
mWrapT = _wrapT;
mWrapT = _wrapR;
return *this;
}
inline TextureControl& internalFormat (GLenum _internalFormat) { mInternalFormat = _internalFormat; return *this; }
inline TextureControl& target (GLenum _target) { mTarget = _target; return *this; }
inline TextureControl& format (GLenum _format) { mFormat = _format; return *this; }
......@@ -64,6 +75,7 @@ public:
texture->bind();
if(mMinFilter > 0) texture->setMinFilter(mMinFilter);
if(mMagFilter > 0) texture->setMagFilter(mMagFilter);
texture->setWrap(mWrapS, mWrapT, mWrapR);
texture->setImageData(
NULL,
mWidth,
......@@ -88,6 +100,9 @@ protected:
GLenum mType;
GLint mMinFilter;
GLint mMagFilter;
GLenum mWrapS;
GLenum mWrapT;
GLenum mWrapR;
};
} // OpenGL
......
......@@ -46,7 +46,10 @@ public:
mFormat(GL_RGBA),
mType(GL_UNSIGNED_BYTE),
mMinFilter(GL_NEAREST_MIPMAP_LINEAR),
mMagFilter(GL_LINEAR)
mMagFilter(GL_LINEAR),
mWrapS(GL_REPEAT),
mWrapT(GL_REPEAT),
mWrapR(GL_REPEAT)
{
glGenTextures(1, &mObjectName);
if (openGLCriticalErrorOccured() ) {
......@@ -75,6 +78,9 @@ public:
inline GLenum getType (void) const { return mType; }
inline GLint getMinFilter (void) const { return mMinFilter; }
inline GLint getMagFilter (void) const { return mMagFilter; }
inline GLenum getWrapS (void) const { return mWrapS; }
inline GLenum getWrapT (void) const { return mWrapT; }
inline GLenum getWrapR (void) const { return mWrapR; }
// ===================================================================================================== \/
// ============================================================================================ WRAPPERS \/
......@@ -113,6 +119,27 @@ public:
openGLRareError();
}
//! Note: The function is not const, because it changes the corresponding GPU data
inline void setWrap(GLenum _wrapS, GLenum _wrapT = 0, GLenum _wrapR = 0)
{
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);
}
}
//! _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 )
{
......@@ -357,6 +384,9 @@ private:
GLenum mType;
GLint mMinFilter;
GLint mMagFilter;
GLenum mWrapS;
GLenum mWrapT;
GLenum mWrapR;
};
ACGL_SHARED_TYPEDEF(Texture)
......
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