diff options
Diffstat (limited to 'Godeps/_workspace/src/github.com/obscuren/qml/examples/painting-es2')
-rw-r--r-- | Godeps/_workspace/src/github.com/obscuren/qml/examples/painting-es2/painting.go | 115 | ||||
-rw-r--r-- | Godeps/_workspace/src/github.com/obscuren/qml/examples/painting-es2/painting.qml | 66 |
2 files changed, 0 insertions, 181 deletions
diff --git a/Godeps/_workspace/src/github.com/obscuren/qml/examples/painting-es2/painting.go b/Godeps/_workspace/src/github.com/obscuren/qml/examples/painting-es2/painting.go deleted file mode 100644 index 71f2d89a2..000000000 --- a/Godeps/_workspace/src/github.com/obscuren/qml/examples/painting-es2/painting.go +++ /dev/null @@ -1,115 +0,0 @@ -package main - -import ( - "fmt" - "os" - - "gopkg.in/qml.v1" - "gopkg.in/qml.v1/gl/es2" -) - -func main() { - if err := qml.Run(run); err != nil { - fmt.Fprintf(os.Stderr, "error: %v\n", err) - os.Exit(1) - } -} - -func run() error { - qml.RegisterTypes("GoExtensions", 1, 0, []qml.TypeSpec{{ - Init: func(r *GoRect, obj qml.Object) { r.Object = obj }, - }}) - - engine := qml.NewEngine() - component, err := engine.LoadFile("painting.qml") - if err != nil { - return err - } - - win := component.CreateWindow(nil) - win.Show() - win.Wait() - return nil -} - -type GoRect struct { - qml.Object -} - -var vertexShader = ` -#version 120 - -attribute vec2 position; - -void main() -{ - gl_Position = vec4(position.x, position.y, 0.0, 1.0); -} -` - -var fragmentShader = ` -#version 120 - -void main() -{ - gl_FragColor = vec4(1.0, 1.0, 1.0, 0.8); -} -` - -func (r *GoRect) Paint(p *qml.Painter) { - gl := GL.API(p) - - vertices := []float32{ - -1, -1, - +1, -1, - +1, +1, - -1, +1, - } - - indices := []uint8{ - 0, 1, 2, // first triangle - 2, 3, 0, // second triangle - } - - buf := gl.GenBuffers(2) - gl.BindBuffer(GL.ARRAY_BUFFER, buf[0]) - gl.BufferData(GL.ARRAY_BUFFER, 0, vertices, GL.STATIC_DRAW) - gl.BindBuffer(GL.ELEMENT_ARRAY_BUFFER, buf[1]) - gl.BufferData(GL.ELEMENT_ARRAY_BUFFER, 0, indices, GL.STATIC_DRAW) - - vshader := gl.CreateShader(GL.VERTEX_SHADER); - gl.ShaderSource(vshader, vertexShader) - gl.CompileShader(vshader) - - var status [1]int32 - gl.GetShaderiv(vshader, GL.COMPILE_STATUS, status[:]) - if status[0] == 0 { - log := gl.GetShaderInfoLog(vshader) - panic("vertex shader compilation failed: " + string(log)) - } - - fshader := gl.CreateShader(GL.FRAGMENT_SHADER) - gl.ShaderSource(fshader, fragmentShader) - gl.CompileShader(fshader) - - gl.GetShaderiv(fshader, GL.COMPILE_STATUS, status[:]) - if status[0] == 0 { - log := gl.GetShaderInfoLog(fshader) - panic("fragment shader compilation failed: " + string(log)) - } - - program := gl.CreateProgram() - gl.AttachShader(program, vshader) - gl.AttachShader(program, fshader) - gl.LinkProgram(program) - gl.UseProgram(program) - - position := gl.GetAttribLocation(program, "position") - gl.VertexAttribPointer(position, 2, GL.FLOAT, false, 0, 0) - gl.EnableVertexAttribArray(position) - - gl.Enable(GL.BLEND) - gl.BlendFunc(GL.SRC_ALPHA, GL.ONE_MINUS_SRC_ALPHA) - - gl.DrawElements(GL.TRIANGLES, 6, GL.UNSIGNED_BYTE, nil) -} diff --git a/Godeps/_workspace/src/github.com/obscuren/qml/examples/painting-es2/painting.qml b/Godeps/_workspace/src/github.com/obscuren/qml/examples/painting-es2/painting.qml deleted file mode 100644 index 8c59fc351..000000000 --- a/Godeps/_workspace/src/github.com/obscuren/qml/examples/painting-es2/painting.qml +++ /dev/null @@ -1,66 +0,0 @@ -import QtQuick 2.0 -import GoExtensions 1.0 - -Rectangle { - id: root - - width: 640 - height: 280 - color: "black" - - Rectangle { - x: 20; y: 20; width: 100; height: 100 - color: "red" - - SequentialAnimation on x { - loops: Animation.Infinite - NumberAnimation { from: 20; to: 120; duration: 4000; easing.type: Easing.InOutQuad } - NumberAnimation { from: 120; to: 20; duration: 4000; easing.type: Easing.InOutQuad } - } - } - - Rectangle { - x: 40; y: 40; width: 100; height: 100 - color: "yellow" - opacity: 0.7 - - SequentialAnimation on x { - loops: Animation.Infinite - NumberAnimation { from: 40; to: 220; duration: 4000; easing.type: Easing.InOutQuad } - NumberAnimation { from: 220; to: 40; duration: 4000; easing.type: Easing.InOutQuad } - } - } - - GoRect { - x: 60; y: 60; width: 100; height: 100 - - SequentialAnimation on x { - loops: Animation.Infinite - NumberAnimation { from: 60; to: 320; duration: 4000; easing.type: Easing.InOutQuad } - NumberAnimation { from: 320; to: 60; duration: 4000; easing.type: Easing.InOutQuad } - } - } - - Rectangle { - x: 80; y: 80; width: 100; height: 100 - color: "yellow" - opacity: 0.7 - - SequentialAnimation on x { - loops: Animation.Infinite - NumberAnimation { from: 80; to: 420; duration: 4000; easing.type: Easing.InOutQuad } - NumberAnimation { from: 420; to: 80; duration: 4000; easing.type: Easing.InOutQuad } - } - } - - Rectangle { - x: 100; y: 100; width: 100; height: 100 - color: "red" - - SequentialAnimation on x { - loops: Animation.Infinite - NumberAnimation { from: 100; to: 520; duration: 4000; easing.type: Easing.InOutQuad } - NumberAnimation { from: 520; to: 100; duration: 4000; easing.type: Easing.InOutQuad } - } - } -} |