remove boat lwjgl

This commit is contained in:
ShirosakiMio 2024-08-19 16:56:29 +08:00
parent a32b3686bd
commit 7d738e78ce
1157 changed files with 0 additions and 336479 deletions

View File

@ -1,35 +0,0 @@
plugins {
id 'java'
}
group 'org.lwjgl'
configurations.default.setCanBeResolved(true)
project.setArchivesBaseName('lwjgl')
project.setLibsDirName("${rootDir}/FCL/src/main/assets/app_runtime/lwjgl")
task buildLwjgl(dependsOn:'jar')
jar {
doLast {
archiveFileName = 'lwjgl.jar'
manifest {
attributes 'Manifest-Version': '3.3.3'
}
destinationDirectory.set(file("../FCL/src/main/assets/app_runtime/lwjgl"))
File versionFile = file("../FCL/src/main/assets/app_runtime/lwjgl/version")
versionFile.write(String.valueOf(new Date().getTime()))
}
}
java {
toolchain {
languageVersion = JavaLanguageVersion.of(8)
}
}
dependencies {
compileOnly 'com.google.code.findbugs:jsr305:3.0.2'
compileOnly fileTree(dir: 'libs', include: ['*.jar'])
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,292 +0,0 @@
/*
* Copyright (c) 2002-2008 LWJGL Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of 'LWJGL' nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.lwjgl;
import java.nio.Buffer;
import java.nio.ByteBuffer;
import java.nio.DoubleBuffer;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;
import java.nio.LongBuffer;
import java.nio.ShortBuffer;
/**
* <p>A class to check buffer boundaries in general. If there is unsufficient space
* in the buffer when the call is made then a buffer overflow would otherwise
* occur and cause unexpected behaviour, a crash, or worse, a security risk.
*
* Internal class, don't use.
* </p>
* @author cix_foo <cix_foo@users.sourceforge.net>
* @author elias_naur <elias_naur@users.sourceforge.net>
* @version $Revision$
* $Id$
*/
public class BufferChecks {
/** Static methods only! */
private BufferChecks() {
}
/**
* Helper methods to ensure a function pointer is not-null (0)
*/
public static void checkFunctionAddress(long pointer) {
if (LWJGLUtil.CHECKS && pointer == 0) {
throw new IllegalStateException("Function is not supported");
}
}
/**
* Helper methods to ensure a ByteBuffer is null-terminated
*/
public static void checkNullTerminated(ByteBuffer buf) {
if ( LWJGLUtil.CHECKS && buf.get(buf.limit() - 1) != 0) {
throw new IllegalArgumentException("Missing null termination");
}
}
public static void checkNullTerminated(ByteBuffer buf, int count) {
if ( LWJGLUtil.CHECKS ) {
int nullFound = 0;
for ( int i = buf.position(); i < buf.limit(); i++ ) {
if ( buf.get(i) == 0 )
nullFound++;
}
if ( nullFound < count )
throw new IllegalArgumentException("Missing null termination");
}
}
/** Helper method to ensure an IntBuffer is null-terminated */
public static void checkNullTerminated(IntBuffer buf) {
if ( LWJGLUtil.CHECKS && buf.get(buf.limit() - 1) != 0 ) {
throw new IllegalArgumentException("Missing null termination");
}
}
/** Helper method to ensure a LongBuffer is null-terminated */
public static void checkNullTerminated(LongBuffer buf) {
if ( LWJGLUtil.CHECKS && buf.get(buf.limit() - 1) != 0 ) {
throw new IllegalArgumentException("Missing null termination");
}
}
/** Helper method to ensure a PointerBuffer is null-terminated */
public static void checkNullTerminated(PointerBuffer buf) {
if ( LWJGLUtil.CHECKS && buf.get(buf.limit() - 1) != 0 ) {
throw new IllegalArgumentException("Missing null termination");
}
}
public static void checkNotNull(Object o) {
if ( LWJGLUtil.CHECKS && o == null)
throw new IllegalArgumentException("Null argument");
}
/**
* Helper methods to ensure a buffer is direct (and, implicitly, non-null).
*/
public static void checkDirect(ByteBuffer buf) {
if ( LWJGLUtil.CHECKS && !buf.isDirect()) {
throw new IllegalArgumentException("ByteBuffer is not direct");
}
}
public static void checkDirect(ShortBuffer buf) {
if ( LWJGLUtil.CHECKS && !buf.isDirect()) {
throw new IllegalArgumentException("ShortBuffer is not direct");
}
}
public static void checkDirect(IntBuffer buf) {
if ( LWJGLUtil.CHECKS && !buf.isDirect()) {
throw new IllegalArgumentException("IntBuffer is not direct");
}
}
public static void checkDirect(LongBuffer buf) {
if ( LWJGLUtil.CHECKS && !buf.isDirect()) {
throw new IllegalArgumentException("LongBuffer is not direct");
}
}
public static void checkDirect(FloatBuffer buf) {
if ( LWJGLUtil.CHECKS && !buf.isDirect()) {
throw new IllegalArgumentException("FloatBuffer is not direct");
}
}
public static void checkDirect(DoubleBuffer buf) {
if ( LWJGLUtil.CHECKS && !buf.isDirect()) {
throw new IllegalArgumentException("DoubleBuffer is not direct");
}
}
public static void checkDirect(PointerBuffer buf) {
// NO-OP, PointerBuffer is always direct.
}
public static void checkArray(Object[] array) {
if ( LWJGLUtil.CHECKS && (array == null || array.length == 0) )
throw new IllegalArgumentException("Invalid array");
}
/**
* This is a separate call to help inline checkBufferSize.
*/
private static void throwBufferSizeException(Buffer buf, int size) {
throw new IllegalArgumentException("Number of remaining buffer elements is " + buf.remaining() + ", must be at least " + size + ". Because at most " + size + " elements can be returned, a buffer with at least " + size + " elements is required, regardless of actual returned element count");
}
private static void throwBufferSizeException(PointerBuffer buf, int size) {
throw new IllegalArgumentException("Number of remaining pointer buffer elements is " + buf.remaining() + ", must be at least " + size);
}
private static void throwArraySizeException(Object[] array, int size) {
throw new IllegalArgumentException("Number of array elements is " + array.length + ", must be at least " + size);
}
private static void throwArraySizeException(long[] array, int size) {
throw new IllegalArgumentException("Number of array elements is " + array.length + ", must be at least " + size);
}
/**
* Helper method to ensure a buffer is big enough to receive data from a
* glGet* operation.
*
* @param buf
* The buffer to check
* @param size
* The minimum buffer size
* @throws IllegalArgumentException
*/
public static void checkBufferSize(Buffer buf, int size) {
if ( LWJGLUtil.CHECKS && buf.remaining() < size) {
throwBufferSizeException(buf, size);
}
}
/**
* Detects the buffer type and performs the corresponding check
* and also returns the buffer position in bytes.
*
* @param buffer the buffer to check
* @param size the size to check
*
* @return the buffer position in bytes
*/
public static int checkBuffer(final Buffer buffer, final int size) {
final int posShift;
if ( buffer instanceof ByteBuffer ) {
BufferChecks.checkBuffer((ByteBuffer)buffer, size);
posShift = 0;
} else if ( buffer instanceof ShortBuffer ) {
BufferChecks.checkBuffer((ShortBuffer)buffer, size);
posShift = 1;
} else if ( buffer instanceof IntBuffer ) {
BufferChecks.checkBuffer((IntBuffer)buffer, size);
posShift = 2;
} else if ( buffer instanceof LongBuffer ) {
BufferChecks.checkBuffer((LongBuffer)buffer, size);
posShift = 4;
} else if ( buffer instanceof FloatBuffer ) {
BufferChecks.checkBuffer((FloatBuffer)buffer, size);
posShift = 2;
} else if ( buffer instanceof DoubleBuffer ) {
BufferChecks.checkBuffer((DoubleBuffer)buffer, size);
posShift = 4;
} else
throw new IllegalArgumentException("Unsupported Buffer type specified: " + buffer.getClass());
return buffer.position() << posShift;
}
public static void checkBuffer(ByteBuffer buf, int size) {
if ( LWJGLUtil.CHECKS ) {
checkBufferSize(buf, size);
checkDirect(buf);
}
}
public static void checkBuffer(ShortBuffer buf, int size) {
if ( LWJGLUtil.CHECKS ) {
checkBufferSize(buf, size);
checkDirect(buf);
}
}
public static void checkBuffer(IntBuffer buf, int size) {
if ( LWJGLUtil.CHECKS ) {
checkBufferSize(buf, size);
checkDirect(buf);
}
}
public static void checkBuffer(LongBuffer buf, int size) {
if ( LWJGLUtil.CHECKS ) {
checkBufferSize(buf, size);
checkDirect(buf);
}
}
public static void checkBuffer(FloatBuffer buf, int size) {
if ( LWJGLUtil.CHECKS ) {
checkBufferSize(buf, size);
checkDirect(buf);
}
}
public static void checkBuffer(DoubleBuffer buf, int size) {
if ( LWJGLUtil.CHECKS ) {
checkBufferSize(buf, size);
checkDirect(buf);
}
}
public static void checkBuffer(PointerBuffer buf, int size) {
if ( LWJGLUtil.CHECKS && buf.remaining() < size ) {
throwBufferSizeException(buf, size);
}
}
public static void checkArray(Object[] array, int size) {
if ( LWJGLUtil.CHECKS && array.length < size )
throwArraySizeException(array, size);
}
public static void checkArray(long[] array, int size) {
if ( LWJGLUtil.CHECKS && array.length < size )
throwArraySizeException(array, size);
}
}

View File

@ -1,267 +0,0 @@
/*
* Copyright LWJGL. All rights reserved.
* License terms: https://www.lwjgl.org/license
*/
package org.lwjgl;
import org.lwjgl.system.*;
import java.nio.*;
import static org.lwjgl.system.APIUtil.*;
import static org.lwjgl.system.MemoryUtil.*;
/**
* <p>This class makes it easy and safe to work with direct buffers. It is the recommended way to allocate memory to use with LWJGL.</p>
*
* <h3>Direct buffers</h3>
*
* <p>LWJGL requires that all NIO buffers passed to it are direct buffers. Direct buffers essentially wrap an address that points to off-heap memory, i.e. a
* native pointer. This is the only way LWJGL can safely pass data from Java code to native code, and vice-versa, without a performance penalty. It does not
* support on-heap Java arrays (or plain NIO buffers, which wrap them) because arrays may be moved around in memory by the JVM's garbage collector while native
* code is accessing them. In addition, Java arrays have an unspecified layout, i.e. they are not necessarily contiguous in memory.</p>
*
* <h3>Usage</h3>
*
* <p>When a direct buffer is passed as an argument to an LWJGL method, no data is copied. Instead, the current buffer position is added to the buffer's memory
* address and the resulting value is passed to native code. The native code interprets that value as a pointer and reads or copies from it as necessary. LWJGL
* will often also use the current buffer limit (via {@link Buffer#remaining()}) to automatically pass length/maxlength arguments. This means that, just like
* other APIs that use NIO buffers, the current {@link Buffer#position()} and {@link Buffer#limit()} at the time of the call is very important. Contrary to
* other APIs, LWJGL never modifies the current position, it will be the same value before and after the call.</p>
*
* <h3>Arrays of pointers</h3>
*
* <p>In addition to the standard NIO buffer classes, LWJGL provides a {@link PointerBuffer} class for storing pointer data in an architecture independent way.
* It is used in bindings for pointer-to-pointers arguments, usually to provide arrays of data (input parameter) or to store returned pointer values (output
* parameter). Also, there's the {@link CLongBuffer} class which is similar to {@code PointerBuffer}, but for C {@code long} data.</p>
*
* <h3>Memory management</h3>
*
* <p>Using NIO buffers for off-heap memory has some drawbacks:</p>
* <ul>
* <li>Memory blocks bigger than {@link Integer#MAX_VALUE} bytes cannot be allocated.</li>
* <li>Memory blocks are zeroed-out on allocation, for safety. This has (sometimes unwanted) performance implications.</li>
* <li>There is no way to free a buffer explicitly (without JVM specific reflection). Buffer objects are subject to GC and it usually takes two GC cycles to
* free the off-heap memory after the buffer object becomes unreachable.</li>
* </ul>
*
* <p>An alternative API for allocating off-heap memory can be found in the {@link org.lwjgl.system.MemoryUtil} class. This has none of the above drawbacks,
* but requires allocated memory to be explictly freed when not used anymore.</p>
*
* <h3>Memory alignment</h3>
*
* <p>Allocations done via this class have a guaranteed alignment of 8 bytes. If higher alignment values are required, use the explicit memory management API
* or pad the requested memory with extra bytes and align manually.</p>
*
* <h3>Structs and arrays of structs</h3>
*
* <p>Java does not support struct value types, so LWJGL requires struct values that are backed by off-heap memory. Each struct type defined in a binding
* has a corresponding class in LWJGL that can be used to access its members. Each struct class also has a {@code Buffer} inner class that can be used to
* access (packed) arrays of struct values. Both struct and struct buffer classes may be backed by direct {@link ByteBuffer}s allocated from this class, but it
* is highly recommended to use explicit memory management for performance.</p>
*/
public final class BufferUtils {
private BufferUtils() {}
/**
* @return n, where buffer_element_size=2^n.
*/
public static int getElementSizeExponent(Buffer buf) {
if (buf instanceof ByteBuffer)
return 0;
else if (buf instanceof ShortBuffer || buf instanceof CharBuffer)
return 1;
else if (buf instanceof FloatBuffer || buf instanceof IntBuffer)
return 2;
else if (buf instanceof LongBuffer || buf instanceof DoubleBuffer)
return 3;
else
throw new IllegalStateException("Unsupported buffer type: " + buf);
}
/**
* A helper function which is used to get the byte offset in an arbitrary buffer
* based on its position
* @return the position of the buffer, in BYTES
*/
public static int getOffset(Buffer buffer) {
return buffer.position() << getElementSizeExponent(buffer);
}
/**
* Returns the memory address of the specified buffer.
*
* @param buffer
* the buffer
*
* @return the memory address
*/
static long getBufferAddress(Buffer buffer) {
// Should be below or memAddress0() ?
return memAddress(buffer);
}
/**
* Allocates a direct native-ordered {@code ByteBuffer} with the specified capacity.
*
* @param capacity the capacity, in bytes
*
* @return a {@code ByteBuffer}
*/
public static ByteBuffer createByteBuffer(int capacity) {
return ByteBuffer.allocateDirect(capacity).order(ByteOrder.nativeOrder());
}
static int getAllocationSize(int elements, int elementShift) {
apiCheckAllocation(elements, apiGetBytes(elements, elementShift), 0x7FFF_FFFFL);
return elements << elementShift;
}
/**
* Allocates a direct native-order {@code ShortBuffer} with the specified number of elements.
*
* @param capacity the capacity, in shorts
*
* @return a {@code ShortBuffer}
*/
public static ShortBuffer createShortBuffer(int capacity) {
return createByteBuffer(getAllocationSize(capacity, 1)).asShortBuffer();
}
/**
* Allocates a direct native-order {@code CharBuffer} with the specified number of elements.
*
* @param capacity the capacity, in chars
*
* @return a {@code CharBuffer}
*/
public static CharBuffer createCharBuffer(int capacity) {
return createByteBuffer(getAllocationSize(capacity, 1)).asCharBuffer();
}
/**
* Allocates a direct native-order {@code IntBuffer} with the specified number of elements.
*
* @param capacity the capacity, in ints
*
* @return an {@code IntBuffer}
*/
public static IntBuffer createIntBuffer(int capacity) {
return createByteBuffer(getAllocationSize(capacity, 2)).asIntBuffer();
}
/**
* Allocates a direct native-order {@code LongBuffer} with the specified number of elements.
*
* @param capacity the capacity, in longs
*
* @return a {@code LongBuffer}
*/
public static LongBuffer createLongBuffer(int capacity) {
return createByteBuffer(getAllocationSize(capacity, 3)).asLongBuffer();
}
/**
* Allocates a {@code CLongBuffer} with the specified number of elements.
*
* @param capacity the capacity, in memory addresses
*
* @return a {@code CLongBuffer}
*/
public static CLongBuffer createCLongBuffer(int capacity) {
return CLongBuffer.allocateDirect(capacity);
}
/**
* Allocates a direct native-order {@code FloatBuffer} with the specified number of elements.
*
* @param capacity the capacity, in floats
*
* @return a FloatBuffer
*/
public static FloatBuffer createFloatBuffer(int capacity) {
return createByteBuffer(getAllocationSize(capacity, 2)).asFloatBuffer();
}
/**
* Allocates a direct native-order {@code DoubleBuffer} with the specified number of elements.
*
* @param capacity the capacity, in doubles
*
* @return a {@code DoubleBuffer}
*/
public static DoubleBuffer createDoubleBuffer(int capacity) {
return createByteBuffer(getAllocationSize(capacity, 3)).asDoubleBuffer();
}
/**
* Allocates a {@code PointerBuffer} with the specified number of elements.
*
* @param capacity the capacity, in memory addresses
*
* @return a {@code PointerBuffer}
*/
public static PointerBuffer createPointerBuffer(int capacity) {
return PointerBuffer.allocateDirect(capacity);
}
// memsets
/**
* Fills the specified buffer with zeros from the current position to the current limit.
*
* @param buffer the buffer to fill with zeros
*/
public static void zeroBuffer(ByteBuffer buffer) { memSet(buffer, 0); }
/**
* Fills the specified buffer with zeros from the current position to the current limit.
*
* @param buffer the buffer to fill with zeros
*/
public static void zeroBuffer(ShortBuffer buffer) { memSet(buffer, 0); }
/**
* Fills the specified buffer with zeros from the current position to the current limit.
*
* @param buffer the buffer to fill with zeros
*/
public static void zeroBuffer(CharBuffer buffer) { memSet(buffer, 0); }
/**
* Fills the specified buffer with zeros from the current position to the current limit.
*
* @param buffer the buffer to fill with zeros
*/
public static void zeroBuffer(IntBuffer buffer) { memSet(buffer, 0); }
/**
* Fills the specified buffer with zeros from the current position to the current limit.
*
* @param buffer the buffer to fill with zeros
*/
public static void zeroBuffer(FloatBuffer buffer) { memSet(buffer, 0); }
/**
* Fills the specified buffer with zeros from the current position to the current limit.
*
* @param buffer the buffer to fill with zeros
*/
public static void zeroBuffer(LongBuffer buffer) { memSet(buffer, 0); }
/**
* Fills the specified buffer with zeros from the current position to the current limit.
*
* @param buffer the buffer to fill with zeros
*/
public static void zeroBuffer(DoubleBuffer buffer) { memSet(buffer, 0); }
/**
* Fills the specified buffer with zeros from the current position to the current limit.
*
* @param buffer the buffer to fill with zeros
*/
public static <T extends CustomBuffer<T>> void zeroBuffer(T buffer) { memSet(buffer, 0); }
}

View File

@ -1,407 +0,0 @@
/*
* Copyright LWJGL. All rights reserved.
* License terms: https://www.lwjgl.org/license
*/
package org.lwjgl;
import org.lwjgl.system.*;
import javax.annotation.*;
import java.nio.*;
import static org.lwjgl.system.CheckIntrinsics.*;
import static org.lwjgl.system.Checks.*;
import static org.lwjgl.system.MemoryUtil.*;
/**
* This class is a container for C {@code long} data. Its interface mirrors the {@link LongBuffer} API for convenience.
*
* <p>The size of the C {@code long} type depends on the platform and CPU architecture. On Windows it is always 32-bit. On other platforms, it is 32-bit on
* 32-bit architectures and 64-bit on 64-bit architectures. Most APIs prefer portable sizes, so this class is rarely needed.</p>
*/
public class CLongBuffer extends CustomBuffer<CLongBuffer> implements Comparable<CLongBuffer> {
protected CLongBuffer(long address, @Nullable ByteBuffer container, int mark, int position, int limit, int capacity) {
super(address, container, mark, position, limit, capacity);
}
/**
* Allocates a new long buffer.
*
* <p>The new buffer's position will be zero, its limit will be its capacity, and its mark will be undefined.</p>
*
* @param capacity the new buffer's capacity, in longs
*
* @return the new long buffer
*
* @throws IllegalArgumentException If the {@code capacity} is a negative integer
*/
public static CLongBuffer allocateDirect(int capacity) {
ByteBuffer source = BufferUtils.createByteBuffer(BufferUtils.getAllocationSize(capacity, CLONG_SHIFT));
return new CLongBuffer(memAddress(source), source, -1, 0, capacity, capacity);
}
/**
* Creates a new {@code CLongBuffer} that starts at the specified memory address and has the specified capacity.
*
* @param address the starting memory address
* @param capacity the buffer capacity, in number of longs
*/
public static CLongBuffer create(long address, int capacity) {
return new CLongBuffer(address, null, -1, 0, capacity, capacity);
}
/**
* Creates a new {@code CLongBuffer} using the specified ByteBuffer as its long data source.
*
* @param source the source buffer
*/
public static CLongBuffer create(ByteBuffer source) {
int capacity = source.remaining() >> CLONG_SHIFT;
return new CLongBuffer(memAddress(source), source, -1, 0, capacity, capacity);
}
@Override
protected CLongBuffer self() {
return this;
}
@Override
public int sizeof() {
return CLONG_SIZE;
}
/**
* Relative <i>get</i> method. Reads the long at this buffer's current position, and then increments the position.
*
* @return the long at the buffer's current position
*
* @throws BufferUnderflowException If the buffer's current position is not smaller than its limit
*/
public long get() {
return memGetCLong(address + Integer.toUnsignedLong(nextGetIndex()) * CLONG_SIZE);
}
/**
* Convenience relative get from a source ByteBuffer.
*
* @param source the source ByteBuffer
*/
public static long get(ByteBuffer source) {
if (source.remaining() < CLONG_SIZE) {
throw new BufferUnderflowException();
}
try {
return memGetCLong(memAddress(source));
} finally {
source.position(source.position() + CLONG_SIZE);
}
}
/**
* Relative <i>put</i> method&nbsp;&nbsp;<i>(optional operation)</i>.
*
* <p>Writes the specified long into this buffer at the current position, and then increments the position.</p>
*
* @param p the long to be written
*
* @return This buffer
*
* @throws BufferOverflowException If this buffer's current position is not smaller than its limit
*/
public CLongBuffer put(long p) {
memPutCLong(address + Integer.toUnsignedLong(nextPutIndex()) * CLONG_SIZE, p);
return this;
}
/**
* Convenience relative put on a target ByteBuffer.
*
* @param target the target ByteBuffer
* @param p the long value to be written
*/
public static void put(ByteBuffer target, long p) {
if (target.remaining() < CLONG_SIZE) {
throw new BufferOverflowException();
}
try {
memPutCLong(memAddress(target), p);
} finally {
target.position(target.position() + CLONG_SIZE);
}
}
/**
* Absolute <i>get</i> method. Reads the long at the specified {@code index}.
*
* @param index the index from which the long will be read
*
* @return the long at the specified {@code index}
*
* @throws IndexOutOfBoundsException If {@code index} is negative or not smaller than the buffer's limit
*/
public long get(int index) {
return memGetCLong(address + check(index, limit) * CLONG_SIZE);
}
/**
* Convenience absolute get from a source ByteBuffer.
*
* @param source the source ByteBuffer
* @param index the index at which the long will be read
*/
public static long get(ByteBuffer source, int index) {
checkFromIndexSize(index, CLONG_SIZE, source.limit());
return memGetCLong(memAddress0(source) + index);
}
/**
* Absolute <i>put</i> method&nbsp;&nbsp;<i>(optional operation)</i>.
*
* <p>Writes the specified long into this buffer at the specified {@code index}.</p>
*
* @param index the index at which the long will be written
* @param p the long value to be written
*
* @return This buffer
*
* @throws IndexOutOfBoundsException If {@code index} is negative or not smaller than the buffer's limit
*/
public CLongBuffer put(int index, long p) {
memPutCLong(address + check(index, limit) * CLONG_SIZE, p);
return this;
}
/**
* Convenience absolute put on a target ByteBuffer.
*
* @param target the target ByteBuffer
* @param index the index at which the long will be written
* @param p the long value to be written
*/
public static void put(ByteBuffer target, int index, long p) {
checkFromIndexSize(index, CLONG_SIZE, target.limit());
memPutCLong(memAddress0(target) + index, p);
}
// -- Bulk get operations --
/**
* Relative bulk <i>get</i> method.
*
* <p>This method transfers longs from this buffer into the specified destination array. An invocation of this method of the form {@code src.get(a)}
* behaves in exactly the same way as the invocation
*
* <pre>
* src.get(a, 0, a.length) </pre>
*
* @return This buffer
*
* @throws BufferUnderflowException If there are fewer than {@code length} longs remaining in this buffer
*/
public CLongBuffer get(long[] dst) {
return get(dst, 0, dst.length);
}
/**
* Relative bulk <i>get</i> method.
*
* <p>This method transfers longs from this buffer into the specified destination array. If there are fewer longs remaining in the buffer than are
* required to satisfy the request, that is, if {@code length}&nbsp;{@code &gt;}&nbsp;{@code remaining()}, then no longs are transferred and a
* {@link BufferUnderflowException} is thrown.
*
* <p>Otherwise, this method copies {@code length} longs from this buffer into the specified array, starting at the current position of this buffer and
* at the specified offset in the array. The position of this buffer is then incremented by {@code length}.
*
* <p>In other words, an invocation of this method of the form {@code src.get(dst,&nbsp;off,&nbsp;len)} has exactly the same effect as the loop</p>
*
* <pre>
* for (int i = off; i &lt; off + len; i++)
* dst[i] = src.get(); </pre>
*
* <p>except that it first checks that there are sufficient longs in this buffer and it is potentially much more efficient. </p>
*
* @param dst the array into which longs are to be written
* @param offset the offset within the array of the first long to be written; must be non-negative and no larger than {@code dst.length}
* @param length the maximum number of longs to be written to the specified array; must be non-negative and no larger than {@code dst.length - offset}
*
* @return This buffer
*
* @throws BufferUnderflowException If there are fewer than {@code length} longs remaining in this buffer
* @throws IndexOutOfBoundsException If the preconditions on the {@code offset} and {@code length} parameters do not hold
*/
public CLongBuffer get(long[] dst, int offset, int length) {
if (CLONG_SIZE == 8) {
memLongBuffer(address(), remaining()).get(dst, offset, length);
position(position() + length);
} else {
get32(dst, offset, length);
}
return this;
}
private void get32(long[] dst, int offset, int length) {
checkFromIndexSize(offset, length, dst.length);
if (remaining() < length) {
throw new BufferUnderflowException();
}
for (int i = offset, end = offset + length; i < end; i++) {
dst[i] = get();
}
}
/**
* Relative bulk <i>put</i> method&nbsp;&nbsp;<i>(optional operation)</i>.
*
* <p>This method transfers the entire content of the specified source long array into this buffer. An invocation of this method of the form
* {@code dst.put(a)} behaves in exactly the same way as the invocation</p>
*
* <pre>
* dst.put(a, 0, a.length) </pre>
*
* @return This buffer
*
* @throws BufferOverflowException If there is insufficient space in this buffer
*/
public CLongBuffer put(long[] src) {
return put(src, 0, src.length);
}
/**
* Relative bulk <i>put</i> method&nbsp;&nbsp;<i>(optional operation)</i>.
*
* <p>This method transfers longs into this buffer from the specified source array. If there are more longs to be copied from the array than remain
* in this buffer, that is, if {@code length}&nbsp;{@code &gt;}&nbsp;{@code remaining()}, then no longs are transferred and a
* {@link BufferOverflowException} is thrown.
*
* <p>Otherwise, this method copies {@code length} longs from the specified array into this buffer, starting at the specified offset in the array and
* at the current position of this buffer. The position of this buffer is then incremented by {@code length}.</p>
*
* <p>In other words, an invocation of this method of the form {@code dst.put(src,&nbsp;off,&nbsp;len)} has exactly the same effect as the loop</p>
*
* <pre>
* for (int i = off; i &lt; off + len; i++)
* dst.put(a[i]); </pre>
*
* <p>except that it first checks that there is sufficient space in this buffer and it is potentially much more efficient.</p>
*
* @param src the array from which longs are to be read
* @param offset the offset within the array of the first long to be read; must be non-negative and no larger than {@code array.length}
* @param length the number of longs to be read from the specified array; must be non-negative and no larger than {@code array.length - offset}
*
* @return This buffer
*
* @throws BufferOverflowException If there is insufficient space in this buffer
* @throws IndexOutOfBoundsException If the preconditions on the {@code offset} and {@code length} parameters do not hold
*/
public CLongBuffer put(long[] src, int offset, int length) {
if (CLONG_SIZE == 8) {
memLongBuffer(address(), remaining()).put(src, offset, length);
position(position() + length);
} else {
put32(src, offset, length);
}
return this;
}
private void put32(long[] src, int offset, int length) {
checkFromIndexSize(offset, length, src.length);
if (remaining() < length) {
throw new BufferOverflowException();
}
int end = offset + length;
for (int i = offset; i < end; i++) {
put(src[i]);
}
}
/**
* Returns the current hash code of this buffer.
*
* <p>The hash code of a long buffer depends only upon its remaining elements; that is, upon the elements from {@code position()} up to, and including,
* the element at {@code limit()}&nbsp;-&nbsp;{@code 1}.</p>
*
* <p>Because buffer hash codes are content-dependent, it is inadvisable to use buffers as keys in hash maps or similar data structures unless it is known
* that their contents will not change.</p>
*
* @return the current hash code of this buffer
*/
public int hashCode() {
int h = 1;
int p = position();
for (int i = limit() - 1; i >= p; i--) {
h = 31 * h + (int)get(i);
}
return h;
}
/**
* Tells whether or not this buffer is equal to another object.
*
* <p>Two long buffers are equal if, and only if,</p>
*
* <ol>
* <li>They have the same element type,</li>
* <li>They have the same number of remaining elements, and</li>
* <li>The two sequences of remaining elements, considered
* independently of their starting positions, are pointwise equal.</li>
* </ol>
*
* <p>A long buffer is not equal to any other type of object.</p>
*
* @param ob the object to which this buffer is to be compared
*
* @return {@code true} if, and only if, this buffer is equal to the
* given object
*/
public boolean equals(Object ob) {
if (!(ob instanceof CLongBuffer)) {
return false;
}
CLongBuffer that = (CLongBuffer)ob;
if (this.remaining() != that.remaining()) {
return false;
}
int p = this.position();
for (int i = this.limit() - 1, j = that.limit() - 1; i >= p; i--, j--) {
long v1 = this.get(i);
long v2 = that.get(j);
if (v1 != v2) {
return false;
}
}
return true;
}
/**
* Compares this buffer to another.
*
* <p>Two long buffers are compared by comparing their sequences of remaining elements lexicographically, without regard to the starting position of
* each sequence within its corresponding buffer.</p>
*
* <p>A long buffer is not comparable to any other type of object.</p>
*
* @return A negative integer, zero, or a positive integer as this buffer is less than, equal to, or greater than the specified buffer
*/
@Override
public int compareTo(CLongBuffer that) {
int n = this.position() + Math.min(this.remaining(), that.remaining());
for (int i = this.position(), j = that.position(); i < n; i++, j++) {
long v1 = this.get(i);
long v2 = that.get(j);
if (v1 == v2) {
continue;
}
if (v1 < v2) {
return -1;
}
return +1;
}
return this.remaining() - that.remaining();
}
}

View File

@ -1,79 +0,0 @@
/*
* Copyright (c) 2002-2008 LWJGL Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of 'LWJGL' nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.lwjgl;
/**
* <p>
* This exception is supplied to make exception handling more generic for LWJGL
* specific exceptions
* </p>
*
* @author Brian Matzon <brian@matzon.dk>
* @version $Revision$
* $Id$
*/
public class LWJGLException extends Exception {
private static final long serialVersionUID = 1L;
/**
* Plain c'tor
*/
public LWJGLException() {
super();
}
/**
* Creates a new LWJGLException
*
* @param msg
* String identifier for exception
*/
public LWJGLException(String msg) {
super(msg);
}
/**
* @param message
* @param cause
*/
public LWJGLException(String message, Throwable cause) {
super(message, cause);
}
/**
* @param cause
*/
public LWJGLException(Throwable cause) {
super(cause);
}
}

View File

@ -1,632 +0,0 @@
/*
* Copyright (c) 2002-2008 LWJGL Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of 'LWJGL' nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.lwjgl;
import java.io.File;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.nio.ByteBuffer;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
/**
* <p>
* Internal library methods
* </p>
*
* @author Brian Matzon <brian@matzon.dk>
* @version $Revision$
* $Id$
*/
public class LWJGLUtil {
public static final int PLATFORM_LINUX = 1;
public static final int PLATFORM_MACOSX = 2;
public static final int PLATFORM_WINDOWS = 3;
public static final String PLATFORM_LINUX_NAME = "linux";
public static final String PLATFORM_MACOSX_NAME = "macosx";
public static final String PLATFORM_WINDOWS_NAME = "windows";
private static final String LWJGL_ICON_DATA_16x16 =
"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" +
"\377\377\377\377\377\377\377\377\376\377\377\377\302\327\350\377" +
"\164\244\313\377\120\213\275\377\124\216\277\377\206\257\322\377" +
"\347\357\366\377\377\377\377\377\377\377\377\377\377\377\377\377" +
"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" +
"\377\377\377\377\365\365\365\377\215\217\221\377\166\202\215\377" +
"\175\215\233\377\204\231\252\377\224\267\325\377\072\175\265\377" +
"\110\206\272\377\332\347\361\377\377\377\377\377\377\377\377\377" +
"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" +
"\364\370\373\377\234\236\240\377\000\000\000\377\000\000\000\377" +
"\000\000\000\377\000\000\000\377\344\344\344\377\204\255\320\377" +
"\072\175\265\377\133\222\301\377\374\375\376\377\377\377\377\377" +
"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" +
"\221\266\325\377\137\137\137\377\000\000\000\377\000\000\000\377" +
"\000\000\000\377\042\042\042\377\377\377\377\377\350\360\366\377" +
"\071\174\265\377\072\175\265\377\304\330\351\377\377\377\377\377" +
"\377\377\377\377\377\377\377\377\377\377\377\377\306\331\351\377" +
"\201\253\316\377\035\035\035\377\000\000\000\377\000\000\000\377" +
"\000\000\000\377\146\146\146\377\377\377\377\377\320\340\355\377" +
"\072\175\265\377\072\175\265\377\215\264\324\377\377\377\377\377" +
"\362\362\362\377\245\245\245\377\337\337\337\377\242\301\334\377" +
"\260\305\326\377\012\012\012\377\000\000\000\377\000\000\000\377" +
"\000\000\000\377\250\250\250\377\377\377\377\377\227\272\330\377" +
"\072\175\265\377\072\175\265\377\161\241\312\377\377\377\377\377" +
"\241\241\241\377\000\000\000\377\001\001\001\377\043\043\043\377" +
"\314\314\314\377\320\320\320\377\245\245\245\377\204\204\204\377" +
"\134\134\134\377\357\357\357\377\377\377\377\377\140\226\303\377" +
"\072\175\265\377\072\175\265\377\155\236\310\377\377\377\377\377" +
"\136\136\136\377\000\000\000\377\000\000\000\377\000\000\000\377" +
"\317\317\317\377\037\037\037\377\003\003\003\377\053\053\053\377" +
"\154\154\154\377\306\306\306\377\372\374\375\377\236\277\332\377" +
"\167\245\314\377\114\211\274\377\174\250\316\377\377\377\377\377" +
"\033\033\033\377\000\000\000\377\000\000\000\377\027\027\027\377" +
"\326\326\326\377\001\001\001\377\000\000\000\377\000\000\000\377" +
"\000\000\000\377\122\122\122\377\345\345\345\377\075\075\075\377" +
"\150\150\150\377\246\246\247\377\332\336\341\377\377\377\377\377" +
"\164\164\164\377\016\016\016\377\000\000\000\377\131\131\131\377" +
"\225\225\225\377\000\000\000\377\000\000\000\377\000\000\000\377" +
"\000\000\000\377\221\221\221\377\233\233\233\377\000\000\000\377" +
"\000\000\000\377\000\000\000\377\002\002\002\377\103\103\103\377" +
"\377\377\377\377\356\356\356\377\214\214\214\377\277\277\277\377" +
"\126\126\126\377\000\000\000\377\000\000\000\377\000\000\000\377" +
"\000\000\000\377\323\323\323\377\130\130\130\377\000\000\000\377" +
"\000\000\000\377\000\000\000\377\000\000\000\377\063\063\063\377" +
"\377\377\377\377\377\377\377\377\374\375\376\377\377\377\377\377" +
"\300\300\300\377\100\100\100\377\002\002\002\377\000\000\000\377" +
"\033\033\033\377\373\373\373\377\027\027\027\377\000\000\000\377" +
"\000\000\000\377\000\000\000\377\000\000\000\377\170\170\170\377" +
"\377\377\377\377\377\377\377\377\322\341\356\377\176\251\316\377" +
"\340\352\363\377\377\377\377\377\324\324\324\377\155\155\155\377" +
"\204\204\204\377\323\323\323\377\000\000\000\377\000\000\000\377" +
"\000\000\000\377\000\000\000\377\000\000\000\377\275\275\275\377" +
"\377\377\377\377\377\377\377\377\376\376\376\377\146\232\305\377" +
"\075\177\266\377\202\254\320\377\344\355\365\377\377\377\377\377" +
"\377\377\377\377\345\345\345\377\055\055\055\377\000\000\000\377" +
"\000\000\000\377\000\000\000\377\014\014\014\377\366\366\366\377" +
"\377\377\377\377\377\377\377\377\377\377\377\377\342\354\364\377" +
"\115\211\274\377\072\175\265\377\076\200\266\377\207\260\322\377" +
"\347\357\366\377\377\377\377\377\376\376\376\377\274\274\274\377" +
"\117\117\117\377\003\003\003\377\112\112\112\377\377\377\377\377" +
"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" +
"\353\362\370\377\214\263\324\377\126\220\300\377\120\214\275\377" +
"\167\245\314\377\355\363\370\377\377\377\377\377\377\377\377\377" +
"\377\377\377\377\337\337\337\377\346\346\346\377\377\377\377\377";
private static final String LWJGL_ICON_DATA_32x32 =
"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" +
"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\372\374\375\377" +
"\313\335\354\377\223\267\326\377\157\240\311\377\134\223\302\377\140\226\303\377\172\247\315\377\254\310\340\377\355\363\370\377" +
"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" +
"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" +
"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\374\375\376\377\265\316\343\377\132\222\301\377" +
"\072\175\265\377\072\175\265\377\072\175\265\377\072\175\265\377\072\175\265\377\072\175\265\377\072\175\265\377\105\205\271\377" +
"\241\301\334\377\374\375\376\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" +
"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" +
"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\374\374\374\377\342\352\361\377\270\317\343\377\256\311\340\377" +
"\243\302\334\377\230\272\330\377\214\263\323\377\201\254\317\377\156\237\310\377\075\177\266\377\072\175\265\377\072\175\265\377" +
"\072\175\265\377\162\242\312\377\365\370\373\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" +
"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" +
"\377\377\377\377\377\377\377\377\377\377\377\377\330\330\330\377\061\061\061\377\044\044\044\377\061\061\061\377\100\100\100\377" +
"\122\122\122\377\145\145\145\377\164\164\164\377\217\217\217\377\367\370\370\377\254\310\337\377\073\175\265\377\072\175\265\377" +
"\072\175\265\377\072\175\265\377\171\247\315\377\374\375\376\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" +
"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" +
"\377\377\377\377\377\377\377\377\376\376\376\377\150\150\150\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377" +
"\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\266\266\266\377\376\376\376\377\206\256\321\377\072\175\265\377" +
"\072\175\265\377\072\175\265\377\072\175\265\377\256\312\341\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" +
"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" +
"\377\377\377\377\323\342\356\377\341\352\362\377\050\050\050\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377" +
"\000\000\000\377\000\000\000\377\000\000\000\377\002\002\002\377\336\336\336\377\377\377\377\377\365\370\373\377\133\222\301\377" +
"\072\175\265\377\072\175\265\377\072\175\265\377\110\206\272\377\364\370\373\377\377\377\377\377\377\377\377\377\377\377\377\377" +
"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" +
"\354\363\370\377\144\231\305\377\327\331\333\377\005\005\005\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377" +
"\000\000\000\377\000\000\000\377\000\000\000\377\044\044\044\377\376\376\376\377\377\377\377\377\377\377\377\377\300\325\347\377" +
"\071\174\265\377\072\175\265\377\072\175\265\377\072\175\265\377\253\310\340\377\377\377\377\377\377\377\377\377\377\377\377\377" +
"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\376\377\377\377" +
"\170\246\314\377\173\247\315\377\236\236\236\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377" +
"\000\000\000\377\000\000\000\377\000\000\000\377\145\145\145\377\377\377\377\377\377\377\377\377\377\377\377\377\342\354\364\377" +
"\067\173\264\377\072\175\265\377\072\175\265\377\072\175\265\377\146\232\305\377\377\377\377\377\377\377\377\377\377\377\377\377" +
"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\303\327\350\377" +
"\071\175\265\377\262\314\341\377\130\130\130\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377" +
"\000\000\000\377\000\000\000\377\000\000\000\377\251\251\251\377\377\377\377\377\377\377\377\377\377\377\377\377\274\322\345\377" +
"\072\175\265\377\072\175\265\377\072\175\265\377\072\175\265\377\100\201\267\377\356\364\371\377\377\377\377\377\377\377\377\377" +
"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\372\374\375\377\132\222\301\377" +
"\075\177\266\377\335\345\355\377\034\034\034\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377" +
"\000\000\000\377\000\000\000\377\007\007\007\377\347\347\347\377\377\377\377\377\377\377\377\377\377\377\377\377\205\256\321\377" +
"\072\175\265\377\072\175\265\377\072\175\265\377\072\175\265\377\071\175\265\377\314\336\354\377\377\377\377\377\377\377\377\377" +
"\377\377\377\377\377\377\377\377\376\376\376\377\377\377\377\377\377\377\377\377\377\377\377\377\272\322\345\377\072\175\265\377" +
"\127\220\277\377\320\321\321\377\003\003\003\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377" +
"\000\000\000\377\000\000\000\377\063\063\063\377\375\375\375\377\377\377\377\377\377\377\377\377\373\374\375\377\120\213\275\377" +
"\072\175\265\377\072\175\265\377\072\175\265\377\072\175\265\377\071\175\265\377\261\314\342\377\377\377\377\377\377\377\377\377" +
"\377\377\377\377\312\312\312\377\067\067\067\377\141\141\141\377\242\242\242\377\335\335\335\377\344\354\363\377\261\313\341\377" +
"\264\315\342\377\346\346\346\377\043\043\043\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377" +
"\000\000\000\377\000\000\000\377\162\162\162\377\377\377\377\377\377\377\377\377\377\377\377\377\330\345\360\377\072\175\265\377" +
"\072\175\265\377\072\175\265\377\072\175\265\377\072\175\265\377\072\175\265\377\240\300\333\377\377\377\377\377\377\377\377\377" +
"\377\377\377\377\146\146\146\377\000\000\000\377\000\000\000\377\000\000\000\377\006\006\006\377\047\047\047\377\146\146\146\377" +
"\324\324\324\377\377\377\377\377\366\366\366\377\320\320\320\377\227\227\227\377\136\136\136\377\047\047\047\377\004\004\004\377" +
"\000\000\000\377\003\003\003\377\300\300\300\377\377\377\377\377\377\377\377\377\377\377\377\377\242\301\333\377\072\175\265\377" +
"\072\175\265\377\072\175\265\377\072\175\265\377\072\175\265\377\072\175\265\377\236\277\332\377\377\377\377\377\377\377\377\377" +
"\373\373\373\377\045\045\045\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377" +
"\134\134\134\377\377\377\377\377\352\352\352\377\217\217\217\377\265\265\265\377\351\351\351\377\375\375\375\377\347\347\347\377" +
"\262\262\262\377\275\275\275\377\376\376\376\377\377\377\377\377\377\377\377\377\377\377\377\377\153\235\307\377\072\175\265\377" +
"\072\175\265\377\072\175\265\377\072\175\265\377\072\175\265\377\072\175\265\377\241\301\334\377\377\377\377\377\377\377\377\377" +
"\333\333\333\377\003\003\003\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377" +
"\203\203\203\377\377\377\377\377\137\137\137\377\000\000\000\377\000\000\000\377\013\013\013\377\067\067\067\377\166\166\166\377" +
"\267\267\267\377\360\360\360\377\377\377\377\377\377\377\377\377\377\377\377\377\360\365\371\377\113\210\273\377\075\177\266\377" +
"\071\174\265\377\072\175\265\377\072\175\265\377\072\175\265\377\072\175\265\377\262\314\342\377\377\377\377\377\377\377\377\377" +
"\232\232\232\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377" +
"\305\305\305\377\367\367\367\377\035\035\035\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377" +
"\000\000\000\377\007\007\007\377\074\074\074\377\337\337\337\377\377\377\377\377\373\374\375\377\374\375\376\377\363\367\372\377" +
"\314\335\353\377\236\276\332\377\162\241\311\377\114\211\273\377\072\175\265\377\311\334\353\377\377\377\377\377\377\377\377\377" +
"\126\126\126\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\017\017\017\377" +
"\371\371\371\377\321\321\321\377\003\003\003\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377" +
"\000\000\000\377\000\000\000\377\000\000\000\377\216\216\216\377\377\377\377\377\371\371\371\377\204\204\204\377\160\160\160\377" +
"\260\260\260\377\352\352\352\377\377\377\377\377\371\373\374\377\334\350\362\377\366\371\374\377\377\377\377\377\377\377\377\377" +
"\025\025\025\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\116\116\116\377" +
"\377\377\377\377\221\221\221\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377" +
"\000\000\000\377\000\000\000\377\000\000\000\377\273\273\273\377\377\377\377\377\236\236\236\377\000\000\000\377\000\000\000\377" +
"\000\000\000\377\004\004\004\377\057\057\057\377\160\160\160\377\260\260\260\377\346\346\346\377\376\376\376\377\377\377\377\377" +
"\071\071\071\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\220\220\220\377" +
"\377\377\377\377\115\115\115\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377" +
"\000\000\000\377\000\000\000\377\020\020\020\377\360\360\360\377\377\377\377\377\132\132\132\377\000\000\000\377\000\000\000\377" +
"\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\011\011\011\377\062\062\062\377\261\261\261\377" +
"\366\366\366\377\241\241\241\377\065\065\065\377\002\002\002\377\000\000\000\377\000\000\000\377\002\002\002\377\321\321\321\377" +
"\365\365\365\377\023\023\023\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377" +
"\000\000\000\377\000\000\000\377\105\105\105\377\376\376\376\377\370\370\370\377\035\035\035\377\000\000\000\377\000\000\000\377" +
"\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\053\053\053\377" +
"\377\377\377\377\377\377\377\377\374\374\374\377\276\276\276\377\120\120\120\377\005\005\005\377\045\045\045\377\371\371\371\377" +
"\302\302\302\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377" +
"\000\000\000\377\000\000\000\377\206\206\206\377\377\377\377\377\322\322\322\377\001\001\001\377\000\000\000\377\000\000\000\377" +
"\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\103\103\103\377" +
"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\376\376\376\377\334\334\334\377\340\340\340\377\377\377\377\377" +
"\225\225\225\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377" +
"\000\000\000\377\001\001\001\377\310\310\310\377\377\377\377\377\216\216\216\377\000\000\000\377\000\000\000\377\000\000\000\377" +
"\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\210\210\210\377" +
"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" +
"\337\337\337\377\051\051\051\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377" +
"\000\000\000\377\030\030\030\377\365\365\365\377\377\377\377\377\112\112\112\377\000\000\000\377\000\000\000\377\000\000\000\377" +
"\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\317\317\317\377" +
"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\361\366\372\377\377\377\377\377\377\377\377\377" +
"\377\377\377\377\371\371\371\377\265\265\265\377\113\113\113\377\006\006\006\377\000\000\000\377\000\000\000\377\000\000\000\377" +
"\000\000\000\377\122\122\122\377\377\377\377\377\370\370\370\377\020\020\020\377\000\000\000\377\000\000\000\377\000\000\000\377" +
"\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\034\034\034\377\370\370\370\377" +
"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\206\257\321\377\220\265\325\377\352\361\367\377" +
"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\333\333\333\377\170\170\170\377\033\033\033\377\000\000\000\377" +
"\000\000\000\377\226\226\226\377\377\377\377\377\306\306\306\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377" +
"\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\132\132\132\377\377\377\377\377" +
"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\303\330\351\377\072\175\265\377\103\203\270\377" +
"\224\270\326\377\355\363\370\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\364\364\364\377\247\247\247\377" +
"\205\205\205\377\364\364\364\377\377\377\377\377\206\206\206\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377" +
"\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\235\235\235\377\377\377\377\377" +
"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\372\373\375\377\135\224\302\377\072\175\265\377" +
"\072\175\265\377\106\205\271\377\230\273\330\377\357\364\371\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" +
"\377\377\377\377\377\377\377\377\377\377\377\377\233\233\233\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377" +
"\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\005\005\005\377\335\335\335\377\377\377\377\377" +
"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\305\331\351\377\073\176\266\377" +
"\072\175\265\377\072\175\265\377\072\175\265\377\110\206\272\377\236\276\332\377\362\366\372\377\377\377\377\377\377\377\377\377" +
"\377\377\377\377\377\377\377\377\377\377\377\377\373\373\373\377\216\216\216\377\045\045\045\377\001\001\001\377\000\000\000\377" +
"\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\054\054\054\377\374\374\374\377\377\377\377\377" +
"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\217\265\325\377" +
"\072\175\265\377\072\175\265\377\072\175\265\377\072\175\265\377\072\175\265\377\112\207\273\377\243\302\334\377\363\367\372\377" +
"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\372\372\372\377\260\260\260\377\105\105\105\377" +
"\004\004\004\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\156\156\156\377\377\377\377\377\377\377\377\377" +
"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\374\375\376\377" +
"\205\257\321\377\072\175\265\377\072\175\265\377\072\175\265\377\072\175\265\377\072\175\265\377\072\175\265\377\115\211\274\377" +
"\250\305\336\377\366\371\374\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\376\376\376\377" +
"\322\322\322\377\150\150\150\377\016\016\016\377\000\000\000\377\001\001\001\377\270\270\270\377\377\377\377\377\377\377\377\377" +
"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" +
"\376\376\377\377\261\313\342\377\114\211\274\377\071\175\265\377\072\175\265\377\072\175\265\377\072\175\265\377\072\175\265\377" +
"\072\175\265\377\115\211\274\377\277\324\347\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" +
"\377\377\377\377\377\377\377\377\354\354\354\377\223\223\223\377\233\233\233\377\375\375\375\377\377\377\377\377\377\377\377\377" +
"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" +
"\377\377\377\377\377\377\377\377\363\367\372\377\265\316\343\377\201\254\320\377\145\231\305\377\141\227\304\377\154\236\310\377" +
"\217\265\325\377\305\331\351\377\367\372\374\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" +
"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377";
/** LWJGL Logo - 16 by 16 pixels */
public static final ByteBuffer LWJGLIcon16x16 = loadIcon(LWJGL_ICON_DATA_16x16);
/** LWJGL Logo - 32 by 32 pixels */
public static final ByteBuffer LWJGLIcon32x32 = loadIcon(LWJGL_ICON_DATA_32x32);
/** Debug flag. */
public static final boolean DEBUG = getPrivilegedBoolean("org.lwjgl.util.Debug");
public static final boolean CHECKS = !getPrivilegedBoolean("org.lwjgl.util.NoChecks");
private static final int PLATFORM;
static {
final String osName = getPrivilegedProperty("os.name");
if ( osName.startsWith("Windows") )
PLATFORM = PLATFORM_WINDOWS;
else if ( osName.startsWith("Linux") || osName.startsWith("FreeBSD") || osName.startsWith("OpenBSD") || osName.startsWith("SunOS") || osName.startsWith("Unix") )
PLATFORM = PLATFORM_LINUX;
else if ( osName.startsWith("Mac OS X") || osName.startsWith("Darwin") )
PLATFORM = PLATFORM_MACOSX;
else
throw new LinkageError("Unknown platform: " + osName);
}
private static ByteBuffer loadIcon(String data) {
int len = data.length();
ByteBuffer bb = BufferUtils.createByteBuffer(len);
for(int i=0 ; i<len ; i++) {
bb.put(i, (byte)data.charAt(i));
}
return bb.asReadOnlyBuffer();
}
/**
* @see #PLATFORM_WINDOWS
* @see #PLATFORM_LINUX
* @see #PLATFORM_MACOSX
* @return the current platform type
*/
public static int getPlatform() {
return PLATFORM;
}
/**
* @see #PLATFORM_WINDOWS_NAME
* @see #PLATFORM_LINUX_NAME
* @see #PLATFORM_MACOSX_NAME
* @return current platform name
*/
public static String getPlatformName() {
switch (LWJGLUtil.getPlatform()) {
case LWJGLUtil.PLATFORM_LINUX:
return PLATFORM_LINUX_NAME;
case LWJGLUtil.PLATFORM_MACOSX:
return PLATFORM_MACOSX_NAME;
case LWJGLUtil.PLATFORM_WINDOWS:
return PLATFORM_WINDOWS_NAME;
default:
return "unknown";
}
}
/**
* Wraps {@link System#mapLibraryName}. On OS X with JDK 6, the .jnilib file
* extension will be replaced with .dylib.
*
* @param name the name of the library.
*
* @return a platform-dependent native library name.
*/
public static String mapLibraryName(String name) {
String libName = System.mapLibraryName(name);
return LWJGLUtil.getPlatform() == LWJGLUtil.PLATFORM_MACOSX && libName.endsWith(".jnilib")
? libName.substring(0, libName.length() - ".jnilib".length()) + ".dylib"
: libName;
}
/**
* Locates the paths required by a library.
*
* @param libname Local Library Name to search the classloader with ("openal").
* @param platform_lib_name The native library name ("libopenal.so")
* @param classloader The classloader to ask for library paths
* @return Paths to located libraries, if any
*/
public static String[] getLibraryPaths(String libname, String platform_lib_name, ClassLoader classloader) {
return getLibraryPaths(libname, new String[]{platform_lib_name}, classloader);
}
/**
* Locates the paths required by a library.
*
* @param libname Local Library Name to search the classloader with ("openal").
* @param platform_lib_names The list of possible library names ("libopenal.so")
* @param classloader The classloader to ask for library paths
* @return Paths to located libraries, if any
*/
public static String[] getLibraryPaths(String libname, String[] platform_lib_names, ClassLoader classloader) {
// need to pass path of possible locations of library to native side
List<String> possible_paths = new ArrayList<String>();
String classloader_path = getPathFromClassLoader(libname, classloader);
if (classloader_path != null) {
log("getPathFromClassLoader: Path found: " + classloader_path);
possible_paths.add(classloader_path);
}
for ( String platform_lib_name : platform_lib_names ) {
String lwjgl_classloader_path = getPathFromClassLoader("lwjgl", classloader);
if ( lwjgl_classloader_path != null ) {
log("getPathFromClassLoader: Path found: " + lwjgl_classloader_path);
possible_paths.add(lwjgl_classloader_path.substring(0, lwjgl_classloader_path.lastIndexOf(File.separator))
+ File.separator + platform_lib_name);
}
// add Installer path
String alternative_path = getPrivilegedProperty("org.lwjgl.librarypath");
if ( alternative_path != null ) {
possible_paths.add(alternative_path + File.separator + platform_lib_name);
}
// Add all possible paths from java.library.path
String java_library_path = getPrivilegedProperty("java.library.path");
StringTokenizer st = new StringTokenizer(java_library_path, File.pathSeparator);
while ( st.hasMoreTokens() ) {
String path = st.nextToken();
possible_paths.add(path + File.separator + platform_lib_name);
}
//add current path
String current_dir = getPrivilegedProperty("user.dir");
possible_paths.add(current_dir + File.separator + platform_lib_name);
//add pure library (no path, let OS search)
possible_paths.add(platform_lib_name);
}
//create needed string array
return possible_paths.toArray(new String[possible_paths.size()]);
}
static void execPrivileged(final String[] cmd_array) throws Exception {
try {
Process process = AccessController.doPrivileged(new PrivilegedExceptionAction<Process>() {
public Process run() throws Exception {
return Runtime.getRuntime().exec(cmd_array);
}
});
// Close unused streams to make sure the child process won't hang
process.getInputStream().close();
process.getOutputStream().close();
process.getErrorStream().close();
} catch (PrivilegedActionException e) {
throw (Exception)e.getCause();
}
}
private static String getPrivilegedProperty(final String property_name) {
return AccessController.doPrivileged(new PrivilegedAction<String>() {
public String run() {
return System.getProperty(property_name);
}
});
}
/**
* Tries to locate named library from the current ClassLoader
* This method exists because native libraries are loaded from native code, and as such
* is exempt from ClassLoader library loading rutines. It therefore always fails.
* We therefore invoke the protected method of the ClassLoader to see if it can
* locate it.
*
* @param libname Name of library to search for
* @param classloader Classloader to use
* @return Absolute path to library if found, otherwise null
*/
private static String getPathFromClassLoader(final String libname, final ClassLoader classloader) {
Class<?> c = null;
try {
log("getPathFromClassLoader: searching for: " + libname);
c = classloader.getClass();
while (c != null) {
final Class<?> clazz = c;
try {
return AccessController.doPrivileged(new PrivilegedExceptionAction<String>() {
public String run() throws Exception {
Method findLibrary = clazz.getDeclaredMethod("findLibrary", String.class);
findLibrary.setAccessible(true);
String path = (String)findLibrary.invoke(classloader, libname);
return path;
}
});
} catch (PrivilegedActionException e) {
log("Failed to locate findLibrary method: " + e.getCause());
c = c.getSuperclass();
}
}
} catch (Exception e) {
log("Failure locating " + e + " using classloader:" + c);
}
return null;
}
/**
* Gets a boolean property as a privileged action.
*/
public static boolean getPrivilegedBoolean(final String property_name) {
return AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
public Boolean run() {
return Boolean.getBoolean(property_name);
}
});
}
/**
* Gets an integer property as a privileged action.
*
* @param property_name the integer property name
*
* @return the property value
*/
public static Integer getPrivilegedInteger(final String property_name) {
return AccessController.doPrivileged(new PrivilegedAction<Integer>() {
public Integer run() {
return Integer.getInteger(property_name);
}
});
}
/**
* Gets an integer property as a privileged action.
*
* @param property_name the integer property name
* @param default_val the default value to use if the property is not defined
*
* @return the property value
*/
public static Integer getPrivilegedInteger(final String property_name, final int default_val) {
return AccessController.doPrivileged(new PrivilegedAction<Integer>() {
public Integer run() {
return Integer.getInteger(property_name, default_val);
}
});
}
/**
* @param msg Message to print
*/
public static void log(CharSequence msg) {
if (DEBUG) {
System.err.println("[LWJGL] " + msg);
}
}
/**
* Method to determine if the current system is running a version of
* Mac OS X better than the given version. This is only useful for Mac OS X
* specific code and will not work for any other platform.
*/
public static boolean isMacOSXEqualsOrBetterThan(int major_required, int minor_required) {
String os_version = getPrivilegedProperty("os.version");
StringTokenizer version_tokenizer = new StringTokenizer(os_version, ".");
int major;
int minor;
try {
String major_str = version_tokenizer.nextToken();
String minor_str = version_tokenizer.nextToken();
major = Integer.parseInt(major_str);
minor = Integer.parseInt(minor_str);
} catch (Exception e) {
LWJGLUtil.log("Exception occurred while trying to determine OS version: " + e);
// Best guess, no
return false;
}
return major > major_required || (major == major_required && minor >= minor_required);
}
/**
* Returns a map of public static final integer fields in the specified classes, to their String representations.
* An optional filter can be specified to only include specific fields. The target map may be null, in which
* case a new map is allocated and returned.
* <p>
* This method is useful when debugging to quickly identify values returned from the AL/GL/CL APIs.
*
* @param filter the filter to use (optional)
* @param target the target map (optional)
* @param tokenClasses an array of classes to get tokens from
*
* @return the token map
*/
public static Map<Integer, String> getClassTokens(final TokenFilter filter, final Map<Integer, String> target, final Class ... tokenClasses) {
return getClassTokens(filter, target, Arrays.asList(tokenClasses));
}
/**
* Returns a map of public static final integer fields in the specified classes, to their String representations.
* An optional filter can be specified to only include specific fields. The target map may be null, in which
* case a new map is allocated and returned.
* <p>
* This method is useful when debugging to quickly identify values returned from the AL/GL/CL APIs.
*
* @param filter the filter to use (optional)
* @param target the target map (optional)
* @param tokenClasses the classes to get tokens from
*
* @return the token map
*/
public static Map<Integer, String> getClassTokens(final TokenFilter filter, Map<Integer, String> target, final Iterable<Class> tokenClasses) {
if ( target == null )
target = new HashMap<Integer, String>();
final int TOKEN_MODIFIERS = Modifier.PUBLIC | Modifier.STATIC | Modifier.FINAL;
for ( final Class tokenClass : tokenClasses ) {
for ( final Field field : tokenClass.getDeclaredFields() ) {
// Get only <public static final int> fields.
if ( (field.getModifiers() & TOKEN_MODIFIERS) == TOKEN_MODIFIERS && field.getType() == int.class ) {
try {
final int value = field.getInt(null);
if ( filter != null && !filter.accept(field, value) )
continue;
if ( target.containsKey(value) ) // Print colliding tokens in their hex representation.
target.put(value, toHexString(value));
else
target.put(value, field.getName());
} catch (IllegalAccessException e) {
// Ignore
}
}
}
}
return target;
}
/**
* Returns a string representation of the integer argument as an
* unsigned integer in base&nbsp;16. The string will be uppercase
* and will have a leading '0x'.
*
* @param value the integer value
*
* @return the hex string representation
*/
public static String toHexString(final int value) {
return "0x" + Integer.toHexString(value).toUpperCase();
}
/** Simple interface for Field filtering. */
public interface TokenFilter {
/**
* Should return true if the specified Field passes the filter.
*
* @param field the Field to test
* @param value the integer value of the field
*
* @return true if the Field is accepted
*/
boolean accept(Field field, int value);
}
}

View File

@ -1,441 +0,0 @@
/*
* Copyright (c) 2002-2011 LWJGL Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of 'LWJGL' nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.lwjgl;
import java.lang.reflect.Field;
import java.nio.Buffer;
import java.nio.ByteBuffer;
import java.nio.CharBuffer;
import java.nio.DoubleBuffer;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;
import java.nio.LongBuffer;
import java.nio.ShortBuffer;
import java.nio.charset.CharacterCodingException;
import java.nio.charset.Charset;
import java.nio.charset.CharsetDecoder;
import java.nio.charset.CharsetEncoder;
import java.nio.charset.CoderResult;
/**
* [INTERNAL USE ONLY]
* <p/>
* This class provides utility methods for passing buffers to JNI API calls.
*
* @author Spasi
*/
public final class MemoryUtil {
private static final Charset ascii;
private static final Charset utf8;
private static final Charset utf16;
static {
ascii = Charset.forName("ISO-8859-1");
utf8 = Charset.forName("UTF-8");
utf16 = Charset.forName("UTF-16LE");
}
private static final Accessor memUtil;
static {
Accessor util;
try {
// Depends on java.nio.Buffer#address and sun.misc.Unsafe
util = loadAccessor("org.lwjgl.MemoryUtilSun$AccessorUnsafe");
} catch (Exception e0) {
try {
// Depends on java.nio.Buffer#address and sun.reflect.FieldAccessor
util = loadAccessor("org.lwjgl.MemoryUtilSun$AccessorReflectFast");
} catch (Exception e1) {
try {
// Depends on java.nio.Buffer#address
util = new AccessorReflect();
} catch (Exception e2) {
LWJGLUtil.log("Unsupported JVM detected, this will likely result in low performance. Please inform LWJGL developers.");
util = new AccessorJNI();
}
}
}
LWJGLUtil.log("MemoryUtil Accessor: " + util.getClass().getSimpleName());
memUtil = util;
/*
BENCHMARK RESULTS - Oracle Server VM:
Unsafe: 4ns
ReflectFast: 8ns
Reflect: 10ns
JNI: 82ns
BENCHMARK RESULTS - Oracle Client VM:
Unsafe: 5ns
ReflectFast: 81ns
Reflect: 85ns
JNI: 87ns
On non-Oracle VMs, Unsafe should be the fastest implementation as well. In the absence
of Unsafe, performance will depend on how reflection and JNI are implemented. For now
we'll go with what we see on the Oracle VM (that is, we'll prefer reflection over JNI).
*/
}
private MemoryUtil() {
}
/**
* Returns the memory address of the specified buffer. [INTERNAL USE ONLY]
*
* @param buffer the buffer
*
* @return the memory address
*/
public static long getAddress0(Buffer buffer) { return memUtil.getAddress(buffer); }
public static long getAddress0Safe(Buffer buffer) { return buffer == null ? 0L : memUtil.getAddress(buffer); }
public static long getAddress0(PointerBuffer buffer) { return memUtil.getAddress(buffer.getBuffer()); }
public static long getAddress0Safe(PointerBuffer buffer) { return buffer == null ? 0L : memUtil.getAddress(buffer.getBuffer()); }
// --- [ API utilities ] ---
public static long getAddress(ByteBuffer buffer) { return getAddress(buffer, buffer.position()); }
public static long getAddress(ByteBuffer buffer, int position) { return getAddress0(buffer) + position; }
public static long getAddress(ShortBuffer buffer) { return getAddress(buffer, buffer.position()); }
public static long getAddress(ShortBuffer buffer, int position) { return getAddress0(buffer) + (position << 1); }
public static long getAddress(CharBuffer buffer) { return getAddress(buffer, buffer.position()); }
public static long getAddress(CharBuffer buffer, int position) { return getAddress0(buffer) + (position << 1); }
public static long getAddress(IntBuffer buffer) { return getAddress(buffer, buffer.position()); }
public static long getAddress(IntBuffer buffer, int position) { return getAddress0(buffer) + (position << 2); }
public static long getAddress(FloatBuffer buffer) { return getAddress(buffer, buffer.position()); }
public static long getAddress(FloatBuffer buffer, int position) { return getAddress0(buffer) + (position << 2); }
public static long getAddress(LongBuffer buffer) { return getAddress(buffer, buffer.position()); }
public static long getAddress(LongBuffer buffer, int position) { return getAddress0(buffer) + (position << 3); }
public static long getAddress(DoubleBuffer buffer) { return getAddress(buffer, buffer.position()); }
public static long getAddress(DoubleBuffer buffer, int position) { return getAddress0(buffer) + (position << 3); }
public static long getAddress(PointerBuffer buffer) { return getAddress(buffer, buffer.position()); }
public static long getAddress(PointerBuffer buffer, int position) { return getAddress0(buffer) + (position * PointerBuffer.getPointerSize()); }
// --- [ API utilities - Safe ] ---
public static long getAddressSafe(ByteBuffer buffer) { return buffer == null ? 0L : getAddress(buffer); }
public static long getAddressSafe(ByteBuffer buffer, int position) { return buffer == null ? 0L : getAddress(buffer, position); }
public static long getAddressSafe(ShortBuffer buffer) { return buffer == null ? 0L : getAddress(buffer); }
public static long getAddressSafe(ShortBuffer buffer, int position) { return buffer == null ? 0L : getAddress(buffer, position); }
public static long getAddressSafe(CharBuffer buffer) { return buffer == null ? 0L : getAddress(buffer); }
public static long getAddressSafe(CharBuffer buffer, int position) { return buffer == null ? 0L : getAddress(buffer, position); }
public static long getAddressSafe(IntBuffer buffer) { return buffer == null ? 0L : getAddress(buffer); }
public static long getAddressSafe(IntBuffer buffer, int position) { return buffer == null ? 0L : getAddress(buffer, position); }
public static long getAddressSafe(FloatBuffer buffer) { return buffer == null ? 0L : getAddress(buffer); }
public static long getAddressSafe(FloatBuffer buffer, int position) { return buffer == null ? 0L : getAddress(buffer, position); }
public static long getAddressSafe(LongBuffer buffer) { return buffer == null ? 0L : getAddress(buffer); }
public static long getAddressSafe(LongBuffer buffer, int position) { return buffer == null ? 0L : getAddress(buffer, position); }
public static long getAddressSafe(DoubleBuffer buffer) { return buffer == null ? 0L : getAddress(buffer); }
public static long getAddressSafe(DoubleBuffer buffer, int position) { return buffer == null ? 0L : getAddress(buffer, position); }
public static long getAddressSafe(PointerBuffer buffer) { return buffer == null ? 0L : getAddress(buffer); }
public static long getAddressSafe(PointerBuffer buffer, int position) { return buffer == null ? 0L : getAddress(buffer, position); }
// --- [ String utilities ] ---
/**
* Returns a ByteBuffer containing the specified text ASCII encoded and null-terminated.
* If text is null, null is returned.
*
* @param text the text to encode
*
* @return the encoded text or null
*
* @see String#getBytes()
*/
public static ByteBuffer encodeASCII(final CharSequence text) {
return encode(text, ascii);
}
/**
* Returns a ByteBuffer containing the specified text UTF-8 encoded and null-terminated.
* If text is null, null is returned.
*
* @param text the text to encode
*
* @return the encoded text or null
*
* @see String#getBytes()
*/
public static ByteBuffer encodeUTF8(final CharSequence text) {
return encode(text, utf8);
}
/**
* Returns a ByteBuffer containing the specified text UTF-16LE encoded and null-terminated.
* If text is null, null is returned.
*
* @param text the text to encode
*
* @return the encoded text
*/
public static ByteBuffer encodeUTF16(final CharSequence text) {
return encode(text, utf16);
}
/**
* Wraps the specified text in a null-terminated CharBuffer and encodes it using the specified Charset.
*
* @param text the text to encode
* @param charset the charset to use for encoding
*
* @return the encoded text
*/
private static ByteBuffer encode(final CharSequence text, final Charset charset) {
if ( text == null )
return null;
return encode(CharBuffer.wrap(new CharSequenceNT(text)), charset);
}
/**
* A {@link CharsetEncoder#encode(CharBuffer)} implementation that uses {@link BufferUtils#createByteBuffer(int)}
* instead of {@link ByteBuffer#allocate(int)}.
*
* @see CharsetEncoder#encode(CharBuffer)
*/
private static ByteBuffer encode(final CharBuffer in, final Charset charset) {
final CharsetEncoder encoder = charset.newEncoder(); // encoders are not thread-safe, create a new one on every call
int n = (int)(in.remaining() * encoder.averageBytesPerChar());
ByteBuffer out = BufferUtils.createByteBuffer(n);
if ( n == 0 && in.remaining() == 0 )
return out;
encoder.reset();
while ( true ) {
CoderResult cr = in.hasRemaining() ? encoder.encode(in, out, true) : CoderResult.UNDERFLOW;
if ( cr.isUnderflow() )
cr = encoder.flush(out);
if ( cr.isUnderflow() )
break;
if ( cr.isOverflow() ) {
n = 2 * n + 1; // Ensure progress; n might be 0!
ByteBuffer o = BufferUtils.createByteBuffer(n);
out.flip();
o.put(out);
out = o;
continue;
}
try {
cr.throwException();
} catch (CharacterCodingException e) {
throw new RuntimeException(e);
}
}
out.flip();
return out;
}
public static String decodeASCII(final ByteBuffer buffer) {
return decode(buffer, ascii);
}
public static String decodeUTF8(final ByteBuffer buffer) {
return decode(buffer, utf8);
}
public static String decodeUTF16(final ByteBuffer buffer) {
return decode(buffer, utf16);
}
private static String decode(final ByteBuffer buffer, final Charset charset) {
if ( buffer == null )
return null;
return decodeImpl(buffer, charset);
}
private static String decodeImpl(final ByteBuffer in, final Charset charset) {
final CharsetDecoder decoder = charset.newDecoder(); // decoders are not thread-safe, create a new one on every call
int n = (int)(in.remaining() * decoder.averageCharsPerByte());
CharBuffer out = BufferUtils.createCharBuffer(n);
if ( (n == 0) && (in.remaining() == 0) )
return "";
decoder.reset();
for (; ; ) {
CoderResult cr = in.hasRemaining() ? decoder.decode(in, out, true) : CoderResult.UNDERFLOW;
if ( cr.isUnderflow() )
cr = decoder.flush(out);
if ( cr.isUnderflow() )
break;
if ( cr.isOverflow() ) {
n = 2 * n + 1; // Ensure progress; n might be 0!
CharBuffer o = BufferUtils.createCharBuffer(n);
out.flip();
o.put(out);
out = o;
continue;
}
try {
cr.throwException();
} catch (CharacterCodingException e) {
throw new RuntimeException(e);
}
}
out.flip();
return out.toString();
}
/** A null-terminated CharSequence. */
private static class CharSequenceNT implements CharSequence {
final CharSequence source;
CharSequenceNT(CharSequence source) {
this.source = source;
}
public int length() {
return source.length() + 1;
}
public char charAt(final int index) {
return index == source.length() ? '\0' : source.charAt(index);
}
public CharSequence subSequence(final int start, final int end) {
return new CharSequenceNT(source.subSequence(start, Math.min(end, source.length())));
}
}
interface Accessor {
long getAddress(Buffer buffer);
}
private static Accessor loadAccessor(final String className) throws Exception {
return (Accessor)Class.forName(className).newInstance();
}
/** Default implementation. */
private static class AccessorJNI implements Accessor {
public long getAddress(final Buffer buffer) {
return BufferUtils.getBufferAddress(buffer);
}
}
/** Implementation using reflection on ByteBuffer. */
private static class AccessorReflect implements Accessor {
private final Field address;
AccessorReflect() {
try {
address = getAddressField();
} catch (NoSuchFieldException e) {
throw new UnsupportedOperationException(e);
}
address.setAccessible(true);
}
public long getAddress(final Buffer buffer) {
try {
return address.getLong(buffer);
} catch (IllegalAccessException e) {
// cannot happen
return 0L;
}
}
}
static Field getAddressField() throws NoSuchFieldException {
return getDeclaredFieldRecursive(ByteBuffer.class, "address");
}
private static Field getDeclaredFieldRecursive(final Class<?> root, final String fieldName) throws NoSuchFieldException {
Class<?> type = root;
do {
try {
return type.getDeclaredField(fieldName);
} catch (NoSuchFieldException e) {
type = type.getSuperclass();
}
} while ( type != null );
throw new NoSuchFieldException(fieldName + " does not exist in " + root.getSimpleName() + " or any of its superclasses.");
}
}

View File

@ -1,804 +0,0 @@
/*
* Copyright LWJGL. All rights reserved.
* License terms: https://www.lwjgl.org/license
*/
package org.lwjgl;
import org.lwjgl.system.*;
import javax.annotation.*;
import java.nio.*;
import static org.lwjgl.system.CheckIntrinsics.*;
import static org.lwjgl.system.Checks.*;
import static org.lwjgl.system.MemoryUtil.*;
/** This class is a container for architecture-independent pointer data. Its interface mirrors the {@link LongBuffer} API for convenience. */
public class PointerBuffer extends CustomBuffer<PointerBuffer> implements Comparable<PointerBuffer> {
public PointerBuffer(final int capacity) {
this(allocateDirect(capacity));
}
public PointerBuffer(final ByteBuffer source) {
this(create(source));
}
protected PointerBuffer(PointerBuffer copy) {
this(copy.address0(), copy.container, copy.mark, copy.position, copy.limit, copy.capacity);
}
/**
* Returns the ByteBuffer that backs this PointerBuffer.
*
* @return the pointer ByteBuffer
*/
public ByteBuffer getBuffer() {
return container;
}
/** Returns true if the underlying architecture is 64bit. */
public static boolean is64Bit() {
return POINTER_SIZE == 8;
}
/**
* Returns the pointer size in bytes, based on the underlying architecture.
*
* @return The pointer size in bytes
*/
public static int getPointerSize() {
return POINTER_SIZE;
}
/**
* Returns this buffer's position, in bytes. </p>
*
* @return The position of this buffer in bytes.
*/
public final int positionByte() {
return position() * getPointerSize();
}
/**
* Returns the number of bytes between the current position and the
* limit. </p>
*
* @return The number of bytes remaining in this buffer
*/
public final int remainingByte() {
return remaining() * getPointerSize();
}
/**
* Creates a new, read-only pointer buffer that shares this buffer's
* content.
* <p/>
* <p> The content of the new buffer will be that of this buffer. Changes
* to this buffer's content will be visible in the new buffer; the new
* buffer itself, however, will be read-only and will not allow the shared
* content to be modified. The two buffers' position, limit, and mark
* values will be independent.
* <p/>
* <p> The new buffer's capacity, limit and position will be
* identical to those of this buffer.
* <p/>
* <p> If this buffer is itself read-only then this method behaves in
* exactly the same way as the {@link #duplicate duplicate} method. </p>
*
* @return The new, read-only pointer buffer
*/
public PointerBuffer asReadOnlyBuffer() {
final PointerBuffer buffer = new PointerBufferR(container);
buffer.position(position());
buffer.limit(limit());
return buffer;
}
public boolean isReadOnly() {
return false;
}
/**
* Read-only version of PointerBuffer.
*
* @author Spasi
*/
private static final class PointerBufferR extends PointerBuffer {
PointerBufferR(final ByteBuffer source) {
super(source);
}
public boolean isReadOnly() {
return true;
}
protected PointerBuffer newInstance(final ByteBuffer source) {
return new PointerBufferR(source);
}
public PointerBuffer asReadOnlyBuffer() {
return duplicate();
}
public PointerBuffer put(final long l) {
throw new ReadOnlyBufferException();
}
public PointerBuffer put(final int index, final long l) {
throw new ReadOnlyBufferException();
}
public PointerBuffer put(final PointerBuffer src) {
throw new ReadOnlyBufferException();
}
public PointerBuffer put(final long[] src, final int offset, final int length) {
throw new ReadOnlyBufferException();
}
public PointerBuffer compact() {
throw new ReadOnlyBufferException();
}
}
protected PointerBuffer(long address, @Nullable ByteBuffer container, int mark, int position, int limit, int capacity) {
super(address, container, mark, position, limit, capacity);
}
/**
* Allocates a new pointer buffer.
*
* <p>The new buffer's position will be zero, its limit will be its capacity, and its mark will be undefined.</p>
*
* @param capacity the new buffer's capacity, in pointers
*
* @return the new pointer buffer
*
* @throws IllegalArgumentException If the {@code capacity} is a negative integer
*/
public static PointerBuffer allocateDirect(int capacity) {
ByteBuffer source = BufferUtils.createByteBuffer(BufferUtils.getAllocationSize(capacity, POINTER_SHIFT));
return new PointerBuffer(memAddress(source), source, -1, 0, capacity, capacity);
}
/**
* Creates a new PointerBuffer that starts at the specified memory address and has the specified capacity.
*
* @param address the starting memory address
* @param capacity the buffer capacity, in number of pointers
*/
public static PointerBuffer create(long address, int capacity) {
return new PointerBuffer(address, null, -1, 0, capacity, capacity);
}
/**
* Creates a new PointerBuffer using the specified ByteBuffer as its pointer data source.
*
* @param source the source buffer
*/
public static PointerBuffer create(ByteBuffer source) {
int capacity = source.remaining() >> POINTER_SHIFT;
return new PointerBuffer(memAddress(source), source, -1, 0, capacity, capacity);
}
@Override
protected PointerBuffer self() {
return this;
}
@Override
public int sizeof() {
return POINTER_SIZE;
}
/**
* Relative <i>get</i> method. Reads the pointer at this buffer's current position, and then increments the position.
*
* @return the pointer at the buffer's current position
*
* @throws BufferUnderflowException If the buffer's current position is not smaller than its limit
*/
public long get() {
return memGetAddress(address + Integer.toUnsignedLong(nextGetIndex()) * POINTER_SIZE);
}
/**
* Convenience relative get from a source ByteBuffer.
*
* @param source the source ByteBuffer
*/
public static long get(ByteBuffer source) {
if (source.remaining() < POINTER_SIZE) {
throw new BufferUnderflowException();
}
try {
return memGetAddress(memAddress(source));
} finally {
source.position(source.position() + POINTER_SIZE);
}
}
/**
* Relative <i>put</i> method&nbsp;&nbsp;<i>(optional operation)</i>.
*
* <p>Writes the specified pointer into this buffer at the current position, and then increments the position.</p>
*
* @param p the pointer to be written
*
* @return This buffer
*
* @throws BufferOverflowException If this buffer's current position is not smaller than its limit
*/
public PointerBuffer put(long p) {
memPutAddress(address + Integer.toUnsignedLong(nextPutIndex()) * POINTER_SIZE, p);
return this;
}
/**
* Convenience relative put on a target ByteBuffer.
*
* @param target the target ByteBuffer
* @param p the pointer value to be written
*/
public static void put(ByteBuffer target, long p) {
if (target.remaining() < POINTER_SIZE) {
throw new BufferOverflowException();
}
try {
memPutAddress(memAddress(target), p);
} finally {
target.position(target.position() + POINTER_SIZE);
}
}
/**
* Absolute <i>get</i> method. Reads the pointer at the specified {@code index}.
*
* @param index the index from which the pointer will be read
*
* @return the pointer at the specified {@code index}
*
* @throws IndexOutOfBoundsException If {@code index} is negative or not smaller than the buffer's limit
*/
public long get(int index) {
return memGetAddress(address + check(index, limit) * POINTER_SIZE);
}
/**
* Convenience absolute get from a source ByteBuffer.
*
* @param source the source ByteBuffer
* @param index the index at which the pointer will be read
*/
public static long get(ByteBuffer source, int index) {
checkFromIndexSize(index, POINTER_SIZE, source.limit());
return memGetAddress(memAddress0(source) + index);
}
/**
* Absolute <i>put</i> method&nbsp;&nbsp;<i>(optional operation)</i>.
*
* <p>Writes the specified pointer into this buffer at the specified {@code index}.</p>
*
* @param index the index at which the pointer will be written
* @param p the pointer value to be written
*
* @return This buffer
*
* @throws IndexOutOfBoundsException If {@code index} is negative or not smaller than the buffer's limit
*/
public PointerBuffer put(int index, long p) {
memPutAddress(address + check(index, limit) * POINTER_SIZE, p);
return this;
}
/**
* Convenience absolute put on a target ByteBuffer.
*
* @param target the target ByteBuffer
* @param index the index at which the pointer will be written
* @param p the pointer value to be written
*/
public static void put(ByteBuffer target, int index, long p) {
checkFromIndexSize(index, POINTER_SIZE, target.limit());
memPutAddress(memAddress0(target) + index, p);
}
// -- PointerWrapper operations --
/** Puts the pointer value of the specified {@link Pointer} at the current position and then increments the position. */
public PointerBuffer put(Pointer pointer) {
put(pointer.address());
return this;
}
/** Puts the pointer value of the specified {@link Pointer} at the specified {@code index}. */
public PointerBuffer put(int index, Pointer pointer) {
put(index, pointer.address());
return this;
}
// -- Buffer address operations --
/**
* <p>Writes the address of the specified {@code buffer} into this buffer at the current position, and then increments the position.</p>
*
* @param buffer the pointer to be written
*
* @return this buffer
*
* @throws BufferOverflowException If this buffer's current position is not smaller than its limit
*/
public PointerBuffer put(ByteBuffer buffer) {
put(memAddress(buffer));
return this;
}
/**
* <p>Writes the address of the specified {@code buffer} into this buffer at the current position, and then increments the position.</p>
*
* @param buffer the pointer to be written
*
* @return this buffer
*
* @throws BufferOverflowException If this buffer's current position is not smaller than its limit
*/
public PointerBuffer put(ShortBuffer buffer) {
put(memAddress(buffer));
return this;
}
/**
* <p>Writes the address of the specified {@code buffer} into this buffer at the current position, and then increments the position.</p>
*
* @param buffer the pointer to be written
*
* @return this buffer
*
* @throws BufferOverflowException If this buffer's current position is not smaller than its limit
*/
public PointerBuffer put(IntBuffer buffer) {
put(memAddress(buffer));
return this;
}
/**
* <p>Writes the address of the specified {@code buffer} into this buffer at the current position, and then increments the position.</p>
*
* @param buffer the pointer to be written
*
* @return this buffer
*
* @throws BufferOverflowException If this buffer's current position is not smaller than its limit
*/
public PointerBuffer put(LongBuffer buffer) {
put(memAddress(buffer));
return this;
}
/**
* <p>Writes the address of the specified {@code buffer} into this buffer at the current position, and then increments the position.</p>
*
* @param buffer the pointer to be written
*
* @return this buffer
*
* @throws BufferOverflowException If this buffer's current position is not smaller than its limit
*/
public PointerBuffer put(FloatBuffer buffer) {
put(memAddress(buffer));
return this;
}
/**
* <p>Writes the address of the specified {@code buffer} into this buffer at the current position, and then increments the position.</p>
*
* @param buffer the pointer to be written
*
* @return this buffer
*
* @throws BufferOverflowException If this buffer's current position is not smaller than its limit
*/
public PointerBuffer put(DoubleBuffer buffer) {
put(memAddress(buffer));
return this;
}
/**
* <p>Writes the address of the specified {@code buffer} into this buffer at the current position, and then increments the position.</p>
*
* @param buffer the pointer to be written
*
* @return this buffer
*
* @throws BufferOverflowException If this buffer's current position is not smaller than its limit
*/
public PointerBuffer putAddressOf(CustomBuffer<?> buffer) {
put(memAddress(buffer));
return this;
}
// ---
/** Puts the address of the specified {@code buffer} at the specified {@code index}. */
public PointerBuffer put(int index, ByteBuffer buffer) {
put(index, memAddress(buffer));
return this;
}
/** Puts the address of the specified {@code buffer} at the specified {@code index}. */
public PointerBuffer put(int index, ShortBuffer buffer) {
put(index, memAddress(buffer));
return this;
}
/** Puts the address of the specified {@code buffer} at the specified {@code index}. */
public PointerBuffer put(int index, IntBuffer buffer) {
put(index, memAddress(buffer));
return this;
}
/** Puts the address of the specified {@code buffer} at the specified {@code index}. */
public PointerBuffer put(int index, LongBuffer buffer) {
put(index, memAddress(buffer));
return this;
}
/** Puts the address of the specified {@code buffer} at the specified {@code index}. */
public PointerBuffer put(int index, FloatBuffer buffer) {
put(index, memAddress(buffer));
return this;
}
/** Puts the address of the specified {@code buffer} at the specified {@code index}. */
public PointerBuffer put(int index, DoubleBuffer buffer) {
put(index, memAddress(buffer));
return this;
}
/** Puts the address of the specified {@code buffer} at the specified {@code index}. */
public PointerBuffer putAddressOf(int index, CustomBuffer<?> buffer) {
put(index, memAddress(buffer));
return this;
}
// ---
/**
* Reads the pointer at this buffer's current position, and then increments the position. The pointer is returned as a {@link ByteBuffer} instance that
* starts at the pointer address and has capacity equal to the specified {@code size}.
*
* @throws BufferUnderflowException If the buffer's current position is not smaller than its limit
*/
public ByteBuffer getByteBuffer(int size) { return memByteBuffer(get(), size); }
/**
* Reads the pointer at this buffer's current position, and then increments the position. The pointer is returned as a {@link ShortBuffer} instance that
* starts at the pointer address and has capacity equal to the specified {@code size}.
*
* @throws BufferUnderflowException If the buffer's current position is not smaller than its limit
*/
public ShortBuffer getShortBuffer(int size) { return memShortBuffer(get(), size); }
/**
* Reads the pointer at this buffer's current position, and then increments the position. The pointer is returned as a {@link IntBuffer} instance that
* starts at the pointer address and has capacity equal to the specified {@code size}.
*
* @throws BufferUnderflowException If the buffer's current position is not smaller than its limit
*/
public IntBuffer getIntBuffer(int size) { return memIntBuffer(get(), size); }
/**
* Reads the pointer at this buffer's current position, and then increments the position. The pointer is returned as a {@link LongBuffer} instance that
* starts at the pointer address and has capacity equal to the specified {@code size}.
*
* @throws BufferUnderflowException If the buffer's current position is not smaller than its limit
*/
public LongBuffer getLongBuffer(int size) { return memLongBuffer(get(), size); }
/**
* Reads the pointer at this buffer's current position, and then increments the position. The pointer is returned as a {@link FloatBuffer} instance that
* starts at the pointer address and has capacity equal to the specified {@code size}.
*
* @throws BufferUnderflowException If the buffer's current position is not smaller than its limit
*/
public FloatBuffer getFloatBuffer(int size) { return memFloatBuffer(get(), size); }
/**
* Reads the pointer at this buffer's current position, and then increments the position. The pointer is returned as a {@link DoubleBuffer} instance that
* starts at the pointer address and has capacity equal to the specified {@code size}.
*
* @throws BufferUnderflowException If the buffer's current position is not smaller than its limit
*/
public DoubleBuffer getDoubleBuffer(int size) { return memDoubleBuffer(get(), size); }
/**
* Reads the pointer at this buffer's current position, and then increments the position. The pointer is returned as a {@code PointerBuffer} instance that
* starts at the pointer address and has capacity equal to the specified {@code size}.
*
* @throws BufferUnderflowException If the buffer's current position is not smaller than its limit
*/
public PointerBuffer getPointerBuffer(int size) { return memPointerBuffer(get(), size); }
/**
* Reads the pointer at this buffer's current position, and then increments the position. The pointer is evaluated as a null-terminated ASCII string, which
* is decoded and returned as a {@link String} instance.
*
* @throws BufferUnderflowException If the buffer's current position is not smaller than its limit
*/
public String getStringASCII() { return memASCII(get()); }
/**
* Reads the pointer at this buffer's current position, and then increments the position. The pointer is evaluated as a null-terminated UTF-8 string, which
* is decoded and returned as a {@link String} instance.
*
* @throws BufferUnderflowException If the buffer's current position is not smaller than its limit
*/
public String getStringUTF8() { return memUTF8(get()); }
/**
* Reads the pointer at this buffer's current position, and then increments the position. The pointer is evaluated as a null-terminated UTF-16 string,
* which is decoded and returned as a {@link String} instance.
*
* @throws BufferUnderflowException If the buffer's current position is not smaller than its limit
*/
public String getStringUTF16() { return memUTF16(get()); }
// ---
/** Returns a {@link ByteBuffer} instance that starts at the address found at the specified {@code index} and has capacity equal to the specified size. */
public ByteBuffer getByteBuffer(int index, int size) { return memByteBuffer(get(index), size); }
/** Returns a {@link ShortBuffer} instance that starts at the address found at the specified {@code index} and has capacity equal to the specified size. */
public ShortBuffer getShortBuffer(int index, int size) { return memShortBuffer(get(index), size); }
/** Returns a {@link IntBuffer} instance that starts at the address found at the specified {@code index} and has capacity equal to the specified size. */
public IntBuffer getIntBuffer(int index, int size) { return memIntBuffer(get(index), size); }
/** Returns a {@link LongBuffer} instance that starts at the address found at the specified {@code index} and has capacity equal to the specified size. */
public LongBuffer getLongBuffer(int index, int size) { return memLongBuffer(get(index), size); }
/** Returns a {@link FloatBuffer} instance that starts at the address found at the specified {@code index} and has capacity equal to the specified size. */
public FloatBuffer getFloatBuffer(int index, int size) { return memFloatBuffer(get(index), size); }
/** Returns a {@link DoubleBuffer} instance that starts at the address found at the specified {@code index} and has capacity equal to the specified size. */
public DoubleBuffer getDoubleBuffer(int index, int size) { return memDoubleBuffer(get(index), size); }
/** Returns a {@code PointerBuffer} instance that starts at the address found at the specified {@code index} and has capacity equal to the specified size. */
public PointerBuffer getPointerBuffer(int index, int size) { return memPointerBuffer(get(index), size); }
/** Decodes the ASCII string that starts at the address found at the specified {@code index}. */
public String getStringASCII(int index) { return memASCII(get(index)); }
/** Decodes the UTF-8 string that starts at the address found at the specified {@code index}. */
public String getStringUTF8(int index) { return memUTF8(get(index)); }
/** Decodes the UTF-16 string that starts at the address found at the specified {@code index}. */
public String getStringUTF16(int index) { return memUTF16(get(index)); }
// -- Bulk get operations --
/**
* Relative bulk <i>get</i> method.
*
* <p>This method transfers pointers from this buffer into the specified destination array. An invocation of this method of the form {@code src.get(a)}
* behaves in exactly the same way as the invocation
*
* <pre>
* src.get(a, 0, a.length) </pre>
*
* @return This buffer
*
* @throws BufferUnderflowException If there are fewer than {@code length} pointers remaining in this buffer
*/
public PointerBuffer get(long[] dst) {
return get(dst, 0, dst.length);
}
/**
* Relative bulk <i>get</i> method.
*
* <p>This method transfers pointers from this buffer into the specified destination array. If there are fewer pointers remaining in the buffer than are
* required to satisfy the request, that is, if {@code length}&nbsp;{@code &gt;}&nbsp;{@code remaining()}, then no pointers are transferred and a
* {@link BufferUnderflowException} is thrown.
*
* <p>Otherwise, this method copies {@code length} pointers from this buffer into the specified array, starting at the current position of this buffer and
* at the specified offset in the array. The position of this buffer is then incremented by {@code length}.
*
* <p>In other words, an invocation of this method of the form {@code src.get(dst,&nbsp;off,&nbsp;len)} has exactly the same effect as the loop</p>
*
* <pre>
* for (int i = off; i &lt; off + len; i++)
* dst[i] = src.get(); </pre>
*
* <p>except that it first checks that there are sufficient pointers in this buffer and it is potentially much more efficient. </p>
*
* @param dst the array into which pointers are to be written
* @param offset the offset within the array of the first pointer to be written; must be non-negative and no larger than {@code dst.length}
* @param length the maximum number of pointers to be written to the specified array; must be non-negative and no larger than {@code dst.length - offset}
*
* @return This buffer
*
* @throws BufferUnderflowException If there are fewer than {@code length} pointers remaining in this buffer
* @throws IndexOutOfBoundsException If the preconditions on the {@code offset} and {@code length} parameters do not hold
*/
public PointerBuffer get(long[] dst, int offset, int length) {
if (BITS64) {
memLongBuffer(address(), remaining()).get(dst, offset, length);
position(position() + length);
} else {
get32(dst, offset, length);
}
return this;
}
private void get32(long[] dst, int offset, int length) {
checkFromIndexSize(offset, length, dst.length);
if (remaining() < length) {
throw new BufferUnderflowException();
}
for (int i = offset, end = offset + length; i < end; i++) {
dst[i] = get();
}
}
/**
* Relative bulk <i>put</i> method&nbsp;&nbsp;<i>(optional operation)</i>.
*
* <p>This method transfers the entire content of the specified source pointer array into this buffer. An invocation of this method of the form
* {@code dst.put(a)} behaves in exactly the same way as the invocation</p>
*
* <pre>
* dst.put(a, 0, a.length) </pre>
*
* @return This buffer
*
* @throws BufferOverflowException If there is insufficient space in this buffer
*/
public PointerBuffer put(long[] src) {
return put(src, 0, src.length);
}
/**
* Relative bulk <i>put</i> method&nbsp;&nbsp;<i>(optional operation)</i>.
*
* <p>This method transfers pointers into this buffer from the specified source array. If there are more pointers to be copied from the array than remain
* in this buffer, that is, if {@code length}&nbsp;{@code &gt;}&nbsp;{@code remaining()}, then no pointers are transferred and a
* {@link BufferOverflowException} is thrown.
*
* <p>Otherwise, this method copies {@code length} pointers from the specified array into this buffer, starting at the specified offset in the array and
* at the current position of this buffer. The position of this buffer is then incremented by {@code length}.</p>
*
* <p>In other words, an invocation of this method of the form {@code dst.put(src,&nbsp;off,&nbsp;len)} has exactly the same effect as the loop</p>
*
* <pre>
* for (int i = off; i &lt; off + len; i++)
* dst.put(a[i]); </pre>
*
* <p>except that it first checks that there is sufficient space in this buffer and it is potentially much more efficient.</p>
*
* @param src the array from which pointers are to be read
* @param offset the offset within the array of the first pointer to be read; must be non-negative and no larger than {@code array.length}
* @param length the number of pointers to be read from the specified array; must be non-negative and no larger than {@code array.length - offset}
*
* @return This buffer
*
* @throws BufferOverflowException If there is insufficient space in this buffer
* @throws IndexOutOfBoundsException If the preconditions on the {@code offset} and {@code length} parameters do not hold
*/
public PointerBuffer put(long[] src, int offset, int length) {
if (BITS64) {
memLongBuffer(address(), remaining()).put(src, offset, length);
position(position() + length);
} else {
put32(src, offset, length);
}
return this;
}
private void put32(long[] src, int offset, int length) {
checkFromIndexSize(offset, length, src.length);
if (remaining() < length) {
throw new BufferOverflowException();
}
int end = offset + length;
for (int i = offset; i < end; i++) {
put(src[i]);
}
}
/**
* Returns the current hash code of this buffer.
*
* <p>The hash code of a pointer buffer depends only upon its remaining elements; that is, upon the elements from {@code position()} up to, and including,
* the element at {@code limit()}&nbsp;-&nbsp;{@code 1}.</p>
*
* <p>Because buffer hash codes are content-dependent, it is inadvisable to use buffers as keys in hash maps or similar data structures unless it is known
* that their contents will not change.</p>
*
* @return the current hash code of this buffer
*/
public int hashCode() {
int h = 1;
int p = position();
for (int i = limit() - 1; i >= p; i--) {
h = 31 * h + (int)get(i);
}
return h;
}
/**
* Tells whether or not this buffer is equal to another object.
*
* <p>Two pointer buffers are equal if, and only if,</p>
*
* <ol>
* <li>They have the same element type,</li>
* <li>They have the same number of remaining elements, and</li>
* <li>The two sequences of remaining elements, considered
* independently of their starting positions, are pointwise equal.</li>
* </ol>
*
* <p>A pointer buffer is not equal to any other type of object.</p>
*
* @param ob the object to which this buffer is to be compared
*
* @return {@code true} if, and only if, this buffer is equal to the
* given object
*/
public boolean equals(Object ob) {
if (!(ob instanceof PointerBuffer)) {
return false;
}
PointerBuffer that = (PointerBuffer)ob;
if (this.remaining() != that.remaining()) {
return false;
}
int p = this.position();
for (int i = this.limit() - 1, j = that.limit() - 1; i >= p; i--, j--) {
long v1 = this.get(i);
long v2 = that.get(j);
if (v1 != v2) {
return false;
}
}
return true;
}
/**
* Compares this buffer to another.
*
* <p>Two pointer buffers are compared by comparing their sequences of remaining elements lexicographically, without regard to the starting position of
* each sequence within its corresponding buffer.</p>
*
* <p>A pointer buffer is not comparable to any other type of object.</p>
*
* @return A negative integer, zero, or a positive integer as this buffer is less than, equal to, or greater than the specified buffer
*/
@Override
public int compareTo(PointerBuffer that) {
int n = this.position() + Math.min(this.remaining(), that.remaining());
for (int i = this.position(), j = that.position(); i < n; i++, j++) {
long v1 = this.get(i);
long v2 = that.get(j);
if (v1 == v2) {
continue;
}
if (v1 < v2) {
return -1;
}
return +1;
}
return this.remaining() - that.remaining();
}
}

View File

@ -1,43 +0,0 @@
/*
* Copyright (c) 2002-2008 LWJGL Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of 'LWJGL' nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.lwjgl;
/**
* A common interface for classes that wrap pointer addresses.
*
* @author Spasi
*/
public interface PointerWrapper {
long getPointer();
}

View File

@ -1,92 +0,0 @@
/*
* Copyright (c) 2002-2010 LWJGL Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of 'LWJGL' nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.lwjgl;
/**
* Base PointerWrapper implementation.
*
* @author Spasi
*/
public abstract class PointerWrapperAbstract implements PointerWrapper {
protected final long pointer;
protected PointerWrapperAbstract(final long pointer) {
this.pointer = pointer;
}
/**
* Returns true if this object represents a valid pointer.
* The pointer might be invalid because it is NULL or because
* some other action has deleted the object that this pointer
* represents.
*
* @return true if the pointer is valid
*/
public boolean isValid() {
return pointer != 0;
}
/**
* Checks if the pointer is valid and throws an IllegalStateException if
* it is not. This method is a NO-OP, unless the org.lwjgl.util.Debug
* property has been set to true.
*/
public final void checkValid() {
if ( LWJGLUtil.DEBUG && !isValid() )
throw new IllegalStateException("This " + getClass().getSimpleName() + " pointer is not valid.");
}
public final long getPointer() {
checkValid();
return pointer;
}
public boolean equals(final Object o) {
if ( this == o ) return true;
if ( !(o instanceof PointerWrapperAbstract) ) return false;
final PointerWrapperAbstract that = (PointerWrapperAbstract)o;
if ( pointer != that.pointer ) return false;
return true;
}
public int hashCode() {
return (int)(pointer ^ (pointer >>> 32));
}
public String toString() {
return getClass().getSimpleName() + " pointer (0x" + Long.toHexString(pointer).toUpperCase() + ")";
}
}

View File

@ -1,181 +0,0 @@
/*
* Copyright (c) 2002-2008 LWJGL Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of 'LWJGL' nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.lwjgl;
import org.lwjgl.glfw.GLFW;
import java.lang.reflect.Method;
import java.net.MalformedURLException;
import java.net.URL;
import java.security.AccessController;
import java.security.PrivilegedExceptionAction;
import javax.swing.JOptionPane;
import javax.swing.UIManager;
/**
* <p>
* System class (named Sys so as not to conflict with java.lang.System)
* </p>
* @author cix_foo <cix_foo@users.sourceforge.net>
* @version $Revision$
* $Id$
*/
public final class Sys {
/**
* No constructor for Sys.
*/
private Sys() {
}
/**
* Return the version of the core LWJGL libraries as a String.
*/
public static String getVersion() {
return Version.getVersion();
}
/**
* Initialization. This is just a dummy method to trigger the static constructor.
*/
public static void initialize() {
if (!GLFW.glfwInit())
throw new IllegalStateException("Unable to initialize GLFW");
}
/**
* Obtains the number of ticks that the hires timer does in a second. This method is fast;
* it should be called as frequently as possible, as it recalibrates the timer.
*
* @return timer resolution in ticks per second or 0 if no timer is present.
*/
public static long getTimerResolution() {
return 1000;
}
/**
* Gets the current value of the hires timer, in ticks. When the Sys class is first loaded
* the hires timer is reset to 0. If no hires timer is present then this method will always
* return 0.<p><strong>NOTEZ BIEN</strong> that the hires timer WILL wrap around.
*
* @return the current hires time, in ticks (always >= 0)
*/
public static long getTime() {
return GLFW.glfwGetTimerValue();
}
public static long getNanoTime() {
return System.nanoTime();
}
/**
* Attempt to display a modal alert to the user. This method should be used
* when a game fails to initialize properly or crashes out losing its display
* in the process. It is provided because AWT may not be available on the target
* platform, although on Mac and Linux and other platforms supporting AWT we
* delegate the task to AWT instead of doing it ourselves.
* <p>
* The alert should display the title and the message and then the current
* thread should block until the user dismisses the alert - typically with an
* OK button click.
* <p>
* It may be that the user's system has no windowing system installed for some
* reason, in which case this method may do nothing at all, or attempt to provide
* some console output.
*
* @param title The title of the alert. We suggest using the title of your game.
* @param message The message text for the alert.
*/
public static void alert(String title, String message) {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception e) {
LWJGLUtil.log("Caught exception while setting Look-and-Feel: " + e);
}
JOptionPane.showMessageDialog(null, message, title, JOptionPane.WARNING_MESSAGE);
}
/**
* Open the system web browser and point it at the specified URL. It is recommended
* that this not be called whilst your game is running, but on application exit in
* a shutdown hook, as the screen resolution will not be reset when the browser is
* brought into view.
* <p>
* There is no guarantee that this will work, nor that we can detect if it has
* failed - hence we don't return success code or throw an Exception. This is just a
* best attempt at opening the URL given - don't rely on it to work!
* <p>
* @param url The URL. Ensure that the URL is properly encoded.
* @return false if we are CERTAIN the call has failed
*/
public static boolean openURL(String url) {
// Attempt to use Webstart if we have it available
try {
// Lookup the javax.jnlp.BasicService object
final Class<?> serviceManagerClass = Class.forName("javax.jnlp.ServiceManager");
Method lookupMethod = AccessController.doPrivileged(new PrivilegedExceptionAction<Method>() {
public Method run() throws Exception {
return serviceManagerClass.getMethod("lookup", String.class);
}
});
Object basicService = lookupMethod.invoke(serviceManagerClass, new Object[] {"javax.jnlp.BasicService"});
final Class<?> basicServiceClass = Class.forName("javax.jnlp.BasicService");
Method showDocumentMethod = AccessController.doPrivileged(new PrivilegedExceptionAction<Method>() {
public Method run() throws Exception {
return basicServiceClass.getMethod("showDocument", URL.class);
}
});
try {
Boolean ret = (Boolean) showDocumentMethod.invoke(basicService, new URL(url));
return ret;
} catch (MalformedURLException e) {
e.printStackTrace(System.err);
return false;
}
} catch (Exception ue) {
return false;
}
}
/**
* Get the contents of the system clipboard. The system might not have a
* clipboard (particularly if it doesn't even have a keyboard) in which case
* we return null. Otherwise we return a String, which may be the empty
* string "".
*
* @return a String, or null if there is no system clipboard.
*/
public static String getClipboard() {
return GLFW.glfwGetClipboardString(GLFW.glfwGetPrimaryMonitor());
}
}

View File

@ -1,127 +0,0 @@
/*
* Copyright LWJGL. All rights reserved.
* License terms: https://www.lwjgl.org/license
*/
package org.lwjgl;
import javax.annotation.*;
import java.io.*;
import java.net.*;
import java.util.*;
import java.util.jar.*;
/** This class can be used to query the LWJGL version. */
public final class Version {
/** Current version of library. */
public static final int
VERSION_MAJOR = 3,
VERSION_MINOR = 3,
VERSION_REVISION = 3;
/** The development state of the current build. */
public static final BuildType BUILD_TYPE = BuildType.STABLE;
private static final String versionPlain =
String.valueOf(VERSION_MAJOR) +
'.' + VERSION_MINOR +
'.' + VERSION_REVISION + BUILD_TYPE.postfix;
private static final String version = versionPlain + VersionImpl.find();
private Version() {
}
public static void main(String[] args) {
System.out.println(version);
System.err.println(versionPlain);
}
/** Returns the LWJGL version. */
public static String getVersion() {
return version;
}
/** The development state of the current build. */
public enum BuildType {
/** Work in progress, unstable. */
ALPHA("a"),
/** Feature complete, unstable. */
BETA("b"),
/** Feature complete, stable, official release. */
STABLE("");
public final String postfix;
BuildType(String postfix) {
this.postfix = postfix;
}
}
static String createImplementation(String specVersion, String implVersion) {
String build = "+" + (implVersion.startsWith("build ") && 6 < implVersion.length() ? implVersion.substring(6) : implVersion);
if (specVersion.contains("SNAPSHOT") || specVersion.contains("snapshot")) {
return "-snapshot" + build;
}
return build;
}
@Nullable
static String findImplementationFromManifest() {
ClassLoader classLoader = Version.class.getClassLoader();
URL url = classLoader.getResource("org/lwjgl/Version.class");
if (url != null) {
String classURL = url.toString();
try {
if (classURL.startsWith("jar:")) { // running on standard JDK
URL manifest = Version.class.getResource("/" + JarFile.MANIFEST_NAME);
String version = readImplementationFromManifest(Objects.requireNonNull(manifest));
if (version != null) {
return version;
}
} else if (classURL.startsWith("resource:")) { // running on GraalVM native image
Enumeration<URL> e = classLoader.getResources(JarFile.MANIFEST_NAME);
while (e.hasMoreElements()) {
String version = readImplementationFromManifest(e.nextElement());
if (version != null) {
return version;
}
}
}
} catch (Exception ignored) {
}
}
return null;
}
@Nullable
private static String readImplementationFromManifest(URL url) {
try (InputStream stream = url.openStream()) {
Attributes attribs = new Manifest(stream).getMainAttributes();
// make sure this is the manifest from lwjgl.jar
if (!"lwjgl".equals(attribs.getValue(Attributes.Name.IMPLEMENTATION_TITLE))) {
return null;
}
if (!"lwjgl.org".equals(attribs.getValue(Attributes.Name.IMPLEMENTATION_VENDOR))) {
return null;
}
String specVersion = attribs.getValue(Attributes.Name.SPECIFICATION_VERSION);
String implVersion = attribs.getValue(Attributes.Name.IMPLEMENTATION_VERSION);
if (specVersion == null || implVersion == null) {
return null;
}
return createImplementation(specVersion, implVersion);
} catch (Exception ignored) {
return null;
}
}
}

View File

@ -1,32 +0,0 @@
/*
* Copyright LWJGL. All rights reserved.
* License terms: https://www.lwjgl.org/license
*/
package org.lwjgl;
/**
* Finds the LWJGL implementation version (build type/number).
*
* <p>Base implementation for Java 8. When run in the module path, it cannot find the implementation version without reading the JAR manifest. See the
* {@code lwjgl.core9} module for the module-aware implementation.</p>
*/
final class VersionImpl {
static String find() {
Package org_lwjgl = Version.class.getPackage();
String specVersion = org_lwjgl.getSpecificationVersion();
String implVersion = org_lwjgl.getImplementationVersion();
if (specVersion != null && implVersion != null) {
return Version.createImplementation(specVersion, implVersion);
}
String version = Version.findImplementationFromManifest();
if (version != null) {
return version;
}
return "-snapshot";
}
}

View File

@ -1,60 +0,0 @@
/*
* Copyright LWJGL. All rights reserved.
* License terms: https://www.lwjgl.org/license
*/
package org.lwjgl.glfw;
import org.lwjgl.system.*;
import static org.lwjgl.system.Checks.*;
import static org.lwjgl.system.JNI.*;
import static org.lwjgl.system.MemoryUtil.*;
/** Utility class for GLFW callbacks. */
public final class Callbacks {
private Callbacks() {}
/**
* Resets all callbacks for the specified GLFW window to {@code NULL} and {@link Callback#free frees} all previously set callbacks.
*
* <p>This method resets only callbacks registered with a GLFW window. Non-window callbacks (registered with
* {@link GLFW#glfwSetErrorCallback SetErrorCallback}, {@link GLFW#glfwSetMonitorCallback SetMonitorCallback}, etc.) must be reset and freed
* separately.</p>
*
* <p>This method is not official GLFW API. It exists in LWJGL to simplify window callback cleanup.</p>
*
* @param window the GLFW window
*/
public static void glfwFreeCallbacks(@NativeType("GLFWwindow *") long window) {
if (Checks.CHECKS) {
check(window);
}
for (long callback : new long[] {
GLFW.Functions.SetWindowPosCallback,
GLFW.Functions.SetWindowSizeCallback,
GLFW.Functions.SetWindowCloseCallback,
GLFW.Functions.SetWindowRefreshCallback,
GLFW.Functions.SetWindowFocusCallback,
GLFW.Functions.SetWindowIconifyCallback,
GLFW.Functions.SetWindowMaximizeCallback,
GLFW.Functions.SetFramebufferSizeCallback,
GLFW.Functions.SetWindowContentScaleCallback,
GLFW.Functions.SetKeyCallback,
GLFW.Functions.SetCharCallback,
GLFW.Functions.SetCharModsCallback,
GLFW.Functions.SetMouseButtonCallback,
GLFW.Functions.SetCursorPosCallback,
GLFW.Functions.SetCursorEnterCallback,
GLFW.Functions.SetScrollCallback,
GLFW.Functions.SetDropCallback
}) {
long prevCB = invokePPP(window, NULL, callback);
if (prevCB != NULL) {
Callback.free(prevCB);
}
}
}
}

View File

@ -1,58 +0,0 @@
/*
* Copyright LWJGL. All rights reserved.
* License terms: https://www.lwjgl.org/license
*/
package org.lwjgl.glfw;
import org.lwjgl.system.*;
import org.lwjgl.system.macosx.*;
import static org.lwjgl.system.JNI.*;
import static org.lwjgl.system.macosx.LibC.*;
import static org.lwjgl.system.macosx.ObjCRuntime.*;
/**
* Contains checks for the event loop issues on OS X.
*
* <p>GLFW can only be used on the main thread and only if that thread is the first thread in the process. This requires running the JVM with
* {@code -XstartOnFirstThread}, which means that other window toolkits (AWT/Swing, JavaFX, etc.) cannot be used at the same time.</p>
*
* <p>Another window toolkit <em>can</em> be used if GLFW windows are never shown (created with {@link GLFW#GLFW_VISIBLE GLFW_VISIBLE} equal to
* {@link GLFW#GLFW_FALSE GLFW_FALSE}) and only used as contexts for offscreen rendering. This is possible if the window toolkit has initialized and created
* the shared application (NSApp) before GLFW is initialized.</p>
*/
final class EventLoop {
private EventLoop() {
}
static void check() {
if (Platform.get() == Platform.MACOSX && !isMainThread()) {
// The only way to avoid a crash is if the shared application (NSApp) has been created by something else
throw new IllegalStateException(
isJavaStartedOnFirstThread()
? "GLFW may only be used on the main thread. This check may be disabled with Configuration.GLFW_CHECK_THREAD0."
: "GLFW may only be used on the main thread and that thread must be the first thread in the process. Please run " +
"the JVM with -XstartOnFirstThread. This check may be disabled with Configuration.GLFW_CHECK_THREAD0."
);
}
}
private static boolean isMainThread() {
if (!Configuration.GLFW_CHECK_THREAD0.get(true) || Configuration.GLFW_LIBRARY_NAME.get("").contains("glfw_async")) {
return true;
}
long objc_msgSend = ObjCRuntime.getLibrary().getFunctionAddress("objc_msgSend");
long NSThread = objc_getClass("NSThread");
long currentThread = invokePPP(NSThread, sel_getUid("currentThread"), objc_msgSend);
return invokePPZ(currentThread, sel_getUid("isMainThread"), objc_msgSend);
}
private static boolean isJavaStartedOnFirstThread() {
return "1".equals(System.getenv().get("JAVA_STARTED_ON_FIRST_THREAD_" + getpid()));
}
}

View File

@ -1,170 +0,0 @@
package org.lwjgl.glfw;
import org.lwjgl.system.*;
import javax.annotation.Nullable;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import static org.lwjgl.system.APIUtil.apiGetFunctionAddress;
import static org.lwjgl.system.APIUtil.apiLog;
import static org.lwjgl.system.JNI.invokePP;
import static org.lwjgl.system.MemoryUtil.memAddressSafe;
/**
* By Tungsten
* This class is for Fold Craft Launcher.
*/
public class FCLInjector {
public static final long SetInjectorCallBack = apiGetFunctionAddress(GLFW.GLFW, "glfwSetInjectorCallback");
public static final long SetHitResultType = apiGetFunctionAddress(GLFW.GLFW, "glfwSetHitResultType");
private static boolean get = false;
private static ClassLoader classLoader;
private static final String HIT_RESULT_TYPE_UNKNOWN = "UNKNOWN";
private static final String HIT_RESULT_TYPE_MISS = "MISS";
private static final String HIT_RESULT_TYPE_BLOCK = "BLOCK";
private static final String HIT_RESULT_TYPE_BLOCK_OLD = "TILE";
private static final String HIT_RESULT_TYPE_ENTITY = "ENTITY";
private static final int INJECTOR_LEVEL_0 = 0; // unknown
private static final int INJECTOR_LEVEL_1 = 1; // 1.0 - 1.2
private static final int INJECTOR_LEVEL_2 = 2; // 1.3 - 1.6
private static final int INJECTOR_LEVEL_3 = 3; // 1.7 - 1.13
private static final int INJECTOR_LEVEL_4 = 4; // 1.13+
private static final int INJECTOR_MODE_ENABLE = 1;
private static final int INJECTOR_MODE_DISABLE = 0;
private static int level = 0;
@Nullable
private static String param0 = null;
@Nullable
private static String param1 = null;
@Nullable
private static String param2 = null;
@Nullable
private static String param3 = null;
public static void setClassLoader(ClassLoader classLoader) {
String prop = System.getProperty("fcl.injector");
if (!get && prop != null && !prop.isEmpty()) {
FCLInjector.classLoader = classLoader;
String[] props = prop.split(":");
if (props.length == 5 && (props[0].equals("0") || props[0].equals("1") || props[0].equals("2") || props[0].equals("3") || props[0].equals("4"))) {
int level = Integer.parseInt(props[0]);
String param0 = props[1];
String param1 = props[2];
String param2 = props[3];
String param3 = props[4];
setup(level, param0, param1, param2, param3);
}
}
}
public static void setup(int level, String param0, String param1, String param2, String param3) {
FCLInjector.level = level;
FCLInjector.param0 = param0;
FCLInjector.param1 = param1;
FCLInjector.param2 = param2;
FCLInjector.param3 = param3;
get = true;
FCLInjectorCallback callback = new FCLInjectorCallback() {
@Override
public void invoke() {
getHitResultType();
}
};
glfwSetFCLInjectorCallback(callback);
}
@Nullable
@NativeType("FCLinjectorfun")
public static FCLInjectorCallback glfwSetFCLInjectorCallback(@Nullable @NativeType("FCLinjectorfun") FCLInjectorCallbackI cbfun) {
return FCLInjectorCallback.createSafe(nglfwSetFCLInjectorCallback(memAddressSafe(cbfun)));
}
public static long nglfwSetFCLInjectorCallback(long cbfun) {
return invokePP(cbfun, SetInjectorCallBack);
}
public static void nglfwSetHitResultType(String type) {
int typeInt;
switch (type) {
case HIT_RESULT_TYPE_MISS:
typeInt = 1;
break;
case HIT_RESULT_TYPE_BLOCK:
case HIT_RESULT_TYPE_BLOCK_OLD:
typeInt = 2;
break;
case HIT_RESULT_TYPE_ENTITY:
typeInt = 3;
break;
default:
typeInt = 0;
break;
}
JNI.invokeV(typeInt, FCLInjector.SetHitResultType);
}
public static void getHitResultType() {
if (!get) {
nglfwSetHitResultType(HIT_RESULT_TYPE_UNKNOWN);
apiLog("FCL Injector not initialized!\n");
return;
}
if (param0 != null && param1 != null && param2 != null && param3 != null) {
Object type = null;
boolean success = false;
try {
Class<?> minecraftClass = Class.forName(param0, true, classLoader);
Method method = minecraftClass.getDeclaredMethod(param1);
method.setAccessible(true);
Object minecraft = method.invoke(null);
Field targetField = minecraftClass.getDeclaredField(param2);
targetField.setAccessible(true);
Object target = targetField.get(minecraft);
if (target != null) {
switch (level) {
case INJECTOR_LEVEL_2:
case INJECTOR_LEVEL_3:
Field typeField = target.getClass().getDeclaredField(param3);
typeField.setAccessible(true);
type = typeField.get(target);
break;
case INJECTOR_LEVEL_4:
Method typeMethod = target.getClass().getDeclaredMethod(param3);
typeMethod.setAccessible(true);
type = typeMethod.invoke(target);
break;
default:
break;
}
}
success = true;
} catch (ClassNotFoundException | NoSuchFieldException | NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
apiLog(e.getMessage());
}
if (level == INJECTOR_LEVEL_2) {
if (success && type == null) {
nglfwSetHitResultType(HIT_RESULT_TYPE_MISS);
} else if (success && (type.toString().equals(HIT_RESULT_TYPE_BLOCK_OLD) || type.toString().equals(HIT_RESULT_TYPE_ENTITY))) {
nglfwSetHitResultType(type.toString());
} else {
nglfwSetHitResultType(HIT_RESULT_TYPE_UNKNOWN);
}
} else {
if (type != null && (type.toString().equals(HIT_RESULT_TYPE_MISS) || type.toString().equals(HIT_RESULT_TYPE_BLOCK) || type.toString().equals(HIT_RESULT_TYPE_ENTITY))) {
nglfwSetHitResultType(type.toString());
} else {
nglfwSetHitResultType(HIT_RESULT_TYPE_UNKNOWN);
}
}
}
}
}

View File

@ -1,55 +0,0 @@
package org.lwjgl.glfw;
import static org.lwjgl.system.MemoryUtil.NULL;
import org.lwjgl.system.Callback;
import javax.annotation.Nullable;
public abstract class FCLInjectorCallback extends Callback implements FCLInjectorCallbackI {
public static FCLInjectorCallback create(long functionPointer) {
FCLInjectorCallbackI instance = Callback.get(functionPointer);
return instance instanceof FCLInjectorCallback
? (FCLInjectorCallback)instance
: new FCLInjectorCallback.Container(functionPointer, instance);
}
/** Like {@link #create(long) create}, but returns {@code null} if {@code functionPointer} is {@code NULL}. */
@Nullable
public static FCLInjectorCallback createSafe(long functionPointer) {
return functionPointer == NULL ? null : create(functionPointer);
}
/** Creates a {@code GLFWCursorEnterCallback} instance that delegates to the specified {@code GLFWCursorEnterCallbackI} instance. */
public static FCLInjectorCallback create(FCLInjectorCallbackI instance) {
return instance instanceof FCLInjectorCallback
? (FCLInjectorCallback)instance
: new FCLInjectorCallback.Container(instance.address(), instance);
}
protected FCLInjectorCallback() {
super(CIF);
}
FCLInjectorCallback(long functionPointer) {
super(functionPointer);
}
private static final class Container extends FCLInjectorCallback {
private final FCLInjectorCallbackI delegate;
Container(long functionPointer, FCLInjectorCallbackI delegate) {
super(functionPointer);
this.delegate = delegate;
}
@Override
public void invoke() {
delegate.invoke();
}
}
}

View File

@ -1,33 +0,0 @@
package org.lwjgl.glfw;
import static org.lwjgl.system.APIUtil.apiCreateCIF;
import static org.lwjgl.system.libffi.LibFFI.FFI_DEFAULT_ABI;
import static org.lwjgl.system.libffi.LibFFI.ffi_type_pointer;
import static org.lwjgl.system.libffi.LibFFI.ffi_type_uint32;
import static org.lwjgl.system.libffi.LibFFI.ffi_type_void;
import org.lwjgl.system.CallbackI;
import org.lwjgl.system.NativeType;
import org.lwjgl.system.libffi.FFICIF;
@FunctionalInterface
@NativeType("FCLinjectorfun")
public interface FCLInjectorCallbackI extends CallbackI {
FFICIF CIF = apiCreateCIF(
FFI_DEFAULT_ABI,
ffi_type_void,
ffi_type_pointer, ffi_type_uint32
);
@Override
default FFICIF getCallInterface() { return CIF; }
@Override
default void callback(long ret, long args) {
invoke();
}
void invoke();
}

File diff suppressed because it is too large Load Diff

View File

@ -1,101 +0,0 @@
/*
* Copyright LWJGL. All rights reserved.
* License terms: https://www.lwjgl.org/license
* MACHINE GENERATED FILE, DO NOT EDIT
*/
package org.lwjgl.glfw;
import javax.annotation.*;
import org.lwjgl.system.*;
import static org.lwjgl.system.MemoryUtil.*;
/**
* The function pointer type for memory allocation callbacks.
*
* <p>This is the function pointer type for memory allocation callbacks. A memory allocation callback function has the following signature:</p>
*
* <pre><code>
* void* function_name(size_t size, void* user)</code></pre>
*
* <p>This function must return either a memory block at least {@code size} bytes long, or {@code NULL} if allocation failed. Note that not all parts of GLFW
* handle allocation failures gracefully yet.</p>
*
* <p>This function may be called during {@link GLFW#glfwInit Init} but before the library is flagged as initialized, as well as during {@link GLFW#glfwTerminate Terminate} after the library is no
* longer flagged as initialized.</p>
*
* <p>Any memory allocated by this function will be deallocated during library termination or earlier.</p>
*
* <p>The size will always be greater than zero. Allocations of size zero are filtered out before reaching the custom allocator.</p>
*
* <div style="margin-left: 26px; border-left: 1px solid gray; padding-left: 14px;"><h5>Note</h5>
*
* <ul>
* <li>The returned memory block must be valid at least until it is deallocated.</li>
* <li>This function should not call any GLFW function.</li>
* <li>This function may be called from any thread that calls GLFW functions.</li>
* </ul></div>
*
* <h3>Type</h3>
*
* <pre><code>
* void * (*{@link #invoke}) (
* size_t size,
* void *user
* )</code></pre>
*
* @since version 3.4
*/
public abstract class GLFWAllocateCallback extends Callback implements GLFWAllocateCallbackI {
/**
* Creates a {@code GLFWAllocateCallback} instance from the specified function pointer.
*
* @return the new {@code GLFWAllocateCallback}
*/
public static GLFWAllocateCallback create(long functionPointer) {
GLFWAllocateCallbackI instance = Callback.get(functionPointer);
return instance instanceof GLFWAllocateCallback
? (GLFWAllocateCallback)instance
: new Container(functionPointer, instance);
}
/** Like {@link #create(long) create}, but returns {@code null} if {@code functionPointer} is {@code NULL}. */
@Nullable
public static GLFWAllocateCallback createSafe(long functionPointer) {
return functionPointer == NULL ? null : create(functionPointer);
}
/** Creates a {@code GLFWAllocateCallback} instance that delegates to the specified {@code GLFWAllocateCallbackI} instance. */
public static GLFWAllocateCallback create(GLFWAllocateCallbackI instance) {
return instance instanceof GLFWAllocateCallback
? (GLFWAllocateCallback)instance
: new Container(instance.address(), instance);
}
protected GLFWAllocateCallback() {
super(CIF);
}
GLFWAllocateCallback(long functionPointer) {
super(functionPointer);
}
private static final class Container extends GLFWAllocateCallback {
private final GLFWAllocateCallbackI delegate;
Container(long functionPointer, GLFWAllocateCallbackI delegate) {
super(functionPointer);
this.delegate = delegate;
}
@Override
public long invoke(long size, long user) {
return delegate.invoke(size, user);
}
}
}

View File

@ -1,83 +0,0 @@
/*
* Copyright LWJGL. All rights reserved.
* License terms: https://www.lwjgl.org/license
* MACHINE GENERATED FILE, DO NOT EDIT
*/
package org.lwjgl.glfw;
import org.lwjgl.system.*;
import org.lwjgl.system.libffi.*;
import static org.lwjgl.system.APIUtil.*;
import static org.lwjgl.system.MemoryUtil.*;
import static org.lwjgl.system.libffi.LibFFI.*;
/**
* The function pointer type for memory allocation callbacks.
*
* <p>This is the function pointer type for memory allocation callbacks. A memory allocation callback function has the following signature:</p>
*
* <pre><code>
* void* function_name(size_t size, void* user)</code></pre>
*
* <p>This function must return either a memory block at least {@code size} bytes long, or {@code NULL} if allocation failed. Note that not all parts of GLFW
* handle allocation failures gracefully yet.</p>
*
* <p>This function may be called during {@link GLFW#glfwInit Init} but before the library is flagged as initialized, as well as during {@link GLFW#glfwTerminate Terminate} after the library is no
* longer flagged as initialized.</p>
*
* <p>Any memory allocated by this function will be deallocated during library termination or earlier.</p>
*
* <p>The size will always be greater than zero. Allocations of size zero are filtered out before reaching the custom allocator.</p>
*
* <div style="margin-left: 26px; border-left: 1px solid gray; padding-left: 14px;"><h5>Note</h5>
*
* <ul>
* <li>The returned memory block must be valid at least until it is deallocated.</li>
* <li>This function should not call any GLFW function.</li>
* <li>This function may be called from any thread that calls GLFW functions.</li>
* </ul></div>
*
* <h3>Type</h3>
*
* <pre><code>
* void * (*{@link #invoke}) (
* size_t size,
* void *user
* )</code></pre>
*
* @since version 3.4
*/
@FunctionalInterface
@NativeType("GLFWallocatefun")
public interface GLFWAllocateCallbackI extends CallbackI {
FFICIF CIF = apiCreateCIF(
FFI_DEFAULT_ABI,
ffi_type_pointer,
ffi_type_pointer, ffi_type_pointer
);
@Override
default FFICIF getCallInterface() { return CIF; }
@Override
default void callback(long ret, long args) {
long __result = invoke(
memGetAddress(memGetAddress(args)),
memGetAddress(memGetAddress(args + POINTER_SIZE))
);
apiClosureRetP(ret, __result);
}
/**
* Will be called for memory allocation requests.
*
* @param size the minimum size, in bytes, of the memory block
* @param user the user-defined pointer from the allocator
*
* @return the address of the newly allocated memory block, or {@code NULL} if an error occurred
*/
@NativeType("void *") long invoke(@NativeType("size_t") long size, @NativeType("void *") long user);
}

View File

@ -1,342 +0,0 @@
/*
* Copyright LWJGL. All rights reserved.
* License terms: https://www.lwjgl.org/license
* MACHINE GENERATED FILE, DO NOT EDIT
*/
package org.lwjgl.glfw;
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.*;
/**
* A custom memory allocator that can be set with {@link GLFW#glfwInitAllocator InitAllocator}.
*
* <h3>Layout</h3>
*
* <pre><code>
* struct GLFWallocator {
* {@link GLFWAllocateCallbackI GLFWallocatefun} {@link #allocate};
* {@link GLFWReallocateCallbackI GLFWreallocatefun} {@link #reallocate};
* {@link GLFWDeallocateCallbackI GLFWdeallocatefun} {@link #deallocate};
* void * {@link #user};
* }</code></pre>
*
* @since version 3.4
*/
@NativeType("struct GLFWallocator")
public class GLFWAllocator extends Struct<GLFWAllocator> 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
ALLOCATE,
REALLOCATE,
DEALLOCATE,
USER;
static {
Layout layout = __struct(
__member(POINTER_SIZE),
__member(POINTER_SIZE),
__member(POINTER_SIZE),
__member(POINTER_SIZE)
);
SIZEOF = layout.getSize();
ALIGNOF = layout.getAlignment();
ALLOCATE = layout.offsetof(0);
REALLOCATE = layout.offsetof(1);
DEALLOCATE = layout.offsetof(2);
USER = layout.offsetof(3);
}
protected GLFWAllocator(long address, @Nullable ByteBuffer container) {
super(address, container);
}
@Override
protected GLFWAllocator create(long address, @Nullable ByteBuffer container) {
return new GLFWAllocator(address, container);
}
/**
* Creates a {@code GLFWAllocator} 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.
*
* <p>The created instance holds a strong reference to the container object.</p>
*/
public GLFWAllocator(ByteBuffer container) {
super(memAddress(container), __checkContainer(container, SIZEOF));
}
@Override
public int sizeof() { return SIZEOF; }
/** the memory allocation callback */
@NativeType("GLFWallocatefun")
public GLFWAllocateCallback allocate() { return nallocate(address()); }
/** the memory reallocation callback */
@NativeType("GLFWreallocatefun")
public GLFWReallocateCallback reallocate() { return nreallocate(address()); }
/** the memory deallocation callback */
@NativeType("GLFWdeallocatefun")
public GLFWDeallocateCallback deallocate() { return ndeallocate(address()); }
/** a user-defined pointer that will be passed to the callbacks */
@NativeType("void *")
public long user() { return nuser(address()); }
/** Sets the specified value to the {@link #allocate} field. */
public GLFWAllocator allocate(@NativeType("GLFWallocatefun") GLFWAllocateCallbackI value) { nallocate(address(), value); return this; }
/** Sets the specified value to the {@link #reallocate} field. */
public GLFWAllocator reallocate(@NativeType("GLFWreallocatefun") GLFWReallocateCallbackI value) { nreallocate(address(), value); return this; }
/** Sets the specified value to the {@link #deallocate} field. */
public GLFWAllocator deallocate(@NativeType("GLFWdeallocatefun") GLFWDeallocateCallbackI value) { ndeallocate(address(), value); return this; }
/** Sets the specified value to the {@link #user} field. */
public GLFWAllocator user(@NativeType("void *") long value) { nuser(address(), value); return this; }
/** Initializes this struct with the specified values. */
public GLFWAllocator set(
GLFWAllocateCallbackI allocate,
GLFWReallocateCallbackI reallocate,
GLFWDeallocateCallbackI deallocate,
long user
) {
allocate(allocate);
reallocate(reallocate);
deallocate(deallocate);
user(user);
return this;
}
/**
* Copies the specified struct data to this struct.
*
* @param src the source struct
*
* @return this struct
*/
public GLFWAllocator set(GLFWAllocator src) {
memCopy(src.address(), address(), SIZEOF);
return this;
}
// -----------------------------------
/** Returns a new {@code GLFWAllocator} instance allocated with {@link MemoryUtil#memAlloc memAlloc}. The instance must be explicitly freed. */
public static GLFWAllocator malloc() {
return new GLFWAllocator(nmemAllocChecked(SIZEOF), null);
}
/** Returns a new {@code GLFWAllocator} instance allocated with {@link MemoryUtil#memCalloc memCalloc}. The instance must be explicitly freed. */
public static GLFWAllocator calloc() {
return new GLFWAllocator(nmemCallocChecked(1, SIZEOF), null);
}
/** Returns a new {@code GLFWAllocator} instance allocated with {@link BufferUtils}. */
public static GLFWAllocator create() {
ByteBuffer container = BufferUtils.createByteBuffer(SIZEOF);
return new GLFWAllocator(memAddress(container), container);
}
/** Returns a new {@code GLFWAllocator} instance for the specified memory address. */
public static GLFWAllocator create(long address) {
return new GLFWAllocator(address, null);
}
/** Like {@link #create(long) create}, but returns {@code null} if {@code address} is {@code NULL}. */
@Nullable
public static GLFWAllocator createSafe(long address) {
return address == NULL ? null : new GLFWAllocator(address, null);
}
/**
* Returns a new {@link 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 new Buffer(nmemAllocChecked(__checkMalloc(capacity, SIZEOF)), capacity);
}
/**
* Returns a new {@link 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 new Buffer(nmemCallocChecked(capacity, SIZEOF), capacity);
}
/**
* Returns a new {@link Buffer} instance allocated with {@link BufferUtils}.
*
* @param capacity the buffer capacity
*/
public static Buffer create(int capacity) {
ByteBuffer container = __create(capacity, SIZEOF);
return new Buffer(memAddress(container), container, -1, 0, capacity, capacity);
}
/**
* Create a {@link 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 new Buffer(address, capacity);
}
/** Like {@link #create(long, int) create}, but returns {@code null} if {@code address} is {@code NULL}. */
@Nullable
public static Buffer createSafe(long address, int capacity) {
return address == NULL ? null : new Buffer(address, capacity);
}
/**
* Returns a new {@code GLFWAllocator} instance allocated on the specified {@link MemoryStack}.
*
* @param stack the stack from which to allocate
*/
public static GLFWAllocator malloc(MemoryStack stack) {
return new GLFWAllocator(stack.nmalloc(ALIGNOF, SIZEOF), null);
}
/**
* Returns a new {@code GLFWAllocator} instance allocated on the specified {@link MemoryStack} and initializes all its bits to zero.
*
* @param stack the stack from which to allocate
*/
public static GLFWAllocator calloc(MemoryStack stack) {
return new GLFWAllocator(stack.ncalloc(ALIGNOF, 1, SIZEOF), null);
}
/**
* Returns a new {@link Buffer} instance allocated on the specified {@link MemoryStack}.
*
* @param stack the stack from which to allocate
* @param capacity the buffer capacity
*/
public static Buffer malloc(int capacity, MemoryStack stack) {
return new Buffer(stack.nmalloc(ALIGNOF, capacity * SIZEOF), capacity);
}
/**
* Returns a new {@link 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 calloc(int capacity, MemoryStack stack) {
return new Buffer(stack.ncalloc(ALIGNOF, capacity, SIZEOF), capacity);
}
// -----------------------------------
/** Unsafe version of {@link #allocate}. */
public static GLFWAllocateCallback nallocate(long struct) { return GLFWAllocateCallback.create(memGetAddress(struct + GLFWAllocator.ALLOCATE)); }
/** Unsafe version of {@link #reallocate}. */
public static GLFWReallocateCallback nreallocate(long struct) { return GLFWReallocateCallback.create(memGetAddress(struct + GLFWAllocator.REALLOCATE)); }
/** Unsafe version of {@link #deallocate}. */
public static GLFWDeallocateCallback ndeallocate(long struct) { return GLFWDeallocateCallback.create(memGetAddress(struct + GLFWAllocator.DEALLOCATE)); }
/** Unsafe version of {@link #user}. */
public static long nuser(long struct) { return memGetAddress(struct + GLFWAllocator.USER); }
/** Unsafe version of {@link #allocate(GLFWAllocateCallbackI) allocate}. */
public static void nallocate(long struct, GLFWAllocateCallbackI value) { memPutAddress(struct + GLFWAllocator.ALLOCATE, value.address()); }
/** Unsafe version of {@link #reallocate(GLFWReallocateCallbackI) reallocate}. */
public static void nreallocate(long struct, GLFWReallocateCallbackI value) { memPutAddress(struct + GLFWAllocator.REALLOCATE, value.address()); }
/** Unsafe version of {@link #deallocate(GLFWDeallocateCallbackI) deallocate}. */
public static void ndeallocate(long struct, GLFWDeallocateCallbackI value) { memPutAddress(struct + GLFWAllocator.DEALLOCATE, value.address()); }
/** Unsafe version of {@link #user(long) user}. */
public static void nuser(long struct, long value) { memPutAddress(struct + GLFWAllocator.USER, value); }
/**
* Validates pointer members that should not be {@code NULL}.
*
* @param struct the struct to validate
*/
public static void validate(long struct) {
check(memGetAddress(struct + GLFWAllocator.ALLOCATE));
check(memGetAddress(struct + GLFWAllocator.REALLOCATE));
check(memGetAddress(struct + GLFWAllocator.DEALLOCATE));
}
// -----------------------------------
/** An array of {@link GLFWAllocator} structs. */
public static class Buffer extends StructBuffer<GLFWAllocator, Buffer> implements NativeResource {
private static final GLFWAllocator ELEMENT_FACTORY = GLFWAllocator.create(-1L);
/**
* Creates a new {@code GLFWAllocator.Buffer} instance backed by the specified container.
*
* <p>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 GLFWAllocator#SIZEOF}, and its mark will be undefined.</p>
*
* <p>The created buffer instance holds a strong reference to the container object.</p>
*/
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 GLFWAllocator getElementFactory() {
return ELEMENT_FACTORY;
}
/** @return the value of the {@link GLFWAllocator#allocate} field. */
@NativeType("GLFWallocatefun")
public GLFWAllocateCallback allocate() { return GLFWAllocator.nallocate(address()); }
/** @return the value of the {@link GLFWAllocator#reallocate} field. */
@NativeType("GLFWreallocatefun")
public GLFWReallocateCallback reallocate() { return GLFWAllocator.nreallocate(address()); }
/** @return the value of the {@link GLFWAllocator#deallocate} field. */
@NativeType("GLFWdeallocatefun")
public GLFWDeallocateCallback deallocate() { return GLFWAllocator.ndeallocate(address()); }
/** @return the value of the {@link GLFWAllocator#user} field. */
@NativeType("void *")
public long user() { return GLFWAllocator.nuser(address()); }
/** Sets the specified value to the {@link GLFWAllocator#allocate} field. */
public Buffer allocate(@NativeType("GLFWallocatefun") GLFWAllocateCallbackI value) { GLFWAllocator.nallocate(address(), value); return this; }
/** Sets the specified value to the {@link GLFWAllocator#reallocate} field. */
public Buffer reallocate(@NativeType("GLFWreallocatefun") GLFWReallocateCallbackI value) { GLFWAllocator.nreallocate(address(), value); return this; }
/** Sets the specified value to the {@link GLFWAllocator#deallocate} field. */
public Buffer deallocate(@NativeType("GLFWdeallocatefun") GLFWDeallocateCallbackI value) { GLFWAllocator.ndeallocate(address(), value); return this; }
/** Sets the specified value to the {@link GLFWAllocator#user} field. */
public Buffer user(@NativeType("void *") long value) { GLFWAllocator.nuser(address(), value); return this; }
}
}

View File

@ -1,86 +0,0 @@
/*
* Copyright LWJGL. All rights reserved.
* License terms: https://www.lwjgl.org/license
* MACHINE GENERATED FILE, DO NOT EDIT
*/
package org.lwjgl.glfw;
import javax.annotation.*;
import org.lwjgl.system.*;
import static org.lwjgl.system.MemoryUtil.*;
import static org.lwjgl.glfw.GLFW.*;
/**
* Instances of this class may be passed to the {@link GLFW#glfwSetCharCallback SetCharCallback} method.
*
* <h3>Type</h3>
*
* <pre><code>
* void (*{@link #invoke}) (
* GLFWwindow *window,
* unsigned int codepoint
* )</code></pre>
*
* @since version 2.4
*/
public abstract class GLFWCharCallback extends Callback implements GLFWCharCallbackI {
/**
* Creates a {@code GLFWCharCallback} instance from the specified function pointer.
*
* @return the new {@code GLFWCharCallback}
*/
public static GLFWCharCallback create(long functionPointer) {
GLFWCharCallbackI instance = Callback.get(functionPointer);
return instance instanceof GLFWCharCallback
? (GLFWCharCallback)instance
: new Container(functionPointer, instance);
}
/** Like {@link #create(long) create}, but returns {@code null} if {@code functionPointer} is {@code NULL}. */
@Nullable
public static GLFWCharCallback createSafe(long functionPointer) {
return functionPointer == NULL ? null : create(functionPointer);
}
/** Creates a {@code GLFWCharCallback} instance that delegates to the specified {@code GLFWCharCallbackI} instance. */
public static GLFWCharCallback create(GLFWCharCallbackI instance) {
return instance instanceof GLFWCharCallback
? (GLFWCharCallback)instance
: new Container(instance.address(), instance);
}
protected GLFWCharCallback() {
super(CIF);
}
GLFWCharCallback(long functionPointer) {
super(functionPointer);
}
/** See {@link GLFW#glfwSetCharCallback SetCharCallback}. */
public GLFWCharCallback set(long window) {
glfwSetCharCallback(window, this);
return this;
}
private static final class Container extends GLFWCharCallback {
private final GLFWCharCallbackI delegate;
Container(long functionPointer, GLFWCharCallbackI delegate) {
super(functionPointer);
this.delegate = delegate;
}
@Override
public void invoke(long window, int codepoint) {
delegate.invoke(window, codepoint);
}
}
}

View File

@ -1,57 +0,0 @@
/*
* Copyright LWJGL. All rights reserved.
* License terms: https://www.lwjgl.org/license
* MACHINE GENERATED FILE, DO NOT EDIT
*/
package org.lwjgl.glfw;
import org.lwjgl.system.*;
import org.lwjgl.system.libffi.*;
import static org.lwjgl.system.APIUtil.*;
import static org.lwjgl.system.MemoryUtil.*;
import static org.lwjgl.system.libffi.LibFFI.*;
/**
* Instances of this interface may be passed to the {@link GLFW#glfwSetCharCallback SetCharCallback} method.
*
* <h3>Type</h3>
*
* <pre><code>
* void (*{@link #invoke}) (
* GLFWwindow *window,
* unsigned int codepoint
* )</code></pre>
*
* @since version 2.4
*/
@FunctionalInterface
@NativeType("GLFWcharfun")
public interface GLFWCharCallbackI extends CallbackI {
FFICIF CIF = apiCreateCIF(
FFI_DEFAULT_ABI,
ffi_type_void,
ffi_type_pointer, ffi_type_uint32
);
@Override
default FFICIF getCallInterface() { return CIF; }
@Override
default void callback(long ret, long args) {
invoke(
memGetAddress(memGetAddress(args)),
memGetInt(memGetAddress(args + POINTER_SIZE))
);
}
/**
* Will be called when a Unicode character is input.
*
* @param window the window that received the event
* @param codepoint the Unicode code point of the character
*/
void invoke(@NativeType("GLFWwindow *") long window, @NativeType("unsigned int") int codepoint);
}

View File

@ -1,89 +0,0 @@
/*
* Copyright LWJGL. All rights reserved.
* License terms: https://www.lwjgl.org/license
* MACHINE GENERATED FILE, DO NOT EDIT
*/
package org.lwjgl.glfw;
import javax.annotation.*;
import org.lwjgl.system.*;
import static org.lwjgl.system.MemoryUtil.*;
import static org.lwjgl.glfw.GLFW.*;
/**
* Instances of this class may be passed to the {@link GLFW#glfwSetCharModsCallback SetCharModsCallback} method.
*
* <p>Deprecared: scheduled for removal in version 4.0.</p>
*
* <h3>Type</h3>
*
* <pre><code>
* void (*{@link #invoke}) (
* GLFWwindow *window,
* unsigned int codepoint,
* int mods
* )</code></pre>
*
* @since version 3.1
*/
public abstract class GLFWCharModsCallback extends Callback implements GLFWCharModsCallbackI {
/**
* Creates a {@code GLFWCharModsCallback} instance from the specified function pointer.
*
* @return the new {@code GLFWCharModsCallback}
*/
public static GLFWCharModsCallback create(long functionPointer) {
GLFWCharModsCallbackI instance = Callback.get(functionPointer);
return instance instanceof GLFWCharModsCallback
? (GLFWCharModsCallback)instance
: new Container(functionPointer, instance);
}
/** Like {@link #create(long) create}, but returns {@code null} if {@code functionPointer} is {@code NULL}. */
@Nullable
public static GLFWCharModsCallback createSafe(long functionPointer) {
return functionPointer == NULL ? null : create(functionPointer);
}
/** Creates a {@code GLFWCharModsCallback} instance that delegates to the specified {@code GLFWCharModsCallbackI} instance. */
public static GLFWCharModsCallback create(GLFWCharModsCallbackI instance) {
return instance instanceof GLFWCharModsCallback
? (GLFWCharModsCallback)instance
: new Container(instance.address(), instance);
}
protected GLFWCharModsCallback() {
super(CIF);
}
GLFWCharModsCallback(long functionPointer) {
super(functionPointer);
}
/** See {@link GLFW#glfwSetCharModsCallback SetCharModsCallback}. */
public GLFWCharModsCallback set(long window) {
glfwSetCharModsCallback(window, this);
return this;
}
private static final class Container extends GLFWCharModsCallback {
private final GLFWCharModsCallbackI delegate;
Container(long functionPointer, GLFWCharModsCallbackI delegate) {
super(functionPointer);
this.delegate = delegate;
}
@Override
public void invoke(long window, int codepoint, int mods) {
delegate.invoke(window, codepoint, mods);
}
}
}

View File

@ -1,62 +0,0 @@
/*
* Copyright LWJGL. All rights reserved.
* License terms: https://www.lwjgl.org/license
* MACHINE GENERATED FILE, DO NOT EDIT
*/
package org.lwjgl.glfw;
import org.lwjgl.system.*;
import org.lwjgl.system.libffi.*;
import static org.lwjgl.system.APIUtil.*;
import static org.lwjgl.system.MemoryUtil.*;
import static org.lwjgl.system.libffi.LibFFI.*;
/**
* Instances of this interface may be passed to the {@link GLFW#glfwSetCharModsCallback SetCharModsCallback} method.
*
* <p>Deprecared: scheduled for removal in version 4.0.</p>
*
* <h3>Type</h3>
*
* <pre><code>
* void (*{@link #invoke}) (
* GLFWwindow *window,
* unsigned int codepoint,
* int mods
* )</code></pre>
*
* @since version 3.1
*/
@FunctionalInterface
@NativeType("GLFWcharmodsfun")
public interface GLFWCharModsCallbackI extends CallbackI {
FFICIF CIF = apiCreateCIF(
FFI_DEFAULT_ABI,
ffi_type_void,
ffi_type_pointer, ffi_type_uint32, ffi_type_sint32
);
@Override
default FFICIF getCallInterface() { return CIF; }
@Override
default void callback(long ret, long args) {
invoke(
memGetAddress(memGetAddress(args)),
memGetInt(memGetAddress(args + POINTER_SIZE)),
memGetInt(memGetAddress(args + 2 * POINTER_SIZE))
);
}
/**
* Will be called when a Unicode character is input regardless of what modifier keys are used.
*
* @param window the window that received the event
* @param codepoint the Unicode code point of the character
* @param mods bitfield describing which modifier keys were held down
*/
void invoke(@NativeType("GLFWwindow *") long window, @NativeType("unsigned int") int codepoint, int mods);
}

View File

@ -1,86 +0,0 @@
/*
* Copyright LWJGL. All rights reserved.
* License terms: https://www.lwjgl.org/license
* MACHINE GENERATED FILE, DO NOT EDIT
*/
package org.lwjgl.glfw;
import javax.annotation.*;
import org.lwjgl.system.*;
import static org.lwjgl.system.MemoryUtil.*;
import static org.lwjgl.glfw.GLFW.*;
/**
* Instances of this class may be passed to the {@link GLFW#glfwSetCursorEnterCallback SetCursorEnterCallback} method.
*
* <h3>Type</h3>
*
* <pre><code>
* void (*{@link #invoke}) (
* GLFWwindow *window,
* int entered
* )</code></pre>
*
* @since version 3.0
*/
public abstract class GLFWCursorEnterCallback extends Callback implements GLFWCursorEnterCallbackI {
/**
* Creates a {@code GLFWCursorEnterCallback} instance from the specified function pointer.
*
* @return the new {@code GLFWCursorEnterCallback}
*/
public static GLFWCursorEnterCallback create(long functionPointer) {
GLFWCursorEnterCallbackI instance = Callback.get(functionPointer);
return instance instanceof GLFWCursorEnterCallback
? (GLFWCursorEnterCallback)instance
: new Container(functionPointer, instance);
}
/** Like {@link #create(long) create}, but returns {@code null} if {@code functionPointer} is {@code NULL}. */
@Nullable
public static GLFWCursorEnterCallback createSafe(long functionPointer) {
return functionPointer == NULL ? null : create(functionPointer);
}
/** Creates a {@code GLFWCursorEnterCallback} instance that delegates to the specified {@code GLFWCursorEnterCallbackI} instance. */
public static GLFWCursorEnterCallback create(GLFWCursorEnterCallbackI instance) {
return instance instanceof GLFWCursorEnterCallback
? (GLFWCursorEnterCallback)instance
: new Container(instance.address(), instance);
}
protected GLFWCursorEnterCallback() {
super(CIF);
}
GLFWCursorEnterCallback(long functionPointer) {
super(functionPointer);
}
/** See {@link GLFW#glfwSetCursorEnterCallback SetCursorEnterCallback}. */
public GLFWCursorEnterCallback set(long window) {
glfwSetCursorEnterCallback(window, this);
return this;
}
private static final class Container extends GLFWCursorEnterCallback {
private final GLFWCursorEnterCallbackI delegate;
Container(long functionPointer, GLFWCursorEnterCallbackI delegate) {
super(functionPointer);
this.delegate = delegate;
}
@Override
public void invoke(long window, boolean entered) {
delegate.invoke(window, entered);
}
}
}

View File

@ -1,57 +0,0 @@
/*
* Copyright LWJGL. All rights reserved.
* License terms: https://www.lwjgl.org/license
* MACHINE GENERATED FILE, DO NOT EDIT
*/
package org.lwjgl.glfw;
import org.lwjgl.system.*;
import org.lwjgl.system.libffi.*;
import static org.lwjgl.system.APIUtil.*;
import static org.lwjgl.system.MemoryUtil.*;
import static org.lwjgl.system.libffi.LibFFI.*;
/**
* Instances of this interface may be passed to the {@link GLFW#glfwSetCursorEnterCallback SetCursorEnterCallback} method.
*
* <h3>Type</h3>
*
* <pre><code>
* void (*{@link #invoke}) (
* GLFWwindow *window,
* int entered
* )</code></pre>
*
* @since version 3.0
*/
@FunctionalInterface
@NativeType("GLFWcursorenterfun")
public interface GLFWCursorEnterCallbackI extends CallbackI {
FFICIF CIF = apiCreateCIF(
FFI_DEFAULT_ABI,
ffi_type_void,
ffi_type_pointer, ffi_type_uint32
);
@Override
default FFICIF getCallInterface() { return CIF; }
@Override
default void callback(long ret, long args) {
invoke(
memGetAddress(memGetAddress(args)),
memGetInt(memGetAddress(args + POINTER_SIZE)) != 0
);
}
/**
* Will be called when the cursor enters or leaves the client area of the window.
*
* @param window the window that received the event
* @param entered {@link GLFW#GLFW_TRUE TRUE} if the cursor entered the window's content area, or {@link GLFW#GLFW_FALSE FALSE} if it left it
*/
void invoke(@NativeType("GLFWwindow *") long window, @NativeType("int") boolean entered);
}

View File

@ -1,87 +0,0 @@
/*
* Copyright LWJGL. All rights reserved.
* License terms: https://www.lwjgl.org/license
* MACHINE GENERATED FILE, DO NOT EDIT
*/
package org.lwjgl.glfw;
import javax.annotation.*;
import org.lwjgl.system.*;
import static org.lwjgl.system.MemoryUtil.*;
import static org.lwjgl.glfw.GLFW.*;
/**
* Instances of this class may be passed to the {@link GLFW#glfwSetCursorPosCallback SetCursorPosCallback} method.
*
* <h3>Type</h3>
*
* <pre><code>
* void (*{@link #invoke}) (
* GLFWwindow *window,
* double xpos,
* double ypos
* )</code></pre>
*
* @since version 3.0
*/
public abstract class GLFWCursorPosCallback extends Callback implements GLFWCursorPosCallbackI {
/**
* Creates a {@code GLFWCursorPosCallback} instance from the specified function pointer.
*
* @return the new {@code GLFWCursorPosCallback}
*/
public static GLFWCursorPosCallback create(long functionPointer) {
GLFWCursorPosCallbackI instance = Callback.get(functionPointer);
return instance instanceof GLFWCursorPosCallback
? (GLFWCursorPosCallback)instance
: new Container(functionPointer, instance);
}
/** Like {@link #create(long) create}, but returns {@code null} if {@code functionPointer} is {@code NULL}. */
@Nullable
public static GLFWCursorPosCallback createSafe(long functionPointer) {
return functionPointer == NULL ? null : create(functionPointer);
}
/** Creates a {@code GLFWCursorPosCallback} instance that delegates to the specified {@code GLFWCursorPosCallbackI} instance. */
public static GLFWCursorPosCallback create(GLFWCursorPosCallbackI instance) {
return instance instanceof GLFWCursorPosCallback
? (GLFWCursorPosCallback)instance
: new Container(instance.address(), instance);
}
protected GLFWCursorPosCallback() {
super(CIF);
}
GLFWCursorPosCallback(long functionPointer) {
super(functionPointer);
}
/** See {@link GLFW#glfwSetCursorPosCallback SetCursorPosCallback}. */
public GLFWCursorPosCallback set(long window) {
glfwSetCursorPosCallback(window, this);
return this;
}
private static final class Container extends GLFWCursorPosCallback {
private final GLFWCursorPosCallbackI delegate;
Container(long functionPointer, GLFWCursorPosCallbackI delegate) {
super(functionPointer);
this.delegate = delegate;
}
@Override
public void invoke(long window, double xpos, double ypos) {
delegate.invoke(window, xpos, ypos);
}
}
}

View File

@ -1,63 +0,0 @@
/*
* Copyright LWJGL. All rights reserved.
* License terms: https://www.lwjgl.org/license
* MACHINE GENERATED FILE, DO NOT EDIT
*/
package org.lwjgl.glfw;
import org.lwjgl.system.*;
import org.lwjgl.system.libffi.*;
import static org.lwjgl.system.APIUtil.*;
import static org.lwjgl.system.MemoryUtil.*;
import static org.lwjgl.system.libffi.LibFFI.*;
/**
* Instances of this interface may be passed to the {@link GLFW#glfwSetCursorPosCallback SetCursorPosCallback} method.
*
* <h3>Type</h3>
*
* <pre><code>
* void (*{@link #invoke}) (
* GLFWwindow *window,
* double xpos,
* double ypos
* )</code></pre>
*
* @since version 3.0
*/
@FunctionalInterface
@NativeType("GLFWcursorposfun")
public interface GLFWCursorPosCallbackI extends CallbackI {
FFICIF CIF = apiCreateCIF(
FFI_DEFAULT_ABI,
ffi_type_void,
ffi_type_pointer, ffi_type_double, ffi_type_double
);
@Override
default FFICIF getCallInterface() { return CIF; }
@Override
default void callback(long ret, long args) {
invoke(
memGetAddress(memGetAddress(args)),
memGetDouble(memGetAddress(args + POINTER_SIZE)),
memGetDouble(memGetAddress(args + 2 * POINTER_SIZE))
);
}
/**
* Will be called when the cursor is moved.
*
* <p>The callback function receives the cursor position, measured in screen coordinates but relative to the top-left corner of the window client area. On
* platforms that provide it, the full sub-pixel cursor position is passed on.</p>
*
* @param window the window that received the event
* @param xpos the new cursor x-coordinate, relative to the left edge of the content area
* @param ypos the new cursor y-coordinate, relative to the top edge of the content area
*/
void invoke(@NativeType("GLFWwindow *") long window, double xpos, double ypos);
}

View File

@ -1,98 +0,0 @@
/*
* Copyright LWJGL. All rights reserved.
* License terms: https://www.lwjgl.org/license
* MACHINE GENERATED FILE, DO NOT EDIT
*/
package org.lwjgl.glfw;
import javax.annotation.*;
import org.lwjgl.system.*;
import static org.lwjgl.system.MemoryUtil.*;
/**
* The function pointer type for memory deallocation callbacks.
*
* <p>This is the function pointer type for memory deallocation callbacks. A memory deallocation callback function has the following signature:</p>
*
* <pre><code>
* void function_name(void* block, void* user)</code></pre>
*
* <p>This function may deallocate the specified memory block. This memory block will have been allocated with the same allocator.</p>
*
* <p>This function may be called during {@link GLFW#glfwInit Init} but before the library is flagged as initialized, as well as during {@link GLFW#glfwTerminate Terminate} after the library is no
* longer flagged as initialized.</p>
*
* <p>The block address will never be {@code NULL}. Deallocations of {@code NULL} are filtered out before reaching the custom allocator.</p>
*
* <div style="margin-left: 26px; border-left: 1px solid gray; padding-left: 14px;"><h5>Note</h5>
*
* <ul>
* <li>The specified memory block will not be accessed by GLFW after this function is called.</li>
* <li>This function should not call any GLFW function.</li>
* <li>This function may be called from any thread that calls GLFW functions.</li>
* </ul></div>
*
* <h3>Type</h3>
*
* <pre><code>
* void (*{@link #invoke}) (
* void *block,
* void *user
* )</code></pre>
*
* @since version 3.4
*/
public abstract class GLFWDeallocateCallback extends Callback implements GLFWDeallocateCallbackI {
/**
* Creates a {@code GLFWDeallocateCallback} instance from the specified function pointer.
*
* @return the new {@code GLFWDeallocateCallback}
*/
public static GLFWDeallocateCallback create(long functionPointer) {
GLFWDeallocateCallbackI instance = Callback.get(functionPointer);
return instance instanceof GLFWDeallocateCallback
? (GLFWDeallocateCallback)instance
: new Container(functionPointer, instance);
}
/** Like {@link #create(long) create}, but returns {@code null} if {@code functionPointer} is {@code NULL}. */
@Nullable
public static GLFWDeallocateCallback createSafe(long functionPointer) {
return functionPointer == NULL ? null : create(functionPointer);
}
/** Creates a {@code GLFWDeallocateCallback} instance that delegates to the specified {@code GLFWDeallocateCallbackI} instance. */
public static GLFWDeallocateCallback create(GLFWDeallocateCallbackI instance) {
return instance instanceof GLFWDeallocateCallback
? (GLFWDeallocateCallback)instance
: new Container(instance.address(), instance);
}
protected GLFWDeallocateCallback() {
super(CIF);
}
GLFWDeallocateCallback(long functionPointer) {
super(functionPointer);
}
private static final class Container extends GLFWDeallocateCallback {
private final GLFWDeallocateCallbackI delegate;
Container(long functionPointer, GLFWDeallocateCallbackI delegate) {
super(functionPointer);
this.delegate = delegate;
}
@Override
public void invoke(long block, long user) {
delegate.invoke(block, user);
}
}
}

View File

@ -1,77 +0,0 @@
/*
* Copyright LWJGL. All rights reserved.
* License terms: https://www.lwjgl.org/license
* MACHINE GENERATED FILE, DO NOT EDIT
*/
package org.lwjgl.glfw;
import org.lwjgl.system.*;
import org.lwjgl.system.libffi.*;
import static org.lwjgl.system.APIUtil.*;
import static org.lwjgl.system.MemoryUtil.*;
import static org.lwjgl.system.libffi.LibFFI.*;
/**
* The function pointer type for memory deallocation callbacks.
*
* <p>This is the function pointer type for memory deallocation callbacks. A memory deallocation callback function has the following signature:</p>
*
* <pre><code>
* void function_name(void* block, void* user)</code></pre>
*
* <p>This function may deallocate the specified memory block. This memory block will have been allocated with the same allocator.</p>
*
* <p>This function may be called during {@link GLFW#glfwInit Init} but before the library is flagged as initialized, as well as during {@link GLFW#glfwTerminate Terminate} after the library is no
* longer flagged as initialized.</p>
*
* <p>The block address will never be {@code NULL}. Deallocations of {@code NULL} are filtered out before reaching the custom allocator.</p>
*
* <div style="margin-left: 26px; border-left: 1px solid gray; padding-left: 14px;"><h5>Note</h5>
*
* <ul>
* <li>The specified memory block will not be accessed by GLFW after this function is called.</li>
* <li>This function should not call any GLFW function.</li>
* <li>This function may be called from any thread that calls GLFW functions.</li>
* </ul></div>
*
* <h3>Type</h3>
*
* <pre><code>
* void (*{@link #invoke}) (
* void *block,
* void *user
* )</code></pre>
*
* @since version 3.4
*/
@FunctionalInterface
@NativeType("GLFWdeallocatefun")
public interface GLFWDeallocateCallbackI extends CallbackI {
FFICIF CIF = apiCreateCIF(
FFI_DEFAULT_ABI,
ffi_type_void,
ffi_type_pointer, ffi_type_pointer
);
@Override
default FFICIF getCallInterface() { return CIF; }
@Override
default void callback(long ret, long args) {
invoke(
memGetAddress(memGetAddress(args)),
memGetAddress(memGetAddress(args + POINTER_SIZE))
);
}
/**
* Will be called for memory deallocation requests.
*
* @param block the address of the memory block to deallocate
* @param user the user-defined pointer from the allocator
*/
void invoke(@NativeType("void *") long block, @NativeType("void *") long user);
}

View File

@ -1,101 +0,0 @@
/*
* Copyright LWJGL. All rights reserved.
* License terms: https://www.lwjgl.org/license
* MACHINE GENERATED FILE, DO NOT EDIT
*/
package org.lwjgl.glfw;
import javax.annotation.*;
import org.lwjgl.system.*;
import static org.lwjgl.system.MemoryUtil.*;
import static org.lwjgl.glfw.GLFW.*;
/**
* Instances of this class may be passed to the {@link GLFW#glfwSetDropCallback SetDropCallback} method.
*
* <h3>Type</h3>
*
* <pre><code>
* void (*{@link #invoke}) (
* GLFWwindow *window,
* int count,
* char const **names
* )</code></pre>
*
* @since version 3.1
*/
public abstract class GLFWDropCallback extends Callback implements GLFWDropCallbackI {
/**
* Creates a {@code GLFWDropCallback} instance from the specified function pointer.
*
* @return the new {@code GLFWDropCallback}
*/
public static GLFWDropCallback create(long functionPointer) {
GLFWDropCallbackI instance = Callback.get(functionPointer);
return instance instanceof GLFWDropCallback
? (GLFWDropCallback)instance
: new Container(functionPointer, instance);
}
/** Like {@link #create(long) create}, but returns {@code null} if {@code functionPointer} is {@code NULL}. */
@Nullable
public static GLFWDropCallback createSafe(long functionPointer) {
return functionPointer == NULL ? null : create(functionPointer);
}
/** Creates a {@code GLFWDropCallback} instance that delegates to the specified {@code GLFWDropCallbackI} instance. */
public static GLFWDropCallback create(GLFWDropCallbackI instance) {
return instance instanceof GLFWDropCallback
? (GLFWDropCallback)instance
: new Container(instance.address(), instance);
}
protected GLFWDropCallback() {
super(CIF);
}
GLFWDropCallback(long functionPointer) {
super(functionPointer);
}
/**
* Decodes the specified {@link GLFWDropCallback} arguments to a String.
*
* <p>This method may only be used inside a {@code GLFWDropCallback} invocation.</p>
*
* @param names pointer to the array of UTF-8 encoded path names of the dropped files
* @param index the index to decode
*
* @return the name at the specified index as a String
*/
public static String getName(long names, int index) {
return memUTF8(memGetAddress(names + Pointer.POINTER_SIZE * index));
}
/** See {@link GLFW#glfwSetDropCallback SetDropCallback}. */
public GLFWDropCallback set(long window) {
glfwSetDropCallback(window, this);
return this;
}
private static final class Container extends GLFWDropCallback {
private final GLFWDropCallbackI delegate;
Container(long functionPointer, GLFWDropCallbackI delegate) {
super(functionPointer);
this.delegate = delegate;
}
@Override
public void invoke(long window, int count, long names) {
delegate.invoke(window, count, names);
}
}
}

View File

@ -1,60 +0,0 @@
/*
* Copyright LWJGL. All rights reserved.
* License terms: https://www.lwjgl.org/license
* MACHINE GENERATED FILE, DO NOT EDIT
*/
package org.lwjgl.glfw;
import org.lwjgl.system.*;
import org.lwjgl.system.libffi.*;
import static org.lwjgl.system.APIUtil.*;
import static org.lwjgl.system.MemoryUtil.*;
import static org.lwjgl.system.libffi.LibFFI.*;
/**
* Instances of this interface may be passed to the {@link GLFW#glfwSetDropCallback SetDropCallback} method.
*
* <h3>Type</h3>
*
* <pre><code>
* void (*{@link #invoke}) (
* GLFWwindow *window,
* int count,
* char const **names
* )</code></pre>
*
* @since version 3.1
*/
@FunctionalInterface
@NativeType("GLFWdropfun")
public interface GLFWDropCallbackI extends CallbackI {
FFICIF CIF = apiCreateCIF(
FFI_DEFAULT_ABI,
ffi_type_void,
ffi_type_pointer, ffi_type_sint32, ffi_type_pointer
);
@Override
default FFICIF getCallInterface() { return CIF; }
@Override
default void callback(long ret, long args) {
invoke(
memGetAddress(memGetAddress(args)),
memGetInt(memGetAddress(args + POINTER_SIZE)),
memGetAddress(memGetAddress(args + 2 * POINTER_SIZE))
);
}
/**
* Will be called when one or more dragged files are dropped on the window.
*
* @param window the window that received the event
* @param count the number of dropped files
* @param names pointer to the array of UTF-8 encoded path names of the dropped files
*/
void invoke(@NativeType("GLFWwindow *") long window, int count, @NativeType("char const **") long names);
}

View File

@ -1,162 +0,0 @@
/*
* Copyright LWJGL. All rights reserved.
* License terms: https://www.lwjgl.org/license
* MACHINE GENERATED FILE, DO NOT EDIT
*/
package org.lwjgl.glfw;
import javax.annotation.*;
import org.lwjgl.system.*;
import static org.lwjgl.system.MemoryUtil.*;
import java.io.PrintStream;
import java.util.Map;
import static org.lwjgl.glfw.GLFW.*;
/**
* Instances of this class may be passed to the {@link GLFW#glfwSetErrorCallback SetErrorCallback} method.
*
* <h3>Type</h3>
*
* <pre><code>
* void (*{@link #invoke}) (
* int error,
* char *description
* )</code></pre>
*
* @since version 3.0
*/
public abstract class GLFWErrorCallback extends Callback implements GLFWErrorCallbackI {
/**
* Creates a {@code GLFWErrorCallback} instance from the specified function pointer.
*
* @return the new {@code GLFWErrorCallback}
*/
public static GLFWErrorCallback create(long functionPointer) {
GLFWErrorCallbackI instance = Callback.get(functionPointer);
return instance instanceof GLFWErrorCallback
? (GLFWErrorCallback)instance
: new Container(functionPointer, instance);
}
/** Like {@link #create(long) create}, but returns {@code null} if {@code functionPointer} is {@code NULL}. */
@Nullable
public static GLFWErrorCallback createSafe(long functionPointer) {
return functionPointer == NULL ? null : create(functionPointer);
}
/** Creates a {@code GLFWErrorCallback} instance that delegates to the specified {@code GLFWErrorCallbackI} instance. */
public static GLFWErrorCallback create(GLFWErrorCallbackI instance) {
return instance instanceof GLFWErrorCallback
? (GLFWErrorCallback)instance
: new Container(instance.address(), instance);
}
protected GLFWErrorCallback() {
super(CIF);
}
GLFWErrorCallback(long functionPointer) {
super(functionPointer);
}
/**
* Converts the specified {@code GLFWErrorCallback} argument to a String.
*
* <p>This method may only be used inside a GLFWErrorCallback invocation.</p>
*
* @param description pointer to the UTF-8 encoded description string
*
* @return the description as a String
*/
public static String getDescription(long description) {
return memUTF8(description);
}
/**
* Returns a {@code GLFWErrorCallback} instance that prints the error to the {@link APIUtil#DEBUG_STREAM}.
*
* @return the GLFWerrorCallback
*/
public static GLFWErrorCallback createPrint() {
return createPrint(APIUtil.DEBUG_STREAM);
}
/**
* Returns a {@code GLFWErrorCallback} instance that prints the error in the specified {@link PrintStream}.
*
* @param stream the PrintStream to use
*
* @return the GLFWerrorCallback
*/
public static GLFWErrorCallback createPrint(PrintStream stream) {
return new GLFWErrorCallback() {
private Map<Integer, String> ERROR_CODES = APIUtil.apiClassTokens((field, value) -> 0x10000 < value && value < 0x20000, null, GLFW.class);
@Override
public void invoke(int error, long description) {
String msg = getDescription(description);
StringBuilder sb = new StringBuilder(512);
sb
.append("[LWJGL] ")
.append(ERROR_CODES.get(error))
.append(" error\n")
.append("\tDescription : ")
.append(msg)
.append("\n")
.append("\tStacktrace :\n");
StackTraceElement[] stack = Thread.currentThread().getStackTrace();
for (int i = 4; i < stack.length; i++) {
sb.append("\t\t");
sb.append(stack[i]);
sb.append("\n");
}
stream.print(sb);
}
};
}
/**
* Returns a {@code GLFWErrorCallback} instance that throws an {@link IllegalStateException} when an error occurs.
*
* @return the GLFWerrorCallback
*/
public static GLFWErrorCallback createThrow() {
return new GLFWErrorCallback() {
@Override
public void invoke(int error, long description) {
throw new IllegalStateException(String.format("GLFW error [0x%X]: %s", error, getDescription(description)));
}
};
}
/** See {@link GLFW#glfwSetErrorCallback SetErrorCallback}. */
public GLFWErrorCallback set() {
glfwSetErrorCallback(this);
return this;
}
private static final class Container extends GLFWErrorCallback {
private final GLFWErrorCallbackI delegate;
Container(long functionPointer, GLFWErrorCallbackI delegate) {
super(functionPointer);
this.delegate = delegate;
}
@Override
public void invoke(int error, long description) {
delegate.invoke(error, description);
}
}
}

View File

@ -1,57 +0,0 @@
/*
* Copyright LWJGL. All rights reserved.
* License terms: https://www.lwjgl.org/license
* MACHINE GENERATED FILE, DO NOT EDIT
*/
package org.lwjgl.glfw;
import org.lwjgl.system.*;
import org.lwjgl.system.libffi.*;
import static org.lwjgl.system.APIUtil.*;
import static org.lwjgl.system.MemoryUtil.*;
import static org.lwjgl.system.libffi.LibFFI.*;
/**
* Instances of this interface may be passed to the {@link GLFW#glfwSetErrorCallback SetErrorCallback} method.
*
* <h3>Type</h3>
*
* <pre><code>
* void (*{@link #invoke}) (
* int error,
* char *description
* )</code></pre>
*
* @since version 3.0
*/
@FunctionalInterface
@NativeType("GLFWerrorfun")
public interface GLFWErrorCallbackI extends CallbackI {
FFICIF CIF = apiCreateCIF(
FFI_DEFAULT_ABI,
ffi_type_void,
ffi_type_sint32, ffi_type_pointer
);
@Override
default FFICIF getCallInterface() { return CIF; }
@Override
default void callback(long ret, long args) {
invoke(
memGetInt(memGetAddress(args)),
memGetAddress(memGetAddress(args + POINTER_SIZE))
);
}
/**
* Will be called with an error code and a human-readable description when a GLFW error occurs.
*
* @param error the error code
* @param description a pointer to a UTF-8 encoded string describing the error
*/
void invoke(int error, @NativeType("char *") long description);
}

View File

@ -1,87 +0,0 @@
/*
* Copyright LWJGL. All rights reserved.
* License terms: https://www.lwjgl.org/license
* MACHINE GENERATED FILE, DO NOT EDIT
*/
package org.lwjgl.glfw;
import javax.annotation.*;
import org.lwjgl.system.*;
import static org.lwjgl.system.MemoryUtil.*;
import static org.lwjgl.glfw.GLFW.*;
/**
* Instances of this class may be passed to the {@link GLFW#glfwSetFramebufferSizeCallback SetFramebufferSizeCallback} method.
*
* <h3>Type</h3>
*
* <pre><code>
* void (*{@link #invoke}) (
* GLFWwindow *window,
* int width,
* int height
* )</code></pre>
*
* @since version 3.0
*/
public abstract class GLFWFramebufferSizeCallback extends Callback implements GLFWFramebufferSizeCallbackI {
/**
* Creates a {@code GLFWFramebufferSizeCallback} instance from the specified function pointer.
*
* @return the new {@code GLFWFramebufferSizeCallback}
*/
public static GLFWFramebufferSizeCallback create(long functionPointer) {
GLFWFramebufferSizeCallbackI instance = Callback.get(functionPointer);
return instance instanceof GLFWFramebufferSizeCallback
? (GLFWFramebufferSizeCallback)instance
: new Container(functionPointer, instance);
}
/** Like {@link #create(long) create}, but returns {@code null} if {@code functionPointer} is {@code NULL}. */
@Nullable
public static GLFWFramebufferSizeCallback createSafe(long functionPointer) {
return functionPointer == NULL ? null : create(functionPointer);
}
/** Creates a {@code GLFWFramebufferSizeCallback} instance that delegates to the specified {@code GLFWFramebufferSizeCallbackI} instance. */
public static GLFWFramebufferSizeCallback create(GLFWFramebufferSizeCallbackI instance) {
return instance instanceof GLFWFramebufferSizeCallback
? (GLFWFramebufferSizeCallback)instance
: new Container(instance.address(), instance);
}
protected GLFWFramebufferSizeCallback() {
super(CIF);
}
GLFWFramebufferSizeCallback(long functionPointer) {
super(functionPointer);
}
/** See {@link GLFW#glfwSetFramebufferSizeCallback SetFramebufferSizeCallback}. */
public GLFWFramebufferSizeCallback set(long window) {
glfwSetFramebufferSizeCallback(window, this);
return this;
}
private static final class Container extends GLFWFramebufferSizeCallback {
private final GLFWFramebufferSizeCallbackI delegate;
Container(long functionPointer, GLFWFramebufferSizeCallbackI delegate) {
super(functionPointer);
this.delegate = delegate;
}
@Override
public void invoke(long window, int width, int height) {
delegate.invoke(window, width, height);
}
}
}

View File

@ -1,60 +0,0 @@
/*
* Copyright LWJGL. All rights reserved.
* License terms: https://www.lwjgl.org/license
* MACHINE GENERATED FILE, DO NOT EDIT
*/
package org.lwjgl.glfw;
import org.lwjgl.system.*;
import org.lwjgl.system.libffi.*;
import static org.lwjgl.system.APIUtil.*;
import static org.lwjgl.system.MemoryUtil.*;
import static org.lwjgl.system.libffi.LibFFI.*;
/**
* Instances of this interface may be passed to the {@link GLFW#glfwSetFramebufferSizeCallback SetFramebufferSizeCallback} method.
*
* <h3>Type</h3>
*
* <pre><code>
* void (*{@link #invoke}) (
* GLFWwindow *window,
* int width,
* int height
* )</code></pre>
*
* @since version 3.0
*/
@FunctionalInterface
@NativeType("GLFWframebuffersizefun")
public interface GLFWFramebufferSizeCallbackI extends CallbackI {
FFICIF CIF = apiCreateCIF(
FFI_DEFAULT_ABI,
ffi_type_void,
ffi_type_pointer, ffi_type_sint32, ffi_type_sint32
);
@Override
default FFICIF getCallInterface() { return CIF; }
@Override
default void callback(long ret, long args) {
invoke(
memGetAddress(memGetAddress(args)),
memGetInt(memGetAddress(args + POINTER_SIZE)),
memGetInt(memGetAddress(args + 2 * POINTER_SIZE))
);
}
/**
* Will be called when the framebuffer of the specified window is resized.
*
* @param window the window whose framebuffer was resized
* @param width the new width, in pixels, of the framebuffer
* @param height the new height, in pixels, of the framebuffer
*/
void invoke(@NativeType("GLFWwindow *") long window, int width, int height);
}

View File

@ -1,350 +0,0 @@
/*
* Copyright LWJGL. All rights reserved.
* License terms: https://www.lwjgl.org/license
* MACHINE GENERATED FILE, DO NOT EDIT
*/
package org.lwjgl.glfw;
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.*;
/**
* Describes the input state of a gamepad.
*
* <h3>Layout</h3>
*
* <pre><code>
* struct GLFWgamepadstate {
* unsigned char {@link #buttons}[15];
* float {@link #axes}[6];
* }</code></pre>
*
* @since version 3.3
*/
@NativeType("struct GLFWgamepadstate")
public class GLFWGamepadState extends Struct<GLFWGamepadState> 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
BUTTONS,
AXES;
static {
Layout layout = __struct(
__array(1, 15),
__array(4, 6)
);
SIZEOF = layout.getSize();
ALIGNOF = layout.getAlignment();
BUTTONS = layout.offsetof(0);
AXES = layout.offsetof(1);
}
protected GLFWGamepadState(long address, @Nullable ByteBuffer container) {
super(address, container);
}
@Override
protected GLFWGamepadState create(long address, @Nullable ByteBuffer container) {
return new GLFWGamepadState(address, container);
}
/**
* Creates a {@code GLFWGamepadState} 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.
*
* <p>The created instance holds a strong reference to the container object.</p>
*/
public GLFWGamepadState(ByteBuffer container) {
super(memAddress(container), __checkContainer(container, SIZEOF));
}
@Override
public int sizeof() { return SIZEOF; }
/** the states of each gamepad button, {@link GLFW#GLFW_PRESS PRESS} or {@link GLFW#GLFW_RELEASE RELEASE} */
@NativeType("unsigned char[15]")
public ByteBuffer buttons() { return nbuttons(address()); }
/** the states of each gamepad button, {@link GLFW#GLFW_PRESS PRESS} or {@link GLFW#GLFW_RELEASE RELEASE} */
@NativeType("unsigned char")
public byte buttons(int index) { return nbuttons(address(), index); }
/** the states of each gamepad axis, in the range -1.0 to 1.0 inclusive */
@NativeType("float[6]")
public FloatBuffer axes() { return naxes(address()); }
/** the states of each gamepad axis, in the range -1.0 to 1.0 inclusive */
public float axes(int index) { return naxes(address(), index); }
/** Copies the specified {@link ByteBuffer} to the {@link #buttons} field. */
public GLFWGamepadState buttons(@NativeType("unsigned char[15]") ByteBuffer value) { nbuttons(address(), value); return this; }
/** Sets the specified value at the specified index of the {@link #buttons} field. */
public GLFWGamepadState buttons(int index, @NativeType("unsigned char") byte value) { nbuttons(address(), index, value); return this; }
/** Copies the specified {@link FloatBuffer} to the {@link #axes} field. */
public GLFWGamepadState axes(@NativeType("float[6]") FloatBuffer value) { naxes(address(), value); return this; }
/** Sets the specified value at the specified index of the {@link #axes} field. */
public GLFWGamepadState axes(int index, float value) { naxes(address(), index, value); return this; }
/** Initializes this struct with the specified values. */
public GLFWGamepadState set(
ByteBuffer buttons,
FloatBuffer axes
) {
buttons(buttons);
axes(axes);
return this;
}
/**
* Copies the specified struct data to this struct.
*
* @param src the source struct
*
* @return this struct
*/
public GLFWGamepadState set(GLFWGamepadState src) {
memCopy(src.address(), address(), SIZEOF);
return this;
}
// -----------------------------------
/** Returns a new {@code GLFWGamepadState} instance allocated with {@link MemoryUtil#memAlloc memAlloc}. The instance must be explicitly freed. */
public static GLFWGamepadState malloc() {
return new GLFWGamepadState(nmemAllocChecked(SIZEOF), null);
}
/** Returns a new {@code GLFWGamepadState} instance allocated with {@link MemoryUtil#memCalloc memCalloc}. The instance must be explicitly freed. */
public static GLFWGamepadState calloc() {
return new GLFWGamepadState(nmemCallocChecked(1, SIZEOF), null);
}
/** Returns a new {@code GLFWGamepadState} instance allocated with {@link BufferUtils}. */
public static GLFWGamepadState create() {
ByteBuffer container = BufferUtils.createByteBuffer(SIZEOF);
return new GLFWGamepadState(memAddress(container), container);
}
/** Returns a new {@code GLFWGamepadState} instance for the specified memory address. */
public static GLFWGamepadState create(long address) {
return new GLFWGamepadState(address, null);
}
/** Like {@link #create(long) create}, but returns {@code null} if {@code address} is {@code NULL}. */
@Nullable
public static GLFWGamepadState createSafe(long address) {
return address == NULL ? null : new GLFWGamepadState(address, null);
}
/**
* Returns a new {@link 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 new Buffer(nmemAllocChecked(__checkMalloc(capacity, SIZEOF)), capacity);
}
/**
* Returns a new {@link 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 new Buffer(nmemCallocChecked(capacity, SIZEOF), capacity);
}
/**
* Returns a new {@link Buffer} instance allocated with {@link BufferUtils}.
*
* @param capacity the buffer capacity
*/
public static Buffer create(int capacity) {
ByteBuffer container = __create(capacity, SIZEOF);
return new Buffer(memAddress(container), container, -1, 0, capacity, capacity);
}
/**
* Create a {@link 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 new Buffer(address, capacity);
}
/** Like {@link #create(long, int) create}, but returns {@code null} if {@code address} is {@code NULL}. */
@Nullable
public static Buffer createSafe(long address, int capacity) {
return address == NULL ? null : new Buffer(address, capacity);
}
// -----------------------------------
/** Deprecated for removal in 3.4.0. Use {@link #malloc(MemoryStack)} instead. */
@Deprecated public static GLFWGamepadState mallocStack() { return malloc(stackGet()); }
/** Deprecated for removal in 3.4.0. Use {@link #calloc(MemoryStack)} instead. */
@Deprecated public static GLFWGamepadState callocStack() { return calloc(stackGet()); }
/** Deprecated for removal in 3.4.0. Use {@link #malloc(MemoryStack)} instead. */
@Deprecated public static GLFWGamepadState mallocStack(MemoryStack stack) { return malloc(stack); }
/** Deprecated for removal in 3.4.0. Use {@link #calloc(MemoryStack)} instead. */
@Deprecated public static GLFWGamepadState callocStack(MemoryStack stack) { return calloc(stack); }
/** Deprecated for removal in 3.4.0. Use {@link #malloc(int, MemoryStack)} instead. */
@Deprecated public static Buffer mallocStack(int capacity) { return malloc(capacity, stackGet()); }
/** Deprecated for removal in 3.4.0. Use {@link #calloc(int, MemoryStack)} instead. */
@Deprecated public static Buffer callocStack(int capacity) { return calloc(capacity, stackGet()); }
/** Deprecated for removal in 3.4.0. Use {@link #malloc(int, MemoryStack)} instead. */
@Deprecated public static Buffer mallocStack(int capacity, MemoryStack stack) { return malloc(capacity, stack); }
/** Deprecated for removal in 3.4.0. Use {@link #calloc(int, MemoryStack)} instead. */
@Deprecated public static Buffer callocStack(int capacity, MemoryStack stack) { return calloc(capacity, stack); }
/**
* Returns a new {@code GLFWGamepadState} instance allocated on the specified {@link MemoryStack}.
*
* @param stack the stack from which to allocate
*/
public static GLFWGamepadState malloc(MemoryStack stack) {
return new GLFWGamepadState(stack.nmalloc(ALIGNOF, SIZEOF), null);
}
/**
* Returns a new {@code GLFWGamepadState} instance allocated on the specified {@link MemoryStack} and initializes all its bits to zero.
*
* @param stack the stack from which to allocate
*/
public static GLFWGamepadState calloc(MemoryStack stack) {
return new GLFWGamepadState(stack.ncalloc(ALIGNOF, 1, SIZEOF), null);
}
/**
* Returns a new {@link Buffer} instance allocated on the specified {@link MemoryStack}.
*
* @param stack the stack from which to allocate
* @param capacity the buffer capacity
*/
public static Buffer malloc(int capacity, MemoryStack stack) {
return new Buffer(stack.nmalloc(ALIGNOF, capacity * SIZEOF), capacity);
}
/**
* Returns a new {@link 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 calloc(int capacity, MemoryStack stack) {
return new Buffer(stack.ncalloc(ALIGNOF, capacity, SIZEOF), capacity);
}
// -----------------------------------
/** Unsafe version of {@link #buttons}. */
public static ByteBuffer nbuttons(long struct) { return memByteBuffer(struct + GLFWGamepadState.BUTTONS, 15); }
/** Unsafe version of {@link #buttons(int) buttons}. */
public static byte nbuttons(long struct, int index) {
return UNSAFE.getByte(null, struct + GLFWGamepadState.BUTTONS + check(index, 15) * 1);
}
/** Unsafe version of {@link #axes}. */
public static FloatBuffer naxes(long struct) { return memFloatBuffer(struct + GLFWGamepadState.AXES, 6); }
/** Unsafe version of {@link #axes(int) axes}. */
public static float naxes(long struct, int index) {
return UNSAFE.getFloat(null, struct + GLFWGamepadState.AXES + check(index, 6) * 4);
}
/** Unsafe version of {@link #buttons(ByteBuffer) buttons}. */
public static void nbuttons(long struct, ByteBuffer value) {
if (CHECKS) { checkGT(value, 15); }
memCopy(memAddress(value), struct + GLFWGamepadState.BUTTONS, value.remaining() * 1);
}
/** Unsafe version of {@link #buttons(int, byte) buttons}. */
public static void nbuttons(long struct, int index, byte value) {
UNSAFE.putByte(null, struct + GLFWGamepadState.BUTTONS + check(index, 15) * 1, value);
}
/** Unsafe version of {@link #axes(FloatBuffer) axes}. */
public static void naxes(long struct, FloatBuffer value) {
if (CHECKS) { checkGT(value, 6); }
memCopy(memAddress(value), struct + GLFWGamepadState.AXES, value.remaining() * 4);
}
/** Unsafe version of {@link #axes(int, float) axes}. */
public static void naxes(long struct, int index, float value) {
UNSAFE.putFloat(null, struct + GLFWGamepadState.AXES + check(index, 6) * 4, value);
}
// -----------------------------------
/** An array of {@link GLFWGamepadState} structs. */
public static class Buffer extends StructBuffer<GLFWGamepadState, Buffer> implements NativeResource {
private static final GLFWGamepadState ELEMENT_FACTORY = GLFWGamepadState.create(-1L);
/**
* Creates a new {@code GLFWGamepadState.Buffer} instance backed by the specified container.
*
* <p>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 GLFWGamepadState#SIZEOF}, and its mark will be undefined.</p>
*
* <p>The created buffer instance holds a strong reference to the container object.</p>
*/
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 GLFWGamepadState getElementFactory() {
return ELEMENT_FACTORY;
}
/** @return a {@link ByteBuffer} view of the {@link GLFWGamepadState#buttons} field. */
@NativeType("unsigned char[15]")
public ByteBuffer buttons() { return GLFWGamepadState.nbuttons(address()); }
/** @return the value at the specified index of the {@link GLFWGamepadState#buttons} field. */
@NativeType("unsigned char")
public byte buttons(int index) { return GLFWGamepadState.nbuttons(address(), index); }
/** @return a {@link FloatBuffer} view of the {@link GLFWGamepadState#axes} field. */
@NativeType("float[6]")
public FloatBuffer axes() { return GLFWGamepadState.naxes(address()); }
/** @return the value at the specified index of the {@link GLFWGamepadState#axes} field. */
public float axes(int index) { return GLFWGamepadState.naxes(address(), index); }
/** Copies the specified {@link ByteBuffer} to the {@link GLFWGamepadState#buttons} field. */
public Buffer buttons(@NativeType("unsigned char[15]") ByteBuffer value) { GLFWGamepadState.nbuttons(address(), value); return this; }
/** Sets the specified value at the specified index of the {@link GLFWGamepadState#buttons} field. */
public Buffer buttons(int index, @NativeType("unsigned char") byte value) { GLFWGamepadState.nbuttons(address(), index, value); return this; }
/** Copies the specified {@link FloatBuffer} to the {@link GLFWGamepadState#axes} field. */
public Buffer axes(@NativeType("float[6]") FloatBuffer value) { GLFWGamepadState.naxes(address(), value); return this; }
/** Sets the specified value at the specified index of the {@link GLFWGamepadState#axes} field. */
public Buffer axes(int index, float value) { GLFWGamepadState.naxes(address(), index, value); return this; }
}
}

View File

@ -1,361 +0,0 @@
/*
* Copyright LWJGL. All rights reserved.
* License terms: https://www.lwjgl.org/license
* MACHINE GENERATED FILE, DO NOT EDIT
*/
package org.lwjgl.glfw;
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.*;
/**
* Describes the gamma ramp for a monitor.
*
* <h3>Layout</h3>
*
* <pre><code>
* struct GLFWgammaramp {
* unsigned short * {@link #red};
* unsigned short * {@link #green};
* unsigned short * {@link #blue};
* unsigned int {@link #size};
* }</code></pre>
*
* @since version 3.0
*/
@NativeType("struct GLFWgammaramp")
public class GLFWGammaRamp extends Struct<GLFWGammaRamp> 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
RED,
GREEN,
BLUE,
SIZE;
static {
Layout layout = __struct(
__member(POINTER_SIZE),
__member(POINTER_SIZE),
__member(POINTER_SIZE),
__member(4)
);
SIZEOF = layout.getSize();
ALIGNOF = layout.getAlignment();
RED = layout.offsetof(0);
GREEN = layout.offsetof(1);
BLUE = layout.offsetof(2);
SIZE = layout.offsetof(3);
}
protected GLFWGammaRamp(long address, @Nullable ByteBuffer container) {
super(address, container);
}
@Override
protected GLFWGammaRamp create(long address, @Nullable ByteBuffer container) {
return new GLFWGammaRamp(address, container);
}
/**
* Creates a {@code GLFWGammaRamp} 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.
*
* <p>The created instance holds a strong reference to the container object.</p>
*/
public GLFWGammaRamp(ByteBuffer container) {
super(memAddress(container), __checkContainer(container, SIZEOF));
}
@Override
public int sizeof() { return SIZEOF; }
/** an array of values describing the response of the red channel */
@NativeType("unsigned short *")
public ShortBuffer red() { return nred(address()); }
/** an array of values describing the response of the green channel */
@NativeType("unsigned short *")
public ShortBuffer green() { return ngreen(address()); }
/** an array of values describing the response of the blue channel */
@NativeType("unsigned short *")
public ShortBuffer blue() { return nblue(address()); }
/** the number of elements in each array */
@NativeType("unsigned int")
public int size() { return nsize(address()); }
/** Sets the address of the specified {@link ShortBuffer} to the {@link #red} field. */
public GLFWGammaRamp red(@NativeType("unsigned short *") ShortBuffer value) { nred(address(), value); return this; }
/** Sets the address of the specified {@link ShortBuffer} to the {@link #green} field. */
public GLFWGammaRamp green(@NativeType("unsigned short *") ShortBuffer value) { ngreen(address(), value); return this; }
/** Sets the address of the specified {@link ShortBuffer} to the {@link #blue} field. */
public GLFWGammaRamp blue(@NativeType("unsigned short *") ShortBuffer value) { nblue(address(), value); return this; }
/** Sets the specified value to the {@link #size} field. */
public GLFWGammaRamp size(@NativeType("unsigned int") int value) { nsize(address(), value); return this; }
/** Initializes this struct with the specified values. */
public GLFWGammaRamp set(
ShortBuffer red,
ShortBuffer green,
ShortBuffer blue,
int size
) {
red(red);
green(green);
blue(blue);
size(size);
return this;
}
/**
* Copies the specified struct data to this struct.
*
* @param src the source struct
*
* @return this struct
*/
public GLFWGammaRamp set(GLFWGammaRamp src) {
memCopy(src.address(), address(), SIZEOF);
return this;
}
// -----------------------------------
/** Returns a new {@code GLFWGammaRamp} instance allocated with {@link MemoryUtil#memAlloc memAlloc}. The instance must be explicitly freed. */
public static GLFWGammaRamp malloc() {
return new GLFWGammaRamp(nmemAllocChecked(SIZEOF), null);
}
/** Returns a new {@code GLFWGammaRamp} instance allocated with {@link MemoryUtil#memCalloc memCalloc}. The instance must be explicitly freed. */
public static GLFWGammaRamp calloc() {
return new GLFWGammaRamp(nmemCallocChecked(1, SIZEOF), null);
}
/** Returns a new {@code GLFWGammaRamp} instance allocated with {@link BufferUtils}. */
public static GLFWGammaRamp create() {
ByteBuffer container = BufferUtils.createByteBuffer(SIZEOF);
return new GLFWGammaRamp(memAddress(container), container);
}
/** Returns a new {@code GLFWGammaRamp} instance for the specified memory address. */
public static GLFWGammaRamp create(long address) {
return new GLFWGammaRamp(address, null);
}
/** Like {@link #create(long) create}, but returns {@code null} if {@code address} is {@code NULL}. */
@Nullable
public static GLFWGammaRamp createSafe(long address) {
return address == NULL ? null : new GLFWGammaRamp(address, null);
}
/**
* Returns a new {@link 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 new Buffer(nmemAllocChecked(__checkMalloc(capacity, SIZEOF)), capacity);
}
/**
* Returns a new {@link 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 new Buffer(nmemCallocChecked(capacity, SIZEOF), capacity);
}
/**
* Returns a new {@link Buffer} instance allocated with {@link BufferUtils}.
*
* @param capacity the buffer capacity
*/
public static Buffer create(int capacity) {
ByteBuffer container = __create(capacity, SIZEOF);
return new Buffer(memAddress(container), container, -1, 0, capacity, capacity);
}
/**
* Create a {@link 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 new Buffer(address, capacity);
}
/** Like {@link #create(long, int) create}, but returns {@code null} if {@code address} is {@code NULL}. */
@Nullable
public static Buffer createSafe(long address, int capacity) {
return address == NULL ? null : new Buffer(address, capacity);
}
// -----------------------------------
/** Deprecated for removal in 3.4.0. Use {@link #malloc(MemoryStack)} instead. */
@Deprecated public static GLFWGammaRamp mallocStack() { return malloc(stackGet()); }
/** Deprecated for removal in 3.4.0. Use {@link #calloc(MemoryStack)} instead. */
@Deprecated public static GLFWGammaRamp callocStack() { return calloc(stackGet()); }
/** Deprecated for removal in 3.4.0. Use {@link #malloc(MemoryStack)} instead. */
@Deprecated public static GLFWGammaRamp mallocStack(MemoryStack stack) { return malloc(stack); }
/** Deprecated for removal in 3.4.0. Use {@link #calloc(MemoryStack)} instead. */
@Deprecated public static GLFWGammaRamp callocStack(MemoryStack stack) { return calloc(stack); }
/** Deprecated for removal in 3.4.0. Use {@link #malloc(int, MemoryStack)} instead. */
@Deprecated public static Buffer mallocStack(int capacity) { return malloc(capacity, stackGet()); }
/** Deprecated for removal in 3.4.0. Use {@link #calloc(int, MemoryStack)} instead. */
@Deprecated public static Buffer callocStack(int capacity) { return calloc(capacity, stackGet()); }
/** Deprecated for removal in 3.4.0. Use {@link #malloc(int, MemoryStack)} instead. */
@Deprecated public static Buffer mallocStack(int capacity, MemoryStack stack) { return malloc(capacity, stack); }
/** Deprecated for removal in 3.4.0. Use {@link #calloc(int, MemoryStack)} instead. */
@Deprecated public static Buffer callocStack(int capacity, MemoryStack stack) { return calloc(capacity, stack); }
/**
* Returns a new {@code GLFWGammaRamp} instance allocated on the specified {@link MemoryStack}.
*
* @param stack the stack from which to allocate
*/
public static GLFWGammaRamp malloc(MemoryStack stack) {
return new GLFWGammaRamp(stack.nmalloc(ALIGNOF, SIZEOF), null);
}
/**
* Returns a new {@code GLFWGammaRamp} instance allocated on the specified {@link MemoryStack} and initializes all its bits to zero.
*
* @param stack the stack from which to allocate
*/
public static GLFWGammaRamp calloc(MemoryStack stack) {
return new GLFWGammaRamp(stack.ncalloc(ALIGNOF, 1, SIZEOF), null);
}
/**
* Returns a new {@link Buffer} instance allocated on the specified {@link MemoryStack}.
*
* @param stack the stack from which to allocate
* @param capacity the buffer capacity
*/
public static Buffer malloc(int capacity, MemoryStack stack) {
return new Buffer(stack.nmalloc(ALIGNOF, capacity * SIZEOF), capacity);
}
/**
* Returns a new {@link 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 calloc(int capacity, MemoryStack stack) {
return new Buffer(stack.ncalloc(ALIGNOF, capacity, SIZEOF), capacity);
}
// -----------------------------------
/** Unsafe version of {@link #red() red}. */
public static ShortBuffer nred(long struct) { return memShortBuffer(memGetAddress(struct + GLFWGammaRamp.RED), nsize(struct)); }
/** Unsafe version of {@link #green() green}. */
public static ShortBuffer ngreen(long struct) { return memShortBuffer(memGetAddress(struct + GLFWGammaRamp.GREEN), nsize(struct)); }
/** Unsafe version of {@link #blue() blue}. */
public static ShortBuffer nblue(long struct) { return memShortBuffer(memGetAddress(struct + GLFWGammaRamp.BLUE), nsize(struct)); }
/** Unsafe version of {@link #size}. */
public static int nsize(long struct) { return UNSAFE.getInt(null, struct + GLFWGammaRamp.SIZE); }
/** Unsafe version of {@link #red(ShortBuffer) red}. */
public static void nred(long struct, ShortBuffer value) { memPutAddress(struct + GLFWGammaRamp.RED, memAddress(value)); }
/** Unsafe version of {@link #green(ShortBuffer) green}. */
public static void ngreen(long struct, ShortBuffer value) { memPutAddress(struct + GLFWGammaRamp.GREEN, memAddress(value)); }
/** Unsafe version of {@link #blue(ShortBuffer) blue}. */
public static void nblue(long struct, ShortBuffer value) { memPutAddress(struct + GLFWGammaRamp.BLUE, memAddress(value)); }
/** Sets the specified value to the {@code size} field of the specified {@code struct}. */
public static void nsize(long struct, int value) { UNSAFE.putInt(null, struct + GLFWGammaRamp.SIZE, value); }
/**
* Validates pointer members that should not be {@code NULL}.
*
* @param struct the struct to validate
*/
public static void validate(long struct) {
check(memGetAddress(struct + GLFWGammaRamp.RED));
check(memGetAddress(struct + GLFWGammaRamp.GREEN));
check(memGetAddress(struct + GLFWGammaRamp.BLUE));
}
// -----------------------------------
/** An array of {@link GLFWGammaRamp} structs. */
public static class Buffer extends StructBuffer<GLFWGammaRamp, Buffer> implements NativeResource {
private static final GLFWGammaRamp ELEMENT_FACTORY = GLFWGammaRamp.create(-1L);
/**
* Creates a new {@code GLFWGammaRamp.Buffer} instance backed by the specified container.
*
* <p>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 GLFWGammaRamp#SIZEOF}, and its mark will be undefined.</p>
*
* <p>The created buffer instance holds a strong reference to the container object.</p>
*/
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 GLFWGammaRamp getElementFactory() {
return ELEMENT_FACTORY;
}
/** @return a {@link ShortBuffer} view of the data pointed to by the {@link GLFWGammaRamp#red} field. */
@NativeType("unsigned short *")
public ShortBuffer red() { return GLFWGammaRamp.nred(address()); }
/** @return a {@link ShortBuffer} view of the data pointed to by the {@link GLFWGammaRamp#green} field. */
@NativeType("unsigned short *")
public ShortBuffer green() { return GLFWGammaRamp.ngreen(address()); }
/** @return a {@link ShortBuffer} view of the data pointed to by the {@link GLFWGammaRamp#blue} field. */
@NativeType("unsigned short *")
public ShortBuffer blue() { return GLFWGammaRamp.nblue(address()); }
/** @return the value of the {@link GLFWGammaRamp#size} field. */
@NativeType("unsigned int")
public int size() { return GLFWGammaRamp.nsize(address()); }
/** Sets the address of the specified {@link ShortBuffer} to the {@link GLFWGammaRamp#red} field. */
public Buffer red(@NativeType("unsigned short *") ShortBuffer value) { GLFWGammaRamp.nred(address(), value); return this; }
/** Sets the address of the specified {@link ShortBuffer} to the {@link GLFWGammaRamp#green} field. */
public Buffer green(@NativeType("unsigned short *") ShortBuffer value) { GLFWGammaRamp.ngreen(address(), value); return this; }
/** Sets the address of the specified {@link ShortBuffer} to the {@link GLFWGammaRamp#blue} field. */
public Buffer blue(@NativeType("unsigned short *") ShortBuffer value) { GLFWGammaRamp.nblue(address(), value); return this; }
/** Sets the specified value to the {@link GLFWGammaRamp#size} field. */
public Buffer size(@NativeType("unsigned int") int value) { GLFWGammaRamp.nsize(address(), value); return this; }
}
}

View File

@ -1,345 +0,0 @@
/*
* Copyright LWJGL. All rights reserved.
* License terms: https://www.lwjgl.org/license
* MACHINE GENERATED FILE, DO NOT EDIT
*/
package org.lwjgl.glfw;
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.*;
/**
* Image data.
*
* <p>This describes a single 2D image. See the documentation for each related function to see what the expected pixel format is.</p>
*
* <h3>Layout</h3>
*
* <pre><code>
* struct GLFWimage {
* int {@link #width};
* int {@link #height};
* unsigned char * {@link #pixels};
* }</code></pre>
*
* @since version 2.1
*/
@NativeType("struct GLFWimage")
public class GLFWImage extends Struct<GLFWImage> 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
WIDTH,
HEIGHT,
PIXELS;
static {
Layout layout = __struct(
__member(4),
__member(4),
__member(POINTER_SIZE)
);
SIZEOF = layout.getSize();
ALIGNOF = layout.getAlignment();
WIDTH = layout.offsetof(0);
HEIGHT = layout.offsetof(1);
PIXELS = layout.offsetof(2);
}
protected GLFWImage(long address, @Nullable ByteBuffer container) {
super(address, container);
}
@Override
protected GLFWImage create(long address, @Nullable ByteBuffer container) {
return new GLFWImage(address, container);
}
/**
* Creates a {@code GLFWImage} 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.
*
* <p>The created instance holds a strong reference to the container object.</p>
*/
public GLFWImage(ByteBuffer container) {
super(memAddress(container), __checkContainer(container, SIZEOF));
}
@Override
public int sizeof() { return SIZEOF; }
/** the width, in pixels, of this image */
public int width() { return nwidth(address()); }
/** the height, in pixels, of this image */
public int height() { return nheight(address()); }
/**
* @param capacity the number of elements in the returned buffer
*
* @return the pixel data of this image, arranged left-to-right, top-to-bottom
*/
@NativeType("unsigned char *")
public ByteBuffer pixels(int capacity) { return npixels(address(), capacity); }
/** Sets the specified value to the {@link #width} field. */
public GLFWImage width(int value) { nwidth(address(), value); return this; }
/** Sets the specified value to the {@link #height} field. */
public GLFWImage height(int value) { nheight(address(), value); return this; }
/** Sets the address of the specified {@link ByteBuffer} to the {@link #pixels} field. */
public GLFWImage pixels(@NativeType("unsigned char *") ByteBuffer value) { npixels(address(), value); return this; }
/** Initializes this struct with the specified values. */
public GLFWImage set(
int width,
int height,
ByteBuffer pixels
) {
width(width);
height(height);
pixels(pixels);
return this;
}
/**
* Copies the specified struct data to this struct.
*
* @param src the source struct
*
* @return this struct
*/
public GLFWImage set(GLFWImage src) {
memCopy(src.address(), address(), SIZEOF);
return this;
}
// -----------------------------------
/** Returns a new {@code GLFWImage} instance allocated with {@link MemoryUtil#memAlloc memAlloc}. The instance must be explicitly freed. */
public static GLFWImage malloc() {
return new GLFWImage(nmemAllocChecked(SIZEOF), null);
}
/** Returns a new {@code GLFWImage} instance allocated with {@link MemoryUtil#memCalloc memCalloc}. The instance must be explicitly freed. */
public static GLFWImage calloc() {
return new GLFWImage(nmemCallocChecked(1, SIZEOF), null);
}
/** Returns a new {@code GLFWImage} instance allocated with {@link BufferUtils}. */
public static GLFWImage create() {
ByteBuffer container = BufferUtils.createByteBuffer(SIZEOF);
return new GLFWImage(memAddress(container), container);
}
/** Returns a new {@code GLFWImage} instance for the specified memory address. */
public static GLFWImage create(long address) {
return new GLFWImage(address, null);
}
/** Like {@link #create(long) create}, but returns {@code null} if {@code address} is {@code NULL}. */
@Nullable
public static GLFWImage createSafe(long address) {
return address == NULL ? null : new GLFWImage(address, null);
}
/**
* Returns a new {@link 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 new Buffer(nmemAllocChecked(__checkMalloc(capacity, SIZEOF)), capacity);
}
/**
* Returns a new {@link 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 new Buffer(nmemCallocChecked(capacity, SIZEOF), capacity);
}
/**
* Returns a new {@link Buffer} instance allocated with {@link BufferUtils}.
*
* @param capacity the buffer capacity
*/
public static Buffer create(int capacity) {
ByteBuffer container = __create(capacity, SIZEOF);
return new Buffer(memAddress(container), container, -1, 0, capacity, capacity);
}
/**
* Create a {@link 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 new Buffer(address, capacity);
}
/** Like {@link #create(long, int) create}, but returns {@code null} if {@code address} is {@code NULL}. */
@Nullable
public static Buffer createSafe(long address, int capacity) {
return address == NULL ? null : new Buffer(address, capacity);
}
// -----------------------------------
/** Deprecated for removal in 3.4.0. Use {@link #malloc(MemoryStack)} instead. */
@Deprecated public static GLFWImage mallocStack() { return malloc(stackGet()); }
/** Deprecated for removal in 3.4.0. Use {@link #calloc(MemoryStack)} instead. */
@Deprecated public static GLFWImage callocStack() { return calloc(stackGet()); }
/** Deprecated for removal in 3.4.0. Use {@link #malloc(MemoryStack)} instead. */
@Deprecated public static GLFWImage mallocStack(MemoryStack stack) { return malloc(stack); }
/** Deprecated for removal in 3.4.0. Use {@link #calloc(MemoryStack)} instead. */
@Deprecated public static GLFWImage callocStack(MemoryStack stack) { return calloc(stack); }
/** Deprecated for removal in 3.4.0. Use {@link #malloc(int, MemoryStack)} instead. */
@Deprecated public static Buffer mallocStack(int capacity) { return malloc(capacity, stackGet()); }
/** Deprecated for removal in 3.4.0. Use {@link #calloc(int, MemoryStack)} instead. */
@Deprecated public static Buffer callocStack(int capacity) { return calloc(capacity, stackGet()); }
/** Deprecated for removal in 3.4.0. Use {@link #malloc(int, MemoryStack)} instead. */
@Deprecated public static Buffer mallocStack(int capacity, MemoryStack stack) { return malloc(capacity, stack); }
/** Deprecated for removal in 3.4.0. Use {@link #calloc(int, MemoryStack)} instead. */
@Deprecated public static Buffer callocStack(int capacity, MemoryStack stack) { return calloc(capacity, stack); }
/**
* Returns a new {@code GLFWImage} instance allocated on the specified {@link MemoryStack}.
*
* @param stack the stack from which to allocate
*/
public static GLFWImage malloc(MemoryStack stack) {
return new GLFWImage(stack.nmalloc(ALIGNOF, SIZEOF), null);
}
/**
* Returns a new {@code GLFWImage} instance allocated on the specified {@link MemoryStack} and initializes all its bits to zero.
*
* @param stack the stack from which to allocate
*/
public static GLFWImage calloc(MemoryStack stack) {
return new GLFWImage(stack.ncalloc(ALIGNOF, 1, SIZEOF), null);
}
/**
* Returns a new {@link Buffer} instance allocated on the specified {@link MemoryStack}.
*
* @param stack the stack from which to allocate
* @param capacity the buffer capacity
*/
public static Buffer malloc(int capacity, MemoryStack stack) {
return new Buffer(stack.nmalloc(ALIGNOF, capacity * SIZEOF), capacity);
}
/**
* Returns a new {@link 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 calloc(int capacity, MemoryStack stack) {
return new Buffer(stack.ncalloc(ALIGNOF, capacity, SIZEOF), capacity);
}
// -----------------------------------
/** Unsafe version of {@link #width}. */
public static int nwidth(long struct) { return UNSAFE.getInt(null, struct + GLFWImage.WIDTH); }
/** Unsafe version of {@link #height}. */
public static int nheight(long struct) { return UNSAFE.getInt(null, struct + GLFWImage.HEIGHT); }
/** Unsafe version of {@link #pixels(int) pixels}. */
public static ByteBuffer npixels(long struct, int capacity) { return memByteBuffer(memGetAddress(struct + GLFWImage.PIXELS), capacity); }
/** Unsafe version of {@link #width(int) width}. */
public static void nwidth(long struct, int value) { UNSAFE.putInt(null, struct + GLFWImage.WIDTH, value); }
/** Unsafe version of {@link #height(int) height}. */
public static void nheight(long struct, int value) { UNSAFE.putInt(null, struct + GLFWImage.HEIGHT, value); }
/** Unsafe version of {@link #pixels(ByteBuffer) pixels}. */
public static void npixels(long struct, ByteBuffer value) { memPutAddress(struct + GLFWImage.PIXELS, memAddress(value)); }
/**
* Validates pointer members that should not be {@code NULL}.
*
* @param struct the struct to validate
*/
public static void validate(long struct) {
check(memGetAddress(struct + GLFWImage.PIXELS));
}
// -----------------------------------
/** An array of {@link GLFWImage} structs. */
public static class Buffer extends StructBuffer<GLFWImage, Buffer> implements NativeResource {
private static final GLFWImage ELEMENT_FACTORY = GLFWImage.create(-1L);
/**
* Creates a new {@code GLFWImage.Buffer} instance backed by the specified container.
*
* <p>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 GLFWImage#SIZEOF}, and its mark will be undefined.</p>
*
* <p>The created buffer instance holds a strong reference to the container object.</p>
*/
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 GLFWImage getElementFactory() {
return ELEMENT_FACTORY;
}
/** @return the value of the {@link GLFWImage#width} field. */
public int width() { return GLFWImage.nwidth(address()); }
/** @return the value of the {@link GLFWImage#height} field. */
public int height() { return GLFWImage.nheight(address()); }
/**
* @return a {@link ByteBuffer} view of the data pointed to by the {@link GLFWImage#pixels} field.
*
* @param capacity the number of elements in the returned buffer
*/
@NativeType("unsigned char *")
public ByteBuffer pixels(int capacity) { return GLFWImage.npixels(address(), capacity); }
/** Sets the specified value to the {@link GLFWImage#width} field. */
public Buffer width(int value) { GLFWImage.nwidth(address(), value); return this; }
/** Sets the specified value to the {@link GLFWImage#height} field. */
public Buffer height(int value) { GLFWImage.nheight(address(), value); return this; }
/** Sets the address of the specified {@link ByteBuffer} to the {@link GLFWImage#pixels} field. */
public Buffer pixels(@NativeType("unsigned char *") ByteBuffer value) { GLFWImage.npixels(address(), value); return this; }
}
}

View File

@ -1,86 +0,0 @@
/*
* Copyright LWJGL. All rights reserved.
* License terms: https://www.lwjgl.org/license
* MACHINE GENERATED FILE, DO NOT EDIT
*/
package org.lwjgl.glfw;
import javax.annotation.*;
import org.lwjgl.system.*;
import static org.lwjgl.system.MemoryUtil.*;
import static org.lwjgl.glfw.GLFW.*;
/**
* Instances of this class may be passed to the {@link GLFW#glfwSetJoystickCallback SetJoystickCallback} method.
*
* <h3>Type</h3>
*
* <pre><code>
* void (*{@link #invoke}) (
* int jid,
* int event
* )</code></pre>
*
* @since version 3.2
*/
public abstract class GLFWJoystickCallback extends Callback implements GLFWJoystickCallbackI {
/**
* Creates a {@code GLFWJoystickCallback} instance from the specified function pointer.
*
* @return the new {@code GLFWJoystickCallback}
*/
public static GLFWJoystickCallback create(long functionPointer) {
GLFWJoystickCallbackI instance = Callback.get(functionPointer);
return instance instanceof GLFWJoystickCallback
? (GLFWJoystickCallback)instance
: new Container(functionPointer, instance);
}
/** Like {@link #create(long) create}, but returns {@code null} if {@code functionPointer} is {@code NULL}. */
@Nullable
public static GLFWJoystickCallback createSafe(long functionPointer) {
return functionPointer == NULL ? null : create(functionPointer);
}
/** Creates a {@code GLFWJoystickCallback} instance that delegates to the specified {@code GLFWJoystickCallbackI} instance. */
public static GLFWJoystickCallback create(GLFWJoystickCallbackI instance) {
return instance instanceof GLFWJoystickCallback
? (GLFWJoystickCallback)instance
: new Container(instance.address(), instance);
}
protected GLFWJoystickCallback() {
super(CIF);
}
GLFWJoystickCallback(long functionPointer) {
super(functionPointer);
}
/** See {@link GLFW#glfwSetJoystickCallback SetJoystickCallback}. */
public GLFWJoystickCallback set() {
glfwSetJoystickCallback(this);
return this;
}
private static final class Container extends GLFWJoystickCallback {
private final GLFWJoystickCallbackI delegate;
Container(long functionPointer, GLFWJoystickCallbackI delegate) {
super(functionPointer);
this.delegate = delegate;
}
@Override
public void invoke(int jid, int event) {
delegate.invoke(jid, event);
}
}
}

View File

@ -1,57 +0,0 @@
/*
* Copyright LWJGL. All rights reserved.
* License terms: https://www.lwjgl.org/license
* MACHINE GENERATED FILE, DO NOT EDIT
*/
package org.lwjgl.glfw;
import org.lwjgl.system.*;
import org.lwjgl.system.libffi.*;
import static org.lwjgl.system.APIUtil.*;
import static org.lwjgl.system.MemoryUtil.*;
import static org.lwjgl.system.libffi.LibFFI.*;
/**
* Instances of this interface may be passed to the {@link GLFW#glfwSetJoystickCallback SetJoystickCallback} method.
*
* <h3>Type</h3>
*
* <pre><code>
* void (*{@link #invoke}) (
* int jid,
* int event
* )</code></pre>
*
* @since version 3.2
*/
@FunctionalInterface
@NativeType("GLFWjoystickfun")
public interface GLFWJoystickCallbackI extends CallbackI {
FFICIF CIF = apiCreateCIF(
FFI_DEFAULT_ABI,
ffi_type_void,
ffi_type_sint32, ffi_type_sint32
);
@Override
default FFICIF getCallInterface() { return CIF; }
@Override
default void callback(long ret, long args) {
invoke(
memGetInt(memGetAddress(args)),
memGetInt(memGetAddress(args + POINTER_SIZE))
);
}
/**
* Will be called when a joystick is connected to or disconnected from the system.
*
* @param jid the joystick that was connected or disconnected
* @param event one of {@link GLFW#GLFW_CONNECTED CONNECTED} or {@link GLFW#GLFW_DISCONNECTED DISCONNECTED}. Remaining values reserved for future use.
*/
void invoke(int jid, int event);
}

View File

@ -1,87 +0,0 @@
/*
* Copyright LWJGL. All rights reserved.
* License terms: https://www.lwjgl.org/license
* MACHINE GENERATED FILE, DO NOT EDIT
*/
package org.lwjgl.glfw;
import javax.annotation.*;
import org.lwjgl.system.*;
import static org.lwjgl.system.MemoryUtil.*;
import static org.lwjgl.glfw.GLFW.*;
/**
* Instances of this class may be passed to the {@link GLFW#glfwSetKeyCallback SetKeyCallback} method.
*
* <h3>Type</h3>
*
* <pre><code>
* void (*{@link #invoke}) (
* GLFWwindow *window,
* int key,
* int scancode,
* int action,
* int mods
* )</code></pre>
*/
public abstract class GLFWKeyCallback extends Callback implements GLFWKeyCallbackI {
/**
* Creates a {@code GLFWKeyCallback} instance from the specified function pointer.
*
* @return the new {@code GLFWKeyCallback}
*/
public static GLFWKeyCallback create(long functionPointer) {
GLFWKeyCallbackI instance = Callback.get(functionPointer);
return instance instanceof GLFWKeyCallback
? (GLFWKeyCallback)instance
: new Container(functionPointer, instance);
}
/** Like {@link #create(long) create}, but returns {@code null} if {@code functionPointer} is {@code NULL}. */
@Nullable
public static GLFWKeyCallback createSafe(long functionPointer) {
return functionPointer == NULL ? null : create(functionPointer);
}
/** Creates a {@code GLFWKeyCallback} instance that delegates to the specified {@code GLFWKeyCallbackI} instance. */
public static GLFWKeyCallback create(GLFWKeyCallbackI instance) {
return instance instanceof GLFWKeyCallback
? (GLFWKeyCallback)instance
: new Container(instance.address(), instance);
}
protected GLFWKeyCallback() {
super(CIF);
}
GLFWKeyCallback(long functionPointer) {
super(functionPointer);
}
/** See {@link GLFW#glfwSetKeyCallback SetKeyCallback}. */
public GLFWKeyCallback set(long window) {
glfwSetKeyCallback(window, this);
return this;
}
private static final class Container extends GLFWKeyCallback {
private final GLFWKeyCallbackI delegate;
Container(long functionPointer, GLFWKeyCallbackI delegate) {
super(functionPointer);
this.delegate = delegate;
}
@Override
public void invoke(long window, int key, int scancode, int action, int mods) {
delegate.invoke(window, key, scancode, action, mods);
}
}
}

View File

@ -1,64 +0,0 @@
/*
* Copyright LWJGL. All rights reserved.
* License terms: https://www.lwjgl.org/license
* MACHINE GENERATED FILE, DO NOT EDIT
*/
package org.lwjgl.glfw;
import org.lwjgl.system.*;
import org.lwjgl.system.libffi.*;
import static org.lwjgl.system.APIUtil.*;
import static org.lwjgl.system.MemoryUtil.*;
import static org.lwjgl.system.libffi.LibFFI.*;
/**
* Instances of this interface may be passed to the {@link GLFW#glfwSetKeyCallback SetKeyCallback} method.
*
* <h3>Type</h3>
*
* <pre><code>
* void (*{@link #invoke}) (
* GLFWwindow *window,
* int key,
* int scancode,
* int action,
* int mods
* )</code></pre>
*/
@FunctionalInterface
@NativeType("GLFWkeyfun")
public interface GLFWKeyCallbackI extends CallbackI {
FFICIF CIF = apiCreateCIF(
FFI_DEFAULT_ABI,
ffi_type_void,
ffi_type_pointer, ffi_type_sint32, ffi_type_sint32, ffi_type_sint32, ffi_type_sint32
);
@Override
default FFICIF getCallInterface() { return CIF; }
@Override
default void callback(long ret, long args) {
invoke(
memGetAddress(memGetAddress(args)),
memGetInt(memGetAddress(args + POINTER_SIZE)),
memGetInt(memGetAddress(args + 2 * POINTER_SIZE)),
memGetInt(memGetAddress(args + 3 * POINTER_SIZE)),
memGetInt(memGetAddress(args + 4 * POINTER_SIZE))
);
}
/**
* Will be called when a key is pressed, repeated or released.
*
* @param window the window that received the event
* @param key the keyboard key that was pressed or released
* @param scancode the platform-specific scancode of the key
* @param action the key action. One of:<br><table><tr><td>{@link GLFW#GLFW_PRESS PRESS}</td><td>{@link GLFW#GLFW_RELEASE RELEASE}</td><td>{@link GLFW#GLFW_REPEAT REPEAT}</td></tr></table>
* @param mods bitfield describing which modifiers keys were held down
*/
void invoke(@NativeType("GLFWwindow *") long window, int key, int scancode, int action, int mods);
}

View File

@ -1,86 +0,0 @@
/*
* Copyright LWJGL. All rights reserved.
* License terms: https://www.lwjgl.org/license
* MACHINE GENERATED FILE, DO NOT EDIT
*/
package org.lwjgl.glfw;
import javax.annotation.*;
import org.lwjgl.system.*;
import static org.lwjgl.system.MemoryUtil.*;
import static org.lwjgl.glfw.GLFW.*;
/**
* Instances of this class may be passed to the {@link GLFW#glfwSetMonitorCallback SetMonitorCallback} method.
*
* <h3>Type</h3>
*
* <pre><code>
* void (*{@link #invoke}) (
* GLFWmonitor *monitor,
* int event
* )</code></pre>
*
* @since version 3.0
*/
public abstract class GLFWMonitorCallback extends Callback implements GLFWMonitorCallbackI {
/**
* Creates a {@code GLFWMonitorCallback} instance from the specified function pointer.
*
* @return the new {@code GLFWMonitorCallback}
*/
public static GLFWMonitorCallback create(long functionPointer) {
GLFWMonitorCallbackI instance = Callback.get(functionPointer);
return instance instanceof GLFWMonitorCallback
? (GLFWMonitorCallback)instance
: new Container(functionPointer, instance);
}
/** Like {@link #create(long) create}, but returns {@code null} if {@code functionPointer} is {@code NULL}. */
@Nullable
public static GLFWMonitorCallback createSafe(long functionPointer) {
return functionPointer == NULL ? null : create(functionPointer);
}
/** Creates a {@code GLFWMonitorCallback} instance that delegates to the specified {@code GLFWMonitorCallbackI} instance. */
public static GLFWMonitorCallback create(GLFWMonitorCallbackI instance) {
return instance instanceof GLFWMonitorCallback
? (GLFWMonitorCallback)instance
: new Container(instance.address(), instance);
}
protected GLFWMonitorCallback() {
super(CIF);
}
GLFWMonitorCallback(long functionPointer) {
super(functionPointer);
}
/** See {@link GLFW#glfwSetMonitorCallback SetMonitorCallback}. */
public GLFWMonitorCallback set() {
glfwSetMonitorCallback(this);
return this;
}
private static final class Container extends GLFWMonitorCallback {
private final GLFWMonitorCallbackI delegate;
Container(long functionPointer, GLFWMonitorCallbackI delegate) {
super(functionPointer);
this.delegate = delegate;
}
@Override
public void invoke(long monitor, int event) {
delegate.invoke(monitor, event);
}
}
}

View File

@ -1,57 +0,0 @@
/*
* Copyright LWJGL. All rights reserved.
* License terms: https://www.lwjgl.org/license
* MACHINE GENERATED FILE, DO NOT EDIT
*/
package org.lwjgl.glfw;
import org.lwjgl.system.*;
import org.lwjgl.system.libffi.*;
import static org.lwjgl.system.APIUtil.*;
import static org.lwjgl.system.MemoryUtil.*;
import static org.lwjgl.system.libffi.LibFFI.*;
/**
* Instances of this interface may be passed to the {@link GLFW#glfwSetMonitorCallback SetMonitorCallback} method.
*
* <h3>Type</h3>
*
* <pre><code>
* void (*{@link #invoke}) (
* GLFWmonitor *monitor,
* int event
* )</code></pre>
*
* @since version 3.0
*/
@FunctionalInterface
@NativeType("GLFWmonitorfun")
public interface GLFWMonitorCallbackI extends CallbackI {
FFICIF CIF = apiCreateCIF(
FFI_DEFAULT_ABI,
ffi_type_void,
ffi_type_pointer, ffi_type_sint32
);
@Override
default FFICIF getCallInterface() { return CIF; }
@Override
default void callback(long ret, long args) {
invoke(
memGetAddress(memGetAddress(args)),
memGetInt(memGetAddress(args + POINTER_SIZE))
);
}
/**
* Will be called when a monitor is connected to or disconnected from the system.
*
* @param monitor the monitor that was connected or disconnected
* @param event one of {@link GLFW#GLFW_CONNECTED CONNECTED} or {@link GLFW#GLFW_DISCONNECTED DISCONNECTED}. Remaining values reserved for future use.
*/
void invoke(@NativeType("GLFWmonitor *") long monitor, int event);
}

View File

@ -1,86 +0,0 @@
/*
* Copyright LWJGL. All rights reserved.
* License terms: https://www.lwjgl.org/license
* MACHINE GENERATED FILE, DO NOT EDIT
*/
package org.lwjgl.glfw;
import javax.annotation.*;
import org.lwjgl.system.*;
import static org.lwjgl.system.MemoryUtil.*;
import static org.lwjgl.glfw.GLFW.*;
/**
* Instances of this class may be passed to the {@link GLFW#glfwSetMouseButtonCallback SetMouseButtonCallback} method.
*
* <h3>Type</h3>
*
* <pre><code>
* void (*{@link #invoke}) (
* GLFWwindow *window,
* int button,
* int action,
* int mods
* )</code></pre>
*/
public abstract class GLFWMouseButtonCallback extends Callback implements GLFWMouseButtonCallbackI {
/**
* Creates a {@code GLFWMouseButtonCallback} instance from the specified function pointer.
*
* @return the new {@code GLFWMouseButtonCallback}
*/
public static GLFWMouseButtonCallback create(long functionPointer) {
GLFWMouseButtonCallbackI instance = Callback.get(functionPointer);
return instance instanceof GLFWMouseButtonCallback
? (GLFWMouseButtonCallback)instance
: new Container(functionPointer, instance);
}
/** Like {@link #create(long) create}, but returns {@code null} if {@code functionPointer} is {@code NULL}. */
@Nullable
public static GLFWMouseButtonCallback createSafe(long functionPointer) {
return functionPointer == NULL ? null : create(functionPointer);
}
/** Creates a {@code GLFWMouseButtonCallback} instance that delegates to the specified {@code GLFWMouseButtonCallbackI} instance. */
public static GLFWMouseButtonCallback create(GLFWMouseButtonCallbackI instance) {
return instance instanceof GLFWMouseButtonCallback
? (GLFWMouseButtonCallback)instance
: new Container(instance.address(), instance);
}
protected GLFWMouseButtonCallback() {
super(CIF);
}
GLFWMouseButtonCallback(long functionPointer) {
super(functionPointer);
}
/** See {@link GLFW#glfwSetMouseButtonCallback SetMouseButtonCallback}. */
public GLFWMouseButtonCallback set(long window) {
glfwSetMouseButtonCallback(window, this);
return this;
}
private static final class Container extends GLFWMouseButtonCallback {
private final GLFWMouseButtonCallbackI delegate;
Container(long functionPointer, GLFWMouseButtonCallbackI delegate) {
super(functionPointer);
this.delegate = delegate;
}
@Override
public void invoke(long window, int button, int action, int mods) {
delegate.invoke(window, button, action, mods);
}
}
}

View File

@ -1,61 +0,0 @@
/*
* Copyright LWJGL. All rights reserved.
* License terms: https://www.lwjgl.org/license
* MACHINE GENERATED FILE, DO NOT EDIT
*/
package org.lwjgl.glfw;
import org.lwjgl.system.*;
import org.lwjgl.system.libffi.*;
import static org.lwjgl.system.APIUtil.*;
import static org.lwjgl.system.MemoryUtil.*;
import static org.lwjgl.system.libffi.LibFFI.*;
/**
* Instances of this interface may be passed to the {@link GLFW#glfwSetMouseButtonCallback SetMouseButtonCallback} method.
*
* <h3>Type</h3>
*
* <pre><code>
* void (*{@link #invoke}) (
* GLFWwindow *window,
* int button,
* int action,
* int mods
* )</code></pre>
*/
@FunctionalInterface
@NativeType("GLFWmousebuttonfun")
public interface GLFWMouseButtonCallbackI extends CallbackI {
FFICIF CIF = apiCreateCIF(
FFI_DEFAULT_ABI,
ffi_type_void,
ffi_type_pointer, ffi_type_sint32, ffi_type_sint32, ffi_type_sint32
);
@Override
default FFICIF getCallInterface() { return CIF; }
@Override
default void callback(long ret, long args) {
invoke(
memGetAddress(memGetAddress(args)),
memGetInt(memGetAddress(args + POINTER_SIZE)),
memGetInt(memGetAddress(args + 2 * POINTER_SIZE)),
memGetInt(memGetAddress(args + 3 * POINTER_SIZE))
);
}
/**
* Will be called when a mouse button is pressed or released.
*
* @param window the window that received the event
* @param button the mouse button that was pressed or released
* @param action the button action. One of:<br><table><tr><td>{@link GLFW#GLFW_PRESS PRESS}</td><td>{@link GLFW#GLFW_RELEASE RELEASE}</td></tr></table>
* @param mods bitfield describing which modifiers keys were held down
*/
void invoke(@NativeType("GLFWwindow *") long window, int button, int action, int mods);
}

View File

@ -1,81 +0,0 @@
/*
* Copyright LWJGL. All rights reserved.
* License terms: https://www.lwjgl.org/license
* MACHINE GENERATED FILE, DO NOT EDIT
*/
package org.lwjgl.glfw;
import org.lwjgl.system.*;
import static org.lwjgl.system.APIUtil.*;
import static org.lwjgl.system.Checks.*;
import static org.lwjgl.system.JNI.*;
/** Native bindings to the GLFW library's Cocoa native access functions. */
public class GLFWNativeCocoa {
/** Contains the function pointers loaded from {@code GLFW.getLibrary()}. */
public static final class Functions {
private Functions() {}
/** Function address. */
public static final long
GetCocoaMonitor = apiGetFunctionAddress(GLFW.getLibrary(), "glfwGetCocoaMonitor"),
GetCocoaWindow = apiGetFunctionAddress(GLFW.getLibrary(), "glfwGetCocoaWindow");
}
protected GLFWNativeCocoa() {
throw new UnsupportedOperationException();
}
// --- [ glfwGetCocoaMonitor ] ---
/**
* Returns the {@code CGDirectDisplayID} of the specified monitor.
*
* <p>Note: This function may be called from any thread. Access is not synchronized.</p>
*
* @param monitor the GLFW monitor
*
* @return the {@code CGDirectDisplayID} of the specified monitor, or {@code kCGNullDirectDisplay} if an error occurred.
*
* <p>Possible errors include {@link GLFW#GLFW_NOT_INITIALIZED NOT_INITIALIZED}.</p>
*
* @since version 3.1
*/
@NativeType("CGDirectDisplayID")
public static int glfwGetCocoaMonitor(@NativeType("GLFWmonitor *") long monitor) {
long __functionAddress = Functions.GetCocoaMonitor;
if (CHECKS) {
check(monitor);
}
return invokePI(monitor, __functionAddress);
}
// --- [ glfwGetCocoaWindow ] ---
/**
* Returns the {@code NSWindow} of the specified GLFW window.
*
* <p>Note: This function may be called from any thread. Access is not synchronized.</p>
*
* @param window the GLFW window
*
* @return the {@code NSWindow} of the specified window, or nil if an error occurred.
*
* <p>Possible errors include {@link GLFW#GLFW_NOT_INITIALIZED NOT_INITIALIZED}.</p>
*
* @since version 3.0
*/
@NativeType("id")
public static long glfwGetCocoaWindow(@NativeType("GLFWwindow *") long window) {
long __functionAddress = Functions.GetCocoaWindow;
if (CHECKS) {
check(window);
}
return invokePP(window, __functionAddress);
}
}

View File

@ -1,220 +0,0 @@
/*
* Copyright LWJGL. All rights reserved.
* License terms: https://www.lwjgl.org/license
* MACHINE GENERATED FILE, DO NOT EDIT
*/
package org.lwjgl.glfw;
import org.lwjgl.system.*;
import static org.lwjgl.system.APIUtil.*;
import static org.lwjgl.system.Checks.*;
import static org.lwjgl.system.JNI.*;
import javax.annotation.*;
import static org.lwjgl.system.MemoryUtil.*;
/** Native bindings to the GLFW library's EGL native access functions. */
public class GLFWNativeEGL {
/** Contains the function pointers loaded from {@code GLFW.getLibrary()}. */
public static final class Functions {
private Functions() {}
/** Function address. */
public static final long
GetEGLDisplay = apiGetFunctionAddress(GLFW.getLibrary(), "glfwGetEGLDisplay"),
GetEGLContext = apiGetFunctionAddress(GLFW.getLibrary(), "glfwGetEGLContext"),
GetEGLSurface = apiGetFunctionAddress(GLFW.getLibrary(), "glfwGetEGLSurface"),
GetEGLConfig = apiGetFunctionAddress(GLFW.getLibrary(), "glfwGetEGLConfig");
}
protected GLFWNativeEGL() {
throw new UnsupportedOperationException();
}
// --- [ glfwGetEGLDisplay ] ---
/**
* Returns the {@code EGLDisplay} used by GLFW.
*
* <p>Because EGL is initialized on demand, this function will return {@link EGL10#EGL_NO_DISPLAY} until the first context has been created via EGL.</p>
*
* <p>This function may be called from any thread. Access is not synchronized.</p>
*
* @return the {@code EGLDisplay} used by GLFW, or {@link EGL10#EGL_NO_DISPLAY} if an error occured.
*
* <p>Possible errors include {@link GLFW#GLFW_NOT_INITIALIZED NOT_INITIALIZED}.</p>
*
* @since version 3.0
*/
@NativeType("EGLDisplay")
public static long glfwGetEGLDisplay() {
long __functionAddress = Functions.GetEGLDisplay;
return invokeP(__functionAddress);
}
// --- [ glfwGetEGLContext ] ---
/**
* Returns the {@code EGLContext} of the specified window.
*
* <p>This function may be called from any thread. Access is not synchronized.</p>
*
* @param window a GLFW window
*
* @return the {@code EGLContext} of the specified window, or {@link EGL10#EGL_NO_CONTEXT} if an error occurred.
*
* <p>Possible errors include {@link GLFW#GLFW_NO_WINDOW_CONTEXT NO_WINDOW_CONTEXT} and {@link GLFW#GLFW_NOT_INITIALIZED NOT_INITIALIZED}.</p>
*
* @since version 3.0
*/
@NativeType("EGLContext")
public static long glfwGetEGLContext(@NativeType("GLFWwindow *") long window) {
long __functionAddress = Functions.GetEGLContext;
if (CHECKS) {
check(window);
}
return invokePP(window, __functionAddress);
}
// --- [ glfwGetEGLSurface ] ---
/**
* Returns the {@code EGLSurface} of the specified window.
*
* <p>This function may be called from any thread. Access is not synchronized.</p>
*
* @return the {@code EGLSurface} of the specified window, or {@link EGL10#EGL_NO_SURFACE} if an error occurred.
*
* <p>Possible errors include {@link GLFW#GLFW_NO_WINDOW_CONTEXT NO_WINDOW_CONTEXT} and {@link GLFW#GLFW_NOT_INITIALIZED NOT_INITIALIZED}.</p>
*
* @since version 3.0
*/
@NativeType("EGLSurface")
public static long glfwGetEGLSurface(@NativeType("GLFWwindow *") long window) {
long __functionAddress = Functions.GetEGLSurface;
if (CHECKS) {
check(window);
}
return invokePP(window, __functionAddress);
}
// --- [ glfwGetEGLConfig ] ---
/**
* Returns the {@code EGLConfig} of the specified window.
*
* <p>This function may be called from any thread. Access is not synchronized.</p>
*
* @return the {@code EGLConfig} of the specified window, or {@link EGL10#EGL_NO_SURFACE} if an error occurred.
*
* <p>Possible errors include {@link GLFW#GLFW_NO_WINDOW_CONTEXT NO_WINDOW_CONTEXT} and {@link GLFW#GLFW_NOT_INITIALIZED NOT_INITIALIZED}.</p>
*
* @since version 3.4
*/
@NativeType("EGLConfig")
public static long glfwGetEGLConfig(@NativeType("GLFWwindow *") long window) {
long __functionAddress = Functions.GetEGLConfig;
if (CHECKS) {
check(window);
}
return invokePP(window, __functionAddress);
}
/**
* Calls {@link #setEGLPath(String)} with the path of the specified {@link SharedLibrary}.
*
* <p>Example usage: <code>GLFWNativeEGL.setEGLPath(EGL.getFunctionProvider());</code></p>
*
* @param sharedLibrary a {@code FunctionProvider} instance that will be cast to {@code SharedLibrary}
*/
public static void setEGLPath(FunctionProvider sharedLibrary) {
if (!(sharedLibrary instanceof SharedLibrary)) {
apiLog("GLFW EGL path override not set: Function provider is not a shared library.");
return;
}
String path = ((SharedLibrary)sharedLibrary).getPath();
if (path == null) {
apiLog("GLFW EGL path override not set: Could not resolve the shared library path.");
return;
}
setEGLPath(path);
}
/**
* Overrides the EGL shared library that GLFW loads internally.
*
* <p>This is useful when there's a mismatch between the shared libraries loaded by LWJGL and GLFW.</p>
*
* <p>This method must be called before GLFW initializes EGL. The override is available only in the default GLFW build bundled with LWJGL. Using the
* override with a custom GLFW build will produce a warning in {@code DEBUG} mode (but not an error).</p>
*
* @param path the EGL shared library path, or {@code null} to remove the override.
*/
public static void setEGLPath(@Nullable String path) {
if (!override("_glfw_egl_library", path)) {
apiLog("GLFW EGL path override not set: Could not resolve override symbol.");
}
}
/**
* Calls {@link #setGLESPath(String)} with the path of the specified {@link SharedLibrary}.
*
* <p>Example usage: <code>GLFWNativeEGL.setGLESPath(GLES.getFunctionProvider());</code></p>
*
* @param sharedLibrary a {@code FunctionProvider} instance that will be cast to {@code SharedLibrary}
*/
public static void setGLESPath(FunctionProvider sharedLibrary) {
if (!(sharedLibrary instanceof SharedLibrary)) {
apiLog("GLFW OpenGL ES path override not set: Function provider is not a shared library.");
return;
}
String path = ((SharedLibrary)sharedLibrary).getPath();
if (path == null) {
apiLog("GLFW OpenGL ES path override not set: Could not resolve the shared library path.");
return;
}
setGLESPath(path);
}
/**
* Overrides the OpenGL ES shared library that GLFW loads internally.
*
* <p>This is useful when there's a mismatch between the shared libraries loaded by LWJGL and GLFW.</p>
*
* <p>This method must be called before GLFW initializes OpenGL ES. The override is available only in the default GLFW build bundled with LWJGL. Using the
* override with a custom GLFW build will produce a warning in {@code DEBUG} mode (but not an error).</p>
*
* @param path the OpenGL ES shared library path, or {@code null} to remove the override.
*/
public static void setGLESPath(@Nullable String path) {
if (!override("_glfw_opengles_library", path)) {
apiLog("GLFW OpenGL ES path override not set: Could not resolve override symbol.");
}
}
private static boolean override(String symbol, @Nullable String path) {
long override = GLFW.getLibrary().getFunctionAddress(symbol);
if (override == NULL) {
return false;
}
long a = memGetAddress(override);
if (a != NULL) {
nmemFree(a);
}
memPutAddress(override, path == null ? NULL : memAddress(memUTF8(path)));
return true;
}
}

View File

@ -1,158 +0,0 @@
/*
* Copyright LWJGL. All rights reserved.
* License terms: https://www.lwjgl.org/license
* MACHINE GENERATED FILE, DO NOT EDIT
*/
package org.lwjgl.glfw;
import org.lwjgl.system.*;
import static org.lwjgl.system.APIUtil.*;
import static org.lwjgl.system.Checks.*;
import static org.lwjgl.system.JNI.*;
import javax.annotation.*;
import org.lwjgl.opengl.GL;
import static org.lwjgl.system.MemoryUtil.*;
/** Native bindings to the GLFW library's GLX native access functions. */
public class GLFWNativeGLX {
/** Contains the function pointers loaded from {@code GLFW.getLibrary()}. */
public static final class Functions {
private Functions() {}
/** Function address. */
public static final long
GetGLXContext = apiGetFunctionAddress(GLFW.getLibrary(), "glfwGetGLXContext"),
GetGLXWindow = apiGetFunctionAddress(GLFW.getLibrary(), "glfwGetGLXWindow"),
GetGLXFBConfig = apiGetFunctionAddress(GLFW.getLibrary(), "glfwGetGLXFBConfig");
}
protected GLFWNativeGLX() {
throw new UnsupportedOperationException();
}
// --- [ glfwGetGLXContext ] ---
/**
* Returns the {@code GLXContext} of the specified window.
*
* <p>This function may be called from any thread. Access is not synchronized.</p>
*
* @param window a GLFW window
*
* @return the {@code GLXContext} of the specified window, or {@code NULL} if an error occurred.
*
* <p>Possible errors include {@link GLFW#GLFW_NO_WINDOW_CONTEXT NO_WINDOW_CONTEXT} and {@link GLFW#GLFW_NOT_INITIALIZED NOT_INITIALIZED}.</p>
*
* @since version 3.0
*/
@NativeType("GLXContext")
public static long glfwGetGLXContext(@NativeType("GLFWwindow *") long window) {
long __functionAddress = Functions.GetGLXContext;
if (CHECKS) {
check(window);
}
return invokePP(window, __functionAddress);
}
// --- [ glfwGetGLXWindow ] ---
/**
* Returns the {@code GLXWindow} of the specified window.
*
* <p>This function may be called from any thread. Access is not synchronized.</p>
*
* @param window a GLFW window
*
* @return the {@code GLXWindow} of the specified window, or {@code None} if an error occurred.
*
* <p>Possible errors include {@link GLFW#GLFW_NO_WINDOW_CONTEXT NO_WINDOW_CONTEXT} and {@link GLFW#GLFW_NOT_INITIALIZED NOT_INITIALIZED}.</p>
*
* @since version 3.2
*/
@NativeType("GLXWindow")
public static long glfwGetGLXWindow(@NativeType("GLFWwindow *") long window) {
long __functionAddress = Functions.GetGLXWindow;
if (CHECKS) {
check(window);
}
return invokePP(window, __functionAddress);
}
// --- [ glfwGetGLXFBConfig ] ---
/**
* Returns the {@code GLXFBConfig} that was chosen to create the specified window.
*
* <p>This function may be called from any thread. Access is not synchronized.</p>
*
* @param window a GLFW window
*
* @return the {@code GLXFBConfig} that was chosen to create the specified window, or {@code NULL} if an error occurred.
*
* <p>Possible errors include {@link GLFW#GLFW_NO_WINDOW_CONTEXT NO_WINDOW_CONTEXT} and {@link GLFW#GLFW_NOT_INITIALIZED NOT_INITIALIZED}.</p>
*
* @since version 3.4
*/
@NativeType("GLXWindow")
public static long glfwGetGLXFBConfig(@NativeType("GLFWwindow *") long window) {
long __functionAddress = Functions.GetGLXFBConfig;
if (CHECKS) {
check(window);
}
return invokePP(window, __functionAddress);
}
/**
* Calls {@link #setPath(String)} with the path of the specified {@link SharedLibrary}.
*
* <p>Example usage: <code>GLFWNativeGLX.setPath(GL.getFunctionProvider());</code></p>
*
* @param sharedLibrary a {@code FunctionProvider} instance that will be cast to {@code SharedLibrary}
*/
public static void setPath(FunctionProvider sharedLibrary) {
if (!(sharedLibrary instanceof SharedLibrary)) {
apiLog("GLFW OpenGL path override not set: Function provider is not a shared library.");
return;
}
String path = ((SharedLibrary)sharedLibrary).getPath();
if (path == null) {
apiLog("GLFW OpenGL path override not set: Could not resolve the shared library path.");
return;
}
setPath(path);
}
/**
* Overrides the OpenGL shared library that GLFW loads internally.
*
* <p>This is useful when there's a mismatch between the shared libraries loaded by LWJGL and GLFW.</p>
*
* <p>This method must be called before GLFW initializes OpenGL. The override is available only in the default GLFW build bundled with LWJGL. Using the
* override with a custom GLFW build will produce a warning in {@code DEBUG} mode (but not an error).</p>
*
* @param path the OpenGL shared library path, or {@code null} to remove the override.
*/
public static void setPath(@Nullable String path) {
long override = GLFW.getLibrary().getFunctionAddress("_glfw_opengl_library");
if (override == NULL) {
apiLog("GLFW OpenGL path override not set: Could not resolve override symbol.");
return;
}
long a = memGetAddress(override);
if (a != NULL) {
nmemFree(a);
}
memPutAddress(override, path == null ? NULL : memAddress(memUTF8(path)));
}
}

View File

@ -1,62 +0,0 @@
/*
* Copyright LWJGL. All rights reserved.
* License terms: https://www.lwjgl.org/license
* MACHINE GENERATED FILE, DO NOT EDIT
*/
package org.lwjgl.glfw;
import org.lwjgl.system.*;
import static org.lwjgl.system.APIUtil.*;
import static org.lwjgl.system.Checks.*;
import static org.lwjgl.system.JNI.*;
import javax.annotation.*;
import org.lwjgl.opengl.GL;
import org.lwjgl.system.macosx.*;
import static org.lwjgl.system.MemoryUtil.*;
/** Native bindings to the GLFW library's NSGL native access functions. */
public class GLFWNativeNSGL {
/** Contains the function pointers loaded from {@code GLFW.getLibrary()}. */
public static final class Functions {
private Functions() {}
/** Function address. */
public static final long
GetNSGLContext = apiGetFunctionAddress(GLFW.getLibrary(), "glfwGetNSGLContext");
}
protected GLFWNativeNSGL() {
throw new UnsupportedOperationException();
}
// --- [ glfwGetNSGLContext ] ---
/**
* Returns the {@code NSOpenGLContext} of the specified GLFW window.
*
* <p>Note: This function may be called from any thread. Access is not synchronized.</p>
*
* @param window the GLFW window
*
* @return the {@code NSOpenGLContext} of the specified window, or nil if an error occurred.
*
* <p>Possible errors include {@link GLFW#GLFW_NO_WINDOW_CONTEXT NO_WINDOW_CONTEXT} and {@link GLFW#GLFW_NOT_INITIALIZED NOT_INITIALIZED}.</p>
*
* @since version 3.0
*/
@NativeType("id")
public static long glfwGetNSGLContext(@NativeType("GLFWwindow *") long window) {
long __functionAddress = Functions.GetNSGLContext;
if (CHECKS) {
check(window);
}
return invokePP(window, __functionAddress);
}
}

View File

@ -1,220 +0,0 @@
/*
* Copyright LWJGL. All rights reserved.
* License terms: https://www.lwjgl.org/license
* MACHINE GENERATED FILE, DO NOT EDIT
*/
package org.lwjgl.glfw;
import javax.annotation.*;
import java.nio.*;
import org.lwjgl.*;
import org.lwjgl.system.*;
import static org.lwjgl.system.APIUtil.*;
import static org.lwjgl.system.Checks.*;
import static org.lwjgl.system.JNI.*;
import static org.lwjgl.system.MemoryUtil.*;
import javax.annotation.*;
import org.lwjgl.opengl.GL;
import static org.lwjgl.system.MemoryUtil.*;
/** Native bindings to the GLFW library's GLX native access functions. */
public class GLFWNativeOSMesa {
/** Contains the function pointers loaded from {@code GLFW.getLibrary()}. */
public static final class Functions {
private Functions() {}
/** Function address. */
public static final long
GetOSMesaColorBuffer = apiGetFunctionAddress(GLFW.getLibrary(), "glfwGetOSMesaColorBuffer"),
GetOSMesaDepthBuffer = apiGetFunctionAddress(GLFW.getLibrary(), "glfwGetOSMesaDepthBuffer"),
GetOSMesaContext = apiGetFunctionAddress(GLFW.getLibrary(), "glfwGetOSMesaContext");
}
protected GLFWNativeOSMesa() {
throw new UnsupportedOperationException();
}
// --- [ glfwGetOSMesaColorBuffer ] ---
/** Unsafe version of: {@link #glfwGetOSMesaColorBuffer GetOSMesaColorBuffer} */
public static int nglfwGetOSMesaColorBuffer(long window, long width, long height, long format, long buffer) {
long __functionAddress = Functions.GetOSMesaColorBuffer;
if (CHECKS) {
check(window);
}
return invokePPPPPI(window, width, height, format, buffer, __functionAddress);
}
/**
* Retrieves the color buffer associated with the specified window.
*
* <p>This function may be called from any thread. Access is not synchronized.</p>
*
* @param window the window whose color buffer to retrieve
* @param width where to store the width of the color buffer, or {@code NULL}
* @param height where to store the height of the color buffer, or {@code NULL}
* @param format where to store the OSMesa pixel format of the color buffer, or {@code NULL}
* @param buffer where to store the address of the color buffer, or {@code NULL}
*
* @return {@link GLFW#GLFW_TRUE TRUE} if successful, or {@link GLFW#GLFW_FALSE FALSE} if an error occurred.
*
* <p>Possible errors include {@link GLFW#GLFW_NO_WINDOW_CONTEXT NO_WINDOW_CONTEXT} and {@link GLFW#GLFW_NOT_INITIALIZED NOT_INITIALIZED}.</p>
*
* @since version 3.3
*/
@NativeType("int")
public static boolean glfwGetOSMesaColorBuffer(@NativeType("GLFWwindow *") long window, @Nullable @NativeType("int *") IntBuffer width, @Nullable @NativeType("int *") IntBuffer height, @Nullable @NativeType("int *") IntBuffer format, @Nullable @NativeType("void **") PointerBuffer buffer) {
if (CHECKS) {
checkSafe(width, 1);
checkSafe(height, 1);
checkSafe(format, 1);
checkSafe(buffer, 1);
}
return nglfwGetOSMesaColorBuffer(window, memAddressSafe(width), memAddressSafe(height), memAddressSafe(format), memAddressSafe(buffer)) != 0;
}
// --- [ glfwGetOSMesaDepthBuffer ] ---
/** Unsafe version of: {@link #glfwGetOSMesaDepthBuffer GetOSMesaDepthBuffer} */
public static int nglfwGetOSMesaDepthBuffer(long window, long width, long height, long bytesPerValue, long buffer) {
long __functionAddress = Functions.GetOSMesaDepthBuffer;
if (CHECKS) {
check(window);
}
return invokePPPPPI(window, width, height, bytesPerValue, buffer, __functionAddress);
}
/**
* Retrieves the depth buffer associated with the specified window.
*
* <p>This function may be called from any thread. Access is not synchronized.</p>
*
* @param window the window whose depth buffer to retrieve
* @param width where to store the width of the depth buffer, or {@code NULL}
* @param height where to store the height of the depth buffer, or {@code NULL}
* @param bytesPerValue where to store the number of bytes per depth buffer element, or {@code NULL}
* @param buffer where to store the address of the depth buffer, or {@code NULL}
*
* @return {@link GLFW#GLFW_TRUE TRUE} if successful, or {@link GLFW#GLFW_FALSE FALSE} if an error occurred.
*
* <p>Possible errors include {@link GLFW#GLFW_NO_WINDOW_CONTEXT NO_WINDOW_CONTEXT} and {@link GLFW#GLFW_NOT_INITIALIZED NOT_INITIALIZED}.</p>
*
* @since version 3.3
*/
public static int glfwGetOSMesaDepthBuffer(@NativeType("GLFWwindow *") long window, @Nullable @NativeType("int *") IntBuffer width, @Nullable @NativeType("int *") IntBuffer height, @Nullable @NativeType("int *") IntBuffer bytesPerValue, @Nullable @NativeType("void **") PointerBuffer buffer) {
if (CHECKS) {
checkSafe(width, 1);
checkSafe(height, 1);
checkSafe(bytesPerValue, 1);
checkSafe(buffer, 1);
}
return nglfwGetOSMesaDepthBuffer(window, memAddressSafe(width), memAddressSafe(height), memAddressSafe(bytesPerValue), memAddressSafe(buffer));
}
// --- [ glfwGetOSMesaContext ] ---
/**
* Returns the {@code OSMesaContext} of the specified window.
*
* <p>This function may be called from any thread. Access is not synchronized.</p>
*
* @param window the window whose context to retrieve
*
* @return the {@code OSMesaContext} of the specified window, or {@code NULL} if an error occurred.
*
* <p>Possible errors include {@link GLFW#GLFW_NO_WINDOW_CONTEXT NO_WINDOW_CONTEXT} and {@link GLFW#GLFW_NOT_INITIALIZED NOT_INITIALIZED}.</p>
*
* @since version 3.3
*/
@NativeType("OSMesaContext")
public static long glfwGetOSMesaContext(@NativeType("GLFWwindow *") long window) {
long __functionAddress = Functions.GetOSMesaContext;
if (CHECKS) {
check(window);
}
return invokePP(window, __functionAddress);
}
/** Array version of: {@link #glfwGetOSMesaColorBuffer GetOSMesaColorBuffer} */
@NativeType("int")
public static boolean glfwGetOSMesaColorBuffer(@NativeType("GLFWwindow *") long window, @Nullable @NativeType("int *") int[] width, @Nullable @NativeType("int *") int[] height, @Nullable @NativeType("int *") int[] format, @Nullable @NativeType("void **") PointerBuffer buffer) {
long __functionAddress = Functions.GetOSMesaColorBuffer;
if (CHECKS) {
check(window);
checkSafe(width, 1);
checkSafe(height, 1);
checkSafe(format, 1);
checkSafe(buffer, 1);
}
return invokePPPPPI(window, width, height, format, memAddressSafe(buffer), __functionAddress) != 0;
}
/** Array version of: {@link #glfwGetOSMesaDepthBuffer GetOSMesaDepthBuffer} */
public static int glfwGetOSMesaDepthBuffer(@NativeType("GLFWwindow *") long window, @Nullable @NativeType("int *") int[] width, @Nullable @NativeType("int *") int[] height, @Nullable @NativeType("int *") int[] bytesPerValue, @Nullable @NativeType("void **") PointerBuffer buffer) {
long __functionAddress = Functions.GetOSMesaDepthBuffer;
if (CHECKS) {
check(window);
checkSafe(width, 1);
checkSafe(height, 1);
checkSafe(bytesPerValue, 1);
checkSafe(buffer, 1);
}
return invokePPPPPI(window, width, height, bytesPerValue, memAddressSafe(buffer), __functionAddress);
}
/**
* Calls {@link #setPath(String)} with the path of the specified {@link SharedLibrary}.
*
* <p>Example usage: <code>GLFWNativeOSMesa.setPath(GL.getFunctionProvider());</code></p>
*
* @param sharedLibrary a {@code FunctionProvider} instance that will be cast to {@code SharedLibrary}
*/
public static void setPath(FunctionProvider sharedLibrary) {
if (!(sharedLibrary instanceof SharedLibrary)) {
apiLog("GLFW OSMesa path override not set: Function provider is not a shared library.");
return;
}
String path = ((SharedLibrary)sharedLibrary).getPath();
if (path == null) {
apiLog("GLFW OSMesa path override not set: Could not resolve the OSMesa shared library path.");
return;
}
setPath(path);
}
/**
* Overrides the OSMesa shared library that GLFW loads internally.
*
* <p>This is useful when there's a mismatch between the shared libraries loaded by LWJGL and GLFW.</p>
*
* <p>This method must be called before GLFW initializes OpenGL. The override is available only in the default GLFW build bundled with LWJGL. Using the
* override with a custom GLFW build will produce a warning in {@code DEBUG} mode (but not an error).</p>
*
* @param path the OSMesa shared library path, or {@code null} to remove the override.
*/
public static void setPath(@Nullable String path) {
long override = GLFW.getLibrary().getFunctionAddress("_glfw_mesa_library");
if (override == NULL) {
apiLog("GLFW OSMesa path override not set: Could not resolve override symbol.");
return;
}
long a = memGetAddress(override);
if (a != NULL) {
nmemFree(a);
}
memPutAddress(override, path == null ? NULL : memAddress(memUTF8(path)));
}
}

View File

@ -1,113 +0,0 @@
/*
* Copyright LWJGL. All rights reserved.
* License terms: https://www.lwjgl.org/license
* MACHINE GENERATED FILE, DO NOT EDIT
*/
package org.lwjgl.glfw;
import org.lwjgl.system.*;
import static org.lwjgl.system.APIUtil.*;
import static org.lwjgl.system.Checks.*;
import static org.lwjgl.system.JNI.*;
import javax.annotation.*;
import org.lwjgl.opengl.GL;
import static org.lwjgl.system.MemoryUtil.*;
/** Native bindings to the GLFW library's WGL native access functions. */
public class GLFWNativeWGL {
/** Contains the function pointers loaded from {@code GLFW.getLibrary()}. */
public static final class Functions {
private Functions() {}
/** Function address. */
public static final long
GetWGLContext = apiGetFunctionAddress(GLFW.getLibrary(), "glfwGetWGLContext");
}
protected GLFWNativeWGL() {
throw new UnsupportedOperationException();
}
// --- [ glfwGetWGLContext ] ---
/**
* Returns the {@code HGLRC} of the specified window.
*
* <p>The {@code HDC} associated with the window can be queried with the
* <a href="https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getdc">GetDC</a> function.
* <code>
* HDC dc = GetDC(glfwGetWin32Window(window));</code>
* This DC is private and does not need to be released.</p>
*
* <p>Note: This function may be called from any thread. Access is not synchronized.</p>
*
* @param window the GLFW window
*
* @return the {@code HGLRC} of the specified window, or {@code NULL} if an error occurred.
*
* <p>Possible errors include {@link GLFW#GLFW_NO_WINDOW_CONTEXT NO_WINDOW_CONTEXT} and {@link GLFW#GLFW_NOT_INITIALIZED NOT_INITIALIZED}.</p>
*
* @since version 3.0
*/
@NativeType("HGLRC")
public static long glfwGetWGLContext(@NativeType("GLFWwindow *") long window) {
long __functionAddress = Functions.GetWGLContext;
if (CHECKS) {
check(window);
}
return invokePP(window, __functionAddress);
}
/**
* Calls {@link #setPath(String)} with the path of the specified {@link SharedLibrary}.
*
* <p>Example usage: <code>GLFWNativeWGL.setPath(GL.getFunctionProvider());</code></p>
*
* @param sharedLibrary a {@code FunctionProvider} instance that will be cast to {@code SharedLibrary}
*/
public static void setPath(FunctionProvider sharedLibrary) {
if (!(sharedLibrary instanceof SharedLibrary)) {
apiLog("GLFW OpenGL path override not set: Function provider is not a shared library.");
return;
}
String path = ((SharedLibrary)sharedLibrary).getPath();
if (path == null) {
apiLog("GLFW OpenGL path override not set: Could not resolve the shared library path.");
return;
}
setPath(path);
}
/**
* Overrides the OpenGL shared library that GLFW loads internally.
*
* <p>This is useful when there's a mismatch between the shared libraries loaded by LWJGL and GLFW.</p>
*
* <p>This method must be called before GLFW initializes OpenGL. The override is available only in the default GLFW build bundled with LWJGL. Using the
* override with a custom GLFW build will produce a warning in {@code DEBUG} mode (but not an error).</p>
*
* @param path the OpenGL shared library path, or {@code null} to remove the override.
*/
public static void setPath(@Nullable String path) {
long override = GLFW.getLibrary().getFunctionAddress("_glfw_opengl_library");
if (override == NULL) {
apiLog("GLFW OpenGL path override not set: Could not resolve override symbol.");
return;
}
long a = memGetAddress(override);
if (a != NULL) {
nmemFree(a);
}
memPutAddress(override, path == null ? NULL : memAddress(memUTF16(path)));
}
}

View File

@ -1,97 +0,0 @@
/*
* Copyright LWJGL. All rights reserved.
* License terms: https://www.lwjgl.org/license
* MACHINE GENERATED FILE, DO NOT EDIT
*/
package org.lwjgl.glfw;
import org.lwjgl.system.*;
import static org.lwjgl.system.APIUtil.*;
import static org.lwjgl.system.Checks.*;
import static org.lwjgl.system.JNI.*;
/** Native bindings to the GLFW library's Wayland native access functions. */
public class GLFWNativeWayland {
/** Contains the function pointers loaded from {@code GLFW.getLibrary()}. */
public static final class Functions {
private Functions() {}
/** Function address. */
public static final long
GetWaylandDisplay = apiGetFunctionAddress(GLFW.getLibrary(), "glfwGetWaylandDisplay"),
GetWaylandMonitor = apiGetFunctionAddress(GLFW.getLibrary(), "glfwGetWaylandMonitor"),
GetWaylandWindow = apiGetFunctionAddress(GLFW.getLibrary(), "glfwGetWaylandWindow");
}
protected GLFWNativeWayland() {
throw new UnsupportedOperationException();
}
// --- [ glfwGetWaylandDisplay ] ---
/**
* Returns the {@code struct wl_display*} used by GLFW.
*
* <p>This function may be called from any thread. Access is not synchronized.</p>
*
* @return the {@code struct wl_display*} used by GLFW, or {@code NULL} if an error occurred.
*
* <p>Possible errors include {@link GLFW#GLFW_NOT_INITIALIZED NOT_INITIALIZED}.</p>
*
* @since version 3.2
*/
@NativeType("struct wl_display *")
public static long glfwGetWaylandDisplay() {
long __functionAddress = Functions.GetWaylandDisplay;
return invokeP(__functionAddress);
}
// --- [ glfwGetWaylandMonitor ] ---
/**
* Returns the {@code struct wl_output*} of the specified monitor.
*
* <p>This function may be called from any thread. Access is not synchronized.</p>
*
* @return the {@code struct wl_output*} of the specified monitor, or {@code NULL} if an error occurred.
*
* <p>Possible errors include {@link GLFW#GLFW_NOT_INITIALIZED NOT_INITIALIZED}.</p>
*
* @since version 3.2
*/
@NativeType("struct wl_output *")
public static long glfwGetWaylandMonitor(@NativeType("GLFWmonitor *") long monitor) {
long __functionAddress = Functions.GetWaylandMonitor;
if (CHECKS) {
check(monitor);
}
return invokePP(monitor, __functionAddress);
}
// --- [ glfwGetWaylandWindow ] ---
/**
* Returns the main {@code struct wl_surface*} of the specified window.
*
* <p>This function may be called from any thread. Access is not synchronized.</p>
*
* @return the main {@code struct wl_surface*} of the specified window, or {@code NULL} if an error occurred.
*
* <p>Possible errors include {@link GLFW#GLFW_NOT_INITIALIZED NOT_INITIALIZED}.</p>
*
* @since version 3.2
*/
@NativeType("struct wl_surface *")
public static long glfwGetWaylandWindow(@NativeType("GLFWwindow *") long window) {
long __functionAddress = Functions.GetWaylandWindow;
if (CHECKS) {
check(window);
}
return invokePP(window, __functionAddress);
}
}

View File

@ -1,158 +0,0 @@
/*
* Copyright LWJGL. All rights reserved.
* License terms: https://www.lwjgl.org/license
* MACHINE GENERATED FILE, DO NOT EDIT
*/
package org.lwjgl.glfw;
import javax.annotation.*;
import org.lwjgl.system.*;
import static org.lwjgl.system.APIUtil.*;
import static org.lwjgl.system.Checks.*;
import static org.lwjgl.system.JNI.*;
import static org.lwjgl.system.MemoryUtil.*;
/** Native bindings to the GLFW library's Win32 native access functions. */
public class GLFWNativeWin32 {
/** Contains the function pointers loaded from {@code GLFW.getLibrary()}. */
public static final class Functions {
private Functions() {}
/** Function address. */
public static final long
GetWin32Adapter = apiGetFunctionAddress(GLFW.getLibrary(), "glfwGetWin32Adapter"),
GetWin32Monitor = apiGetFunctionAddress(GLFW.getLibrary(), "glfwGetWin32Monitor"),
GetWin32Window = apiGetFunctionAddress(GLFW.getLibrary(), "glfwGetWin32Window"),
AttachWin32Window = apiGetFunctionAddress(GLFW.getLibrary(), "glfwAttachWin32Window");
}
protected GLFWNativeWin32() {
throw new UnsupportedOperationException();
}
// --- [ glfwGetWin32Adapter ] ---
/** Unsafe version of: {@link #glfwGetWin32Adapter GetWin32Adapter} */
public static long nglfwGetWin32Adapter(long monitor) {
long __functionAddress = Functions.GetWin32Adapter;
if (CHECKS) {
check(monitor);
}
return invokePP(monitor, __functionAddress);
}
/**
* Returns the adapter device name of the specified monitor.
*
* <p>Note: This function may be called from any thread. Access is not synchronized.</p>
*
* @param monitor the GLFW monitor
*
* @return the UTF-8 encoded adapter device name (for example `\\.\DISPLAY1`) of the specified monitor, or {@code NULL} if an error occurred.
*
* <p>Possible errors include {@link GLFW#GLFW_NOT_INITIALIZED NOT_INITIALIZED}.</p>
*
* @since version 3.1
*/
@Nullable
@NativeType("char const *")
public static String glfwGetWin32Adapter(@NativeType("GLFWmonitor *") long monitor) {
long __result = nglfwGetWin32Adapter(monitor);
return memUTF8Safe(__result);
}
// --- [ glfwGetWin32Monitor ] ---
/** Unsafe version of: {@link #glfwGetWin32Monitor GetWin32Monitor} */
public static long nglfwGetWin32Monitor(long monitor) {
long __functionAddress = Functions.GetWin32Monitor;
if (CHECKS) {
check(monitor);
}
return invokePP(monitor, __functionAddress);
}
/**
* Returns the display device name of the specified monitor.
*
* <p>Note: This function may be called from any thread. Access is not synchronized.</p>
*
* @param monitor the GLFW monitor
*
* @return the UTF-8 encoded display device name (for example `\\.\DISPLAY1\Monitor0`) of the specified monitor, or {@code NULL} if an error occurred.
*
* <p>Possible errors include {@link GLFW#GLFW_NOT_INITIALIZED NOT_INITIALIZED}.</p>
*
* @since version 3.1
*/
@Nullable
@NativeType("char const *")
public static String glfwGetWin32Monitor(@NativeType("GLFWmonitor *") long monitor) {
long __result = nglfwGetWin32Monitor(monitor);
return memUTF8Safe(__result);
}
// --- [ glfwGetWin32Window ] ---
/**
* Returns the {@code HWND} of the specified window.
*
* <p>The {@code HDC} associated with the window can be queried with the
* <a href="https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getdc">GetDC</a> function.
* <code>
* HDC dc = GetDC(glfwGetWin32Window(window));</code>
* This DC is private and does not need to be released.</p>
*
* <p>Note: This function may be called from any thread. Access is not synchronized.</p>
*
* @param window the GLFW window
*
* @return the {@code HWND} of the specified window, or {@code NULL} if an error occurred.
*
* <p>Possible errors include {@link GLFW#GLFW_NOT_INITIALIZED NOT_INITIALIZED}.</p>
*
* @since version 3.0
*/
@NativeType("HWND")
public static long glfwGetWin32Window(@NativeType("GLFWwindow *") long window) {
long __functionAddress = Functions.GetWin32Window;
if (CHECKS) {
check(window);
}
return invokePP(window, __functionAddress);
}
// --- [ glfwAttachWin32Window ] ---
/**
* Wraps an existing {@code HWND} in a new GLFW window object.
*
* <p>This function creates a GLFW window object and its associated OpenGL or OpenGL ES context for an existing {@code HWND}. The {@code HWND} is not
* destroyed by GLFW.</p>
*
* <p>This function may be called from any thread.</p>
*
* <p><b>LWJGL</b>: This functionality is experimental and not officially supported by GLFW yet.</p>
*
* @param handle the {@code HWND} to attach to the window object
* @param share the window whose context to share resources with, or {@code NULL} to not share resources
*
* @return the handle of the created window, or {@code NULL} if an error occurred
*
* @since version 3.3
*/
@NativeType("GLFWwindow *")
public static long glfwAttachWin32Window(@NativeType("HWND") long handle, @NativeType("GLFWwindow *") long share) {
long __functionAddress = Functions.AttachWin32Window;
if (CHECKS) {
check(handle);
}
return invokePPP(handle, share, __functionAddress);
}
}

View File

@ -1,207 +0,0 @@
/*
* Copyright LWJGL. All rights reserved.
* License terms: https://www.lwjgl.org/license
* MACHINE GENERATED FILE, DO NOT EDIT
*/
package org.lwjgl.glfw;
import javax.annotation.*;
import java.nio.*;
import org.lwjgl.system.*;
import static org.lwjgl.system.APIUtil.*;
import static org.lwjgl.system.Checks.*;
import static org.lwjgl.system.JNI.*;
import static org.lwjgl.system.MemoryStack.*;
import static org.lwjgl.system.MemoryUtil.*;
/** Native bindings to the GLFW library's X11 native access functions. */
public class GLFWNativeX11 {
/** Contains the function pointers loaded from {@code GLFW.getLibrary()}. */
public static final class Functions {
private Functions() {}
/** Function address. */
public static final long
GetX11Display = apiGetFunctionAddress(GLFW.getLibrary(), "glfwGetX11Display"),
GetX11Adapter = apiGetFunctionAddress(GLFW.getLibrary(), "glfwGetX11Adapter"),
GetX11Monitor = apiGetFunctionAddress(GLFW.getLibrary(), "glfwGetX11Monitor"),
GetX11Window = apiGetFunctionAddress(GLFW.getLibrary(), "glfwGetX11Window"),
SetX11SelectionString = apiGetFunctionAddress(GLFW.getLibrary(), "glfwSetX11SelectionString"),
GetX11SelectionString = apiGetFunctionAddress(GLFW.getLibrary(), "glfwGetX11SelectionString");
}
protected GLFWNativeX11() {
throw new UnsupportedOperationException();
}
// --- [ glfwGetX11Display ] ---
/**
* Returns the {@code Display} used by GLFW.
*
* <p>Note: This function may be called from any thread. Access is not synchronized.</p>
*
* @return the {@code Display} used by GLFW, or {@code NULL} if an error occurred.
*
* <p>Possible errors include {@link GLFW#GLFW_NOT_INITIALIZED NOT_INITIALIZED}.</p>
*
* @since version 3.0
*/
@NativeType("Display *")
public static long glfwGetX11Display() {
long __functionAddress = Functions.GetX11Display;
return invokeP(__functionAddress);
}
// --- [ glfwGetX11Adapter ] ---
/**
* Returns the {@code RRCrtc} of the specified monitor.
*
* <p>Note: This function may be called from any thread. Access is not synchronized.</p>
*
* @param monitor the GLFW monitor
*
* @return the {@code RRCrtc} of the specified monitor, or {@code None} if an error occurred.
*
* <p>Possible errors include {@link GLFW#GLFW_NOT_INITIALIZED NOT_INITIALIZED}.</p>
*
* @since version 3.1
*/
@NativeType("RRCrtc")
public static long glfwGetX11Adapter(@NativeType("GLFWmonitor *") long monitor) {
long __functionAddress = Functions.GetX11Adapter;
if (CHECKS) {
check(monitor);
}
return invokePN(monitor, __functionAddress);
}
// --- [ glfwGetX11Monitor ] ---
/**
* Returns the {@code RROutput} of the specified monitor.
*
* <p>Note: This function may be called from any thread. Access is not synchronized.</p>
*
* @param monitor the GLFW monitor
*
* @return the {@code RROutput} of the specified monitor, or {@code None} if an error occurred.
*
* <p>Possible errors include {@link GLFW#GLFW_NOT_INITIALIZED NOT_INITIALIZED}.</p>
*
* @since version 3.1
*/
@NativeType("RROutput")
public static long glfwGetX11Monitor(@NativeType("GLFWmonitor *") long monitor) {
long __functionAddress = Functions.GetX11Monitor;
if (CHECKS) {
check(monitor);
}
return invokePN(monitor, __functionAddress);
}
// --- [ glfwGetX11Window ] ---
/**
* Returns the {@code Window} of the specified window.
*
* <p>Note: This function may be called from any thread. Access is not synchronized.</p>
*
* @param window a GLFW window
*
* @return the {@code Window} of the specified window, or {@code None} if an error occurred.
*
* <p>Possible errors include {@link GLFW#GLFW_NOT_INITIALIZED NOT_INITIALIZED}.</p>
*
* @since version 3.0
*/
@NativeType("Window")
public static long glfwGetX11Window(@NativeType("GLFWwindow *") long window) {
long __functionAddress = Functions.GetX11Window;
if (CHECKS) {
check(window);
}
return invokePN(window, __functionAddress);
}
// --- [ glfwSetX11SelectionString ] ---
/** Unsafe version of: {@link #glfwSetX11SelectionString SetX11SelectionString} */
public static void nglfwSetX11SelectionString(long string) {
long __functionAddress = Functions.SetX11SelectionString;
invokePV(string, __functionAddress);
}
/**
* Sets the current primary selection to the specified string.
*
* <p>This function must only be called from the main thread.</p>
*
* @param string a UTF-8 encoded string. The specified string is copied before this function returns.
*
* @since version 3.3
*/
public static void glfwSetX11SelectionString(@NativeType("char const *") ByteBuffer string) {
if (CHECKS) {
checkNT1(string);
}
nglfwSetX11SelectionString(memAddress(string));
}
/**
* Sets the current primary selection to the specified string.
*
* <p>This function must only be called from the main thread.</p>
*
* @param string a UTF-8 encoded string. The specified string is copied before this function returns.
*
* @since version 3.3
*/
public static void glfwSetX11SelectionString(@NativeType("char const *") CharSequence string) {
MemoryStack stack = stackGet(); int stackPointer = stack.getPointer();
try {
stack.nUTF8(string, true);
long stringEncoded = stack.getPointerAddress();
nglfwSetX11SelectionString(stringEncoded);
} finally {
stack.setPointer(stackPointer);
}
}
// --- [ glfwGetX11SelectionString ] ---
/** Unsafe version of: {@link #glfwGetX11SelectionString GetX11SelectionString} */
public static long nglfwGetX11SelectionString() {
long __functionAddress = Functions.GetX11SelectionString;
return invokeP(__functionAddress);
}
/**
* Returns the contents of the current primary selection as a string.
*
* <p>If the selection is empty or if its contents cannot be converted, {@code NULL} is returned and a {@link GLFW#GLFW_FORMAT_UNAVAILABLE FORMAT_UNAVAILABLE} error is generated.</p>
*
* <p>The returned string is allocated and freed by GLFW. You should not free it yourself. It is valid until the next call to {@link #glfwGetX11SelectionString GetX11SelectionString} or
* {@link #glfwSetX11SelectionString SetX11SelectionString}, or until the library is terminated.</p>
*
* <p>This function must only be called from the main thread.</p>
*
* @return the contents of the selection as a UTF-8 encoded string, or {@code NULL} if an error occurred
*
* @since version 3.3
*/
@Nullable
@NativeType("char const *")
public static String glfwGetX11SelectionString() {
long __result = nglfwGetX11SelectionString();
return memUTF8Safe(__result);
}
}

View File

@ -1,103 +0,0 @@
/*
* Copyright LWJGL. All rights reserved.
* License terms: https://www.lwjgl.org/license
* MACHINE GENERATED FILE, DO NOT EDIT
*/
package org.lwjgl.glfw;
import javax.annotation.*;
import org.lwjgl.system.*;
import static org.lwjgl.system.MemoryUtil.*;
/**
* The function pointer type for memory reallocation callbacks.
*
* <p>This is the function pointer type for memory reallocation callbacks. A memory reallocation callback function has the following signature:</p>
*
* <pre><code>
* void* function_name(void* block, size_t size, void* user) </code></pre>
*
* <p>This function must return a memory block at least {@code size} bytes long, or {@code NULL} if allocation failed. Note that not all parts of GLFW handle
* allocation failures gracefully yet.</p>
*
* <p>This function may be called during {@link GLFW#glfwInit Init} but before the library is flagged as initialized, as well as during {@link GLFW#glfwTerminate Terminate} after the library is no
* longer flagged as initialized.</p>
*
* <p>Any memory allocated by this function will be deallocated during library termination or earlier.</p>
*
* <p>The block address will never be {@code NULL} and the size will always be greater than zero. Reallocations of a block to size zero are converted into
* deallocations. Reallocations of {@code NULL} to a non-zero size are converted into regular allocations.</p>
*
* <div style="margin-left: 26px; border-left: 1px solid gray; padding-left: 14px;"><h5>Note</h5>
*
* <ul>
* <li>The returned memory block must be valid at least until it is deallocated.</li>
* <li>This function should not call any GLFW function.</li>
* <li>This function may be called from any thread that calls GLFW functions.</li>
* </ul></div>
*
* <h3>Type</h3>
*
* <pre><code>
* void * (*{@link #invoke}) (
* void *block,
* size_t size,
* void *user
* )</code></pre>
*
* @since version 3.4
*/
public abstract class GLFWReallocateCallback extends Callback implements GLFWReallocateCallbackI {
/**
* Creates a {@code GLFWReallocateCallback} instance from the specified function pointer.
*
* @return the new {@code GLFWReallocateCallback}
*/
public static GLFWReallocateCallback create(long functionPointer) {
GLFWReallocateCallbackI instance = Callback.get(functionPointer);
return instance instanceof GLFWReallocateCallback
? (GLFWReallocateCallback)instance
: new Container(functionPointer, instance);
}
/** Like {@link #create(long) create}, but returns {@code null} if {@code functionPointer} is {@code NULL}. */
@Nullable
public static GLFWReallocateCallback createSafe(long functionPointer) {
return functionPointer == NULL ? null : create(functionPointer);
}
/** Creates a {@code GLFWReallocateCallback} instance that delegates to the specified {@code GLFWReallocateCallbackI} instance. */
public static GLFWReallocateCallback create(GLFWReallocateCallbackI instance) {
return instance instanceof GLFWReallocateCallback
? (GLFWReallocateCallback)instance
: new Container(instance.address(), instance);
}
protected GLFWReallocateCallback() {
super(CIF);
}
GLFWReallocateCallback(long functionPointer) {
super(functionPointer);
}
private static final class Container extends GLFWReallocateCallback {
private final GLFWReallocateCallbackI delegate;
Container(long functionPointer, GLFWReallocateCallbackI delegate) {
super(functionPointer);
this.delegate = delegate;
}
@Override
public long invoke(long block, long size, long user) {
return delegate.invoke(block, size, user);
}
}
}

View File

@ -1,87 +0,0 @@
/*
* Copyright LWJGL. All rights reserved.
* License terms: https://www.lwjgl.org/license
* MACHINE GENERATED FILE, DO NOT EDIT
*/
package org.lwjgl.glfw;
import org.lwjgl.system.*;
import org.lwjgl.system.libffi.*;
import static org.lwjgl.system.APIUtil.*;
import static org.lwjgl.system.MemoryUtil.*;
import static org.lwjgl.system.libffi.LibFFI.*;
/**
* The function pointer type for memory reallocation callbacks.
*
* <p>This is the function pointer type for memory reallocation callbacks. A memory reallocation callback function has the following signature:</p>
*
* <pre><code>
* void* function_name(void* block, size_t size, void* user) </code></pre>
*
* <p>This function must return a memory block at least {@code size} bytes long, or {@code NULL} if allocation failed. Note that not all parts of GLFW handle
* allocation failures gracefully yet.</p>
*
* <p>This function may be called during {@link GLFW#glfwInit Init} but before the library is flagged as initialized, as well as during {@link GLFW#glfwTerminate Terminate} after the library is no
* longer flagged as initialized.</p>
*
* <p>Any memory allocated by this function will be deallocated during library termination or earlier.</p>
*
* <p>The block address will never be {@code NULL} and the size will always be greater than zero. Reallocations of a block to size zero are converted into
* deallocations. Reallocations of {@code NULL} to a non-zero size are converted into regular allocations.</p>
*
* <div style="margin-left: 26px; border-left: 1px solid gray; padding-left: 14px;"><h5>Note</h5>
*
* <ul>
* <li>The returned memory block must be valid at least until it is deallocated.</li>
* <li>This function should not call any GLFW function.</li>
* <li>This function may be called from any thread that calls GLFW functions.</li>
* </ul></div>
*
* <h3>Type</h3>
*
* <pre><code>
* void * (*{@link #invoke}) (
* void *block,
* size_t size,
* void *user
* )</code></pre>
*
* @since version 3.4
*/
@FunctionalInterface
@NativeType("GLFWreallocatefun")
public interface GLFWReallocateCallbackI extends CallbackI {
FFICIF CIF = apiCreateCIF(
FFI_DEFAULT_ABI,
ffi_type_pointer,
ffi_type_pointer, ffi_type_pointer, ffi_type_pointer
);
@Override
default FFICIF getCallInterface() { return CIF; }
@Override
default void callback(long ret, long args) {
long __result = invoke(
memGetAddress(memGetAddress(args)),
memGetAddress(memGetAddress(args + POINTER_SIZE)),
memGetAddress(memGetAddress(args + 2 * POINTER_SIZE))
);
apiClosureRetP(ret, __result);
}
/**
* Will be called for memory reallocation requests.
*
* @param block the address of the memory block to reallocate
* @param size the new minimum size, in bytes, of the memory block
* @param user the user-defined pointer from the allocator
*
* @return the address of the newly allocated or resized memory block, or {@code NULL} if an error occurred
*/
@NativeType("void *") long invoke(@NativeType("void *") long block, @NativeType("size_t") long size, @NativeType("void *") long user);
}

View File

@ -1,87 +0,0 @@
/*
* Copyright LWJGL. All rights reserved.
* License terms: https://www.lwjgl.org/license
* MACHINE GENERATED FILE, DO NOT EDIT
*/
package org.lwjgl.glfw;
import javax.annotation.*;
import org.lwjgl.system.*;
import static org.lwjgl.system.MemoryUtil.*;
import static org.lwjgl.glfw.GLFW.*;
/**
* Instances of this class may be passed to the {@link GLFW#glfwSetScrollCallback SetScrollCallback} method.
*
* <h3>Type</h3>
*
* <pre><code>
* void (*{@link #invoke}) (
* GLFWwindow *window,
* double xoffset,
* double yoffset
* )</code></pre>
*
* @since version 3.0
*/
public abstract class GLFWScrollCallback extends Callback implements GLFWScrollCallbackI {
/**
* Creates a {@code GLFWScrollCallback} instance from the specified function pointer.
*
* @return the new {@code GLFWScrollCallback}
*/
public static GLFWScrollCallback create(long functionPointer) {
GLFWScrollCallbackI instance = Callback.get(functionPointer);
return instance instanceof GLFWScrollCallback
? (GLFWScrollCallback)instance
: new Container(functionPointer, instance);
}
/** Like {@link #create(long) create}, but returns {@code null} if {@code functionPointer} is {@code NULL}. */
@Nullable
public static GLFWScrollCallback createSafe(long functionPointer) {
return functionPointer == NULL ? null : create(functionPointer);
}
/** Creates a {@code GLFWScrollCallback} instance that delegates to the specified {@code GLFWScrollCallbackI} instance. */
public static GLFWScrollCallback create(GLFWScrollCallbackI instance) {
return instance instanceof GLFWScrollCallback
? (GLFWScrollCallback)instance
: new Container(instance.address(), instance);
}
protected GLFWScrollCallback() {
super(CIF);
}
GLFWScrollCallback(long functionPointer) {
super(functionPointer);
}
/** See {@link GLFW#glfwSetScrollCallback SetScrollCallback}. */
public GLFWScrollCallback set(long window) {
glfwSetScrollCallback(window, this);
return this;
}
private static final class Container extends GLFWScrollCallback {
private final GLFWScrollCallbackI delegate;
Container(long functionPointer, GLFWScrollCallbackI delegate) {
super(functionPointer);
this.delegate = delegate;
}
@Override
public void invoke(long window, double xoffset, double yoffset) {
delegate.invoke(window, xoffset, yoffset);
}
}
}

View File

@ -1,60 +0,0 @@
/*
* Copyright LWJGL. All rights reserved.
* License terms: https://www.lwjgl.org/license
* MACHINE GENERATED FILE, DO NOT EDIT
*/
package org.lwjgl.glfw;
import org.lwjgl.system.*;
import org.lwjgl.system.libffi.*;
import static org.lwjgl.system.APIUtil.*;
import static org.lwjgl.system.MemoryUtil.*;
import static org.lwjgl.system.libffi.LibFFI.*;
/**
* Instances of this interface may be passed to the {@link GLFW#glfwSetScrollCallback SetScrollCallback} method.
*
* <h3>Type</h3>
*
* <pre><code>
* void (*{@link #invoke}) (
* GLFWwindow *window,
* double xoffset,
* double yoffset
* )</code></pre>
*
* @since version 3.0
*/
@FunctionalInterface
@NativeType("GLFWscrollfun")
public interface GLFWScrollCallbackI extends CallbackI {
FFICIF CIF = apiCreateCIF(
FFI_DEFAULT_ABI,
ffi_type_void,
ffi_type_pointer, ffi_type_double, ffi_type_double
);
@Override
default FFICIF getCallInterface() { return CIF; }
@Override
default void callback(long ret, long args) {
invoke(
memGetAddress(memGetAddress(args)),
memGetDouble(memGetAddress(args + POINTER_SIZE)),
memGetDouble(memGetAddress(args + 2 * POINTER_SIZE))
);
}
/**
* Will be called when a scrolling device is used, such as a mouse wheel or scrolling area of a touchpad.
*
* @param window the window that received the event
* @param xoffset the scroll offset along the x-axis
* @param yoffset the scroll offset along the y-axis
*/
void invoke(@NativeType("GLFWwindow *") long window, double xoffset, double yoffset);
}

View File

@ -1,202 +0,0 @@
/*
* Copyright LWJGL. All rights reserved.
* License terms: https://www.lwjgl.org/license
* MACHINE GENERATED FILE, DO NOT EDIT
*/
package org.lwjgl.glfw;
import javax.annotation.*;
import java.nio.*;
import org.lwjgl.system.*;
import static org.lwjgl.system.MemoryUtil.*;
/**
* Describes a single video mode.
*
* <h3>Layout</h3>
*
* <pre><code>
* struct GLFWvidmode {
* int {@link #width};
* int {@link #height};
* int {@link #redBits};
* int {@link #greenBits};
* int {@link #blueBits};
* int {@link #refreshRate};
* }</code></pre>
*/
@NativeType("struct GLFWvidmode")
public class GLFWVidMode extends Struct<GLFWVidMode> {
/** 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
WIDTH,
HEIGHT,
REDBITS,
GREENBITS,
BLUEBITS,
REFRESHRATE;
static {
Layout layout = __struct(
__member(4),
__member(4),
__member(4),
__member(4),
__member(4),
__member(4)
);
SIZEOF = layout.getSize();
ALIGNOF = layout.getAlignment();
WIDTH = layout.offsetof(0);
HEIGHT = layout.offsetof(1);
REDBITS = layout.offsetof(2);
GREENBITS = layout.offsetof(3);
BLUEBITS = layout.offsetof(4);
REFRESHRATE = layout.offsetof(5);
}
protected GLFWVidMode(long address, @Nullable ByteBuffer container) {
super(address, container);
}
@Override
protected GLFWVidMode create(long address, @Nullable ByteBuffer container) {
return new GLFWVidMode(address, container);
}
/**
* Creates a {@code GLFWVidMode} 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.
*
* <p>The created instance holds a strong reference to the container object.</p>
*/
public GLFWVidMode(ByteBuffer container) {
super(memAddress(container), __checkContainer(container, SIZEOF));
}
@Override
public int sizeof() { return SIZEOF; }
/** the width, in screen coordinates, of the video mode */
public int width() { return nwidth(address()); }
/** the height, in screen coordinates, of the video mode */
public int height() { return nheight(address()); }
/** the bit depth of the red channel of the video mode */
public int redBits() { return nredBits(address()); }
/** the bit depth of the green channel of the video mode */
public int greenBits() { return ngreenBits(address()); }
/** the bit depth of the blue channel of the video mode */
public int blueBits() { return nblueBits(address()); }
/** the refresh rate, in Hz, of the video mode */
public int refreshRate() { return nrefreshRate(address()); }
// -----------------------------------
/** Returns a new {@code GLFWVidMode} instance for the specified memory address. */
public static GLFWVidMode create(long address) {
return new GLFWVidMode(address, null);
}
/** Like {@link #create(long) create}, but returns {@code null} if {@code address} is {@code NULL}. */
@Nullable
public static GLFWVidMode createSafe(long address) {
return address == NULL ? null : new GLFWVidMode(address, null);
}
/**
* Create a {@link 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 new Buffer(address, capacity);
}
/** Like {@link #create(long, int) create}, but returns {@code null} if {@code address} is {@code NULL}. */
@Nullable
public static Buffer createSafe(long address, int capacity) {
return address == NULL ? null : new Buffer(address, capacity);
}
// -----------------------------------
/** Unsafe version of {@link #width}. */
public static int nwidth(long struct) { return UNSAFE.getInt(null, struct + GLFWVidMode.WIDTH); }
/** Unsafe version of {@link #height}. */
public static int nheight(long struct) { return UNSAFE.getInt(null, struct + GLFWVidMode.HEIGHT); }
/** Unsafe version of {@link #redBits}. */
public static int nredBits(long struct) { return UNSAFE.getInt(null, struct + GLFWVidMode.REDBITS); }
/** Unsafe version of {@link #greenBits}. */
public static int ngreenBits(long struct) { return UNSAFE.getInt(null, struct + GLFWVidMode.GREENBITS); }
/** Unsafe version of {@link #blueBits}. */
public static int nblueBits(long struct) { return UNSAFE.getInt(null, struct + GLFWVidMode.BLUEBITS); }
/** Unsafe version of {@link #refreshRate}. */
public static int nrefreshRate(long struct) { return UNSAFE.getInt(null, struct + GLFWVidMode.REFRESHRATE); }
// -----------------------------------
/** An array of {@link GLFWVidMode} structs. */
public static class Buffer extends StructBuffer<GLFWVidMode, Buffer> {
private static final GLFWVidMode ELEMENT_FACTORY = GLFWVidMode.create(-1L);
/**
* Creates a new {@code GLFWVidMode.Buffer} instance backed by the specified container.
*
* <p>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 GLFWVidMode#SIZEOF}, and its mark will be undefined.</p>
*
* <p>The created buffer instance holds a strong reference to the container object.</p>
*/
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 GLFWVidMode getElementFactory() {
return ELEMENT_FACTORY;
}
/** @return the value of the {@link GLFWVidMode#width} field. */
public int width() { return GLFWVidMode.nwidth(address()); }
/** @return the value of the {@link GLFWVidMode#height} field. */
public int height() { return GLFWVidMode.nheight(address()); }
/** @return the value of the {@link GLFWVidMode#redBits} field. */
public int redBits() { return GLFWVidMode.nredBits(address()); }
/** @return the value of the {@link GLFWVidMode#greenBits} field. */
public int greenBits() { return GLFWVidMode.ngreenBits(address()); }
/** @return the value of the {@link GLFWVidMode#blueBits} field. */
public int blueBits() { return GLFWVidMode.nblueBits(address()); }
/** @return the value of the {@link GLFWVidMode#refreshRate} field. */
public int refreshRate() { return GLFWVidMode.nrefreshRate(address()); }
}
}

View File

@ -1,352 +0,0 @@
/*
* Copyright LWJGL. All rights reserved.
* License terms: https://www.lwjgl.org/license
* MACHINE GENERATED FILE, DO NOT EDIT
*/
package org.lwjgl.glfw;
import javax.annotation.*;
import java.nio.*;
import org.lwjgl.*;
import org.lwjgl.system.*;
import static org.lwjgl.system.APIUtil.*;
import static org.lwjgl.system.Checks.*;
import static org.lwjgl.system.JNI.*;
import static org.lwjgl.system.MemoryStack.*;
import static org.lwjgl.system.MemoryUtil.*;
import static org.lwjgl.vulkan.EXTMetalSurface.VK_STRUCTURE_TYPE_METAL_SURFACE_CREATE_INFO_EXT;
import static org.lwjgl.vulkan.EXTMetalSurface.vkCreateMetalSurfaceEXT;
import static org.lwjgl.vulkan.KHRAndroidSurface.VK_STRUCTURE_TYPE_ANDROID_SURFACE_CREATE_INFO_KHR;
import static org.lwjgl.vulkan.KHRAndroidSurface.vkCreateAndroidSurfaceKHR;
import org.lwjgl.vulkan.*;
/** Native bindings to the GLFW library's Vulkan functions. */
public class GLFWVulkan {
static {
if (Platform.get() == Platform.MACOSX) {
setPath(VK.getFunctionProvider());
}
}
protected GLFWVulkan() {
throw new UnsupportedOperationException();
}
// --- [ glfwInitVulkanLoader ] ---
/**
* Sets the desired Vulkan {@code vkGetInstanceProcAddr} function.
*
* <p>This function sets the {@code vkGetInstanceProcAddr} function that GLFW will use for all Vulkan related entry point queries.</p>
*
* <p>This feature is mostly useful on macOS, if your copy of the Vulkan loader is in a location where GLFW cannot find it through dynamic loading, or if you
* are still using the static library version of the loader.</p>
*
* <p>If set to {@code NULL}, GLFW will try to load the Vulkan loader dynamically by its standard name and get this function from there. This is the default
* behavior.</p>
*
* <p>The standard name of the loader is {@code vulkan-1.dll} on Windows, {@code libvulkan.so.1} on Linux and other Unix-like systems and
* {@code libvulkan.1.dylib} on macOS. If your code is also loading it via these names then you probably don't need to use this function.</p>
*
* <p>The function address you set is never reset by GLFW, but it only takes effect during initialization. Once GLFW has been initialized, any updates will
* be ignored until the library is terminated and initialized again.</p>
*
* <p>This function may be called before {@link GLFW#glfwInit Init}.</p>
*
* <p>This function must only be called from the main thread.</p>
*
* @param loader the address of the function to use, or {@code NULL}
*
* @since version 3.4
*/
public static void glfwInitVulkanLoader(@NativeType("PFN_vkGetInstanceProcAddr") long loader) {
//long __functionAddress = Functions.InitVulkanLoader;
//invokePV(loader, __functionAddress);
}
// --- [ glfwVulkanSupported ] ---
/**
* Returns whether the Vulkan loader has been found. This check is performed by {@link GLFW#glfwInit Init}.
*
* <p>The availability of a Vulkan loader and even an ICD does not by itself guarantee that surface creation or even instance creation is possible. Call
* {@link #glfwGetRequiredInstanceExtensions GetRequiredInstanceExtensions} to check whether the extensions necessary for Vulkan surface creation are available and
* {@link #glfwGetPhysicalDevicePresentationSupport GetPhysicalDevicePresentationSupport} to check whether a queue family of a physical device supports image presentation.</p>
*
* <p>Possible errors include {@link GLFW#GLFW_NOT_INITIALIZED NOT_INITIALIZED}.</p>
*
* <p>This function may be called from any thread.</p>
*
* @return {@link GLFW#GLFW_TRUE TRUE} if Vulkan is available, or {@link GLFW#GLFW_FALSE FALSE} otherwise
*
* @since version 3.2
*/
@NativeType("int")
public static boolean glfwVulkanSupported() {
//long __functionAddress = Functions.VulkanSupported;
//return invokeI(__functionAddress) != 0;
return true;
}
// --- [ glfwGetRequiredInstanceExtensions ] ---
/**
* Returns an array of names of Vulkan instance extensions required by GLFW for creating Vulkan surfaces for GLFW windows. If successful, the list will
* always contain {@code VK_KHR_surface}, so if you don't require any additional extensions you can pass this list directly to the {@link VkInstanceCreateInfo}
* struct.
*
* <p>If Vulkan is not available on the machine, this function returns {@code NULL} and generates a {@link GLFW#GLFW_API_UNAVAILABLE API_UNAVAILABLE} error. Call {@link #glfwVulkanSupported VulkanSupported} to check whether
* Vulkan is available.</p>
*
* <p>If Vulkan is available but no set of extensions allowing window surface creation was found, this function returns {@code NULL}. You may still use Vulkan for
* off-screen rendering and compute work.</p>
*
* <p>Additional extensions may be required by future versions of GLFW. You should check if any extensions you wish to enable are already in the returned
* array, as it is an error to specify an extension more than once in the {@code VkInstanceCreateInfo} struct.</p>
*
* <p>The returned array is allocated and freed by GLFW. You should not free it yourself. It is guaranteed to be valid only until the library is terminated.</p>
*
* <p>This function may be called from any thread.</p>
*
* <p>Possible errors include {@link GLFW#GLFW_NOT_INITIALIZED NOT_INITIALIZED} and {@link GLFW#GLFW_API_UNAVAILABLE API_UNAVAILABLE}.</p>
*
* @return an array of ASCII encoded extension names, or {@code NULL} if an error occurred
*
* @since version 3.2
*/
@Nullable
@NativeType("char const **")
public static PointerBuffer glfwGetRequiredInstanceExtensions() {
MemoryStack stack = MemoryStack.stackPush();
String platformSurface;
if (Platform.get() == Platform.MACOSX) {
platformSurface = "VK_EXT_metal_surface";
} else {
platformSurface = "VK_KHR_android_surface";
}
return stack.pointers(stack.UTF8(KHRSurface.VK_KHR_SURFACE_EXTENSION_NAME), stack.UTF8(platformSurface));
}
/**
* Returns the address of the specified Vulkan core or extension function for the specified instance. If instance is set to {@code NULL} it can return any
* function exported from the Vulkan loader, including at least the following functions:
*
* <ul>
* <li>{@link VK10#vkEnumerateInstanceExtensionProperties}</li>
* <li>{@link VK10#vkEnumerateInstanceLayerProperties}</li>
* <li>{@link VK10#vkCreateInstance}</li>
* <li>{@link VK10#vkGetInstanceProcAddr}</li>
* </ul>
*
* <p>If Vulkan is not available on the machine, this function returns {@code NULL} and generates a {@link GLFW#GLFW_API_UNAVAILABLE API_UNAVAILABLE} error. Call {@link #glfwVulkanSupported VulkanSupported} to check whether
* Vulkan is available.</p>
*
* <p>This function is equivalent to calling {@link VK10#vkGetInstanceProcAddr} with a platform-specific query of the Vulkan loader as a fallback.</p>
*
* <p>Possible errors include {@link GLFW#GLFW_NOT_INITIALIZED NOT_INITIALIZED} and {@link GLFW#GLFW_API_UNAVAILABLE API_UNAVAILABLE}.</p>
*
* <p>The returned function pointer is valid until the library is terminated.</p>
*
* <p>This function may be called from any thread.</p>
*
* @param instance the Vulkan instance to query, or {@code NULL} to retrieve functions related to instance creation
* @param procname the ASCII encoded name of the function
*
* @return the address of the function, or {@code NULL} if an error occurred
*
* @since version 3.2
*/
@NativeType("GLFWvkproc")
public static long glfwGetInstanceProcAddress(@Nullable VkInstance instance, @NativeType("char const *") ByteBuffer procname) {
if (CHECKS) {
checkNT1(procname);
}
return VK10.vkGetInstanceProcAddr(instance, procname);
}
/**
* Returns the address of the specified Vulkan core or extension function for the specified instance. If instance is set to {@code NULL} it can return any
* function exported from the Vulkan loader, including at least the following functions:
*
* <ul>
* <li>{@link VK10#vkEnumerateInstanceExtensionProperties}</li>
* <li>{@link VK10#vkEnumerateInstanceLayerProperties}</li>
* <li>{@link VK10#vkCreateInstance}</li>
* <li>{@link VK10#vkGetInstanceProcAddr}</li>
* </ul>
*
* <p>If Vulkan is not available on the machine, this function returns {@code NULL} and generates a {@link GLFW#GLFW_API_UNAVAILABLE API_UNAVAILABLE} error. Call {@link #glfwVulkanSupported VulkanSupported} to check whether
* Vulkan is available.</p>
*
* <p>This function is equivalent to calling {@link VK10#vkGetInstanceProcAddr} with a platform-specific query of the Vulkan loader as a fallback.</p>
*
* <p>Possible errors include {@link GLFW#GLFW_NOT_INITIALIZED NOT_INITIALIZED} and {@link GLFW#GLFW_API_UNAVAILABLE API_UNAVAILABLE}.</p>
*
* <p>The returned function pointer is valid until the library is terminated.</p>
*
* <p>This function may be called from any thread.</p>
*
* @param instance the Vulkan instance to query, or {@code NULL} to retrieve functions related to instance creation
* @param procname the ASCII encoded name of the function
*
* @return the address of the function, or {@code NULL} if an error occurred
*
* @since version 3.2
*/
@NativeType("GLFWvkproc")
public static long glfwGetInstanceProcAddress(@Nullable VkInstance instance, @NativeType("char const *") CharSequence procname) {
return VK10.vkGetInstanceProcAddr(instance, procname);
}
// --- [ glfwGetPhysicalDevicePresentationSupport ] ---
/**
* Returns whether the specified queue family of the specified physical device supports presentation to the platform GLFW was built for.
*
* <p>If Vulkan or the required window surface creation instance extensions are not available on the machine, or if the specified instance was not created
* with the required extensions, this function returns {@link GLFW#GLFW_FALSE FALSE} and generates a {@link GLFW#GLFW_API_UNAVAILABLE API_UNAVAILABLE} error. Call {@link #glfwVulkanSupported VulkanSupported} to check whether Vulkan is
* available and {@link #glfwGetRequiredInstanceExtensions GetRequiredInstanceExtensions} to check what instance extensions are required.</p>
*
* <p>Possible errors include {@link GLFW#GLFW_NOT_INITIALIZED NOT_INITIALIZED}, {@link GLFW#GLFW_API_UNAVAILABLE API_UNAVAILABLE} and {@link GLFW#GLFW_PLATFORM_ERROR PLATFORM_ERROR}.</p>
*
* <p>macOS: This function currently always returns {@link GLFW#GLFW_TRUE TRUE}, as the {@code VK_MVK_macos_surface} and {@code VK_EXT_metal_surface} extensions do not provide a
* {@code vkGetPhysicalDevice*PresentationSupport} type function.</p>
*
* <p>This function may be called from any thread. For synchronization details of Vulkan objects, see the Vulkan specification.</p>
*
* @param instance the instance that the physical device belongs to
* @param device the physical device that the queue family belongs to
* @param queuefamily the index of the queue family to query
*
* @return {@link GLFW#GLFW_TRUE TRUE} if the queue family supports presentation, or {@link GLFW#GLFW_FALSE FALSE} otherwise
*
* @since version 3.2
*/
@NativeType("int")
public static boolean glfwGetPhysicalDevicePresentationSupport(VkInstance instance, VkPhysicalDevice device, @NativeType("uint32_t") int queuefamily) {
return true;
}
// --- [ glfwCreateWindowSurface ] ---
/**
* Creates a Vulkan surface for the specified window.
*
* <p>If the Vulkan loader was not found at initialization, this function returns {@link VK10#VK_ERROR_INITIALIZATION_FAILED} and generates a {@link GLFW#GLFW_API_UNAVAILABLE API_UNAVAILABLE} error.
* Call {@link #glfwVulkanSupported VulkanSupported} to check whether the Vulkan loader was found.</p>
*
* <p>If the required window surface creation instance extensions are not available or if the specified instance was not created with these extensions
* enabled, this function returns {@link VK10#VK_ERROR_EXTENSION_NOT_PRESENT} and generates a {@link GLFW#GLFW_API_UNAVAILABLE API_UNAVAILABLE} error. Call {@link #glfwGetRequiredInstanceExtensions GetRequiredInstanceExtensions} to
* check what instance extensions are required.</p>
*
* <p>The window surface cannot be shared with another API so the window must have been created with the client api hint set to {@link GLFW#GLFW_NO_API NO_API} otherwise it
* generates a {@link GLFW#GLFW_INVALID_VALUE INVALID_VALUE} error and returns {@link KHRSurface#VK_ERROR_NATIVE_WINDOW_IN_USE_KHR}.</p>
*
* <p>The window surface must be destroyed before the specified Vulkan instance. It is the responsibility of the caller to destroy the window surface. GLFW
* does not destroy it for you. Call {@link KHRSurface#vkDestroySurfaceKHR} to destroy the surface.</p>
*
* <p>Possible errors include {@link GLFW#GLFW_NOT_INITIALIZED NOT_INITIALIZED}, {@link GLFW#GLFW_API_UNAVAILABLE API_UNAVAILABLE}, {@link GLFW#GLFW_PLATFORM_ERROR PLATFORM_ERROR} and {@link GLFW#GLFW_INVALID_VALUE INVALID_VALUE}.</p>
*
* <p>If an error occurs before the creation call is made, GLFW returns the Vulkan error code most appropriate for the error. Appropriate use of
* {@link #glfwVulkanSupported VulkanSupported} and {@code glfwGetRequiredInstanceExtensions} should eliminate almost all occurrences of these errors.</p>
*
* <p>Notes:</p>
*
* <ul>
* <li>This function may be called from any thread. For synchronization details of Vulkan objects, see the Vulkan specification.</li>
* <li><b>macOS</b>: GLFW prefers the {@code VK_EXT_metal_surface} extension, with the {@code VK_MVK_macos_surface} extension as a fallback. The name of
* the selected extension, if any, is included in the array returned by {@code glfwGetRequiredInstanceExtensions}.</li>
* <li><b>macOS</b>: This function creates and sets a {@code CAMetalLayer} instance for the window content view, which is required for MoltenVK to
* function.</li>
* <li><b>x11</b>: By default GLFW prefers the {@code VK_KHR_xcb_surface} extension, with the {@code VK_KHR_xlib_surface} extension as a fallback. You can
* make {@code VK_KHR_xlib_surface} the preferred extension by setting the {@link GLFW#GLFW_X11_XCB_VULKAN_SURFACE X11_XCB_VULKAN_SURFACE} init hint. The name of the selected extension, if
* any, is included in the array returned by {@code glfwGetRequiredInstanceExtensions}.</li>
* </ul>
*
* @param instance the Vulkan instance to create the surface in
* @param window the window to create the surface for
* @param allocator the allocator to use, or {@code NULL} to use the default allocator.
* @param surface where to store the handle of the surface. This is set to {@link VK10#VK_NULL_HANDLE} if an error occurred.
*
* @return {@link VK10#VK_SUCCESS} if successful, or a Vulkan error code if an error occurred
*
* @since version 3.2
*/
@NativeType("VkResult")
public static int glfwCreateWindowSurface(VkInstance instance, @NativeType("GLFWwindow *") long window, @Nullable @NativeType("VkAllocationCallbacks const *") VkAllocationCallbacks allocator, @NativeType("VkSurfaceKHR *") LongBuffer surface) {
if (CHECKS) {
check(surface, 1);
}
if (Platform.get() == Platform.LINUX) {
VkAndroidSurfaceCreateInfoKHR pCreateInfo = VkAndroidSurfaceCreateInfoKHR
.calloc()
.sType(VK_STRUCTURE_TYPE_ANDROID_SURFACE_CREATE_INFO_KHR)
.window(window);
return vkCreateAndroidSurfaceKHR(instance, pCreateInfo, null, surface);
}
return VK10.VK_ERROR_EXTENSION_NOT_PRESENT;
}
/** Array version of: {@link #glfwCreateWindowSurface CreateWindowSurface} */
@NativeType("VkResult")
public static int glfwCreateWindowSurface(VkInstance instance, @NativeType("GLFWwindow *") long window, @Nullable @NativeType("VkAllocationCallbacks const *") VkAllocationCallbacks allocator, @NativeType("VkSurfaceKHR *") long[] surface) {
MemoryStack stack = stackGet();
LongBuffer pSurface = stack.mallocLong(1);
int result = glfwCreateWindowSurface(instance, window, allocator, pSurface);
surface[0] = pSurface.get(0);
return result;
}
/**
* Calls {@link #setPath(String)} with the path of the specified {@link SharedLibrary}.
*
* <p>Example usage: <code>GLFWVulkan.setPath(VK.getFunctionProvider());</code></p>
*
* @param sharedLibrary a {@code FunctionProvider} instance that will be cast to {@code SharedLibrary}
*/
public static void setPath(FunctionProvider sharedLibrary) {
if (!(sharedLibrary instanceof SharedLibrary)) {
apiLog("GLFW Vulkan path override not set: function provider is not a shared library.");
return;
}
String path = ((SharedLibrary)sharedLibrary).getPath();
if (path == null) {
apiLog("GLFW Vulkan path override not set: Could not resolve the shared library path.");
return;
}
setPath(path);
}
/**
* Overrides the Vulkan shared library that GLFW loads internally.
*
* <p>This is useful when there's a mismatch between the shared libraries loaded by LWJGL and GLFW.</p>
*
* <p>This method must be called before GLFW initializes Vulkan. The override is available only in the default GLFW build bundled with LWJGL. Using the
* override with a custom GLFW build will produce a warning in {@code DEBUG} mode (but not an error).</p>
*
* @param path the Vulkan shared library path, or {@code null} to remove the override.
*/
public static void setPath(@Nullable String path) {
long override = GLFW.getLibrary().getFunctionAddress("_glfw_vulkan_library");
if (override == NULL) {
apiLog("GLFW Vulkan path override not set: Could not resolve override symbol.");
return;
}
long a = memGetAddress(override);
if (a != NULL) {
nmemFree(a);
}
memPutAddress(override, path == null ? NULL : memAddress(memUTF8(path)));
}
}

View File

@ -1,85 +0,0 @@
/*
* Copyright LWJGL. All rights reserved.
* License terms: https://www.lwjgl.org/license
* MACHINE GENERATED FILE, DO NOT EDIT
*/
package org.lwjgl.glfw;
import javax.annotation.*;
import org.lwjgl.system.*;
import static org.lwjgl.system.MemoryUtil.*;
import static org.lwjgl.glfw.GLFW.*;
/**
* Instances of this class may be passed to the {@link GLFW#glfwSetWindowCloseCallback SetWindowCloseCallback} method.
*
* <h3>Type</h3>
*
* <pre><code>
* void (*{@link #invoke}) (
* GLFWwindow *window
* )</code></pre>
*
* @since version 2.5
*/
public abstract class GLFWWindowCloseCallback extends Callback implements GLFWWindowCloseCallbackI {
/**
* Creates a {@code GLFWWindowCloseCallback} instance from the specified function pointer.
*
* @return the new {@code GLFWWindowCloseCallback}
*/
public static GLFWWindowCloseCallback create(long functionPointer) {
GLFWWindowCloseCallbackI instance = Callback.get(functionPointer);
return instance instanceof GLFWWindowCloseCallback
? (GLFWWindowCloseCallback)instance
: new Container(functionPointer, instance);
}
/** Like {@link #create(long) create}, but returns {@code null} if {@code functionPointer} is {@code NULL}. */
@Nullable
public static GLFWWindowCloseCallback createSafe(long functionPointer) {
return functionPointer == NULL ? null : create(functionPointer);
}
/** Creates a {@code GLFWWindowCloseCallback} instance that delegates to the specified {@code GLFWWindowCloseCallbackI} instance. */
public static GLFWWindowCloseCallback create(GLFWWindowCloseCallbackI instance) {
return instance instanceof GLFWWindowCloseCallback
? (GLFWWindowCloseCallback)instance
: new Container(instance.address(), instance);
}
protected GLFWWindowCloseCallback() {
super(CIF);
}
GLFWWindowCloseCallback(long functionPointer) {
super(functionPointer);
}
/** See {@link GLFW#glfwSetWindowCloseCallback SetWindowCloseCallback}. */
public GLFWWindowCloseCallback set(long window) {
glfwSetWindowCloseCallback(window, this);
return this;
}
private static final class Container extends GLFWWindowCloseCallback {
private final GLFWWindowCloseCallbackI delegate;
Container(long functionPointer, GLFWWindowCloseCallbackI delegate) {
super(functionPointer);
this.delegate = delegate;
}
@Override
public void invoke(long window) {
delegate.invoke(window);
}
}
}

View File

@ -1,54 +0,0 @@
/*
* Copyright LWJGL. All rights reserved.
* License terms: https://www.lwjgl.org/license
* MACHINE GENERATED FILE, DO NOT EDIT
*/
package org.lwjgl.glfw;
import org.lwjgl.system.*;
import org.lwjgl.system.libffi.*;
import static org.lwjgl.system.APIUtil.*;
import static org.lwjgl.system.MemoryUtil.*;
import static org.lwjgl.system.libffi.LibFFI.*;
/**
* Instances of this interface may be passed to the {@link GLFW#glfwSetWindowCloseCallback SetWindowCloseCallback} method.
*
* <h3>Type</h3>
*
* <pre><code>
* void (*{@link #invoke}) (
* GLFWwindow *window
* )</code></pre>
*
* @since version 2.5
*/
@FunctionalInterface
@NativeType("GLFWwindowclosefun")
public interface GLFWWindowCloseCallbackI extends CallbackI {
FFICIF CIF = apiCreateCIF(
FFI_DEFAULT_ABI,
ffi_type_void,
ffi_type_pointer
);
@Override
default FFICIF getCallInterface() { return CIF; }
@Override
default void callback(long ret, long args) {
invoke(
memGetAddress(memGetAddress(args))
);
}
/**
* Will be called when the user attempts to close the specified window, for example by clicking the close widget in the title bar.
*
* @param window the window that the user attempted to close
*/
void invoke(@NativeType("GLFWwindow *") long window);
}

View File

@ -1,87 +0,0 @@
/*
* Copyright LWJGL. All rights reserved.
* License terms: https://www.lwjgl.org/license
* MACHINE GENERATED FILE, DO NOT EDIT
*/
package org.lwjgl.glfw;
import javax.annotation.*;
import org.lwjgl.system.*;
import static org.lwjgl.system.MemoryUtil.*;
import static org.lwjgl.glfw.GLFW.*;
/**
* Instances of this class may be passed to the {@link GLFW#glfwSetWindowContentScaleCallback SetWindowContentScaleCallback} method.
*
* <h3>Type</h3>
*
* <pre><code>
* void (*{@link #invoke}) (
* GLFWwindow *window,
* float xscale,
* float yscale
* )</code></pre>
*
* @since version 3.3
*/
public abstract class GLFWWindowContentScaleCallback extends Callback implements GLFWWindowContentScaleCallbackI {
/**
* Creates a {@code GLFWWindowContentScaleCallback} instance from the specified function pointer.
*
* @return the new {@code GLFWWindowContentScaleCallback}
*/
public static GLFWWindowContentScaleCallback create(long functionPointer) {
GLFWWindowContentScaleCallbackI instance = Callback.get(functionPointer);
return instance instanceof GLFWWindowContentScaleCallback
? (GLFWWindowContentScaleCallback)instance
: new Container(functionPointer, instance);
}
/** Like {@link #create(long) create}, but returns {@code null} if {@code functionPointer} is {@code NULL}. */
@Nullable
public static GLFWWindowContentScaleCallback createSafe(long functionPointer) {
return functionPointer == NULL ? null : create(functionPointer);
}
/** Creates a {@code GLFWWindowContentScaleCallback} instance that delegates to the specified {@code GLFWWindowContentScaleCallbackI} instance. */
public static GLFWWindowContentScaleCallback create(GLFWWindowContentScaleCallbackI instance) {
return instance instanceof GLFWWindowContentScaleCallback
? (GLFWWindowContentScaleCallback)instance
: new Container(instance.address(), instance);
}
protected GLFWWindowContentScaleCallback() {
super(CIF);
}
GLFWWindowContentScaleCallback(long functionPointer) {
super(functionPointer);
}
/** See {@link GLFW#glfwSetWindowContentScaleCallback SetWindowContentScaleCallback}. */
public GLFWWindowContentScaleCallback set(long window) {
glfwSetWindowContentScaleCallback(window, this);
return this;
}
private static final class Container extends GLFWWindowContentScaleCallback {
private final GLFWWindowContentScaleCallbackI delegate;
Container(long functionPointer, GLFWWindowContentScaleCallbackI delegate) {
super(functionPointer);
this.delegate = delegate;
}
@Override
public void invoke(long window, float xscale, float yscale) {
delegate.invoke(window, xscale, yscale);
}
}
}

View File

@ -1,60 +0,0 @@
/*
* Copyright LWJGL. All rights reserved.
* License terms: https://www.lwjgl.org/license
* MACHINE GENERATED FILE, DO NOT EDIT
*/
package org.lwjgl.glfw;
import org.lwjgl.system.*;
import org.lwjgl.system.libffi.*;
import static org.lwjgl.system.APIUtil.*;
import static org.lwjgl.system.MemoryUtil.*;
import static org.lwjgl.system.libffi.LibFFI.*;
/**
* Instances of this interface may be passed to the {@link GLFW#glfwSetWindowContentScaleCallback SetWindowContentScaleCallback} method.
*
* <h3>Type</h3>
*
* <pre><code>
* void (*{@link #invoke}) (
* GLFWwindow *window,
* float xscale,
* float yscale
* )</code></pre>
*
* @since version 3.3
*/
@FunctionalInterface
@NativeType("GLFWwindowcontentscalefun")
public interface GLFWWindowContentScaleCallbackI extends CallbackI {
FFICIF CIF = apiCreateCIF(
FFI_DEFAULT_ABI,
ffi_type_void,
ffi_type_pointer, ffi_type_float, ffi_type_float
);
@Override
default FFICIF getCallInterface() { return CIF; }
@Override
default void callback(long ret, long args) {
invoke(
memGetAddress(memGetAddress(args)),
memGetFloat(memGetAddress(args + POINTER_SIZE)),
memGetFloat(memGetAddress(args + 2 * POINTER_SIZE))
);
}
/**
* Will be called when the window content scale changes.
*
* @param window the window whose content scale changed
* @param xscale the new x-axis content scale of the window
* @param yscale the new y-axis content scale of the window
*/
void invoke(@NativeType("GLFWwindow *") long window, float xscale, float yscale);
}

View File

@ -1,86 +0,0 @@
/*
* Copyright LWJGL. All rights reserved.
* License terms: https://www.lwjgl.org/license
* MACHINE GENERATED FILE, DO NOT EDIT
*/
package org.lwjgl.glfw;
import javax.annotation.*;
import org.lwjgl.system.*;
import static org.lwjgl.system.MemoryUtil.*;
import static org.lwjgl.glfw.GLFW.*;
/**
* Instances of this class may be passed to the {@link GLFW#glfwSetWindowFocusCallback SetWindowFocusCallback} method.
*
* <h3>Type</h3>
*
* <pre><code>
* void (*{@link #invoke}) (
* GLFWwindow *window,
* int focused
* )</code></pre>
*
* @since version 3.0
*/
public abstract class GLFWWindowFocusCallback extends Callback implements GLFWWindowFocusCallbackI {
/**
* Creates a {@code GLFWWindowFocusCallback} instance from the specified function pointer.
*
* @return the new {@code GLFWWindowFocusCallback}
*/
public static GLFWWindowFocusCallback create(long functionPointer) {
GLFWWindowFocusCallbackI instance = Callback.get(functionPointer);
return instance instanceof GLFWWindowFocusCallback
? (GLFWWindowFocusCallback)instance
: new Container(functionPointer, instance);
}
/** Like {@link #create(long) create}, but returns {@code null} if {@code functionPointer} is {@code NULL}. */
@Nullable
public static GLFWWindowFocusCallback createSafe(long functionPointer) {
return functionPointer == NULL ? null : create(functionPointer);
}
/** Creates a {@code GLFWWindowFocusCallback} instance that delegates to the specified {@code GLFWWindowFocusCallbackI} instance. */
public static GLFWWindowFocusCallback create(GLFWWindowFocusCallbackI instance) {
return instance instanceof GLFWWindowFocusCallback
? (GLFWWindowFocusCallback)instance
: new Container(instance.address(), instance);
}
protected GLFWWindowFocusCallback() {
super(CIF);
}
GLFWWindowFocusCallback(long functionPointer) {
super(functionPointer);
}
/** See {@link GLFW#glfwSetWindowFocusCallback SetWindowFocusCallback}. */
public GLFWWindowFocusCallback set(long window) {
glfwSetWindowFocusCallback(window, this);
return this;
}
private static final class Container extends GLFWWindowFocusCallback {
private final GLFWWindowFocusCallbackI delegate;
Container(long functionPointer, GLFWWindowFocusCallbackI delegate) {
super(functionPointer);
this.delegate = delegate;
}
@Override
public void invoke(long window, boolean focused) {
delegate.invoke(window, focused);
}
}
}

View File

@ -1,57 +0,0 @@
/*
* Copyright LWJGL. All rights reserved.
* License terms: https://www.lwjgl.org/license
* MACHINE GENERATED FILE, DO NOT EDIT
*/
package org.lwjgl.glfw;
import org.lwjgl.system.*;
import org.lwjgl.system.libffi.*;
import static org.lwjgl.system.APIUtil.*;
import static org.lwjgl.system.MemoryUtil.*;
import static org.lwjgl.system.libffi.LibFFI.*;
/**
* Instances of this interface may be passed to the {@link GLFW#glfwSetWindowFocusCallback SetWindowFocusCallback} method.
*
* <h3>Type</h3>
*
* <pre><code>
* void (*{@link #invoke}) (
* GLFWwindow *window,
* int focused
* )</code></pre>
*
* @since version 3.0
*/
@FunctionalInterface
@NativeType("GLFWwindowfocusfun")
public interface GLFWWindowFocusCallbackI extends CallbackI {
FFICIF CIF = apiCreateCIF(
FFI_DEFAULT_ABI,
ffi_type_void,
ffi_type_pointer, ffi_type_uint32
);
@Override
default FFICIF getCallInterface() { return CIF; }
@Override
default void callback(long ret, long args) {
invoke(
memGetAddress(memGetAddress(args)),
memGetInt(memGetAddress(args + POINTER_SIZE)) != 0
);
}
/**
* Will be called when the specified window gains or loses focus.
*
* @param window the window that was focused or defocused
* @param focused {@link GLFW#GLFW_TRUE TRUE} if the window was focused, or {@link GLFW#GLFW_FALSE FALSE} if it was defocused
*/
void invoke(@NativeType("GLFWwindow *") long window, @NativeType("int") boolean focused);
}

View File

@ -1,86 +0,0 @@
/*
* Copyright LWJGL. All rights reserved.
* License terms: https://www.lwjgl.org/license
* MACHINE GENERATED FILE, DO NOT EDIT
*/
package org.lwjgl.glfw;
import javax.annotation.*;
import org.lwjgl.system.*;
import static org.lwjgl.system.MemoryUtil.*;
import static org.lwjgl.glfw.GLFW.*;
/**
* Instances of this class may be passed to the {@link GLFW#glfwSetWindowIconifyCallback SetWindowIconifyCallback} method.
*
* <h3>Type</h3>
*
* <pre><code>
* void (*{@link #invoke}) (
* GLFWwindow *window,
* int iconified
* )</code></pre>
*
* @since version 3.0
*/
public abstract class GLFWWindowIconifyCallback extends Callback implements GLFWWindowIconifyCallbackI {
/**
* Creates a {@code GLFWWindowIconifyCallback} instance from the specified function pointer.
*
* @return the new {@code GLFWWindowIconifyCallback}
*/
public static GLFWWindowIconifyCallback create(long functionPointer) {
GLFWWindowIconifyCallbackI instance = Callback.get(functionPointer);
return instance instanceof GLFWWindowIconifyCallback
? (GLFWWindowIconifyCallback)instance
: new Container(functionPointer, instance);
}
/** Like {@link #create(long) create}, but returns {@code null} if {@code functionPointer} is {@code NULL}. */
@Nullable
public static GLFWWindowIconifyCallback createSafe(long functionPointer) {
return functionPointer == NULL ? null : create(functionPointer);
}
/** Creates a {@code GLFWWindowIconifyCallback} instance that delegates to the specified {@code GLFWWindowIconifyCallbackI} instance. */
public static GLFWWindowIconifyCallback create(GLFWWindowIconifyCallbackI instance) {
return instance instanceof GLFWWindowIconifyCallback
? (GLFWWindowIconifyCallback)instance
: new Container(instance.address(), instance);
}
protected GLFWWindowIconifyCallback() {
super(CIF);
}
GLFWWindowIconifyCallback(long functionPointer) {
super(functionPointer);
}
/** See {@link GLFW#glfwSetWindowIconifyCallback SetWindowIconifyCallback}. */
public GLFWWindowIconifyCallback set(long window) {
glfwSetWindowIconifyCallback(window, this);
return this;
}
private static final class Container extends GLFWWindowIconifyCallback {
private final GLFWWindowIconifyCallbackI delegate;
Container(long functionPointer, GLFWWindowIconifyCallbackI delegate) {
super(functionPointer);
this.delegate = delegate;
}
@Override
public void invoke(long window, boolean iconified) {
delegate.invoke(window, iconified);
}
}
}

View File

@ -1,57 +0,0 @@
/*
* Copyright LWJGL. All rights reserved.
* License terms: https://www.lwjgl.org/license
* MACHINE GENERATED FILE, DO NOT EDIT
*/
package org.lwjgl.glfw;
import org.lwjgl.system.*;
import org.lwjgl.system.libffi.*;
import static org.lwjgl.system.APIUtil.*;
import static org.lwjgl.system.MemoryUtil.*;
import static org.lwjgl.system.libffi.LibFFI.*;
/**
* Instances of this interface may be passed to the {@link GLFW#glfwSetWindowIconifyCallback SetWindowIconifyCallback} method.
*
* <h3>Type</h3>
*
* <pre><code>
* void (*{@link #invoke}) (
* GLFWwindow *window,
* int iconified
* )</code></pre>
*
* @since version 3.0
*/
@FunctionalInterface
@NativeType("GLFWwindowiconifyfun")
public interface GLFWWindowIconifyCallbackI extends CallbackI {
FFICIF CIF = apiCreateCIF(
FFI_DEFAULT_ABI,
ffi_type_void,
ffi_type_pointer, ffi_type_uint32
);
@Override
default FFICIF getCallInterface() { return CIF; }
@Override
default void callback(long ret, long args) {
invoke(
memGetAddress(memGetAddress(args)),
memGetInt(memGetAddress(args + POINTER_SIZE)) != 0
);
}
/**
* Will be called when the specified window is iconified or restored.
*
* @param window the window that was iconified or restored.
* @param iconified {@link GLFW#GLFW_TRUE TRUE} if the window was iconified, or {@link GLFW#GLFW_FALSE FALSE} if it was restored
*/
void invoke(@NativeType("GLFWwindow *") long window, @NativeType("int") boolean iconified);
}

View File

@ -1,86 +0,0 @@
/*
* Copyright LWJGL. All rights reserved.
* License terms: https://www.lwjgl.org/license
* MACHINE GENERATED FILE, DO NOT EDIT
*/
package org.lwjgl.glfw;
import javax.annotation.*;
import org.lwjgl.system.*;
import static org.lwjgl.system.MemoryUtil.*;
import static org.lwjgl.glfw.GLFW.*;
/**
* Instances of this class may be passed to the {@link GLFW#glfwSetWindowMaximizeCallback SetWindowMaximizeCallback} method.
*
* <h3>Type</h3>
*
* <pre><code>
* void (*{@link #invoke}) (
* GLFWwindow *window,
* int maximized
* )</code></pre>
*
* @since version 3.3
*/
public abstract class GLFWWindowMaximizeCallback extends Callback implements GLFWWindowMaximizeCallbackI {
/**
* Creates a {@code GLFWWindowMaximizeCallback} instance from the specified function pointer.
*
* @return the new {@code GLFWWindowMaximizeCallback}
*/
public static GLFWWindowMaximizeCallback create(long functionPointer) {
GLFWWindowMaximizeCallbackI instance = Callback.get(functionPointer);
return instance instanceof GLFWWindowMaximizeCallback
? (GLFWWindowMaximizeCallback)instance
: new Container(functionPointer, instance);
}
/** Like {@link #create(long) create}, but returns {@code null} if {@code functionPointer} is {@code NULL}. */
@Nullable
public static GLFWWindowMaximizeCallback createSafe(long functionPointer) {
return functionPointer == NULL ? null : create(functionPointer);
}
/** Creates a {@code GLFWWindowMaximizeCallback} instance that delegates to the specified {@code GLFWWindowMaximizeCallbackI} instance. */
public static GLFWWindowMaximizeCallback create(GLFWWindowMaximizeCallbackI instance) {
return instance instanceof GLFWWindowMaximizeCallback
? (GLFWWindowMaximizeCallback)instance
: new Container(instance.address(), instance);
}
protected GLFWWindowMaximizeCallback() {
super(CIF);
}
GLFWWindowMaximizeCallback(long functionPointer) {
super(functionPointer);
}
/** See {@link GLFW#glfwSetWindowMaximizeCallback SetWindowMaximizeCallback}. */
public GLFWWindowMaximizeCallback set(long window) {
glfwSetWindowMaximizeCallback(window, this);
return this;
}
private static final class Container extends GLFWWindowMaximizeCallback {
private final GLFWWindowMaximizeCallbackI delegate;
Container(long functionPointer, GLFWWindowMaximizeCallbackI delegate) {
super(functionPointer);
this.delegate = delegate;
}
@Override
public void invoke(long window, boolean maximized) {
delegate.invoke(window, maximized);
}
}
}

View File

@ -1,57 +0,0 @@
/*
* Copyright LWJGL. All rights reserved.
* License terms: https://www.lwjgl.org/license
* MACHINE GENERATED FILE, DO NOT EDIT
*/
package org.lwjgl.glfw;
import org.lwjgl.system.*;
import org.lwjgl.system.libffi.*;
import static org.lwjgl.system.APIUtil.*;
import static org.lwjgl.system.MemoryUtil.*;
import static org.lwjgl.system.libffi.LibFFI.*;
/**
* Instances of this interface may be passed to the {@link GLFW#glfwSetWindowMaximizeCallback SetWindowMaximizeCallback} method.
*
* <h3>Type</h3>
*
* <pre><code>
* void (*{@link #invoke}) (
* GLFWwindow *window,
* int maximized
* )</code></pre>
*
* @since version 3.3
*/
@FunctionalInterface
@NativeType("GLFWwindowmaximizefun")
public interface GLFWWindowMaximizeCallbackI extends CallbackI {
FFICIF CIF = apiCreateCIF(
FFI_DEFAULT_ABI,
ffi_type_void,
ffi_type_pointer, ffi_type_uint32
);
@Override
default FFICIF getCallInterface() { return CIF; }
@Override
default void callback(long ret, long args) {
invoke(
memGetAddress(memGetAddress(args)),
memGetInt(memGetAddress(args + POINTER_SIZE)) != 0
);
}
/**
* Will be called when the specified window is maximized or restored.
*
* @param window the window that was maximized or restored.
* @param maximized {@link GLFW#GLFW_TRUE TRUE} if the window was maximized, or {@link GLFW#GLFW_FALSE FALSE} if it was restored
*/
void invoke(@NativeType("GLFWwindow *") long window, @NativeType("int") boolean maximized);
}

View File

@ -1,87 +0,0 @@
/*
* Copyright LWJGL. All rights reserved.
* License terms: https://www.lwjgl.org/license
* MACHINE GENERATED FILE, DO NOT EDIT
*/
package org.lwjgl.glfw;
import javax.annotation.*;
import org.lwjgl.system.*;
import static org.lwjgl.system.MemoryUtil.*;
import static org.lwjgl.glfw.GLFW.*;
/**
* Instances of this class may be passed to the {@link GLFW#glfwSetWindowPosCallback SetWindowPosCallback} method.
*
* <h3>Type</h3>
*
* <pre><code>
* void (*{@link #invoke}) (
* GLFWwindow *window,
* int xpos,
* int ypos
* )</code></pre>
*
* @since version 3.0
*/
public abstract class GLFWWindowPosCallback extends Callback implements GLFWWindowPosCallbackI {
/**
* Creates a {@code GLFWWindowPosCallback} instance from the specified function pointer.
*
* @return the new {@code GLFWWindowPosCallback}
*/
public static GLFWWindowPosCallback create(long functionPointer) {
GLFWWindowPosCallbackI instance = Callback.get(functionPointer);
return instance instanceof GLFWWindowPosCallback
? (GLFWWindowPosCallback)instance
: new Container(functionPointer, instance);
}
/** Like {@link #create(long) create}, but returns {@code null} if {@code functionPointer} is {@code NULL}. */
@Nullable
public static GLFWWindowPosCallback createSafe(long functionPointer) {
return functionPointer == NULL ? null : create(functionPointer);
}
/** Creates a {@code GLFWWindowPosCallback} instance that delegates to the specified {@code GLFWWindowPosCallbackI} instance. */
public static GLFWWindowPosCallback create(GLFWWindowPosCallbackI instance) {
return instance instanceof GLFWWindowPosCallback
? (GLFWWindowPosCallback)instance
: new Container(instance.address(), instance);
}
protected GLFWWindowPosCallback() {
super(CIF);
}
GLFWWindowPosCallback(long functionPointer) {
super(functionPointer);
}
/** See {@link GLFW#glfwSetWindowPosCallback SetWindowPosCallback}. */
public GLFWWindowPosCallback set(long window) {
glfwSetWindowPosCallback(window, this);
return this;
}
private static final class Container extends GLFWWindowPosCallback {
private final GLFWWindowPosCallbackI delegate;
Container(long functionPointer, GLFWWindowPosCallbackI delegate) {
super(functionPointer);
this.delegate = delegate;
}
@Override
public void invoke(long window, int xpos, int ypos) {
delegate.invoke(window, xpos, ypos);
}
}
}

View File

@ -1,60 +0,0 @@
/*
* Copyright LWJGL. All rights reserved.
* License terms: https://www.lwjgl.org/license
* MACHINE GENERATED FILE, DO NOT EDIT
*/
package org.lwjgl.glfw;
import org.lwjgl.system.*;
import org.lwjgl.system.libffi.*;
import static org.lwjgl.system.APIUtil.*;
import static org.lwjgl.system.MemoryUtil.*;
import static org.lwjgl.system.libffi.LibFFI.*;
/**
* Instances of this interface may be passed to the {@link GLFW#glfwSetWindowPosCallback SetWindowPosCallback} method.
*
* <h3>Type</h3>
*
* <pre><code>
* void (*{@link #invoke}) (
* GLFWwindow *window,
* int xpos,
* int ypos
* )</code></pre>
*
* @since version 3.0
*/
@FunctionalInterface
@NativeType("GLFWwindowposfun")
public interface GLFWWindowPosCallbackI extends CallbackI {
FFICIF CIF = apiCreateCIF(
FFI_DEFAULT_ABI,
ffi_type_void,
ffi_type_pointer, ffi_type_sint32, ffi_type_sint32
);
@Override
default FFICIF getCallInterface() { return CIF; }
@Override
default void callback(long ret, long args) {
invoke(
memGetAddress(memGetAddress(args)),
memGetInt(memGetAddress(args + POINTER_SIZE)),
memGetInt(memGetAddress(args + 2 * POINTER_SIZE))
);
}
/**
* Will be called when the specified window moves.
*
* @param window the window that was moved
* @param xpos the new x-coordinate, in screen coordinates, of the upper-left corner of the content area of the window
* @param ypos the new y-coordinate, in screen coordinates, of the upper-left corner of the content area of the window
*/
void invoke(@NativeType("GLFWwindow *") long window, int xpos, int ypos);
}

View File

@ -1,85 +0,0 @@
/*
* Copyright LWJGL. All rights reserved.
* License terms: https://www.lwjgl.org/license
* MACHINE GENERATED FILE, DO NOT EDIT
*/
package org.lwjgl.glfw;
import javax.annotation.*;
import org.lwjgl.system.*;
import static org.lwjgl.system.MemoryUtil.*;
import static org.lwjgl.glfw.GLFW.*;
/**
* Instances of this class may be passed to the {@link GLFW#glfwSetWindowRefreshCallback SetWindowRefreshCallback} method.
*
* <h3>Type</h3>
*
* <pre><code>
* void (*{@link #invoke}) (
* GLFWwindow *window
* )</code></pre>
*
* @since version 2.5
*/
public abstract class GLFWWindowRefreshCallback extends Callback implements GLFWWindowRefreshCallbackI {
/**
* Creates a {@code GLFWWindowRefreshCallback} instance from the specified function pointer.
*
* @return the new {@code GLFWWindowRefreshCallback}
*/
public static GLFWWindowRefreshCallback create(long functionPointer) {
GLFWWindowRefreshCallbackI instance = Callback.get(functionPointer);
return instance instanceof GLFWWindowRefreshCallback
? (GLFWWindowRefreshCallback)instance
: new Container(functionPointer, instance);
}
/** Like {@link #create(long) create}, but returns {@code null} if {@code functionPointer} is {@code NULL}. */
@Nullable
public static GLFWWindowRefreshCallback createSafe(long functionPointer) {
return functionPointer == NULL ? null : create(functionPointer);
}
/** Creates a {@code GLFWWindowRefreshCallback} instance that delegates to the specified {@code GLFWWindowRefreshCallbackI} instance. */
public static GLFWWindowRefreshCallback create(GLFWWindowRefreshCallbackI instance) {
return instance instanceof GLFWWindowRefreshCallback
? (GLFWWindowRefreshCallback)instance
: new Container(instance.address(), instance);
}
protected GLFWWindowRefreshCallback() {
super(CIF);
}
GLFWWindowRefreshCallback(long functionPointer) {
super(functionPointer);
}
/** See {@link GLFW#glfwSetWindowRefreshCallback SetWindowRefreshCallback}. */
public GLFWWindowRefreshCallback set(long window) {
glfwSetWindowRefreshCallback(window, this);
return this;
}
private static final class Container extends GLFWWindowRefreshCallback {
private final GLFWWindowRefreshCallbackI delegate;
Container(long functionPointer, GLFWWindowRefreshCallbackI delegate) {
super(functionPointer);
this.delegate = delegate;
}
@Override
public void invoke(long window) {
delegate.invoke(window);
}
}
}

View File

@ -1,55 +0,0 @@
/*
* Copyright LWJGL. All rights reserved.
* License terms: https://www.lwjgl.org/license
* MACHINE GENERATED FILE, DO NOT EDIT
*/
package org.lwjgl.glfw;
import org.lwjgl.system.*;
import org.lwjgl.system.libffi.*;
import static org.lwjgl.system.APIUtil.*;
import static org.lwjgl.system.MemoryUtil.*;
import static org.lwjgl.system.libffi.LibFFI.*;
/**
* Instances of this interface may be passed to the {@link GLFW#glfwSetWindowRefreshCallback SetWindowRefreshCallback} method.
*
* <h3>Type</h3>
*
* <pre><code>
* void (*{@link #invoke}) (
* GLFWwindow *window
* )</code></pre>
*
* @since version 2.5
*/
@FunctionalInterface
@NativeType("GLFWwindowrefreshfun")
public interface GLFWWindowRefreshCallbackI extends CallbackI {
FFICIF CIF = apiCreateCIF(
FFI_DEFAULT_ABI,
ffi_type_void,
ffi_type_pointer
);
@Override
default FFICIF getCallInterface() { return CIF; }
@Override
default void callback(long ret, long args) {
invoke(
memGetAddress(memGetAddress(args))
);
}
/**
* Will be called when the client area of the specified window needs to be redrawn, for example if the window has been exposed after having been covered by
* another window.
*
* @param window the window whose content needs to be refreshed
*/
void invoke(@NativeType("GLFWwindow *") long window);
}

View File

@ -1,85 +0,0 @@
/*
* Copyright LWJGL. All rights reserved.
* License terms: https://www.lwjgl.org/license
* MACHINE GENERATED FILE, DO NOT EDIT
*/
package org.lwjgl.glfw;
import javax.annotation.*;
import org.lwjgl.system.*;
import static org.lwjgl.system.MemoryUtil.*;
import static org.lwjgl.glfw.GLFW.*;
/**
* Instances of this class may be passed to the {@link GLFW#glfwSetWindowSizeCallback SetWindowSizeCallback} method.
*
* <h3>Type</h3>
*
* <pre><code>
* void (*{@link #invoke}) (
* GLFWwindow *window,
* int width,
* int height
* )</code></pre>
*/
public abstract class GLFWWindowSizeCallback extends Callback implements GLFWWindowSizeCallbackI {
/**
* Creates a {@code GLFWWindowSizeCallback} instance from the specified function pointer.
*
* @return the new {@code GLFWWindowSizeCallback}
*/
public static GLFWWindowSizeCallback create(long functionPointer) {
GLFWWindowSizeCallbackI instance = Callback.get(functionPointer);
return instance instanceof GLFWWindowSizeCallback
? (GLFWWindowSizeCallback)instance
: new Container(functionPointer, instance);
}
/** Like {@link #create(long) create}, but returns {@code null} if {@code functionPointer} is {@code NULL}. */
@Nullable
public static GLFWWindowSizeCallback createSafe(long functionPointer) {
return functionPointer == NULL ? null : create(functionPointer);
}
/** Creates a {@code GLFWWindowSizeCallback} instance that delegates to the specified {@code GLFWWindowSizeCallbackI} instance. */
public static GLFWWindowSizeCallback create(GLFWWindowSizeCallbackI instance) {
return instance instanceof GLFWWindowSizeCallback
? (GLFWWindowSizeCallback)instance
: new Container(instance.address(), instance);
}
protected GLFWWindowSizeCallback() {
super(CIF);
}
GLFWWindowSizeCallback(long functionPointer) {
super(functionPointer);
}
/** See {@link GLFW#glfwSetWindowSizeCallback SetWindowSizeCallback}. */
public GLFWWindowSizeCallback set(long window) {
glfwSetWindowSizeCallback(window, this);
return this;
}
private static final class Container extends GLFWWindowSizeCallback {
private final GLFWWindowSizeCallbackI delegate;
Container(long functionPointer, GLFWWindowSizeCallbackI delegate) {
super(functionPointer);
this.delegate = delegate;
}
@Override
public void invoke(long window, int width, int height) {
delegate.invoke(window, width, height);
}
}
}

View File

@ -1,58 +0,0 @@
/*
* Copyright LWJGL. All rights reserved.
* License terms: https://www.lwjgl.org/license
* MACHINE GENERATED FILE, DO NOT EDIT
*/
package org.lwjgl.glfw;
import org.lwjgl.system.*;
import org.lwjgl.system.libffi.*;
import static org.lwjgl.system.APIUtil.*;
import static org.lwjgl.system.MemoryUtil.*;
import static org.lwjgl.system.libffi.LibFFI.*;
/**
* Instances of this interface may be passed to the {@link GLFW#glfwSetWindowSizeCallback SetWindowSizeCallback} method.
*
* <h3>Type</h3>
*
* <pre><code>
* void (*{@link #invoke}) (
* GLFWwindow *window,
* int width,
* int height
* )</code></pre>
*/
@FunctionalInterface
@NativeType("GLFWwindowsizefun")
public interface GLFWWindowSizeCallbackI extends CallbackI {
FFICIF CIF = apiCreateCIF(
FFI_DEFAULT_ABI,
ffi_type_void,
ffi_type_pointer, ffi_type_sint32, ffi_type_sint32
);
@Override
default FFICIF getCallInterface() { return CIF; }
@Override
default void callback(long ret, long args) {
invoke(
memGetAddress(memGetAddress(args)),
memGetInt(memGetAddress(args + POINTER_SIZE)),
memGetInt(memGetAddress(args + 2 * POINTER_SIZE))
);
}
/**
* Will be called when the specified window is resized.
*
* @param window the window that was resized
* @param width the new width, in screen coordinates, of the window
* @param height the new height, in screen coordinates, of the window
*/
void invoke(@NativeType("GLFWwindow *") long window, int width, int height);
}

View File

@ -1,290 +0,0 @@
/*
* Copyright (c) 2002-2008 LWJGL Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of 'LWJGL' nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.lwjgl.input;
/**
* A game controller of some sort that will provide input. The controller
* presents buttons and axes. Buttons are either pressed or not pressed. Axis
* provide analogue values.
*
* @author Kevin Glass
*/
public interface Controller {
/**
* Get the name assigned to this controller.
*
* @return The name assigned to this controller
*/
String getName();
/**
* Get the index of this controller in the collection
*
* @return The index of this controller in the collection
*/
int getIndex();
/**
* Retrieve the number of buttons available on this controller
*
* @return The number of butotns available on this controller
*/
int getButtonCount();
/**
* Get the name of the specified button. Be warned, often this is
* as exciting as "Button X"
*
* @param index The index of the button whose name should be retrieved
* @return The name of the button requested
*/
String getButtonName(int index);
/**
* Check if a button is currently pressed
*
* @param index The button to check
* @return True if the button is currently pressed
*/
boolean isButtonPressed(int index);
/**
* Poll the controller for new data. This will also update
* events
*/
void poll();
/**
* Get the X-Axis value of the POV on this controller
*
* @return The X-Axis value of the POV on this controller
*/
float getPovX();
/**
* Get the Y-Axis value of the POV on this controller
*
* @return The Y-Axis value of the POV on this controller
*/
float getPovY();
/**
* Get the dead zone for a specified axis
*
* @param index The index of the axis for which to retrieve the dead zone
* @return The dead zone for the specified axis
*/
float getDeadZone(int index);
/**
* Set the dead zone for the specified axis
*
* @param index The index of hte axis for which to set the dead zone
* @param zone The dead zone to use for the specified axis
*/
void setDeadZone(int index,float zone);
/**
* Retrieve the number of axes available on this controller.
*
* @return The number of axes available on this controller.
*/
int getAxisCount();
/**
* Get the name that's given to the specified axis
*
* @param index The index of the axis whose name should be retrieved
* @return The name of the specified axis.
*/
String getAxisName(int index);
/**
* Retrieve the value thats currently available on a specified axis. The
* value will always be between 1.0 and -1.0 and will calibrate as values
* are passed read. It may be useful to get the player to wiggle the joystick
* from side to side to get the calibration right.
*
* @param index The index of axis to be read
* @return The value from the specified axis.
*/
float getAxisValue(int index);
/**
* Get the value from the X axis if there is one. If no X axis is
* defined a zero value will be returned.
*
* @return The value from the X axis
*/
float getXAxisValue();
/**
* Get the dead zone for the X axis.
*
* @return The dead zone for the X axis
*/
float getXAxisDeadZone();
/**
* Set the dead zone for the X axis
*
* @param zone The dead zone to use for the X axis
*/
void setXAxisDeadZone(float zone);
/**
* Get the value from the Y axis if there is one. If no Y axis is
* defined a zero value will be returned.
*
* @return The value from the Y axis
*/
float getYAxisValue();
/**
* Get the dead zone for the Y axis.
*
* @return The dead zone for the Y axis
*/
float getYAxisDeadZone();
/**
* Set the dead zone for the Y axis
*
* @param zone The dead zone to use for the Y axis
*/
void setYAxisDeadZone(float zone);
/**
* Get the value from the Z axis if there is one. If no Z axis is
* defined a zero value will be returned.
*
* @return The value from the Z axis
*/
float getZAxisValue();
/**
* Get the dead zone for the Z axis.
*
* @return The dead zone for the Z axis
*/
float getZAxisDeadZone();
/**
* Set the dead zone for the Z axis
*
* @param zone The dead zone to use for the Z axis
*/
void setZAxisDeadZone(float zone);
/**
* Get the value from the RX axis if there is one. If no RX axis is
* defined a zero value will be returned.
*
* @return The value from the RX axis
*/
float getRXAxisValue();
/**
* Get the dead zone for the RX axis.
*
* @return The dead zone for the RX axis
*/
float getRXAxisDeadZone();
/**
* Set the dead zone for the RX axis
*
* @param zone The dead zone to use for the RX axis
*/
void setRXAxisDeadZone(float zone);
/**
* Get the value from the RY axis if there is one. If no RY axis is
* defined a zero value will be returned.
*
* @return The value from the RY axis
*/
float getRYAxisValue();
/**
* Get the dead zone for the RY axis.
*
* @return The dead zone for the RY axis
*/
float getRYAxisDeadZone();
/**
* Set the dead zone for the RY axis
*
* @param zone The dead zone to use for the RY axis
*/
void setRYAxisDeadZone(float zone);
/**
* Get the value from the RZ axis if there is one. If no RZ axis is
* defined a zero value will be returned.
*
* @return The value from the RZ axis
*/
float getRZAxisValue();
/**
* Get the dead zone for the RZ axis.
*
* @return The dead zone for the RZ axis
*/
float getRZAxisDeadZone();
/**
* Set the dead zone for the RZ axis
*
* @param zone The dead zone to use for the RZ axis
*/
void setRZAxisDeadZone(float zone);
/** Returns the number of rumblers this controller supports */
int getRumblerCount();
/** Returns the name of the specified rumbler
*
* @param index The rumbler index
*/
String getRumblerName(int index);
/** Sets the vibration strength of the specified rumbler
*
* @param index The index of the rumbler
* @param strength The strength to vibrate at
*/
void setRumblerStrength(int index, float strength);
}

View File

@ -1,222 +0,0 @@
/*
* Copyright (c) 2002-2008 LWJGL Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of 'LWJGL' nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.lwjgl.input;
/**
* An event occuring on a controller.
*
* @author Kevin Glass
*/
class ControllerEvent {
/** Indicates the event was caused by a button */
public static final int BUTTON = 1;
/** Indicates the event was caused by a axis */
public static final int AXIS = 2;
/** Indicates the event was caused by a pov X */
public static final int POVX = 3;
/** Indicates the event was caused by a pov Y */
public static final int POVY = 4;
/** The controller generating the event */
private Controller source;
/** The index of the input (axis or button) that generated the event */
private int index;
/** Type of control that generated the event */
private int type;
/** True when a button is pressed, if this event was caused by the button */
private boolean buttonState;
/** True if this event was caused by the x axis */
private boolean xaxis;
/** True if this event was caused by the y axis */
private boolean yaxis;
/** The time stamp of this event */
private long timeStamp;
/** The value on a specified axis, if this event was caused by the x-axis */
private float xaxisValue;
/** The value on a specified axis, if this event was caused by the y-axis */
private float yaxisValue;
/**
* Create a new event
*
* @param source The source of the event
* @param timeStamp The time stamp given for this event
* @param type The type of control generating this event
* @param index The index of the input that generated the event
* @param xaxis True if this event was caused by the x-axis
* @param yaxis True if this event was caused by the y-axis
*/
ControllerEvent(Controller source,long timeStamp, int type,int index,boolean xaxis,boolean yaxis) {
this(source, timeStamp, type, index, false, xaxis, yaxis, 0, 0);
}
/**
* Create a new event
*
* @param source The source of the event
* @param timeStamp The time stamp given for this event
* @param type The type of control generating this event
* @param index The index of the input that generated the event
* @param buttonState True when a button is pressed, if this event was caused by the button
* @param xaxis True if this event was caused by the x-axis
* @param yaxis True if this event was caused by the y-axis
* @param xaxisValue The value on a specified axis, if this event was caused by the x-axis
* @param yaxisValue The value on a specified axis, if this event was caused by the y-axis
*/
ControllerEvent(Controller source,long timeStamp, int type,int index,boolean buttonState,boolean xaxis,boolean yaxis,float xaxisValue,float yaxisValue) {
this.source = source;
this.timeStamp = timeStamp;
this.type = type;
this.index = index;
this.buttonState = buttonState;
this.xaxis = xaxis;
this.yaxis = yaxis;
this.xaxisValue = xaxisValue;
this.yaxisValue = yaxisValue;
}
/**
* Get the time stamp given for this event. As with nanoTime()
* this value means nothing other than giving ordering
*
* @return The time stamp given for this event
*/
public long getTimeStamp() {
return timeStamp;
}
/**
* Get the controller that generated this event
*
* @return The controller that generated this event
*/
public Controller getSource() {
return source;
}
/**
* Get the index of the control generating this event
*
* @return The index of the control generating this event
*/
public int getControlIndex() {
return index;
}
/**
* Check if this event was generated by a button
*
* @return True if this event was generated by a button
*/
public boolean isButton() {
return type == BUTTON;
}
/**
* Check the button is pressed or not, when this event was caused
*
* @return True when a button is pressed, if this event was caused by the button
*/
public boolean getButtonState() {
return buttonState;
}
/**
* Check if this event was generated by a axis
*
* @return True if this event was generated by a axis
*/
public boolean isAxis() {
return type == AXIS;
}
/**
* Check if this event was generated by a pov
*
* @return True if this event was generated by a pov
*/
public boolean isPovY() {
return type == POVY;
}
/**
*
* Check if this event was generated by a pov
*
* @return True if this event was generated by a pov
*/
public boolean isPovX() {
return type == POVX;
}
/**
* Check if this event was caused by the X axis
*
* @return True if this event was caused by the X axis
*/
public boolean isXAxis() {
return xaxis;
}
/**
* Check if this event was caused by the Y axis
*
* @return True if this event was caused by the Y axis
*/
public boolean isYAxis() {
return yaxis;
}
/**
* Get the value on an X axis when this event was caused
*
* @return The value on a specified axis, if this event was caused by the x-axis
*/
public float getXAxisValue() {
return xaxisValue;
}
/**
* Get the value on an Y axis when this event was caused
*
* @return The value on a specified axis, if this event was caused by the y-axis
*/
public float getYAxisValue() {
return yaxisValue;
}
/*
* @see java.lang.Object#toString()
*/
public String toString() {
return "["+source+" type="+type+" xaxis="+xaxis+" yaxis="+yaxis+"]";
}
}

View File

@ -1,308 +0,0 @@
/*
* Copyright (c) 2002-2008 LWJGL Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of 'LWJGL' nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.lwjgl.input;
import net.java.games.input.ControllerEnvironment;
import org.lwjgl.LWJGLException;
import java.util.ArrayList;
/**
* The collection of controllers currently connected.
*
* @author Kevin Glass
*/
public class Controllers {
/** The controllers available */
private static ArrayList<JInputController> controllers = new ArrayList<JInputController>();
/** The number of controllers */
private static int controllerCount;
/** The current list of events */
private static ArrayList<ControllerEvent> events = new ArrayList<ControllerEvent>();
/** The current event */
private static ControllerEvent event;
/** Whether controllers were created */
private static boolean created;
/**
* Initialise the controllers collection
*
* @throws LWJGLException Indicates a failure to initialise the controller library.
*/
public static void create() throws LWJGLException {
if (created)
return;
try {
ControllerEnvironment env = ControllerEnvironment.getDefaultEnvironment();
net.java.games.input.Controller[] found = env.getControllers();
ArrayList<net.java.games.input.Controller> lollers = new ArrayList<net.java.games.input.Controller>();
for ( net.java.games.input.Controller c : found ) {
if ( (!c.getType().equals(net.java.games.input.Controller.Type.KEYBOARD)) &&
(!c.getType().equals(net.java.games.input.Controller.Type.MOUSE)) ) {
lollers.add(c);
}
}
for ( net.java.games.input.Controller c : lollers ) {
createController(c);
}
created = true;
} catch (Throwable e) {
throw new LWJGLException("Failed to initialise controllers",e);
}
}
/**
* Utility to create a controller based on its potential sub-controllers
*
* @param c The controller to add
*/
private static void createController(net.java.games.input.Controller c) {
net.java.games.input.Controller[] subControllers = c.getControllers();
if (subControllers.length == 0) {
JInputController controller = new JInputController(controllerCount,c);
controllers.add(controller);
controllerCount++;
} else {
for ( net.java.games.input.Controller sub : subControllers ) {
createController(sub);
}
}
}
/**
* Get a controller from the collection
*
* @param index The index of the controller to retrieve
* @return The controller requested
*/
public static Controller getController(int index) {
return controllers.get(index);
}
/**
* Retrieve a count of the number of controllers
*
* @return The number of controllers available
*/
public static int getControllerCount() {
return controllers.size();
}
/**
* Poll the controllers available. This will both update their state
* and generate events that must be cleared.
*/
public static void poll() {
for (int i=0;i<controllers.size();i++) {
getController(i).poll();
}
}
/**
* Clear any events stored for the controllers in this set
*/
public static void clearEvents() {
events.clear();
}
/**
* Move to the next event that has been stored.
*
* @return True if there is still an event to process
*/
public static boolean next() {
if (events.size() == 0) {
event = null;
return false;
}
event = events.remove(0);
return event != null;
}
/**
* @return True if Controllers has been created
*/
public static boolean isCreated() {
return created;
}
/**
* Destroys any resources used by the controllers
*/
public static void destroy() {
// FIXME! not currently possible to destroy a controller
// if (!created)
// return;
// created = false;
//
// // nuke each controller
// for (int i=0;i<controllers.size();i++) {
// //
// }
//
// // cleanup
// event = null;
// events.clear();
// controllers.clear();
// controllerCount = 0;
}
/**
* Get the source of the current event
*
* @return The source of the current event
*/
public static Controller getEventSource() {
return event.getSource();
}
/**
* Get the index of the control that caused the current event
*
* @return The index of the control that cause the current event
*/
public static int getEventControlIndex() {
return event.getControlIndex();
}
/**
* Check if the current event was caused by a button
*
* @return True if the current event was caused by a button
*/
public static boolean isEventButton() {
return event.isButton();
}
/**
* Check if the current event was caused by a axis
*
* @return True if the current event was caused by a axis
*/
public static boolean isEventAxis() {
return event.isAxis();
}
/**
* Check if the current event was caused by movement on the x-axis
*
* @return True if the current event was cause by movement on the x-axis
*/
public static boolean isEventXAxis() {
return event.isXAxis();
}
/**
* Check if the current event was caused by movement on the y-axis
*
* @return True if the current event was caused by movement on the y-axis
*/
public static boolean isEventYAxis() {
return event.isYAxis();
}
/**
* Check if the current event was cause by the POV x-axis
*
* @return True if the current event was caused by the POV x-axis
*/
public static boolean isEventPovX() {
return event.isPovX();
}
/**
* Check if the current event was cause by the POV x-axis
*
* @return True if the current event was caused by the POV x-axis
*/
public static boolean isEventPovY() {
return event.isPovY();
}
/**
* Get the timestamp assigned to the current event
*
* @return The timestamp assigned to the current event
*/
public static long getEventNanoseconds() {
return event.getTimeStamp();
}
/**
* Gets the state of the button that generated the current event
*
* @return True if button was down, or false if released
*/
public static boolean getEventButtonState() {
return event.getButtonState();
}
/**
* Get the value on an X axis of the current event
*
* @return The value on a x axis of the current event
*/
public static float getEventXAxisValue() {
return event.getXAxisValue();
}
/**
* Get the value on an Y axis of the current event
*
* @return The value on a y axis of the current event
*/
public static float getEventYAxisValue() {
return event.getYAxisValue();
}
/**
* Add an event to the stack of events that have been caused
*
* @param event The event to add to the list
*/
static void addEvent(ControllerEvent event) {
if (event != null) {
events.add(event);
}
}
}

View File

@ -1,284 +0,0 @@
package org.lwjgl.input;
import org.lwjgl.BufferUtils;
import org.lwjgl.LWJGLException;
import org.lwjgl.glfw.GLFW;
import org.lwjgl.glfw.GLFWImage;
import org.lwjgl.system.MemoryUtil;
import java.nio.ByteBuffer;
import java.nio.IntBuffer;
public class Cursor {
/** 1 bit transparency for native cursor */
public static final int CURSOR_ONE_BIT_TRANSPARENCY = 1;
/** 8 bit alpha native cursor */
public static final int CURSOR_8_BIT_ALPHA = 2;
/** Animation native cursor */
public static final int CURSOR_ANIMATION = 4;
/** Elements to display */
private final CursorElement[] cursors;
/** Index into list of cursors */
private int index;
/** Flag set when the cursor has been destroyed */
private boolean destroyed;
/** Flag set if the cursor is empty */
private boolean isEmpty;
/**
* Constructs a new Cursor, with the given parameters. Mouse must have been
* created before you can create Cursor objects. Cursor images are in ARGB
* format, but only one bit transparency is guaranteed to be supported. So
* to maximize portability, LWJGL applications should only create cursor
* images with 0x00 or 0xff as alpha values. The constructor will copy the
* images and delays, so there's no need to keep them around.
*
* @param width
* cursor image width
* @param height
* cursor image height
* @param xHotspot
* the x coordinate of the cursor hotspot
* @param yHotspot
* the y coordinate of the cursor hotspot
* @param numImages
* number of cursor images specified. Must be 1 if animations are
* not supported.
* @param images
* A buffer containing the images. The origin is at the lower
* left corner, like OpenGL.
* @param delays
* An int buffer of animation frame delays, if numImages is
* greater than 1, else null
* @throws LWJGLException
* if the cursor could not be created for any reason
*/
public Cursor(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, IntBuffer delays) throws LWJGLException {
cursors = new CursorElement[numImages];
IntBuffer flippedImages = BufferUtils.createIntBuffer(images.limit());
flipImages(width, height, numImages, images, flippedImages);
ByteBuffer pixels = convertARGBIntBuffertoRGBAByteBuffer(width, height, flippedImages);
if(numImages == 1) {
isEmpty = true;
for(int i = 0; i < width*height; i++) if(pixels.get(i) != 0) {
System.out.println("Encountered non-zero byte at "+i+", custom cursor is not empty!");
isEmpty = false;
}
}
for (int i = 0; i < numImages; i++) {
int size = width * height;
ByteBuffer image = BufferUtils.createByteBuffer(size);
for (int j = 0; j < size; j++)
image.put(pixels.get());
GLFWImage cursorImage = GLFWImage.malloc();
cursorImage.width(width);
cursorImage.height(height);
cursorImage.pixels(image);
long delay = (delays != null) ? delays.get(i) : 0;
long timeout = GLFW.glfwGetTimerValue();
cursors[i] = new CursorElement(xHotspot, yHotspot, delay, timeout, cursorImage);
}
}
private static ByteBuffer convertARGBIntBuffertoRGBAByteBuffer(int width, int height, IntBuffer imageBuffer) {
ByteBuffer pixels = BufferUtils.createByteBuffer(width * height * 4);
for (int i = 0; i < imageBuffer.limit(); i++) {
int argbColor = imageBuffer.get(i);
byte alpha = (byte) (argbColor >>> 24);
byte blue = (byte) (argbColor >>> 16);
byte green = (byte) (argbColor >>> 8);
byte red = (byte) argbColor;
pixels.put(red);
pixels.put(green);
pixels.put(blue);
pixels.put(alpha);
}
pixels.flip();
return pixels;
}
/**
* Gets the minimum size of a native cursor. Can only be called if The Mouse
* is created and cursor caps includes at least CURSOR_ONE_BIT_TRANSPARANCY.
*
* @return the minimum size of a native cursor
*/
public static int getMinCursorSize() {
return 1;
}
/**
* Gets the maximum size of a native cursor. Can only be called if the
* cursor caps includes at least {@link #CURSOR_ONE_BIT_TRANSPARENCY}.
*
* @return the maximum size of a native cursor
*/
public static int getMaxCursorSize() {
return 512;
}
/**
* Get the capabilities of the native cursor. Return a bit mask of the
* native cursor capabilities.
* <ul>
* <li><code>CURSOR_ONE_BIT_TRANSPARENCY</code> indicates support for
* cursors with one bit transparency.</li>
*
* <li><code>CURSOR_8_BIT_ALPHA</code> indicates support for 8 bit
* alpha.</li>
*
* <li><code>CURSOR_ANIMATION</code> indicates support for cursor
* animations.</li>
* </ul>
*
* @return A bit mask with native cursor capabilities.
*/
public static int getCapabilities() {
return CURSOR_8_BIT_ALPHA | CURSOR_ANIMATION;
}
/**
* Flips the images so they're oriented according to OpenGL
*
* @param width
* Width of image
* @param height
* Height of images
* @param numImages
* How many images to flip
* @param images
* Source images
* @param images_copy
* Destination images
*/
private static void flipImages(int width, int height, int numImages, IntBuffer images, IntBuffer images_copy) {
for (int i = 0; i < numImages; i++) {
int start_index = i * width * height;
flipImage(width, height, start_index, images, images_copy);
}
}
/**
* @param width
* Width of image
* @param height
* Height of images
* @param start_index
* index into source buffer to copy to
* @param images
* Source images
* @param images_copy
* Destination images
*/
private static void flipImage(int width, int height, int start_index, IntBuffer images, IntBuffer images_copy) {
for (int y = 0; y < height >> 1; y++) {
int index_y_1 = y * width + start_index;
int index_y_2 = (height - y - 1) * width + start_index;
for (int x = 0; x < width; x++) {
int index1 = index_y_1 + x;
int index2 = index_y_2 + x;
int temp_pixel = images.get(index1 + images.position());
images_copy.put(index1, images.get(index2 + images.position()));
images_copy.put(index2, temp_pixel);
}
}
}
/**
* Gets the native handle associated with the cursor object.
*/
long getHandle() {
checkValid();
return cursors[index].cursorHandle;
}
/**
* Checks whether the cursor is still active and not yet destroyed.
*/
private void checkValid() {
if (destroyed)
throw new IllegalStateException("The cursor is already destroyed");
}
/**
* Destroy the current cursor. If the cursor is current, the current native
* cursor is set to null (the default OS cursor)
*/
public void destroy() {
for (CursorElement cursor : cursors)
GLFW.glfwDestroyCursor(cursor.cursorHandle);
destroyed = true;
}
/**
* Sets the timout property to the time it should be changed
*/
protected void setTimeout() {
checkValid();
cursors[index].timeout = GLFW.glfwGetTimerValue() + cursors[index].delay;
}
/**
* Determines whether this cursor has timed out
*
* @return true if the this cursor has timed out, false if not
*/
protected boolean hasTimedOut() {
checkValid();
return cursors.length > 1 && cursors[index].timeout < GLFW.glfwGetTimerValue();
}
/**
* Changes to the next cursor
*/
protected void nextCursor() {
checkValid();
index = ++index % cursors.length;
}
/**
/* Returns wheteher the cursor image is empty or not
*/
/*package-private*/ boolean isEmpty() {
return isEmpty;
}
/**
* A single cursor element, used when animating
*/
private static class CursorElement {
final long cursorHandle;
long delay;
long timeout;
CursorElement(int xHotspot, int yHotspot, long delay, long timeout, GLFWImage image) {
this.delay = delay;
this.timeout = timeout;
this.cursorHandle = GLFW.glfwCreateCursor(image, xHotspot, yHotspot);
if (cursorHandle == MemoryUtil.NULL)
throw new RuntimeException("Error creating GLFW cursor");
}
}
}

View File

@ -1,83 +0,0 @@
/*
* Copyright (c) 2002-2008 LWJGL Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of 'LWJGL' nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.lwjgl.input;
/**
* A java implementation of a LWJGL compatible event queue.
* @author elias_naur
*/
import java.nio.ByteBuffer;
class EventQueue {
private static final int QUEUE_SIZE = 200;
private final int event_size;
private final ByteBuffer queue;
protected EventQueue(int event_size) {
this.event_size = event_size;
this.queue = ByteBuffer.allocate(QUEUE_SIZE*event_size);
}
protected synchronized void clearEvents() {
queue.clear();
}
/**
* Copy available events into the specified buffer.
*/
public synchronized void copyEvents(ByteBuffer dest) {
queue.flip();
int old_limit = queue.limit();
if (dest.remaining() < queue.remaining())
queue.limit(dest.remaining() + queue.position());
dest.put(queue);
queue.limit(old_limit);
queue.compact();
}
/**
* Put an event into the queue.
* @return true if the event fitted into the queue, false otherwise
*/
public synchronized boolean putEvent(ByteBuffer event) {
if (event.remaining() != event_size)
throw new IllegalArgumentException("Internal error: event size " + event_size + " does not equal the given event size " + event.remaining());
if (queue.remaining() >= event.remaining()) {
queue.put(event);
return true;
} else
return false;
}
}

View File

@ -1,183 +0,0 @@
package org.lwjgl.input;
import org.lwjgl.LWJGLException;
import org.lwjgl.glfw.GLFW;
import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.InputImplementation;
import java.nio.ByteBuffer;
import java.nio.IntBuffer;
public class GLFWInputImplementation implements InputImplementation {
public static final GLFWInputImplementation singleton = new GLFWInputImplementation();
private final ByteBuffer eventBuffer = ByteBuffer.allocate(Mouse.EVENT_SIZE);
private final EventQueue eventQueue = new EventQueue(Mouse.EVENT_SIZE);
private final EventQueue keyboardEventQueue = new EventQueue(Keyboard.EVENT_SIZE);
private final ByteBuffer keyboardEvent = ByteBuffer.allocate(Keyboard.EVENT_SIZE);
public final byte[] keyDownBuffer = new byte[Keyboard.KEYBOARD_SIZE];
public final byte[] mouseBuffer = new byte[3];
public int mouseX = 0;
public int mouseY = 0;
public int mouseLastX = 0;
public int mouseLastY = 0;
public boolean grab;
public boolean correctCursor;
@Override
public boolean hasWheel() {
return true;
}
@Override
public int getButtonCount() {
return 3;
}
@Override
public void createMouse() throws LWJGLException {
}
@Override
public void destroyMouse() {
}
@Override
public void pollMouse(IntBuffer coord_buffer, ByteBuffer buttons) {
coord_buffer.put(0, grab ? mouseX - mouseLastX : mouseX);
coord_buffer.put(1, grab ? mouseY - mouseLastY : mouseY);
buttons.rewind();
buttons.put(mouseBuffer);
mouseLastX = mouseX;
mouseLastY = mouseY;
}
@Override
public void readMouse(ByteBuffer buffer) {
eventQueue.copyEvents(buffer);
}
@Override
public void grabMouse(boolean newGrab) {
grab = newGrab;
correctCursor = newGrab;
GLFW.glfwSetInputMode(Display.getWindow(), GLFW.GLFW_CURSOR, grab ? GLFW.GLFW_CURSOR_DISABLED : GLFW.GLFW_CURSOR_NORMAL);
}
@Override
public int getNativeCursorCapabilities() {
return 0;
}
@Override
public void setCursorPosition(int x, int y) {
}
@Override
public void setNativeCursor(Object handle) throws LWJGLException {
}
@Override
public int getMinCursorSize() {
return 0;
}
@Override
public int getMaxCursorSize() {
return 0;
}
@Override
public void createKeyboard() throws LWJGLException {
}
@Override
public void destroyKeyboard() {
}
@Override
public void pollKeyboard(ByteBuffer keyDownBuffer) {
int oldPosition = keyDownBuffer.position();
keyDownBuffer.put(this.keyDownBuffer);
keyDownBuffer.position(oldPosition);
}
public void readKeyboard(ByteBuffer buffer) {
keyboardEventQueue.copyEvents(buffer);
}
@Override
public Object createCursor(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, IntBuffer delays) throws LWJGLException {
return null;
}
@Override
public void destroyCursor(Object cursor_handle) {
}
@Override
public int getWidth() {
return Display.getWidth();
}
@Override
public int getHeight() {
return Display.getHeight();
}
@Override
public boolean isInsideWindow() {
return true;
}
public void putMouseEventWithCoords(byte button, byte state, int x, int y, int dz, long nanos) {
int rebaseX;
int rebaseY;
if (x == -1 && y == -1) {
rebaseX = mouseX;
rebaseY = mouseY;
} else {
rebaseX = x;
rebaseY = y;
if (correctCursor) {
mouseX = x;
mouseY = y;
mouseLastX = mouseX;
mouseLastY = mouseY;
correctCursor = false;
return;
}
}
eventBuffer.clear();
eventBuffer.put(button).put(state);
if (grab) {
eventBuffer.putInt(rebaseX - mouseX).putInt(rebaseY - mouseY);
} else {
eventBuffer.putInt(rebaseX).putInt(rebaseY);
}
if (button != -1) {
mouseBuffer[button] = state;
}
eventBuffer.putInt(dz).putLong(nanos);
eventBuffer.flip();
eventQueue.putEvent(eventBuffer);
mouseX = rebaseX;
mouseY = rebaseY;
}
public void putKeyboardEvent(int keycode, byte state, int ch, long nanos, boolean repeat) {
keyDownBuffer[keycode] = state;
keyboardEvent.clear();
keyboardEvent.putInt(keycode).put(state).putInt(ch).putLong(nanos).put(repeat ? (byte) 1 : (byte) 0);
keyboardEvent.flip();
keyboardEventQueue.putEvent(keyboardEvent);
}
}

View File

@ -1,26 +0,0 @@
package org.lwjgl.input;
import net.java.openjdk.cacio.ctc.ExternalMouseReader;
import net.java.openjdk.cacio.ctc.InfdevGrabHandler;
public class InfdevMouse implements ExternalMouseReader, Mouse.EmptyCursorGrabListener {
static {
InfdevGrabHandler.setMouseReader(new InfdevMouse());
}
@Override
public int getX() {
return Mouse.getAbsoluteX();
}
@Override
public int getY() {
return Mouse.getAbsoluteY();
}
@Override
public void onGrab(boolean grabbing) {
InfdevGrabHandler.setGrabbed(grabbing);
}
}

View File

@ -1,537 +0,0 @@
/*
* Copyright (c) 2002-2008 LWJGL Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of 'LWJGL' nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.lwjgl.input;
import net.java.games.input.Component;
import net.java.games.input.Component.Identifier.Axis;
import net.java.games.input.Component.Identifier.Button;
import net.java.games.input.Event;
import net.java.games.input.EventQueue;
import net.java.games.input.Rumbler;
import java.util.ArrayList;
/**
* A wrapper round a JInput controller that attempts to make the interface
* more useable.
*
* @author Kevin Glass
*/
class JInputController implements Controller {
/** The JInput controller this class is wrapping */
private net.java.games.input.Controller target;
/** The index that has been assigned to this controller */
private int index;
/** The Buttons that have been detected on the JInput controller */
private ArrayList<Component> buttons = new ArrayList<Component>();
/** The Axes that have been detected on the JInput controller */
private ArrayList<Component> axes = new ArrayList<Component>();
/** The POVs that have been detected on the JInput controller */
private ArrayList<Component> pov = new ArrayList<Component>();
/** The rumblers exposed by the controller */
private Rumbler[] rumblers;
/** The state of the buttons last check */
private boolean[] buttonState;
/** The values that were read from the pov last check */
private float[] povValues;
/** The values that were read from the axes last check */
private float[] axesValue;
/** The maximum values read for each axis */
private float[] axesMax;
/** The dead zones for each axis */
private float[] deadZones;
/** The index of the X axis or -1 if no X axis is defined */
private int xaxis = -1;
/** The index of the Y axis or -1 if no Y axis is defined */
private int yaxis = -1;
/** The index of the X axis or -1 if no Z axis is defined */
private int zaxis = -1;
/** The index of the RX axis or -1 if no RX axis is defined */
private int rxaxis = -1;
/** The index of the RY axis or -1 if no RY axis is defined */
private int ryaxis = -1;
/** The index of the RZ axis or -1 if no RZ axis is defined */
private int rzaxis = -1;
/**
* Create a new controller that wraps round a JInput controller and hopefully
* makes it easier to use.
*
* @param index The index this controller has been assigned to
* @param target The target JInput controller this class is wrapping
*/
JInputController(int index, net.java.games.input.Controller target) {
this.target = target;
this.index = index;
Component[] sourceAxes = target.getComponents();
for ( Component sourceAxis : sourceAxes ) {
if ( sourceAxis.getIdentifier() instanceof Button ) {
buttons.add(sourceAxis);
} else if ( sourceAxis.getIdentifier().equals(Axis.POV) ) {
pov.add(sourceAxis);
} else {
axes.add(sourceAxis);
}
}
buttonState = new boolean[buttons.size()];
povValues = new float[pov.size()];
axesValue = new float[axes.size()];
int buttonsCount = 0;
int axesCount = 0;
// initialise the state
for ( Component sourceAxis : sourceAxes ) {
if ( sourceAxis.getIdentifier() instanceof Button ) {
buttonState[buttonsCount] = sourceAxis.getPollData() != 0;
buttonsCount++;
} else if ( sourceAxis.getIdentifier().equals(Axis.POV) ) {
// no account for POV yet
// pov.add(sourceAxes[i]);
} else {
axesValue[axesCount] = sourceAxis.getPollData();
if ( sourceAxis.getIdentifier().equals(Axis.X) ) {
xaxis = axesCount;
}
if ( sourceAxis.getIdentifier().equals(Axis.Y) ) {
yaxis = axesCount;
}
if ( sourceAxis.getIdentifier().equals(Axis.Z) ) {
zaxis = axesCount;
}
if ( sourceAxis.getIdentifier().equals(Axis.RX) ) {
rxaxis = axesCount;
}
if ( sourceAxis.getIdentifier().equals(Axis.RY) ) {
ryaxis = axesCount;
}
if ( sourceAxis.getIdentifier().equals(Axis.RZ) ) {
rzaxis = axesCount;
}
axesCount++;
}
}
axesMax = new float[axes.size()];
deadZones = new float[axes.size()];
for (int i=0;i<axesMax.length;i++) {
axesMax[i] = 1.0f;
deadZones[i] = 0.05f;
}
rumblers = target.getRumblers();
}
/*
* @see org.lwjgl.input.Controller#getName()
*/
public String getName() {
String name = target.getName();
return name;
}
/*
* @see org.lwjgl.input.Controller#getIndex()
*/
public int getIndex() {
return index;
}
/*
* @see org.lwjgl.input.Controller#getButtonCount()
*/
public int getButtonCount() {
return buttons.size();
}
/*
* @see org.lwjgl.input.Controller#getButtonName(int)
*/
public String getButtonName(int index) {
return buttons.get(index).getName();
}
/*
* @see org.lwjgl.input.Controller#isButtonPressed(int)
*/
public boolean isButtonPressed(int index) {
return buttonState[index];
}
/*
* @see org.lwjgl.input.Controller#poll()
*/
public void poll() {
target.poll();
Event event = new Event();
EventQueue queue = target.getEventQueue();
while (queue.getNextEvent(event)) {
// handle button event
if (buttons.contains(event.getComponent())) {
Component button = event.getComponent();
int buttonIndex = buttons.indexOf(button);
buttonState[buttonIndex] = event.getValue() != 0;
// fire button pressed event
Controllers.addEvent(new ControllerEvent(this,event.getNanos(),ControllerEvent.BUTTON,buttonIndex,
buttonState[buttonIndex],false,false,0,0));
}
// handle pov events
if (pov.contains(event.getComponent())) {
Component povComponent = event.getComponent();
int povIndex = pov.indexOf(povComponent);
float prevX = getPovX();
float prevY = getPovY();
povValues[povIndex] = event.getValue();
if (prevX != getPovX()) {
Controllers.addEvent(new ControllerEvent(this,event.getNanos(),ControllerEvent.POVX,0,false,false));
}
if (prevY != getPovY()) {
Controllers.addEvent(new ControllerEvent(this,event.getNanos(),ControllerEvent.POVY,0,false,false));
}
}
// handle axis updates
if (axes.contains(event.getComponent())) {
Component axis = event.getComponent();
int axisIndex = axes.indexOf(axis);
float value = axis.getPollData();
float xaxisValue = 0;
float yaxisValue = 0;
// fixed dead zone since most axis don't report it :(
if (Math.abs(value) < deadZones[axisIndex]) {
value = 0;
}
if (Math.abs(value) < axis.getDeadZone()) {
value = 0;
}
if (Math.abs(value) > axesMax[axisIndex]) {
axesMax[axisIndex] = Math.abs(value);
}
// normalize the value based on maximum value read in the past
value /= axesMax[axisIndex];
if (axisIndex == xaxis) {
xaxisValue = value;
}
if (axisIndex == yaxis) {
yaxisValue = value;
}
// fire event
Controllers.addEvent(new ControllerEvent(this,event.getNanos(),ControllerEvent.AXIS,axisIndex,false,
axisIndex == xaxis,axisIndex == yaxis,xaxisValue,yaxisValue));
axesValue[axisIndex] = value;
}
}
}
/*
* @see org.lwjgl.input.Controller#getAxisCount()
*/
public int getAxisCount() {
return axes.size();
}
/*
* @see org.lwjgl.input.Controller#getAxisName(int)
*/
public String getAxisName(int index) {
return axes.get(index).getName();
}
/*
* @see org.lwjgl.input.Controller#getAxisValue(int)
*/
public float getAxisValue(int index) {
return axesValue[index];
}
/*
* @see org.lwjgl.input.Controller#getXAxisValue()
*/
public float getXAxisValue() {
if (xaxis == -1) {
return 0;
}
return getAxisValue(xaxis);
}
/*
* @see org.lwjgl.input.Controller#getYAxisValue()
*/
public float getYAxisValue() {
if (yaxis == -1) {
return 0;
}
return getAxisValue(yaxis);
}
/*
* @see org.lwjgl.input.Controller#getXAxisDeadZone()
*/
public float getXAxisDeadZone() {
if (xaxis == -1) {
return 0;
}
return getDeadZone(xaxis);
}
/*
* @see org.lwjgl.input.Controller#getYAxisDeadZone()
*/
public float getYAxisDeadZone() {
if (yaxis == -1) {
return 0;
}
return getDeadZone(yaxis);
}
/*
* @see org.lwjgl.input.Controller#setXAxisDeadZone(float)
*/
public void setXAxisDeadZone(float zone) {
setDeadZone(xaxis,zone);
}
/*
* @see org.lwjgl.input.Controller#setYAxisDeadZone(float)
*/
public void setYAxisDeadZone(float zone) {
setDeadZone(yaxis,zone);
}
/*
* @see org.lwjgl.input.Controller#getDeadZone(int)
*/
public float getDeadZone(int index) {
return deadZones[index];
}
/*
* @see org.lwjgl.input.Controller#setDeadZone(int, float)
*/
public void setDeadZone(int index, float zone) {
deadZones[index] = zone;
}
/*
* @see org.lwjgl.input.Controller#getZAxisValue()
*/
public float getZAxisValue() {
if (zaxis == -1) {
return 0;
}
return getAxisValue(zaxis);
}
/*
* @see org.lwjgl.input.Controller#getZAxisDeadZone()
*/
public float getZAxisDeadZone() {
if (zaxis == -1) {
return 0;
}
return getDeadZone(zaxis);
}
/*
* @see org.lwjgl.input.Controller#setZAxisDeadZone(float)
*/
public void setZAxisDeadZone(float zone) {
setDeadZone(zaxis,zone);
}
/*
* @see org.lwjgl.input.Controller#getRXAxisValue()
*/
public float getRXAxisValue() {
if (rxaxis == -1) {
return 0;
}
return getAxisValue(rxaxis);
}
/*
* @see org.lwjgl.input.Controller#getRXAxisDeadZone()
*/
public float getRXAxisDeadZone() {
if (rxaxis == -1) {
return 0;
}
return getDeadZone(rxaxis);
}
/*
* @see org.lwjgl.input.Controller#setRXAxisDeadZone(float)
*/
public void setRXAxisDeadZone(float zone) {
setDeadZone(rxaxis,zone);
}
/*
* @see org.lwjgl.input.Controller#getRYAxisValue()
*/
public float getRYAxisValue() {
if (ryaxis == -1) {
return 0;
}
return getAxisValue(ryaxis);
}
/*
* @see org.lwjgl.input.Controller#getRYAxisDeadZone()
*/
public float getRYAxisDeadZone() {
if (ryaxis == -1) {
return 0;
}
return getDeadZone(ryaxis);
}
/*
* @see org.lwjgl.input.Controller#setRYAxisDeadZone(float)
*/
public void setRYAxisDeadZone(float zone) {
setDeadZone(ryaxis,zone);
}
/*
* @see org.lwjgl.input.Controller#getRZAxisValue()
*/
public float getRZAxisValue() {
if (rzaxis == -1) {
return 0;
}
return getAxisValue(rzaxis);
}
/*
* @see org.lwjgl.input.Controller#getRZAxisDeadZone()
*/
public float getRZAxisDeadZone() {
if (rzaxis == -1) {
return 0;
}
return getDeadZone(rzaxis);
}
/*
* @see org.lwjgl.input.Controller#setRZAxisDeadZone(float)
*/
public void setRZAxisDeadZone(float zone) {
setDeadZone(rzaxis,zone);
}
/*
* @see org.lwjgl.input.Controller#getPovX()
*/
public float getPovX() {
if (pov.size() == 0) {
return 0;
}
float value = povValues[0];
if ((value == Component.POV.DOWN_LEFT) ||
(value == Component.POV.UP_LEFT) ||
(value == Component.POV.LEFT)) {
return -1;
}
if ((value == Component.POV.DOWN_RIGHT) ||
(value == Component.POV.UP_RIGHT) ||
(value == Component.POV.RIGHT)) {
return 1;
}
return 0;
}
/*
* @see org.lwjgl.input.Controller#getPovY()
*/
public float getPovY() {
if (pov.size() == 0) {
return 0;
}
float value = povValues[0];
if ((value == Component.POV.DOWN_LEFT) ||
(value == Component.POV.DOWN_RIGHT) ||
(value == Component.POV.DOWN)) {
return 1;
}
if ((value == Component.POV.UP_LEFT) ||
(value == Component.POV.UP_RIGHT) ||
(value == Component.POV.UP)) {
return -1;
}
return 0;
}
public int getRumblerCount() {
return rumblers.length;
}
public String getRumblerName(int index) {
return rumblers[index].getAxisName();
}
public void setRumblerStrength(int index, float strength) {
rumblers[index].rumble(strength);
}
}

View File

@ -1,276 +0,0 @@
package org.lwjgl.input;
import org.lwjgl.glfw.GLFW;
public class KeyCodes {
public static int toLwjglKey(int glfwKeyCode) {
switch (glfwKeyCode) {
case GLFW.GLFW_KEY_ESCAPE : return Keyboard.KEY_ESCAPE;
case GLFW.GLFW_KEY_BACKSPACE : return Keyboard.KEY_BACK;
case GLFW.GLFW_KEY_TAB : return Keyboard.KEY_TAB;
case GLFW.GLFW_KEY_ENTER : return Keyboard.KEY_RETURN;
case GLFW.GLFW_KEY_SPACE : return Keyboard.KEY_SPACE;
case GLFW.GLFW_KEY_LEFT_CONTROL : return Keyboard.KEY_LCONTROL;
case GLFW.GLFW_KEY_LEFT_SHIFT : return Keyboard.KEY_LSHIFT;
case GLFW.GLFW_KEY_LEFT_ALT : return Keyboard.KEY_LMENU;
case GLFW.GLFW_KEY_LEFT_SUPER : return Keyboard.KEY_LMETA;
case GLFW.GLFW_KEY_RIGHT_CONTROL: return Keyboard.KEY_RCONTROL;
case GLFW.GLFW_KEY_RIGHT_SHIFT : return Keyboard.KEY_RSHIFT;
case GLFW.GLFW_KEY_RIGHT_ALT : return Keyboard.KEY_RMENU;
case GLFW.GLFW_KEY_RIGHT_SUPER : return Keyboard.KEY_RMETA;
case GLFW.GLFW_KEY_1 : return Keyboard.KEY_1;
case GLFW.GLFW_KEY_2 : return Keyboard.KEY_2;
case GLFW.GLFW_KEY_3 : return Keyboard.KEY_3;
case GLFW.GLFW_KEY_4 : return Keyboard.KEY_4;
case GLFW.GLFW_KEY_5 : return Keyboard.KEY_5;
case GLFW.GLFW_KEY_6 : return Keyboard.KEY_6;
case GLFW.GLFW_KEY_7 : return Keyboard.KEY_7;
case GLFW.GLFW_KEY_8 : return Keyboard.KEY_8;
case GLFW.GLFW_KEY_9 : return Keyboard.KEY_9;
case GLFW.GLFW_KEY_0 : return Keyboard.KEY_0;
case GLFW.GLFW_KEY_A : return Keyboard.KEY_A;
case GLFW.GLFW_KEY_B : return Keyboard.KEY_B;
case GLFW.GLFW_KEY_C : return Keyboard.KEY_C;
case GLFW.GLFW_KEY_D : return Keyboard.KEY_D;
case GLFW.GLFW_KEY_E : return Keyboard.KEY_E;
case GLFW.GLFW_KEY_F : return Keyboard.KEY_F;
case GLFW.GLFW_KEY_G : return Keyboard.KEY_G;
case GLFW.GLFW_KEY_H : return Keyboard.KEY_H;
case GLFW.GLFW_KEY_I : return Keyboard.KEY_I;
case GLFW.GLFW_KEY_J : return Keyboard.KEY_J;
case GLFW.GLFW_KEY_K : return Keyboard.KEY_K;
case GLFW.GLFW_KEY_L : return Keyboard.KEY_L;
case GLFW.GLFW_KEY_M : return Keyboard.KEY_M;
case GLFW.GLFW_KEY_N : return Keyboard.KEY_N;
case GLFW.GLFW_KEY_O : return Keyboard.KEY_O;
case GLFW.GLFW_KEY_P : return Keyboard.KEY_P;
case GLFW.GLFW_KEY_Q : return Keyboard.KEY_Q;
case GLFW.GLFW_KEY_R : return Keyboard.KEY_R;
case GLFW.GLFW_KEY_S : return Keyboard.KEY_S;
case GLFW.GLFW_KEY_T : return Keyboard.KEY_T;
case GLFW.GLFW_KEY_U : return Keyboard.KEY_U;
case GLFW.GLFW_KEY_V : return Keyboard.KEY_V;
case GLFW.GLFW_KEY_W : return Keyboard.KEY_W;
case GLFW.GLFW_KEY_X : return Keyboard.KEY_X;
case GLFW.GLFW_KEY_Y : return Keyboard.KEY_Y;
case GLFW.GLFW_KEY_Z : return Keyboard.KEY_Z;
case GLFW.GLFW_KEY_UP : return Keyboard.KEY_UP;
case GLFW.GLFW_KEY_DOWN : return Keyboard.KEY_DOWN;
case GLFW.GLFW_KEY_LEFT : return Keyboard.KEY_LEFT;
case GLFW.GLFW_KEY_RIGHT : return Keyboard.KEY_RIGHT;
case GLFW.GLFW_KEY_INSERT : return Keyboard.KEY_INSERT;
case GLFW.GLFW_KEY_DELETE : return Keyboard.KEY_DELETE;
case GLFW.GLFW_KEY_HOME : return Keyboard.KEY_HOME;
case GLFW.GLFW_KEY_END : return Keyboard.KEY_END;
case GLFW.GLFW_KEY_PAGE_UP : return Keyboard.KEY_PRIOR;
case GLFW.GLFW_KEY_PAGE_DOWN : return Keyboard.KEY_NEXT;
case GLFW.GLFW_KEY_F1 : return Keyboard.KEY_F1;
case GLFW.GLFW_KEY_F2 : return Keyboard.KEY_F2;
case GLFW.GLFW_KEY_F3 : return Keyboard.KEY_F3;
case GLFW.GLFW_KEY_F4 : return Keyboard.KEY_F4;
case GLFW.GLFW_KEY_F5 : return Keyboard.KEY_F5;
case GLFW.GLFW_KEY_F6 : return Keyboard.KEY_F6;
case GLFW.GLFW_KEY_F7 : return Keyboard.KEY_F7;
case GLFW.GLFW_KEY_F8 : return Keyboard.KEY_F8;
case GLFW.GLFW_KEY_F9 : return Keyboard.KEY_F9;
case GLFW.GLFW_KEY_F10 : return Keyboard.KEY_F10;
case GLFW.GLFW_KEY_F11 : return Keyboard.KEY_F11;
case GLFW.GLFW_KEY_F12 : return Keyboard.KEY_F12;
case GLFW.GLFW_KEY_F13 : return Keyboard.KEY_F13;
case GLFW.GLFW_KEY_F14 : return Keyboard.KEY_F14;
case GLFW.GLFW_KEY_F15 : return Keyboard.KEY_F15;
case GLFW.GLFW_KEY_F16 : return Keyboard.KEY_F16;
case GLFW.GLFW_KEY_F17 : return Keyboard.KEY_F17;
case GLFW.GLFW_KEY_F18 : return Keyboard.KEY_F18;
case GLFW.GLFW_KEY_F19 : return Keyboard.KEY_F19;
case GLFW.GLFW_KEY_KP_1 : return Keyboard.KEY_NUMPAD1;
case GLFW.GLFW_KEY_KP_2 : return Keyboard.KEY_NUMPAD2;
case GLFW.GLFW_KEY_KP_3 : return Keyboard.KEY_NUMPAD3;
case GLFW.GLFW_KEY_KP_4 : return Keyboard.KEY_NUMPAD4;
case GLFW.GLFW_KEY_KP_5 : return Keyboard.KEY_NUMPAD5;
case GLFW.GLFW_KEY_KP_6 : return Keyboard.KEY_NUMPAD6;
case GLFW.GLFW_KEY_KP_7 : return Keyboard.KEY_NUMPAD7;
case GLFW.GLFW_KEY_KP_8 : return Keyboard.KEY_NUMPAD8;
case GLFW.GLFW_KEY_KP_9 : return Keyboard.KEY_NUMPAD9;
case GLFW.GLFW_KEY_KP_0 : return Keyboard.KEY_NUMPAD0;
case GLFW.GLFW_KEY_KP_ADD : return Keyboard.KEY_ADD;
case GLFW.GLFW_KEY_KP_SUBTRACT : return Keyboard.KEY_SUBTRACT;
case GLFW.GLFW_KEY_KP_MULTIPLY : return Keyboard.KEY_MULTIPLY;
case GLFW.GLFW_KEY_KP_DIVIDE : return Keyboard.KEY_DIVIDE;
case GLFW.GLFW_KEY_KP_DECIMAL : return Keyboard.KEY_DECIMAL;
case GLFW.GLFW_KEY_KP_EQUAL : return Keyboard.KEY_NUMPADEQUALS;
case GLFW.GLFW_KEY_KP_ENTER : return Keyboard.KEY_NUMPADENTER;
case GLFW.GLFW_KEY_NUM_LOCK : return Keyboard.KEY_NUMLOCK;
case GLFW.GLFW_KEY_SEMICOLON : return Keyboard.KEY_SEMICOLON;
case GLFW.GLFW_KEY_BACKSLASH : return Keyboard.KEY_BACKSLASH;
case GLFW.GLFW_KEY_COMMA : return Keyboard.KEY_COMMA;
case GLFW.GLFW_KEY_PERIOD : return Keyboard.KEY_PERIOD;
case GLFW.GLFW_KEY_SLASH : return Keyboard.KEY_SLASH;
case GLFW.GLFW_KEY_GRAVE_ACCENT : return Keyboard.KEY_GRAVE;
case GLFW.GLFW_KEY_CAPS_LOCK : return Keyboard.KEY_CAPITAL;
case GLFW.GLFW_KEY_SCROLL_LOCK : return Keyboard.KEY_SCROLL;
case GLFW.GLFW_KEY_WORLD_1 : return Keyboard.KEY_CIRCUMFLEX; // TODO not sure if correct
case GLFW.GLFW_KEY_PAUSE : return Keyboard.KEY_PAUSE;
case GLFW.GLFW_KEY_MINUS : return Keyboard.KEY_MINUS;
case GLFW.GLFW_KEY_EQUAL : return Keyboard.KEY_EQUALS;
case GLFW.GLFW_KEY_LEFT_BRACKET : return Keyboard.KEY_LBRACKET;
case GLFW.GLFW_KEY_RIGHT_BRACKET: return Keyboard.KEY_RBRACKET;
case GLFW.GLFW_KEY_APOSTROPHE : return Keyboard.KEY_APOSTROPHE;
default:
if (glfwKeyCode != -1)
System.out.println("UNKNOWN GLFW KEY CODE: " + glfwKeyCode);
return Keyboard.KEY_NONE;
}
}
public static int toGlfwKey(int lwjglKeyCode) {
switch (lwjglKeyCode) {
case Keyboard.KEY_ESCAPE : return GLFW.GLFW_KEY_ESCAPE;
case Keyboard.KEY_BACK : return GLFW.GLFW_KEY_BACKSPACE;
case Keyboard.KEY_TAB : return GLFW.GLFW_KEY_TAB;
case Keyboard.KEY_RETURN : return GLFW.GLFW_KEY_ENTER;
case Keyboard.KEY_SPACE : return GLFW.GLFW_KEY_SPACE;
case Keyboard.KEY_LCONTROL : return GLFW.GLFW_KEY_LEFT_CONTROL;
case Keyboard.KEY_LSHIFT : return GLFW.GLFW_KEY_LEFT_SHIFT;
case Keyboard.KEY_LMENU : return GLFW.GLFW_KEY_LEFT_ALT;
case Keyboard.KEY_LMETA : return GLFW.GLFW_KEY_LEFT_SUPER;
case Keyboard.KEY_RCONTROL : return GLFW.GLFW_KEY_RIGHT_CONTROL;
case Keyboard.KEY_RSHIFT : return GLFW.GLFW_KEY_RIGHT_SHIFT;
case Keyboard.KEY_RMENU : return GLFW.GLFW_KEY_RIGHT_ALT;
case Keyboard.KEY_RMETA : return GLFW.GLFW_KEY_RIGHT_SUPER;
case Keyboard.KEY_1 : return GLFW.GLFW_KEY_1;
case Keyboard.KEY_2 : return GLFW.GLFW_KEY_2;
case Keyboard.KEY_3 : return GLFW.GLFW_KEY_3;
case Keyboard.KEY_4 : return GLFW.GLFW_KEY_4;
case Keyboard.KEY_5 : return GLFW.GLFW_KEY_5;
case Keyboard.KEY_6 : return GLFW.GLFW_KEY_6;
case Keyboard.KEY_7 : return GLFW.GLFW_KEY_7;
case Keyboard.KEY_8 : return GLFW.GLFW_KEY_8;
case Keyboard.KEY_9 : return GLFW.GLFW_KEY_9;
case Keyboard.KEY_0 : return GLFW.GLFW_KEY_0;
case Keyboard.KEY_A : return GLFW.GLFW_KEY_A;
case Keyboard.KEY_B : return GLFW.GLFW_KEY_B;
case Keyboard.KEY_C : return GLFW.GLFW_KEY_C;
case Keyboard.KEY_D : return GLFW.GLFW_KEY_D;
case Keyboard.KEY_E : return GLFW.GLFW_KEY_E;
case Keyboard.KEY_F : return GLFW.GLFW_KEY_F;
case Keyboard.KEY_G : return GLFW.GLFW_KEY_G;
case Keyboard.KEY_H : return GLFW.GLFW_KEY_H;
case Keyboard.KEY_I : return GLFW.GLFW_KEY_I;
case Keyboard.KEY_J : return GLFW.GLFW_KEY_J;
case Keyboard.KEY_K : return GLFW.GLFW_KEY_K;
case Keyboard.KEY_L : return GLFW.GLFW_KEY_L;
case Keyboard.KEY_M : return GLFW.GLFW_KEY_M;
case Keyboard.KEY_N : return GLFW.GLFW_KEY_N;
case Keyboard.KEY_O : return GLFW.GLFW_KEY_O;
case Keyboard.KEY_P : return GLFW.GLFW_KEY_P;
case Keyboard.KEY_Q : return GLFW.GLFW_KEY_Q;
case Keyboard.KEY_R : return GLFW.GLFW_KEY_R;
case Keyboard.KEY_S : return GLFW.GLFW_KEY_S;
case Keyboard.KEY_T : return GLFW.GLFW_KEY_T;
case Keyboard.KEY_U : return GLFW.GLFW_KEY_U;
case Keyboard.KEY_V : return GLFW.GLFW_KEY_V;
case Keyboard.KEY_W : return GLFW.GLFW_KEY_W;
case Keyboard.KEY_X : return GLFW.GLFW_KEY_X;
case Keyboard.KEY_Y : return GLFW.GLFW_KEY_Y;
case Keyboard.KEY_Z : return GLFW.GLFW_KEY_Z;
case Keyboard.KEY_UP : return GLFW.GLFW_KEY_UP;
case Keyboard.KEY_DOWN : return GLFW.GLFW_KEY_DOWN;
case Keyboard.KEY_LEFT : return GLFW.GLFW_KEY_LEFT;
case Keyboard.KEY_RIGHT : return GLFW.GLFW_KEY_RIGHT;
case Keyboard.KEY_INSERT : return GLFW.GLFW_KEY_INSERT;
case Keyboard.KEY_DELETE : return GLFW.GLFW_KEY_DELETE;
case Keyboard.KEY_HOME : return GLFW.GLFW_KEY_HOME;
case Keyboard.KEY_END : return GLFW.GLFW_KEY_END;
case Keyboard.KEY_PRIOR : return GLFW.GLFW_KEY_PAGE_UP;
case Keyboard.KEY_NEXT : return GLFW.GLFW_KEY_PAGE_DOWN;
case Keyboard.KEY_F1 : return GLFW.GLFW_KEY_F1;
case Keyboard.KEY_F2 : return GLFW.GLFW_KEY_F2;
case Keyboard.KEY_F3 : return GLFW.GLFW_KEY_F3;
case Keyboard.KEY_F4 : return GLFW.GLFW_KEY_F4;
case Keyboard.KEY_F5 : return GLFW.GLFW_KEY_F5;
case Keyboard.KEY_F6 : return GLFW.GLFW_KEY_F6;
case Keyboard.KEY_F7 : return GLFW.GLFW_KEY_F7;
case Keyboard.KEY_F8 : return GLFW.GLFW_KEY_F8;
case Keyboard.KEY_F9 : return GLFW.GLFW_KEY_F9;
case Keyboard.KEY_F10 : return GLFW.GLFW_KEY_F10;
case Keyboard.KEY_F11 : return GLFW.GLFW_KEY_F11;
case Keyboard.KEY_F12 : return GLFW.GLFW_KEY_F12;
case Keyboard.KEY_F13 : return GLFW.GLFW_KEY_F13;
case Keyboard.KEY_F14 : return GLFW.GLFW_KEY_F14;
case Keyboard.KEY_F15 : return GLFW.GLFW_KEY_F15;
case Keyboard.KEY_F16 : return GLFW.GLFW_KEY_F16;
case Keyboard.KEY_F17 : return GLFW.GLFW_KEY_F17;
case Keyboard.KEY_F18 : return GLFW.GLFW_KEY_F18;
case Keyboard.KEY_F19 : return GLFW.GLFW_KEY_F19;
case Keyboard.KEY_NUMPAD1 : return GLFW.GLFW_KEY_KP_1;
case Keyboard.KEY_NUMPAD2 : return GLFW.GLFW_KEY_KP_2;
case Keyboard.KEY_NUMPAD3 : return GLFW.GLFW_KEY_KP_3;
case Keyboard.KEY_NUMPAD4 : return GLFW.GLFW_KEY_KP_4;
case Keyboard.KEY_NUMPAD5 : return GLFW.GLFW_KEY_KP_5;
case Keyboard.KEY_NUMPAD6 : return GLFW.GLFW_KEY_KP_6;
case Keyboard.KEY_NUMPAD7 : return GLFW.GLFW_KEY_KP_7;
case Keyboard.KEY_NUMPAD8 : return GLFW.GLFW_KEY_KP_8;
case Keyboard.KEY_NUMPAD9 : return GLFW.GLFW_KEY_KP_9;
case Keyboard.KEY_NUMPAD0 : return GLFW.GLFW_KEY_KP_0;
case Keyboard.KEY_ADD : return GLFW.GLFW_KEY_KP_ADD;
case Keyboard.KEY_SUBTRACT : return GLFW.GLFW_KEY_KP_SUBTRACT;
case Keyboard.KEY_MULTIPLY : return GLFW.GLFW_KEY_KP_MULTIPLY;
case Keyboard.KEY_DIVIDE : return GLFW.GLFW_KEY_KP_DIVIDE;
case Keyboard.KEY_DECIMAL : return GLFW.GLFW_KEY_KP_DECIMAL;
case Keyboard.KEY_NUMPADEQUALS : return GLFW.GLFW_KEY_KP_EQUAL;
case Keyboard.KEY_NUMPADENTER : return GLFW.GLFW_KEY_KP_ENTER;
case Keyboard.KEY_NUMLOCK : return GLFW.GLFW_KEY_NUM_LOCK;
case Keyboard.KEY_SEMICOLON : return GLFW.GLFW_KEY_SEMICOLON;
case Keyboard.KEY_BACKSLASH : return GLFW.GLFW_KEY_BACKSLASH;
case Keyboard.KEY_COMMA : return GLFW.GLFW_KEY_COMMA;
case Keyboard.KEY_PERIOD : return GLFW.GLFW_KEY_PERIOD;
case Keyboard.KEY_SLASH : return GLFW.GLFW_KEY_SLASH;
case Keyboard.KEY_GRAVE : return GLFW.GLFW_KEY_GRAVE_ACCENT;
case Keyboard.KEY_CAPITAL : return GLFW.GLFW_KEY_CAPS_LOCK;
case Keyboard.KEY_SCROLL : return GLFW.GLFW_KEY_SCROLL_LOCK;
case Keyboard.KEY_PAUSE : return GLFW.GLFW_KEY_PAUSE;
case Keyboard.KEY_CIRCUMFLEX : return GLFW.GLFW_KEY_WORLD_1; // TODO not sure if correct
case Keyboard.KEY_MINUS : return GLFW.GLFW_KEY_MINUS;
case Keyboard.KEY_EQUALS : return GLFW.GLFW_KEY_EQUAL;
case Keyboard.KEY_LBRACKET : return GLFW.GLFW_KEY_LEFT_BRACKET;
case Keyboard.KEY_RBRACKET : return GLFW.GLFW_KEY_RIGHT_BRACKET;
case Keyboard.KEY_APOSTROPHE : return GLFW.GLFW_KEY_APOSTROPHE;
default:
if (lwjglKeyCode != -1)
System.out.println("UNKNOWN LWJGL KEY CODE: " + lwjglKeyCode);
return GLFW.GLFW_KEY_UNKNOWN;
}
}
}

View File

@ -1,582 +0,0 @@
/*
* Copyright (c) 2002-2008 LWJGL Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of 'LWJGL' nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.lwjgl.input;
import org.lwjgl.BufferUtils;
import org.lwjgl.LWJGLException;
import org.lwjgl.Sys;
import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.InputImplementation;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.nio.ByteBuffer;
import java.util.HashMap;
import java.util.Map;
/**
* <br>
* A raw Keyboard interface. This can be used to poll the current state of the
* keys, or read all the keyboard presses / releases since the last read.
*
* @author cix_foo <cix_foo@users.sourceforge.net>
* @author elias_naur <elias_naur@users.sourceforge.net>
* @author Brian Matzon <brian@matzon.dk>
* @version $Revision$
* $Id$
*/
public class Keyboard {
/** Internal use - event size in bytes */
public static final int EVENT_SIZE = 4 + 1 + 4 + 8 + 1;
/**
* The special character meaning that no
* character was translated for the event.
*/
public static final int CHAR_NONE = '\0';
/**
* The special keycode meaning that only the
* translated character is valid.
*/
public static final int KEY_NONE = 0x00;
public static final int KEY_ESCAPE = 0x01;
public static final int KEY_1 = 0x02;
public static final int KEY_2 = 0x03;
public static final int KEY_3 = 0x04;
public static final int KEY_4 = 0x05;
public static final int KEY_5 = 0x06;
public static final int KEY_6 = 0x07;
public static final int KEY_7 = 0x08;
public static final int KEY_8 = 0x09;
public static final int KEY_9 = 0x0A;
public static final int KEY_0 = 0x0B;
public static final int KEY_MINUS = 0x0C; /* - on main keyboard */
public static final int KEY_EQUALS = 0x0D;
public static final int KEY_BACK = 0x0E; /* backspace */
public static final int KEY_TAB = 0x0F;
public static final int KEY_Q = 0x10;
public static final int KEY_W = 0x11;
public static final int KEY_E = 0x12;
public static final int KEY_R = 0x13;
public static final int KEY_T = 0x14;
public static final int KEY_Y = 0x15;
public static final int KEY_U = 0x16;
public static final int KEY_I = 0x17;
public static final int KEY_O = 0x18;
public static final int KEY_P = 0x19;
public static final int KEY_LBRACKET = 0x1A;
public static final int KEY_RBRACKET = 0x1B;
public static final int KEY_RETURN = 0x1C; /* Enter on main keyboard */
public static final int KEY_LCONTROL = 0x1D;
public static final int KEY_A = 0x1E;
public static final int KEY_S = 0x1F;
public static final int KEY_D = 0x20;
public static final int KEY_F = 0x21;
public static final int KEY_G = 0x22;
public static final int KEY_H = 0x23;
public static final int KEY_J = 0x24;
public static final int KEY_K = 0x25;
public static final int KEY_L = 0x26;
public static final int KEY_SEMICOLON = 0x27;
public static final int KEY_APOSTROPHE = 0x28;
public static final int KEY_GRAVE = 0x29; /* accent grave */
public static final int KEY_LSHIFT = 0x2A;
public static final int KEY_BACKSLASH = 0x2B;
public static final int KEY_Z = 0x2C;
public static final int KEY_X = 0x2D;
public static final int KEY_C = 0x2E;
public static final int KEY_V = 0x2F;
public static final int KEY_B = 0x30;
public static final int KEY_N = 0x31;
public static final int KEY_M = 0x32;
public static final int KEY_COMMA = 0x33;
public static final int KEY_PERIOD = 0x34; /* . on main keyboard */
public static final int KEY_SLASH = 0x35; /* / on main keyboard */
public static final int KEY_RSHIFT = 0x36;
public static final int KEY_MULTIPLY = 0x37; /* * on numeric keypad */
public static final int KEY_LMENU = 0x38; /* left Alt */
public static final int KEY_SPACE = 0x39;
public static final int KEY_CAPITAL = 0x3A;
public static final int KEY_F1 = 0x3B;
public static final int KEY_F2 = 0x3C;
public static final int KEY_F3 = 0x3D;
public static final int KEY_F4 = 0x3E;
public static final int KEY_F5 = 0x3F;
public static final int KEY_F6 = 0x40;
public static final int KEY_F7 = 0x41;
public static final int KEY_F8 = 0x42;
public static final int KEY_F9 = 0x43;
public static final int KEY_F10 = 0x44;
public static final int KEY_NUMLOCK = 0x45;
public static final int KEY_SCROLL = 0x46; /* Scroll Lock */
public static final int KEY_NUMPAD7 = 0x47;
public static final int KEY_NUMPAD8 = 0x48;
public static final int KEY_NUMPAD9 = 0x49;
public static final int KEY_SUBTRACT = 0x4A; /* - on numeric keypad */
public static final int KEY_NUMPAD4 = 0x4B;
public static final int KEY_NUMPAD5 = 0x4C;
public static final int KEY_NUMPAD6 = 0x4D;
public static final int KEY_ADD = 0x4E; /* + on numeric keypad */
public static final int KEY_NUMPAD1 = 0x4F;
public static final int KEY_NUMPAD2 = 0x50;
public static final int KEY_NUMPAD3 = 0x51;
public static final int KEY_NUMPAD0 = 0x52;
public static final int KEY_DECIMAL = 0x53; /* . on numeric keypad */
public static final int KEY_F11 = 0x57;
public static final int KEY_F12 = 0x58;
public static final int KEY_F13 = 0x64; /* (NEC PC98) */
public static final int KEY_F14 = 0x65; /* (NEC PC98) */
public static final int KEY_F15 = 0x66; /* (NEC PC98) */
public static final int KEY_F16 = 0x67; /* Extended Function keys - (Mac) */
public static final int KEY_F17 = 0x68;
public static final int KEY_F18 = 0x69;
public static final int KEY_KANA = 0x70; /* (Japanese keyboard) */
public static final int KEY_F19 = 0x71; /* Extended Function keys - (Mac) */
public static final int KEY_CONVERT = 0x79; /* (Japanese keyboard) */
public static final int KEY_NOCONVERT = 0x7B; /* (Japanese keyboard) */
public static final int KEY_YEN = 0x7D; /* (Japanese keyboard) */
public static final int KEY_NUMPADEQUALS = 0x8D; /* = on numeric keypad (NEC PC98) */
public static final int KEY_CIRCUMFLEX = 0x90; /* (Japanese keyboard) */
public static final int KEY_AT = 0x91; /* (NEC PC98) */
public static final int KEY_COLON = 0x92; /* (NEC PC98) */
public static final int KEY_UNDERLINE = 0x93; /* (NEC PC98) */
public static final int KEY_KANJI = 0x94; /* (Japanese keyboard) */
public static final int KEY_STOP = 0x95; /* (NEC PC98) */
public static final int KEY_AX = 0x96; /* (Japan AX) */
public static final int KEY_UNLABELED = 0x97; /* (J3100) */
public static final int KEY_NUMPADENTER = 0x9C; /* Enter on numeric keypad */
public static final int KEY_RCONTROL = 0x9D;
public static final int KEY_SECTION = 0xA7; /* Section symbol (Mac) */
public static final int KEY_NUMPADCOMMA = 0xB3; /* , on numeric keypad (NEC PC98) */
public static final int KEY_DIVIDE = 0xB5; /* / on numeric keypad */
public static final int KEY_SYSRQ = 0xB7;
public static final int KEY_RMENU = 0xB8; /* right Alt */
public static final int KEY_FUNCTION = 0xC4; /* Function (Mac) */
public static final int KEY_PAUSE = 0xC5; /* Pause */
public static final int KEY_HOME = 0xC7; /* Home on arrow keypad */
public static final int KEY_UP = 0xC8; /* UpArrow on arrow keypad */
public static final int KEY_PRIOR = 0xC9; /* PgUp on arrow keypad */
public static final int KEY_LEFT = 0xCB; /* LeftArrow on arrow keypad */
public static final int KEY_RIGHT = 0xCD; /* RightArrow on arrow keypad */
public static final int KEY_END = 0xCF; /* End on arrow keypad */
public static final int KEY_DOWN = 0xD0; /* DownArrow on arrow keypad */
public static final int KEY_NEXT = 0xD1; /* PgDn on arrow keypad */
public static final int KEY_INSERT = 0xD2; /* Insert on arrow keypad */
public static final int KEY_DELETE = 0xD3; /* Delete on arrow keypad */
public static final int KEY_CLEAR = 0xDA; /* Clear key (Mac) */
public static final int KEY_LMETA = 0xDB; /* Left Windows/Option key */
/**
* The left windows key, mapped to KEY_LMETA
*
* @deprecated Use KEY_LMETA instead
*/
public static final int KEY_LWIN = KEY_LMETA; /* Left Windows key */
public static final int KEY_RMETA = 0xDC; /* Right Windows/Option key */
/**
* The right windows key, mapped to KEY_RMETA
*
* @deprecated Use KEY_RMETA instead
*/
public static final int KEY_RWIN = KEY_RMETA; /* Right Windows key */
public static final int KEY_APPS = 0xDD; /* AppMenu key */
public static final int KEY_POWER = 0xDE;
public static final int KEY_SLEEP = 0xDF;
/* public static final int STATE_ON = 0;
public static final int STATE_OFF = 1;
public static final int STATE_UNKNOWN = 2;
*/
public static final int KEYBOARD_SIZE = 256;
/** Buffer size in events */
private static final int BUFFER_SIZE = 50;
/** Key names */
private static final String[] keyName = new String[KEYBOARD_SIZE];
private static final Map<String, Integer> keyMap = new HashMap<String, Integer>(253);
private static int counter;
static {
// Use reflection to find out key names
Field[] fields = Keyboard.class.getFields();
try {
for ( Field field : fields ) {
if ( Modifier.isStatic(field.getModifiers())
&& Modifier.isPublic(field.getModifiers())
&& Modifier.isFinal(field.getModifiers())
&& field.getType().equals(int.class)
&& field.getName().startsWith("KEY_")
&& !field.getName().endsWith("WIN") ) { /* Don't use deprecated names */
int key = field.getInt(null);
String name = field.getName().substring(4);
keyName[key] = name;
keyMap.put(name, key);
counter++;
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
/** The number of keys supported */
private static final int keyCount = counter;
/** Has the keyboard been created? */
private static boolean created;
/** Are repeat events enabled? */
private static boolean repeat_enabled;
/** The keys status from the last poll */
private static final ByteBuffer keyDownBuffer = BufferUtils.createByteBuffer(KEYBOARD_SIZE);
/**
* The key events from the last read: a sequence of pairs of key number,
* followed by state. The state is followed by
* a 4 byte code point representing the translated character.
*/
private static ByteBuffer readBuffer;
/** current event */
private static KeyEvent current_event = new KeyEvent();
/** scratch event */
private static KeyEvent tmp_event = new KeyEvent();
/** One time initialization */
private static boolean initialized;
private static InputImplementation implementation;
/**
* Keyboard cannot be constructed.
*/
private Keyboard() {
}
/**
* Static initialization
*/
private static void initialize() {
if (initialized)
return;
Sys.initialize();
initialized = true;
}
/**
* "Create" the keyboard with the given implementation. This is used
* reflectively from AWTInputAdapter.
*
* @throws LWJGLException if the keyboard could not be created for any reason
*/
private static void create(InputImplementation impl) throws LWJGLException {
if (created)
return;
if (!initialized)
initialize();
implementation = impl;
implementation.createKeyboard();
created = true;
readBuffer = ByteBuffer.allocate(EVENT_SIZE*BUFFER_SIZE);
reset();
}
/**
* "Create" the keyboard. The display must first have been created. The
* reason for this is so the keyboard has a window to "focus" in.
*
* @throws LWJGLException if the keyboard could not be created for any reason
*/
public static void create() throws LWJGLException {
if (!Display.isCreated()) throw new IllegalStateException("Display must be created.");
create((InputImplementation) GLFWInputImplementation.singleton);
}
private static void reset() {
readBuffer.limit(0);
for (int i = 0; i < keyDownBuffer.remaining(); i++)
keyDownBuffer.put(i, (byte)0);
current_event.reset();
}
/**
* @return true if the keyboard has been created
*/
public static boolean isCreated() {
return created;
}
/**
* "Destroy" the keyboard
*/
public static void destroy() {
if (!created)
return;
created = false;
implementation.destroyKeyboard();
reset();
}
/**
* Polls the keyboard for its current state. Access the polled values using the
* <code>isKeyDown</code> method.
* By using this method, it is possible to "miss" keyboard keys if you don't
* poll fast enough.
*
* To use buffered values, you have to call <code>next</code> for each event you
* want to read. You can query which key caused the event by using
* <code>getEventKey</code>. To get the state of that key, for that event, use
* <code>getEventKeyState</code> - finally use <code>getEventCharacter</code> to get the
* character for that event.
*
* NOTE: This method does not query the operating system for new events. To do that,
* Display.processMessages() (or Display.update()) must be called first.
*
* @see Keyboard#isKeyDown(int key)
* @see Keyboard#next()
* @see Keyboard#getEventKey()
* @see Keyboard#getEventKeyState()
* @see Keyboard#getEventCharacter()
*/
public static void poll() {
if (!created)
throw new IllegalStateException("Keyboard must be created before you can poll the device");
implementation.pollKeyboard(keyDownBuffer);
read();
}
private static void read() {
readBuffer.compact();
implementation.readKeyboard(readBuffer);
readBuffer.flip();
}
/**
* Checks to see if a key is down.
* @param key Keycode to check
* @return true if the key is down according to the last poll()
*/
public static boolean isKeyDown(int key) {
if (!created)
throw new IllegalStateException("Keyboard must be created before you can query key state");
if(key >= KEYBOARD_SIZE) return false;
return keyDownBuffer.get(key) != 0;
}
/**
* Checks whether one of the state keys are "active"
*
* @param key State key to test (KEY_CAPITAL | KEY_NUMLOCK | KEY_SYSRQ)
* @return STATE_ON if on, STATE_OFF if off and STATE_UNKNOWN if the state is unknown
*/
/* public static int isStateKeySet(int key) {
if (!created)
throw new IllegalStateException("Keyboard must be created before you can query key state");
return implementation.isStateKeySet(key);
}
*/
/**
* Gets a key's name
* @param key The key
* @return a String with the key's human readable name in it or null if the key is unnamed
*/
public static synchronized String getKeyName(int key) {
return keyName[key];
}
/**
* Get's a key's index. If the key is unrecognised then KEY_NONE is returned.
* @param keyName The key name
*/
public static synchronized int getKeyIndex(String keyName) {
Integer ret = keyMap.get(keyName);
if (ret == null)
return KEY_NONE;
else
return ret;
}
/**
* Gets the number of keyboard events waiting after doing a buffer enabled poll().
* @return the number of keyboard events
*/
public static int getNumKeyboardEvents() {
if (!created)
throw new IllegalStateException("Keyboard must be created before you can read events");
int old_position = readBuffer.position();
int num_events = 0;
while (readNext(tmp_event) && (!tmp_event.repeat || repeat_enabled))
num_events++;
readBuffer.position(old_position);
return num_events;
}
/**
* Gets the next keyboard event. You can query which key caused the event by using
* <code>getEventKey</code>. To get the state of that key, for that event, use
* <code>getEventKeyState</code> - finally use <code>getEventCharacter</code> to get the
* character for that event.
*
* @see Keyboard#getEventKey()
* @see Keyboard#getEventKeyState()
* @see Keyboard#getEventCharacter()
* @return true if a keyboard event was read, false otherwise
*/
public static boolean next() {
if (!created)
throw new IllegalStateException("Keyboard must be created before you can read events");
boolean result;
while ((result = readNext(current_event)) && current_event.repeat && !repeat_enabled)
;
return result;
}
/**
* Controls whether repeat events are reported or not. If repeat events
* are enabled, key down events are reported when a key is pressed and held for
* a OS dependent amount of time. To distinguish a repeat event from a normal event,
* use isRepeatEvent().
*
* @see Keyboard#getEventKey()
*/
public static void enableRepeatEvents(boolean enable) {
repeat_enabled = enable;
}
/**
* Check whether repeat events are currently reported or not.
*
* @return true is repeat events are reported, false if not.
* @see Keyboard#getEventKey()
*/
public static boolean areRepeatEventsEnabled() {
return repeat_enabled;
}
private static boolean readNext(KeyEvent event) {
if (readBuffer.hasRemaining()) {
event.key = readBuffer.getInt() & 0xFF;
event.state = readBuffer.get() != 0;
event.character = readBuffer.getInt();
event.nanos = readBuffer.getLong();
event.repeat = readBuffer.get() == 1;
return true;
} else
return false;
}
/**
* @return Number of keys on this keyboard
*/
public static int getKeyCount() {
return keyCount;
}
/**
* @return The character from the current event
*/
public static char getEventCharacter() {
return (char)current_event.character;
}
/**
* Please note that the key code returned is NOT valid against the
* current keyboard layout. To get the actual character pressed call
* getEventCharacter
*
* @return The key from the current event
*/
public static int getEventKey() {
return current_event.key;
}
/**
* Gets the state of the key that generated the
* current event
*
* @return True if key was down, or false if released
*/
public static boolean getEventKeyState() {
return current_event.state;
}
/**
* Gets the time in nanoseconds of the current event.
* Only useful for relative comparisons with other
* Keyboard events, as the absolute time has no defined
* origin.
* @return The time in nanoseconds of the current event
*/
public static long getEventNanoseconds() {
return current_event.nanos;
}
/**
* @see Keyboard#enableRepeatEvents(boolean)
* @return true if the current event is a repeat event, false if
* the current event is not a repeat even or if repeat events are disabled.
*/
public static boolean isRepeatEvent() {
return current_event.repeat;
}
private static final class KeyEvent {
/** The current keyboard character being examined */
private int character;
/** The current keyboard event key being examined */
private int key;
/** The current state of the key being examined in the event queue */
private boolean state;
/** The current event time */
private long nanos;
/** Is the current event a repeated event? */
private boolean repeat;
private void reset() {
character = 0;
key = 0;
state = false;
repeat = false;
}
}
}

View File

@ -1,659 +0,0 @@
/*
* Copyright (c) 2002-2008 LWJGL Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of 'LWJGL' nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.lwjgl.input;
import org.lwjgl.BufferUtils;
import org.lwjgl.LWJGLException;
import org.lwjgl.LWJGLUtil;
import org.lwjgl.Sys;
import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.InputImplementation;
import java.lang.reflect.Constructor;
import java.nio.ByteBuffer;
import java.nio.IntBuffer;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.HashMap;
import java.util.Map;
/**
* <br>
* A raw Mouse interface. This can be used to poll the current state of the
* mouse buttons, and determine the mouse movement delta since the last poll.
*
* n buttons supported, n being a native limit. A scrolly wheel is also
* supported, if one such is available. Movement is reported as delta from
* last position or as an absolute position. If the window has been created
* the absolute position will be clamped to 0 - width | height.
*
* @author cix_foo <cix_foo@users.sourceforge.net>
* @author elias_naur <elias_naur@users.sourceforge.net>
* @author Brian Matzon <brian@matzon.dk>
* @version $Revision$
* $Id$
*/
public class Mouse {
/** Internal use - event size in bytes */
public static final int EVENT_SIZE = 1 + 1 + 4 + 4 + 4 + 8;
/** Has the mouse been created? */
private static boolean created;
/** The mouse buttons status from the last poll */
private static ByteBuffer buttons;
/** Mouse absolute X position in pixels */
private static int x;
/** Mouse absolute Y position in pixels */
private static int y;
/** Mouse absolute X position in pixels without any clipping */
private static int absolute_x;
/** Mouse absolute Y position in pixels without any clipping */
private static int absolute_y;
/** Buffer to hold the deltas dx, dy and dwheel */
private static IntBuffer coord_buffer;
/** Delta X */
private static int dx;
/** Delta Y */
private static int dy;
/** Delta Z */
private static int dwheel;
/** Number of buttons supported by the mouse */
private static int buttonCount = -1;
/** Does this mouse support a scroll wheel */
private static boolean hasWheel;
/** The current native cursor, if any */
private static Cursor currentCursor;
/** Button names. These are set upon create(), to names like BUTTON0, BUTTON1, etc. */
private static String[] buttonName;
/** hashmap of button names, for fast lookup */
private static final Map<String, Integer> buttonMap = new HashMap<String, Integer>(16);
/** Lazy initialization */
private static boolean initialized;
/** The mouse button events from the last read */
private static ByteBuffer readBuffer;
/** The current mouse event button being examined */
private static int eventButton;
/** The current state of the button being examined in the event queue */
private static boolean eventState;
/** The current delta of the mouse in the event queue */
private static int event_dx;
private static int event_dy;
private static int event_dwheel;
/** The current absolute position of the mouse in the event queue */
private static int event_x;
private static int event_y;
private static long event_nanos;
/** The position of the mouse it was grabbed at */
private static int grab_x;
private static int grab_y;
/** The last absolute mouse event position (before clipping) for delta computation */
private static int last_event_raw_x;
private static int last_event_raw_y;
/** Buffer size in events */
private static final int BUFFER_SIZE = 50;
private static boolean isGrabbed;
private static InputImplementation implementation;
private static EmptyCursorGrabListener grabListener = null;
private static boolean clipMouseCoordinatesToWindow = !getPrivilegedBoolean("org.lwjgl.input.Mouse.allowNegativeMouseCoords");
static {
try {
Class infdevMouse = Class.forName("org.lwjgl.input.InfdevMouse");
Constructor constructor = infdevMouse.getConstructor();
grabListener = (EmptyCursorGrabListener) constructor.newInstance();
} catch (Throwable e) {
e.printStackTrace();
}
}
/**
* Mouse cannot be constructed.
*/
private Mouse() {
}
/**
* Gets the currently bound native cursor, if any.
*
* @return the currently bound native cursor, if any.
*/
public static Cursor getNativeCursor() {
return currentCursor;
}
/**
* Binds a native cursor. If the cursor argument is null, any
* currently bound native cursor is disabled, and the cursor reverts
* to the default operating system supplied cursor.
*
* NOTE: The native cursor is not constrained to the window, but
* relative events will not be generated if the cursor is outside.
*
* @param cursor the native cursor object to bind. May be null.
* @return The previous Cursor object set, or null.
* @throws LWJGLException if the cursor could not be set for any reason
*/
public static Cursor setNativeCursor(Cursor cursor) throws LWJGLException {
//dummy
if (cursor == null && currentCursor.isEmpty()) {
Mouse.setGrabbed(false);
if (grabListener != null) grabListener.onGrab(false);
}
if (cursor != null && cursor.isEmpty()) {
Mouse.setGrabbed(true);
if (grabListener != null) grabListener.onGrab(true);
}
currentCursor = cursor;
return currentCursor;
}
public static boolean isClipMouseCoordinatesToWindow() {
return clipMouseCoordinatesToWindow;
}
public static void setClipMouseCoordinatesToWindow(boolean clip) {
clipMouseCoordinatesToWindow = clip;
}
/**
* Set the position of the cursor. If the cursor is not grabbed,
* the native cursor is moved to the new position.
*
* @param new_x The x coordinate of the new cursor position in OpenGL coordinates relative
* to the window origin.
* @param new_y The y coordinate of the new cursor position in OpenGL coordinates relative
* to the window origin.
*/
public static void setCursorPosition(int new_x, int new_y) {
//dummy
LWJGLUtil.log("setCursorPosition");
}
/**
* Static initialization
*/
private static void initialize() {
Sys.initialize();
// Assign names to all the buttons
buttonName = new String[16];
for (int i = 0; i < 16; i++) {
buttonName[i] = "BUTTON" + i;
buttonMap.put(buttonName[i], i);
}
initialized = true;
}
private static void resetMouse() {
dx = dy = dwheel = 0;
readBuffer.position(readBuffer.limit());
}
static InputImplementation getImplementation() {
return implementation;
}
/**
* "Create" the mouse with the given custom implementation. This is used
* reflectively by AWTInputAdapter.
*
* @throws LWJGLException if the mouse could not be created for any reason
*/
private static void create(InputImplementation impl) throws LWJGLException {
if (created)
return;
if (!initialized)
initialize();
implementation = impl;
implementation.createMouse();
hasWheel = implementation.hasWheel();
created = true;
// set mouse buttons
buttonCount = implementation.getButtonCount();
buttons = BufferUtils.createByteBuffer(buttonCount);
coord_buffer = BufferUtils.createIntBuffer(3);
if (currentCursor != null && implementation.getNativeCursorCapabilities() != 0)
setNativeCursor(currentCursor);
readBuffer = ByteBuffer.allocate(EVENT_SIZE * BUFFER_SIZE);
readBuffer.limit(0);
setGrabbed(isGrabbed);
}
/**
* "Create" the mouse. The display must first have been created.
* Initially, the mouse is not grabbed and the delta values are reported
* with respect to the center of the display.
*
* @throws LWJGLException if the mouse could not be created for any reason
*/
public static void create() throws LWJGLException {
if (!Display.isCreated()) throw new IllegalStateException("Display must be created.");
create((InputImplementation) GLFWInputImplementation.singleton);
}
/**
* @return true if the mouse has been created
*/
public static boolean isCreated() {
return created;
}
/**
* "Destroy" the mouse.
*/
public static void destroy() {
if (!created) return;
created = false;
buttons = null;
coord_buffer = null;
implementation.destroyMouse();
}
/**
* Polls the mouse for its current state. Access the polled values using the
* get<value> methods.
* By using this method, it is possible to "miss" mouse click events if you don't
* poll fast enough.
*
* To use buffered values, you have to call <code>next</code> for each event you
* want to read. You can query which button caused the event by using
* <code>getEventButton</code>. To get the state of that button, for that event, use
* <code>getEventButtonState</code>.
*
* NOTE: This method does not query the operating system for new events. To do that,
* Display.processMessages() (or Display.update()) must be called first.
*
* @see Mouse#next()
* @see Mouse#getEventButton()
* @see Mouse#getEventButtonState()
* @see Mouse#isButtonDown(int button)
* @see Mouse#getX()
* @see Mouse#getY()
* @see Mouse#getDX()
* @see Mouse#getDY()
* @see Mouse#getDWheel()
*/
public static void poll() {
if (!created) throw new IllegalStateException("Mouse must be created before you can poll it");
implementation.pollMouse(coord_buffer, buttons);
/* If we're grabbed, poll returns mouse deltas, if not it returns absolute coordinates */
int poll_coord1 = coord_buffer.get(0);
int poll_coord2 = coord_buffer.get(1);
/* The wheel is always relative */
int poll_dwheel = coord_buffer.get(2);
if (isGrabbed()) {
dx += poll_coord1;
dy += poll_coord2;
x += poll_coord1;
y += poll_coord2;
absolute_x += poll_coord1;
absolute_y += poll_coord2;
} else {
dx = poll_coord1 - absolute_x;
dy = poll_coord2 - absolute_y;
absolute_x = x = poll_coord1;
absolute_y = y = poll_coord2;
}
if (clipMouseCoordinatesToWindow) {
x = Math.min(Display.getWidth() - 1, Math.max(0, x));
y = Math.min(Display.getHeight() - 1, Math.max(0, y));
}
dwheel += poll_dwheel;
read();
}
private static void read() {
readBuffer.compact();
implementation.readMouse(readBuffer);
readBuffer.flip();
}
/**
* See if a particular mouse button is down.
*
* @param button The index of the button you wish to test (0..getButtonCount-1)
* @return true if the specified button is down
*/
public static boolean isButtonDown(int button) {
if (!created) throw new IllegalStateException("Mouse must be created before you can poll the button state");
if (button >= buttonCount || button < 0)
return false;
else
return buttons.get(button) == 1;
}
/**
* Gets a button's name
* @param button The button
* @return a String with the button's human readable name in it or null if the button is unnamed
*/
public static String getButtonName(int button) {
if (button >= buttonName.length || button < 0)
return null;
else
return buttonName[button];
}
/**
* Get's a button's index. If the button is unrecognised then -1 is returned.
* @param buttonName The button name
*/
public static int getButtonIndex(String buttonName) {
Integer ret = buttonMap.get(buttonName);
if (ret == null)
return -1;
else
return ret;
}
/**
* Gets the next mouse event. You can query which button caused the event by using
* <code>getEventButton()</code> (if any). To get the state of that key, for that event, use
* <code>getEventButtonState</code>. To get the current mouse delta values use <code>getEventDX()</code>
* and <code>getEventDY()</code>.
* @see Mouse#getEventButton()
* @see Mouse#getEventButtonState()
* @return true if a mouse event was read, false otherwise
*/
public static boolean next() {
if (!created) throw new IllegalStateException("Mouse must be created before you can read events");
if (readBuffer.hasRemaining()) {
eventButton = readBuffer.get();
eventState = readBuffer.get() != 0;
if (isGrabbed()) {
event_dx = readBuffer.getInt();
event_dy = readBuffer.getInt();
event_x += event_dx;
event_y += event_dy;
last_event_raw_x = event_x;
last_event_raw_y = event_y;
} else {
int new_event_x = readBuffer.getInt();
int new_event_y = readBuffer.getInt();
event_dx = new_event_x - last_event_raw_x;
event_dy = new_event_y - last_event_raw_y;
event_x = new_event_x;
event_y = new_event_y;
last_event_raw_x = new_event_x;
last_event_raw_y = new_event_y;
}
if(clipMouseCoordinatesToWindow) {
event_x = Math.min(Display.getWidth() - 1, Math.max(0, event_x));
event_y = Math.min(Display.getHeight() - 1, Math.max(0, event_y));
}
event_dwheel = readBuffer.getInt();
event_nanos = readBuffer.getLong();
return true;
} else
return false;
}
/**
* @return Current events button. Returns -1 if no button state was changed
*/
public static int getEventButton() {
return eventButton;
}
/**
* Get the current events button state.
* @return Current events button state.
*/
public static boolean getEventButtonState() {
return eventState;
}
/**
* @return Current events delta x.
*/
public static int getEventDX() {
return event_dx;
}
/**
* @return Current events delta y.
*/
public static int getEventDY() {
return event_dy;
}
/**
* @return Current events absolute x.
*/
public static int getEventX() {
return event_x;
}
/**
* @return Current events absolute y.
*/
public static int getEventY() {
return event_y;
}
/**
* @return Current events delta z
*/
public static int getEventDWheel() {
return event_dwheel;
}
/**
* Gets the time in nanoseconds of the current event.
* Only useful for relative comparisons with other
* Mouse events, as the absolute time has no defined
* origin.
*
* @return The time in nanoseconds of the current event
*/
public static long getEventNanoseconds() {
return event_nanos;
}
/**
* Retrieves the absolute position. It will be clamped to
* 0...width-1.
*
* @return Absolute x axis position of mouse
*/
public static int getX() {
return x;
}
/**
* Retrieves the absolute position. It will be clamped to
* 0...height-1.
*
* @return Absolute y axis position of mouse
*/
public static int getY() {
return y;
}
/**
* @return Movement on the x axis since last time getDX() was called.
*/
public static int getDX() {
int result = dx;
dx = 0;
return result;
}
/**
* @return Movement on the y axis since last time getDY() was called.
*/
public static int getDY() {
int result = dy;
dy = 0;
return result;
}
/**
* @return Movement of the wheel since last time getDWheel() was called
*/
public static int getDWheel() {
int result = dwheel;
dwheel = 0;
return result;
}
/**
* @return Number of buttons on this mouse
*/
public static int getButtonCount() {
return buttonCount;
}
/**
* @return Whether or not this mouse has wheel support
*/
public static boolean hasWheel() {
return hasWheel;
}
/**
* @return whether or not the mouse has grabbed the cursor
*/
public static boolean isGrabbed() {
return isGrabbed;
}
/**
* Sets whether or not the mouse has grabbed the cursor
* (and thus hidden). If grab is false, the getX() and getY()
* will return delta movement in pixels clamped to the display
* dimensions, from the center of the display.
*
* @param grab whether the mouse should be grabbed
*/
public static void setGrabbed(boolean grab) {
boolean grabbed = isGrabbed;
isGrabbed = grab;
if (isCreated()) {
if (grab && !grabbed) {
// store location mouse was grabbed
grab_x = x;
grab_y = y;
}
else if (!grab && grabbed) {
// move mouse back to location it was grabbed before ungrabbing
if ((Cursor.getCapabilities() & Cursor.CURSOR_ONE_BIT_TRANSPARENCY) != 0)
implementation.setCursorPosition(grab_x, grab_y);
}
implementation.grabMouse(grab);
// Get latest values from native side
poll();
event_x = x;
event_y = y;
last_event_raw_x = x;
last_event_raw_y = y;
resetMouse();
}
}
/**
* Updates the cursor, so that animation can be changed if needed.
* This method is called automatically by the window on its update, and
* shouldn't be called otherwise
*/
public static void updateCursor() {
//dummy
}
/** Gets a boolean property as a privileged action. */
static boolean getPrivilegedBoolean(final String property_name) {
Boolean value = AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
public Boolean run() {
return Boolean.getBoolean(property_name);
}
});
return value;
}
/**
* Retrieves whether or not the mouse cursor is within the bounds of the window.
* If the mouse cursor was moved outside the display during a drag, then the result of calling
* this method will be true until the button is released.
* @return true if mouse is inside display, false otherwise.
*/
public static boolean isInsideWindow() {
return implementation.isInsideWindow();
}
/*
* Package private methods to get the absolute unclipped X/Y coordiates
*/
/*package-private*/ static int getAbsoluteX() {
return absolute_x;
}
/*package-private*/ static int getAbsoluteY() {
return absolute_y;
}
interface EmptyCursorGrabListener {
void onGrab(boolean grabbing);
}
}

View File

@ -1,428 +0,0 @@
/*
* Copyright LWJGL. All rights reserved.
* License terms: https://www.lwjgl.org/license
* MACHINE GENERATED FILE, DO NOT EDIT
*/
package org.lwjgl.nanovg;
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.*;
/**
* Describes the theme used to draw nodes.
*
* <h3>Layout</h3>
*
* <pre><code>
* struct BNDnodeTheme {
* {@link NVGColor NVGcolor} {@link #nodeSelectedColor};
* {@link NVGColor NVGcolor} {@link #wiresColor};
* {@link NVGColor NVGcolor} {@link #textSelectedColor};
* {@link NVGColor NVGcolor} {@link #activeNodeColor};
* {@link NVGColor NVGcolor} {@link #wireSelectColor};
* {@link NVGColor NVGcolor} {@link #nodeBackdropColor};
* int {@link #noodleCurving};
* }</code></pre>
*/
public class BNDnodeTheme extends Struct<BNDnodeTheme> 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
NODESELECTEDCOLOR,
WIRESCOLOR,
TEXTSELECTEDCOLOR,
ACTIVENODECOLOR,
WIRESELECTCOLOR,
NODEBACKDROPCOLOR,
NOODLECURVING;
static {
Layout layout = __struct(
__member(NVGColor.SIZEOF, NVGColor.ALIGNOF),
__member(NVGColor.SIZEOF, NVGColor.ALIGNOF),
__member(NVGColor.SIZEOF, NVGColor.ALIGNOF),
__member(NVGColor.SIZEOF, NVGColor.ALIGNOF),
__member(NVGColor.SIZEOF, NVGColor.ALIGNOF),
__member(NVGColor.SIZEOF, NVGColor.ALIGNOF),
__member(4)
);
SIZEOF = layout.getSize();
ALIGNOF = layout.getAlignment();
NODESELECTEDCOLOR = layout.offsetof(0);
WIRESCOLOR = layout.offsetof(1);
TEXTSELECTEDCOLOR = layout.offsetof(2);
ACTIVENODECOLOR = layout.offsetof(3);
WIRESELECTCOLOR = layout.offsetof(4);
NODEBACKDROPCOLOR = layout.offsetof(5);
NOODLECURVING = layout.offsetof(6);
}
protected BNDnodeTheme(long address, @Nullable ByteBuffer container) {
super(address, container);
}
@Override
protected BNDnodeTheme create(long address, @Nullable ByteBuffer container) {
return new BNDnodeTheme(address, container);
}
/**
* Creates a {@code BNDnodeTheme} 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.
*
* <p>The created instance holds a strong reference to the container object.</p>
*/
public BNDnodeTheme(ByteBuffer container) {
super(memAddress(container), __checkContainer(container, SIZEOF));
}
@Override
public int sizeof() { return SIZEOF; }
/** inner color of selected node (and downarrow) */
@NativeType("NVGcolor")
public NVGColor nodeSelectedColor() { return nnodeSelectedColor(address()); }
/** outline of wires */
@NativeType("NVGcolor")
public NVGColor wiresColor() { return nwiresColor(address()); }
/** color of text label when active */
@NativeType("NVGcolor")
public NVGColor textSelectedColor() { return ntextSelectedColor(address()); }
/** inner color of active node (and dragged wire) */
@NativeType("NVGcolor")
public NVGColor activeNodeColor() { return nactiveNodeColor(address()); }
/** color of selected wire */
@NativeType("NVGcolor")
public NVGColor wireSelectColor() { return nwireSelectColor(address()); }
/** color of background of node */
@NativeType("NVGcolor")
public NVGColor nodeBackdropColor() { return nnodeBackdropColor(address()); }
/** how much a noodle curves (0 to 10) */
public int noodleCurving() { return nnoodleCurving(address()); }
/** Copies the specified {@link NVGColor} to the {@link #nodeSelectedColor} field. */
public BNDnodeTheme nodeSelectedColor(@NativeType("NVGcolor") NVGColor value) { nnodeSelectedColor(address(), value); return this; }
/** Passes the {@link #nodeSelectedColor} field to the specified {@link java.util.function.Consumer Consumer}. */
public BNDnodeTheme nodeSelectedColor(java.util.function.Consumer<NVGColor> consumer) { consumer.accept(nodeSelectedColor()); return this; }
/** Copies the specified {@link NVGColor} to the {@link #wiresColor} field. */
public BNDnodeTheme wiresColor(@NativeType("NVGcolor") NVGColor value) { nwiresColor(address(), value); return this; }
/** Passes the {@link #wiresColor} field to the specified {@link java.util.function.Consumer Consumer}. */
public BNDnodeTheme wiresColor(java.util.function.Consumer<NVGColor> consumer) { consumer.accept(wiresColor()); return this; }
/** Copies the specified {@link NVGColor} to the {@link #textSelectedColor} field. */
public BNDnodeTheme textSelectedColor(@NativeType("NVGcolor") NVGColor value) { ntextSelectedColor(address(), value); return this; }
/** Passes the {@link #textSelectedColor} field to the specified {@link java.util.function.Consumer Consumer}. */
public BNDnodeTheme textSelectedColor(java.util.function.Consumer<NVGColor> consumer) { consumer.accept(textSelectedColor()); return this; }
/** Copies the specified {@link NVGColor} to the {@link #activeNodeColor} field. */
public BNDnodeTheme activeNodeColor(@NativeType("NVGcolor") NVGColor value) { nactiveNodeColor(address(), value); return this; }
/** Passes the {@link #activeNodeColor} field to the specified {@link java.util.function.Consumer Consumer}. */
public BNDnodeTheme activeNodeColor(java.util.function.Consumer<NVGColor> consumer) { consumer.accept(activeNodeColor()); return this; }
/** Copies the specified {@link NVGColor} to the {@link #wireSelectColor} field. */
public BNDnodeTheme wireSelectColor(@NativeType("NVGcolor") NVGColor value) { nwireSelectColor(address(), value); return this; }
/** Passes the {@link #wireSelectColor} field to the specified {@link java.util.function.Consumer Consumer}. */
public BNDnodeTheme wireSelectColor(java.util.function.Consumer<NVGColor> consumer) { consumer.accept(wireSelectColor()); return this; }
/** Copies the specified {@link NVGColor} to the {@link #nodeBackdropColor} field. */
public BNDnodeTheme nodeBackdropColor(@NativeType("NVGcolor") NVGColor value) { nnodeBackdropColor(address(), value); return this; }
/** Passes the {@link #nodeBackdropColor} field to the specified {@link java.util.function.Consumer Consumer}. */
public BNDnodeTheme nodeBackdropColor(java.util.function.Consumer<NVGColor> consumer) { consumer.accept(nodeBackdropColor()); return this; }
/** Sets the specified value to the {@link #noodleCurving} field. */
public BNDnodeTheme noodleCurving(int value) { nnoodleCurving(address(), value); return this; }
/** Initializes this struct with the specified values. */
public BNDnodeTheme set(
NVGColor nodeSelectedColor,
NVGColor wiresColor,
NVGColor textSelectedColor,
NVGColor activeNodeColor,
NVGColor wireSelectColor,
NVGColor nodeBackdropColor,
int noodleCurving
) {
nodeSelectedColor(nodeSelectedColor);
wiresColor(wiresColor);
textSelectedColor(textSelectedColor);
activeNodeColor(activeNodeColor);
wireSelectColor(wireSelectColor);
nodeBackdropColor(nodeBackdropColor);
noodleCurving(noodleCurving);
return this;
}
/**
* Copies the specified struct data to this struct.
*
* @param src the source struct
*
* @return this struct
*/
public BNDnodeTheme set(BNDnodeTheme src) {
memCopy(src.address(), address(), SIZEOF);
return this;
}
// -----------------------------------
/** Returns a new {@code BNDnodeTheme} instance allocated with {@link MemoryUtil#memAlloc memAlloc}. The instance must be explicitly freed. */
public static BNDnodeTheme malloc() {
return new BNDnodeTheme(nmemAllocChecked(SIZEOF), null);
}
/** Returns a new {@code BNDnodeTheme} instance allocated with {@link MemoryUtil#memCalloc memCalloc}. The instance must be explicitly freed. */
public static BNDnodeTheme calloc() {
return new BNDnodeTheme(nmemCallocChecked(1, SIZEOF), null);
}
/** Returns a new {@code BNDnodeTheme} instance allocated with {@link BufferUtils}. */
public static BNDnodeTheme create() {
ByteBuffer container = BufferUtils.createByteBuffer(SIZEOF);
return new BNDnodeTheme(memAddress(container), container);
}
/** Returns a new {@code BNDnodeTheme} instance for the specified memory address. */
public static BNDnodeTheme create(long address) {
return new BNDnodeTheme(address, null);
}
/** Like {@link #create(long) create}, but returns {@code null} if {@code address} is {@code NULL}. */
@Nullable
public static BNDnodeTheme createSafe(long address) {
return address == NULL ? null : new BNDnodeTheme(address, null);
}
/**
* Returns a new {@link 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 new Buffer(nmemAllocChecked(__checkMalloc(capacity, SIZEOF)), capacity);
}
/**
* Returns a new {@link 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 new Buffer(nmemCallocChecked(capacity, SIZEOF), capacity);
}
/**
* Returns a new {@link Buffer} instance allocated with {@link BufferUtils}.
*
* @param capacity the buffer capacity
*/
public static Buffer create(int capacity) {
ByteBuffer container = __create(capacity, SIZEOF);
return new Buffer(memAddress(container), container, -1, 0, capacity, capacity);
}
/**
* Create a {@link 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 new Buffer(address, capacity);
}
/** Like {@link #create(long, int) create}, but returns {@code null} if {@code address} is {@code NULL}. */
@Nullable
public static Buffer createSafe(long address, int capacity) {
return address == NULL ? null : new Buffer(address, capacity);
}
// -----------------------------------
/** Deprecated for removal in 3.4.0. Use {@link #malloc(MemoryStack)} instead. */
@Deprecated public static BNDnodeTheme mallocStack() { return malloc(stackGet()); }
/** Deprecated for removal in 3.4.0. Use {@link #calloc(MemoryStack)} instead. */
@Deprecated public static BNDnodeTheme callocStack() { return calloc(stackGet()); }
/** Deprecated for removal in 3.4.0. Use {@link #malloc(MemoryStack)} instead. */
@Deprecated public static BNDnodeTheme mallocStack(MemoryStack stack) { return malloc(stack); }
/** Deprecated for removal in 3.4.0. Use {@link #calloc(MemoryStack)} instead. */
@Deprecated public static BNDnodeTheme callocStack(MemoryStack stack) { return calloc(stack); }
/** Deprecated for removal in 3.4.0. Use {@link #malloc(int, MemoryStack)} instead. */
@Deprecated public static Buffer mallocStack(int capacity) { return malloc(capacity, stackGet()); }
/** Deprecated for removal in 3.4.0. Use {@link #calloc(int, MemoryStack)} instead. */
@Deprecated public static Buffer callocStack(int capacity) { return calloc(capacity, stackGet()); }
/** Deprecated for removal in 3.4.0. Use {@link #malloc(int, MemoryStack)} instead. */
@Deprecated public static Buffer mallocStack(int capacity, MemoryStack stack) { return malloc(capacity, stack); }
/** Deprecated for removal in 3.4.0. Use {@link #calloc(int, MemoryStack)} instead. */
@Deprecated public static Buffer callocStack(int capacity, MemoryStack stack) { return calloc(capacity, stack); }
/**
* Returns a new {@code BNDnodeTheme} instance allocated on the specified {@link MemoryStack}.
*
* @param stack the stack from which to allocate
*/
public static BNDnodeTheme malloc(MemoryStack stack) {
return new BNDnodeTheme(stack.nmalloc(ALIGNOF, SIZEOF), null);
}
/**
* Returns a new {@code BNDnodeTheme} instance allocated on the specified {@link MemoryStack} and initializes all its bits to zero.
*
* @param stack the stack from which to allocate
*/
public static BNDnodeTheme calloc(MemoryStack stack) {
return new BNDnodeTheme(stack.ncalloc(ALIGNOF, 1, SIZEOF), null);
}
/**
* Returns a new {@link Buffer} instance allocated on the specified {@link MemoryStack}.
*
* @param stack the stack from which to allocate
* @param capacity the buffer capacity
*/
public static Buffer malloc(int capacity, MemoryStack stack) {
return new Buffer(stack.nmalloc(ALIGNOF, capacity * SIZEOF), capacity);
}
/**
* Returns a new {@link 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 calloc(int capacity, MemoryStack stack) {
return new Buffer(stack.ncalloc(ALIGNOF, capacity, SIZEOF), capacity);
}
// -----------------------------------
/** Unsafe version of {@link #nodeSelectedColor}. */
public static NVGColor nnodeSelectedColor(long struct) { return NVGColor.create(struct + BNDnodeTheme.NODESELECTEDCOLOR); }
/** Unsafe version of {@link #wiresColor}. */
public static NVGColor nwiresColor(long struct) { return NVGColor.create(struct + BNDnodeTheme.WIRESCOLOR); }
/** Unsafe version of {@link #textSelectedColor}. */
public static NVGColor ntextSelectedColor(long struct) { return NVGColor.create(struct + BNDnodeTheme.TEXTSELECTEDCOLOR); }
/** Unsafe version of {@link #activeNodeColor}. */
public static NVGColor nactiveNodeColor(long struct) { return NVGColor.create(struct + BNDnodeTheme.ACTIVENODECOLOR); }
/** Unsafe version of {@link #wireSelectColor}. */
public static NVGColor nwireSelectColor(long struct) { return NVGColor.create(struct + BNDnodeTheme.WIRESELECTCOLOR); }
/** Unsafe version of {@link #nodeBackdropColor}. */
public static NVGColor nnodeBackdropColor(long struct) { return NVGColor.create(struct + BNDnodeTheme.NODEBACKDROPCOLOR); }
/** Unsafe version of {@link #noodleCurving}. */
public static int nnoodleCurving(long struct) { return UNSAFE.getInt(null, struct + BNDnodeTheme.NOODLECURVING); }
/** Unsafe version of {@link #nodeSelectedColor(NVGColor) nodeSelectedColor}. */
public static void nnodeSelectedColor(long struct, NVGColor value) { memCopy(value.address(), struct + BNDnodeTheme.NODESELECTEDCOLOR, NVGColor.SIZEOF); }
/** Unsafe version of {@link #wiresColor(NVGColor) wiresColor}. */
public static void nwiresColor(long struct, NVGColor value) { memCopy(value.address(), struct + BNDnodeTheme.WIRESCOLOR, NVGColor.SIZEOF); }
/** Unsafe version of {@link #textSelectedColor(NVGColor) textSelectedColor}. */
public static void ntextSelectedColor(long struct, NVGColor value) { memCopy(value.address(), struct + BNDnodeTheme.TEXTSELECTEDCOLOR, NVGColor.SIZEOF); }
/** Unsafe version of {@link #activeNodeColor(NVGColor) activeNodeColor}. */
public static void nactiveNodeColor(long struct, NVGColor value) { memCopy(value.address(), struct + BNDnodeTheme.ACTIVENODECOLOR, NVGColor.SIZEOF); }
/** Unsafe version of {@link #wireSelectColor(NVGColor) wireSelectColor}. */
public static void nwireSelectColor(long struct, NVGColor value) { memCopy(value.address(), struct + BNDnodeTheme.WIRESELECTCOLOR, NVGColor.SIZEOF); }
/** Unsafe version of {@link #nodeBackdropColor(NVGColor) nodeBackdropColor}. */
public static void nnodeBackdropColor(long struct, NVGColor value) { memCopy(value.address(), struct + BNDnodeTheme.NODEBACKDROPCOLOR, NVGColor.SIZEOF); }
/** Unsafe version of {@link #noodleCurving(int) noodleCurving}. */
public static void nnoodleCurving(long struct, int value) { UNSAFE.putInt(null, struct + BNDnodeTheme.NOODLECURVING, value); }
// -----------------------------------
/** An array of {@link BNDnodeTheme} structs. */
public static class Buffer extends StructBuffer<BNDnodeTheme, Buffer> implements NativeResource {
private static final BNDnodeTheme ELEMENT_FACTORY = BNDnodeTheme.create(-1L);
/**
* Creates a new {@code BNDnodeTheme.Buffer} instance backed by the specified container.
*
* <p>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 BNDnodeTheme#SIZEOF}, and its mark will be undefined.</p>
*
* <p>The created buffer instance holds a strong reference to the container object.</p>
*/
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 BNDnodeTheme getElementFactory() {
return ELEMENT_FACTORY;
}
/** @return a {@link NVGColor} view of the {@link BNDnodeTheme#nodeSelectedColor} field. */
@NativeType("NVGcolor")
public NVGColor nodeSelectedColor() { return BNDnodeTheme.nnodeSelectedColor(address()); }
/** @return a {@link NVGColor} view of the {@link BNDnodeTheme#wiresColor} field. */
@NativeType("NVGcolor")
public NVGColor wiresColor() { return BNDnodeTheme.nwiresColor(address()); }
/** @return a {@link NVGColor} view of the {@link BNDnodeTheme#textSelectedColor} field. */
@NativeType("NVGcolor")
public NVGColor textSelectedColor() { return BNDnodeTheme.ntextSelectedColor(address()); }
/** @return a {@link NVGColor} view of the {@link BNDnodeTheme#activeNodeColor} field. */
@NativeType("NVGcolor")
public NVGColor activeNodeColor() { return BNDnodeTheme.nactiveNodeColor(address()); }
/** @return a {@link NVGColor} view of the {@link BNDnodeTheme#wireSelectColor} field. */
@NativeType("NVGcolor")
public NVGColor wireSelectColor() { return BNDnodeTheme.nwireSelectColor(address()); }
/** @return a {@link NVGColor} view of the {@link BNDnodeTheme#nodeBackdropColor} field. */
@NativeType("NVGcolor")
public NVGColor nodeBackdropColor() { return BNDnodeTheme.nnodeBackdropColor(address()); }
/** @return the value of the {@link BNDnodeTheme#noodleCurving} field. */
public int noodleCurving() { return BNDnodeTheme.nnoodleCurving(address()); }
/** Copies the specified {@link NVGColor} to the {@link BNDnodeTheme#nodeSelectedColor} field. */
public Buffer nodeSelectedColor(@NativeType("NVGcolor") NVGColor value) { BNDnodeTheme.nnodeSelectedColor(address(), value); return this; }
/** Passes the {@link BNDnodeTheme#nodeSelectedColor} field to the specified {@link java.util.function.Consumer Consumer}. */
public Buffer nodeSelectedColor(java.util.function.Consumer<NVGColor> consumer) { consumer.accept(nodeSelectedColor()); return this; }
/** Copies the specified {@link NVGColor} to the {@link BNDnodeTheme#wiresColor} field. */
public Buffer wiresColor(@NativeType("NVGcolor") NVGColor value) { BNDnodeTheme.nwiresColor(address(), value); return this; }
/** Passes the {@link BNDnodeTheme#wiresColor} field to the specified {@link java.util.function.Consumer Consumer}. */
public Buffer wiresColor(java.util.function.Consumer<NVGColor> consumer) { consumer.accept(wiresColor()); return this; }
/** Copies the specified {@link NVGColor} to the {@link BNDnodeTheme#textSelectedColor} field. */
public Buffer textSelectedColor(@NativeType("NVGcolor") NVGColor value) { BNDnodeTheme.ntextSelectedColor(address(), value); return this; }
/** Passes the {@link BNDnodeTheme#textSelectedColor} field to the specified {@link java.util.function.Consumer Consumer}. */
public Buffer textSelectedColor(java.util.function.Consumer<NVGColor> consumer) { consumer.accept(textSelectedColor()); return this; }
/** Copies the specified {@link NVGColor} to the {@link BNDnodeTheme#activeNodeColor} field. */
public Buffer activeNodeColor(@NativeType("NVGcolor") NVGColor value) { BNDnodeTheme.nactiveNodeColor(address(), value); return this; }
/** Passes the {@link BNDnodeTheme#activeNodeColor} field to the specified {@link java.util.function.Consumer Consumer}. */
public Buffer activeNodeColor(java.util.function.Consumer<NVGColor> consumer) { consumer.accept(activeNodeColor()); return this; }
/** Copies the specified {@link NVGColor} to the {@link BNDnodeTheme#wireSelectColor} field. */
public Buffer wireSelectColor(@NativeType("NVGcolor") NVGColor value) { BNDnodeTheme.nwireSelectColor(address(), value); return this; }
/** Passes the {@link BNDnodeTheme#wireSelectColor} field to the specified {@link java.util.function.Consumer Consumer}. */
public Buffer wireSelectColor(java.util.function.Consumer<NVGColor> consumer) { consumer.accept(wireSelectColor()); return this; }
/** Copies the specified {@link NVGColor} to the {@link BNDnodeTheme#nodeBackdropColor} field. */
public Buffer nodeBackdropColor(@NativeType("NVGcolor") NVGColor value) { BNDnodeTheme.nnodeBackdropColor(address(), value); return this; }
/** Passes the {@link BNDnodeTheme#nodeBackdropColor} field to the specified {@link java.util.function.Consumer Consumer}. */
public Buffer nodeBackdropColor(java.util.function.Consumer<NVGColor> consumer) { consumer.accept(nodeBackdropColor()); return this; }
/** Sets the specified value to the {@link BNDnodeTheme#noodleCurving} field. */
public Buffer noodleCurving(int value) { BNDnodeTheme.nnoodleCurving(address(), value); return this; }
}
}

View File

@ -1,576 +0,0 @@
/*
* Copyright LWJGL. All rights reserved.
* License terms: https://www.lwjgl.org/license
* MACHINE GENERATED FILE, DO NOT EDIT
*/
package org.lwjgl.nanovg;
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.*;
/**
* Describes the theme used to draw widgets.
*
* <h3>Layout</h3>
*
* <pre><code>
* struct BNDtheme {
* {@link NVGColor NVGcolor} {@link #backgroundColor};
* {@link BNDwidgetTheme BNDwidgetTheme} {@link #regularTheme};
* {@link BNDwidgetTheme BNDwidgetTheme} {@link #toolTheme};
* {@link BNDwidgetTheme BNDwidgetTheme} {@link #radioTheme};
* {@link BNDwidgetTheme BNDwidgetTheme} {@link #textFieldTheme};
* {@link BNDwidgetTheme BNDwidgetTheme} {@link #optionTheme};
* {@link BNDwidgetTheme BNDwidgetTheme} {@link #choiceTheme};
* {@link BNDwidgetTheme BNDwidgetTheme} {@link #numberFieldTheme};
* {@link BNDwidgetTheme BNDwidgetTheme} {@link #sliderTheme};
* {@link BNDwidgetTheme BNDwidgetTheme} {@link #scrollBarTheme};
* {@link BNDwidgetTheme BNDwidgetTheme} {@link #tooltipTheme};
* {@link BNDwidgetTheme BNDwidgetTheme} {@link #menuTheme};
* {@link BNDwidgetTheme BNDwidgetTheme} {@link #menuItemTheme};
* {@link BNDnodeTheme BNDnodeTheme} {@link #nodeTheme};
* }</code></pre>
*/
public class BNDtheme extends Struct<BNDtheme> 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
BACKGROUNDCOLOR,
REGULARTHEME,
TOOLTHEME,
RADIOTHEME,
TEXTFIELDTHEME,
OPTIONTHEME,
CHOICETHEME,
NUMBERFIELDTHEME,
SLIDERTHEME,
SCROLLBARTHEME,
TOOLTIPTHEME,
MENUTHEME,
MENUITEMTHEME,
NODETHEME;
static {
Layout layout = __struct(
__member(NVGColor.SIZEOF, NVGColor.ALIGNOF),
__member(BNDwidgetTheme.SIZEOF, BNDwidgetTheme.ALIGNOF),
__member(BNDwidgetTheme.SIZEOF, BNDwidgetTheme.ALIGNOF),
__member(BNDwidgetTheme.SIZEOF, BNDwidgetTheme.ALIGNOF),
__member(BNDwidgetTheme.SIZEOF, BNDwidgetTheme.ALIGNOF),
__member(BNDwidgetTheme.SIZEOF, BNDwidgetTheme.ALIGNOF),
__member(BNDwidgetTheme.SIZEOF, BNDwidgetTheme.ALIGNOF),
__member(BNDwidgetTheme.SIZEOF, BNDwidgetTheme.ALIGNOF),
__member(BNDwidgetTheme.SIZEOF, BNDwidgetTheme.ALIGNOF),
__member(BNDwidgetTheme.SIZEOF, BNDwidgetTheme.ALIGNOF),
__member(BNDwidgetTheme.SIZEOF, BNDwidgetTheme.ALIGNOF),
__member(BNDwidgetTheme.SIZEOF, BNDwidgetTheme.ALIGNOF),
__member(BNDwidgetTheme.SIZEOF, BNDwidgetTheme.ALIGNOF),
__member(BNDnodeTheme.SIZEOF, BNDnodeTheme.ALIGNOF)
);
SIZEOF = layout.getSize();
ALIGNOF = layout.getAlignment();
BACKGROUNDCOLOR = layout.offsetof(0);
REGULARTHEME = layout.offsetof(1);
TOOLTHEME = layout.offsetof(2);
RADIOTHEME = layout.offsetof(3);
TEXTFIELDTHEME = layout.offsetof(4);
OPTIONTHEME = layout.offsetof(5);
CHOICETHEME = layout.offsetof(6);
NUMBERFIELDTHEME = layout.offsetof(7);
SLIDERTHEME = layout.offsetof(8);
SCROLLBARTHEME = layout.offsetof(9);
TOOLTIPTHEME = layout.offsetof(10);
MENUTHEME = layout.offsetof(11);
MENUITEMTHEME = layout.offsetof(12);
NODETHEME = layout.offsetof(13);
}
protected BNDtheme(long address, @Nullable ByteBuffer container) {
super(address, container);
}
@Override
protected BNDtheme create(long address, @Nullable ByteBuffer container) {
return new BNDtheme(address, container);
}
/**
* Creates a {@code BNDtheme} 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.
*
* <p>The created instance holds a strong reference to the container object.</p>
*/
public BNDtheme(ByteBuffer container) {
super(memAddress(container), __checkContainer(container, SIZEOF));
}
@Override
public int sizeof() { return SIZEOF; }
/** the background color of panels and windows */
@NativeType("NVGcolor")
public NVGColor backgroundColor() { return nbackgroundColor(address()); }
/** theme for labels */
public BNDwidgetTheme regularTheme() { return nregularTheme(address()); }
/** theme for tool buttons */
public BNDwidgetTheme toolTheme() { return ntoolTheme(address()); }
/** theme for radio buttons */
public BNDwidgetTheme radioTheme() { return nradioTheme(address()); }
/** theme for text fields */
public BNDwidgetTheme textFieldTheme() { return ntextFieldTheme(address()); }
/** theme for option buttons (checkboxes) */
public BNDwidgetTheme optionTheme() { return noptionTheme(address()); }
/** theme for choice buttons (comboboxes) Blender calls them "menu buttons" */
public BNDwidgetTheme choiceTheme() { return nchoiceTheme(address()); }
/** theme for number fields */
public BNDwidgetTheme numberFieldTheme() { return nnumberFieldTheme(address()); }
/** theme for slider controls */
public BNDwidgetTheme sliderTheme() { return nsliderTheme(address()); }
/** theme for scrollbars */
public BNDwidgetTheme scrollBarTheme() { return nscrollBarTheme(address()); }
/** theme for tooltips */
public BNDwidgetTheme tooltipTheme() { return ntooltipTheme(address()); }
/** theme for menu backgrounds */
public BNDwidgetTheme menuTheme() { return nmenuTheme(address()); }
/** theme for menu items */
public BNDwidgetTheme menuItemTheme() { return nmenuItemTheme(address()); }
/** theme for nodes */
public BNDnodeTheme nodeTheme() { return nnodeTheme(address()); }
/** Copies the specified {@link NVGColor} to the {@link #backgroundColor} field. */
public BNDtheme backgroundColor(@NativeType("NVGcolor") NVGColor value) { nbackgroundColor(address(), value); return this; }
/** Passes the {@link #backgroundColor} field to the specified {@link java.util.function.Consumer Consumer}. */
public BNDtheme backgroundColor(java.util.function.Consumer<NVGColor> consumer) { consumer.accept(backgroundColor()); return this; }
/** Copies the specified {@link BNDwidgetTheme} to the {@link #regularTheme} field. */
public BNDtheme regularTheme(BNDwidgetTheme value) { nregularTheme(address(), value); return this; }
/** Passes the {@link #regularTheme} field to the specified {@link java.util.function.Consumer Consumer}. */
public BNDtheme regularTheme(java.util.function.Consumer<BNDwidgetTheme> consumer) { consumer.accept(regularTheme()); return this; }
/** Copies the specified {@link BNDwidgetTheme} to the {@link #toolTheme} field. */
public BNDtheme toolTheme(BNDwidgetTheme value) { ntoolTheme(address(), value); return this; }
/** Passes the {@link #toolTheme} field to the specified {@link java.util.function.Consumer Consumer}. */
public BNDtheme toolTheme(java.util.function.Consumer<BNDwidgetTheme> consumer) { consumer.accept(toolTheme()); return this; }
/** Copies the specified {@link BNDwidgetTheme} to the {@link #radioTheme} field. */
public BNDtheme radioTheme(BNDwidgetTheme value) { nradioTheme(address(), value); return this; }
/** Passes the {@link #radioTheme} field to the specified {@link java.util.function.Consumer Consumer}. */
public BNDtheme radioTheme(java.util.function.Consumer<BNDwidgetTheme> consumer) { consumer.accept(radioTheme()); return this; }
/** Copies the specified {@link BNDwidgetTheme} to the {@link #textFieldTheme} field. */
public BNDtheme textFieldTheme(BNDwidgetTheme value) { ntextFieldTheme(address(), value); return this; }
/** Passes the {@link #textFieldTheme} field to the specified {@link java.util.function.Consumer Consumer}. */
public BNDtheme textFieldTheme(java.util.function.Consumer<BNDwidgetTheme> consumer) { consumer.accept(textFieldTheme()); return this; }
/** Copies the specified {@link BNDwidgetTheme} to the {@link #optionTheme} field. */
public BNDtheme optionTheme(BNDwidgetTheme value) { noptionTheme(address(), value); return this; }
/** Passes the {@link #optionTheme} field to the specified {@link java.util.function.Consumer Consumer}. */
public BNDtheme optionTheme(java.util.function.Consumer<BNDwidgetTheme> consumer) { consumer.accept(optionTheme()); return this; }
/** Copies the specified {@link BNDwidgetTheme} to the {@link #choiceTheme} field. */
public BNDtheme choiceTheme(BNDwidgetTheme value) { nchoiceTheme(address(), value); return this; }
/** Passes the {@link #choiceTheme} field to the specified {@link java.util.function.Consumer Consumer}. */
public BNDtheme choiceTheme(java.util.function.Consumer<BNDwidgetTheme> consumer) { consumer.accept(choiceTheme()); return this; }
/** Copies the specified {@link BNDwidgetTheme} to the {@link #numberFieldTheme} field. */
public BNDtheme numberFieldTheme(BNDwidgetTheme value) { nnumberFieldTheme(address(), value); return this; }
/** Passes the {@link #numberFieldTheme} field to the specified {@link java.util.function.Consumer Consumer}. */
public BNDtheme numberFieldTheme(java.util.function.Consumer<BNDwidgetTheme> consumer) { consumer.accept(numberFieldTheme()); return this; }
/** Copies the specified {@link BNDwidgetTheme} to the {@link #sliderTheme} field. */
public BNDtheme sliderTheme(BNDwidgetTheme value) { nsliderTheme(address(), value); return this; }
/** Passes the {@link #sliderTheme} field to the specified {@link java.util.function.Consumer Consumer}. */
public BNDtheme sliderTheme(java.util.function.Consumer<BNDwidgetTheme> consumer) { consumer.accept(sliderTheme()); return this; }
/** Copies the specified {@link BNDwidgetTheme} to the {@link #scrollBarTheme} field. */
public BNDtheme scrollBarTheme(BNDwidgetTheme value) { nscrollBarTheme(address(), value); return this; }
/** Passes the {@link #scrollBarTheme} field to the specified {@link java.util.function.Consumer Consumer}. */
public BNDtheme scrollBarTheme(java.util.function.Consumer<BNDwidgetTheme> consumer) { consumer.accept(scrollBarTheme()); return this; }
/** Copies the specified {@link BNDwidgetTheme} to the {@link #tooltipTheme} field. */
public BNDtheme tooltipTheme(BNDwidgetTheme value) { ntooltipTheme(address(), value); return this; }
/** Passes the {@link #tooltipTheme} field to the specified {@link java.util.function.Consumer Consumer}. */
public BNDtheme tooltipTheme(java.util.function.Consumer<BNDwidgetTheme> consumer) { consumer.accept(tooltipTheme()); return this; }
/** Copies the specified {@link BNDwidgetTheme} to the {@link #menuTheme} field. */
public BNDtheme menuTheme(BNDwidgetTheme value) { nmenuTheme(address(), value); return this; }
/** Passes the {@link #menuTheme} field to the specified {@link java.util.function.Consumer Consumer}. */
public BNDtheme menuTheme(java.util.function.Consumer<BNDwidgetTheme> consumer) { consumer.accept(menuTheme()); return this; }
/** Copies the specified {@link BNDwidgetTheme} to the {@link #menuItemTheme} field. */
public BNDtheme menuItemTheme(BNDwidgetTheme value) { nmenuItemTheme(address(), value); return this; }
/** Passes the {@link #menuItemTheme} field to the specified {@link java.util.function.Consumer Consumer}. */
public BNDtheme menuItemTheme(java.util.function.Consumer<BNDwidgetTheme> consumer) { consumer.accept(menuItemTheme()); return this; }
/** Copies the specified {@link BNDnodeTheme} to the {@link #nodeTheme} field. */
public BNDtheme nodeTheme(BNDnodeTheme value) { nnodeTheme(address(), value); return this; }
/** Passes the {@link #nodeTheme} field to the specified {@link java.util.function.Consumer Consumer}. */
public BNDtheme nodeTheme(java.util.function.Consumer<BNDnodeTheme> consumer) { consumer.accept(nodeTheme()); return this; }
/** Initializes this struct with the specified values. */
public BNDtheme set(
NVGColor backgroundColor,
BNDwidgetTheme regularTheme,
BNDwidgetTheme toolTheme,
BNDwidgetTheme radioTheme,
BNDwidgetTheme textFieldTheme,
BNDwidgetTheme optionTheme,
BNDwidgetTheme choiceTheme,
BNDwidgetTheme numberFieldTheme,
BNDwidgetTheme sliderTheme,
BNDwidgetTheme scrollBarTheme,
BNDwidgetTheme tooltipTheme,
BNDwidgetTheme menuTheme,
BNDwidgetTheme menuItemTheme,
BNDnodeTheme nodeTheme
) {
backgroundColor(backgroundColor);
regularTheme(regularTheme);
toolTheme(toolTheme);
radioTheme(radioTheme);
textFieldTheme(textFieldTheme);
optionTheme(optionTheme);
choiceTheme(choiceTheme);
numberFieldTheme(numberFieldTheme);
sliderTheme(sliderTheme);
scrollBarTheme(scrollBarTheme);
tooltipTheme(tooltipTheme);
menuTheme(menuTheme);
menuItemTheme(menuItemTheme);
nodeTheme(nodeTheme);
return this;
}
/**
* Copies the specified struct data to this struct.
*
* @param src the source struct
*
* @return this struct
*/
public BNDtheme set(BNDtheme src) {
memCopy(src.address(), address(), SIZEOF);
return this;
}
// -----------------------------------
/** Returns a new {@code BNDtheme} instance allocated with {@link MemoryUtil#memAlloc memAlloc}. The instance must be explicitly freed. */
public static BNDtheme malloc() {
return new BNDtheme(nmemAllocChecked(SIZEOF), null);
}
/** Returns a new {@code BNDtheme} instance allocated with {@link MemoryUtil#memCalloc memCalloc}. The instance must be explicitly freed. */
public static BNDtheme calloc() {
return new BNDtheme(nmemCallocChecked(1, SIZEOF), null);
}
/** Returns a new {@code BNDtheme} instance allocated with {@link BufferUtils}. */
public static BNDtheme create() {
ByteBuffer container = BufferUtils.createByteBuffer(SIZEOF);
return new BNDtheme(memAddress(container), container);
}
/** Returns a new {@code BNDtheme} instance for the specified memory address. */
public static BNDtheme create(long address) {
return new BNDtheme(address, null);
}
/** Like {@link #create(long) create}, but returns {@code null} if {@code address} is {@code NULL}. */
@Nullable
public static BNDtheme createSafe(long address) {
return address == NULL ? null : new BNDtheme(address, null);
}
/**
* Returns a new {@link 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 new Buffer(nmemAllocChecked(__checkMalloc(capacity, SIZEOF)), capacity);
}
/**
* Returns a new {@link 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 new Buffer(nmemCallocChecked(capacity, SIZEOF), capacity);
}
/**
* Returns a new {@link Buffer} instance allocated with {@link BufferUtils}.
*
* @param capacity the buffer capacity
*/
public static Buffer create(int capacity) {
ByteBuffer container = __create(capacity, SIZEOF);
return new Buffer(memAddress(container), container, -1, 0, capacity, capacity);
}
/**
* Create a {@link 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 new Buffer(address, capacity);
}
/** Like {@link #create(long, int) create}, but returns {@code null} if {@code address} is {@code NULL}. */
@Nullable
public static Buffer createSafe(long address, int capacity) {
return address == NULL ? null : new Buffer(address, capacity);
}
// -----------------------------------
/** Deprecated for removal in 3.4.0. Use {@link #malloc(MemoryStack)} instead. */
@Deprecated public static BNDtheme mallocStack() { return malloc(stackGet()); }
/** Deprecated for removal in 3.4.0. Use {@link #calloc(MemoryStack)} instead. */
@Deprecated public static BNDtheme callocStack() { return calloc(stackGet()); }
/** Deprecated for removal in 3.4.0. Use {@link #malloc(MemoryStack)} instead. */
@Deprecated public static BNDtheme mallocStack(MemoryStack stack) { return malloc(stack); }
/** Deprecated for removal in 3.4.0. Use {@link #calloc(MemoryStack)} instead. */
@Deprecated public static BNDtheme callocStack(MemoryStack stack) { return calloc(stack); }
/** Deprecated for removal in 3.4.0. Use {@link #malloc(int, MemoryStack)} instead. */
@Deprecated public static Buffer mallocStack(int capacity) { return malloc(capacity, stackGet()); }
/** Deprecated for removal in 3.4.0. Use {@link #calloc(int, MemoryStack)} instead. */
@Deprecated public static Buffer callocStack(int capacity) { return calloc(capacity, stackGet()); }
/** Deprecated for removal in 3.4.0. Use {@link #malloc(int, MemoryStack)} instead. */
@Deprecated public static Buffer mallocStack(int capacity, MemoryStack stack) { return malloc(capacity, stack); }
/** Deprecated for removal in 3.4.0. Use {@link #calloc(int, MemoryStack)} instead. */
@Deprecated public static Buffer callocStack(int capacity, MemoryStack stack) { return calloc(capacity, stack); }
/**
* Returns a new {@code BNDtheme} instance allocated on the specified {@link MemoryStack}.
*
* @param stack the stack from which to allocate
*/
public static BNDtheme malloc(MemoryStack stack) {
return new BNDtheme(stack.nmalloc(ALIGNOF, SIZEOF), null);
}
/**
* Returns a new {@code BNDtheme} instance allocated on the specified {@link MemoryStack} and initializes all its bits to zero.
*
* @param stack the stack from which to allocate
*/
public static BNDtheme calloc(MemoryStack stack) {
return new BNDtheme(stack.ncalloc(ALIGNOF, 1, SIZEOF), null);
}
/**
* Returns a new {@link Buffer} instance allocated on the specified {@link MemoryStack}.
*
* @param stack the stack from which to allocate
* @param capacity the buffer capacity
*/
public static Buffer malloc(int capacity, MemoryStack stack) {
return new Buffer(stack.nmalloc(ALIGNOF, capacity * SIZEOF), capacity);
}
/**
* Returns a new {@link 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 calloc(int capacity, MemoryStack stack) {
return new Buffer(stack.ncalloc(ALIGNOF, capacity, SIZEOF), capacity);
}
// -----------------------------------
/** Unsafe version of {@link #backgroundColor}. */
public static NVGColor nbackgroundColor(long struct) { return NVGColor.create(struct + BNDtheme.BACKGROUNDCOLOR); }
/** Unsafe version of {@link #regularTheme}. */
public static BNDwidgetTheme nregularTheme(long struct) { return BNDwidgetTheme.create(struct + BNDtheme.REGULARTHEME); }
/** Unsafe version of {@link #toolTheme}. */
public static BNDwidgetTheme ntoolTheme(long struct) { return BNDwidgetTheme.create(struct + BNDtheme.TOOLTHEME); }
/** Unsafe version of {@link #radioTheme}. */
public static BNDwidgetTheme nradioTheme(long struct) { return BNDwidgetTheme.create(struct + BNDtheme.RADIOTHEME); }
/** Unsafe version of {@link #textFieldTheme}. */
public static BNDwidgetTheme ntextFieldTheme(long struct) { return BNDwidgetTheme.create(struct + BNDtheme.TEXTFIELDTHEME); }
/** Unsafe version of {@link #optionTheme}. */
public static BNDwidgetTheme noptionTheme(long struct) { return BNDwidgetTheme.create(struct + BNDtheme.OPTIONTHEME); }
/** Unsafe version of {@link #choiceTheme}. */
public static BNDwidgetTheme nchoiceTheme(long struct) { return BNDwidgetTheme.create(struct + BNDtheme.CHOICETHEME); }
/** Unsafe version of {@link #numberFieldTheme}. */
public static BNDwidgetTheme nnumberFieldTheme(long struct) { return BNDwidgetTheme.create(struct + BNDtheme.NUMBERFIELDTHEME); }
/** Unsafe version of {@link #sliderTheme}. */
public static BNDwidgetTheme nsliderTheme(long struct) { return BNDwidgetTheme.create(struct + BNDtheme.SLIDERTHEME); }
/** Unsafe version of {@link #scrollBarTheme}. */
public static BNDwidgetTheme nscrollBarTheme(long struct) { return BNDwidgetTheme.create(struct + BNDtheme.SCROLLBARTHEME); }
/** Unsafe version of {@link #tooltipTheme}. */
public static BNDwidgetTheme ntooltipTheme(long struct) { return BNDwidgetTheme.create(struct + BNDtheme.TOOLTIPTHEME); }
/** Unsafe version of {@link #menuTheme}. */
public static BNDwidgetTheme nmenuTheme(long struct) { return BNDwidgetTheme.create(struct + BNDtheme.MENUTHEME); }
/** Unsafe version of {@link #menuItemTheme}. */
public static BNDwidgetTheme nmenuItemTheme(long struct) { return BNDwidgetTheme.create(struct + BNDtheme.MENUITEMTHEME); }
/** Unsafe version of {@link #nodeTheme}. */
public static BNDnodeTheme nnodeTheme(long struct) { return BNDnodeTheme.create(struct + BNDtheme.NODETHEME); }
/** Unsafe version of {@link #backgroundColor(NVGColor) backgroundColor}. */
public static void nbackgroundColor(long struct, NVGColor value) { memCopy(value.address(), struct + BNDtheme.BACKGROUNDCOLOR, NVGColor.SIZEOF); }
/** Unsafe version of {@link #regularTheme(BNDwidgetTheme) regularTheme}. */
public static void nregularTheme(long struct, BNDwidgetTheme value) { memCopy(value.address(), struct + BNDtheme.REGULARTHEME, BNDwidgetTheme.SIZEOF); }
/** Unsafe version of {@link #toolTheme(BNDwidgetTheme) toolTheme}. */
public static void ntoolTheme(long struct, BNDwidgetTheme value) { memCopy(value.address(), struct + BNDtheme.TOOLTHEME, BNDwidgetTheme.SIZEOF); }
/** Unsafe version of {@link #radioTheme(BNDwidgetTheme) radioTheme}. */
public static void nradioTheme(long struct, BNDwidgetTheme value) { memCopy(value.address(), struct + BNDtheme.RADIOTHEME, BNDwidgetTheme.SIZEOF); }
/** Unsafe version of {@link #textFieldTheme(BNDwidgetTheme) textFieldTheme}. */
public static void ntextFieldTheme(long struct, BNDwidgetTheme value) { memCopy(value.address(), struct + BNDtheme.TEXTFIELDTHEME, BNDwidgetTheme.SIZEOF); }
/** Unsafe version of {@link #optionTheme(BNDwidgetTheme) optionTheme}. */
public static void noptionTheme(long struct, BNDwidgetTheme value) { memCopy(value.address(), struct + BNDtheme.OPTIONTHEME, BNDwidgetTheme.SIZEOF); }
/** Unsafe version of {@link #choiceTheme(BNDwidgetTheme) choiceTheme}. */
public static void nchoiceTheme(long struct, BNDwidgetTheme value) { memCopy(value.address(), struct + BNDtheme.CHOICETHEME, BNDwidgetTheme.SIZEOF); }
/** Unsafe version of {@link #numberFieldTheme(BNDwidgetTheme) numberFieldTheme}. */
public static void nnumberFieldTheme(long struct, BNDwidgetTheme value) { memCopy(value.address(), struct + BNDtheme.NUMBERFIELDTHEME, BNDwidgetTheme.SIZEOF); }
/** Unsafe version of {@link #sliderTheme(BNDwidgetTheme) sliderTheme}. */
public static void nsliderTheme(long struct, BNDwidgetTheme value) { memCopy(value.address(), struct + BNDtheme.SLIDERTHEME, BNDwidgetTheme.SIZEOF); }
/** Unsafe version of {@link #scrollBarTheme(BNDwidgetTheme) scrollBarTheme}. */
public static void nscrollBarTheme(long struct, BNDwidgetTheme value) { memCopy(value.address(), struct + BNDtheme.SCROLLBARTHEME, BNDwidgetTheme.SIZEOF); }
/** Unsafe version of {@link #tooltipTheme(BNDwidgetTheme) tooltipTheme}. */
public static void ntooltipTheme(long struct, BNDwidgetTheme value) { memCopy(value.address(), struct + BNDtheme.TOOLTIPTHEME, BNDwidgetTheme.SIZEOF); }
/** Unsafe version of {@link #menuTheme(BNDwidgetTheme) menuTheme}. */
public static void nmenuTheme(long struct, BNDwidgetTheme value) { memCopy(value.address(), struct + BNDtheme.MENUTHEME, BNDwidgetTheme.SIZEOF); }
/** Unsafe version of {@link #menuItemTheme(BNDwidgetTheme) menuItemTheme}. */
public static void nmenuItemTheme(long struct, BNDwidgetTheme value) { memCopy(value.address(), struct + BNDtheme.MENUITEMTHEME, BNDwidgetTheme.SIZEOF); }
/** Unsafe version of {@link #nodeTheme(BNDnodeTheme) nodeTheme}. */
public static void nnodeTheme(long struct, BNDnodeTheme value) { memCopy(value.address(), struct + BNDtheme.NODETHEME, BNDnodeTheme.SIZEOF); }
// -----------------------------------
/** An array of {@link BNDtheme} structs. */
public static class Buffer extends StructBuffer<BNDtheme, Buffer> implements NativeResource {
private static final BNDtheme ELEMENT_FACTORY = BNDtheme.create(-1L);
/**
* Creates a new {@code BNDtheme.Buffer} instance backed by the specified container.
*
* <p>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 BNDtheme#SIZEOF}, and its mark will be undefined.</p>
*
* <p>The created buffer instance holds a strong reference to the container object.</p>
*/
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 BNDtheme getElementFactory() {
return ELEMENT_FACTORY;
}
/** @return a {@link NVGColor} view of the {@link BNDtheme#backgroundColor} field. */
@NativeType("NVGcolor")
public NVGColor backgroundColor() { return BNDtheme.nbackgroundColor(address()); }
/** @return a {@link BNDwidgetTheme} view of the {@link BNDtheme#regularTheme} field. */
public BNDwidgetTheme regularTheme() { return BNDtheme.nregularTheme(address()); }
/** @return a {@link BNDwidgetTheme} view of the {@link BNDtheme#toolTheme} field. */
public BNDwidgetTheme toolTheme() { return BNDtheme.ntoolTheme(address()); }
/** @return a {@link BNDwidgetTheme} view of the {@link BNDtheme#radioTheme} field. */
public BNDwidgetTheme radioTheme() { return BNDtheme.nradioTheme(address()); }
/** @return a {@link BNDwidgetTheme} view of the {@link BNDtheme#textFieldTheme} field. */
public BNDwidgetTheme textFieldTheme() { return BNDtheme.ntextFieldTheme(address()); }
/** @return a {@link BNDwidgetTheme} view of the {@link BNDtheme#optionTheme} field. */
public BNDwidgetTheme optionTheme() { return BNDtheme.noptionTheme(address()); }
/** @return a {@link BNDwidgetTheme} view of the {@link BNDtheme#choiceTheme} field. */
public BNDwidgetTheme choiceTheme() { return BNDtheme.nchoiceTheme(address()); }
/** @return a {@link BNDwidgetTheme} view of the {@link BNDtheme#numberFieldTheme} field. */
public BNDwidgetTheme numberFieldTheme() { return BNDtheme.nnumberFieldTheme(address()); }
/** @return a {@link BNDwidgetTheme} view of the {@link BNDtheme#sliderTheme} field. */
public BNDwidgetTheme sliderTheme() { return BNDtheme.nsliderTheme(address()); }
/** @return a {@link BNDwidgetTheme} view of the {@link BNDtheme#scrollBarTheme} field. */
public BNDwidgetTheme scrollBarTheme() { return BNDtheme.nscrollBarTheme(address()); }
/** @return a {@link BNDwidgetTheme} view of the {@link BNDtheme#tooltipTheme} field. */
public BNDwidgetTheme tooltipTheme() { return BNDtheme.ntooltipTheme(address()); }
/** @return a {@link BNDwidgetTheme} view of the {@link BNDtheme#menuTheme} field. */
public BNDwidgetTheme menuTheme() { return BNDtheme.nmenuTheme(address()); }
/** @return a {@link BNDwidgetTheme} view of the {@link BNDtheme#menuItemTheme} field. */
public BNDwidgetTheme menuItemTheme() { return BNDtheme.nmenuItemTheme(address()); }
/** @return a {@link BNDnodeTheme} view of the {@link BNDtheme#nodeTheme} field. */
public BNDnodeTheme nodeTheme() { return BNDtheme.nnodeTheme(address()); }
/** Copies the specified {@link NVGColor} to the {@link BNDtheme#backgroundColor} field. */
public Buffer backgroundColor(@NativeType("NVGcolor") NVGColor value) { BNDtheme.nbackgroundColor(address(), value); return this; }
/** Passes the {@link BNDtheme#backgroundColor} field to the specified {@link java.util.function.Consumer Consumer}. */
public Buffer backgroundColor(java.util.function.Consumer<NVGColor> consumer) { consumer.accept(backgroundColor()); return this; }
/** Copies the specified {@link BNDwidgetTheme} to the {@link BNDtheme#regularTheme} field. */
public Buffer regularTheme(BNDwidgetTheme value) { BNDtheme.nregularTheme(address(), value); return this; }
/** Passes the {@link BNDtheme#regularTheme} field to the specified {@link java.util.function.Consumer Consumer}. */
public Buffer regularTheme(java.util.function.Consumer<BNDwidgetTheme> consumer) { consumer.accept(regularTheme()); return this; }
/** Copies the specified {@link BNDwidgetTheme} to the {@link BNDtheme#toolTheme} field. */
public Buffer toolTheme(BNDwidgetTheme value) { BNDtheme.ntoolTheme(address(), value); return this; }
/** Passes the {@link BNDtheme#toolTheme} field to the specified {@link java.util.function.Consumer Consumer}. */
public Buffer toolTheme(java.util.function.Consumer<BNDwidgetTheme> consumer) { consumer.accept(toolTheme()); return this; }
/** Copies the specified {@link BNDwidgetTheme} to the {@link BNDtheme#radioTheme} field. */
public Buffer radioTheme(BNDwidgetTheme value) { BNDtheme.nradioTheme(address(), value); return this; }
/** Passes the {@link BNDtheme#radioTheme} field to the specified {@link java.util.function.Consumer Consumer}. */
public Buffer radioTheme(java.util.function.Consumer<BNDwidgetTheme> consumer) { consumer.accept(radioTheme()); return this; }
/** Copies the specified {@link BNDwidgetTheme} to the {@link BNDtheme#textFieldTheme} field. */
public Buffer textFieldTheme(BNDwidgetTheme value) { BNDtheme.ntextFieldTheme(address(), value); return this; }
/** Passes the {@link BNDtheme#textFieldTheme} field to the specified {@link java.util.function.Consumer Consumer}. */
public Buffer textFieldTheme(java.util.function.Consumer<BNDwidgetTheme> consumer) { consumer.accept(textFieldTheme()); return this; }
/** Copies the specified {@link BNDwidgetTheme} to the {@link BNDtheme#optionTheme} field. */
public Buffer optionTheme(BNDwidgetTheme value) { BNDtheme.noptionTheme(address(), value); return this; }
/** Passes the {@link BNDtheme#optionTheme} field to the specified {@link java.util.function.Consumer Consumer}. */
public Buffer optionTheme(java.util.function.Consumer<BNDwidgetTheme> consumer) { consumer.accept(optionTheme()); return this; }
/** Copies the specified {@link BNDwidgetTheme} to the {@link BNDtheme#choiceTheme} field. */
public Buffer choiceTheme(BNDwidgetTheme value) { BNDtheme.nchoiceTheme(address(), value); return this; }
/** Passes the {@link BNDtheme#choiceTheme} field to the specified {@link java.util.function.Consumer Consumer}. */
public Buffer choiceTheme(java.util.function.Consumer<BNDwidgetTheme> consumer) { consumer.accept(choiceTheme()); return this; }
/** Copies the specified {@link BNDwidgetTheme} to the {@link BNDtheme#numberFieldTheme} field. */
public Buffer numberFieldTheme(BNDwidgetTheme value) { BNDtheme.nnumberFieldTheme(address(), value); return this; }
/** Passes the {@link BNDtheme#numberFieldTheme} field to the specified {@link java.util.function.Consumer Consumer}. */
public Buffer numberFieldTheme(java.util.function.Consumer<BNDwidgetTheme> consumer) { consumer.accept(numberFieldTheme()); return this; }
/** Copies the specified {@link BNDwidgetTheme} to the {@link BNDtheme#sliderTheme} field. */
public Buffer sliderTheme(BNDwidgetTheme value) { BNDtheme.nsliderTheme(address(), value); return this; }
/** Passes the {@link BNDtheme#sliderTheme} field to the specified {@link java.util.function.Consumer Consumer}. */
public Buffer sliderTheme(java.util.function.Consumer<BNDwidgetTheme> consumer) { consumer.accept(sliderTheme()); return this; }
/** Copies the specified {@link BNDwidgetTheme} to the {@link BNDtheme#scrollBarTheme} field. */
public Buffer scrollBarTheme(BNDwidgetTheme value) { BNDtheme.nscrollBarTheme(address(), value); return this; }
/** Passes the {@link BNDtheme#scrollBarTheme} field to the specified {@link java.util.function.Consumer Consumer}. */
public Buffer scrollBarTheme(java.util.function.Consumer<BNDwidgetTheme> consumer) { consumer.accept(scrollBarTheme()); return this; }
/** Copies the specified {@link BNDwidgetTheme} to the {@link BNDtheme#tooltipTheme} field. */
public Buffer tooltipTheme(BNDwidgetTheme value) { BNDtheme.ntooltipTheme(address(), value); return this; }
/** Passes the {@link BNDtheme#tooltipTheme} field to the specified {@link java.util.function.Consumer Consumer}. */
public Buffer tooltipTheme(java.util.function.Consumer<BNDwidgetTheme> consumer) { consumer.accept(tooltipTheme()); return this; }
/** Copies the specified {@link BNDwidgetTheme} to the {@link BNDtheme#menuTheme} field. */
public Buffer menuTheme(BNDwidgetTheme value) { BNDtheme.nmenuTheme(address(), value); return this; }
/** Passes the {@link BNDtheme#menuTheme} field to the specified {@link java.util.function.Consumer Consumer}. */
public Buffer menuTheme(java.util.function.Consumer<BNDwidgetTheme> consumer) { consumer.accept(menuTheme()); return this; }
/** Copies the specified {@link BNDwidgetTheme} to the {@link BNDtheme#menuItemTheme} field. */
public Buffer menuItemTheme(BNDwidgetTheme value) { BNDtheme.nmenuItemTheme(address(), value); return this; }
/** Passes the {@link BNDtheme#menuItemTheme} field to the specified {@link java.util.function.Consumer Consumer}. */
public Buffer menuItemTheme(java.util.function.Consumer<BNDwidgetTheme> consumer) { consumer.accept(menuItemTheme()); return this; }
/** Copies the specified {@link BNDnodeTheme} to the {@link BNDtheme#nodeTheme} field. */
public Buffer nodeTheme(BNDnodeTheme value) { BNDtheme.nnodeTheme(address(), value); return this; }
/** Passes the {@link BNDtheme#nodeTheme} field to the specified {@link java.util.function.Consumer Consumer}. */
public Buffer nodeTheme(java.util.function.Consumer<BNDnodeTheme> consumer) { consumer.accept(nodeTheme()); return this; }
}
}

View File

@ -1,447 +0,0 @@
/*
* Copyright LWJGL. All rights reserved.
* License terms: https://www.lwjgl.org/license
* MACHINE GENERATED FILE, DO NOT EDIT
*/
package org.lwjgl.nanovg;
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.*;
/**
* Describes the theme used to draw a single widget or widget box; these values correspond to the same values that can be retrieved from the Theme panel
* in the Blender preferences.
*
* <h3>Layout</h3>
*
* <pre><code>
* struct BNDwidgetTheme {
* {@link NVGColor NVGcolor} {@link #outlineColor};
* {@link NVGColor NVGcolor} {@link #itemColor};
* {@link NVGColor NVGcolor} {@link #innerColor};
* {@link NVGColor NVGcolor} {@link #innerSelectedColor};
* {@link NVGColor NVGcolor} {@link #textColor};
* {@link NVGColor NVGcolor} {@link #textSelectedColor};
* int {@link #shadeTop};
* int {@link #shadeDown};
* }</code></pre>
*/
public class BNDwidgetTheme extends Struct<BNDwidgetTheme> 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
OUTLINECOLOR,
ITEMCOLOR,
INNERCOLOR,
INNERSELECTEDCOLOR,
TEXTCOLOR,
TEXTSELECTEDCOLOR,
SHADETOP,
SHADEDOWN;
static {
Layout layout = __struct(
__member(NVGColor.SIZEOF, NVGColor.ALIGNOF),
__member(NVGColor.SIZEOF, NVGColor.ALIGNOF),
__member(NVGColor.SIZEOF, NVGColor.ALIGNOF),
__member(NVGColor.SIZEOF, NVGColor.ALIGNOF),
__member(NVGColor.SIZEOF, NVGColor.ALIGNOF),
__member(NVGColor.SIZEOF, NVGColor.ALIGNOF),
__member(4),
__member(4)
);
SIZEOF = layout.getSize();
ALIGNOF = layout.getAlignment();
OUTLINECOLOR = layout.offsetof(0);
ITEMCOLOR = layout.offsetof(1);
INNERCOLOR = layout.offsetof(2);
INNERSELECTEDCOLOR = layout.offsetof(3);
TEXTCOLOR = layout.offsetof(4);
TEXTSELECTEDCOLOR = layout.offsetof(5);
SHADETOP = layout.offsetof(6);
SHADEDOWN = layout.offsetof(7);
}
protected BNDwidgetTheme(long address, @Nullable ByteBuffer container) {
super(address, container);
}
@Override
protected BNDwidgetTheme create(long address, @Nullable ByteBuffer container) {
return new BNDwidgetTheme(address, container);
}
/**
* Creates a {@code BNDwidgetTheme} 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.
*
* <p>The created instance holds a strong reference to the container object.</p>
*/
public BNDwidgetTheme(ByteBuffer container) {
super(memAddress(container), __checkContainer(container, SIZEOF));
}
@Override
public int sizeof() { return SIZEOF; }
/** color of widget box outline */
@NativeType("NVGcolor")
public NVGColor outlineColor() { return noutlineColor(address()); }
/** color of widget item (meaning changes depending on class) */
@NativeType("NVGcolor")
public NVGColor itemColor() { return nitemColor(address()); }
/** fill color of widget box */
@NativeType("NVGcolor")
public NVGColor innerColor() { return ninnerColor(address()); }
/** fill color of widget box when active */
@NativeType("NVGcolor")
public NVGColor innerSelectedColor() { return ninnerSelectedColor(address()); }
/** color of text label */
@NativeType("NVGcolor")
public NVGColor textColor() { return ntextColor(address()); }
/** color of text label when active */
@NativeType("NVGcolor")
public NVGColor textSelectedColor() { return ntextSelectedColor(address()); }
/** delta modifier for upper part of gradient (-100 to 100) */
public int shadeTop() { return nshadeTop(address()); }
/** delta modifier for lower part of gradient (-100 to 100) */
public int shadeDown() { return nshadeDown(address()); }
/** Copies the specified {@link NVGColor} to the {@link #outlineColor} field. */
public BNDwidgetTheme outlineColor(@NativeType("NVGcolor") NVGColor value) { noutlineColor(address(), value); return this; }
/** Passes the {@link #outlineColor} field to the specified {@link java.util.function.Consumer Consumer}. */
public BNDwidgetTheme outlineColor(java.util.function.Consumer<NVGColor> consumer) { consumer.accept(outlineColor()); return this; }
/** Copies the specified {@link NVGColor} to the {@link #itemColor} field. */
public BNDwidgetTheme itemColor(@NativeType("NVGcolor") NVGColor value) { nitemColor(address(), value); return this; }
/** Passes the {@link #itemColor} field to the specified {@link java.util.function.Consumer Consumer}. */
public BNDwidgetTheme itemColor(java.util.function.Consumer<NVGColor> consumer) { consumer.accept(itemColor()); return this; }
/** Copies the specified {@link NVGColor} to the {@link #innerColor} field. */
public BNDwidgetTheme innerColor(@NativeType("NVGcolor") NVGColor value) { ninnerColor(address(), value); return this; }
/** Passes the {@link #innerColor} field to the specified {@link java.util.function.Consumer Consumer}. */
public BNDwidgetTheme innerColor(java.util.function.Consumer<NVGColor> consumer) { consumer.accept(innerColor()); return this; }
/** Copies the specified {@link NVGColor} to the {@link #innerSelectedColor} field. */
public BNDwidgetTheme innerSelectedColor(@NativeType("NVGcolor") NVGColor value) { ninnerSelectedColor(address(), value); return this; }
/** Passes the {@link #innerSelectedColor} field to the specified {@link java.util.function.Consumer Consumer}. */
public BNDwidgetTheme innerSelectedColor(java.util.function.Consumer<NVGColor> consumer) { consumer.accept(innerSelectedColor()); return this; }
/** Copies the specified {@link NVGColor} to the {@link #textColor} field. */
public BNDwidgetTheme textColor(@NativeType("NVGcolor") NVGColor value) { ntextColor(address(), value); return this; }
/** Passes the {@link #textColor} field to the specified {@link java.util.function.Consumer Consumer}. */
public BNDwidgetTheme textColor(java.util.function.Consumer<NVGColor> consumer) { consumer.accept(textColor()); return this; }
/** Copies the specified {@link NVGColor} to the {@link #textSelectedColor} field. */
public BNDwidgetTheme textSelectedColor(@NativeType("NVGcolor") NVGColor value) { ntextSelectedColor(address(), value); return this; }
/** Passes the {@link #textSelectedColor} field to the specified {@link java.util.function.Consumer Consumer}. */
public BNDwidgetTheme textSelectedColor(java.util.function.Consumer<NVGColor> consumer) { consumer.accept(textSelectedColor()); return this; }
/** Sets the specified value to the {@link #shadeTop} field. */
public BNDwidgetTheme shadeTop(int value) { nshadeTop(address(), value); return this; }
/** Sets the specified value to the {@link #shadeDown} field. */
public BNDwidgetTheme shadeDown(int value) { nshadeDown(address(), value); return this; }
/** Initializes this struct with the specified values. */
public BNDwidgetTheme set(
NVGColor outlineColor,
NVGColor itemColor,
NVGColor innerColor,
NVGColor innerSelectedColor,
NVGColor textColor,
NVGColor textSelectedColor,
int shadeTop,
int shadeDown
) {
outlineColor(outlineColor);
itemColor(itemColor);
innerColor(innerColor);
innerSelectedColor(innerSelectedColor);
textColor(textColor);
textSelectedColor(textSelectedColor);
shadeTop(shadeTop);
shadeDown(shadeDown);
return this;
}
/**
* Copies the specified struct data to this struct.
*
* @param src the source struct
*
* @return this struct
*/
public BNDwidgetTheme set(BNDwidgetTheme src) {
memCopy(src.address(), address(), SIZEOF);
return this;
}
// -----------------------------------
/** Returns a new {@code BNDwidgetTheme} instance allocated with {@link MemoryUtil#memAlloc memAlloc}. The instance must be explicitly freed. */
public static BNDwidgetTheme malloc() {
return new BNDwidgetTheme(nmemAllocChecked(SIZEOF), null);
}
/** Returns a new {@code BNDwidgetTheme} instance allocated with {@link MemoryUtil#memCalloc memCalloc}. The instance must be explicitly freed. */
public static BNDwidgetTheme calloc() {
return new BNDwidgetTheme(nmemCallocChecked(1, SIZEOF), null);
}
/** Returns a new {@code BNDwidgetTheme} instance allocated with {@link BufferUtils}. */
public static BNDwidgetTheme create() {
ByteBuffer container = BufferUtils.createByteBuffer(SIZEOF);
return new BNDwidgetTheme(memAddress(container), container);
}
/** Returns a new {@code BNDwidgetTheme} instance for the specified memory address. */
public static BNDwidgetTheme create(long address) {
return new BNDwidgetTheme(address, null);
}
/** Like {@link #create(long) create}, but returns {@code null} if {@code address} is {@code NULL}. */
@Nullable
public static BNDwidgetTheme createSafe(long address) {
return address == NULL ? null : new BNDwidgetTheme(address, null);
}
/**
* Returns a new {@link 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 new Buffer(nmemAllocChecked(__checkMalloc(capacity, SIZEOF)), capacity);
}
/**
* Returns a new {@link 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 new Buffer(nmemCallocChecked(capacity, SIZEOF), capacity);
}
/**
* Returns a new {@link Buffer} instance allocated with {@link BufferUtils}.
*
* @param capacity the buffer capacity
*/
public static Buffer create(int capacity) {
ByteBuffer container = __create(capacity, SIZEOF);
return new Buffer(memAddress(container), container, -1, 0, capacity, capacity);
}
/**
* Create a {@link 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 new Buffer(address, capacity);
}
/** Like {@link #create(long, int) create}, but returns {@code null} if {@code address} is {@code NULL}. */
@Nullable
public static Buffer createSafe(long address, int capacity) {
return address == NULL ? null : new Buffer(address, capacity);
}
// -----------------------------------
/** Deprecated for removal in 3.4.0. Use {@link #malloc(MemoryStack)} instead. */
@Deprecated public static BNDwidgetTheme mallocStack() { return malloc(stackGet()); }
/** Deprecated for removal in 3.4.0. Use {@link #calloc(MemoryStack)} instead. */
@Deprecated public static BNDwidgetTheme callocStack() { return calloc(stackGet()); }
/** Deprecated for removal in 3.4.0. Use {@link #malloc(MemoryStack)} instead. */
@Deprecated public static BNDwidgetTheme mallocStack(MemoryStack stack) { return malloc(stack); }
/** Deprecated for removal in 3.4.0. Use {@link #calloc(MemoryStack)} instead. */
@Deprecated public static BNDwidgetTheme callocStack(MemoryStack stack) { return calloc(stack); }
/** Deprecated for removal in 3.4.0. Use {@link #malloc(int, MemoryStack)} instead. */
@Deprecated public static Buffer mallocStack(int capacity) { return malloc(capacity, stackGet()); }
/** Deprecated for removal in 3.4.0. Use {@link #calloc(int, MemoryStack)} instead. */
@Deprecated public static Buffer callocStack(int capacity) { return calloc(capacity, stackGet()); }
/** Deprecated for removal in 3.4.0. Use {@link #malloc(int, MemoryStack)} instead. */
@Deprecated public static Buffer mallocStack(int capacity, MemoryStack stack) { return malloc(capacity, stack); }
/** Deprecated for removal in 3.4.0. Use {@link #calloc(int, MemoryStack)} instead. */
@Deprecated public static Buffer callocStack(int capacity, MemoryStack stack) { return calloc(capacity, stack); }
/**
* Returns a new {@code BNDwidgetTheme} instance allocated on the specified {@link MemoryStack}.
*
* @param stack the stack from which to allocate
*/
public static BNDwidgetTheme malloc(MemoryStack stack) {
return new BNDwidgetTheme(stack.nmalloc(ALIGNOF, SIZEOF), null);
}
/**
* Returns a new {@code BNDwidgetTheme} instance allocated on the specified {@link MemoryStack} and initializes all its bits to zero.
*
* @param stack the stack from which to allocate
*/
public static BNDwidgetTheme calloc(MemoryStack stack) {
return new BNDwidgetTheme(stack.ncalloc(ALIGNOF, 1, SIZEOF), null);
}
/**
* Returns a new {@link Buffer} instance allocated on the specified {@link MemoryStack}.
*
* @param stack the stack from which to allocate
* @param capacity the buffer capacity
*/
public static Buffer malloc(int capacity, MemoryStack stack) {
return new Buffer(stack.nmalloc(ALIGNOF, capacity * SIZEOF), capacity);
}
/**
* Returns a new {@link 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 calloc(int capacity, MemoryStack stack) {
return new Buffer(stack.ncalloc(ALIGNOF, capacity, SIZEOF), capacity);
}
// -----------------------------------
/** Unsafe version of {@link #outlineColor}. */
public static NVGColor noutlineColor(long struct) { return NVGColor.create(struct + BNDwidgetTheme.OUTLINECOLOR); }
/** Unsafe version of {@link #itemColor}. */
public static NVGColor nitemColor(long struct) { return NVGColor.create(struct + BNDwidgetTheme.ITEMCOLOR); }
/** Unsafe version of {@link #innerColor}. */
public static NVGColor ninnerColor(long struct) { return NVGColor.create(struct + BNDwidgetTheme.INNERCOLOR); }
/** Unsafe version of {@link #innerSelectedColor}. */
public static NVGColor ninnerSelectedColor(long struct) { return NVGColor.create(struct + BNDwidgetTheme.INNERSELECTEDCOLOR); }
/** Unsafe version of {@link #textColor}. */
public static NVGColor ntextColor(long struct) { return NVGColor.create(struct + BNDwidgetTheme.TEXTCOLOR); }
/** Unsafe version of {@link #textSelectedColor}. */
public static NVGColor ntextSelectedColor(long struct) { return NVGColor.create(struct + BNDwidgetTheme.TEXTSELECTEDCOLOR); }
/** Unsafe version of {@link #shadeTop}. */
public static int nshadeTop(long struct) { return UNSAFE.getInt(null, struct + BNDwidgetTheme.SHADETOP); }
/** Unsafe version of {@link #shadeDown}. */
public static int nshadeDown(long struct) { return UNSAFE.getInt(null, struct + BNDwidgetTheme.SHADEDOWN); }
/** Unsafe version of {@link #outlineColor(NVGColor) outlineColor}. */
public static void noutlineColor(long struct, NVGColor value) { memCopy(value.address(), struct + BNDwidgetTheme.OUTLINECOLOR, NVGColor.SIZEOF); }
/** Unsafe version of {@link #itemColor(NVGColor) itemColor}. */
public static void nitemColor(long struct, NVGColor value) { memCopy(value.address(), struct + BNDwidgetTheme.ITEMCOLOR, NVGColor.SIZEOF); }
/** Unsafe version of {@link #innerColor(NVGColor) innerColor}. */
public static void ninnerColor(long struct, NVGColor value) { memCopy(value.address(), struct + BNDwidgetTheme.INNERCOLOR, NVGColor.SIZEOF); }
/** Unsafe version of {@link #innerSelectedColor(NVGColor) innerSelectedColor}. */
public static void ninnerSelectedColor(long struct, NVGColor value) { memCopy(value.address(), struct + BNDwidgetTheme.INNERSELECTEDCOLOR, NVGColor.SIZEOF); }
/** Unsafe version of {@link #textColor(NVGColor) textColor}. */
public static void ntextColor(long struct, NVGColor value) { memCopy(value.address(), struct + BNDwidgetTheme.TEXTCOLOR, NVGColor.SIZEOF); }
/** Unsafe version of {@link #textSelectedColor(NVGColor) textSelectedColor}. */
public static void ntextSelectedColor(long struct, NVGColor value) { memCopy(value.address(), struct + BNDwidgetTheme.TEXTSELECTEDCOLOR, NVGColor.SIZEOF); }
/** Unsafe version of {@link #shadeTop(int) shadeTop}. */
public static void nshadeTop(long struct, int value) { UNSAFE.putInt(null, struct + BNDwidgetTheme.SHADETOP, value); }
/** Unsafe version of {@link #shadeDown(int) shadeDown}. */
public static void nshadeDown(long struct, int value) { UNSAFE.putInt(null, struct + BNDwidgetTheme.SHADEDOWN, value); }
// -----------------------------------
/** An array of {@link BNDwidgetTheme} structs. */
public static class Buffer extends StructBuffer<BNDwidgetTheme, Buffer> implements NativeResource {
private static final BNDwidgetTheme ELEMENT_FACTORY = BNDwidgetTheme.create(-1L);
/**
* Creates a new {@code BNDwidgetTheme.Buffer} instance backed by the specified container.
*
* <p>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 BNDwidgetTheme#SIZEOF}, and its mark will be undefined.</p>
*
* <p>The created buffer instance holds a strong reference to the container object.</p>
*/
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 BNDwidgetTheme getElementFactory() {
return ELEMENT_FACTORY;
}
/** @return a {@link NVGColor} view of the {@link BNDwidgetTheme#outlineColor} field. */
@NativeType("NVGcolor")
public NVGColor outlineColor() { return BNDwidgetTheme.noutlineColor(address()); }
/** @return a {@link NVGColor} view of the {@link BNDwidgetTheme#itemColor} field. */
@NativeType("NVGcolor")
public NVGColor itemColor() { return BNDwidgetTheme.nitemColor(address()); }
/** @return a {@link NVGColor} view of the {@link BNDwidgetTheme#innerColor} field. */
@NativeType("NVGcolor")
public NVGColor innerColor() { return BNDwidgetTheme.ninnerColor(address()); }
/** @return a {@link NVGColor} view of the {@link BNDwidgetTheme#innerSelectedColor} field. */
@NativeType("NVGcolor")
public NVGColor innerSelectedColor() { return BNDwidgetTheme.ninnerSelectedColor(address()); }
/** @return a {@link NVGColor} view of the {@link BNDwidgetTheme#textColor} field. */
@NativeType("NVGcolor")
public NVGColor textColor() { return BNDwidgetTheme.ntextColor(address()); }
/** @return a {@link NVGColor} view of the {@link BNDwidgetTheme#textSelectedColor} field. */
@NativeType("NVGcolor")
public NVGColor textSelectedColor() { return BNDwidgetTheme.ntextSelectedColor(address()); }
/** @return the value of the {@link BNDwidgetTheme#shadeTop} field. */
public int shadeTop() { return BNDwidgetTheme.nshadeTop(address()); }
/** @return the value of the {@link BNDwidgetTheme#shadeDown} field. */
public int shadeDown() { return BNDwidgetTheme.nshadeDown(address()); }
/** Copies the specified {@link NVGColor} to the {@link BNDwidgetTheme#outlineColor} field. */
public Buffer outlineColor(@NativeType("NVGcolor") NVGColor value) { BNDwidgetTheme.noutlineColor(address(), value); return this; }
/** Passes the {@link BNDwidgetTheme#outlineColor} field to the specified {@link java.util.function.Consumer Consumer}. */
public Buffer outlineColor(java.util.function.Consumer<NVGColor> consumer) { consumer.accept(outlineColor()); return this; }
/** Copies the specified {@link NVGColor} to the {@link BNDwidgetTheme#itemColor} field. */
public Buffer itemColor(@NativeType("NVGcolor") NVGColor value) { BNDwidgetTheme.nitemColor(address(), value); return this; }
/** Passes the {@link BNDwidgetTheme#itemColor} field to the specified {@link java.util.function.Consumer Consumer}. */
public Buffer itemColor(java.util.function.Consumer<NVGColor> consumer) { consumer.accept(itemColor()); return this; }
/** Copies the specified {@link NVGColor} to the {@link BNDwidgetTheme#innerColor} field. */
public Buffer innerColor(@NativeType("NVGcolor") NVGColor value) { BNDwidgetTheme.ninnerColor(address(), value); return this; }
/** Passes the {@link BNDwidgetTheme#innerColor} field to the specified {@link java.util.function.Consumer Consumer}. */
public Buffer innerColor(java.util.function.Consumer<NVGColor> consumer) { consumer.accept(innerColor()); return this; }
/** Copies the specified {@link NVGColor} to the {@link BNDwidgetTheme#innerSelectedColor} field. */
public Buffer innerSelectedColor(@NativeType("NVGcolor") NVGColor value) { BNDwidgetTheme.ninnerSelectedColor(address(), value); return this; }
/** Passes the {@link BNDwidgetTheme#innerSelectedColor} field to the specified {@link java.util.function.Consumer Consumer}. */
public Buffer innerSelectedColor(java.util.function.Consumer<NVGColor> consumer) { consumer.accept(innerSelectedColor()); return this; }
/** Copies the specified {@link NVGColor} to the {@link BNDwidgetTheme#textColor} field. */
public Buffer textColor(@NativeType("NVGcolor") NVGColor value) { BNDwidgetTheme.ntextColor(address(), value); return this; }
/** Passes the {@link BNDwidgetTheme#textColor} field to the specified {@link java.util.function.Consumer Consumer}. */
public Buffer textColor(java.util.function.Consumer<NVGColor> consumer) { consumer.accept(textColor()); return this; }
/** Copies the specified {@link NVGColor} to the {@link BNDwidgetTheme#textSelectedColor} field. */
public Buffer textSelectedColor(@NativeType("NVGcolor") NVGColor value) { BNDwidgetTheme.ntextSelectedColor(address(), value); return this; }
/** Passes the {@link BNDwidgetTheme#textSelectedColor} field to the specified {@link java.util.function.Consumer Consumer}. */
public Buffer textSelectedColor(java.util.function.Consumer<NVGColor> consumer) { consumer.accept(textSelectedColor()); return this; }
/** Sets the specified value to the {@link BNDwidgetTheme#shadeTop} field. */
public Buffer shadeTop(int value) { BNDwidgetTheme.nshadeTop(address(), value); return this; }
/** Sets the specified value to the {@link BNDwidgetTheme#shadeDown} field. */
public Buffer shadeDown(int value) { BNDwidgetTheme.nshadeDown(address(), value); return this; }
}
}

File diff suppressed because one or more lines are too long

View File

@ -1,46 +0,0 @@
/*
* Copyright LWJGL. All rights reserved.
* License terms: https://www.lwjgl.org/license
* MACHINE GENERATED FILE, DO NOT EDIT
*/
package org.lwjgl.nanovg;
import org.lwjgl.system.*;
import static org.lwjgl.system.MemoryUtil.*;
/** Initializes the nanovg shared library. */
final class LibNanoVG {
static {
String libName = Platform.mapLibraryNameBundled("lwjgl_nanovg");
Library.loadSystem(System::load, System::loadLibrary, LibNanoVG.class, "org.lwjgl.nanovg", libName);
MemoryAllocator allocator = getAllocator(Configuration.DEBUG_MEMORY_ALLOCATOR_INTERNAL.get(true));
setupMalloc(
allocator.getMalloc(),
allocator.getCalloc(),
allocator.getRealloc(),
allocator.getFree(),
allocator.getAlignedAlloc(),
allocator.getAlignedFree()
);
}
private LibNanoVG() {
}
static void initialize() {
// intentionally empty to trigger static initializer
}
private static native void setupMalloc(
long malloc,
long calloc,
long realloc,
long free,
long aligned_alloc,
long aligned_free
);
}

Some files were not shown because too many files have changed in this diff Show More