com.io7m.jcanephora.async

## Interface JCGLAsyncResourceLoaderType

- All Known Implementing Classes:
    JCGLAsyncResourceLoader

      public interface JCGLAsyncResourceLoaderType

  The type of asynchronous resource loaders.

  An asynchronous resource loader attempts to simplify the allocation and population of OpenGL resources by evaluating user-provided functions on a pool of worker threads, and creating shared OpenGL objects on a dedicated OpenGL context.

  The interface tries to provide a generalized and type-safe interface to allow programmers to conveniently load textures and 3D mesh data asynchronously, without the interface itself having to know anything about the source of the data.

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `<T> CompletableFuture<JCGLAsyncBufferPairType>` | `loadArrayIndexBuffers(Supplier<T> on_data, Function<T,Long> on_array_size, JCGLUsageHint array_usage, Function<T,Long> on_index_size, JCGLUnsignedType index_type, JCGLUsageHint index_usage, BiFunction<T,JCGLArrayBufferType,JCGLBufferUpdateType<JCGLArrayBufferType>> on_populate_array, BiFunction<T,JCGLIndexBufferType,JCGLBufferUpdateType<JCGLIndexBufferType>> on_populate_index)` Asynchronously create an array and index buffer pair.
    `CompletableFuture<JCGLTexture2DType>` | `loadTexture(Supplier<JCGLTLTextureDataType> on_data, JCGLTextureFormat format, JCGLTextureWrapS wrap_s, JCGLTextureWrapT wrap_t, JCGLTextureFilterMinification min_filter, JCGLTextureFilterMagnification mag_filter, BiFunction<JCGLTexture2DType,JCGLTLTextureDataType,JCGLTexture2DUpdateType> on_populate)` Asynchronously load a texture.

- - ### Method Detail

    - #### loadTexture

          CompletableFuture<JCGLTexture2DType> loadTexture(Supplier<JCGLTLTextureDataType> on_data,
                                                           JCGLTextureFormat format,
                                                           JCGLTextureWrapS wrap_s,
                                                           JCGLTextureWrapT wrap_t,
                                                           JCGLTextureFilterMinification min_filter,
                                                           JCGLTextureFilterMagnification mag_filter,
                                                           BiFunction<JCGLTexture2DType,JCGLTLTextureDataType,JCGLTexture2DUpdateType> on_populate)

      Asynchronously load a texture. The given `on_data` function is evaluated, yielding texture data. A texture is allocated with the given parameters, and then the `on_populate` function is evaluated, yielding a `JCGLTexture2DUpdateType` which is then used to populate the texture.

      All functions are evaluated on an arbitrary number of background worker threads.

      Parameters:
        `on_data` - A function that returns texture data
        `format` - The allocated texture format
        `wrap_s` - The allocated texture wrapping mode on the S axis
        `wrap_t` - The allocated texture wrapping mode on the T axis
        `min_filter` - The allocated texture minification filter
        `mag_filter` - The allocated texture magnification filter
        `on_populate` - A function that returns a texture update
      Returns:
        A future representing the loading in progress

    - #### loadArrayIndexBuffers

          <T> CompletableFuture<JCGLAsyncBufferPairType> loadArrayIndexBuffers(Supplier<T> on_data,
                                                                               Function<T,Long> on_array_size,
                                                                               JCGLUsageHint array_usage,
                                                                               Function<T,Long> on_index_size,
                                                                               JCGLUnsignedType index_type,
                                                                               JCGLUsageHint index_usage,
                                                                               BiFunction<T,JCGLArrayBufferType,JCGLBufferUpdateType<JCGLArrayBufferType>> on_populate_array,
                                                                               BiFunction<T,JCGLIndexBufferType,JCGLBufferUpdateType<JCGLIndexBufferType>> on_populate_index)

      Asynchronously create an array and index buffer pair. The given `on_data` function is evaluated on a worker thread, yielding user data `d`. The `on_array_size` function is passed `d` and is expected to return the size in bytes of the array buffer that should be allocated. The `on_index_size` function is passed `d` and is expected to return the size in bytes of the index buffer that should be allocated. The `on_populate_array` function is evaluated, and is passed `d` and the allocated array buffer, and is expected to yield an `JCGLBufferUpdateType` value that can be used to populate the array buffer with data. The `on_populate_index` function is evaluated, and is passed `d` and the allocated index buffer, and is expected to yield an `JCGLBufferUpdateType` value that can be used to populate the index buffer with data.

      All functions are evaluated on an arbitrary number of background worker threads.

      Type Parameters:
        `T` - The type of user data
      Parameters:
        `on_data` - A function that returns an abstract user data value
        `on_array_size` - A function that yields an array buffer size
        `array_usage` - The array buffer usage hint
        `on_index_size` - A function that yields an index buffer size
        `index_type` - The type of index buffer indices
        `index_usage` - The index buffer usage hint
        `on_populate_array` - A function that yields a buffer update, used to populate the array buffer
        `on_populate_index` - A function that yields a buffer update, used to populate the index buffer
      Returns:
        A future representing the loading in progress

Copyright © 2016 <code@io7m.com> http://io7m.com