move GL::Widget to RNR::OgreWidget
This commit is contained in:
parent
2d63474c9f
commit
c8a41d027f
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -11,14 +11,14 @@
|
|||
|
||||
#include <GL/Adorn.hpp>
|
||||
|
||||
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;
|
||||
};
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
#include <GL/Widget.hpp>
|
||||
#include <OgreWidget.hpp>
|
||||
#include <QApplication>
|
||||
|
||||
#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;
|
||||
}
|
||||
|
|
@ -8,7 +8,7 @@
|
|||
#include <QToolBar>
|
||||
#include <QMenuBar>
|
||||
|
||||
#include <GL/Widget.hpp>
|
||||
#include <OgreWidget.hpp>
|
||||
|
||||
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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue