Results 1 to 5 of 5

Thread: Scaling matrix before positioning it

  1. #1
    Member Contributor
    Join Date
    May 2012
    Posts
    51

    Scaling matrix before positioning it

    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.

    Code :
    //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);

  2. #2
    Member Contributor
    Join Date
    Sep 2010
    Posts
    74

    Re: Scaling matrix before positioning it

    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.

  3. #3
    Newbie OpenGL Pro
    Join Date
    Jan 2007
    Posts
    1,789

    Re: Scaling matrix before positioning it

    Code :
    		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/x...LoadMatrix.xml
    glLoadMatrix replace the current matrix with the specified matrix
    The 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.

  4. #4
    Member Contributor
    Join Date
    May 2012
    Posts
    51

    Re: Scaling matrix before positioning it

    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.

  5. #5
    Senior Member OpenGL Lord
    Join Date
    Mar 2015
    Posts
    6,675

    Re: Scaling matrix before positioning it

    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.

Similar Threads

  1. Scaling modelview matrix distorts directional light diffuse intensity
    By kevinfishburne in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 09-02-2012, 11:30 PM
  2. Positioning issue using transformation matrix
    By altreality in forum OpenGL: Advanced Coding
    Replies: 2
    Last Post: 04-25-2011, 11:31 AM
  3. Replies: 2
    Last Post: 08-29-2006, 11:02 AM
  4. Scaling --> transformation matrix
    By Theater in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 10-07-2002, 05:35 AM
  5. Replies: 1
    Last Post: 05-21-2002, 06:38 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean