Merge branch '7.8'
[mesa.git] / progs / egl / openvg / trivial / ellipse.c
1 #include "eglcommon.h"
2
3 #include <VG/openvg.h>
4
5 #include <math.h>
6 #include <stdlib.h>
7
8 const VGfloat white_color[4] = {1.0, 1.0, 1.0, 1.0};
9 const VGfloat color[4] = {0.0, 0.0, 0.0, 1.0};
10
11 VGPath path;
12 VGPaint paint;
13
14 static void
15 init(void)
16 {
17 VGfloat clearColor[] = {1.0f, 1.0f, 1.0f, 1.0f};/* white color */
18 VGfloat fillColor[] = {1.0f, 0.0f, 0.0f, 1.0f};/* red color */
19 static const VGubyte segments[4] = {VG_MOVE_TO_ABS,
20 VG_SCCWARC_TO_ABS,
21 VG_SCCWARC_TO_ABS,
22 VG_CLOSE_PATH};
23 VGfloat data[12];
24 const VGfloat cx = 0, cy=29, width=80, height=40;
25 const VGfloat hw = width * 0.5f;
26 const VGfloat hh = height * 0.5f;
27
28 data[0] = cx + hw;
29 data[1] = cy;
30 data[2] = hw;
31 data[3] = hh;
32 data[4] = 0;
33 data[5] = cx - hw;
34 data[6] = cy;
35 data[7] = hw;
36 data[8] = hh;
37 data[9] = 0;
38 data[10] = data[0];
39 data[11] = cy;
40
41 vgSetfv(VG_CLEAR_COLOR, 4, clearColor);
42 vgSeti(VG_RENDERING_QUALITY, VG_RENDERING_QUALITY_NONANTIALIASED);
43
44
45 path = vgCreatePath(VG_PATH_FORMAT_STANDARD, VG_PATH_DATATYPE_F,
46 1.0f, 0.0f, 0, 0, VG_PATH_CAPABILITY_ALL);
47 if (path == VG_INVALID_HANDLE) {
48 return;
49 }
50 paint = vgCreatePaint();
51 if (paint == VG_INVALID_HANDLE) {
52 vgDestroyPath(path);
53 return;
54 }
55
56 vgAppendPathData(path, 4, segments, data);
57 vgSetParameterfv(paint, VG_PAINT_COLOR, 4, fillColor);
58 vgSetParameteri( paint, VG_PAINT_TYPE, VG_PAINT_TYPE_COLOR);
59 vgSetPaint(paint, VG_FILL_PATH);
60 }
61
62 /* new window size or exposure */
63 static void
64 reshape(int w, int h)
65 {
66 }
67
68 static void
69 draw(void)
70 {
71 vgClear(0, 0, window_width(), window_height());
72 vgLoadIdentity();
73 vgTranslate(50, 21);
74 vgDrawPath(path, VG_FILL_PATH);
75 vgFlush();
76 }
77
78
79 int main(int argc, char **argv)
80 {
81 set_window_size(100, 100);
82 return run(argc, argv, init, reshape,
83 draw, 0);
84 }