Mesa (master): mesa: fix incorrect transformation of GL_SPOT_DIRECTION

Brian Paul brianp at kemper.freedesktop.org
Wed Jan 14 18:51:42 UTC 2009


Module: Mesa
Branch: master
Commit: c12d24b513a67648c30bf892964f887fad71e103
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=c12d24b513a67648c30bf892964f887fad71e103

Author: Brian Paul <brianp at vmware.com>
Date:   Wed Jan 14 11:50:32 2009 -0700

mesa: fix incorrect transformation of GL_SPOT_DIRECTION

This was changed between GL 1.0 and 1.1.  Mesa still had the 1.0 behaviour.

---

 docs/relnotes-7.3.html   |    1 +
 src/mesa/main/light.c    |    3 ++-
 src/mesa/math/m_matrix.h |   12 ++++++++++++
 3 files changed, 15 insertions(+), 1 deletions(-)

diff --git a/docs/relnotes-7.3.html b/docs/relnotes-7.3.html
index 69f335f..d46a509 100644
--- a/docs/relnotes-7.3.html
+++ b/docs/relnotes-7.3.html
@@ -46,6 +46,7 @@ tbd
 <li>Fix for wglCreateLayerContext() in WGL/Windows driver
 <li>Build fixes for OpenBSD and gcc 2.95
 <li>GLSL preprocessor handles #pragma now
+<li>Fix incorrect transformation of GL_SPOT_DIRECTION
 </ul>
 
 <h2>Changes</h2>
diff --git a/src/mesa/main/light.c b/src/mesa/main/light.c
index 10ee088..ce50224 100644
--- a/src/mesa/main/light.c
+++ b/src/mesa/main/light.c
@@ -208,7 +208,8 @@ _mesa_Lightfv( GLenum light, GLenum pname, const GLfloat *params )
       if (_math_matrix_is_dirty(ctx->ModelviewMatrixStack.Top)) {
 	 _math_matrix_analyse(ctx->ModelviewMatrixStack.Top);
       }
-      TRANSFORM_NORMAL(temp, params, ctx->ModelviewMatrixStack.Top->inv);
+      TRANSFORM_DIRECTION(temp, params, ctx->ModelviewMatrixStack.Top->m);
+      NORMALIZE_3FV(temp);
       params = temp;
       break;
    case GL_SPOT_EXPONENT:
diff --git a/src/mesa/math/m_matrix.h b/src/mesa/math/m_matrix.h
index e8303f3..a8d9000 100644
--- a/src/mesa/math/m_matrix.h
+++ b/src/mesa/math/m_matrix.h
@@ -189,6 +189,18 @@ do {								\
 } while (0)
 
 
+/**
+ * Transform a direction by a matrix.
+ */
+#define TRANSFORM_DIRECTION( TO, DIR, MAT )			\
+do {								\
+   TO[0] = DIR[0] * MAT[0] + DIR[1] * MAT[4] + DIR[2] * MAT[8];	\
+   TO[1] = DIR[0] * MAT[1] + DIR[1] * MAT[5] + DIR[2] * MAT[9];	\
+   TO[2] = DIR[0] * MAT[2] + DIR[1] * MAT[6] + DIR[2] * MAT[10];\
+} while (0)
+
+
+
 /*@}*/
 
 




More information about the mesa-commit mailing list