diff options
author | xengineering <mail2xengineering@protonmail.com> | 2021-05-21 14:55:33 +0200 |
---|---|---|
committer | xengineering <mail2xengineering@protonmail.com> | 2021-05-21 14:55:33 +0200 |
commit | 78a83df3572c7a91dbcbca21d74d8d11170d947c (patch) | |
tree | 75ddda15c22d483a48238158ee4aa485da02c014 /graphics.go | |
parent | 10679867f1742121f5e953247406cfb83f3b3e65 (diff) | |
download | stlscope-78a83df3572c7a91dbcbca21d74d8d11170d947c.tar stlscope-78a83df3572c7a91dbcbca21d74d8d11170d947c.tar.zst stlscope-78a83df3572c7a91dbcbca21d74d8d11170d947c.zip |
Animated Rotation
Diffstat (limited to 'graphics.go')
-rw-r--r-- | graphics.go | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/graphics.go b/graphics.go index a5c7373..999b37d 100644 --- a/graphics.go +++ b/graphics.go @@ -9,6 +9,7 @@ import ( "github.com/go-gl/gl/v4.6-core/gl" "github.com/go-gl/mathgl/mgl32" + "github.com/go-gl/glfw/v3.3/glfw" ) var ( @@ -21,6 +22,13 @@ var ( ) const ( + + // rotational speed and vector + OMEGA = 6 + ROT_X = 0 + ROT_Y = 1 + ROT_Z = 1 + // vertex shader to draw points VERTEX_SHADER = ` #version 410 @@ -87,7 +95,7 @@ func newGraphics() Graphics { graphics.vao = makeVao(triangle) // create transformation matrix - graphics.trafo = mgl32.HomogRotate3D(float32(1.57), mgl32.Vec3{0, 1, 1}) // mgl32.Ident4() + graphics.trafo = mgl32.HomogRotate3D(float32(glfw.GetTime()) * OMEGA, mgl32.Vec3{ROT_X, ROT_Y, ROT_Z}) graphics.trafoUniform = gl.GetUniformLocation(graphics.program, gl.Str("trafo\x00")) gl.UniformMatrix4fv(graphics.trafoUniform, 1, false, &graphics.trafo[0]) @@ -98,6 +106,7 @@ func (graphics Graphics) draw() { gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT) gl.UseProgram(graphics.program) + graphics.trafo = mgl32.HomogRotate3D(float32(glfw.GetTime()) * OMEGA, mgl32.Vec3{ROT_X, ROT_Y, ROT_Z}) gl.UniformMatrix4fv(graphics.trafoUniform, 1, false, &graphics.trafo[0]) gl.BindVertexArray(graphics.vao) |