Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Qt3D shows blank screen on Android device
Forum Updated to NodeBB v4.3 + New Features

Qt3D shows blank screen on Android device

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
1 Posts 1 Posters 485 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    tech2nick
    wrote on last edited by tech2nick
    #1

    Hi guys,
    I'm working on Augmented Reality mobile app on Android. I wanted to use some 3d models in it, so I decided to use Qt. I used one of the examples embedded in QtCreator, namely "Scene3D QML Example" It works perfectly on PC, while on Android phone it shows only blank screen. Other QML apps (which don't use Qt3D) works without problems on my phone. Have anyone encountered such problem? I don't know wheter there's something wrong with my phone or just my Qt? I have Android 4.4 on my phone.

    Edit: I tried another example: "Cube", which uses pure C++ and OpenGL ES and it works well. So probably the problem lies in QML with Qt3D?

    Here's my code:

    • main.cpp
    #include <QGuiApplication>
    #include <QQuickView>
    
    int main(int argc, char **argv)
    {
        QGuiApplication app(argc, argv);
    
        QQuickView view;
    
        view.resize(500, 500);
        view.setResizeMode(QQuickView::SizeRootObjectToView);
        view.setSource(QUrl("qrc:/main.qml"));
        view.show();
    
        return app.exec();
    }
    
    
    • main.qml
    import QtQuick 2.0
    import QtQuick.Scene3D 2.0
    
    Item {
        Text {
            text: "Click me!"
            anchors.top: parent.top
            anchors.topMargin: 10
            anchors.horizontalCenter: parent.horizontalCenter
    
            MouseArea {
                anchors.fill: parent
                onClicked: animation.start()
            }
        }
    
        Text {
            text: "Multisample: " + scene3d.multisample
            anchors.bottom: parent.bottom
            anchors.bottomMargin: 10
            anchors.horizontalCenter: parent.horizontalCenter
    
            MouseArea {
                anchors.fill: parent
                onClicked: scene3d.multisample = !scene3d.multisample
            }
        }
    
        Rectangle {
            id: scene
            anchors.fill: parent
            anchors.margins: 50
            color: "darkRed"
    
            transform: Rotation {
                id: sceneRotation
                axis.x: 1
                axis.y: 0
                axis.z: 0
                origin.x: scene.width / 2
                origin.y: scene.height / 2
            }
    
            Scene3D {
                id: scene3d
                anchors.fill: parent
                anchors.margins: 10
                focus: true
                aspects: ["input", "logic"]
                cameraAspectRatioMode: Scene3D.AutomaticAspectRatio
    
                AnimatedEntity {}
            }
        }
    
        SequentialAnimation {
            id: animation
    
            RotationAnimation {
                to: 45
                duration: 1000
                target: sceneRotation
                property: "angle"
                easing.type: Easing.InOutQuad
            }
            PauseAnimation { duration: 500 }
            NumberAnimation {
                to: 0.5
                duration: 1000
                target: scene
                property: "scale"
                easing.type: Easing.OutElastic
            }
            PauseAnimation { duration: 500 }
            NumberAnimation {
                to: 1.0
                duration: 1000
                target: scene
                property: "scale"
                easing.type: Easing.OutElastic
            }
            PauseAnimation { duration: 500 }
            RotationAnimation {
                to: 0
                duration: 1000
                target: sceneRotation
                property: "angle"
                easing.type: Easing.InOutQuad
            }
        }
    }
    
    
    • AnimatedEntity.qml
    import Qt3D.Core 2.0
    import Qt3D.Render 2.0
    import Qt3D.Input 2.0
    import Qt3D.Extras 2.0
    
    import QtQuick 2.0 as QQ2
    
    Entity {
        id: sceneRoot
    
        Camera {
            id: camera
            projectionType: CameraLens.PerspectiveProjection
            fieldOfView: 45
            nearPlane : 0.1
            farPlane : 1000.0
            position: Qt.vector3d( 0.0, 0.0, 40.0 )
            upVector: Qt.vector3d( 0.0, 1.0, 0.0 )
            viewCenter: Qt.vector3d( 0.0, 0.0, 0.0 )
        }
    
    
        components: [
            RenderSettings {
                activeFrameGraph: ForwardRenderer {
                    camera: camera
                    clearColor: "transparent"
                }
            },
            InputSettings { }
        ]
    
        PhongMaterial {
            id: material
        }
    
        TorusMesh {
            id: torusMesh
            radius: 5
            minorRadius: 1
            rings: 100
            slices: 20
        }
    
        Transform {
            id: torusTransform
            scale3D: Qt.vector3d(1.5, 1, 0.5)
            rotation: fromAxisAndAngle(Qt.vector3d(1, 0, 0), 45)
        }
    
        Entity {
            id: torusEntity
            components: [ torusMesh, material, torusTransform ]
        }
    
        SphereMesh {
            id: sphereMesh
            radius: 3
        }
    
        Transform {
            id: sphereTransform
            property real userAngle: 0.0
            matrix: {
                var m = Qt.matrix4x4();
                m.rotate(userAngle, Qt.vector3d(0, 1, 0))
                m.translate(Qt.vector3d(20, 0, 0));
                return m;
            }
        }
    
        QQ2.NumberAnimation {
            target: sphereTransform
            property: "userAngle"
            duration: 10000
            from: 0
            to: 360
    
            loops: QQ2.Animation.Infinite
            running: true
        }
    
        Entity {
            id: sphereEntity
            components: [ sphereMesh, material, sphereTransform ]
        }
    }
    
    
    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved