… | |
… | |
56 | # define PARACHUTE SDL_INIT_NOPARACHUTE |
56 | # define PARACHUTE SDL_INIT_NOPARACHUTE |
57 | #else |
57 | #else |
58 | # define PARACHUTE 0 |
58 | # define PARACHUTE 0 |
59 | #endif |
59 | #endif |
60 | |
60 | |
|
|
61 | static AV *texture_av; |
|
|
62 | |
61 | static struct |
63 | static struct |
62 | { |
64 | { |
63 | #define GL_FUNC(ptr,name) ptr name; |
65 | #define GL_FUNC(ptr,name) ptr name; |
64 | #include "glfunc.h" |
66 | #include "glfunc.h" |
65 | #undef GL_FUNC |
67 | #undef GL_FUNC |
… | |
… | |
163 | typedef struct { |
165 | typedef struct { |
164 | int name; |
166 | int name; |
165 | int w, h; |
167 | int w, h; |
166 | float s, t; |
168 | float s, t; |
167 | uint8_t r, g, b, a; |
169 | uint8_t r, g, b, a; |
|
|
170 | tileid smoothtile; |
|
|
171 | uint8_t smoothlevel; |
168 | } maptex; |
172 | } maptex; |
169 | |
173 | |
170 | typedef struct { |
174 | typedef struct { |
171 | uint32_t player; |
175 | uint32_t player; |
172 | tileid tile[3]; |
176 | tileid tile[3]; |
173 | uint16_t darkness; |
177 | uint16_t darkness; |
174 | uint8_t stat_width, stat_hp, flags; |
178 | uint8_t stat_width, stat_hp, flags, smoothmax; |
175 | } mapcell; |
179 | } mapcell; |
176 | |
180 | |
177 | typedef struct { |
181 | typedef struct { |
178 | int32_t c0, c1; |
182 | int32_t c0, c1; |
179 | mapcell *col; |
183 | mapcell *col; |
… | |
… | |
333 | cell->stat_hp = 0; |
337 | cell->stat_hp = 0; |
334 | cell->flags = 0; |
338 | cell->flags = 0; |
335 | cell->player = 0; |
339 | cell->player = 0; |
336 | } |
340 | } |
337 | } |
341 | } |
|
|
342 | } |
|
|
343 | |
|
|
344 | typedef struct { |
|
|
345 | tileid tile; |
|
|
346 | uint8_t x, y, level; |
|
|
347 | } smooth_key; |
|
|
348 | |
|
|
349 | static void |
|
|
350 | smooth_or_bits (HV *hv, smooth_key *key, IV bits) |
|
|
351 | { |
|
|
352 | SV **sv = hv_fetch (hv, (char *)key, sizeof (*key), 1); |
|
|
353 | |
|
|
354 | if (SvIOK (*sv)) |
|
|
355 | SvIV_set (*sv, SvIVX (*sv) | bits); |
|
|
356 | else |
|
|
357 | sv_setiv (*sv, bits); |
338 | } |
358 | } |
339 | |
359 | |
340 | static void |
360 | static void |
341 | music_finished (void) |
361 | music_finished (void) |
342 | { |
362 | { |
… | |
… | |
596 | RETVAL = !!SDL_SetVideoMode ( |
616 | RETVAL = !!SDL_SetVideoMode ( |
597 | w, h, 0, SDL_OPENGL | (fullscreen ? SDL_FULLSCREEN : 0) |
617 | w, h, 0, SDL_OPENGL | (fullscreen ? SDL_FULLSCREEN : 0) |
598 | ); |
618 | ); |
599 | if (RETVAL) |
619 | if (RETVAL) |
600 | { |
620 | { |
|
|
621 | av_clear (texture_av); |
|
|
622 | |
601 | SDL_WM_SetCaption ("Crossfire+ Client " VERSION, "Crossfire+"); |
623 | SDL_WM_SetCaption ("Crossfire+ Client " VERSION, "Crossfire+"); |
602 | # define GL_FUNC(ptr,name) gl.name = (ptr)SDL_GL_GetProcAddress ("gl" # name); |
624 | # define GL_FUNC(ptr,name) gl.name = (ptr)SDL_GL_GetProcAddress ("gl" # name); |
603 | # include "glfunc.h" |
625 | # include "glfunc.h" |
604 | # undef GL_FUNC |
626 | # undef GL_FUNC |
|
|
627 | |
605 | } |
628 | } |
606 | OUTPUT: |
629 | OUTPUT: |
607 | RETVAL |
630 | RETVAL |
608 | |
631 | |
609 | void |
632 | void |
… | |
… | |
683 | Mix_AllocateChannels (int numchans = -1) |
706 | Mix_AllocateChannels (int numchans = -1) |
684 | |
707 | |
685 | void |
708 | void |
686 | lowdelay (int fd, int val = 1) |
709 | lowdelay (int fd, int val = 1) |
687 | CODE: |
710 | CODE: |
688 | #ifndef _WIN32 |
|
|
689 | setsockopt (fd, IPPROTO_TCP, TCP_NODELAY, &val, sizeof (val)); |
711 | setsockopt (fd, IPPROTO_TCP, TCP_NODELAY, (void *)&val, sizeof (val)); |
690 | #endif |
|
|
691 | |
712 | |
692 | void |
713 | void |
693 | win32_proxy_info () |
714 | win32_proxy_info () |
694 | PPCODE: |
715 | PPCODE: |
695 | { |
716 | { |
… | |
… | |
1295 | need_facenum (self, face); self->face2tile [face] = tile; |
1316 | need_facenum (self, face); self->face2tile [face] = tile; |
1296 | need_texid (self, tile); |
1317 | need_texid (self, tile); |
1297 | } |
1318 | } |
1298 | |
1319 | |
1299 | void |
1320 | void |
|
|
1321 | set_smooth (CFPlus::Map self, int face, int smooth, int level) |
|
|
1322 | CODE: |
|
|
1323 | { |
|
|
1324 | tileid texid; |
|
|
1325 | maptex *tex; |
|
|
1326 | |
|
|
1327 | if (face < 0 || face >= self->faces) |
|
|
1328 | return; |
|
|
1329 | |
|
|
1330 | if (smooth < 0 || smooth >= self->faces) |
|
|
1331 | return; |
|
|
1332 | |
|
|
1333 | texid = self->face2tile [face]; |
|
|
1334 | |
|
|
1335 | if (!texid) |
|
|
1336 | return; |
|
|
1337 | |
|
|
1338 | tex = self->tex + texid; |
|
|
1339 | tex->smoothtile = self->face2tile [smooth]; |
|
|
1340 | tex->smoothlevel = level; |
|
|
1341 | } |
|
|
1342 | |
|
|
1343 | void |
1300 | set_texture (CFPlus::Map self, int texid, int name, int w, int h, float s, float t, int r, int g, int b, int a) |
1344 | set_texture (CFPlus::Map self, int texid, int name, int w, int h, float s, float t, int r, int g, int b, int a) |
1301 | CODE: |
1345 | CODE: |
1302 | { |
1346 | { |
1303 | need_texid (self, texid); |
1347 | need_texid (self, texid); |
1304 | |
1348 | |
… | |
… | |
1352 | CODE: |
1396 | CODE: |
1353 | { |
1397 | { |
1354 | if (dx > 0) |
1398 | if (dx > 0) |
1355 | map_blank (self, self->x, self->y, dx, self->h); |
1399 | map_blank (self, self->x, self->y, dx, self->h); |
1356 | else if (dx < 0) |
1400 | else if (dx < 0) |
1357 | map_blank (self, self->x + self->w + dx + 1, self->y, -dx, self->h); |
1401 | map_blank (self, self->x + self->w + dx, self->y, -dx, self->h); |
1358 | |
1402 | |
1359 | if (dy > 0) |
1403 | if (dy > 0) |
1360 | map_blank (self, self->x, self->y, self->w, dy); |
1404 | map_blank (self, self->x, self->y, self->w, dy); |
1361 | else if (dy < 0) |
1405 | else if (dy < 0) |
1362 | map_blank (self, self->x, self->y + self->h + dy + 1, self->w, -dy); |
1406 | map_blank (self, self->x, self->y + self->h + dy, self->w, -dy); |
1363 | |
1407 | |
1364 | self->ox += dx; self->x += dx; |
1408 | self->ox += dx; self->x += dx; |
1365 | self->oy += dy; self->y += dy; |
1409 | self->oy += dy; self->y += dy; |
1366 | |
1410 | |
1367 | while (self->y < 0) |
1411 | while (self->y < 0) |
… | |
… | |
1421 | } |
1465 | } |
1422 | else if (cmd == 6) // monster width |
1466 | else if (cmd == 6) // monster width |
1423 | cell->stat_width = *data++ + 1; |
1467 | cell->stat_width = *data++ + 1; |
1424 | else if (cmd == 0x47) |
1468 | else if (cmd == 0x47) |
1425 | { |
1469 | { |
1426 | if (*data == 8) |
1470 | if (*data == 4) |
1427 | ; // decode player uuid |
1471 | ; // decode player count |
1428 | |
1472 | |
1429 | data += *data + 1; |
1473 | data += *data + 1; |
1430 | } |
1474 | } |
1431 | else if (cmd == 8) // cell flags |
1475 | else if (cmd == 8) // cell flags |
1432 | cell->flags = *data++; |
1476 | cell->flags = *data++; |
… | |
… | |
1524 | |
1568 | |
1525 | void |
1569 | void |
1526 | draw (CFPlus::Map self, int mx, int my, int sw, int sh, int T) |
1570 | draw (CFPlus::Map self, int mx, int my, int sw, int sh, int T) |
1527 | CODE: |
1571 | CODE: |
1528 | { |
1572 | { |
|
|
1573 | HV *smooth = (HV *)sv_2mortal ((SV *)newHV ()); |
|
|
1574 | uint32_t smooth_level[256 / 32]; // one bit for every possible smooth level |
|
|
1575 | static uint8_t smooth_max[256][256]; // egad, fats and wasteful on memory (64k) |
|
|
1576 | smooth_key skey; |
1529 | int x, y, z; |
1577 | int x, y, z; |
1530 | int last_name; |
1578 | int last_name; |
|
|
1579 | |
|
|
1580 | // thats current max. sorry. |
|
|
1581 | if (sw > 255) sw = 255; |
|
|
1582 | if (sh > 255) sh = 255; |
|
|
1583 | |
|
|
1584 | // clear key, in case of extra padding |
|
|
1585 | memset (&skey, 0, sizeof (skey)); |
1531 | |
1586 | |
1532 | glColor4ub (255, 255, 255, 255); |
1587 | glColor4ub (255, 255, 255, 255); |
1533 | |
1588 | |
1534 | glEnable (GL_BLEND); |
1589 | glEnable (GL_BLEND); |
1535 | glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
1590 | glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
… | |
… | |
1541 | last_name = 0; |
1596 | last_name = 0; |
1542 | |
1597 | |
1543 | mx += self->x; |
1598 | mx += self->x; |
1544 | my += self->y; |
1599 | my += self->y; |
1545 | |
1600 | |
|
|
1601 | // first pass: determine smooth_max |
|
|
1602 | // rather ugly, if you ask me |
|
|
1603 | // could also be stored inside mapcell and updated on change |
|
|
1604 | memset (smooth_max, 0, sizeof (smooth_max)); |
|
|
1605 | |
|
|
1606 | for (y = 0; y < sh; y++) |
|
|
1607 | if (0 <= y + my && y + my < self->rows) |
|
|
1608 | { |
|
|
1609 | maprow *row = self->row + (y + my); |
|
|
1610 | |
|
|
1611 | for (x = 0; x < sw; x++) |
|
|
1612 | if (row->c0 <= x + mx && x + mx < row->c1) |
|
|
1613 | { |
|
|
1614 | mapcell *cell = row->col + (x + mx - row->c0); |
|
|
1615 | |
|
|
1616 | smooth_max[x + 1][y + 1] = |
|
|
1617 | MAX (self->tex [cell->tile [0]].smoothlevel, |
|
|
1618 | MAX (self->tex [cell->tile [1]].smoothlevel, |
|
|
1619 | self->tex [cell->tile [2]].smoothlevel)); |
|
|
1620 | } |
|
|
1621 | } |
|
|
1622 | |
1546 | for (z = 0; z < 3; z++) |
1623 | for (z = 0; z <= 2; z++) |
|
|
1624 | { |
|
|
1625 | memset (smooth_level, 0, sizeof (smooth_level)); |
|
|
1626 | |
1547 | for (y = 0; y < sh; y++) |
1627 | for (y = 0; y < sh; y++) |
1548 | if (0 <= y + my && y + my < self->rows) |
1628 | if (0 <= y + my && y + my < self->rows) |
1549 | { |
1629 | { |
1550 | maprow *row = self->row + (y + my); |
1630 | maprow *row = self->row + (y + my); |
1551 | |
1631 | |
1552 | for (x = 0; x < sw; x++) |
1632 | for (x = 0; x < sw; x++) |
1553 | if (row->c0 <= x + mx && x + mx < row->c1) |
1633 | if (row->c0 <= x + mx && x + mx < row->c1) |
1554 | { |
1634 | { |
1555 | mapcell *cell = row->col + (x + mx - row->c0); |
1635 | mapcell *cell = row->col + (x + mx - row->c0); |
1556 | tileid tile = cell->tile [z]; |
1636 | tileid tile = cell->tile [z]; |
|
|
1637 | |
|
|
1638 | if (tile) |
|
|
1639 | { |
|
|
1640 | maptex tex = self->tex [tile]; |
|
|
1641 | int px = (x + 1) * T - tex.w; |
|
|
1642 | int py = (y + 1) * T - tex.h; |
|
|
1643 | |
|
|
1644 | // suppressing texture state switches here |
|
|
1645 | // is only moderately effective, but worth the extra effort |
|
|
1646 | if (last_name != tex.name) |
|
|
1647 | { |
|
|
1648 | if (!tex.name) |
|
|
1649 | tex = self->tex [2]; /* missing, replace by noface */ |
|
|
1650 | |
|
|
1651 | glEnd (); |
|
|
1652 | glBindTexture (GL_TEXTURE_2D, last_name = tex.name); |
|
|
1653 | glBegin (GL_QUADS); |
|
|
1654 | } |
|
|
1655 | |
|
|
1656 | glTexCoord2f (0 , 0 ); glVertex2f (px , py ); |
|
|
1657 | glTexCoord2f (0 , tex.t); glVertex2f (px , py + tex.h); |
|
|
1658 | glTexCoord2f (tex.s, tex.t); glVertex2f (px + tex.w, py + tex.h); |
|
|
1659 | glTexCoord2f (tex.s, 0 ); glVertex2f (px + tex.w, py ); |
|
|
1660 | |
|
|
1661 | if (cell->flags && z == 2) |
|
|
1662 | { |
|
|
1663 | if (cell->flags & 1) |
|
|
1664 | { |
|
|
1665 | maptex tex = self->tex [1]; |
|
|
1666 | int px = x * T + T * 2 / 32; |
|
|
1667 | int py = y * T - T * 6 / 32; |
|
|
1668 | |
|
|
1669 | glEnd (); |
|
|
1670 | glBindTexture (GL_TEXTURE_2D, last_name = tex.name); |
|
|
1671 | glBegin (GL_QUADS); |
|
|
1672 | |
|
|
1673 | glTexCoord2f (0 , 0 ); glVertex2f (px , py ); |
|
|
1674 | glTexCoord2f (0 , tex.t); glVertex2f (px , py + T); |
|
|
1675 | glTexCoord2f (tex.s, tex.t); glVertex2f (px + T, py + T); |
|
|
1676 | glTexCoord2f (tex.s, 0 ); glVertex2f (px + T, py ); |
|
|
1677 | } |
|
|
1678 | } |
|
|
1679 | |
|
|
1680 | // update smooth hash |
|
|
1681 | if (tex.smoothtile) |
|
|
1682 | { |
|
|
1683 | skey.tile = tex.smoothtile; |
|
|
1684 | skey.level = tex.smoothlevel; |
|
|
1685 | |
|
|
1686 | smooth_level [tex.smoothlevel >> 5] |= ((uint32_t)1) << (tex.smoothlevel & 31); |
|
|
1687 | |
|
|
1688 | // add bits to current tile and all neighbours. skey.x|y is |
|
|
1689 | // shifted +1|+1 so we always stay positive. |
|
|
1690 | |
|
|
1691 | // bits is ___n cccc CCCC bbbb |
|
|
1692 | // n do not draw borders&corners |
|
|
1693 | // c draw these corners, but... |
|
|
1694 | // C ... not these |
|
|
1695 | // b draw these borders |
|
|
1696 | |
|
|
1697 | // borders: 1 ┃· 2 ━━ 4 ·┃ 8 ·· |
|
|
1698 | // ┃· ·· ·┃ ━━ |
|
|
1699 | |
|
|
1700 | // corners: 1 ┛· 2 ·┗ 4 ·· 8 ·· |
|
|
1701 | // ·· ·· ·┏ ┓· |
|
|
1702 | |
|
|
1703 | // full tile |
|
|
1704 | skey.x = x + 1; skey.y = y + 1; smooth_or_bits (smooth, &skey, 0x1000); |
|
|
1705 | |
|
|
1706 | // borders |
|
|
1707 | skey.x = x + 2; skey.y = y + 1; smooth_or_bits (smooth, &skey, 0x0091); |
|
|
1708 | skey.x = x + 1; skey.y = y + 2; smooth_or_bits (smooth, &skey, 0x0032); |
|
|
1709 | skey.x = x ; skey.y = y + 1; smooth_or_bits (smooth, &skey, 0x0064); |
|
|
1710 | skey.x = x + 1; skey.y = y ; smooth_or_bits (smooth, &skey, 0x00c8); |
|
|
1711 | |
|
|
1712 | // corners |
|
|
1713 | skey.x = x + 2; skey.y = y + 2; smooth_or_bits (smooth, &skey, 0x0100); |
|
|
1714 | skey.x = x ; skey.y = y + 2; smooth_or_bits (smooth, &skey, 0x0200); |
|
|
1715 | skey.x = x ; skey.y = y ; smooth_or_bits (smooth, &skey, 0x0400); |
|
|
1716 | skey.x = x + 2; skey.y = y ; smooth_or_bits (smooth, &skey, 0x0800); |
|
|
1717 | } |
|
|
1718 | } |
1557 | |
1719 | } |
|
|
1720 | } |
|
|
1721 | |
|
|
1722 | // go through all smoothlevels, lowest to highest, then draw. |
|
|
1723 | // this is basically counting sort |
|
|
1724 | { |
|
|
1725 | int w, b; |
|
|
1726 | |
|
|
1727 | for (w = 0; w < 256 / 32; ++w) |
|
|
1728 | { |
|
|
1729 | uint32_t smask = smooth_level [w]; |
1558 | if (tile) |
1730 | if (smask) |
|
|
1731 | for (b = 0; b < 32; ++b) |
|
|
1732 | if (smask & (((uint32_t)1) << b)) |
1559 | { |
1733 | { |
1560 | maptex tex = self->tex [tile]; |
1734 | int level = (w << 5) | b; |
1561 | int px = (x + 1) * T - tex.w; |
1735 | HE *he; |
1562 | int py = (y + 1) * T - tex.h; |
|
|
1563 | |
1736 | |
1564 | if (last_name != tex.name) |
1737 | hv_iterinit (smooth); |
|
|
1738 | while ((he = hv_iternext (smooth))) |
1565 | { |
1739 | { |
|
|
1740 | smooth_key *skey = (smooth_key *)HeKEY (he); |
|
|
1741 | IV bits = SvIVX (HeVAL (he)); |
|
|
1742 | |
1566 | if (!tex.name) |
1743 | if (!(bits & 0x1000) |
1567 | tex = self->tex [2]; /* missing, replace by noface */ |
1744 | && skey->level == level |
1568 | |
1745 | && level >= smooth_max [skey->x][skey->y]) |
1569 | glEnd (); |
|
|
1570 | glBindTexture (GL_TEXTURE_2D, last_name = tex.name); |
|
|
1571 | glBegin (GL_QUADS); |
|
|
1572 | } |
|
|
1573 | |
|
|
1574 | glTexCoord2f (0 , 0 ); glVertex2f (px , py ); |
|
|
1575 | glTexCoord2f (0 , tex.t); glVertex2f (px , py + tex.h); |
|
|
1576 | glTexCoord2f (tex.s, tex.t); glVertex2f (px + tex.w, py + tex.h); |
|
|
1577 | glTexCoord2f (tex.s, 0 ); glVertex2f (px + tex.w, py ); |
|
|
1578 | |
|
|
1579 | if (cell->flags && z == 2) |
|
|
1580 | { |
|
|
1581 | if (cell->flags & 1) |
|
|
1582 | { |
1746 | { |
1583 | maptex tex = self->tex [1]; |
1747 | maptex tex = self->tex [skey->tile]; |
1584 | int px = x * T + T * 2 / 32; |
1748 | int px = (((int)skey->x) - 1) * T; |
1585 | int py = y * T - T * 6 / 32; |
1749 | int py = (((int)skey->y) - 1) * T; |
|
|
1750 | int border = bits & 15; |
|
|
1751 | int corner = (bits >> 8) & ~(bits >> 4) & 15; |
|
|
1752 | float dx = tex.s * .0625f; // 16 images/row |
|
|
1753 | float dy = tex.t * .5f ; // 2 images/column |
1586 | |
1754 | |
|
|
1755 | // this time naively avoiding texture state changes |
|
|
1756 | // save gobs of state changes. |
|
|
1757 | if (last_name != tex.name) |
|
|
1758 | { |
|
|
1759 | if (!tex.name) |
|
|
1760 | continue; // smoothing not yet available |
|
|
1761 | |
1587 | glEnd (); |
1762 | glEnd (); |
1588 | glBindTexture (GL_TEXTURE_2D, last_name = tex.name); |
1763 | glBindTexture (GL_TEXTURE_2D, last_name = tex.name); |
1589 | glBegin (GL_QUADS); |
1764 | glBegin (GL_QUADS); |
|
|
1765 | } |
1590 | |
1766 | |
|
|
1767 | if (border) |
|
|
1768 | { |
|
|
1769 | float ox = border * dx; |
|
|
1770 | |
|
|
1771 | glTexCoord2f (ox , 0.f ); glVertex2f (px , py ); |
|
|
1772 | glTexCoord2f (ox , dy ); glVertex2f (px , py + T); |
|
|
1773 | glTexCoord2f (ox + dx, dy ); glVertex2f (px + T, py + T); |
|
|
1774 | glTexCoord2f (ox + dx, 0.f ); glVertex2f (px + T, py ); |
|
|
1775 | } |
|
|
1776 | |
|
|
1777 | if (corner) |
|
|
1778 | { |
|
|
1779 | float ox = corner * dx; |
|
|
1780 | |
1591 | glTexCoord2f (0 , 0 ); glVertex2f (px , py ); |
1781 | glTexCoord2f (ox , dy ); glVertex2f (px , py ); |
1592 | glTexCoord2f (0 , tex.t); glVertex2f (px , py + T); |
1782 | glTexCoord2f (ox , dy * 2.f); glVertex2f (px , py + T); |
1593 | glTexCoord2f (tex.s, tex.t); glVertex2f (px + T, py + T); |
1783 | glTexCoord2f (ox + dx, dy * 2.f); glVertex2f (px + T, py + T); |
1594 | glTexCoord2f (tex.s, 0 ); glVertex2f (px + T, py ); |
1784 | glTexCoord2f (ox + dx, dy ); glVertex2f (px + T, py ); |
|
|
1785 | } |
1595 | } |
1786 | } |
1596 | } |
1787 | } |
1597 | } |
1788 | } |
1598 | } |
|
|
1599 | } |
1789 | } |
|
|
1790 | } |
|
|
1791 | |
|
|
1792 | hv_clear (smooth); |
|
|
1793 | } |
1600 | |
1794 | |
1601 | glEnd (); |
1795 | glEnd (); |
1602 | |
1796 | |
1603 | glDisable (GL_TEXTURE_2D); |
1797 | glDisable (GL_TEXTURE_2D); |
1604 | glDisable (GL_BLEND); |
1798 | glDisable (GL_BLEND); |
… | |
… | |
2021 | # undef const_iv |
2215 | # undef const_iv |
2022 | }; |
2216 | }; |
2023 | |
2217 | |
2024 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
2218 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
2025 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
2219 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
|
|
2220 | |
|
|
2221 | texture_av = newAV (); |
|
|
2222 | AvREAL_off (texture_av); |
2026 | } |
2223 | } |
2027 | |
2224 | |
2028 | char * |
2225 | char * |
2029 | gl_vendor () |
2226 | gl_vendor () |
2030 | CODE: |
2227 | CODE: |
… | |
… | |
2181 | |
2378 | |
2182 | int glGenTexture () |
2379 | int glGenTexture () |
2183 | CODE: |
2380 | CODE: |
2184 | { |
2381 | { |
2185 | GLuint name; |
2382 | GLuint name; |
|
|
2383 | if (AvFILL (texture_av) >= 0) |
|
|
2384 | name = (GLuint)(size_t)av_pop (texture_av); |
|
|
2385 | else |
2186 | glGenTextures (1, &name); |
2386 | glGenTextures (1, &name); |
2187 | RETVAL = name; |
2387 | RETVAL = name; |
2188 | } |
2388 | } |
2189 | OUTPUT: |
2389 | OUTPUT: |
2190 | RETVAL |
2390 | RETVAL |
2191 | |
2391 | |
2192 | void glDeleteTexture (int name) |
2392 | void glDeleteTexture (int name) |
2193 | CODE: |
2393 | CODE: |
2194 | { |
2394 | { |
2195 | GLuint name_ = name; |
2395 | /* make a half-assed attempt at returning the memory used by the texture */ |
2196 | glDeleteTextures (1, &name_); |
2396 | /* textures are frequently being reused by cfplus anyway */ |
|
|
2397 | /*glBindTexture (GL_TEXTURE_2D, name);*/ |
|
|
2398 | /*glTexImage2D (GL_TEXTURE_2D, 0, GL_ALPHA, 0, 0, 0, GL_ALPHA, GL_UNSIGNED_BYTE, 0);*/ |
|
|
2399 | av_push (texture_av, (SV *)(size_t)name); |
|
|
2400 | /*{ GLuint name_ = name; glDeleteTextures (1, &name_); }*/ |
2197 | } |
2401 | } |
2198 | |
2402 | |
2199 | int glGenList () |
2403 | int glGenList () |
2200 | CODE: |
2404 | CODE: |
2201 | RETVAL = glGenLists (1); |
2405 | RETVAL = glGenLists (1); |