This article is republished from Baidu Lesson: Configuring OpenGL in Visual Studio 2015









Program test:
#include "stdafx.h"
#include <GL/glut.h>
void init(void)
{
glClearColor(1.0, 1.0, 1.0, 0.0);
glMatrixMode(GL_PROJECTION);
gluOrtho2D(0.0, 200.0, 0.0, 150.0);
}
void lineSegment(void)
{
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(0.0, 0.4, 0.2);
glBegin(GL_LINES);
glVertex2i(180, 15);
glVertex2i(10, 145);
glEnd();
glFlush();
}
int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowPosition(50, 100);
glutInitWindowSize(400, 300);
glutCreateWindow("An Example OpenGL Program");
init();
glutDisplayFunc(lineSegment);
glutMainLoop();
return 0;
}
Program running results:
Read More:
- Vs2017 installing OpenGL
- Vc2010 configuring OpenGL environment
- 1 vs20152017 + OpenGL to configure and draw a white rectangle
- A strange problem in compiling OpenGL program
- Configuring OpenGL in VS
- The first day of OpenGL [vs2017 + OpenGL environment configuration]
- The simplest course of configuring OpenGL in vs2015
- Vs2015 + OpenGL environment configuration
- On the configuration of OpenGL Red Book eighth edition environment in vs2013
- OpenGL programming error analysis
- To solve the problem of flashback of calling class function of glutsolidcube() in Win32 program
- The function and usage of argc and argv in C language
- Configure glut in Ubuntu and implement basic OpenGL experiment on CodeBlocks platform
- OpenGL Usage Summary (including problems encountered and solutions)
- “Error: ` cout ‘was not declared in this scope”
- Solving the problem of Chinese garbled code in qtring
- error C2057: expected constant expression (Can the size of an array in C language be defined when the program is running?)
- Building OpenGL environment
- Lost in computer OPENGL.dll
- Implementation of OpenGL rotating cube