summaryrefslogtreecommitdiff
path: root/rsSampler.cpp
diff options
context:
space:
mode:
authorAlex Sakhartchouk <alexst@google.com>2010-09-30 11:36:37 -0700
committerAlex Sakhartchouk <alexst@google.com>2010-09-30 11:36:37 -0700
commit1103d8eade6af4f373ba143752cab2344893babf (patch)
tree7c0a69231cf96bb0a67b39dcfe4ca8a9ed6f4e6a /rsSampler.cpp
parent886f11ade9dde05485cb11c0d67d87f76a428f6c (diff)
downloadrs-1103d8eade6af4f373ba143752cab2344893babf.tar.gz
Adding anisotropic filtering and related samples.
Change-Id: Idb173274417feb5e25bfd64c5e9fa2492a23a17e
Diffstat (limited to 'rsSampler.cpp')
-rw-r--r--rsSampler.cpp30
1 files changed, 27 insertions, 3 deletions
diff --git a/rsSampler.cpp b/rsSampler.cpp
index c6a848c6..180d78ec 100644
--- a/rsSampler.cpp
+++ b/rsSampler.cpp
@@ -44,7 +44,8 @@ Sampler::Sampler(Context *rsc,
RsSamplerValue minFilter,
RsSamplerValue wrapS,
RsSamplerValue wrapT,
- RsSamplerValue wrapR) : ObjectBase(rsc)
+ RsSamplerValue wrapR,
+ float aniso) : ObjectBase(rsc)
{
mAllocFile = __FILE__;
mAllocLine = __LINE__;
@@ -53,6 +54,7 @@ Sampler::Sampler(Context *rsc,
mWrapS = wrapS;
mWrapT = wrapT;
mWrapR = wrapR;
+ mAniso = aniso;
}
Sampler::~Sampler()
@@ -93,6 +95,11 @@ void Sampler::setupGL(const Context *rsc, const Allocation *tex)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, trans[mWrapT]);
}
+ float anisoValue = rsMin(rsc->ext_texture_max_aniso(), mAniso);
+ if(rsc->ext_texture_max_aniso() > 1.0f) {
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, anisoValue);
+ }
+
rsc->checkError("Sampler::setupGL2 tex env");
}
@@ -147,6 +154,7 @@ void rsi_SamplerBegin(Context *rsc)
ss->mWrapS = RS_SAMPLER_WRAP;
ss->mWrapT = RS_SAMPLER_WRAP;
ss->mWrapR = RS_SAMPLER_WRAP;
+ ss->mAniso = 1.0f;
}
void rsi_SamplerSet(Context *rsc, RsSamplerParam param, RsSamplerValue value)
@@ -169,21 +177,37 @@ void rsi_SamplerSet(Context *rsc, RsSamplerParam param, RsSamplerValue value)
case RS_SAMPLER_WRAP_R:
ss->mWrapR = value;
break;
+ default:
+ LOGE("Attempting to set invalid value on sampler");
+ break;
}
+}
+
+void rsi_SamplerSet2(Context *rsc, RsSamplerParam param, float value)
+{
+ SamplerState * ss = &rsc->mStateSampler;
+ switch(param) {
+ case RS_SAMPLER_ANISO:
+ ss->mAniso = value;
+ break;
+ default:
+ LOGE("Attempting to set invalid value on sampler");
+ break;
+ }
}
RsSampler rsi_SamplerCreate(Context *rsc)
{
SamplerState * ss = &rsc->mStateSampler;
-
Sampler * s = new Sampler(rsc,
ss->mMagFilter,
ss->mMinFilter,
ss->mWrapS,
ss->mWrapT,
- ss->mWrapR);
+ ss->mWrapR,
+ ss->mAniso);
s->incUserRef();
return s;
}