fix ebn warnings regarding includes
[kdegames.git] / kubrick / src / gameglview.h
blob4785d628f2634f95ce8d6d829b4c53338c12d58b
1 /*******************************************************************************
2 Copyright 2008 Ian Wadham <ianw2@optusnet.com.au>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 *******************************************************************************/
19 #ifndef GAMEGLVIEW_H
20 #define GAMEGLVIEW_H
22 // Qt includes
23 #include <QGLWidget>
24 #include <QMouseEvent>
26 // Local includes
27 #include "game.h"
28 #include "kbkglobal.h"
30 class Game; // Forward declaration of Game class.
32 /**
33 * Demonstrate the features of the Qt OpenGL
34 * view and OpenGL itself.
36 class GameGLView : public QGLWidget
38 Q_OBJECT
40 public:
41 /**
42 * Create a new GL view for the game
43 **/
44 GameGLView (Game * g, QWidget * parent = 0);
46 /**
47 * Dump all OpenGL and GLU extensions to stdout
48 **/
49 void dumpExtensions ();
51 void pushGLMatrix ();
52 void moveGLView (float xChange, float yChange, float zChange);
53 void rotateGLView (float degrees, float x, float y, float z);
54 void popGLMatrix ();
56 void drawACubie (float size, float centre[], int axis, int angle);
57 void finishCubie ();
58 void drawASticker (float size, int color, bool blinking,
59 int faceNormal[], float faceCentre []);
60 void setBlinkIntensity (float intensity);
62 QPoint getMousePosition ();
64 void setBevelAmount (int bevelPerCent);
66 protected:
67 /**
68 * Reimplemented to initialize the OpenGL context.
70 * This method is called automatically by Qt once.
72 virtual void initializeGL();
74 /**
75 * Called by Qt when the size of the GL view changes.
76 **/
77 virtual void resizeGL(int w, int h);
79 /**
80 * This method actually renders the scene. It is called automatically by Qt
81 * when paint events occur. A manual repaint (for example for animations) can
82 * be made by calling updateGL which also calls this method.
84 * Do not call this method directly!
85 **/
86 virtual void paintGL();
88 /**
89 * Handle mouse events. In these implementations, game->handleMouseEvent
90 * is called with event type, button, X co-ordinate and Y co-ordinate in
91 * OpenGL convention (zero at bottom of window).
92 **/
93 virtual void mousePressEvent (QMouseEvent* e);
94 virtual void mouseReleaseEvent (QMouseEvent* e);
96 /**
97 * Check for an OpenGL error. Dump any error to stdout
98 * @return true, if an error occured, otherwise false
99 **/
100 bool checkGLError();
102 private:
103 void turnOnLighting ();
105 Game * game;
106 float bevelAmount; // Fraction of bevelling on a cubie (eg. 0.1).
107 QColor bgColor; // Background color.
109 static float colors [7] [3];
110 float blinkIntensity;
113 #endif