Awesome Go

go-glmatrix

CategoryOpenGL
SubcategoryOpenGL
Stars0

Go port of [glMatrix](https://glmatrix.net/) library

About go-glmatrix

Mentioned in Awesome Go
Build Status Coverage Status Go Report Card GoDoc license

go-glmatrix

go-glmatrix is a golang version of glMatrix, which is ``designed to perform vector and matrix operations stupidly fast''.

Usage

package main

import (
	"fmt"
	glm "github.com/technohippy/go-glmatrix"
)

func main() {
	// config
	rotateQuat := glm.QuatFromValues(1, 2, 3, 4)
	translateVec3 := glm.Vec3FromValues(1, 2, 3)
	scale := []float64{4, 5, 6}
	rotateOrigin := []float64{7, 8, 9}

	// construct matrix
	transMat := glm.Mat4Create()
	glm.Mat4Identity(transMat)
	glm.Mat4Translate(transMat, transMat, translateVec3)
	glm.Mat4Translate(transMat, transMat, rotateOrigin)
	rotateMat := glm.Mat4Create()
	rotateMat = glm.Mat4FromQuat(rotateMat, rotateQuat)
	matrix := glm.Mat4Multiply(glm.Mat4Create(), transMat, rotateMat)
	glm.Mat4Scale(matrix, matrix, scale)
	negativeOrigin := glm.Vec3Negate(glm.Vec3Create(), rotateOrigin)
	glm.Mat4Translate(matrix, matrix, negativeOrigin)

	// transform position
	position := glm.Vec3FromValues(10, 20, 30)
	glm.Vec3TransformMat4(position, position, matrix)
	fmt.Printf(glm.Vec3Str(position)) // => vec3(1280, -290, -42)
}

Document

License

MIT

Frequently Asked Questions

What is go-glmatrix?

go-glmatrix is a OpenGL library for the Go programming language. Go port of [glMatrix](https://glmatrix.net/) library

How do I install go-glmatrix?

Install go-glmatrix with the Go module system using `go get technohippy/go-glmatrix`. Check the repository for the current installation instructions.

What category does go-glmatrix belong to?

go-glmatrix is listed under OpenGL, specifically OpenGL.

← Back to OpenGL