{"action":"created","comment":{"url":"https://api.github.com/repos/amit-goldstein/ToneMapperMichael/pulls/comments/62428826","id":62428826,"diff_hunk":"@@ -0,0 +1,111 @@\n+// Copyright (c) 2016 Lightricks. All rights reserved.\n+// Created by Michael Kupchick.\n+\n+#import \"ResourceFactory.h\"\n+\n+#import <GLKit/GLKit.h>\n+\n+#import \"Defs.h\"\n+#import \"GLBuffer.h\"\n+#import \"GLFrameBuffer.h\"\n+#import \"GLProgram.h\"\n+#import \"GLTexture2D.h\"\n+#import \"GLVertexAttributesArray.h\"\n+\n+NS_ASSUME_NONNULL_BEGIN\n+\n+@implementation ResourceFactory\n+\n++ (id<Buffer>)bufferWithBytes:(NSData *)data usage:(GLenum)usage {\n+  GLBuffer *buffer = [[GLBuffer alloc] initArrayWithUsage:usage];\n+  \n+  [ResourceFactory setupBuffer:buffer data:data];\n+  \n+  return buffer;\n+}\n+\n++ (void)setupBuffer:(GLBuffer *)buffer data:(NSData *)data {\n+  [buffer setBytes:data];\n+}\n+\n++ (id<Buffer>)dynamicBufferWithBytes:(NSData *)data {\n+  return [ResourceFactory bufferWithBytes:data usage:Dynamic];\n+}\n+\n++ (id<Buffer>)staticBufferWithBytes:(NSData *)data {\n+  return [ResourceFactory bufferWithBytes:data usage:Static];\n+}\n+\n++ (id<Buffer>)elementBufferWithBytes:(NSData *)data {\n+  GLBuffer *buffer = [[GLBuffer alloc] initElementWithUsage:Static];\n+  [ResourceFactory setupBuffer:buffer data:data];\n+  return buffer;\n+}\n+\n++ (id<VertexAttributesArray>)vertexAttributesArray:(NSArray<id<VertexAttribute>> *)attributes {\n+  return [[GLVertexAttributesArray alloc] initWithAttributes:attributes];\n+}\n+\n++ (id<Program>)programWithVertexShader:(NSString *)vertex fragmentShader:(NSString *)fragment {\n+  return [[GLProgram alloc] initWithVertexShader:vertex fragmentShader:fragment];\n+}\n+\n++ (nullable id<Program>)programFromBundleWithResourceName:(NSString *)resourceName {\n+  NSBundle* main = [NSBundle mainBundle];\n+  \n+  NSString *vshPath = [main pathForResource:resourceName ofType:@\"vsh\"];\n+  NSString *fshPath = [main pathForResource:resourceName ofType:@\"fsh\"];\n+  \n+  NSError *error = nil;\n+  NSString *vsh = [NSString stringWithContentsOfFile:vshPath encoding:NSUTF8StringEncoding\n+                                               error:&error];\n+  if (error) {\n+    NSLog(@\"%@\", error);\n+    return nil;\n+  }\n+  \n+  NSString *fsh = [NSString stringWithContentsOfFile:fshPath encoding:NSUTF8StringEncoding\n+                                               error:&error];\n+  if (error) {\n+    NSLog(@\"%@\", error);\n+    return nil;\n+  }\n+  \n+  return [self programWithVertexShader:vsh fragmentShader:fsh];\n+}\n+\n++ (id<Texture2D>)textureWithProps:(Texture2DProps *)props andData:(nullable NSData *)data {\n+  GLTexture2D *result = [[GLTexture2D alloc] initWithProps:props];\n+  \n+  [Scope bind:result andExecute:^{\n+    [result setDefaultParameters];\n+    [result updateWithData:data];\n+  }];\n+  \n+  return result;\n+}\n+\n++ (id<Texture2D>)textureFromData:(NSData *)data {\n+  NSError *error;\n+  \n+  // GLKTextureLoader binds the loaded texture which ruins previous state, lets save it.\n+  GLint prevTexture;\n+  GL_ERROR_CHECK(glGetIntegerv(GL_TEXTURE_BINDING_2D, &prevTexture));\n+  GLKTextureInfo *info =\n+      [GLKTextureLoader textureWithContentsOfData:data\n+                                          options:@{GLKTextureLoaderOriginBottomLeft: @YES}\n+                                            error:&error];\n+  GL_ERROR_CHECK(glBindTexture(GL_TEXTURE_2D, prevTexture));\n+  \n+  GLTexture2D *result = [[GLTexture2D alloc] initWithInfo:info];\n+   \n+  return result;","path":"opengl-ex/model/ResourceFactory.m","position":102,"original_position":102,"commit_id":"e96761c04ae7bd08b14e4d4382a8fc9b55791750","original_commit_id":"e96761c04ae7bd08b14e4d4382a8fc9b55791750","user":{"login":"michaellightricks","id":17297304,"avatar_url":"https://avatars.githubusercontent.com/u/17297304?v=3","gravatar_id":"","url":"https://api.github.com/users/michaellightricks","html_url":"https://github.com/michaellightricks","followers_url":"https://api.github.com/users/michaellightricks/followers","following_url":"https://api.github.com/users/michaellightricks/following{/other_user}","gists_url":"https://api.github.com/users/michaellightricks/gists{/gist_id}","starred_url":"https://api.github.com/users/michaellightricks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/michaellightricks/subscriptions","organizations_url":"https://api.github.com/users/michaellightricks/orgs","repos_url":"https://api.github.com/users/michaellightricks/repos","events_url":"https://api.github.com/users/michaellightricks/events{/privacy}","received_events_url":"https://api.github.com/users/michaellightricks/received_events","type":"User","site_admin":false},"body":"done","created_at":"2016-05-08T08:28:01Z","updated_at":"2016-05-08T08:28:01Z","html_url":"https://github.com/amit-goldstein/ToneMapperMichael/pull/1#discussion_r62428826","pull_request_url":"https://api.github.com/repos/amit-goldstein/ToneMapperMichael/pulls/1","_links":{"self":{"href":"https://api.github.com/repos/amit-goldstein/ToneMapperMichael/pulls/comments/62428826"},"html":{"href":"https://github.com/amit-goldstein/ToneMapperMichael/pull/1#discussion_r62428826"},"pull_request":{"href":"https://api.github.com/repos/amit-goldstein/ToneMapperMichael/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/amit-goldstein/ToneMapperMichael/pulls/1","id":66178713,"html_url":"https://github.com/amit-goldstein/ToneMapperMichael/pull/1","diff_url":"https://github.com/amit-goldstein/ToneMapperMichael/pull/1.diff","patch_url":"https://github.com/amit-goldstein/ToneMapperMichael/pull/1.patch","issue_url":"https://api.github.com/repos/amit-goldstein/ToneMapperMichael/issues/1","number":1,"state":"open","locked":false,"title":"Feature/opengl wrapper","user":{"login":"michaellightricks","id":17297304,"avatar_url":"https://avatars.githubusercontent.com/u/17297304?v=3","gravatar_id":"","url":"https://api.github.com/users/michaellightricks","html_url":"https://github.com/michaellightricks","followers_url":"https://api.github.com/users/michaellightricks/followers","following_url":"https://api.github.com/users/michaellightricks/following{/other_user}","gists_url":"https://api.github.com/users/michaellightricks/gists{/gist_id}","starred_url":"https://api.github.com/users/michaellightricks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/michaellightricks/subscriptions","organizations_url":"https://api.github.com/users/michaellightricks/orgs","repos_url":"https://api.github.com/users/michaellightricks/repos","events_url":"https://api.github.com/users/michaellightricks/events{/privacy}","received_events_url":"https://api.github.com/users/michaellightricks/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-04-12T15:32:45Z","updated_at":"2016-05-08T08:28:01Z","closed_at":null,"merged_at":null,"merge_commit_sha":"cbcf5f23d7f49fea134ca62f94031249983fd3c6","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/amit-goldstein/ToneMapperMichael/pulls/1/commits","review_comments_url":"https://api.github.com/repos/amit-goldstein/ToneMapperMichael/pulls/1/comments","review_comment_url":"https://api.github.com/repos/amit-goldstein/ToneMapperMichael/pulls/comments{/number}","comments_url":"https://api.github.com/repos/amit-goldstein/ToneMapperMichael/issues/1/comments","statuses_url":"https://api.github.com/repos/amit-goldstein/ToneMapperMichael/statuses/e96761c04ae7bd08b14e4d4382a8fc9b55791750","head":{"label":"michaellightricks:feature/opengl_wrapper","ref":"feature/opengl_wrapper","sha":"e96761c04ae7bd08b14e4d4382a8fc9b55791750","user":{"login":"michaellightricks","id":17297304,"avatar_url":"https://avatars.githubusercontent.com/u/17297304?v=3","gravatar_id":"","url":"https://api.github.com/users/michaellightricks","html_url":"https://github.com/michaellightricks","followers_url":"https://api.github.com/users/michaellightricks/followers","following_url":"https://api.github.com/users/michaellightricks/following{/other_user}","gists_url":"https://api.github.com/users/michaellightricks/gists{/gist_id}","starred_url":"https://api.github.com/users/michaellightricks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/michaellightricks/subscriptions","organizations_url":"https://api.github.com/users/michaellightricks/orgs","repos_url":"https://api.github.com/users/michaellightricks/repos","events_url":"https://api.github.com/users/michaellightricks/events{/privacy}","received_events_url":"https://api.github.com/users/michaellightricks/received_events","type":"User","site_admin":false},"repo":{"id":54562807,"name":"ToneMapperMichael","full_name":"michaellightricks/ToneMapperMichael","owner":{"login":"michaellightricks","id":17297304,"avatar_url":"https://avatars.githubusercontent.com/u/17297304?v=3","gravatar_id":"","url":"https://api.github.com/users/michaellightricks","html_url":"https://github.com/michaellightricks","followers_url":"https://api.github.com/users/michaellightricks/followers","following_url":"https://api.github.com/users/michaellightricks/following{/other_user}","gists_url":"https://api.github.com/users/michaellightricks/gists{/gist_id}","starred_url":"https://api.github.com/users/michaellightricks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/michaellightricks/subscriptions","organizations_url":"https://api.github.com/users/michaellightricks/orgs","repos_url":"https://api.github.com/users/michaellightricks/repos","events_url":"https://api.github.com/users/michaellightricks/events{/privacy}","received_events_url":"https://api.github.com/users/michaellightricks/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/michaellightricks/ToneMapperMichael","description":"","fork":true,"url":"https://api.github.com/repos/michaellightricks/ToneMapperMichael","forks_url":"https://api.github.com/repos/michaellightricks/ToneMapperMichael/forks","keys_url":"https://api.github.com/repos/michaellightricks/ToneMapperMichael/keys{/key_id}","collaborators_url":"https://api.github.com/repos/michaellightricks/ToneMapperMichael/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/michaellightricks/ToneMapperMichael/teams","hooks_url":"https://api.github.com/repos/michaellightricks/ToneMapperMichael/hooks","issue_events_url":"https://api.github.com/repos/michaellightricks/ToneMapperMichael/issues/events{/number}","events_url":"https://api.github.com/repos/michaellightricks/ToneMapperMichael/events","assignees_url":"https://api.github.com/repos/michaellightricks/ToneMapperMichael/assignees{/user}","branches_url":"https://api.github.com/repos/michaellightricks/ToneMapperMichael/branches{/branch}","tags_url":"https://api.github.com/repos/michaellightricks/ToneMapperMichael/tags","blobs_url":"https://api.github.com/repos/michaellightricks/ToneMapperMichael/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/michaellightricks/ToneMapperMichael/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/michaellightricks/ToneMapperMichael/git/refs{/sha}","trees_url":"https://api.github.com/repos/michaellightricks/ToneMapperMichael/git/trees{/sha}","statuses_url":"https://api.github.com/repos/michaellightricks/ToneMapperMichael/statuses/{sha}","languages_url":"https://api.github.com/repos/michaellightricks/ToneMapperMichael/languages","stargazers_url":"https://api.github.com/repos/michaellightricks/ToneMapperMichael/stargazers","contributors_url":"https://api.github.com/repos/michaellightricks/ToneMapperMichael/contributors","subscribers_url":"https://api.github.com/repos/michaellightricks/ToneMapperMichael/subscribers","subscription_url":"https://api.github.com/repos/michaellightricks/ToneMapperMichael/subscription","commits_url":"https://api.github.com/repos/michaellightricks/ToneMapperMichael/commits{/sha}","git_commits_url":"https://api.github.com/repos/michaellightricks/ToneMapperMichael/git/commits{/sha}","comments_url":"https://api.github.com/repos/michaellightricks/ToneMapperMichael/comments{/number}","issue_comment_url":"https://api.github.com/repos/michaellightricks/ToneMapperMichael/issues/comments{/number}","contents_url":"https://api.github.com/repos/michaellightricks/ToneMapperMichael/contents/{+path}","compare_url":"https://api.github.com/repos/michaellightricks/ToneMapperMichael/compare/{base}...{head}","merges_url":"https://api.github.com/repos/michaellightricks/ToneMapperMichael/merges","archive_url":"https://api.github.com/repos/michaellightricks/ToneMapperMichael/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/michaellightricks/ToneMapperMichael/downloads","issues_url":"https://api.github.com/repos/michaellightricks/ToneMapperMichael/issues{/number}","pulls_url":"https://api.github.com/repos/michaellightricks/ToneMapperMichael/pulls{/number}","milestones_url":"https://api.github.com/repos/michaellightricks/ToneMapperMichael/milestones{/number}","notifications_url":"https://api.github.com/repos/michaellightricks/ToneMapperMichael/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/michaellightricks/ToneMapperMichael/labels{/name}","releases_url":"https://api.github.com/repos/michaellightricks/ToneMapperMichael/releases{/id}","deployments_url":"https://api.github.com/repos/michaellightricks/ToneMapperMichael/deployments","created_at":"2016-03-23T13:42:14Z","updated_at":"2016-03-23T12:45:36Z","pushed_at":"2016-05-01T09:09:48Z","git_url":"git://github.com/michaellightricks/ToneMapperMichael.git","ssh_url":"git@github.com:michaellightricks/ToneMapperMichael.git","clone_url":"https://github.com/michaellightricks/ToneMapperMichael.git","svn_url":"https://github.com/michaellightricks/ToneMapperMichael","homepage":null,"size":1616,"stargazers_count":0,"watchers_count":0,"language":null,"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":"amit-goldstein:master","ref":"master","sha":"8c9bc7ee3d163e2c6d098986314c98b3dd2837a2","user":{"login":"amit-goldstein","id":3172498,"avatar_url":"https://avatars.githubusercontent.com/u/3172498?v=3","gravatar_id":"","url":"https://api.github.com/users/amit-goldstein","html_url":"https://github.com/amit-goldstein","followers_url":"https://api.github.com/users/amit-goldstein/followers","following_url":"https://api.github.com/users/amit-goldstein/following{/other_user}","gists_url":"https://api.github.com/users/amit-goldstein/gists{/gist_id}","starred_url":"https://api.github.com/users/amit-goldstein/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amit-goldstein/subscriptions","organizations_url":"https://api.github.com/users/amit-goldstein/orgs","repos_url":"https://api.github.com/users/amit-goldstein/repos","events_url":"https://api.github.com/users/amit-goldstein/events{/privacy}","received_events_url":"https://api.github.com/users/amit-goldstein/received_events","type":"User","site_admin":false},"repo":{"id":54559095,"name":"ToneMapperMichael","full_name":"amit-goldstein/ToneMapperMichael","owner":{"login":"amit-goldstein","id":3172498,"avatar_url":"https://avatars.githubusercontent.com/u/3172498?v=3","gravatar_id":"","url":"https://api.github.com/users/amit-goldstein","html_url":"https://github.com/amit-goldstein","followers_url":"https://api.github.com/users/amit-goldstein/followers","following_url":"https://api.github.com/users/amit-goldstein/following{/other_user}","gists_url":"https://api.github.com/users/amit-goldstein/gists{/gist_id}","starred_url":"https://api.github.com/users/amit-goldstein/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amit-goldstein/subscriptions","organizations_url":"https://api.github.com/users/amit-goldstein/orgs","repos_url":"https://api.github.com/users/amit-goldstein/repos","events_url":"https://api.github.com/users/amit-goldstein/events{/privacy}","received_events_url":"https://api.github.com/users/amit-goldstein/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/amit-goldstein/ToneMapperMichael","description":"","fork":false,"url":"https://api.github.com/repos/amit-goldstein/ToneMapperMichael","forks_url":"https://api.github.com/repos/amit-goldstein/ToneMapperMichael/forks","keys_url":"https://api.github.com/repos/amit-goldstein/ToneMapperMichael/keys{/key_id}","collaborators_url":"https://api.github.com/repos/amit-goldstein/ToneMapperMichael/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/amit-goldstein/ToneMapperMichael/teams","hooks_url":"https://api.github.com/repos/amit-goldstein/ToneMapperMichael/hooks","issue_events_url":"https://api.github.com/repos/amit-goldstein/ToneMapperMichael/issues/events{/number}","events_url":"https://api.github.com/repos/amit-goldstein/ToneMapperMichael/events","assignees_url":"https://api.github.com/repos/amit-goldstein/ToneMapperMichael/assignees{/user}","branches_url":"https://api.github.com/repos/amit-goldstein/ToneMapperMichael/branches{/branch}","tags_url":"https://api.github.com/repos/amit-goldstein/ToneMapperMichael/tags","blobs_url":"https://api.github.com/repos/amit-goldstein/ToneMapperMichael/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/amit-goldstein/ToneMapperMichael/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/amit-goldstein/ToneMapperMichael/git/refs{/sha}","trees_url":"https://api.github.com/repos/amit-goldstein/ToneMapperMichael/git/trees{/sha}","statuses_url":"https://api.github.com/repos/amit-goldstein/ToneMapperMichael/statuses/{sha}","languages_url":"https://api.github.com/repos/amit-goldstein/ToneMapperMichael/languages","stargazers_url":"https://api.github.com/repos/amit-goldstein/ToneMapperMichael/stargazers","contributors_url":"https://api.github.com/repos/amit-goldstein/ToneMapperMichael/contributors","subscribers_url":"https://api.github.com/repos/amit-goldstein/ToneMapperMichael/subscribers","subscription_url":"https://api.github.com/repos/amit-goldstein/ToneMapperMichael/subscription","commits_url":"https://api.github.com/repos/amit-goldstein/ToneMapperMichael/commits{/sha}","git_commits_url":"https://api.github.com/repos/amit-goldstein/ToneMapperMichael/git/commits{/sha}","comments_url":"https://api.github.com/repos/amit-goldstein/ToneMapperMichael/comments{/number}","issue_comment_url":"https://api.github.com/repos/amit-goldstein/ToneMapperMichael/issues/comments{/number}","contents_url":"https://api.github.com/repos/amit-goldstein/ToneMapperMichael/contents/{+path}","compare_url":"https://api.github.com/repos/amit-goldstein/ToneMapperMichael/compare/{base}...{head}","merges_url":"https://api.github.com/repos/amit-goldstein/ToneMapperMichael/merges","archive_url":"https://api.github.com/repos/amit-goldstein/ToneMapperMichael/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/amit-goldstein/ToneMapperMichael/downloads","issues_url":"https://api.github.com/repos/amit-goldstein/ToneMapperMichael/issues{/number}","pulls_url":"https://api.github.com/repos/amit-goldstein/ToneMapperMichael/pulls{/number}","milestones_url":"https://api.github.com/repos/amit-goldstein/ToneMapperMichael/milestones{/number}","notifications_url":"https://api.github.com/repos/amit-goldstein/ToneMapperMichael/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/amit-goldstein/ToneMapperMichael/labels{/name}","releases_url":"https://api.github.com/repos/amit-goldstein/ToneMapperMichael/releases{/id}","deployments_url":"https://api.github.com/repos/amit-goldstein/ToneMapperMichael/deployments","created_at":"2016-03-23T12:45:36Z","updated_at":"2016-03-23T12:45:36Z","pushed_at":"2016-05-01T09:09:49Z","git_url":"git://github.com/amit-goldstein/ToneMapperMichael.git","ssh_url":"git@github.com:amit-goldstein/ToneMapperMichael.git","clone_url":"https://github.com/amit-goldstein/ToneMapperMichael.git","svn_url":"https://github.com/amit-goldstein/ToneMapperMichael","homepage":null,"size":0,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/amit-goldstein/ToneMapperMichael/pulls/1"},"html":{"href":"https://github.com/amit-goldstein/ToneMapperMichael/pull/1"},"issue":{"href":"https://api.github.com/repos/amit-goldstein/ToneMapperMichael/issues/1"},"comments":{"href":"https://api.github.com/repos/amit-goldstein/ToneMapperMichael/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/amit-goldstein/ToneMapperMichael/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/amit-goldstein/ToneMapperMichael/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/amit-goldstein/ToneMapperMichael/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/amit-goldstein/ToneMapperMichael/statuses/e96761c04ae7bd08b14e4d4382a8fc9b55791750"}}}}