Home | History | Annotate | Download | only in raw
      1 // Fountain test script
      2 #pragma version(1)
      3 
      4 #include "rs_types.rsh"
      5 #include "rs_math.rsh"
      6 #include "rs_graphics.rsh"
      7 
      8 static int newPart = 0;
      9 
     10 typedef struct Control_s {
     11     int x, y;
     12     int rate;
     13     int count;
     14     float r, g, b;
     15     rs_allocation partBuffer;
     16     rs_mesh partMesh;
     17 } Control_t;
     18 Control_t *Control;
     19 
     20 typedef struct Point_s{
     21     float2 delta;
     22     float2 position;
     23     unsigned int color;
     24 } Point_t;
     25 Point_t *point;
     26 
     27 int main(int launchID) {
     28     int ct;
     29     int count = Control->count;
     30     int rate = Control->rate;
     31     float height = getHeight();
     32     Point_t * p = point;
     33 
     34     if (rate) {
     35         float rMax = ((float)rate) * 0.005f;
     36         int x = Control->x;
     37         int y = Control->y;
     38         int color = ((int)(Control->r * 255.f)) |
     39                     ((int)(Control->g * 255.f)) << 8 |
     40                     ((int)(Control->b * 255.f)) << 16 |
     41                     (0xf0 << 24);
     42         Point_t * np = &p[newPart];
     43 
     44         while (rate--) {
     45             np->delta = vec2Rand(rMax);
     46             np->position.x = x;
     47             np->position.y = y;
     48             np->color = color;
     49             newPart++;
     50             np++;
     51             if (newPart >= count) {
     52                 newPart = 0;
     53                 np = &p[newPart];
     54             }
     55         }
     56     }
     57 
     58     for (ct=0; ct < count; ct++) {
     59         float dy = p->delta.y + 0.15f;
     60         float posy = p->position.y + dy;
     61         if ((posy > height) && (dy > 0)) {
     62             dy *= -0.3f;
     63         }
     64         p->delta.y = dy;
     65         p->position.x += p->delta.x;
     66         p->position.y = posy;
     67         p++;
     68     }
     69 
     70     uploadToBufferObject(Control->partBuffer);
     71     drawSimpleMesh(Control->partMesh);
     72     return 1;
     73 }
     74