hello_window.mod 908 B

1234567891011121314151617181920212223242526272829303132333435
  1. MODULE hello_window ;
  2. (*
  3. m2SDL3 example: open a window for ~2 seconds, then quit.
  4. Build: make examples or see Makefile.
  5. Run: ./build/examples/hello_window
  6. SDL3: CreateWindow takes (title, w, h, flags) - no x/y - and
  7. init returns BOOLEAN.
  8. *)
  9. FROM SDL3 IMPORT SDL_Init, SDL_Quit, SDL_Delay, SDLInitVideo;
  10. FROM SDL3Video IMPORT SDL_CreateWindow, SDL_DestroyWindow, WindowHidden;
  11. FROM SYSTEM IMPORT ADDRESS;
  12. FROM libc IMPORT printf;
  13. VAR win: ADDRESS;
  14. BEGIN
  15. IF NOT SDL_Init(SDLInitVideo) THEN
  16. printf("SDL_Init failed\n");
  17. HALT(1)
  18. END;
  19. win := SDL_CreateWindow("Hello from GNU Modula-2 + SDL3",
  20. 640, 480, 0);
  21. IF win = NIL THEN
  22. printf("CreateWindow failed\n");
  23. SDL_Quit;
  24. HALT(1)
  25. END;
  26. printf("window open for 2s...\n");
  27. SDL_Delay(2000);
  28. SDL_DestroyWindow(win);
  29. SDL_Quit;
  30. printf("bye\n")
  31. END hello_window.