org.lwjgl.bgfx.BGFXCallbackInterface Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of lwjgl-bgfx Show documentation
Show all versions of lwjgl-bgfx Show documentation
A cross-platform, graphics API agnostic rendering library. It provides a high performance, low level abstraction for common platform graphics APIs like OpenGL, Direct3D and Apple Metal.
/*
* Copyright LWJGL. All rights reserved.
* License terms: https://www.lwjgl.org/license
* MACHINE GENERATED FILE, DO NOT EDIT
*/
package org.lwjgl.bgfx;
import javax.annotation.*;
import java.nio.*;
import org.lwjgl.*;
import org.lwjgl.system.*;
import static org.lwjgl.system.Checks.*;
import static org.lwjgl.system.MemoryUtil.*;
import static org.lwjgl.system.MemoryStack.*;
/**
* Callback interface to implement application specific behavior.
*
* Cached items are currently used for OpenGL and Direct3D 12 binary shaders.
*
* {@code fatal} and {@code trace_vargs} callbacks can be called from any thread. Other callbacks are called from the render thread.
*
* Member documentation
*
*
* - {@code vtbl} – the callback virtual table
*
*
* Layout
*
*
* struct bgfx_callback_interface_t {
* {@link BGFXCallbackVtbl bgfx_callback_vtbl_t const} * vtbl;
* }
*/
@NativeType("struct bgfx_callback_interface_t")
public class BGFXCallbackInterface extends Struct implements NativeResource {
/** The struct size in bytes. */
public static final int SIZEOF;
/** The struct alignment in bytes. */
public static final int ALIGNOF;
/** The struct member offsets. */
public static final int
VTBL;
static {
Layout layout = __struct(
__member(POINTER_SIZE)
);
SIZEOF = layout.getSize();
ALIGNOF = layout.getAlignment();
VTBL = layout.offsetof(0);
}
BGFXCallbackInterface(long address, @Nullable ByteBuffer container) {
super(address, container);
}
/**
* Creates a {@link BGFXCallbackInterface} instance at the current position of the specified {@link 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.
*/
public BGFXCallbackInterface(ByteBuffer container) {
this(memAddress(container), __checkContainer(container, SIZEOF));
}
@Override
public int sizeof() { return SIZEOF; }
/** Returns a {@link BGFXCallbackVtbl} view of the struct pointed to by the {@code vtbl} field. */
@NativeType("bgfx_callback_vtbl_t const *")
public BGFXCallbackVtbl vtbl() { return nvtbl(address()); }
/** Sets the address of the specified {@link BGFXCallbackVtbl} to the {@code vtbl} field. */
public BGFXCallbackInterface vtbl(@NativeType("bgfx_callback_vtbl_t const *") BGFXCallbackVtbl value) { nvtbl(address(), value); return this; }
/**
* Copies the specified struct data to this struct.
*
* @param src the source struct
*
* @return this struct
*/
public BGFXCallbackInterface set(BGFXCallbackInterface src) {
memCopy(src.address(), address(), SIZEOF);
return this;
}
// -----------------------------------
/** Returns a new {@link BGFXCallbackInterface} instance allocated with {@link MemoryUtil#memAlloc memAlloc}. The instance must be explicitly freed. */
public static BGFXCallbackInterface malloc() {
return create(nmemAllocChecked(SIZEOF));
}
/** Returns a new {@link BGFXCallbackInterface} instance allocated with {@link MemoryUtil#memCalloc memCalloc}. The instance must be explicitly freed. */
public static BGFXCallbackInterface calloc() {
return create(nmemCallocChecked(1, SIZEOF));
}
/** Returns a new {@link BGFXCallbackInterface} instance allocated with {@link BufferUtils}. */
public static BGFXCallbackInterface create() {
return new BGFXCallbackInterface(BufferUtils.createByteBuffer(SIZEOF));
}
/** Returns a new {@link BGFXCallbackInterface} instance for the specified memory address. */
public static BGFXCallbackInterface create(long address) {
return new BGFXCallbackInterface(address, null);
}
/** Like {@link #create(long) create}, but returns {@code null} if {@code address} is {@code NULL}. */
@Nullable
public static BGFXCallbackInterface createSafe(long address) {
return address == NULL ? null : create(address);
}
// -----------------------------------
/** Returns a new {@link BGFXCallbackInterface} instance allocated on the thread-local {@link MemoryStack}. */
public static BGFXCallbackInterface mallocStack() {
return mallocStack(stackGet());
}
/** Returns a new {@link BGFXCallbackInterface} instance allocated on the thread-local {@link MemoryStack} and initializes all its bits to zero. */
public static BGFXCallbackInterface callocStack() {
return callocStack(stackGet());
}
/**
* Returns a new {@link BGFXCallbackInterface} instance allocated on the specified {@link MemoryStack}.
*
* @param stack the stack from which to allocate
*/
public static BGFXCallbackInterface mallocStack(MemoryStack stack) {
return create(stack.nmalloc(ALIGNOF, SIZEOF));
}
/**
* Returns a new {@link BGFXCallbackInterface} instance allocated on the specified {@link MemoryStack} and initializes all its bits to zero.
*
* @param stack the stack from which to allocate
*/
public static BGFXCallbackInterface callocStack(MemoryStack stack) {
return create(stack.ncalloc(ALIGNOF, 1, SIZEOF));
}
// -----------------------------------
/** Unsafe version of {@link #vtbl}. */
public static BGFXCallbackVtbl nvtbl(long struct) { return BGFXCallbackVtbl.create(memGetAddress(struct + BGFXCallbackInterface.VTBL)); }
/** Unsafe version of {@link #vtbl(BGFXCallbackVtbl) vtbl}. */
public static void nvtbl(long struct, BGFXCallbackVtbl value) { memPutAddress(struct + BGFXCallbackInterface.VTBL, value.address()); }
/**
* Validates pointer members that should not be {@code NULL}.
*
* @param struct the struct to validate
*/
public static void validate(long struct) {
long vtbl = memGetAddress(struct + BGFXCallbackInterface.VTBL);
check(vtbl);
BGFXCallbackVtbl.validate(vtbl);
}
/**
* Calls {@link #validate(long)} for each struct contained in the specified struct array.
*
* @param array the struct array to validate
* @param count the number of structs in {@code array}
*/
public static void validate(long array, int count) {
for (int i = 0; i < count; i++) {
validate(array + i * SIZEOF);
}
}
}