Raylib DrawTriangle() usage

1.6k Views Asked by At

I'm having trouble displaying a triangle with Raylib's DrawTriangle() function.

Minimum Reproducible Example

#include <raylib.h>
#include <stdlib.h>

int main(int argc, char** argv)
{
    const unsigned int screenWidth = 1000;
    const unsigned int screenWidth = 1000;

    InitializeWindow(screenWidth, screenHeight, "Amazing Window");

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

        DrawTriangle(
            // triangle vertices
            {100, 10},
            {10, 100},
            {10, 10},

            // triangle color
            BLUE
        );

        EndDrawing();
    }
}

Note

An example from Raylib's website worked fine, so the arguments to DrawTriangle are probably to blame.

1

There are 1 best solutions below

0
On BEST ANSWER

Passing the arguments in counterclockwise did the trick:

DrawTriangle(
    {100, 10},  // point a
    {10, 100},  // point b
    {100, 100}, // point c
    BLACK       // triangle color
);