123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 |
- /**
- * Draws number of really large paths, created by rasterising a photograph
- * (using inkscape/potrace, svgconv)
- *
- */
- #include "game.h"
- // for readability, the screen and texture sizes are hard-coded
- const float SCREEN_WIDTH=640.0f;
- const float SCREEN_HEIGHT=360.0f;
- const VGfloat backgroundColor[4] = { 0.9f, .83f, 0.76f, 1.0f };
- // defines used by svgconv
- typedef int HGint32;
- typedef unsigned int HGuint32;
- typedef short HGint16;
- typedef unsigned short HGuint16;
- typedef signed char HGint8;
- typedef unsigned char HGuint8;
- typedef int HGbool;
- #define HG_FALSE (0 == 1)
- #define HG_TRUE (1 == 1)
- #define OVG_RGB(r,g,b) ((b<<8)|(g<<16)|(r<<24)|0xff)
- typedef struct
- {
- const float* floats;
- const HGuint8* cmds;
- HGint32 nCommands;
- HGint32 nFloats;
- HGuint32 color;
- float transform[9];
- } PathData;
- #include "redonion_svg.h"
- #define NUM_PATHS (sizeof(_paths)/sizeof(PathData))
- // runtime path handles
- VGPath paths[NUM_PATHS];
- VGPaint paint;
- /** walltime */
- float t;
- void game_init()
- {
- }
- void game_destroy()
- {
- }
- void game_prepare()
- {
- vgSeti(VG_RENDERING_QUALITY, VG_RENDERING_QUALITY_FASTER);
- paint = vgCreatePaint();
- vgSetPaint(paint, VG_FILL_PATH);
- vgSeti(VG_FILL_RULE, VG_NON_ZERO);
- for(int i=0;i<NUM_PATHS;i++)
- {
- paths[i] = vgCreatePath(VG_PATH_FORMAT_STANDARD, VG_PATH_DATATYPE_F, 1.0f, 0.0f, 0, 0, VG_PATH_CAPABILITY_APPEND_TO);
- vgAppendPathData(paths[i], _paths[i].nCommands, (VGubyte*)_paths[i].cmds, _paths[i].floats);
- }
- }
- void game_release()
- {
- for(int i=0;i<NUM_PATHS;i++)
- {
- vgDestroyPath(paths[i]);
- paths[i]=VG_INVALID_HANDLE;
- }
- vgDestroyPaint(paint);
- paint=VG_INVALID_HANDLE;
- }
- void game_update(float walltime)
- {
- t=walltime;
- }
- void game_render()
- {
- // clear background using black
- vgSetfv(VG_CLEAR_COLOR, 4, backgroundColor);
- vgClear(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
- vgSetPaint(paint, VG_FILL_PATH);
- for(int i = 0; i < NUM_PATHS; i++)
- {
- vgSetColor(paint, _paths[i].color);
- vgSeti(VG_MATRIX_MODE, VG_MATRIX_PATH_USER_TO_SURFACE);
- vgLoadIdentity();
- vgRotate(90);
- vgTranslate(-130*(1+sin(t*.2)),0);
- vgScale(1.0f, -1.0f);
- vgMultMatrix(_paths[i].transform);
- vgDrawPath(paths[i], VG_FILL_PATH);
- }
- }
- void game_event(int type, float x, float y, float z)
- {
- }
|