Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

71 строка
2.9 KiB

5 лет назад
5 лет назад
9 лет назад
3 лет назад
  1. /*******************************************************************************************
  2. *
  3. * raylib [textures] example - Image loading and texture creation
  4. *
  5. * Example complexity rating: [] 1/4
  6. *
  7. * NOTE: Images are loaded in CPU memory (RAM); textures are loaded in GPU memory (VRAM)
  8. *
  9. * Example originally created with raylib 1.3, last time updated with raylib 1.3
  10. *
  11. * Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
  12. * BSD-like license that allows static linking with closed source software
  13. *
  14. * Copyright (c) 2015-2025 Ramon Santamaria (@raysan5)
  15. *
  16. ********************************************************************************************/
  17. #include "raylib.h"
  18. //------------------------------------------------------------------------------------
  19. // Program main entry point
  20. //------------------------------------------------------------------------------------
  21. int main(void)
  22. {
  23. // Initialization
  24. //--------------------------------------------------------------------------------------
  25. const int screenWidth = 800;
  26. const int screenHeight = 450;
  27. InitWindow(screenWidth, screenHeight, "raylib [textures] example - image loading");
  28. // NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required)
  29. Image image = LoadImage("resources/raylib_logo.png"); // Loaded in CPU memory (RAM)
  30. Texture2D texture = LoadTextureFromImage(image); // Image converted to texture, GPU memory (VRAM)
  31. UnloadImage(image); // Once image has been converted to texture and uploaded to VRAM, it can be unloaded from RAM
  32. SetTargetFPS(60); // Set our game to run at 60 frames-per-second
  33. //---------------------------------------------------------------------------------------
  34. // Main game loop
  35. while (!WindowShouldClose()) // Detect window close button or ESC key
  36. {
  37. // Update
  38. //----------------------------------------------------------------------------------
  39. // TODO: Update your variables here
  40. //----------------------------------------------------------------------------------
  41. // Draw
  42. //----------------------------------------------------------------------------------
  43. BeginDrawing();
  44. ClearBackground(RAYWHITE);
  45. DrawTexture(texture, screenWidth/2 - texture.width/2, screenHeight/2 - texture.height/2, WHITE);
  46. DrawText("this IS a texture loaded from an image!", 300, 370, 10, GRAY);
  47. EndDrawing();
  48. //----------------------------------------------------------------------------------
  49. }
  50. // De-Initialization
  51. //--------------------------------------------------------------------------------------
  52. UnloadTexture(texture); // Texture unloading
  53. CloseWindow(); // Close window and OpenGL context
  54. //--------------------------------------------------------------------------------------
  55. return 0;
  56. }