20 #include <emscripten/emscripten.h>
25 #define SWAP(typ,a,b) do{typ t=a;a=b;b=t;}while(0)
26 #define NUM_OBJECTS 100
77 x = rand() % viewport.
w;
78 y = rand() % viewport.
h;
91 if ((x1 == x2) && (y1 == y2))
94 SDL_Log(
"adding line (%d, %d), (%d, %d)\n", x1, y1, x2, y2);
135 if ((x1 == x2) || (y1 == y2))
143 SDL_Log(
"adding rect (%d, %d), (%d, %d) [%dx%d]\n", x1, y1, x2, y2,
210 switch (event.
type) {
229 add_line(rand() % 640, rand() % 480, rand() % 640,
236 add_rect(rand() % 640, rand() % 480, rand() % 640,
260 #ifdef __EMSCRIPTEN__
262 emscripten_cancel_main_loop();
284 for (i = 1; i < argc;) {
318 SDL_Log(
"Usage: %s %s [--blend none|blend|add|mod] [--cyclecolor] [--cyclealpha]\n",
343 #ifdef __EMSCRIPTEN__
344 emscripten_set_main_loop(
loop, 0, 1);
357 double fps = ((double) frames * 1000) / (now - then);
358 SDL_Log(
"%2.2f frames per second\n", fps);