move WorldRenderer to game package

This commit is contained in:
2022-02-24 13:18:05 +08:00
parent 1ec4f9d281
commit 9195dd7c3f
5 changed files with 140 additions and 265 deletions

View File

@@ -6,7 +6,6 @@ import (
"os"
"time"
"edgaru089.ml/go/gl01/internal/igwrap"
"edgaru089.ml/go/gl01/internal/igwrap/backend"
"edgaru089.ml/go/gl01/internal/io"
"edgaru089.ml/go/gl01/internal/render"
@@ -14,7 +13,6 @@ import (
"edgaru089.ml/go/gl01/internal/util/itype"
"edgaru089.ml/go/gl01/internal/world"
"edgaru089.ml/go/gl01/internal/world/worldgen"
"github.com/go-gl/gl/all-core/gl"
"github.com/go-gl/glfw/v3.3/glfw"
"github.com/go-gl/mathgl/mgl64"
"github.com/inkyblackness/imgui-go/v4"
@@ -39,9 +37,8 @@ func (g *Game) Init(win *glfw.Window) {
g.world = world.NewWorld()
g.view = &render.View{}
g.worldrender = &render.WorldRenderer{}
err := g.worldrender.Init(g.world)
err := g.initRender()
if err != nil {
panic(err)
}
@@ -249,19 +246,5 @@ func (g *Game) Update(win *glfw.Window, delta time.Duration) {
imgui.ShowDemoWindow(nil)
g.imgui()
if ok, bc, face, _, _ := g.world.CastViewRay(io.ViewPos, io.ViewDir.Normalize(), 10); ok {
igwrap.TextBackground("Looking At: (%d %d %d) facing %s", bc[0], bc[1], bc[2], itype.DirectionName[face])
}
io.Diagnostics.Times.GUI = clock.Restart()
}
// Render, called with a OpenGL context, renders the game.
func (g *Game) Render(win *glfw.Window) {
gl.Viewport(0, 0, int32(io.DisplaySize[0]), int32(io.DisplaySize[1]))
g.worldrender.Render(g.world, g.view)
render.Framewire.Render(g.view)
backend.Render(win)
}