summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKeith Whitwell <keith@tungstengraphics.com>2006-09-20 14:30:22 +0000
committerKeith Whitwell <keith@tungstengraphics.com>2006-09-20 14:30:22 +0000
commit187f2cfb4ace79fabc994f4ce2753db5b11528eb (patch)
tree069cb2e2f9bc6e0ef5111949513f596e5b335dc1 /src
parent0c9259f3b95615ceda134bd7074d871cd0186c89 (diff)
Add a new internal program parameter value STATE_TEXRECT_SCALE which
provides 1/width and 1/height of the active texture, useful for implementing ARB_texture_rectangle support on hardware which only supports ARB_npot-style texturing.
Diffstat (limited to 'src')
-rw-r--r--src/mesa/shader/program.c11
-rw-r--r--src/mesa/shader/program.h1
2 files changed, 12 insertions, 0 deletions
diff --git a/src/mesa/shader/program.c b/src/mesa/shader/program.c
index 6fd69dd982..f999e0695b 100644
--- a/src/mesa/shader/program.c
+++ b/src/mesa/shader/program.c
@@ -917,6 +917,15 @@ _mesa_fetch_state(GLcontext *ctx, const enum state_index state[],
case STATE_NORMAL_SCALE:
ASSIGN_4V(value, ctx->_ModelViewInvScale, 0, 0, 1);
break;
+ case STATE_TEXRECT_SCALE: {
+ const int unit = (int) state[2];
+ const struct gl_texture_object *texObj = ctx->Texture.Unit[unit]._Current;
+ if (texObj) {
+ struct gl_texture_image *texImage = texObj->Image[0][0];
+ ASSIGN_4V(value, 1.0 / texImage->Width, 1.0 / texImage->Height, 0, 1);
+ }
+ break;
+ }
default:
_mesa_problem(ctx, "Bad state switch in _mesa_fetch_state()");
return;
@@ -988,6 +997,8 @@ static GLuint make_state_flags(const GLint state[])
switch (state[1]) {
case STATE_NORMAL_SCALE:
return _NEW_MODELVIEW;
+ case STATE_TEXRECT_SCALE:
+ return _NEW_TEXTURE;
default:
_mesa_problem(NULL, "unexpected int. state in make_state_flags()");
return 0;
diff --git a/src/mesa/shader/program.h b/src/mesa/shader/program.h
index 5b73965dca..cf3b1cc099 100644
--- a/src/mesa/shader/program.h
+++ b/src/mesa/shader/program.h
@@ -188,6 +188,7 @@ enum state_index {
STATE_INTERNAL, /* Mesa additions */
STATE_NORMAL_SCALE,
+ STATE_TEXRECT_SCALE,
STATE_POSITION_NORMALIZED /* normalized light position */
};