OpenGL 2.1 headers Ubuntu

I’ve just install an nvidia card in my CPU, an nvidia Geforce 7300 GT. I use Ubuntu Feisty Fawn. Compiz Fusion works fine. ALso I have this output:

#glxinfo | grep version
server glx version string: 1.4
client glx version string: 1.4
GLX version: 1.3
OpenGL version string: 2.1.0 NVIDIA 96.31

Everything looks fine!

The problem is when I try to compile a program ising VBO I have the output GLgenBuffers don’t found. I’ve check GL/gl.h and there is just 1.1 API. Whick packages do I need to download?

You need to include GL/glext.h as well. GL/gl.h only has the features that are core to all Linux OGL implementations - namely, the 1.1 API. Everything else is in GL/glext.h

I don’t know for Linux but on Windows you need something like GLEW to access features beyound version 1.1. AFAIK GLEW also works on Linux and maybe other OSes.

[ www.trenki.net | vector_math (3d math library) | software renderer ]

:frowning: 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

Hey it works! The trick is add <GL/glew.h> before(BEFORE) <QGLWidget> in the header file. But I think this will make compilation slow right? Any other way?:S

this will make compilation slow right?
No, what makes you think it will ???

I mean, I had to add <GL/glew> to <MyGLWidget.h>, so every time I need <MyGLWidget.h> the compiler will parse <glew.h> too, every time, and will be propagated. It seems than QGLWidget makes an #include <GL/gl.h>, but glew have to be added first.

There is another problem :frowning: . After I compiled I have to solve another problems with lib3ds. They are soled. So I wanted to make the full test and I have a wear result, a core dumped. Then i put debug messages and… the core dump happens in glGenBuffers :S. Now I remember I had the same problem when once I tried to use glew. I’m linking incorecctly? This is my *.pro file (qmake):

######################################################################

Automatically generated by qmake (2.01a) Fri Aug 31 13:35:48 2007

######################################################################

TEMPLATE = app
TARGET =
DEPENDPATH += .
INCLUDEPATH += /usr/share/doc/nvidia-glx-dev/include/

LIBS += -L/usr/X11R6/lib/ -lGL -lGLEW -l3ds
QT += opengl

Input

HEADERS += Lib3DSLoader.h MyGLWidget.h
SOURCES += Lib3DSLoader.cc MyGLWidget.cc Test.cc

Oh I’m sorry, everything was solved, I just forget to call glewInit().

Thank you so much guys!

Muchas gracias!

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.