PDA

View Full Version : Scaling matrix before positioning it



blessman11
03-20-2011, 04:34 AM
How do I scale an object before positioning it?
I've been having this error where my object refuses to be scaled before its repositioned.


//draw font in array
qva_Fonts[((int)*s)-32]-> draw();
s++;

//loadmatrix Position & Scalling

gfaaSca[0] = gfFont_Size;
gfaaSca[5] = gfFont_Size;
gfaaSca[10] = gfFont_Size;
gfaaSca[15] = gfFont_Size;

gfText_PosX += gfFont_Spacing;
gfaaPos[12] = gfText_PosX;
gfaaPos[13] = gfText_PosY;

//multiply matrix

glMultMatrixf(gfaaSca);
glMultMatrixf(gfaaPos);
glLoadMatrixf(gfaaSca); glLoadMatrixf(gfaaPos);

Zyx_2000
03-20-2011, 06:48 AM
You are using glMultMatrixf() and glLoadMatrixf() the wrong way. Try taking a look at glScalef() and glTranalatef(), those should do the thing you want to be done.

mhagain
03-20-2011, 07:19 AM
glMultMatrixf(gfaaSca);
glMultMatrixf(gfaaPos);
glLoadMatrixf(gfaaSca); glLoadMatrixf(gfaaPos);
I posted this in your other thread. Your problem is that you are calling glLoadMatrixf twice.

Please look at the documentation for glLoadMatrix: http://www.opengl.org/sdk/docs/man/xhtml/glLoadMatrix.xml

glLoadMatrix replace the current matrix with the specified matrixThe second call is not positioning as well as scaling, it is replacing your scaling with your positioning. In other words it's behaving this way because that's what you told it to do.

blessman11
03-20-2011, 11:18 AM
I wanted to learn how to do this using matrix I defined myself, I was told thats the way I would have to do it when working on the xbox 360/ps3 next year at uni.

Alfonse Reinheart
03-20-2011, 11:41 AM
I wanted to learn how to do this using matrix I defined myself

If so, then you need to also learn how to multiply matrices, thus combining transformations.

Though honestly, if you want to "learn how to do this", you should just read my signature.