gl_frustum(-aspect * x, aspect * x, -x, x, near, far);\r
}\r
\r
+/* return the matrix (16 elements, 4x4 matrix, row-major order */\r
float* get_matrix(int mm)\r
{\r
int idx = MMODE_IDX(mm);\r
#define M3(i, j) ((i * 3) + j)\r
static float inv_transpose_result[9];\r
\r
+/* return the inverse transpose of the left-upper 3x3 of a matrix\r
+ The returned pointer is only valid until the next time this function is\r
+ called, so make a deep copy when you want to keep it around.\r
+ */\r
float* get_inv_transpose_3x3(int mm)\r
{\r
int idx = MMODE_IDX(mm);\r
\r
return inv_transpose_result;\r
}\r
-\r
-\r
-#if 0\r
-void gl_apply_xform(unsigned int prog)\r
-{\r
- int loc, mvidx, pidx, tidx, mvtop, ptop, ttop;\r
-\r
- mvidx = MMODE_IDX(GL_MODELVIEW);\r
- pidx = MMODE_IDX(GL_PROJECTION);\r
- tidx = MMODE_IDX(GL_TEXTURE);\r
-\r
- mvtop = stack_top[mvidx];\r
- ptop = stack_top[pidx];\r
- ttop = stack_top[tidx];\r
-\r
- assert(prog);\r
-\r
- if((loc = glGetUniformLocation(prog, "matrix_modelview")) != -1) {\r
- glUniformMatrix4fv(loc, 1, 0, mat_stack[mvidx][mvtop]);\r
- }\r
-\r
- if((loc = glGetUniformLocation(prog, "matrix_projection")) != -1) {\r
- glUniformMatrix4fv(loc, 1, 0, mat_stack[pidx][ptop]);\r
- }\r
-\r
- if((loc = glGetUniformLocation(prog, "matrix_texture")) != -1) {\r
- glUniformMatrix4fv(loc, 1, 0, mat_stack[tidx][ttop]);\r
- }\r
-\r
- if((loc = glGetUniformLocation(prog, "matrix_normal")) != -1) {\r
- float nmat[9];\r
-\r
- nmat[0] = mat_stack[mvidx][mvtop][0];\r
- nmat[1] = mat_stack[mvidx][mvtop][1];\r
- nmat[2] = mat_stack[mvidx][mvtop][2];\r
- nmat[3] = mat_stack[mvidx][mvtop][4];\r
- nmat[4] = mat_stack[mvidx][mvtop][5];\r
- nmat[5] = mat_stack[mvidx][mvtop][6];\r
- nmat[6] = mat_stack[mvidx][mvtop][8];\r
- nmat[7] = mat_stack[mvidx][mvtop][9];\r
- nmat[8] = mat_stack[mvidx][mvtop][10];\r
- glUniformMatrix3fv(loc, 1, 0, nmat);\r
- }\r
-}\r
-#endif\r