diff --git a/src/game.h b/src/game.h index 2879e8e..a1a2dc0 100644 --- a/src/game.h +++ b/src/game.h @@ -17,8 +17,8 @@ * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ -#ifndef TORUSCHESSTESTGAME_H -#define TORUSCHESSTESTGAME_H +#ifndef TORUSCHESSGAME_H +#define TORUSCHESSGAME_H #include #include diff --git a/src/piecelibrary.cpp b/src/piecelibrary.cpp index be15397..ff0e132 100644 --- a/src/piecelibrary.cpp +++ b/src/piecelibrary.cpp @@ -25,8 +25,6 @@ #include #include -#include - namespace toruschess { typedef Lib3dsBool (*Lib3dsIoErrorFunc)(void *self); typedef long (*Lib3dsIoSeekFunc)(void *self, long offset, Lib3dsIoSeek origin); @@ -117,7 +115,7 @@ typedef size_t (*Lib3dsIoWriteFunc)(void *self, const void *buffer, size_t size) IO3ds io(data); Lib3dsFile *f = lib3ds_file_new(); if (!lib3ds_file_read(f, io.io())) { - qDebug("data size: %i", (int) data.size()); +// qDebug("data size: %i", (int) data.size()); lib3ds_file_free(f); return NULL; } @@ -126,13 +124,13 @@ typedef size_t (*Lib3dsIoWriteFunc)(void *self, const void *buffer, size_t size) QByteArray loadResource(const QString &filename) { QResource res(filename); - qDebug("res size: %i", (int) res.size()); +// qDebug("res size: %i", (int) res.size()); return QByteArray((const char*) res.data(), (int) res.size()); } PieceLibrary::PieceLibrary(QObject *parent) - : QObject(parent), m_pieces(0), m_buffers(0) { + : QObject(parent), m_pieces(0), m_buffers(0), m_pawn_list(0) { m_board = new QImage*[2]; m_board[0] = new QImage(":/media/board2_white.png"); m_board[1] = new QImage(":/media/board2_dark.png"); @@ -142,6 +140,7 @@ typedef size_t (*Lib3dsIoWriteFunc)(void *self, const void *buffer, size_t size) PieceLibrary::~PieceLibrary() { if (m_pawn) lib3ds_file_free(m_pawn); + if (m_pawn_list) glDeleteLists(m_pawn_list, 1); delete [] m_pieces; delete [] m_buffers; delete [] m_board; @@ -190,9 +189,16 @@ typedef size_t (*Lib3dsIoWriteFunc)(void *self, const void *buffer, size_t size) void PieceLibrary::paint_pawn() { glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer(3,GL_FLOAT,0,m_pawn->meshes->pointL); - for (unsigned int i = 0; i < m_pawn->meshes->faces; i++) { - glNormal3fv(m_pawn->meshes->faceL[i].normal); - glDrawElements(GL_TRIANGLES, 3, GL_UNSIGNED_SHORT, m_pawn->meshes->faceL[i].points); + if (m_pawn_list) { + glCallList(m_pawn_list); + } else { + m_pawn_list = glGenLists(1); + if (m_pawn_list) glNewList(m_pawn_list, GL_COMPILE_AND_EXECUTE); + for (unsigned int i = 0; i < m_pawn->meshes->faces; i++) { + glNormal3fv(m_pawn->meshes->faceL[i].normal); + glDrawElements(GL_TRIANGLES, 3, GL_UNSIGNED_SHORT, m_pawn->meshes->faceL[i].points); + } + if (m_pawn_list) glEndList(); } glDisableClientState(GL_VERTEX_ARRAY); } diff --git a/src/piecelibrary.h b/src/piecelibrary.h index 4be4f9e..ff4dfe3 100644 --- a/src/piecelibrary.h +++ b/src/piecelibrary.h @@ -22,6 +22,7 @@ #include +#include #include /** @@ -60,6 +61,7 @@ namespace toruschess { int m_width, m_height; Lib3dsFile *m_pawn; + GLuint m_pawn_list; }; }