1#include "eglcommon.h"
2
3#include <VG/openvg.h>
4
5const VGfloat white_color[4] = {1.0, 1.0, 1.0, 1.0};
6const VGfloat color[4] = {0.4, 0.1, 1.0, 1.0};
7
8VGPath path;
9VGPaint fill;
10
11
12static void
13init(void)
14{
15   static const VGubyte sqrCmds[5] = {VG_MOVE_TO_ABS, VG_HLINE_TO_ABS, VG_VLINE_TO_ABS, VG_HLINE_TO_ABS, VG_CLOSE_PATH};
16   static const VGfloat sqrCoords[5]   = {50.0f, 50.0f, 250.0f, 250.0f, 50.0f};
17   path = vgCreatePath(VG_PATH_FORMAT_STANDARD, VG_PATH_DATATYPE_F, 1, 0, 0, 0,
18                       VG_PATH_CAPABILITY_APPEND_TO);
19   vgAppendPathData(path, 5, sqrCmds, sqrCoords);
20
21   fill = vgCreatePaint();
22   vgSetParameterfv(fill, VG_PAINT_COLOR, 4, color);
23   vgSetPaint(fill, VG_FILL_PATH);
24
25   vgSetfv(VG_CLEAR_COLOR, 4, white_color);
26   vgSetf(VG_STROKE_LINE_WIDTH, 10);
27   vgSeti(VG_STROKE_CAP_STYLE, VG_CAP_BUTT);
28   vgSeti(VG_STROKE_JOIN_STYLE, VG_JOIN_ROUND);
29   vgSetf(VG_STROKE_MITER_LIMIT, 4.0f);
30
31   vgSeti(VG_MASKING, VG_TRUE);
32
33   vgMask(VG_INVALID_HANDLE, VG_CLEAR_MASK,
34          25, 25, 100, 100);
35}
36
37/* new window size or exposure */
38static void
39reshape(int w, int h)
40{
41   vgLoadIdentity();
42}
43
44static void
45draw(void)
46{
47   vgClear(0, 0, window_width(), window_height());
48   vgDrawPath(path, VG_FILL_PATH);
49
50   vgFlush();
51}
52
53
54int main(int argc, char **argv)
55{
56   return run(argc, argv, init, reshape,
57              draw, 0);
58}
59