{"action":"created","issue":{"url":"https://api.github.com/repos/azul3d/engine/issues/27","repository_url":"https://api.github.com/repos/azul3d/engine","labels_url":"https://api.github.com/repos/azul3d/engine/issues/27/labels{/name}","comments_url":"https://api.github.com/repos/azul3d/engine/issues/27/comments","events_url":"https://api.github.com/repos/azul3d/engine/issues/27/events","html_url":"https://github.com/azul3d/engine/issues/27","id":138742001,"number":27,"title":"Example: Dynamic Reload of Shaders","user":{"login":"slimsag","id":3173176,"avatar_url":"https://avatars.githubusercontent.com/u/3173176?v=3","gravatar_id":"","url":"https://api.github.com/users/slimsag","html_url":"https://github.com/slimsag","followers_url":"https://api.github.com/users/slimsag/followers","following_url":"https://api.github.com/users/slimsag/following{/other_user}","gists_url":"https://api.github.com/users/slimsag/gists{/gist_id}","starred_url":"https://api.github.com/users/slimsag/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/slimsag/subscriptions","organizations_url":"https://api.github.com/users/slimsag/orgs","repos_url":"https://api.github.com/users/slimsag/repos","events_url":"https://api.github.com/users/slimsag/events{/privacy}","received_events_url":"https://api.github.com/users/slimsag/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"slimsag","id":3173176,"avatar_url":"https://avatars.githubusercontent.com/u/3173176?v=3","gravatar_id":"","url":"https://api.github.com/users/slimsag","html_url":"https://github.com/slimsag","followers_url":"https://api.github.com/users/slimsag/followers","following_url":"https://api.github.com/users/slimsag/following{/other_user}","gists_url":"https://api.github.com/users/slimsag/gists{/gist_id}","starred_url":"https://api.github.com/users/slimsag/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/slimsag/subscriptions","organizations_url":"https://api.github.com/users/slimsag/orgs","repos_url":"https://api.github.com/users/slimsag/repos","events_url":"https://api.github.com/users/slimsag/events{/privacy}","received_events_url":"https://api.github.com/users/slimsag/received_events","type":"User","site_admin":false},"milestone":null,"comments":10,"created_at":"2016-03-06T01:26:49Z","updated_at":"2016-03-06T01:26:52Z","closed_at":null,"body":"_From @dskinner on August 29, 2014 15:58_\n\nCan be accomplished with fsnotify. Different editors save files in different ways which can complicate the implementation.\r\n\r\nI'll put together a short sample of how I accomplished this later tonight. The example would perhaps be a simplified version of the following that I do:\r\n\r\n* Keep shaders in a data/ directory\r\n* Names by convention, so there would be a `triangle-vert.glsl` and `triangle-frag.glsl`\r\n* When creating a new shader on an object, call `obj.Shader = gfx.NewShader(\"triangle\")`\r\n* During object rendering, first check if a shader has been compiled. If not, load the shader data.\r\n* If fsnotify over shaders is enabled then:\r\n    * When a file is changed, lookup objects using shader based on name, for example `triangle`\r\n    * Mark each object shader as dirty\r\n    * During object rendering, if shader is marked as dirty, reload the data\r\n\r\nThe example could provide some values in the shaders that encourage the user to change while the program is running.\r\n\r\nSee https://github.com/azul3d/gfx-gl2/issues/1\n\n_Copied from original issue: azul3d/oldissues#19_"},"comment":{"url":"https://api.github.com/repos/azul3d/engine/issues/comments/192777231","html_url":"https://github.com/azul3d/engine/issues/27#issuecomment-192777231","issue_url":"https://api.github.com/repos/azul3d/engine/issues/27","id":192777231,"user":{"login":"slimsag","id":3173176,"avatar_url":"https://avatars.githubusercontent.com/u/3173176?v=3","gravatar_id":"","url":"https://api.github.com/users/slimsag","html_url":"https://github.com/slimsag","followers_url":"https://api.github.com/users/slimsag/followers","following_url":"https://api.github.com/users/slimsag/following{/other_user}","gists_url":"https://api.github.com/users/slimsag/gists{/gist_id}","starred_url":"https://api.github.com/users/slimsag/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/slimsag/subscriptions","organizations_url":"https://api.github.com/users/slimsag/orgs","repos_url":"https://api.github.com/users/slimsag/repos","events_url":"https://api.github.com/users/slimsag/events{/privacy}","received_events_url":"https://api.github.com/users/slimsag/received_events","type":"User","site_admin":false},"created_at":"2016-03-06T01:26:52Z","updated_at":"2016-03-06T01:26:52Z","body":"_From @dskinner on December 25, 2014 22:56_\n\nthanks, merged. It's an older sample where most relevant part is the watchShaders func and an implied reload based on shader name.\r\n\r\nWhat a better solution should do as discussed elsewhere is be able to reload a single shader attached to multiple objects since that's more along the lines of what you would see in a larger application."}}