Removed Add() method from System interface, added 2D culling.

This commit is contained in:
Marvin Blum
2016-05-07 11:28:42 +02:00
parent 11cf7a9251
commit 80e5cb20f8
4 changed files with 123 additions and 41 deletions

13
game.go
View File

@@ -227,6 +227,7 @@ func initGoga(width, height int) {
EnableAlphaBlending(true)
AddLoader(&PngLoader{gl.LINEAR, false})
AddSystem(NewSpriteRenderer(nil, nil, false))
AddSystem(NewCulling2D(0, 0, width, height))
}
func cleanup() {
@@ -296,13 +297,23 @@ func EnableAlphaBlending(enable bool) {
}
}
// Sets GL viewport.
// Sets GL viewport and updates default resources and systems.
func SetViewport(x, y, width, height int32) {
viewportWidth = int(width)
viewportHeight = int(height)
DefaultCamera.SetViewport(int(x), int(y), viewportWidth, viewportHeight)
DefaultCamera.CalcRatio()
DefaultCamera.CalcOrtho()
if culling2d := GetSystemByName(culling_2d_name); culling2d != nil {
system, ok := culling2d.(*Culling2D)
if ok {
system.SetViewport(int(x), int(y), viewportWidth, viewportHeight)
}
}
gl.Viewport(x, y, width, height)
}