Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MultMatrix for purego added #390

Merged
merged 2 commits into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions raylib/raymath.go
Original file line number Diff line number Diff line change
Expand Up @@ -1360,6 +1360,12 @@ func MatrixToFloatV(mat Matrix) [16]float32 {
return result
}

// MatrixToFloat - Converts Matrix to float32 slice
func MatrixToFloat(mat Matrix) []float32 {
data := MatrixToFloatV(mat)
return data[:]
}

// QuaternionAdd - Add two quaternions
func QuaternionAdd(q1 Quaternion, q2 Quaternion) Quaternion {
var result = Quaternion{X: q1.X + q2.X, Y: q1.Y + q2.Y, Z: q1.Z + q2.Z, W: q1.W + q2.W}
Expand Down
24 changes: 0 additions & 24 deletions raylib/rcore.go
Original file line number Diff line number Diff line change
Expand Up @@ -854,30 +854,6 @@ func Vector3ToFloat(vec Vector3) []float32 {
return data
}

// MatrixToFloat - Converts Matrix to float32 slice
func MatrixToFloat(mat Matrix) []float32 {
data := make([]float32, 16)

data[0] = mat.M0
data[1] = mat.M4
data[2] = mat.M8
data[3] = mat.M12
data[4] = mat.M1
data[5] = mat.M5
data[6] = mat.M9
data[7] = mat.M13
data[8] = mat.M2
data[9] = mat.M6
data[10] = mat.M10
data[11] = mat.M14
data[12] = mat.M3
data[13] = mat.M7
data[14] = mat.M11
data[15] = mat.M15

return data
}

// GetRandomValue - Returns a random value between min and max (both included)
func GetRandomValue(min, max int32) int32 {
cmin := (C.int)(min)
Expand Down
8 changes: 8 additions & 0 deletions raylib/rlgl_purego.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ var rlLoadIdentity func()
var rlTranslatef func(x float32, y float32, z float32)
var rlRotatef func(angle float32, x float32, y float32, z float32)
var rlScalef func(x float32, y float32, z float32)
var rlMultMatrixf func(matf *float32)
var rlFrustum func(left float64, right float64, bottom float64, top float64, znear float64, zfar float64)
var rlOrtho func(left float64, right float64, bottom float64, top float64, znear float64, zfar float64)
var rlViewport func(x int32, y int32, width int32, height int32)
Expand Down Expand Up @@ -138,6 +139,7 @@ func initRlglPurego() {
purego.RegisterLibFunc(&rlTranslatef, raylibDll, "rlTranslatef")
purego.RegisterLibFunc(&rlRotatef, raylibDll, "rlRotatef")
purego.RegisterLibFunc(&rlScalef, raylibDll, "rlScalef")
purego.RegisterLibFunc(&rlMultMatrixf, raylibDll, "rlMultMatrixf")
purego.RegisterLibFunc(&rlFrustum, raylibDll, "rlFrustum")
purego.RegisterLibFunc(&rlOrtho, raylibDll, "rlOrtho")
purego.RegisterLibFunc(&rlViewport, raylibDll, "rlViewport")
Expand Down Expand Up @@ -298,6 +300,12 @@ func Scalef(x float32, y float32, z float32) {
rlScalef(x, y, z)
}

// MultMatrix - Multiply the current matrix by another matrix
func MultMatrix(m Matrix) {
f := MatrixToFloat(m)
rlMultMatrixf((*float32)(&f[0]))
}

// Frustum .
func Frustum(left float64, right float64, bottom float64, top float64, znear float64, zfar float64) {
rlFrustum(left, right, bottom, top, znear, zfar)
Expand Down
Loading