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   /* Absent VG_CLOSE_PATH */
16   VGubyte commands[] = {VG_MOVE_TO_ABS, VG_LINE_TO_ABS, VG_LINE_TO_ABS, VG_LINE_TO_ABS,
17                         VG_MOVE_TO_ABS, VG_LINE_TO_ABS, VG_LINE_TO_ABS, VG_LINE_TO_ABS};
18   VGfloat clearColor[] = {1.0f, 1.0f, 1.0f, 1.0f};/* white color */
19   VGfloat fillColor[] = {1.0f, 0.0f, 0.0f, 1.0f};/* red color */
20   VGfloat coords[] = {-16.0f, -16.0f, 0.0f, -16.0f, 0.0f, 0.0f, -16.0f, 0.0f,
21                       0.0f, 0.0f, 16.0f, 0.0f, 16.0f, 16.0f, 0.0f, 16.0f};
22
23   vgSetfv(VG_CLEAR_COLOR, 4, clearColor);
24   vgSeti(VG_RENDERING_QUALITY, VG_RENDERING_QUALITY_NONANTIALIASED);
25
26   vgSeti(VG_MATRIX_MODE, VG_MATRIX_PATH_USER_TO_SURFACE);
27   vgLoadIdentity();
28   vgTranslate(32.0f, 32.0f);
29
30   path = vgCreatePath(VG_PATH_FORMAT_STANDARD, VG_PATH_DATATYPE_F, 1.0f, 0.0f, 0, 0,
31                       VG_PATH_CAPABILITY_ALL);
32   if (path == VG_INVALID_HANDLE)
33      return;
34   fill = vgCreatePaint();
35   if (fill == VG_INVALID_HANDLE) {
36      vgDestroyPath(path);
37      return;
38   }
39   vgAppendPathData(path, 8, commands, coords);
40   vgSetPaint(fill, VG_FILL_PATH);
41   vgSetParameterfv(fill, VG_PAINT_COLOR, 4, fillColor);
42   vgSetParameteri(fill, VG_PAINT_TYPE, VG_PAINT_TYPE_COLOR);
43}
44
45/* new window size or exposure */
46static void
47reshape(int w, int h)
48{
49}
50
51static void
52draw(void)
53{
54   vgClear(0, 0, window_width(), window_height());
55   vgDrawPath(path, VG_FILL_PATH);
56
57   vgFlush();
58}
59
60
61int main(int argc, char **argv)
62{
63   set_window_size(64, 64);
64   return run(argc, argv, init, reshape,
65              draw, 0);
66}
67