1

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)
{
    // window width/height
    const unsigned int screenWidth = 1000;
    const unsigned int screenWidth = 1000;

    // initialize window
    InitializeWindow(screenWidth, screenHeight, "Amazing Window");

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

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

            // triangle color
            BLUE
        );

        // end drawing
        EndDrawing();
    }
}

Note

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

GooseDeveloper
  • 97
  • 1
  • 11
  • 1
    Please provide complete code as a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example). Also, please note that C and C++ are different languages. Please only tag the language you are actually coding in. – kaylum Apr 22 '21 at 22:26
  • 1
    I highly don't recommend mixing C and C++. The C++ allows for operating overloading and compilers may use name mangling in order to make overloaded function names compatible with the C language names. Also, C++ has references and exceptions. This is possible to do in C, but gets tricky when trying to combine with C++. Please update your language tags to the language (single) you are programming in. – Thomas Matthews Apr 22 '21 at 22:35
  • 1
    Please add the definition of `TRIANGLE` to your post, as text. – Thomas Matthews Apr 22 '21 at 22:37
  • @ThomasMatthews `TRIANGLE` signifies the `WindowElement` type of `PlayerElement`, as when my code renders the element, it doesn't know what type the element data is. `TRIANGLE` is defined in an enumeration of possible element types – GooseDeveloper Apr 23 '21 at 00:35

1 Answers1

1

Passing the arguments in counterclockwise did the trick:

// draw triangle
DrawTriangle(
    {100, 10},  // point a
    {10, 100},  // point b
    {100, 100}, // point c
    BLACK       // triangle color
);
GooseDeveloper
  • 97
  • 1
  • 11