132001f49Smrg#include "eglcommon.h"
232001f49Smrg
332001f49Smrg#include <VG/openvg.h>
432001f49Smrg
532001f49Smrg#include <math.h>
632001f49Smrg#include <stdlib.h>
732001f49Smrg
832001f49Smrgconst VGfloat white_color[4] = {1.0, 1.0, 1.0, 1.0};
932001f49Smrgconst VGfloat color[4] = {0.0, 0.0, 0.0, 1.0};
1032001f49Smrg
1132001f49SmrgVGPath path;
1232001f49SmrgVGPaint paint;
1332001f49Smrg
1432001f49Smrgstatic void
1532001f49Smrginit(void)
1632001f49Smrg{
1732001f49Smrg   VGfloat clearColor[] = {1.0f, 1.0f, 1.0f, 1.0f};/* white color */
1832001f49Smrg   VGfloat fillColor[] = {1.0f, 0.0f, 0.0f, 1.0f};/* red color */
1932001f49Smrg   static const VGubyte segments[4] = {VG_MOVE_TO_ABS,
2032001f49Smrg                                       VG_SCCWARC_TO_ABS,
2132001f49Smrg                                       VG_SCCWARC_TO_ABS,
2232001f49Smrg                                       VG_CLOSE_PATH};
2332001f49Smrg   VGfloat data[12];
2432001f49Smrg   const VGfloat cx = 0, cy=29, width=80, height=40;
2532001f49Smrg   const VGfloat hw = width * 0.5f;
2632001f49Smrg   const VGfloat hh = height * 0.5f;
2732001f49Smrg
2832001f49Smrg   data[0] = cx + hw;
2932001f49Smrg   data[1] = cy;
3032001f49Smrg   data[2] = hw;
3132001f49Smrg   data[3] = hh;
3232001f49Smrg   data[4] = 0;
3332001f49Smrg   data[5] = cx - hw;
3432001f49Smrg   data[6] = cy;
3532001f49Smrg   data[7] = hw;
3632001f49Smrg   data[8] = hh;
3732001f49Smrg   data[9] = 0;
3832001f49Smrg   data[10] = data[0];
3932001f49Smrg   data[11] = cy;
4032001f49Smrg
4132001f49Smrg   vgSetfv(VG_CLEAR_COLOR, 4, clearColor);
4232001f49Smrg   vgSeti(VG_RENDERING_QUALITY, VG_RENDERING_QUALITY_NONANTIALIASED);
4332001f49Smrg
4432001f49Smrg
4532001f49Smrg   path = vgCreatePath(VG_PATH_FORMAT_STANDARD, VG_PATH_DATATYPE_F,
4632001f49Smrg                       1.0f, 0.0f, 0, 0, VG_PATH_CAPABILITY_ALL);
4732001f49Smrg   if (path == VG_INVALID_HANDLE) {
4832001f49Smrg      return;
4932001f49Smrg   }
5032001f49Smrg   paint = vgCreatePaint();
5132001f49Smrg   if (paint == VG_INVALID_HANDLE) {
5232001f49Smrg      vgDestroyPath(path);
5332001f49Smrg      return;
5432001f49Smrg   }
5532001f49Smrg
5632001f49Smrg   vgAppendPathData(path, 4, segments, data);
5732001f49Smrg   vgSetParameterfv(paint, VG_PAINT_COLOR, 4, fillColor);
5832001f49Smrg   vgSetParameteri( paint, VG_PAINT_TYPE, VG_PAINT_TYPE_COLOR);
5932001f49Smrg   vgSetPaint(paint, VG_FILL_PATH);
6032001f49Smrg}
6132001f49Smrg
6232001f49Smrg/* new window size or exposure */
6332001f49Smrgstatic void
6432001f49Smrgreshape(int w, int h)
6532001f49Smrg{
6632001f49Smrg}
6732001f49Smrg
6832001f49Smrgstatic void
6932001f49Smrgdraw(void)
7032001f49Smrg{
7132001f49Smrg   vgClear(0, 0, window_width(), window_height());
7232001f49Smrg   vgLoadIdentity();
7332001f49Smrg   vgTranslate(50, 21);
7432001f49Smrg   vgDrawPath(path, VG_FILL_PATH);
7532001f49Smrg   vgFlush();
7632001f49Smrg}
7732001f49Smrg
7832001f49Smrg
7932001f49Smrgint main(int argc, char **argv)
8032001f49Smrg{
8132001f49Smrg   set_window_size(100, 100);
8232001f49Smrg   return run(argc, argv, init, reshape,
8332001f49Smrg              draw, 0);
8432001f49Smrg}
85