Skip to content
Snippets Groups Projects
Commit ee29d009 authored by dg's avatar dg
Browse files

fix particles

New video option: gamma correction


git-svn-id: http://svn.net-core.org/repos/t-engine4@2608 51575b47-30f0-44d4-a5cc-537603b46e54
parent f0f70b6f
No related branches found
No related tags found
No related merge requests found
......@@ -132,5 +132,17 @@ function _M:generateList()
self.c_list:drawItem(item)
end,}
local zone = Textzone.new{width=self.c_desc.w, height=self.c_desc.h, text=string.toTString"Gamma correction setting.\nIncrease this to get a brighter display.#WHITE#"}
list[#list+1] = { zone=zone, name=string.toTString"#GOLD##{bold}#Gamma correction#WHITE##{normal}#", status=function(item)
return tostring(config.settings.gamma_correction)
end, fct=function(item)
game:registerDialog(GetQuantity.new("Gamma correction", "From 1 to 300", config.settings.gamma_correction, 300, function(qty)
game:saveSettings("gamma_correction", ("gamma_correction = %d\n"):format(qty))
config.settings.gamma_correction = qty
core.display.setGamma(config.settings.gamma_correction / 100)
self.c_list:drawItem(item)
end), 1)
end,}
self.list = list
end
......@@ -57,6 +57,7 @@ particles_density = 100
background_saves = true
mouse_cursor = true
display_fps = 30
gamma_correction = 100
]]
for i, file in ipairs(fs.list("/settings/")) do
if file:find(".cfg$") then
......@@ -84,6 +85,7 @@ game = false
-- Setup resolution
engine.Game:setResolution(config.settings.window.size, true)
core.display.setTextBlended(config.settings.aa_text)
core.display.setGamma(config.settings.gamma_correction / 100)
if not config.settings.fbo_active then core.display.disableFBO() print("Disabling FBO") end
if not config.settings.shaders_active then core.shader.disable() print("Disabling Shaders") end
......
game/modules/tome/data/gfx/shockbolt/object/money_small.png

3.34 KiB | W: | H:

game/modules/tome/data/gfx/shockbolt/object/money_small.png

6.01 KiB | W: | H:

game/modules/tome/data/gfx/shockbolt/object/money_small.png
game/modules/tome/data/gfx/shockbolt/object/money_small.png
game/modules/tome/data/gfx/shockbolt/object/money_small.png
game/modules/tome/data/gfx/shockbolt/object/money_small.png
  • 2-up
  • Swipe
  • Onion skin
......@@ -1459,6 +1459,18 @@ static int sdl_get_modes_list(lua_State *L)
return 1;
}
extern float gamma_correction;
static int sdl_set_gamma(lua_State *L)
{
if (lua_isnumber(L, 1))
{
gamma_correction = lua_tonumber(L, 1);
SDL_SetGamma(gamma_correction, gamma_correction, gamma_correction);
}
lua_pushnumber(L, gamma_correction);
return 1;
}
static const struct luaL_reg displaylib[] =
{
{"setTextBlended", set_text_aa},
......@@ -1480,6 +1492,7 @@ static const struct luaL_reg displaylib[] =
{"setWindowSize", sdl_set_window_size},
{"getModesList", sdl_get_modes_list},
{"setMouseCursor", sdl_set_mouse_cursor},
{"setGamma", sdl_set_gamma},
{NULL, NULL},
};
......
......@@ -63,6 +63,7 @@ int mouse_cursor_tex = 0, mouse_cursor_tex_ref = LUA_NOREF;
int mouse_cursor_down_tex = 0, mouse_cursor_down_tex_ref = LUA_NOREF;
int mouse_cursor_ox = 0, mouse_cursor_oy = 0;
int mousex = 0, mousey = 0;
float gamma_correction = 1;
SDL_TimerID display_timer_id = NULL;
SDL_TimerID realtime_timer_id = NULL;
......@@ -98,7 +99,7 @@ void stackDump (lua_State *L) {
case LUA_TNUMBER:
printf("%d: %g\n", i, lua_tonumber(L, i));
break;
default: printf("%d: %s\n", i, lua_typename(L, t)); break;
default: printf("%d: %s // %x\n", i, lua_typename(L, t), lua_topointer(L, i)); break;
}
i--;
}
......@@ -569,6 +570,8 @@ int resizeWindow(int width, int height)
/* Reset The View */
glLoadIdentity( );
SDL_SetGamma(gamma_correction, gamma_correction, gamma_correction);
return( TRUE );
}
......
......@@ -108,7 +108,7 @@ static int particles_free(lua_State *L)
particles_type *ps = (particles_type*)auxiliar_checkclass(L, "core{particles}", 1);
plist *l = ps->l;
printf("Deleting particle from main lua state %x :: %x\n", (int)ps->l, (int)ps);
// printf("Deleting particle from main lua state %x :: %x\n", (int)ps->l, (int)ps);
if (l && l->pt) SDL_mutexP(l->pt->lock);
......@@ -523,11 +523,9 @@ void thread_particle_run(particle_thread *pt, plist *l)
// Update
lua_rawgeti(L, LUA_REGISTRYINDEX, l->updator_ref);
lua_rawgeti(L, LUA_REGISTRYINDEX, l->emit_ref);
// printf("Updating!!!! %x %s\n", l, ps->name_def);
// stackDump (L);
if (lua_pcall(L, 1, 0, 0))
{
printf("Particle updater error %x (%d, %d): %s\n", (int)l, l->updator_ref, l->emit_ref, lua_tostring(L, -1));
printf("L(%x) Particle updater error %x (%d, %d): %s\n", (int)L, (int)l, l->updator_ref, l->emit_ref, lua_tostring(L, -1));
lua_pop(L, 1);
}
......@@ -690,11 +688,6 @@ void thread_particle_init(particle_thread *pt, plist *l)
lua_settable(L, -3);
l->emit_ref = luaL_ref(L, LUA_REGISTRYINDEX);
//
// printf("Checking!!!! %x %s\n", l, ps->name_def);
// lua_rawgeti(L, LUA_REGISTRYINDEX, l->emit_ref);
// stackDump (L);
// lua_pop(L,1);
free((char*)ps->name_def);
free((char*)ps->args);
......@@ -707,11 +700,13 @@ void thread_particle_die(particle_thread *pt, plist *l)
lua_State *L = pt->L;
particles_type *ps = l->ps;
printf("Deleting particle from list %x :: %x\n", (int)l, (int)ps);
luaL_unref(L, LUA_REGISTRYINDEX, l->emit_ref);
luaL_unref(L, LUA_REGISTRYINDEX, l->updator_ref);
luaL_unref(L, LUA_REGISTRYINDEX, l->update_ref);
// printf("Deleting particle from list %x :: %x\n", (int)l, (int)ps);
if (l->emit_ref != LUA_NOREF) luaL_unref(L, LUA_REGISTRYINDEX, l->emit_ref);
if (l->updator_ref != LUA_NOREF) luaL_unref(L, LUA_REGISTRYINDEX, l->updator_ref);
if (l->generator_ref != LUA_NOREF) luaL_unref(L, LUA_REGISTRYINDEX, l->generator_ref);
l->emit_ref = LUA_NOREF;
l->updator_ref = LUA_NOREF;
l->generator_ref = LUA_NOREF;
if (ps)
{
......@@ -746,6 +741,7 @@ int thread_particles(void *data)
SDL_SemWait(pt->keyframes);
SDL_mutexP(pt->lock);
// int nb = 0;
l = pt->list;
prev = NULL;
while (l)
......@@ -768,7 +764,9 @@ int thread_particles(void *data)
l = l->next;
}
// nb++;
}
// printf("Particels thread has %d systems\n",nb);
SDL_mutexV(pt->lock);
}
......@@ -813,7 +811,7 @@ void thread_add(particles_type *ps)
ps->l = l;
SDL_mutexV(pt->lock);
printf("New particles registered on thread %d: %s\n", cur_thread, ps->name_def);
// printf("New particles registered on thread %d: %s\n", cur_thread, ps->name_def);
cur_thread++;
if (cur_thread >= MAX_THREADS) cur_thread = 0;
......@@ -858,7 +856,7 @@ void create_particles_thread()
thread = SDL_CreateThread(thread_particles, pt);
if (thread == NULL) {
printf("Unable to create particle thread: %s\n", SDL_GetError());
return;
continue;
}
printf("Creating particles thread %d\n", pt->id);
......
......@@ -87,7 +87,6 @@ struct s_plist {
int generator_ref;
int updator_ref;
int emit_ref;
int update_ref;
struct s_particle_thread *pt;
struct s_plist *next;
};
......
......@@ -180,6 +180,7 @@ static void basic_serialize(lua_State *L, serial_type *s, int type, int idx)
writeZipFixed(s, "}\n", 2);
}
} else {
writeZipFixed(s, "nil", 3);
printf("*WARNING* can not save value of type %s\n", lua_typename(L, type));
}
}
......
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