Class BGFXMemory

  • All Implemented Interfaces:
    java.lang.AutoCloseable, NativeResource, Pointer

    public class BGFXMemory
    extends Struct
    implements NativeResource
    Memory must be obtained by calling alloc, copy, or make_ref.

    It is illegal to create this structure on stack and pass it to any bgfx API.

    Member documentation

    • data – pointer to data
    • size – data size

    Layout

    
     struct bgfx_memory_t {
         uint8_t * data;
         uint32_t size;
     }
    • Field Detail

      • SIZEOF

        The struct size in bytes.
      • ALIGNOF

        The struct alignment in bytes.
      • DATA, SIZE

        The struct member offsets.
    • Constructor Detail

      • BGFXMemory

        public BGFXMemory​(java.nio.ByteBuffer container)
        Creates a BGFXMemory instance at the current position of the specified ByteBuffer container. Changes to the buffer's content will be visible to the struct instance and vice versa.

        The created instance holds a strong reference to the container object.

    • Method Detail

      • sizeof

        public int sizeof()
        Description copied from class: Struct
        Returns sizeof(struct).
        Specified by:
        sizeof in class Struct
      • data

        public java.nio.ByteBuffer data()
        Returns a ByteBuffer view of the data pointed to by the data field.
      • size

        public int size()
        Returns the value of the size field.
      • data

        public BGFXMemory data​(java.nio.ByteBuffer value)
        Sets the address of the specified ByteBuffer to the data field.
      • set

        public BGFXMemory set​(BGFXMemory src)
        Copies the specified struct data to this struct.
        Parameters:
        src - the source struct
        Returns:
        this struct
      • malloc

        public static BGFXMemory malloc()
        Returns a new BGFXMemory instance allocated with memAlloc. The instance must be explicitly freed.
      • create

        public static BGFXMemory create​(long address)
        Returns a new BGFXMemory instance for the specified memory address.
      • createSafe

        @Nullable
        public static BGFXMemory createSafe​(long address)
        Like create, but returns null if address is NULL.
      • malloc

        public static BGFXMemory.Buffer malloc​(int capacity)
        Returns a new BGFXMemory.Buffer instance allocated with memAlloc. The instance must be explicitly freed.
        Parameters:
        capacity - the buffer capacity
      • calloc

        public static BGFXMemory.Buffer calloc​(int capacity)
        Returns a new BGFXMemory.Buffer instance allocated with memCalloc. The instance must be explicitly freed.
        Parameters:
        capacity - the buffer capacity
      • create

        public static BGFXMemory.Buffer create​(long address,
                                               int capacity)
        Create a BGFXMemory.Buffer instance at the specified memory.
        Parameters:
        address - the memory address
        capacity - the buffer capacity
      • createSafe

        @Nullable
        public static BGFXMemory.Buffer createSafe​(long address,
                                                   int capacity)
        Like create, but returns null if address is NULL.
      • callocStack

        public static BGFXMemory callocStack()
        Returns a new BGFXMemory instance allocated on the thread-local MemoryStack and initializes all its bits to zero.
      • callocStack

        public static BGFXMemory callocStack​(MemoryStack stack)
        Returns a new BGFXMemory instance allocated on the specified MemoryStack and initializes all its bits to zero.
        Parameters:
        stack - the stack from which to allocate
      • callocStack

        public static BGFXMemory.Buffer callocStack​(int capacity)
        Returns a new BGFXMemory.Buffer instance allocated on the thread-local MemoryStack and initializes all its bits to zero.
        Parameters:
        capacity - the buffer capacity
      • callocStack

        public static BGFXMemory.Buffer callocStack​(int capacity,
                                                    MemoryStack stack)
        Returns a new BGFXMemory.Buffer instance allocated on the specified MemoryStack and initializes all its bits to zero.
        Parameters:
        stack - the stack from which to allocate
        capacity - the buffer capacity
      • ndata

        public static java.nio.ByteBuffer ndata​(long struct)
        Unsafe version of data.
      • nsize

        public static int nsize​(long struct)
        Unsafe version of size().
      • ndata

        public static void ndata​(long struct,
                                 java.nio.ByteBuffer value)
        Unsafe version of data.
      • nsize

        public static void nsize​(long struct,
                                 int value)
        Sets the specified value to the size field of the specified struct.
      • validate

        public static void validate​(long struct)
        Validates pointer members that should not be NULL.
        Parameters:
        struct - the struct to validate
      • validate

        public static void validate​(long array,
                                    int count)
        Calls validate(long) for each struct contained in the specified struct array.
        Parameters:
        array - the struct array to validate
        count - the number of structs in array