com.io7m.jcanephora.async

## Class JCGLAsyncResourceLoader

- java.lang.Object
- - com.io7m.jcanephora.async.JCGLAsyncResourceLoader

- All Implemented Interfaces:
    JCGLAsyncResourceLoaderType

      public final class JCGLAsyncResourceLoader
      extends Object
      implements JCGLAsyncResourceLoaderType

  The default implementation of the `JCGLAsyncResourceLoaderType` interface.

- - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `<T> CompletableFuture<JCGLAsyncBufferPair>` | `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.
    `static JCGLAsyncResourceLoaderType` | `newLoader(Executor in_exec_io, JCGLAsyncInterfaceUsableGL33Type in_g)` Construct a new resource loader.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### newLoader

          public static JCGLAsyncResourceLoaderType newLoader(Executor in_exec_io,
                                                              JCGLAsyncInterfaceUsableGL33Type in_g)

      Construct a new resource loader.
      Parameters:
        `in_exec_io` - An executor for I/O tasks
        `in_g` - An async GL interface
      Returns:
        A new loader

    - #### loadTexture

          public 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)

      Description copied from interface: `JCGLAsyncResourceLoaderType`

      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.

      Specified by:
        `loadTexture` in interface `JCGLAsyncResourceLoaderType`
      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

          public <T> CompletableFuture<JCGLAsyncBufferPair> 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)

      Description copied from interface: `JCGLAsyncResourceLoaderType`

      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.

      Specified by:
        `loadArrayIndexBuffers` in interface `JCGLAsyncResourceLoaderType`
      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 © 2017 <code@io7m.com> http://io7m.com