-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
75 lines (62 loc) · 2.25 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package main
import (
"github.com/galaco/Lambda/internal/config"
"github.com/galaco/Lambda/internal/event"
"github.com/galaco/Lambda/internal/events"
"github.com/galaco/Lambda/internal/filesystem"
"github.com/galaco/Lambda/internal/filesystem/importers"
"github.com/galaco/Lambda/internal/graphics/opengl"
"github.com/galaco/Lambda/internal/input"
"github.com/galaco/Lambda/internal/log"
"github.com/galaco/Lambda/internal/model"
"github.com/galaco/Lambda/internal/ui"
"github.com/galaco/lambda-core/lib/util"
"github.com/inkyblackness/imgui-go"
"github.com/vulkan-go/glfw/v3.3/glfw"
"time"
)
func main() {
app := Application{}
defer app.Close()
app.Model = model.NewModel()
util.Logger().SetWriter(log.NewLog(func(msg string) {
app.Model.Logs.AddLog(model.LogTypeApplication, msg)
}))
util.Logger().EnablePretty()
configuration, err := config.Load("./lambda.json")
if err != nil {
util.Logger().Panic(err)
}
app.Model.Preferences = &configuration.Preferences
app.FileSystem = filesystem.New(configuration.Preferences.General.GameDirectory)
app.GraphicsAdapter = &opengl.OpenGL{}
app.EventDispatcher = event.NewDispatcher()
app.Keyboard = input.NewKeyboard()
app.VmfImporter = importers.NewVmfImporter()
uiContext := app.InitializeUIContext()
uiContext.Window().SetKeyCallback(app.Keyboard.GlfwKeyCallback)
app.InitializeGUITheme()
app.InitializeViews()
// Subscribe to window closing event
windowShouldClose := false
app.EventDispatcher.Subscribe(events.TypeWindowClosed, func(action event.Dispatchable) {
windowShouldClose = true
})
app.EventDispatcher.Subscribe(events.TypePreferencesUpdated, func(action event.Dispatchable) {
ui.ApplyImguiStyles(action.(*events.PreferencesUpdated).Appearance.Theme)
})
for !uiContext.Window().ShouldClose() && !windowShouldClose {
glfw.PollEvents()
app.Render()
displayWidth, displayHeight := uiContext.Window().GetFramebufferSize()
app.GraphicsAdapter.Viewport(0, 0, int32(displayWidth), int32(displayHeight))
imgui.Render()
uiContext.Imgui().Render(imgui.RenderedDrawData())
uiContext.DrawContext().Stack.Execute()
uiContext.Window().SwapBuffers()
app.GraphicsAdapter.ClearColor(0, 0, 0, 0)
app.GraphicsAdapter.ClearAll()
app.Update()
<-time.After(time.Millisecond * 25)
}
}