{"id":1343,"date":"2024-08-25T16:48:30","date_gmt":"2024-08-25T16:48:30","guid":{"rendered":"https:\/\/www.gislxz.com\/?p=1343"},"modified":"2024-09-12T08:05:15","modified_gmt":"2024-09-12T08:05:15","slug":"qtopengl%e5%ad%a6%e4%b9%a0%e7%ac%94%e8%ae%b0%ef%bc%882%ef%bc%89","status":"publish","type":"post","link":"https:\/\/www.gislxz.com\/index.php\/2024\/08\/25\/qtopengl%e5%ad%a6%e4%b9%a0%e7%ac%94%e8%ae%b0%ef%bc%882%ef%bc%89\/","title":{"rendered":"QT+OpenGL\u5b66\u4e60\u7b14\u8bb0\uff082\uff09"},"content":{"rendered":"\n<p>OpenGL\u57fa\u7840\u77e5\u8bc6\u7684\u5b66\u4e60\u544a\u4e00\u6bb5\u843d\uff0c\u6bd5\u7adf\u6211\u60f3\u53ea\u7528OpenGL\u7ed8\u5236\u5e73\u9762\u7684\u77e2\u91cf\u56fe\u5f62\u800c\u5df2\uff0c\u63a5\u4e0b\u6765\u5f00\u59cb\u5b9e\u9a8c\u7528qt\u3001gdal\u3001opengl\u8fdb\u884c\u77e2\u91cf\u7ed8\u5236\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u591a\u8fb9\u5f62\u7ed8\u5236<\/h2>\n\n\n\n<p>\u9996\u5148OpenGL\u867d\u7136\u53ef\u4ee5\u7ed8\u5236\u591a\u8fb9\u5f62\uff0c\u4f46\u4e0d\u652f\u6301\u51f9\u591a\u8fb9\u5f62\u3002\u800c\u4e14\u8fd9\u79cd\u56fa\u5b9a\u7ba1\u7ebf\u7684\u7ed8\u5236\u65b9\u6cd5\u5df2\u7ecf\u88ab\u6dd8\u6c70\u4e86\uff0c\u6bcf\u6b21\u90fd\u8981\u4f20\u8f93\u5750\u6807\u4fe1\u606f\u7ed9\u663e\u5b58\uff0c\u5bf9\u4e8e\u5927\u89c4\u6a21\u77e2\u91cf\u7684\u6e32\u67d3\u6765\u8bf4\u662f\u4e0d\u73b0\u5b9e\u7684\u3002<\/p>\n\n\n\n<p><a href=\"https:\/\/hanshuliang.blog.csdn.net\/article\/details\/112855351?spm=1001.2101.3001.6650.3&amp;utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromBaidu%7ERate-3-112855351-blog-123678157.235%5Ev43%5Epc_blog_bottom_relevance_base7&amp;depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromBaidu%7ERate-3-112855351-blog-123678157.235%5Ev43%5Epc_blog_bottom_relevance_base7&amp;utm_relevant_index=6\" target=\"_blank\"  rel=\"nofollow\" >\u3010OpenGL\u3011\u5341\u516b\u3001OpenGL \u7ed8\u5236\u591a\u8fb9\u5f62 ( \u7ed8\u5236 GL_POLYGON \u6a21\u5f0f\u591a\u8fb9\u5f62 )_glut\u7ed8\u5236\u591a\u8fb9\u5f62-CSDN\u535a\u5ba2<\/a><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\t\/\/ \u53ea\u663e\u793a\u6b63\u9762 , \u4e0d\u663e\u793a\u80cc\u9762\n\t\/\/glEnable(GL_CULL_FACE);\n\n\t\/\/ \u8bbe\u7f6e\u987a\u65f6\u9488\u65b9\u5411 CW : Clock Wind \u987a\u65f6\u9488\u65b9\u5411\n\t\/\/ \u9ed8\u8ba4\u662f GL_CCW : Counter Clock Wind \u9006\u65f6\u9488\u65b9\u5411 \n\t\/\/glFrontFace(GL_CW);\n\n    \/\/ \u4e3b\u6d88\u606f\u5faa\u73af:\n    while (GetMessage(&amp;msg, nullptr, 0, 0))\n    {\n        if (!TranslateAccelerator(msg.hwnd, hAccelTable, &amp;msg))\n        {\n            TranslateMessage(&amp;msg);\n            DispatchMessage(&amp;msg);\n        }\n\n\t\t\/\/ \u6e32\u67d3\u573a\u666f\n\n\t\t\/\/ \u6e05\u9664\u7f13\u51b2\u533a , \n\t\t\/\/ \u4f7f\u7528\u4e4b\u524d\u8bbe\u7f6e\u7684 glClearColor(1.0, 0.0, 0.0, 1.0) \u64e6\u9664\u989c\u8272\u7f13\u51b2\u533a\n\t\t\/\/ \u7ea2\u8272\u80cc\u666f\n\t\tglClear(GL_COLOR_BUFFER_BIT);\n\n        \/\/ \u8bbe\u7f6e\u5f53\u524d\u7684\u7ed8\u5236\u989c\u8272 , 4 \u4e2a unsigned byte \n        \/\/ \u6bcf\u4e2a\u989c\u8272\u7684\u5206\u91cf\u5360\u4e00\u4e2a\u5b57\u8282\n        \/\/ \u53c2\u6570\u6570\u636e\u662f R \u7ea2\u8272 G \u7eff\u8272 B \u84dd\u8272 A \u900f\u660e\u5ea6\n        \/\/ \u4e0b\u9762\u8bbe\u7f6e\u7684\u542b\u4e49\u662f\u767d\u8272, \u7ed8\u5236\u70b9\u7684\u65f6\u5019, \u6bcf\u6b21\u90fd\u4f7f\u7528\u767d\u8272\u7ed8\u5236\n        glColor4ub(255, 255, 255, 255);\n\n\t\t\/\/ \u8bbe\u7f6e\u7ebf\u7684\u5bbd\u5ea6 \n\t\tglLineWidth(2.0f);\n\n        \/\/glBegin(GL_POINTS);\t\/\/ \u7ed8\u5236\u70b9\n        \/\/glBegin(GL_LINES);\t\/\/ \u7ed8\u5236\u7ebf\n\t\t\/\/glBegin(GL_LINE_STRIP);\/\/ \u7ed8\u5236\u524d\u540e\u8fde\u63a5\u7684\u70b9\u7ec4\u6210\u7684\u7ebf\n        \/\/glBegin(GL_LINE_LOOP); \/\/ \u7ed8\u5236\u524d\u540e\u8fde\u63a5\u7684\u70b9\u7ec4\u6210\u7684\u7ebf , \u5e76\u4e14\u6536\u5c3e\u76f8\u8fde\n        \/\/glBegin(GL_TRIANGLES); \/\/ \u7ed8\u5236\u591a\u4e2a\u4e09\u89d2\u5f62\n        \/\/glBegin(GL_TRIANGLE_STRIP); \/\/ \u7ed8\u5236 GL_TRIANGLE_STRIP \u4e09\u89d2\u5f62\n\t\t\/\/glBegin(GL_TRIANGLE_FAN);\t\/\/ \u7ed8\u5236\u4e09\u89d2\u5f62\u6247\n\n\t\t\/\/ \u7ed8\u5236\u591a\u8fb9\u5f62\n        glBegin(GL_POLYGON);\n\n\t\t\/\/ 1. \u8bbe\u7f6e\u767d\u8272 , glVertex3f (GLfloat x, GLfloat y, GLfloat z)\n\t\tglColor4ub(255, 255, 255, 255);\n        glVertex3f(0.0f, 0.0f, -10.0f);\n\n\t\t\/\/ 2. \u8bbe\u7f6e\u7eff\u8272 \n\t\tglColor4ub(0, 255, 0, 255);\n\t\tglVertex3f(-5.0f, 0.0f, -10.0f);\n\n\t\t\/\/ 3. \u8bbe\u7f6e\u84dd\u8272\n\t\tglColor4ub(0, 0, 255, 255);\n\t\tglVertex3f(-5.0f, -2.0f, -10.0f);\n\n\t\t\/\/ 4. \u8bbe\u7f6e\u7eff\u8272 \n\t\tglColor4ub(0, 255, 0, 255);\n\t\tglVertex3f(0.0f, -2.0f, -10.0f);\n\n\n\n\t\t\/\/ 5. \u8bbe\u7f6e\u767d\u8272 , glVertex3f (GLfloat x, GLfloat y, GLfloat z)\n\t\tglColor4ub(255, 255, 255, 255);\n\t\tglVertex3f(0.0f, 4.0f, -10.0f);\n\n\t\t\/\/ 6. \u8bbe\u7f6e\u7eff\u8272 \n\t\tglColor4ub(0, 255, 0, 255);\n\t\tglVertex3f(-5.0f, 4.0f, -10.0f);\n\n\t\t\n        \/\/ \u7ed8\u5236\u56db\u8fb9\u5f62\u7ed3\u675f\n        glEnd();\n\n\t\t\/\/ \u5c06\u540e\u7f13\u51b2\u533a\u7ed8\u5236\u5230\u524d\u53f0\n\t\tSwapBuffers(dc);\n\n    }\n<\/code><\/pre>\n\n\n\n<p>\u53ef\u7f16\u7a0b\u7ba1\u7ebf\uff0c\u4e5f\u5c31\u662fVBO\uff0cVAO\u7684\u6a21\u5f0f\uff0c\u5c40\u9650\u6027\u5728\u4e8e\u53ea\u80fd\u7ed8\u5236\u70b9\u7ebf\u4e09\u89d2\u5f62\uff0c\u6211\u4eec\u9700\u8981\u628a\u77e2\u91cf\u591a\u8fb9\u5f62\u5148\u5256\u5206\u6210\u4e09\u89d2\u5f62\u3002CGAL\u5e93\u592a\u91cd\u4e86\uff0c\u6211\u9009\u7528Poly2Tri\u5e93\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u4e09\u89d2\u5f62\u5256\u5206 CLipper2\u548cPoly2Tri\u5e93\u914d\u7f6e<\/h3>\n\n\n\n<p>\u672c\u6765\u6253\u7b97\u7528Clipper2\u5e93\u7684\uff0c\u4f46\u662f\u53d1\u73b0Clipper2\u4e0d\u80fd\u8fdb\u884c\u4e09\u89d2\u5f62\u5256\u5206\uff0c\u4f46\u662f\u8fd9\u4e2a\u5e93\u529f\u80fd\u8fd8\u633a\u591a\u7684\uff0c\u5148\u8bb0\u5f55\u4e00\u4e0b\u4ee5\u9632\u4ee5\u540e\u7528\u3002<\/p>\n\n\n\n<p><a href=\"https:\/\/github.com\/AngusJohnson\/Clipper2\" target=\"_blank\"  rel=\"nofollow\" >https:\/\/github.com\/AngusJohnson\/Clipper2<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/www.cnblogs.com\/yuchq\/articles\/17876382.html\" target=\"_blank\"  rel=\"nofollow\" >CLipper2 \u7f16\u8bd1\u8bb0\u5f55 - yuchq - \u535a\u5ba2\u56ed (cnblogs.com)<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/blog.csdn.net\/ithiker\/article\/details\/126579448\" target=\"_blank\"  rel=\"nofollow\" >Clipper2\u4e2d\u7684\u672f\u8bed\u548c\u57fa\u672c\u6982\u5ff5-CSDN\u535a\u5ba2<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/blog.csdn.net\/lovely_yoshino\/article\/details\/129301527\" target=\"_blank\"  rel=\"nofollow\" >cmake \u5f15\u5165\u7b2c\u4e09\u65b9\u5e93\uff08\u5934\u6587\u4ef6\u76ee\u5f55\u3001\u5e93\u76ee\u5f55\u3001\u5e93\u6587\u4ef6\uff09_qt cmake \u5c06\u7b2c\u4e09\u65b9\u5e93\u52a0\u5165\u5230\u81ea\u5df1\u5de5\u7a0b-CSDN\u535a\u5ba2<\/a><\/p>\n\n\n\n<p>Clipper2\u5e93\u7ed9\u4e86VS\u5de5\u7a0b\u6587\u4ef6\uff0c\u76f4\u63a5\u751f\u6210dll\u548clib\uff0c\u5148\u5728cmake\u7528\u7edd\u5bf9\u8def\u5f84\u5bfc\u5165\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># \u5305\u542b\u5934\u6587\u4ef6\u76ee\u5f55\ninclude_directories(\"D:\\\\coding\\\\libs\\\\Clipper2-main\\\\CPP\\\\Clipper2Lib\\\\include\")\n# \u5bfc\u5165\u5e93\nlink_libraries(\"D:\\\\coding\\\\libs\\\\Clipper2-main\\\\DLL\\\\CPP_DLL\\\\x64\\\\Debug\")<\/code><\/pre>\n\n\n\n<p>\u4e09\u89d2\u5f62\u5256\u5206\u76f4\u63a5\u7528Poly2Tri<\/p>\n\n\n\n<p><a href=\"https:\/\/github.com\/jhasse\/poly2tri\" target=\"_blank\"  rel=\"nofollow\" >https:\/\/github.com\/jhasse\/poly2tri<\/a><\/p>\n\n\n\n<p>\u7f16\u8bd1\u65f6\u9047\u5230\u5927\u9ebb\u70e6\u3002\u9996\u5148\u662fninja\u7f16\u8bd1\uff0c\u5176\u6b21\u53ea\u80fd\u52a8\u6001\u7f16\u8bd1\uff0c\u6d6a\u8d39\u4e86\u56db\u5c0f\u65f6\uff0c\u5199\u4e2a\u7b14\u8bb0\u65b9\u4fbf\u540e\u4eba\u4e86<\/p>\n\n\n\n<p><a href=\"https:\/\/www.bilibili.com\/read\/cv37627345\/\" target=\"_blank\"  rel=\"nofollow\" >MSVC2022 poly2tri\u7f16\u8bd1 - \u54d4\u54e9\u54d4\u54e9 (bilibili.com)<\/a><\/p>\n\n\n\n<p>\u5256\u5206\u4e4b\u540e\u7528opengl\u663e\u793a\uff0c\u5177\u4f53\u5c31\u4e0d\u8bb0\u5f55\u4e86\uff0c\u4ee3\u7801\u5199\u7684\u633a\u6e05\u695a\u7684<\/p>\n\n\n\n<p><a href=\"https:\/\/github.com\/GISlxz\/drawShpWithOpengl\" target=\"_blank\"  rel=\"nofollow\" >GISlxz\/drawShpWithOpengl: draw polygon shp with opengl (github.com)<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>OpenGL\u57fa\u7840\u77e5\u8bc6\u7684\u5b66\u4e60\u544a\u4e00\u6bb5\u843d\uff0c\u6bd5\u7adf\u6211\u60f3\u53ea\u7528OpenGL\u7ed8\u5236\u5e73\u9762\u7684\u77e2\u91cf\u56fe\u5f62\u800c\u5df2\uff0c\u63a5\u4e0b\u6765\u5f00\u59cb\u5b9e\u9a8c\u7528qt\u3001gdal\u3001opengl\u8fdb &#8230;<\/p>","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1343","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.gislxz.com\/index.php\/wp-json\/wp\/v2\/posts\/1343","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.gislxz.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gislxz.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gislxz.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gislxz.com\/index.php\/wp-json\/wp\/v2\/comments?post=1343"}],"version-history":[{"count":3,"href":"https:\/\/www.gislxz.com\/index.php\/wp-json\/wp\/v2\/posts\/1343\/revisions"}],"predecessor-version":[{"id":1360,"href":"https:\/\/www.gislxz.com\/index.php\/wp-json\/wp\/v2\/posts\/1343\/revisions\/1360"}],"wp:attachment":[{"href":"https:\/\/www.gislxz.com\/index.php\/wp-json\/wp\/v2\/media?parent=1343"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gislxz.com\/index.php\/wp-json\/wp\/v2\/categories?post=1343"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gislxz.com\/index.php\/wp-json\/wp\/v2\/tags?post=1343"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}