summaryrefslogtreecommitdiff
path: root/graphics.go
diff options
context:
space:
mode:
Diffstat (limited to 'graphics.go')
-rw-r--r--graphics.go21
1 files changed, 10 insertions, 11 deletions
diff --git a/graphics.go b/graphics.go
index 87c21ed..66b8274 100644
--- a/graphics.go
+++ b/graphics.go
@@ -9,7 +9,6 @@ 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 (
@@ -22,12 +21,6 @@ var (
const (
- // rotational speed and vector
- OMEGA = 3
- ROT_X = 0
- ROT_Y = 1
- ROT_Z = 1
-
// vertex shader to draw points
VERTEX_SHADER = `
#version 410
@@ -65,6 +58,8 @@ func newGraphics() Graphics {
var graphics Graphics = Graphics{}
+ graphics.trafo = mgl32.Ident4()
+
// init OpenGL and save/log version
log.Println("OpenGL init")
err := gl.Init()
@@ -94,8 +89,8 @@ func newGraphics() Graphics {
graphics.vao = makeVao(vertices)
// create transformation matrix
- 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"))
+ //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])
return graphics
@@ -105,11 +100,11 @@ 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})
+ //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)
- gl.DrawArrays(gl.TRIANGLES, 0, int32(len(vertices)/3))
+ gl.DrawArrays(gl.LINE_STRIP, 0, int32(len(vertices)/3)) // POINTS, LINES, LINE_STRIP, LINE_LOOP, TRIANGLES, TRIANGLE_STRIP, TRIANGLE_FAN
}
// makeVao initializes and returns a vertex array from the points provided.
@@ -157,3 +152,7 @@ func compileShader(source string, shaderType uint32) (uint32, error) {
return shader, nil
}
+
+func (graphics *Graphics) setTrafo(trafo mgl32.Mat4) {
+ graphics.trafo = trafo
+}