summaryrefslogtreecommitdiff
path: root/graphics.go
diff options
context:
space:
mode:
Diffstat (limited to 'graphics.go')
-rw-r--r--graphics.go5
1 files changed, 5 insertions, 0 deletions
diff --git a/graphics.go b/graphics.go
index a952e40..6c93204 100644
--- a/graphics.go
+++ b/graphics.go
@@ -59,6 +59,7 @@ void main() {
` + "\x00"
)
+// Graphics is a struct to save OpenGL-related data like shaders.
type Graphics struct {
version string
vao uint32
@@ -69,6 +70,7 @@ type Graphics struct {
trafoUniform int32
}
+// newGraphics initializes a new Graphics struct and returns it.
func newGraphics() Graphics {
var graphics Graphics = Graphics{}
@@ -111,6 +113,7 @@ func newGraphics() Graphics {
return graphics
}
+// draw executes the rendering process for a Graphics struct one time.
func (graphics Graphics) draw() {
gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
gl.UseProgram(graphics.program)
@@ -162,6 +165,7 @@ func makeVao(points []float32, normals []float32) uint32 {
return vao
}
+// compileShaders compiles the shader from source code.
func compileShader(source string, shaderType uint32) (uint32, error) {
log.Println("Compiling shader")
@@ -187,6 +191,7 @@ func compileShader(source string, shaderType uint32) (uint32, error) {
return shader, nil
}
+// setTrafo sets the current transformation matrix of the given Graphics struct.
func (graphics *Graphics) setTrafo(trafo mgl32.Mat4) {
graphics.trafo = trafo
}