Mike Cleron | af45d44 | 2009-12-02 02:04:46 -0800 | [diff] [blame] | 1 | // Copyright (C) 2009 The Android Open Source Project |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | #pragma version(1) |
Jason Sams | 8aeb983 | 2010-05-11 14:02:00 -0700 | [diff] [blame] | 16 | |
| 17 | #include "../../../../../frameworks/base/libs/rs/scriptc/rs_types.rsh" |
| 18 | #include "../../../../../frameworks/base/libs/rs/scriptc/rs_math.rsh" |
| 19 | #include "../../../../../frameworks/base/libs/rs/scriptc/rs_graphics.rsh" |
| 20 | //#pragma stateVertex(PVOrtho) |
| 21 | //#pragma stateStore(PSSolid) |
Mike Cleron | af45d44 | 2009-12-02 02:04:46 -0800 | [diff] [blame] | 22 | |
| 23 | #define MAX_PULSES 20 |
| 24 | #define MAX_EXTRAS 40 |
| 25 | #define PULSE_SIZE 14 // Size in pixels of a cell |
| 26 | #define HALF_PULSE_SIZE 7 |
Daniel Sandler | deadbf5 | 2009-12-03 11:28:35 -0500 | [diff] [blame] | 27 | #define GLOW_SIZE 64 // Size of the leading glow in pixels |
Jason Sams | 0cd5306 | 2009-12-08 15:46:00 -0800 | [diff] [blame] | 28 | #define HALF_GLOW_SIZE 32 |
Mike Cleron | af45d44 | 2009-12-02 02:04:46 -0800 | [diff] [blame] | 29 | #define SPEED 0.2f // (200 / 1000) Pixels per ms |
| 30 | #define SPEED_VARIANCE 0.3f |
| 31 | #define PULSE_NORMAL 0 |
| 32 | #define PULSE_EXTRA 1 |
| 33 | #define TRAIL_SIZE 40 // Number of cells in a trail |
| 34 | #define MAX_DELAY 2000 // Delay between a pulse going offscreen and restarting |
| 35 | |
Jason Sams | 8aeb983 | 2010-05-11 14:02:00 -0700 | [diff] [blame] | 36 | typedef struct pulse_s { |
Mike Cleron | af45d44 | 2009-12-02 02:04:46 -0800 | [diff] [blame] | 37 | int pulseType; |
| 38 | float originX; |
| 39 | float originY; |
| 40 | int color; |
| 41 | int startTime; |
| 42 | float dx; |
| 43 | float dy; |
| 44 | int active; |
Jason Sams | 8aeb983 | 2010-05-11 14:02:00 -0700 | [diff] [blame] | 45 | } pulse_t; |
Mike Cleron | af45d44 | 2009-12-02 02:04:46 -0800 | [diff] [blame] | 46 | |
Jason Sams | 8aeb983 | 2010-05-11 14:02:00 -0700 | [diff] [blame] | 47 | static pulse_t gPulses[MAX_PULSES]; |
| 48 | static pulse_t gExtras[MAX_EXTRAS]; |
| 49 | static int gNow; |
| 50 | static int gWidth; |
| 51 | static int gHeight; |
| 52 | static int gRotate; |
Mike Cleron | af45d44 | 2009-12-02 02:04:46 -0800 | [diff] [blame] | 53 | |
Jason Sams | 8aeb983 | 2010-05-11 14:02:00 -0700 | [diff] [blame] | 54 | |
| 55 | int gIsPreview; |
| 56 | float gXOffset; |
| 57 | int gMode; |
| 58 | |
| 59 | rs_program_fragment gPFTexture; |
| 60 | rs_program_store gPSBlend; |
| 61 | rs_program_fragment gPFTexture565; |
| 62 | rs_program_vertex gPVOrtho; |
| 63 | |
| 64 | rs_allocation gTBackground; |
| 65 | rs_allocation gTPulse; |
| 66 | rs_allocation gTGlow; |
| 67 | |
| 68 | #pragma rs export_var(gIsPreview, gXOffset, gMode, gPFTexture, gPSBlend, gPFTexture565, gPVOrtho, gTBackground, gTPulse, gTGlow) |
Mike Cleron | af45d44 | 2009-12-02 02:04:46 -0800 | [diff] [blame] | 69 | |
| 70 | |
| 71 | void setColor(int c) { |
Jason Sams | 8aeb983 | 2010-05-11 14:02:00 -0700 | [diff] [blame] | 72 | //debugPi(99, 6); |
| 73 | if (gMode == 1) { |
Jason Sams | 6a500a1 | 2009-12-10 17:32:28 -0800 | [diff] [blame] | 74 | // sholes red |
| 75 | color(0.9f, 0.1f, 0.1f, 0.8f); |
| 76 | } else if (c == 0) { |
Mike Cleron | af45d44 | 2009-12-02 02:04:46 -0800 | [diff] [blame] | 77 | // red |
Jason Sams | 6a500a1 | 2009-12-10 17:32:28 -0800 | [diff] [blame] | 78 | color(1.0f, 0.0f, 0.0f, 0.8f); |
Mike Cleron | af45d44 | 2009-12-02 02:04:46 -0800 | [diff] [blame] | 79 | } else if (c == 1) { |
| 80 | // green |
Jason Sams | 6a500a1 | 2009-12-10 17:32:28 -0800 | [diff] [blame] | 81 | color(0.0f, 0.8f, 0.0f, 0.8f); |
Mike Cleron | af45d44 | 2009-12-02 02:04:46 -0800 | [diff] [blame] | 82 | } else if (c == 2) { |
| 83 | // blue |
Jason Sams | 6a500a1 | 2009-12-10 17:32:28 -0800 | [diff] [blame] | 84 | color(0.0f, 0.4f, 0.9f, 0.8f); |
Mike Cleron | af45d44 | 2009-12-02 02:04:46 -0800 | [diff] [blame] | 85 | } else if (c == 3) { |
| 86 | // yellow |
Jason Sams | 6a500a1 | 2009-12-10 17:32:28 -0800 | [diff] [blame] | 87 | color(1.0f, 0.8f, 0.0f, 0.8f); |
Mike Cleron | af45d44 | 2009-12-02 02:04:46 -0800 | [diff] [blame] | 88 | } |
| 89 | } |
| 90 | |
| 91 | void initPulse(struct pulse_s * pulse, int pulseType) { |
Jason Sams | 8aeb983 | 2010-05-11 14:02:00 -0700 | [diff] [blame] | 92 | //debugPi(99, 5); |
| 93 | if (randf(1.f) > 0.5f) { |
| 94 | pulse->originX = (int)randf(getWidth() * 2 / PULSE_SIZE) * PULSE_SIZE; |
Mike Cleron | af45d44 | 2009-12-02 02:04:46 -0800 | [diff] [blame] | 95 | pulse->dx = 0; |
Jason Sams | 8aeb983 | 2010-05-11 14:02:00 -0700 | [diff] [blame] | 96 | if (randf(1.f) > 0.5f) { |
Mike Cleron | af45d44 | 2009-12-02 02:04:46 -0800 | [diff] [blame] | 97 | // Top |
| 98 | pulse->originY = 0; |
| 99 | pulse->dy = randf2(1.0f - SPEED_VARIANCE, 1.0 + SPEED_VARIANCE); |
| 100 | } else { |
| 101 | // Bottom |
Jason Sams | 8aeb983 | 2010-05-11 14:02:00 -0700 | [diff] [blame] | 102 | pulse->originY = gHeight; |
Mike Cleron | af45d44 | 2009-12-02 02:04:46 -0800 | [diff] [blame] | 103 | pulse->dy = -randf2(1.0f - SPEED_VARIANCE, 1.0 + SPEED_VARIANCE); |
| 104 | } |
| 105 | } else { |
Jason Sams | 8aeb983 | 2010-05-11 14:02:00 -0700 | [diff] [blame] | 106 | pulse->originY = (int)randf(getHeight() / PULSE_SIZE) * PULSE_SIZE; |
Mike Cleron | af45d44 | 2009-12-02 02:04:46 -0800 | [diff] [blame] | 107 | pulse->dy = 0; |
Jason Sams | 8aeb983 | 2010-05-11 14:02:00 -0700 | [diff] [blame] | 108 | if (randf(1.f) > 0.5f) { |
Mike Cleron | af45d44 | 2009-12-02 02:04:46 -0800 | [diff] [blame] | 109 | // Left |
| 110 | pulse->originX = 0; |
| 111 | pulse->dx = randf2(1.0f - SPEED_VARIANCE, 1.0 + SPEED_VARIANCE); |
| 112 | } else { |
| 113 | // Right |
Jason Sams | 8aeb983 | 2010-05-11 14:02:00 -0700 | [diff] [blame] | 114 | pulse->originX = getWidth() * 2; |
Mike Cleron | af45d44 | 2009-12-02 02:04:46 -0800 | [diff] [blame] | 115 | pulse->dx = -randf2(1.0f - SPEED_VARIANCE, 1.0 + SPEED_VARIANCE); |
| 116 | } |
| 117 | } |
| 118 | pulse->startTime = gNow + (int)randf(MAX_DELAY); |
Jason Sams | 0cd5306 | 2009-12-08 15:46:00 -0800 | [diff] [blame] | 119 | |
Mike Cleron | af45d44 | 2009-12-02 02:04:46 -0800 | [diff] [blame] | 120 | pulse->color = (int)randf(4.0f); |
Jason Sams | 0cd5306 | 2009-12-08 15:46:00 -0800 | [diff] [blame] | 121 | |
Mike Cleron | af45d44 | 2009-12-02 02:04:46 -0800 | [diff] [blame] | 122 | pulse->pulseType = pulseType; |
| 123 | if (pulseType == PULSE_EXTRA) { |
| 124 | pulse->active = 0; |
| 125 | } else { |
| 126 | pulse->active = 1; |
| 127 | } |
| 128 | } |
| 129 | |
| 130 | void initPulses() { |
Jason Sams | 8aeb983 | 2010-05-11 14:02:00 -0700 | [diff] [blame] | 131 | //debugPi(99, 4); |
Mike Cleron | af45d44 | 2009-12-02 02:04:46 -0800 | [diff] [blame] | 132 | gNow = uptimeMillis(); |
| 133 | int i; |
| 134 | for (i=0; i<MAX_PULSES; i++) { |
| 135 | initPulse(&gPulses[i], PULSE_NORMAL); |
| 136 | } |
| 137 | for (i=0; i<MAX_EXTRAS; i++) { |
| 138 | struct pulse_s * p = &gExtras[i]; |
| 139 | p->pulseType = PULSE_EXTRA; |
| 140 | p->active = 0; |
| 141 | } |
| 142 | } |
| 143 | |
Jason Sams | 8aeb983 | 2010-05-11 14:02:00 -0700 | [diff] [blame] | 144 | void drawBackground() { |
| 145 | //debugPi(99, 3); |
| 146 | bindProgramFragment(gPFTexture565); |
| 147 | bindTexture(gPFTexture565, 0, gTBackground); |
Mike Cleron | af45d44 | 2009-12-02 02:04:46 -0800 | [diff] [blame] | 148 | color(1.0f, 1.0f, 1.0f, 1.0f); |
Jason Sams | 8aeb983 | 2010-05-11 14:02:00 -0700 | [diff] [blame] | 149 | if (gRotate) { |
| 150 | drawRect(0.0f, 0.0f, gHeight*2, gWidth, 0.0f); |
Mike Cleron | af45d44 | 2009-12-02 02:04:46 -0800 | [diff] [blame] | 151 | } else { |
Jason Sams | 8aeb983 | 2010-05-11 14:02:00 -0700 | [diff] [blame] | 152 | drawRect(0.0f, 0.0f, gWidth*2, gHeight, 0.0f); |
| 153 | } |
Mike Cleron | af45d44 | 2009-12-02 02:04:46 -0800 | [diff] [blame] | 154 | } |
| 155 | |
Jason Sams | 8aeb983 | 2010-05-11 14:02:00 -0700 | [diff] [blame] | 156 | void drawPulses(pulse_t * pulseSet, int setSize) { |
| 157 | //debugPi(99, 2); |
| 158 | bindProgramFragment(gPFTexture); |
| 159 | bindProgramFragmentStore(gPSBlend); |
Mike Cleron | af45d44 | 2009-12-02 02:04:46 -0800 | [diff] [blame] | 160 | |
| 161 | float matrix[16]; |
Jason Sams | 0cd5306 | 2009-12-08 15:46:00 -0800 | [diff] [blame] | 162 | |
Mike Cleron | af45d44 | 2009-12-02 02:04:46 -0800 | [diff] [blame] | 163 | int i; |
| 164 | for (i=0; i<setSize; i++) { |
| 165 | struct pulse_s * p = &pulseSet[i]; |
Jason Sams | 0cd5306 | 2009-12-08 15:46:00 -0800 | [diff] [blame] | 166 | |
Mike Cleron | af45d44 | 2009-12-02 02:04:46 -0800 | [diff] [blame] | 167 | int delta = gNow - p->startTime; |
Jason Sams | 0cd5306 | 2009-12-08 15:46:00 -0800 | [diff] [blame] | 168 | |
Mike Cleron | af45d44 | 2009-12-02 02:04:46 -0800 | [diff] [blame] | 169 | if (p->active != 0 && delta >= 0) { |
Jason Sams | 0cd5306 | 2009-12-08 15:46:00 -0800 | [diff] [blame] | 170 | |
Mike Cleron | af45d44 | 2009-12-02 02:04:46 -0800 | [diff] [blame] | 171 | float x = p->originX + (p->dx * SPEED * delta); |
| 172 | float y = p->originY + (p->dy * SPEED * delta); |
Jason Sams | 0cd5306 | 2009-12-08 15:46:00 -0800 | [diff] [blame] | 173 | |
Mike Cleron | af45d44 | 2009-12-02 02:04:46 -0800 | [diff] [blame] | 174 | matrixLoadIdentity(matrix); |
| 175 | if (p->dx < 0) { |
| 176 | vpLoadTextureMatrix(matrix); |
| 177 | float xx = x + (TRAIL_SIZE * PULSE_SIZE); |
| 178 | if (xx <= 0) { |
| 179 | initPulse(p, p->pulseType); |
| 180 | } else { |
| 181 | setColor(p->color); |
Jason Sams | 8aeb983 | 2010-05-11 14:02:00 -0700 | [diff] [blame] | 182 | bindTexture(gPFTexture, 0, gTPulse); |
Mike Cleron | af45d44 | 2009-12-02 02:04:46 -0800 | [diff] [blame] | 183 | drawRect(x, y, xx, y + PULSE_SIZE, 0.0f); |
Jason Sams | 8aeb983 | 2010-05-11 14:02:00 -0700 | [diff] [blame] | 184 | bindTexture(gPFTexture, 0, gTGlow); |
Mike Cleron | af45d44 | 2009-12-02 02:04:46 -0800 | [diff] [blame] | 185 | drawRect(x + HALF_PULSE_SIZE - HALF_GLOW_SIZE, |
| 186 | y + HALF_PULSE_SIZE - HALF_GLOW_SIZE, |
Jason Sams | 0cd5306 | 2009-12-08 15:46:00 -0800 | [diff] [blame] | 187 | x + HALF_PULSE_SIZE + HALF_GLOW_SIZE, |
Mike Cleron | af45d44 | 2009-12-02 02:04:46 -0800 | [diff] [blame] | 188 | y + HALF_PULSE_SIZE + HALF_GLOW_SIZE, |
| 189 | 0.0f); |
| 190 | } |
| 191 | } else if (p->dx > 0) { |
Daniel Sandler | deadbf5 | 2009-12-03 11:28:35 -0500 | [diff] [blame] | 192 | x += PULSE_SIZE; // need to start on the other side of this cell |
Mike Cleron | af45d44 | 2009-12-02 02:04:46 -0800 | [diff] [blame] | 193 | matrixRotate(matrix, 180.0f, 0.0f, 0.0f, 1.0f); |
| 194 | vpLoadTextureMatrix(matrix); |
| 195 | float xx = x - (TRAIL_SIZE * PULSE_SIZE); |
Jason Sams | 8aeb983 | 2010-05-11 14:02:00 -0700 | [diff] [blame] | 196 | if (xx >= gWidth * 2) { |
Mike Cleron | af45d44 | 2009-12-02 02:04:46 -0800 | [diff] [blame] | 197 | initPulse(p, p->pulseType); |
| 198 | } else { |
| 199 | setColor(p->color); |
Jason Sams | 8aeb983 | 2010-05-11 14:02:00 -0700 | [diff] [blame] | 200 | bindTexture(gPFTexture, 0, gTPulse); |
Mike Cleron | af45d44 | 2009-12-02 02:04:46 -0800 | [diff] [blame] | 201 | drawRect(xx, y, x, y + PULSE_SIZE, 0.0f); |
Jason Sams | 8aeb983 | 2010-05-11 14:02:00 -0700 | [diff] [blame] | 202 | bindTexture(gPFTexture, 0, gTGlow); |
Mike Cleron | af45d44 | 2009-12-02 02:04:46 -0800 | [diff] [blame] | 203 | drawRect(x - HALF_PULSE_SIZE - HALF_GLOW_SIZE, |
| 204 | y + HALF_PULSE_SIZE - HALF_GLOW_SIZE, |
Jason Sams | 0cd5306 | 2009-12-08 15:46:00 -0800 | [diff] [blame] | 205 | x - HALF_PULSE_SIZE + HALF_GLOW_SIZE, |
Mike Cleron | af45d44 | 2009-12-02 02:04:46 -0800 | [diff] [blame] | 206 | y + HALF_PULSE_SIZE + HALF_GLOW_SIZE, |
| 207 | 0.0f); |
| 208 | } |
| 209 | } else if (p->dy < 0) { |
| 210 | matrixRotate(matrix, -90.0f, 0.0f, 0.0f, 1.0f); |
| 211 | vpLoadTextureMatrix(matrix); |
| 212 | float yy = y + (TRAIL_SIZE * PULSE_SIZE); |
| 213 | if (yy <= 0) { |
| 214 | initPulse(p, p->pulseType); |
| 215 | } else { |
| 216 | setColor(p->color); |
Jason Sams | 8aeb983 | 2010-05-11 14:02:00 -0700 | [diff] [blame] | 217 | bindTexture(gPFTexture, 0, gTPulse); |
Mike Cleron | af45d44 | 2009-12-02 02:04:46 -0800 | [diff] [blame] | 218 | drawRect(x, y, x + PULSE_SIZE, yy, 0.0f); |
Jason Sams | 8aeb983 | 2010-05-11 14:02:00 -0700 | [diff] [blame] | 219 | bindTexture(gPFTexture, 0, gTGlow); |
Mike Cleron | af45d44 | 2009-12-02 02:04:46 -0800 | [diff] [blame] | 220 | drawRect(x + HALF_PULSE_SIZE - HALF_GLOW_SIZE, |
| 221 | y + HALF_PULSE_SIZE - HALF_GLOW_SIZE, |
Jason Sams | 0cd5306 | 2009-12-08 15:46:00 -0800 | [diff] [blame] | 222 | x + HALF_PULSE_SIZE + HALF_GLOW_SIZE, |
Mike Cleron | af45d44 | 2009-12-02 02:04:46 -0800 | [diff] [blame] | 223 | y + HALF_PULSE_SIZE + HALF_GLOW_SIZE, |
| 224 | 0.0f); |
| 225 | } |
| 226 | } else if (p->dy > 0) { |
Daniel Sandler | deadbf5 | 2009-12-03 11:28:35 -0500 | [diff] [blame] | 227 | y += PULSE_SIZE; // need to start on the other side of this cell |
Mike Cleron | af45d44 | 2009-12-02 02:04:46 -0800 | [diff] [blame] | 228 | matrixRotate(matrix, 90.0f, 0.0f, 0.0f, 1.0f); |
| 229 | vpLoadTextureMatrix(matrix); |
| 230 | float yy = y - (TRAIL_SIZE * PULSE_SIZE); |
Jason Sams | 8aeb983 | 2010-05-11 14:02:00 -0700 | [diff] [blame] | 231 | if (yy >= gHeight) { |
Mike Cleron | af45d44 | 2009-12-02 02:04:46 -0800 | [diff] [blame] | 232 | initPulse(p, p->pulseType); |
| 233 | } else { |
| 234 | setColor(p->color); |
Jason Sams | 8aeb983 | 2010-05-11 14:02:00 -0700 | [diff] [blame] | 235 | bindTexture(gPFTexture, 0, gTPulse); |
Mike Cleron | af45d44 | 2009-12-02 02:04:46 -0800 | [diff] [blame] | 236 | drawRect(x, yy, x + PULSE_SIZE, y, 0.0f); |
Jason Sams | 8aeb983 | 2010-05-11 14:02:00 -0700 | [diff] [blame] | 237 | bindTexture(gPFTexture, 0, gTGlow); |
Mike Cleron | af45d44 | 2009-12-02 02:04:46 -0800 | [diff] [blame] | 238 | drawRect(x + HALF_PULSE_SIZE - HALF_GLOW_SIZE, |
| 239 | y - HALF_PULSE_SIZE - HALF_GLOW_SIZE, |
Jason Sams | 0cd5306 | 2009-12-08 15:46:00 -0800 | [diff] [blame] | 240 | x + HALF_PULSE_SIZE + HALF_GLOW_SIZE, |
Mike Cleron | af45d44 | 2009-12-02 02:04:46 -0800 | [diff] [blame] | 241 | y - HALF_PULSE_SIZE + HALF_GLOW_SIZE, |
| 242 | 0.0f); |
| 243 | } |
| 244 | } |
| 245 | } |
| 246 | } |
Jason Sams | 0cd5306 | 2009-12-08 15:46:00 -0800 | [diff] [blame] | 247 | |
Mike Cleron | af45d44 | 2009-12-02 02:04:46 -0800 | [diff] [blame] | 248 | matrixLoadIdentity(matrix); |
| 249 | vpLoadTextureMatrix(matrix); |
| 250 | } |
| 251 | |
| 252 | void addTap(int x, int y) { |
Jason Sams | 8aeb983 | 2010-05-11 14:02:00 -0700 | [diff] [blame] | 253 | //debugPi(99, 1); |
Mike Cleron | af45d44 | 2009-12-02 02:04:46 -0800 | [diff] [blame] | 254 | int i; |
| 255 | int count = 0; |
| 256 | int color = (int)randf(4.0f); |
| 257 | x = (int)(x / PULSE_SIZE) * PULSE_SIZE; |
Jason Sams | 0cd5306 | 2009-12-08 15:46:00 -0800 | [diff] [blame] | 258 | y = (int)(y / PULSE_SIZE) * PULSE_SIZE; |
Mike Cleron | af45d44 | 2009-12-02 02:04:46 -0800 | [diff] [blame] | 259 | for (i=0; i<MAX_EXTRAS; i++) { |
| 260 | struct pulse_s * p = &gExtras[i]; |
| 261 | if (p->active == 0) { |
| 262 | p->originX = x; |
| 263 | p->originY = y; |
Jason Sams | 0cd5306 | 2009-12-08 15:46:00 -0800 | [diff] [blame] | 264 | |
| 265 | if (count == 0) { |
Mike Cleron | af45d44 | 2009-12-02 02:04:46 -0800 | [diff] [blame] | 266 | p->dx = 1.5f; |
| 267 | p->dy = 0.0f; |
| 268 | } else if (count == 1) { |
| 269 | p->dx = -1.5f; |
| 270 | p->dy = 0.0f; |
| 271 | } else if (count == 2) { |
| 272 | p->dx = 0.0f; |
| 273 | p->dy = 1.5f; |
| 274 | } else if (count == 3) { |
| 275 | p->dx = 0.0f; |
| 276 | p->dy = -1.5f; |
| 277 | } |
Jason Sams | 0cd5306 | 2009-12-08 15:46:00 -0800 | [diff] [blame] | 278 | |
Mike Cleron | af45d44 | 2009-12-02 02:04:46 -0800 | [diff] [blame] | 279 | p->active = 1; |
| 280 | p->color = color; |
| 281 | color++; |
| 282 | if (color >= 4) { |
| 283 | color = 0; |
| 284 | } |
| 285 | p->startTime = gNow; |
| 286 | count++; |
| 287 | if (count == 4) { |
| 288 | break; |
| 289 | } |
| 290 | } |
| 291 | } |
| 292 | } |
| 293 | |
Jason Sams | 8aeb983 | 2010-05-11 14:02:00 -0700 | [diff] [blame] | 294 | int root() { |
| 295 | //debugPi(99, 0); |
| 296 | gWidth = getWidth(); |
| 297 | gHeight = getHeight(); |
| 298 | gRotate = gWidth > gHeight ? 1 : 0; |
Mike Cleron | af45d44 | 2009-12-02 02:04:46 -0800 | [diff] [blame] | 299 | |
| 300 | gNow = uptimeMillis(); |
Jason Sams | 0cd5306 | 2009-12-08 15:46:00 -0800 | [diff] [blame] | 301 | |
Jason Sams | 8aeb983 | 2010-05-11 14:02:00 -0700 | [diff] [blame] | 302 | bindProgramVertex(gPVOrtho); |
Jason Sams | 0cd5306 | 2009-12-08 15:46:00 -0800 | [diff] [blame] | 303 | |
Mike Cleron | af45d44 | 2009-12-02 02:04:46 -0800 | [diff] [blame] | 304 | float matrix[16]; |
| 305 | matrixLoadIdentity(matrix); |
Jason Sams | 8aeb983 | 2010-05-11 14:02:00 -0700 | [diff] [blame] | 306 | if (gRotate) { |
Mike Cleron | af45d44 | 2009-12-02 02:04:46 -0800 | [diff] [blame] | 307 | //matrixLoadRotate(matrix, 90.0f, 0.0f, 0.0f, 1.0f); |
| 308 | //matrixTranslate(matrix, 0.0f, -height, 1.0f); |
Daniel Sandler | 12290bd | 2010-02-19 15:43:28 -0500 | [diff] [blame] | 309 | // XXX: HAX: do not slide display in landscape |
Mike Cleron | af45d44 | 2009-12-02 02:04:46 -0800 | [diff] [blame] | 310 | } else { |
Jason Sams | 8aeb983 | 2010-05-11 14:02:00 -0700 | [diff] [blame] | 311 | matrixTranslate(matrix, -(gXOffset * gWidth), 0, 0); |
Mike Cleron | af45d44 | 2009-12-02 02:04:46 -0800 | [diff] [blame] | 312 | } |
Jason Sams | 0cd5306 | 2009-12-08 15:46:00 -0800 | [diff] [blame] | 313 | |
Mike Cleron | af45d44 | 2009-12-02 02:04:46 -0800 | [diff] [blame] | 314 | vpLoadModelMatrix(matrix); |
Jason Sams | 0cd5306 | 2009-12-08 15:46:00 -0800 | [diff] [blame] | 315 | |
Jason Sams | 8aeb983 | 2010-05-11 14:02:00 -0700 | [diff] [blame] | 316 | drawBackground(); |
Mike Cleron | af45d44 | 2009-12-02 02:04:46 -0800 | [diff] [blame] | 317 | drawPulses(gPulses, MAX_PULSES); |
| 318 | drawPulses(gExtras, MAX_EXTRAS); |
Jason Sams | 0cd5306 | 2009-12-08 15:46:00 -0800 | [diff] [blame] | 319 | |
| 320 | return 45; |
Mike Cleron | af45d44 | 2009-12-02 02:04:46 -0800 | [diff] [blame] | 321 | } |