… | |
… | |
967 | { |
967 | { |
968 | HV *hv = (HV *)SvRV (self); |
968 | HV *hv = (HV *)SvRV (self); |
969 | float s = SvNV (*hv_fetch (hv, "s", 1, 1)); |
969 | float s = SvNV (*hv_fetch (hv, "s", 1, 1)); |
970 | float t = SvNV (*hv_fetch (hv, "t", 1, 1)); |
970 | float t = SvNV (*hv_fetch (hv, "t", 1, 1)); |
971 | int name = SvIV (*hv_fetch (hv, "name", 4, 1)); |
971 | int name = SvIV (*hv_fetch (hv, "name", 4, 1)); |
972 | int wrap_mode = SvIV (*hv_fetch (hv, "wrap_mode", 9, 1)); |
|
|
973 | |
972 | |
974 | if (items < 5) |
973 | if (items < 5) |
975 | { |
974 | { |
976 | w = SvNV (*hv_fetch (hv, "w", 1, 1)); |
975 | w = SvNV (*hv_fetch (hv, "w", 1, 1)); |
977 | h = SvNV (*hv_fetch (hv, "h", 1, 1)); |
976 | h = SvNV (*hv_fetch (hv, "h", 1, 1)); |
… | |
… | |
984 | glEnable (GL_ALPHA_TEST); |
983 | glEnable (GL_ALPHA_TEST); |
985 | glAlphaFunc (GL_GREATER, 0.01f); |
984 | glAlphaFunc (GL_GREATER, 0.01f); |
986 | } |
985 | } |
987 | |
986 | |
988 | glBindTexture (GL_TEXTURE_2D, name); |
987 | glBindTexture (GL_TEXTURE_2D, name); |
989 | |
|
|
990 | if (wrap_mode) |
|
|
991 | { |
|
|
992 | glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); |
|
|
993 | glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); |
|
|
994 | } |
|
|
995 | |
988 | |
996 | glBegin (GL_QUADS); |
989 | glBegin (GL_QUADS); |
997 | glTexCoord2f (0, 0); glVertex2f (x , y ); |
990 | glTexCoord2f (0, 0); glVertex2f (x , y ); |
998 | glTexCoord2f (0, t); glVertex2f (x , y + h); |
991 | glTexCoord2f (0, t); glVertex2f (x , y + h); |
999 | glTexCoord2f (s, t); glVertex2f (x + w, y + h); |
992 | glTexCoord2f (s, t); glVertex2f (x + w, y + h); |
… | |
… | |
1080 | } |
1073 | } |
1081 | |
1074 | |
1082 | // somewhat hackish, but for textures that require it, it really |
1075 | // somewhat hackish, but for textures that require it, it really |
1083 | // improves the look, and most others don't suffer. |
1076 | // improves the look, and most others don't suffer. |
1084 | glBindTexture (GL_TEXTURE_2D, name); |
1077 | glBindTexture (GL_TEXTURE_2D, name); |
1085 | glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); |
1078 | //glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
1086 | glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); |
1079 | //glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
|
|
1080 | // use uglier nearest interpolation because linear suffers |
|
|
1081 | // from transparent color bleeding and ugly wrapping effects. |
|
|
1082 | glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
1087 | } |
1083 | } |
1088 | |
1084 | |
1089 | int |
1085 | int |
1090 | ox (CFClient::Map self) |
1086 | ox (CFClient::Map self) |
1091 | ALIAS: |
1087 | ALIAS: |
1092 | oy = 1 |
1088 | oy = 1 |
|
|
1089 | x = 2 |
|
|
1090 | y = 3 |
|
|
1091 | w = 4 |
|
|
1092 | h = 5 |
1093 | CODE: |
1093 | CODE: |
1094 | switch (ix) |
1094 | switch (ix) |
1095 | { |
1095 | { |
1096 | case 0: RETVAL = self->ox; break; |
1096 | case 0: RETVAL = self->ox; break; |
1097 | case 1: RETVAL = self->oy; break; |
1097 | case 1: RETVAL = self->oy; break; |
|
|
1098 | case 2: RETVAL = self->x; break; |
|
|
1099 | case 3: RETVAL = self->y; break; |
|
|
1100 | case 4: RETVAL = self->w; break; |
|
|
1101 | case 5: RETVAL = self->h; break; |
1098 | } |
1102 | } |
1099 | OUTPUT: |
1103 | OUTPUT: |
1100 | RETVAL |
1104 | RETVAL |
1101 | |
1105 | |
1102 | void |
1106 | void |
… | |
… | |
1562 | const_iv (GL_TEXTURE_MAG_FILTER), |
1566 | const_iv (GL_TEXTURE_MAG_FILTER), |
1563 | const_iv (GL_TEXTURE_MIN_FILTER), |
1567 | const_iv (GL_TEXTURE_MIN_FILTER), |
1564 | const_iv (GL_TEXTURE_ENV_MODE), |
1568 | const_iv (GL_TEXTURE_ENV_MODE), |
1565 | const_iv (GL_TEXTURE_WRAP_S), |
1569 | const_iv (GL_TEXTURE_WRAP_S), |
1566 | const_iv (GL_TEXTURE_WRAP_T), |
1570 | const_iv (GL_TEXTURE_WRAP_T), |
|
|
1571 | const_iv (GL_REPEAT), |
1567 | const_iv (GL_CLAMP), |
1572 | const_iv (GL_CLAMP), |
1568 | const_iv (GL_REPEAT), |
1573 | const_iv (GL_CLAMP_TO_EDGE), |
1569 | const_iv (GL_NEAREST), |
1574 | const_iv (GL_NEAREST), |
1570 | const_iv (GL_LINEAR), |
1575 | const_iv (GL_LINEAR), |
1571 | const_iv (GL_NEAREST_MIPMAP_NEAREST), |
1576 | const_iv (GL_NEAREST_MIPMAP_NEAREST), |
1572 | const_iv (GL_LINEAR_MIPMAP_NEAREST), |
1577 | const_iv (GL_LINEAR_MIPMAP_NEAREST), |
1573 | const_iv (GL_NEAREST_MIPMAP_LINEAR), |
1578 | const_iv (GL_NEAREST_MIPMAP_LINEAR), |
… | |
… | |
1685 | |
1690 | |
1686 | void glColor (float r, float g, float b, float a = 1.0) |
1691 | void glColor (float r, float g, float b, float a = 1.0) |
1687 | PROTOTYPE: @ |
1692 | PROTOTYPE: @ |
1688 | CODE: |
1693 | CODE: |
1689 | // microsoft visual "c" rounds instead of truncating... |
1694 | // microsoft visual "c" rounds instead of truncating... |
1690 | glColor4ub (MIN ((int)(r * 255.f), 255), |
1695 | glColor4ub (MIN ((int)(r * 256.f), 255), |
1691 | MIN ((int)(g * 255.f), 255), |
1696 | MIN ((int)(g * 256.f), 255), |
1692 | MIN ((int)(b * 255.f), 255), |
1697 | MIN ((int)(b * 256.f), 255), |
1693 | MIN ((int)(a * 255.f), 255)); |
1698 | MIN ((int)(a * 256.f), 255)); |
1694 | |
1699 | |
1695 | void glInterleavedArrays (int format, int stride, char *data) |
1700 | void glInterleavedArrays (int format, int stride, char *data) |
1696 | |
1701 | |
1697 | void glDrawElements (int mode, int count, int type, char *indices) |
1702 | void glDrawElements (int mode, int count, int type, char *indices) |
1698 | |
1703 | |