{"id":3619,"date":"2018-01-20T16:06:21","date_gmt":"2018-01-20T08:06:21","guid":{"rendered":"http:\/\/www.bookcard.net\/wordpress\/?p=3619"},"modified":"2018-10-14T21:24:25","modified_gmt":"2018-10-14T13:24:25","slug":"opengl_light","status":"publish","type":"post","link":"https:\/\/www.bookcard.net\/wordpress\/opengl_light\/","title":{"rendered":"OpenGL\u4e4b\u5149\u7167"},"content":{"rendered":"<figure id=\"attachment_3620\" aria-describedby=\"caption-attachment-3620\" style=\"width: 1024px\" class=\"wp-caption alignnone\"><a href=\"https:\/\/www.bookcard.net\/wordpress\/wp-content\/uploads\/2018\/01\/OpenGL_Light.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-3620\" src=\"https:\/\/www.bookcard.net\/wordpress\/wp-content\/uploads\/2018\/01\/OpenGL_Light.jpg\" alt=\"\" width=\"1024\" height=\"768\" srcset=\"https:\/\/www.bookcard.net\/wordpress\/wp-content\/uploads\/2018\/01\/OpenGL_Light.jpg 1024w, https:\/\/www.bookcard.net\/wordpress\/wp-content\/uploads\/2018\/01\/OpenGL_Light-300x225.jpg 300w, https:\/\/www.bookcard.net\/wordpress\/wp-content\/uploads\/2018\/01\/OpenGL_Light-768x576.jpg 768w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption id=\"caption-attachment-3620\" class=\"wp-caption-text\">OpenGL\u4e4b\u5149\u7167<\/figcaption><\/figure>\n<p>OpenGL\u5149\u7684\u984f\u8272\u7531\u7d05\u7da0\u85cd(RGB)\u7684\u5206\u91cf\u78ba\u5b9a,\u7576\u5149\u7167\u5230\u8868\u9762\u6642,\u7531\u8868\u9762\u7684\u6750\u8cea\u7684\u78ba\u5b9a\u53cd\u5c04\u7684\u5149\u7684\u984f\u8272(RGB).<\/p>\n<table>\n<tbody>\n<tr>\n<td width=\"284\">OpenGL\u5149\u6709\u56db\u985e<\/td>\n<td width=\"284\">\u7c21\u4ecb<\/td>\n<\/tr>\n<tr>\n<td width=\"284\">\u74b0\u5883\u5149<\/td>\n<td width=\"284\">\u7121\u7279\u5b9a\u7167\u5c04\u65b9\u5411,\u592a\u967d\u5149<\/td>\n<\/tr>\n<tr>\n<td width=\"284\">\u6f2b\u5c04\u5149<\/td>\n<td width=\"284\">\u6709\u7167\u5c04\u65b9\u5411\u7684\u5149,\u9047\u8868\u9762\u5149\u5c07\u671d\u53cd\u65b9\u5411\u7167\u5c04, \u5982\u71c8\u5149\u4e0d\u53d7\u76f8\u6a5f\u4f4d\u7f6e\u5f71\u97ff.<\/td>\n<\/tr>\n<tr>\n<td width=\"284\">\u53cd\u5c04\u5149<\/td>\n<td width=\"284\">\u6709\u7167\u5c04\u65b9\u5411,\u9047\u8868\u9762\u5149\u5c07\u671d\u53cd\u65b9\u5411\u7167\u5c04.\u5982\u4eae\u5149\u4f46\u53d7\u76f8\u6a5f\u4f4d\u7f6e\u5f71\u97ff.<\/td>\n<\/tr>\n<tr>\n<td width=\"284\">\u653e\u5c04\u5149<\/td>\n<td width=\"284\">\u53ea\u589e\u52a0\u7269\u9ad4\u7684\u4eae\u5ea6<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<table>\n<tbody>\n<tr>\n<td width=\"284\">OpenGL\u5149\u7167\u5f71\u97ff\u56e0\u7d20<\/td>\n<td width=\"284\">\u7c21\u4ecb<\/td>\n<\/tr>\n<tr>\n<td width=\"284\">\u5149\u6e90<\/td>\n<td width=\"284\">\u74b0\u5883\u5149\u3001\u6f2b\u5c04\u5149\u3001\u53cd\u5c04\u5149\u3001\u653e\u5c04\u5149<\/td>\n<\/tr>\n<tr>\n<td width=\"284\"><a href=\"https:\/\/www.bookcard.net\/wordpress\/opengl_material\/\">\u6750\u8cea<\/a><\/td>\n<td width=\"284\">\u78ba\u5b9a\u53cd\u5c04\u5149RGBA\u503c<\/td>\n<\/tr>\n<tr>\n<td width=\"284\"><a href=\"https:\/\/www.bookcard.net\/wordpress\/opengl_normal\/\">\u6cd5\u7dda<\/a><\/td>\n<td width=\"284\">\u7531\u8868\u9762\u7684\u9802\u9ede\u8a08\u7b97\u65b9\u5411<\/td>\n<\/tr>\n<tr>\n<td width=\"284\">\u76f8\u6a5f\u4f4d\u7f6e<\/td>\n<td width=\"284\">\u7576\u5149\u6298\u5c04\u6642, \u76f8\u6a5f\u4f4d\u7f6e\u5f71\u97ff\u53cd\u5c04\u5149\u7684\u8a08\u7b97<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<table>\n<tbody>\n<tr>\n<td width=\"568\">\u5149\u7684\u984f\u8272\u3001\u4f4d\u7f6e\u3001\u65b9\u5411\u7684\u8a2d\u5b9a:<\/td>\n<\/tr>\n<tr>\n<td width=\"568\">void glLightfv (GLenum light, GLenum pname, const GLfloat *params);<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<table>\n<tbody>\n<tr>\n<td width=\"284\">glLightfv()\u53c3\u6578<\/td>\n<td width=\"284\">\u7c21\u4ecb<\/td>\n<\/tr>\n<tr>\n<td width=\"284\">light<\/td>\n<td width=\"284\">GL_LIGHT0~ GL_LIGHT7<\/p>\n<p>OpenGL\u6700\u591a\u53ef\u4ee5\u6307\u5b9a8\u500b\u5149\u6e90<\/td>\n<\/tr>\n<tr>\n<td width=\"284\">pname<\/td>\n<td width=\"284\">\u5149\u6e90\u7684\u53c3\u6578\u540d\u898b\u4e0b\u8868<\/td>\n<\/tr>\n<tr>\n<td width=\"284\">Params<\/td>\n<td width=\"284\">\u5149\u6e90\u7684\u53c3\u6578\u503c<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<table>\n<tbody>\n<tr>\n<td width=\"284\">\u5149\u6e90\u7684\u53c3\u6578\u540dPname<\/td>\n<td width=\"284\">\u7c21\u4ecb<\/td>\n<\/tr>\n<tr>\n<td width=\"284\">GL_AMBIENT<\/td>\n<td width=\"284\">\u74b0\u5883\u5149\u5411\u6240\u6709\u65b9\u5411\u7167\u5c04<\/td>\n<\/tr>\n<tr>\n<td width=\"284\">GL_DIFFUSE<\/td>\n<td width=\"284\">\u6f2b\u5c04\u5149\u5177\u6709\u65b9\u5411,\u78b0\u649e\u5230FACE\u6703\u9032\u884c\u53cd\u5c04<\/td>\n<\/tr>\n<tr>\n<td width=\"284\">GL_SPECULAR<\/td>\n<td width=\"284\">\u93e1\u9762\u53cd\u5c04\u5149<\/td>\n<\/tr>\n<tr>\n<td width=\"284\">GL_POSITION<\/td>\n<td width=\"284\">\u5149\u7684\u4f4d\u7f6e<\/td>\n<\/tr>\n<tr>\n<td width=\"284\">GL_SPOT_DIRECTION<\/td>\n<td width=\"284\">\u805a\u5149\u71c8\u7684\u77e2\u91cf\u65b9\u5411<\/td>\n<\/tr>\n<tr>\n<td width=\"284\">GL_SPOT_EXPONENT<\/td>\n<td width=\"284\">\u805a\u5149\u71c8\u7684\u6307\u6578<\/td>\n<\/tr>\n<tr>\n<td width=\"284\">GL_SPOT_CUTOFF<\/td>\n<td width=\"284\">\u805a\u5149\u71c8\u7684\u908a\u754c<\/td>\n<\/tr>\n<tr>\n<td width=\"284\">GL_CONSTANT_ATTENUATION<\/td>\n<td width=\"284\">\u8870\u6e1b\u503c\u4fc2\u6578\u5e38\u91cf<\/td>\n<\/tr>\n<tr>\n<td width=\"284\">GL_LINEAR_ATTENUATION<\/td>\n<td width=\"284\">\u7dda\u6027\u8870\u6e1b\u503c\u4fc2\u6578<\/td>\n<\/tr>\n<tr>\n<td width=\"284\">GL_QUADRATIC_ATTENUATION<\/td>\n<td width=\"284\">\u4e8c\u6b21\u8870\u6e1b\u503c\u4fc2\u6578<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<table>\n<tbody>\n<tr>\n<td width=\"359\">\u74b0\u5883\u5149<\/td>\n<td width=\"209\">\u7c21\u4ecb<\/td>\n<\/tr>\n<tr>\n<td width=\"359\">Pname=GL_AMBIENT<\/td>\n<td width=\"209\">\u74b0\u5883\u5149<\/td>\n<\/tr>\n<tr>\n<td width=\"359\">Params=(x,y,z,w)<\/td>\n<td width=\"209\">\u984f\u8272\u5206\u91cf<\/td>\n<\/tr>\n<tr>\n<td width=\"359\">w=alpha<\/td>\n<td width=\"209\">w=0\u900f\u660e<\/p>\n<p>w=1\u5be6\u9ad4<\/td>\n<\/tr>\n<tr>\n<td width=\"359\">float Light_Ambient[] = { 1.0f,1.0f,1.0f,1.0f};<\/p>\n<p>glLightfv(GL_LIGHT0,GL_AMBIENT, Light_Ambient);<\/td>\n<td width=\"209\">\u4eae\u767d\u7684\u74b0\u5883\u5149\u793a\u4f8b<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<table>\n<tbody>\n<tr>\n<td width=\"359\">\u6f2b\u5c04\u5149<\/td>\n<td width=\"209\">\u7c21\u4ecb<\/td>\n<\/tr>\n<tr>\n<td width=\"359\">GL_DIFFUSE<\/td>\n<td width=\"209\">\u6f2b\u5c04\u5149<\/td>\n<\/tr>\n<tr>\n<td width=\"359\">Params=(x,y,z,w)<\/td>\n<td width=\"209\">\u984f\u8272\u5206\u91cf<\/td>\n<\/tr>\n<tr>\n<td width=\"359\">w=alpha<\/td>\n<td width=\"209\">w=0\u900f\u660e<\/p>\n<p>w=1\u5be6\u9ad4<\/td>\n<\/tr>\n<tr>\n<td width=\"359\">float Light_Diffuse[] = { 1.0f,1.0f,1.0f,1.0f};<\/p>\n<p>glLightfv(GL_LIGHT0,GL_DIFFUSE, Light_Diffuse);<\/td>\n<td width=\"209\">\u4eae\u767d\u7684\u6f2b\u5c04\u5149\u793a\u4f8b<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<table>\n<tbody>\n<tr>\n<td width=\"360\">\u5149\u6e90\u7684\u4f4d\u7f6e<\/td>\n<td width=\"208\">\u7c21\u4ecb<\/td>\n<\/tr>\n<tr>\n<td width=\"360\">Pname= GL_POSITION<\/td>\n<td width=\"208\">\u8a2d\u5b9a\u5149\u6e90\u7684\u4f4d\u7f6e<\/td>\n<\/tr>\n<tr>\n<td width=\"360\">Params=(x,y,z,w)<\/td>\n<td width=\"208\">\u5411\u91cf\u6216\u5750\u6a19<\/td>\n<\/tr>\n<tr>\n<td width=\"360\">w=0<\/td>\n<td width=\"208\">\u5b9a\u5411\u5149\u6e90(x,y,z)\u70ba\u5411\u91cf\u5b9a\u7fa9\u5149\u7684\u7167\u5c04\u65b9\u5411,\u5982\u592a\u967d.<\/td>\n<\/tr>\n<tr>\n<td width=\"360\">W=1<\/td>\n<td width=\"208\">\u5b9a\u9ede\u5149\u6e90(x,y,z)\u70ba\u5750\u6a19\u5b9a\u7fa9\u5149\u6e90\u7684\u4f4d\u7f6e,\u5982\u71c8\u6ce1.<\/td>\n<\/tr>\n<tr>\n<td width=\"360\">float Light_Position[] = {0.0f,0.0f,0.0f,1.0f };<\/p>\n<p>glLightfv(GL_LIGHT0,GL_POSITION,Light_Position);<\/td>\n<td width=\"208\">\u5149\u6e90\u7684\u4f4d\u7f6e\u8a2d\u5728\u539f\u9ede<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<table>\n<tbody>\n<tr>\n<td width=\"224\">\u5149\u8870\u6e1b(OpenGL\u652f\u6301\u4e09\u985e\u5149\u8870\u6e1b)<\/td>\n<td width=\"71\">\u9ed8\u8a8d\u503c<\/td>\n<td width=\"273\">\u7c21\u4ecb<\/td>\n<\/tr>\n<tr>\n<td width=\"224\">ATTENUATION<\/td>\n<td width=\"71\"><\/td>\n<td width=\"273\">\u5149\u7dda\u96a8\u8457\u8ddd\u96e2\u7684\u589e\u5927\u5176\u5f37\u5ea6\u6e1b\u5c0f,\u4f46\u53ea\u9069\u7528\u65bc\u5b9a\u9ede\u5149\u6e90,\u4f46\u5b9a\u5411\u5149\u6e90\u662f\u7121\u7aae\u9060\u7684\u8a2d\u7f6e\u8870\u6e1b\u662f\u7121\u610f\u7fa9.<\/p>\n<p>\u8870\u6e1b\u56e0\u5b50*\u5149\u5f37\u5ea6 = \u5149\u8870\u6e1b<\/td>\n<\/tr>\n<tr>\n<td width=\"224\">GL_CONSTANT_ATTENUATION<\/td>\n<td width=\"71\">1.0f<\/td>\n<td width=\"273\">\u8870\u6e1b\u503c\u4fc2\u6578\u5e38\u91cf<\/td>\n<\/tr>\n<tr>\n<td width=\"224\">GL_LINEAR_ATTENUATION<\/td>\n<td width=\"71\">0.0f<\/td>\n<td width=\"273\">\u7dda\u6027\u8870\u6e1b\u503c\u4fc2\u6578<\/td>\n<\/tr>\n<tr>\n<td width=\"224\">GL_QUADRATIC_ATTENUATION<\/td>\n<td width=\"71\">0.0f<\/td>\n<td width=\"273\">\u4e8c\u6b21\u8870\u6e1b\u503c\u4fc2\u6578<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u5149\u7167\u4eae\u5ea6\u6f14\u793a\u7a0b\u5f0f,\u5b9a\u9ede\u5149\u6e90\u4e26\u4e14\u5168\u65b9\u4f4d\u8f3b\u5c04.\u5982\u4e0a\u5716:<a href=\"https:\/\/www.bookcard.net\/wordpress\/wp-content\/uploads\/2018\/01\/OpenGLLight.zip\">\u4e0b\u8f09<\/a><\/p>\n<ol>\n<li>\u6309+\/-\u9375\u589e\u52a0\u6216\u6e1b\u5c0f\u5149\u7167\u4eae\u5ea6<\/li>\n<li>\u6309SPACE(\u7a7a\u683c)\u9375\u555f\u7528\u6216\u7981\u7528\u5149\u7167<\/li>\n<li>\u6309UP\/DOWN\u9375\u6b63\u65b9\u5f62\u7e5eX\u8ef8\u65cb\u8f49<\/li>\n<li>\u6309LEFT\/RIGHT\u9375\u6b63\u65b9\u5f62\u7e5eY\u8ef8\u65cb\u8f49<\/li>\n<li>\u6309Z+LEFT\/Z+RIGHT\u9375\u7e5eZ\u8ef8\u65cb\u8f49<\/li>\n<li>\u6309F1\u9375\u6253\u958b\u5e6b\u52a9<\/li>\n<li>\u6309ESC\u9375\u91cd\u7f6e\u6a21\u578b\u65cb\u8f49\u89d2\u5ea6<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>OpenGL\u5149\u7684\u984f\u8272\u7531\u7d05\u7da0\u85cd(RGB)\u7684\u5206\u91cf\u78ba\u5b9a,\u7576\u5149\u7167\u5230\u8868\u9762\u6642,\u7531\u8868\u9762\u7684\u6750\u8cea\u7684\u78ba\u5b9a\u53cd\u5c04\u7684\u5149\u7684\u984f\u8272(RGB). &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.bookcard.net\/wordpress\/opengl_light\/\" class=\"more-link\">\u7e7c\u7e8c\u95b1\u8b80 <span class=\"screen-reader-text\">OpenGL\u4e4b\u5149\u7167<\/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-3619","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\/3619","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=3619"}],"version-history":[{"count":3,"href":"https:\/\/www.bookcard.net\/wordpress\/wp-json\/wp\/v2\/posts\/3619\/revisions"}],"predecessor-version":[{"id":3636,"href":"https:\/\/www.bookcard.net\/wordpress\/wp-json\/wp\/v2\/posts\/3619\/revisions\/3636"}],"wp:attachment":[{"href":"https:\/\/www.bookcard.net\/wordpress\/wp-json\/wp\/v2\/media?parent=3619"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bookcard.net\/wordpress\/wp-json\/wp\/v2\/categories?post=3619"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.bookcard.net\/wordpress\/wp-json\/wp\/v2\/tags?post=3619"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}