summaryrefslogtreecommitdiff
path: root/src/mesa/tnl
diff options
context:
space:
mode:
authorMichal Krol <mjkrol@gmail.org>2006-02-15 11:02:07 +0000
committerMichal Krol <mjkrol@gmail.org>2006-02-15 11:02:07 +0000
commitdc3a922cf30bf12cb01167bf1328d377ff3ee120 (patch)
treead1173a6df96cc368979c59d9e6d72bec96ffee8 /src/mesa/tnl
parent0c8e578a3834882a3a1ce0b755955ae18bdee645 (diff)
Get arbfslight demo running.
Diffstat (limited to 'src/mesa/tnl')
-rw-r--r--src/mesa/tnl/t_vb_arbshader.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/src/mesa/tnl/t_vb_arbshader.c b/src/mesa/tnl/t_vb_arbshader.c
index d779e44004..c1244ba925 100644
--- a/src/mesa/tnl/t_vb_arbshader.c
+++ b/src/mesa/tnl/t_vb_arbshader.c
@@ -94,6 +94,7 @@ extern void exec_vertex_shader (struct gl2_vertex_shader_intf **vs);
extern int _slang_fetch_float (struct gl2_vertex_shader_intf **, const char *, GLfloat *, int);
extern int _slang_fetch_vec3 (struct gl2_vertex_shader_intf **, const char *, GLfloat *, int);
extern int _slang_fetch_vec4 (struct gl2_vertex_shader_intf **, const char *, GLfloat *, GLuint, int);
+extern int _slang_fetch_mat3 (struct gl2_vertex_shader_intf **, const char *, GLfloat *, GLuint, int);
extern int _slang_fetch_mat4 (struct gl2_vertex_shader_intf **, const char *, GLfloat *, GLuint, int);
static void fetch_input_float (const char *name, GLuint attr, GLuint i, struct vertex_buffer *vb,
@@ -178,9 +179,28 @@ static void fetch_output_vec4 (const char *name, GLuint attr, GLuint i, GLuint i
static void fetch_uniform_mat4 (const char *name, const GLmatrix *matrix, GLuint index,
struct gl2_vertex_shader_intf **vs)
{
+ /* XXX: transpose? */
_slang_fetch_mat4 (vs, name, matrix->m, index, 1);
}
+static void fetch_normal_matrix (const char *name, GLmatrix *matrix,
+ struct gl2_vertex_shader_intf **vs)
+{
+ GLfloat mat[9];
+
+ _math_matrix_analyse (matrix);
+ mat[0] = matrix->inv[0];
+ mat[1] = matrix->inv[1];
+ mat[2] = matrix->inv[2];
+ mat[3] = matrix->inv[4];
+ mat[4] = matrix->inv[5];
+ mat[5] = matrix->inv[6];
+ mat[6] = matrix->inv[8];
+ mat[7] = matrix->inv[9];
+ mat[8] = matrix->inv[10];
+ _slang_fetch_mat3 (vs, name, mat, 0, 1);
+}
+
static GLboolean run_arb_vertex_shader (GLcontext *ctx, struct tnl_pipeline_stage *stage)
{
TNLcontext *tnl = TNL_CONTEXT(ctx);
@@ -217,7 +237,7 @@ static GLboolean run_arb_vertex_shader (GLcontext *ctx, struct tnl_pipeline_stag
fetch_uniform_mat4 ("gl_ModelViewProjectionMatrix", &ctx->_ModelProjectMatrix, 0, vs);
for (j = 0; j < 8; j++)
fetch_uniform_mat4 ("gl_TextureMatrix", ctx->TextureMatrixStack[j].Top, j, vs);
- /* XXX: fetch uniform mat3 gl_NormalMatrix */
+ fetch_normal_matrix ("gl_NormalMatrix", ctx->ModelviewMatrixStack.Top, vs);
/* XXX: fetch uniform mat4 gl_ModelViewMatrixInverse */
/* XXX: fetch uniform mat4 gl_ProjectionMatrixInverse */
/* XXX: fetch uniform mat4 gl_ModelViewProjectionMatrixInverse */