VS configuration OpenGL environment under Windows

Article directory


foreword

Thanks to the students at station B for carrying the teaching videos on YouTube.

Get GLFW

Download the 64-bit binary file for GLFW macOS from the official website
insert image description here


Open VS

  1. Create a new solution OpenGL testand create a new folder in the solution Dependencies:

insert image description here

insert image description here

  1. Find the latest version of the link file and file from the downloaded glfwfolder include, and move them to Dependencies/GLFWthe path :
    insert image description here
    insert image description here

  2. lib-vc2022But not all the things in the folder are what we need, we only need .libthe library file, and delete the other three files.

insert image description here

  1. Open the properties of the solution:
    insert image description here
  2. Add path for C/C++ -> 常规in :附加包含目录
    insert image description here
  3. 链接器->输入For 附加依赖项the add glfw3.lib, opengl32.libfile in:

insert image description here

Here is a very interesting place. In the video, cherno directly deletes all the default dependencies that come with VS, and buildthen error - lack of dependencies, and the solution is:

  • Pick missing dependency names:
    insert image description here

  • Google it, and you will know:
    insert image description here

  • According to the tips of MSDN documentation, add the corresponding dependency files 链接器->输入in : This can be regarded as teaching a man how to fish rather than giving him a fish.附加依赖项
    insert image description here

Closer to home, after the above operations, the code should no longer be marked in red:

insert image description here
Run it and try:

insert image description here
Got a window named Hello Worldand 640 X 480sized .

Use legacy openglto draw a triangle:
insert image description here
you're done~

Guess you like

Origin blog.csdn.net/Jormungand_V/article/details/126441491