alexbcd
5th October 2010, 17:21
Hello,
I have started to develop a 3D viewer on a computer, and I would like to test it on another one. Both of them are under ubuntu lucid lynx. Unfortunately, on the second computer, the QGLWidget is blank. I have made up a minimal application that doesn't work neither on that second computer :
#ifndef GLVIEWER_H
#define GLVIEWER_H
#include <QtOpenGL/qgl.h>
class GLViewer : public QGLWidget {
public:
GLViewer(QWidget * parent = 0);
~GLViewer();
protected:
int viewport[4];
void initializeGL();
void resizeGL (int width, int height);
void paintGL();
};
#endif // GLVIEWER_H
and
#include "GLViewer.h"
GLViewer::GLViewer(QWidget * parent)
: QGLWidget(parent)
{
}
GLViewer::~GLViewer() {
}
void GLViewer::initializeGL() {
}
void GLViewer::resizeGL(int width, int height) {
viewport[0] = 0;
viewport[1] = 0;
viewport[2] = width;
viewport[3] = height;
glViewport(0, 0, width, height);
}
void GLViewer::paintGL() {
glClearColor(1,1,1,1);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-1.0, 1.0, -1.0, 1.0, 0, 1);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glColor3f(0.0f, 0.0f, 1.0f);
glBegin(GL_TRIANGLES);
glVertex3f(0,0,.5);
glVertex3f(0,1,.5);
glVertex3f(1,1,.5);
glEnd();
}
What it does is to draw a blank area in clearColor, but nothing else. It seems however that the Qt precompiled demo are working well with opengl. Where can the problem come from ?
I have started to develop a 3D viewer on a computer, and I would like to test it on another one. Both of them are under ubuntu lucid lynx. Unfortunately, on the second computer, the QGLWidget is blank. I have made up a minimal application that doesn't work neither on that second computer :
#ifndef GLVIEWER_H
#define GLVIEWER_H
#include <QtOpenGL/qgl.h>
class GLViewer : public QGLWidget {
public:
GLViewer(QWidget * parent = 0);
~GLViewer();
protected:
int viewport[4];
void initializeGL();
void resizeGL (int width, int height);
void paintGL();
};
#endif // GLVIEWER_H
and
#include "GLViewer.h"
GLViewer::GLViewer(QWidget * parent)
: QGLWidget(parent)
{
}
GLViewer::~GLViewer() {
}
void GLViewer::initializeGL() {
}
void GLViewer::resizeGL(int width, int height) {
viewport[0] = 0;
viewport[1] = 0;
viewport[2] = width;
viewport[3] = height;
glViewport(0, 0, width, height);
}
void GLViewer::paintGL() {
glClearColor(1,1,1,1);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-1.0, 1.0, -1.0, 1.0, 0, 1);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glColor3f(0.0f, 0.0f, 1.0f);
glBegin(GL_TRIANGLES);
glVertex3f(0,0,.5);
glVertex3f(0,1,.5);
glVertex3f(1,1,.5);
glEnd();
}
What it does is to draw a blank area in clearColor, but nothing else. It seems however that the Qt precompiled demo are working well with opengl. Where can the problem come from ?