RioEngine  0.1
My first attempt to create a 3D WYSIWYG Game Engine
qgamewindow.cpp
Go to the documentation of this file.
1 //--------------------------------------------------------------- @License begins
2 // RioEngine: The late night Coke -without whores- debugging sessions
3 // 2012-2015 Leopoldo Lomas Flores. Torreon, Coahuila. MEXICO
4 // leopoldolomas [at] gmail
5 // www.rioengine.com
6 // www.leopoldolomas.info
7 // "You have a problem, you face it like a man."
8 //
9 // This is free and unencumbered software released into the public domain.
10 //
11 // Anyone is free to copy, modify, publish, use, compile, sell, or distribute this
12 // software, either in source code form or as a compiled binary, for any purpose,
13 // commercial or non-commercial, and by any means.
14 //
15 // In jurisdictions that recognize copyright laws, the author or authors of this
16 // software dedicate any and all copyright interest in the software to the public
17 // domain. We make this dedication for the benefit of the public at large and to
18 // the detriment of our heirs and successors. We intend this dedication to be
19 // an overt act of relinquishment in perpetuity of all present and future
20 // rights to this software under copyright law.
21 //
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS
24 // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE
25 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
26 // CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
27 // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 //--------------------------------------------------------------- @License ends
29 
30 #include <QBoxLayout>
31 #include <QTimer>
33 #include "cengine/cgamescene.h"
34 #include "cengine/cdirector.h"
36 #include "ui_qgamewindow.h"
37 #include "qgamewindow.h"
38 
39 //-----------------------------------------------------------------------------
40 
41 QGameWindow::QGameWindow(QWidget *parent,
42  CLScene* collada_scene,
43  CGameScene* game_scene,
44  QGLWidget* shared_widget) :
45  QMainWindow(parent),
46  m_ui(new Ui::QGameWindow) {
47  m_ui->setupUi(this);
48 
49  m_ui->actionWired->setEnabled(false); // not supported yet
50  m_ui->actionSolid->setEnabled(false); // not supported yet
51 
52  createGameViewport(collada_scene, shared_widget);
53 
54  m_timer = new QTimer(this);
55  connect(m_timer, SIGNAL(timeout()), this, SLOT(TimeOut()));
56  m_timer->start(17); // 60 fps
57 
58  CDIRECTOR->resume();
59 }
60 
61 //-----------------------------------------------------------------------------
62 
64  m_gameViewport->setDrawMode(draw_mode);
65  m_ui->actionWired->setChecked(draw_mode == WIRED);
66  m_ui->actionSolid->setChecked(draw_mode == SOLID);
67  m_ui->actionTextured->setChecked(draw_mode == TEXTURED);
68 }
69 
70 //-----------------------------------------------------------------------------
71 
72 void QGameWindow::createGameViewport(CLScene* collada_scene,
73  QGLWidget* shared_widget) {
74  m_gameViewport = new QGLGameViewport(collada_scene, shared_widget);
75  setCentralWidget(m_gameViewport);
76 }
77 
78 //-----------------------------------------------------------------------------
79 
80 void QGameWindow::updateGUIState() {
81 }
82 
83 //-----------------------------------------------------------------------------
84 
86  if (m_gameViewport) {
87  m_gameViewport->updateGL();
88  }
89 }
90 
91 //-----------------------------------------------------------------------------
92 
93 void QGameWindow::on_actionExit_triggered() {
94  close();
95 }
96 
97 //-----------------------------------------------------------------------------
98 
99 void QGameWindow::on_actionWired_triggered() {
101 }
102 
103 //-----------------------------------------------------------------------------
104 
105 void QGameWindow::on_actionSolid_triggered() {
107 }
108 
109 //-----------------------------------------------------------------------------
110 
111 void QGameWindow::on_actionTextured_triggered() {
113 }
114 
115 //-----------------------------------------------------------------------------
116 
117 void QGameWindow::on_actionFull_Screen_triggered(bool checked) {
118  if (checked) {
119  showFullScreen();
120  }
121  else {
122  showNormal();
123  }
124 }
125 
126 //-----------------------------------------------------------------------------
127 
128 void QGameWindow::closeEvent(QCloseEvent *) {
129  m_timer->stop();
130 }
131 
132 //-----------------------------------------------------------------------------
133 
135  SAFE_RELEASE(m_ui);
136 }
void setDrawMode(const QGLViewportDrawMode &value)
Definition: about.h:6
QGameWindow(QWidget *parent=0, CLScene *collada_scene=NULL, CGameScene *game_scene=NULL, QGLWidget *shared_widget=NULL)
Definition: qgamewindow.cpp:41
void TimeOut(void)
Definition: qgamewindow.cpp:85
void setDrawMode(QGLBaseViewport::QGLViewportDrawMode draw_mode)
Definition: qgamewindow.cpp:63
#define SAFE_RELEASE(x)
Definition: cobject.h:36
#define CDIRECTOR
Definition: cdirector.h:37