I' using debian linux,
the code is very simple
---------------globject.h------------------------
#ifndef __CLASSGLOBJECT
#define __CLASSGLOBJECT
#include <qgl.h>
class GLObject : public QGLWidget{
public:
GLObject(QWidget * p=0);
~GLObject();
GLuint createDL();
void draw();
};
#endif
---------------globject.cpp-------------------
#include "globject.h"
#include <qpainter.h>
GLObject::GLObject(QWidget * p) : QGLWidget(p){}
GLObject::~GLObject(){}
GLuint GLObject::createDL(){
GLuint index;
index=glGenLists(1);
glNewList(index, GL_COMPILE);
draw();
glEndList();
return index;
}
void GLObject::draw(){
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
//glColor(0.9f, 0.9f, 0.9f);
glBegin(GL_QUADS);
glVertex2f(-100.0f, 0.0f);
glVertex2f(-100.0f, 100.0f);
glVertex2f(0.0f, 100.0f);
glVertex2f(100.0f, -100.0f);
glEnd();
}
----------------------------aplication.cpp-----------------------------------------------
#include <qapplication.h>
#include <qpainter.h>
#include "globject.h"
int main(int argc, char **argv){
QApplication a(argc, argv);
GLObject glObject;
a.setMainWidget(&glObject);
glObject.show();
return a.exec();
}
--------------------------------and these are the error
messages-------------------------------------
compiling using : qmake -project && qmake && make
g++ -c -pipe -Wall -W -O2 -DQT_NO_DEBUG -DQT_SHARED
-DQT_THREAD_SUPPORT -I/usr/share/qt3/mkspecs/default -I. -I.
-I/usr/include/qt3 -o aplication.o aplication.cpp
g++ -c -pipe -Wall -W -O2 -DQT_NO_DEBUG -DQT_SHARED
-DQT_THREAD_SUPPORT -I/usr/share/qt3/mkspecs/default -I. -I.
-I/usr/include/qt3 -o globject.o globject.cpp
g++ -o cg aplication.o globject.o -L/usr/share/qt3/lib
-L/usr/X11R6/lib -lqt-mt -lXext -lX11 -lm
globject.o(.text+0x141): In function `GLObject::createDL()':
: undefined reference to `glGenLists'
globject.o(.text+0x154): In function `GLObject::createDL()':
: undefined reference to `glNewList'
globject.o(.text+0x164): In function `GLObject::createDL()':
: undefined reference to `glEndList'
globject.o(.text+0x1a6): In function `GLObject::draw()':
: undefined reference to `glClear'
globject.o(.text+0x1b2): In function `GLObject::draw()':
: undefined reference to `glBegin'
globject.o(.text+0x1be): In function `GLObject::draw()':
: undefined reference to `glVertex2f'
globject.o(.text+0x1ca): In function `GLObject::draw()':
: undefined reference to `glVertex2f'
globject.o(.text+0x1d6): In function `GLObject::draw()':
: undefined reference to `glVertex2f'
globject.o(.text+0x1e2): In function `GLObject::draw()':
: undefined reference to `glVertex2f'
globject.o(.text+0x1f3): In function `GLObject::draw()':
: undefined reference to `glEnd'
collect2: ld returned 1 exit status
make: *** [cg] Error 1