… | |
… | |
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 | |