{"action":"opened","issue":{"url":"https://api.github.com/repos/EngoEngine/engo/issues/392","repository_url":"https://api.github.com/repos/EngoEngine/engo","labels_url":"https://api.github.com/repos/EngoEngine/engo/issues/392/labels{/name}","comments_url":"https://api.github.com/repos/EngoEngine/engo/issues/392/comments","events_url":"https://api.github.com/repos/EngoEngine/engo/issues/392/events","html_url":"https://github.com/EngoEngine/engo/issues/392","id":190580703,"number":392,"title":"Impossible to scroll on subsequent scenes","user":{"login":"johnny-morrice","id":10660403,"avatar_url":"https://avatars.githubusercontent.com/u/10660403?v=3","gravatar_id":"","url":"https://api.github.com/users/johnny-morrice","html_url":"https://github.com/johnny-morrice","followers_url":"https://api.github.com/users/johnny-morrice/followers","following_url":"https://api.github.com/users/johnny-morrice/following{/other_user}","gists_url":"https://api.github.com/users/johnny-morrice/gists{/gist_id}","starred_url":"https://api.github.com/users/johnny-morrice/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/johnny-morrice/subscriptions","organizations_url":"https://api.github.com/users/johnny-morrice/orgs","repos_url":"https://api.github.com/users/johnny-morrice/repos","events_url":"https://api.github.com/users/johnny-morrice/events{/privacy}","received_events_url":"https://api.github.com/users/johnny-morrice/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-11-20T20:17:10Z","updated_at":"2016-11-20T20:17:10Z","closed_at":null,"body":"It's impossible to do CameraSystem based scrolling on all but the first scene.  (I have tested with EdgeScroller but I believe this applies across the board)\r\n\r\nWhy?\r\n\r\nOn shader initialization, the global shader instances (e.g. DefaultShader) grab a reference to the first CameraSystem they find (See *DefaultShader Setup method).\r\n\r\nWhen the user creates a new RenderSystem for use in a second scene ([as per the examples](https://github.com/EngoEngine/engo/blob/master/demos/scenes/scenes.go), a new CameraSystem is created, but the reference in the shaders is not updated.\r\n\r\nHere is a quick and stupid fix whereby a CameraSystem instance persists across all RenderSystem instances:\r\n\r\n```\r\nfunc (rs *RenderSystem) New(w *ecs.World) {\r\n\trs.world = w\r\n\r\n\tif __camera == nil {\r\n\t\t__camera = &CameraSystem{}\r\n\t}\r\n\r\n\tw.AddSystem(__camera)\r\n\r\n\tif !engo.Headless() {\r\n\t\tinitShaders(w)\r\n\t\tengo.Gl.Enable(engo.Gl.MULTISAMPLE)\r\n\t}\r\n\r\n\tengo.Mailbox.Listen(\"renderChangeMessage\", func(engo.Message) {\r\n\t\trs.sortingNeeded = true\r\n\t})\r\n}\r\n\r\nvar __camera *CameraSystem\r\n```\r\n\r\nThis is stupid but you'll find that one can now scroll in scenes after the first.\r\n\r\nAnother suggestion is that one could fix the bug by ensuring the CameraSystem instances are not shared across global variables.  Perhaps by turning those global variables into instance variables or methods.  As I'm not a core contributor I don't know what design you have in mind!"}}
{"actor":{"display_login":"johnny-morrice"}}