Как подключить opengl в visual studio 2019

Русские Блоги

1. Установите компоненты разработки C ++ и диспетчер пакетов NuGet.

1. Откройте программу установки Visual Studio, чтобы изменить:

2. Нажмите, чтобы изменить:

3. Проверьте настольную разработку на C ++:

4. Проверьте диспетчер пакетов NuGet:

Во-вторых, настройте OpenGL

Ссылка для скачивания: https://www.opengl.org/resources/libraries/glut/glutdlls37beta.zip
Ссылка на сетевой диск: https://pan.baidu.com/s/1O0eFXG-EPDR_9PzD0se1qg Код извлечения: 7dmk

После загрузки и распаковки сжатого пакета есть следующие файлы:

Просто поместите файл в соответствующую папку:
①Поместите glut.h в C: \ Program Files (x86) \ Microsoft Visual Studio \ community \ VC \ Tools \ MSVC \ 14.24.28314 \ include \ gl
②Поместите glut.lib и glut32.lib в . \ Microsoft VisualStudio \ community \ VC \ Tools \ MSVC \ 14.24.28314 \ lib \ x86
③ Поместите glut.dll и glut32.dll в C: \ Windows \ SysWOW64

Примечание:
① Если папки gl нет, создайте новую
②Windows 64-битная, просто выполните описанную выше операцию, если она 32-битная, поместите glut.dll и glut32.dll в C: \ Windows \ System32

3. Новый проект OpenGL

1. Откройте Visual Studio2019 и выберите создание нового проекта:

2. Выберите Мастер рабочего стола Windows:

3. Проверьте пустой проект:

4. Выберите «Инструменты-NuGet Package Management-NuGet Packages for Management Solutions» и найдите «nupengl» в браузере.

5. Должны быть установлены и nupengl.core, и nupengl.core.redist:

Он был успешно настроен, и затем вы можете создать новый файл .cpp для тестирования кода в только что созданном проекте.

OpenGL in VS 2019–1: Your Window

In the old fashion, we ran code in linear method among CPUs. With OpenGL, you can run code in parallel tasks among the GPUs. That’s much faster. Don’t you want to have a fast program under your design? Let’s work on OpenGL with C++. In this chapter, I will focus on setup and opening the first window.

1. Download Requirements …… →Menu

Please download the source package.

    : Multi-Language GL/GLES/EGL/GLX/WGL Loader-Generator based on the official specs.

Download the glad.zip file.

Unzip glad.zip to my OpenGL_Project\glad.

2. Generate GLFW Project with CMake …… →Menu

Download or Your saved folder

Unzip glfw-3.3.4.zip to “glfw-3.3.4” folder.

Unzip GLFW to its folder and create a “build” folder in it.

Default is fine.

VS2019: Build GLFW Lib & Move into Libraries\lib

In glfw-3.3.4\build\

Open GLFW.sln in Visual Studio.

The project will generate a library file called glfw3.lib at build/src/debug.

If you encounter an error, you may have moved the folder from somewhere else. So you need to redo the CMake process.

Now, let’s move glfw3.lib to your project Libraries\lib folder:

User GLFW’s include as Your include

Download: Unzip glad.zip to glad

glad\include to Libraries\include

glad\glad.c to C:\OpenGL_Project\MyOpenGL

3. VS2019 — Setup Project …… →Menu

Switch back to MyOpenGL project:

Let’s choose x64 as our code standard.

  • Platform + Configuration Manager

  • VC++ : Include

  • VC++ → Library

  • Linker → Input

Drag glad.c to the folder of “Source Files”.

✒️ 4. Main C++ …… →Menu

Ctrl+Shift+A: Add main.cpp

OpenGL Block: OpenGL code will insert in the block.

— Let’s Run

It’s nothing but a pure white background.

5. GLAD &. Set Background Color …… →Menu

Before the window event, we can use the GLAD(Multi-Language GL/GLES/EGL/GLX/WGL Loader-Generator) function.

How to setup OpenGL with Visual Studio 2019 on Windows 10?

OpenGL is a 2D and 3D graphics API that provides a cross-platform application programming interface for a wide variety of computer platforms. It is operating system independent and has a transparent network. Application developers use it to develop high-performing and visually compelling graphics software applications.

Prerequisites:

  • Visual Studio 2019 (Download)

Installation:

Now let’s jump into the setup of OpenGL. To do so follow the below steps:

Step 1: First we have to download Visual Studio 2019 for windows10.

Step 2: Now we have installed Visual Studio2019 from its downloaded the .exe file with Windows installer.

Select Visual Stdio community 2019 and click Modify, now select the required components as shown in below image and click install while Downloading :

It will take some time after it will be complete restart the computer after the installation take place.

Step 3:

  • Now download GLUT header file, the .LIB, and .DLL files all pre-compiled for Intel platforms, you can simply download the glutdlls37beta.zip file from the website.
  • File inside folder look like this:

Step 4: After this, we have to copy the file as instructed below:

  • First, pasteglut.h file in:
  • Then paste glut.lib in:
  • Then paste the glut32.lib in:
  • Then pasteglut.dll and glut32.dll in:
  • Finally copy glut32.dllto:

Take a look at the below video for installation:

Here is one sample code for running to check whether it is working or not

1. First download the OpenGL library file

http://www.opengl.org/resources/libraries/glut/glutdlls37beta.zip
Click blue words to automatically download
After downloading, decompress it gets the picture 5 files. According to the suffix name, it is divided into .dll; .h; .lib three categories.
This thing is indeed the product of the last century, and the native version will not be updated after 98 years.

2. Place the file classification to the specified folder

Find a directory \ Microsoft Visual
Studio\2019\Community\VC\Tools\MSVC\14.24.28314\include\GL。
Put glut.h in it.

Include directory generally does not have a GL folder, requiring new one. The author’s VS is installed under the C: \ Program Files (x86) directory, and the following figure takes this as an example.
14.24.28314 Version number will vary from version

Find a directory \ Microsoft Visual
Studio\2019\Community\VC\Tools\MSVC\14.24.28314\lib\x86
Put glut.lib, glut32.lib inside.

  • The method is the same, the reference directory is shown

Find the directory C: \ windows \ syswow64 put glut.dll and glut32.dll inside.

If it is a 32-bit system, put two folders into the C: \ Windows \ System32 directory

3. Create a console application

  • Delete the original content in the .cpp file, copy the test code below to the file
  • Open Project> Manage NuGet Package

Search Nupengl in the left browsing section, two, install them (these two should be the same, install one, the other is also installed)

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *