DRI2: report swap events correctly in direct rendered case
[mesa.git] / progs / openvg / trivial / path3.c
1 #include "eglcommon.h"
2
3 #include <VG/openvg.h>
4 #include <VG/vgu.h>
5 #include <stdio.h>
6 #include <math.h>
7 #include <stdlib.h>
8
9 static void
10 init(void)
11 {
12 }
13
14 /* new window size or exposure */
15 static void
16 reshape(int w, int h)
17 {
18 }
19
20
21 static void
22 draw(void)
23 {
24 VGint WINDSIZEX = window_width();
25 VGint WINDSIZEY = window_height();
26 VGPath path;
27 VGPaint paint;
28
29 VGfloat clearColor[] = {1.0f, 1.0f, 1.0f, 0.0f};/* white color */
30 VGfloat fillColor[] = {1.0f, 0.0f, 0.0f, 1.0f};/* red color */
31
32 #if 1
33 VGubyte commands[4] = {VG_MOVE_TO_ABS, VG_LCWARC_TO_ABS, VG_SCWARC_TO_ABS, VG_CLOSE_PATH};
34 #else
35 VGubyte commands[4] = {VG_MOVE_TO_ABS, VG_SCCWARC_TO_ABS, VG_LCCWARC_TO_ABS,VG_CLOSE_PATH};
36 #endif
37 VGfloat coords[] = {32.0f, 0.0f,
38 -32.0f, -32.0f, 0.0f, 64.0f, 32.0f,
39 -32.0f, -32.0f, 0.0f, 32.0f, 0.0f};
40
41
42 vgSetfv(VG_CLEAR_COLOR, 4, clearColor);
43 vgClear(0, 0, WINDSIZEX, WINDSIZEY);
44 vgSeti(VG_RENDERING_QUALITY, VG_RENDERING_QUALITY_NONANTIALIASED);
45
46 vgSeti(VG_MATRIX_MODE, VG_MATRIX_PATH_USER_TO_SURFACE);
47 vgLoadIdentity();
48 //vgTranslate(32.0f, 32.0f);
49
50 path = vgCreatePath( VG_PATH_FORMAT_STANDARD, VG_PATH_DATATYPE_F,
51 1.0f, 0.0f, 0, 0, VG_PATH_CAPABILITY_ALL );
52 if ( path == VG_INVALID_HANDLE ) {
53 return;
54 }
55 paint = vgCreatePaint();
56 if ( paint == VG_INVALID_HANDLE ) {
57 vgDestroyPath(path);
58 return;
59 }
60
61 vgAppendPathData(path, 4, commands, coords);
62 vgSetParameterfv(paint, VG_PAINT_COLOR, 4, fillColor);
63 vgSetParameteri( paint, VG_PAINT_TYPE, VG_PAINT_TYPE_COLOR);
64 vgSetPaint(paint, VG_FILL_PATH);
65 vgDrawPath(path, VG_FILL_PATH);
66
67 vgDestroyPath(path);
68 vgDestroyPaint(paint);
69 }
70
71
72 int main(int argc, char **argv)
73 {
74 set_window_size(64, 64);
75 return run(argc, argv, init, reshape,
76 draw, 0);
77 }