Render one frame: advance the clock, update the frames and draw. Returns false once the window has been closed (or on failure).
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(WindowProxy), | intent(inout) | :: | self |
logical function frame(self) result(running) class(WindowProxy), intent(inout) :: self class(ReferenceFrame), pointer :: root real(wp) :: t integer(c_int) :: status integer(c_long_long) :: frames real(wp) :: started running = .false. if (.not. self%is_open()) return started = wall_time() root => null() if (associated(self%scene)) root => self%scene%frame() if (.not. self%scene_added) then if (associated(root)) then call root%realize(self%viewer_) if (vkf_viewer_add_node(self%viewer_, root%node()) /= 0) write(*, '(a)') 'vkframes: could not add the scene' end if if (associated(self%sky_)) then if (vkf_viewer_add_node(self%viewer_, self%sky_%node(self%viewer_)) /= 0) & write(*, '(a)') 'vkframes: could not add the sky' end if call create_huds(self) self%scene_added = .true. end if t = self%clock_%update(window_wall(self)) if (associated(self%handler)) call self%handler%before_update(self, t) if (.not. self%is_open()) return ! (closed by the handler) if (associated(root)) call self%scene%update(t, self%scene_seen) ! (once per time across windows) call update_window_light(self, root) call place_camera(self) status = vkf_viewer_frame_begin(self%viewer_) ! (to the window's events: the camera is final) self%running = status == 1 if (self%running .and. associated(self%handler)) then call self%handler%before_draw(self, t) if (associated(root) .and. self%is_open()) call root%sync() ! (frames it moved) ! the view's frame again, where before_draw left it: a view following a ! frame it moved would otherwise lag a frame behind it (jittering as ! the frames' times vary) if (self%is_open()) call track_view(self) end if if (self%running .and. self%is_open()) then call update_huds(self) self%running = vkf_viewer_frame_draw(self%viewer_) == 1 end if if (self%recording_ .and. self%running) then frames = vkf_viewer_record_frames(self%viewer_) ! (frames not drawn don't count) if (frames >= 0) then self%record_frames = frames else ! (ffmpeg failed: see its messages) if (.not. self%stop_recording()) write(*, '(a)') 'vkframes: recording failed' end if end if if (self%running) call dispatch_events(self) if (self%running) call count_frame(self, started) running = self%running .and. self%is_open() end function frame