OSDN Git Service

SDL_EventState 関連項目(関数)にSDL_GetEventStateを追加 https://wiki.libsdl.org/SDL_EventState...
[sdl2referencejp/sdl2referencejp.git] / SDL_GetThreadID.html
index ab437d1..4dbcfa7 100644 (file)
 <pre>\r
 #include &lt;stdio.h&gt;\r
 #include "SDL_thread.h"\r
-#include "SDL_timer.h"\r
 \r
-int TestThread(void *ptr);\r
+// \82Æ\82Ä\82à\92P\8f\83\82È\83X\83\8c\83b\83h - 50ms\8aÔ\8au\82Å0\82©\82ç9\82Ü\82Å\83J\83E\83\93\83g\82·\82é\r
+int TestThread(void *ptr)\r
+{\r
+    int cnt;\r
+\r
+    for (cnt = 0; cnt &lt; 10; ++cnt) {\r
+        printf("\n\83X\83\8c\83b\83h\83J\83E\83\93\83^: %d", cnt);\r
+        SDL_Delay(50);\r
+    }\r
+\r
+    return cnt;\r
+}\r
 \r
 int main(int argc, char *argv[])\r
 {\r
     SDL_Thread *thread;\r
     int         threadReturnValue;\r
 \r
-    printf("\nSDL_CreateThread\82Ì\8aÈ\92P\82È\83e\83X\83g:");\r
+    printf("\nSDL_CreateThread\82Ì\92P\8f\83\82È\83e\83X\83g:");\r
 \r
-    // Simply create a thread\r
+    /\92P\82É\83X\83\8c\83b\83h\82ð\90\90¬\82·\82é */\r
     thread = SDL_CreateThread(TestThread, "TestThread", (void *)NULL);\r
 \r
     if (NULL == thread) {\r
         printf("\nSDL_CreateThread \8e¸\94s: %s\n", SDL_GetError());\r
-    } else {\r
-        SDL_WaitThread(thread, &threadReturnValue);\r
-        printf("\n\83X\83\8c\83b\83h\82Ì\96ß\82è\92l: %d", threadReturnValue);\r
+        exit(-1);\r
     }\r
 \r
-    return 0;\r
-}\r
+    /* \90V\82½\82É\90\90¬\82³\82ê\82½\83X\83\8c\83b\83h\82ÌID\82ð\8eó\82¯\8eæ\82é */\r
+    threadID = SDL_GetThreadID(thread);\r
 \r
-// \82Æ\82Ä\82à\8aÈ\92P\82È\83X\83\8c\83b\83h - 50ms\8aÔ\8au\82Å0\82©\82ç9\82Ü\82Å\83J\83E\83\93\83g\82·\82é\r
-int TestThread(void *ptr)\r
-{\r
-    int cnt;\r
+    /* \83X\83\8c\83b\83h\82ª\8a®\97¹\82·\82é\82Ì\82ð\91Ò\82¿\96ß\82è\92l\82ð\93¾\82é */\r
+    SDL_WaitThread(thread, &threadReturnValue);\r
+    printf("\n\83X\83\8c\83b\83h\82Ì\96ß\82è\92l: %d", threadReturnValue);\r
 \r
-    for (cnt = 0; cnt &lt; 10; ++cnt) {\r
-        printf("\n\83X\83\8c\83b\83h\83J\83E\83\93\83^: %d", cnt);\r
-        SDL_Delay(50);\r
-    }\r
-\r
-    return cnt;\r
+    return 0;\r
 }\r
 </pre>\r
 </code>\r