no errors then run your project.
- #include<Windows.h>
-
- #include<stdio.h>
- #include<gl/GL.h> // GL.h header file
- #include<gl/GLU.h> // GLU.h header file
- #include<gl/glut.h> // glut.h header file from freeglut\include\GL folder
- #include<conio.h>
- #include<stdio.h>
- #include<math.h>
- #include<string.h>
-
- void Init_OpenGL()
- {
-
- glClearColor(0.0, 0.0, 0.0, 0.0);
-
- glShadeModel(GL_FLAT);
- }
-
-
- void Display_Objects(void)
- {
-
- glClear(GL_COLOR_BUFFER_BIT);
-
-
-
- glPushMatrix();
-
- glTranslatef(0.0, 0.0, 0.0);
-
- glColor3f(1.0, 0.8, 0.0);
-
- glutWireTeapot(1.0);
-
-
- glTranslatef(-2.5, 0.0, 0.0);
- glColor3f(0.0, 1.0, 0.0);
- glutWireSphere(0.8, 30, 30);
-
-
- glTranslatef(5.0, 0.0, 0.0);
- glColor3f(0.0, 0.6, 1.0);
- glutWireCone(0.8, 1.5, 20, 20);
-
-
- glTranslatef(-1.0, 1.4, 0.0);
- glColor3f(1.0, 0.3, 0.0);
- glutWireCube(1.0);
-
-
- glTranslatef(-3.0, 0.4, 0.0);
- glColor3f(1.0, 0.3, 1.0);
- glutWireTorus(0.2, 0.6, 20, 20);
-
-
- glTranslatef(-2.5, -4.0, 0.0);
-
- char str[] = {“OpenGL Demo in Visual C++”};
-
- glColor3f(1.0, 1.0, 1.0);
-
- glRasterPos2f(2.0, 0.0);
-
- for (int i = 0; i < strlen(str); i++)
- {
-
- glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24, str[i]);
- }
-
-
-
- glPopMatrix();
- glutSwapBuffers();
- }
-
- void Reshape(int w, int h)
- {
-
- glViewport(0, 0, (GLsizei)w, (GLsizei)h);
-
- glMatrixMode(GL_PROJECTION);
-
- glLoadIdentity();
- gluPerspective(60.0, (GLfloat)w / (GLfloat)h, 1.0, 20.0);
-
- glMatrixMode(GL_MODELVIEW);
-
- glLoadIdentity();
-
-
- gluLookAt(-0.3, 0.5, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
- }
-
-
- int main(int argc, char** argv)
- {
-
- glutInit(&argc, argv);
- glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
-
- glutInitWindowSize(700, 500);
-
- glutInitWindowPosition(250, 50);
-
- glutCreateWindow(“OpenGL Demo”);
-
- Init_OpenGL();
-
- glutDisplayFunc(Display_Objects);
-
- glutReshapeFunc(Reshape);
-
- glutMainLoop();
- return 0;
- }
Leave a comment