shapes_logo_raylib.c 3.2 KB

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