OSDN Git Service

修正
[sdl2referencejp/sdl2referencejp.git] / SDL_Point.html
index a9aaaf2..477903d 100644 (file)
 <a href="index.html">\96Ú\8e\9f</a> - <a href="ApiByCategory.html">API(\8b@\94\\95Ê)</a> - <a href="CategoryRect.html">\97Ì\88æ</a> - SDL_Point\r
 <hr>\r
 <h1>SDL_Point</h1>\r
-2\8e\9f\8c³\82Ì\93_\82ð\92è\8b`\82·\82é\8d\\91¢\91Ì\r
+2\8e\9f\8c³\8fã\82Ì\93_\82ð\92è\8b`\82·\82é\8d\\91¢\91Ì\r
 <h2>\83t\83B\81[\83\8b\83h</h2>\r
 <table border="1" summary="SDL_Point">\r
 <tr><td>int</td><td>x</td><td>\93_\82ÌX\8dÀ\95W</td></tr>\r
 <tr><td>int</td><td>y</td><td>\93_\82ÌY\8dÀ\95W</td></tr>\r
 </table>\r
+<p>\r
+<h2>\83T\83\93\83v\83\8b\83R\81[\83h</h2>\r
+<code>\r
+<pre>\r
+// \83T\83\93\83v\83\8b\83v\83\8d\83O\83\89\83\80:\r
+// \83R\81[\83h\82Ì\8ae\8f\8a\82ÅSDL_Point\82ð\8eg\82Á\82Ä\82¢\82é\r
+\r
+#include "SDL.h"\r
+#include &lt;stdio.h&gt;\r
+\r
+int main(int argc, char *argv[]) {\r
+\r
+    SDL_Window *window;\r
+\r
+    SDL_Point window_position = {         //    \83E\83B\83\93\83h\83E\82Ì\88Ê\92u\r
+        SDL_WINDOWPOS_CENTERED,\r
+        SDL_WINDOWPOS_CENTERED\r
+    };\r
+    SDL_Point window_size = {640, 480};   //    \83E\83B\83\93\83h\83E\82Ì\83T\83C\83Y\r
+\r
+    SDL_Point mouse_position;             //    \83}\83E\83X\82Ì\8dÀ\95W\r
+\r
+    SDL_Init(SDL_INIT_VIDEO);             //    SDL2\82ð\8f\89\8aú\89»\82·\82é\r
+\r
+    // \8e\9f\82Ì\90Ý\92è\82Å\83A\83v\83\8a\83P\81[\83V\83\87\83\93\83E\83B\83\93\83h\83E\82ð\90Ý\92è\82·\82é\r
+    window = SDL_CreateWindow( \r
+        "SDL_Point usage",                //    \83^\83C\83g\83\8b\r
+        window_position.x,                //    X\8dÀ\95W\82Ì\8f\89\8aú\92l\r
+        window_position.y,                //    Y\8dÀ\95W\82Ì\8f\89\8aú\92l\r
+        window_size.x,                    //    \95\9d\83s\83N\83Z\83\8b\90\94\r
+        window_size.y,                    //    \8d\82\82³\83s\83N\83Z\83\8b\90\94\r
+        SDL_WINDOW_OPENGL                 //    \83t\83\89\83O\r
+    );\r
+\r
+    // \83E\83B\83\93\83h\83E\82ð\90\90¬\82Å\82«\82½\82©\83`\83F\83b\83N\82·\82é\r
+    if (window == NULL) {\r
+        SDL_Log("\83E\83B\83\93\83h\83E\82ð\90\90¬\82Å\82«\82È\82©\82Á\82½: %s", SDL_GetError());\r
+        return 1;\r
+    }\r
+\r
+    SDL_GetMouseState(                    //    \83}\83E\83X\82Ì\83E\83B\83\93\83h\83E\8fã\82Ì...\r
+        &amp;mouse_position.x,            // ...\8dÀ\95W\82ð\93¾\82é\r
+        &amp;mouse_position.y\r
+    );\r
+\r
+    SDL_Log("\83}\83E\83X\82Ì\88Ê\92u: x=%d y=%d",    //    \83}\83E\83X\82Ì\88Ê\92u\82ð\95\\8e¦\82·\82é\r
+         mouse_position.x, mouse_position.y\r
+    );\r
+\r
+    // \83E\83B\83\93\83h\83E\82ð\95Â\82\82Ä\94j\8aü\82·\82é\r
+    SDL_DestroyWindow(window); \r
+\r
+    // \8fI\97¹\8f\88\97\9d\r
+    SDL_Quit();\r
+    return 0; \r
+}\r
+</pre>\r
+</code>\r
+</p>\r
 <h2>\8fÚ\8d×</h2>\r
 <a href="SDL_Point.html">SDL_Point</a>\82Í1\82Â\82Ì2\8e\9f\8c³\8fã\82Ì\93_\82ð\92è\8b`\82·\82é.\r
 \93_\88È\8aO\82Å\82à\8eg\82¦\82é\82ª, \83T\83C\83Y\82ð\8e\9d\82½\82È\82¢.\r