QML:unable to display 3D scene (scene flicker)

Viewed 130

I run the following code, Scene3D is flickering all time.

If I remove Pane,Scene does not flicker.

Here is what I have in application output window

07:05:10: Starting D:\api\qt\Examples\Qt-5.13.2\qt3d\build-scene3d-Desktop_Qt_5_13_2_MSVC2017_32bit-Debug\debug\scene3d.exe ...
QML debugging is enabled. Only use this in a safe environment.
qrc:/main.qml:83:9: QML Scene3D: Detected anchors on an item that is managed by a layout. This is undefined behavior; use Layout.alignment instead.
qrc:/main.qml:63: ReferenceError: tabBar is not defined
[opengl\qopenglframebufferobject.cpp line 607] OpenGL Error: 1281
QOpenGLFramebufferObject: Framebuffer incomplete attachment.
QOpenGLFramebufferObject: Framebuffer incomplete attachment.
QOpenGLFramebufferObject: Framebuffer incomplete attachment.
QOpenGLFramebufferObject: Framebuffer incomplete attachment.
QOpenGLFramebufferObject: Framebuffer incomplete, missing attachment.
[opengl\qopenglframebufferobject.cpp line 804] OpenGL Error: 1281
[opengl\qopenglframebufferobject.cpp line 570] OpenGL Error: 1281
QOpenGLFramebufferObject: Framebuffer incomplete attachment.
QOpenGLFramebufferObject: Framebuffer incomplete attachment.
QOpenGLFramebufferObject: Framebuffer incomplete, missing attachment.
[opengl\qopenglframebufferobject.cpp line 804] OpenGL Error: 1281
[opengl\qopenglframebufferobject.cpp line 607] OpenGL Error: 1281
QOpenGLFramebufferObject: Framebuffer incomplete attachment.
QOpenGLFramebufferObject: Framebuffer incomplete attachment.
QOpenGLFramebufferObject: Framebuffer incomplete attachment.
QOpenGLFramebufferObject: Framebuffer incomplete attachment.
QOpenGLFramebufferObject: Framebuffer incomplete, missing attachment.
[opengl\qopenglframebufferobject.cpp line 804] OpenGL Error: 1281
[opengl\qopenglframebufferobject.cpp line 570] OpenGL Error: 1281
QOpenGLFramebufferObject: Framebuffer incomplete attachment.
QOpenGLFramebufferObject: Framebuffer incomplete attachment.
QOpenGLFramebufferObject: Framebuffer incomplete, missing attachment.
[opengl\qopenglframebufferobject.cpp line 804] OpenGL Error: 1281
QOpenGLContext::swapBuffers() called without corresponding makeCurrent()

#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();
}
import QtQuick.Scene3D 2.0
import Qt3D.Core 2.0
import Qt3D.Render 2.9
import Qt3D.Input 2.0
import Qt3D.Extras 2.9
import QtQuick 2.0
import QtQuick 2.13 as QQ2
import QtQuick.Layouts 1.13
import QtQuick.Controls 2.13
Pane{
SwipeView{
     anchors.fill: parent
    id: swipeView
    currentIndex: tabBar.currentIndex
ColumnLayout{
    Text {
        text: "Click me000!"

        MouseArea {
            anchors.fill: parent
        }
    }
}
ColumnLayout{Text {
        text: "Click me333!"

        MouseArea {
            anchors.fill: parent
        }
    }}
ColumnLayout {


        Scene3D {
            id: scene3d
            anchors.fill: parent
            anchors.margins: 10
            focus: true
            aspects: ["input", "logic"]
            cameraAspectRatioMode: Scene3D.AutomaticAspectRatio

            Entity {
                id: sceneRoot

                Camera {
                    id: camera
                    projectionType: CameraLens.PerspectiveProjection
                    fieldOfView: 45
                    aspectRatio: 16/9
                    nearPlane : 0.1
                    farPlane : 1000.0
                    position: Qt.vector3d( -15, -15, -15 )
                    upVector: Qt.vector3d( 0.0, 1.0, 0.0 )
                    viewCenter: Qt.vector3d( 0.0, 0.0, 0.0 )
                }

                OrbitCameraController {
                    camera: camera
                }

                components: [
                    RenderSettings {
                        activeFrameGraph: ForwardRenderer {
                            clearColor: Qt.rgba(0, 0.5, 1, 1)
                            camera: camera
                        }
                    },
                    // Event Source will be set by the Qt3DQuickWindow
                    InputSettings { }
                ]

                PhongAlphaMaterial  {
                    id: material
                    alpha: 1
                    ambient: Qt.rgba( 0, .5, .5, 1.0 )
                    diffuse: Qt.rgba( 0, .5, .5, 1.0 )
                    shininess: 50
                }
                Transform {
                    id: torusTransform1
                    translation: Qt.vector3d(-10,-10,-10)
                }
                Transform {
                    id: torusTransform2
                    translation:  Qt.vector3d(-10, -10, -8)
                }

                CylinderMesh {
                    id: cyMesh1
                    length: 5
                    radius: 1
                    rings: 20
                    slices: 20
                }
                CylinderMesh {
                    id: cyMesh2
                    length: 5
                    radius: 1
                    rings: 20
                    slices: 20
                }
                Entity {
                    id: cyEntity1
                    components: [ cyMesh1, material, torusTransform1 ]
                }
                Entity {
                    id: cyEntity2
                    components: [ cyMesh2, material, torusTransform2 ]
                }
                QQ2.NumberAnimation {
                    target: cyMesh1
                    property: "length"
                    duration: 10000
                    from: 5
                    to: 0

                    loops: QQ2.Animation.Infinite
                    running: true
                }
            }

        }
  }
}
}
0 Answers
Related