org.lwjgl.vulkan.VkViewport Maven / Gradle / Ivy
Show all versions of lwjgl-vulkan Show documentation
/*
* Copyright LWJGL. All rights reserved.
* License terms: https://www.lwjgl.org/license
* MACHINE GENERATED FILE, DO NOT EDIT
*/
package org.lwjgl.vulkan;
import java.nio.*;
import org.lwjgl.*;
import org.lwjgl.system.*;
import static org.lwjgl.system.MemoryUtil.*;
import static org.lwjgl.system.MemoryStack.*;
/**
* Structure specifying a viewport.
*
* Description
*
* The framebuffer depth coordinate zf
may be represented using either a fixed-point or floating-point representation. However, a floating-point representation must be used if the depth/stencil attachment has a floating-point depth component. If an m
-bit fixed-point representation is used, we assume that it represents each value latexmath:[\frac{k}{2m - 1}
], where k {elem} { 0, 1, ..., 2m^-1 }
, as k
(e.g. 1.0 is represented in binary as a string of all ones).
*
* The viewport parameters shown in the above equations are found from these values as
*
*
* ox = x + width / 2
* oy = y + height / 2
* oz = minDepth
* px = width
* py = height
* pz = maxDepth - minDepth
.
*
*
* The width and height of the implementation-dependent maximum viewport dimensions must be greater than or equal to the width and height of the largest image which can be created and attached to a framebuffer.
*
* The floating-point viewport bounds are represented with an implementation-dependent precision.
*
* Valid Usage
*
*
* - {@code width} must be greater than {@code 0.0} and less than or equal to {@link VkPhysicalDeviceLimits}{@code ::maxViewportDimensions}[0]
* - {@code height} must be greater than {@code 0.0} and less than or equal to {@link VkPhysicalDeviceLimits}{@code ::maxViewportDimensions}[1]
* - If the VK_AMD_negative_viewport_height extension is enabled, {@code height} can also be negative.
* - {@code x} and {@code y} must each be between {@code viewportBoundsRange}[0] and {@code viewportBoundsRange}[1], inclusive
* - {@code x} + {@code width} must be less than or equal to {@code viewportBoundsRange}[1]
* - {@code y} + {@code height} must be less than or equal to {@code viewportBoundsRange}[1]
* - {@code minDepth} must be between {@code 0.0} and {@code 1.0}, inclusive
* - {@code maxDepth} must be between {@code 0.0} and {@code 1.0}, inclusive
*
*
* See Also
*
* {@link VkPipelineViewportStateCreateInfo}, {@link VK10#vkCmdSetViewport CmdSetViewport}
*
* Member documentation
*
*
* - {@code x} – {@code x} and {@code y} are the viewport’s upper left corner
(x,y)
.
* - {@code y} – see {@code x}
* - {@code width} – {@code width} and {@code height} are the viewport’s width and height, respectively.
* - {@code height} – see {@code width}
* - {@code minDepth} – {@code minDepth} and {@code maxDepth} are the depth range for the viewport. It is valid for {@code minDepth} to be greater than or equal to {@code maxDepth}.
* - {@code maxDepth} – see {@code minDepth}
*
*
* Layout
*
* struct VkViewport {
float x;
float y;
float width;
float height;
float minDepth;
float maxDepth;
}
*/
public class VkViewport extends Struct implements NativeResource {
/** The struct size in bytes. */
public static final int SIZEOF;
public static final int ALIGNOF;
/** The struct member offsets. */
public static final int
X,
Y,
WIDTH,
HEIGHT,
MINDEPTH,
MAXDEPTH;
static {
Layout layout = __struct(
__member(4),
__member(4),
__member(4),
__member(4),
__member(4),
__member(4)
);
SIZEOF = layout.getSize();
ALIGNOF = layout.getAlignment();
X = layout.offsetof(0);
Y = layout.offsetof(1);
WIDTH = layout.offsetof(2);
HEIGHT = layout.offsetof(3);
MINDEPTH = layout.offsetof(4);
MAXDEPTH = layout.offsetof(5);
}
VkViewport(long address, ByteBuffer container) {
super(address, container);
}
/**
* Creates a {@link VkViewport} 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 VkViewport(ByteBuffer container) {
this(memAddress(container), checkContainer(container, SIZEOF));
}
@Override
public int sizeof() { return SIZEOF; }
/** Returns the value of the {@code x} field. */
public float x() { return nx(address()); }
/** Returns the value of the {@code y} field. */
public float y() { return ny(address()); }
/** Returns the value of the {@code width} field. */
public float width() { return nwidth(address()); }
/** Returns the value of the {@code height} field. */
public float height() { return nheight(address()); }
/** Returns the value of the {@code minDepth} field. */
public float minDepth() { return nminDepth(address()); }
/** Returns the value of the {@code maxDepth} field. */
public float maxDepth() { return nmaxDepth(address()); }
/** Sets the specified value to the {@code x} field. */
public VkViewport x(float value) { nx(address(), value); return this; }
/** Sets the specified value to the {@code y} field. */
public VkViewport y(float value) { ny(address(), value); return this; }
/** Sets the specified value to the {@code width} field. */
public VkViewport width(float value) { nwidth(address(), value); return this; }
/** Sets the specified value to the {@code height} field. */
public VkViewport height(float value) { nheight(address(), value); return this; }
/** Sets the specified value to the {@code minDepth} field. */
public VkViewport minDepth(float value) { nminDepth(address(), value); return this; }
/** Sets the specified value to the {@code maxDepth} field. */
public VkViewport maxDepth(float value) { nmaxDepth(address(), value); return this; }
/** Initializes this struct with the specified values. */
public VkViewport set(
float x,
float y,
float width,
float height,
float minDepth,
float maxDepth
) {
x(x);
y(y);
width(width);
height(height);
minDepth(minDepth);
maxDepth(maxDepth);
return this;
}
/** Unsafe version of {@link #set(VkViewport) set}. */
public VkViewport nset(long struct) {
memCopy(struct, address(), SIZEOF);
return this;
}
/**
* Copies the specified struct data to this struct.
*
* @param src the source struct
*
* @return this struct
*/
public VkViewport set(VkViewport src) {
return nset(src.address());
}
// -----------------------------------
/** Returns a new {@link VkViewport} instance allocated with {@link MemoryUtil#memAlloc memAlloc}. The instance must be explicitly freed. */
public static VkViewport malloc() {
return create(nmemAlloc(SIZEOF));
}
/** Returns a new {@link VkViewport} instance allocated with {@link MemoryUtil#memCalloc memCalloc}. The instance must be explicitly freed. */
public static VkViewport calloc() {
return create(nmemCalloc(1, SIZEOF));
}
/** Returns a new {@link VkViewport} instance allocated with {@link BufferUtils}. */
public static VkViewport create() {
return new VkViewport(BufferUtils.createByteBuffer(SIZEOF));
}
/** Returns a new {@link VkViewport} instance for the specified memory address or {@code null} if the address is {@code NULL}. */
public static VkViewport create(long address) {
return address == NULL ? null : new VkViewport(address, null);
}
/**
* Returns a new {@link VkViewport.Buffer} instance allocated with {@link MemoryUtil#memAlloc memAlloc}. The instance must be explicitly freed.
*
* @param capacity the buffer capacity
*/
public static Buffer malloc(int capacity) {
return create(nmemAlloc(capacity * SIZEOF), capacity);
}
/**
* Returns a new {@link VkViewport.Buffer} instance allocated with {@link MemoryUtil#memCalloc memCalloc}. The instance must be explicitly freed.
*
* @param capacity the buffer capacity
*/
public static Buffer calloc(int capacity) {
return create(nmemCalloc(capacity, SIZEOF), capacity);
}
/**
* Returns a new {@link VkViewport.Buffer} instance allocated with {@link BufferUtils}.
*
* @param capacity the buffer capacity
*/
public static Buffer create(int capacity) {
return new Buffer(BufferUtils.createByteBuffer(capacity * SIZEOF));
}
/**
* Create a {@link VkViewport.Buffer} instance at the specified memory.
*
* @param address the memory address
* @param capacity the buffer capacity
*/
public static Buffer create(long address, int capacity) {
return address == NULL ? null : new Buffer(address, null, -1, 0, capacity, capacity);
}
// -----------------------------------
/** Returns a new {@link VkViewport} instance allocated on the thread-local {@link MemoryStack}. */
public static VkViewport mallocStack() {
return mallocStack(stackGet());
}
/** Returns a new {@link VkViewport} instance allocated on the thread-local {@link MemoryStack} and initializes all its bits to zero. */
public static VkViewport callocStack() {
return callocStack(stackGet());
}
/**
* Returns a new {@link VkViewport} instance allocated on the specified {@link MemoryStack}.
*
* @param stack the stack from which to allocate
*/
public static VkViewport mallocStack(MemoryStack stack) {
return create(stack.nmalloc(ALIGNOF, SIZEOF));
}
/**
* Returns a new {@link VkViewport} instance allocated on the specified {@link MemoryStack} and initializes all its bits to zero.
*
* @param stack the stack from which to allocate
*/
public static VkViewport callocStack(MemoryStack stack) {
return create(stack.ncalloc(ALIGNOF, 1, SIZEOF));
}
/**
* Returns a new {@link VkViewport.Buffer} instance allocated on the thread-local {@link MemoryStack}.
*
* @param capacity the buffer capacity
*/
public static Buffer mallocStack(int capacity) {
return mallocStack(capacity, stackGet());
}
/**
* Returns a new {@link VkViewport.Buffer} instance allocated on the thread-local {@link MemoryStack} and initializes all its bits to zero.
*
* @param capacity the buffer capacity
*/
public static Buffer callocStack(int capacity) {
return callocStack(capacity, stackGet());
}
/**
* Returns a new {@link VkViewport.Buffer} instance allocated on the specified {@link MemoryStack}.
*
* @param stack the stack from which to allocate
* @param capacity the buffer capacity
*/
public static Buffer mallocStack(int capacity, MemoryStack stack) {
return create(stack.nmalloc(ALIGNOF, capacity * SIZEOF), capacity);
}
/**
* Returns a new {@link VkViewport.Buffer} instance allocated on the specified {@link MemoryStack} and initializes all its bits to zero.
*
* @param stack the stack from which to allocate
* @param capacity the buffer capacity
*/
public static Buffer callocStack(int capacity, MemoryStack stack) {
return create(stack.ncalloc(ALIGNOF, capacity, SIZEOF), capacity);
}
// -----------------------------------
/** Unsafe version of {@link #x}. */
public static float nx(long struct) { return memGetFloat(struct + VkViewport.X); }
/** Unsafe version of {@link #y}. */
public static float ny(long struct) { return memGetFloat(struct + VkViewport.Y); }
/** Unsafe version of {@link #width}. */
public static float nwidth(long struct) { return memGetFloat(struct + VkViewport.WIDTH); }
/** Unsafe version of {@link #height}. */
public static float nheight(long struct) { return memGetFloat(struct + VkViewport.HEIGHT); }
/** Unsafe version of {@link #minDepth}. */
public static float nminDepth(long struct) { return memGetFloat(struct + VkViewport.MINDEPTH); }
/** Unsafe version of {@link #maxDepth}. */
public static float nmaxDepth(long struct) { return memGetFloat(struct + VkViewport.MAXDEPTH); }
/** Unsafe version of {@link #x(float) x}. */
public static void nx(long struct, float value) { memPutFloat(struct + VkViewport.X, value); }
/** Unsafe version of {@link #y(float) y}. */
public static void ny(long struct, float value) { memPutFloat(struct + VkViewport.Y, value); }
/** Unsafe version of {@link #width(float) width}. */
public static void nwidth(long struct, float value) { memPutFloat(struct + VkViewport.WIDTH, value); }
/** Unsafe version of {@link #height(float) height}. */
public static void nheight(long struct, float value) { memPutFloat(struct + VkViewport.HEIGHT, value); }
/** Unsafe version of {@link #minDepth(float) minDepth}. */
public static void nminDepth(long struct, float value) { memPutFloat(struct + VkViewport.MINDEPTH, value); }
/** Unsafe version of {@link #maxDepth(float) maxDepth}. */
public static void nmaxDepth(long struct, float value) { memPutFloat(struct + VkViewport.MAXDEPTH, value); }
// -----------------------------------
/** An array of {@link VkViewport} structs. */
public static class Buffer extends StructBuffer implements NativeResource {
/**
* Creates a new {@link VkViewport.Buffer} instance backed by the specified container.
*
* Changes to the container's content will be visible to the struct buffer instance and vice versa. The two buffers' position, limit, and mark values
* will be independent. The new buffer's position will be zero, its capacity and its limit will be the number of bytes remaining in this buffer divided
* by {@link VkViewport#SIZEOF}, and its mark will be undefined.
*
* The created buffer instance holds a strong reference to the container object.
*/
public Buffer(ByteBuffer container) {
super(container, container.remaining() / SIZEOF);
}
Buffer(long address, ByteBuffer container, int mark, int pos, int lim, int cap) {
super(address, container, mark, pos, lim, cap);
}
@Override
protected Buffer self() {
return this;
}
@Override
protected Buffer newBufferInstance(long address, ByteBuffer container, int mark, int pos, int lim, int cap) {
return new Buffer(address, container, mark, pos, lim, cap);
}
@Override
protected VkViewport newInstance(long address) {
return new VkViewport(address, container);
}
@Override
protected int sizeof() {
return SIZEOF;
}
/** Returns the value of the {@code x} field. */
public float x() { return VkViewport.nx(address()); }
/** Returns the value of the {@code y} field. */
public float y() { return VkViewport.ny(address()); }
/** Returns the value of the {@code width} field. */
public float width() { return VkViewport.nwidth(address()); }
/** Returns the value of the {@code height} field. */
public float height() { return VkViewport.nheight(address()); }
/** Returns the value of the {@code minDepth} field. */
public float minDepth() { return VkViewport.nminDepth(address()); }
/** Returns the value of the {@code maxDepth} field. */
public float maxDepth() { return VkViewport.nmaxDepth(address()); }
/** Sets the specified value to the {@code x} field. */
public VkViewport.Buffer x(float value) { VkViewport.nx(address(), value); return this; }
/** Sets the specified value to the {@code y} field. */
public VkViewport.Buffer y(float value) { VkViewport.ny(address(), value); return this; }
/** Sets the specified value to the {@code width} field. */
public VkViewport.Buffer width(float value) { VkViewport.nwidth(address(), value); return this; }
/** Sets the specified value to the {@code height} field. */
public VkViewport.Buffer height(float value) { VkViewport.nheight(address(), value); return this; }
/** Sets the specified value to the {@code minDepth} field. */
public VkViewport.Buffer minDepth(float value) { VkViewport.nminDepth(address(), value); return this; }
/** Sets the specified value to the {@code maxDepth} field. */
public VkViewport.Buffer maxDepth(float value) { VkViewport.nmaxDepth(address(), value); return this; }
}
}