25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

122 lines
5.4 KiB

  1. /*
  2. WELCOME raylib EXAMPLES CONTRIBUTOR!
  3. This is a basic template to anyone ready to contribute with some code example for the library,
  4. here there are some guidelines on how to create an example to be included in raylib
  5. 1. File naming: <module>_<description> - Lower case filename, words separated by underscore,
  6. no more than 3-4 words in total to describe the example. <module> referes to the primary
  7. raylib module the example is more related with (code, shapes, textures, models, shaders, raudio).
  8. i.e: core_input_multitouch, shapes_lines_bezier, shaders_palette_switch
  9. 2. Follow below template structure, example info should list the module, the short description
  10. and the author of the example, twitter or github info could be also provided for the author.
  11. Short description should also be used on the title of the window.
  12. 3. Code should be organized by sections:[Initialization]- [Update] - [Draw] - [De-Initialization]
  13. Place your code between the dotted lines for every section, please don't mix update logic with drawing
  14. and remember to unload all loaded resources.
  15. 4. Code should follow raylib conventions: https://github.com/raysan5/raylib/wiki/raylib-coding-conventions
  16. Try to be very organized, using line-breaks appropiately.
  17. 5. Add comments to the specific parts of code the example is focus on.
  18. Don't abuse with comments, try to be clear and impersonal on the comments.
  19. 6. Try to keep the example simple, under 300 code lines if possible. Try to avoid external dependencies.
  20. Try to avoid defining functions outside the main(). Example should be as self-contained as possible.
  21. 7. About external resources, they should be placed in a [resources] folder and those resources
  22. should be open and free for use and distribution. Avoid propietary content.
  23. 8. Try to keep the example simple but with a creative touch.
  24. Simple but beautiful examples are more appealing to users!
  25. 9. In case of additional information is required, just come to raylib Discord channel: example-contributions
  26. 10. Have fun!
  27. The following files should be updated when adding a new example, it's planned to create some
  28. script to automatize this process but not available yet.
  29. - raylib/examples/<category>/<category>_example_name.c
  30. - raylib/examples/<category>/<category>_example_name.png
  31. - raylib/examples/<category>/resources/*.*
  32. - raylib/examples/Makefile
  33. - raylib/examples/Makefile.Web
  34. - raylib/examples/README.md
  35. - raylib/projects/VS2022/examples/<category>_example_name.vcxproj
  36. - raylib/projects/VS2022/raylib.sln
  37. - raylib.com/common/examples.js
  38. - raylib.com/examples/<category>/<category>_example_name.html
  39. - raylib.com/examples/<category>/<category>_example_name.data
  40. - raylib.com/examples/<category>/<category>_example_name.wasm
  41. - raylib.com/examples/<category>/<category>_example_name.js
  42. */
  43. /*******************************************************************************************
  44. *
  45. * raylib [core] example - Basic window
  46. *
  47. * Example originally created with raylib 4.5, last time updated with raylib 4.5
  48. *
  49. * Example contributed by <user_name> (@<user_github>) and reviewed by Ramon Santamaria (@raysan5)
  50. *
  51. * Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
  52. * BSD-like license that allows static linking with closed source software
  53. *
  54. * Copyright (c) 2023 <user_name> (@<user_github>)
  55. *
  56. ********************************************************************************************/
  57. #include "raylib.h"
  58. //------------------------------------------------------------------------------------
  59. // Program main entry point
  60. //------------------------------------------------------------------------------------
  61. int main(void)
  62. {
  63. // Initialization
  64. //--------------------------------------------------------------------------------------
  65. const int screenWidth = 800;
  66. const int screenHeight = 450;
  67. InitWindow(screenWidth, screenHeight, "raylib [core] example - basic window");
  68. // TODO: Load resources / Initialize variables at this point
  69. SetTargetFPS(60);
  70. //--------------------------------------------------------------------------------------
  71. // Main game loop
  72. while (!WindowShouldClose()) // Detect window close button or ESC key
  73. {
  74. // Update
  75. //----------------------------------------------------------------------------------
  76. // TODO: Update variables / Implement example logic at this point
  77. //----------------------------------------------------------------------------------
  78. // Draw
  79. //----------------------------------------------------------------------------------
  80. BeginDrawing();
  81. ClearBackground(RAYWHITE);
  82. // TODO: Draw everything that requires to be drawn at this point:
  83. DrawText("Congrats! You created your first window!", 190, 200, 20, LIGHTGRAY); // Example
  84. EndDrawing();
  85. //----------------------------------------------------------------------------------
  86. }
  87. // De-Initialization
  88. //--------------------------------------------------------------------------------------
  89. // TODO: Unload all loaded resources at this point
  90. CloseWindow(); // Close window and OpenGL context
  91. //--------------------------------------------------------------------------------------
  92. return 0;
  93. }