sp.c revision 32001f49
132001f49Smrg#include <VG/openvg.h> 232001f49Smrg#include <VG/vgu.h> 332001f49Smrg#include <math.h> 432001f49Smrg#include <string.h> 532001f49Smrg 632001f49Smrg#include "eglut.h" 732001f49Smrg 832001f49Smrg#define ELEMENTS(x) (sizeof(x)/sizeof((x)[0])) 932001f49Smrg 1032001f49Smrgstruct object { 1132001f49Smrg VGPath path; 1232001f49Smrg VGPaint fill; 1332001f49Smrg VGPaint stroke; 1432001f49Smrg VGint draw_mode; 1532001f49Smrg VGfloat matrix[9]; 1632001f49Smrg VGfloat stroke_width; 1732001f49Smrg}; 1832001f49Smrg 1932001f49Smrgstruct character { 2032001f49Smrg struct object objects[32]; 2132001f49Smrg VGint num_objects; 2232001f49Smrg}; 2332001f49SmrgVGfloat identity_matrix[] = {1, 0, 0, 0, 1, 0, 0, 0, 1}; 2432001f49Smrg 2532001f49Smrgstruct character cartman; 2632001f49Smrg 2732001f49Smrgstatic void add_object_fill(const VGubyte *segments, VGint num_segments, 2832001f49Smrg const VGfloat *coords, 2932001f49Smrg VGuint color) 3032001f49Smrg{ 3132001f49Smrg struct object object; 3232001f49Smrg 3332001f49Smrg object.path = vgCreatePath(VG_PATH_FORMAT_STANDARD, VG_PATH_DATATYPE_F, 3432001f49Smrg 1, 0, 0, 0, VG_PATH_CAPABILITY_ALL); 3532001f49Smrg vgAppendPathData(object.path, num_segments, segments, coords); 3632001f49Smrg 3732001f49Smrg object.fill = vgCreatePaint(); 3832001f49Smrg vgSetColor(object.fill, color); 3932001f49Smrg memcpy(object.matrix, identity_matrix, 9 * sizeof(VGfloat)); 4032001f49Smrg object.draw_mode = VG_FILL_PATH; 4132001f49Smrg 4232001f49Smrg cartman.objects[cartman.num_objects] = object; 4332001f49Smrg ++cartman.num_objects; 4432001f49Smrg} 4532001f49Smrg 4632001f49Smrg 4732001f49Smrgstatic void add_object_stroke(const VGubyte *segments, VGint num_segments, 4832001f49Smrg const VGfloat *coords, 4932001f49Smrg VGuint color, VGfloat width) 5032001f49Smrg{ 5132001f49Smrg struct object object; 5232001f49Smrg 5332001f49Smrg object.path = vgCreatePath(VG_PATH_FORMAT_STANDARD, VG_PATH_DATATYPE_F, 5432001f49Smrg 1, 0, 0, 0, VG_PATH_CAPABILITY_ALL); 5532001f49Smrg vgAppendPathData(object.path, num_segments, segments, coords); 5632001f49Smrg 5732001f49Smrg object.stroke = vgCreatePaint(); 5832001f49Smrg vgSetColor(object.stroke, color); 5932001f49Smrg memcpy(object.matrix, identity_matrix, 9 * sizeof(VGfloat)); 6032001f49Smrg object.draw_mode = VG_STROKE_PATH; 6132001f49Smrg object.stroke_width = width; 6232001f49Smrg 6332001f49Smrg cartman.objects[cartman.num_objects] = object; 6432001f49Smrg ++cartman.num_objects; 6532001f49Smrg} 6632001f49Smrg 6732001f49Smrg 6832001f49Smrgstatic void add_object_fillm(const VGubyte *segments, VGint num_segments, 6932001f49Smrg const VGfloat *coords, 7032001f49Smrg VGuint color, 7132001f49Smrg VGfloat *matrix) 7232001f49Smrg{ 7332001f49Smrg struct object object; 7432001f49Smrg 7532001f49Smrg object.path = vgCreatePath(VG_PATH_FORMAT_STANDARD, VG_PATH_DATATYPE_F, 7632001f49Smrg 1, 0, 0, 0, VG_PATH_CAPABILITY_ALL); 7732001f49Smrg vgAppendPathData(object.path, num_segments, segments, coords); 7832001f49Smrg 7932001f49Smrg object.fill = vgCreatePaint(); 8032001f49Smrg vgSetColor(object.fill, color); 8132001f49Smrg memcpy(object.matrix, matrix, 9 * sizeof(VGfloat)); 8232001f49Smrg object.draw_mode = VG_FILL_PATH; 8332001f49Smrg 8432001f49Smrg cartman.objects[cartman.num_objects] = object; 8532001f49Smrg ++cartman.num_objects; 8632001f49Smrg} 8732001f49Smrg 8832001f49Smrg 8932001f49Smrgstatic void add_object_m(const VGubyte *segments, VGint num_segments, 9032001f49Smrg const VGfloat *coords, 9132001f49Smrg VGuint fill_color, 9232001f49Smrg VGuint stroke_color, VGfloat stroke_width, 9332001f49Smrg VGfloat *matrix) 9432001f49Smrg{ 9532001f49Smrg struct object object; 9632001f49Smrg 9732001f49Smrg object.path = vgCreatePath(VG_PATH_FORMAT_STANDARD, VG_PATH_DATATYPE_F, 9832001f49Smrg 1, 0, 0, 0, VG_PATH_CAPABILITY_ALL); 9932001f49Smrg vgAppendPathData(object.path, num_segments, segments, coords); 10032001f49Smrg memcpy(object.matrix, matrix, 9 * sizeof(VGfloat)); 10132001f49Smrg 10232001f49Smrg object.fill = vgCreatePaint(); 10332001f49Smrg vgSetColor(object.fill, fill_color); 10432001f49Smrg object.draw_mode = VG_FILL_PATH | VG_STROKE_PATH; 10532001f49Smrg 10632001f49Smrg object.stroke = vgCreatePaint(); 10732001f49Smrg vgSetColor(object.stroke, stroke_color); 10832001f49Smrg object.stroke_width = stroke_width; 10932001f49Smrg 11032001f49Smrg cartman.objects[cartman.num_objects] = object; 11132001f49Smrg ++cartman.num_objects; 11232001f49Smrg} 11332001f49Smrg 11432001f49Smrgstatic void init_character() 11532001f49Smrg{ 11632001f49Smrg { 11732001f49Smrg const VGubyte segments[] = {VG_MOVE_TO_ABS, 11832001f49Smrg VG_CUBIC_TO_ABS, 11932001f49Smrg VG_CUBIC_TO_ABS, 12032001f49Smrg VG_CUBIC_TO_ABS, 12132001f49Smrg VG_CUBIC_TO_ABS, 12232001f49Smrg VG_CLOSE_PATH}; 12332001f49Smrg const VGfloat coords[] = {181.83267, 102.60408, 12432001f49Smrg 181.83267,102.60408, 185.53793,114.5749, 186.5355,115.00243, 12532001f49Smrg 187.53306,115.42996, 286.0073,115.00243, 286.0073,115.00243, 12632001f49Smrg 286.0073,115.00243, 292.70526,103.45914, 290.85263,101.03648, 12732001f49Smrg 289.00001,98.61381, 181.54765,102.31906, 181.83267,102.60408 12832001f49Smrg }; 12932001f49Smrg VGuint color = 0x7c4e32ff; 13032001f49Smrg add_object_fill(segments, ELEMENTS(segments), 13132001f49Smrg coords, color); 13232001f49Smrg } 13332001f49Smrg { 13432001f49Smrg const VGubyte segments[] = { 13532001f49Smrg VG_MOVE_TO_ABS, 13632001f49Smrg VG_CUBIC_TO_ABS, 13732001f49Smrg VG_CUBIC_TO_ABS, 13832001f49Smrg VG_LINE_TO_ABS, 13932001f49Smrg VG_CUBIC_TO_ABS, 14032001f49Smrg VG_CUBIC_TO_ABS, 14132001f49Smrg VG_CUBIC_TO_ABS, 14232001f49Smrg VG_CUBIC_TO_ABS, 14332001f49Smrg VG_CUBIC_TO_ABS, 14432001f49Smrg VG_CUBIC_TO_ABS, 14532001f49Smrg VG_CLOSE_PATH 14632001f49Smrg }; 14732001f49Smrg const VGfloat coords[] = {188.62208,50.604156, 14832001f49Smrg 188.62208,50.604156, 176.73127,60.479579, 170.68509,69.548844, 14932001f49Smrg 164.63892,78.618109, 175.11895,79.827344, 175.11895,79.827344, 15032001f49Smrg 176.52973,98.368952, 15132001f49Smrg 176.52973,98.368952, 189.83131,110.05823, 208.97754,110.25976, 15232001f49Smrg 228.12377,110.46131, 244.24691,111.67054, 247.06846,110.25976, 15332001f49Smrg 249.89,108.849, 258.95927,106.8336, 260.16851,105.01975, 15432001f49Smrg 261.37774,103.2059, 296.84865,106.43053, 297.05019,91.919698, 15532001f49Smrg 297.25172,77.408874, 306.11945,64.308824, 282.13628,51.611853, 15632001f49Smrg 258.15311,38.914882, 189.2267,49.999539, 188.62208,50.604156 15732001f49Smrg }; 15832001f49Smrg 15932001f49Smrg VGuint color = 0xe30000ff; 16032001f49Smrg add_object_fill(segments, ELEMENTS(segments), 16132001f49Smrg coords, color); 16232001f49Smrg } 16332001f49Smrg { 16432001f49Smrg const VGubyte segments[] = { 16532001f49Smrg VG_MOVE_TO_ABS, 16632001f49Smrg VG_CUBIC_TO_ABS, 16732001f49Smrg VG_CUBIC_TO_ABS, 16832001f49Smrg VG_CUBIC_TO_ABS, 16932001f49Smrg VG_CUBIC_TO_ABS, 17032001f49Smrg VG_CLOSE_PATH 17132001f49Smrg }; 17232001f49Smrg const VGfloat coords[] = { 17332001f49Smrg 68.25, 78.875, 17432001f49Smrg 68.25,93.296, 54.642,105, 37.875,105, 17532001f49Smrg 21.108,105, 7.5,93.296, 7.5,78.875, 17632001f49Smrg 7.5,64.454, 21.108,52.75, 37.875,52.75, 17732001f49Smrg 54.642,52.75, 68.25,64.454, 68.25,78.875 17832001f49Smrg }; 17932001f49Smrg 18032001f49Smrg VGuint color = 0xffe1c4ff; 18132001f49Smrg VGfloat matrix[] = { 18232001f49Smrg 1.6529, 0, 0, 18332001f49Smrg 0, 1.582037, 0, 18432001f49Smrg 172.9649,-90.0116, 1 18532001f49Smrg }; 18632001f49Smrg add_object_fillm(segments, ELEMENTS(segments), 18732001f49Smrg coords, color, matrix); 18832001f49Smrg } 18932001f49Smrg { 19032001f49Smrg const VGubyte segments[] = { 19132001f49Smrg VG_MOVE_TO_ABS, VG_CUBIC_TO_ABS, VG_CUBIC_TO_ABS, VG_CUBIC_TO_ABS, 19232001f49Smrg VG_CUBIC_TO_ABS, VG_CUBIC_TO_ABS, VG_CLOSE_PATH 19332001f49Smrg }; 19432001f49Smrg const VGfloat coords[] = { 19532001f49Smrg 170.14687,71.536958, 19632001f49Smrg 173.53626,68.814326, 176.70232,68.971782, 180.55009,71.679467, 19732001f49Smrg 184.39785,74.387153, 199.19294,80.036105, 191.52334,86.500482, 19832001f49Smrg 189.02942,88.6025, 183.97032,85.787933, 180.26507,86.928011, 19932001f49Smrg 178.8737,87.356121, 174.71827,89.783259, 171.8028,87.494856, 20032001f49Smrg 166.95426,83.689139, 163.51779,76.861986, 170.14687,71.536958 20132001f49Smrg }; 20232001f49Smrg 20332001f49Smrg VGuint color = 0xfff200ff; 20432001f49Smrg add_object_fill(segments, ELEMENTS(segments), 20532001f49Smrg coords, color); 20632001f49Smrg } 20732001f49Smrg { 20832001f49Smrg const VGubyte segments[] = { 20932001f49Smrg VG_MOVE_TO_ABS, VG_CUBIC_TO_ABS, VG_CUBIC_TO_ABS, 21032001f49Smrg VG_CUBIC_TO_ABS, VG_CUBIC_TO_ABS, VG_CUBIC_TO_ABS, 21132001f49Smrg VG_CUBIC_TO_ABS, VG_CLOSE_PATH 21232001f49Smrg }; 21332001f49Smrg const VGfloat coords[] = { 21432001f49Smrg 299.83075,66.834136, 21532001f49Smrg 299.83075,66.834136, 287.85993,64.69649, 284.15467,72.962055, 21632001f49Smrg 280.44942,81.227621, 280.1644,78.234916, 280.1644,79.374994, 21732001f49Smrg 280.1644,80.515072, 278.16927,84.077816, 284.86722,83.792796, 21832001f49Smrg 291.56518,83.507777, 291.99271,86.785501, 294.84291,86.642991, 21932001f49Smrg 297.6931,86.500482, 303.536,85.645423, 303.67851,80.657582, 22032001f49Smrg 303.82102,75.66974, 302.68094,65.551548, 299.83075,66.834136 22132001f49Smrg }; 22232001f49Smrg 22332001f49Smrg VGuint color = 0xfff200ff; 22432001f49Smrg add_object_fill(segments, ELEMENTS(segments), 22532001f49Smrg coords, color); 22632001f49Smrg } 22732001f49Smrg { 22832001f49Smrg const VGubyte segments[] = { 22932001f49Smrg VG_MOVE_TO_ABS, VG_CUBIC_TO_ABS, VG_CUBIC_TO_ABS, VG_CUBIC_TO_ABS 23032001f49Smrg }; 23132001f49Smrg const VGfloat coords[] = { 23232001f49Smrg 240.83171,75.81225, 23332001f49Smrg 240.83171,75.81225, 241.54426,88.495618, 242.25681,91.488323, 23432001f49Smrg 242.96936,94.481028, 240.6892,108.01945, 240.83171,110.01459, 23532001f49Smrg 240.97422,112.00973, 240.97422,111.01216, 240.97422,111.01216 23632001f49Smrg }; 23732001f49Smrg VGuint color = 0x000000ff; 23832001f49Smrg VGfloat swidth = 1.14007807; 23932001f49Smrg add_object_stroke(segments, ELEMENTS(segments), coords, color, swidth); 24032001f49Smrg } 24132001f49Smrg { 24232001f49Smrg const VGubyte segments[] = { 24332001f49Smrg VG_MOVE_TO_ABS, VG_CUBIC_TO_ABS, VG_CUBIC_TO_ABS, VG_CUBIC_TO_ABS, 24432001f49Smrg VG_CUBIC_TO_ABS, VG_LINE_TO_ABS, VG_LINE_TO_ABS, VG_CLOSE_PATH 24532001f49Smrg }; 24632001f49Smrg const VGfloat coords[] = { 24732001f49Smrg 83.375, 95.5, 24832001f49Smrg 83.375,96.121, 83.067,96.625, 82.6875,96.625, 24932001f49Smrg 82.308,96.625, 82,96.121, 82,95.5, 25032001f49Smrg 82,94.879, 82.308,94.375, 82.6875,94.375, 25132001f49Smrg 83.066677,94.375, 83.374492,94.878024, 83.374999,95.498494, 25232001f49Smrg 82.6875,95.5, 25332001f49Smrg 83.375,95.5 25432001f49Smrg }; 25532001f49Smrg VGuint fill_color = 0x000000ff; 25632001f49Smrg VGuint stroke_color = 0x000000ff; 25732001f49Smrg VGfloat swidth = 0.60000002; 25832001f49Smrg VGfloat matrix1[] = { 25932001f49Smrg 1.140078, 0, 0, 26032001f49Smrg 0, 1.140078, 0, 26132001f49Smrg 145.4927, -15.10897, 1 26232001f49Smrg }; 26332001f49Smrg VGfloat matrix2[] = { 26432001f49Smrg 1.140078,0, 0, 26532001f49Smrg 0,1.140078, 0, 26632001f49Smrg 144.2814,-27.93485, 1 26732001f49Smrg }; 26832001f49Smrg VGfloat matrix3[] = { 26932001f49Smrg 1.140078,0, 0, 27032001f49Smrg 0,1.140078, 0, 27132001f49Smrg 144.1388,-3.70819, 1 27232001f49Smrg }; 27332001f49Smrg add_object_m(segments, ELEMENTS(segments), coords, 27432001f49Smrg fill_color, stroke_color, swidth, matrix1); 27532001f49Smrg add_object_m(segments, ELEMENTS(segments), coords, 27632001f49Smrg fill_color, stroke_color, swidth, matrix2); 27732001f49Smrg add_object_m(segments, ELEMENTS(segments), coords, 27832001f49Smrg fill_color, stroke_color, swidth, matrix3); 27932001f49Smrg } 28032001f49Smrg { 28132001f49Smrg const VGubyte segments[] = { 28232001f49Smrg VG_MOVE_TO_ABS, 28332001f49Smrg VG_CUBIC_TO_ABS, VG_CUBIC_TO_ABS, 28432001f49Smrg VG_LINE_TO_ABS, VG_CLOSE_PATH 28532001f49Smrg }; 28632001f49Smrg const VGfloat coords[] = { 28732001f49Smrg 179.41001,115.28745, 28832001f49Smrg 179.41001,115.28745, 207.48443,109.30204, 236.84144,115.14494, 28932001f49Smrg 236.84144,115.14494, 274.74903,109.87208, 291.8502,115.42996, 29032001f49Smrg 179.41001,115.28745 29132001f49Smrg }; 29232001f49Smrg 29332001f49Smrg VGuint color = 0x000000ff; 29432001f49Smrg add_object_fill(segments, ELEMENTS(segments), 29532001f49Smrg coords, color); 29632001f49Smrg } 29732001f49Smrg { 29832001f49Smrg const VGubyte segments[] = { 29932001f49Smrg VG_MOVE_TO_ABS, VG_CUBIC_TO_ABS, VG_CUBIC_TO_ABS, VG_CUBIC_TO_ABS, 30032001f49Smrg VG_CUBIC_TO_ABS, VG_LINE_TO_ABS, VG_LINE_TO_ABS, VG_CLOSE_PATH 30132001f49Smrg }; 30232001f49Smrg const VGfloat coords[] = { 30332001f49Smrg 83.792156,68.157364, 30432001f49Smrg 83.792156,69.669865, 82.72301,70.897403, 81.40567,70.897403, 30532001f49Smrg 80.08833,70.897403, 79.019185,69.669865, 79.019185,68.157364, 30632001f49Smrg 79.019185,66.644862, 80.08833,65.417325, 81.40567,65.417325, 30732001f49Smrg 82.721887,65.417325, 83.790391,66.642485, 83.792153,68.153696, 30832001f49Smrg 81.40567,68.157364, 30932001f49Smrg 83.792156,68.157364 31032001f49Smrg }; 31132001f49Smrg VGuint fill_color = 0x000000ff; 31232001f49Smrg VGuint stroke_color = 0x000000ff; 31332001f49Smrg VGfloat swidth = 0.52891117; 31432001f49Smrg VGfloat matrix1[] = { 31532001f49Smrg 1.140078,0, 0, 31632001f49Smrg 0,1.140078, 0, 31732001f49Smrg 145.2489,-15.58714, 1 31832001f49Smrg }; 31932001f49Smrg add_object_m(segments, ELEMENTS(segments), coords, 32032001f49Smrg fill_color, stroke_color, swidth, matrix1); 32132001f49Smrg } 32232001f49Smrg { 32332001f49Smrg const VGubyte segments[] = { 32432001f49Smrg VG_MOVE_TO_ABS, VG_CUBIC_TO_ABS 32532001f49Smrg }; 32632001f49Smrg const VGfloat coords[] = { 32732001f49Smrg 232.28113,66.976646, 32832001f49Smrg 232.28113,66.976646, 237.98152,70.539389, 245.39202,66.549116 32932001f49Smrg }; 33032001f49Smrg VGuint color = 0x000000ff; 33132001f49Smrg VGfloat swidth = 0.60299999; 33232001f49Smrg add_object_stroke(segments, ELEMENTS(segments), coords, color, swidth); 33332001f49Smrg } 33432001f49Smrg { 33532001f49Smrg const VGubyte segments[] = { 33632001f49Smrg VG_MOVE_TO_ABS, VG_CUBIC_TO_ABS, VG_CUBIC_TO_ABS, VG_CUBIC_TO_ABS, 33732001f49Smrg VG_CUBIC_TO_ABS, VG_CUBIC_TO_ABS, VG_CLOSE_PATH 33832001f49Smrg }; 33932001f49Smrg const VGfloat coords[] = { 34032001f49Smrg 185.96908,30.061986, 34132001f49Smrg 185.96908,30.061986, 187.76995,14.508377, 203.23909,3.7427917, 34232001f49Smrg 209.95028,-0.92779696, 219.37764,-4.9841866, 232.1078,-6.00046, 34332001f49Smrg 246.13578,-7.1203411, 256.92106,-2.8560739, 264.81774,1.9451947, 34432001f49Smrg 280.60485,11.543934, 284.31582,25.937274, 284.08015,26.526452, 34532001f49Smrg 283.7266,27.410336, 240.83461,1.9346323, 185.96908,30.061986 34632001f49Smrg }; 34732001f49Smrg VGuint color = 0x8ed8f8ff; 34832001f49Smrg add_object_fill(segments, ELEMENTS(segments), coords, color); 34932001f49Smrg } 35032001f49Smrg { 35132001f49Smrg const VGubyte segments[] = { 35232001f49Smrg VG_MOVE_TO_ABS, VG_LINE_TO_ABS, VG_CUBIC_TO_ABS, 35332001f49Smrg VG_LINE_TO_ABS, VG_CUBIC_TO_ABS, VG_CLOSE_PATH 35432001f49Smrg }; 35532001f49Smrg const VGfloat coords[] = { 35632001f49Smrg 185.39542,32.061757, 35732001f49Smrg 185.82295,29.211562, 35832001f49Smrg 185.82295,29.211562, 234.70379,2.277219, 284.01217,25.078779, 35932001f49Smrg 284.86722,27.643954, 36032001f49Smrg 284.86722,27.643954, 236.69893,4.5573746, 185.39542,32.061757 36132001f49Smrg }; 36232001f49Smrg VGuint color = 0xfff200ff; 36332001f49Smrg add_object_fill(segments, ELEMENTS(segments), coords, color); 36432001f49Smrg } 36532001f49Smrg 36632001f49Smrg { 36732001f49Smrg const VGubyte segments[] = { 36832001f49Smrg VG_MOVE_TO_ABS, VG_CUBIC_TO_ABS, VG_CUBIC_TO_ABS, VG_CUBIC_TO_ABS, 36932001f49Smrg VG_CUBIC_TO_ABS, VG_CUBIC_TO_ABS, VG_CUBIC_TO_ABS, VG_CUBIC_TO_ABS, 37032001f49Smrg VG_CUBIC_TO_ABS, VG_CUBIC_TO_ABS, VG_CUBIC_TO_ABS, VG_CUBIC_TO_ABS, 37132001f49Smrg VG_CUBIC_TO_ABS, VG_CLOSE_PATH 37232001f49Smrg }; 37332001f49Smrg const VGfloat coords[] = { 37432001f49Smrg 219.74027,-5.917093, 37532001f49Smrg 220.49206,-8.44929, 225.15564,-10.904934, 230.21473,-11.189954, 37632001f49Smrg 235.27383,-11.474973, 243.27521,-13.287236, 249.21385,-5.724198, 37732001f49Smrg 249.89961,-4.850868, 249.28247,-4.332166, 248.62298,-3.971398, 37832001f49Smrg 247.79117,-3.516361, 247.13703,-3.392737, 246.16222,-3.408047, 37932001f49Smrg 243.63973,-3.447664, 242.54183,-3.850701, 242.54183,-3.850701, 38032001f49Smrg 242.54183,-3.850701, 238.78367,-1.737343, 236.20014,-3.565682, 38132001f49Smrg 233.88436,-5.204544, 234.27626,-4.56325, 234.27626,-4.56325, 38232001f49Smrg 234.27626,-4.56325, 232.33303,-2.975658, 230.85603,-2.995643, 38332001f49Smrg 228.59433,-3.025282, 227.73672,-4.501857, 227.21966,-4.93027, 38432001f49Smrg 226.76318,-4.932008, 226.50948,-4.491995, 226.50948,-4.491995, 38532001f49Smrg 226.50948,-4.491995, 224.53199,-2.085883, 222.51431,-2.467064, 38632001f49Smrg 221.48814,-2.66093, 218.91968,-3.15318, 219.74027,-5.917093 38732001f49Smrg }; 38832001f49Smrg VGuint color = 0xfff200ff; 38932001f49Smrg add_object_fill(segments, ELEMENTS(segments), coords, color); 39032001f49Smrg } 39132001f49Smrg { 39232001f49Smrg const VGubyte segments[] = { 39332001f49Smrg VG_MOVE_TO_ABS, VG_CUBIC_TO_ABS, VG_CUBIC_TO_ABS, 39432001f49Smrg VG_CUBIC_TO_ABS, VG_CUBIC_TO_ABS, VG_CLOSE_PATH 39532001f49Smrg }; 39632001f49Smrg const VGfloat coords[] = { 39732001f49Smrg 178.97347,166.06432, 39832001f49Smrg 178.97347,181.2154, 168.0245,193.51193, 154.53381,193.51193, 39932001f49Smrg 141.04312,193.51193, 130.09416,181.2154, 130.09416,166.06432, 40032001f49Smrg 130.09416,150.91323, 141.04312,138.6167, 154.53381,138.6167, 40132001f49Smrg 168.0245,138.6167, 178.97347,150.91323, 178.97347,166.06432 40232001f49Smrg }; 40332001f49Smrg VGuint color = 0xffffffff; 40432001f49Smrg VGfloat matrix1[] = { 40532001f49Smrg 0.466614,-0.23492, 0, 40632001f49Smrg 0.108683,0.436638, 0, 40732001f49Smrg 134.5504,-0.901632, 1 40832001f49Smrg }; 40932001f49Smrg VGfloat matrix2[] = { 41032001f49Smrg -0.466614,-0.23492, 0, 41132001f49Smrg -0.108683,0.436638, 0, 41232001f49Smrg 338.4496,-0.512182, 1 41332001f49Smrg }; 41432001f49Smrg add_object_fillm(segments, ELEMENTS(segments), coords, color, matrix1); 41532001f49Smrg add_object_fillm(segments, ELEMENTS(segments), coords, color, matrix2); 41632001f49Smrg } 41732001f49Smrg { 41832001f49Smrg const VGubyte segments[] = { 41932001f49Smrg VG_MOVE_TO_ABS, VG_CUBIC_TO_ABS, VG_CUBIC_TO_ABS, 42032001f49Smrg VG_CUBIC_TO_ABS, VG_CUBIC_TO_ABS, VG_CLOSE_PATH 42132001f49Smrg }; 42232001f49Smrg const VGfloat coords[] = { 42332001f49Smrg 123.82758,165.06168, 42432001f49Smrg 123.82758,166.79125, 122.59232,168.19497, 121.07029,168.19497, 42532001f49Smrg 119.54826,168.19497, 118.313,166.79125, 118.313,165.06168, 42632001f49Smrg 118.313,163.3321, 119.54826,161.92839, 121.07029,161.92839, 42732001f49Smrg 122.59232,161.92839, 123.82758,163.3321, 123.82758,165.06168 42832001f49Smrg }; 42932001f49Smrg VGuint color = 0x000000ff; 43032001f49Smrg VGfloat matrix1[] = { 43132001f49Smrg 0.525719,0, 0, 43232001f49Smrg 0,0.479931, 0, 43332001f49Smrg 178.9702,-43.3532, 1 43432001f49Smrg }; 43532001f49Smrg VGfloat matrix2[] = { 43632001f49Smrg 0.525719,0, 0, 43732001f49Smrg 0,0.479931, 0, 43832001f49Smrg 165.258,-43.46162, 1 43932001f49Smrg }; 44032001f49Smrg add_object_fillm(segments, ELEMENTS(segments), coords, color, matrix1); 44132001f49Smrg add_object_fillm(segments, ELEMENTS(segments), coords, color, matrix2); 44232001f49Smrg } 44332001f49Smrg { 44432001f49Smrg const VGubyte segments[] = { 44532001f49Smrg VG_MOVE_TO_ABS, VG_CUBIC_TO_ABS, VG_CUBIC_TO_ABS 44632001f49Smrg }; 44732001f49Smrg const VGfloat coords[] = { 44832001f49Smrg 197.25,54.5, 44932001f49Smrg 197.25,54.5, 211.75,71.5, 229.25,71.5, 45032001f49Smrg 246.75,71.5, 261.74147,71.132714, 277.75,50.75 45132001f49Smrg }; 45232001f49Smrg VGuint color = 0x000000ff; 45332001f49Smrg VGfloat swidth = 0.60299999; 45432001f49Smrg add_object_stroke(segments, ELEMENTS(segments), coords, color, swidth); 45532001f49Smrg } 45632001f49Smrg} 45732001f49Smrg 45832001f49Smrg 45932001f49Smrgstatic void 46032001f49Smrginit(void) 46132001f49Smrg{ 46232001f49Smrg float clear_color[4] = {1.0, 1.0, 1.0, 1.0}; 46332001f49Smrg vgSetfv(VG_CLEAR_COLOR, 4, clear_color); 46432001f49Smrg 46532001f49Smrg init_character(); 46632001f49Smrg} 46732001f49Smrg 46832001f49Smrg/* new window size or exposure */ 46932001f49Smrgstatic void 47032001f49Smrgreshape(int w, int h) 47132001f49Smrg{ 47232001f49Smrg} 47332001f49Smrg 47432001f49Smrgstatic void 47532001f49Smrgdraw(void) 47632001f49Smrg{ 47732001f49Smrg VGint i; 47832001f49Smrg VGfloat save_matrix[9]; 47932001f49Smrg 48032001f49Smrg vgClear(0, 0, eglutGetWindowWidth(), eglutGetWindowHeight()); 48132001f49Smrg 48232001f49Smrg vgSeti(VG_MATRIX_MODE, VG_MATRIX_PATH_USER_TO_SURFACE); 48332001f49Smrg vgLoadIdentity(); 48432001f49Smrg vgScale(2, 2); 48532001f49Smrg vgTranslate(160, 60); 48632001f49Smrg vgRotate(180); 48732001f49Smrg vgTranslate(-160, -100); 48832001f49Smrg vgGetMatrix(save_matrix); 48932001f49Smrg for (i = 0; i < cartman.num_objects; ++i) { 49032001f49Smrg struct object object = cartman.objects[i]; 49132001f49Smrg if ((object.draw_mode & VG_STROKE_PATH)) { 49232001f49Smrg vgSetf(VG_STROKE_LINE_WIDTH, object.stroke_width); 49332001f49Smrg vgSetPaint(object.stroke, VG_STROKE_PATH); 49432001f49Smrg } 49532001f49Smrg if ((object.draw_mode & VG_FILL_PATH)) 49632001f49Smrg vgSetPaint(object.fill, VG_FILL_PATH); 49732001f49Smrg vgMultMatrix(object.matrix); 49832001f49Smrg vgDrawPath(object.path, object.draw_mode); 49932001f49Smrg vgLoadMatrix(save_matrix); 50032001f49Smrg } 50132001f49Smrg 50232001f49Smrg vgFlush(); 50332001f49Smrg} 50432001f49Smrg 50532001f49Smrg 50632001f49Smrgint main(int argc, char **argv) 50732001f49Smrg{ 50832001f49Smrg eglutInitWindowSize(400, 400); 50932001f49Smrg eglutInitAPIMask(EGLUT_OPENVG_BIT); 51032001f49Smrg eglutInit(argc, argv); 51132001f49Smrg 51232001f49Smrg eglutCreateWindow("sp"); 51332001f49Smrg 51432001f49Smrg eglutReshapeFunc(reshape); 51532001f49Smrg eglutDisplayFunc(draw); 51632001f49Smrg 51732001f49Smrg init(); 51832001f49Smrg 51932001f49Smrg eglutMainLoop(); 52032001f49Smrg 52132001f49Smrg return 0; 52232001f49Smrg} 523