This repository has been archived by the owner on Apr 28, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* don't create folder if not needed * add example for recording a video * remove old comment * add more comments * remove GL * try our own tmpdir * use GLWindow
- Loading branch information
1 parent
3de3140
commit 1f9f071
Showing
2 changed files
with
52 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
using Colors, GLVisualize, GLAbstraction, GLWindow | ||
|
||
if !isdefined(:runtests) | ||
window = glscreen() | ||
end | ||
description = """ | ||
Example of how to record a video from GLVisualize | ||
""" | ||
kitty = visualize(loadasset("cat.obj")) | ||
_view(kitty, window) | ||
|
||
# save video to report dir, or in some tmp dir we'll delete later | ||
path = if haskey(ENV, "CI_REPORT_DIR") | ||
ENV["CI_REPORT_DIR"] * "/videorecord.mkv" | ||
else | ||
homedir() | ||
end | ||
name = "" | ||
while true # for some reason, folder retured by mktempdir isn't usable -.- | ||
name = path * "/$(randstring()).mkv" | ||
isfile(name) || break | ||
end | ||
|
||
# create a stream to which we can add frames | ||
io, buffer = GLVisualize.create_video_stream(name, window) | ||
for i=1:10 # record 10 frames | ||
# do something | ||
GLAbstraction.set_arg!(kitty, :color, RGBA{Float32}(1, 0, 1-(i/10), i/10)) | ||
#render current frame | ||
# if you call @async renderloop(window) you can replace this part with yield | ||
GLWindow.render_frame(window) | ||
GLWindow.swapbuffers(window) | ||
GLWindow.poll_reactive() | ||
|
||
# add the frame from the current window | ||
GLVisualize.add_frame!(io, window, buffer) | ||
end | ||
# closing the stream will trigger writing the video! | ||
close(io) | ||
|
||
if !isdefined(:runtests) | ||
renderloop(window) | ||
end | ||
# clean up, only when we're not recording this! | ||
if !haskey(ENV, "CI_REPORT_DIR") | ||
rm(name) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters