...
|
...
|
@@ -497,13 +497,13 @@ static void setup_seens_texture(map_type *map) |
497
|
497
|
if (map->seens_map) free(map->seens_map);
|
498
|
498
|
|
499
|
499
|
glGenTextures(1, &(map->seens_texture));
|
500
|
|
- printf("C Map seens texture: %d (%dx%d)\n", map->seens_texture, map->mwidth + 7, map->mheight + 7);
|
|
500
|
+ printf("C Map seens texture: %d (%dx%d)\n", map->seens_texture, map->w, map->h);
|
501
|
501
|
tglBindTexture(GL_TEXTURE_2D, map->seens_texture);
|
502
|
502
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
503
|
503
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
504
|
504
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
505
|
|
- glTexImage2D(GL_TEXTURE_2D, 0, 4, map->mwidth + 7, map->mheight + 7, 0, GL_BGRA, GL_UNSIGNED_BYTE, NULL);
|
506
|
|
- map->seens_map = calloc((map->mwidth + 7)*(map->mheight + 7)*4, sizeof(GLubyte));
|
|
505
|
+ glTexImage2D(GL_TEXTURE_2D, 0, 4, map->w, map->h, 0, GL_BGRA, GL_UNSIGNED_BYTE, NULL);
|
|
506
|
+ map->seens_map = calloc((map->w)*(map->h)*4, sizeof(GLubyte));
|
507
|
507
|
map->seen_changed = TRUE;
|
508
|
508
|
}
|
509
|
509
|
|
...
|
...
|
@@ -822,10 +822,6 @@ static int map_get_seensinfo(lua_State *L) |
822
|
822
|
static void map_update_seen_texture(map_type *map)
|
823
|
823
|
{
|
824
|
824
|
glBindTexture(GL_TEXTURE_2D, map->seens_texture);
|
825
|
|
-// int zx, zy;
|
826
|
|
-// glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &zx);
|
827
|
|
-// glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &zy);
|
828
|
|
-// printf("UPDATE SEENS: %dx%d vs %dx%d\n", zx,zy, map->mwidth + 7, map->mheight + 7);
|
829
|
825
|
gl_c_texture = -1;
|
830
|
826
|
|
831
|
827
|
int mx = map->used_mx;
|
...
|
...
|
@@ -833,14 +829,14 @@ static void map_update_seen_texture(map_type *map) |
833
|
829
|
GLubyte *seens = map->seens_map;
|
834
|
830
|
int ptr = 0;
|
835
|
831
|
int ii, jj;
|
836
|
|
- map->seensinfo_w = map->mwidth + 7;
|
837
|
|
- map->seensinfo_h = map->mheight + 7;
|
|
832
|
+ map->seensinfo_w = map->w;
|
|
833
|
+ map->seensinfo_h = map->h;
|
838
|
834
|
|
839
|
|
- for (jj = 0; jj < map->mheight + 7; jj++)
|
|
835
|
+ for (jj = 0; jj < map->h; jj++)
|
840
|
836
|
{
|
841
|
|
- for (ii = 0; ii < map->mwidth + 7; ii++)
|
|
837
|
+ for (ii = 0; ii < map->w; ii++)
|
842
|
838
|
{
|
843
|
|
- int i = mx - 3 + ii, j = my - 3 + jj;
|
|
839
|
+ int i = ii, j = jj;
|
844
|
840
|
if ((i < 0) || (j < 0) || (i >= map->w) || (j >= map->h))
|
845
|
841
|
{
|
846
|
842
|
seens[ptr] = 0;
|
...
|
...
|
@@ -877,7 +873,14 @@ static void map_update_seen_texture(map_type *map) |
877
|
873
|
ptr += 4;
|
878
|
874
|
}
|
879
|
875
|
}
|
880
|
|
- glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, map->mwidth + 7, map->mheight + 7, GL_BGRA, GL_UNSIGNED_BYTE, seens);
|
|
876
|
+ glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, map->w, map->h, GL_BGRA, GL_UNSIGNED_BYTE, seens);
|
|
877
|
+}
|
|
878
|
+
|
|
879
|
+static int map_update_seen_texture_lua(lua_State *L)
|
|
880
|
+{
|
|
881
|
+ map_type *map = (map_type*)auxiliar_checkclass(L, "core{map}", 1);
|
|
882
|
+ map_update_seen_texture(map);
|
|
883
|
+ return 0;
|
881
|
884
|
}
|
882
|
885
|
|
883
|
886
|
static int map_draw_seen_texture(lua_State *L)
|
...
|
...
|
@@ -886,15 +889,15 @@ static int map_draw_seen_texture(lua_State *L) |
886
|
889
|
int x = lua_tonumber(L, 2);
|
887
|
890
|
int y = lua_tonumber(L, 3);
|
888
|
891
|
int nb_keyframes = 0;
|
889
|
|
- x += -map->tile_w * 3;
|
890
|
|
- y += -map->tile_h * 3;
|
891
|
|
- int w = (map->mwidth + 7) * map->tile_w;
|
892
|
|
- int h = (map->mheight + 7) * map->tile_h;
|
|
892
|
+// x += -map->tile_w * 3;
|
|
893
|
+// y += -map->tile_h * 3;
|
|
894
|
+ int w = (map->w) * map->tile_w;
|
|
895
|
+ int h = (map->h) * map->tile_h;
|
893
|
896
|
|
894
|
897
|
int mx = map->mx;
|
895
|
898
|
int my = map->my;
|
896
|
|
- x -= map->tile_w * map->used_animdx;
|
897
|
|
- y -= map->tile_h * map->used_animdy;
|
|
899
|
+ x -= map->tile_w * (map->used_animdx + map->used_mx);
|
|
900
|
+ y -= map->tile_h * (map->used_animdy + map->used_my);
|
898
|
901
|
|
899
|
902
|
tglBindTexture(GL_TEXTURE_2D, map->seens_texture);
|
900
|
903
|
|
...
|
...
|
@@ -1186,6 +1189,7 @@ static int map_to_screen(lua_State *L) |
1186
|
1189
|
int y = luaL_checknumber(L, 3);
|
1187
|
1190
|
int nb_keyframes = luaL_checknumber(L, 4);
|
1188
|
1191
|
bool always_show = lua_toboolean(L, 5);
|
|
1192
|
+ bool changed = lua_toboolean(L, 6);
|
1189
|
1193
|
int i = 0, j = 0, z = 0;
|
1190
|
1194
|
int vert_idx = 0;
|
1191
|
1195
|
int col_idx = 0;
|
...
|
...
|
@@ -1194,7 +1198,7 @@ static int map_to_screen(lua_State *L) |
1194
|
1198
|
int my = map->my;
|
1195
|
1199
|
|
1196
|
1200
|
/* Enables Depth Testing */
|
1197
|
|
- glEnable(GL_DEPTH_TEST);
|
|
1201
|
+ //glEnable(GL_DEPTH_TEST);
|
1198
|
1202
|
|
1199
|
1203
|
GLfloat *vertices = map->vertices;
|
1200
|
1204
|
GLfloat *colors = map->colors;
|
...
|
...
|
@@ -1225,6 +1229,7 @@ static int map_to_screen(lua_State *L) |
1225
|
1229
|
mx = map->mx + (int)(adx * map->move_step / (float)map->move_max - adx);
|
1226
|
1230
|
my = map->my + (int)(ady * map->move_step / (float)map->move_max - ady);
|
1227
|
1231
|
}
|
|
1232
|
+ changed = TRUE;
|
1228
|
1233
|
}
|
1229
|
1234
|
x -= map->tile_w * animdx;
|
1230
|
1235
|
y -= map->tile_h * animdy;
|
...
|
...
|
@@ -1278,11 +1283,19 @@ static int map_to_screen(lua_State *L) |
1278
|
1283
|
}
|
1279
|
1284
|
|
1280
|
1285
|
/* Disables Depth Testing, we do not need it for the rest of the display */
|
1281
|
|
- glDisable(GL_DEPTH_TEST);
|
|
1286
|
+ //glDisable(GL_DEPTH_TEST);
|
1282
|
1287
|
|
1283
|
|
-// if (always_show && map->seen_changed)
|
1284
|
|
- if (always_show)
|
|
1288
|
+ if (always_show && changed)
|
1285
|
1289
|
{
|
|
1290
|
+ lua_getglobal(L, "game");
|
|
1291
|
+ lua_pushstring(L, "updateFOV");
|
|
1292
|
+ lua_gettable(L, -2);
|
|
1293
|
+ if (lua_isfunction(L, -1)) {
|
|
1294
|
+ lua_pushvalue(L, -2);
|
|
1295
|
+ lua_call(L, 1, 0);
|
|
1296
|
+ lua_pop(L, 1);
|
|
1297
|
+ }
|
|
1298
|
+ else lua_pop(L, 2);
|
1286
|
1299
|
map_update_seen_texture(map);
|
1287
|
1300
|
map->seen_changed = FALSE;
|
1288
|
1301
|
}
|
...
|
...
|
@@ -1409,7 +1422,7 @@ static const struct luaL_reg map_reg[] = |
1409
|
1422
|
{
|
1410
|
1423
|
{"__gc", map_free},
|
1411
|
1424
|
{"close", map_free},
|
1412
|
|
-// {"updateSeensTexture", map_update_seen_texture},
|
|
1425
|
+ {"updateSeensTexture", map_update_seen_texture_lua},
|
1413
|
1426
|
{"bindSeensTexture", map_bind_seen_texture},
|
1414
|
1427
|
{"drawSeensTexture", map_draw_seen_texture},
|
1415
|
1428
|
{"setZoom", map_set_zoom},
|
...
|
...
|
|