Vs2015 + OpenGL environment configuration

The article from http://jingyan.baidu.com/article/d5c4b52bca5005da560dc5d6.html
http://www.linuxidc.com/Linux/2013-02/78959p2.htm
Look at both of them if I don’t make sense

Download the GLUT library http://www.opengl.org/resources/libraries/glut/glutdlls37beta.zip
(If you can’t get out, remember over the wall. I gotover the wallfrom BBB1 and downloaded it directly in the browser.)

Copy the static function libraries Glut. lib and Glut32.lib into the lib folder of the file directory after extracting them
X:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\lib

Will glut. DLL, glut32 DLL this two dynamic library file into the operating system directory under the C: \ Windows \ system32 folder (32-bit system) or ‪ C: \ Windows \ SysWOW64 (64 – bit systems).
For compatibility, it is best to copy the corresponding files in both directories.

Copy the extracted header file Glut. h into the following directory:
X:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\ Include \GL

Tip: If there is no GL folder in the incluce directory, you will need to create it manually

Verification method:
Create a blank Win32 console application

2,
Add the include directory at the beginning of the code
#include < GL/glut.h>

3. Then you can edit your own OpenGL program

4,
For example: Copy the following code into the newly configured VS

#include < GL/glut.h>
#include < stdlib.h>
#include < math.h>
#include < stdio.h>
static int year = 0,spin=0, day = 0;
static GLint fogMode;
const int n = 100;
Const GLFloat R = 1.0F;
Const GLFloat Pi = 3.1415926536 F;

void DrawCircle()
{

Int I;
glClear(GL_COLOR_BUFFER_BIT);

glBegin(GL_LINE_LOOP);

for (i = 0; i < n; ++i)
{
GlColor3f (1.0, 0.0, 0.0);
glVertex2f(R*cos(2 * Pi/n*i), R*sin(2 * Pi/n*i));
}

glEnd();
glFlush();
}

void init(void)
{
GlFloat Position [] = {0.5, 0.5, 3.0, 0.0};

glEnable(GL_DEPTH_TEST); // prevent occlusion
glLightfv(GL_LIGHT0, GL_POSITION, position);
GlEnable (GL_LIGHTING);
glEnable(GL_LIGHT0);
{
GLFloat Mat [3] = {0.1745, 0.01175, 0.01175};
glMaterialfv(GL_FRONT, GL_AMBIENT, mat);
Mat [0] = 0.61424; Mat [1] = 0.04136; Mat [2] = 0.04136;
glMaterialfv(GL_FRONT, GL_DIFFUSE, mat);
Mat [0] = 0.727811; Mat [1] = 0.626959; Mat [2] = 0.626959;
glMaterialfv(GL_FRONT, GL_SPECULAR, mat);
GlMaterialf (GL_FRONT GL_SHININESS, 0.6 * 128.0);
}

glEnable(GL_FOG);
{
GlFloat fogColor[4] = {0.5, 0.5, 0.5, 1.0};

fogMode = GL_EXP;
glFogi(GL_FOG_MODE, fogMode);
glFogfv(GL_FOG_COLOR, fogColor);
GlFogf (GL_FOG_DENSITY, 0.35);
glHint(GL_FOG_HINT, GL_DONT_CARE);
GlFogf (GL_FOG_START, 1.0);
GlFogf (GL_FOG_END, 5.0);
}
GlClearColor (0.5, 0.9, 0.9, 1.0); Fog color/* * /

}

void display(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
GlColor3f (0.0, 1.0, 1.0);
GlPushMatrix (); // Remember your position
GlutSolidSphere (1.0, 20, 16); /* Draw solar radius, 20 longitude, 16 latitude */
GlRotatef (spin, 0.0, 1.0, 0.0); // Rotate around a vector at a given Angle (positive is counterclockwise)

GlTranslatef (2.0, 1.0, 0.0);

GlRotatef (spin, 1.0, 0.0, 0.0);// revolution
GlRectf (0.1, 0.1, 0.5, 0.5);

GlColor3f (0.0, 0.0, 1.0);
GlutWireSphere (0.2, 8, 8); /* Draw the first asteroid */
GlColor3f (1.0, 0.0, 0.0);
GlTranslatef (2.0, 1.0, 0.0);

Glrotatef (2 * spin, 0.0, 1.0, 0.0);
GlutSolidSphere (0.5, 16, 8);

glPopMatrix(); // Return to the original position

glutSwapBuffers();
}

void spinDisplay(void)
{
spin = spin + 2;
if (spin > 360).
spin = spin – 360;
glutPostRedisplay();
}

void mouse(int button,int state,int x,int y )
{
switch (button)
{
case GLUT_LEFT_BUTTON:
if (state == GLUT_DOWN)
glutIdleFunc(spinDisplay);
break;
case GLUT_MIDDLE_BUTTON:
if (state == GLUT_DOWN)
glutIdleFunc(NULL);
break;
default:
break;
}
}

void reshape(int w, int h)
{
glViewport(0, 0, (GLsizei)w, (GLsizei)h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
GluPerspective (60.0, (GLFloat)w/(GLFloat)h, 0.5, 20.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
GluLookAt (0.0, 10.0, 10.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
}

void keyboard(unsigned char key, int x, int y)
{
switch (key) {
case ‘d’:
day = (day + 10) % 360;
glutPostRedisplay();
break;
case ‘D’:
day = (day – 10) % 360;
glutPostRedisplay();
break;
case ‘y’:
year = (year + 5) % 360;
glutPostRedisplay();
break;
case ‘Y’:
year = (year – 5) % 360;
glutPostRedisplay();
break;
case 27:
exit(0);
break;
default:
break;
}
}

int main(int argc, char** argv)
{
glutInit(& argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
glutInitWindowSize(400, 400);
glutInitWindowPosition(100, 100);
GlutCreateWindow (” OpenGL Programming — Yang Chao “);

init();
//glutDisplayFunc(DrawCircle);
glutDisplayFunc(display);
glutReshapeFunc(reshape);
//glutKeyboardFunc(keyboard);
glutMouseFunc(mouse);

glutMainLoop();
return 0;
}

5,
http://jingyan.baidu.com/album/d5c4b52bca5005da560dc5d6.html?picindex=5
So we have the picture


Read More: