我正在使用 GLFW + GLAD 或 GLEW ( ) 设置 opengl #include glad/glad.h #include <GL/glew.h>。在该函数之后,glfwMakeContextCurrent(window);我需要检查 GLAD 或 GLEW 是否已正确初始化,否则我将在 Visual Studio 2019 中遇到异常错误。
#include <glad/glad.h>
#include <GLFW/glfw3.h>
#include <iostream>
using namespace std;
int main(void) {
GLFWwindow* window;
/* Initialize the library */
if (!glfwInit())
return -1;
/* Create a windowed mode window and its OpenGL context */
window = glfwCreateWindow(640, 480, "Hello World", NULL, NULL);
if (!window)
{
glfwTerminate();
return -1;
}
/* Make the window's …Run Code Online (Sandbox Code Playgroud)