OSDN Git Service

SDL_AllocPalette サンプルコードを追加 https://github.com/libsdl-org/sdlwiki/commit/87b2649fca47...
authormaruhiro <maruhiro@bridge.ocn.ne.jp>
Sun, 5 Mar 2023 07:24:54 +0000 (16:24 +0900)
committermaruhiro <maruhiro@bridge.ocn.ne.jp>
Sun, 5 Mar 2023 07:24:54 +0000 (16:24 +0900)
SDL_AllocPalette.html

index 5c6aaa3..c2b3b09 100644 (file)
 <h2>\96ß\82è\92l</h2>\r
 \90¬\8c÷\82Ì\82Æ\82«\90\90¬\82³\82ê\82½<a href="SDL_Palette.html">SDL_Palette</a>, \8e¸\94s(\8f\\95ª\82È\83\81\83\82\83\8a\82ª\82È\82¢\93\99)\82Ì\82Æ\82«NULL\82ð\96ß\82·.\r
 <a href="SDL_GetError.html">SDL_GetError()</a>\82Å\8fÚ\8d×\82ð\92m\82é\82±\82Æ\82ª\82Å\82«\82é.\r
+<h2>\83T\83\93\83v\83\8b\83R\81[\83h</h2>\r
+<p>\r
+<code>\r
+<pre>\r
+SDL_Palette* palette = nullptr;\r
+\r
+...\r
+\r
+SDL_Init(SDL_EVERYTHING);\r
+\r
+// 4\90F\82Ì\83p\83\8c\83b\83g\82ð\90V\82½\82É\90\90¬\82·\82é\r
+\r
+palette = SDL_AllocPalette(4);\r
+\r
+if (palette == nullptr) printf( "\83G\83\89\81[: %s\n", SDL_GetError() );\r
+\r
+...\r
+\r
+// \83p\83\8c\83b\83g0\82Ì\97Î\90¬\95ª\82Æ\90Â\90¬\95ª\82ð0\82É\82·\82é\r
+\r
+palette->colors[0].g = 0;\r
+palette->colors[0].b = 0;\r
+\r
+// \83\8c\83\93\83_\83\89\82ð\90Ô\90F\82É\90Ý\92è\82·\82é\r
+\r
+SDL_SetRenderDrawColor(renderer, palette->colors[0].r, palette->colors[0].g, palette->colors.b, palette->colors[0].a);\r
+\r
+...\r
+\r
+SDL_FreePalette(palette);\r
+palette = nullptr;\r
+</pre>\r
+</code>\r
 <h2>\8fÚ\8d×</h2>\r
 \83p\83\8c\83b\83g\82Ì\8f\89\8aú\92l\82Í\94\92\82Å\82 \82é.\r
 <h2>\83o\81[\83W\83\87\83\93</h2>\r