I am not doing much of different that what is described in http://doc.qt.io/qt-5/qtquick-sceneg...l-example.html . Lets compare the sync() there and mine:
void Squircle::sync()
{
if (!m_renderer) {
m_renderer = new SquircleRenderer();
connect(window(), SIGNAL(beforeRendering()), m_renderer, SLOT(paint()), Qt::DirectConnection);
}
m_renderer->setViewportSize(window()->size() * window()->devicePixelRatio());
m_renderer->setT(m_t);
}
void Squircle::sync()
{
if (!m_renderer) {
m_renderer = new SquircleRenderer();
connect(window(), SIGNAL(beforeRendering()), m_renderer, SLOT(paint()), Qt::DirectConnection);
}
m_renderer->setViewportSize(window()->size() * window()->devicePixelRatio());
m_renderer->setT(m_t);
}
To copy to clipboard, switch view to plain text mode
Whereas I am doing the following:
void TriangleSceneItem::sync()
{
if(mScene)
{
connect(mTimer,SIGNAL(timeout()),this,SLOT(updateTime()),Qt::DirectConnection);
mScene->setViewportSize(window()->width() * window()->devicePixelRatio(),
window()->height() * window()->devicePixelRatio());
}
}
void TriangleSceneItem::sync()
{
if(mScene)
{
connect(mTimer,SIGNAL(timeout()),this,SLOT(updateTime()),Qt::DirectConnection);
mScene->setViewportSize(window()->width() * window()->devicePixelRatio(),
window()->height() * window()->devicePixelRatio());
}
}
To copy to clipboard, switch view to plain text mode
I am creating the timer for the animation and then setting the viewport size that is lated used during rendering. The renderer intialization is done inside the constructor.
Bookmarks