gx_canvas_polygon_draw() - SSP 1.6.3

Using GUIX 5.4.1 and SSP 1.6.3

Polygon fill function is not working as I expected.

May be I am doing something incorrect with the API ?

So below is the 4 point polygon fill code that is filling the shape with for only 3 points, so it looks like a triangle fill. 

 

//Sample Code

ULONG brush_style = 0;
GX_RESOURCE_ID imp_line_color = GX_COLOR_ID_GREEN;
GX_RESOURCE_ID imp_fill_color = GX_COLOR_ID_GREEN;

brush_style |= GX_BRUSH_ALIAS;
brush_style |= GX_BRUSH_SOLID_FILL;

gx_context_brush_define(imp_line_color, imp_fill_color, brush_style);
gx_context_brush_width_set(5);
gx_context_line_color_set(imp_line_color);

GX_POINT point_arr[4];

point_arr[0].gx_point_x = 350;
point_arr[0].gx_point_y = 260;
point_arr[1].gx_point_x = 370;
point_arr[1].gx_point_y = 260;

point_arr[2].gx_point_x = 350;
point_arr[2].gx_point_y = 240;
point_arr[3].gx_point_x = 370;
point_arr[3].gx_point_y = 240;

gx_canvas_polygon_draw(point_arr, 4);

  • In reply to Jeremy:

    For the polygon not being filled when the Dave2D is enabled, there is a limitations with the Dave2D in that the points of a polygon need to be defined in a clockwise order.

    E.g. if I define the points of a polygon :-

                point_arr[0].gx_point_x = 100;
                point_arr[0].gx_point_y = 260;

                point_arr[1].gx_point_x = 50;
                point_arr[1].gx_point_y = 270;

                point_arr[2].gx_point_x = 50;
                point_arr[2].gx_point_y = 300;

                point_arr[3].gx_point_x = 150;
                point_arr[3].gx_point_y = 310;

                point_arr[4].gx_point_x = 200;
                point_arr[4].gx_point_y = 300;

                point_arr[5].gx_point_x = 200;
                point_arr[5].gx_point_y = 270;

     

    the polygon is drawn :-

     

    However if I reverse the points of the polygon :-

                point_arr[0].gx_point_x = 100;
                point_arr[0].gx_point_y = 260;

                point_arr[1].gx_point_x = 200;
                point_arr[1].gx_point_y = 270;

                point_arr[2].gx_point_x = 200;
                point_arr[2].gx_point_y = 300;

                point_arr[3].gx_point_x = 150;
                point_arr[3].gx_point_y = 310;

                point_arr[4].gx_point_x = 50;
                point_arr[4].gx_point_y = 300;

                point_arr[5].gx_point_x = 50;
                point_arr[5].gx_point_y = 270;

    it is drawn:-

    both of these were drawn with the Dave2D HW enabled.