opengl头文件引用错误

项目场景:

运行一个opengl的小程序


问题描述:

这个小程序的代码如下:

//#include "./lib/glfw32/GLFW/glfw3.h"
//#pragma comment (lib, "lib/glfw32/glfw3.lib")
//#pragma comment (lib, "lib/glew32/glew32d.lib")

//#include<GL/glut.h>
#include <GL/glfw3.h>

#pragma comment (lib, "D:/Program Files (x86)/Microsoft Visual Studio 12.0/VC/lib/glfw3.lib")
//#pragma comment (lib, "D:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\lib\glew32s.lib")
int main(void)
{
	GLFWwindow* window;

	/* Initialize the library */
	if (!glfwInit())
		return -1;

	/* Create a windowed mode window and its OpenGL context */
	window = glfwCreateWindow(480, 320, "Hello World", NULL, NULL);
	if (!window)
	{
		glfwTerminate();
		return -1;
	}

	/* Make the window's context current */
	glfwMakeContextCurrent(window);

	/* Loop until the user closes the window */
	while (!glfwWindowShouldClose(window))
	{
		/* Draw a triangle */
		glBegin(GL_TRIANGLES);

		glColor3f(1.0, 0.0, 0.0);    // Red
		glVertex3f(0.0, 1.0, 0.0);

		glColor3f(0.0, 1.0, 0.0);    // Green
		glVertex3f(-1.0, -1.0, 0.0);

		glColor3f(0.0, 0.0, 1.0);    // Blue
		glVertex3f(1.0, -1.0, 0.0);

		glEnd();

		/* Swap front and back buffers */
		glfwSwapBuffers(window);

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

	glfwTerminate();
	return 0;
}

运行之后报错:
在这里插入图片描述


原因分析:

找了属性配置,经过修改也还是报错.
最后想想有可能是缺小头文件的原因.


解决方案:

加了句

#include<GL/glut.h>

成功运行,debug和release都没问题
在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值