{"id":45,"date":"2020-11-27T19:38:00","date_gmt":"2020-11-27T11:38:00","guid":{"rendered":"https:\/\/blog.51time.top\/?p=45"},"modified":"2022-01-14T16:44:14","modified_gmt":"2022-01-14T08:44:14","slug":"macopengl","status":"publish","type":"post","link":"https:\/\/blog.51time.top\/index.php\/2020\/11\/27\/macopengl\/","title":{"rendered":"Mac\u4e0bOpenGL\u8d85\u7ea7\u5b9d\u5178\u7b2c\u4e03\u7248\u7eb9\u7406\u5750\u6807\u4ee3\u7801\u95ee\u9898"},"content":{"rendered":"<h3>\u95ee\u9898<\/h3>\n<ul>\n<li>\u539f\u6587P107\u7684simpletexcoords\u8fd9\u4e2a\u4f8b\u5b50\uff0c\u914d\u5957\u7684sb7code\u4e0b\u6e90\u7801\u5728Mac\u4e0b\u8fd0\u884c\u540e\u7cfb\u7edf\u9519\u8bef\uff1a<br \/>\n<figure class=\"mdx-lazyload-container\" style=\"\"><div style=\"padding-top:50%\"><\/div><div class=\"mdx-img-loading-sp mdui-valign\"><div><div class=\"mdui-spinner\"><\/div><\/div><\/div><img class=\"lazyload\" title=\"Mac\u4e0bOpenGL\u8d85\u7ea7\u5b9d\u5178\u7b2c\u4e03\u7248\u7eb9\u7406\u5750\u6807\u4ee3\u7801\u95ee\u9898\" src=\"data:image\/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==\" data-src=\"https:\/\/blog.51time.top\/wp-content\/uploads\/2020\/11\/\u622a\u5c4f2020-11-27-\u4e0a\u534810.29.48-300x240.png\" alt=\"https:\/\/blog.51time.top\/wp-content\/uploads\/2020\/11\/\u622a\u5c4f2020-11-27-\u4e0a\u534810.29.48-300x240.png\"><\/figure><\/li>\n<li>\u4ece\u56fe\u4e0a\u53ef\u4ee5\u770b\u51fa\u662fobject\u7c7b\u4e0b\u7684render_sub_object\u8fd9\u4e2a\u51fd\u6570\u7684\u95ee\u9898\u3002\u4f46\u662f\u8fd9\u4e2a\u51fd\u6570\u662f\u88ab\u5c01\u88c5\u5728libsb7.dylib\u5e93\u91cc\u7684\uff0c\u9700\u8981\u4fee\u6539\u6e90\u4ee3\u7801\u5e76\u91cd\u65b0\u7f16\u8bd1\u3002<\/li>\n<\/ul>\n<h3>\u539f\u56e0\u5206\u6790<\/h3>\n<ul>\n<li>\n<p>\u6253\u5f00sb7object.cpp\u6e90\u6587\u4ef6\uff0c\u770b\u5230render_sub_object\u8fd9\u4e2a\u51fd\u6570\u91cc\uff0c\u7528\u4e86glDrawElementsInstancedBaseInstance \u548c glDrawArraysInstancedBaseInstance \u8fd9\u4e24\u4e2aGL\u51fd\u6570\u3002\u67e5\u8be2OpenGL\u6587\u6863\uff0c\u53d1\u73b0\u8fd9\u4e24\u4e2a\u51fd\u6570\u662fOpenGL 4.2\u7248\u672c\u624d\u51fa\u73b0\u7684\u3002\u800cMac\u6700\u9ad8\u652f\u6301\u52304.1\u7248\u672c\uff0c\u6240\u4ee5\u4e0a\u9762\u62a5\u7cfb\u7edf\u9519\u8bef\u539f\u56e0\u5c31\u5728\u4e8e\u6b64\u3002<\/p>\n<\/li>\n<li>\n<p>\u5177\u4f53\u7248\u672c\u548c\u529f\u80fd\uff0c\u53c2\u8003\u5982\u4e0b\u94fe\u63a5\uff1a<br \/>\n<a href=\"https:\/\/www.shuzhiduo.com\/A\/VGzlVb415b\/\">https:\/\/www.shuzhiduo.com\/A\/VGzlVb415b\/<\/a><\/p>\n<\/li>\n<\/ul>\n<h3>\u89e3\u51b3\u65b9\u6cd5<\/h3>\n<ol>\n<li>\u4fee\u6539sb7object.cpp\u548cobject.h\u6587\u4ef6\uff0c\u5c064.2\u7248\u672c\u7684\u8fd9\u4e24\u4e2a\u51fd\u6570\uff0c\u6539\u6210\u652f\u63014.1\u7684glDrawElementsInstanced \u548c glDrawArraysInstanced \u3002\u524d\u8005\u591a\u4e00\u4e2abaseinstance\u53c2\u6570\uff0c\u5206\u522b\u5220\u9664\u6389\u5373\u53ef\u3002<\/li>\n<\/ol>\n<pre><code class=\"language-cpp\">void glDrawElementsInstancedBaseInstance(   GLenum mode,\n    GLsizei count,\n    GLenum type,\n    const void * indices,\n    GLsizei instancecount,\n    GLuint baseinstance);<\/code><\/pre>\n<p>\u6539\u6210<\/p>\n<pre><code class=\"language-cpp\">void glDrawElementsInstanced(   GLenum mode,\n    GLsizei count,\n    GLenum type,\n    const void * indices,\n    GLsizei instancecount);<\/code><\/pre>\n<pre><code class=\"language-cpp\">void glDrawArraysInstancedBaseInstance( GLenum mode,\n    GLint first,\n    GLsizei count,\n    GLsizei instancecount,\n    GLuint baseinstance);<\/code><\/pre>\n<p>\u6539\u6210<\/p>\n<pre><code class=\"language-cpp\">void glDrawArraysInstanced( GLenum mode,\n    GLint first,\n    GLsizei count,\n    GLsizei instancecount);<\/code><\/pre>\n<ol start=\"2\">\n<li>\u91cd\u65b0\u7f16\u8bd1\u5e93\u6587\u4ef6\u3002<\/li>\n<\/ol>\n<pre><code class=\"language-shell\">$git clone https:\/\/github.com\/shawhen\/sb7framework.git\n$cd sb7framework\n$mkdir build\n$cd build\n$cmake ..\n$make<\/code><\/pre>\n<ol start=\"3\">\n<li>\u5c06\u5e93\u6587\u4ef6\u548c\u5934\u6587\u4ef6\u653e\u5165\u76f8\u5e94\u4f4d\u7f6e\u3002<\/li>\n<\/ol>\n<pre><code class=\"language-shell\">$cp lib\/libsb7.dylib \/usr\/local\/lib\/\n$cd ..\n$cp include\/object.h \/usr\/local\/include\/<\/code><\/pre>\n<ol start=\"4\">\n<li>\u91cd\u65b0\u7f16\u8bd1\u8fd0\u884csimpletexcoords\u4ee3\u7801\uff0c\u770b\u5230\u4e86\u7ed3\u679c\u3002<\/li>\n<\/ol>\n<pre><code class=\"language-shell\">$cd simpletexcoords\/build\/\n$cmake ..\n$.\/simpletexcoords<\/code><\/pre>\n<p><figure class=\"mdx-lazyload-container\" style=\"\"><div style=\"padding-top:50%\"><\/div><div class=\"mdx-img-loading-sp mdui-valign\"><div><div class=\"mdui-spinner\"><\/div><\/div><\/div><img class=\"lazyload\" title=\"Mac\u4e0bOpenGL\u8d85\u7ea7\u5b9d\u5178\u7b2c\u4e03\u7248\u7eb9\u7406\u5750\u6807\u4ee3\u7801\u95ee\u9898\" src=\"data:image\/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==\" data-src=\"https:\/\/blog.51time.top\/wp-content\/uploads\/2020\/11\/\u622a\u5c4f2020-11-27-\u4e0a\u534810.32.34-300x224.png\" alt=\"https:\/\/blog.51time.top\/wp-content\/uploads\/2020\/11\/\u622a\u5c4f2020-11-27-\u4e0a\u534810.32.34-300x224.png\"><\/figure><br \/>\n<figure class=\"mdx-lazyload-container\" style=\"\"><div style=\"padding-top:50%\"><\/div><div class=\"mdx-img-loading-sp mdui-valign\"><div><div class=\"mdui-spinner\"><\/div><\/div><\/div><img class=\"lazyload\" title=\"Mac\u4e0bOpenGL\u8d85\u7ea7\u5b9d\u5178\u7b2c\u4e03\u7248\u7eb9\u7406\u5750\u6807\u4ee3\u7801\u95ee\u9898\" src=\"data:image\/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==\" data-src=\"https:\/\/blog.51time.top\/wp-content\/uploads\/2020\/11\/\u622a\u5c4f2020-11-27-\u4e0a\u534810.32.52-300x224.png\" alt=\"https:\/\/blog.51time.top\/wp-content\/uploads\/2020\/11\/\u622a\u5c4f2020-11-27-\u4e0a\u534810.32.52-300x224.png\"><\/figure><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u95ee\u9898 \u539f\u6587P107\u7684simpletexcoords\u8fd9\u4e2a\u4f8b\u5b50\uff0c\u914d\u5957\u7684sb7code\u4e0b\u6e90\u7801\u5728Mac\u4e0b\u8fd0\u884c\u540e\u7cfb\u7edf\u9519\u8bef [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[6],"tags":[],"_links":{"self":[{"href":"https:\/\/blog.51time.top\/index.php\/wp-json\/wp\/v2\/posts\/45"}],"collection":[{"href":"https:\/\/blog.51time.top\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.51time.top\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.51time.top\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.51time.top\/index.php\/wp-json\/wp\/v2\/comments?post=45"}],"version-history":[{"count":1,"href":"https:\/\/blog.51time.top\/index.php\/wp-json\/wp\/v2\/posts\/45\/revisions"}],"predecessor-version":[{"id":49,"href":"https:\/\/blog.51time.top\/index.php\/wp-json\/wp\/v2\/posts\/45\/revisions\/49"}],"wp:attachment":[{"href":"https:\/\/blog.51time.top\/index.php\/wp-json\/wp\/v2\/media?parent=45"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.51time.top\/index.php\/wp-json\/wp\/v2\/categories?post=45"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.51time.top\/index.php\/wp-json\/wp\/v2\/tags?post=45"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}