{"id":55442,"date":"2020-01-21T00:00:00","date_gmt":"2020-01-20T21:00:00","guid":{"rendered":"https:\/\/prohoster.info\/blog\/blog_prohoster\/podgotovka-sdl2-proekta-dlya-zapuska-na-android"},"modified":"2020-02-18T14:03:33","modified_gmt":"2020-02-18T11:03:33","slug":"podgotovka-sdl2-proekta-dlya-zapuska-na-android","status":"publish","type":"post","link":"https:\/\/prohoster.info\/hu\/blog\/administrirovanie\/podgotovka-sdl2-proekta-dlya-zapuska-na-android","title":{"rendered":"SDL2 projekt el\u0151k\u00e9sz\u00edt\u00e9se Androidon val\u00f3 futtat\u00e1shoz","gt_translate_keys":[{"key":"rendered","format":"text"}]},"content":{"rendered":"<p>Hell\u00f3 mindenkinek. Ma megn\u00e9zz\u00fck, hogyan k\u00e9sz\u00edthetj\u00fck el\u0151 a projektet sdl2 k\u00f6nyvt\u00e1r haszn\u00e1lat\u00e1val, hogy j\u00e1t\u00e9kot ind\u00edtsunk Androidon.<br \/>\n<noindex><a rel=\"nofollow\" name=\"habracut\"><\/a><\/noindex><br \/>\nEls\u0151 l\u00e9p\u00e9sk\u00e9nt le kell t\u00f6lten\u00fcnk az Android Studio-t, telep\u00edten\u00fcnk kell, \u00e9s mindent be kell \u00e1ll\u00edtanunk a fejleszt\u00e9shez ezen a platformon. P\u00e9ld\u00e1ul nekem most Kde Neon van, \u00e9s ebben a rendszerben van egy f\u00e1jl \"\/etc\/environment\", ami az ubuntuban is megtal\u00e1lhat\u00f3. Ott meg kell hat\u00e1roznunk n\u00e9h\u00e1ny v\u00e1ltoz\u00f3t.<\/p>\n<pre><code class=\"plaintext\">ANDROID_HOME=\\\/home\\\/username\\\/Android\\\/Sdk\nANDROID_NDK_HOME=\\\/home\\\/username\\\/ndk\n<\/code><\/pre>\n<p>\nTov\u00e1bb\u00e1 le kell t\u00f6lten\u00fcnk az NDK-t a hivatalos weboldalr\u00f3l, ki kell csomagolnunk a saj\u00e1t mapp\u00e1nkba, \u00e9s \u00e1t kell nevezn\u00fcnk NDK-ra. Ezut\u00e1n el kell menn\u00fcnk a SDL2 k\u00f6nyvt\u00e1r let\u00f6lt\u00e9s\u00e9re a <noindex><a rel=\"nofollow\" href=\"https:\/\/www.libsdl.org\/\">libsdl.org<\/a><\/noindex>. Az sdl2 Androidra t\u00f6rt\u00e9n\u0151 haszn\u00e1lat\u00e1hoz fontos, hogy ne sz\u00e1m\u00edtsuk \u00f6ssze a sz\u00e1m\u00edt\u00f3g\u00e9phez, mert akkor nem fog m\u0171k\u00f6dni Androidra. A projekt \u00f6ssze\u00e1ll\u00edt\u00e1s\u00e1hoz egy b\u00e1rmilyen projektet kell l\u00e9trehozni az Android Studio-ban, hogy elfogadjuk a licencet, k\u00fcl\u00f6nben az SDL2 \u00e9p\u00edt\u00e9sekor licencet fog k\u00e9rni.<\/p>\n<p>Az Androidban az assets-b\u0151l val\u00f3 f\u00e1jlok olvas\u00e1s\u00e1hoz az SDL_RWops funkci\u00f3kat kell haszn\u00e1lni. \u00cdme egy p\u00e9lda a bet\u0171t\u00edpusok kezel\u00e9s\u00e9re. Ebben az esetben nem haszn\u00e1lhatjuk az FT_New_Face-t, helyette az FT_New_Memory_Face haszn\u00e1lata sz\u00fcks\u00e9ges a m\u00e1r bet\u00f6lt\u00f6tt adatokhoz.<\/p>\n<pre><code class=\"cpp\">#ifdef __ANDROID__\n        snprintf ( path, 254, &quot;fonts\/%s&quot;, file );\n        SDL_RWops *rw = SDL_RWFromFile(path, &quot;r&quot; );\n        char *memory = ( char * ) calloc ( rw-&gt;hidden.androidio.size, 1 );\n        SDL_RWread(rw, memory, 1, rw-&gt;hidden.androidio.size );\n\n        FT_New_Memory_Face(*this-&gt;ft_library, ( const FT_Byte  * )memory, rw-&gt;hidden.androidio.size, 0, &this;-&gt;face );\n        SDL_RWclose(rw);\n        free ( memory );\n#else\n        snprintf ( path, 254, &quot;%s\/fonts\/%s&quot;, DEFAULT_ASSETS, file );\n        if ( access ( path, F_OK ) ) {\n                fprintf ( stderr, &quot;not found font: %sn&quot;, path );\n                exit ( EXIT_FAILURE );\n        }\n        struct stat st;\n        stat ( path, &st; );\n        FILE *rw = fopen ( path, &quot;r&quot; );\n        char *memory = ( char * ) calloc ( st.st_size, 1 );\n        fread ( memory, 1, st.st_size, rw );\n\n        FT_New_Memory_Face ( *this-&gt;ft_library, ( const FT_Byte * ) memory, st.st_size, 0, &this;-&gt;face );\n        fclose ( rw );\n        free ( memory );\n#endif\n\n<\/code><\/pre>\n<p>\nK\u00e9sz\u00edtettem egy fejl\u00e9ces f\u00e1jlt az SDL2 fejl\u00e9cf\u00e1jljainak csatlakoztat\u00e1s\u00e1hoz. A NO_SDL_GLEXT sz\u00fcks\u00e9ges, hogy a ford\u00edt\u00e1s sikeresen v\u00e9gbemenjen Androidon.<\/p>\n<pre><code class=\"cpp\">#ifdef __ANDROID__\n#include &quot;SDL.h&quot;\n#include &quot;SDL_video.h&quot;\n#include &quot;SDL_events.h&quot;\n#define NO_SDL_GLEXT \n#include &quot;SDL_opengl.h&quot;\n#include &quot;SDL_opengles2.h&quot;\n#else\n#include &lt;SDL2\/SDL.h&gt;\n#include &lt;SDL2\/SDL_video.h&gt;\n#include &lt;SDL2\/SDL_opengl.h&gt;\n#include &lt;SDL2\/SDL_opengles2.h&gt;\n#endif\n<\/code><\/pre>\n<p>\nTeh\u00e1t a projekt k\u00e9szen \u00e1ll, a shader-ek k\u00e9szen \u00e1llnak az Opengl Es 3.0-hoz. Most l\u00e9tre kell hoznunk az android-projectet. Ehhez ki kell csomagolnunk az SDL2 arch\u00edvumot. Bel\u00e9p\u00fcnk a build-scripts mapp\u00e1ba. \u00c9s v\u00e9grehajtjuk a k\u00f6vetkez\u0151t.<\/p>\n<pre><code class=\"bash\">.\\\/androidbuild.sh com.xverizex.test main.cpp\n<\/code><\/pre>\n<p>\nMegjelenik egy \u00fczenet.<\/p>\n<pre><code class=\"bash\">A tesztel\u00e9shez sz\u00fcks\u00e9ges eszk\u00f6zre val\u00f3 \u00e9p\u00edt\u00e9shez \u00e9s telep\u00edt\u00e9shez futtassa az al\u00e1bbi parancsokat:\ncd \\\/home\\\/cf\\\/programs\\\/SDL2-2.0.10\\\/build\\\/com.xverizex.test\n.\\\/gradlew installDebug\n<\/code><\/pre>\n<p>\nL\u00e9pj\u00fcnk be a com.xverizex.test mapp\u00e1ba. Bel\u00e9p\u00fcnk a com.xverizex.test\\\/app\\\/jni\\\/src mapp\u00e1ba. M\u00e1soljuk \u00e1t a saj\u00e1t j\u00e1t\u00e9kprojekt\u00fcnket. \u00c9s m\u00f3dos\u00edtjuk az Android.mk f\u00e1jlt, az \u00e9n esetemben \u00edgy n\u00e9z ki.<\/p>\n<pre><code class=\"cpp\">LOCAL_PATH := $(call my-dir)\n\ninclude $(CLEAR_VARS)\n\nLOCAL_MODULE := main\n\nSDL_PATH := ..\\\/SDL\nFREETYPE_PATH := ..\\\/Freetype2\n\nLOCAL_C_INCLUDES := $(LOCAL_PATH)\\\/${SDL_PATH}\\\/include $(LOCAL_PATH)\\\/${FREETYPE_PATH}\\\/include\n\n# Add your application source files here...\nLOCAL_SRC_FILES := .\\\/engine\\\/lang.cpp .\\\/engine\\\/actor.cpp .\\\/engine\\\/sprite.cpp .\\\/engine\\\/shaders.cpp .\\\/engine\\\/box.cpp .\\\/engine\\\/menubox.cpp .\\\/engine\\\/load_manager.cpp .\\\/engine\\\/main.cpp .\\\/engine\\\/font.cpp .\\\/engine\\\/model.cpp .\\\/engine\\\/button.cpp .\\\/theme.cpp .\\\/level_manager.cpp .\\\/menu\\\/menu.cpp\n\nLOCAL_SHARED_LIBRARIES := SDL2 Freetype2\n\nLOCAL_LDLIBS := -lGLESv1_CM -lGLESv2 -llog \n\ninclude $(BUILD_SHARED_LIBRARY)\n<\/code><\/pre>\n<p>\nAhogy \u00e9szrevett\u00e9k, a Freetype2 k\u00f6nyvt\u00e1rat is csatlakoztatom. Tal\u00e1ltam egy m\u00e1r m\u0171k\u00f6d\u0151 verzi\u00f3t a github-on Androidra, de nem m\u0171k\u00f6d\u00f6tt, n\u00e9h\u00e1ny dolgot m\u00f3dos\u00edtani kellett. Ezen k\u00edv\u00fcl l\u00e9trehozzuk az app\\\/src\\\/main\\\/assets mapp\u00e1t. Ide tessz\u00fck a forr\u00e1sainkat (bet\u0171t\u00edpusok, sprite-ok, 3D modellek).<\/p>\n<p>Most be\u00e1ll\u00edtjuk a Freetype2-t Androidhoz. T\u00f6lts\u00fck le az \u00e9n github-omr\u00f3l <noindex><a rel=\"nofollow\" href=\"https:\/\/github.com\/xverizex\/Android-Freetype2\">(lehet\u0151v\u00e9 teszi a webfejleszt\u0151k sz\u00e1m\u00e1ra, hogy optimaliz\u00e1lj\u00e1k az er\u0151forr\u00e1sok bet\u00f6lt\u00e9s\u00e9t az er\u0151forr\u00e1sok relat\u00edv priorit\u00e1s\u00e1nak megad\u00e1s\u00e1val).<\/a><\/noindex>, \u00e9s m\u00e1soljuk a Freetype2 mapp\u00e1t az app\/jni\/ mapp\u00e1ba. Minden k\u00e9szen \u00e1ll. Most futtassuk a com.xverizex.test parancsot .\/{gradlew installDebug}. Ahhoz, hogy ezt a j\u00e1t\u00e9kot androidra adhassuk, az androidon enged\u00e9lyezve kell lennie a hibakeres\u00e9snek. Ehhez l\u00e9pj\u00fcnk a be\u00e1ll\u00edt\u00e1sokhoz, menj\u00fcnk a \u201eRendszer\u201d r\u00e9szhez, majd az \u201eA t\u00e1blag\u00e9pr\u0151l\u201d opci\u00f3hoz, \u00e9s nyomjuk meg k\u00f6r\u00fclbel\u00fcl hatszor a \u201eBuild sz\u00e1m\u201d opci\u00f3t. Ezut\u00e1n l\u00e9pj\u00fcnk vissza, \u00e9s megjelenik a fejleszt\u0151k sz\u00e1m\u00e1ra k\u00e9sz\u00fclt opci\u00f3. Menj\u00fcnk oda, \u00e9s kapcsoljuk be, valamint kapcsoljuk be az \u201eUSB hibakeres\u00e9s\u201d opci\u00f3t is. Most meg kell szerezn\u00fcnk a kulcsot a t\u00e1blag\u00e9phez. Ehhez telep\u00edts\u00fck az adb programot. Ind\u00edtsuk el a konzolban az adb shellt, \u00e9s a t\u00e1blag\u00e9pen megjelenik a kulcs, amelyet el kell fogadni. K\u00e9sz, most m\u00e1r a j\u00e1t\u00e9kokat lehet telep\u00edteni a t\u00e1blag\u00e9pre.<br \/>\n<br \/>Forr\u00e1s: <a content=\"nofollow\" rel=\"nofollow\" href=\"https:\/\/habr.com\/ru\/post\/484526\/\">habr.com<\/a><\/p>","protected":false,"gt_translate_keys":[{"key":"rendered","format":"html"}]},"excerpt":{"rendered":"<p>\u0412\u0441\u0435\u043c \u043f\u0440\u0438\u0432\u0435\u0442. \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u043c\u044b \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043a\u0430\u043a \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u0442\u044c \u043f\u0440\u043e\u0435\u043a\u0442 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 sdl2 \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0438\u0433\u0440\u044b \u043d\u0430 android. \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0430\u0434\u043e \u0441\u043a\u0430\u0447\u0430\u0442\u044c Android Studio, \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0435\u0451 \u0438 \u0432\u0441\u0451 \u0447\u0442\u043e \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0432 \u044d\u0442\u043e\u0439 \u0441\u0440\u0435\u0434\u0435 \u0434\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0443 \u043c\u0435\u043d\u044f \u0441\u0435\u0439\u0447\u0430\u0441 Kde Neon, \u0438 \u0432 \u044d\u0442\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0444\u0430\u0439\u043b \/etc\/environment, \u0442\u0430\u043a\u043e\u0439 \u0436\u0435 \u0444\u0430\u0439\u043b \u0435\u0441\u0442\u044c \u0438 \u0432 ubuntu. \u0422\u0430\u043c [&hellip;]<\/p>\n","protected":false,"gt_translate_keys":[{"key":"rendered","format":"html"}]},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[688],"tags":[],"class_list":["post-55442","post","type-post","status-publish","format-standard","hentry","category-administrirovanie"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.3 - aioseo.com -->\n\t<meta name=\"description\" content=\"\u0412\u0441\u0435\u043c \u043f\u0440\u0438\u0432\u0435\u0442.\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Yuri Gagarin\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/prohoster.info\/hu\/blog\/administrirovanie\/podgotovka-sdl2-proekta-dlya-zapuska-na-android\" \/>\n\t\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.3\" \/>\n\t\t<meta property=\"og:locale\" content=\"hu_HU\" \/>\n\t\t<meta property=\"og:site_name\" content=\"ProHoster | \u041a\u0443\u043f\u0438\u0442\u044c \u043d\u0430\u0434\u0435\u0436\u043d\u044b\u0439 \u0445\u043e\u0441\u0442\u0438\u043d\u0433 \u0434\u043b\u044f \u0441\u0430\u0439\u0442\u043e\u0432 \u0441 \u0437\u0430\u0449\u0438\u0442\u043e\u0439 \u043e\u0442 DDoS, VPS VDS \u0441\u0435\u0440\u0432\u0435\u0440\u044b\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"\ud83e\udd47\u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0430 SDL2-\u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043d\u0430 android | ProHoster\" \/>\n\t\t<meta property=\"og:description\" content=\"\u0412\u0441\u0435\u043c \u043f\u0440\u0438\u0432\u0435\u0442.\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/prohoster.info\/hu\/blog\/administrirovanie\/podgotovka-sdl2-proekta-dlya-zapuska-na-android\" \/>\n\t\t<meta property=\"og:image\" content=\"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg\" \/>\n\t\t<meta property=\"og:image:secure_url\" content=\"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg\" \/>\n\t\t<meta property=\"og:image:width\" content=\"350\" \/>\n\t\t<meta property=\"og:image:height\" content=\"350\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2020-01-20T21:00:00+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2020-02-18T11:03:33+00:00\" \/>\n\t\t<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/prohoster\" \/>\n\t\t<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/prohoster\" \/>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"\ud83e\udd47SDL2-projekt el\u0151k\u00e9sz\u00edt\u00e9se Androidon val\u00f3 futtat\u00e1shoz | ProHoster","description":"Hell\u00f3 mindenkinek.","canonical_url":"https:\/\/prohoster.info\/hu\/blog\/administrirovanie\/podgotovka-sdl2-proekta-dlya-zapuska-na-android","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":null,"og:locale":"hu_HU","og:site_name":"ProHoster | \u041a\u0443\u043f\u0438\u0442\u044c \u043d\u0430\u0434\u0435\u0436\u043d\u044b\u0439 \u0445\u043e\u0441\u0442\u0438\u043d\u0433 \u0434\u043b\u044f \u0441\u0430\u0439\u0442\u043e\u0432 \u0441 \u0437\u0430\u0449\u0438\u0442\u043e\u0439 \u043e\u0442 DDoS, VPS VDS \u0441\u0435\u0440\u0432\u0435\u0440\u044b","og:type":"article","og:title":"\ud83e\udd47\u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0430 SDL2-\u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043d\u0430 android | ProHoster","og:description":"\u0412\u0441\u0435\u043c \u043f\u0440\u0438\u0432\u0435\u0442.","og:url":"https:\/\/prohoster.info\/hu\/blog\/administrirovanie\/podgotovka-sdl2-proekta-dlya-zapuska-na-android","og:image":"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg","og:image:secure_url":"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg","og:image:width":350,"og:image:height":350,"article:published_time":"2020-01-20T21:00:00+00:00","article:modified_time":"2020-02-18T11:03:33+00:00","article:publisher":"https:\/\/www.facebook.com\/prohoster","article:author":"https:\/\/www.facebook.com\/prohoster"},"aioseo_meta_data":{"post_id":"55442","title":null,"description":null,"keywords":null,"keyphrases":null,"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":null,"og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"","isEnabled":true},"graphs":[]},"schema_type":null,"schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"local_seo":null,"seo_analyzer_scan_date":null,"breadcrumb_settings":null,"limit_modified_date":false,"reviewed_by":null,"ai":null,"created":"2021-02-28 19:44:25","updated":"2022-10-04 17:24:27","focus_keyword":null,"additional_keywords":null,"truseo_locale":null},"gt_translate_keys":[{"key":"link","format":"url"}],"_links":{"self":[{"href":"https:\/\/prohoster.info\/hu\/wp-json\/wp\/v2\/posts\/55442","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/prohoster.info\/hu\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/prohoster.info\/hu\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/prohoster.info\/hu\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/prohoster.info\/hu\/wp-json\/wp\/v2\/comments?post=55442"}],"version-history":[{"count":0,"href":"https:\/\/prohoster.info\/hu\/wp-json\/wp\/v2\/posts\/55442\/revisions"}],"wp:attachment":[{"href":"https:\/\/prohoster.info\/hu\/wp-json\/wp\/v2\/media?parent=55442"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/prohoster.info\/hu\/wp-json\/wp\/v2\/categories?post=55442"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/prohoster.info\/hu\/wp-json\/wp\/v2\/tags?post=55442"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}