C++ OpenGL learning-introduction

This article from the reference
opengl learning website
opengl learning Chinese version website

1. What is OpenGL

OpenGL is considered to be an API (an application program interface) in mainstream, providing a large number of functions, using these functions to manipulate graphics and images. But OpenGL itself is not an API, but a specification, developed and maintained by Khronos Group

Two, installation and configuration

1. OpenGL itself does not have a function to create a window, so it can only call other function libraries, here use GLFW to create a window
2. Install GLFW

Download method: download the library directly from the
official website of glfw . If you download the source code, you need to manually compile with cmake.
Insert picture description here
Installation method:
(1) Directly add the lib (in the corresponding version library downloaded or compiled in the previous step) and the contents of the GLDW /include folder to In the /include folder of the IDE, similarly add glfw3.lib to the /lib folder of the IDE. This is possible, but not recommended. It is difficult to track library include files, and the newly installed IDE/compiler will cause you to re-execute this process.
(2) Another method (and recommended) is to create a new set of directories in a location of your choice, which contains all the header files/libraries in the third-party library, and you can reference these header files/ from the IDE/compiler. Library. For example, you can create a folder containing Libs and Include folders, where we store all the libraries and header files of the OpenGL project respectively. Now, all third-party libraries are organized in one place (can be shared across multiple computers). However, our requirement is that every time we create a new project, we must tell the IDE where to find these directories
Insert picture description here
Insert picture description here

Specific method:
OpenGL development environment configuration: Visual Studio 2017 + GLFW + GLEW
Create a directory OpenGL, containing two folders inludes and libs

Create a project, write in the project

#include<glfw/glfw3.h>

Compilation without errors means the configuration is complete

3. Install GLAD

Insert picture description here
After decompression, put the files in inlude into includes in the previous step, and the
file directory is as follows:
Insert picture description here

Add gald.c to the project, write it in the project

#include<glad/glad.h>
#include<GLFW/glfw3.h>

Compilation without errors means the configuration is complete

Guess you like

Origin blog.csdn.net/peixin_huang/article/details/104352714