View Full Version : Scaling matrix before positioning it

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();

//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

glLoadMatrixf(gfaaSca); glLoadMatrixf(gfaaPos);

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.

03-20-2011, 07:19 AM
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.

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.