~npisanti/rl_tools

ref: 5b5e618853158665f1fa1cd998c26b2d159b74f0 rl_tools/shadercam/main.lua -rw-r--r-- 822 bytes
5b5e6188Nicola Pisanti shadercam saves also with s 3 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
require "strict"

-- settings ---------
local camw = 640
local camh = 480 

-- variables --------
local numsaved = 0
local freeze = 0

----------------------------------------------------

window.title( "" )
window.size( camw, camh )
layer.create( "def", camw, camh, 1) 

frag.load( args.get(0), "glsl" )      

cam.open(args.get(1), camw, camh )

----------------------------------------------------
function loop()
	freeze = freeze + 1
	if freeze > 0 then 
	
	    layer.open()
	    	rl.clear(0,0,0,0)
			cam.draw( 0, 0 )
	    layer.close() 
	
	   	frag.apply( "glsl" )
	end

	if key.pressed( key.space ) or key.pressed( key.s ) then 
		local filename = "shadercam_output_"..tostring(numsaved)..".png"
		layer.select("def")
		layer.save( filename )
		freeze = -40
		numsaved = numsaved + 1
		print( filename )
	end 
end