[osg-users] OSG with Qt on Android fails to render anything
Raymond de Vries
reedev at xs4all.nl
Mon Oct 24 02:18:36 PDT 2016
Hi Andrea,
One question/test: have you been able to run osgviewerQt on Windows for
instance? Usually, I need to patch src/osgQt/GraphicsWindowQt.cpp in 2
locations in order to prevent illegal values for scaled_width and/or
scaled_height:
void GLWidget::resizeEvent( QResizeEvent* event )
{
const QSize& size = event->size();
int scaled_width = static_cast<int>(size.width()*_devicePixelRatio);
int scaled_height = static_cast<int>(size.height()*_devicePixelRatio);
if (scaled_width <= 0 || scaled_height <= 0)
return;
_gw->resized( x(), y(), scaled_width, scaled_height);
_gw->getEventQueue()->windowResize( x(), y(), scaled_width,
scaled_height );
_gw->requestRedraw();
}
void GLWidget::moveEvent( QMoveEvent* event )
{
const QPoint& pos = event->pos();
int scaled_width = static_cast<int>(width()*_devicePixelRatio);
int scaled_height = static_cast<int>(height()*_devicePixelRatio);
if (scaled_width <= 0 || scaled_height <= 0)
return;
_gw->resized( pos.x(), pos.y(), scaled_width, scaled_height );
_gw->getEventQueue()->windowResize( pos.x(), pos.y(),
scaled_width, scaled_height );
}
Without these checks nothing is rendered. Maybe this is the case for
Android too?
hth,
Raymond
On 10/24/2016 11:11 AM, Andrea Bracci wrote:
> Hi,
>
> I'm trying to run a simple application using OSG + Qt on Android.
>
> I have successfully built OSG Release 3.4.0 for Android (armeabi-v7a) and it successfully runs on Android as expected (I have run the example osgAndroidExampleGLES2 and it runs flawlessly). I have also successfully built osgQt for my Qt version 5.7.0, as well as the osgViewerQt example for Android armeabi-v7a.
>
> However if I run osgviewerQt on my Android device (version 5.0.2, API 21) it fails to render anything, in a way similar to what I found at the following link:
>
> http://lists.qt-project.org/pipermail/interest/2015-July/017869.html
>
> In order to simplify the application I allocate a single QWidget (instead of the four ones contained in the original osgviewerQt example) loading a single osg::Node* from a file cessna.osg. I have verified that the cessna.osg file is successfully loaded through a qDebug() logging message on the value of the loaded pointer. On my Android device I see the OSG-default blue screen without any object.
>
> As an additional information: I have successfully built and executed the Qt examples with OpenGLES on my Android device.
>
> I have done an extensive web search but I didn't find the solution to my problem, nor anyone that successfully ran OSG + Qt on Android.
>
> Can anyone tell me where am I wrong, or what steps shall I follow to make my OSG+Qt application to work on Android?
>
> Thank you in advance for your kind replies!
>
> Cheers,
> Andrea
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=69134#69134
>
>
>
>
>
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
More information about the osg-users
mailing list