1 /**************************************************************************** 2 3 Copyright (C) 2002-2014 Gilles Debunne. All rights reserved. 4 5 This file is part of the QGLViewer library version 2.7.2. 6 7 http://www.libqglviewer.com - contact@libqglviewer.com 8 9 This file may be used under the terms of the GNU General Public License 10 versions 2.0 or 3.0 as published by the Free Software Foundation and 11 appearing in the LICENSE file included in the packaging of this file. 12 In addition, as a special exception, Gilles Debunne gives you certain 13 additional rights, described in the file GPL_EXCEPTION in this package. 14 15 libQGLViewer uses dual licensing. Commercial/proprietary software must 16 purchase a libQGLViewer Commercial License. 17 18 This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 19 WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 20 21 *****************************************************************************/ 22 23 #ifndef GLVIEW_H 24 #define GLVIEW_H 25 26 #include "jeu.h" 27 #include "piece.h" 28 #include <QGLViewer/qglviewer.h> 29 #include <iostream> 30 #include <qgl.h> 31 32 /* 33 * Classe generique pour les fenetres OpenGl 34 */ 35 class GLView : public QGLViewer { 36 Q_OBJECT 37 public: GLView(QWidget * parent)38 GLView(QWidget *parent) : QGLViewer(parent) {} 39 40 virtual void init(); setPieces(SetOfPiece * sop)41 virtual void setPieces(SetOfPiece *sop) { setofpiece = sop; }; 42 43 Q_SIGNALS: 44 void update(); 45 46 protected: 47 virtual void select(const QMouseEvent *e); drawWithId()48 virtual void drawWithId(){}; applySelection(int)49 virtual void applySelection(int){}; keyPressEvent(QKeyEvent *)50 virtual void keyPressEvent(QKeyEvent *){}; 51 52 SetOfPiece *setofpiece; 53 54 private: 55 GLuint texture_bois; 56 }; 57 58 // Classe fille pour la vue des pieces a selectionner 59 class GLViewPieces : public GLView { 60 Q_OBJECT 61 public: GLViewPieces(QWidget * parent)62 GLViewPieces(QWidget *parent) : GLView(parent) {} 63 64 protected: 65 virtual void draw(); 66 virtual void init(); 67 drawWithId()68 virtual void drawWithId() { draw(); }; 69 virtual void applySelection(int); 70 71 Q_SIGNALS: 72 void changeJoueur(); 73 }; 74 75 // Classe fille pour la vue du plateau de jeu 76 class GLViewJeu : public GLView { 77 Q_OBJECT 78 79 public: GLViewJeu(QWidget * parent)80 GLViewJeu(QWidget *parent) : GLView(parent) {} ~GLViewJeu()81 ~GLViewJeu() { glDeleteLists(plateau, 1); } 82 reset()83 void reset() { jeu.init(); } 84 85 protected: 86 virtual void draw(); 87 virtual void init(); 88 89 virtual void drawWithId(); 90 virtual void applySelection(int); 91 92 Q_SIGNALS: 93 void piecePlacee(); 94 void endGame(); 95 96 private: 97 GLuint plateau; 98 Jeu jeu; 99 100 void makePlateau(); 101 }; 102 103 #endif // GLVIEW_H 104