Hello ,
I got a project downloaded from internet in C++ and i need to explain the code to my teacher .
Can someone give me a explanation please ?
code :
#include <GL/freeglut.h>
#include <stdlib.h>
void initGL(int width, int height)
{
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.0f, (GLfloat) width / (GLfloat) height, 2.0f, 100.0f);
glMatrixMode(GL_MODELVIEW);
}
static void display(void)
{
glLoadIdentity();
glPushMatrix();
glTranslatef(0.0, 0.0, -10);
glRotatef(60, 1, 0, 0);
glRotatef(60, 0, 1, 0);
glutSolidCube(2);
glPopMatrix();
glFlush();
}
static void idle(void)
{
glutPostRedisplay();
}
int main(int argc, char *argv[])
{
int width = 640;
int height = 480;
glutInit(&argc, argv);
glutInitWindowSize(width, height);
glutInitWindowPosition(10, 10);
glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE);
glutCreateWindow("Hello world!");
glutDisplayFunc(display);
glutIdleFunc(idle);
initGL(width, height);
glutMainLoop();
return EXIT_SUCCESS;
}
I got a project downloaded from internet in C++ and i need to explain the code to my teacher .
Can someone give me a explanation please ?
code :
#include <GL/freeglut.h>
#include <stdlib.h>
void initGL(int width, int height)
{
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.0f, (GLfloat) width / (GLfloat) height, 2.0f, 100.0f);
glMatrixMode(GL_MODELVIEW);
}
static void display(void)
{
glLoadIdentity();
glPushMatrix();
glTranslatef(0.0, 0.0, -10);
glRotatef(60, 1, 0, 0);
glRotatef(60, 0, 1, 0);
glutSolidCube(2);
glPopMatrix();
glFlush();
}
static void idle(void)
{
glutPostRedisplay();
}
int main(int argc, char *argv[])
{
int width = 640;
int height = 480;
glutInit(&argc, argv);
glutInitWindowSize(width, height);
glutInitWindowPosition(10, 10);
glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE);
glutCreateWindow("Hello world!");
glutDisplayFunc(display);
glutIdleFunc(idle);
initGL(width, height);
glutMainLoop();
return EXIT_SUCCESS;
}


