… | |
… | |
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), |
… | |
… | |
633 | |
646 | |
634 | NV floor (NV x) |
647 | NV floor (NV x) |
635 | |
648 | |
636 | NV ceil (NV x) |
649 | NV ceil (NV x) |
637 | |
650 | |
|
|
651 | IV minpot (UV n) |
|
|
652 | |
|
|
653 | IV popcount (UV n) |
|
|
654 | |
638 | void |
655 | void |
639 | pango_init () |
656 | pango_init () |
640 | CODE: |
657 | CODE: |
641 | { |
658 | { |
642 | opengl_fontmap = pango_opengl_font_map_new (); |
659 | opengl_fontmap = pango_opengl_font_map_new (); |
… | |
… | |
1345 | } |
1362 | } |
1346 | |
1363 | |
1347 | MODULE = CFPlus PACKAGE = CFPlus::Texture |
1364 | MODULE = CFPlus PACKAGE = CFPlus::Texture |
1348 | |
1365 | |
1349 | PROTOTYPES: ENABLE |
1366 | PROTOTYPES: ENABLE |
1350 | |
|
|
1351 | int minpot (int n) |
|
|
1352 | |
1367 | |
1353 | void |
1368 | void |
1354 | pad (SV *data_, int ow, int oh, int nw, int nh) |
1369 | pad (SV *data_, int ow, int oh, int nw, int nh) |
1355 | CODE: |
1370 | CODE: |
1356 | { |
1371 | { |
… | |
… | |
2757 | |
2772 | |
2758 | void glRect (float x1, float y1, float x2, float y2) |
2773 | void glRect (float x1, float y1, float x2, float y2) |
2759 | CODE: |
2774 | CODE: |
2760 | glRectf (x1, y1, x2, y2); |
2775 | glRectf (x1, y1, x2, y2); |
2761 | |
2776 | |
|
|
2777 | void glRect_lineloop (float x1, float y1, float x2, float y2) |
|
|
2778 | CODE: |
|
|
2779 | glBegin (GL_LINE_LOOP); |
|
|
2780 | glVertex2f (x1, y1); |
|
|
2781 | glVertex2f (x2, y1); |
|
|
2782 | glVertex2f (x2, y2); |
|
|
2783 | glVertex2f (x1, y2); |
|
|
2784 | glEnd (); |
|
|
2785 | |
2762 | PROTOTYPES: ENABLE |
2786 | PROTOTYPES: ENABLE |
2763 | |
2787 | |
2764 | void glBegin (int mode) |
2788 | void glBegin (int mode) |
2765 | |
2789 | |
2766 | void glEnd () |
2790 | void glEnd () |
… | |
… | |
2918 | glEnd (); |
2942 | glEnd (); |
2919 | glDisable (GL_BLEND); |
2943 | glDisable (GL_BLEND); |
2920 | } |
2944 | } |
2921 | } |
2945 | } |
2922 | #if 0 |
2946 | #if 0 |
2923 | if ($ENV{CFPLUS_DEBUG} & 1) { |
2947 | // draw borders, for debugging |
2924 | glPushMatrix; |
2948 | glPushMatrix (); |
2925 | glColor 1, 1, 0, 1; |
2949 | glColor4f (1., 1., 0., 1.); |
2926 | glTranslate 0.375, 0.375; |
2950 | glTranslatef (.5, .5, 0.); |
2927 | glBegin GL_LINE_LOOP; |
2951 | glBegin (GL_LINE_LOOP); |
2928 | glVertex 0 , 0; |
2952 | glVertex2f (0 , 0); |
2929 | glVertex $self->{w} - 1, 0; |
2953 | glVertex2f (w - 1, 0); |
2930 | glVertex $self->{w} - 1, $self->{h} - 1; |
2954 | glVertex2f (w - 1, h - 1); |
2931 | glVertex 0 , $self->{h} - 1; |
2955 | glVertex2f (0 , h - 1); |
2932 | glEnd; |
2956 | glEnd (); |
2933 | glPopMatrix; |
2957 | glPopMatrix (); |
2934 | #CFPlus::UI::Label->new (w => $self->{w}, h => $self->{h}, text => $self, fontsize => 0)->_draw; |
|
|
2935 | } |
|
|
2936 | #endif |
2958 | #endif |
2937 | PUSHMARK (SP); |
2959 | PUSHMARK (SP); |
2938 | XPUSHs (self); |
2960 | XPUSHs (self); |
2939 | PUTBACK; |
2961 | PUTBACK; |
2940 | call_method ("_draw", G_VOID | G_DISCARD); |
2962 | call_method ("_draw", G_VOID | G_DISCARD); |