Open the window: width x height (logical pixels) titled title, or,
with native_window (a host window's native handle) and its
pixel_ratio, render into that window. vsync (default true): frames
are presented at the display's refresh; false: as soon as they are ready
(where the driver allows it), e.g. to measure frame times. Returns false
on failure.
A window of its own showing a scene, run until it is closed:
type(WindowProxy), target :: window
if (.not. window%open(800, 600, 'My mission')) error stop 'could not open a window'
call window%set_scene(scene)
call window%run() ! or: do while (window%frame()) ... end do
call window%close()
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(WindowProxy), | intent(inout) | :: | self | |||
| integer, | intent(in) | :: | width |
window units (logical pixels) |
||
| integer, | intent(in) | :: | height |
window units (logical pixels) |
||
| character(len=*), | intent(in), | optional | :: | title |
default 'vkframes' |
|
| integer(kind=c_long_long), | intent(in), | optional | :: | native_window |
host window's handle (0: own window) |
|
| real(kind=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 |
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