blob: 6f0046e96ecd2afb688ed6f5436330da9a35160d [file] [log] [blame]
Jason Sams0f505e52009-10-13 17:18:35 -07001#pragma version(1)
2#pragma stateVertex(PV)
Jason Samsc8514792009-10-29 14:27:29 -07003#pragma stateFragment(PFTexNearest)
Jason Sams0f505e52009-10-13 17:18:35 -07004#pragma stateStore(PSIcons)
5
6#define PI 3.14159f
7
Jason Sams41b61c82009-10-15 15:40:54 -07008int g_SpecialHWWar;
Jason Sams0f505e52009-10-13 17:18:35 -07009
10// Attraction to center values from page edge to page center.
11float g_AttractionTable[9];
Jason Sams2e19c052009-10-20 18:19:55 -070012float g_FrictionTable[9];
Jason Sams0f505e52009-10-13 17:18:35 -070013float g_PhysicsTableSize;
14
15float g_PosPage;
16float g_PosVelocity;
17float g_LastPositionX;
18int g_LastTouchDown;
19float g_DT;
20int g_LastTime;
21int g_PosMax;
22float g_Zoom;
23float g_OldPosPage;
24float g_OldPosVelocity;
25float g_OldZoom;
Jason Samsc1c521e2009-10-19 14:45:45 -070026float g_MoveToTotalTime;
27float g_MoveToTime;
28float g_MoveToOldPos;
29
Jason Sams0f505e52009-10-13 17:18:35 -070030
31// Drawing constants, should be parameters ======
32#define VIEW_ANGLE 1.28700222f
33
34int g_DrawLastFrame;
35int lastFrame(int draw) {
36 // We draw one extra frame to work around the last frame post bug.
37 // We also need to track if we drew the last frame to deal with large DT
38 // in the physics.
39 int ret = g_DrawLastFrame | draw;
40 g_DrawLastFrame = draw;
41 return ret; // should return draw instead.
42}
43
44void updateReadback() {
45 if ((g_OldPosPage != g_PosPage) ||
46 (g_OldPosVelocity != g_PosVelocity) ||
47 (g_OldZoom != g_Zoom)) {
48
49 g_OldPosPage = g_PosPage;
50 g_OldPosVelocity = g_PosVelocity;
51 g_OldZoom = g_Zoom;
52
53 int i[3];
54 i[0] = g_PosPage * (1 << 16);
55 i[1] = g_PosVelocity * (1 << 16);
56 i[2] = g_OldZoom * (1 << 16);
57 sendToClient(&i[0], 1, 12, 1);
58 }
59}
60
Jason Sams41b61c82009-10-15 15:40:54 -070061void setColor(float r, float g, float b, float a) {
62 if (g_SpecialHWWar) {
63 color(0, 0, 0, 0.001f);
64 } else {
65 color(r, g, b, a);
66 }
67}
Jason Sams0f505e52009-10-13 17:18:35 -070068
69void init() {
Jason Sams2e19c052009-10-20 18:19:55 -070070 g_AttractionTable[0] = 20.0f;
71 g_AttractionTable[1] = 20.0f;
Jason Samsc8514792009-10-29 14:27:29 -070072 g_AttractionTable[2] = 20.0f;
Jason Sams2e19c052009-10-20 18:19:55 -070073 g_AttractionTable[3] = 10.0f;
74 g_AttractionTable[4] = -10.0f;
Jason Samsc8514792009-10-29 14:27:29 -070075 g_AttractionTable[5] = -20.0f;
76 g_AttractionTable[6] = -20.0f;
Jason Sams2e19c052009-10-20 18:19:55 -070077 g_AttractionTable[7] = -20.0f;
78 g_AttractionTable[8] = -20.0f; // dup 7 to avoid a clamp later
79 g_FrictionTable[0] = 10.0f;
80 g_FrictionTable[1] = 10.0f;
81 g_FrictionTable[2] = 11.0f;
82 g_FrictionTable[3] = 15.0f;
83 g_FrictionTable[4] = 15.0f;
84 g_FrictionTable[5] = 11.0f;
85 g_FrictionTable[6] = 10.0f;
86 g_FrictionTable[7] = 10.0f;
87 g_FrictionTable[8] = 10.0f; // dup 7 to avoid a clamp later
Jason Sams0f505e52009-10-13 17:18:35 -070088 g_PhysicsTableSize = 7;
89
90 g_PosVelocity = 0;
91 g_PosPage = 0;
92 g_LastTouchDown = 0;
93 g_LastPositionX = 0;
94 g_Zoom = 0;
Jason Sams41b61c82009-10-15 15:40:54 -070095 g_SpecialHWWar = 1;
Jason Samsc1c521e2009-10-19 14:45:45 -070096 g_MoveToTime = 0;
97 g_MoveToOldPos = 0;
Mike Cleron7d5d7462009-10-20 14:06:00 -070098 g_MoveToTotalTime = 0.2f; // Duration of scrolling 1 line
Jason Sams41b61c82009-10-15 15:40:54 -070099}
100
101void resetHWWar() {
102 g_SpecialHWWar = 1;
Jason Sams0f505e52009-10-13 17:18:35 -0700103}
104
105void move() {
106 if (g_LastTouchDown) {
107 float dx = -(state->newPositionX - g_LastPositionX);
108 g_PosVelocity = 0;
109 g_PosPage += dx * 4;
110
Jason Samsc8514792009-10-29 14:27:29 -0700111 float pmin = -0.49f;
112 float pmax = g_PosMax + 0.49f;
Jason Sams0f505e52009-10-13 17:18:35 -0700113 g_PosPage = clampf(g_PosPage, pmin, pmax);
114 }
115 g_LastTouchDown = state->newTouchDown;
116 g_LastPositionX = state->newPositionX;
Jason Samsc1c521e2009-10-19 14:45:45 -0700117 g_MoveToTime = 0;
Jason Sams0f505e52009-10-13 17:18:35 -0700118 //debugF("Move P", g_PosPage);
119}
120
Jason Samsc1c521e2009-10-19 14:45:45 -0700121void moveTo() {
122 g_MoveToTime = g_MoveToTotalTime;
123 g_PosVelocity = 0;
124 g_MoveToOldPos = g_PosPage;
Jason Sams2e19c052009-10-20 18:19:55 -0700125
Mike Cleron7d5d7462009-10-20 14:06:00 -0700126 // debugF("======= moveTo", state->targetPos);
Jason Samsc1c521e2009-10-19 14:45:45 -0700127}
128
Joe Onorato3a8820b2009-11-10 15:06:42 -0800129void setZoom() {
130 g_Zoom = state->zoomTarget;
131 g_DrawLastFrame = 1;
132 updateReadback();
133}
134
Jason Sams0f505e52009-10-13 17:18:35 -0700135void fling() {
136 g_LastTouchDown = 0;
Jason Sams37e7c2b2009-10-19 12:55:43 -0700137 g_PosVelocity = -state->flingVelocity * 4;
Jason Sams0f505e52009-10-13 17:18:35 -0700138 float av = fabsf(g_PosVelocity);
139 float minVel = 3.5f;
140
141 minVel *= 1.f - (fabsf(fracf(g_PosPage + 0.5f) - 0.5f) * 0.45f);
142
143 if (av < minVel && av > 0.2f) {
144 if (g_PosVelocity > 0) {
145 g_PosVelocity = minVel;
146 } else {
147 g_PosVelocity = -minVel;
148 }
149 }
150
151 if (g_PosPage <= 0) {
152 g_PosVelocity = maxf(0, g_PosVelocity);
153 }
154 if (g_PosPage > g_PosMax) {
155 g_PosVelocity = minf(0, g_PosVelocity);
156 }
157}
158
Jason Sams0f505e52009-10-13 17:18:35 -0700159float
160modf(float x, float y)
161{
162 return x-(y*floorf(x/y));
163}
164
Mike Cleron7d5d7462009-10-20 14:06:00 -0700165
166/*
167 * Interpolates values in the range 0..1 to a curve that eases in
168 * and out.
169 */
170float
171getInterpolation(float input) {
172 return (cosf((input + 1) * PI) / 2.0f) + 0.5f;
173}
174
175
Jason Sams0f505e52009-10-13 17:18:35 -0700176void updatePos() {
177 if (g_LastTouchDown) {
178 return;
179 }
180
Jason Sams0f505e52009-10-13 17:18:35 -0700181 float tablePosNorm = fracf(g_PosPage + 0.5f);
182 float tablePosF = tablePosNorm * g_PhysicsTableSize;
183 int tablePosI = tablePosF;
184 float tablePosFrac = tablePosF - tablePosI;
185 float accel = lerpf(g_AttractionTable[tablePosI],
186 g_AttractionTable[tablePosI + 1],
187 tablePosFrac) * g_DT;
Jason Sams2e19c052009-10-20 18:19:55 -0700188 float friction = lerpf(g_FrictionTable[tablePosI],
189 g_FrictionTable[tablePosI + 1],
190 tablePosFrac) * g_DT;
Jason Sams0f505e52009-10-13 17:18:35 -0700191
Jason Samsc1c521e2009-10-19 14:45:45 -0700192 if (g_MoveToTime) {
Jason Samsc8514792009-10-29 14:27:29 -0700193 // New position is old posiition + (total distance) * (interpolated time)
194 g_PosPage = g_MoveToOldPos + (state->targetPos - g_MoveToOldPos) * getInterpolation((g_MoveToTotalTime - g_MoveToTime) / g_MoveToTotalTime);
Jason Samsc1c521e2009-10-19 14:45:45 -0700195 g_MoveToTime -= g_DT;
196 if (g_MoveToTime <= 0) {
197 g_MoveToTime = 0;
198 g_PosPage = state->targetPos;
199 }
200 return;
201 }
202
Jason Sams0f505e52009-10-13 17:18:35 -0700203 // If our velocity is low OR acceleration is opposing it, apply it.
Jason Samsc8514792009-10-29 14:27:29 -0700204 if (fabsf(g_PosVelocity) < 4.0f || (g_PosVelocity * accel) < 0) {
Jason Sams0f505e52009-10-13 17:18:35 -0700205 g_PosVelocity += accel;
206 }
Jason Samsc8514792009-10-29 14:27:29 -0700207 //debugF("g_PosPage", g_PosPage);
208 //debugF(" g_PosVelocity", g_PosVelocity);
209 //debugF(" friction", friction);
210 //debugF(" accel", accel);
Jason Sams0f505e52009-10-13 17:18:35 -0700211
Jason Samsc8514792009-10-29 14:27:29 -0700212 // Normal physics
213 if (g_PosVelocity > 0) {
214 g_PosVelocity -= friction;
215 g_PosVelocity = maxf(g_PosVelocity, 0);
216 } else {
217 g_PosVelocity += friction;
218 g_PosVelocity = minf(g_PosVelocity, 0);
219 }
220
221 if ((friction > fabsf(g_PosVelocity)) && (friction > fabsf(accel))) {
Jason Sams0f505e52009-10-13 17:18:35 -0700222 // Special get back to center and overcome friction physics.
223 float t = tablePosNorm - 0.5f;
224 if (fabsf(t) < (friction * g_DT)) {
225 // really close, just snap
226 g_PosPage = roundf(g_PosPage);
227 g_PosVelocity = 0;
228 } else {
229 if (t > 0) {
230 g_PosVelocity = -friction;
231 } else {
232 g_PosVelocity = friction;
233 }
234 }
Jason Sams0f505e52009-10-13 17:18:35 -0700235 }
Jason Sams0f505e52009-10-13 17:18:35 -0700236
237 // Check for out of boundry conditions.
238 if (g_PosPage < 0 && g_PosVelocity < 0) {
Jason Sams0f505e52009-10-13 17:18:35 -0700239 float damp = 1.0 + (g_PosPage * 4);
240 damp = clampf(damp, 0.f, 0.9f);
241 g_PosVelocity *= damp;
242 }
243 if (g_PosPage > g_PosMax && g_PosVelocity > 0) {
Jason Sams0f505e52009-10-13 17:18:35 -0700244 float damp = 1.0 - ((g_PosPage - g_PosMax) * 4);
245 damp = clampf(damp, 0.f, 0.9f);
246 g_PosVelocity *= damp;
247 }
Jason Samsc8514792009-10-29 14:27:29 -0700248
249 g_PosPage += g_PosVelocity * g_DT;
250 g_PosPage = clampf(g_PosPage, -0.49, g_PosMax + 0.49);
Jason Sams0f505e52009-10-13 17:18:35 -0700251}
252
Jason Samsc8514792009-10-29 14:27:29 -0700253int positionStrip(float row, float column, int isTop, float p, int isText)
Jason Sams0f505e52009-10-13 17:18:35 -0700254{
255 float mat1[16];
Jason Sams0f505e52009-10-13 17:18:35 -0700256 float x = 0.5f * (column - 1.5f);
Jason Sams0f505e52009-10-13 17:18:35 -0700257 float scale = 72.f * 3 / getWidth();
Jason Sams0f505e52009-10-13 17:18:35 -0700258
259 if (isTop) {
260 matrixLoadTranslate(mat1, x, 0.8f, 0.f);
261 matrixScale(mat1, scale, scale, 1.f);
262 } else {
263 matrixLoadTranslate(mat1, x, -0.9f, 0.f);
264 matrixScale(mat1, scale, -scale, 1.f);
265 }
Jason Sams461073b2009-10-20 12:06:28 -0700266 matrixTranslate(mat1, 0, p * 2, 0.f);
267 matrixRotate(mat1, -p * 50, 1, 0, 0);
Jason Sams0f505e52009-10-13 17:18:35 -0700268 vpLoadModelMatrix(mat1);
269
Jason Samsb52dfa02009-10-14 20:16:14 -0700270 float soff = -(row * 1.4);
Jason Sams0f505e52009-10-13 17:18:35 -0700271 if (isTop) {
272 matrixLoadScale(mat1, 1.f, -0.85f, 1.f);
Jason Samsc8514792009-10-29 14:27:29 -0700273 if (isText) {
274 matrixScale(mat1, 1.f, 2.f, 1.f);
275 }
Jason Samsb52dfa02009-10-14 20:16:14 -0700276 matrixTranslate(mat1, 0, soff - 0.97f, 0);
Jason Sams0f505e52009-10-13 17:18:35 -0700277 } else {
278 matrixLoadScale(mat1, 1.f, 0.85f, 1.f);
Jason Samsc8514792009-10-29 14:27:29 -0700279 if (isText) {
280 matrixScale(mat1, 1.f, 2.f, 1.f);
281 }
Jason Samsb52dfa02009-10-14 20:16:14 -0700282 matrixTranslate(mat1, 0, soff - 0.45f, 0);
Jason Sams0f505e52009-10-13 17:18:35 -0700283 }
284 vpLoadTextureMatrix(mat1);
Jason Samsb52dfa02009-10-14 20:16:14 -0700285 return -soff * 10.f;
Jason Sams0f505e52009-10-13 17:18:35 -0700286}
287
288void
289draw_home_button()
290{
Jason Sams41b61c82009-10-15 15:40:54 -0700291 setColor(1.0f, 1.0f, 1.0f, 1.0f);
Jason Samsc8514792009-10-29 14:27:29 -0700292 bindTexture(NAMED_PFTexNearest, 0, state->homeButtonId);
Jason Sams96b49d82009-10-20 14:28:53 -0700293 float x = (SCREEN_WIDTH_PX - params->homeButtonTextureWidth) / 2;
294 float y = (g_Zoom - 1.f) * params->homeButtonTextureHeight;
Jason Sams0f505e52009-10-13 17:18:35 -0700295
Jason Samsc8514792009-10-29 14:27:29 -0700296 y -= 30; // move the house to the edge of the screen as it doesn't fill the texture.
Jason Sams96b49d82009-10-20 14:28:53 -0700297 drawSpriteScreenspace(x, y, 0, params->homeButtonTextureWidth, params->homeButtonTextureHeight);
Jason Sams0f505e52009-10-13 17:18:35 -0700298}
299
Jason Sams09c6fc02009-10-16 17:23:23 -0700300void drawFrontGrid(float rowOffset, float p)
Jason Sams0f505e52009-10-13 17:18:35 -0700301{
302 float h = getHeight();
303 float w = getWidth();
304
305 int intRowOffset = rowOffset;
306 float rowFrac = rowOffset - intRowOffset;
307 float colWidth = getWidth() / 4;
308 float rowHeight = colWidth + 25.f;
309 float yoff = h - ((h - (rowHeight * 4.f)) / 2);
310
311 yoff -= 110;
312
313 int row, col;
314 int iconNum = intRowOffset * 4;
315 float ymax = yoff;
316 float ymin = yoff - (3 * rowHeight) - 70;
317
318 for (row = 0; row < 5; row++) {
319 float y = yoff - ((-rowFrac + row) * rowHeight);
320
321 for (col=0; col < 4; col++) {
322 if (iconNum >= state->iconCount) {
323 return;
324 }
325
326 if (iconNum >= 0) {
327 float x = colWidth * col - ((128 - colWidth) / 2);
328
329 if ((y >= ymin) && (y <= ymax)) {
Jason Sams41b61c82009-10-15 15:40:54 -0700330 setColor(1.f, 1.f, 1.f, 1.f);
Jason Sams09c6fc02009-10-16 17:23:23 -0700331 if (state->selectedIconIndex == iconNum && !p) {
Jason Samsc8514792009-10-29 14:27:29 -0700332 bindTexture(NAMED_PFTexNearest, 0, state->selectedIconTexture);
Joe Onorato742d7fc2009-10-15 19:48:16 -0700333 drawSpriteScreenspace(x, y, 0, 128, 128);
334 }
335
Jason Samsc8514792009-10-29 14:27:29 -0700336 bindTexture(NAMED_PFTexNearest, 0, loadI32(ALLOC_ICON_IDS, iconNum));
Jason Sams09c6fc02009-10-16 17:23:23 -0700337 if (!p) {
338 drawSpriteScreenspace(x, y, 0, 128, 128);
339 } else {
340 float px = ((x + 64) - (getWidth() / 2)) / (getWidth() / 2);
341 float py = ((y + 64) - (getHeight() / 2)) / (getWidth() / 2);
342 float d = 64.f / (getWidth() / 2);
343 px *= p + 1;
344 py *= p + 1;
345 drawQuadTexCoords(px - d, py - d, -p, 0, 1,
346 px - d, py + d, -p, 0, 0,
347 px + d, py + d, -p, 1, 0,
348 px + d, py - d, -p, 1, 1);
349 }
Jason Sams0f505e52009-10-13 17:18:35 -0700350 }
351
352 float y2 = y - 44;
Jason Samsc8514792009-10-29 14:27:29 -0700353 if ((y2 >= ymin) && (y2 <= ymax)) {
354 float a = maxf(0, 1.f - p * 5.f);
355 setColor(1.f, 1.f, 1.f, a);
356 bindTexture(NAMED_PFTexNearest, 0, loadI32(ALLOC_LABEL_IDS, iconNum));
357 drawSpriteScreenspace(x, y - 44, 0,
358 params->bubbleBitmapWidth, params->bubbleBitmapHeight);
Jason Sams0f505e52009-10-13 17:18:35 -0700359 }
Jason Sams0f505e52009-10-13 17:18:35 -0700360 }
361 iconNum++;
362 }
363 }
364}
365
Jason Sams09c6fc02009-10-16 17:23:23 -0700366void drawStrip(float row, float column, int isTop, int iconNum, float p)
Jason Samsb52dfa02009-10-14 20:16:14 -0700367{
368 if (iconNum < 0) return;
Jason Samsc8514792009-10-29 14:27:29 -0700369 int offset = positionStrip(row, column, isTop, p, 0);
370 bindTexture(NAMED_PFTexMip, 0, loadI32(ALLOC_ICON_IDS, iconNum));
Jason Samsb52dfa02009-10-14 20:16:14 -0700371 if (offset < -20) return;
372 offset = clamp(offset, 0, 199 - 20);
Jason Sams37e7c2b2009-10-19 12:55:43 -0700373 drawSimpleMeshRange(NAMED_SMMesh, offset * 6, 20 * 6);
Jason Samsc8514792009-10-29 14:27:29 -0700374
375 if (isTop) {
376 offset = positionStrip(row - 0.72f, column, isTop, p, 1);
377 } else {
378 offset = positionStrip(row + 0.73f, column, isTop, p, 1);
379 }
380 if (offset < -20) return;
Jason Sams84bfa562009-11-20 13:16:41 -0800381 if (offset > 200) return;
Jason Samsc8514792009-10-29 14:27:29 -0700382 bindTexture(NAMED_PFTexMip, 0, loadI32(ALLOC_LABEL_IDS, iconNum));
383 offset = clamp(offset, 0, 199 - 20);
Jason Sams84bfa562009-11-20 13:16:41 -0800384 drawSimpleMeshRange(NAMED_SMMesh, offset * 6, 20 * 6);
385 //drawSimpleMesh(NAMED_SMMesh);
Jason Samsb52dfa02009-10-14 20:16:14 -0700386}
387
Jason Sams461073b2009-10-20 12:06:28 -0700388void drawTop(float rowOffset, float p)
Jason Sams0f505e52009-10-13 17:18:35 -0700389{
Jason Sams0f505e52009-10-13 17:18:35 -0700390 int row, col;
391 int iconNum = 0;
392 for (row = 0; row < rowOffset; row++) {
393 for (col=0; col < 4; col++) {
394 if (iconNum >= state->iconCount) {
395 return;
396 }
Jason Sams461073b2009-10-20 12:06:28 -0700397 drawStrip(rowOffset - row, col, 1, iconNum, p);
Jason Sams0f505e52009-10-13 17:18:35 -0700398 iconNum++;
399 }
400 }
401}
402
Jason Sams09c6fc02009-10-16 17:23:23 -0700403void drawBottom(float rowOffset, float p)
Jason Sams0f505e52009-10-13 17:18:35 -0700404{
405 float pos = -1.f;
406 int intRowOffset = rowOffset;
407 pos -= rowOffset - intRowOffset;
408
409 int row, col;
410 int iconNum = (intRowOffset + 3) * 4;
411 while (1) {
412 for (col=0; col < 4; col++) {
413 if (iconNum >= state->iconCount) {
414 return;
415 }
416 if (pos > -1) {
Jason Sams09c6fc02009-10-16 17:23:23 -0700417 drawStrip(pos, col, 0, iconNum, p);
Jason Sams0f505e52009-10-13 17:18:35 -0700418 }
419 iconNum++;
420 }
421 pos += 1.f;
422 }
423}
424
425int
426main(int launchID)
427{
428 // Compute dt in seconds.
429 int newTime = uptimeMillis();
430 g_DT = (newTime - g_LastTime) / 1000.f;
431 g_LastTime = newTime;
Jason Sams2e19c052009-10-20 18:19:55 -0700432
Jason Sams0f505e52009-10-13 17:18:35 -0700433 if (!g_DrawLastFrame) {
434 // If we stopped rendering we cannot use DT.
435 // assume 30fps in this case.
436 g_DT = 0.033f;
437 }
Jason Samsb52dfa02009-10-14 20:16:14 -0700438 // physics may break if DT is large.
439 g_DT = minf(g_DT, 0.2f);
Jason Sams0f505e52009-10-13 17:18:35 -0700440
441 if (g_Zoom != state->zoomTarget) {
Jason Sams09c6fc02009-10-16 17:23:23 -0700442 float dz;
443 if (state->zoomTarget > 0.5f) {
444 dz = (1 - g_Zoom) * 0.2f;
445 } else {
446 dz = -g_DT - (1 - g_Zoom) * 0.2f;
447 }
448 if (dz && (fabsf(dz) < 0.02f)) {
Jason Sams0f505e52009-10-13 17:18:35 -0700449 if (dz > 0) {
Jason Sams09c6fc02009-10-16 17:23:23 -0700450 dz = 0.02f;
Jason Sams0f505e52009-10-13 17:18:35 -0700451 } else {
Jason Sams09c6fc02009-10-16 17:23:23 -0700452 dz = -0.02f;
Jason Sams0f505e52009-10-13 17:18:35 -0700453 }
454 }
455 if (fabsf(g_Zoom - state->zoomTarget) < fabsf(dz)) {
456 g_Zoom = state->zoomTarget;
457 } else {
458 g_Zoom += dz;
459 }
460 updateReadback();
461 }
462
463 // Set clear value to dim the background based on the zoom position.
Jason Sams41b61c82009-10-15 15:40:54 -0700464 if ((g_Zoom < 0.001f) && (state->zoomTarget < 0.001f) && !g_SpecialHWWar) {
Jason Sams0f505e52009-10-13 17:18:35 -0700465 pfClearColor(0.0f, 0.0f, 0.0f, 0.0f);
466 // When we're zoomed out and not tracking motion events, reset the pos to 0.
467 if (!g_LastTouchDown) {
468 g_PosPage = 0;
469 }
470 return lastFrame(0);
Jason Sams0f505e52009-10-13 17:18:35 -0700471 } else {
472 pfClearColor(0.0f, 0.0f, 0.0f, g_Zoom);
473 }
474
475 // icons & labels
476 int iconCount = state->iconCount;
477 g_PosMax = ((iconCount + 3) / 4) - 4;
478 if (g_PosMax < 0) g_PosMax = 0;
479
480 updatePos(0.1f);
481 updateReadback();
482
483 //debugF(" draw g_PosPage", g_PosPage);
484
485 // Draw the icons ========================================
486
487 //bindProgramFragment(NAMED_PFColor);
488 //positionStrip(1, 0, 0);
Jason Sams37e7c2b2009-10-19 12:55:43 -0700489 //drawSimpleMesh(NAMED_SMMesh);
Jason Sams0f505e52009-10-13 17:18:35 -0700490
Jason Samsc8514792009-10-29 14:27:29 -0700491 bindProgramFragment(NAMED_PFTexMip);
Jason Sams0f505e52009-10-13 17:18:35 -0700492
493
Jason Sams461073b2009-10-20 12:06:28 -0700494 drawTop(g_PosPage, 1-g_Zoom);
Jason Sams09c6fc02009-10-16 17:23:23 -0700495 drawBottom(g_PosPage, 1-g_Zoom);
Jason Sams0f505e52009-10-13 17:18:35 -0700496
497 {
498 float mat1[16];
499 matrixLoadIdentity(mat1);
500 vpLoadModelMatrix(mat1);
501 vpLoadTextureMatrix(mat1);
502 }
Jason Samsc8514792009-10-29 14:27:29 -0700503
504 bindProgramFragment(NAMED_PFTexNearest);
Jason Sams09c6fc02009-10-16 17:23:23 -0700505 drawFrontGrid(g_PosPage, 1-g_Zoom);
Jason Samsb52dfa02009-10-14 20:16:14 -0700506 draw_home_button();
Jason Sams0f505e52009-10-13 17:18:35 -0700507
Jason Sams41b61c82009-10-15 15:40:54 -0700508
509 // This is a WAR to do a rendering pass without drawing during init to
510 // force the driver to preload and compile its shaders.
511 // Without this the first animation does not appear due to the time it
512 // takes to init the driver state.
513 if (g_SpecialHWWar) {
514 g_SpecialHWWar = 0;
515 return 1;
516 }
517
Jason Sams0f505e52009-10-13 17:18:35 -0700518 // Bug workaround where the last frame is not always displayed
519 // So we keep rendering until the bug is fixed.
Mike Cleron7d5d7462009-10-20 14:06:00 -0700520 return lastFrame((g_PosVelocity != 0) || fracf(g_PosPage) || g_Zoom != state->zoomTarget || (g_MoveToTime != 0));
Jason Sams0f505e52009-10-13 17:18:35 -0700521}
522