qwzm: Add more error reporting
git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@6232 4a71c877-e1ca-e34f-864e-861f7616d084master
parent
b32d3eaa76
commit
232629a685
|
@ -35,17 +35,13 @@ QWzmViewer::QWzmViewer(QWidget *parent)
|
||||||
connect(comboBoxTeam, SIGNAL(currentIndexChanged(int)), this, SLOT(toggleTeam(int)));
|
connect(comboBoxTeam, SIGNAL(currentIndexChanged(int)), this, SLOT(toggleTeam(int)));
|
||||||
|
|
||||||
// Set defaults
|
// Set defaults
|
||||||
toggleCulling();
|
|
||||||
toggleAnimation();
|
toggleAnimation();
|
||||||
toggleWireframe();
|
|
||||||
|
|
||||||
timer->start(10); // 10 fps, which is more than enough!
|
timer->start(100); // 10 fps, which is more than enough!
|
||||||
}
|
}
|
||||||
|
|
||||||
QWzmViewer::~QWzmViewer()
|
QWzmViewer::~QWzmViewer()
|
||||||
{
|
{
|
||||||
glDisableClientState(GL_VERTEX_ARRAY);
|
|
||||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QWzmViewer::toggleTeam(int index)
|
void QWzmViewer::toggleTeam(int index)
|
||||||
|
|
|
@ -18,10 +18,24 @@
|
||||||
|
|
||||||
#include "wzmglwidget.h"
|
#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)
|
WZMOpenGLWidget::WZMOpenGLWidget(QWidget *parent)
|
||||||
: QGLWidget(parent)
|
: QGLWidget(parent)
|
||||||
{
|
{
|
||||||
|
animation = false;
|
||||||
|
dimension = 0.0;
|
||||||
psModel = NULL;
|
psModel = NULL;
|
||||||
|
teamIndex = 0;
|
||||||
if (!QGLFormat::hasOpenGL())
|
if (!QGLFormat::hasOpenGL())
|
||||||
{
|
{
|
||||||
qWarning("This system has no OpenGL support!");
|
qWarning("This system has no OpenGL support!");
|
||||||
|
@ -32,6 +46,8 @@ WZMOpenGLWidget::WZMOpenGLWidget(QWidget *parent)
|
||||||
|
|
||||||
WZMOpenGLWidget::~WZMOpenGLWidget()
|
WZMOpenGLWidget::~WZMOpenGLWidget()
|
||||||
{
|
{
|
||||||
|
glDisableClientState(GL_VERTEX_ARRAY);
|
||||||
|
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||||
freeModel(psModel);
|
freeModel(psModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,7 +67,7 @@ void WZMOpenGLWidget::initializeGL()
|
||||||
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||||
glEnableClientState(GL_VERTEX_ARRAY);
|
glEnableClientState(GL_VERTEX_ARRAY);
|
||||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||||
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
|
gl_errors();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WZMOpenGLWidget::resizeGL(int w, int h)
|
void WZMOpenGLWidget::resizeGL(int w, int h)
|
||||||
|
@ -64,6 +80,7 @@ void WZMOpenGLWidget::resizeGL(int w, int h)
|
||||||
glViewport(0, 0, w, h);
|
glViewport(0, 0, w, h);
|
||||||
|
|
||||||
gluPerspective(45.0f, aspect, 0.1f, 500.0f);
|
gluPerspective(45.0f, aspect, 0.1f, 500.0f);
|
||||||
|
gl_errors();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WZMOpenGLWidget::paintGL()
|
void WZMOpenGLWidget::paintGL()
|
||||||
|
@ -71,7 +88,8 @@ void WZMOpenGLWidget::paintGL()
|
||||||
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
|
||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
glLoadIdentity();
|
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)
|
if (psModel)
|
||||||
{
|
{
|
||||||
int now = timer.elapsed();
|
int now = timer.elapsed();
|
||||||
|
@ -102,6 +120,7 @@ void WZMOpenGLWidget::paintGL()
|
||||||
|
|
||||||
drawModel(psModel, QTime::currentTime().elapsed());
|
drawModel(psModel, QTime::currentTime().elapsed());
|
||||||
}
|
}
|
||||||
|
gl_errors();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WZMOpenGLWidget::setTeam(int index)
|
void WZMOpenGLWidget::setTeam(int index)
|
||||||
|
@ -135,12 +154,13 @@ void WZMOpenGLWidget::setAnimation(bool value)
|
||||||
|
|
||||||
void WZMOpenGLWidget::setModel(MODEL *model)
|
void WZMOpenGLWidget::setModel(MODEL *model)
|
||||||
{
|
{
|
||||||
psModel = model;
|
|
||||||
if (!model)
|
if (!model)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
prepareModel(model);
|
prepareModel(model);
|
||||||
|
gl_errors();
|
||||||
|
psModel = model;
|
||||||
|
|
||||||
// Calculate best z offset
|
// Calculate best z offset
|
||||||
for (int i = 0; i < psModel->meshes; i++)
|
for (int i = 0; i < psModel->meshes; i++)
|
||||||
|
|
Loading…
Reference in New Issue