All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.lwjgl.vulkan.VkViewport Maven / Gradle / Ivy

Go to download

A new generation graphics and compute API that provides high-efficiency, cross-platform access to modern GPUs used in a wide variety of devices from PCs and consoles to mobile phones and embedded platforms.

There is a newer version: 3.3.4
Show newest version
/*
 * Copyright LWJGL. All rights reserved.
 * License terms: https://www.lwjgl.org/license
 * MACHINE GENERATED FILE, DO NOT EDIT
 */
package org.lwjgl.vulkan;

import javax.annotation.*;

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 k / (2m - 1), where k ∈ { 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 application can specify a negative term for {@code height}, which has the effect of negating the y coordinate in clip space before performing the transform. When using a negative {@code height}, the application should also adjust the {@code y} value to point to the lower left corner of the viewport instead of the upper left corner. Using the negative {@code height} allows the application to avoid having to negate the y component of the {@code Position} output from the last vertex processing stage in shaders that also target other graphics APIs.

* *

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}
  • *
  • {@code width} must be less than or equal to {@link VkPhysicalDeviceLimits}{@code ::maxViewportDimensions}[0]
  • *
  • The absolute value of {@code height} must be less than or equal to {@link VkPhysicalDeviceLimits}{@code ::maxViewportDimensions}[1]
  • *
  • {@code x} must be greater than or equal to {@code viewportBoundsRange}[0]
  • *
  • (x + width) must be less than or equal to {@code viewportBoundsRange}[1]
  • *
  • {@code y} must be greater than or equal to {@code viewportBoundsRange}[0]
  • *
  • {@code y} must be less than or equal to {@code viewportBoundsRange}[1]
  • *
  • (y + height) must be greater than or equal to {@code viewportBoundsRange}[0]
  • *
  • (y + height) must be less than or equal to {@code viewportBoundsRange}[1]
  • *
* *
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, @Nullable 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; } /** * Copies the specified struct data to this struct. * * @param src the source struct * * @return this struct */ public VkViewport set(VkViewport src) { memCopy(src.address(), address(), SIZEOF); return this; } // ----------------------------------- /** Returns a new {@link VkViewport} instance allocated with {@link MemoryUtil#memAlloc memAlloc}. The instance must be explicitly freed. */ public static VkViewport malloc() { return create(nmemAllocChecked(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(nmemCallocChecked(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. */ public static VkViewport create(long address) { return new VkViewport(address, null); } /** Like {@link #create(long) create}, but returns {@code null} if {@code address} is {@code NULL}. */ @Nullable public static VkViewport createSafe(long address) { return address == NULL ? null : create(address); } /** * 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 VkViewport.Buffer malloc(int capacity) { return create(__malloc(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 VkViewport.Buffer calloc(int capacity) { return create(nmemCallocChecked(capacity, SIZEOF), capacity); } /** * Returns a new {@link VkViewport.Buffer} instance allocated with {@link BufferUtils}. * * @param capacity the buffer capacity */ public static VkViewport.Buffer create(int capacity) { return new Buffer(__create(capacity, SIZEOF)); } /** * Create a {@link VkViewport.Buffer} instance at the specified memory. * * @param address the memory address * @param capacity the buffer capacity */ public static VkViewport.Buffer create(long address, int capacity) { return new Buffer(address, capacity); } /** Like {@link #create(long, int) create}, but returns {@code null} if {@code address} is {@code NULL}. */ @Nullable public static VkViewport.Buffer createSafe(long address, int capacity) { return address == NULL ? null : create(address, 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 VkViewport.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 VkViewport.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 VkViewport.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 VkViewport.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); } public Buffer(long address, int cap) { super(address, null, -1, 0, cap, cap); } Buffer(long address, @Nullable 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, @Nullable 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 public 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; } } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy