ci-platforms / darwin amd64 smoke (push) Skipped
ci-platforms / windows amd64 smoke (push) Skipped
ci-platforms / darwin arm64 smoke (push) Skipped
github-native / linux amd64 native (push) Skipped
ci / checks (push) Successful in 6m33s
ci / build (amd64, linux, ubuntu-24.04) (push) Failing after 12m26s
ci / release (push) Skipped
github-native / darwin amd64 native (push) Canceled after 0s
github-native / windows amd64 native (push) Canceled after 0s
github-native / darwin arm64 native (push) Canceled after 0s
60 lines
1.1 KiB
Go
60 lines
1.1 KiB
Go
package engine
|
|
|
|
import "aego/platform"
|
|
|
|
const (
|
|
SystemAppFixed = "app.fixed"
|
|
SystemAppUpdate = "app.update"
|
|
SystemAppRender = "app.render"
|
|
ZoneFrameWait = "app.frame_wait"
|
|
ZoneIdleWait = "app.idle_wait"
|
|
)
|
|
|
|
type App interface {
|
|
Init(*Engine) error
|
|
Event(platform.Event)
|
|
FixedUpdate(dt float64)
|
|
Update(dt float64)
|
|
Render(alpha float64)
|
|
Shutdown()
|
|
}
|
|
|
|
// FramePacer is an optional app capability invoked once after the render phase.
|
|
// Deliberate waits belong here, outside the render system's trace and render time.
|
|
type FramePacer interface {
|
|
PaceFrame()
|
|
}
|
|
|
|
// FrameFinisher runs on the main thread after GPU EndFrame and before swap.
|
|
// It is not called on frames that do not render.
|
|
type FrameFinisher interface {
|
|
FrameFinished()
|
|
}
|
|
|
|
type appSystemKind uint8
|
|
|
|
const (
|
|
appFixed appSystemKind = iota
|
|
appUpdate
|
|
appRender
|
|
)
|
|
|
|
type appSystem struct {
|
|
e *Engine
|
|
kind appSystemKind
|
|
}
|
|
|
|
func (s *appSystem) Run(ctx *Context) {
|
|
if s.e.app == nil {
|
|
return
|
|
}
|
|
switch s.kind {
|
|
case appFixed:
|
|
s.e.app.FixedUpdate(ctx.Dt)
|
|
case appUpdate:
|
|
s.e.app.Update(ctx.Dt)
|
|
case appRender:
|
|
s.e.app.Render(ctx.Alpha)
|
|
}
|
|
}
|