| 24 | int result = 0; |
| 25 | |
| 26 | void *ThreadMain(void *arg) |
| 27 | { |
| 28 | printf("ThreadMain\n"); |
| 29 | switch(numThreadsCreated) |
| 30 | { |
| 31 | case 1: printf("Thread 1 started: you should see the WebGL canvas fade from black to red.\n"); break; |
| 32 | case 2: printf("Thread 2 started: you should see the WebGL canvas fade from black to green.\n"); break; |
| 33 | case 3: printf("Thread 3 started: you should see the WebGL canvas fade from black to blue.\n"); break; |
| 34 | } |
| 35 | EmscriptenWebGLContextAttributes attr; |
| 36 | emscripten_webgl_init_context_attributes(&attr); |
| 37 | attr.explicitSwapControl = true; |
| 38 | ctx = emscripten_webgl_create_context("#canvas", &attr); |
| 39 | emscripten_webgl_make_context_current(ctx); |
| 40 | |
| 41 | double color = 0; |
| 42 | for(int i = 0; i < 100; ++i) |
| 43 | { |
| 44 | color += 0.01; |
| 45 | switch(numThreadsCreated) |
| 46 | { |
| 47 | case 1: glClearColor(color, 0, 0, 1); break; |
| 48 | case 2: glClearColor(0, color, 0, 1); break; |
| 49 | case 3: glClearColor(0, 0, color, 1); break; |
| 50 | } |
| 51 | glClear(GL_COLOR_BUFFER_BIT); |
| 52 | EMSCRIPTEN_RESULT r = emscripten_webgl_commit_frame(); |
| 53 | assert(r == EMSCRIPTEN_RESULT_SUCCESS); |
| 54 | |
| 55 | double now = emscripten_get_now(); |
| 56 | while(emscripten_get_now() - now < 16) /*no-op*/; |
| 57 | } |
| 58 | |
| 59 | emscripten_webgl_make_context_current(0); |
| 60 | emscripten_webgl_destroy_context(ctx); |
| 61 | printf("Thread quit\n"); |
| 62 | pthread_exit(0); |
| 63 | } |
| 64 | |
| 65 | void CreateThread() |
| 66 | { |
nothing calls this directly
no test coverage detected