Setup OpenGL with Visual Studio 2019
Installation
- Download GLUT header, lib, and dll files from OpenGL - GLUT
- Paste
include->GLinC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.24.28314\include - Download https://www.opengl.org/resources/libraries/glut/glutdlls37beta.zip
Pasteglut32.libinC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.24.28314\lib\x86
andglut.libinC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.24.28314\lib\x64 - Paste
glut32.dllinC:\Windows\System32,C:\Windows, andglut.dllinC:\Windows\SysWOW64
Create a project
Open
Visual Studio, selectcreate a new project, chooseEmpty Project.Go to
Project -> Properties (Alt + F7), on the top selectAll ConfigurationsfromConfigurationdropdown menu.
ChooseConfiguration Properties -> C/C++ -> Precompiled Headers, setPrecompiled Header‘s value toNot Using Precompiled Headers.
ChooseConfiguration Properties -> Linker -> Input, clickAdditional Dependencies, and then clickEdit, and type:opengl32.lib
glu32.lib
glut32.libthen click OK.
Paste the code I found in Internet to test:
void display() {
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0, 0.0, 0.0);
glBegin(GL_POINTS);
glVertex2f(10.0, 10.0);
glVertex2f(150.0, 80.0);
glVertex2f(100.0, 20.0);
glVertex2f(200.0, 100.0);
glEnd();
glFlush();
}
void myinit() {
glClearColor(1.0, 1.0, 1.0, 1.0);
glColor3f(1.0, 0.0, 0.0);
glPointSize(5.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0, 499.0, 0.0, 499.0);
}
int main(int argc, char** argv) {
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(500, 500);
glutInitWindowPosition(0, 0);
glutCreateWindow("Points");
glutDisplayFunc(display);
myinit();
glutMainLoop();
return 0;
}Then Compile and run(x86).
One more thing…
If you upgrade VS, you should re-install OpenGL, since the folder is moved to a higher version one.
Reference
Special thanks to https://www.absingh.com/opengl/