{"id":308,"date":"2015-11-05T17:11:16","date_gmt":"2015-11-05T09:11:16","guid":{"rendered":"http:\/\/www.olinone.com\/?p=308"},"modified":"2015-12-05T14:27:01","modified_gmt":"2015-12-05T06:27:01","slug":"ios%e5%bc%80%e5%8f%91opengl%e6%96%b0%e6%89%8b%e5%85%a5%e9%97%a8","status":"publish","type":"post","link":"http:\/\/www.olinone.com\/?p=308","title":{"rendered":"iOS\u5f00\u53d1OpenGL\u65b0\u624b\u5165\u95e8"},"content":{"rendered":"<address class=\"\"><em>\u8f6c\u8f7d\u8bf7\u6ce8\u660e\u51fa\u5904:<a href=\"http:\/\/www.olinone.com\/\">http:\/\/www.olinone.com\/<\/a><\/em><\/address>\n<address class=\"\">\u5199\u5728\u524d\u5934\uff0c\u597d\u4e45\u6ca1\u6709\u66f4\u65b0\u535a\u5ba2\uff0c\u611f\u8c22\u8001\u670b\u53cb\u7684\u518d\u6b21\u6765\u8bbf\uff0c\u540c\u65f6\u4e5f\u6b22\u8fce\u65b0\u670b\u53cb~<\/address>\n<address class=\"\">\u8bf4\u8d77OpenGL\uff0c\u76f8\u4fe1\u5927\u4e0d\u591a\u6570\u670b\u53cb\u90fd\u4e0d\u4f1a\u964c\u751f\uff0c\u6216\u591a\u6216\u5c11\u90fd\u6709\u63a5\u89e6\u3002\u672c\u6587\u4e0d\u5c5e\u4e8eOpenGL\u63d0\u9ad8\u7bc7\uff0c\u4e3b\u8981\u76ee\u7684\u5728\u4e8e\u5e2e\u52a9\u65b0\u624b\u66f4\u5feb\u719f\u6089iOS\u4e2d\u5982\u4f55\u4f7f\u7528OpenGL\uff0c\u5173\u4e8e\u8fd9\u65b9\u9762\u7684\u4ecb\u7ecd\uff0c\u7f51\u4e0a\u4e5f\u6709\u5f88\u591a\uff0c\u672c\u6587\u4e3b\u8981\u4efb\u52a1\u5728\u4e8e\u6574\u7406\uff0c\u4ecb\u7ecd\u7a0d\u6709\u504f\u91cd\u3002<a href=\"https:\/\/github.com\/panghaijiao\/HJGLKViewControllerDemo\">\u8fd9\u91cc<\/a>\u6709\u6bd4\u8f83\u5b8c\u6574\u7684Demo\uff0c\u53ef\u4ee5\u534f\u52a9\u5927\u5bb6\u66f4\u5feb\u4e0a\u624b<\/address>\n<h3>OpenGL\u7248\u672c<\/h3>\n<p>iOS\u7cfb\u7edf\u9ed8\u8ba4\u652f\u6301OpenGl ES1.0\u3001ES2.0\u4ee5\u53caES3.0 3\u4e2a\u7248\u672c\uff0c\u4e09\u8005\u4e4b\u95f4\u5e76\u4e0d\u662f\u7b80\u5355\u7684\u7248\u672c\u5347\u7ea7\uff0c\u8bbe\u8ba1\u7406\u5ff5\u751a\u81f3\u5b8c\u5168\u4e0d\u540c\uff0c\u5728\u5f00\u53d1OpenGL\u9879\u76ee\u524d\uff0c\u9700\u8981\u6839\u636e\u4e1a\u52a1\u9700\u6c42\u9009\u62e9\u5408\u9002\u7684\u7248\u672c\u3002\u8fd9\u65b9\u9762\u7684<a href=\"http:\/\/sdgdfgdsfgfg.iteye.com\/blog\/1113829\">\u4ecb\u7ecd<\/a>\u4e0d\u5c11\uff0c\u4e0d\u518d\u5c55\u5f00\u3002\u5728\u5b66\u4e60OpenGL\u4ee3\u7801\u7684\u65f6\u5019\u4e5f\u9700\u8981\u77e5\u9053\u5b83\u5bf9\u5e94\u7740\u54ea\u4e2a\u7248\u672c\uff0c\u5728ES1\u4e2d\u6267\u884cES2\u4ee3\u7801\u662f\u770b\u4e0d\u5230\u4efb\u4f55\u6548\u679c\u7684\uff0c\u4f60\u53ef\u4ee5\u5728\u521d\u59cb\u5316EAGLContext\u65f6\u6307\u5b9aES\u7248\u672c\u53f7<\/p>\n<pre class=\"lang:objc highlight:0 decode:true\">EAGLContext *context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES1];<\/pre>\n<h3>OpenGL\u5750\u6807\u7cfb<\/h3>\n<p>OpenGL\u5750\u6807\u7cfb\u4e0d\u540c\u4e8eUIKit\u5750\u6807\u7cfb\uff0c\u5176\u5b9e\u5b83\u662f\u8fd9\u6837\u7684<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone\" src=\"http:\/\/cc.cocimg.com\/api\/uploads\/20151109\/1447037947251885.png\" alt=\"\" width=\"230\" height=\"205\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>\u9664\u4e86\u65b9\u5411\uff0c\u8fd8\u6709\u4e00\u70b9\u9700\u8981\u6ce8\u610f\uff0c\u9ed8\u8ba4\u60c5\u51b5\u5404\u4e2a\u65b9\u5411\u5750\u6807\u503c\u8303\u56f4\u4e3a\uff08-1\uff0c1\uff09\uff0c\u800c\u4e0d\u662fUIKit\u4e2d\u7684\uff080\uff0c320\uff09\u3002\u5f53\u7ed8\u5236\u70b9(320\uff0c0)\uff0c\u5b83\u5e76\u4e0d\u4f1a\u51fa\u73b0\u5728\u5c4f\u5e55\u53f3\u4e0a\u89d2\u3002\u5728ES1\u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u4ee3\u7801\u5c06\u5750\u6807\u7cfb\u8f6c\u5316\u4e3a\u719f\u6089\u7684\uff08320\uff0c480\uff09<\/p>\n<pre class=\"lang:objc highlight:0 decode:true\">- (void)glkView:(GLKView *)view drawInRect:(CGRect)rect {\r\n    glViewport(0, 0, rect.size.width * 2, rect.size.height * 2);\r\n    glMatrixMode(GL_PROJECTION);\r\n    glLoadIdentity();\r\n    glOrthof(0, 320, 0, 480, -1024, 1024);\r\n    glMatrixMode(GL_MODELVIEW);\r\n    glLoadIdentity();\r\n}<\/pre>\n<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; \u00a0 \u00a0<strong>olinone\u51fa\u54c1<\/strong> \u00a0 \u00a0\u00a0&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<\/p>\n<p>\u7325\u7410\u7684\u5206\u5272\u7ebf\u8fc7\u540e\uff0c\u63a5\u4e0b\u6765\u8bf4\u8bf4iOS\u4e2d\u5982\u4f55\u4f7f\u7528OpenGL<\/p>\n<h3 class=\"p1\"><span class=\"s1\">GLKViewController &amp; GLKView<\/span><\/h3>\n<p class=\"p1\">\u673a\u667a\u7684\u7801\u519c\u662f\u4e0d\u662f\u5df2\u7ecf\u53d1\u73b0\u8fd9\u4e24\u4e2a\u5bf9\u8c61\uff0c \u4e3a\u4e86\u65b9\u4fbf\u5927\u5bb6\u66f4\u5feb\u7684\u5f00\u53d1\uff0c\u7cfb\u7edf\u4e3aOpenGL\u63d0\u4f9b\u4e86\u7b80\u5355\u7684\u5c01\u88c5\uff0c\u7ee7\u627fGLKViewController\u5b9a\u4e49\u81ea\u5df1\u7684ViewController\uff0cGLKViewController\u7684view\u4e3aGLKView\u7c7b\uff0cGLKView\u7684delegate\u5b9a\u4e49\u4e86\u7ed8\u5236\u56de\u8c03\u51fd\u6570<\/p>\n<pre class=\"lang:objc highlight:0 decode:true\">- (void)glkView:(GLKView *)view drawInRect:(CGRect)rect<\/pre>\n<p>GLKViewController\u5b9a\u4e49\u6570\u636e\u5237\u65b0\u51fd\u6570\uff0c\u5f53\u5b50\u7c7b\u5b9e\u73b0-(void)update\u65b9\u6cd5\uff0cglkViewControllerUpdate\u65b9\u6cd5\u5c06\u4e0d\u518d\u88ab\u8c03\u7528<\/p>\n<pre class=\"lang:objc highlight:0 decode:true\">- (void)glkViewControllerUpdate:(GLKViewController *)controller\r\n<\/pre>\n<p><a href=\"https:\/\/github.com\/panghaijiao\/HJGLKViewControllerDemo\">HJGLKViewControllerDemo<\/a>\u6a21\u62df\u4e86GLKViewController\u65b9\u6cd5\u5b9e\u73b0\uff0c\u6709\u5174\u8da3\u7684\u7ae5\u978b\u53ef\u4ee5\u67e5\u770bGLKViewController\u5185\u90e8\u5b9e\u73b0\u673a\u5236\u3002\u9700\u8981\u8865\u5145\u4e00\u70b9\uff0c\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0cGLKViewController\u6e32\u67d3RunLoop\u5e76\u975eNSRunLoopCommonModes\uff0c\u800c\u662fNSDefaultRunLoopMode\uff0c\u56e0\u6b64\u5728UIKit\u4e2d\u4f7f\u7528GLKViewController\uff0c\u5f53\u6ed1\u52a8\u754c\u9762\u65f6\uff0cOpenGL\u662f\u4e0d\u4f1a\u6e32\u67d3\u7684\uff0c\u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0c\u53ef\u4ee5\u4f7f\u7528HJGLKViewController\u66ff\u6362GLKViewController\uff0cHJGLKViewController\u4e2d\u9ed8\u8ba4\u6e32\u67d3RunLoop\u4f7f\u7528NSRunLoopCommonModes\u6a21\u5f0f<\/p>\n<h3 class=\"p1\"><span class=\"s1\">EAGLContext<\/span><\/h3>\n<p class=\"p1\">\u5728\u4ecb\u7ecd\u9009\u62e9\u7248\u672c\u65f6\u5df2\u7ecf\u63d0\u5230EAGLContext\uff0c\u4e0eUIKit\u4e2dCGContextRef\u76f8\u4f3c\uff0cEAGLContext\u76f8\u5f53\u4e8eOpenGL\u7ed8\u5236\u53e5\u67c4\u6216\u8005\u4e0a\u4e0b\u6587\uff0c\u5728\u7ed8\u5236\u8bd5\u56fe\u4e4b\u524d\uff0c\u9700\u8981\u6307\u5b9a\u4f7f\u7528\u521b\u5efa\u7684\u4e0a\u4e0b\u6587\u7ed8\u5236<\/p>\n<pre class=\"lang:objc highlight:0 decode:true \">[EAGLContext setCurrentContext:view.context];<\/pre>\n<p>\u5f53\u4e00\u4e2aAPP\u53ef\u80fd\u5b58\u5728\u591a\u4e2aEAGLContext\u65f6\uff0c\u9700\u8981\u5904\u7406\u5e76\u5b58\u51b2\u7a81\u7b49\u95ee\u9898\uff0c\u6bd4\u5982\u5927\u5bb6\u6240\u719f\u77e5\u7684<a href=\"https:\/\/github.com\/BradLarson\/GPUImage\">GPUImage<\/a>\uff0c\u90fd\u4f1a\u4f7f\u7528\u5230EAGLContext\u3002\u56e0\u6b64\uff0c\u5728\u4f7f\u7528\u4e2d\u8981\u8bb0\u5f97\u53ca\u65f6\u91ca\u653e\u3002\u6709\u5174\u8da3\u7684\u670b\u53cb\u53ef\u4ee5\u770b\u770b\u8fd9\u7bc7<a href=\"http:\/\/blog.csdn.net\/mengtnt\/article\/details\/7773279\">\u6587\u7ae0<\/a><\/p>\n<h3>Draw<\/h3>\n<p>OpenGL\u7ed8\u5236\u672c\u6587\u5c31\u4e0d\u505a\u4ecb\u7ecd\uff0c<a href=\"https:\/\/github.com\/panghaijiao\/HJGLKViewControllerDemo\">HJGLKViewControllerDemo<\/a>\u4e2d\u6709\u5927\u91cf\u7684\u793a\u4f8b\uff0c\u987a\u4fbf\u63a8\u8350\u51e0\u7bc7\u76f8\u5173\u6587\u7ae0<\/p>\n<ol>\n<li><a href=\"http:\/\/www.cocoachina.com\/game\/20141127\/10335.html\">\u8be6\u89e3\u7b2c\u4e00\u4e2aOpenGL\u7a0b\u5e8f<\/a><\/li>\n<li><a href=\"http:\/\/www.cocoachina.com\/special\/2010\/0126\/404.html\">\u897f\u8499iPhone-OpenGL ES \u4e2d\u6587\u6559\u7a0b\u4e13\u9898<\/a><\/li>\n<li><a href=\"http:\/\/cocos2d.org\/\">Cocos2d\u6e90\u7801<\/a><\/li>\n<\/ol>\n<p><em>\u5c0f\u8d34\u58eb\uff1a\u5f53App\u9000\u5230\u540e\u53f0\u65f6\uff0c \u5207\u8bb0\u6682\u505cOpenGL\u7ed8\u5236\uff0c\u5426\u5219\u53ef\u80fd\u5bfc\u81f4crash<\/em><\/p>\n<hr \/>\n<p>&nbsp;<\/p>\n<p><strong>\u540e\u8bb0\uff1a<a href=\"https:\/\/github.com\/iOS-Developer-Documents-Chinese\/iOS-Developer-Documents-Chinese\">iOS-Developer-Documents-Chinese<\/a>\u662f\u56fd\u5185\u7b2c\u4e00\u4e2a\u82f9\u679c\u6587\u6863\u7ffb\u8bd1\u7ec4\u7ec7\uff0c\u6b22\u8fce\u6709\u5fd7\u7ffb\u8bd1\u82f9\u679c\u5b98\u65b9\u6587\u6863\u7684\u670b\u53cb\u52a0\u5165\uff0cQQ\u7fa4\uff1a486111671<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8f6c\u8f7d\u8bf7\u6ce8\u660e\u51fa\u5904:http:\/\/www.olinone.com\/ \u5199\u5728\u524d\u5934\uff0c\u597d\u4e45\u6ca1\u6709\u66f4\u65b0\u535a\u5ba2\uff0c\u611f\u8c22\u8001\u670b\u53cb\u7684\u518d\u6b21\u6765\u2026 <span class=\"read-more\"><a href=\"http:\/\/www.olinone.com\/?p=308\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[7],"tags":[],"_links":{"self":[{"href":"http:\/\/www.olinone.com\/index.php?rest_route=\/wp\/v2\/posts\/308"}],"collection":[{"href":"http:\/\/www.olinone.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.olinone.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.olinone.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.olinone.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=308"}],"version-history":[{"count":19,"href":"http:\/\/www.olinone.com\/index.php?rest_route=\/wp\/v2\/posts\/308\/revisions"}],"predecessor-version":[{"id":397,"href":"http:\/\/www.olinone.com\/index.php?rest_route=\/wp\/v2\/posts\/308\/revisions\/397"}],"wp:attachment":[{"href":"http:\/\/www.olinone.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=308"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.olinone.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=308"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.olinone.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=308"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}