首页 > 其他 > 详细

GLFW 环境如何配置?

时间:2021-03-04 19:03:14      阅读:38      评论:0      收藏:0      [点我收藏+]

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

GLFW 环境如何配置?

原文:https://www.cnblogs.com/cheungxiongwei/p/14481713.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!