How to generate basic Perlin noise with Raylib in C

1 Answer

0 votes
#include "raylib.h"

int main(void)
{
    const int screenWidth = 800;
    const int screenHeight = 450;

    InitWindow(screenWidth, screenHeight, "Raylib Perlin Noise");

    // Image GenImagePerlinNoise(int width, int height, int offsetX, int offsetY, float scale); 
    Image perlinNoise = GenImagePerlinNoise(screenWidth, screenHeight, 50, 50, 4.0f);
    
    Texture2D textures;

    // Texture2D LoadTextureFromImage(Image image);
    textures = LoadTextureFromImage(perlinNoise);

    // Unload image data (CPU RAM)
    UnloadImage(perlinNoise);

    int currentTexture = 0;

    SetTargetFPS(60);

    // Main game loop
    while (!WindowShouldClose())
    {
        BeginDrawing();

        ClearBackground(RAYWHITE);

        // void DrawTexture(Texture2D texture, int posX, int posY, Color tint);   
        DrawTexture(textures, 0, 0, WHITE);

        // void DrawText(const char *text, int posX, int posY, int fontSize, Color color);   
        DrawText("PERLIN NOISE", 640, 10, 20, RED); 

        EndDrawing();
    }

    // Unload textures data (GPU VRAM)
    UnloadTexture(textures);

    CloseWindow(); // Close window and OpenGL context

    return 0;
}


/*
run:


*/

 



answered Jan 24 by avibootz
...