It’s not working. I’ll show my code. The namespace Lib3DSLoader have just some useful functions(I’m using qt and qmake). I’m just trying to learn how to use lib3ds:
#include "MyGLWidget.h"
#include "Lib3DSLoader.h"
#include <GL/gl.h>
#include <GL/glext.h>
#include <GL/glu.h>
MyGLWidget::MyGLWidget(const QString& file_to_open){
QString obj("Objeto");
this->file= new QString(file_to_open);
//Abrimos archivo
Lib3dsFile* tfile = Lib3DSLoader::loadFile( (this->file) );
//Cargamos la malla
Lib3dsMesh* object = Lib3DSLoader::getMesh(&obj, tfile);
//cargamos los vertices y los indices de caras
this->vertex = Lib3DSLoader::getMeshVertexs(object,&(this->nvert) );
this->faces = Lib3DSLoader::getMeshTriangles(object, &(this->nfaces) );
//borramos el archivo
Lib3DSLoader::deleteFile(tfile);
}
void MyGLWidget::initializeGL(){
glClearColor(0.0f, 0.0f, 0.0f,0.0f);
glShadeModel(GL_SMOOTH);
glEnable(GL_DEPTH_TEST);
glEnable(GL_CULL_FACE);
glCullFace(GL_BACK);
glGenBuffers(1,&(this->vbufferid));
glBindBuffer(GL_ARRAY_BUFFER, this->vbufferid);
glBufferData(GL_ARRAY_BUFFER, (this->nvert)*3*sizeof(GLfloat), this->vertex, GL_STATIC_DRAW);
}
void MyGLWidget::paintGL(){
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLooakAt(0,0,2, 0,0,0, 0,1,0);
glEnableClientState(GL_VERTEX_ARRAY);
glBindBuffer(GL_ARRAY_BUFFER, this->vbufferid);
glVertexPointer(3,GL_FLOAT,0,0);
glDrawElements( GL_TRIANGLES, this->nfaces, GL_UNSIGNED_SHORT, this->faces );
glDisableClientState(GL_VERTEX_ARRAY);
}
void MyGLWidget::resizeGL(int w, int h){
glViewport(0,0,w,h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0,(GLdouble)0.0,0.0, (GLdouble)h);
}
MyGLWidget::~MyGLWidget()
{
this->makeCurrent();
glDeleteBuffers(1, &(this->vbufferid));
delete [] this->vertex;
delete [] this->faces;
}
The *.pro file have QT += opengl, so that is not the problem. Here is the compiler output:
MyGLWidget.cc: In member function ‘virtual void MyGLWidget::initializeGL()’:
MyGLWidget.cc:37: error: ‘glGenBuffers’ was not declared in this scope
MyGLWidget.cc:39: error: ‘glBindBuffer’ was not declared in this scope
MyGLWidget.cc:40: error: ‘glBufferData’ was not declared in this scope
MyGLWidget.cc: In member function ‘virtual void MyGLWidget::paintGL()’:
MyGLWidget.cc:51: error: ‘gluLooakAt’ was not declared in this scope
MyGLWidget.cc:53: error: ‘glBindBuffer’ was not declared in this scope
MyGLWidget.cc: In destructor ‘virtual MyGLWidget::~MyGLWidget()’:
MyGLWidget.cc:77: error: ‘glDeleteBuffers’ was not declared in this scope