运行时出现如下错误:
Starting E:\Qt\OpenGL\QtOpenGL\VowelCube-build-desktop\debug\VowelCube.exe...
ASSERT: "d" in file ..\..\include/QtCore/../../src/corelib/tools/qscopedpointer.h, line 112
Invalid parameter passed to C runtime function.
Invalid parameter passed to C runtime function.
QWidget::repaint: Recursive repaint detected
ASSERT: "d" in file ..\..\include/QtCore/../../src/corelib/tools/qscopedpointer.h, line 112
Invalid parameter passed to C runtime function.
Invalid parameter passed to C runtime function.
E:\Qt\OpenGL\QtOpenGL\VowelCube-build-desktop\debug\VowelCube.exe exited with code 3
不知道到底出了什么问题,恳请各位高人指点迷津,在下感激不尽!
#ifndef VOWELCUBE_H
#define VOWELCUBE_H
#include <QtCore>
#include <QtGui>
#include <QtOpenGL>
class VowelCube : public QGLWidget
{
Q_OBJECT
public:
VowelCube(QWidget *parent = 0);
~VowelCube();
protected:
void paintEvent(QPaintEvent *e);
void mousePressEvent(QMouseEvent *e);
void mouseMoveEvent(QMouseEvent *e);
void wheelEvent(QWheelEvent *e);
private:
void createGradient();
void createGLObject();
void drawBackground(QPainter *painter);
void drawCube();
void drawLegend(QPainter *painter);
GLuint glObject;
QRadialGradient gradient;
GLfloat xrot, yrot, zrot;
GLfloat scaling;
QPoint lastPos;
};
#endif // VOWELCUBE_H
#include <cmath>
#include "vowelcube.h"
#ifndef GL_MULTISAMPLE
#define GL_MULTISAMPLE 0x809D
#endif
VowelCube::VowelCube(QWidget *parent)
: QGLWidget(parent)
{
setFormat(QGLFormat(QGL::SampleBuffers));
xrot = -38.0;
yrot = -58.0;
zrot = 0.0;
scaling = 1.0;
createGradient();
createGLObject();
}
VowelCube::~VowelCube()
{
makeCurrent();
glDeleteLists(glObject, 1);
}
void VowelCube::paintEvent(QPaintEvent *e)
{
QPainter painter(this);
drawBackground(&painter);
drawCube();
drawLegend(&painter);
}
void VowelCube::mousePressEvent(QMouseEvent *e)
{
lastPos = e->pos();
}
void VowelCube::mouseMoveEvent(QMouseEvent *e)
{
GLfloat dx = GLfloat(e->x() - lastPos.x()) / width();
GLfloat dy = GLfloat(e->y() - lastPos.y()) / height();