{"id":10388,"date":"2020-06-24T02:30:09","date_gmt":"2020-06-23T17:30:09","guid":{"rendered":"http:\/\/www.webcyou.com\/?p=10388"},"modified":"2020-06-24T02:30:09","modified_gmt":"2020-06-23T17:30:09","slug":"mac-home-brew%e3%81%a7sdl2-0%e3%82%92%e7%b0%a1%e5%8d%98%e3%81%ab%e7%92%b0%e5%a2%83%e8%a8%ad%e5%ae%9a","status":"publish","type":"post","link":"https:\/\/www.webcyou.com\/?p=10388","title":{"rendered":"Mac Home brew\u3067SDL2.0\u3092\u7c21\u5358\u306b\u74b0\u5883\u8a2d\u5b9a"},"content":{"rendered":"<p>\u3069\u3082\u3067\u3059\u3002<\/p>\n<p>\u305d\u308d\u305d\u308d\u3001Ubuntu\u3067\u3001SDL2.0\u958b\u767a\u3067\u3082\u59cb\u3081\u3088\u3046\u304b\u3068\u601d\u3044\u304d\u3084\uff08\u3053\u306e\u6642\u4ee3\u306b\u3067\u3059\u304cw\uff09\u3001<\/p>\n<p>\u305d\u3082\u305d\u3082Mac\u3067\u3082\u958b\u767a\u51fa\u6765\u308b\u3067\u306f\u306a\u3044\u304b\uff01<\/p>\n<p>\u5b8c\u5168\u306b\u601d\u3044\u8fbc\u3093\u3067\u3044\u307e\u3057\u305f\u3002<\/p>\n<p>\u3057\u304b\u3082\u3001Home Brew\u3067\u30b5\u30af\u30c3\u3068\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u51fa\u6765\u308b\u3067\u306f\u306a\u3044\u304b\uff01\uff1f<\/p>\n<p>\u3068\u306a\u308c\u3070\u3001Mac\u3067\u30b5\u30af\u30c3\u3068\u74b0\u5883\u8a2d\u5b9a\u3057\u3001\u958b\u767a\u3067\u3082\u3068\u3002<\/p>\n<p>\u3068\u306f\u3044\u3048\u3001\u5148\u65e5\u306eWWDC 2020\u3067\u306f\u3001ARM Mac\u306b\u79fb\u884c\u3059\u308b\u3063\u3066\u8a00\u3046\u3082\u3093\u3060\u304b\u3089\u3001\u8272\u3005\u3068\u3069\u3046\u306a\u308b\u3093\u3060\u308d\u3046\u611f\u304c\u534a\u7aef\u306a\u3044\u4eca\u65e5\u3053\u306e\u9803\u3067\u3059\u3002<\/p>\n<p>\u307e\u3041\u3001BootCamp\u306f\u7121\u304f\u306a\u308b\u3060\u308d\u3046\u3057\u3001\u69cb\u60f3\u3057\u3066\u3044\u305fMacMini + eGPU\u69cb\u6210\u3082\u5922\u306e\u307e\u307e\u7d42\u308f\u308a\u305d\u3046\u3067\u3059\u3002<\/p>\n<p>\uff08\u4eca\u8cb7\u3046\u306e\u3082\u5fae\u5999\u3060\u3057\u3001ARM\u306b\u306a\u308b\u3068\u3001eGPU\u7121\u304f\u306a\u308a\u305d\u3046\u3060\u3057\uff09<\/p>\n<p>\u3068\u8a00\u3046\u3001\u30e2\u30e4\u30e2\u30e4\u306f\u4e00\u65e6\u7f6e\u3044\u3068\u3044\u3066\u3001<\/p>\n<h4>\u30d0\u30fc\u30b8\u30e7\u30f3<\/h4>\n<ul>\n<li>Mac OS\u00a010.14.5<\/li>\n<li>Homebrew 2.4.1<\/li>\n<li>Apple clang version 11.0.0<\/li>\n<\/ul>\n<h4>\u74b0\u5883\u69cb\u7bc9<\/h4>\n<p>Home Brew\u3067\u30b5\u30af\u30c3\u3068\u3001SDL2.0\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\u5834\u5408\u306f\u3001\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3067\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">$ brew install sdl2<\/pre>\n<p>\u8af8\u3005\u306e\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\u5834\u5408\u306f\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3067\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">$ brew install sdl2 sdl2_image sdl2_ttf sdl2_mixer sdl2_gfx sdl2_net<\/pre>\n<p>\u5404\u30e9\u30a4\u30d6\u30e9\u30ea\u306e\u6982\u8981\u306f\u4ee5\u4e0b\u306e\u901a\u308a<\/p>\n<ul>\n<li>sdl2_image \u753b\u50cf\u3092\u6271\u3046\u30e9\u30a4\u30d6\u30e9\u30ea<\/li>\n<li>sdl2_ttf \u30d5\u30a9\u30f3\u30c8\u3092\u6271\u3046\u30e9\u30a4\u30d6\u30e9\u30ea<\/li>\n<li>sdl2_mixer \u30b5\u30a6\u30f3\u30c9\u30df\u30ad\u30b7\u30f3\u30b0\u30e9\u30a4\u30d6\u30e9\u30ea<\/li>\n<li>sdl2_gfx \u7dda\u5206\u3001\u56db\u89d2\u3001\u5186\u3001\u591a\u89d2\u5f62\u306e\u63cf\u753b\u7b49\u3092\u6301\u3064\u30b0\u30e9\u30d5\u30a3\u30c3\u30af\u30e9\u30a4\u30d6\u30e9\u30ea<\/li>\n<li>sdl2_net \u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u30e9\u30a4\u30d6\u30e9\u30ea<\/li>\n<\/ul>\n<p>\u3053\u3061\u3089\u306e<a href=\"https:\/\/wiki.libsdl.org\/Installation#Mac_OS_X\" target=\"_blank\">SDL\u306ewiki<\/a>\u3067\u306f\u3001\u30d3\u30eb\u30c9\u3059\u308b\u3084\u308a\u65b9\u3067\u3059\u304c\u3001brew\u3067\u30b5\u30af\u30c3\u3068\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3061\u3083\u3044\u307e\u3057\u305f\u3002<\/p>\n<p>\u30b3\u30f3\u30d1\u30a4\u30eb\u3092\u884c\u3046\u969b\u306e\u30b3\u30de\u30f3\u30c9\u306f\u4ee5\u4e0b\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">$ gcc main.c `sdl2-config --cflags --libs` <\/pre>\n<p>\u305d\u308c\u3067\u306f\u3001\u65e9\u901f\u3001\u30a6\u30a3\u30f3\u30c9\u30a6\u3092\u7acb\u3061\u4e0a\u3052\u308b\u30bd\u30fc\u30b9\u3092\u4f5c\u308a\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">#include &quot;SDL.h&quot;\r\n#include &lt;stdio.h&gt;\r\n\r\nint main() {\r\n    SDL_Init(SDL_INIT_VIDEO);\r\n\r\n    SDL_Window *window = SDL_CreateWindow(\r\n        &quot;SDL2 window title&quot;,\r\n        SDL_WINDOWPOS_UNDEFINED,\r\n        SDL_WINDOWPOS_UNDEFINED,\r\n        640,\r\n        480,\r\n        SDL_WINDOW_OPENGL\r\n    );\r\n\r\n    if (window == NULL) {\r\n        printf(&quot;Could not create window: %s\\n&quot;, SDL_GetError());\r\n        return 1;\r\n    }\r\n\r\n    SDL_Event event;\r\n    while(SDL_PollEvent(&amp;event)) {\r\n        if (event.type == SDL_QUIT) {\r\n            SDL_DestroyWindow(window);\r\n            SDL_Quit();\r\n            return 0;\r\n        }\r\n    }\r\n\r\n    SDL_Delay(5000);\r\n    SDL_DestroyWindow(window);\r\n    SDL_Quit();\r\n    return 0;\r\n}<\/pre>\n<p>\u4e0a\u8a18\u306e\u30bd\u30fc\u30b9\u3092\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3067\u3001\u30b3\u30f3\u30d1\u30a4\u30eb<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">$ gcc main.c `sdl2-config --cflags --libs`<\/pre>\n<p>main.out\u306e\u30d5\u30a1\u30a4\u30eb\u304c\u751f\u6210\u3055\u308c\u3066\u3044\u308b\u304b\u3068\u601d\u3044\u307e\u3059\u306e\u3067\u3001\u5b9f\u884c\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">$ .\/main<\/pre>\n<p>\u3059\u308b\u3068\u3001\u30a6\u30a3\u30f3\u30c9\u30a6\u304c\u7acb\u3061\u304c\u308a\u307e\u3057\u305f\uff01<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-10392\" src=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/2020\/06\/19ede937884eb65f4136878afe85c3ea.png\" alt=\"\" width=\"490\" height=\"400\" srcset=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/2020\/06\/19ede937884eb65f4136878afe85c3ea.png 752w, https:\/\/www.webcyou.com\/wp-content\/uploads\/2020\/06\/19ede937884eb65f4136878afe85c3ea-300x245.png 300w\" sizes=\"auto, (max-width: 490px) 100vw, 490px\" \/><\/p>\n<h4>\u30bd\u30fc\u30b9\u6982\u8981<\/h4>\n<p>\u3056\u3063\u3068\u3060\u3051\u89e3\u8aac\u3092\u3002<\/p>\n<p>SDL_CreateWindow\u3067\u3001\u30a6\u30a3\u30f3\u30c9\u30a6\u3092\u751f\u6210\u3057\u3066\u304a\u308a\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">SDL_Window *window = SDL_CreateWindow(\r\n    \"SDL2 window title\", \/\/ \u30a6\u30a3\u30f3\u30c9\u30a6\u306e\u30bf\u30a4\u30c8\u30eb\r\n    SDL_WINDOWPOS_UNDEFINED, \/\/ \u30a6\u30a3\u30f3\u30c9\u30a6\u306eX\u5ea7\u6a19\u306e\u521d\u671f\u5024\r\n    SDL_WINDOWPOS_UNDEFINED, \/\/ \u30a6\u30a3\u30f3\u30c9\u30a6\u306eY\u5ea7\u6a19\u306e\u521d\u671f\u5024\r\n    640, \/\/ \u30a6\u30a3\u30f3\u30c9\u30a6\u306e\u5e45\r\n    480, \/\/ \u30a6\u30a3\u30f3\u30c9\u30a6\u306e\u9ad8\u3055\r\n    SDL_WINDOW_OPENGL \/\/ 0 \u307e\u305f\u306f 1\u306e\u30d5\u30e9\u30b0\r\n);<\/pre>\n<p>\u3061\u3087\u3063\u3068\u30cf\u30de\u3063\u305f\u306e\u304c\u3001\u554f\u984c\u306a\u304f\u5b9f\u884c\u3055\u308c\u3066\u3044\u308b\u304c\u3001\u30a6\u30a3\u30f3\u30c9\u30a6\u304c\u8868\u793a\u3057\u306a\u3044\u73fe\u8c61\u306b\u9665\u3063\u305f\u4e8b\u3002\u3000<\/p>\n<p>\u3069\u3046\u3084\u3089\u3001\u4ee5\u4e0b\u306e\u30eb\u30fc\u30d7\u304c\u7121\u3044\u3068\u3001\u30a6\u30a3\u30f3\u30c9\u30a6\u304c\u8868\u793a\u3057\u306a\u3044\u307f\u305f\u3044\u306a\u306e\u3067\u3001\u8ffd\u8a18\u3057\u307e\u3057\u305f\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">SDL_Event event;\r\nwhile(SDL_PollEvent(&event)) {\r\n    if (event.type == SDL_QUIT) {\r\n        SDL_DestroyWindow(window);\r\n        SDL_Quit();\r\n        return 0;\r\n    }\r\n}\r\n<\/pre>\n<p>C++\u306e\u30d5\u30a1\u30a4\u30eb\u3067\u3082\u3001\u4ee5\u4e0b\u306e g++ \u30b3\u30de\u30f3\u30c9\u3067\u30b3\u30f3\u30d1\u30a4\u30eb\u51fa\u6765\u307e\u3057\u305f\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">$ g++ main.cpp `sdl2-config --cflags --libs`<\/pre>\n<p>\u751f\u6210\u3059\u308b\u3001\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u30d5\u30a1\u30a4\u30eb\u540d\u3092\u5909\u66f4\u3057\u305f\u3044\u5834\u5408\u3058\u3083\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">g++ -o window main.cpp `sdl2-config --cflags --libs`<\/pre>\n<p>\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3067\u3001\u884c\u306a\u3063\u3066\u3044\u308b\u30b3\u30de\u30f3\u30c9\u306e\u8a73\u7d30\u3092\u78ba\u8a8d\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">$ sdl2-config --cflags --libs<\/pre>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">-I\/usr\/local\/include\/SDL2 -D_THREAD_SAFE\r\n-L\/usr\/local\/lib -lSDL2<\/pre>\n<p>\u3068\u3044\u3063\u305f\u8a33\u3067\u3001\u4eca\u56de\u306f\u6700\u5c0f\u9650\u3067SDL2.0\u3067\u3001\u30a6\u30a3\u30f3\u30c9\u30a6\u3092\u7acb\u3061\u4e0a\u3052\u307e\u3057\u305f\u3002<\/p>\n<p>\u3061\u3087\u3063\u3068\u3057\u305f\u30b0\u30e9\u30d5\u30a3\u30c3\u30af\u4f5c\u6210\u306b\u826f\u3044\u3067\u3059\u306d\u3002<\/p>\n<p>\u3067\u306f\u3067\u306f\u3041\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3069\u3082\u3067\u3059\u3002 \u305d\u308d\u305d\u308d\u3001Ubuntu\u3067\u3001SDL2.0\u958b\u767a\u3067\u3082\u59cb\u3081\u3088\u3046\u304b\u3068\u601d\u3044\u304d\u3084\uff08\u3053\u306e\u6642\u4ee3\u306b\u3067\u3059\u304cw\uff09\u3001 \u305d\u3082\u305d\u3082Mac\u3067\u3082\u958b\u767a\u51fa\u6765\u308b\u3067\u306f\u306a\u3044\u304b\uff01 \u5b8c\u5168\u306b\u601d\u3044\u8fbc\u3093\u3067\u3044\u307e\u3057\u305f\u3002 \u3057\u304b\u3082\u3001Home Brew\u3067\u30b5\u30af\u30c3\u3068\u30a4\u30f3\u30b9\u30c8\u30fc [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[200],"tags":[169,107,180,150,45,111,95,39,55,178,78,114,118],"class_list":["post-10388","post","type-post","status-publish","format-standard","hentry","category-c-2","tag-mac","tag-mamp","tag-mysql","tag-vagrant","tag-web","tag-wordpress-2","tag-95","tag-39","tag-55","tag-178","tag-78","tag-114","tag-118"],"_links":{"self":[{"href":"https:\/\/www.webcyou.com\/index.php?rest_route=\/wp\/v2\/posts\/10388","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.webcyou.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.webcyou.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.webcyou.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.webcyou.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=10388"}],"version-history":[{"count":5,"href":"https:\/\/www.webcyou.com\/index.php?rest_route=\/wp\/v2\/posts\/10388\/revisions"}],"predecessor-version":[{"id":10394,"href":"https:\/\/www.webcyou.com\/index.php?rest_route=\/wp\/v2\/posts\/10388\/revisions\/10394"}],"wp:attachment":[{"href":"https:\/\/www.webcyou.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=10388"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webcyou.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=10388"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webcyou.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=10388"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}