You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

84 lines
3.2 KiB

  1. /*******************************************************************************************
  2. *
  3. * raylib [core] example - Basic window (adapted for HTML5 platform)
  4. *
  5. * This example is prepared to compile for PLATFORM_WEB, PLATFORM_DESKTOP and PLATFORM_RPI
  6. * As you will notice, code structure is slightly diferent to the other examples...
  7. * To compile it for PLATFORM_WEB just uncomment #define PLATFORM_WEB at beginning
  8. *
  9. * This example has been created using raylib 1.3 (www.raylib.com)
  10. * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
  11. *
  12. * Copyright (c) 2015 Ramon Santamaria (@raysan5)
  13. *
  14. ********************************************************************************************/
  15. #include "raylib.h"
  16. //#define PLATFORM_WEB
  17. #if defined(PLATFORM_WEB)
  18. #include <emscripten/emscripten.h>
  19. #endif
  20. //----------------------------------------------------------------------------------
  21. // Global Variables Definition
  22. //----------------------------------------------------------------------------------
  23. int screenWidth = 800;
  24. int screenHeight = 450;
  25. //----------------------------------------------------------------------------------
  26. // Module Functions Declaration
  27. //----------------------------------------------------------------------------------
  28. void UpdateDrawFrame(void); // Update and Draw one frame
  29. //----------------------------------------------------------------------------------
  30. // Main Enry Point
  31. //----------------------------------------------------------------------------------
  32. int main()
  33. {
  34. // Initialization
  35. //--------------------------------------------------------------------------------------
  36. InitWindow(screenWidth, screenHeight, "raylib [core] example - basic window");
  37. #if defined(PLATFORM_WEB)
  38. emscripten_set_main_loop(UpdateDrawFrame, 0, 1);
  39. #else
  40. SetTargetFPS(60); // Set our game to run at 60 frames-per-second
  41. //--------------------------------------------------------------------------------------
  42. // Main game loop
  43. while (!WindowShouldClose()) // Detect window close button or ESC key
  44. {
  45. UpdateDrawFrame();
  46. }
  47. #endif
  48. // De-Initialization
  49. //--------------------------------------------------------------------------------------
  50. CloseWindow(); // Close window and OpenGL context
  51. //--------------------------------------------------------------------------------------
  52. return 0;
  53. }
  54. //----------------------------------------------------------------------------------
  55. // Module Functions Definition
  56. //----------------------------------------------------------------------------------
  57. void UpdateDrawFrame(void)
  58. {
  59. // Update
  60. //----------------------------------------------------------------------------------
  61. // TODO: Update your variables here
  62. //----------------------------------------------------------------------------------
  63. // Draw
  64. //----------------------------------------------------------------------------------
  65. BeginDrawing();
  66. ClearBackground(RAYWHITE);
  67. DrawText("Congrats! You created your first window!", 190, 200, 20, LIGHTGRAY);
  68. EndDrawing();
  69. //----------------------------------------------------------------------------------
  70. }