其他分享
首页 > 其他分享> > GLFW 环境如何配置?

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;
}

标签:return,配置,环境,window,GLFW,https,NULL,glad
来源: https://www.cnblogs.com/cheungxiongwei/p/14481713.html