{"id":11039,"date":"2021-12-06T23:23:20","date_gmt":"2021-12-06T15:23:20","guid":{"rendered":"https:\/\/www.bookcard.net\/wordpress\/?p=11039"},"modified":"2021-12-06T23:23:20","modified_gmt":"2021-12-06T15:23:20","slug":"android_studio_ndk_opengl_es_2d_camera","status":"publish","type":"post","link":"https:\/\/www.bookcard.net\/wordpress\/android_studio_ndk_opengl_es_2d_camera\/","title":{"rendered":"Android Studio NDK-OpenGL ES-2D\u76f8\u6a5f"},"content":{"rendered":"<figure id=\"attachment_11040\" aria-describedby=\"caption-attachment-11040\" style=\"width: 1280px\" class=\"wp-caption alignnone\"><a href=\"https:\/\/www.bookcard.net\/wordpress\/wp-content\/uploads\/2021\/12\/Android_Studio_NDK_OpenGL_ES_2D_Camera.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-11040\" src=\"https:\/\/www.bookcard.net\/wordpress\/wp-content\/uploads\/2021\/12\/Android_Studio_NDK_OpenGL_ES_2D_Camera.jpg\" alt=\"Android Studio NDK-OpenGL ES-2D\u76f8\u6a5f\" width=\"1280\" height=\"800\" srcset=\"https:\/\/www.bookcard.net\/wordpress\/wp-content\/uploads\/2021\/12\/Android_Studio_NDK_OpenGL_ES_2D_Camera.jpg 1280w, https:\/\/www.bookcard.net\/wordpress\/wp-content\/uploads\/2021\/12\/Android_Studio_NDK_OpenGL_ES_2D_Camera-300x188.jpg 300w, https:\/\/www.bookcard.net\/wordpress\/wp-content\/uploads\/2021\/12\/Android_Studio_NDK_OpenGL_ES_2D_Camera-768x480.jpg 768w\" sizes=\"auto, (max-width: 1280px) 100vw, 1280px\" \/><\/a><figcaption id=\"caption-attachment-11040\" class=\"wp-caption-text\">Android Studio NDK-OpenGL ES-2D\u76f8\u6a5f<\/figcaption><\/figure>\n<p>OpenGL\u6709\u300e\u5e73\u884c\u6295\u5f71\u300f\u540c\u300e\u900f\u8996\u6295\u5f71\u300f, 2D\u76f8\u6a5f\u4fc2\u300e\u5e73\u884c\u6295\u5f71\u300f\u751f\u6210\u65b9\u76d2\u300e\u8996\u9ad4\u300f, \u611b\u849e\u526a\u88c1\u7269\u9ad4, \u5514\u4fc2\u300e\u8996\u9ad4\u300f\u5167\u5514\u300e\u6e32\u67d3\u300f. \u611b\u849e\u300e\u7b49\u6bd4\u4f8b\u6e38\u6232\u300f\u300e\u5e73\u9762\u6e38\u6232\u300f<\/p>\n<p>OpenGL\u300e2D\u76f8\u6a5f\u300f\u539f\u9ede\u300e0,0\u300f\u4fc2\u300e\u5de6\u4e0b\u89d2\u300f, z\u8ef8\u9060\u7aef\u4fc2\u8ca0,\u8fd1\u7aef\u6b63.<\/p>\n<p>Android\u300e\u7192\u5c4f\u300f\u539f\u9ede\u300e0,0\u300f\u4fc2\u300e\u5de6\u4e0a\u89d2\u300f,<\/p>\n<ol>\n<li>\u9996\u5148\u6307\u5b9a\u300e\u77e9\u9663\u5806\u68e7\u300f\u70ba\u300e\u6295\u5f71\u77e9\u9663\u5806\u68e7\u300f<\/li>\n<\/ol>\n<table>\n<tbody>\n<tr>\n<td width=\"575\">glMatrixMode(GL_PROJECTION);<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<ol start=\"2\">\n<li>\u6e05\u9664\u6b98\u7559\u77e9\u9663\u5e76\u8f09\u5165\u300e\u55ae\u4f4d\u77e9\u9663\u300f,.<\/li>\n<\/ol>\n<table>\n<tbody>\n<tr>\n<td width=\"575\">glLoadIdentity();<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<ol start=\"3\">\n<li>\u91cd\u7f6e\u8996\u5340\u5c3a\u5bf8,\u300e\u8996\u5340\u300f\u8b8a\u63db\u4fc2\u300e\u6295\u5f71\u300f\u8b8a\u63db\u4e4b\u5f8c,\u300ex,y\u300f\u5de6\u4e0b\u89d2\u300e0,0\u300f. \u300ewidth,height\u300f\u540c\u8996\u7a97\u5c3a\u5bf8\u76f8\u61c9\u300e\u7192\u5c4f\u50cf\u7d20\u300f, \u9664\u975e\u60f3\u4fc2\u8996\u7a97\u4e00\u90e8\u5206\u5340\u57df\u7e6a\u756b, \u53ef\u8a2d\u8f03\u5b9a\u8f03\u7d30\u300e\u8996\u5340\u300f.<\/li>\n<\/ol>\n<table>\n<tbody>\n<tr>\n<td width=\"575\">glViewport(x, y, window_width, window_height);<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<ol start=\"4\">\n<li>\u300e\u5e73\u884c\u6295\u5f71\u300f\u5b9a\u65b9\u76d2\u300e\u8996\u9ad4\u300f\u611b\u849e\u526a\u88c1\u7269\u9ad4, \u800c\u5514\u4fc23D\u76f8\u6a5f\u9310\u5f62.\u300eleft, bottom\u300f\u6307\u5de6\u4e0b\u89d2\u300e0, 0\u300f,\u300eright, top\u300f\u6307\u53f3\u4e0a\u89d2\u300ewidth, height\u300f. \u7192\u5c4f\u5c3a\u5bf8\u8a2d\u300e800,600\u300f\u6216\u300e640,480\u300f. \u6e38\u6232\u4e16\u754c\u5c3a\u5bf8\u8a2d\u300e80,60\u300f\u6216\u300e64,48\u300f. OpenGL\u6703\u81ea\u52d5\u653e\u5927\u8207\u8996\u5340\u76f8\u914d.\u300enear, far\u300fz\u8ef8\u526a\u88c1\u9762\u300e1, -1\u300f<\/li>\n<\/ol>\n<table>\n<tbody>\n<tr>\n<td width=\"575\">glOrthof (left,right,bottom,top,near,far);<\/td>\n<\/tr>\n<tr>\n<td width=\"575\">glOrthof (0, frustum_width, 0, frustum_height, 1, -1);<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<ol start=\"5\">\n<li>\u6307\u5b9a\u300e\u8996\u9ad4\u300f\u4e2d\u5fc3\u300ex, y\u300f.\u79fb\u52d52D\u76f8\u6a5f<\/li>\n<\/ol>\n<table>\n<tbody>\n<tr>\n<td width=\"575\">glOrthof (x- width\/2, \u00a0x+width\/x, y-height\/2, y+height\/2, 1, -1);<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<table>\n<tbody>\n<tr>\n<td width=\"288\">glOrthof()<\/td>\n<td width=\"288\">&nbsp;<\/td>\n<\/tr>\n<tr>\n<td width=\"288\">\u300eleft, bottom\u300f<\/td>\n<td width=\"288\">\u5de6\u4e0b\u89d2\u300e0, 0\u300f<\/td>\n<\/tr>\n<tr>\n<td width=\"288\">\u300eright, top\u300f<\/td>\n<td width=\"288\">\u53f3\u4e0a\u89d2\u300ewidth, height\u300f<\/td>\n<\/tr>\n<tr>\n<td width=\"288\">near<\/td>\n<td width=\"288\">z\u8ef8\u8fd1\u7aef\u526a\u88c1\u9762<\/td>\n<\/tr>\n<tr>\n<td width=\"288\">far<\/td>\n<td width=\"288\">z\u8ef8\u9060\u7aef\u526a\u88c1\u9762<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<ol start=\"6\">\n<li>\u6062\u5fa9\u300e\u77e9\u9663\u5806\u68e7\u300f\u70ba\u300e\u8996\u5716\u77e9\u9663\u5806\u68e7\u300f<\/li>\n<\/ol>\n<table>\n<tbody>\n<tr>\n<td width=\"575\">glMatrixMode(GL_MODELVIEW);<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<ol start=\"7\">\n<li>\u8f09\u5165\u300e\u55ae\u4f4d\u77e9\u9663\u300f,\u6e05\u9664\u6b98\u7559\u77e9\u9663<\/li>\n<\/ol>\n<table>\n<tbody>\n<tr>\n<td width=\"575\">glLoadIdentity();<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u793a\u4f8b<\/p>\n<table>\n<tbody>\n<tr>\n<td width=\"575\">void\u00a0 Projection_Camera2D(CAMERA2D_PTR cam){<\/p>\n<p>\/\/ \u91cd\u7f6e\u8996\u5340\u5c3a\u5bf8<\/p>\n<p>::glViewport(0,0,cam-&gt;real_width,cam-&gt;real_height);<\/p>\n<p>\/\/ \u8a2d\u7232\u6295\u5f71\u77e9\u9663<\/p>\n<p>::glMatrixMode(GL_PROJECTION);<\/p>\n<p>\/\/ \u8f09\u5165\u55ae\u4f4d\u77e9\u9663<\/p>\n<p>::glLoadIdentity();<\/p>\n<p>\/\/ \u6b63\u4ea4\u6295\u5f71<\/p>\n<p>glOrthof (0, cam-&gt;frustum_width, 0, cam-&gt;frustum_height, 1, -1);<\/p>\n<p>\/\/ \u8a2d\u5b9a\u6a21\u578b\u8996\u5716\u77e9\u9663<\/p>\n<p>::glMatrixMode(GL_MODELVIEW);<\/p>\n<p>\/\/ \u8f09\u5165\u55ae\u4f4d\u77e9\u9663<\/p>\n<p>::glLoadIdentity();<\/p>\n<p>}<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>OpenGL\u6709\u300e\u5e73\u884c\u6295\u5f71\u300f\u540c\u300e\u900f\u8996\u6295\u5f71\u300f, 2D\u76f8\u6a5f\u4fc2\u300e\u5e73\u884c\u6295\u5f71\u300f\u751f\u6210\u65b9\u76d2\u300e\u8996\u9ad4\u300f, \u611b\u849e\u526a\u88c1\u7269\u9ad4, \u5514\u4fc2\u300e\u8996 &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.bookcard.net\/wordpress\/android_studio_ndk_opengl_es_2d_camera\/\" class=\"more-link\">\u7e7c\u7e8c\u95b1\u8b80 <span class=\"screen-reader-text\">Android Studio NDK-OpenGL ES-2D\u76f8\u6a5f<\/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":[4,62],"tags":[2,50],"class_list":["post-11039","post","type-post","status-publish","format-standard","hentry","category-android","category-opengl","tag-android","tag-opengl","entry"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.bookcard.net\/wordpress\/wp-json\/wp\/v2\/posts\/11039","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=11039"}],"version-history":[{"count":1,"href":"https:\/\/www.bookcard.net\/wordpress\/wp-json\/wp\/v2\/posts\/11039\/revisions"}],"predecessor-version":[{"id":11041,"href":"https:\/\/www.bookcard.net\/wordpress\/wp-json\/wp\/v2\/posts\/11039\/revisions\/11041"}],"wp:attachment":[{"href":"https:\/\/www.bookcard.net\/wordpress\/wp-json\/wp\/v2\/media?parent=11039"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bookcard.net\/wordpress\/wp-json\/wp\/v2\/categories?post=11039"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.bookcard.net\/wordpress\/wp-json\/wp\/v2\/tags?post=11039"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}