blob: cbcdb22ea64e51aee442bf6bca5cb17ae9141aad [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
Jason Sams0f505e52009-10-13 17:18:35 -0700129void fling() {
130 g_LastTouchDown = 0;
Jason Sams37e7c2b2009-10-19 12:55:43 -0700131 g_PosVelocity = -state->flingVelocity * 4;
Jason Sams0f505e52009-10-13 17:18:35 -0700132 float av = fabsf(g_PosVelocity);
133 float minVel = 3.5f;
134
135 minVel *= 1.f - (fabsf(fracf(g_PosPage + 0.5f) - 0.5f) * 0.45f);
136
137 if (av < minVel && av > 0.2f) {
138 if (g_PosVelocity > 0) {
139 g_PosVelocity = minVel;
140 } else {
141 g_PosVelocity = -minVel;
142 }
143 }
144
145 if (g_PosPage <= 0) {
146 g_PosVelocity = maxf(0, g_PosVelocity);
147 }
148 if (g_PosPage > g_PosMax) {
149 g_PosVelocity = minf(0, g_PosVelocity);
150 }
151}
152
Jason Sams0f505e52009-10-13 17:18:35 -0700153float
154modf(float x, float y)
155{
156 return x-(y*floorf(x/y));
157}
158
Mike Cleron7d5d7462009-10-20 14:06:00 -0700159
160/*
161 * Interpolates values in the range 0..1 to a curve that eases in
162 * and out.
163 */
164float
165getInterpolation(float input) {
166 return (cosf((input + 1) * PI) / 2.0f) + 0.5f;
167}
168
169
Jason Sams0f505e52009-10-13 17:18:35 -0700170void updatePos() {
171 if (g_LastTouchDown) {
172 return;
173 }
174
Jason Sams0f505e52009-10-13 17:18:35 -0700175 float tablePosNorm = fracf(g_PosPage + 0.5f);
176 float tablePosF = tablePosNorm * g_PhysicsTableSize;
177 int tablePosI = tablePosF;
178 float tablePosFrac = tablePosF - tablePosI;
179 float accel = lerpf(g_AttractionTable[tablePosI],
180 g_AttractionTable[tablePosI + 1],
181 tablePosFrac) * g_DT;
Jason Sams2e19c052009-10-20 18:19:55 -0700182 float friction = lerpf(g_FrictionTable[tablePosI],
183 g_FrictionTable[tablePosI + 1],
184 tablePosFrac) * g_DT;
Jason Sams0f505e52009-10-13 17:18:35 -0700185
Jason Samsc1c521e2009-10-19 14:45:45 -0700186 if (g_MoveToTime) {
Jason Samsc8514792009-10-29 14:27:29 -0700187 // New position is old posiition + (total distance) * (interpolated time)
188 g_PosPage = g_MoveToOldPos + (state->targetPos - g_MoveToOldPos) * getInterpolation((g_MoveToTotalTime - g_MoveToTime) / g_MoveToTotalTime);
Jason Samsc1c521e2009-10-19 14:45:45 -0700189 g_MoveToTime -= g_DT;
190 if (g_MoveToTime <= 0) {
191 g_MoveToTime = 0;
192 g_PosPage = state->targetPos;
193 }
194 return;
195 }
196
Jason Sams0f505e52009-10-13 17:18:35 -0700197 // If our velocity is low OR acceleration is opposing it, apply it.
Jason Samsc8514792009-10-29 14:27:29 -0700198 if (fabsf(g_PosVelocity) < 4.0f || (g_PosVelocity * accel) < 0) {
Jason Sams0f505e52009-10-13 17:18:35 -0700199 g_PosVelocity += accel;
200 }
Jason Samsc8514792009-10-29 14:27:29 -0700201 //debugF("g_PosPage", g_PosPage);
202 //debugF(" g_PosVelocity", g_PosVelocity);
203 //debugF(" friction", friction);
204 //debugF(" accel", accel);
Jason Sams0f505e52009-10-13 17:18:35 -0700205
Jason Samsc8514792009-10-29 14:27:29 -0700206 // Normal physics
207 if (g_PosVelocity > 0) {
208 g_PosVelocity -= friction;
209 g_PosVelocity = maxf(g_PosVelocity, 0);
210 } else {
211 g_PosVelocity += friction;
212 g_PosVelocity = minf(g_PosVelocity, 0);
213 }
214
215 if ((friction > fabsf(g_PosVelocity)) && (friction > fabsf(accel))) {
Jason Sams0f505e52009-10-13 17:18:35 -0700216 // Special get back to center and overcome friction physics.
217 float t = tablePosNorm - 0.5f;
218 if (fabsf(t) < (friction * g_DT)) {
219 // really close, just snap
220 g_PosPage = roundf(g_PosPage);
221 g_PosVelocity = 0;
222 } else {
223 if (t > 0) {
224 g_PosVelocity = -friction;
225 } else {
226 g_PosVelocity = friction;
227 }
228 }
Jason Sams0f505e52009-10-13 17:18:35 -0700229 }
Jason Sams0f505e52009-10-13 17:18:35 -0700230
231 // Check for out of boundry conditions.
232 if (g_PosPage < 0 && g_PosVelocity < 0) {
Jason Sams0f505e52009-10-13 17:18:35 -0700233 float damp = 1.0 + (g_PosPage * 4);
234 damp = clampf(damp, 0.f, 0.9f);
235 g_PosVelocity *= damp;
236 }
237 if (g_PosPage > g_PosMax && g_PosVelocity > 0) {
Jason Sams0f505e52009-10-13 17:18:35 -0700238 float damp = 1.0 - ((g_PosPage - g_PosMax) * 4);
239 damp = clampf(damp, 0.f, 0.9f);
240 g_PosVelocity *= damp;
241 }
Jason Samsc8514792009-10-29 14:27:29 -0700242
243 g_PosPage += g_PosVelocity * g_DT;
244 g_PosPage = clampf(g_PosPage, -0.49, g_PosMax + 0.49);
Jason Sams0f505e52009-10-13 17:18:35 -0700245}
246
Jason Samsc8514792009-10-29 14:27:29 -0700247int positionStrip(float row, float column, int isTop, float p, int isText)
Jason Sams0f505e52009-10-13 17:18:35 -0700248{
249 float mat1[16];
Jason Sams0f505e52009-10-13 17:18:35 -0700250 float x = 0.5f * (column - 1.5f);
Jason Sams0f505e52009-10-13 17:18:35 -0700251 float scale = 72.f * 3 / getWidth();
Jason Sams0f505e52009-10-13 17:18:35 -0700252
253 if (isTop) {
254 matrixLoadTranslate(mat1, x, 0.8f, 0.f);
255 matrixScale(mat1, scale, scale, 1.f);
256 } else {
257 matrixLoadTranslate(mat1, x, -0.9f, 0.f);
258 matrixScale(mat1, scale, -scale, 1.f);
259 }
Jason Sams461073b2009-10-20 12:06:28 -0700260 matrixTranslate(mat1, 0, p * 2, 0.f);
261 matrixRotate(mat1, -p * 50, 1, 0, 0);
Jason Sams0f505e52009-10-13 17:18:35 -0700262 vpLoadModelMatrix(mat1);
263
Jason Samsb52dfa02009-10-14 20:16:14 -0700264 float soff = -(row * 1.4);
Jason Sams0f505e52009-10-13 17:18:35 -0700265 if (isTop) {
266 matrixLoadScale(mat1, 1.f, -0.85f, 1.f);
Jason Samsc8514792009-10-29 14:27:29 -0700267 if (isText) {
268 matrixScale(mat1, 1.f, 2.f, 1.f);
269 }
Jason Samsb52dfa02009-10-14 20:16:14 -0700270 matrixTranslate(mat1, 0, soff - 0.97f, 0);
Jason Sams0f505e52009-10-13 17:18:35 -0700271 } else {
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.45f, 0);
Jason Sams0f505e52009-10-13 17:18:35 -0700277 }
278 vpLoadTextureMatrix(mat1);
Jason Samsb52dfa02009-10-14 20:16:14 -0700279 return -soff * 10.f;
Jason Sams0f505e52009-10-13 17:18:35 -0700280}
281
282void
283draw_home_button()
284{
Jason Sams41b61c82009-10-15 15:40:54 -0700285 setColor(1.0f, 1.0f, 1.0f, 1.0f);
Jason Samsc8514792009-10-29 14:27:29 -0700286 bindTexture(NAMED_PFTexNearest, 0, state->homeButtonId);
Jason Sams96b49d82009-10-20 14:28:53 -0700287 float x = (SCREEN_WIDTH_PX - params->homeButtonTextureWidth) / 2;
288 float y = (g_Zoom - 1.f) * params->homeButtonTextureHeight;
Jason Sams0f505e52009-10-13 17:18:35 -0700289
Jason Samsc8514792009-10-29 14:27:29 -0700290 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 -0700291 drawSpriteScreenspace(x, y, 0, params->homeButtonTextureWidth, params->homeButtonTextureHeight);
Jason Sams0f505e52009-10-13 17:18:35 -0700292}
293
Jason Sams09c6fc02009-10-16 17:23:23 -0700294void drawFrontGrid(float rowOffset, float p)
Jason Sams0f505e52009-10-13 17:18:35 -0700295{
296 float h = getHeight();
297 float w = getWidth();
298
299 int intRowOffset = rowOffset;
300 float rowFrac = rowOffset - intRowOffset;
301 float colWidth = getWidth() / 4;
302 float rowHeight = colWidth + 25.f;
303 float yoff = h - ((h - (rowHeight * 4.f)) / 2);
304
305 yoff -= 110;
306
307 int row, col;
308 int iconNum = intRowOffset * 4;
309 float ymax = yoff;
310 float ymin = yoff - (3 * rowHeight) - 70;
311
312 for (row = 0; row < 5; row++) {
313 float y = yoff - ((-rowFrac + row) * rowHeight);
314
315 for (col=0; col < 4; col++) {
316 if (iconNum >= state->iconCount) {
317 return;
318 }
319
320 if (iconNum >= 0) {
321 float x = colWidth * col - ((128 - colWidth) / 2);
322
323 if ((y >= ymin) && (y <= ymax)) {
Jason Sams41b61c82009-10-15 15:40:54 -0700324 setColor(1.f, 1.f, 1.f, 1.f);
Jason Sams09c6fc02009-10-16 17:23:23 -0700325 if (state->selectedIconIndex == iconNum && !p) {
Jason Samsc8514792009-10-29 14:27:29 -0700326 bindTexture(NAMED_PFTexNearest, 0, state->selectedIconTexture);
Joe Onorato742d7fc2009-10-15 19:48:16 -0700327 drawSpriteScreenspace(x, y, 0, 128, 128);
328 }
329
Jason Samsc8514792009-10-29 14:27:29 -0700330 bindTexture(NAMED_PFTexNearest, 0, loadI32(ALLOC_ICON_IDS, iconNum));
Jason Sams09c6fc02009-10-16 17:23:23 -0700331 if (!p) {
332 drawSpriteScreenspace(x, y, 0, 128, 128);
333 } else {
334 float px = ((x + 64) - (getWidth() / 2)) / (getWidth() / 2);
335 float py = ((y + 64) - (getHeight() / 2)) / (getWidth() / 2);
336 float d = 64.f / (getWidth() / 2);
337 px *= p + 1;
338 py *= p + 1;
339 drawQuadTexCoords(px - d, py - d, -p, 0, 1,
340 px - d, py + d, -p, 0, 0,
341 px + d, py + d, -p, 1, 0,
342 px + d, py - d, -p, 1, 1);
343 }
Jason Sams0f505e52009-10-13 17:18:35 -0700344 }
345
346 float y2 = y - 44;
Jason Samsc8514792009-10-29 14:27:29 -0700347 if ((y2 >= ymin) && (y2 <= ymax)) {
348 float a = maxf(0, 1.f - p * 5.f);
349 setColor(1.f, 1.f, 1.f, a);
350 bindTexture(NAMED_PFTexNearest, 0, loadI32(ALLOC_LABEL_IDS, iconNum));
351 drawSpriteScreenspace(x, y - 44, 0,
352 params->bubbleBitmapWidth, params->bubbleBitmapHeight);
Jason Sams0f505e52009-10-13 17:18:35 -0700353 }
Jason Sams0f505e52009-10-13 17:18:35 -0700354 }
355 iconNum++;
356 }
357 }
358}
359
Jason Sams09c6fc02009-10-16 17:23:23 -0700360void drawStrip(float row, float column, int isTop, int iconNum, float p)
Jason Samsb52dfa02009-10-14 20:16:14 -0700361{
362 if (iconNum < 0) return;
Jason Samsc8514792009-10-29 14:27:29 -0700363 int offset = positionStrip(row, column, isTop, p, 0);
364 bindTexture(NAMED_PFTexMip, 0, loadI32(ALLOC_ICON_IDS, iconNum));
Jason Samsb52dfa02009-10-14 20:16:14 -0700365 if (offset < -20) return;
366 offset = clamp(offset, 0, 199 - 20);
Jason Sams37e7c2b2009-10-19 12:55:43 -0700367 drawSimpleMeshRange(NAMED_SMMesh, offset * 6, 20 * 6);
Jason Samsc8514792009-10-29 14:27:29 -0700368
369 if (isTop) {
370 offset = positionStrip(row - 0.72f, column, isTop, p, 1);
371 } else {
372 offset = positionStrip(row + 0.73f, column, isTop, p, 1);
373 }
374 if (offset < -20) return;
375 bindTexture(NAMED_PFTexMip, 0, loadI32(ALLOC_LABEL_IDS, iconNum));
376 offset = clamp(offset, 0, 199 - 20);
377 //drawSimpleMeshRange(NAMED_SMMesh, offset * 6, 20 * 6);
378 drawSimpleMesh(NAMED_SMMesh);
Jason Samsb52dfa02009-10-14 20:16:14 -0700379}
380
Jason Sams461073b2009-10-20 12:06:28 -0700381void drawTop(float rowOffset, float p)
Jason Sams0f505e52009-10-13 17:18:35 -0700382{
Jason Sams0f505e52009-10-13 17:18:35 -0700383 int row, col;
384 int iconNum = 0;
385 for (row = 0; row < rowOffset; row++) {
386 for (col=0; col < 4; col++) {
387 if (iconNum >= state->iconCount) {
388 return;
389 }
Jason Sams461073b2009-10-20 12:06:28 -0700390 drawStrip(rowOffset - row, col, 1, iconNum, p);
Jason Sams0f505e52009-10-13 17:18:35 -0700391 iconNum++;
392 }
393 }
394}
395
Jason Sams09c6fc02009-10-16 17:23:23 -0700396void drawBottom(float rowOffset, float p)
Jason Sams0f505e52009-10-13 17:18:35 -0700397{
398 float pos = -1.f;
399 int intRowOffset = rowOffset;
400 pos -= rowOffset - intRowOffset;
401
402 int row, col;
403 int iconNum = (intRowOffset + 3) * 4;
404 while (1) {
405 for (col=0; col < 4; col++) {
406 if (iconNum >= state->iconCount) {
407 return;
408 }
409 if (pos > -1) {
Jason Sams09c6fc02009-10-16 17:23:23 -0700410 drawStrip(pos, col, 0, iconNum, p);
Jason Sams0f505e52009-10-13 17:18:35 -0700411 }
412 iconNum++;
413 }
414 pos += 1.f;
415 }
416}
417
418int
419main(int launchID)
420{
421 // Compute dt in seconds.
422 int newTime = uptimeMillis();
423 g_DT = (newTime - g_LastTime) / 1000.f;
424 g_LastTime = newTime;
Jason Sams2e19c052009-10-20 18:19:55 -0700425
Jason Sams0f505e52009-10-13 17:18:35 -0700426 if (!g_DrawLastFrame) {
427 // If we stopped rendering we cannot use DT.
428 // assume 30fps in this case.
429 g_DT = 0.033f;
430 }
Jason Samsb52dfa02009-10-14 20:16:14 -0700431 // physics may break if DT is large.
432 g_DT = minf(g_DT, 0.2f);
Jason Sams0f505e52009-10-13 17:18:35 -0700433
434 if (g_Zoom != state->zoomTarget) {
Jason Sams09c6fc02009-10-16 17:23:23 -0700435 float dz;
436 if (state->zoomTarget > 0.5f) {
437 dz = (1 - g_Zoom) * 0.2f;
438 } else {
439 dz = -g_DT - (1 - g_Zoom) * 0.2f;
440 }
441 if (dz && (fabsf(dz) < 0.02f)) {
Jason Sams0f505e52009-10-13 17:18:35 -0700442 if (dz > 0) {
Jason Sams09c6fc02009-10-16 17:23:23 -0700443 dz = 0.02f;
Jason Sams0f505e52009-10-13 17:18:35 -0700444 } else {
Jason Sams09c6fc02009-10-16 17:23:23 -0700445 dz = -0.02f;
Jason Sams0f505e52009-10-13 17:18:35 -0700446 }
447 }
448 if (fabsf(g_Zoom - state->zoomTarget) < fabsf(dz)) {
449 g_Zoom = state->zoomTarget;
450 } else {
451 g_Zoom += dz;
452 }
453 updateReadback();
454 }
455
456 // Set clear value to dim the background based on the zoom position.
Jason Sams41b61c82009-10-15 15:40:54 -0700457 if ((g_Zoom < 0.001f) && (state->zoomTarget < 0.001f) && !g_SpecialHWWar) {
Jason Sams0f505e52009-10-13 17:18:35 -0700458 pfClearColor(0.0f, 0.0f, 0.0f, 0.0f);
459 // When we're zoomed out and not tracking motion events, reset the pos to 0.
460 if (!g_LastTouchDown) {
461 g_PosPage = 0;
462 }
463 return lastFrame(0);
Jason Sams0f505e52009-10-13 17:18:35 -0700464 } else {
465 pfClearColor(0.0f, 0.0f, 0.0f, g_Zoom);
466 }
467
468 // icons & labels
469 int iconCount = state->iconCount;
470 g_PosMax = ((iconCount + 3) / 4) - 4;
471 if (g_PosMax < 0) g_PosMax = 0;
472
473 updatePos(0.1f);
474 updateReadback();
475
476 //debugF(" draw g_PosPage", g_PosPage);
477
478 // Draw the icons ========================================
479
480 //bindProgramFragment(NAMED_PFColor);
481 //positionStrip(1, 0, 0);
Jason Sams37e7c2b2009-10-19 12:55:43 -0700482 //drawSimpleMesh(NAMED_SMMesh);
Jason Sams0f505e52009-10-13 17:18:35 -0700483
Jason Samsc8514792009-10-29 14:27:29 -0700484 bindProgramFragment(NAMED_PFTexMip);
Jason Sams0f505e52009-10-13 17:18:35 -0700485
486
Jason Sams461073b2009-10-20 12:06:28 -0700487 drawTop(g_PosPage, 1-g_Zoom);
Jason Sams09c6fc02009-10-16 17:23:23 -0700488 drawBottom(g_PosPage, 1-g_Zoom);
Jason Sams0f505e52009-10-13 17:18:35 -0700489
490 {
491 float mat1[16];
492 matrixLoadIdentity(mat1);
493 vpLoadModelMatrix(mat1);
494 vpLoadTextureMatrix(mat1);
495 }
Jason Samsc8514792009-10-29 14:27:29 -0700496
497 bindProgramFragment(NAMED_PFTexNearest);
Jason Sams09c6fc02009-10-16 17:23:23 -0700498 drawFrontGrid(g_PosPage, 1-g_Zoom);
Jason Samsb52dfa02009-10-14 20:16:14 -0700499 draw_home_button();
Jason Sams0f505e52009-10-13 17:18:35 -0700500
Jason Sams41b61c82009-10-15 15:40:54 -0700501
502 // This is a WAR to do a rendering pass without drawing during init to
503 // force the driver to preload and compile its shaders.
504 // Without this the first animation does not appear due to the time it
505 // takes to init the driver state.
506 if (g_SpecialHWWar) {
507 g_SpecialHWWar = 0;
508 return 1;
509 }
510
Jason Sams0f505e52009-10-13 17:18:35 -0700511 // Bug workaround where the last frame is not always displayed
512 // So we keep rendering until the bug is fixed.
Mike Cleron7d5d7462009-10-20 14:06:00 -0700513 return lastFrame((g_PosVelocity != 0) || fracf(g_PosPage) || g_Zoom != state->zoomTarget || (g_MoveToTime != 0));
Jason Sams0f505e52009-10-13 17:18:35 -0700514}
515