main.qml Example File
framebuffer/qml/framebuffer/main.qml
import QtQuick 2.0
import QtCanvas3D 1.0
import QtQuick.Controls 1.0
import QtQuick.Layouts 1.0
import "framebuffer.js" as GLCode
Item {
id: mainview
width: 1280
height: 768
visible: true
Canvas3D {
id: canvas3d
anchors.fill: parent
property double xRotSlider: 0
property double yRotSlider: 0
property double zRotSlider: 0
property double xRotAnim: 0
property double yRotAnim: 0
property double zRotAnim: 0
property bool isRunning: true
onInitializeGL: {
GLCode.initializeGL(canvas3d);
}
onPaintGL: {
GLCode.paintGL(canvas3d);
}
onResizeGL: {
GLCode.resizeGL(canvas3d);
}
Keys.onSpacePressed: {
canvas3d.isRunning = !canvas3d.isRunning
if (canvas3d.isRunning) {
objAnimationX.pause();
objAnimationY.pause();
objAnimationZ.pause();
} else {
objAnimationX.resume();
objAnimationY.resume();
objAnimationZ.resume();
}
}
SequentialAnimation {
id: objAnimationX
loops: Animation.Infinite
running: true
NumberAnimation {
target: canvas3d
property: "xRotAnim"
from: 0.0
to: 120.0
duration: 7000
easing.type: Easing.InOutQuad
}
NumberAnimation {
target: canvas3d
property: "xRotAnim"
from: 120.0
to: 0.0
duration: 7000
easing.type: Easing.InOutQuad
}
}
SequentialAnimation {
id: objAnimationY
loops: Animation.Infinite
running: true
NumberAnimation {
target: canvas3d
property: "yRotAnim"
from: 0.0
to: 240.0
duration: 5000
easing.type: Easing.InOutCubic
}
NumberAnimation {
target: canvas3d
property: "yRotAnim"
from: 240.0
to: 0.0
duration: 5000
easing.type: Easing.InOutCubic
}
}
SequentialAnimation {
id: objAnimationZ
loops: Animation.Infinite
running: true
NumberAnimation {
target: canvas3d
property: "zRotAnim"
from: -100.0
to: 100.0
duration: 3000
easing.type: Easing.InOutSine
}
NumberAnimation {
target: canvas3d
property: "zRotAnim"
from: 100.0
to: -100.0
duration: 3000
easing.type: Easing.InOutSine
}
}
}
RowLayout {
id: controlLayout
spacing: 5
x: 12
y: parent.height - 100
width: parent.width - (x * 2)
height: 100
visible: true
Label {
id: xRotLabel
Layout.alignment: Qt.AlignRight
Layout.fillWidth: false
text: "X-axis:"
}
Slider {
id: xSlider
Layout.alignment: Qt.AlignLeft
Layout.fillWidth: true
minimumValue: 0;
maximumValue: 360;
onValueChanged: canvas3d.xRotSlider = value;
}
Label {
id: yRotLabel
Layout.alignment: Qt.AlignRight
Layout.fillWidth: false
text: "Y-axis:"
}
Slider {
id: ySlider
Layout.alignment: Qt.AlignLeft
Layout.fillWidth: true
minimumValue: 0;
maximumValue: 360;
onValueChanged: canvas3d.yRotSlider = value;
}
Label {
id: zRotLabel
Layout.alignment: Qt.AlignRight
Layout.fillWidth: false
text: "Z-axis:"
}
Slider {
id: zSlider
Layout.alignment: Qt.AlignLeft
Layout.fillWidth: true
minimumValue: 0;
maximumValue: 360;
onValueChanged: canvas3d.zRotSlider = value;
}
}
}