Beginners_-_Image_Perlin.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #include "raylib.h"
  2. int main(void)
  3. {
  4. // Initialization
  5. //--------------------------------------------------------------------------------------
  6. const int screenWidth = 800;
  7. const int screenHeight = 450;
  8. InitWindow(screenWidth, screenHeight, "raylib example.");
  9. // Create a Perlin Image
  10. Image perlinImage = GenImagePerlinNoise(screenWidth, screenHeight,0,0,1.5f);
  11. // Images are inside the CPU and not fast. Use Textures(GPU) for quick manipulation.
  12. Texture2D texture = { 0 };
  13. texture = LoadTextureFromImage(perlinImage);
  14. // Unload image data (CPU RAM)
  15. UnloadImage(perlinImage);
  16. SetTargetFPS(60); // Set our game to run at 60 frames-per-second
  17. //--------------------------------------------------------------------------------------
  18. // Main game loop
  19. while (!WindowShouldClose()) // Detect window close button or ESC key
  20. {
  21. // Update
  22. //----------------------------------------------------------------------------------
  23. //----------------------------------------------------------------------------------
  24. // Draw
  25. //----------------------------------------------------------------------------------
  26. BeginDrawing();
  27. ClearBackground(RAYWHITE);
  28. DrawTexture(texture, 0, 0, WHITE);
  29. EndDrawing();
  30. //----------------------------------------------------------------------------------
  31. }
  32. // De-Initialization
  33. //--------------------------------------------------------------------------------------
  34. UnloadTexture(texture); // Unload texture from VRAM
  35. CloseWindow(); // Close window and OpenGL context
  36. //--------------------------------------------------------------------------------------
  37. return 0;
  38. }