mirror of
https://github.com/bloeys/nterm.git
synced 2025-12-29 06:28:20 +00:00
Upgrade to latest nmage
This commit is contained in:
@ -8,6 +8,7 @@ import (
|
||||
"github.com/bloeys/gglm/gglm"
|
||||
"github.com/bloeys/nmage/assets"
|
||||
"github.com/bloeys/nmage/buffers"
|
||||
"github.com/bloeys/nmage/camera"
|
||||
"github.com/bloeys/nmage/materials"
|
||||
"github.com/bloeys/nmage/meshes"
|
||||
"github.com/bloeys/nterm/assert"
|
||||
@ -681,7 +682,7 @@ func (gr *GlyphRend) updateFontAtlasTexture() error {
|
||||
gr.AtlasTex = nil
|
||||
}
|
||||
|
||||
atlasTex, err := assets.LoadTextureInMemImg(gr.Atlas.Img, nil)
|
||||
atlasTex, err := assets.LoadTextureInMemPngImg(gr.Atlas.Img, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -696,8 +697,6 @@ func (gr *GlyphRend) updateFontAtlasTexture() error {
|
||||
|
||||
//Update material
|
||||
gr.GlyphMat.DiffuseTex = gr.AtlasTex.TexID
|
||||
// gr.GlyphMat.SetUnifFloat32("spaceAdv", gr.Atlas.SpaceAdvance)
|
||||
// gr.GlyphMat.SetUnifFloat32("lineHeight", gr.Atlas.LineHeight)
|
||||
|
||||
return nil
|
||||
}
|
||||
@ -707,12 +706,11 @@ func (gr *GlyphRend) SetScreenSize(screenWidth, screenHeight int32) {
|
||||
gr.ScreenWidth = screenWidth
|
||||
gr.ScreenHeight = screenHeight
|
||||
|
||||
//The projection matrix fits the screen size. This is needed so we can size and position characters correctly.
|
||||
projMtx := gglm.Ortho(0, float32(screenWidth), float32(screenHeight), 0, 0.1, 20)
|
||||
viewMtx := gglm.LookAt(gglm.NewVec3(0, 0, -10), gglm.NewVec3(0, 0, 0), gglm.NewVec3(0, 1, 0))
|
||||
projViewMtx := projMtx.Mul(viewMtx)
|
||||
//The camera is orthographic and fits the screen size exactly. This is needed so we can size and position characters correctly.
|
||||
cam := camera.NewOrthographic(gglm.NewVec3(0, 0, 10), gglm.NewVec3(0, 0, -1), gglm.NewVec3(0, 1, 0), 0.1, 20, 0, float32(screenWidth), float32(screenHeight), 0)
|
||||
projViewMtx := cam.ProjMat.Mul(&cam.ViewMat)
|
||||
|
||||
gr.GlyphMat.SetUnifMat4("projViewMat", &projViewMtx.Mat4)
|
||||
gr.GlyphMat.SetUnifMat4("projViewMat", projViewMtx)
|
||||
}
|
||||
|
||||
func NewGlyphRend(fontFile string, fontOptions *truetype.Options, screenWidth, screenHeight int32) (*GlyphRend, error) {
|
||||
|
||||
12
go.mod
12
go.mod
@ -3,16 +3,16 @@ module github.com/bloeys/nterm
|
||||
go 1.18
|
||||
|
||||
require (
|
||||
github.com/bloeys/gglm v0.41.10
|
||||
github.com/bloeys/nmage v0.12.15
|
||||
github.com/go-gl/gl v0.0.0-20211025173605-bda47ffaa784
|
||||
github.com/bloeys/gglm v0.43.0
|
||||
github.com/bloeys/nmage v0.16.3
|
||||
github.com/go-gl/gl v0.0.0-20211210172815-726fda9656d6
|
||||
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0
|
||||
github.com/veandco/go-sdl2 v0.4.10
|
||||
github.com/veandco/go-sdl2 v0.4.25
|
||||
golang.org/x/exp v0.0.0-20220706164943-b4a6d9510983
|
||||
golang.org/x/image v0.0.0-20220617043117-41969df76e82
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/bloeys/assimp-go v0.4.2 // indirect
|
||||
github.com/inkyblackness/imgui-go/v4 v4.3.0 // indirect
|
||||
github.com/bloeys/assimp-go v0.4.4 // indirect
|
||||
github.com/inkyblackness/imgui-go/v4 v4.6.0 // indirect
|
||||
)
|
||||
|
||||
24
go.sum
24
go.sum
@ -1,24 +1,24 @@
|
||||
github.com/bloeys/assimp-go v0.4.2 h1:ArVK74BCFcTO/rCGj2NgZG9xtbjnJdEn5npIeJx1Z04=
|
||||
github.com/bloeys/assimp-go v0.4.2/go.mod h1:my3yRxT7CfOztmvi+0svmwbaqw0KFrxaHxncoyaEIP0=
|
||||
github.com/bloeys/gglm v0.41.10 h1:R9FMiI+VQVXAI+vDwCB7z9xqzy5VAR1657u8TQTDNKA=
|
||||
github.com/bloeys/gglm v0.41.10/go.mod h1:qwJQ0WzV191wAMwlGicbfbChbKoSedMk7gFFX6GnyOk=
|
||||
github.com/bloeys/nmage v0.12.15 h1:9ZdkOUqfaMKCO0MuKMeFiWgkBHv7oYZhAfSM8Bua0zs=
|
||||
github.com/bloeys/nmage v0.12.15/go.mod h1:chDDenktiDvAG4BoFYNq1n8nACpbQ6/RFuCgCGmDxh4=
|
||||
github.com/bloeys/assimp-go v0.4.4 h1:Yn5e/RpE0Oes0YMBy8O7KkwAO4R/RpgrZPJCt08dVIU=
|
||||
github.com/bloeys/assimp-go v0.4.4/go.mod h1:my3yRxT7CfOztmvi+0svmwbaqw0KFrxaHxncoyaEIP0=
|
||||
github.com/bloeys/gglm v0.43.0 h1:ZpOghR3PHfpkigTDh+FqxLsF0gN8CD6s/bWoei6LyxI=
|
||||
github.com/bloeys/gglm v0.43.0/go.mod h1:qwJQ0WzV191wAMwlGicbfbChbKoSedMk7gFFX6GnyOk=
|
||||
github.com/bloeys/nmage v0.16.3 h1:1RZZXydx9tKIRfklQz510Gyhjd4jMGyCCVFJ1Zrz8jQ=
|
||||
github.com/bloeys/nmage v0.16.3/go.mod h1:Z9pqkadzLYP+HUnV11lsomfxIzcpzLX3Yp5YCqiICUM=
|
||||
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/go-gl/gl v0.0.0-20211025173605-bda47ffaa784 h1:1Zi56D0LNfvkzM+BdoxKryvUEdyWO7LP8oRT+oSYJW0=
|
||||
github.com/go-gl/gl v0.0.0-20211025173605-bda47ffaa784/go.mod h1:9YTyiznxEY1fVinfM7RvRcjRHbw2xLBJ3AAGIT0I4Nw=
|
||||
github.com/go-gl/gl v0.0.0-20211210172815-726fda9656d6 h1:zDw5v7qm4yH7N8C8uWd+8Ii9rROdgWxQuGoJ9WDXxfk=
|
||||
github.com/go-gl/gl v0.0.0-20211210172815-726fda9656d6/go.mod h1:9YTyiznxEY1fVinfM7RvRcjRHbw2xLBJ3AAGIT0I4Nw=
|
||||
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 h1:DACJavvAHhabrF08vX0COfcOBJRhZ8lUbR+ZWIs0Y5g=
|
||||
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k=
|
||||
github.com/inkyblackness/imgui-go/v4 v4.3.0 h1:iyAzqWXq/dG5+6ckDPhGivtrIo6AywGQMvENKzun04s=
|
||||
github.com/inkyblackness/imgui-go/v4 v4.3.0/go.mod h1:g8SAGtOYUP7rYaOB2AsVKCEHmPMDmJKgt4z6d+flhb0=
|
||||
github.com/inkyblackness/imgui-go/v4 v4.6.0 h1:ShcnXEYl80+xREGBY9OpGWePA6FfJChY9Varsm+3jjE=
|
||||
github.com/inkyblackness/imgui-go/v4 v4.6.0/go.mod h1:g8SAGtOYUP7rYaOB2AsVKCEHmPMDmJKgt4z6d+flhb0=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/veandco/go-sdl2 v0.4.10 h1:8QoD2bhWl7SbQDflIAUYWfl9Vq+mT8/boJFAUzAScgY=
|
||||
github.com/veandco/go-sdl2 v0.4.10/go.mod h1:OROqMhHD43nT4/i9crJukyVecjPNYYuCofep6SNiAjY=
|
||||
github.com/veandco/go-sdl2 v0.4.25 h1:J5ac3KKOccp/0xGJA1PaNYKPUcZm19IxhDGs8lJofPI=
|
||||
github.com/veandco/go-sdl2 v0.4.25/go.mod h1:OROqMhHD43nT4/i9crJukyVecjPNYYuCofep6SNiAjY=
|
||||
golang.org/x/exp v0.0.0-20220706164943-b4a6d9510983 h1:sUweFwmLOje8KNfXAVqGGAsmgJ/F8jJ6wBLJDt4BTKY=
|
||||
golang.org/x/exp v0.0.0-20220706164943-b4a6d9510983/go.mod h1:Kr81I6Kryrl9sr8s2FK3vxD90NdsKWRuOIl2O4CvYbA=
|
||||
golang.org/x/image v0.0.0-20220617043117-41969df76e82 h1:KpZB5pUSBvrHltNEdK/tw0xlPeD13M6M6aGP32gKqiw=
|
||||
|
||||
7
main.go
7
main.go
@ -16,6 +16,7 @@ import (
|
||||
"unicode/utf8"
|
||||
|
||||
"github.com/bloeys/gglm/gglm"
|
||||
"github.com/bloeys/nmage/camera"
|
||||
"github.com/bloeys/nmage/engine"
|
||||
"github.com/bloeys/nmage/input"
|
||||
"github.com/bloeys/nmage/materials"
|
||||
@ -869,9 +870,9 @@ func (nt *nterm) HandleWindowResize() {
|
||||
w, h := nt.win.SDLWin.GetSize()
|
||||
nt.GlyphRend.SetScreenSize(w, h)
|
||||
|
||||
projMtx := gglm.Ortho(0, float32(w), float32(h), 0, 0.1, 20)
|
||||
viewMtx := gglm.LookAt(gglm.NewVec3(0, 0, -10), gglm.NewVec3(0, 0, 0), gglm.NewVec3(0, 1, 0))
|
||||
nt.gridMat.SetUnifMat4("projViewMat", &projMtx.Mul(viewMtx).Mat4)
|
||||
cam := camera.NewOrthographic(gglm.NewVec3(0, 0, 10), gglm.NewVec3(0, 0, -1), gglm.NewVec3(0, 1, 0), 0.1, 20, 0, float32(w), float32(h), 0)
|
||||
projViewMtx := cam.ProjMat.Mul(&cam.ViewMat)
|
||||
nt.gridMat.SetUnifMat4("projViewMat", projViewMtx)
|
||||
}
|
||||
|
||||
func (nt *nterm) WriteToTextBuf(text []byte) {
|
||||
|
||||
Reference in New Issue
Block a user