freeglut.ext中的函数不能调用的问题
#include<iostream>
#include<gl/glew.h>
#define GLUT_DISABLE_ATEXIT_HACK
#include<gl/glut.h>
#include<gl/freeglut_ext.h>
#include<gl/freeglut.h>
#pragma comment(lib, "glut32.lib")
#pragma comment(lib, "opengl32.lib")
#pragma comment(lib, "freeglut_static.lib")
#pragma comment(lib, "freeglut.lib")
#pragma comment(lib, "glew32.lib")
using namespace std;
GLuint VAOs[1];
GLuint Buffers[1];
void init()
{
glGenVertexArrays(0, VAOs);
glBindVertexArray(VAOs[0]);
GLfloat vertices[6][2] = {
{-0.90, -0.90},
{ 0.85, -0.90},
{-0.90, 0.85},
{ 0.90, -0.85},
{ 0.90, 0.90},
{-0.85, 0.90},
};
glGenBuffers(1, Buffers);
glBindBuffer(GL_ARRAY_BUFFER,Buffers[0]);
glBufferData(GL_ARRAY_BUFFER,sizeof(vertices),vertices,GL_STATIC_DRAW);
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, 0);
glEnableVertexAttribArray(0);
glBindVertexArray(0);
}
void display()
{
glClear(GL_COLOR_BUFFER_BIT);
glBindVertexArray(VAOs[0]);
glDrawArrays(GL_TRIANGLES, 0, 6);
glFlush();
glBindVertexArray(0);
}
int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGBA);
glutInitWindowSize(512,512);
glutInitContextVersion(4,3);
glutInitContextProfile(GLUT_CORE_PROFILE);
glutCreateWindow(argv[0]);
if(glewInit()){
cerr<<"Unable to initialize GLEW..."<<endl;
exit(EXIT_FAILURE);
}
init();
glutDisplayFunc(display);
glutMainLoop();
}
因为遇到了freeglut库的链接问题,所以代码前加了
#define GLUT_DISABLE_ATEXIT_HACK
以及
#pragma comment(lib, "glut32.lib")
#pragma comment(lib, "opengl32.lib")
#pragma comment(lib, "freeglut_static.lib")
#pragma comment(lib, "freeglut.lib")
#pragma comment(lib, "glew32.lib")
但是即使这样,还是无法链接到freeglut_ext.h头文件里面的函数,报错如下:
1>Source.obj : error LNK2019: 无法解析的外部符号 __imp__glutInitContextVersion@8,该符号在函数 _main 中被引用
1>Source.obj : error LNK2019: 无法解析的外部符号 __imp__glutInitContextProfile@4,该符号在函数 _main 中被引用
1>E:\Project\VS\tem\Debug\tem.exe : fatal error LNK1120: 2 个无法解析的外部命令
我又试了一下freeeglut_ext.h下的其他函数,都是同样的错误。
freeglut库使用的3.0.0,配置应该没有问题,lib、dll和头文件都放好了。
哪位大侠能给点提示、 、不胜感激T^T
相关推荐
freeglut预编译版(头文件+lib+dll)
因为freeglut3.0之后没有再直接提供预编译版本的lib和dll,这是一个已经经过cmake编译好的windows平台下的freeglut的预编译内容,包含头文件,lib和dll,有debug版本和release版本两种
OpenGL工程实现实用教程4---freeglut库图片显示
利用OpenGL绘制OpenCV图像 方法一: #include<gl/glut.h> #include <opencv2/opencv.hpp> using namespace cv; Mat imgbgr; Mat imgbgra; void display(void) { //绘图,GL_BGRA_EXT表示输入图像格式为BGRA,也可是GL_BGR_EXT,则...
freeglut 2.8.0 (.h .lib .dll)
包含文件: freeglut.h freeglut_ext.h freeglut_std.h freeglut.lib freeglut.dll
freeglut_ext.h
freeglut_ext.h 1. Dynamic link library file (. DLL) glaux.dll, glu32.dll, glut32.dll, OPENGL32.DLL, glut.dll。 2. Header file (. H) GL.H, GLAUX.H, GLU.H, glut.h。 3. Library file (. LIB) GLAUX.LIB、Glu32.lib、glut32.lib、Opengl32.lib,glut.lib。
freeglut相关文件
提供freeglut相关的lib、dll以及头文件。最近版。


非技术区
