How to draw a polygon with Raylib in C

1 Answer

0 votes
#include "raylib.h"

#define WIDTH 800
#define HEIGHT 600

int main()
{
    InitWindow(WIDTH, HEIGHT, "Raylib Draw Polygon");

    // Main game loop
    while (!WindowShouldClose()) // Detect window close button or ESC key
    {
        BeginDrawing();

        ClearBackground(RAYWHITE);

        // Draw a regular polygon
        // void DrawPoly(Vector2 center, int sides, float radius, float rotation, Color color);
        DrawPoly((Vector2) { WIDTH / 2.0f, 330 }, 6, 80, 0, ORANGE);

        // Draw a polygon outline of n sides
        // void DrawPolyLines(Vector2 center, int sides, float radius, float rotation, Color color); 
        DrawPolyLines((Vector2) { WIDTH / 2.0f, 330 }, 6, 90, 0, BLACK);

        // Draw a polygon outline of n sides with extended parameters
        // void DrawPolyLinesEx(Vector2 center, int sides, float radius, float rotation, float lineThick, Color color); 
        DrawPolyLinesEx((Vector2) { WIDTH / 2.0f, 330 }, 6, 85, 0, 6, GREEN);

        EndDrawing();
    }

    CloseWindow(); // Close window and OpenGL context

    return 0;
}


/*
run:


*/

 



answered Jan 12, 2025 by avibootz
edited Jan 13, 2025 by avibootz

Related questions

...