{"id":3550,"date":"2018-01-14T00:33:57","date_gmt":"2018-01-13T16:33:57","guid":{"rendered":"http:\/\/www.bookcard.net\/wordpress\/?p=3550"},"modified":"2018-10-14T21:31:41","modified_gmt":"2018-10-14T13:31:41","slug":"opengl_projection","status":"publish","type":"post","link":"https:\/\/www.bookcard.net\/wordpress\/opengl_projection\/","title":{"rendered":"OpenGL\u4e4b\u6295\u5f71\u8b8a\u63db"},"content":{"rendered":"<figure id=\"attachment_3557\" aria-describedby=\"caption-attachment-3557\" style=\"width: 1024px\" class=\"wp-caption alignnone\"><a href=\"https:\/\/www.bookcard.net\/wordpress\/wp-content\/uploads\/2018\/01\/OpenGL_PROJECTION.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-3557\" src=\"https:\/\/www.bookcard.net\/wordpress\/wp-content\/uploads\/2018\/01\/OpenGL_PROJECTION.jpg\" alt=\"\" width=\"1024\" height=\"768\" srcset=\"https:\/\/www.bookcard.net\/wordpress\/wp-content\/uploads\/2018\/01\/OpenGL_PROJECTION.jpg 1024w, https:\/\/www.bookcard.net\/wordpress\/wp-content\/uploads\/2018\/01\/OpenGL_PROJECTION-300x225.jpg 300w, https:\/\/www.bookcard.net\/wordpress\/wp-content\/uploads\/2018\/01\/OpenGL_PROJECTION-768x576.jpg 768w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption id=\"caption-attachment-3557\" class=\"wp-caption-text\">OpenGL\u4e4b\u6295\u5f71\u8b8a\u63db<\/figcaption><\/figure>\n<p>\u6295\u5f71\u8b8a\u63db\u662f\u6307\u8a2d\u5b9a\u8996\u53e3\u9762\u7a4d\u548c\u526a\u5207\u5e73\u9762,\u5b83\u5728\u6a21\u578b\u8b8a\u63db\u8207\u8996\u5716\u8b8a\u63db\u4e4b\u5f8c\u57f7\u884c,\u7528\u65bc\u78ba\u5b9a\u90a3\u4e9b\u591a\u908a\u578b\u6a21\u578b\u4f4d\u65bc\u8996\u53e3\u4e4b\u5167. OpenGL\u652f\u6301\u5169\u985e\u6295\u5f71<\/p>\n<table>\n<tbody>\n<tr>\n<td width=\"284\">\u6295\u5f71\u8b8a\u63db(PROJECTION transformation)<\/td>\n<td width=\"284\">\u7c21\u4ecb<\/td>\n<\/tr>\n<tr>\n<td width=\"284\">\u900f\u8996\u6295\u5f71<\/p>\n<p>glFrustum()<\/p>\n<p>gluPerspective()<\/td>\n<td width=\"284\">\u7528\u65bc3D\u4e16\u754c\u7684\u986f\u793a\u8207\u771f\u5be6\u4e16\u754c\u4e00\u6a23, \u591a\u908a\u578b\u6a21\u578b\u5448\u73fe\u8fd1\u5927\u9060\u5c0f<\/td>\n<\/tr>\n<tr>\n<td width=\"284\">\u6b63\u4ea4\u6295\u5f71<\/p>\n<p>glOrtho()<\/p>\n<p>gluOrtho2D()<\/td>\n<td width=\"284\">\u4e0d\u8003\u6ffe\u8207\u651d\u5f71\u6a5f\u7684\u8ddd\u96e2,\u986f\u793a\u591a\u908a\u578b\u6a21\u578b\u771f\u5be6\u7684\u5927\u5c0f,\u5e38\u7528\u65bcCAD\u8edf\u4ef6\u548c2D\u904a\u6232,\u6587\u672c\u986f\u793a<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<table>\n<tbody>\n<tr>\n<td width=\"284\">\u900f\u8996\u6295\u5f71<\/td>\n<td width=\"284\">\u7c21\u4ecb<\/td>\n<\/tr>\n<tr>\n<td width=\"284\">void gluPerspective (<\/p>\n<p>GLdouble fovy,<\/p>\n<p>GLdouble aspect,<\/p>\n<p>GLdouble zNear,<\/p>\n<p>GLdouble zFar);<\/td>\n<td width=\"284\">\u76f4\u63a5\u6307\u5b9a\u8996\u89d2\u548c\u5c4f\u5e55\u5bec\u9ad8\u6bd4\u5f9e\u800c\u8a08\u7b97\u89c0\u5bdf\u622a\u9ad4.<\/td>\n<\/tr>\n<tr>\n<td width=\"284\">Fovy<\/td>\n<td width=\"284\">\u53ef\u8996\u89d2\u5ea6\u4e00\u822c\u8a2d\u70ba45\u5ea6\u81f390\u5ea6<\/td>\n<\/tr>\n<tr>\n<td width=\"284\">Aspect<\/td>\n<td width=\"284\">\u5c4f\u5e55\u7684\u5bec\u9ad8\u6bd4(Width\/Height)<\/td>\n<\/tr>\n<tr>\n<td width=\"284\">zNear<\/td>\n<td width=\"284\">\u8fd1\u7aef\u526a\u5207\u9762\u8ddd\u96e2<\/td>\n<\/tr>\n<tr>\n<td width=\"284\">zFar<\/td>\n<td width=\"284\">\u9060\u7aef\u526a\u5207\u9762\u8ddd\u96e2<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<table>\n<tbody>\n<tr>\n<td width=\"284\">\u900f\u8996\u6295\u5f71<\/td>\n<td width=\"284\">\u7c21\u4ecb<\/td>\n<\/tr>\n<tr>\n<td width=\"284\">void glFrustum (<\/p>\n<p>GLdouble left,<\/p>\n<p>GLdouble right,<\/p>\n<p>GLdouble bottom,<\/p>\n<p>GLdouble top,<\/p>\n<p>GLdouble zNear,<\/p>\n<p>GLdouble zFar);<\/td>\n<td width=\"284\">\u89c0\u5bdf\u622a\u9ad4\u7684\u8a08\u7b97\u7531\u8fd1\u7aef\u526a\u5207\u9762\u8207\u9060\u7aef\u526a\u5207\u9762\u78ba\u5b9a<\/td>\n<\/tr>\n<tr>\n<td width=\"284\">Left right bottom top<\/td>\n<td width=\"284\">\u8fd1\u7aef\u526a\u5207\u9762\u7684\u7bc4\u570d<\/td>\n<\/tr>\n<tr>\n<td width=\"284\">zNear<\/td>\n<td width=\"284\">\u8fd1\u7aef\u526a\u5207\u9762\u8ddd\u96e2<\/td>\n<\/tr>\n<tr>\n<td width=\"284\">zFar<\/td>\n<td width=\"284\">\u9060\u7aef\u526a\u5207\u9762\u8ddd\u96e2<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<table>\n<tbody>\n<tr>\n<td width=\"284\">\u6b63\u4ea4\u6295\u5f71<\/td>\n<td width=\"284\">\u7c21\u4ecb<\/td>\n<\/tr>\n<tr>\n<td width=\"284\">Void glOrtho (<\/p>\n<p>GLdouble left,<\/p>\n<p>GLdouble right,<\/p>\n<p>GLdouble bottom,<\/p>\n<p>GLdouble top,<\/p>\n<p>GLdouble zNear,<\/p>\n<p>GLdouble zFar);<\/td>\n<td width=\"284\">\u76f8\u540c\u7684\u6a21\u578b\u4e0d\u7ba1\u8207\u651d\u5f71\u6a5f\u8ddd\u96e2\u7684\u9060\u8fd1,\u5176\u5448\u73fe\u7684\u76f8\u540c\u5927\u5c0f<\/td>\n<\/tr>\n<tr>\n<td width=\"284\">left right bottom top<\/td>\n<td width=\"284\">\u526a\u5207\u9762\u7684\u7bc4\u570d<\/td>\n<\/tr>\n<tr>\n<td width=\"284\">zNear<\/td>\n<td width=\"284\">\u8fd1\u7aef\u526a\u5207\u9762\u8ddd\u96e2<\/td>\n<\/tr>\n<tr>\n<td width=\"284\">zFar<\/td>\n<td width=\"284\">\u9060\u7aef\u526a\u5207\u9762\u8ddd\u96e2<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<table>\n<tbody>\n<tr>\n<td width=\"284\">\u6b63\u4ea4\u6295\u5f71<\/td>\n<td width=\"284\">\u7c21\u4ecb<\/td>\n<\/tr>\n<tr>\n<td width=\"284\">void gluOrtho2D (<\/p>\n<p>GLdouble left,<\/p>\n<p>GLdouble right,<\/p>\n<p>GLdouble bottom,<\/p>\n<p>GLdouble top);<\/td>\n<td width=\"284\">\u76f8\u7576\u65bcglOrtho(left,right,bottom,top,-1,1);<\/td>\n<\/tr>\n<tr>\n<td width=\"284\">left right bottom top<\/td>\n<td width=\"284\">\u526a\u5207\u9762\u7684\u7bc4\u570d<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u6295\u5f71\u793a\u4f8b<\/p>\n<ol>\n<li>\u9078\u64c7\u6295\u5f71\u77e9\u9663\u5806\u68e7glMatrixMode(GL_PROJECTION);<\/li>\n<li>\u8f09\u5165\u55ae\u4f4d\u77e9\u9663glLoadIdentity()<\/li>\n<li>\u8a2d\u5b9a\u900f\u8996\u6295\u5f71\u6216\u6b63\u4ea4\u6295\u5f71<\/li>\n<\/ol>\n<p>\u6295\u5f71\u51fd\u5f0f<\/p>\n<p>void Set_Projection_OpenGL(bool Is3D)<\/p>\n<p>{<\/p>\n<p>::glViewport(0,0,OpenGL_Width,OpenGL_Height); \/\/ \u91cd\u7f6e\u8996\u5340\u5c3a\u5bf8<\/p>\n<p>::glMatrixMode(GL_PROJECTION); \/\/ \u8a2d\u5b9a\u6295\u5f71\u77e9\u9663<\/p>\n<p>::glLoadIdentity();\/\/ \u8f09\u5165\u55ae\u4f4d\u77e9\u9663<\/p>\n<p>if(Is3D == true) \/\/ 3D\u6295\u5f71\u8a08\u7b97\u7a97\u53e3\u5c3a\u5bf8\u6bd4\u4f8b<\/p>\n<p>gluPerspective(54.0f,(GLfloat)OpenGL_Width\/(GLfloat)OpenGL_Height,1.0f,1000.0f);<\/p>\n<p>else\u00a0 \/\/ \u8a2d\u70ba2D\u6295\u5f71<\/p>\n<p>gluOrtho2D(0, OpenGL_Width, 0, OpenGL_Height);<\/p>\n<p>::glMatrixMode(GL_MODELVIEW);\u00a0 \/\/ \u8a2d\u5b9a\u6a21\u578b\u8996\u5716\u77e9\u9663<\/p>\n<p>::glLoadIdentity();\/\/ \u8f09\u5165\u55ae\u4f4d\u77e9\u9663<\/p>\n<p>}<\/p>\n<p>\u6295\u5f71\u6f14\u793a\u7a0b\u5f0f\u5982\u4e0a\u5716:<a href=\"https:\/\/www.bookcard.net\/wordpress\/wp-content\/uploads\/2018\/01\/OpenGLProjection.zip\">\u4e0b\u8f09<\/a><\/p>\n<ol>\n<li>\u6309P\u9375\u5728\u6b63\u4ea4\u6295\u5f71\u8207\u900f\u8996\u6295\u5f71\u4e4b\u9593\u5207\u63db<\/li>\n<li>\u6309S\u9375\u5207\u63db\u6297\u92f8\u9f52\u529f\u80fd<\/li>\n<li>\u63091\u9375\u5207\u63db\u70ba\u9ec3\u8272<\/li>\n<li>\u63092\u9375\u5207\u63db\u70ba\u7da0\u8272<\/li>\n<li>\u63093\u9375\u5207\u63db\u70ba\u7d05\u8272<\/li>\n<li>\u6309F1\u9375\u6253\u958b\u5e6b\u52a9<\/li>\n<li>\u6309ESC\u9375\u65cb\u8f49\u89d2\u5ea6\u6e05\u96f6<\/li>\n<li>\u6309+\u9375\u52a0\u5927\u76f4\u7dda\u5bec\u5ea6<\/li>\n<li>\u6309-\u9375\u6e1b\u5c0f\u76f4\u7dda\u5bec\u5ea6<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>\u6295\u5f71\u8b8a\u63db\u662f\u6307\u8a2d\u5b9a\u8996\u53e3\u9762\u7a4d\u548c\u526a\u5207\u5e73\u9762,\u5b83\u5728\u6a21\u578b\u8b8a\u63db\u8207\u8996\u5716\u8b8a\u63db\u4e4b\u5f8c\u57f7\u884c,\u7528\u65bc\u78ba\u5b9a\u90a3\u4e9b\u591a\u908a\u578b\u6a21\u578b\u4f4d\u65bc\u8996\u53e3\u4e4b\u5167. Op &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.bookcard.net\/wordpress\/opengl_projection\/\" class=\"more-link\">\u7e7c\u7e8c\u95b1\u8b80 <span class=\"screen-reader-text\">OpenGL\u4e4b\u6295\u5f71\u8b8a\u63db<\/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-3550","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\/3550","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=3550"}],"version-history":[{"count":4,"href":"https:\/\/www.bookcard.net\/wordpress\/wp-json\/wp\/v2\/posts\/3550\/revisions"}],"predecessor-version":[{"id":3558,"href":"https:\/\/www.bookcard.net\/wordpress\/wp-json\/wp\/v2\/posts\/3550\/revisions\/3558"}],"wp:attachment":[{"href":"https:\/\/www.bookcard.net\/wordpress\/wp-json\/wp\/v2\/media?parent=3550"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bookcard.net\/wordpress\/wp-json\/wp\/v2\/categories?post=3550"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.bookcard.net\/wordpress\/wp-json\/wp\/v2\/tags?post=3550"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}