~ubuntu-branches/ubuntu/oneiric/mesa-demos/oneiric

« back to all changes in this revision

Viewing changes to src/egl/openvg/trivial/gradorigin.c

  • Committer: Bazaar Package Importer
  • Author(s): Christopher James Halse Rogers
  • Date: 2010-09-27 16:18:27 UTC
  • Revision ID: james.westby@ubuntu.com-20100927161827-1yfgolc1oy9sjhi8
Tags: upstream-8.0.1
ImportĀ upstreamĀ versionĀ 8.0.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include "eglcommon.h"
 
2
 
 
3
#include <VG/openvg.h>
 
4
 
 
5
#include <stdio.h>
 
6
#include <string.h>
 
7
 
 
8
static const VGfloat white_color[4] = {1.0, 1.0, 1.0, 1.0};
 
9
 
 
10
static VGPath path;
 
11
static VGPaint fill;
 
12
 
 
13
VGColorRampSpreadMode spread = VG_COLOR_RAMP_SPREAD_PAD;
 
14
 
 
15
static void
 
16
init(void)
 
17
{
 
18
   VGubyte commands[5] =  {VG_MOVE_TO_ABS, VG_LINE_TO_ABS, VG_LINE_TO_ABS, VG_LINE_TO_ABS, VG_CLOSE_PATH};
 
19
   VGfloat coords[8] =    {0.0f,0.0f, 32.0f,0.0f, 32.0f,32.0f, 0.0f,32.0f };
 
20
 
 
21
   VGfloat rampStop[20] = {-0.5f,  1.0f, 1.0f, 1.0f, 1.0f,
 
22
                           0.25f, 1.0f, 0.0f, 0.0f, 1.0f,
 
23
                           0.75f, 0.0f, 0.0f, 1.0f, 1.0f,
 
24
                           1.5f,  0.0f, 0.0f, 0.0f, 0.0f};
 
25
 
 
26
   VGfloat defaultColor[] = {1.0f, 1.0f, 1.0f, 1.0f};
 
27
   VGfloat linearGradient[4] = {0.0f, 0.0f, 0.0f, 32.0f};
 
28
 
 
29
   path = vgCreatePath(VG_PATH_FORMAT_STANDARD, VG_PATH_DATATYPE_F,
 
30
                       1.0f, 0.0f, 0, 0, VG_PATH_CAPABILITY_ALL);
 
31
   if (path == VG_INVALID_HANDLE)
 
32
      return;
 
33
 
 
34
   fill = vgCreatePaint();
 
35
   if (fill == VG_INVALID_HANDLE) {
 
36
      vgDestroyPath(path);
 
37
      return;
 
38
   }
 
39
 
 
40
   vgSetfv(VG_CLEAR_COLOR, 4, defaultColor);
 
41
   vgSeti(VG_RENDERING_QUALITY, VG_RENDERING_QUALITY_NONANTIALIASED);
 
42
 
 
43
   vgAppendPathData(path, 5, commands, coords);
 
44
 
 
45
   vgSetPaint(fill, VG_FILL_PATH);
 
46
   vgSetParameteri(fill, VG_PAINT_TYPE, VG_PAINT_TYPE_LINEAR_GRADIENT);
 
47
   vgSetParameteri(fill, VG_PAINT_COLOR_RAMP_SPREAD_MODE,
 
48
                   VG_COLOR_RAMP_SPREAD_REPEAT);
 
49
   vgSetParameterfv(fill, VG_PAINT_LINEAR_GRADIENT, 4, linearGradient);
 
50
   vgSetParameterfv(fill, VG_PAINT_COLOR_RAMP_STOPS, 20, rampStop);
 
51
}
 
52
 
 
53
/* new window size or exposure */
 
54
static void
 
55
reshape(int w, int h)
 
56
{
 
57
   vgLoadIdentity();
 
58
}
 
59
 
 
60
static void
 
61
draw(void)
 
62
{
 
63
   vgClear(0, 0, window_width(), window_height());
 
64
 
 
65
   vgDrawPath(path, VG_FILL_PATH);
 
66
 
 
67
   vgFlush();
 
68
}
 
69
 
 
70
 
 
71
int main(int argc, char **argv)
 
72
{
 
73
   if (argc > 1) {
 
74
      const char *arg = argv[1];
 
75
      if (!strcmp("-pad", arg))
 
76
         spread = VG_COLOR_RAMP_SPREAD_PAD;
 
77
      else if (!strcmp("-repeat", arg))
 
78
         spread = VG_COLOR_RAMP_SPREAD_REPEAT;
 
79
      else if (!strcmp("-reflect", arg))
 
80
         spread = VG_COLOR_RAMP_SPREAD_REFLECT;
 
81
   }
 
82
 
 
83
   switch(spread) {
 
84
   case VG_COLOR_RAMP_SPREAD_PAD:
 
85
      printf("Using spread mode: pad\n");
 
86
      break;
 
87
   case VG_COLOR_RAMP_SPREAD_REPEAT:
 
88
      printf("Using spread mode: repeat\n");
 
89
      break;
 
90
   case VG_COLOR_RAMP_SPREAD_REFLECT:
 
91
      printf("Using spread mode: reflect\n");
 
92
   }
 
93
 
 
94
   set_window_size(200, 200);
 
95
 
 
96
   return run(argc, argv, init, reshape,
 
97
              draw, 0);
 
98
}