{"id":649,"date":"2009-09-23T22:21:00","date_gmt":"2009-09-23T02:21:00","guid":{"rendered":""},"modified":"2013-11-17T17:03:05","modified_gmt":"2013-11-17T09:03:05","slug":"opengl%e4%b8%ad%e7%9a%84%e6%8a%97%e9%94%af%e9%bd%bf%e5%ae%9e%e7%8e%b0","status":"publish","type":"post","link":"https:\/\/kyle.ai\/blog\/649.html","title":{"rendered":"openGL\u4e2d\u7684\u6297\u952f\u9f7f\u5b9e\u73b0"},"content":{"rendered":"<p>\u56fe\u5f62\u7ed8\u5236\u5230\u5c4f\u5e55\u65f6\uff0c\u5149\u6805\u5316\u56fe\u50cf\u901a\u8fc7\u79bb\u6563\u7684\u50cf\u7d20\u70b9\u6765\u8868\u793a\uff0c\u56e0\u6b64\u6240\u7ed8\u5236\u7684\u56fe\u5143\uff08\u6bd4\u5982\u76f4\u7ebf\uff09\u4f1a\u4ea7\u751f\u952f\u9f7f\uff0c\u8fd9\u79cd\u952f\u9f7f\u4e5f\u79f0\u4f5c\u8d70\u6837\u3002\u6d88\u9664\u952f\u9f7f\u7684\u6280\u672f\u79f0\u4e3a\u53cd\u8d70\u6837\uff0c\u4e5f\u53eb\u505a\u6297\u952f\u9f7f\uff0c\u901a\u8fc7\u8fd9\u79cd\u5904\u7406\u53ef\u5728\u4e00\u5b9a\u7a0b\u5ea6\u4e0a\u6d88\u9664\u952f\u9f7f\u7684\u5f71\u54cd\uff0c\u589e\u5f3a\u663e\u793a\u6548\u679c\u3002\u5728OpenGL\u4e2d\uff0c\u53ef\u901a\u8fc7\u51fd\u6570glHint\uff08\uff09\u6765\u5bf9\u56fe\u50cf\u8d28\u91cf\u548c\u7ed8\u5236\u901f\u5ea6\u4e4b\u95f4\u7684\u6743\u8861\u4f5c\u4e00\u4e9b\u63a7\u5236\uff0c\u5176\u51fd\u6570\u5f62\u5f0f\u4e3a\uff1a<\/p>\n<pre class=\"brush: delphi; title: ; notranslate\" title=\"\">\r\nvoid glHint(GLenum target,GLenum hint);\r\n<\/pre>\n<p>\u53c2\u6570target\u8bf4\u660e\u63a7\u5236\u4ec0\u4e48\u884c\u4e3a\uff1aGL_POINT_SMOOTH_HINT\u3001GL_LINE_SMOOTH_HINT\u548cGL_POLYGON_SMOOTH_HINT\u5206\u522b\u6307\u5b9a\u70b9\u3001\u7ebf\u548c\u591a\u8fb9\u5f62\u7684\u91c7\u6837\u8d28\u91cf\uff1bGL_FOG_HINT\u6307\u51fa\u96fe\u662f\u6309\u50cf\u7d20\u8fdb\u884c\uff08GL_NICEST\uff09\u8fd8\u662f\u6309\u9876\u70b9\u8fdb\u884c\uff08GL_FASTEST\uff09\uff1bGL_PERSPECTIVE_CORRECTION_HINT\u6307\u5b9a\u4e86\u989c\u8272\u7eb9\u7406\u63d2\u503c\u7684\u8d28\u91cf\u5e76\u53ef\u7ea0\u6b63\u7531\u5355\u7eaf\u7ebf\u6027\u63d2\u503c\u6240\u5e26\u6765\u7684\u4e00\u4e9b\u89c6\u89c9\u9519\u8bef\u3002\u53c2\u6570hint\u53ef\u4ee5\u662f\uff1aGL_FASTEST\uff08\u7ed9\u51fa\u6700\u6709\u6548\u7684\u9009\u62e9\uff09\u3001GL_NICEST\uff08\u7ed9\u51fa\u6700\u9ad8\u8d28\u91cf\u7684\u9009\u62e9\uff09\u3001GL_DONT_CARE\uff08\u6ca1\u6709\u9009\u62e9\uff09\u3002<\/p>\n<p>\u867d\u7136\u5728OpenGL\u7684\u989c\u8272\u7d22\u5f15\u6a21\u5f0f\u4e0b\u4e5f\u53ef\u4ee5\u5b9e\u73b0\u53cd\u8d70\u6837\uff0c\u4f46\u4ecd\u5efa\u8bae\u5728RGBA\u6a21\u5f0f\u4e0b\u8fdb\u884c\u3002\u5bf9\u56fe\u5143\u8fdb\u884c\u53cd\u8d70\u6837\u65f6\u4e5f\u8981\u5148\u8c03\u7528glEnable\uff08\uff09\u51fd\u6570\u542f\u52a8\u53cd\u8d70\u6837\uff08\u5176\u53c2\u6570\u4e3aGL_POINT\u3001GL_LINE_SMOOTH\u6216GL_POLYGON_SMOOTH\uff09\u3002\u5982\u679c\u662f\u5728RGBA\u6a21\u5f0f\u4e0b\u8fdb\u884c\u53cd\u8d70\u6837\uff0c\u8fd8\u5fc5\u987b\u4e0e\u878d\u5408\u914d\u5408\u4f7f\u7528\uff0c\u901a\u5e38\u4f7f\u7528GL_SRC_ALPHA\u548cGL_ONE_MINUS_SRC_ALPHA\u5206\u522b\u4f5c\u4e3a\u6e90\u548c\u76ee\u7684\u56e0\u5b50\u3002<\/p>\n<p>openGL\u4e2d\u4f7f\u7528\u53cd\u8d70\u6837\uff0c\u9700\u8981\u5728\u8bbe\u7f6e\u51fd\u6570\u4e2d\u8fdb\u884c\u8bbe\u7f6e\uff0c\u4e0b\u9762\u8bbe\u7f6e\u53cd\u8d70\u6837\u7684\u4ee3\u7801\uff1a<\/p>\n<pre class=\"brush: delphi; title: ; notranslate\" title=\"\">\r\nview plaincopy to clipboardprint?\r\n\/\/ Initialize OpenGL's rendering modes\r\nvoid initRendering()\r\n{\r\n glEnable ( GL_DEPTH_TEST );\r\n \/\/ Uncomment out the first block of code below, and then the second block,\r\n \/\/  to see how they affect line and point drawing.\r\n\r\n \/\/ The following commands should cause points and line to be drawn larger\r\n \/\/ than a single pixel width.\r\n glPointSize(8);\r\n glLineWidth(5);\r\n\r\n \/\/ The following commands should induce OpenGL to create round points and\r\n \/\/ antialias points and lines.  (This is implementation dependent unfortunately).\r\n \/\/RGBA mode antialias need cooperate with blend function.\r\n glEnable(GL_POINT_SMOOTH);\r\n glEnable(GL_LINE_SMOOTH);\r\n glHint(GL_POINT_SMOOTH_HINT, GL_NICEST); \/\/ Make round points, not square points\r\n glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);  \/\/ Antialias the lines\r\n glEnable(GL_BLEND);\r\n glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);\r\n}\r\n\/\/ Initialize OpenGL's rendering modes\r\nvoid initRendering()\r\n{\r\n glEnable ( GL_DEPTH_TEST );\r\n\r\n \/\/ Uncomment out the first block of code below, and then the second block,\r\n \/\/  to see how they affect line and point drawing.\r\n\r\n \/\/ The following commands should cause points and line to be drawn larger\r\n \/\/ than a single pixel width.\r\n glPointSize(8);\r\n glLineWidth(5);\r\n \/\/ The following commands should induce OpenGL to create round points and\r\n \/\/ antialias points and lines.  (This is implementation dependent unfortunately).\r\n \/\/RGBA mode antialias need cooperate with blend function.\r\n glEnable(GL_POINT_SMOOTH);\r\n glEnable(GL_LINE_SMOOTH);\r\n glHint(GL_POINT_SMOOTH_HINT, GL_NICEST); \/\/ Make round points, not square points\r\n glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);  \/\/ Antialias the lines\r\n glEnable(GL_BLEND);\r\n glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);\r\n}\r\n<\/pre>\n<p>\u5199\u4e00\u4e2aopenGL\u7a0b\u5e8f\u753b\u4e00\u4e2a\u70b9\uff0c\u5982\u679c\u6ca1\u6709\u6297\u952f\u9f7f\uff0c\u5219\u4e3a\u65b9\u5f62\u7684\u3002\u5982\u679c\u6211\u4eec\u542f\u52a8\u6297\u952f\u9f7f\u8bbe\u7f6e\uff0c\u5219\u70b9\u662f\u4e00\u4e2a\u5706\u70b9\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u56fe\u5f62\u7ed8\u5236\u5230\u5c4f\u5e55\u65f6\uff0c\u5149\u6805\u5316\u56fe\u50cf\u901a\u8fc7\u79bb\u6563\u7684\u50cf\u7d20\u70b9\u6765\u8868\u793a\uff0c\u56e0\u6b64\u6240\u7ed8\u5236\u7684\u56fe\u5143\uff08\u6bd4\u5982\u76f4\u7ebf\uff09\u4f1a\u4ea7\u751f\u952f\u9f7f\uff0c\u8fd9\u79cd\u952f\u9f7f\u4e5f\u79f0\u4f5c\u8d70\u6837 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"class_list":["post-649","post","type-post","status-publish","format-standard","hentry","category-code_related"],"_links":{"self":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts\/649","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/comments?post=649"}],"version-history":[{"count":1,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts\/649\/revisions"}],"predecessor-version":[{"id":4718,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts\/649\/revisions\/4718"}],"wp:attachment":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/media?parent=649"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/categories?post=649"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/tags?post=649"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}