import Qt 4.7 import QExtend 1.0 Canvas { width:600 height:400 color : Qt.rgba(0,0,0,1) onGeometryChanged: {initGLScene() } property double rx : 45 property double ry : 45 property double rz : 45 function initGLScene() { var gl = getContext3D() gl.beginGl() gl.defaultInit(); gl.enable(GL.BLEND); gl.disable(GL.DEPTH_TEST); 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(); gl.bindTexture("./Glass.bmp") } Component.onCompleted: { // initGLScene() QExtend.setInterval(function() { var gl = getContext3D() gl.beginGl() gl.clear(GL.COLOR_BUFFER_BIT | GL.DEPTH_BUFFER_BIT); gl.loadIdentity(); gl.translate(0.0,0.0,-5.0); gl.rotate(rx,1.0,0.0,0.0); // Rotate On The X Axis gl.rotate(ry,0.0,1.0,0.0); // Rotate On The Y Axis gl.rotate(rz,0.0,0.0,1.0); gl.color4(1.0,1.0,1.0,0.5); // Full Brightness, 50% Alpha ( NEW ) gl.blendFunc(GL.SRC_ALPHA,GL.ONE); gl.begin(GL.QUADS); // ront ace gl.texCoord2(0.0, 0.0); gl.vertex3(-1.0, -1.0, 1.0); // Bottom Let O The Texture and Quad gl.texCoord2(1.0, 0.0); gl.vertex3( 1.0, -1.0, 1.0); // Bottom Right O The Texture and Quad gl.texCoord2(1.0, 1.0); gl.vertex3( 1.0, 1.0, 1.0); // Top Right O The Texture and Quad gl.texCoord2(0.0, 1.0); gl.vertex3(-1.0, 1.0, 1.0); // Top Let O The Texture and Quad // Back ace gl.texCoord2(1.0, 0.0); gl.vertex3(-1.0, -1.0, -1.0); // Bottom Right O The Texture and Quad gl.texCoord2(1.0, 1.0); gl.vertex3(-1.0, 1.0, -1.0); // Top Right O The Texture and Quad gl.texCoord2(0.0, 1.0); gl.vertex3( 1.0, 1.0, -1.0); // Top Let O The Texture and Quad gl.texCoord2(0.0, 0.0); gl.vertex3( 1.0, -1.0, -1.0); // Bottom Let O The Texture and Quad // Top ace gl.texCoord2(0.0, 1.0); gl.vertex3(-1.0, 1.0, -1.0); // Top Let O The Texture and Quad gl.texCoord2(0.0, 0.0); gl.vertex3(-1.0, 1.0, 1.0); // Bottom Let O The Texture and Quad gl.texCoord2(1.0, 0.0); gl.vertex3( 1.0, 1.0, 1.0); // Bottom Right O The Texture and Quad gl.texCoord2(1.0, 1.0); gl.vertex3( 1.0, 1.0, -1.0); // Top Right O The Texture and Quad // Bottom ace gl.texCoord2(1.0, 1.0); gl.vertex3(-1.0, -1.0, -1.0); // Top Right O The Texture and Quad gl.texCoord2(0.0, 1.0); gl.vertex3( 1.0, -1.0, -1.0); // Top Let O The Texture and Quad gl.texCoord2(0.0, 0.0); gl.vertex3( 1.0, -1.0, 1.0); // Bottom Let O The Texture and Quad gl.texCoord2(1.0, 0.0); gl.vertex3(-1.0, -1.0, 1.0); // Bottom Right O The Texture and Quad // Right ace gl.texCoord2(1.0, 0.0); gl.vertex3( 1.0, -1.0, -1.0); // Bottom Right O The Texture and Quad gl.texCoord2(1.0, 1.0); gl.vertex3( 1.0, 1.0, -1.0); // Top Right O The Texture and Quad gl.texCoord2(0.0, 1.0); gl.vertex3( 1.0, 1.0, 1.0); // Top Let O The Texture and Quad gl.texCoord2(0.0, 0.0); gl.vertex3( 1.0, -1.0, 1.0); // Bottom Let O The Texture and Quad // Let ace gl.texCoord2(0.0, 0.0); gl.vertex3(-1.0, -1.0, -1.0); // Bottom Let O The Texture and Quad gl.texCoord2(1.0, 0.0); gl.vertex3(-1.0, -1.0, 1.0); // Bottom Right O The Texture and Quad gl.texCoord2(1.0, 1.0); gl.vertex3(-1.0, 1.0, 1.0); // Top Right O The Texture and Quad gl.texCoord2(0.0, 1.0); gl.vertex3(-1.0, 1.0, -1.0); // Top Let O The Texture and Quad gl.end(); gl.endGl() rx+=0.3; ry+=0.2; rz+=0.4; },1); } }