… | |
… | |
203 | |
203 | |
204 | typedef uint16_t tileid; |
204 | typedef uint16_t tileid; |
205 | typedef uint16_t faceid; |
205 | typedef uint16_t faceid; |
206 | |
206 | |
207 | typedef struct { |
207 | typedef struct { |
208 | int name; |
208 | GLuint name; |
209 | int w, h; |
209 | int w, h; |
210 | float s, t; |
210 | float s, t; |
211 | uint8_t r, g, b, a; |
211 | uint8_t r, g, b, a; |
212 | tileid smoothtile; |
212 | tileid smoothtile; |
213 | uint8_t smoothlevel; |
213 | uint8_t smoothlevel; |
… | |
… | |
715 | |
715 | |
716 | if (RETVAL) |
716 | if (RETVAL) |
717 | { |
717 | { |
718 | av_clear (texture_av); |
718 | av_clear (texture_av); |
719 | |
719 | |
720 | SDL_WM_SetCaption ("Crossfire+ Client " VERSION, "Crossfire+"); |
720 | SDL_WM_SetCaption ("Crossfire TRT Client " VERSION, "Crossfire TRT"); |
721 | #define GL_FUNC(ptr,name) gl.name = (ptr)SDL_GL_GetProcAddress ("gl" # name); |
721 | #define GL_FUNC(ptr,name) gl.name = (ptr)SDL_GL_GetProcAddress ("gl" # name); |
722 | #include "glfunc.h" |
722 | #include "glfunc.h" |
723 | #undef GL_FUNC |
723 | #undef GL_FUNC |
724 | } |
724 | } |
725 | } |
725 | } |
… | |
… | |
1745 | { |
1745 | { |
1746 | int x, y, z; |
1746 | int x, y, z; |
1747 | |
1747 | |
1748 | HV *smooth = (HV *)sv_2mortal ((SV *)newHV ()); |
1748 | HV *smooth = (HV *)sv_2mortal ((SV *)newHV ()); |
1749 | uint32_t smooth_level[256 / 32]; // one bit for every possible smooth level |
1749 | uint32_t smooth_level[256 / 32]; // one bit for every possible smooth level |
1750 | static uint8_t smooth_max[256][256]; // egad, fats and wasteful on memory (64k) |
1750 | static uint8_t smooth_max[256][256]; // egad, fast and wasteful on memory (64k) |
1751 | smooth_key skey; |
1751 | smooth_key skey; |
1752 | |
1752 | |
1753 | rc_t *rc = rc_alloc (); |
1753 | rc_t *rc = rc_alloc (); |
1754 | rc_key_t key; |
1754 | rc_key_t key; |
1755 | rc_array_t *arr; |
1755 | rc_array_t *arr; |
… | |
… | |
1817 | if (tile) |
1817 | if (tile) |
1818 | { |
1818 | { |
1819 | maptex tex = self->tex [tile]; |
1819 | maptex tex = self->tex [tile]; |
1820 | int px, py; |
1820 | int px, py; |
1821 | |
1821 | |
1822 | // suppressing texture state switches here |
|
|
1823 | // is only moderately effective, but worth the extra effort |
|
|
1824 | if (key.texname != tex.name) |
1822 | if (key.texname != tex.name) |
1825 | { |
1823 | { |
1826 | if (!tex.name) |
1824 | if (!tex.name) |
1827 | tex = self->tex [2]; /* missing, replace by noface */ |
1825 | tex = self->tex [2]; /* missing, replace by noface */ |
1828 | |
1826 | |
… | |
… | |
1911 | // go through all smoothlevels, lowest to highest, then draw. |
1909 | // go through all smoothlevels, lowest to highest, then draw. |
1912 | // this is basically counting sort |
1910 | // this is basically counting sort |
1913 | { |
1911 | { |
1914 | int w, b; |
1912 | int w, b; |
1915 | |
1913 | |
|
|
1914 | glEnable (GL_TEXTURE_2D); |
|
|
1915 | glBegin (GL_QUADS); |
1916 | for (w = 0; w < 256 / 32; ++w) |
1916 | for (w = 0; w < 256 / 32; ++w) |
1917 | { |
1917 | { |
1918 | uint32_t smask = smooth_level [w]; |
1918 | uint32_t smask = smooth_level [w]; |
1919 | if (smask) |
1919 | if (smask) |
1920 | for (b = 0; b < 32; ++b) |
1920 | for (b = 0; b < 32; ++b) |
… | |
… | |
1945 | { |
1945 | { |
1946 | // this time avoiding texture state changes |
1946 | // this time avoiding texture state changes |
1947 | // save gobs of state changes. |
1947 | // save gobs of state changes. |
1948 | if (key.texname != tex.name) |
1948 | if (key.texname != tex.name) |
1949 | { |
1949 | { |
|
|
1950 | glEnd (); |
1950 | key.texname = tex.name; |
1951 | glBindTexture (GL_TEXTURE_2D, key.texname = tex.name); |
1951 | arr = rc_array (rc, &key); |
1952 | glBegin (GL_QUADS); |
1952 | } |
1953 | } |
1953 | |
1954 | |
1954 | if (border) |
1955 | if (border) |
1955 | { |
1956 | { |
1956 | float ox = border * dx; |
1957 | float ox = border * dx; |
1957 | |
1958 | |
1958 | rc_t2f_v3f (arr, ox , 0.f , px , py , 0); |
1959 | glTexCoord2f (ox , 0.f ); glVertex2i (px , py ); |
1959 | rc_t2f_v3f (arr, ox , dy , px , py + T, 0); |
1960 | glTexCoord2f (ox , dy ); glVertex2i (px , py + T); |
1960 | rc_t2f_v3f (arr, ox + dx, dy , px + T, py + T, 0); |
1961 | glTexCoord2f (ox + dx, dy ); glVertex2i (px + T, py + T); |
1961 | rc_t2f_v3f (arr, ox + dx, 0.f , px + T, py , 0); |
1962 | glTexCoord2f (ox + dx, 0.f ); glVertex2i (px + T, py ); |
1962 | } |
1963 | } |
1963 | |
1964 | |
1964 | if (corner) |
1965 | if (corner) |
1965 | { |
1966 | { |
1966 | float ox = corner * dx; |
1967 | float ox = corner * dx; |
1967 | |
1968 | |
1968 | rc_t2f_v3f (arr, ox , dy , px , py , 0); |
1969 | glTexCoord2f (ox , dy ); glVertex2i (px , py ); |
1969 | rc_t2f_v3f (arr, ox , dy * 2.f, px , py + T, 0); |
1970 | glTexCoord2f (ox , dy * 2.f); glVertex2i (px , py + T); |
1970 | rc_t2f_v3f (arr, ox + dx, dy * 2.f, px + T, py + T, 0); |
1971 | glTexCoord2f (ox + dx, dy * 2.f); glVertex2i (px + T, py + T); |
1971 | rc_t2f_v3f (arr, ox + dx, dy , px + T, py , 0); |
1972 | glTexCoord2f (ox + dx, dy ); glVertex2i (px + T, py ); |
1972 | } |
1973 | } |
1973 | } |
1974 | } |
1974 | } |
1975 | } |
1975 | } |
1976 | } |
1976 | } |
1977 | } |
1977 | } |
1978 | } |
|
|
1979 | |
|
|
1980 | glEnd (); |
|
|
1981 | glDisable (GL_TEXTURE_2D); |
|
|
1982 | key.texname = -1; |
1978 | } |
1983 | } |
1979 | |
1984 | |
1980 | hv_clear (smooth); |
1985 | hv_clear (smooth); |
1981 | rc_draw (rc); |
|
|
1982 | rc_clear (rc); |
|
|
1983 | } |
1986 | } |
1984 | |
1987 | |
1985 | glDisable (GL_BLEND); |
1988 | glDisable (GL_BLEND); |
1986 | rc_free (rc); |
1989 | rc_free (rc); |
1987 | |
1990 | |
… | |
… | |
2240 | int x, y, z; |
2243 | int x, y, z; |
2241 | int w, h; |
2244 | int w, h; |
2242 | int x1, y1; |
2245 | int x1, y1; |
2243 | |
2246 | |
2244 | if (*data++ != 0) |
2247 | if (*data++ != 0) |
2245 | return; /* version mismatch */ |
2248 | XSRETURN_EMPTY; /* version mismatch */ |
2246 | |
2249 | |
2247 | w = *data++ << 8; w |= *data++; |
2250 | w = *data++ << 8; w |= *data++; |
2248 | h = *data++ << 8; h |= *data++; |
2251 | h = *data++ << 8; h |= *data++; |
2249 | |
2252 | |
2250 | // we need to do this 'cause we don't keep an absolute coord system for rows |
2253 | // we need to do this 'cause we don't keep an absolute coord system for rows |
… | |
… | |
2546 | const_iv (GL_INTENSITY), |
2549 | const_iv (GL_INTENSITY), |
2547 | const_iv (GL_LUMINANCE), |
2550 | const_iv (GL_LUMINANCE), |
2548 | const_iv (GL_LUMINANCE_ALPHA), |
2551 | const_iv (GL_LUMINANCE_ALPHA), |
2549 | const_iv (GL_FLOAT), |
2552 | const_iv (GL_FLOAT), |
2550 | const_iv (GL_UNSIGNED_INT_8_8_8_8_REV), |
2553 | const_iv (GL_UNSIGNED_INT_8_8_8_8_REV), |
|
|
2554 | const_iv (GL_COMPRESSED_ALPHA_ARB), |
|
|
2555 | const_iv (GL_COMPRESSED_LUMINANCE_ARB), |
|
|
2556 | const_iv (GL_COMPRESSED_LUMINANCE_ALPHA_ARB), |
|
|
2557 | const_iv (GL_COMPRESSED_INTENSITY_ARB), |
|
|
2558 | const_iv (GL_COMPRESSED_RGB_ARB), |
|
|
2559 | const_iv (GL_COMPRESSED_RGBA_ARB), |
2551 | const_iv (GL_COMPILE), |
2560 | const_iv (GL_COMPILE), |
2552 | const_iv (GL_PROXY_TEXTURE_1D), |
2561 | const_iv (GL_PROXY_TEXTURE_1D), |
2553 | const_iv (GL_PROXY_TEXTURE_2D), |
2562 | const_iv (GL_PROXY_TEXTURE_2D), |
2554 | const_iv (GL_TEXTURE_1D), |
2563 | const_iv (GL_TEXTURE_1D), |
2555 | const_iv (GL_TEXTURE_2D), |
2564 | const_iv (GL_TEXTURE_2D), |
… | |
… | |
2594 | const_iv (GL_PERSPECTIVE_CORRECTION_HINT), |
2603 | const_iv (GL_PERSPECTIVE_CORRECTION_HINT), |
2595 | const_iv (GL_POINT_SMOOTH_HINT), |
2604 | const_iv (GL_POINT_SMOOTH_HINT), |
2596 | const_iv (GL_LINE_SMOOTH_HINT), |
2605 | const_iv (GL_LINE_SMOOTH_HINT), |
2597 | const_iv (GL_POLYGON_SMOOTH_HINT), |
2606 | const_iv (GL_POLYGON_SMOOTH_HINT), |
2598 | const_iv (GL_GENERATE_MIPMAP_HINT), |
2607 | const_iv (GL_GENERATE_MIPMAP_HINT), |
|
|
2608 | const_iv (GL_TEXTURE_COMPRESSION_HINT), |
2599 | const_iv (GL_FASTEST), |
2609 | const_iv (GL_FASTEST), |
2600 | const_iv (GL_DONT_CARE), |
2610 | const_iv (GL_DONT_CARE), |
2601 | const_iv (GL_NICEST), |
2611 | const_iv (GL_NICEST), |
2602 | const_iv (GL_V2F), |
2612 | const_iv (GL_V2F), |
2603 | const_iv (GL_V3F), |
2613 | const_iv (GL_V3F), |
… | |
… | |
2611 | |
2621 | |
2612 | texture_av = newAV (); |
2622 | texture_av = newAV (); |
2613 | AvREAL_off (texture_av); |
2623 | AvREAL_off (texture_av); |
2614 | } |
2624 | } |
2615 | |
2625 | |
|
|
2626 | void |
|
|
2627 | disable_GL_EXT_blend_func_separate () |
|
|
2628 | CODE: |
|
|
2629 | gl.BlendFuncSeparate = 0; |
|
|
2630 | gl.BlendFuncSeparateEXT = 0; |
|
|
2631 | |
2616 | char * |
2632 | char * |
2617 | gl_vendor () |
2633 | gl_vendor () |
2618 | CODE: |
2634 | CODE: |
2619 | RETVAL = (char *)glGetString (GL_VENDOR); |
2635 | RETVAL = (char *)glGetString (GL_VENDOR); |
2620 | OUTPUT: |
2636 | OUTPUT: |
… | |
… | |
2741 | |
2757 | |
2742 | void glRect (float x1, float y1, float x2, float y2) |
2758 | void glRect (float x1, float y1, float x2, float y2) |
2743 | CODE: |
2759 | CODE: |
2744 | glRectf (x1, y1, x2, y2); |
2760 | glRectf (x1, y1, x2, y2); |
2745 | |
2761 | |
|
|
2762 | void glRect_lineloop (float x1, float y1, float x2, float y2) |
|
|
2763 | CODE: |
|
|
2764 | glBegin (GL_LINE_LOOP); |
|
|
2765 | glVertex2f (x1, y1); |
|
|
2766 | glVertex2f (x2, y1); |
|
|
2767 | glVertex2f (x2, y2); |
|
|
2768 | glVertex2f (x1, y2); |
|
|
2769 | glEnd (); |
|
|
2770 | |
2746 | PROTOTYPES: ENABLE |
2771 | PROTOTYPES: ENABLE |
2747 | |
2772 | |
2748 | void glBegin (int mode) |
2773 | void glBegin (int mode) |
2749 | |
2774 | |
2750 | void glEnd () |
2775 | void glEnd () |
… | |
… | |
2851 | NV x, y, w, h; |
2876 | NV x, y, w, h; |
2852 | SV *draw_x_sv = GvSV (draw_x_gv); |
2877 | SV *draw_x_sv = GvSV (draw_x_gv); |
2853 | SV *draw_y_sv = GvSV (draw_y_gv); |
2878 | SV *draw_y_sv = GvSV (draw_y_gv); |
2854 | SV *draw_w_sv = GvSV (draw_w_gv); |
2879 | SV *draw_w_sv = GvSV (draw_w_gv); |
2855 | SV *draw_h_sv = GvSV (draw_h_gv); |
2880 | SV *draw_h_sv = GvSV (draw_h_gv); |
2856 | SV *hover; |
|
|
2857 | double draw_x, draw_y, draw_w, draw_h; |
2881 | double draw_x, draw_y; |
2858 | |
2882 | |
2859 | if (!SvROK (self)) |
2883 | if (!SvROK (self)) |
2860 | croak ("CFPlus::Base::draw: %s not a reference", SvPV_nolen (self)); |
2884 | croak ("CFPlus::Base::draw: %s not a reference", SvPV_nolen (self)); |
2861 | |
2885 | |
2862 | hv = (HV *)SvRV (self); |
2886 | hv = (HV *)SvRV (self); |
… | |
… | |
2890 | { |
2914 | { |
2891 | svp = hv_fetch (hv, "can_hover", sizeof ("can_hover") - 1, 0); |
2915 | svp = hv_fetch (hv, "can_hover", sizeof ("can_hover") - 1, 0); |
2892 | |
2916 | |
2893 | if (svp && SvTRUE (*svp)) |
2917 | if (svp && SvTRUE (*svp)) |
2894 | { |
2918 | { |
2895 | glColor4f (1*0.2f, 0.8*0.2f, 0.5*0.2f, 0.2f); |
2919 | glColor4f (1.0f * 0.2f, 0.8f * 0.2f, 0.5f * 0.2f, 0.2f); |
2896 | glEnable (GL_BLEND); |
2920 | glEnable (GL_BLEND); |
2897 | glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA); |
2921 | glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA); |
2898 | glBegin (GL_QUADS); |
2922 | glBegin (GL_QUADS); |
2899 | glVertex2f (0, 0); |
2923 | glVertex2f (0, 0); |
2900 | glVertex2f (w, 0); |
2924 | glVertex2f (w, 0); |