glScalef function:
glScalef() function is use for scaling in OpenGL so the question is what is scaling?
scaling:
Scaling
is about the origin. If Sx = Sy the scaling is uniform; otherwise it
distorts the image. If Sx or Sy < 0, the image is reflected across the x
or y axis. in scaling we multiply the object position with the scaling factor.so if object position is p(x,y) and scaling factor is s(x,y) so we can say that
P'=p(x,y).s(x,y)
In two dimension scaling :
P'=p(x,y).s(x,y)
In two dimension scaling :
•(sx and sy )>
1 ---> Increases Object Size
•(sx and sy )<
1 ---> Decreases Object Size
•(sx and sy )= 1 ---> Unchanged Object Size
•sx = sy ---> Uniform Scaling
•sx != sy ---> Differential Scaling
types of scaling:
uniform scaling:
if scaling factor are same then scaling is called is called uniform scaling
Sx=Sy
Differential scaling:
if the scaling factor is not same then scaling is called differential scaling
Sx is not equal to Sy
scaling in openGl:
glScalef() function is use for scaling in OpenGL
syntax:
glsaclef(x , y , z);
Example:
void Draw_scalling() {
glPushMatrix();
glScalef(0.2,0.2,0.0);
glBegin(GL_QUADS);
glColor3f(0.0f,1.0f,0.0f);
glVertex2f( 0.2, 0.49);
glVertex2f(0.4, 0.49);
glVertex2f(0.4, 0.76);
glVertex2f( 0.2, 0.76);
glEnd();
glPopMatrix();
glFlush();
}
screen short:
Before scaling |
After scaling |
you can see the scaling effect in above fig after scaling you can see that your body is moved in left corner . so i am telling you before scaling is always about the origin so if u want that your image is not move toward the origin so you can use the gltranslatef() function here
0 comments:
Post a Comment