qwzm: Add more error reporting

git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@6232 4a71c877-e1ca-e34f-864e-861f7616d084
master
Per Inge Mathisen 2008-11-01 20:57:43 +00:00
parent b32d3eaa76
commit 232629a685
2 changed files with 24 additions and 8 deletions

View File

@ -35,17 +35,13 @@ QWzmViewer::QWzmViewer(QWidget *parent)
connect(comboBoxTeam, SIGNAL(currentIndexChanged(int)), this, SLOT(toggleTeam(int)));
// Set defaults
toggleCulling();
toggleAnimation();
toggleWireframe();
timer->start(10); // 10 fps, which is more than enough!
timer->start(100); // 10 fps, which is more than enough!
}
QWzmViewer::~QWzmViewer()
{
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
}
void QWzmViewer::toggleTeam(int index)

View File

@ -18,10 +18,24 @@
#include "wzmglwidget.h"
#define gl_errors() really_report_gl_errors(__FILE__, __LINE__)
static void really_report_gl_errors (const char *file, int line)
{
GLenum error = glGetError();
if (error != GL_NO_ERROR)
{
qFatal("Oops, GL error caught: %s %s:%i", gluErrorString(error), file, line);
}
}
WZMOpenGLWidget::WZMOpenGLWidget(QWidget *parent)
: QGLWidget(parent)
{
animation = false;
dimension = 0.0;
psModel = NULL;
teamIndex = 0;
if (!QGLFormat::hasOpenGL())
{
qWarning("This system has no OpenGL support!");
@ -32,6 +46,8 @@ WZMOpenGLWidget::WZMOpenGLWidget(QWidget *parent)
WZMOpenGLWidget::~WZMOpenGLWidget()
{
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
freeModel(psModel);
}
@ -51,7 +67,7 @@ void WZMOpenGLWidget::initializeGL()
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
gl_errors();
}
void WZMOpenGLWidget::resizeGL(int w, int h)
@ -64,6 +80,7 @@ void WZMOpenGLWidget::resizeGL(int w, int h)
glViewport(0, 0, w, h);
gluPerspective(45.0f, aspect, 0.1f, 500.0f);
gl_errors();
}
void WZMOpenGLWidget::paintGL()
@ -71,7 +88,8 @@ void WZMOpenGLWidget::paintGL()
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(0.0f, -30.0f, -50.0f + -(dimension * 2.0f));;
glTranslatef(0.0f, -40.0f, -50.0f + -(dimension * 2.0f));;
gl_errors();
if (psModel)
{
int now = timer.elapsed();
@ -102,6 +120,7 @@ void WZMOpenGLWidget::paintGL()
drawModel(psModel, QTime::currentTime().elapsed());
}
gl_errors();
}
void WZMOpenGLWidget::setTeam(int index)
@ -135,12 +154,13 @@ void WZMOpenGLWidget::setAnimation(bool value)
void WZMOpenGLWidget::setModel(MODEL *model)
{
psModel = model;
if (!model)
{
return;
}
prepareModel(model);
gl_errors();
psModel = model;
// Calculate best z offset
for (int i = 0; i < psModel->meshes; i++)