Image noise: Difference between revisions

Content added Content deleted
(python fps info)
(J: change fps display, since previous fps updated too rapidly and varied too widely to be useful)
Line 186: Line 186:
<lang j>coclass'example'
<lang j>coclass'example'
(coinsert[require)'jzopengl'
(coinsert[require)'jzopengl'

P=: 0 : 0
P=: 0 : 0
pc p nosize;
pc p nosize;
Line 195: Line 195:
timer 1;
timer 1;
)
)

timestamp=: (6!:8'') %~ 6!:9
timestamp=: (6!:8'') %~ 6!:9

create=:3 :0
create=:3 :0
ogl=:''conew'jzopengl'
ogl=:''conew'jzopengl'
frames=:0
start=: timestamp''
start=: timestamp''
sys_timer_base_=: ''1 :('p_c_paint_',(;coname''),'_')
sys_timer_base_=: ''1 :('p_c_paint_',(;coname''),'_')
wd P
wd P
)
)

p_run=: 3 : 0
p_run=: 3 : 0
''conew'example'
''conew'example'
)
)

destroy=:3 :0
destroy=:3 :0
end=:timestamp''
smoutput 'frames per second: ',":frames%end-start
wd 'timer 0'
wd 'timer 0'
destroy__ogl''
destroy__ogl''
Line 215: Line 218:
codestroy''
codestroy''
)
)

p_close=: destroy
p_close=: destroy

p_c_paint=: 3 : 0
p_c_paint=: 3 : 0
rc__ogl''
rc__ogl''
Line 225: Line 228:
glEnd''
glEnd''
show__ogl''
show__ogl''
frames=:frames+1
now=. timestamp''
wd 'pn *',":%now-start
start=:now
)
)

p_run''</lang>
p_run''</lang>


The script auto-starts when run (that last line <code><nowiki>p_run''</nowiki></code> is responsible for the auto-start.
The script auto-starts when run (that last line <code><nowiki>p_run''</nowiki></code> is responsible for the auto-start.


FPS is displayed in the window title bar.
Average FPS are displayed when the window is closed.


Frames will be updated no more often than once every millisecond, to allow for window events to be processed.
Frames will be updated no more often than once every millisecond, to allow for window events to be processed, though this is a relatively minor effect on my laptop.


FPS would probably be improved if I moved the camera so that I could eliminate the _1+2* from the noise generation line.
FPS would probably be improved if I moved the camera so that I could eliminate the _1+2* from the noise generation line.