Scaling in OpenGL
In this post I am going to show a simple way to learn how to do Scaling in OpenGL. Scaling is a property of transformation which helps increasing and decreasing the size of an object in computer graphics. The alteration in the size of object is done in each of the axis - X,Y and Z.
For Scaling in OpenGL we have inbuilt function which can be used easily on any 2d or 3d objects. The function is -
Prototype :
void glScaled (GLdouble x,GLdouble y,GLdouble z);
void glScalef (GLfloat x,GLfloat y, GLfloat z);
Sample :
glScalef (GLfloat 1.0f,GLfloat 0.5f , GLfloat 2.0f);
Here, in above sample code we see the function will scale the object into half in y direction, twice in z axis while remain same in x.
One thing is to be note is that - the matrix mode should be either GL_MODELVIEW or GL_PROJECTION, for object to be scaled.
Here is a sample program Which helps you understand the how the scaling works in perspective of Opengl computer graphics. This is simple c program, use x,y,z to…