import Qt 4.7 import QExtend 1.0 Canvas { width:800 height:600 color : Qt.rgba(.1,0,0,1) property double t: 0 function initGLScene() { var gl = getContext3D() gl.beginGl() gl.defaultInit(); gl.viewport(0, 0,width, height); gl.matrixMode(GL.PROJECTION); gl.loadIdentity(); gl.makePerspective(45.0, 1.*width/height, 0.1, 100.0); gl.matrixMode(GL.MODELVIEW); gl.loadIdentity(); } onTChanged: { var gl = getContext3D() gl.beginGl() gl.clear(GL.COLOR_BUFFER_BIT | GL.DEPTH_BUFFER_BIT); gl.loadIdentity(); gl.translate(-1.5, 0.0, -6.0); gl.rotate(t *90,0.0,1.0,0.0); gl.begin(GL.TRIANGLES); gl.color3(1.0,0.0,0.0); gl.vertex3( 0.0, 1.0, 0.0); gl.color3(0.0,1.0,0.0); gl.vertex3(-1.0,-1.0, 0.0); gl.color3(0.0,0.0,1.0); gl.vertex3( 1.0,-1.0, 0.0); gl.end(); gl.loadIdentity(); // Reset The Current Modelview Matrix gl.translate(1.5,0.0,-6.0); // Move Right 1.5 Units And Into The Screen 6.0 gl.rotate(t * 80,1.0,0.0,0.0); gl.color3(0.5,0.5,1.0); gl.begin(GL.QUADS); gl.vertex3(-1.0, 1.0, 0.0); gl.vertex3( 1.0, 1.0, 0.0); gl.vertex3( 1.0,-1.0, 0.0); gl.vertex3(-1.0,-1.0, 0.0); gl.end(); gl.endGl() } SequentialAnimation on t { loops: Animation.Infinite // Move from minHeight to maxHeight in 300ms, using the OutExpo easing function NumberAnimation { from: 0; to: 1. easing.type: Easing.OutExpo; duration: 1000 } // Then move back to minHeight in 1 second, using the OutBounce easing function NumberAnimation { from: 1.; to: 0 easing.type: Easing.OutBounce; duration: 1000 } } onGeometryChanged: {initGLScene() } /* Component.onCompleted: { QExtend.setTimeout(function() { console.log("begin "+width +" "+height) var gl = getContext3D() gl.beginGl() gl.defaultInit(); gl.viewport(0, 0,width, height); console.log(GL.PROJECTION) gl.matrixMode(GL.PROJECTION); gl.loadIdentity(); gl.makePerspective(45.0, 1.*width/height, 0.1, 100.0); gl.matrixMode(GL.MODELVIEW); gl.loadIdentity(); } ,1) }*/ }