… | |
… | |
19 | |
19 | |
20 | #ifdef _WIN32 |
20 | #ifdef _WIN32 |
21 | # undef pipe |
21 | # undef pipe |
22 | // microsoft vs. C |
22 | // microsoft vs. C |
23 | # define sqrtf(x) sqrt(x) |
23 | # define sqrtf(x) sqrt(x) |
24 | # define roundf(x) (int)(x) |
|
|
25 | # define atan2f(x,y) atan2(x,y) |
24 | # define atan2f(x,y) atan2(x,y) |
26 | # define M_PI 3.14159265f |
25 | # define M_PI 3.14159265f |
27 | #endif |
26 | #endif |
28 | |
27 | |
29 | #include <assert.h> |
28 | #include <assert.h> |
… | |
… | |
822 | |
821 | |
823 | IV minpot (UV n) |
822 | IV minpot (UV n) |
824 | |
823 | |
825 | IV popcount (UV n) |
824 | IV popcount (UV n) |
826 | |
825 | |
|
|
826 | NV distance (NV dx, NV dy) |
|
|
827 | CODE: |
|
|
828 | RETVAL = pow (dx * dx + dy * dy, 0.5); |
|
|
829 | OUTPUT: |
|
|
830 | RETVAL |
|
|
831 | |
827 | void |
832 | void |
828 | pango_init () |
833 | pango_init () |
829 | CODE: |
834 | CODE: |
830 | { |
835 | { |
831 | opengl_fontmap = pango_opengl_font_map_new (); |
836 | opengl_fontmap = pango_opengl_font_map_new (); |
… | |
… | |
2427 | } |
2432 | } |
2428 | } |
2433 | } |
2429 | } |
2434 | } |
2430 | |
2435 | |
2431 | void |
2436 | void |
2432 | draw_magicmap (DC::Map self, int dx, int dy, int w, int h, unsigned char *data) |
2437 | draw_magicmap (DC::Map self, int w, int h, unsigned char *data) |
2433 | CODE: |
2438 | CODE: |
2434 | { |
2439 | { |
2435 | static float color[16][3] = { |
2440 | static float color[16][3] = { |
2436 | { 0.00F, 0.00F, 0.00F }, |
2441 | { 0.00f, 0.00f, 0.00f }, |
2437 | { 1.00F, 1.00F, 1.00F }, |
2442 | { 1.00f, 1.00f, 1.00f }, |
2438 | { 0.00F, 0.00F, 0.55F }, |
2443 | { 0.00f, 0.00f, 0.55f }, |
2439 | { 1.00F, 0.00F, 0.00F }, |
2444 | { 1.00f, 0.00f, 0.00f }, |
2440 | |
2445 | |
2441 | { 1.00F, 0.54F, 0.00F }, |
2446 | { 1.00f, 0.54f, 0.00f }, |
2442 | { 0.11F, 0.56F, 1.00F }, |
2447 | { 0.11f, 0.56f, 1.00f }, |
2443 | { 0.93F, 0.46F, 0.00F }, |
2448 | { 0.93f, 0.46f, 0.00f }, |
2444 | { 0.18F, 0.54F, 0.34F }, |
2449 | { 0.18f, 0.54f, 0.34f }, |
2445 | |
2450 | |
2446 | { 0.56F, 0.73F, 0.56F }, |
2451 | { 0.56f, 0.73f, 0.56f }, |
2447 | { 0.80F, 0.80F, 0.80F }, |
2452 | { 0.80f, 0.80f, 0.80f }, |
2448 | { 0.55F, 0.41F, 0.13F }, |
2453 | { 0.55f, 0.41f, 0.13f }, |
2449 | { 0.99F, 0.77F, 0.26F }, |
2454 | { 0.99f, 0.77f, 0.26f }, |
2450 | |
2455 | |
2451 | { 0.74F, 0.65F, 0.41F }, |
2456 | { 0.74f, 0.65f, 0.41f }, |
2452 | |
2457 | |
2453 | { 0.00F, 1.00F, 1.00F }, |
2458 | { 0.00f, 1.00f, 1.00f }, |
2454 | { 1.00F, 0.00F, 1.00F }, |
2459 | { 1.00f, 0.00f, 1.00f }, |
2455 | { 1.00F, 1.00F, 0.00F }, |
2460 | { 1.00f, 1.00f, 0.00f }, |
2456 | }; |
2461 | }; |
2457 | |
2462 | |
2458 | int x, y; |
2463 | int x, y; |
2459 | |
2464 | |
2460 | glEnable (GL_TEXTURE_2D); |
2465 | glEnable (GL_TEXTURE_2D); |
… | |
… | |
2476 | |
2481 | |
2477 | if (m) |
2482 | if (m) |
2478 | { |
2483 | { |
2479 | float *c = color [m & 15]; |
2484 | float *c = color [m & 15]; |
2480 | |
2485 | |
2481 | float tx1 = m & 0x40 ? 0.5 : 0.; |
2486 | float tx1 = m & 0x40 ? 0.5f : 0.f; |
2482 | float tx2 = tx1 + 0.5; |
2487 | float tx2 = tx1 + 0.5f; |
2483 | |
2488 | |
2484 | glColor4f (c[0], c[1], c[2], 1); |
2489 | glColor4f (c[0], c[1], c[2], 1); |
2485 | glTexCoord2f (tx1, 0.); glVertex2i (x , y ); |
2490 | glTexCoord2f (tx1, 0.); glVertex2i (x , y ); |
2486 | glTexCoord2f (tx1, 1.); glVertex2i (x , y + 1); |
2491 | glTexCoord2f (tx1, 1.); glVertex2i (x , y + 1); |
2487 | glTexCoord2f (tx2, 1.); glVertex2i (x + 1, y + 1); |
2492 | glTexCoord2f (tx2, 1.); glVertex2i (x + 1, y + 1); |
… | |
… | |
2835 | void |
2840 | void |
2836 | set_position_r (DC::Channel self, int dx, int dy, int maxdistance) |
2841 | set_position_r (DC::Channel self, int dx, int dy, int maxdistance) |
2837 | CODE: |
2842 | CODE: |
2838 | { |
2843 | { |
2839 | int distance = sqrtf (dx * dx + dy * dy) * (255.f / sqrtf (maxdistance * maxdistance)); |
2844 | int distance = sqrtf (dx * dx + dy * dy) * (255.f / sqrtf (maxdistance * maxdistance)); |
2840 | int angle = 360 + (int)roundf (atan2f (dx, -dy) * 180.f / (float)M_PI); |
2845 | int angle = atan2f (dx, -dy) * 180.f / (float)M_PI + 360.f; |
2841 | Mix_SetPosition (self, angle, CLAMP (distance, 0, 255)); |
2846 | Mix_SetPosition (self, angle, CLAMP (distance, 0, 255)); |
2842 | } |
2847 | } |
2843 | |
2848 | |
2844 | void |
2849 | void |
2845 | set_reverse_stereo (DC::Channel self, int flip) |
2850 | set_reverse_stereo (DC::Channel self, int flip) |