Skip to content

Commit

Permalink
libgui|GLTexture: Added maximum anisotropy parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Mar 5, 2014
1 parent ff078fa commit 0c86709
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 8 deletions.
2 changes: 2 additions & 0 deletions doomsday/libgui/include/de/gui/gltexture.h
Expand Up @@ -112,13 +112,15 @@ class LIBGUI_PUBLIC GLTexture : public Asset
setWrapS(st.x);
setWrapT(st.y);
}
void setMaxAnisotropy(dfloat maxAnisotropy);

gl::Filter minFilter() const;
gl::Filter magFilter() const;
gl::MipFilter mipFilter() const;
gl::Wrapping wrapS() const;
gl::Wrapping wrapT() const;
Wraps wrap() const;
dfloat maxAnisotropy() const;

bool isCubeMap() const;

Expand Down
35 changes: 27 additions & 8 deletions doomsday/libgui/src/gltexture.cpp
Expand Up @@ -17,6 +17,7 @@
*/

#include "de/GLTexture"
#include "de/GLInfo"
#include "de/gui/opengl.h"

namespace de {
Expand Down Expand Up @@ -46,16 +47,18 @@ DENG2_PIMPL(GLTexture)
Filter magFilter;
MipFilter mipFilter;
Wraps wrap;
dfloat maxAnisotropy;
TextureFlags flags;

Instance(Public *i)
: Base(i),
format(Image::Unknown),
name(0),
texTarget(GL_TEXTURE_2D),
minFilter(Linear), magFilter(Linear), mipFilter(MipNone),
wrap(Wraps(Repeat, Repeat)),
flags(ParamsChanged)
: Base(i)
, format(Image::Unknown)
, name(0)
, texTarget(GL_TEXTURE_2D)
, minFilter(Linear), magFilter(Linear), mipFilter(MipNone)
, wrap(Wraps(Repeat, Repeat))
, maxAnisotropy(1.0f)
, flags(ParamsChanged)
{}

~Instance()
Expand Down Expand Up @@ -156,12 +159,17 @@ DENG2_PIMPL(GLTexture)
* calling.
*/
void glUpdateParamsOfBoundTexture()
{
{
glTexParameteri(texTarget, GL_TEXTURE_WRAP_S, glWrap(wrap.x));
glTexParameteri(texTarget, GL_TEXTURE_WRAP_T, glWrap(wrap.y));
glTexParameteri(texTarget, GL_TEXTURE_MAG_FILTER, magFilter == Nearest? GL_NEAREST : GL_LINEAR);
glTexParameteri(texTarget, GL_TEXTURE_MIN_FILTER, glMinFilter(minFilter, mipFilter));

if(GLInfo::extensions().EXT_texture_filter_anisotropic)
{
glTexParameteri(texTarget, GL_TEXTURE_MAX_ANISOTROPY_EXT, maxAnisotropy);
}

LIBGUI_ASSERT_GL_OK();

flags &= ~ParamsChanged;
Expand Down Expand Up @@ -242,6 +250,12 @@ void GLTexture::setWrapT(Wrapping mode)
d->flags |= ParamsChanged;
}

void GLTexture::setMaxAnisotropy(dfloat maxAnisotropy)
{
d->maxAnisotropy = maxAnisotropy;
d->flags |= ParamsChanged;
}

Filter GLTexture::minFilter() const
{
return d->minFilter;
Expand Down Expand Up @@ -272,6 +286,11 @@ GLTexture::Wraps GLTexture::wrap() const
return d->wrap;
}

dfloat GLTexture::maxAnisotropy() const
{
return d->maxAnisotropy;
}

bool GLTexture::isCubeMap() const
{
return d->isCube();
Expand Down

0 comments on commit 0c86709

Please sign in to comment.