{"action":"created","comment":{"url":"https://api.github.com/repos/amethyst/amethyst/pulls/comments/62110178","id":62110178,"diff_hunk":"@@ -0,0 +1,234 @@\n+\n+extern crate cgmath;\n+extern crate gfx;\n+extern crate gfx_device_gl;\n+extern crate gfx_window_glutin;\n+extern crate glutin;\n+extern crate genmesh;\n+extern crate amethyst_renderer;\n+extern crate rand;\n+\n+use std::time::SystemTime;\n+use std::collections::HashMap;\n+use rand::Rng;\n+\n+use gfx::{Device};\n+use gfx::traits::FactoryExt;\n+\n+use cgmath::{Point3, Vector3, Matrix4, EuclideanVector};\n+use cgmath::{Transform, AffineMatrix3};\n+use genmesh::generators::SphereUV;\n+use genmesh::{Triangulate, MapToVertices, Vertices};\n+\n+use amethyst_renderer::VertexPosNormal as Vertex;\n+use amethyst_renderer::{ColorFormat, DepthFormat};\n+\n+fn build_sphere() -> Vec<Vertex> {\n+    SphereUV::new(32, 32)\n+        .vertex(|(x, y, z)| Vertex{\n+            pos: [x, y, z],\n+            normal: Vector3::new(x, y, z).normalize().into()\n+        })\n+        .triangulate()\n+        .vertices()\n+        .collect()\n+}\n+\n+fn main() {\n+    let builder = glutin::WindowBuilder::new()\n+        .with_title(\"Amethyst Renderer Demo\".to_string())\n+        .with_dimensions(800, 600)\n+        .with_vsync();\n+\n+    let (window, mut device, mut factory, main_color, main_depth) =\n+        gfx_window_glutin::init::<ColorFormat, DepthFormat>(builder);\n+    let combuf = factory.create_command_buffer();\n+\n+    let sphere = build_sphere();\n+    let buffer = factory.create_vertex_buffer(&sphere);\n+    let slice = gfx::Slice::new_match_vertex_buffer(&buffer);\n+\n+    let mut scene = amethyst_renderer::Scene{\n+        fragments: vec![],\n+        lights: vec![]\n+    };\n+\n+    let mut rng = rand::thread_rng();\n+\n+    for x in -1..2 {\n+        for y in -1..2 {\n+            for z in -1..2 {\n+                let x = x as f32 * 4.;\n+                let y = y as f32 * 4.;\n+                let z = z as f32 * 4.;\n+\n+                let color = [rng.gen_range(0., 1.), rng.gen_range(0., 1.), rng.gen_range(0., 1.), 1.];\n+\n+                scene.fragments.push(amethyst_renderer::Fragment{\n+                    buffer: buffer.clone(),\n+                    slice: slice.clone(),\n+                    ka: [color[0] * 0.1, color[1] * 0.1, color[2] * 0.1, 1.],\n+                    kd: color,\n+                    transform: Matrix4::from_translation(Vector3::new(x, y, z)).into()\n+                })\n+            }\n+        }\n+    }\n+\n+    for x in -2..3 {\n+        for y in -2..3 {\n+            for z in -2..3 {\n+                let x = x as f32 * 5.;\n+                let y = y as f32 * 5.;\n+                let z = z as f32 * 5.;\n+\n+                let r = (x + 10.) / 20.;\n+                let g = (y + 10.) / 20.;\n+                let b = (z + 10.) / 20.;\n+\n+                scene.lights.push(amethyst_renderer::Light{\n+                    color: [r, g, b, 1.],\n+                    radius: 1.,\n+                    center: [x, y, z],\n+                    propagation_constant: 0.,\n+                    propagation_linear: 0.,\n+                    propagation_r_square: 1.,\n+                })\n+            }\n+        }\n+    }\n+\n+\n+    let mut frame = amethyst_renderer::Frame{\n+        passes: vec![],\n+        targets: HashMap::new(),\n+        scenes: std::collections::HashMap::new(),\n+        cameras: std::collections::HashMap::new()\n+    };\n+\n+    frame.scenes.insert(format!(\"main\"), scene);\n+    frame.passes.push(amethyst_renderer::RenderPasses::new(format!(\"gbuffer\")));\n+    frame.passes[0].operations = vec![\n+        Box::new(amethyst_renderer::Clear{color: [0., 0., 0., 1.]}),\n+        Box::new(amethyst_renderer::Draw{\n+            camera: format!(\"main\"),\n+            scene: format!(\"main\")\n+        })\n+    ];\n+    frame.passes.push(amethyst_renderer::RenderPasses::new(format!(\"main\")));","path":"src/renderer/examples/main.rs","position":118,"original_position":118,"commit_id":"dbcc50b824f17b4be7b5a6744af099f2547b4c5c","original_commit_id":"dbcc50b824f17b4be7b5a6744af099f2547b4c5c","user":{"login":"kvark","id":107301,"avatar_url":"https://avatars.githubusercontent.com/u/107301?v=3","gravatar_id":"","url":"https://api.github.com/users/kvark","html_url":"https://github.com/kvark","followers_url":"https://api.github.com/users/kvark/followers","following_url":"https://api.github.com/users/kvark/following{/other_user}","gists_url":"https://api.github.com/users/kvark/gists{/gist_id}","starred_url":"https://api.github.com/users/kvark/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kvark/subscriptions","organizations_url":"https://api.github.com/users/kvark/orgs","repos_url":"https://api.github.com/users/kvark/repos","events_url":"https://api.github.com/users/kvark/events{/privacy}","received_events_url":"https://api.github.com/users/kvark/received_events","type":"User","site_admin":false},"body":"the default passes could be something simpler for this example since you already have this code bound on `Key1`","created_at":"2016-05-04T20:37:28Z","updated_at":"2016-05-04T20:37:28Z","html_url":"https://github.com/amethyst/amethyst/pull/45#discussion_r62110178","pull_request_url":"https://api.github.com/repos/amethyst/amethyst/pulls/45","_links":{"self":{"href":"https://api.github.com/repos/amethyst/amethyst/pulls/comments/62110178"},"html":{"href":"https://github.com/amethyst/amethyst/pull/45#discussion_r62110178"},"pull_request":{"href":"https://api.github.com/repos/amethyst/amethyst/pulls/45"}}},"pull_request":{"url":"https://api.github.com/repos/amethyst/amethyst/pulls/45","id":68807128,"html_url":"https://github.com/amethyst/amethyst/pull/45","diff_url":"https://github.com/amethyst/amethyst/pull/45.diff","patch_url":"https://github.com/amethyst/amethyst/pull/45.patch","issue_url":"https://api.github.com/repos/amethyst/amethyst/issues/45","number":45,"state":"open","locked":false,"title":"[WIP] Gfx Renderer","user":{"login":"csherratt","id":62622,"avatar_url":"https://avatars.githubusercontent.com/u/62622?v=3","gravatar_id":"","url":"https://api.github.com/users/csherratt","html_url":"https://github.com/csherratt","followers_url":"https://api.github.com/users/csherratt/followers","following_url":"https://api.github.com/users/csherratt/following{/other_user}","gists_url":"https://api.github.com/users/csherratt/gists{/gist_id}","starred_url":"https://api.github.com/users/csherratt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/csherratt/subscriptions","organizations_url":"https://api.github.com/users/csherratt/orgs","repos_url":"https://api.github.com/users/csherratt/repos","events_url":"https://api.github.com/users/csherratt/events{/privacy}","received_events_url":"https://api.github.com/users/csherratt/received_events","type":"User","site_admin":false},"body":"Basically from a high level command are abstracted away from the data in the rendering pipeline. Commands are matched to a Method that can work with it's data. Right now that is just based on the render target and the Command itself. I think this can expand in the future.\r\n\r\nUsers can add their own targets and their own methods to the Renderer, and in addition replace methods. This replacing could be neat for doing something like a shader toy.\r\n\r\nRight now I have a basic flat shading pipeline, and a terribly unoptimized deferred lighting. But it should be easy to to keep adding new passes and build a library of useful ones.\r\n\r\nDemo of it working: https://www.youtube.com/watch?v=m3Q_3behpPA\r\n\r\nProblem areas:\r\n - No texture support yet\r\n - The mesh format is static, we will need something like `gfx_mesh` to allow for multiple formats without static types\r\n - Resizing of buffers is incomplete\r\n - Single threaded\r\n","created_at":"2016-05-04T03:36:01Z","updated_at":"2016-05-04T20:37:28Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ddba29df5777c2615de406ab8cfd7a416f9fb7c7","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/amethyst/amethyst/pulls/45/commits","review_comments_url":"https://api.github.com/repos/amethyst/amethyst/pulls/45/comments","review_comment_url":"https://api.github.com/repos/amethyst/amethyst/pulls/comments{/number}","comments_url":"https://api.github.com/repos/amethyst/amethyst/issues/45/comments","statuses_url":"https://api.github.com/repos/amethyst/amethyst/statuses/dbcc50b824f17b4be7b5a6744af099f2547b4c5c","head":{"label":"csherratt:gfx","ref":"gfx","sha":"dbcc50b824f17b4be7b5a6744af099f2547b4c5c","user":{"login":"csherratt","id":62622,"avatar_url":"https://avatars.githubusercontent.com/u/62622?v=3","gravatar_id":"","url":"https://api.github.com/users/csherratt","html_url":"https://github.com/csherratt","followers_url":"https://api.github.com/users/csherratt/followers","following_url":"https://api.github.com/users/csherratt/following{/other_user}","gists_url":"https://api.github.com/users/csherratt/gists{/gist_id}","starred_url":"https://api.github.com/users/csherratt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/csherratt/subscriptions","organizations_url":"https://api.github.com/users/csherratt/orgs","repos_url":"https://api.github.com/users/csherratt/repos","events_url":"https://api.github.com/users/csherratt/events{/privacy}","received_events_url":"https://api.github.com/users/csherratt/received_events","type":"User","site_admin":false},"repo":{"id":55012318,"name":"amethyst","full_name":"csherratt/amethyst","owner":{"login":"csherratt","id":62622,"avatar_url":"https://avatars.githubusercontent.com/u/62622?v=3","gravatar_id":"","url":"https://api.github.com/users/csherratt","html_url":"https://github.com/csherratt","followers_url":"https://api.github.com/users/csherratt/followers","following_url":"https://api.github.com/users/csherratt/following{/other_user}","gists_url":"https://api.github.com/users/csherratt/gists{/gist_id}","starred_url":"https://api.github.com/users/csherratt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/csherratt/subscriptions","organizations_url":"https://api.github.com/users/csherratt/orgs","repos_url":"https://api.github.com/users/csherratt/repos","events_url":"https://api.github.com/users/csherratt/events{/privacy}","received_events_url":"https://api.github.com/users/csherratt/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/csherratt/amethyst","description":"Data-oriented game engine written in Rust","fork":true,"url":"https://api.github.com/repos/csherratt/amethyst","forks_url":"https://api.github.com/repos/csherratt/amethyst/forks","keys_url":"https://api.github.com/repos/csherratt/amethyst/keys{/key_id}","collaborators_url":"https://api.github.com/repos/csherratt/amethyst/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/csherratt/amethyst/teams","hooks_url":"https://api.github.com/repos/csherratt/amethyst/hooks","issue_events_url":"https://api.github.com/repos/csherratt/amethyst/issues/events{/number}","events_url":"https://api.github.com/repos/csherratt/amethyst/events","assignees_url":"https://api.github.com/repos/csherratt/amethyst/assignees{/user}","branches_url":"https://api.github.com/repos/csherratt/amethyst/branches{/branch}","tags_url":"https://api.github.com/repos/csherratt/amethyst/tags","blobs_url":"https://api.github.com/repos/csherratt/amethyst/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/csherratt/amethyst/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/csherratt/amethyst/git/refs{/sha}","trees_url":"https://api.github.com/repos/csherratt/amethyst/git/trees{/sha}","statuses_url":"https://api.github.com/repos/csherratt/amethyst/statuses/{sha}","languages_url":"https://api.github.com/repos/csherratt/amethyst/languages","stargazers_url":"https://api.github.com/repos/csherratt/amethyst/stargazers","contributors_url":"https://api.github.com/repos/csherratt/amethyst/contributors","subscribers_url":"https://api.github.com/repos/csherratt/amethyst/subscribers","subscription_url":"https://api.github.com/repos/csherratt/amethyst/subscription","commits_url":"https://api.github.com/repos/csherratt/amethyst/commits{/sha}","git_commits_url":"https://api.github.com/repos/csherratt/amethyst/git/commits{/sha}","comments_url":"https://api.github.com/repos/csherratt/amethyst/comments{/number}","issue_comment_url":"https://api.github.com/repos/csherratt/amethyst/issues/comments{/number}","contents_url":"https://api.github.com/repos/csherratt/amethyst/contents/{+path}","compare_url":"https://api.github.com/repos/csherratt/amethyst/compare/{base}...{head}","merges_url":"https://api.github.com/repos/csherratt/amethyst/merges","archive_url":"https://api.github.com/repos/csherratt/amethyst/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/csherratt/amethyst/downloads","issues_url":"https://api.github.com/repos/csherratt/amethyst/issues{/number}","pulls_url":"https://api.github.com/repos/csherratt/amethyst/pulls{/number}","milestones_url":"https://api.github.com/repos/csherratt/amethyst/milestones{/number}","notifications_url":"https://api.github.com/repos/csherratt/amethyst/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/csherratt/amethyst/labels{/name}","releases_url":"https://api.github.com/repos/csherratt/amethyst/releases{/id}","deployments_url":"https://api.github.com/repos/csherratt/amethyst/deployments","created_at":"2016-03-29T21:39:25Z","updated_at":"2016-03-29T21:39:25Z","pushed_at":"2016-05-04T03:28:15Z","git_url":"git://github.com/csherratt/amethyst.git","ssh_url":"git@github.com:csherratt/amethyst.git","clone_url":"https://github.com/csherratt/amethyst.git","svn_url":"https://github.com/csherratt/amethyst","homepage":"","size":14403,"stargazers_count":0,"watchers_count":0,"language":"Rust","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"amethyst:master","ref":"master","sha":"2d491f57bf8df752df7cb42a89b6d04a1b996fe5","user":{"login":"amethyst","id":17814736,"avatar_url":"https://avatars.githubusercontent.com/u/17814736?v=3","gravatar_id":"","url":"https://api.github.com/users/amethyst","html_url":"https://github.com/amethyst","followers_url":"https://api.github.com/users/amethyst/followers","following_url":"https://api.github.com/users/amethyst/following{/other_user}","gists_url":"https://api.github.com/users/amethyst/gists{/gist_id}","starred_url":"https://api.github.com/users/amethyst/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amethyst/subscriptions","organizations_url":"https://api.github.com/users/amethyst/orgs","repos_url":"https://api.github.com/users/amethyst/repos","events_url":"https://api.github.com/users/amethyst/events{/privacy}","received_events_url":"https://api.github.com/users/amethyst/received_events","type":"Organization","site_admin":false},"repo":{"id":48364554,"name":"amethyst","full_name":"amethyst/amethyst","owner":{"login":"amethyst","id":17814736,"avatar_url":"https://avatars.githubusercontent.com/u/17814736?v=3","gravatar_id":"","url":"https://api.github.com/users/amethyst","html_url":"https://github.com/amethyst","followers_url":"https://api.github.com/users/amethyst/followers","following_url":"https://api.github.com/users/amethyst/following{/other_user}","gists_url":"https://api.github.com/users/amethyst/gists{/gist_id}","starred_url":"https://api.github.com/users/amethyst/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amethyst/subscriptions","organizations_url":"https://api.github.com/users/amethyst/orgs","repos_url":"https://api.github.com/users/amethyst/repos","events_url":"https://api.github.com/users/amethyst/events{/privacy}","received_events_url":"https://api.github.com/users/amethyst/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/amethyst/amethyst","description":"Data-oriented game engine written in Rust","fork":false,"url":"https://api.github.com/repos/amethyst/amethyst","forks_url":"https://api.github.com/repos/amethyst/amethyst/forks","keys_url":"https://api.github.com/repos/amethyst/amethyst/keys{/key_id}","collaborators_url":"https://api.github.com/repos/amethyst/amethyst/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/amethyst/amethyst/teams","hooks_url":"https://api.github.com/repos/amethyst/amethyst/hooks","issue_events_url":"https://api.github.com/repos/amethyst/amethyst/issues/events{/number}","events_url":"https://api.github.com/repos/amethyst/amethyst/events","assignees_url":"https://api.github.com/repos/amethyst/amethyst/assignees{/user}","branches_url":"https://api.github.com/repos/amethyst/amethyst/branches{/branch}","tags_url":"https://api.github.com/repos/amethyst/amethyst/tags","blobs_url":"https://api.github.com/repos/amethyst/amethyst/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/amethyst/amethyst/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/amethyst/amethyst/git/refs{/sha}","trees_url":"https://api.github.com/repos/amethyst/amethyst/git/trees{/sha}","statuses_url":"https://api.github.com/repos/amethyst/amethyst/statuses/{sha}","languages_url":"https://api.github.com/repos/amethyst/amethyst/languages","stargazers_url":"https://api.github.com/repos/amethyst/amethyst/stargazers","contributors_url":"https://api.github.com/repos/amethyst/amethyst/contributors","subscribers_url":"https://api.github.com/repos/amethyst/amethyst/subscribers","subscription_url":"https://api.github.com/repos/amethyst/amethyst/subscription","commits_url":"https://api.github.com/repos/amethyst/amethyst/commits{/sha}","git_commits_url":"https://api.github.com/repos/amethyst/amethyst/git/commits{/sha}","comments_url":"https://api.github.com/repos/amethyst/amethyst/comments{/number}","issue_comment_url":"https://api.github.com/repos/amethyst/amethyst/issues/comments{/number}","contents_url":"https://api.github.com/repos/amethyst/amethyst/contents/{+path}","compare_url":"https://api.github.com/repos/amethyst/amethyst/compare/{base}...{head}","merges_url":"https://api.github.com/repos/amethyst/amethyst/merges","archive_url":"https://api.github.com/repos/amethyst/amethyst/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/amethyst/amethyst/downloads","issues_url":"https://api.github.com/repos/amethyst/amethyst/issues{/number}","pulls_url":"https://api.github.com/repos/amethyst/amethyst/pulls{/number}","milestones_url":"https://api.github.com/repos/amethyst/amethyst/milestones{/number}","notifications_url":"https://api.github.com/repos/amethyst/amethyst/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/amethyst/amethyst/labels{/name}","releases_url":"https://api.github.com/repos/amethyst/amethyst/releases{/id}","deployments_url":"https://api.github.com/repos/amethyst/amethyst/deployments","created_at":"2015-12-21T09:59:29Z","updated_at":"2016-05-04T17:55:22Z","pushed_at":"2016-05-04T20:02:05Z","git_url":"git://github.com/amethyst/amethyst.git","ssh_url":"git@github.com:amethyst/amethyst.git","clone_url":"https://github.com/amethyst/amethyst.git","svn_url":"https://github.com/amethyst/amethyst","homepage":"","size":14426,"stargazers_count":238,"watchers_count":238,"language":"Rust","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":17,"mirror_url":null,"open_issues_count":12,"forks":17,"open_issues":12,"watchers":238,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/amethyst/amethyst/pulls/45"},"html":{"href":"https://github.com/amethyst/amethyst/pull/45"},"issue":{"href":"https://api.github.com/repos/amethyst/amethyst/issues/45"},"comments":{"href":"https://api.github.com/repos/amethyst/amethyst/issues/45/comments"},"review_comments":{"href":"https://api.github.com/repos/amethyst/amethyst/pulls/45/comments"},"review_comment":{"href":"https://api.github.com/repos/amethyst/amethyst/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/amethyst/amethyst/pulls/45/commits"},"statuses":{"href":"https://api.github.com/repos/amethyst/amethyst/statuses/dbcc50b824f17b4be7b5a6744af099f2547b4c5c"}}}}