diff options
Diffstat (limited to 'md/writeup')
-rw-r--r-- | md/writeup/web_assembly_sdl_example.md | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/md/writeup/web_assembly_sdl_example.md b/md/writeup/web_assembly_sdl_example.md index c6f475b..0e36f79 100644 --- a/md/writeup/web_assembly_sdl_example.md +++ b/md/writeup/web_assembly_sdl_example.md @@ -80,19 +80,17 @@ void main_tick() { #else int main_tick() { #endif - + + render(); SDL_UpdateWindowSurface(window); - - #if !__EMSCRIPTEN__ - return 1; - #endif +#if !__EMSCRIPTEN__ + return 0; +#endif } void main_loop() { - - #if __EMSCRIPTEN__ emscripten_set_main_loop(main_tick, -1, 1); @@ -101,20 +99,20 @@ void main_loop() SDL_Event event; - while (quit==0) + while (0 == quit) { while (SDL_PollEvent(&event)) { + quit = main_tick(); switch (event.type) { case SDL_QUIT: quit = 1; break; } - quit = main_tick(); + } - printf("Loop\n"); } #endif } @@ -132,7 +130,7 @@ int main() SDL_GL_SetSwapInterval(1); blank = SDL_CreateRGBSurface(0, 16, 16, 32, 0, 255, 255, 50); - Uint32 color = SDL_MapRGB(blank->format, 50, 0 , 0); + Uint32 color = SDL_MapRGB(blank->format, 150, 0 , 0); for (int x = 0; x < 16; x++) { for (int y = 0; y < 16; y++) @@ -146,7 +144,7 @@ int main() main_loop(); SDL_DestroyWindow(window); - SDL_Quit(); + SDL_Quit(); return 0; } |