Framebuffer pixels per window unit of a host's window (as given to open or resize; 1 for a window of its own).
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(WindowProxy), | intent(in) | :: | self |
logical function open(self, width, height, title, native_window, pixel_ratio, vsync) result(ok) class(WindowProxy), intent(inout) :: self integer, intent(in) :: width, height !! window units (logical pixels) character(len=*), intent(in), optional :: title !! default 'vkframes' integer(c_long_long), intent(in), optional :: native_window !! host window's handle (0: own window) real(wp), intent(in), optional :: pixel_ratio !! framebuffer pixels per window unit (default 1) logical, intent(in), optional :: vsync !! default true: at the display's refresh; false: when ready character(len=:), allocatable :: t integer(c_long_long) :: handle real(c_double) :: ratio integer(c_int) :: sync t = 'vkframes' if (present(title)) t = title handle = 0 ratio = 1.0_c_double if (present(native_window)) handle = native_window if (present(pixel_ratio)) ratio = pixel_ratio self%pixel_ratio_ = ratio sync = 1_c_int if (present(vsync)) sync = merge(1_c_int, 0_c_int, vsync) self%viewer_ = vkf_viewer_create(int(width, c_int), int(height, c_int), t, len(t, kind=c_int), handle, ratio, sync) ok = c_associated(self%viewer_) if (.not. ok) return self%running = .true. self%scene_added = .false. self%shown => null() self%width_ = max(1, width) self%height_ = max(1, height) self%hosted = handle /= 0 call self%set_background_color(self%background) self%light_on = .true. call apply_window_light(self) call apply_camera_controls(self) end function open !> Close the window (waiting for the GPU). The scene is kept, and can be !> shown again in another window. So are the window's settings (views, !> HUD texts, sky, handler, time): [[open]] again (e.g. on a host's new !> native window, after Qt destroyed the old one) shows them as before. subroutine close(self) class(WindowProxy), intent(inout) :: self logical :: ok integer :: k if (self%recording_) ok = self%stop_recording() call forget_handles(self) if (c_associated(self%viewer_)) call vkf_viewer_delete(self%viewer_) self%viewer_ = c_null_ptr self%running = .false. do k = 1, self%n_huds ! (made again for the next viewer) if (c_associated(self%huds(k)%node)) call vkf_node_delete(self%huds(k)%node) self%huds(k)%node = c_null_ptr end do self%scene_added = .false. ! (the scene, sky and HUD given to the next viewer) self%scene_seen = -1 end subroutine close !> Framebuffer pixels per window unit of a host's window (as given to !> [[open]] or [[resize]]; 1 for a window of its own). pure real(wp) function pixel_ratio(self) class(WindowProxy), intent(in) :: self pixel_ratio = self%pixel_ratio_ end function pixel_ratio