Closed godispy closed 8 years ago
Translating C++ glm code to Go mathgl is quite doable, since the API is modeled to be similar.
For example, a C++ vec3:
glm::vec3(4,3,3)
Would look like this in Go:
mgl64.Vec3{4, 3, 3}
A bigger example:
glm::mat4 View = glm::lookAt(
glm::vec3(4,3,3), // Camera is at (4,3,3), in World Space
glm::vec3(0,0,0), // and looks at the origin
glm::vec3(0,1,0) // Head is up (set to 0,-1,0 to look upside-down)
);
Would be:
view := mgl64.LookAtV(
mgl64.Vec3{4, 3, 3},
mgl64.Vec3{0, 0, 0},
mgl64.Vec3{0, 1, 0},
}
I recommend the following resources:
It doesn't work!! //---------------------------------- programID := LoadShaders( "SimpleTransform.vertexshader", "SingleColor.fragmentshader" ) gl.BindFragDataLocation(programID, 0, gl.Str("MVP\x00"))
projection:=mgl32.Perspective(45.0, 4.0 / 3.0, 0.1, 100.0)
camera:=mgl32.LookAtV(mgl32.Vec3{4,3,3},mgl32.Vec3{0,0,0},mgl32.Vec3{0,1,0})
model := mgl32.Ident4()
var MVP mgl32.Mat4
MVP=MVP.Mul4(projection)
MVP=MVP.Mul4(camera)
MVP=MVP.Mul4(model)
modelUniform := gl.GetUniformLocation(programID, gl.Str("MVP\x00"))
gl.UniformMatrix4fv(modelUniform, 1, false, &MVP[0])
The golang code contains "github.com/veandco/go-sdl2/sdl" "github.com/go-gl/gl/v3.3-core/gl" "github.com/go-gl/mathgl/mgl32"
It doesn't work!!
What's the error message?
Thx shurcooL!! I solved this problem!! go-gl/mathgl is a Great Gopackage!
Good to hear.