blob: b2b6cf197441580e945e3852e0f474bec909e74d [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;
381 bindTexture(NAMED_PFTexMip, 0, loadI32(ALLOC_LABEL_IDS, iconNum));
382 offset = clamp(offset, 0, 199 - 20);
383 //drawSimpleMeshRange(NAMED_SMMesh, offset * 6, 20 * 6);
384 drawSimpleMesh(NAMED_SMMesh);
Jason Samsb52dfa02009-10-14 20:16:14 -0700385}
386
Jason Sams461073b2009-10-20 12:06:28 -0700387void drawTop(float rowOffset, float p)
Jason Sams0f505e52009-10-13 17:18:35 -0700388{
Jason Sams0f505e52009-10-13 17:18:35 -0700389 int row, col;
390 int iconNum = 0;
391 for (row = 0; row < rowOffset; row++) {
392 for (col=0; col < 4; col++) {
393 if (iconNum >= state->iconCount) {
394 return;
395 }
Jason Sams461073b2009-10-20 12:06:28 -0700396 drawStrip(rowOffset - row, col, 1, iconNum, p);
Jason Sams0f505e52009-10-13 17:18:35 -0700397 iconNum++;
398 }
399 }
400}
401
Jason Sams09c6fc02009-10-16 17:23:23 -0700402void drawBottom(float rowOffset, float p)
Jason Sams0f505e52009-10-13 17:18:35 -0700403{
404 float pos = -1.f;
405 int intRowOffset = rowOffset;
406 pos -= rowOffset - intRowOffset;
407
408 int row, col;
409 int iconNum = (intRowOffset + 3) * 4;
410 while (1) {
411 for (col=0; col < 4; col++) {
412 if (iconNum >= state->iconCount) {
413 return;
414 }
415 if (pos > -1) {
Jason Sams09c6fc02009-10-16 17:23:23 -0700416 drawStrip(pos, col, 0, iconNum, p);
Jason Sams0f505e52009-10-13 17:18:35 -0700417 }
418 iconNum++;
419 }
420 pos += 1.f;
421 }
422}
423
424int
425main(int launchID)
426{
427 // Compute dt in seconds.
428 int newTime = uptimeMillis();
429 g_DT = (newTime - g_LastTime) / 1000.f;
430 g_LastTime = newTime;
Jason Sams2e19c052009-10-20 18:19:55 -0700431
Jason Sams0f505e52009-10-13 17:18:35 -0700432 if (!g_DrawLastFrame) {
433 // If we stopped rendering we cannot use DT.
434 // assume 30fps in this case.
435 g_DT = 0.033f;
436 }
Jason Samsb52dfa02009-10-14 20:16:14 -0700437 // physics may break if DT is large.
438 g_DT = minf(g_DT, 0.2f);
Jason Sams0f505e52009-10-13 17:18:35 -0700439
440 if (g_Zoom != state->zoomTarget) {
Jason Sams09c6fc02009-10-16 17:23:23 -0700441 float dz;
442 if (state->zoomTarget > 0.5f) {
443 dz = (1 - g_Zoom) * 0.2f;
444 } else {
445 dz = -g_DT - (1 - g_Zoom) * 0.2f;
446 }
447 if (dz && (fabsf(dz) < 0.02f)) {
Jason Sams0f505e52009-10-13 17:18:35 -0700448 if (dz > 0) {
Jason Sams09c6fc02009-10-16 17:23:23 -0700449 dz = 0.02f;
Jason Sams0f505e52009-10-13 17:18:35 -0700450 } else {
Jason Sams09c6fc02009-10-16 17:23:23 -0700451 dz = -0.02f;
Jason Sams0f505e52009-10-13 17:18:35 -0700452 }
453 }
454 if (fabsf(g_Zoom - state->zoomTarget) < fabsf(dz)) {
455 g_Zoom = state->zoomTarget;
456 } else {
457 g_Zoom += dz;
458 }
459 updateReadback();
460 }
461
462 // Set clear value to dim the background based on the zoom position.
Jason Sams41b61c82009-10-15 15:40:54 -0700463 if ((g_Zoom < 0.001f) && (state->zoomTarget < 0.001f) && !g_SpecialHWWar) {
Jason Sams0f505e52009-10-13 17:18:35 -0700464 pfClearColor(0.0f, 0.0f, 0.0f, 0.0f);
465 // When we're zoomed out and not tracking motion events, reset the pos to 0.
466 if (!g_LastTouchDown) {
467 g_PosPage = 0;
468 }
469 return lastFrame(0);
Jason Sams0f505e52009-10-13 17:18:35 -0700470 } else {
471 pfClearColor(0.0f, 0.0f, 0.0f, g_Zoom);
472 }
473
474 // icons & labels
475 int iconCount = state->iconCount;
476 g_PosMax = ((iconCount + 3) / 4) - 4;
477 if (g_PosMax < 0) g_PosMax = 0;
478
479 updatePos(0.1f);
480 updateReadback();
481
482 //debugF(" draw g_PosPage", g_PosPage);
483
484 // Draw the icons ========================================
485
486 //bindProgramFragment(NAMED_PFColor);
487 //positionStrip(1, 0, 0);
Jason Sams37e7c2b2009-10-19 12:55:43 -0700488 //drawSimpleMesh(NAMED_SMMesh);
Jason Sams0f505e52009-10-13 17:18:35 -0700489
Jason Samsc8514792009-10-29 14:27:29 -0700490 bindProgramFragment(NAMED_PFTexMip);
Jason Sams0f505e52009-10-13 17:18:35 -0700491
492
Jason Sams461073b2009-10-20 12:06:28 -0700493 drawTop(g_PosPage, 1-g_Zoom);
Jason Sams09c6fc02009-10-16 17:23:23 -0700494 drawBottom(g_PosPage, 1-g_Zoom);
Jason Sams0f505e52009-10-13 17:18:35 -0700495
496 {
497 float mat1[16];
498 matrixLoadIdentity(mat1);
499 vpLoadModelMatrix(mat1);
500 vpLoadTextureMatrix(mat1);
501 }
Jason Samsc8514792009-10-29 14:27:29 -0700502
503 bindProgramFragment(NAMED_PFTexNearest);
Jason Sams09c6fc02009-10-16 17:23:23 -0700504 drawFrontGrid(g_PosPage, 1-g_Zoom);
Jason Samsb52dfa02009-10-14 20:16:14 -0700505 draw_home_button();
Jason Sams0f505e52009-10-13 17:18:35 -0700506
Jason Sams41b61c82009-10-15 15:40:54 -0700507
508 // This is a WAR to do a rendering pass without drawing during init to
509 // force the driver to preload and compile its shaders.
510 // Without this the first animation does not appear due to the time it
511 // takes to init the driver state.
512 if (g_SpecialHWWar) {
513 g_SpecialHWWar = 0;
514 return 1;
515 }
516
Jason Sams0f505e52009-10-13 17:18:35 -0700517 // Bug workaround where the last frame is not always displayed
518 // So we keep rendering until the bug is fixed.
Mike Cleron7d5d7462009-10-20 14:06:00 -0700519 return lastFrame((g_PosVelocity != 0) || fracf(g_PosPage) || g_Zoom != state->zoomTarget || (g_MoveToTime != 0));
Jason Sams0f505e52009-10-13 17:18:35 -0700520}
521