Keyboarder
Topic Author
Posts: 21
Joined: 21 Oct 2014, 11:57

Re: c++ initialization

18 Jan 2017, 15:42

We are trying to make NoesisGui wrapper for Qt now and got into a problem.
The test wrapper is being built upon Qt OpenGL example code: https://doc.qt.io/qt-5/qtgui-openglwindow-example.html.
The app runs with very high CPU usage and crashes when closing. Do you have any suggestions on how to overcome this problem?
// NoesisGUI v1.3.0b4
// main.cpp
QGuiApplication a(argc, argv);
Noesis::GUI::Init(...);

QNoesisWindow w;
w.show();
a.exec();


//QNoesisWIndow.h
class QNoesisWindow : public OpenGLWindow ...

// QNoesisWIndow.cpp
QNoesisWindow::~QNoesisWindow() // Problem
{
    m_view.Reset();   // Crashes or does not finish with high CPU usage
    Noesis::GUI::Shutdown();
}


QNoesisWindow::QNoesisWindow(QWindow* parent): OpenGLWindow(parent), m_frame(0)
{
    setAnimating(true);
    Noesis::GUI::SetResourceProvider("Data");
    m_root = Noesis::GUI::LoadXaml<Noesis::UserControl>("test.xaml");
    m_view = Noesis::GUI::CreateView(m_root.GetPtr());
    m_view->SetAntialiasingMode(Noesis::Gui::AntialiasingMode_PPAA);
    m_view->SetSize(this->width(), this->height());
}

void QNoesisWindow::initialize()
{
    Noesis::Core::Ptr<GLRenderDevice> device = *new GLRenderDevice();
    Noesis::Core::Ptr<Noesis::VGContext> context = Noesis::GUI::CreateVGContext(device.GetPtr(), Noesis::VGOptions());

    m_view->GetRenderer()->Init(context.GetPtr());

      .....
}

void QNoesisWindow::render()
{
    m_view->Update(m_frame / screen()->refreshRate());

    Noesis::IRenderer* renderer = m_view->GetRenderer();
    renderer->UpdateRenderTree();

    if (renderer->NeedsOffscreen()) {
        renderer->RenderOffscreen();
    }

    glColorMask(true, true, true, true);
    glClearStencil(0);
    glClear(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);

    const qreal retinaScale = devicePixelRatio();
    glViewport(0, 0, width() * retinaScale, height() * retinaScale);

    renderer->Render();  // high CPU usage (qt runs it in main thread)
    m_frame++;
}

 
User avatar
jsantos
Site Admin
Posts: 3918
Joined: 20 Jan 2012, 17:18
Contact:

Re: c++ initialization

19 Jan 2017, 05:45

Can we please move to a new thread?

Also I need more information about the crash. Is the rendering output correct?

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot] and 10 guests