extern int _slang_fetch_float (struct gl2_vertex_shader_intf **, const char *, GLfloat *, int);\r
extern int _slang_fetch_vec3 (struct gl2_vertex_shader_intf **, const char *, GLfloat *, int);\r
extern int _slang_fetch_vec4 (struct gl2_vertex_shader_intf **, const char *, GLfloat *, GLuint, int);\r
+extern int _slang_fetch_mat3 (struct gl2_vertex_shader_intf **, const char *, GLfloat *, GLuint, int);\r
extern int _slang_fetch_mat4 (struct gl2_vertex_shader_intf **, const char *, GLfloat *, GLuint, int);\r
\r
static void fetch_input_float (const char *name, GLuint attr, GLuint i, struct vertex_buffer *vb,\r
static void fetch_uniform_mat4 (const char *name, const GLmatrix *matrix, GLuint index,\r
struct gl2_vertex_shader_intf **vs)\r
{\r
+ /* XXX: transpose? */\r
_slang_fetch_mat4 (vs, name, matrix->m, index, 1);\r
}\r
\r
+static void fetch_normal_matrix (const char *name, GLmatrix *matrix,\r
+ struct gl2_vertex_shader_intf **vs)\r
+{\r
+ GLfloat mat[9];\r
+\r
+ _math_matrix_analyse (matrix);\r
+ mat[0] = matrix->inv[0];\r
+ mat[1] = matrix->inv[1];\r
+ mat[2] = matrix->inv[2];\r
+ mat[3] = matrix->inv[4];\r
+ mat[4] = matrix->inv[5];\r
+ mat[5] = matrix->inv[6];\r
+ mat[6] = matrix->inv[8];\r
+ mat[7] = matrix->inv[9];\r
+ mat[8] = matrix->inv[10];\r
+ _slang_fetch_mat3 (vs, name, mat, 0, 1);\r
+}\r
+\r
static GLboolean run_arb_vertex_shader (GLcontext *ctx, struct tnl_pipeline_stage *stage)\r
{\r
TNLcontext *tnl = TNL_CONTEXT(ctx);\r
fetch_uniform_mat4 ("gl_ModelViewProjectionMatrix", &ctx->_ModelProjectMatrix, 0, vs);\r
for (j = 0; j < 8; j++)\r
fetch_uniform_mat4 ("gl_TextureMatrix", ctx->TextureMatrixStack[j].Top, j, vs);\r
- /* XXX: fetch uniform mat3 gl_NormalMatrix */\r
+ fetch_normal_matrix ("gl_NormalMatrix", ctx->ModelviewMatrixStack.Top, vs);\r
/* XXX: fetch uniform mat4 gl_ModelViewMatrixInverse */\r
/* XXX: fetch uniform mat4 gl_ProjectionMatrixInverse */\r
/* XXX: fetch uniform mat4 gl_ModelViewProjectionMatrixInverse */\r