Skip to content

Instantly share code, notes, and snippets.

@letoram
Created November 8, 2018 09:07
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save letoram/494f4e9d6fc092e655314554f1b82822 to your computer and use it in GitHub Desktop.
with the following code available in the 'resource' namespace
(i.e. what you set with the -p argument, like:
arcan -p $HOME -H my_scripts/appl_hook.lua console
in $HOME/my_scripts/appl_hook.lua:
local grey = [[
uniform sampler2D map_tu0;
uniform float obj_opacity;
varying vec2 texco;
void main()
{
uniform sampler2D(map_tu0, texco).rgb;
float luma = 0.2126 * col.r + 0.7152 * col.g + 0.0722 * col.b;
gl_FragColor = vec4(luma, luma, luma, obj_opacity);
}
]]
local shid = build_shader(nil, grey, "GREYSCALE")
local handler
handler = function(source, status)
if status.kind == "resized" then
resize_image(source, status.width, status.height)
image_shader(source, shid)
show_image(source)
move_image(source, 0, 0)
elseif status.kind == "terminated" then
delete_image(source)
target_alloc("demo", handler)
end
end
target_alloc("demo", handler)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment