Code: Select all
float viewmat[16];
...
sceGeGetMtx(PSP_GE_MATRIX_VIEW, viewmat);
Does sceGuGetMtx even work? Other than the meager documentation in pspge.h, I can't find a single reference to it on Google that isn't just a hit on the header file or a syscall index table.
Is this function even referencing the same matrices manipulated by sceGumTranslate and kin? I do find it slightly odd that it is in pspge.h and not pspgu(m).h .
If this is not the correct method to retrieve the transformation matrices could someone kindly point me in the right direction?
many thanks.
P.S. Looking through the source for pspgl's glGetFloatv I noticed that they don't use sceGeGetMtx. They seem to do their own bookkeeping and then switch to a VFPU context based on the requested matrix before directly copying the matrix from the VFPU registers to memory.
Code: Select all
void glGetFloatv (GLenum pname, GLfloat *params)
{
struct pspgl_matrix_stack *s;
switch (pname) {
.
.
.
case GL_MODELVIEW_MATRIX: s = &pspgl_curctx->modelview_stack; goto get_matrix;
case GL_TEXTURE_MATRIX: s = &pspgl_curctx->texture_stack; goto get_matrix;
case GL_PROJECTION_MATRIX: s = &pspgl_curctx->projection_stack; goto get_matrix;
case GL_VIEW_PSP: s = &pspgl_curctx->view_stack; goto get_matrix;
case GL_BONE0_PSP ... GL_BONE7_PSP:
s = &pspgl_curctx->bone_stacks[pname - GL_BONE0_PSP];
/* FALLTHROUGH */
get_matrix:
if (params) {
const GLfloat *matrix = s->stack[s->depth].mat;
int i;
__pspgl_matrix_sync(pspgl_curctx, s);
for (i=0; i<16; i++)
params[i] = matrix[i];
}
break;
default:
GLERROR(GL_INVALID_ENUM);
}
}
Code: Select all
void __pspgl_matrix_sync(struct pspgl_context *c, const struct pspgl_matrix_stack *s)
{
struct pspgl_matrix *m = &s->stack[s->depth];
if ((s->flags & MF_VFPU) == 0)
return;
pspvfpu_use_matrices(c->vfpu_context, VFPU_STACKTOP, 0);
asm volatile("sv.q c700, 0 + %0, wb\n"
"sv.q c710, 16 + %0, wb\n"
"sv.q c720, 32 + %0, wb\n"
"sv.q c730, 48 + %0, wb\n"
: "=m" (m->mat[0]) : : "memory");
}