… | |
… | |
150 | typedef struct cf_layout { |
150 | typedef struct cf_layout { |
151 | PangoLayout *pl; |
151 | PangoLayout *pl; |
152 | float r, g, b, a; // default color for rgba mode |
152 | float r, g, b, a; // default color for rgba mode |
153 | int base_height; |
153 | int base_height; |
154 | CFPlus__Font font; |
154 | CFPlus__Font font; |
|
|
155 | rc_t *rc; |
155 | } *CFPlus__Layout; |
156 | } *CFPlus__Layout; |
156 | |
157 | |
157 | static CFPlus__Font default_font; |
158 | static CFPlus__Font default_font; |
158 | static PangoContext *opengl_context; |
159 | static PangoContext *opengl_context; |
159 | static PangoFontMap *opengl_fontmap; |
160 | static PangoFontMap *opengl_fontmap; |
… | |
… | |
202 | |
203 | |
203 | typedef uint16_t tileid; |
204 | typedef uint16_t tileid; |
204 | typedef uint16_t faceid; |
205 | typedef uint16_t faceid; |
205 | |
206 | |
206 | typedef struct { |
207 | typedef struct { |
207 | int name; |
208 | GLuint name; |
208 | int w, h; |
209 | int w, h; |
209 | float s, t; |
210 | float s, t; |
210 | uint8_t r, g, b, a; |
211 | uint8_t r, g, b, a; |
211 | tileid smoothtile; |
212 | tileid smoothtile; |
212 | uint8_t smoothlevel; |
213 | uint8_t smoothlevel; |
… | |
… | |
437 | n |= n >> 4; |
438 | n |= n >> 4; |
438 | n |= n >> 8; |
439 | n |= n >> 8; |
439 | n |= n >> 16; |
440 | n |= n >> 16; |
440 | |
441 | |
441 | 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; |
442 | } |
454 | } |
443 | |
455 | |
444 | /* SDL should provide this, really. */ |
456 | /* SDL should provide this, really. */ |
445 | #define SDLK_MODIFIER_MIN 300 |
457 | #define SDLK_MODIFIER_MIN 300 |
446 | #define SDLK_MODIFIER_MAX 314 |
458 | #define SDLK_MODIFIER_MAX 314 |
… | |
… | |
524 | |
536 | |
525 | const_iv (SDL_APPINPUTFOCUS), |
537 | const_iv (SDL_APPINPUTFOCUS), |
526 | const_iv (SDL_APPMOUSEFOCUS), |
538 | const_iv (SDL_APPMOUSEFOCUS), |
527 | const_iv (SDL_APPACTIVE), |
539 | const_iv (SDL_APPACTIVE), |
528 | |
540 | |
|
|
541 | const_iv (SDLK_FIRST), |
|
|
542 | const_iv (SDLK_LAST), |
529 | const_iv (SDLK_KP0), |
543 | const_iv (SDLK_KP0), |
530 | const_iv (SDLK_KP1), |
544 | const_iv (SDLK_KP1), |
531 | const_iv (SDLK_KP2), |
545 | const_iv (SDLK_KP2), |
532 | const_iv (SDLK_KP3), |
546 | const_iv (SDLK_KP3), |
533 | const_iv (SDLK_KP4), |
547 | const_iv (SDLK_KP4), |
… | |
… | |
605 | const_iv (KMOD_LMETA), |
619 | const_iv (KMOD_LMETA), |
606 | const_iv (KMOD_RMETA), |
620 | const_iv (KMOD_RMETA), |
607 | const_iv (KMOD_NUM), |
621 | const_iv (KMOD_NUM), |
608 | const_iv (KMOD_CAPS), |
622 | const_iv (KMOD_CAPS), |
609 | const_iv (KMOD_MODE), |
623 | const_iv (KMOD_MODE), |
|
|
624 | |
|
|
625 | const_iv (MIX_DEFAULT_FORMAT), |
610 | # undef const_iv |
626 | # undef const_iv |
611 | }; |
627 | }; |
612 | |
628 | |
613 | 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; ) |
614 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
630 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
… | |
… | |
631 | RETVAL |
647 | RETVAL |
632 | |
648 | |
633 | NV floor (NV x) |
649 | NV floor (NV x) |
634 | |
650 | |
635 | NV ceil (NV x) |
651 | NV ceil (NV x) |
|
|
652 | |
|
|
653 | IV minpot (UV n) |
|
|
654 | |
|
|
655 | IV popcount (UV n) |
636 | |
656 | |
637 | void |
657 | void |
638 | pango_init () |
658 | pango_init () |
639 | CODE: |
659 | CODE: |
640 | { |
660 | { |
… | |
… | |
714 | |
734 | |
715 | if (RETVAL) |
735 | if (RETVAL) |
716 | { |
736 | { |
717 | av_clear (texture_av); |
737 | av_clear (texture_av); |
718 | |
738 | |
719 | SDL_WM_SetCaption ("Crossfire+ Client " VERSION, "Crossfire+"); |
739 | SDL_WM_SetCaption ("Crossfire TRT Client " VERSION, "Crossfire TRT"); |
720 | #define GL_FUNC(ptr,name) gl.name = (ptr)SDL_GL_GetProcAddress ("gl" # name); |
740 | #define GL_FUNC(ptr,name) gl.name = (ptr)SDL_GL_GetProcAddress ("gl" # name); |
721 | #include "glfunc.h" |
741 | #include "glfunc.h" |
722 | #undef GL_FUNC |
742 | #undef GL_FUNC |
723 | } |
743 | } |
724 | } |
744 | } |
… | |
… | |
810 | 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)))); |
811 | } |
831 | } |
812 | } |
832 | } |
813 | |
833 | |
814 | int |
834 | int |
815 | 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) |
816 | POSTCALL: |
836 | POSTCALL: |
817 | Mix_HookMusicFinished (music_finished); |
837 | Mix_HookMusicFinished (music_finished); |
818 | 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 | } |
819 | |
855 | |
820 | void |
856 | void |
821 | Mix_CloseAudio () |
857 | Mix_CloseAudio () |
822 | |
858 | |
823 | int |
859 | int |
… | |
… | |
1036 | RETVAL->g = 1.; |
1072 | RETVAL->g = 1.; |
1037 | RETVAL->b = 1.; |
1073 | RETVAL->b = 1.; |
1038 | RETVAL->a = 1.; |
1074 | RETVAL->a = 1.; |
1039 | RETVAL->base_height = MIN_FONT_HEIGHT; |
1075 | RETVAL->base_height = MIN_FONT_HEIGHT; |
1040 | RETVAL->font = 0; |
1076 | RETVAL->font = 0; |
|
|
1077 | RETVAL->rc = rc_alloc (); |
1041 | |
1078 | |
1042 | pango_layout_set_wrap (RETVAL->pl, PANGO_WRAP_WORD_CHAR); |
1079 | pango_layout_set_wrap (RETVAL->pl, PANGO_WRAP_WORD_CHAR); |
1043 | layout_update_font (RETVAL); |
1080 | layout_update_font (RETVAL); |
1044 | OUTPUT: |
1081 | OUTPUT: |
1045 | RETVAL |
1082 | RETVAL |
1046 | |
1083 | |
1047 | void |
1084 | void |
1048 | DESTROY (CFPlus::Layout self) |
1085 | DESTROY (CFPlus::Layout self) |
1049 | CODE: |
1086 | CODE: |
1050 | g_object_unref (self->pl); |
1087 | g_object_unref (self->pl); |
|
|
1088 | rc_free (self->rc); |
1051 | Safefree (self); |
1089 | Safefree (self); |
1052 | |
1090 | |
1053 | void |
1091 | void |
1054 | set_text (CFPlus::Layout self, SV *text_) |
1092 | set_text (CFPlus::Layout self, SV *text_) |
1055 | CODE: |
1093 | CODE: |
… | |
… | |
1307 | } |
1345 | } |
1308 | } |
1346 | } |
1309 | |
1347 | |
1310 | void |
1348 | void |
1311 | render (CFPlus::Layout self, float x, float y, int flags = 0) |
1349 | render (CFPlus::Layout self, float x, float y, int flags = 0) |
1312 | PPCODE: |
1350 | CODE: |
|
|
1351 | rc_clear (self->rc); |
1313 | pango_opengl_render_layout_subpixel ( |
1352 | pango_opengl_render_layout_subpixel ( |
1314 | self->pl, |
1353 | self->pl, |
|
|
1354 | self->rc, |
1315 | x * PANGO_SCALE, y * PANGO_SCALE, |
1355 | x * PANGO_SCALE, y * PANGO_SCALE, |
1316 | self->r, self->g, self->b, self->a, |
1356 | self->r, self->g, self->b, self->a, |
1317 | flags |
1357 | flags |
1318 | ); |
1358 | ); |
|
|
1359 | // we assume that context_change actually clears/frees stuff |
|
|
1360 | // and does not do any recomputation... |
|
|
1361 | pango_layout_context_changed (self->pl); |
|
|
1362 | |
|
|
1363 | void |
|
|
1364 | draw (CFPlus::Layout self) |
|
|
1365 | CODE: |
|
|
1366 | { |
|
|
1367 | glEnable (GL_TEXTURE_2D); |
|
|
1368 | glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); |
|
|
1369 | glEnable (GL_BLEND); |
|
|
1370 | gl_BlendFuncSeparate (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, |
|
|
1371 | GL_ONE , GL_ONE_MINUS_SRC_ALPHA); |
|
|
1372 | glEnable (GL_ALPHA_TEST); |
|
|
1373 | glAlphaFunc (GL_GREATER, 7.f / 255.f); |
|
|
1374 | |
|
|
1375 | rc_draw (self->rc); |
|
|
1376 | |
|
|
1377 | glDisable (GL_ALPHA_TEST); |
|
|
1378 | glDisable (GL_BLEND); |
|
|
1379 | glDisable (GL_TEXTURE_2D); |
|
|
1380 | } |
1319 | |
1381 | |
1320 | MODULE = CFPlus PACKAGE = CFPlus::Texture |
1382 | MODULE = CFPlus PACKAGE = CFPlus::Texture |
1321 | |
1383 | |
1322 | PROTOTYPES: ENABLE |
1384 | PROTOTYPES: ENABLE |
1323 | |
|
|
1324 | int minpot (int n) |
|
|
1325 | |
1385 | |
1326 | void |
1386 | void |
1327 | pad (SV *data_, int ow, int oh, int nw, int nh) |
1387 | pad (SV *data_, int ow, int oh, int nw, int nh) |
1328 | CODE: |
1388 | CODE: |
1329 | { |
1389 | { |
… | |
… | |
1718 | { |
1778 | { |
1719 | int x, y, z; |
1779 | int x, y, z; |
1720 | |
1780 | |
1721 | HV *smooth = (HV *)sv_2mortal ((SV *)newHV ()); |
1781 | HV *smooth = (HV *)sv_2mortal ((SV *)newHV ()); |
1722 | uint32_t smooth_level[256 / 32]; // one bit for every possible smooth level |
1782 | uint32_t smooth_level[256 / 32]; // one bit for every possible smooth level |
1723 | static uint8_t smooth_max[256][256]; // egad, fats and wasteful on memory (64k) |
1783 | static uint8_t smooth_max[256][256]; // egad, fast and wasteful on memory (64k) |
1724 | smooth_key skey; |
1784 | smooth_key skey; |
1725 | |
1785 | |
1726 | rc_t *rc = rc_alloc (); |
1786 | rc_t *rc = rc_alloc (); |
1727 | rc_key_t key; |
1787 | rc_key_t key; |
1728 | rc_array_t *arr; |
1788 | rc_array_t *arr; |
… | |
… | |
1790 | if (tile) |
1850 | if (tile) |
1791 | { |
1851 | { |
1792 | maptex tex = self->tex [tile]; |
1852 | maptex tex = self->tex [tile]; |
1793 | int px, py; |
1853 | int px, py; |
1794 | |
1854 | |
1795 | // suppressing texture state switches here |
|
|
1796 | // is only moderately effective, but worth the extra effort |
|
|
1797 | if (key.texname != tex.name) |
1855 | if (key.texname != tex.name) |
1798 | { |
1856 | { |
1799 | if (!tex.name) |
1857 | if (!tex.name) |
1800 | tex = self->tex [2]; /* missing, replace by noface */ |
1858 | tex = self->tex [2]; /* missing, replace by noface */ |
1801 | |
1859 | |
… | |
… | |
1876 | } |
1934 | } |
1877 | } |
1935 | } |
1878 | } |
1936 | } |
1879 | } |
1937 | } |
1880 | |
1938 | |
|
|
1939 | rc_draw (rc); |
|
|
1940 | rc_clear (rc); |
|
|
1941 | |
1881 | // go through all smoothlevels, lowest to highest, then draw. |
1942 | // go through all smoothlevels, lowest to highest, then draw. |
1882 | // this is basically counting sort |
1943 | // this is basically counting sort |
1883 | { |
1944 | { |
1884 | int w, b; |
1945 | int w, b; |
1885 | |
1946 | |
|
|
1947 | glEnable (GL_TEXTURE_2D); |
|
|
1948 | glBegin (GL_QUADS); |
1886 | for (w = 0; w < 256 / 32; ++w) |
1949 | for (w = 0; w < 256 / 32; ++w) |
1887 | { |
1950 | { |
1888 | uint32_t smask = smooth_level [w]; |
1951 | uint32_t smask = smooth_level [w]; |
1889 | if (smask) |
1952 | if (smask) |
1890 | for (b = 0; b < 32; ++b) |
1953 | for (b = 0; b < 32; ++b) |
… | |
… | |
1915 | { |
1978 | { |
1916 | // this time avoiding texture state changes |
1979 | // this time avoiding texture state changes |
1917 | // save gobs of state changes. |
1980 | // save gobs of state changes. |
1918 | if (key.texname != tex.name) |
1981 | if (key.texname != tex.name) |
1919 | { |
1982 | { |
|
|
1983 | glEnd (); |
1920 | key.texname = tex.name; |
1984 | glBindTexture (GL_TEXTURE_2D, key.texname = tex.name); |
1921 | arr = rc_array (rc, &key); |
1985 | glBegin (GL_QUADS); |
1922 | } |
1986 | } |
1923 | |
1987 | |
1924 | if (border) |
1988 | if (border) |
1925 | { |
1989 | { |
1926 | float ox = border * dx; |
1990 | float ox = border * dx; |
1927 | |
1991 | |
1928 | rc_t2f_v3f (arr, ox , 0.f , px , py , 0); |
1992 | glTexCoord2f (ox , 0.f ); glVertex2i (px , py ); |
1929 | rc_t2f_v3f (arr, ox , dy , px , py + T, 0); |
1993 | glTexCoord2f (ox , dy ); glVertex2i (px , py + T); |
1930 | rc_t2f_v3f (arr, ox + dx, dy , px + T, py + T, 0); |
1994 | glTexCoord2f (ox + dx, dy ); glVertex2i (px + T, py + T); |
1931 | rc_t2f_v3f (arr, ox + dx, 0.f , px + T, py , 0); |
1995 | glTexCoord2f (ox + dx, 0.f ); glVertex2i (px + T, py ); |
1932 | } |
1996 | } |
1933 | |
1997 | |
1934 | if (corner) |
1998 | if (corner) |
1935 | { |
1999 | { |
1936 | float ox = corner * dx; |
2000 | float ox = corner * dx; |
1937 | |
2001 | |
1938 | rc_t2f_v3f (arr, ox , dy , px , py , 0); |
2002 | glTexCoord2f (ox , dy ); glVertex2i (px , py ); |
1939 | rc_t2f_v3f (arr, ox , dy * 2.f, px , py + T, 0); |
2003 | glTexCoord2f (ox , dy * 2.f); glVertex2i (px , py + T); |
1940 | rc_t2f_v3f (arr, ox + dx, dy * 2.f, px + T, py + T, 0); |
2004 | glTexCoord2f (ox + dx, dy * 2.f); glVertex2i (px + T, py + T); |
1941 | rc_t2f_v3f (arr, ox + dx, dy , px + T, py , 0); |
2005 | glTexCoord2f (ox + dx, dy ); glVertex2i (px + T, py ); |
1942 | } |
2006 | } |
1943 | } |
2007 | } |
1944 | } |
2008 | } |
1945 | } |
2009 | } |
1946 | } |
2010 | } |
1947 | } |
2011 | } |
|
|
2012 | |
|
|
2013 | glEnd (); |
|
|
2014 | glDisable (GL_TEXTURE_2D); |
|
|
2015 | key.texname = -1; |
1948 | } |
2016 | } |
1949 | |
2017 | |
1950 | hv_clear (smooth); |
2018 | hv_clear (smooth); |
1951 | rc_draw (rc); |
|
|
1952 | rc_clear (rc); |
|
|
1953 | } |
2019 | } |
1954 | |
2020 | |
1955 | glDisable (GL_BLEND); |
2021 | glDisable (GL_BLEND); |
1956 | rc_free (rc); |
2022 | rc_free (rc); |
1957 | |
2023 | |
… | |
… | |
2210 | int x, y, z; |
2276 | int x, y, z; |
2211 | int w, h; |
2277 | int w, h; |
2212 | int x1, y1; |
2278 | int x1, y1; |
2213 | |
2279 | |
2214 | if (*data++ != 0) |
2280 | if (*data++ != 0) |
2215 | return; /* version mismatch */ |
2281 | XSRETURN_EMPTY; /* version mismatch */ |
2216 | |
2282 | |
2217 | w = *data++ << 8; w |= *data++; |
2283 | w = *data++ << 8; w |= *data++; |
2218 | h = *data++ << 8; h |= *data++; |
2284 | h = *data++ << 8; h |= *data++; |
2219 | |
2285 | |
2220 | // we need to do this 'cause we don't keep an absolute coord system for rows |
2286 | // we need to do this 'cause we don't keep an absolute coord system for rows |
… | |
… | |
2516 | const_iv (GL_INTENSITY), |
2582 | const_iv (GL_INTENSITY), |
2517 | const_iv (GL_LUMINANCE), |
2583 | const_iv (GL_LUMINANCE), |
2518 | const_iv (GL_LUMINANCE_ALPHA), |
2584 | const_iv (GL_LUMINANCE_ALPHA), |
2519 | const_iv (GL_FLOAT), |
2585 | const_iv (GL_FLOAT), |
2520 | const_iv (GL_UNSIGNED_INT_8_8_8_8_REV), |
2586 | const_iv (GL_UNSIGNED_INT_8_8_8_8_REV), |
|
|
2587 | const_iv (GL_COMPRESSED_ALPHA_ARB), |
|
|
2588 | const_iv (GL_COMPRESSED_LUMINANCE_ARB), |
|
|
2589 | const_iv (GL_COMPRESSED_LUMINANCE_ALPHA_ARB), |
|
|
2590 | const_iv (GL_COMPRESSED_INTENSITY_ARB), |
|
|
2591 | const_iv (GL_COMPRESSED_RGB_ARB), |
|
|
2592 | const_iv (GL_COMPRESSED_RGBA_ARB), |
2521 | const_iv (GL_COMPILE), |
2593 | const_iv (GL_COMPILE), |
2522 | const_iv (GL_PROXY_TEXTURE_1D), |
2594 | const_iv (GL_PROXY_TEXTURE_1D), |
2523 | const_iv (GL_PROXY_TEXTURE_2D), |
2595 | const_iv (GL_PROXY_TEXTURE_2D), |
2524 | const_iv (GL_TEXTURE_1D), |
2596 | const_iv (GL_TEXTURE_1D), |
2525 | const_iv (GL_TEXTURE_2D), |
2597 | const_iv (GL_TEXTURE_2D), |
… | |
… | |
2564 | const_iv (GL_PERSPECTIVE_CORRECTION_HINT), |
2636 | const_iv (GL_PERSPECTIVE_CORRECTION_HINT), |
2565 | const_iv (GL_POINT_SMOOTH_HINT), |
2637 | const_iv (GL_POINT_SMOOTH_HINT), |
2566 | const_iv (GL_LINE_SMOOTH_HINT), |
2638 | const_iv (GL_LINE_SMOOTH_HINT), |
2567 | const_iv (GL_POLYGON_SMOOTH_HINT), |
2639 | const_iv (GL_POLYGON_SMOOTH_HINT), |
2568 | const_iv (GL_GENERATE_MIPMAP_HINT), |
2640 | const_iv (GL_GENERATE_MIPMAP_HINT), |
|
|
2641 | const_iv (GL_TEXTURE_COMPRESSION_HINT), |
2569 | const_iv (GL_FASTEST), |
2642 | const_iv (GL_FASTEST), |
2570 | const_iv (GL_DONT_CARE), |
2643 | const_iv (GL_DONT_CARE), |
2571 | const_iv (GL_NICEST), |
2644 | const_iv (GL_NICEST), |
2572 | const_iv (GL_V2F), |
2645 | const_iv (GL_V2F), |
2573 | const_iv (GL_V3F), |
2646 | const_iv (GL_V3F), |
… | |
… | |
2581 | |
2654 | |
2582 | texture_av = newAV (); |
2655 | texture_av = newAV (); |
2583 | AvREAL_off (texture_av); |
2656 | AvREAL_off (texture_av); |
2584 | } |
2657 | } |
2585 | |
2658 | |
|
|
2659 | void |
|
|
2660 | disable_GL_EXT_blend_func_separate () |
|
|
2661 | CODE: |
|
|
2662 | gl.BlendFuncSeparate = 0; |
|
|
2663 | gl.BlendFuncSeparateEXT = 0; |
|
|
2664 | |
2586 | char * |
2665 | char * |
2587 | gl_vendor () |
2666 | gl_vendor () |
2588 | CODE: |
2667 | CODE: |
2589 | RETVAL = (char *)glGetString (GL_VENDOR); |
2668 | RETVAL = (char *)glGetString (GL_VENDOR); |
2590 | OUTPUT: |
2669 | OUTPUT: |
… | |
… | |
2711 | |
2790 | |
2712 | void glRect (float x1, float y1, float x2, float y2) |
2791 | void glRect (float x1, float y1, float x2, float y2) |
2713 | CODE: |
2792 | CODE: |
2714 | glRectf (x1, y1, x2, y2); |
2793 | glRectf (x1, y1, x2, y2); |
2715 | |
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 (); |
|
|
2803 | |
2716 | PROTOTYPES: ENABLE |
2804 | PROTOTYPES: ENABLE |
2717 | |
2805 | |
2718 | void glBegin (int mode) |
2806 | void glBegin (int mode) |
2719 | |
2807 | |
2720 | void glEnd () |
2808 | void glEnd () |
… | |
… | |
2821 | NV x, y, w, h; |
2909 | NV x, y, w, h; |
2822 | SV *draw_x_sv = GvSV (draw_x_gv); |
2910 | SV *draw_x_sv = GvSV (draw_x_gv); |
2823 | SV *draw_y_sv = GvSV (draw_y_gv); |
2911 | SV *draw_y_sv = GvSV (draw_y_gv); |
2824 | SV *draw_w_sv = GvSV (draw_w_gv); |
2912 | SV *draw_w_sv = GvSV (draw_w_gv); |
2825 | SV *draw_h_sv = GvSV (draw_h_gv); |
2913 | SV *draw_h_sv = GvSV (draw_h_gv); |
2826 | SV *hover; |
|
|
2827 | double draw_x, draw_y, draw_w, draw_h; |
2914 | double draw_x, draw_y; |
2828 | |
2915 | |
2829 | if (!SvROK (self)) |
2916 | if (!SvROK (self)) |
2830 | croak ("CFPlus::Base::draw: %s not a reference", SvPV_nolen (self)); |
2917 | croak ("CFPlus::Base::draw: %s not a reference", SvPV_nolen (self)); |
2831 | |
2918 | |
2832 | hv = (HV *)SvRV (self); |
2919 | hv = (HV *)SvRV (self); |
… | |
… | |
2860 | { |
2947 | { |
2861 | svp = hv_fetch (hv, "can_hover", sizeof ("can_hover") - 1, 0); |
2948 | svp = hv_fetch (hv, "can_hover", sizeof ("can_hover") - 1, 0); |
2862 | |
2949 | |
2863 | if (svp && SvTRUE (*svp)) |
2950 | if (svp && SvTRUE (*svp)) |
2864 | { |
2951 | { |
2865 | glColor4f (1*0.2f, 0.8*0.2f, 0.5*0.2f, 0.2f); |
2952 | glColor4f (1.0f * 0.2f, 0.8f * 0.2f, 0.5f * 0.2f, 0.2f); |
2866 | glEnable (GL_BLEND); |
2953 | glEnable (GL_BLEND); |
2867 | glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA); |
2954 | glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA); |
2868 | glBegin (GL_QUADS); |
2955 | glBegin (GL_QUADS); |
2869 | glVertex2f (0, 0); |
2956 | glVertex2f (0, 0); |
2870 | glVertex2f (w, 0); |
2957 | glVertex2f (w, 0); |
… | |
… | |
2873 | glEnd (); |
2960 | glEnd (); |
2874 | glDisable (GL_BLEND); |
2961 | glDisable (GL_BLEND); |
2875 | } |
2962 | } |
2876 | } |
2963 | } |
2877 | #if 0 |
2964 | #if 0 |
2878 | if ($ENV{CFPLUS_DEBUG} & 1) { |
2965 | // draw borders, for debugging |
2879 | glPushMatrix; |
2966 | glPushMatrix (); |
2880 | glColor 1, 1, 0, 1; |
2967 | glColor4f (1., 1., 0., 1.); |
2881 | glTranslate 0.375, 0.375; |
2968 | glTranslatef (.5, .5, 0.); |
2882 | glBegin GL_LINE_LOOP; |
2969 | glBegin (GL_LINE_LOOP); |
2883 | glVertex 0 , 0; |
2970 | glVertex2f (0 , 0); |
2884 | glVertex $self->{w} - 1, 0; |
2971 | glVertex2f (w - 1, 0); |
2885 | glVertex $self->{w} - 1, $self->{h} - 1; |
2972 | glVertex2f (w - 1, h - 1); |
2886 | glVertex 0 , $self->{h} - 1; |
2973 | glVertex2f (0 , h - 1); |
2887 | glEnd; |
2974 | glEnd (); |
2888 | glPopMatrix; |
2975 | glPopMatrix (); |
2889 | #CFPlus::UI::Label->new (w => $self->{w}, h => $self->{h}, text => $self, fontsize => 0)->_draw; |
|
|
2890 | } |
|
|
2891 | #endif |
2976 | #endif |
2892 | PUSHMARK (SP); |
2977 | PUSHMARK (SP); |
2893 | XPUSHs (self); |
2978 | XPUSHs (self); |
2894 | PUTBACK; |
2979 | PUTBACK; |
2895 | call_method ("_draw", G_VOID | G_DISCARD); |
2980 | call_method ("_draw", G_VOID | G_DISCARD); |