From c8a41d027f459a34cc209fe40f22950b75f3a561 Mon Sep 17 00:00:00 2001 From: rjindael Date: Mon, 10 Jul 2023 02:47:28 -0700 Subject: [PATCH] move GL::Widget to RNR::OgreWidget --- CMakeLists.txt | 2 +- Projects/Client/Common/CMakeLists.txt | 4 +-- .../Header/{GL/Widget.hpp => OgreWidget.hpp} | 7 +++-- .../Source/{GL/Widget.cpp => OgreWidget.cpp} | 31 ++++++++++--------- Projects/Client/Studio/Header/MainWindow.hpp | 5 +-- Projects/Client/Studio/Source/MainWindow.cpp | 4 +-- Projects/Client/Studio/Source/main.cpp | 8 ++--- 7 files changed, 32 insertions(+), 29 deletions(-) rename Projects/Client/Common/Header/{GL/Widget.hpp => OgreWidget.hpp} (88%) rename Projects/Client/Common/Source/{GL/Widget.cpp => OgreWidget.cpp} (87%) diff --git a/CMakeLists.txt b/CMakeLists.txt index b751415..e2a0c97 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,7 +9,7 @@ option(COMPILE_STUDIO "Compile the RNR studio" ON) option(COMPILE_SERVER "Compile the RNR server" ON) set(DEPENDENCIES_DIR ${CMAKE_SOURCE_DIR}/Dependencies) -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-attributes") # Ignore attribute warnings generated by Luau +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-attributes -Wno-return-type") # Ignore warnings generated by Luau and Qt find_package(Boost REQUIRED) find_package(cglm REQUIRED CONFIG) diff --git a/Projects/Client/Common/CMakeLists.txt b/Projects/Client/Common/CMakeLists.txt index a27d0d0..df06748 100644 --- a/Projects/Client/Common/CMakeLists.txt +++ b/Projects/Client/Common/CMakeLists.txt @@ -6,10 +6,10 @@ qt_standard_project_setup() qt_add_library(Common STATIC Header/GL/Adorn.hpp Header/GL/RenderContext.hpp - Header/GL/Widget.hpp + Header/OgreWidget.hpp Source/GL/Adorn.cpp - Source/GL/Widget.cpp + Source/OgreWidget.cpp ) target_include_directories(Common PUBLIC Header) diff --git a/Projects/Client/Common/Header/GL/Widget.hpp b/Projects/Client/Common/Header/OgreWidget.hpp similarity index 88% rename from Projects/Client/Common/Header/GL/Widget.hpp rename to Projects/Client/Common/Header/OgreWidget.hpp index 8358f3d..e0b32ca 100644 --- a/Projects/Client/Common/Header/GL/Widget.hpp +++ b/Projects/Client/Common/Header/OgreWidget.hpp @@ -11,14 +11,14 @@ #include -namespace GL +namespace RNR { - class Widget : public QWidget + class OgreWidget : public QWidget { Q_OBJECT public: - Widget(Ogre::Root *root, QWidget* parent = nullptr); + OgreWidget(Ogre::Root *root, QWidget* parent = nullptr); double delta; double render_time; @@ -42,6 +42,7 @@ namespace GL virtual void mouseMoveEvent(QMouseEvent *event); virtual void closeEvent(QCloseEvent* event); virtual QPaintEngine* paintEngine() const; + private: QElapsedTimer timer; }; diff --git a/Projects/Client/Common/Source/GL/Widget.cpp b/Projects/Client/Common/Source/OgreWidget.cpp similarity index 87% rename from Projects/Client/Common/Source/GL/Widget.cpp rename to Projects/Client/Common/Source/OgreWidget.cpp index 72f55d5..6d1f596 100644 --- a/Projects/Client/Common/Source/GL/Widget.cpp +++ b/Projects/Client/Common/Source/OgreWidget.cpp @@ -1,4 +1,4 @@ -#include +#include #include #ifdef __unix__ @@ -7,9 +7,9 @@ #endif // credits to https://github.com/Ekman/Qt-Ogre-Widget -namespace GL +namespace RNR { - Widget::Widget(Ogre::Root *root, QWidget *parent) : QWidget(parent) + OgreWidget::OgreWidget(Ogre::Root *root, QWidget *parent) : QWidget(parent) { this->ogreRoot = root; this->setMinimumSize(640, 480); @@ -22,7 +22,7 @@ namespace GL this->setFocusPolicy(Qt::StrongFocus); } - void Widget::initializeOgre() + void OgreWidget::initializeOgre() { Ogre::NameValuePairList options = this->getRenderOptions(); @@ -64,7 +64,7 @@ namespace GL this->render_time = 0.0; } - void Widget::render() + void OgreWidget::render() { this->delta = ogreRoot->getTimer()->getMicroseconds() / 1000000.0; this->render_time += ogreRoot->getTimer()->getMilliseconds() / 1000.0; @@ -75,7 +75,7 @@ namespace GL ogreRoot->renderOneFrame(this->delta); } - Ogre::NameValuePairList Widget::getRenderOptions() + Ogre::NameValuePairList OgreWidget::getRenderOptions() { Ogre::NameValuePairList options; @@ -88,7 +88,7 @@ namespace GL return options; } - Ogre::String Widget::getWindowHandle() + Ogre::String OgreWidget::getWindowHandle() { Ogre::String windowHandle; windowHandle = Ogre::StringConverter::toString((unsigned long)winId()); @@ -96,7 +96,7 @@ namespace GL return windowHandle; } - void Widget::resizeEvent(QResizeEvent *rEvent) + void OgreWidget::resizeEvent(QResizeEvent *rEvent) { QWidget::resizeEvent(rEvent); if(ogreWindow) @@ -106,20 +106,21 @@ namespace GL } } - void Widget::paintEvent(QPaintEvent *pEvent) + void OgreWidget::paintEvent(QPaintEvent *pEvent) + { + // + } + + void OgreWidget::mouseMoveEvent(QMouseEvent *mEvent) { } - void Widget::mouseMoveEvent(QMouseEvent *mEvent) - { - } - - void Widget::closeEvent(QCloseEvent* event) + void OgreWidget::closeEvent(QCloseEvent* event) { ogreWindow->destroy(); } - QPaintEngine *Widget::paintEngine() const + QPaintEngine* OgreWidget::paintEngine() const { return 0; } diff --git a/Projects/Client/Studio/Header/MainWindow.hpp b/Projects/Client/Studio/Header/MainWindow.hpp index 9a19fb8..7b42c0e 100644 --- a/Projects/Client/Studio/Header/MainWindow.hpp +++ b/Projects/Client/Studio/Header/MainWindow.hpp @@ -8,7 +8,7 @@ #include #include -#include +#include class MainWindow : public QMainWindow { @@ -18,13 +18,14 @@ class MainWindow : public QMainWindow MainWindow(); Ogre::Root* ogreRoot; - GL::Widget* widget; + RNR::OgreWidget* ogreWidget; QTreeWidget* explorer; QToolBar* toolbar; QMenuBar* menubar; void createToolbar(); void updateTree(RNR::Instance* root_instance); + protected: void recurseTreeAddInstance(QTreeWidgetItem* parent, RNR::Instance* instance); void closeEvent(QCloseEvent* event); diff --git a/Projects/Client/Studio/Source/MainWindow.cpp b/Projects/Client/Studio/Source/MainWindow.cpp index 16fc658..83073a3 100644 --- a/Projects/Client/Studio/Source/MainWindow.cpp +++ b/Projects/Client/Studio/Source/MainWindow.cpp @@ -25,8 +25,8 @@ MainWindow::MainWindow() createToolbar(); - this->widget = new GL::Widget(ogreRoot); - grid->addWidget(this->widget, 2, 0, 1, 2); + this->ogreWidget = new RNR::OgreWidget(ogreRoot); + grid->addWidget(this->ogreWidget, 2, 0, 1, 2); explorer = new QTreeWidget(); grid->addWidget(explorer, 2, 2, 1, 1); diff --git a/Projects/Client/Studio/Source/main.cpp b/Projects/Client/Studio/Source/main.cpp index 899779e..8bd7785 100644 --- a/Projects/Client/Studio/Source/main.cpp +++ b/Projects/Client/Studio/Source/main.cpp @@ -18,18 +18,18 @@ int main(int argc, char** argv) MainWindow window = MainWindow(); window.show(); - window.widget->initializeOgre(); + window.ogreWidget->initializeOgre(); RNR::World* world = new RNR::World(); window.updateTree(world->getDatamodel()); while (window.isVisible()) { - window.statusBar()->showMessage(QString::asprintf("Dt=%f, Rt=%f", window.widget->delta, window.widget->render_time)); + window.statusBar()->showMessage(QString::asprintf("Dt=%f, Rt=%f", window.ogreWidget->delta, window.ogreWidget->render_time)); app.processEvents(); - window.widget->render(); + window.ogreWidget->render(); world->preStep(); - world->step(window.widget->delta); + world->step(window.ogreWidget->delta); world->update(); } } \ No newline at end of file