Skip to content

Instantly share code, notes, and snippets.

@DDRBoxman
Created January 16, 2018 03:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DDRBoxman/81f690ad3cdbaadb41c9695ee507494d to your computer and use it in GitHub Desktop.
Save DDRBoxman/81f690ad3cdbaadb41c9695ee507494d to your computer and use it in GitHub Desktop.
-- haha you can only create sources in lua, python will never be allowed
-- because of its dumb global lock
obs = obslua
source_def = {}
source_def.id = "shitty_source"
source_def.output_flags = bit.bor(obs.OBS_SOURCE_VIDEO, obs.OBS_SOURCE_CUSTOM_DRAW)
source_def.get_name = function()
return "Demo Source"
end
source_def.create = function(source, settings)
local data = {}
data.chi = "adding to this number every two seconds:"
data.seconds = 0
data.inc = 0
return data
end
source_def.video_tick = function(data, seconds)
data.seconds = data.seconds + seconds
if data.seconds > 2.0 then
data.inc = data.inc + 1
print(data.chi .. " " .. data.inc)
data.seconds = data.seconds - 2.0
end
end
source_def.video_render = function(data, effect)
local solid = obs.obs_get_base_effect(obs.OBS_EFFECT_SOLID);
local color = obs.gs_effect_get_param_by_name(solid, "color");
local tech = obs.gs_effect_get_technique(solid, "Solid");
local colorVal = obs.vec4();
obs.vec4_from_rgba(colorVal, 0xFFFFFFFF);
obs.gs_effect_set_vec4(color, colorVal);
obs.gs_technique_begin(tech);
obs.gs_technique_begin_pass(tech, 0);
obs.gs_draw_sprite(NULL, 0, 200, 200);
obs.gs_technique_end_pass(tech);
obs.gs_technique_end(tech);
end
source_def.get_width = function(data)
return 200
end
source_def.get_height = function(data)
return 200
end
obs.obs_register_source(source_def)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment