Compare commits

...

1 Commits

Author SHA1 Message Date
b9cd630fcf Reduce cubes+make camera framrate independent 2022-01-22 08:29:53 +04:00
4 changed files with 15 additions and 11 deletions

View File

@ -17,8 +17,8 @@ To run the project you need:
* A C/C++ compiler installed and in your path
* Windows: [MingW](https://www.mingw-w64.org/downloads/#mingw-builds) or similar
* Mac/Linux: Should be installed by default, but if not try [GCC](https://gcc.gnu.org/) or [Clang](https://releases.llvm.org/download.html)
* Get the required [assimp-go](https://github.com/bloeys/assimp-go) DLLs/DyLibs and place them correctly by following the `assimp-go` [README](https://github.com/bloeys/assimp-go#using-assimp-go).
* Get the required [assimp-go](https://github.com/bloeys/assimp-go) DLLs/DyLibs and place them correctly by following the assimp-go [README](https://github.com/bloeys/assimp-go#using-assimp-go).
Then run nMage with `go run .`
Then you can start nMage with `go run .`
> Note: that it might take a while to run the first time because of downloading/compiling dependencies.
> Note: It *might* take a while to clone/run the first time because of downloading/compiling dependencies.

2
go.mod
View File

@ -7,7 +7,7 @@ require github.com/veandco/go-sdl2 v0.4.10
require github.com/go-gl/gl v0.0.0-20211025173605-bda47ffaa784
require (
github.com/bloeys/assimp-go v0.3.2
github.com/bloeys/assimp-go v0.3.3
github.com/bloeys/gglm v0.3.1
github.com/inkyblackness/imgui-go/v4 v4.3.0
)

2
go.sum
View File

@ -2,6 +2,8 @@ github.com/bloeys/assimp-go v0.3.1 h1:GANPXH8ER/4B/XsxZOw03GLZi2qKiWapSJ9dntrGoi
github.com/bloeys/assimp-go v0.3.1/go.mod h1:my3yRxT7CfOztmvi+0svmwbaqw0KFrxaHxncoyaEIP0=
github.com/bloeys/assimp-go v0.3.2 h1:CsKnLloWZyn6uYNNaQE2Jq2Q+yH4d71A+CxbpU2flng=
github.com/bloeys/assimp-go v0.3.2/go.mod h1:my3yRxT7CfOztmvi+0svmwbaqw0KFrxaHxncoyaEIP0=
github.com/bloeys/assimp-go v0.3.3 h1:36Cqdsv/vVWg7mx6Kvu++1Z0SftdAQF4a+ApllpVT4M=
github.com/bloeys/assimp-go v0.3.3/go.mod h1:my3yRxT7CfOztmvi+0svmwbaqw0KFrxaHxncoyaEIP0=
github.com/bloeys/gglm v0.3.1 h1:Sy9upW7SBsBfDXrSmEhid3aQ+7J7itej+upwcxOnPMQ=
github.com/bloeys/gglm v0.3.1/go.mod h1:qwJQ0WzV191wAMwlGicbfbChbKoSedMk7gFFX6GnyOk=
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=

16
main.go
View File

@ -443,20 +443,21 @@ var lightColor1 gglm.Vec3 = *gglm.NewVec3(1, 1, 1)
func runGameLogic() {
var camSpeed float32 = 15.0
if input.KeyDown(sdl.K_w) {
camPos.Data[1] += 0.1
camPos.Data[1] += camSpeed * timing.DT()
updateViewMat()
}
if input.KeyDown(sdl.K_s) {
camPos.Data[1] -= 0.1
camPos.Data[1] -= camSpeed * timing.DT()
updateViewMat()
}
if input.KeyDown(sdl.K_d) {
camPos.Data[0] += 0.1
camPos.Data[0] += camSpeed * timing.DT()
updateViewMat()
}
if input.KeyDown(sdl.K_a) {
camPos.Data[0] -= 0.1
camPos.Data[0] -= camSpeed * timing.DT()
updateViewMat()
}
@ -519,12 +520,13 @@ func draw() {
bo.Activate()
tempModelMat := modelMat.Clone()
for y := 0; y < 100; y++ {
for x := 0; x < 100; x++ {
rowSize := 10
for y := 0; y < rowSize; y++ {
for x := 0; x < rowSize; x++ {
simpleShader.SetUnifMat4("modelMat", &tempModelMat.Translate(gglm.NewVec3(-1, 0, 0)).Mat4)
gl.DrawElements(gl.TRIANGLES, int32(bo.IndexBuf.DataLen), gl.UNSIGNED_INT, gl.PtrOffset(0))
}
simpleShader.SetUnifMat4("modelMat", &tempModelMat.Translate(gglm.NewVec3(100, -1, 0)).Mat4)
simpleShader.SetUnifMat4("modelMat", &tempModelMat.Translate(gglm.NewVec3(float32(rowSize), -1, 0)).Mat4)
}
simpleShader.SetUnifMat4("modelMat", &modelMat.Mat4)