Merge change 23583 into eclair
* changes: Update fountain to use structures.
This commit is contained in:
@@ -4,45 +4,44 @@
|
|||||||
#pragma stateFragment(default)
|
#pragma stateFragment(default)
|
||||||
#pragma stateFragmentStore(default)
|
#pragma stateFragmentStore(default)
|
||||||
|
|
||||||
|
struct PartStruct {float dx; float dy; float x; float y; int c;};
|
||||||
|
int newPart = 0;
|
||||||
|
|
||||||
int main(int launchID) {
|
int main(int launchID) {
|
||||||
int ct;
|
int ct;
|
||||||
int count = Control_count - 1;
|
int count = Control_count - 1;
|
||||||
int rate = Control_rate;
|
int rate = Control_rate;
|
||||||
float *dataF = loadArrayF(1, 0);
|
|
||||||
float height = getHeight();
|
float height = getHeight();
|
||||||
|
struct PartStruct * p = (struct PartStruct *)loadArrayF(1, 0);
|
||||||
|
|
||||||
if (rate) {
|
if (rate) {
|
||||||
int *dataI = loadArrayI32(1, 0);
|
|
||||||
float rMax = ((float)rate) * 0.005f;
|
float rMax = ((float)rate) * 0.005f;
|
||||||
int x = Control_x;
|
int x = Control_x;
|
||||||
int y = Control_y;
|
int y = Control_y;
|
||||||
int newPart = loadI32(1, count * 5);
|
|
||||||
int c = colorFloatRGBAtoUNorm8(Control_r, Control_g, Control_b, 0.99f);
|
int c = colorFloatRGBAtoUNorm8(Control_r, Control_g, Control_b, 0.99f);
|
||||||
|
|
||||||
while (rate--) {
|
while (rate--) {
|
||||||
int idx = newPart * 5;
|
vec2Rand((float *)(p + newPart), rMax);
|
||||||
vec2Rand(dataF + idx, rMax);
|
p[newPart].x = x;
|
||||||
dataF[idx + 2] = x;
|
p[newPart].y = y;
|
||||||
dataF[idx + 3] = y;
|
p[newPart].c = c;
|
||||||
dataI[idx + 4] = c;
|
|
||||||
newPart++;
|
newPart++;
|
||||||
if (newPart >= count) {
|
if (newPart >= count) {
|
||||||
newPart = 0;
|
newPart = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
storeI32(1, count * 5, newPart);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (ct=0; ct < count; ct++) {
|
for (ct=0; ct < count; ct++) {
|
||||||
float dy = dataF[1] + 0.15f;
|
float dy = p->dy + 0.15f;
|
||||||
float posy = dataF[3] + dy;
|
float posy = p->y + dy;
|
||||||
if ((posy > height) && (dy > 0)) {
|
if ((posy > height) && (dy > 0)) {
|
||||||
dy *= -0.3f;
|
dy *= -0.3f;
|
||||||
}
|
}
|
||||||
dataF[1] = dy;
|
p->dy = dy;
|
||||||
dataF[2] += dataF[0];
|
p->x += p->dx;
|
||||||
dataF[3] = posy;
|
p->y = posy;
|
||||||
dataF += 5;
|
p++;
|
||||||
}
|
}
|
||||||
|
|
||||||
uploadToBufferObject(NAMED_PartBuffer);
|
uploadToBufferObject(NAMED_PartBuffer);
|
||||||
|
|||||||
Reference in New Issue
Block a user