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.

83 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 and PLATFORM_DESKTOP
  6. * As you will notice, code structure is slightly different 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. #if defined(PLATFORM_WEB)
  17. #include <emscripten/emscripten.h>
  18. #endif
  19. //----------------------------------------------------------------------------------
  20. // Global Variables Definition
  21. //----------------------------------------------------------------------------------
  22. int screenWidth = 800;
  23. int screenHeight = 450;
  24. //----------------------------------------------------------------------------------
  25. // Module Functions Declaration
  26. //----------------------------------------------------------------------------------
  27. void UpdateDrawFrame(void); // Update and Draw one frame
  28. //----------------------------------------------------------------------------------
  29. // Main Entry Point
  30. //----------------------------------------------------------------------------------
  31. int main()
  32. {
  33. // Initialization
  34. //--------------------------------------------------------------------------------------
  35. InitWindow(screenWidth, screenHeight, "raylib [core] example - basic window");
  36. #if defined(PLATFORM_WEB)
  37. emscripten_set_main_loop(UpdateDrawFrame, 0, 1);
  38. #else
  39. SetTargetFPS(60); // Set our game to run at 60 frames-per-second
  40. //--------------------------------------------------------------------------------------
  41. // Main game loop
  42. while (!WindowShouldClose()) // Detect window close button or ESC key
  43. {
  44. UpdateDrawFrame();
  45. }
  46. #endif
  47. // De-Initialization
  48. //--------------------------------------------------------------------------------------
  49. CloseWindow(); // Close window and OpenGL context
  50. //--------------------------------------------------------------------------------------
  51. return 0;
  52. }
  53. //----------------------------------------------------------------------------------
  54. // Module Functions Definition
  55. //----------------------------------------------------------------------------------
  56. void UpdateDrawFrame(void)
  57. {
  58. // Update
  59. //----------------------------------------------------------------------------------
  60. // TODO: Update your variables here
  61. //----------------------------------------------------------------------------------
  62. // Draw
  63. //----------------------------------------------------------------------------------
  64. BeginDrawing();
  65. ClearBackground(RAYWHITE);
  66. DrawText("Congrats! You created your first window!", 190, 200, 20, LIGHTGRAY);
  67. EndDrawing();
  68. //----------------------------------------------------------------------------------
  69. }