… | |
… | |
438 | n |= n >> 4; |
438 | n |= n >> 4; |
439 | n |= n >> 8; |
439 | n |= n >> 8; |
440 | n |= n >> 16; |
440 | n |= n >> 16; |
441 | |
441 | |
442 | return n + 1; |
442 | return n + 1; |
|
|
443 | } |
|
|
444 | |
|
|
445 | static unsigned int |
|
|
446 | popcount (unsigned int n) |
|
|
447 | { |
|
|
448 | n -= (n >> 1) & 0x55555555U; |
|
|
449 | n = ((n >> 2) & 0x33333333U) + (n & 0x33333333U); |
|
|
450 | n = ((n >> 4) + n) & 0x0f0f0f0fU; |
|
|
451 | n *= 0x01010101U; |
|
|
452 | |
|
|
453 | return n >> 24; |
443 | } |
454 | } |
444 | |
455 | |
445 | /* SDL should provide this, really. */ |
456 | /* SDL should provide this, really. */ |
446 | #define SDLK_MODIFIER_MIN 300 |
457 | #define SDLK_MODIFIER_MIN 300 |
447 | #define SDLK_MODIFIER_MAX 314 |
458 | #define SDLK_MODIFIER_MAX 314 |
… | |
… | |
525 | |
536 | |
526 | const_iv (SDL_APPINPUTFOCUS), |
537 | const_iv (SDL_APPINPUTFOCUS), |
527 | const_iv (SDL_APPMOUSEFOCUS), |
538 | const_iv (SDL_APPMOUSEFOCUS), |
528 | const_iv (SDL_APPACTIVE), |
539 | const_iv (SDL_APPACTIVE), |
529 | |
540 | |
|
|
541 | const_iv (SDLK_FIRST), |
|
|
542 | const_iv (SDLK_LAST), |
530 | const_iv (SDLK_KP0), |
543 | const_iv (SDLK_KP0), |
531 | const_iv (SDLK_KP1), |
544 | const_iv (SDLK_KP1), |
532 | const_iv (SDLK_KP2), |
545 | const_iv (SDLK_KP2), |
533 | const_iv (SDLK_KP3), |
546 | const_iv (SDLK_KP3), |
534 | const_iv (SDLK_KP4), |
547 | const_iv (SDLK_KP4), |
… | |
… | |
606 | const_iv (KMOD_LMETA), |
619 | const_iv (KMOD_LMETA), |
607 | const_iv (KMOD_RMETA), |
620 | const_iv (KMOD_RMETA), |
608 | const_iv (KMOD_NUM), |
621 | const_iv (KMOD_NUM), |
609 | const_iv (KMOD_CAPS), |
622 | const_iv (KMOD_CAPS), |
610 | const_iv (KMOD_MODE), |
623 | const_iv (KMOD_MODE), |
|
|
624 | |
|
|
625 | const_iv (MIX_DEFAULT_FORMAT), |
611 | # undef const_iv |
626 | # undef const_iv |
612 | }; |
627 | }; |
613 | |
628 | |
614 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
629 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
615 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
630 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
… | |
… | |
632 | RETVAL |
647 | RETVAL |
633 | |
648 | |
634 | NV floor (NV x) |
649 | NV floor (NV x) |
635 | |
650 | |
636 | NV ceil (NV x) |
651 | NV ceil (NV x) |
|
|
652 | |
|
|
653 | IV minpot (UV n) |
|
|
654 | |
|
|
655 | IV popcount (UV n) |
637 | |
656 | |
638 | void |
657 | void |
639 | pango_init () |
658 | pango_init () |
640 | CODE: |
659 | CODE: |
641 | { |
660 | { |
… | |
… | |
811 | XPUSHs (sv_2mortal (sv_bless (newRV_noinc ((SV *)hv), gv_stashpv ("CFPlus::UI::Event", 1)))); |
830 | XPUSHs (sv_2mortal (sv_bless (newRV_noinc ((SV *)hv), gv_stashpv ("CFPlus::UI::Event", 1)))); |
812 | } |
831 | } |
813 | } |
832 | } |
814 | |
833 | |
815 | int |
834 | int |
816 | Mix_OpenAudio (int frequency = 44100, int format = MIX_DEFAULT_FORMAT, int channels = 2, int chunksize = 1024) |
835 | Mix_OpenAudio (int frequency = 44100, int format = MIX_DEFAULT_FORMAT, int channels = 2, int chunksize = 4096) |
817 | POSTCALL: |
836 | POSTCALL: |
818 | Mix_HookMusicFinished (music_finished); |
837 | Mix_HookMusicFinished (music_finished); |
819 | Mix_ChannelFinished (channel_finished); |
838 | Mix_ChannelFinished (channel_finished); |
|
|
839 | |
|
|
840 | void |
|
|
841 | Mix_QuerySpec () |
|
|
842 | PPCODE: |
|
|
843 | { |
|
|
844 | int freq, channels; |
|
|
845 | Uint16 format; |
|
|
846 | |
|
|
847 | if (Mix_QuerySpec (&freq, &format, &channels)) |
|
|
848 | { |
|
|
849 | EXTEND (SP, 3); |
|
|
850 | PUSHs (sv_2mortal (newSViv (freq))); |
|
|
851 | PUSHs (sv_2mortal (newSViv (format))); |
|
|
852 | PUSHs (sv_2mortal (newSViv (channels))); |
|
|
853 | } |
|
|
854 | } |
820 | |
855 | |
821 | void |
856 | void |
822 | Mix_CloseAudio () |
857 | Mix_CloseAudio () |
823 | |
858 | |
824 | int |
859 | int |
… | |
… | |
1345 | } |
1380 | } |
1346 | |
1381 | |
1347 | MODULE = CFPlus PACKAGE = CFPlus::Texture |
1382 | MODULE = CFPlus PACKAGE = CFPlus::Texture |
1348 | |
1383 | |
1349 | PROTOTYPES: ENABLE |
1384 | PROTOTYPES: ENABLE |
1350 | |
|
|
1351 | int minpot (int n) |
|
|
1352 | |
1385 | |
1353 | void |
1386 | void |
1354 | pad (SV *data_, int ow, int oh, int nw, int nh) |
1387 | pad (SV *data_, int ow, int oh, int nw, int nh) |
1355 | CODE: |
1388 | CODE: |
1356 | { |
1389 | { |
… | |
… | |
2603 | const_iv (GL_PERSPECTIVE_CORRECTION_HINT), |
2636 | const_iv (GL_PERSPECTIVE_CORRECTION_HINT), |
2604 | const_iv (GL_POINT_SMOOTH_HINT), |
2637 | const_iv (GL_POINT_SMOOTH_HINT), |
2605 | const_iv (GL_LINE_SMOOTH_HINT), |
2638 | const_iv (GL_LINE_SMOOTH_HINT), |
2606 | const_iv (GL_POLYGON_SMOOTH_HINT), |
2639 | const_iv (GL_POLYGON_SMOOTH_HINT), |
2607 | const_iv (GL_GENERATE_MIPMAP_HINT), |
2640 | const_iv (GL_GENERATE_MIPMAP_HINT), |
|
|
2641 | const_iv (GL_TEXTURE_COMPRESSION_HINT), |
2608 | const_iv (GL_FASTEST), |
2642 | const_iv (GL_FASTEST), |
2609 | const_iv (GL_DONT_CARE), |
2643 | const_iv (GL_DONT_CARE), |
2610 | const_iv (GL_NICEST), |
2644 | const_iv (GL_NICEST), |
2611 | const_iv (GL_V2F), |
2645 | const_iv (GL_V2F), |
2612 | const_iv (GL_V3F), |
2646 | const_iv (GL_V3F), |
… | |
… | |
2620 | |
2654 | |
2621 | texture_av = newAV (); |
2655 | texture_av = newAV (); |
2622 | AvREAL_off (texture_av); |
2656 | AvREAL_off (texture_av); |
2623 | } |
2657 | } |
2624 | |
2658 | |
|
|
2659 | void |
|
|
2660 | disable_GL_EXT_blend_func_separate () |
|
|
2661 | CODE: |
|
|
2662 | gl.BlendFuncSeparate = 0; |
|
|
2663 | gl.BlendFuncSeparateEXT = 0; |
|
|
2664 | |
2625 | char * |
2665 | char * |
2626 | gl_vendor () |
2666 | gl_vendor () |
2627 | CODE: |
2667 | CODE: |
2628 | RETVAL = (char *)glGetString (GL_VENDOR); |
2668 | RETVAL = (char *)glGetString (GL_VENDOR); |
2629 | OUTPUT: |
2669 | OUTPUT: |
… | |
… | |
2749 | glTexCoord2f (s, t); |
2789 | glTexCoord2f (s, t); |
2750 | |
2790 | |
2751 | void glRect (float x1, float y1, float x2, float y2) |
2791 | void glRect (float x1, float y1, float x2, float y2) |
2752 | CODE: |
2792 | CODE: |
2753 | glRectf (x1, y1, x2, y2); |
2793 | glRectf (x1, y1, x2, y2); |
|
|
2794 | |
|
|
2795 | void glRect_lineloop (float x1, float y1, float x2, float y2) |
|
|
2796 | CODE: |
|
|
2797 | glBegin (GL_LINE_LOOP); |
|
|
2798 | glVertex2f (x1, y1); |
|
|
2799 | glVertex2f (x2, y1); |
|
|
2800 | glVertex2f (x2, y2); |
|
|
2801 | glVertex2f (x1, y2); |
|
|
2802 | glEnd (); |
2754 | |
2803 | |
2755 | PROTOTYPES: ENABLE |
2804 | PROTOTYPES: ENABLE |
2756 | |
2805 | |
2757 | void glBegin (int mode) |
2806 | void glBegin (int mode) |
2758 | |
2807 | |
… | |
… | |
2911 | glEnd (); |
2960 | glEnd (); |
2912 | glDisable (GL_BLEND); |
2961 | glDisable (GL_BLEND); |
2913 | } |
2962 | } |
2914 | } |
2963 | } |
2915 | #if 0 |
2964 | #if 0 |
2916 | if ($ENV{CFPLUS_DEBUG} & 1) { |
2965 | // draw borders, for debugging |
2917 | glPushMatrix; |
2966 | glPushMatrix (); |
2918 | glColor 1, 1, 0, 1; |
2967 | glColor4f (1., 1., 0., 1.); |
2919 | glTranslate 0.375, 0.375; |
2968 | glTranslatef (.5, .5, 0.); |
2920 | glBegin GL_LINE_LOOP; |
2969 | glBegin (GL_LINE_LOOP); |
2921 | glVertex 0 , 0; |
2970 | glVertex2f (0 , 0); |
2922 | glVertex $self->{w} - 1, 0; |
2971 | glVertex2f (w - 1, 0); |
2923 | glVertex $self->{w} - 1, $self->{h} - 1; |
2972 | glVertex2f (w - 1, h - 1); |
2924 | glVertex 0 , $self->{h} - 1; |
2973 | glVertex2f (0 , h - 1); |
2925 | glEnd; |
2974 | glEnd (); |
2926 | glPopMatrix; |
2975 | glPopMatrix (); |
2927 | #CFPlus::UI::Label->new (w => $self->{w}, h => $self->{h}, text => $self, fontsize => 0)->_draw; |
|
|
2928 | } |
|
|
2929 | #endif |
2976 | #endif |
2930 | PUSHMARK (SP); |
2977 | PUSHMARK (SP); |
2931 | XPUSHs (self); |
2978 | XPUSHs (self); |
2932 | PUTBACK; |
2979 | PUTBACK; |
2933 | call_method ("_draw", G_VOID | G_DISCARD); |
2980 | call_method ("_draw", G_VOID | G_DISCARD); |