{"id":2179,"date":"2021-10-07T13:20:14","date_gmt":"2021-10-07T04:20:14","guid":{"rendered":"https:\/\/sirius10.net\/blog\/wordpress\/?p=2179"},"modified":"2021-10-07T13:20:16","modified_gmt":"2021-10-07T04:20:16","slug":"post-2179","status":"publish","type":"post","link":"https:\/\/sirius10.net\/blog\/wordpress\/index.php\/2021\/10\/07\/2179\/","title":{"rendered":"SDL2 \u3067\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8\u3092\u53d6\u308b"},"content":{"rendered":"\n<p>\u3000SDL2 \u3067\u30a6\u30a3\u30f3\u30c9\u30a6\u30a4\u30e1\u30fc\u30b8\u3092\u753b\u50cf\u306b\u4fdd\u5b58\u3059\u308b\u306b\u306f\u3001\u30c7\u30fc\u30bf\u30b3\u30d4\u30fc\u7528\u306e\u30b5\u30fc\u30d5\u30a7\u30b9\u3092\u6e96\u5099\u3057\u3066\u3001SDL_RenderReadPixels() \u95a2\u6570\u3067\u30a6\u30a3\u30f3\u30c9\u30a6\u30a4\u30e1\u30fc\u30b8\u306e\u30b3\u30d4\u30fc\u3092\u53d6\u5f97\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u3000SDL_RenderReadPixels() \u95a2\u6570\u306f\u3001\u9045\u3044\u95a2\u6570\u306a\u306e\u3067\u3001\u7e70\u308a\u8fd4\u3057\u51e6\u7406\u4e2d\u306b\u547c\u3073\u51fa\u3057\u305f\u308a\u3001\u30bf\u30a4\u30de\u30fc\u306e\u30b3\u30fc\u30eb\u30d0\u30c3\u30af\u3067\u4f7f\u3046\u3068\u3001\u30a4\u30d9\u30f3\u30c8\u306b\u30ad\u30e5\u30fc\u304c\u6e9c\u307e\u308a\u3001\u30a6\u30a3\u30f3\u30c9\u30a6\u3092\u9589\u3058\u3089\u308c\u306a\u304f\u306a\u3063\u305f\u308a\u3057\u3066\u3057\u307e\u3044\u307e\u3059\u3002\u4f7f\u7528\u3059\u308b\u72b6\u6cc1\u306b\u6ce8\u610f\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u3000\u307e\u305f\u3001SDL_RenderPresent() \u306e\u76f4\u5f8c\u306b\u547c\u3073\u51fa\u3059\u3068\u3001\u30a6\u30a3\u30f3\u30c9\u30a6\u306e\u63cf\u753b\u304c\u7d42\u308f\u308b\u524d\u306b\u30a6\u30a3\u30f3\u30c9\u30a6\u306e\u753b\u9762\u30a4\u30e1\u30fc\u30b8\u3092\u30b3\u30d4\u30fc\u3059\u308b\u3053\u3068\u306b\u306a\u308a\u3001\u4e71\u308c\u308b\u3053\u3068\u304c\u3042\u308a\u307e\u3059\u3002\u4e71\u308c\u305f\u5834\u5408\u3001\u3053\u306e\u95a2\u6570\u3092\u547c\u3073\u51fa\u3059\u524d\u306b\u3001SDL_Delay() \u95a2\u6570\u3067\u5f85\u3061\u3092\u5165\u308c\u308b\u3068\u4e71\u308c\u306a\u3044\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002\u79c1\u306f\u3001320x 240 \u3067\u4fdd\u5b58\u3057\u3066\u3044\u307e\u3059\u304c\u300150 \u30df\u30ea\u79d2\u307b\u3069\u5f85\u3061\u3092\u5165\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u3000\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8\u4fdd\u5b58\u7528\u306b\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u95a2\u6570\u3092\u4f5c\u3063\u3066\u4f7f\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted file\">void save_bitmaps(SDL_Renderer *r) {\n    SDL_Surface *s;\n    static int n = 0;\n    char file[20];\n\n    sprintf(file, \"screen%03d.bmp\", n++);\n    s = SDL_CreateRGBSurface(0, <span style=\"background-color: #ffff00\" class=\"background-color\">320, 240, 32<\/span>, 0, 0, 0, 0);\n    if( s == NULL ) {\n        printf(\"Can not create surface\\n\");\n        return;\n    }\n    SDL_LockSurface(s);\n    SDL_RenderReadPixels(r, NULL, s-&gt;format-&gt;format, s-&gt;pixels, s-&gt;pitch);\n    SDL_SaveBMP(s, file);\n    SDL_UnlockSurface(s);\n    SDL_FreeSurface(s);\n}<\/pre>\n\n\n\n<p> \u30d0\u30c3\u30d5\u30a1\u3092\u4f5c\u6210\u3059\u308b SDL_CreateRGBSurface() \u306e\u5e45\u3001\u9ad8\u3055\u3001\u8272\u6df1\u5ea6\u306f\u3001\u5fc5\u8981\u306a\u6570\u5024\u306b\u5909\u66f4\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3000SDL2 \u3067\u30a6\u30a3\u30f3\u30c9\u30a6\u30a4\u30e1\u30fc\u30b8\u3092\u753b\u50cf\u306b\u4fdd\u5b58\u3059\u308b\u306b\u306f\u3001\u30c7\u30fc\u30bf\u30b3\u30d4\u30fc\u7528\u306e\u30b5\u30fc\u30d5\u30a7\u30b9\u3092\u6e96\u5099\u3057\u3066\u3001SDL_RenderReadPixels() \u95a2\u6570\u3067\u30a6\u30a3\u30f3\u30c9\u30a6\u30a4\u30e1\u30fc\u30b8\u306e\u30b3\u30d4\u30fc\u3092\u53d6\u5f97\u3067\u304d\u307e\u3059\u3002 \u3000SDL_RenderReadP [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[27],"tags":[],"class_list":["post-2179","post","type-post","status-publish","format-standard","hentry","category-sdl2"],"_links":{"self":[{"href":"https:\/\/sirius10.net\/blog\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/2179","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sirius10.net\/blog\/wordpress\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sirius10.net\/blog\/wordpress\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sirius10.net\/blog\/wordpress\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sirius10.net\/blog\/wordpress\/index.php\/wp-json\/wp\/v2\/comments?post=2179"}],"version-history":[{"count":4,"href":"https:\/\/sirius10.net\/blog\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/2179\/revisions"}],"predecessor-version":[{"id":2203,"href":"https:\/\/sirius10.net\/blog\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/2179\/revisions\/2203"}],"wp:attachment":[{"href":"https:\/\/sirius10.net\/blog\/wordpress\/index.php\/wp-json\/wp\/v2\/media?parent=2179"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sirius10.net\/blog\/wordpress\/index.php\/wp-json\/wp\/v2\/categories?post=2179"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sirius10.net\/blog\/wordpress\/index.php\/wp-json\/wp\/v2\/tags?post=2179"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}