Skip to content
Snippets Groups Projects
Commit a11c9c0a authored by DarkGod's avatar DarkGod
Browse files

test

parent 169241ba
No related branches found
No related tags found
No related merge requests found
......@@ -963,6 +963,7 @@ core.display.newFont = function(font, size, no_cache)
font_cache[font][size] = oldNewFont(font, size)
return font_cache[font][size]
end
core.display.getFontCache = function() return font_cache end
local tmps = core.display.newFont("/data/font/Vera.ttf", 12)
local word_size_cache = {}
......
......@@ -554,6 +554,8 @@ function _M:createFBOs()
self.fbo2 = core.display.newFBO(Map.viewport.width, Map.viewport.height)
if self.gestures and self.posteffects and self.posteffects.gestures and self.posteffects.gestures.shad then self.gestures.shader = self.posteffects.gestures.shad end
self.entity_default_shader = Shader.new("map/default")
end
if self.player then self.player:updateMainShader() end
......
uniform sampler2D tex;
uniform float tick;
void main(void)
{
vec4 p = texture2D(tex, gl_TexCoord[0].xy);
gl_FragColor = p;
}
-- ToME - Tales of Maj'Eyal
-- Copyright (C) 2009 - 2015 Nicolas Casalini
--
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
--
-- Nicolas Casalini "DarkGod"
-- darkgod@te4.org
return {
frag = "map/default",
vert = nil,
args = {
tex = { texture = 0 },
},
clone = false,
permanent = true,
}
......@@ -328,12 +328,12 @@ function _M:makeDefault()
self:setDescriptor("world", "Maj'Eyal")
self:setDescriptor("difficulty", "Normal")
self:setDescriptor("permadeath", "Adventure")
self:setDescriptor("race", "Human")
self:setDescriptor("subrace", "Higher")
-- self:setDescriptor("class", "Warrior")
-- self:setDescriptor("subclass", "Berserker")
self:setDescriptor("class", "Chronomancer")
self:setDescriptor("subclass", "Paradox Mage")
self:setDescriptor("race", "Giant")
self:setDescriptor("subrace", "Ogre")
self:setDescriptor("class", "Warrior")
self:setDescriptor("subclass", "Berserker")
-- self:setDescriptor("class", "Chronomancer")
-- self:setDescriptor("subclass", "Paradox Mage")
__module_extra_info.no_birth_popup = true
self:atEnd("created")
end
......
......@@ -722,9 +722,9 @@ static int map_new(lua_State *L)
lua_pushnumber(L, map->is_hex);
lua_settable(L, LUA_REGISTRYINDEX);
map->vertices = calloc(2*4*QUADS_PER_BATCH, sizeof(GLfloat)); // 2 coords, 4 vertices per particles
map->colors = calloc(4*4*QUADS_PER_BATCH, sizeof(GLfloat)); // 4 color data, 4 vertices per particles
map->texcoords = calloc(2*4*QUADS_PER_BATCH, sizeof(GLfloat));
map->vertices = calloc(2*6*QUADS_PER_BATCH, sizeof(GLfloat)); // 2 coords, 4 vertices per particles
map->colors = calloc(4*6*QUADS_PER_BATCH, sizeof(GLfloat)); // 4 color data, 4 vertices per particles
map->texcoords = calloc(2*6*QUADS_PER_BATCH, sizeof(GLfloat));
map->displayed_x = map->displayed_y = 0;
map->w = w;
......@@ -1389,7 +1389,7 @@ static int map_get_scroll(lua_State *L)
}
#define unbatchQuads(vert, col) { \
if ((vert)) glDrawArrays(GL_QUADS, 0, (vert) / 2); \
if ((vert)) glDrawArrays(GL_TRIANGLES, 0, (vert) / 2); \
(vert) = 0; \
(col) = 0; \
}
......@@ -1403,28 +1403,34 @@ void do_quad(lua_State *L, const map_object *m, const map_object *dm, const map_
idx = *vert_idx;
vertices[idx + 0] = dx; vertices[idx + 1] = dy;
vertices[idx + 2] = map->tile_w * dw * dm->scale + dx; vertices[idx + 3] = dy;
vertices[idx + 4] = vertices[idx + 2]; vertices[idx + 5] = map->tile_h * dh * dm->scale + dy;
vertices[idx + 6] = dx; vertices[idx + 7] = vertices[idx + 5];
float x1 = dx, x2 = map->tile_w * dw * dm->scale + dx;
float y1 = dy, y2 = map->tile_h * dh * dm->scale + dy;
vertices[idx + 0] = x1; vertices[idx + 1] = y1;
vertices[idx + 2] = x2; vertices[idx + 3] = y1;
vertices[idx + 4] = x2; vertices[idx + 5] = y2;
vertices[idx + 6] = x1; vertices[idx + 7] = y1;
vertices[idx + 8] = x2; vertices[idx + 9] = y2;
vertices[idx +10] = x1; vertices[idx +11] = y2;
texcoords[idx + 0] = dm->tex_x[0] + anim; texcoords[idx + 1] = dm->tex_y[0];
texcoords[idx + 2] = dm->tex_x[0] + anim + dm->tex_factorx[0]; texcoords[idx + 3] = dm->tex_y[0];
texcoords[idx + 4] = dm->tex_x[0] + anim + dm->tex_factorx[0]; texcoords[idx + 5] = dm->tex_y[0] + dm->tex_factory[0];
texcoords[idx + 6] = dm->tex_x[0] + anim; texcoords[idx + 7] = dm->tex_y[0] + dm->tex_factory[0];
texcoords[idx + 6] = dm->tex_x[0] + anim; texcoords[idx + 7] = dm->tex_y[0];
texcoords[idx + 8] = dm->tex_x[0] + anim + dm->tex_factorx[0]; texcoords[idx + 9] = dm->tex_y[0] + dm->tex_factory[0];
texcoords[idx +10] = dm->tex_x[0] + anim; texcoords[idx +11] = dm->tex_y[0] + dm->tex_factory[0];
idx = *col_idx;
for (row = 0; row < 4; row++) {
for (row = 0; row < 6; row++) {
colors[idx + (4 * row + 0)] = r;
colors[idx + (4 * row + 1)] = g;
colors[idx + (4 * row + 2)] = b;
colors[idx + (4 * row + 3)] = a;
}
(*vert_idx) += 8;
(*col_idx) += 16;
if ((*vert_idx) >= 8*QUADS_PER_BATCH || force || dm->cb_ref != LUA_NOREF) {\
(*vert_idx) += 2 * 6;
(*col_idx) += 4 * 6;
if ((*vert_idx) >= 2 * 6 * QUADS_PER_BATCH || force || dm->cb_ref != LUA_NOREF) {\
unbatchQuads((*vert_idx), (*col_idx));
// printf(" -- unbatch1 %d %d\n", force, dm->cb_ref != LUA_NOREF);
}
......@@ -1716,7 +1722,7 @@ static int map_to_screen(lua_State *L)
glVertexPointer(2, GL_FLOAT, 0, vertices);
glColorPointer(4, GL_FLOAT, 0, colors);
// nb_draws = 0;
nb_draws = 0;
// Smooth scrolling
// If we use shaders for FOV display it means we must uses fbos for smooth scroll too
......@@ -1814,9 +1820,9 @@ static int map_to_screen(lua_State *L)
}
/* Display any leftovers */
if (vert_idx) glDrawArrays(GL_QUADS, 0, vert_idx / 2);
unbatchQuads(vert_idx, col_idx);
// printf("draws %d\n", nb_draws);
printf("draws %d\n", nb_draws);
// "Decay" displayed status for all mos
lua_rawgeti(L, LUA_REGISTRYINDEX, map->mo_list_ref);
......
......@@ -63,8 +63,8 @@ extern GLuint gl_c_shader;
}
// extern int nb_draws;
// #define glDrawArrays(a, b, c) \
// { \
// glDrawArrays((a), (b), (c)); nb_draws++; \
// }
extern int nb_draws;
#define glDrawArrays(a, b, c) \
{ \
glDrawArrays((a), (b), (c)); nb_draws++; \
}
......@@ -52,7 +52,7 @@ end
local gd = require "gd"
local ts_size_w, ts_size_h = 1024 * 4, 1024 * 4
local ts_size_w, ts_size_h = 1024 * 2, 1024 * 2
function makeSet(w, h)
local used = {}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment