{"id":4087,"date":"2018-05-15T12:03:34","date_gmt":"2018-05-15T04:03:34","guid":{"rendered":"http:\/\/www.bookcard.net\/wordpress\/?p=4087"},"modified":"2018-10-14T21:09:11","modified_gmt":"2018-10-14T13:09:11","slug":"openglfog","status":"publish","type":"post","link":"https:\/\/www.bookcard.net\/wordpress\/openglfog\/","title":{"rendered":"OpenGL\u4e4b\u8ff7\u9727"},"content":{"rendered":"<figure id=\"attachment_4088\" aria-describedby=\"caption-attachment-4088\" style=\"width: 1024px\" class=\"wp-caption alignnone\"><a href=\"https:\/\/www.bookcard.net\/wordpress\/wp-content\/uploads\/2018\/05\/OpenGLFog.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-4088\" src=\"https:\/\/www.bookcard.net\/wordpress\/wp-content\/uploads\/2018\/05\/OpenGLFog.jpg\" alt=\"\" width=\"1024\" height=\"768\" \/><\/a><figcaption id=\"caption-attachment-4088\" class=\"wp-caption-text\">OpenGL\u4e4b\u8ff7\u9727<\/figcaption><\/figure>\n<p>\u300e\u8ff7\u9727\u300f\u901a\u904e\u6a21\u7cca\u9060\u7aef\u4e4b\u7269,\u800c\u8fd1\u7aef\u6e05\u6670.\u7d663D\u4e16\u754c\u5e36\u4f86\u9727\u611f.\u800c\u4e14\u53ef\u4ee5\u6e1b\u5c0f\u9032\u5834\u5883\u4e2d\u591a\u908a\u5f62\u6578\u91cf,\u5f9e\u800c\u63d0\u9ad8\u6e32\u67d3\u901f\u5ea6.\u6f14\u793a\u7a0b\u5f0f\u6309\u300e+\/-\u300f\u9375\u52a0\u6e1b\u300e\u8ff7\u9727\u300f\u5bc6\u5ea6.\u4e0b\u8f09\u300e<a href=\"https:\/\/www.bookcard.net\/wordpress\/wp-content\/uploads\/2018\/05\/OpenGLFog.zip\">\u8ff7\u9727<\/a>\u300f<\/p>\n<p>OpenGL\u76f4\u63a5\u63d0\u4f9b\u300e\u8ff7\u9727\u300f\u652f\u6301:<\/p>\n<p>1.\u9996\u5148\u9700\u8981\u555f\u7528\u300e\u8ff7\u9727\u300f<\/p>\n<p>glEnable(GL_FOG);<\/p>\n<p>2.\u5c07\u50cf\u7d20\u8207\u300e\u8ff7\u9727\u300f\u984f\u8272\u9032\u884c\u6df7\u5408\u800c\u5be6\u73fe,\u5176\u6df7\u5408\u56e0\u5b50\u7684\u8a2d\u5b9a\u8ddf\u64da\u5176\u8996\u9ede\u8ddd\u96e2, \u300e\u8ff7\u9727\u5bc6\u5ea6\u300f\u548c\u300e\u8ff7\u9727\u6a21\u5f0f\u300f,\u8a2d\u5b9a\u300e\u8ff7\u9727\u300f\u53ef\u901a\u904e\u4ee5\u4e0b\u51fd\u5f0f:<\/p>\n<p>void glFogf(GLenum pname,GLfloat param);<\/p>\n<p>void glFogfv(GLenum pname,const GLfloat*params);<\/p>\n<p>void glFogi(GLenum pname,GLint param);<\/p>\n<p>void glFogiv(GLenum pname,const GLint*params);<\/p>\n<table>\n<tbody>\n<tr>\n<td width=\"208\">Pname(\u53c3\u6578\u540d)<\/td>\n<td width=\"345\">Params(\u53c3\u6578\u503c)<\/td>\n<\/tr>\n<tr>\n<td width=\"208\"><strong>GL_FOG_MODE<\/strong><\/td>\n<td width=\"345\">\u300e\u8ff7\u9727\u300f\u6df7\u5408\u65b9\u7a0b\u5f0f,\u9ed8\u8a8d\u70baGL_EXP<\/p>\n<p>GL_LINEAR:factor=(end-z)\/(end-start)<\/p>\n<p>GL_EXP:factor=e<sup>(-density*depth)<\/sup><\/p>\n<p>GL_EXP2: factor=e<sup>(-density*depth)* (-density*depth)<\/sup><\/td>\n<\/tr>\n<tr>\n<td width=\"208\"><strong>GL_FOG_DENSITY<\/strong><\/td>\n<td width=\"345\">\u8ff7\u9727\u5bc6\u5ea6\u9ed8\u8a8d\u70ba1.0f<\/td>\n<\/tr>\n<tr>\n<td width=\"208\"><strong>GL_FOG_START<\/strong><\/td>\n<td width=\"345\">\u8ff7\u9727\u96e2\u8996\u9ede\u8fd1\u7aef\u9ed8\u8a8d\u70ba0<\/td>\n<\/tr>\n<tr>\n<td width=\"208\"><strong>GL_FOG_END<\/strong><\/td>\n<td width=\"345\">\u8ff7\u9727\u96e2\u8996\u9ede\u9060\u7aef\u9ed8\u8a8d\u70ba1<\/td>\n<\/tr>\n<tr>\n<td width=\"208\"><strong>GL_FOG_INDEX<\/strong><\/td>\n<td width=\"345\">\u8ff7\u9727\u984f\u8272\u7d22\u5f15\u503c\u9ed8\u8a8d\u70ba0<\/td>\n<\/tr>\n<tr>\n<td width=\"208\"><strong>GL_FOG_COLOR<\/strong><\/td>\n<td width=\"345\">\u8ff7\u9727\u984f\u8272\u9ed8\u8a8d\u70ba\u9ed1\u8272(0,0,0,0).<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u555f\u7528\u8ff7\u9727\u51fd\u662f\u4ee3\u78bc<\/p>\n<p>void Enable_Fog()<\/p>\n<p>{<\/p>\n<p>float fogColor[] = { 0.5, 0.5, 0.5, 1.0 };\/\/ \u7070\u8272<\/p>\n<p>glEnable(GL_FOG);\/\/ \u555f\u7528\u9727<\/p>\n<p>glFogfv(GL_FOG_COLOR, fogColor);\/\/ \u9727\u8272<\/p>\n<p>glFogf(GL_FOG_MODE, GL_EXP2);\/\/ \u984f\u8272\u6a21\u5f0f<\/p>\n<p>glFogf(GL_FOG_START, 200);\/\/ \u9727\u8fd1\u7aef\u7bc4\u570d<\/p>\n<p>glFogf(GL_FOG_END, 1000);\/\/ \u9727\u9060\u7aef\u7bc4\u570d<\/p>\n<p>glFogf(GL_FOG_DENSITY, 0.06f);\/\/ \u5bc6\u5ea6<\/p>\n<p>}<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u300e\u8ff7\u9727\u300f\u901a\u904e\u6a21\u7cca\u9060\u7aef\u4e4b\u7269,\u800c\u8fd1\u7aef\u6e05\u6670.\u7d663D\u4e16\u754c\u5e36\u4f86\u9727\u611f.\u800c\u4e14\u53ef\u4ee5\u6e1b\u5c0f\u9032\u5834\u5883\u4e2d\u591a\u908a\u5f62\u6578\u91cf,\u5f9e\u800c\u63d0\u9ad8\u6e32\u67d3\u901f\u5ea6.\u6f14 &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.bookcard.net\/wordpress\/openglfog\/\" class=\"more-link\">\u7e7c\u7e8c\u95b1\u8b80 <span class=\"screen-reader-text\">OpenGL\u4e4b\u8ff7\u9727<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[62],"tags":[50],"class_list":["post-4087","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\/4087","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=4087"}],"version-history":[{"count":1,"href":"https:\/\/www.bookcard.net\/wordpress\/wp-json\/wp\/v2\/posts\/4087\/revisions"}],"predecessor-version":[{"id":4090,"href":"https:\/\/www.bookcard.net\/wordpress\/wp-json\/wp\/v2\/posts\/4087\/revisions\/4090"}],"wp:attachment":[{"href":"https:\/\/www.bookcard.net\/wordpress\/wp-json\/wp\/v2\/media?parent=4087"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bookcard.net\/wordpress\/wp-json\/wp\/v2\/categories?post=4087"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.bookcard.net\/wordpress\/wp-json\/wp\/v2\/tags?post=4087"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}