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);

  • Good day, Sam!

    How are things going for you? Have you already figured this out? Did you try plotting the point arrays as in the example in page 147 of the GUIX user guide?

    Best regards,
    Sai
    RenesasRulz Forum Moderator

    https://renesasrulz.com/
    https://academy.renesas.com/
    en-us.knowledgebase.renesas.com/

  • In reply to Sai:

    No, not yet. I am using the same example that is in the guide.
  • In reply to Sam:

    Hi Sam-
    Which point isn't being drawn? Is it possible it is outside of the drawing area?

    Also- what status return do you get from the draw function?

    Return Values
    GX_SUCCESS (0x00) Successful polygon draw
    GX_CALLER_ERROR (0x11) Invalid caller of this function
    GX_PTR_ERROR (0x07) Invalid pointer
    GX_INVALID_CONTEXT (0x06) No open drawing context
  • In reply to WarrenM:

    The status from the drawPolygon function is success "0"

    All the 6 points are inside the 800x480 screen as shown above

    So in this case of hexagon, the shape looks right but for some reason it will not fill the area with the brush color or brush type (solid fill)

    The fill does not work only for polygon, other shapes fill works

     

    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;

    GX_POINT point_arr[6];

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

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

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

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

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

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

     

    brush_style |= GX_BRUSH_ALIAS;
    brush_style |= GX_BRUSH_SOLID_FILL;

    gx_window_draw((GX_WINDOW*)window);

    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);


    //try polygon
    //gx_canvas_ellipse_draw(200, 200, 100, 50);
    UINT status = gx_canvas_polygon_draw(point_arr, 6);

     

  • In reply to Sam:

    Hi Sam-

    Reading over the GUIX Manual I see the below:

    Looks like GX_BRUSH_PIXELMAP style needs to be used. From pages 54 and 55 of the manual.

    This doesn't explain why fill is being applied to other shapes, but maybe it is being added from somewhere else.

    Does including this style help at all with the your polygon?

  • In reply to WarrenM:

    I have been doing this from day1 of polygon drawing and don't see it fill the polygon:

     

    GX_RESOURCE_ID imp_line_color = GX_COLOR_ID_GREEN;
    GX_RESOURCE_ID imp_fill_color = GX_COLOR_ID_GREEN;
    brush_style |= GX_BRUSH_SOLID_FILL;

    gx_context_brush_define(imp_line_color, imp_fill_color, brush_style);

  • In reply to Sam:

    Hi Sam-
    And you have tried adding the GX_BRUSH_PIXELMAP style too, with no change?
  • In reply to WarrenM:

    Yes, still the same, just the outline is what I am seeing with pixelmap fill

    brush_style |= GX_BRUSH_ALIAS;
    brush_style |= GX_BRUSH_PIXELMAP_FILL;
    //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);




    //try polygon
    //gx_canvas_ellipse_draw(200, 200, 100, 50);
    UINT status = gx_canvas_polygon_draw(point_arr, 4);
  • In reply to Sam:

    Are you using the Dave2D HW accelerator in your GUIX configuration? If so, have you tried disabling the Dave2D HW accelerator to see if it makes a difference, you will need to disable it in both the GUIX studio project (in GUIX Studio, Configure ->Projects->Displays->Advanced Settings) and in the Synergy project under the properties for "GUIX on gx"?
  • In reply to Jeremy:

    Ok this solves the issue, I can see the polygon filled with appropriate colors now.
    But turning off the "2D Engine HW Accerlerator" - does it cause any other issues to my other parts of my application where I have sprites and other pixelmaps rendering ?
  • In reply to Sam:

    There should be no difference in how the GUIX API behave if the HW acceleration is disabled, only the CPU is now doing all the work (rather than off loading it to the Dave2D HW accelerator), so it could be slower.
  • In reply to Jeremy:

    Yes I can see it affect other parts of our graphics rendering where we have sprite animation (10 frames) changing every 10ms is not smooth like before and it looks very slow compared to what we had. Is this a trade off ? Is there a way to make the polygon fill work by having the 2D engine ON? I don't understand the indepth detail of why the fill wont work with 2D engine ON ?
  • In reply to Sam:

    Also, the reason we want to draw and fill the polygon is for on the go screen mapping purpose which is going to draw and fill the polygon every second, screen panning, screen rotation etc., I can see without the 2D drawing engine this UI on the go mapping might look jittery and not smooth? as it is using all the main CPU for drawing ?
  • In reply to Sam:

    The issue still seems to exist in SSP 1.7.8
  • In reply to Sam:

    I have reported the issue of gx_canvas_polygon_draw() API not filling the polygon, when the Dave2D HW accelerator is enabled, to the SSP developers.