Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,859 questions

51,780 answers

573 users

How to draw a triangle with Raylib in C

1 Answer

0 votes
#include "raylib.h"

#define WIDTH 800
#define HEIGHT 600

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

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

        ClearBackground(RAYWHITE);

        // Draw a color-filled triangle
        // void DrawTriangle(Vector2 v1, Vector2 v2, Vector2 v3, Color color);  
        DrawTriangle((Vector2) { WIDTH / 2.0f, 80.0f },
                     (Vector2) { WIDTH / 2.0f - 50.0f, 160.0f },
                     (Vector2) { WIDTH / 2.0f + 50.0f, 160.0f }, GREEN);

        // Draw a regular polygon 
        // void DrawPoly(Vector2 center, int sides, float radius, float rotation, Color color);  
        DrawTriangleLines((Vector2) { WIDTH / 2.0f, 180.0f },
                          (Vector2) { WIDTH / 2.0f - 30.0f, 240.0f },
                          (Vector2) { WIDTH / 2.0f + 30.0f, 240.0f }, 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

1 answer 87 views
87 views asked Jan 16, 2025 by avibootz
1 answer 120 views
120 views asked Jan 12, 2025 by avibootz
1 answer 100 views
100 views asked Jan 12, 2025 by avibootz
1 answer 90 views
...