Download OU BE (B-Tech) CSE Mini Projects Code Programs on Transformations

Download OU (Osmania University)BE (B-Tech) (Bachelor of Engineering) CSE Best Practicle Programs And Code Programs on Transformations

Programs on Transformations
/* Translation transformation to move an object along x-axis */
#include
void display()
{
g1Clear(GL_COLOR_BUFFER_BIT);
g1Begin(GL_QUADS);
glVerteX2f(1.0,1.0);
glVerteX2f(3.0,1.0);
glVerteX2f(3.0,4.0);
glVerteX2f(1.0,4.0);
glEHdO;
glFlush();
}
void init()
{
glMatriXMode(GL_PROJECTION);
glLoadIdentityO;
g1uOrth02D(0.0,12,0.0,7);
}
void timer(int n)
{
glMatriXMode(GL_MODELVIEW);
glLoadIdentityO;
g1Translatef(5.0,0.0,0.0);
glutPostRedisplay();
glutTimerFunc(1000,timer,n); // to have some delay
}
int main(int argc,char** argv)
{
glutlnit(&argc,argv);
g1utInitDisplayM0de(GLUT_SINGLE);
glutlnitWindowPosition(200,200);
g1utInitWind0wSize(300,300);
glutCreateWindow("Translation");
init();
glutDisplayFunC(display);
glutTimerFunc(1000,timer,10); // callback to timer function
glutMainLoopO;

/* Rotation transformation to roatate an object about z-axis wrt to origin */
#include
void p01ygon()
{
ngegin(GL_POLYGON);
g1C010r3f(0.0,0.0,0.0);
glVerteX2f(1.0,1.0);
glVerteX2f(4.0,1.0);
glVerteX2f(4.0,4.0);
glVerteX2f(1.0,4.0);
glEndO;
}
void display()
{
g1ClearC010r(1.0f,1.0f,1.0f,1.0f);
g1C1ear(GL_COLOR_BUFFER_BIT);
polygono;
glFlush();
}
void timer(int n)
{
glMatriXMode(GL_MODELVIEW);
glLoadIdentityO;
//ngranslatef(2.0,2.0,0.0);
g1Rotatef(45.0,0.0,0.0,1.0);
//ngranslatef(?2.0,?2.0,0.0);
polygono;
glutPostRedisplay();
glutTimerFunc(1000,timer,n);
}
void init()
{
glMatriXMode(GL_PROJECTION);
glLoadIdentityO;
gluOrth02D(?6,6,?6,6);
}
int main(int argc, char **argv)
{
glutInit(&argC, argv);
g1utInitDisplayM0de(GLUT_SINGLE);
glutlnitWindowPosition(100,100);
g1utInitWind0wSize(300,300);
glutCreateWindow("Rotation");
init();
glutDisplayFunC(display);
glutTimerFunc(1000,timer,10);
glutMainLoopO;

/* Scaling tranformation */
#include
void display()
{
g1ClearC010r(1.0f,1.0f,1.0f,1.0f);
g1C1ear(GL_COLOR_BUFFER_BIT);
g1Begin(GL_POLYGON);
g1C010r3f(0.0,0.0,0.0);
glVerteX2f(1.0,1.0);
glVerteX2f(4.0,1.0);
glVerteX2f(4.0,4.0);
glVerteX2f(1.0,4.0);
glEHdO;
glFlush();
}
void timer(int n)
{
glMatriXMode(GL_MODELVIEW);
glLoadIdentityO;
g15calef(0.5,0.5,0.5);
glutPostRedisplay();
glutTimerFunc(1000,timer,n);
}
void init()
{
glMatriXMode(GL_PROJECTION);
glLoadIdentityO;
gluOrth02D(?6,6,?6,6);
}
int main(int argc, char **argv)
{
glutInit(&argC, argv);
g1utInitDisplayM0de(GLUT_SINGLE);
glutlnitWindowPosition(100,100);
g1utInitWind0wSize(300,300);
glutCreateWindow("Scaling");
init();
glutDisplayFunC(display);
glutTimerFunc(1000,timer,10);
glutMainLoopO;

This post was last modified on 27 January 2020