glutInit(): This function initialize the glut & takes to parameters.glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB).Here's the main function that can be defined in OpenGL C++ to create a Window & set all methods for execute. You can see syntax when the mouse hovers on that specific function in Visual Studio.Īs you know every C++ program has a main function, here it takes a command line argument. If you want to draw solid then useglutSolidTeapot(). glutWireTeapot() This function draws a wired Teapot.glColor3f(): It specify the color to the object & takes 3 float values of RGB.glTranslatef(): This function set the position to the next object to be drawn for float.glPushMatrix(): This function pushes the coordinates onto stack.glClearColor(): This function clear the background with color RGB.
Read all comments in the code for better understanding. In this code we will draw some common objects defined by glut like Sphere, Teapot, Cone, etc. Here my path is C:\Program Files\Common Files\freeglut\lib.įirst you must define the Windows.h header file before defining the OpenGL header files otherwise error will occur. Here my path is C:\Program Files\Common Files\freeglut\include.Ĭopy and paste path of lib folder of freeglut folder to Library Directories as in the following image:
Now, copy and paste path of include folder of freeglut folder to Include Directories as in the following image:
To run OpenGL programs using VC++ you need OpenGL header files & libraries. It uses algorithms carefully developed and optimized by Silicon Graphics, Inc. (SGI), an acknowledged world leader in computer graphics and animation.
The greatest advantage to using OpenGL is that it is orders of magnitude faster than a ray-tracer. Using OpenGL, you can create elegant and beautiful 3D graphics with nearly the visual quality of a raytracer.
In essence, it is a 3D graphics and modeling library that is extremely portable and very fast. OpenGL is designed as a streamlined, hardware-independent interface to be implemented on many different hardware platforms. This interface consists of about 150 distinct commands that you use to specify the objects and operations needed to produce interactive three-dimensional applications.
OpenGL is a software interface to graphics hardware. In this article we will see about setting up the Visual Studio for OpenGL to run OpenGL programs using Visual C++. I have been coding OpenGL in C++ from a year but I used other IDE's.