0
0
mirror of https://github.com/obsproject/obs-studio.git synced 2024-09-20 13:08:50 +02:00

frontend-tools: Fix a few issues with the clock source script

Fix the image files not being freed, and remove the unused source
definition function 'update', which was additionally calling
image_source_load with the wrong number of parameters.
This commit is contained in:
jp9000 2018-01-19 11:28:44 -08:00
parent a95a8723fb
commit f956203764

View File

@ -5,6 +5,22 @@ source_def = {}
source_def.id = "lua_clock_source"
source_def.output_flags = bit.bor(obs.OBS_SOURCE_VIDEO, obs.OBS_SOURCE_CUSTOM_DRAW)
function image_source_load(image, file)
obs.obs_enter_graphics();
obs.gs_image_file_free(image);
obs.obs_leave_graphics();
obs.gs_image_file_init(image, file);
obs.obs_enter_graphics();
obs.gs_image_file_init_texture(image);
obs.obs_leave_graphics();
if not image.loaded then
print("failed to load texture " .. file);
end
end
source_def.get_name = function()
return "Lua Clock"
end
@ -24,24 +40,13 @@ source_def.create = function(source, settings)
return data
end
function image_source_load(image, file)
source_def.destroy = function(data)
obs.obs_enter_graphics();
obs.gs_image_file_free(image);
obs.gs_image_file_free(data.image);
obs.gs_image_file_free(data.hour_image);
obs.gs_image_file_free(data.minute_image);
obs.gs_image_file_free(data.second_image);
obs.obs_leave_graphics();
obs.gs_image_file_init(image, file);
obs.obs_enter_graphics();
obs.gs_image_file_init_texture(image);
obs.obs_leave_graphics();
if not image.loaded then
print("failed to load texture " .. file);
end
end
source_def.update = function(data, settings)
image_source_load(data)
end
source_def.video_render = function(data, effect)