GLFW 环境如何配置?

1.使用 https://glad.dav1d.de/ 生成 glad.h 头文件(用来动态加载Opengl函数指针)
2.下载 https://www.glfw.org/ glfw 二进制库(GUI库)

#define GLFW_INCLUDE_NONE
#include "glad.h"
#include <GLFW/glfw3.h>

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 context current */
	glfwMakeContextCurrent(window);

	// 使用 glad 加载 OPenGL 函数指针
	if (!gladLoadGL()) {
		return -1;
	}

	/* Loop until the user closes the window */
	while (!glfwWindowShouldClose(window))
	{
		/* Render here */
		glClear(GL_COLOR_BUFFER_BIT);
		/* Swap front and back buffers */
		glfwSwapBuffers(window);

		/* Poll for and process events */
		glfwPollEvents();
	}

	glfwTerminate();
	return 0;
}
上一篇:OpenGL GLFW入门篇 - 画矩形2


下一篇:OpenGL超级宝典(第7版)笔记1 清单的初始环境配置part1