Setup OpenGL with Visual Studio 2019
Installation
- Download GLUT header, lib, and dll files from OpenGL - GLUT
- Paste
include->GL
inC:\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.lib
inC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.24.28314\lib\x86
andglut.lib
inC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.24.28314\lib\x64
- Paste
glut32.dll
inC:\Windows\System32
,C:\Windows
, andglut.dll
inC:\Windows\SysWOW64
Create a project
Open
Visual Studio
, selectcreate a new project
, chooseEmpty Project
.Go to
Project -> Properties (Alt + F7)
, on the top selectAll Configurations
fromConfiguration
dropdown 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/