… | |
… | |
114 | av_push (texture_av, (SV *)(size_t)name); |
114 | av_push (texture_av, (SV *)(size_t)name); |
115 | glDeleteTextures (1, &name); |
115 | glDeleteTextures (1, &name); |
116 | } |
116 | } |
117 | |
117 | |
118 | #include "texcache.c" |
118 | #include "texcache.c" |
|
|
119 | #include "rendercache.c" |
119 | |
120 | |
120 | #include "pango-font.c" |
121 | #include "pango-font.c" |
121 | #include "pango-fontmap.c" |
122 | #include "pango-fontmap.c" |
122 | #include "pango-render.c" |
123 | #include "pango-render.c" |
123 | |
124 | |
… | |
… | |
149 | typedef struct cf_layout { |
150 | typedef struct cf_layout { |
150 | PangoLayout *pl; |
151 | PangoLayout *pl; |
151 | float r, g, b, a; // default color for rgba mode |
152 | float r, g, b, a; // default color for rgba mode |
152 | int base_height; |
153 | int base_height; |
153 | CFPlus__Font font; |
154 | CFPlus__Font font; |
|
|
155 | rc_t *rc; |
154 | } *CFPlus__Layout; |
156 | } *CFPlus__Layout; |
155 | |
157 | |
156 | static CFPlus__Font default_font; |
158 | static CFPlus__Font default_font; |
157 | static PangoContext *opengl_context; |
159 | static PangoContext *opengl_context; |
158 | static PangoFontMap *opengl_fontmap; |
160 | static PangoFontMap *opengl_fontmap; |
… | |
… | |
201 | |
203 | |
202 | typedef uint16_t tileid; |
204 | typedef uint16_t tileid; |
203 | typedef uint16_t faceid; |
205 | typedef uint16_t faceid; |
204 | |
206 | |
205 | typedef struct { |
207 | typedef struct { |
206 | int name; |
208 | GLuint name; |
207 | int w, h; |
209 | int w, h; |
208 | float s, t; |
210 | float s, t; |
209 | uint8_t r, g, b, a; |
211 | uint8_t r, g, b, a; |
210 | tileid smoothtile; |
212 | tileid smoothtile; |
211 | uint8_t smoothlevel; |
213 | uint8_t smoothlevel; |
… | |
… | |
713 | |
715 | |
714 | if (RETVAL) |
716 | if (RETVAL) |
715 | { |
717 | { |
716 | av_clear (texture_av); |
718 | av_clear (texture_av); |
717 | |
719 | |
718 | SDL_WM_SetCaption ("Crossfire+ Client " VERSION, "Crossfire+"); |
720 | SDL_WM_SetCaption ("Crossfire TRT Client " VERSION, "Crossfire TRT"); |
719 | #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); |
720 | #include "glfunc.h" |
722 | #include "glfunc.h" |
721 | #undef GL_FUNC |
723 | #undef GL_FUNC |
722 | } |
724 | } |
723 | } |
725 | } |
… | |
… | |
1035 | RETVAL->g = 1.; |
1037 | RETVAL->g = 1.; |
1036 | RETVAL->b = 1.; |
1038 | RETVAL->b = 1.; |
1037 | RETVAL->a = 1.; |
1039 | RETVAL->a = 1.; |
1038 | RETVAL->base_height = MIN_FONT_HEIGHT; |
1040 | RETVAL->base_height = MIN_FONT_HEIGHT; |
1039 | RETVAL->font = 0; |
1041 | RETVAL->font = 0; |
|
|
1042 | RETVAL->rc = rc_alloc (); |
1040 | |
1043 | |
1041 | pango_layout_set_wrap (RETVAL->pl, PANGO_WRAP_WORD_CHAR); |
1044 | pango_layout_set_wrap (RETVAL->pl, PANGO_WRAP_WORD_CHAR); |
1042 | layout_update_font (RETVAL); |
1045 | layout_update_font (RETVAL); |
1043 | OUTPUT: |
1046 | OUTPUT: |
1044 | RETVAL |
1047 | RETVAL |
1045 | |
1048 | |
1046 | void |
1049 | void |
1047 | DESTROY (CFPlus::Layout self) |
1050 | DESTROY (CFPlus::Layout self) |
1048 | CODE: |
1051 | CODE: |
1049 | g_object_unref (self->pl); |
1052 | g_object_unref (self->pl); |
|
|
1053 | rc_free (self->rc); |
1050 | Safefree (self); |
1054 | Safefree (self); |
1051 | |
1055 | |
1052 | void |
1056 | void |
1053 | set_text (CFPlus::Layout self, SV *text_) |
1057 | set_text (CFPlus::Layout self, SV *text_) |
1054 | CODE: |
1058 | CODE: |
… | |
… | |
1306 | } |
1310 | } |
1307 | } |
1311 | } |
1308 | |
1312 | |
1309 | void |
1313 | void |
1310 | render (CFPlus::Layout self, float x, float y, int flags = 0) |
1314 | render (CFPlus::Layout self, float x, float y, int flags = 0) |
1311 | PPCODE: |
1315 | CODE: |
|
|
1316 | rc_clear (self->rc); |
1312 | pango_opengl_render_layout_subpixel ( |
1317 | pango_opengl_render_layout_subpixel ( |
1313 | self->pl, |
1318 | self->pl, |
|
|
1319 | self->rc, |
1314 | x * PANGO_SCALE, y * PANGO_SCALE, |
1320 | x * PANGO_SCALE, y * PANGO_SCALE, |
1315 | self->r, self->g, self->b, self->a, |
1321 | self->r, self->g, self->b, self->a, |
1316 | flags |
1322 | flags |
1317 | ); |
1323 | ); |
|
|
1324 | // we assume that context_change actually clears/frees stuff |
|
|
1325 | // and does not do any recomputation... |
|
|
1326 | pango_layout_context_changed (self->pl); |
|
|
1327 | |
|
|
1328 | void |
|
|
1329 | draw (CFPlus::Layout self) |
|
|
1330 | CODE: |
|
|
1331 | { |
|
|
1332 | glEnable (GL_TEXTURE_2D); |
|
|
1333 | glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); |
|
|
1334 | glEnable (GL_BLEND); |
|
|
1335 | gl_BlendFuncSeparate (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, |
|
|
1336 | GL_ONE , GL_ONE_MINUS_SRC_ALPHA); |
|
|
1337 | glEnable (GL_ALPHA_TEST); |
|
|
1338 | glAlphaFunc (GL_GREATER, 7.f / 255.f); |
|
|
1339 | |
|
|
1340 | rc_draw (self->rc); |
|
|
1341 | |
|
|
1342 | glDisable (GL_ALPHA_TEST); |
|
|
1343 | glDisable (GL_BLEND); |
|
|
1344 | glDisable (GL_TEXTURE_2D); |
|
|
1345 | } |
1318 | |
1346 | |
1319 | MODULE = CFPlus PACKAGE = CFPlus::Texture |
1347 | MODULE = CFPlus PACKAGE = CFPlus::Texture |
1320 | |
1348 | |
1321 | PROTOTYPES: ENABLE |
1349 | PROTOTYPES: ENABLE |
1322 | |
1350 | |
… | |
… | |
1713 | |
1741 | |
1714 | void |
1742 | void |
1715 | draw (CFPlus::Map self, int mx, int my, int sw, int sh, int T) |
1743 | draw (CFPlus::Map self, int mx, int my, int sw, int sh, int T) |
1716 | CODE: |
1744 | CODE: |
1717 | { |
1745 | { |
|
|
1746 | int x, y, z; |
|
|
1747 | |
1718 | HV *smooth = (HV *)sv_2mortal ((SV *)newHV ()); |
1748 | HV *smooth = (HV *)sv_2mortal ((SV *)newHV ()); |
1719 | 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 |
1720 | 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) |
1721 | smooth_key skey; |
1751 | smooth_key skey; |
1722 | int x, y, z; |
1752 | |
1723 | int last_name; |
1753 | rc_t *rc = rc_alloc (); |
|
|
1754 | rc_key_t key; |
|
|
1755 | rc_array_t *arr; |
1724 | |
1756 | |
1725 | // thats current max. sorry. |
1757 | // thats current max. sorry. |
1726 | if (sw > 255) sw = 255; |
1758 | if (sw > 255) sw = 255; |
1727 | if (sh > 255) sh = 255; |
1759 | if (sh > 255) sh = 255; |
1728 | |
1760 | |
1729 | // clear key, in case of extra padding |
1761 | // clear key, in case of extra padding |
1730 | memset (&skey, 0, sizeof (skey)); |
1762 | memset (&skey, 0, sizeof (skey)); |
1731 | |
1763 | |
1732 | glColor4ub (255, 255, 255, 255); |
1764 | memset (&key, 0, sizeof (key)); |
1733 | |
1765 | key.r = 255; |
1734 | glEnable (GL_BLEND); |
1766 | key.g = 255; |
1735 | glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
1767 | key.b = 255; |
1736 | glEnable (GL_TEXTURE_2D); |
1768 | key.a = 255; |
1737 | glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); |
1769 | key.mode = GL_QUADS; |
1738 | |
1770 | key.format = GL_T2F_V3F; |
1739 | glBegin (GL_QUADS); |
|
|
1740 | |
|
|
1741 | last_name = -1; |
1771 | key.texname = -1; |
1742 | |
1772 | |
1743 | mx += self->x; |
1773 | mx += self->x; |
1744 | my += self->y; |
1774 | my += self->y; |
1745 | |
1775 | |
1746 | // first pass: determine smooth_max |
1776 | // first pass: determine smooth_max |
… | |
… | |
1762 | MAX (self->tex [cell->tile [0]].smoothlevel, |
1792 | MAX (self->tex [cell->tile [0]].smoothlevel, |
1763 | MAX (self->tex [cell->tile [1]].smoothlevel, |
1793 | MAX (self->tex [cell->tile [1]].smoothlevel, |
1764 | self->tex [cell->tile [2]].smoothlevel)); |
1794 | self->tex [cell->tile [2]].smoothlevel)); |
1765 | } |
1795 | } |
1766 | } |
1796 | } |
|
|
1797 | |
|
|
1798 | glEnable (GL_BLEND); |
|
|
1799 | glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
|
|
1800 | glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); |
1767 | |
1801 | |
1768 | for (z = 0; z <= 2; z++) |
1802 | for (z = 0; z <= 2; z++) |
1769 | { |
1803 | { |
1770 | memset (smooth_level, 0, sizeof (smooth_level)); |
1804 | memset (smooth_level, 0, sizeof (smooth_level)); |
1771 | |
1805 | |
… | |
… | |
1783 | if (tile) |
1817 | if (tile) |
1784 | { |
1818 | { |
1785 | maptex tex = self->tex [tile]; |
1819 | maptex tex = self->tex [tile]; |
1786 | int px, py; |
1820 | int px, py; |
1787 | |
1821 | |
1788 | // suppressing texture state switches here |
|
|
1789 | // is only moderately effective, but worth the extra effort |
|
|
1790 | if (last_name != tex.name) |
1822 | if (key.texname != tex.name) |
1791 | { |
1823 | { |
1792 | if (!tex.name) |
1824 | if (!tex.name) |
1793 | tex = self->tex [2]; /* missing, replace by noface */ |
1825 | tex = self->tex [2]; /* missing, replace by noface */ |
1794 | |
1826 | |
1795 | glEnd (); |
1827 | key.texname = tex.name; |
1796 | glBindTexture (GL_TEXTURE_2D, last_name = tex.name); |
1828 | arr = rc_array (rc, &key); |
1797 | glBegin (GL_QUADS); |
|
|
1798 | } |
1829 | } |
1799 | |
1830 | |
1800 | px = (x + 1) * T - tex.w; |
1831 | px = (x + 1) * T - tex.w; |
1801 | py = (y + 1) * T - tex.h; |
1832 | py = (y + 1) * T - tex.h; |
1802 | |
1833 | |
1803 | glTexCoord2f (0 , 0 ); glVertex2f (px , py ); |
1834 | rc_t2f_v3f (arr, 0 , 0 , px , py , 0); |
1804 | glTexCoord2f (0 , tex.t); glVertex2f (px , py + tex.h); |
1835 | rc_t2f_v3f (arr, 0 , tex.t, px , py + tex.h, 0); |
1805 | glTexCoord2f (tex.s, tex.t); glVertex2f (px + tex.w, py + tex.h); |
1836 | rc_t2f_v3f (arr, tex.s, tex.t, px + tex.w, py + tex.h, 0); |
1806 | glTexCoord2f (tex.s, 0 ); glVertex2f (px + tex.w, py ); |
1837 | rc_t2f_v3f (arr, tex.s, 0 , px + tex.w, py , 0); |
1807 | |
1838 | |
1808 | if (cell->flags && z == 2) |
1839 | if (cell->flags && z == 2) |
1809 | { |
1840 | { |
|
|
1841 | // overlays such as the speech bubble, probably more to come |
1810 | if (cell->flags & 1) |
1842 | if (cell->flags & 1) |
1811 | { |
1843 | { |
1812 | maptex tex = self->tex [1]; |
1844 | maptex tex = self->tex [1]; |
1813 | int px = x * T + T * 2 / 32; |
1845 | int px = x * T + T * 2 / 32; |
1814 | int py = y * T - T * 6 / 32; |
1846 | int py = y * T - T * 6 / 32; |
1815 | |
1847 | |
|
|
1848 | if (tex.name) |
1816 | glEnd (); |
1849 | { |
1817 | glBindTexture (GL_TEXTURE_2D, last_name = tex.name); |
1850 | if (key.texname != tex.name) |
|
|
1851 | { |
|
|
1852 | key.texname = tex.name; |
|
|
1853 | arr = rc_array (rc, &key); |
|
|
1854 | } |
|
|
1855 | |
|
|
1856 | rc_t2f_v3f (arr, 0 , 0 , px , py , 0); |
|
|
1857 | rc_t2f_v3f (arr, 0 , tex.t, px , py + T, 0); |
|
|
1858 | rc_t2f_v3f (arr, tex.s, tex.t, px + T, py + T, 0); |
|
|
1859 | rc_t2f_v3f (arr, tex.s, 0 , px + T, py , 0); |
1818 | glBegin (GL_QUADS); |
1860 | } |
1819 | |
|
|
1820 | glTexCoord2f (0 , 0 ); glVertex2f (px , py ); |
|
|
1821 | glTexCoord2f (0 , tex.t); glVertex2f (px , py + T); |
|
|
1822 | glTexCoord2f (tex.s, tex.t); glVertex2f (px + T, py + T); |
|
|
1823 | glTexCoord2f (tex.s, 0 ); glVertex2f (px + T, py ); |
|
|
1824 | } |
1861 | } |
1825 | } |
1862 | } |
1826 | |
1863 | |
1827 | // update smooth hash |
1864 | // update smooth hash |
1828 | if (tex.smoothtile) |
1865 | if (tex.smoothtile) |
… | |
… | |
1864 | } |
1901 | } |
1865 | } |
1902 | } |
1866 | } |
1903 | } |
1867 | } |
1904 | } |
1868 | |
1905 | |
|
|
1906 | rc_draw (rc); |
|
|
1907 | rc_clear (rc); |
|
|
1908 | |
1869 | // go through all smoothlevels, lowest to highest, then draw. |
1909 | // go through all smoothlevels, lowest to highest, then draw. |
1870 | // this is basically counting sort |
1910 | // this is basically counting sort |
1871 | { |
1911 | { |
1872 | int w, b; |
1912 | int w, b; |
1873 | |
1913 | |
|
|
1914 | glEnable (GL_TEXTURE_2D); |
|
|
1915 | glBegin (GL_QUADS); |
1874 | for (w = 0; w < 256 / 32; ++w) |
1916 | for (w = 0; w < 256 / 32; ++w) |
1875 | { |
1917 | { |
1876 | uint32_t smask = smooth_level [w]; |
1918 | uint32_t smask = smooth_level [w]; |
1877 | if (smask) |
1919 | if (smask) |
1878 | for (b = 0; b < 32; ++b) |
1920 | for (b = 0; b < 32; ++b) |
… | |
… | |
1897 | int border = bits & 15; |
1939 | int border = bits & 15; |
1898 | int corner = (bits >> 8) & ~(bits >> 4) & 15; |
1940 | int corner = (bits >> 8) & ~(bits >> 4) & 15; |
1899 | float dx = tex.s * .0625f; // 16 images/row |
1941 | float dx = tex.s * .0625f; // 16 images/row |
1900 | float dy = tex.t * .5f ; // 2 images/column |
1942 | float dy = tex.t * .5f ; // 2 images/column |
1901 | |
1943 | |
1902 | // this time naively avoiding texture state changes |
|
|
1903 | // save gobs of state changes. |
|
|
1904 | if (last_name != tex.name) |
1944 | if (tex.name) |
1905 | { |
1945 | { |
|
|
1946 | // this time avoiding texture state changes |
|
|
1947 | // save gobs of state changes. |
1906 | if (!tex.name) |
1948 | if (key.texname != tex.name) |
1907 | continue; // smoothing not yet available |
1949 | { |
1908 | |
|
|
1909 | glEnd (); |
1950 | glEnd (); |
1910 | glBindTexture (GL_TEXTURE_2D, last_name = tex.name); |
1951 | glBindTexture (GL_TEXTURE_2D, key.texname = tex.name); |
1911 | glBegin (GL_QUADS); |
1952 | glBegin (GL_QUADS); |
1912 | } |
1953 | } |
1913 | |
1954 | |
1914 | if (border) |
1955 | if (border) |
1915 | { |
1956 | { |
1916 | float ox = border * dx; |
1957 | float ox = border * dx; |
1917 | |
1958 | |
1918 | glTexCoord2f (ox , 0.f ); glVertex2f (px , py ); |
1959 | glTexCoord2f (ox , 0.f ); glVertex2i (px , py ); |
1919 | glTexCoord2f (ox , dy ); glVertex2f (px , py + T); |
1960 | glTexCoord2f (ox , dy ); glVertex2i (px , py + T); |
1920 | glTexCoord2f (ox + dx, dy ); glVertex2f (px + T, py + T); |
1961 | glTexCoord2f (ox + dx, dy ); glVertex2i (px + T, py + T); |
1921 | glTexCoord2f (ox + dx, 0.f ); glVertex2f (px + T, py ); |
1962 | glTexCoord2f (ox + dx, 0.f ); glVertex2i (px + T, py ); |
1922 | } |
1963 | } |
1923 | |
1964 | |
1924 | if (corner) |
1965 | if (corner) |
1925 | { |
1966 | { |
1926 | float ox = corner * dx; |
1967 | float ox = corner * dx; |
1927 | |
1968 | |
1928 | glTexCoord2f (ox , dy ); glVertex2f (px , py ); |
1969 | glTexCoord2f (ox , dy ); glVertex2i (px , py ); |
1929 | glTexCoord2f (ox , dy * 2.f); glVertex2f (px , py + T); |
1970 | glTexCoord2f (ox , dy * 2.f); glVertex2i (px , py + T); |
1930 | glTexCoord2f (ox + dx, dy * 2.f); glVertex2f (px + T, py + T); |
1971 | glTexCoord2f (ox + dx, dy * 2.f); glVertex2i (px + T, py + T); |
1931 | glTexCoord2f (ox + dx, dy ); glVertex2f (px + T, py ); |
1972 | glTexCoord2f (ox + dx, dy ); glVertex2i (px + T, py ); |
|
|
1973 | } |
1932 | } |
1974 | } |
1933 | } |
1975 | } |
1934 | } |
1976 | } |
1935 | } |
1977 | } |
1936 | } |
1978 | } |
|
|
1979 | |
|
|
1980 | glEnd (); |
|
|
1981 | glDisable (GL_TEXTURE_2D); |
|
|
1982 | key.texname = -1; |
1937 | } |
1983 | } |
1938 | |
1984 | |
1939 | hv_clear (smooth); |
1985 | hv_clear (smooth); |
1940 | } |
1986 | } |
1941 | |
1987 | |
1942 | glEnd (); |
|
|
1943 | |
|
|
1944 | glDisable (GL_TEXTURE_2D); |
|
|
1945 | glDisable (GL_BLEND); |
1988 | glDisable (GL_BLEND); |
|
|
1989 | rc_free (rc); |
1946 | |
1990 | |
1947 | // top layer: overlays such as the health bar |
1991 | // top layer: overlays such as the health bar |
1948 | for (y = 0; y < sh; y++) |
1992 | for (y = 0; y < sh; y++) |
1949 | if (0 <= y + my && y + my < self->rows) |
1993 | if (0 <= y + my && y + my < self->rows) |
1950 | { |
1994 | { |
… | |
… | |
2199 | int x, y, z; |
2243 | int x, y, z; |
2200 | int w, h; |
2244 | int w, h; |
2201 | int x1, y1; |
2245 | int x1, y1; |
2202 | |
2246 | |
2203 | if (*data++ != 0) |
2247 | if (*data++ != 0) |
2204 | return; /* version mismatch */ |
2248 | XSRETURN_EMPTY; /* version mismatch */ |
2205 | |
2249 | |
2206 | w = *data++ << 8; w |= *data++; |
2250 | w = *data++ << 8; w |= *data++; |
2207 | h = *data++ << 8; h |= *data++; |
2251 | h = *data++ << 8; h |= *data++; |
2208 | |
2252 | |
2209 | // 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 |
… | |
… | |
2505 | const_iv (GL_INTENSITY), |
2549 | const_iv (GL_INTENSITY), |
2506 | const_iv (GL_LUMINANCE), |
2550 | const_iv (GL_LUMINANCE), |
2507 | const_iv (GL_LUMINANCE_ALPHA), |
2551 | const_iv (GL_LUMINANCE_ALPHA), |
2508 | const_iv (GL_FLOAT), |
2552 | const_iv (GL_FLOAT), |
2509 | 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), |
2510 | const_iv (GL_COMPILE), |
2560 | const_iv (GL_COMPILE), |
2511 | const_iv (GL_PROXY_TEXTURE_1D), |
2561 | const_iv (GL_PROXY_TEXTURE_1D), |
2512 | const_iv (GL_PROXY_TEXTURE_2D), |
2562 | const_iv (GL_PROXY_TEXTURE_2D), |
2513 | const_iv (GL_TEXTURE_1D), |
2563 | const_iv (GL_TEXTURE_1D), |
2514 | const_iv (GL_TEXTURE_2D), |
2564 | const_iv (GL_TEXTURE_2D), |
… | |
… | |
2553 | const_iv (GL_PERSPECTIVE_CORRECTION_HINT), |
2603 | const_iv (GL_PERSPECTIVE_CORRECTION_HINT), |
2554 | const_iv (GL_POINT_SMOOTH_HINT), |
2604 | const_iv (GL_POINT_SMOOTH_HINT), |
2555 | const_iv (GL_LINE_SMOOTH_HINT), |
2605 | const_iv (GL_LINE_SMOOTH_HINT), |
2556 | const_iv (GL_POLYGON_SMOOTH_HINT), |
2606 | const_iv (GL_POLYGON_SMOOTH_HINT), |
2557 | const_iv (GL_GENERATE_MIPMAP_HINT), |
2607 | const_iv (GL_GENERATE_MIPMAP_HINT), |
|
|
2608 | const_iv (GL_TEXTURE_COMPRESSION_HINT), |
2558 | const_iv (GL_FASTEST), |
2609 | const_iv (GL_FASTEST), |
2559 | const_iv (GL_DONT_CARE), |
2610 | const_iv (GL_DONT_CARE), |
2560 | const_iv (GL_NICEST), |
2611 | const_iv (GL_NICEST), |
2561 | const_iv (GL_V2F), |
2612 | const_iv (GL_V2F), |
2562 | const_iv (GL_V3F), |
2613 | const_iv (GL_V3F), |
… | |
… | |
2570 | |
2621 | |
2571 | texture_av = newAV (); |
2622 | texture_av = newAV (); |
2572 | AvREAL_off (texture_av); |
2623 | AvREAL_off (texture_av); |
2573 | } |
2624 | } |
2574 | |
2625 | |
|
|
2626 | void |
|
|
2627 | disable_GL_EXT_blend_func_separate () |
|
|
2628 | CODE: |
|
|
2629 | gl.BlendFuncSeparate = 0; |
|
|
2630 | gl.BlendFuncSeparateEXT = 0; |
|
|
2631 | |
2575 | char * |
2632 | char * |
2576 | gl_vendor () |
2633 | gl_vendor () |
2577 | CODE: |
2634 | CODE: |
2578 | RETVAL = (char *)glGetString (GL_VENDOR); |
2635 | RETVAL = (char *)glGetString (GL_VENDOR); |
2579 | OUTPUT: |
2636 | OUTPUT: |
… | |
… | |
2700 | |
2757 | |
2701 | void glRect (float x1, float y1, float x2, float y2) |
2758 | void glRect (float x1, float y1, float x2, float y2) |
2702 | CODE: |
2759 | CODE: |
2703 | glRectf (x1, y1, x2, y2); |
2760 | glRectf (x1, y1, x2, y2); |
2704 | |
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 | |
2705 | PROTOTYPES: ENABLE |
2771 | PROTOTYPES: ENABLE |
2706 | |
2772 | |
2707 | void glBegin (int mode) |
2773 | void glBegin (int mode) |
2708 | |
2774 | |
2709 | void glEnd () |
2775 | void glEnd () |
… | |
… | |
2810 | NV x, y, w, h; |
2876 | NV x, y, w, h; |
2811 | SV *draw_x_sv = GvSV (draw_x_gv); |
2877 | SV *draw_x_sv = GvSV (draw_x_gv); |
2812 | SV *draw_y_sv = GvSV (draw_y_gv); |
2878 | SV *draw_y_sv = GvSV (draw_y_gv); |
2813 | SV *draw_w_sv = GvSV (draw_w_gv); |
2879 | SV *draw_w_sv = GvSV (draw_w_gv); |
2814 | SV *draw_h_sv = GvSV (draw_h_gv); |
2880 | SV *draw_h_sv = GvSV (draw_h_gv); |
2815 | SV *hover; |
|
|
2816 | double draw_x, draw_y, draw_w, draw_h; |
2881 | double draw_x, draw_y; |
2817 | |
2882 | |
2818 | if (!SvROK (self)) |
2883 | if (!SvROK (self)) |
2819 | croak ("CFPlus::Base::draw: %s not a reference", SvPV_nolen (self)); |
2884 | croak ("CFPlus::Base::draw: %s not a reference", SvPV_nolen (self)); |
2820 | |
2885 | |
2821 | hv = (HV *)SvRV (self); |
2886 | hv = (HV *)SvRV (self); |
… | |
… | |
2849 | { |
2914 | { |
2850 | svp = hv_fetch (hv, "can_hover", sizeof ("can_hover") - 1, 0); |
2915 | svp = hv_fetch (hv, "can_hover", sizeof ("can_hover") - 1, 0); |
2851 | |
2916 | |
2852 | if (svp && SvTRUE (*svp)) |
2917 | if (svp && SvTRUE (*svp)) |
2853 | { |
2918 | { |
2854 | 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); |
2855 | glEnable (GL_BLEND); |
2920 | glEnable (GL_BLEND); |
2856 | glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA); |
2921 | glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA); |
2857 | glBegin (GL_QUADS); |
2922 | glBegin (GL_QUADS); |
2858 | glVertex2f (0, 0); |
2923 | glVertex2f (0, 0); |
2859 | glVertex2f (w, 0); |
2924 | glVertex2f (w, 0); |
… | |
… | |
2862 | glEnd (); |
2927 | glEnd (); |
2863 | glDisable (GL_BLEND); |
2928 | glDisable (GL_BLEND); |
2864 | } |
2929 | } |
2865 | } |
2930 | } |
2866 | #if 0 |
2931 | #if 0 |
2867 | if ($ENV{CFPLUS_DEBUG} & 1) { |
2932 | // draw borders, for debugging |
2868 | glPushMatrix; |
2933 | glPushMatrix (); |
2869 | glColor 1, 1, 0, 1; |
2934 | glColor4f (1., 1., 0., 1.); |
2870 | glTranslate 0.375, 0.375; |
2935 | glTranslatef (.5, .5, 0.); |
2871 | glBegin GL_LINE_LOOP; |
2936 | glBegin (GL_LINE_LOOP); |
2872 | glVertex 0 , 0; |
2937 | glVertex2f (0 , 0); |
2873 | glVertex $self->{w} - 1, 0; |
2938 | glVertex2f (w - 1, 0); |
2874 | glVertex $self->{w} - 1, $self->{h} - 1; |
2939 | glVertex2f (w - 1, h - 1); |
2875 | glVertex 0 , $self->{h} - 1; |
2940 | glVertex2f (0 , h - 1); |
2876 | glEnd; |
2941 | glEnd (); |
2877 | glPopMatrix; |
2942 | glPopMatrix (); |
2878 | #CFPlus::UI::Label->new (w => $self->{w}, h => $self->{h}, text => $self, fontsize => 0)->_draw; |
|
|
2879 | } |
|
|
2880 | #endif |
2943 | #endif |
2881 | PUSHMARK (SP); |
2944 | PUSHMARK (SP); |
2882 | XPUSHs (self); |
2945 | XPUSHs (self); |
2883 | PUTBACK; |
2946 | PUTBACK; |
2884 | call_method ("_draw", G_VOID | G_DISCARD); |
2947 | call_method ("_draw", G_VOID | G_DISCARD); |