{"id":3512,"date":"2018-01-09T22:41:39","date_gmt":"2018-01-09T14:41:39","guid":{"rendered":"http:\/\/www.bookcard.net\/wordpress\/?p=3512"},"modified":"2018-10-14T21:32:03","modified_gmt":"2018-10-14T13:32:03","slug":"opengl_triangle","status":"publish","type":"post","link":"https:\/\/www.bookcard.net\/wordpress\/opengl_triangle\/","title":{"rendered":"OpenGL\u4e4b\u7e6a\u756b\u4e09\u89d2\u5f62"},"content":{"rendered":"<figure id=\"attachment_3513\" aria-describedby=\"caption-attachment-3513\" style=\"width: 1024px\" class=\"wp-caption alignnone\"><a href=\"https:\/\/www.bookcard.net\/wordpress\/wp-content\/uploads\/2018\/01\/OpenGL_Triangle.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-3513\" src=\"https:\/\/www.bookcard.net\/wordpress\/wp-content\/uploads\/2018\/01\/OpenGL_Triangle.jpg\" alt=\"\" width=\"1024\" height=\"768\" srcset=\"https:\/\/www.bookcard.net\/wordpress\/wp-content\/uploads\/2018\/01\/OpenGL_Triangle.jpg 1024w, https:\/\/www.bookcard.net\/wordpress\/wp-content\/uploads\/2018\/01\/OpenGL_Triangle-300x225.jpg 300w, https:\/\/www.bookcard.net\/wordpress\/wp-content\/uploads\/2018\/01\/OpenGL_Triangle-768x576.jpg 768w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption id=\"caption-attachment-3513\" class=\"wp-caption-text\">OpenGL\u4e4b\u7e6a\u756b\u4e09\u89d2\u5f62<\/figcaption><\/figure>\n<p>OpenGL\u4e09\u89d2\u5f62\u5c6c\u65bc\u591a\u908a\u5f62.\u6f14\u793a\u7a0b\u5f0f\u5982\u4e0a\u5716:<a href=\"https:\/\/www.bookcard.net\/wordpress\/wp-content\/uploads\/2018\/01\/OpenGLTriangle.zip\">\u4e0b\u8f09<\/a><\/p>\n<ol>\n<li>\u6309\u9f20\u6a19\u5de6\u9375\u9ede\u64ca\u7e6a\u756b\u4e09\u89d2\u5f62,\u7e6a\u756b\u6642\u9802\u9ede\u7684\u8d70\u5411\u70ba\u9006\u6642\u91dd\u4e09\u89d2\u5f62\u70ba\u6b63\u9762,\u5426\u5247\u70ba\u80cc\u9762.<\/li>\n<li>\u6309+\u9375\u52a0\u5927\u76f4\u7dda\u5bec\u5ea6<\/li>\n<li>\u6309-\u9375\u6e1b\u5c0f\u76f4\u7dda\u5bec\u5ea6<\/li>\n<li>\u6309S\u9375\u5207\u63db\u6297\u92f8\u9f52\u529f\u80fd<\/li>\n<li>\u6309.\u9375\u5207\u63db\u4e09\u89d2\u5f62\u9ede\u756b\u6a21\u5f0f<\/li>\n<li>\u6309C\u9375\u5207\u63db\u4e09\u89d2\u5f62\u96b1\u9762\u88c1\u526a<\/li>\n<li>\u63091\u9375\u586b\u5145\u6a21\u5f0f<\/li>\n<li>\u63092\u9375\u7dda\u6846\u6a21\u5f0f<\/li>\n<li>\u63093\u9375\u9802\u9ede\u6a21\u5f0f<\/li>\n<li>\u63094\u9375\u6bcf\u4e09\u500b\u9802\u9ede\u7d44\u6210\u4e09\u89d2\u5f62<\/li>\n<li>\u63095\u9375\u9802\u9ede\u76f8\u9023\u7684\u4e09\u89d2\u5f62<\/li>\n<li>\u63096\u9375\u7b2c\u4e00\u500b\u9802\u9ede\u4f5c\u70ba\u4e09\u89d2\u5f62\u7684\u5171\u540c\u9802\u9ede<\/li>\n<\/ol>\n<p>\u7e6a\u756b\u4e09\u89d2\u5f62<\/p>\n<ol>\n<li>glBegin(GL_TRIANGLES);\u6e96\u5099\u7e6a\u756b\u4e09\u89d2\u5f62<\/li>\n<li>glVertex3f(x1,y1,z1);\u7e6a\u756b\u4e09\u89d2\u5f62\u9802\u9ede1<\/li>\n<li>glVertex3f(x2,y2,z2);\u7e6a\u756b\u4e09\u89d2\u5f62\u9802\u9ede2<\/li>\n<li>glVertex3f(x3,y3,z3);\u7e6a\u756b\u4e09\u89d2\u5f62\u9802\u9ede3<\/li>\n<li>glEnd();\u7d50\u675f\u7e6a\u756b<\/li>\n<\/ol>\n<table>\n<tbody>\n<tr>\n<td width=\"284\">glBegin()\u7e6a\u756b\u76f4\u7dda\u53c3\u6578<\/td>\n<td width=\"284\">\u7c21\u4ecb<\/td>\n<\/tr>\n<tr>\n<td width=\"284\">GL_TRIANGLES<\/td>\n<td width=\"284\">\u6bcf\u4e09\u500b\u9802\u9ede\u7d44\u6210\u4e09\u89d2\u5f62<\/td>\n<\/tr>\n<tr>\n<td width=\"284\">GL_TRIANGLE_STRIP<\/td>\n<td width=\"284\">\u9802\u9ede\u76f8\u9023\u7684\u4e09\u89d2\u5f62<\/td>\n<\/tr>\n<tr>\n<td width=\"284\">GL_TRIANGLE_FAN<\/td>\n<td width=\"284\">\u7b2c\u4e00\u500b\u9802\u9ede\u4f5c\u70ba\u4e09\u89d2\u5f62\u7684\u5171\u540c\u9802\u9ede<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u56e0\u5c4f\u5e55\u7531\u50cf\u7d20\u7d44\u6210,\u4e09\u89d2\u5f62\u908a\u7de3\u6703\u7522\u751f\u92f8\u9f52,\u555f\u7528\u6297\u92f8\u9f52\u7b97\u6cd5\u5f8c\u6703\u8b8a\u5f97\u5e73\u6ed1,\u4e26\u4fee\u6539\u908a\u7de3\u50cf\u7d20\u7684\u984f\u8272:<\/p>\n<ol>\n<li>glEnable(GL_POLYGON_SMOOTH);\u555f\u7528\u591a\u908a\u5f62\u7684\u5e73\u6ed1\u6a21\u5f0f(\u6297\u92f8\u9f52\u529f\u80fd)<\/li>\n<li>glEnable(GL_BLEND);\u555f\u7528\u6df7\u5408<\/li>\n<\/ol>\n<p>\u591a\u908a\u5f62\u6a21\u5f0f(\u6b63\u9762\u9ed8\u8a8d\u70ba\u586b\u5145\u6a21\u5f0f)<\/p>\n<p>void glPolygonMode(GLenum face,GLenum mode);<\/p>\n<table>\n<tbody>\n<tr>\n<td width=\"284\">\u591a\u908a\u5f62\u9762(face)<\/td>\n<td width=\"284\">\u7c21\u4ecb<\/td>\n<\/tr>\n<tr>\n<td width=\"284\">GL_FRONT<\/td>\n<td width=\"284\">\u591a\u908a\u5f62\u6b63\u9762:\u9802\u9ede\u7684\u8d70\u5411\u70ba\u9006\u6642\u91dd(\u9ed8\u8a8d)<\/td>\n<\/tr>\n<tr>\n<td width=\"284\">GL_BACK<\/td>\n<td width=\"284\">\u591a\u908a\u5f62\u80cc\u9762:\u9802\u9ede\u7684\u8d70\u5411\u70ba\u9806\u6642\u91dd<\/td>\n<\/tr>\n<tr>\n<td width=\"284\">GL_FRONT_AND_BACK<\/td>\n<td width=\"284\">\u6b63\u9762\u8207\u80cc\u9762<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<table>\n<tbody>\n<tr>\n<td width=\"284\">\u591a\u908a\u5f62\u6a21\u5f0f(mode)<\/td>\n<td width=\"284\">\u7c21\u4ecb<\/td>\n<\/tr>\n<tr>\n<td width=\"284\">GL_FILL<\/td>\n<td width=\"284\">\u586b\u5145\u6a21\u5f0f:\u5c0d\u591a\u908a\u5f62\u5167\u90e8\u9032\u884c\u984f\u8272\u586b\u5145(\u9ed8\u8a8d)<\/td>\n<\/tr>\n<tr>\n<td width=\"284\">GL_LINE<\/td>\n<td width=\"284\">\u7dda\u6846\u6a21\u5f0f:\u591a\u908a\u5f62\u53ea\u7e6a\u756b\u76f4\u5148\u4e0d\u586b\u5145<\/td>\n<\/tr>\n<tr>\n<td width=\"284\">GL_POINT<\/td>\n<td width=\"284\">\u9802\u9ede\u6a21\u5f0f:\u53ea\u7e6a\u756b\u591a\u908a\u5f62\u9802\u9ede<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u8a2d\u7f6e\u591a\u908a\u5f62\u96b1\u9762\u88c1\u526a<\/p>\n<p>3D\u5716\u5f62\u6e32\u67d3\u7684\u5de5\u4f5c\u91cf\u975e\u5e38\u5927,\u628a\u4e0d\u53ef\u898b\u7684\u9762\u5254\u9664\u5247\u53ef\u7bc0\u6e1b\u5927\u91cf\u8b8a\u63db\u548c\u6e32\u67d3\u6642\u9593.<\/p>\n<ol>\n<li>glEnable(GL_CULL_FACE);\u555f\u7528\u96b1\u9762\u88c1\u526a<\/li>\n<li>glCullFace(GL_BACK);\u8a2d\u80cc\u9762\u70ba\u96b1\u9762<\/li>\n<li>glFrontFace(GL_CCW);\u591a\u908a\u5f62\u6b63\u9762\u4f7f\u7528\u9006\u6642\u91dd<\/li>\n<\/ol>\n<table>\n<tbody>\n<tr>\n<td width=\"284\">\u6b63\u9762\u6a21\u5f0f(MODE)<\/td>\n<td width=\"284\">\u7c21\u4ecb<\/td>\n<\/tr>\n<tr>\n<td width=\"284\">GL_CCW<\/td>\n<td width=\"284\">\u591a\u908a\u5f62\u6b63\u9762\u4f7f\u7528\u9006\u6642\u91dd<\/td>\n<\/tr>\n<tr>\n<td width=\"284\">GL_CW<\/td>\n<td width=\"284\">\u591a\u908a\u5f62\u53cd\u9762\u4f7f\u7528\u9806\u6642\u91dd<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u591a\u908a\u5f62\u9ede\u756b\u6a21\u5f0f\u53ef\u7528\u65bc\u7c21\u55ae\u7684\u586b\u5145(\u4e0d\u592a\u5e38\u7528)<\/p>\n<p>void glPolygonStipple(GLushort * mask);<\/p>\n<p>mask:\u63a9\u78bc\u5927\u5c0f\u5bec8byte*\u9ad816byte=128(byte)=1024(bit),1\u586b\u5145\u50cf\u7d20,0\u4e0d\u586b\u5145<\/p>\n<ol>\n<li>glEnable(GL_POLYGON_STIPPLE);\u555f\u7528\u9ede\u756b\u6a21\u5f0f<\/li>\n<li>glPolygonStipple(mask);\u8a2d\u7f6e\u63a9\u78bc<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>OpenGL\u4e09\u89d2\u5f62\u5c6c\u65bc\u591a\u908a\u5f62.\u6f14\u793a\u7a0b\u5f0f\u5982\u4e0a\u5716:\u4e0b\u8f09 \u6309\u9f20\u6a19\u5de6\u9375\u9ede\u64ca\u7e6a\u756b\u4e09\u89d2\u5f62,\u7e6a\u756b\u6642\u9802\u9ede\u7684\u8d70\u5411\u70ba\u9006\u6642\u91dd\u4e09\u89d2\u5f62\u70ba &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.bookcard.net\/wordpress\/opengl_triangle\/\" class=\"more-link\">\u7e7c\u7e8c\u95b1\u8b80 <span class=\"screen-reader-text\">OpenGL\u4e4b\u7e6a\u756b\u4e09\u89d2\u5f62<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[62],"tags":[50],"class_list":["post-3512","post","type-post","status-publish","format-standard","hentry","category-opengl","tag-opengl","entry"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.bookcard.net\/wordpress\/wp-json\/wp\/v2\/posts\/3512","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.bookcard.net\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.bookcard.net\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.bookcard.net\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bookcard.net\/wordpress\/wp-json\/wp\/v2\/comments?post=3512"}],"version-history":[{"count":5,"href":"https:\/\/www.bookcard.net\/wordpress\/wp-json\/wp\/v2\/posts\/3512\/revisions"}],"predecessor-version":[{"id":3530,"href":"https:\/\/www.bookcard.net\/wordpress\/wp-json\/wp\/v2\/posts\/3512\/revisions\/3530"}],"wp:attachment":[{"href":"https:\/\/www.bookcard.net\/wordpress\/wp-json\/wp\/v2\/media?parent=3512"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bookcard.net\/wordpress\/wp-json\/wp\/v2\/categories?post=3512"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.bookcard.net\/wordpress\/wp-json\/wp\/v2\/tags?post=3512"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}