vkf_layer Module

Fortran interfaces to the C++ VSG layer (src/vsg/vkf_layer.cpp, with src/vsg/vkf_rocky.cpp for Rocky maps and src/vsg/vkf_gui.cpp for GUI panels), and a few helpers that fill the layer's buffers in place.

Objects are opaque type(c_ptr) handles owned by the layer; release each one with its *_delete routine. Strings cross as (pointer, length). Functions returning integer(c_int) return 0 on success and -1 on failure unless documented otherwise; those returning a handle return null on failure.


Uses

  • module~~vkf_layer~~UsesGraph module~vkf_layer vkf_layer iso_c_binding iso_c_binding module~vkf_layer->iso_c_binding

Used by

  • module~~vkf_layer~~UsedByGraph module~vkf_layer vkf_layer module~vkf_artists vkf_artists module~vkf_artists->module~vkf_layer module~vkf_frames vkf_frames module~vkf_artists->module~vkf_frames module~vkf_line_chain vkf_line_chain module~vkf_artists->module~vkf_line_chain module~vkf_cache vkf_cache module~vkf_cache->module~vkf_layer module~vkf_diagnostics vkf_diagnostics module~vkf_diagnostics->module~vkf_layer module~vkf_frames->module~vkf_layer module~vkf_geometry vkf_geometry module~vkf_frames->module~vkf_geometry module~vkf_text vkf_text module~vkf_frames->module~vkf_text module~vkf_geometry->module~vkf_layer module~vkf_gui vkf_gui module~vkf_gui->module~vkf_layer module~vkf_handles vkf_handles module~vkf_handles->module~vkf_layer module~vkf_handles->module~vkf_artists module~vkf_handles->module~vkf_frames module~vkf_handles->module~vkf_geometry module~vkf_line_chain->module~vkf_layer module~vkf_model vkf_model module~vkf_model->module~vkf_layer module~vkf_model->module~vkf_frames module~vkf_shadow vkf_shadow module~vkf_shadow->module~vkf_layer module~vkf_shadow->module~vkf_frames module~vkf_sphere vkf_sphere module~vkf_shadow->module~vkf_sphere module~vkf_terrain vkf_terrain module~vkf_shadow->module~vkf_terrain module~vkf_shapes vkf_shapes module~vkf_shapes->module~vkf_layer module~vkf_shapes->module~vkf_artists module~vkf_shapes->module~vkf_frames module~vkf_sky vkf_sky module~vkf_sky->module~vkf_layer module~vkf_sky->module~vkf_text module~vkf_sphere->module~vkf_layer module~vkf_sphere->module~vkf_frames module~vkf_sphere->module~vkf_geometry module~vkf_terrain->module~vkf_layer module~vkf_terrain->module~vkf_frames module~vkf_text->module~vkf_layer module~vkf_window vkf_window module~vkf_window->module~vkf_layer module~vkf_window->module~vkf_diagnostics module~vkf_window->module~vkf_frames module~vkf_window->module~vkf_gui module~vkf_window->module~vkf_handles module~vkf_window->module~vkf_sky module~vkf_window->module~vkf_text module~vkf_hud vkf_hud module~vkf_window->module~vkf_hud module~vkf_view vkf_view module~vkf_window->module~vkf_view module~vkf_hud->module~vkf_frames module~vkf_line_segments vkf_line_segments module~vkf_line_segments->module~vkf_frames module~vkf_line_segments->module~vkf_line_chain module~vkf_view->module~vkf_frames module~vkframes vkframes module~vkframes->module~vkf_artists module~vkframes->module~vkf_cache module~vkframes->module~vkf_diagnostics module~vkframes->module~vkf_frames module~vkframes->module~vkf_gui module~vkframes->module~vkf_handles module~vkframes->module~vkf_model module~vkframes->module~vkf_shadow module~vkframes->module~vkf_shapes module~vkframes->module~vkf_sky module~vkframes->module~vkf_sphere module~vkframes->module~vkf_terrain module~vkframes->module~vkf_window module~vkframes->module~vkf_hud module~vkframes->module~vkf_line_segments module~vkframes->module~vkf_view

Interfaces

interface

  • public function vkf_cache_clear() bind(C, name="vkf_cache_clear")

    Delete the cache's files (converted fonts, compiled shaders; nothing else), and its fonts and shaders directories if left empty (not the cache directory). Returns the number of files removed, or -1 if some couldn't be.

    Arguments

    None

    Return Value integer(kind=c_int)

interface

  • public function vkf_cache_directory(buf, buflen) bind(C, name="vkf_cache_directory")

    The cache directory (src/vsg/vkf_cache.h: VKFRAMES_CACHE_DIR, or the user's cache directory; created if it doesn't exist) into buf (not null-terminated); returns its length (0: none, or it can't be created), or -1 if buf is too short.

    Arguments

    Type IntentOptional Attributes Name
    character(kind=c_char, len=1), intent(out), dimension(*) :: buf

    the directory (not null-terminated)

    integer(kind=c_int), value :: buflen

    the length of buf

    Return Value integer(kind=c_int)

interface

  • public function vkf_compile_node(node) bind(C, name="vkf_compile_node")

    Compile a node for the running viewers (to add it to a shown scene). Viewers not yet running compile it with their scene at their first frame. Returns 0 on success.

    Arguments

    Type IntentOptional Attributes Name
    type(c_ptr), value :: node

    node handle

    Return Value integer(kind=c_int)

interface

  • public subroutine vkf_driver_preload() bind(C, name="vkf_driver_preload")

    Start loading the Vulkan driver, on a thread of its own, for the first window (see DriverPreload in vkf_layer.cpp): called when a scene is set up, before its window opens.

    Arguments

    None

interface

  • public subroutine vkf_font_delete(font) bind(C, name="vkf_font_delete")

    Delete a font handle.

    Arguments

    Type IntentOptional Attributes Name
    type(c_ptr), value :: font

    font handle (vkf_font_read)

interface

  • public function vkf_font_read(filename, filename_len) bind(C, name="vkf_font_read")

    Read a font file (TrueType, ... through vsgXchange's freetype): a font handle, or null on failure. Converting a font takes seconds, so the result is cached and read from there next time.

    Arguments

    Type IntentOptional Attributes Name
    character(kind=c_char, len=1), intent(in), dimension(*) :: filename
    integer(kind=c_int), value :: filename_len

    the length of filename

    Return Value type(c_ptr)

interface

  • public subroutine vkf_gui_begin(gui, title, title_len, x, y, pivot_x, pivot_y, follow) bind(C, name="vkf_gui_begin")

    Begin a panel: the widgets up to vkf_gui_end are in it.

    Arguments

    Type IntentOptional Attributes Name
    type(c_ptr), value :: gui

    GUI handle (vkf_viewer_gui)

    character(kind=c_char, len=1), intent(in) :: title(*)

    panel title ("##name": no title bar, e.g. a callout)

    integer(kind=c_int), value :: title_len

    the length of title

    real(kind=c_double), value :: x

    position (0 to 1 across the window, y up; x < 0: where ImGui puts it)

    real(kind=c_double), value :: y

    position (0 to 1 across the window, y up; x < 0: where ImGui puts it)

    real(kind=c_double), value :: pivot_x

    the panel's point placed there (0 to 1 across it, from the top left)

    real(kind=c_double), value :: pivot_y

    the panel's point placed there (0 to 1 across it, from the top left)

    integer(kind=c_int), value :: follow

    not 0: placed at (x, y) every frame (and not movable), else only at first

interface

  • public function vkf_gui_button(gui, label, label_len) bind(C, name="vkf_gui_button")

    A button: 1 if it was clicked since the last call for it (in this panel), else 0.

    Arguments

    Type IntentOptional Attributes Name
    type(c_ptr), value :: gui

    GUI handle (vkf_viewer_gui)

    character(kind=c_char, len=1), intent(in) :: label(*)
    integer(kind=c_int), value :: label_len

    the length of label

    Return Value integer(kind=c_int)

interface

  • public function vkf_gui_checkbox(gui, label, label_len, value) bind(C, name="vkf_gui_checkbox")

    A checkbox showing value: 1 (and value set) if the user changed it since the last call for it, else 0.

    Arguments

    Type IntentOptional Attributes Name
    type(c_ptr), value :: gui

    GUI handle (vkf_viewer_gui)

    character(kind=c_char, len=1), intent(in) :: label(*)
    integer(kind=c_int), value :: label_len

    the length of label

    integer(kind=c_int), intent(inout) :: value

    1 checked, 0 not

    Return Value integer(kind=c_int)

interface

  • public function vkf_gui_combo(gui, label, label_len, index, items, items_len) bind(C, name="vkf_gui_combo")

    A combo box (drop-down menu) of items (newline-separated), showing item index (0-based): 1 (and index set) if the user chose another since the last call for it, else 0.

    Arguments

    Type IntentOptional Attributes Name
    type(c_ptr), value :: gui

    GUI handle (vkf_viewer_gui)

    character(kind=c_char, len=1), intent(in) :: label(*)
    integer(kind=c_int), value :: label_len

    the length of label

    integer(kind=c_int), intent(inout) :: index
    character(kind=c_char, len=1), intent(in) :: items(*)
    integer(kind=c_int), value :: items_len

    the length of items

    Return Value integer(kind=c_int)

interface

  • public subroutine vkf_gui_end(gui) bind(C, name="vkf_gui_end")

    End the panel begun by vkf_gui_begin.

    Arguments

    Type IntentOptional Attributes Name
    type(c_ptr), value :: gui

    GUI handle (vkf_viewer_gui)

interface

  • public subroutine vkf_gui_same_line(gui) bind(C, name="vkf_gui_same_line")

    Put the next widget on the same line as the last one.

    Arguments

    Type IntentOptional Attributes Name
    type(c_ptr), value :: gui

    GUI handle (vkf_viewer_gui)

interface

  • public subroutine vkf_gui_separator(gui) bind(C, name="vkf_gui_separator")

    A horizontal separator in the current panel.

    Arguments

    Type IntentOptional Attributes Name
    type(c_ptr), value :: gui

    GUI handle (vkf_viewer_gui)

interface

  • public function vkf_gui_slider(gui, label, label_len, value, low, high, format, format_len) bind(C, name="vkf_gui_slider")

    A slider showing value from low to high (as format, printf's; empty: "%.4g"): 1 (and value set) if the user changed it since the last call for it, else 0.

    Arguments

    Type IntentOptional Attributes Name
    type(c_ptr), value :: gui

    GUI handle (vkf_viewer_gui)

    character(kind=c_char, len=1), intent(in) :: label(*)
    integer(kind=c_int), value :: label_len

    the length of label

    real(kind=c_double), intent(inout) :: value
    real(kind=c_double), value :: low

    the slider's range

    real(kind=c_double), value :: high

    the slider's range

    character(kind=c_char, len=1), intent(in) :: format(*)
    integer(kind=c_int), value :: format_len

    the length of format (0: the default)

    Return Value integer(kind=c_int)

interface

  • public subroutine vkf_gui_text(gui, text, text_len) bind(C, name="vkf_gui_text")

    A line of text in the current panel.

    Arguments

    Type IntentOptional Attributes Name
    type(c_ptr), value :: gui

    GUI handle (vkf_viewer_gui)

    character(kind=c_char, len=1), intent(in) :: text(*)
    integer(kind=c_int), value :: text_len

    the length of text

interface

  • public subroutine vkf_image_delete(image) bind(C, name="vkf_image_delete")

    Delete an image handle.

    Arguments

    Type IntentOptional Attributes Name
    type(c_ptr), value :: image

    image handle (vkf_image_read)

interface

  • public function vkf_image_read(filename, filename_len) bind(C, name="vkf_image_read")

    Read an image file (png, jpg, ...): an image handle, or null on failure.

    Arguments

    Type IntentOptional Attributes Name
    character(kind=c_char, len=1), intent(in), dimension(*) :: filename
    integer(kind=c_int), value :: filename_len

    the length of filename

    Return Value type(c_ptr)

interface

  • public function vkf_label_create(font, text, text_len, rgba, position, size, max_size, halign, valign) bind(C, name="vkf_label_create")

    A label (a node handle): text at position, facing the screen; null on failure.

    Arguments

    Type IntentOptional Attributes Name
    type(c_ptr), value :: font

    font handle (vkf_font_read)

    character(kind=c_char, len=1), intent(in), dimension(*) :: text
    integer(kind=c_int), value :: text_len

    the length of text

    real(kind=c_float), intent(in), dimension(4) :: rgba

    color (rgba, 0 to 1)

    real(kind=c_double), intent(in), dimension(3) :: position

    in its parent's coordinates

    real(kind=c_float), value :: size

    0: size window units tall (a fixed screen size); < 0: -size scene units tall, but at most max_size on screen

    real(kind=c_float), value :: max_size

    the most window units tall on screen (size < 0)

    integer(kind=c_int), value :: halign

    (vsg::StandardLayout's alignments (0 baseline, 1 left/top, 2 center, 3 right/bottom))

    integer(kind=c_int), value :: valign

    (vsg::StandardLayout's alignments (0 baseline, 1 left/top, 2 center, 3 right/bottom))

    Return Value type(c_ptr)

interface

  • public function vkf_label_set_at_infinity(label, on) bind(C, name="vkf_label_set_at_infinity")

    Draw a label at infinity (on /= 0: its position a direction, in its parent's axes; at the far plane, behind the scene, as the sky's stars) or at its position (0). Returns 0, or -1 if not a label.

    Arguments

    Type IntentOptional Attributes Name
    type(c_ptr), value :: label

    label handle (vkf_label_create)

    integer(kind=c_int), value :: on

    1: at infinity; 0: at its position

    Return Value integer(kind=c_int)

interface

  • public function vkf_label_set_color(label, rgba) bind(C, name="vkf_label_set_color")

    Change a label's color. Returns 0, or -1 on failure.

    Arguments

    Type IntentOptional Attributes Name
    type(c_ptr), value :: label

    label handle (vkf_label_create)

    real(kind=c_float), intent(in), dimension(4) :: rgba

    color (rgba, 0 to 1)

    Return Value integer(kind=c_int)

interface

  • public function vkf_label_set_layout(label, position, size, max_size, halign, valign) bind(C, name="vkf_label_set_layout")

    Change a label's layout, in place. Returns 0, or -1 on failure.

    Arguments

    Type IntentOptional Attributes Name
    type(c_ptr), value :: label

    label handle (vkf_label_create)

    real(kind=c_double), intent(in) :: position(3)

    as vkf_label_create's

    real(kind=c_float), value :: size

    as vkf_label_create's

    real(kind=c_float), value :: max_size

    as vkf_label_create's

    integer(kind=c_int), value :: halign

    as vkf_label_create's

    integer(kind=c_int), value :: valign

    as vkf_label_create's

    Return Value integer(kind=c_int)

interface

  • public function vkf_label_set_on_top(label, on) bind(C, name="vkf_label_set_on_top")

    Draw a label on top of the scene (at the near plane, as HUD labels: not hidden by what is in front of it) or depth-tested. Returns 0, or -1 on failure.

    Arguments

    Type IntentOptional Attributes Name
    type(c_ptr), value :: label

    label handle (vkf_label_create)

    integer(kind=c_int), value :: on

    not 0: on top; 0: depth-tested

    Return Value integer(kind=c_int)

interface

  • public function vkf_label_set_text(label, text, text_len) bind(C, name="vkf_label_set_text")

    Change a label's text, in place: a text longer than the label's capacity (glyphs allocated when it was made) is cut to it, with a warning. Returns 0, or -1 on failure.

    Arguments

    Type IntentOptional Attributes Name
    type(c_ptr), value :: label

    label handle (vkf_label_create)

    character(kind=c_char, len=1), intent(in), dimension(*) :: text
    integer(kind=c_int), value :: text_len

    the length of text

    Return Value integer(kind=c_int)

interface

  • public function vkf_light_create() bind(C, name="vkf_light_create")

    A light (a node handle), initially a directional light along -z (in its node's coordinates) of white diffuse color and no ambient or specular part; null on failure.

    Arguments

    None

    Return Value type(c_ptr)

interface

  • public function vkf_light_set(light, ambient, diffuse, specular, position) bind(C, name="vkf_light_set")

    Set a light's colors and position, in its node's coordinates. Returns 0 (-1 for a bad handle).

    Arguments

    Type IntentOptional Attributes Name
    type(c_ptr), value :: light

    light handle (vkf_light_create, vkf_viewer_light)

    real(kind=c_float), intent(in), dimension(3) :: ambient

    colors (rgb, 0 to 1)

    real(kind=c_float), intent(in), dimension(3) :: diffuse

    colors (rgb, 0 to 1)

    real(kind=c_float), intent(in), dimension(3) :: specular

    colors (rgb, 0 to 1)

    real(kind=c_double), intent(in), dimension(4) :: position

    OpenGL's (x, y, z, w): w = 0 for a directional light from direction (x, y, z), else a point light at (x/w, y/w, z/w)

    Return Value integer(kind=c_int)

interface

  • public function vkf_line_colors(line, capacity) bind(C, name="vkf_line_colors")

    The colors (4 floats per point) of a line made by vkf_line_create_colored (null for others).

    Arguments

    Type IntentOptional Attributes Name
    type(c_ptr), value :: line

    line or ribbon handle

    integer(kind=c_int), intent(out) :: capacity

    the buffer's capacity (points)

    Return Value type(c_ptr)

interface

  • public function vkf_line_create(capacity) bind(C, name="vkf_line_create")

    A line strip holding up to capacity points (initially none): a node handle, or null on failure. Fortran fills its point and style buffers in place (vkf_line_points, vkf_line_style), then calls vkf_line_points_changed / vkf_line_style_changed. It can be shown in any number of windows.

    Arguments

    Type IntentOptional Attributes Name
    integer(kind=c_int), value :: capacity

    the most points

    Return Value type(c_ptr)

interface

  • public function vkf_line_create_colored(capacity) bind(C, name="vkf_line_create_colored")

    A line with a color per point (vkf_line_colors), blended along each segment. A node handle, or null on failure.

    Arguments

    Type IntentOptional Attributes Name
    integer(kind=c_int), value :: capacity

    the most points

    Return Value type(c_ptr)

interface

  • public function vkf_line_points(line, capacity) bind(C, name="vkf_line_points")

    A line's point buffer, 8 floats per point (x, y, z and the distance along the strip from its start, high parts, then their low parts; see shaders/line.vert; markers ignore the distance), to fill in place; valid while the line handle exists. Null on failure.

    Arguments

    Type IntentOptional Attributes Name
    type(c_ptr), value :: line

    line, marker or ribbon handle

    integer(kind=c_int), intent(out) :: capacity

    the buffer's capacity (points)

    Return Value type(c_ptr)

interface

  • public function vkf_line_points_changed(line, n) bind(C, name="vkf_line_points_changed")

    The first n points of the buffer have been written: draw n points and upload the buffer. Returns 0, or -1 if n exceeds the capacity.

    Arguments

    Type IntentOptional Attributes Name
    type(c_ptr), value :: line

    line, marker or ribbon handle

    integer(kind=c_int), value :: n

    the number of points

    Return Value integer(kind=c_int)

interface

  • public function vkf_line_set_dash_mode(line, mode, length) bind(C, name="vkf_line_set_dash_mode")

    A line's dashes: screen 1 screen-locked (a constant length in pixels, following the line on screen), 0 anchored to the line (the default). Returns 0, or -1 if line isn't a line.

    Arguments

    Type IntentOptional Attributes Name
    type(c_ptr), value :: line

    line handle

    integer(kind=c_int), value :: mode

    0 anchored, 1 screen-locked, 2 a fixed length

    real(kind=c_double), value :: length

    (2) the pattern's length, scene units (0: from the first view)

    Return Value integer(kind=c_int)

interface

  • public function vkf_line_set_highlight(line, values) bind(C, name="vkf_line_set_highlight")

    Set a line's highlight (shaders/line.vert) and upload it: values are its color (rgba), (flags: 1 pulse, 2 arrows; arrow spacing (window units), arrow speed (window units per second), band width (window units)), (pulse period (s), 0, 0, 0). Returns 0, or -1 if line isn't a line.

    Arguments

    Type IntentOptional Attributes Name
    type(c_ptr), value :: line

    line handle

    real(kind=c_float), intent(in), dimension(12) :: values

    Return Value integer(kind=c_int)

interface

  • public function vkf_line_set_lod(line, center, radius, error, levels) bind(C, name="vkf_line_set_lod")

    A line strip's level of detail: the bounding sphere of its points and error(k): how far the points skipped can be from the segments drawn at stride 2^k (k = 1 .. levels). Returns 0, or -1 on failure.

    Arguments

    Type IntentOptional Attributes Name
    type(c_ptr), value :: line

    line handle

    real(kind=c_double), intent(in), dimension(3) :: center

    bounding sphere center

    real(kind=c_double), value :: radius

    bounding sphere radius

    real(kind=c_float), intent(in), dimension(*) :: error

    (levels), in the points' units

    integer(kind=c_int), value :: levels

    (0: all points drawn)

    Return Value integer(kind=c_int)

interface

  • public function vkf_line_set_range(line, first, n) bind(C, name="vkf_line_set_range")

    Draw only points first .. first+n-1 (no data is uploaded): e.g. for trace mode. (Separate segments: first odd, n even.) Returns 0, or -1 on failure (out of range).

    Arguments

    Type IntentOptional Attributes Name
    type(c_ptr), value :: line

    line, marker or ribbon handle

    integer(kind=c_int), value :: first

    the first point (1-based) and the number of points

    integer(kind=c_int), value :: n

    the first point (1-based) and the number of points

    Return Value integer(kind=c_int)

interface

  • public function vkf_line_set_trail(line, values) bind(C, name="vkf_line_set_trail")

    Set a line strip's trail (shaders/line.vert) and upload it: values are (the distance at the current time as a high/low pair, the direction (1, -1; 0: no trail), the color flags), (the past's cutoff and fade start, the future's fade start and cutoff: distances from the current time's), the past's color (rgba), the future's, (the past's dash pattern and factor, the future's). Returns 0, or -1 if line isn't a line strip.

    Arguments

    Type IntentOptional Attributes Name
    type(c_ptr), value :: line

    line handle

    real(kind=c_float), intent(in), dimension(20) :: values

    Return Value integer(kind=c_int)

interface

  • public function vkf_line_style(line) bind(C, name="vkf_line_style")

    A line's style buffer: 8 floats (r, g, b, a, width in window units, 1 for separate segments (pairs of points) or 0 for a strip, the dash pattern (16 bits; 65535 or 0: solid), window units per bit of it). Set the segment flag before drawing points. Null on failure.

    Arguments

    Type IntentOptional Attributes Name
    type(c_ptr), value :: line

    line, marker or ribbon handle

    Return Value type(c_ptr)

interface

  • public function vkf_line_style_changed(line) bind(C, name="vkf_line_style_changed")

    Upload a line's style again after writing it (vkf_line_style). Returns 0, or -1 on failure.

    Arguments

    Type IntentOptional Attributes Name
    type(c_ptr), value :: line

    line, marker or ribbon handle

    Return Value integer(kind=c_int)

interface

  • public function vkf_marker_create(capacity, image, colored) bind(C, name="vkf_marker_create")

    Markers at up to capacity points (initially none): a screen-space quad per point, of the shape and size in the style buffer (shaders/marker.vert); a node handle, or null on failure. The point and style buffers are those of a line (vkf_line_points, vkf_line_style, vkf_line_points_changed, vkf_line_set_range, vkf_line_style_changed); with colored (1), a color per marker (vkf_line_colors), times the style's.

    Arguments

    Type IntentOptional Attributes Name
    integer(kind=c_int), value :: capacity

    the most points

    type(c_ptr), value :: image

    image handle (vkf_image_read) for the image shape, or null

    integer(kind=c_int), value :: colored

    1: a color per marker, 0: the style's only

    Return Value type(c_ptr)

interface

  • public function vkf_mesh_array(mesh, which) bind(C, name="vkf_mesh_array")

    One of the mesh's arrays, to fill in place; valid while the mesh handle exists.

    Arguments

    Type IntentOptional Attributes Name
    type(c_ptr), value :: mesh

    mesh handle (vkf_mesh_create)

    integer(kind=c_int), value :: which

    1 = vertices (3 floats each), 2 = normals (3 floats), 3 = texture coordinates (2 floats), 4 = triangle indices (uint32, 0-based)

    Return Value type(c_ptr)

interface

  • public function vkf_mesh_create(n_vertices, n_indices, rgba, texture, night_texture, flags) bind(C, name="vkf_mesh_create")

    Arguments

    Type IntentOptional Attributes Name
    integer(kind=c_int), value :: n_vertices

    number of vertices

    integer(kind=c_int), value :: n_indices

    number of triangle indices

    real(kind=c_float), intent(in), dimension(4) :: rgba

    color (rgba, 0 to 1; multiplies the texture)

    type(c_ptr), value :: texture

    image handles (vkf_image_read), or null

    type(c_ptr), value :: night_texture

    image handles (vkf_image_read), or null

    integer(kind=c_int), value :: flags

    1 for an unlit transparent surface (no textures), 2 for view lighting (frames' axes), else lit by the scene's lights with a material (vkf_mesh_material); plus 4 for vertices that change after the mesh is compiled (rewritten in place, then vkf_mesh_vertices_changed); plus 8 for a lit translucent surface (depth sorted: vkf_mesh_set_bound); plus 16 two-sided (lit: no faces culled); plus 32 a color per vertex (vkf_mesh_array 5; rgba each one's initial color)

    Return Value type(c_ptr)

interface

  • public function vkf_mesh_material(mesh) bind(C, name="vkf_mesh_material")

    The material of a lit mesh: 19 floats (vsg::PhongMaterial: ambient, diffuse, specular, emissive rgba, shininess, alpha mask, alpha mask cutoff); call vkf_mesh_material_changed after writing them. Null for a mesh without one.

    Arguments

    Type IntentOptional Attributes Name
    type(c_ptr), value :: mesh

    mesh handle (vkf_mesh_create)

    Return Value type(c_ptr)

interface

  • public function vkf_mesh_material_changed(mesh) bind(C, name="vkf_mesh_material_changed")

    Upload a mesh's material again after writing it (vkf_mesh_material). Returns 0, or -1 on failure.

    Arguments

    Type IntentOptional Attributes Name
    type(c_ptr), value :: mesh

    mesh handle (vkf_mesh_create)

    Return Value integer(kind=c_int)

interface

  • public function vkf_mesh_set_bound(mesh, x, y, z, radius) bind(C, name="vkf_mesh_set_bound")

    A triangle mesh (a node handle), filled from Fortran (vkf_mesh_array, before the first frame); null on failure. A translucent mesh's bounding sphere (its coordinates), for depth sorting and culling. Returns 0, or -1 if it isn't a translucent mesh (vkf_mesh_create's flag 8).

    Arguments

    Type IntentOptional Attributes Name
    type(c_ptr), value :: mesh

    mesh handle (vkf_mesh_create)

    real(kind=c_double), value :: x

    the bound's center and radius

    real(kind=c_double), value :: y

    the bound's center and radius

    real(kind=c_double), value :: z

    the bound's center and radius

    real(kind=c_double), value :: radius

    the bound's center and radius

    Return Value integer(kind=c_int)

interface

  • public function vkf_mesh_set_twilight(mesh, angle) bind(C, name="vkf_mesh_set_twilight")

    A lit mesh's twilight: its diffuse light extended to angle (radians) past the terminator, fading out (0: none). Returns 0, or -1 on failure.

    Arguments

    Type IntentOptional Attributes Name
    type(c_ptr), value :: mesh

    mesh handle (vkf_mesh_create)

    real(kind=c_float), value :: angle

    radians

    Return Value integer(kind=c_int)

interface

  • public function vkf_mesh_vertices_changed(mesh) bind(C, name="vkf_mesh_vertices_changed")

    Upload a mesh's vertices again after rewriting them in place (a mesh created with flag 4). Returns 0, or -1 on failure.

    Arguments

    Type IntentOptional Attributes Name
    type(c_ptr), value :: mesh

    mesh handle (vkf_mesh_create)

    Return Value integer(kind=c_int)

interface

  • public function vkf_model_read(filename, filename_len) bind(C, name="vkf_model_read")

    Read a model file (3ds, obj, gltf, ...): a node handle, or null on failure.

    Arguments

    Type IntentOptional Attributes Name
    character(kind=c_char, len=1), intent(in), dimension(*) :: filename
    integer(kind=c_int), value :: filename_len

    the length of filename

    Return Value type(c_ptr)

interface

  • public function vkf_node_add_child(parent, child) bind(C, name="vkf_node_add_child")

    Add a child to a group node (a transform or a switch); while running, compile the child first (vkf_compile_node). Returns 0, or -1 on failure.

    Arguments

    Type IntentOptional Attributes Name
    type(c_ptr), value :: parent

    node handles

    type(c_ptr), value :: child

    node handles

    Return Value integer(kind=c_int)

interface

  • public function vkf_node_bound(node, center, radius) bind(C, name="vkf_node_bound")

    Bounding sphere of a node in its own coordinates. Returns 0, or -1 if the node is empty.

    Arguments

    Type IntentOptional Attributes Name
    type(c_ptr), value :: node

    node handle

    real(kind=c_double), intent(out), dimension(3) :: center
    real(kind=c_double), intent(out) :: radius

    Return Value integer(kind=c_int)

interface

  • public subroutine vkf_node_delete(node) bind(C, name="vkf_node_delete")

    Delete a node handle (a scene or parent that holds the node keeps it).

    Arguments

    Type IntentOptional Attributes Name
    type(c_ptr), value :: node

    node handle

interface

  • public function vkf_node_remove_child(parent, child) bind(C, name="vkf_node_remove_child")

    Remove a child from a group node (a transform or a switch), also while running: its GPU data are released a few frames later. Returns 0, or -1 if it is not a child.

    Arguments

    Type IntentOptional Attributes Name
    type(c_ptr), value :: parent

    node handles

    type(c_ptr), value :: child

    node handles

    Return Value integer(kind=c_int)

interface

  • public function vkf_ribbon_create(capacity, colored) bind(C, name="vkf_ribbon_create")

    A ribbon of up to capacity points (even): a translucent surface through pairs of points, a quad between each pair and the next; a color per point (vkf_line_colors) if colored is not 0. The buffers are a line's. A node handle, or null on failure.

    Arguments

    Type IntentOptional Attributes Name
    integer(kind=c_int), value :: capacity

    the most points (even)

    integer(kind=c_int), value :: colored

    not 0: a color per point

    Return Value type(c_ptr)

interface

  • public function vkf_rocky_add_elevation(map, kind, uri, uri_len, encoding) bind(C, name="vkf_rocky_add_elevation")

    Add an elevation layer to a map. Returns 0, or -1 on failure.

    Arguments

    Type IntentOptional Attributes Name
    type(c_ptr), value :: map

    map handle (vkf_rocky_map_create)

    integer(kind=c_int), value :: kind

    as vkf_rocky_add_image's

    character(kind=c_char, len=1), intent(in), dimension(*) :: uri
    integer(kind=c_int), value :: uri_len

    the length of uri

    integer(kind=c_int), value :: encoding

    0 single-channel heights (meters), 1 Mapbox RGB, 2 Terrarium RGB

    Return Value integer(kind=c_int)

interface

  • public function vkf_rocky_add_image(map, kind, uri, uri_len) bind(C, name="vkf_rocky_add_image")

    Add an image layer to a map. Returns 0, or -1 on failure.

    Arguments

    Type IntentOptional Attributes Name
    type(c_ptr), value :: map

    map handle (vkf_rocky_map_create)

    integer(kind=c_int), value :: kind

    0 a TMS service (uri its root), 1 a file or service GDAL reads, 2 a template ({z}, {x}, {y}) of geodetic tiles on the map's body, rows from the top (WMTS-style, e.g. NASA's Moon Trek), 3 a template of web Mercator tiles (OpenStreetMap-style)

    character(kind=c_char, len=1), intent(in), dimension(*) :: uri
    integer(kind=c_int), value :: uri_len

    the length of uri

    Return Value integer(kind=c_int)

interface

  • public function vkf_rocky_available() bind(C, name="vkf_rocky_available")

    1 if vkframes was built with Rocky, else 0.

    Arguments

    None

    Return Value integer(kind=c_int)

interface

  • public function vkf_rocky_elevation(uri, uri_len, profile, profile_len, lat, lon, ok) bind(C, name="vkf_rocky_elevation")

    The height (meters) of the elevation data in a file (GDAL) at a latitude and longitude on the body of a Rocky profile, sampled directly (no map or window needed; files are kept open for later samples).

    Arguments

    Type IntentOptional Attributes Name
    character(kind=c_char, len=1), intent(in), dimension(*) :: uri

    the file, and the profile (as vkf_rocky_map_create)

    integer(kind=c_int), value :: uri_len

    the lengths of uri and profile

    character(kind=c_char, len=1), intent(in), dimension(*) :: profile

    the file, and the profile (as vkf_rocky_map_create)

    integer(kind=c_int), value :: profile_len

    the lengths of uri and profile

    real(kind=c_double), value :: lat

    latitude and longitude (degrees)

    real(kind=c_double), value :: lon

    latitude and longitude (degrees)

    integer(kind=c_int), intent(out) :: ok

    1 if there was data there

    Return Value real(kind=c_double)

interface

  • public function vkf_rocky_map_alive(map) bind(C, name="vkf_rocky_map_alive")

    1 while a map can be drawn (the viewer it was made for exists), else 0.

    Arguments

    Type IntentOptional Attributes Name
    type(c_ptr), value :: map

    map handle (vkf_rocky_map_create)

    Return Value integer(kind=c_int)

interface

  • public function vkf_rocky_map_create(viewer, profile, profile_len, scale) bind(C, name="vkf_rocky_map_create")

    A map for the viewer (a node handle: vkf_node_*); null without Rocky or on failure.

    Arguments

    Type IntentOptional Attributes Name
    type(c_ptr), value :: viewer

    viewer handle (vkf_viewer_create)

    character(kind=c_char, len=1), intent(in), dimension(*) :: profile

    Rocky's profile (e.g. "global-geodetic", "global-qsc", "moon"; empty: Rocky's default)

    integer(kind=c_int), value :: profile_len

    the length of profile

    real(kind=c_double), value :: scale

    scene units per meter

    Return Value type(c_ptr)

interface

  • public function vkf_rocky_map_radius(map) bind(C, name="vkf_rocky_map_radius")

    The equatorial radius of a map's body (meters); 0 without Rocky or on failure.

    Arguments

    Type IntentOptional Attributes Name
    type(c_ptr), value :: map

    map handle (vkf_rocky_map_create)

    Return Value real(kind=c_double)

interface

  • public function vkf_rocky_map_settings(map, lighting, background) bind(C, name="vkf_rocky_map_settings")

    A map's settings. Returns 0, or -1 on failure.

    Arguments

    Type IntentOptional Attributes Name
    type(c_ptr), value :: map

    map handle (vkf_rocky_map_create)

    integer(kind=c_int), value :: lighting

    (1: lit by the scene's lights, as vkframes' spheres; 0: imagery as is (Rocky's default))

    real(kind=c_float), intent(in), dimension(4) :: background

    the color where there is no imagery (rgba, 0 to 1)

    Return Value integer(kind=c_int)

interface

  • public function vkf_sky_lines_create(capacity) bind(C, name="vkf_sky_lines_create")

    Lines on the sky (up to capacity; initially none; e.g. constellations): segments between directions, of the color and width of the style's parameters (vkf_sky_style). A node handle, or null on failure. Fortran fills the buffer as the stars' (vkf_sky_stars: 8 floats per line, its first direction x, y, z, unused, then its second) and calls vkf_sky_stars_changed.

    Arguments

    Type IntentOptional Attributes Name
    integer(kind=c_int), value :: capacity

    the most lines

    Return Value type(c_ptr)

interface

  • public function vkf_sky_stars(node, capacity) bind(C, name="vkf_sky_stars")

    The stars' buffer, 8 floats per star (direction x, y, z, size in window units, then r, g, b, unused), to fill in place; null for a sky texture.

    Arguments

    Type IntentOptional Attributes Name
    type(c_ptr), value :: node

    stars or lines handle (vkf_stars_create, vkf_sky_lines_create)

    integer(kind=c_int), intent(out) :: capacity

    the buffer's capacity (stars or lines)

    Return Value type(c_ptr)

interface

  • public function vkf_sky_stars_changed(node, n) bind(C, name="vkf_sky_stars_changed")

    The first n stars were written: draw them, and upload the buffer. Returns 0, or -1 on failure.

    Arguments

    Type IntentOptional Attributes Name
    type(c_ptr), value :: node

    stars handle (vkf_stars_create)

    integer(kind=c_int), value :: n

    the number of stars (at most the capacity)

    Return Value integer(kind=c_int)

interface

  • public function vkf_sky_style(node) bind(C, name="vkf_sky_style")

    The sky's style buffer: 24 floats, the attitude (a column-major 4x4 matrix, sky frame to root frame), then 8 parameters (lines: width in window units, 3 unused, then the color r, g, b, a; unused by stars and the texture); call vkf_sky_style_changed after writing them. Null on failure.

    Arguments

    Type IntentOptional Attributes Name
    type(c_ptr), value :: node

    sky handle (vkf_stars_create, vkf_sky_texture_create)

    Return Value type(c_ptr)

interface

  • public function vkf_sky_style_changed(node) bind(C, name="vkf_sky_style_changed")

    Upload a sky's style again after writing it (vkf_sky_style). Returns 0, or -1 on failure.

    Arguments

    Type IntentOptional Attributes Name
    type(c_ptr), value :: node

    sky handle (vkf_stars_create, vkf_sky_texture_create)

    Return Value integer(kind=c_int)

interface

  • public function vkf_sky_texture_create(image) bind(C, name="vkf_sky_texture_create")

    The sky texture: an image (equirectangular, as a Sphere's texture) on the sky seen from inside; a node handle, or null on failure.

    Arguments

    Type IntentOptional Attributes Name
    type(c_ptr), value :: image

    image handle (vkf_image_read)

    Return Value type(c_ptr)

interface

  • public function vkf_sphere_lod_add(lod, mesh, segments) bind(C, name="vkf_sphere_lod_add")

    Add a mesh of segments segments around the equator. Returns 0, or -1 on failure.

    Arguments

    Type IntentOptional Attributes Name
    type(c_ptr), value :: lod

    handles (vkf_sphere_lod_create, vkf_mesh_create)

    type(c_ptr), value :: mesh

    handles (vkf_sphere_lod_create, vkf_mesh_create)

    integer(kind=c_int), value :: segments

    Return Value integer(kind=c_int)

interface

  • public function vkf_sphere_lod_create(radius) bind(C, name="vkf_sphere_lod_create")

    A sphere's level of detail for a body of radius (its largest semi-axis), centered on the node's origin: a node handle; meshes are added with vkf_sphere_lod_add.

    Arguments

    Type IntentOptional Attributes Name
    real(kind=c_double), value :: radius

    scene units

    Return Value type(c_ptr)

interface

  • public function vkf_sphere_lod_requested(lod) bind(C, name="vkf_sphere_lod_requested")

    The most segments any view wanted since the last call (0 if not drawn).

    Arguments

    Type IntentOptional Attributes Name
    type(c_ptr), value :: lod

    handle (vkf_sphere_lod_create)

    Return Value integer(kind=c_int)

interface

  • public function vkf_stars_create(capacity) bind(C, name="vkf_stars_create")

    Stars (up to capacity; initially none): a node handle, or null on failure. Fortran fills the buffer in place (vkf_sky_stars) and calls vkf_sky_stars_changed.

    Arguments

    Type IntentOptional Attributes Name
    integer(kind=c_int), value :: capacity

    the most stars

    Return Value type(c_ptr)

interface

  • public function vkf_switch_create() bind(C, name="vkf_switch_create")

    A switch node: a group whose children can be hidden and shown together; null on failure.

    Arguments

    None

    Return Value type(c_ptr)

interface

  • public function vkf_switch_set(node, visible) bind(C, name="vkf_switch_set")

    Show or hide all children of a switch. Returns 0, or -1 on failure.

    Arguments

    Type IntentOptional Attributes Name
    type(c_ptr), value :: node

    switch handle (vkf_switch_create)

    integer(kind=c_int), value :: visible

    1 to show, 0 to hide

    Return Value integer(kind=c_int)

interface

  • public function vkf_transform_create() bind(C, name="vkf_transform_create")

    A transform node (a group whose children are placed by a 4x4 matrix), initially identity; null on failure.

    Arguments

    None

    Return Value type(c_ptr)

interface

  • public function vkf_transform_set_matrix(transform, m) bind(C, name="vkf_transform_set_matrix")

    Set a transform node's matrix. Returns 0, or -1 on failure (not a transform).

    Arguments

    Type IntentOptional Attributes Name
    type(c_ptr), value :: transform

    transform handle (vkf_transform_create)

    real(kind=c_double), intent(in), dimension(4,4) :: m

    Return Value integer(kind=c_int)

interface

  • public function vkf_version(which, buf, buflen) bind(C, name="vkf_version")

    A version string into buf (blank-padded): which = 1 VSG, 2 vsgXchange, 3 Dear ImGui, 4 the Vulkan headers vkframes was built with, 5 the Vulkan loader's instance version. Returns its length, or -1.

    Arguments

    Type IntentOptional Attributes Name
    integer(kind=c_int), value :: which

    1 to 5 (see above)

    character(kind=c_char, len=1), intent(out) :: buf(*)
    integer(kind=c_int), value :: buflen

    the length of buf

    Return Value integer(kind=c_int)

interface

  • public function vkf_viewer_add_node(viewer, node) bind(C, name="vkf_viewer_add_node")

    Add a node to the viewer's scene, also while running (it is compiled first). The scene holds a reference: the node handle can be deleted afterwards. Returns 0, or -1 on failure.

    Arguments

    Type IntentOptional Attributes Name
    type(c_ptr), value :: viewer

    viewer handle (vkf_viewer_create) and node handle

    type(c_ptr), value :: node

    viewer handle (vkf_viewer_create) and node handle

    Return Value integer(kind=c_int)

interface

  • public function vkf_viewer_any() bind(C, name="vkf_viewer_any")

    A viewer that exists (the oldest running one, else the oldest), or null.

    Arguments

    None

    Return Value type(c_ptr)

interface

  • public function vkf_viewer_capture(viewer, filename, filename_len) bind(C, name="vkf_viewer_capture")

    Write the last presented frame to an image file (format from the extension, e.g. .png). Call after vkf_viewer_frame. Returns 0 on success.

    Arguments

    Type IntentOptional Attributes Name
    type(c_ptr), value :: viewer

    viewer handle (vkf_viewer_create)

    character(kind=c_char, len=1), intent(in), dimension(*) :: filename
    integer(kind=c_int), value :: filename_len

    the length of filename

    Return Value integer(kind=c_int)

interface

  • public function vkf_viewer_close(viewer) bind(C, name="vkf_viewer_close")

    The host is closing the window: the next vkf_viewer_frame returns 0. Returns 0, or -1 on failure.

    Arguments

    Type IntentOptional Attributes Name
    type(c_ptr), value :: viewer

    viewer handle (vkf_viewer_create)

    Return Value integer(kind=c_int)

interface

  • public function vkf_viewer_create(width, height, title, title_len, native_window, pixel_ratio, vsync) bind(C, name="vkf_viewer_create")

    A viewer with one window, an empty scene and a trackball camera; null on failure. With an existing window (native_window not 0) the host owns that window's events and forwards them (vkf_viewer_mouse, ..., vkf_viewer_resize).

    Arguments

    Type IntentOptional Attributes Name
    integer(kind=c_int), value :: width

    window size (window units: logical pixels)

    integer(kind=c_int), value :: height

    window size (window units: logical pixels)

    character(kind=c_char, len=1), intent(in), dimension(*) :: title

    window title

    integer(kind=c_int), value :: title_len

    the length of title

    integer(kind=c_long_long), value :: native_window

    0 for a window of its own, or the native handle of an existing window to render into (e.g. a Qt QWindow's winId(): an NSView* on macOS, an HWND on Windows, an xcb window on Linux)

    real(kind=c_double), value :: pixel_ratio

    framebuffer pixels per window unit of an existing window (Qt's devicePixelRatio); ignored for a window of its own

    integer(kind=c_int), value :: vsync

    1 to present at the display's refresh (FIFO), 0 as soon as a frame is ready (IMMEDIATE where the driver has it, else FIFO), e.g. for benchmarks

    Return Value type(c_ptr)

interface

  • public subroutine vkf_viewer_delete(viewer) bind(C, name="vkf_viewer_delete")

    Delete a viewer (its window, GUI and default light; waits for the device to be idle first).

    Arguments

    Type IntentOptional Attributes Name
    type(c_ptr), value :: viewer

    viewer handle (vkf_viewer_create)

interface

  • public function vkf_viewer_device_info(viewer, which, buf, buflen) bind(C, name="vkf_viewer_device_info")

    The viewer's Vulkan device into buf (blank-padded): which = 1 its name, 2 its type, 3 the Vulkan version it supports, 4 its driver's name, 5 its driver's information. Returns the length, or -1.

    Arguments

    Type IntentOptional Attributes Name
    type(c_ptr), value :: viewer

    viewer handle (vkf_viewer_create)

    integer(kind=c_int), value :: which

    1 to 5 (see above)

    character(kind=c_char, len=1), intent(out) :: buf(*)
    integer(kind=c_int), value :: buflen

    the length of buf

    Return Value integer(kind=c_int)

interface

  • public function vkf_viewer_events(viewer, events, capacity) bind(C, name="vkf_viewer_events")

    The keyboard and mouse events since the last call, oldest first, up to capacity of them. Returns how many were copied (the rest are kept for the next call), or -1 on failure. Each event (a column of events): kind (1 key press, 2 key release, 3 pointer move, 4 button press, 5 button release), key (modified: 'V' with shift), key base, modifiers, button, buttons held (mask), x, y (framebuffer pixels from the top left), and the render area (offset x, y, width, height). Pointer events have key 1 while the mouse is grabbed (vkf_viewer_set_grab). Events taken by a GUI panel are not included.

    Arguments

    Type IntentOptional Attributes Name
    type(c_ptr), value :: viewer

    viewer handle (vkf_viewer_create)

    integer(kind=c_int), intent(out) :: events(12,*)

    the events, 12 integers each

    integer(kind=c_int), value :: capacity

    the most events events holds

    Return Value integer(kind=c_int)

interface

  • public function vkf_viewer_frame(viewer) bind(C, name="vkf_viewer_frame")

    Render one frame (vkf_viewer_frame_begin, then vkf_viewer_frame_draw). Returns 1 while the viewer is running, 0 once its window has been closed, -1 on failure.

    Arguments

    Type IntentOptional Attributes Name
    type(c_ptr), value :: viewer

    viewer handle (vkf_viewer_create)

    Return Value integer(kind=c_int)

interface

  • public function vkf_viewer_frame_begin(viewer) bind(C, name="vkf_viewer_frame_begin")

    The first part of a frame (compiling the scene on the first call): up to the window's events handled (the trackball has moved the camera), before the scene is drawn (vkf_viewer_frame_draw): a program can still change the scene for this frame in between. Returns 1 while the viewer is running, 0 once its window has been closed, -1 on failure.

    Arguments

    Type IntentOptional Attributes Name
    type(c_ptr), value :: viewer

    viewer handle (vkf_viewer_create)

    Return Value integer(kind=c_int)

interface

  • public function vkf_viewer_frame_draw(viewer) bind(C, name="vkf_viewer_frame_draw")

    The rest of a frame begun by vkf_viewer_frame_begin: the scene's updates, drawn and presented. Returns 1, or -1 on failure.

    Arguments

    Type IntentOptional Attributes Name
    type(c_ptr), value :: viewer

    viewer handle (vkf_viewer_create)

    Return Value integer(kind=c_int)

interface

  • public function vkf_viewer_get_look_at(viewer, eye, center, up) bind(C, name="vkf_viewer_get_look_at")

    The camera's eye, center and up vectors (view-frame coordinates), as the trackball left them. Returns 0, or -1 on failure.

    Arguments

    Type IntentOptional Attributes Name
    type(c_ptr), value :: viewer

    viewer handle (vkf_viewer_create)

    real(kind=c_double), intent(out), dimension(3) :: eye

    view-frame coordinates

    real(kind=c_double), intent(out), dimension(3) :: center

    view-frame coordinates

    real(kind=c_double), intent(out), dimension(3) :: up

    view-frame coordinates

    Return Value integer(kind=c_int)

interface

  • public function vkf_viewer_gui(viewer, font, font_len, size) bind(C, name="vkf_viewer_gui")

    The viewer's GUI panels (vkf_gui.cpp), made on first use: a handle for the vkf_gui_* functions, valid while the viewer exists; null on failure.

    Arguments

    Type IntentOptional Attributes Name
    type(c_ptr), value :: viewer

    viewer handle (vkf_viewer_create)

    character(kind=c_char, len=1), intent(in) :: font(*)

    font file (empty: ImGui's)

    integer(kind=c_int), value :: font_len

    the length of font

    real(kind=c_double), value :: size

    font size (window units)

    Return Value type(c_ptr)

interface

  • public function vkf_viewer_hud_add(viewer, label) bind(C, name="vkf_viewer_hud_add")

    Show a label in the viewer's HUD, on top of the scene, also while running: the label's position is (x, y) from 0 to 1 across the viewport, bottom to top. Returns 0, or -1 on failure.

    Arguments

    Type IntentOptional Attributes Name
    type(c_ptr), value :: viewer

    viewer handle (vkf_viewer_create) and label handle

    type(c_ptr), value :: label

    viewer handle (vkf_viewer_create) and label handle

    Return Value integer(kind=c_int)

interface

  • public function vkf_viewer_hud_remove(viewer, label) bind(C, name="vkf_viewer_hud_remove")

    Remove a label from the viewer's HUD (its GPU data are released a few frames later). Returns 0, or -1 on failure.

    Arguments

    Type IntentOptional Attributes Name
    type(c_ptr), value :: viewer

    viewer handle (vkf_viewer_create) and label handle

    type(c_ptr), value :: label

    viewer handle (vkf_viewer_create) and label handle

    Return Value integer(kind=c_int)

interface

  • public function vkf_viewer_key(viewer, pressed, symbol, modified_symbol, modifier) bind(C, name="vkf_viewer_key")

    A key press or release from the host's window, as VSG key symbols and modifiers (vsg/ui/KeyEvent.h: ASCII for printable keys, X11-style codes otherwise). Returns 0, or -1 on failure.

    Arguments

    Type IntentOptional Attributes Name
    type(c_ptr), value :: viewer

    viewer handle (vkf_viewer_create)

    integer(kind=c_int), value :: pressed

    1 for a press, 0 for a release

    integer(kind=c_int), value :: symbol

    the key's base symbol (unmodified)

    integer(kind=c_int), value :: modified_symbol

    the key's symbol with the modifiers applied ('V' with shift)

    integer(kind=c_int), value :: modifier

    the modifier keys held (vsg::KeyModifier mask)

    Return Value integer(kind=c_int)

interface

  • public function vkf_viewer_light(viewer) bind(C, name="vkf_viewer_light")

    The viewer's default light (a vkf_light_create light in eye coordinates, owned by the viewer); null on failure.

    Arguments

    Type IntentOptional Attributes Name
    type(c_ptr), value :: viewer

    viewer handle (vkf_viewer_create)

    Return Value type(c_ptr)

interface

  • public function vkf_viewer_light_enable(viewer, enabled) bind(C, name="vkf_viewer_light_enable")

    Turn the viewer's default light on or off. Returns 0, or -1 on failure.

    Arguments

    Type IntentOptional Attributes Name
    type(c_ptr), value :: viewer

    viewer handle (vkf_viewer_create)

    integer(kind=c_int), value :: enabled

    1 on, 0 off

    Return Value integer(kind=c_int)

interface

  • public function vkf_viewer_look_at(viewer, eye, center, up) bind(C, name="vkf_viewer_look_at")

    Set the camera's eye, center and up vectors (view-frame coordinates); stops the trackball's throw (the camera doesn't keep turning after it). Returns 0, or -1 on failure.

    Arguments

    Type IntentOptional Attributes Name
    type(c_ptr), value :: viewer

    viewer handle (vkf_viewer_create)

    real(kind=c_double), intent(in), dimension(3) :: eye

    view-frame coordinates

    real(kind=c_double), intent(in), dimension(3) :: center

    view-frame coordinates

    real(kind=c_double), intent(in), dimension(3) :: up

    view-frame coordinates

    Return Value integer(kind=c_int)

interface

  • public function vkf_viewer_mouse(viewer, kind, x, y, mask, button) bind(C, name="vkf_viewer_mouse")

    A mouse event from the host's window. Returns 0, or -1 on failure (or an unknown kind).

    Arguments

    Type IntentOptional Attributes Name
    type(c_ptr), value :: viewer

    viewer handle (vkf_viewer_create)

    integer(kind=c_int), value :: kind

    1 = move, 2 = button press, 3 = button release

    integer(kind=c_int), value :: x

    pointer position (framebuffer pixels from the left)

    integer(kind=c_int), value :: y

    pointer position (framebuffer pixels from the top)

    integer(kind=c_int), value :: mask

    the buttons held (VSG's BUTTON_MASK_1/2/3 = 256/512/1024)

    integer(kind=c_int), value :: button

    the button pressed or released (1 left, 2 middle, 3 right)

    Return Value integer(kind=c_int)

interface

  • public function vkf_viewer_orthographic(viewer, left, right, bottom, top, near_distance, far_distance) bind(C, name="vkf_viewer_orthographic")

    Use an orthographic projection with the given view-volume bounds. Returns 0, or -1 on failure.

    Arguments

    Type IntentOptional Attributes Name
    type(c_ptr), value :: viewer

    viewer handle (vkf_viewer_create)

    real(kind=c_double), value :: left
    real(kind=c_double), value :: right
    real(kind=c_double), value :: bottom
    real(kind=c_double), value :: top
    real(kind=c_double), value :: near_distance
    real(kind=c_double), value :: far_distance

    Return Value integer(kind=c_int)

interface

  • public function vkf_viewer_perspective(viewer, fovy, near_distance, far_distance) bind(C, name="vkf_viewer_perspective")

    Use a perspective projection. Returns 0, or -1 on failure.

    Arguments

    Type IntentOptional Attributes Name
    type(c_ptr), value :: viewer

    viewer handle (vkf_viewer_create)

    real(kind=c_double), value :: fovy

    vertical field of view (degrees)

    real(kind=c_double), value :: near_distance

    near and far plane distances (scene units)

    real(kind=c_double), value :: far_distance

    near and far plane distances (scene units)

    Return Value integer(kind=c_int)

interface

  • public function vkf_viewer_pixel_ratio(viewer) bind(C, name="vkf_viewer_pixel_ratio")

    Framebuffer pixels per window unit (2 on Retina; a host's window's as given).

    Arguments

    Type IntentOptional Attributes Name
    type(c_ptr), value :: viewer

    viewer handle (vkf_viewer_create)

    Return Value real(kind=c_double)

interface

  • public function vkf_viewer_record_frames(viewer) bind(C, name="vkf_viewer_record_frames")

    Frames recorded so far, or -1 if not recording or recording failed.

    Arguments

    Type IntentOptional Attributes Name
    type(c_ptr), value :: viewer

    viewer handle (vkf_viewer_create)

    Return Value integer(kind=c_long_long)

interface

  • public function vkf_viewer_record_start(viewer, ffmpeg, ffmpeg_len, output, output_len, fps) bind(C, name="vkf_viewer_record_start")

    Start recording the frames drawn to a video of fps frames per second: piped as raw video to ffmpeg (the program), encoded with output (ffmpeg's output options, then the file, quoted). Returns 0, or -1 if already recording.

    Arguments

    Type IntentOptional Attributes Name
    type(c_ptr), value :: viewer

    viewer handle (vkf_viewer_create)

    character(kind=c_char, len=1), intent(in), dimension(*) :: ffmpeg

    the ffmpeg command (quoted if need be)

    integer(kind=c_int), value :: ffmpeg_len

    the length of ffmpeg

    character(kind=c_char, len=1), intent(in), dimension(*) :: output

    ffmpeg's output options and file

    integer(kind=c_int), value :: output_len

    the length of output

    real(kind=c_double), value :: fps

    frames per second of the video

    Return Value integer(kind=c_int)

interface

  • public function vkf_viewer_record_stop(viewer) bind(C, name="vkf_viewer_record_stop")

    Stop recording: the last frames written and ffmpeg's input closed (it finishes the file). Returns the frames written, or -1 if not recording or on failure.

    Arguments

    Type IntentOptional Attributes Name
    type(c_ptr), value :: viewer

    viewer handle (vkf_viewer_create)

    Return Value integer(kind=c_long_long)

interface

  • public function vkf_viewer_remove_node(viewer, node) bind(C, name="vkf_viewer_remove_node")

    Remove a node from the viewer's scene (its GPU data are released a few frames later). Returns 0, or -1 if it is not in the scene.

    Arguments

    Type IntentOptional Attributes Name
    type(c_ptr), value :: viewer

    viewer handle (vkf_viewer_create) and node handle

    type(c_ptr), value :: node

    viewer handle (vkf_viewer_create) and node handle

    Return Value integer(kind=c_int)

interface

  • public function vkf_viewer_resize(viewer, width, height) bind(C, name="vkf_viewer_resize")

    The host resized its window: rebuild the swapchain. A window of no width or height (e.g. a collapsed splitter) is not drawn until it has a size again. Returns 0, or -1 on failure.

    Arguments

    Type IntentOptional Attributes Name
    type(c_ptr), value :: viewer

    viewer handle (vkf_viewer_create)

    integer(kind=c_int), value :: width

    the new size (framebuffer pixels)

    integer(kind=c_int), value :: height

    the new size (framebuffer pixels)

    Return Value integer(kind=c_int)

interface

  • public function vkf_viewer_scene_counts(viewer, counts) bind(C, name="vkf_viewer_scene_counts")

    The size of the viewer's scene graph into counts: nodes, draw commands, vertices (traverses it all). Returns 0, or -1.

    Arguments

    Type IntentOptional Attributes Name
    type(c_ptr), value :: viewer

    viewer handle (vkf_viewer_create)

    real(kind=c_double), intent(out) :: counts(3)

    Return Value integer(kind=c_int)

interface

  • public function vkf_viewer_scroll(viewer, dy) bind(C, name="vkf_viewer_scroll")

    A scroll wheel event from the host's window. Returns 0, or -1 on failure.

    Arguments

    Type IntentOptional Attributes Name
    type(c_ptr), value :: viewer

    viewer handle (vkf_viewer_create)

    real(kind=c_float), value :: dy

    the scroll amount: > 0 away from the user

    Return Value integer(kind=c_int)

interface

  • public function vkf_viewer_set_background(viewer, rgba) bind(C, name="vkf_viewer_set_background")

    Set the background (clear) color. Returns 0, or -1 on failure.

    Arguments

    Type IntentOptional Attributes Name
    type(c_ptr), value :: viewer

    viewer handle (vkf_viewer_create)

    real(kind=c_float), intent(in), dimension(4) :: rgba

    color (rgba, 0 to 1)

    Return Value integer(kind=c_int)

interface

  • public function vkf_viewer_set_camera_controls(viewer, zoom_speed, throw) bind(C, name="vkf_viewer_set_camera_controls")

    The trackball's sensitivity: zoom_speed scales each scroll step's zoom and a right drag's; throw (1) keeps the camera moving after a drag released while moving. Returns 0, or -1.

    Arguments

    Type IntentOptional Attributes Name
    type(c_ptr), value :: viewer

    viewer handle (vkf_viewer_create)

    real(kind=c_double), value :: zoom_speed

    (> 0; 1: VSG's)

    integer(kind=c_int), value :: throw

    1: keep moving after a released drag

    Return Value integer(kind=c_int)

interface

  • public function vkf_viewer_set_grab(viewer, armed) bind(C, name="vkf_viewer_set_grab")

    Whether a left button press takes the mouse from the trackball (armed 1: a handle is under the cursor), until the button is released: those events are given with key 1 (vkf_viewer_events). Returns 0, or -1 on failure.

    Arguments

    Type IntentOptional Attributes Name
    type(c_ptr), value :: viewer

    viewer handle (vkf_viewer_create)

    integer(kind=c_int), value :: armed

    1: armed; 0: not

    Return Value integer(kind=c_int)

interface

  • public function vkf_viewer_set_pixel_ratio(viewer, ratio) bind(C, name="vkf_viewer_set_pixel_ratio")

    A host's window now has ratio framebuffer pixels per window unit. (Qt's devicePixelRatio changed: moved to a screen of another scale, or the display's scaling changed.) Sizes in window units (line widths, markers, labels) are scaled by it; the host also resizes (vkf_viewer_resize) to the new framebuffer size. Returns 0, or -1 on failure.

    Arguments

    Type IntentOptional Attributes Name
    type(c_ptr), value :: viewer

    viewer handle (vkf_viewer_create)

    real(kind=c_double), value :: ratio

    framebuffer pixels per window unit (> 0)

    Return Value integer(kind=c_int)

interface

  • public function vkf_viewer_set_view_transform(viewer, m) bind(C, name="vkf_viewer_set_view_transform")

    Set the transform from world (scene root) to view-frame coordinates, applied after the trackball's eye/center/up (see ViewLookAt). Returns 0, or -1 on failure.

    Arguments

    Type IntentOptional Attributes Name
    type(c_ptr), value :: viewer

    viewer handle (vkf_viewer_create)

    real(kind=c_double), intent(in), dimension(4,4) :: m

    world to view-frame matrix

    Return Value integer(kind=c_int)

interface

  • public function vkf_viewer_size(viewer, width, height) bind(C, name="vkf_viewer_size")

    The swapchain's size (framebuffer pixels): a VSG window's size as it is resized (a host's window has the size it gives, vkf_viewer_resize). Returns 0, or -1 on failure.

    Arguments

    Type IntentOptional Attributes Name
    type(c_ptr), value :: viewer

    viewer handle (vkf_viewer_create)

    integer(kind=c_int), intent(out) :: width

    the size (framebuffer pixels)

    integer(kind=c_int), intent(out) :: height

    the size (framebuffer pixels)

    Return Value integer(kind=c_int)

interface

  • public function vkf_viewer_stats(viewer, stats, n) bind(C, name="vkf_viewer_stats")

    The viewer's last frame drawn, into stats(1:n) (n at most 9): frames drawn, milliseconds waiting for a swapchain image, recording and submitting, presenting, the GPU's time (-1: not measured), the framebuffer's width and height, the device memory in use and its budget (bytes; -1: unknown). Returns 0, or -1.

    Arguments

    Type IntentOptional Attributes Name
    type(c_ptr), value :: viewer

    viewer handle (vkf_viewer_create)

    real(kind=c_double), intent(out) :: stats(*)
    integer(kind=c_int), value :: n

    the size of stats

    Return Value integer(kind=c_int)

interface

  • public function vkf_vulkan_device_name(buf, buflen) bind(C, name="vkf_vulkan_device_name")

    Name of the first Vulkan physical device, into buf; returns its length, or -1 on failure. Needs no window, so it checks that the Vulkan loader finds a driver (MoltenVK on macOS).

    Arguments

    Type IntentOptional Attributes Name
    character(kind=c_char, len=1), intent(out), dimension(*) :: buf

    the name (not null-terminated)

    integer(kind=c_int), value :: buflen

    the length of buf

    Return Value integer(kind=c_int)


Functions

public function line_set_pattern(line, factor, pattern) result(status)

Set a line's dash pattern, as OpenGL's line stipple: each bit of the 16-bit pattern (bit 0 first; z'FFFF' solid) covers factor window units (see shaders/line.vert). Returns 0, or -1 on failure.

Arguments

Type IntentOptional Attributes Name
type(c_ptr), intent(in) :: line

line handle

integer, intent(in) :: factor
integer, intent(in) :: pattern

Return Value integer(kind=c_int)

public function line_set_points(line, xyz) result(status)

Set the points of a line strip (xyz(3, n), double precision), splitting each coordinate, and the distance along the strip, into the (high, low) float pair the line shader reads, in place in the strip's buffer. Returns 0, or -1 if n exceeds the capacity.

Arguments

Type IntentOptional Attributes Name
type(c_ptr), intent(in) :: line

line, marker or ribbon handle

real(kind=c_double), intent(in), dimension(:,:) :: xyz

(3, n) points

Return Value integer(kind=c_int)

public function line_set_segments(line, segments) result(status)

Draw a line's points as separate segments (pairs of points: 1-2, 3-4, ...) instead of a strip. Set before its points are drawn. Returns 0, or -1 on failure.

Arguments

Type IntentOptional Attributes Name
type(c_ptr), intent(in) :: line

line handle

logical, intent(in) :: segments

true for separate segments, false for a strip

Return Value integer(kind=c_int)

public function line_set_style(line, rgba, width) result(status)

Set the color (rgba) and width (window units: logical pixels) of a line strip. Returns 0, or -1 on failure.

Arguments

Type IntentOptional Attributes Name
type(c_ptr), intent(in) :: line

line or ribbon handle

real(kind=c_float), intent(in), dimension(4) :: rgba

color (rgba, 0 to 1)

real(kind=c_float), intent(in) :: width

width (window units)

Return Value integer(kind=c_int)

public function marker_set_style(marker, rgba, size, shape, radius) result(status)

Set the color (rgba), size (window units), shape (see shaders/ marker.frag) and attenuation radius (scene units; 0 for none) of markers. Returns 0, or -1 on failure.

Arguments

Type IntentOptional Attributes Name
type(c_ptr), intent(in) :: marker

marker handle (vkf_marker_create)

real(kind=c_float), intent(in), dimension(4) :: rgba

color (rgba, 0 to 1)

real(kind=c_float), intent(in) :: size
integer, intent(in) :: shape
real(kind=c_float), intent(in) :: radius

Return Value integer(kind=c_int)

public function mesh_set_material(mesh, ambient, diffuse, specular, emissive, shininess) result(status)

Set a lit mesh's material: ambient, diffuse, specular and emissive colors (rgba) and shininess (VSG's Phong: the ambient color scales the diffuse color reflected from ambient light). Returns 0, or -1 on failure (e.g. a mesh without a material).

Arguments

Type IntentOptional Attributes Name
type(c_ptr), intent(in) :: mesh

mesh handle (vkf_mesh_create)

real(kind=c_float), intent(in), dimension(4) :: ambient

colors (rgba, 0 to 1)

real(kind=c_float), intent(in), dimension(4) :: diffuse

colors (rgba, 0 to 1)

real(kind=c_float), intent(in), dimension(4) :: specular

colors (rgba, 0 to 1)

real(kind=c_float), intent(in), dimension(4) :: emissive

colors (rgba, 0 to 1)

real(kind=c_float), intent(in) :: shininess

Phong exponent

Return Value integer(kind=c_int)

public function vulkan_device_name() result(name)

Name of the first Vulkan physical device, or an empty string if there is none.

Arguments

None

Return Value character(len=:), allocatable


Subroutines

public subroutine check_status(status, context)

Report a failed rendering-layer call (a status not 0), saying where (context, e.g. 'shapes').

Arguments

Type IntentOptional Attributes Name
integer(kind=c_int), intent(in) :: status

a rendering-layer call's result (0: success)

character(len=*), intent(in), optional :: context

where the call was made

public subroutine mesh_arrays(mesh, n_vertices, n_indices, xyz, normals, uv, indices)

Pointers to the arrays of a mesh of n_vertices vertices and n_indices indices (as created by vkf_mesh_create), to fill in place before the first frame. Indices are 0-based.

Arguments

Type IntentOptional Attributes Name
type(c_ptr), intent(in) :: mesh

mesh handle (vkf_mesh_create)

integer, intent(in) :: n_vertices
integer, intent(in) :: n_indices
real(kind=c_float), intent(out), dimension(:,:), pointer :: xyz

(3, n_vertices)

real(kind=c_float), intent(out), dimension(:,:), pointer :: normals

(3, n_vertices)

real(kind=c_float), intent(out), dimension(:,:), pointer :: uv

(2, n_vertices)

integer(kind=c_int32_t), intent(out), dimension(:), pointer :: indices

(n_indices) triangle indices, 0-based