… | |
… | |
26 | #include <string.h> |
26 | #include <string.h> |
27 | #include <stdio.h> |
27 | #include <stdio.h> |
28 | #include <stdlib.h> |
28 | #include <stdlib.h> |
29 | |
29 | |
30 | #include <SDL.h> |
30 | #include <SDL.h> |
|
|
31 | #include <SDL_thread.h> |
31 | #include <SDL_endian.h> |
32 | #include <SDL_endian.h> |
32 | #include <SDL_image.h> |
33 | #include <SDL_image.h> |
33 | #include <SDL_mixer.h> |
34 | #include <SDL_mixer.h> |
34 | #include <SDL_opengl.h> |
35 | #include <SDL_opengl.h> |
35 | |
36 | |
… | |
… | |
1974 | glDisable (GL_BLEND); |
1975 | glDisable (GL_BLEND); |
1975 | glDisable (GL_TEXTURE_2D); |
1976 | glDisable (GL_TEXTURE_2D); |
1976 | } |
1977 | } |
1977 | |
1978 | |
1978 | void |
1979 | void |
1979 | fow_texture (CFPlus::Map self, int mx, int my, int sw, int sh) |
1980 | fow_texture (CFPlus::Map self, int mx, int my, int sw, int sh, int smoothing, const char *matrix) |
1980 | PPCODE: |
1981 | PPCODE: |
1981 | { |
1982 | { |
1982 | int x, y; |
1983 | int x, y; |
1983 | int sw4 = (sw + 3) & ~3; |
1984 | int sw4 = (sw + 3) & ~3; |
1984 | SV *darkness_sv = sv_2mortal (newSV (sw4 * sh)); |
1985 | SV *darkness_sv = sv_2mortal (newSV (sw4 * sh)); |
… | |
… | |
2004 | darkness[y * sw4 + x] = cell->darkness |
2005 | darkness[y * sw4 + x] = cell->darkness |
2005 | ? 255 - (cell->darkness - 1) |
2006 | ? 255 - (cell->darkness - 1) |
2006 | : 255 - FOW_DARKNESS; |
2007 | : 255 - FOW_DARKNESS; |
2007 | } |
2008 | } |
2008 | } |
2009 | } |
|
|
2010 | |
|
|
2011 | if (smoothing) |
|
|
2012 | { |
|
|
2013 | SV *darkness2_sv = sv_2mortal (newSV (sw4 * sh)); |
|
|
2014 | uint8_t *darkness2 = (uint8_t *)SvPVX (darkness2_sv); |
|
|
2015 | |
|
|
2016 | SvPOK_only (darkness2_sv); |
|
|
2017 | SvCUR_set (darkness2_sv, sw4 * sh); |
|
|
2018 | |
|
|
2019 | for (y = 0; y < sh; ++y) |
|
|
2020 | for (x = 0; x < sw4; ++x) |
|
|
2021 | { |
|
|
2022 | float *f = (float *)matrix; |
|
|
2023 | int dx, dy; |
|
|
2024 | float sum = 0.f; |
|
|
2025 | |
|
|
2026 | for (dy = -1; dy <= 1; ++dy) |
|
|
2027 | for (dx = -1; dx <= 1; ++dx) |
|
|
2028 | { |
|
|
2029 | unsigned int x2 = x + dx; |
|
|
2030 | unsigned int y2 = y + dy; |
|
|
2031 | |
|
|
2032 | sum += (x2 < sw && y2 < sh ? darkness [y2 * sw4 + x2] : 255) * *f++; |
|
|
2033 | } |
|
|
2034 | |
|
|
2035 | darkness2 [y * sw4 + x] = sum > 255. ? 255. : sum; |
|
|
2036 | } |
|
|
2037 | |
|
|
2038 | darkness_sv = darkness2_sv; |
|
|
2039 | } |
2009 | |
2040 | |
2010 | EXTEND (SP, 3); |
2041 | EXTEND (SP, 3); |
2011 | PUSHs (sv_2mortal (newSViv (sw4))); |
2042 | PUSHs (sv_2mortal (newSViv (sw4))); |
2012 | PUSHs (sv_2mortal (newSViv (sh))); |
2043 | PUSHs (sv_2mortal (newSViv (sh))); |
2013 | PUSHs (darkness_sv); |
2044 | PUSHs (darkness_sv); |
… | |
… | |
2346 | CODE: |
2377 | CODE: |
2347 | RETVAL = (char *)glGetString (GL_EXTENSIONS); |
2378 | RETVAL = (char *)glGetString (GL_EXTENSIONS); |
2348 | OUTPUT: |
2379 | OUTPUT: |
2349 | RETVAL |
2380 | RETVAL |
2350 | |
2381 | |
2351 | char *glGetString (GLenum pname) |
2382 | const char *glGetString (GLenum pname) |
2352 | |
2383 | |
2353 | GLint glGetInteger (GLenum pname) |
2384 | GLint glGetInteger (GLenum pname) |
2354 | CODE: |
2385 | CODE: |
2355 | glGetIntegerv (pname, &RETVAL); |
2386 | glGetIntegerv (pname, &RETVAL); |
2356 | OUTPUT: |
2387 | OUTPUT: |