summaryrefslogtreecommitdiff
path: root/graphics.go
diff options
context:
space:
mode:
authorxengineering <me@xengineering.eu>2022-03-16 20:54:19 +0100
committerxengineering <me@xengineering.eu>2022-03-17 09:38:08 +0100
commit77901bb05dbf75e92dd8974ccb23053bb3b2dabf (patch)
tree386cfb941cb338d82ea607f28334705ce4c9d83e /graphics.go
parent8742e1207eb12091eeb061485072dcc2d70c0a52 (diff)
downloadstlscope-77901bb05dbf75e92dd8974ccb23053bb3b2dabf.tar
stlscope-77901bb05dbf75e92dd8974ccb23053bb3b2dabf.tar.zst
stlscope-77901bb05dbf75e92dd8974ccb23053bb3b2dabf.zip
Add docstrings
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
}