mirror of
https://github.com/PojavLauncherTeam/PojavLauncher.git
synced 2025-12-27 21:08:21 +00:00
Feat[LWJGL]: update to 3.3.1 (#4326)
* Feat: update to LWJGL 3.3.1 Add nanovg module for OneConfig mod (untested) Move most of jre_lwjgl3glfw source files to lwjgl3 repo * Update lwjgl libraries * Fix: fatal glfw callback cleanup * Build: update lwjgl.jar (fix dlopen on 32bit) https://github.com/PojavLauncherTeam/lwjgl3/commit/4c35777 * Feat: add support code for VulkanMod Copied changes from v3_vulkanmod branch except libraries Added patch script for VulkanMod * Fix variable name * Fix[oshi]: try to update to jna 5.13.0 and oshi 6.3.0 * fix compilation errors * Fix NumberFormatException: For input string: "1-jre" * Fix the brackets * Fix: jna library path * Fix OpenGL initialization * Fix broken init of GL renderers * Fixes[vulkanmod]: fix patcher script, set Vulkan libname * Fix SHA1 mismatch of replaced libraries * Build: update lwjgl-opengl.jar: reland fixPojavGLContext29db8b5cc0* Include libc++_shared in vulkanmod patcher * Revert "Include libc++_shared in vulkanmod patcher" This reverts commitcf3165e89c. * Fix java version detection for LabyMod4 * Fix lwjgl-openal missing wrapper --------- Co-authored-by: khanhduytran0 <khanhduytran0@users.noreply.github.com>
This commit is contained in:
parent
78737cf249
commit
4a8c1e4bc0
Binary file not shown.
@ -1 +1 @@
|
||||
1689180036097
|
||||
1687078018167
|
||||
@ -39,6 +39,7 @@ public class JMinecraftVersionList {
|
||||
public static class JavaVersionInfo {
|
||||
public String component;
|
||||
public int majorVersion;
|
||||
public int version; // parameter used by LabyMod 4
|
||||
}
|
||||
@Keep
|
||||
public static class LoggingConfig {
|
||||
|
||||
@ -618,6 +618,34 @@ public final class Tools {
|
||||
}
|
||||
return true; // allow if none match
|
||||
}
|
||||
|
||||
private static void preProcessLibraries(DependentLibrary[] libraries) {
|
||||
for (int i = 0; i < libraries.length; i++) {
|
||||
DependentLibrary libItem = libraries[i];
|
||||
String[] version = libItem.name.split(":")[2].split("\\.");
|
||||
if (libItem.name.startsWith("net.java.dev.jna:jna:")) {
|
||||
// Special handling for LabyMod 1.8.9, Forge 1.12.2(?) and oshi
|
||||
// we have libjnidispatch 5.13.0 in jniLibs directory
|
||||
if (Integer.parseInt(version[0]) >= 5 && Integer.parseInt(version[1]) >= 13) return;
|
||||
Log.d(APP_NAME, "Library " + libItem.name + " has been changed to version 5.13.0");
|
||||
libItem.name = "net.java.dev.jna:jna:5.13.0";
|
||||
libItem.downloads.artifact.path = "net/java/dev/jna/jna/5.13.0/jna-5.13.0.jar";
|
||||
libItem.downloads.artifact.sha1 = "1200e7ebeedbe0d10062093f32925a912020e747";
|
||||
libItem.downloads.artifact.url = "https://repo1.maven.org/maven2/net/java/dev/jna/jna/5.13.0/jna-5.13.0.jar";
|
||||
} else if (libItem.name.startsWith("com.github.oshi:oshi-core:")) {
|
||||
//if (Integer.parseInt(version[0]) >= 6 && Integer.parseInt(version[1]) >= 3) return;
|
||||
// FIXME: ensure compatibility
|
||||
|
||||
if (Integer.parseInt(version[0]) != 6 || Integer.parseInt(version[1]) != 2) return;
|
||||
Log.d(APP_NAME, "Library " + libItem.name + " has been changed to version 6.3.0");
|
||||
libItem.name = "com.github.oshi:oshi-core:6.3.0";
|
||||
libItem.downloads.artifact.path = "com/github/oshi/oshi-core/6.3.0/oshi-core-6.3.0.jar";
|
||||
libItem.downloads.artifact.sha1 = "9e98cf55be371cafdb9c70c35d04ec2a8c2b42ac";
|
||||
libItem.downloads.artifact.url = "https://repo1.maven.org/maven2/com/github/oshi/oshi-core/6.3.0/oshi-core-6.3.0.jar";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static String[] generateLibClasspath(JMinecraftVersionList.Version info) {
|
||||
List<String> libDir = new ArrayList<>();
|
||||
for (DependentLibrary libItem: info.libraries) {
|
||||
@ -636,7 +664,7 @@ public final class Tools {
|
||||
try {
|
||||
JMinecraftVersionList.Version customVer = Tools.GLOBAL_GSON.fromJson(read(DIR_HOME_VERSION + "/" + versionName + "/" + versionName + ".json"), JMinecraftVersionList.Version.class);
|
||||
if (skipInheriting || customVer.inheritsFrom == null || customVer.inheritsFrom.equals(customVer.id)) {
|
||||
return customVer;
|
||||
preProcessLibraries(customVer.libraries);
|
||||
} else {
|
||||
JMinecraftVersionList.Version inheritsVer;
|
||||
//If it won't download, just search for it
|
||||
@ -674,6 +702,7 @@ public final class Tools {
|
||||
}
|
||||
} finally {
|
||||
inheritsVer.libraries = libList.toArray(new DependentLibrary[0]);
|
||||
preProcessLibraries(inheritsVer.libraries);
|
||||
}
|
||||
|
||||
// Inheriting Minecraft 1.13+ with append custom args
|
||||
@ -711,8 +740,14 @@ public final class Tools {
|
||||
inheritsVer.arguments.game = totalArgList.toArray(new Object[0]);
|
||||
}
|
||||
|
||||
return inheritsVer;
|
||||
customVer = inheritsVer;
|
||||
}
|
||||
|
||||
// LabyMod 4 sets version instead of majorVersion
|
||||
if (customVer.javaVersion.majorVersion == 0) {
|
||||
customVer.javaVersion.majorVersion = customVer.javaVersion.version;
|
||||
}
|
||||
return customVer;
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
@ -329,6 +329,7 @@ public class JREUtils {
|
||||
ArrayList<String> overridableArguments = new ArrayList<>(Arrays.asList(
|
||||
"-Djava.home=" + runtimeHome,
|
||||
"-Djava.io.tmpdir=" + Tools.DIR_CACHE.getAbsolutePath(),
|
||||
"-Djna.boot.library.path=" + NATIVE_LIB_DIR,
|
||||
"-Duser.home=" + Tools.DIR_GAME_HOME,
|
||||
"-Duser.language=" + System.getProperty("user.language"),
|
||||
"-Dos.name=Linux",
|
||||
@ -337,7 +338,9 @@ public class JREUtils {
|
||||
"-Dpojav.path.private.account=" + Tools.DIR_ACCOUNT_NEW,
|
||||
"-Duser.timezone=" + TimeZone.getDefault().getID(),
|
||||
|
||||
"-Dorg.lwjgl.vulkan.libname=libvulkan.so",
|
||||
//LWJGL 3 DEBUG FLAGS
|
||||
"-Dorg.lwjgl.util.NoChecks=true",
|
||||
//"-Dorg.lwjgl.util.Debug=true",
|
||||
//"-Dorg.lwjgl.util.DebugFunctions=true",
|
||||
//"-Dorg.lwjgl.util.DebugLoader=true",
|
||||
|
||||
@ -23,6 +23,12 @@
|
||||
#include <environ/environ.h>
|
||||
#include "utils.h"
|
||||
#include "ctxbridges/gl_bridge.h"
|
||||
|
||||
#define GLFW_CLIENT_API 0x22001
|
||||
/* Consider GLFW_NO_API as Vulkan API */
|
||||
#define GLFW_NO_API 0
|
||||
#define GLFW_OPENGL_API 0x30001
|
||||
|
||||
// region OSMESA internals
|
||||
|
||||
struct pipe_screen;
|
||||
@ -603,17 +609,12 @@ void bigcore_set_affinity();
|
||||
#define RENDERER_GL4ES 1
|
||||
#define RENDERER_VK_ZINK 2
|
||||
#define RENDERER_VIRGL 3
|
||||
#define RENDERER_VULKAN 4
|
||||
|
||||
void* gbuffer;
|
||||
|
||||
void* egl_make_current(void* window);
|
||||
|
||||
void pojav_openGLOnLoad() {
|
||||
}
|
||||
void pojav_openGLOnUnload() {
|
||||
|
||||
}
|
||||
|
||||
void pojavTerminate() {
|
||||
printf("EGLBridge: Terminating\n");
|
||||
|
||||
@ -732,7 +733,10 @@ int pojavInit() {
|
||||
pojav_environ->savedWidth = ANativeWindow_getWidth(pojav_environ->pojavWindow);
|
||||
pojav_environ->savedHeight = ANativeWindow_getHeight(pojav_environ->pojavWindow);
|
||||
ANativeWindow_setBuffersGeometry(pojav_environ->pojavWindow,pojav_environ->savedWidth,pojav_environ->savedHeight,AHARDWAREBUFFER_FORMAT_R8G8B8X8_UNORM);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int pojavInitOpenGL() {
|
||||
// Only affects GL4ES as of now
|
||||
const char *forceVsync = getenv("FORCE_VSYNC");
|
||||
if (strcmp(forceVsync, "true") == 0)
|
||||
@ -872,6 +876,25 @@ int pojavInit() {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void pojavSetWindowHint(int hint, int value) {
|
||||
if (hint != GLFW_CLIENT_API) return;
|
||||
switch (value) {
|
||||
case GLFW_NO_API:
|
||||
pojav_environ->config_renderer = RENDERER_VULKAN;
|
||||
/* Nothing to do: initialization is handled in Java-side */
|
||||
// pojavInitVulkan();
|
||||
break;
|
||||
case GLFW_OPENGL_API:
|
||||
/* Nothing to do: initialization is called in pojavCreateContext */
|
||||
// pojavInitOpenGL();
|
||||
break;
|
||||
default:
|
||||
printf("GLFW: Unimplemented API 0x%x\n", value);
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
ANativeWindow_Buffer buf;
|
||||
int32_t stride;
|
||||
bool stopSwapBuffers;
|
||||
@ -979,6 +1002,12 @@ Java_org_lwjgl_glfw_GLFW_nativeEglDetachOnCurrentThread(JNIEnv *env, jclass claz
|
||||
*/
|
||||
|
||||
void* pojavCreateContext(void* contextSrc) {
|
||||
if (pojav_environ->config_renderer == RENDERER_VULKAN) {
|
||||
return (void *)pojav_environ->pojavWindow;
|
||||
}
|
||||
|
||||
pojavInitOpenGL();
|
||||
|
||||
if (pojav_environ->config_renderer == RENDERER_GL4ES) {
|
||||
/*const EGLint ctx_attribs[] = {
|
||||
EGL_CONTEXT_CLIENT_VERSION, atoi(getenv("LIBGL_ES")),
|
||||
|
||||
Binary file not shown.
Binary file not shown.
BIN
app_pojavlauncher/src/main/jniLibs/arm64-v8a/liblwjgl_nanovg.so
Normal file
BIN
app_pojavlauncher/src/main/jniLibs/arm64-v8a/liblwjgl_nanovg.so
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
app_pojavlauncher/src/main/jniLibs/arm64-v8a/liblwjgl_tinyfd.so
Normal file
BIN
app_pojavlauncher/src/main/jniLibs/arm64-v8a/liblwjgl_tinyfd.so
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
app_pojavlauncher/src/main/jniLibs/x86/liblwjgl_nanovg.so
Normal file
BIN
app_pojavlauncher/src/main/jniLibs/x86/liblwjgl_nanovg.so
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
app_pojavlauncher/src/main/jniLibs/x86/liblwjgl_tinyfd.so
Normal file
BIN
app_pojavlauncher/src/main/jniLibs/x86/liblwjgl_tinyfd.so
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
app_pojavlauncher/src/main/jniLibs/x86_64/liblwjgl_nanovg.so
Normal file
BIN
app_pojavlauncher/src/main/jniLibs/x86_64/liblwjgl_nanovg.so
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
app_pojavlauncher/src/main/jniLibs/x86_64/liblwjgl_tinyfd.so
Normal file
BIN
app_pojavlauncher/src/main/jniLibs/x86_64/liblwjgl_tinyfd.so
Normal file
Binary file not shown.
BIN
jre_lwjgl3glfw/libs/lwjgl-glfw.jar
Normal file
BIN
jre_lwjgl3glfw/libs/lwjgl-glfw.jar
Normal file
Binary file not shown.
BIN
jre_lwjgl3glfw/libs/lwjgl-lwjglx.jar
Normal file
BIN
jre_lwjgl3glfw/libs/lwjgl-lwjglx.jar
Normal file
Binary file not shown.
BIN
jre_lwjgl3glfw/libs/lwjgl-nanovg.jar
Normal file
BIN
jre_lwjgl3glfw/libs/lwjgl-nanovg.jar
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,293 +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.*;
|
||||
|
||||
/**
|
||||
* <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 {
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,269 +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 {
|
||||
// -- Begin LWJGL2 parts --
|
||||
/**
|
||||
* @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);
|
||||
}
|
||||
// -- End LWJGL2 parts --
|
||||
|
||||
private BufferUtils() {}
|
||||
|
||||
/**
|
||||
* 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); }
|
||||
|
||||
}
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
@ -1,640 +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.*;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Internal library methods
|
||||
* </p>
|
||||
*
|
||||
* @author Brian Matzon <brian@matzon.dk>
|
||||
* @version $Revision: 3608 $ $Id: LWJGLUtil.java 3608 2011-08-10 16:05:46Z
|
||||
* spasi $
|
||||
*/
|
||||
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("SunOS")
|
||||
|| osName.startsWith("Unix") || osName.startsWith("Android"))
|
||||
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";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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) {
|
||||
try {
|
||||
log("getPathFromClassLoader: searching for: " + libname);
|
||||
Class<?> 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:" + e);
|
||||
}
|
||||
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);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints the given message to System.err if DEBUG is true.
|
||||
*
|
||||
* @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 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
|
||||
*
|
||||
* @result true if the Field is accepted
|
||||
*/
|
||||
boolean accept(Field field, int value);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,382 +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.*;
|
||||
import java.nio.charset.*;
|
||||
|
||||
/**
|
||||
* [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;
|
||||
|
||||
static {
|
||||
ascii = Charset.forName("ISO-8859-1");
|
||||
utf8 = Charset.forName("UTF-8");
|
||||
}
|
||||
|
||||
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 org.lwjgl.system.MemoryUtil.memAddress0(buffer); }
|
||||
|
||||
public static long getAddress0Safe(Buffer buffer) { return buffer == null ? 0L : getAddress0(buffer); }
|
||||
|
||||
public static long getAddress0(PointerBuffer buffer) { return getAddress0(buffer.getBuffer()); }
|
||||
|
||||
public static long getAddress0Safe(PointerBuffer buffer) { return buffer == null ? 0L : getAddress0(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 org.lwjgl.system.MemoryUtil.memUTF16(text);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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(java.nio.CharBuffer)} implementation that uses {@link BufferUtils#createByteBuffer(int)}
|
||||
* instead of {@link ByteBuffer#allocate(int)}.
|
||||
*
|
||||
* @see CharsetEncoder#encode(java.nio.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 org.lwjgl.system.MemoryUtil.memUTF16(buffer);
|
||||
}
|
||||
|
||||
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.");
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,807 +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> {
|
||||
// -- Begin LWJGL2 parts --
|
||||
public PointerBuffer(final int capacity) {
|
||||
this(allocateDirect(capacity));
|
||||
}
|
||||
|
||||
public PointerBuffer(final ByteBuffer source) {
|
||||
this(create(source));
|
||||
}
|
||||
|
||||
// Workaround for LWJGL2 bridge
|
||||
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();
|
||||
}
|
||||
|
||||
}
|
||||
// -- End LWJGL2 parts --
|
||||
|
||||
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 wrap(PointerBuffer.class, memAddress(source), capacity, source);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 wrap(PointerBuffer.class, address, 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 wrap(PointerBuffer.class, memAddress(source), capacity, source);
|
||||
}
|
||||
|
||||
@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 <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 <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} {@code >} {@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, off, len)} has exactly the same effect as the loop</p>
|
||||
*
|
||||
* <pre>
|
||||
* for (int i = off; i < 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 <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 <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} {@code >} {@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, off, len)} has exactly the same effect as the loop</p>
|
||||
*
|
||||
* <pre>
|
||||
* for (int i = off; i < 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()} - {@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();
|
||||
}
|
||||
|
||||
}
|
||||
@ -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();
|
||||
|
||||
}
|
||||
@ -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() + ")";
|
||||
}
|
||||
}
|
||||
@ -1,87 +0,0 @@
|
||||
package org.lwjgl;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
import java.awt.Desktop;
|
||||
import java.net.URI;
|
||||
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.UIManager;
|
||||
|
||||
public class Sys {
|
||||
|
||||
/**
|
||||
* No constructor for Sys.
|
||||
*/
|
||||
private Sys() {
|
||||
}
|
||||
|
||||
/** Returns the LWJGL version. */
|
||||
public static String getVersion() {
|
||||
return org.lwjgl.Version.getVersion();
|
||||
}
|
||||
|
||||
public static void initialize() {
|
||||
if (!GLFW.glfwInit())
|
||||
throw new IllegalStateException("Unable to initialize GLFW");
|
||||
}
|
||||
|
||||
/**
|
||||
* GLFW automatically recomputes the time via
|
||||
* {@link GLFW#glfwGetTimerValue()}, no need to divide the frequency
|
||||
*
|
||||
* @return 1
|
||||
*/
|
||||
public static long getTimerResolution() {
|
||||
return 1000;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current value of the hires timer, in ticks. When the Sys class
|
||||
* is first loaded the hi-res timer is reset to 0. If no hi-res timer is
|
||||
* present then this method will always return 0.
|
||||
* <p>
|
||||
* <strong>PLEASE NOTE: </strong> the hi-res timer WILL wrap around.
|
||||
*
|
||||
* @return the current hi-res time, in ticks (always >= 0)
|
||||
*/
|
||||
public static long getTime() {
|
||||
return GLFW.glfwGetTimerValue();
|
||||
}
|
||||
|
||||
public static long getNanoTime() {
|
||||
return System.nanoTime();
|
||||
// return getTime() * 1000L * 1000L;
|
||||
}
|
||||
|
||||
public static boolean openURL(String url) {
|
||||
if (!Desktop.isDesktopSupported())
|
||||
return false;
|
||||
|
||||
Desktop desktop = Desktop.getDesktop();
|
||||
if (!desktop.isSupported(Desktop.Action.BROWSE))
|
||||
return false;
|
||||
|
||||
try {
|
||||
desktop.browse(new URI(url));
|
||||
return true;
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
public static String getClipboard() {
|
||||
return GLFW.glfwGetClipboardString(GLFW.glfwGetPrimaryMonitor());
|
||||
}
|
||||
}
|
||||
@ -31,42 +31,21 @@ public final class Callbacks {
|
||||
if (Checks.CHECKS) {
|
||||
check(window);
|
||||
}
|
||||
|
||||
try {
|
||||
for (Field callback : GLFW.class.getFields()) {
|
||||
if (callback.getName().startsWith("mGLFW") && callback.getName().endsWith("Callback")) {
|
||||
callback.set(null, null);
|
||||
}
|
||||
}
|
||||
} catch (IllegalAccessException|NullPointerException e) {
|
||||
throw new RuntimeException("org.lwjgl.GLFW.mGLFWxxxCallbacks must be set to public and static", e);
|
||||
}
|
||||
|
||||
/*
|
||||
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);
|
||||
try {
|
||||
for (Method callback : GLFW.class.getMethods()) {
|
||||
if (callback.getName().startsWith("glfwSet") && callback.getName().endsWith("Callback")) {
|
||||
if (callback.getParameterCount() == 1) {
|
||||
callback.invoke(null, (Object)null);
|
||||
} else {
|
||||
callback.invoke(null, GLFW.glfwGetCurrentContext(), null);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (IllegalAccessException|NullPointerException e) {
|
||||
throw new RuntimeException("org.lwjgl.GLFW.glfwSetXXXCallback() must be set to public and static", e);
|
||||
} catch (InvocationTargetException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,85 +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>On-screen GLFW windows can only be used in 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 a GLFW window is created.</p>
|
||||
*/
|
||||
final class EventLoop {
|
||||
|
||||
static final class OffScreen {
|
||||
static {
|
||||
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 windows may only be created on the main thread."
|
||||
: "GLFW windows may only be created on the main thread and that thread must be the first thread in the process. Please run " +
|
||||
"the JVM with -XstartOnFirstThread. For offscreen rendering, make sure another window toolkit (e.g. AWT or JavaFX) is " +
|
||||
"initialized before GLFW and Configuration.GLFW_CHECK_THREAD0 is set to false."
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
private OffScreen() {
|
||||
}
|
||||
|
||||
static void check() {
|
||||
// intentionally empty to trigger the static initializer
|
||||
}
|
||||
}
|
||||
|
||||
static final class OnScreen {
|
||||
static {
|
||||
if (Platform.get() == Platform.MACOSX && !isMainThread()) {
|
||||
throw new IllegalStateException(
|
||||
"Please run the JVM with -XstartOnFirstThread and make sure a window toolkit other than GLFW (e.g. AWT or JavaFX) is not initialized."
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
private OnScreen() {
|
||||
}
|
||||
|
||||
static void check() {
|
||||
// intentionally empty to trigger the static initializer
|
||||
}
|
||||
}
|
||||
|
||||
private EventLoop() {
|
||||
}
|
||||
|
||||
private static boolean isMainThread() {
|
||||
if (!Configuration.GLFW_CHECK_THREAD0.get(true)) {
|
||||
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()));
|
||||
}
|
||||
|
||||
}
|
||||
@ -623,6 +623,7 @@ public class GLFW
|
||||
//DetachOnCurrentThread = apiGetFunctionAddress(GLFW, "pojavDetachOnCurrentThread"),
|
||||
MakeContextCurrent = apiGetFunctionAddress(GLFW, "pojavMakeCurrent"),
|
||||
Terminate = apiGetFunctionAddress(GLFW, "pojavTerminate"),
|
||||
SetWindowHint = apiGetFunctionAddress(GLFW, "pojavSetWindowHint"),
|
||||
SwapBuffers = apiGetFunctionAddress(GLFW, "pojavSwapBuffers"),
|
||||
SwapInterval = apiGetFunctionAddress(GLFW, "pojavSwapInterval"),
|
||||
PumpEvents = apiGetFunctionAddress(GLFW, "pojavPumpEvents"),
|
||||
@ -990,7 +991,6 @@ public class GLFW
|
||||
return invokePP(share, Functions.CreateContext);
|
||||
}
|
||||
public static long glfwCreateWindow(int width, int height, CharSequence title, long monitor, long share) {
|
||||
EventLoop.OffScreen.check();
|
||||
// Create an ACTUAL EGL context
|
||||
long ptr = nglfwCreateContext(share);
|
||||
//nativeEglMakeCurrent(ptr);
|
||||
@ -1045,7 +1045,12 @@ public class GLFW
|
||||
public static void glfwShowWindow(long window) {
|
||||
nglfwSetShowingWindow(window);
|
||||
}
|
||||
public static void glfwWindowHint(int hint, int value) {}
|
||||
|
||||
public static void glfwWindowHint(int hint, int value) {
|
||||
long __functionAddress = Functions.SetWindowHint;
|
||||
invokeV(hint, value, __functionAddress);
|
||||
}
|
||||
|
||||
public static void glfwWindowHintString(int hint, @NativeType("const char *") ByteBuffer value) {}
|
||||
public static void glfwWindowHintString(int hint, @NativeType("const char *") CharSequence value) {}
|
||||
|
||||
|
||||
@ -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 (*) (
|
||||
* 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(SIGNATURE);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,50 +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.dyncall.DynCallback.*;
|
||||
|
||||
/**
|
||||
* Instances of this interface may be passed to the {@link GLFW#glfwSetCharCallback SetCharCallback} method.
|
||||
*
|
||||
* <h3>Type</h3>
|
||||
*
|
||||
* <pre><code>
|
||||
* void (*) (
|
||||
* GLFWwindow *window,
|
||||
* unsigned int codepoint
|
||||
* )</code></pre>
|
||||
*
|
||||
* @since version 2.4
|
||||
*/
|
||||
@FunctionalInterface
|
||||
@NativeType("GLFWcharfun")
|
||||
public interface GLFWCharCallbackI extends CallbackI.V {
|
||||
|
||||
String SIGNATURE = "(pi)v";
|
||||
|
||||
@Override
|
||||
default String getSignature() { return SIGNATURE; }
|
||||
|
||||
@Override
|
||||
default void callback(long args) {
|
||||
invoke(
|
||||
dcbArgPointer(args),
|
||||
dcbArgInt(args)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
}
|
||||
@ -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 (*) (
|
||||
* 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(SIGNATURE);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -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 static org.lwjgl.system.dyncall.DynCallback.*;
|
||||
|
||||
/**
|
||||
* 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 (*) (
|
||||
* GLFWwindow *window,
|
||||
* unsigned int codepoint,
|
||||
* int mods
|
||||
* )</code></pre>
|
||||
*
|
||||
* @since version 3.1
|
||||
*/
|
||||
@FunctionalInterface
|
||||
@NativeType("GLFWcharmodsfun")
|
||||
public interface GLFWCharModsCallbackI extends CallbackI.V {
|
||||
|
||||
String SIGNATURE = "(pii)v";
|
||||
|
||||
@Override
|
||||
default String getSignature() { return SIGNATURE; }
|
||||
|
||||
@Override
|
||||
default void callback(long args) {
|
||||
invoke(
|
||||
dcbArgPointer(args),
|
||||
dcbArgInt(args),
|
||||
dcbArgInt(args)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
}
|
||||
@ -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 (*) (
|
||||
* 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(SIGNATURE);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,50 +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.dyncall.DynCallback.*;
|
||||
|
||||
/**
|
||||
* Instances of this interface may be passed to the {@link GLFW#glfwSetCursorEnterCallback SetCursorEnterCallback} method.
|
||||
*
|
||||
* <h3>Type</h3>
|
||||
*
|
||||
* <pre><code>
|
||||
* void (*) (
|
||||
* GLFWwindow *window,
|
||||
* int entered
|
||||
* )</code></pre>
|
||||
*
|
||||
* @since version 3.0
|
||||
*/
|
||||
@FunctionalInterface
|
||||
@NativeType("GLFWcursorenterfun")
|
||||
public interface GLFWCursorEnterCallbackI extends CallbackI.V {
|
||||
|
||||
String SIGNATURE = "(pi)v";
|
||||
|
||||
@Override
|
||||
default String getSignature() { return SIGNATURE; }
|
||||
|
||||
@Override
|
||||
default void callback(long args) {
|
||||
invoke(
|
||||
dcbArgPointer(args),
|
||||
dcbArgInt(args) != 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);
|
||||
|
||||
}
|
||||
@ -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 (*) (
|
||||
* 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(SIGNATURE);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,56 +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.dyncall.DynCallback.*;
|
||||
|
||||
/**
|
||||
* Instances of this interface may be passed to the {@link GLFW#glfwSetCursorPosCallback SetCursorPosCallback} method.
|
||||
*
|
||||
* <h3>Type</h3>
|
||||
*
|
||||
* <pre><code>
|
||||
* void (*) (
|
||||
* GLFWwindow *window,
|
||||
* double xpos,
|
||||
* double ypos
|
||||
* )</code></pre>
|
||||
*
|
||||
* @since version 3.0
|
||||
*/
|
||||
@FunctionalInterface
|
||||
@NativeType("GLFWcursorposfun")
|
||||
public interface GLFWCursorPosCallbackI extends CallbackI.V {
|
||||
|
||||
String SIGNATURE = "(pdd)v";
|
||||
|
||||
@Override
|
||||
default String getSignature() { return SIGNATURE; }
|
||||
|
||||
@Override
|
||||
default void callback(long args) {
|
||||
invoke(
|
||||
dcbArgPointer(args),
|
||||
dcbArgDouble(args),
|
||||
dcbArgDouble(args)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
}
|
||||
@ -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 (*) (
|
||||
* 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(SIGNATURE);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,53 +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.dyncall.DynCallback.*;
|
||||
|
||||
/**
|
||||
* Instances of this interface may be passed to the {@link GLFW#glfwSetDropCallback SetDropCallback} method.
|
||||
*
|
||||
* <h3>Type</h3>
|
||||
*
|
||||
* <pre><code>
|
||||
* void (*) (
|
||||
* GLFWwindow *window,
|
||||
* int count,
|
||||
* char const **names
|
||||
* )</code></pre>
|
||||
*
|
||||
* @since version 3.1
|
||||
*/
|
||||
@FunctionalInterface
|
||||
@NativeType("GLFWdropfun")
|
||||
public interface GLFWDropCallbackI extends CallbackI.V {
|
||||
|
||||
String SIGNATURE = "(pip)v";
|
||||
|
||||
@Override
|
||||
default String getSignature() { return SIGNATURE; }
|
||||
|
||||
@Override
|
||||
default void callback(long args) {
|
||||
invoke(
|
||||
dcbArgPointer(args),
|
||||
dcbArgInt(args),
|
||||
dcbArgPointer(args)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
}
|
||||
@ -1,156 +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 (*) (
|
||||
* 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(SIGNATURE);
|
||||
}
|
||||
|
||||
GLFWErrorCallback(long functionPointer) {
|
||||
super(functionPointer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the specified {@link 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) {
|
||||
try {
|
||||
return memUTF8(description);
|
||||
} catch (NullPointerException e) {
|
||||
return "null (unknown " + Long.toHexString(description) + ")";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a {@link 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 {@link 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);
|
||||
|
||||
stream.printf("[LWJGL] %s error\n", ERROR_CODES.get(error));
|
||||
stream.println("\tDescription : " + msg);
|
||||
stream.println("\tStacktrace :");
|
||||
StackTraceElement[] stack = Thread.currentThread().getStackTrace();
|
||||
for ( int i = 4; i < stack.length; i++ ) {
|
||||
stream.print("\t\t");
|
||||
stream.println(stack[i].toString());
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a {@link 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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,50 +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.dyncall.DynCallback.*;
|
||||
|
||||
/**
|
||||
* Instances of this interface may be passed to the {@link GLFW#glfwSetErrorCallback SetErrorCallback} method.
|
||||
*
|
||||
* <h3>Type</h3>
|
||||
*
|
||||
* <pre><code>
|
||||
* void (*) (
|
||||
* int error,
|
||||
* char *description
|
||||
* )</code></pre>
|
||||
*
|
||||
* @since version 3.0
|
||||
*/
|
||||
@FunctionalInterface
|
||||
@NativeType("GLFWerrorfun")
|
||||
public interface GLFWErrorCallbackI extends CallbackI.V {
|
||||
|
||||
String SIGNATURE = "(ip)v";
|
||||
|
||||
@Override
|
||||
default String getSignature() { return SIGNATURE; }
|
||||
|
||||
@Override
|
||||
default void callback(long args) {
|
||||
invoke(
|
||||
dcbArgInt(args),
|
||||
dcbArgPointer(args)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
}
|
||||
@ -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 (*) (
|
||||
* 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(SIGNATURE);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,53 +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.dyncall.DynCallback.*;
|
||||
|
||||
/**
|
||||
* Instances of this interface may be passed to the {@link GLFW#glfwSetFramebufferSizeCallback SetFramebufferSizeCallback} method.
|
||||
*
|
||||
* <h3>Type</h3>
|
||||
*
|
||||
* <pre><code>
|
||||
* void (*) (
|
||||
* GLFWwindow *window,
|
||||
* int width,
|
||||
* int height
|
||||
* )</code></pre>
|
||||
*
|
||||
* @since version 3.0
|
||||
*/
|
||||
@FunctionalInterface
|
||||
@NativeType("GLFWframebuffersizefun")
|
||||
public interface GLFWFramebufferSizeCallbackI extends CallbackI.V {
|
||||
|
||||
String SIGNATURE = "(pii)v";
|
||||
|
||||
@Override
|
||||
default String getSignature() { return SIGNATURE; }
|
||||
|
||||
@Override
|
||||
default void callback(long args) {
|
||||
invoke(
|
||||
dcbArgPointer(args),
|
||||
dcbArgInt(args),
|
||||
dcbArgInt(args)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
}
|
||||
@ -1,359 +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>Member documentation</h3>
|
||||
*
|
||||
* <ul>
|
||||
* <li>{@code buttons[15]} – the states of each gamepad button, {@link GLFW#GLFW_PRESS PRESS} or {@link GLFW#GLFW_RELEASE RELEASE}</li>
|
||||
* <li>{@code axes[6]} – the states of each gamepad axis, in the range -1.0 to 1.0 inclusive</li>
|
||||
* </ul>
|
||||
*
|
||||
* <h3>Layout</h3>
|
||||
*
|
||||
* <pre><code>
|
||||
* struct GLFWgamepadstate {
|
||||
* unsigned char buttons[15];
|
||||
* float axes[6];
|
||||
* }</code></pre>
|
||||
*
|
||||
* @since version 3.3
|
||||
*/
|
||||
@NativeType("struct GLFWgamepadstate")
|
||||
public class GLFWGamepadState extends Struct implements NativeResource {
|
||||
|
||||
/** The struct size in bytes. */
|
||||
public static final int SIZEOF;
|
||||
|
||||
/** The struct alignment in bytes. */
|
||||
public static final int ALIGNOF;
|
||||
|
||||
/** The struct member offsets. */
|
||||
public static final int
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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; }
|
||||
|
||||
/** Returns a {@link ByteBuffer} view of the {@code buttons} field. */
|
||||
@NativeType("unsigned char[15]")
|
||||
public ByteBuffer buttons() { return nbuttons(address()); }
|
||||
/** Returns the value at the specified index of the {@code buttons} field. */
|
||||
@NativeType("unsigned char")
|
||||
public byte buttons(int index) { return nbuttons(address(), index); }
|
||||
/** Returns a {@link FloatBuffer} view of the {@code axes} field. */
|
||||
@NativeType("float[6]")
|
||||
public FloatBuffer axes() { return naxes(address()); }
|
||||
/** Returns the value at the specified index of the {@code axes} field. */
|
||||
public float axes(int index) { return naxes(address(), index); }
|
||||
|
||||
/** Copies the specified {@link ByteBuffer} to the {@code 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 {@code 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 {@code 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 {@code 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 wrap(GLFWGamepadState.class, nmemAllocChecked(SIZEOF));
|
||||
}
|
||||
|
||||
/** Returns a new {@code GLFWGamepadState} instance allocated with {@link MemoryUtil#memCalloc memCalloc}. The instance must be explicitly freed. */
|
||||
public static GLFWGamepadState calloc() {
|
||||
return wrap(GLFWGamepadState.class, nmemCallocChecked(1, SIZEOF));
|
||||
}
|
||||
|
||||
/** Returns a new {@code GLFWGamepadState} instance allocated with {@link BufferUtils}. */
|
||||
public static GLFWGamepadState create() {
|
||||
ByteBuffer container = BufferUtils.createByteBuffer(SIZEOF);
|
||||
return wrap(GLFWGamepadState.class, memAddress(container), container);
|
||||
}
|
||||
|
||||
/** Returns a new {@code GLFWGamepadState} instance for the specified memory address. */
|
||||
public static GLFWGamepadState create(long address) {
|
||||
return wrap(GLFWGamepadState.class, address);
|
||||
}
|
||||
|
||||
/** 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 : wrap(GLFWGamepadState.class, address);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new {@link GLFWGamepadState.Buffer} instance allocated with {@link MemoryUtil#memAlloc memAlloc}. The instance must be explicitly freed.
|
||||
*
|
||||
* @param capacity the buffer capacity
|
||||
*/
|
||||
public static GLFWGamepadState.Buffer malloc(int capacity) {
|
||||
return wrap(Buffer.class, nmemAllocChecked(__checkMalloc(capacity, SIZEOF)), capacity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new {@link GLFWGamepadState.Buffer} instance allocated with {@link MemoryUtil#memCalloc memCalloc}. The instance must be explicitly freed.
|
||||
*
|
||||
* @param capacity the buffer capacity
|
||||
*/
|
||||
public static GLFWGamepadState.Buffer calloc(int capacity) {
|
||||
return wrap(Buffer.class, nmemCallocChecked(capacity, SIZEOF), capacity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new {@link GLFWGamepadState.Buffer} instance allocated with {@link BufferUtils}.
|
||||
*
|
||||
* @param capacity the buffer capacity
|
||||
*/
|
||||
public static GLFWGamepadState.Buffer create(int capacity) {
|
||||
ByteBuffer container = __create(capacity, SIZEOF);
|
||||
return wrap(Buffer.class, memAddress(container), capacity, container);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a {@link GLFWGamepadState.Buffer} instance at the specified memory.
|
||||
*
|
||||
* @param address the memory address
|
||||
* @param capacity the buffer capacity
|
||||
*/
|
||||
public static GLFWGamepadState.Buffer create(long address, int capacity) {
|
||||
return wrap(Buffer.class, address, capacity);
|
||||
}
|
||||
|
||||
/** Like {@link #create(long, int) create}, but returns {@code null} if {@code address} is {@code NULL}. */
|
||||
@Nullable
|
||||
public static GLFWGamepadState.Buffer createSafe(long address, int capacity) {
|
||||
return address == NULL ? null : wrap(Buffer.class, address, capacity);
|
||||
}
|
||||
|
||||
// -----------------------------------
|
||||
|
||||
/** Returns a new {@code GLFWGamepadState} instance allocated on the thread-local {@link MemoryStack}. */
|
||||
public static GLFWGamepadState mallocStack() {
|
||||
return mallocStack(stackGet());
|
||||
}
|
||||
|
||||
/** Returns a new {@code GLFWGamepadState} instance allocated on the thread-local {@link MemoryStack} and initializes all its bits to zero. */
|
||||
public static GLFWGamepadState callocStack() {
|
||||
return callocStack(stackGet());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new {@code GLFWGamepadState} instance allocated on the specified {@link MemoryStack}.
|
||||
*
|
||||
* @param stack the stack from which to allocate
|
||||
*/
|
||||
public static GLFWGamepadState mallocStack(MemoryStack stack) {
|
||||
return wrap(GLFWGamepadState.class, stack.nmalloc(ALIGNOF, SIZEOF));
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 callocStack(MemoryStack stack) {
|
||||
return wrap(GLFWGamepadState.class, stack.ncalloc(ALIGNOF, 1, SIZEOF));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new {@link GLFWGamepadState.Buffer} instance allocated on the thread-local {@link MemoryStack}.
|
||||
*
|
||||
* @param capacity the buffer capacity
|
||||
*/
|
||||
public static GLFWGamepadState.Buffer mallocStack(int capacity) {
|
||||
return mallocStack(capacity, stackGet());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new {@link GLFWGamepadState.Buffer} instance allocated on the thread-local {@link MemoryStack} and initializes all its bits to zero.
|
||||
*
|
||||
* @param capacity the buffer capacity
|
||||
*/
|
||||
public static GLFWGamepadState.Buffer callocStack(int capacity) {
|
||||
return callocStack(capacity, stackGet());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new {@link GLFWGamepadState.Buffer} instance allocated on the specified {@link MemoryStack}.
|
||||
*
|
||||
* @param stack the stack from which to allocate
|
||||
* @param capacity the buffer capacity
|
||||
*/
|
||||
public static GLFWGamepadState.Buffer mallocStack(int capacity, MemoryStack stack) {
|
||||
return wrap(Buffer.class, stack.nmalloc(ALIGNOF, capacity * SIZEOF), capacity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new {@link GLFWGamepadState.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 GLFWGamepadState.Buffer callocStack(int capacity, MemoryStack stack) {
|
||||
return wrap(Buffer.class, 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.
|
||||
*
|
||||
* 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>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;
|
||||
}
|
||||
|
||||
/** Returns a {@link ByteBuffer} view of the {@code buttons} field. */
|
||||
@NativeType("unsigned char[15]")
|
||||
public ByteBuffer buttons() { return GLFWGamepadState.nbuttons(address()); }
|
||||
/** Returns the value at the specified index of the {@code buttons} field. */
|
||||
@NativeType("unsigned char")
|
||||
public byte buttons(int index) { return GLFWGamepadState.nbuttons(address(), index); }
|
||||
/** Returns a {@link FloatBuffer} view of the {@code axes} field. */
|
||||
@NativeType("float[6]")
|
||||
public FloatBuffer axes() { return GLFWGamepadState.naxes(address()); }
|
||||
/** Returns the value at the specified index of the {@code axes} field. */
|
||||
public float axes(int index) { return GLFWGamepadState.naxes(address(), index); }
|
||||
|
||||
/** Copies the specified {@link ByteBuffer} to the {@code buttons} field. */
|
||||
public GLFWGamepadState.Buffer buttons(@NativeType("unsigned char[15]") ByteBuffer value) { GLFWGamepadState.nbuttons(address(), value); return this; }
|
||||
/** Sets the specified value at the specified index of the {@code buttons} field. */
|
||||
public GLFWGamepadState.Buffer buttons(int index, @NativeType("unsigned char") byte value) { GLFWGamepadState.nbuttons(address(), index, value); return this; }
|
||||
/** Copies the specified {@link FloatBuffer} to the {@code axes} field. */
|
||||
public GLFWGamepadState.Buffer axes(@NativeType("float[6]") FloatBuffer value) { GLFWGamepadState.naxes(address(), value); return this; }
|
||||
/** Sets the specified value at the specified index of the {@code axes} field. */
|
||||
public GLFWGamepadState.Buffer axes(int index, float value) { GLFWGamepadState.naxes(address(), index, value); return this; }
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,384 +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>Member documentation</h3>
|
||||
*
|
||||
* <ul>
|
||||
* <li>{@code red} – an array of values describing the response of the red channel</li>
|
||||
* <li>{@code green} – an array of values describing the response of the green channel</li>
|
||||
* <li>{@code blue} – an array of values describing the response of the blue channel</li>
|
||||
* <li>{@code size} – the number of elements in each array</li>
|
||||
* </ul>
|
||||
*
|
||||
* <h3>Layout</h3>
|
||||
*
|
||||
* <pre><code>
|
||||
* struct GLFWgammaramp {
|
||||
* unsigned short * red;
|
||||
* unsigned short * green;
|
||||
* unsigned short * blue;
|
||||
* unsigned int size;
|
||||
* }</code></pre>
|
||||
*
|
||||
* @since version 3.0
|
||||
*/
|
||||
@NativeType("struct GLFWgammaramp")
|
||||
public class GLFWGammaRamp extends Struct implements NativeResource {
|
||||
|
||||
/** The struct size in bytes. */
|
||||
public static final int SIZEOF;
|
||||
|
||||
/** The struct alignment in bytes. */
|
||||
public static final int ALIGNOF;
|
||||
|
||||
/** The struct member offsets. */
|
||||
public static final int
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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; }
|
||||
|
||||
/** Returns a {@link ShortBuffer} view of the data pointed to by the {@code red} field. */
|
||||
@NativeType("unsigned short *")
|
||||
public ShortBuffer red() { return nred(address()); }
|
||||
/** Returns a {@link ShortBuffer} view of the data pointed to by the {@code green} field. */
|
||||
@NativeType("unsigned short *")
|
||||
public ShortBuffer green() { return ngreen(address()); }
|
||||
/** Returns a {@link ShortBuffer} view of the data pointed to by the {@code blue} field. */
|
||||
@NativeType("unsigned short *")
|
||||
public ShortBuffer blue() { return nblue(address()); }
|
||||
/** Returns the value of the {@code size} field. */
|
||||
@NativeType("unsigned int")
|
||||
public int size() { return nsize(address()); }
|
||||
|
||||
/** Sets the address of the specified {@link ShortBuffer} to the {@code 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 {@code 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 {@code blue} field. */
|
||||
public GLFWGammaRamp blue(@NativeType("unsigned short *") ShortBuffer value) { nblue(address(), value); return this; }
|
||||
/** Sets the specified value to the {@code 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 wrap(GLFWGammaRamp.class, nmemAllocChecked(SIZEOF));
|
||||
}
|
||||
|
||||
/** Returns a new {@code GLFWGammaRamp} instance allocated with {@link MemoryUtil#memCalloc memCalloc}. The instance must be explicitly freed. */
|
||||
public static GLFWGammaRamp calloc() {
|
||||
return wrap(GLFWGammaRamp.class, nmemCallocChecked(1, SIZEOF));
|
||||
}
|
||||
|
||||
/** Returns a new {@code GLFWGammaRamp} instance allocated with {@link BufferUtils}. */
|
||||
public static GLFWGammaRamp create() {
|
||||
ByteBuffer container = BufferUtils.createByteBuffer(SIZEOF);
|
||||
return wrap(GLFWGammaRamp.class, memAddress(container), container);
|
||||
}
|
||||
|
||||
/** Returns a new {@code GLFWGammaRamp} instance for the specified memory address. */
|
||||
public static GLFWGammaRamp create(long address) {
|
||||
return wrap(GLFWGammaRamp.class, address);
|
||||
}
|
||||
|
||||
/** 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 : wrap(GLFWGammaRamp.class, address);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new {@link GLFWGammaRamp.Buffer} instance allocated with {@link MemoryUtil#memAlloc memAlloc}. The instance must be explicitly freed.
|
||||
*
|
||||
* @param capacity the buffer capacity
|
||||
*/
|
||||
public static GLFWGammaRamp.Buffer malloc(int capacity) {
|
||||
return wrap(Buffer.class, nmemAllocChecked(__checkMalloc(capacity, SIZEOF)), capacity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new {@link GLFWGammaRamp.Buffer} instance allocated with {@link MemoryUtil#memCalloc memCalloc}. The instance must be explicitly freed.
|
||||
*
|
||||
* @param capacity the buffer capacity
|
||||
*/
|
||||
public static GLFWGammaRamp.Buffer calloc(int capacity) {
|
||||
return wrap(Buffer.class, nmemCallocChecked(capacity, SIZEOF), capacity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new {@link GLFWGammaRamp.Buffer} instance allocated with {@link BufferUtils}.
|
||||
*
|
||||
* @param capacity the buffer capacity
|
||||
*/
|
||||
public static GLFWGammaRamp.Buffer create(int capacity) {
|
||||
ByteBuffer container = __create(capacity, SIZEOF);
|
||||
return wrap(Buffer.class, memAddress(container), capacity, container);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a {@link GLFWGammaRamp.Buffer} instance at the specified memory.
|
||||
*
|
||||
* @param address the memory address
|
||||
* @param capacity the buffer capacity
|
||||
*/
|
||||
public static GLFWGammaRamp.Buffer create(long address, int capacity) {
|
||||
return wrap(Buffer.class, address, capacity);
|
||||
}
|
||||
|
||||
/** Like {@link #create(long, int) create}, but returns {@code null} if {@code address} is {@code NULL}. */
|
||||
@Nullable
|
||||
public static GLFWGammaRamp.Buffer createSafe(long address, int capacity) {
|
||||
return address == NULL ? null : wrap(Buffer.class, address, capacity);
|
||||
}
|
||||
|
||||
// -----------------------------------
|
||||
|
||||
/** Returns a new {@code GLFWGammaRamp} instance allocated on the thread-local {@link MemoryStack}. */
|
||||
public static GLFWGammaRamp mallocStack() {
|
||||
return mallocStack(stackGet());
|
||||
}
|
||||
|
||||
/** Returns a new {@code GLFWGammaRamp} instance allocated on the thread-local {@link MemoryStack} and initializes all its bits to zero. */
|
||||
public static GLFWGammaRamp callocStack() {
|
||||
return callocStack(stackGet());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new {@code GLFWGammaRamp} instance allocated on the specified {@link MemoryStack}.
|
||||
*
|
||||
* @param stack the stack from which to allocate
|
||||
*/
|
||||
public static GLFWGammaRamp mallocStack(MemoryStack stack) {
|
||||
return wrap(GLFWGammaRamp.class, stack.nmalloc(ALIGNOF, SIZEOF));
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 callocStack(MemoryStack stack) {
|
||||
return wrap(GLFWGammaRamp.class, stack.ncalloc(ALIGNOF, 1, SIZEOF));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new {@link GLFWGammaRamp.Buffer} instance allocated on the thread-local {@link MemoryStack}.
|
||||
*
|
||||
* @param capacity the buffer capacity
|
||||
*/
|
||||
public static GLFWGammaRamp.Buffer mallocStack(int capacity) {
|
||||
return mallocStack(capacity, stackGet());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new {@link GLFWGammaRamp.Buffer} instance allocated on the thread-local {@link MemoryStack} and initializes all its bits to zero.
|
||||
*
|
||||
* @param capacity the buffer capacity
|
||||
*/
|
||||
public static GLFWGammaRamp.Buffer callocStack(int capacity) {
|
||||
return callocStack(capacity, stackGet());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new {@link GLFWGammaRamp.Buffer} instance allocated on the specified {@link MemoryStack}.
|
||||
*
|
||||
* @param stack the stack from which to allocate
|
||||
* @param capacity the buffer capacity
|
||||
*/
|
||||
public static GLFWGammaRamp.Buffer mallocStack(int capacity, MemoryStack stack) {
|
||||
return wrap(Buffer.class, stack.nmalloc(ALIGNOF, capacity * SIZEOF), capacity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new {@link GLFWGammaRamp.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 GLFWGammaRamp.Buffer callocStack(int capacity, MemoryStack stack) {
|
||||
return wrap(Buffer.class, 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));
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls {@link #validate(long)} for each struct contained in the specified struct array.
|
||||
*
|
||||
* @param array the struct array to validate
|
||||
* @param count the number of structs in {@code array}
|
||||
*/
|
||||
public static void validate(long array, int count) {
|
||||
for (int i = 0; i < count; i++) {
|
||||
validate(array + Integer.toUnsignedLong(i) * SIZEOF);
|
||||
}
|
||||
}
|
||||
|
||||
// -----------------------------------
|
||||
|
||||
/** 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.
|
||||
*
|
||||
* 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>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;
|
||||
}
|
||||
|
||||
/** Returns a {@link ShortBuffer} view of the data pointed to by the {@code red} field. */
|
||||
@NativeType("unsigned short *")
|
||||
public ShortBuffer red() { return GLFWGammaRamp.nred(address()); }
|
||||
/** Returns a {@link ShortBuffer} view of the data pointed to by the {@code green} field. */
|
||||
@NativeType("unsigned short *")
|
||||
public ShortBuffer green() { return GLFWGammaRamp.ngreen(address()); }
|
||||
/** Returns a {@link ShortBuffer} view of the data pointed to by the {@code blue} field. */
|
||||
@NativeType("unsigned short *")
|
||||
public ShortBuffer blue() { return GLFWGammaRamp.nblue(address()); }
|
||||
/** Returns the value of the {@code size} field. */
|
||||
@NativeType("unsigned int")
|
||||
public int size() { return GLFWGammaRamp.nsize(address()); }
|
||||
|
||||
/** Sets the address of the specified {@link ShortBuffer} to the {@code red} field. */
|
||||
public GLFWGammaRamp.Buffer red(@NativeType("unsigned short *") ShortBuffer value) { GLFWGammaRamp.nred(address(), value); return this; }
|
||||
/** Sets the address of the specified {@link ShortBuffer} to the {@code green} field. */
|
||||
public GLFWGammaRamp.Buffer green(@NativeType("unsigned short *") ShortBuffer value) { GLFWGammaRamp.ngreen(address(), value); return this; }
|
||||
/** Sets the address of the specified {@link ShortBuffer} to the {@code blue} field. */
|
||||
public GLFWGammaRamp.Buffer blue(@NativeType("unsigned short *") ShortBuffer value) { GLFWGammaRamp.nblue(address(), value); return this; }
|
||||
/** Sets the specified value to the {@code size} field. */
|
||||
public GLFWGammaRamp.Buffer size(@NativeType("unsigned int") int value) { GLFWGammaRamp.nsize(address(), value); return this; }
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,404 +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>Member documentation</h3>
|
||||
*
|
||||
* <ul>
|
||||
* <li>{@code width} – the width, in pixels, of this image</li>
|
||||
* <li>{@code height} – the height, in pixels, of this image</li>
|
||||
* <li>{@code pixels} – the pixel data of this image, arranged left-to-right, top-to-bottom</li>
|
||||
* </ul>
|
||||
*
|
||||
* <h3>Layout</h3>
|
||||
*
|
||||
* <pre><code>
|
||||
* struct GLFWimage {
|
||||
* int width;
|
||||
* int height;
|
||||
* unsigned char * pixels;
|
||||
* }</code></pre>
|
||||
*
|
||||
* @since version 2.1
|
||||
*/
|
||||
@NativeType("struct GLFWimage")
|
||||
public class GLFWImage extends Struct implements NativeResource {
|
||||
|
||||
/** The struct size in bytes. */
|
||||
public static final int SIZEOF;
|
||||
|
||||
/** The struct alignment in bytes. */
|
||||
public static final int ALIGNOF;
|
||||
|
||||
/** The struct member offsets. */
|
||||
public static final int
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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; }
|
||||
|
||||
/** Returns the value of the {@code width} field. */
|
||||
public int width() { return nwidth(address()); }
|
||||
/** Returns the value of the {@code height} field. */
|
||||
public int height() { return nheight(address()); }
|
||||
/**
|
||||
* Returns a {@link ByteBuffer} view of the data pointed to by the {@code pixels} field.
|
||||
*
|
||||
* @param capacity the number of elements in the returned buffer
|
||||
*/
|
||||
@NativeType("unsigned char *")
|
||||
public ByteBuffer pixels(int capacity) { return npixels(address(), capacity); }
|
||||
|
||||
/** Sets the specified value to the {@code width} field. */
|
||||
public GLFWImage width(int value) { nwidth(address(), value); return this; }
|
||||
/** Sets the specified value to the {@code height} field. */
|
||||
public GLFWImage height(int value) { nheight(address(), value); return this; }
|
||||
/** Sets the address of the specified {@link ByteBuffer} to the {@code 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 wrap(GLFWImage.class, nmemAllocChecked(SIZEOF));
|
||||
}
|
||||
|
||||
/** Returns a new {@code GLFWImage} instance allocated with {@link MemoryUtil#memCalloc memCalloc}. The instance must be explicitly freed. */
|
||||
public static GLFWImage calloc() {
|
||||
return wrap(GLFWImage.class, nmemCallocChecked(1, SIZEOF));
|
||||
}
|
||||
|
||||
/** Returns a new {@code GLFWImage} instance allocated with {@link BufferUtils}. */
|
||||
public static GLFWImage create() {
|
||||
ByteBuffer container = BufferUtils.createByteBuffer(SIZEOF);
|
||||
return wrap(GLFWImage.class, memAddress(container), container);
|
||||
}
|
||||
|
||||
/** Returns a new {@code GLFWImage} instance for the specified memory address. */
|
||||
public static GLFWImage create(long address) {
|
||||
return wrap(GLFWImage.class, address);
|
||||
}
|
||||
|
||||
/** 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 : wrap(GLFWImage.class, address);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new {@link GLFWImage.Buffer} instance allocated with {@link MemoryUtil#memAlloc memAlloc}. The instance must be explicitly freed.
|
||||
*
|
||||
* @param capacity the buffer capacity
|
||||
*/
|
||||
public static GLFWImage.Buffer malloc(int capacity) {
|
||||
return wrap(Buffer.class, nmemAllocChecked(__checkMalloc(capacity, SIZEOF)), capacity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new {@link GLFWImage.Buffer} instance allocated with {@link MemoryUtil#memCalloc memCalloc}. The instance must be explicitly freed.
|
||||
*
|
||||
* @param capacity the buffer capacity
|
||||
*/
|
||||
public static GLFWImage.Buffer calloc(int capacity) {
|
||||
return wrap(Buffer.class, nmemCallocChecked(capacity, SIZEOF), capacity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new {@link GLFWImage.Buffer} instance allocated with {@link BufferUtils}.
|
||||
*
|
||||
* @param capacity the buffer capacity
|
||||
*/
|
||||
public static GLFWImage.Buffer create(int capacity) {
|
||||
ByteBuffer container = __create(capacity, SIZEOF);
|
||||
return wrap(Buffer.class, memAddress(container), capacity, container);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a {@link GLFWImage.Buffer} instance at the specified memory.
|
||||
*
|
||||
* @param address the memory address
|
||||
* @param capacity the buffer capacity
|
||||
*/
|
||||
public static GLFWImage.Buffer create(long address, int capacity) {
|
||||
return wrap(Buffer.class, address, capacity);
|
||||
}
|
||||
|
||||
/** Like {@link #create(long, int) create}, but returns {@code null} if {@code address} is {@code NULL}. */
|
||||
@Nullable
|
||||
public static GLFWImage.Buffer createSafe(long address, int capacity) {
|
||||
return address == NULL ? null : wrap(Buffer.class, address, capacity);
|
||||
}
|
||||
/**
|
||||
* 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 wrap(GLFWImage.class, stack.nmalloc(ALIGNOF, SIZEOF));
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 wrap(GLFWImage.class, stack.ncalloc(ALIGNOF, 1, SIZEOF));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new {@link GLFWImage.Buffer} instance allocated on the specified {@link MemoryStack}.
|
||||
*
|
||||
* @param stack the stack from which to allocate
|
||||
* @param capacity the buffer capacity
|
||||
*/
|
||||
public static GLFWImage.Buffer malloc(int capacity, MemoryStack stack) {
|
||||
return wrap(Buffer.class, stack.nmalloc(ALIGNOF, capacity * SIZEOF), capacity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new {@link GLFWImage.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 GLFWImage.Buffer calloc(int capacity, MemoryStack stack) {
|
||||
return wrap(Buffer.class, stack.ncalloc(ALIGNOF, capacity, SIZEOF), capacity);
|
||||
}
|
||||
|
||||
// mallocStack() and callocStack() will be removed in 3.4.0. Keeping them here for compatibility.
|
||||
|
||||
/** Returns a new {@code GLFWImage} instance allocated on the thread-local {@link MemoryStack}. */
|
||||
public static GLFWImage mallocStack() {
|
||||
return mallocStack(stackGet());
|
||||
}
|
||||
|
||||
/** Returns a new {@code GLFWImage} instance allocated on the thread-local {@link MemoryStack} and initializes all its bits to zero. */
|
||||
public static GLFWImage callocStack() {
|
||||
return callocStack(stackGet());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new {@code GLFWImage} instance allocated on the specified {@link MemoryStack}.
|
||||
*
|
||||
* @param stack the stack from which to allocate
|
||||
*/
|
||||
public static GLFWImage mallocStack(MemoryStack stack) {
|
||||
return malloc(stack);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 callocStack(MemoryStack stack) {
|
||||
return calloc(stack);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new {@link GLFWImage.Buffer} instance allocated on the thread-local {@link MemoryStack}.
|
||||
*
|
||||
* @param capacity the buffer capacity
|
||||
*/
|
||||
public static GLFWImage.Buffer mallocStack(int capacity) {
|
||||
return mallocStack(capacity, stackGet());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new {@link GLFWImage.Buffer} instance allocated on the thread-local {@link MemoryStack} and initializes all its bits to zero.
|
||||
*
|
||||
* @param capacity the buffer capacity
|
||||
*/
|
||||
public static GLFWImage.Buffer callocStack(int capacity) {
|
||||
return callocStack(capacity, stackGet());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new {@link GLFWImage.Buffer} instance allocated on the specified {@link MemoryStack}.
|
||||
*
|
||||
* @param stack the stack from which to allocate
|
||||
* @param capacity the buffer capacity
|
||||
*/
|
||||
public static GLFWImage.Buffer mallocStack(int capacity, MemoryStack stack) {
|
||||
return malloc(capacity, stack);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new {@link GLFWImage.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 GLFWImage.Buffer callocStack(int capacity, MemoryStack stack) {
|
||||
return calloc(capacity, stack);
|
||||
}
|
||||
|
||||
// -----------------------------------
|
||||
|
||||
/** 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));
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls {@link #validate(long)} for each struct contained in the specified struct array.
|
||||
*
|
||||
* @param array the struct array to validate
|
||||
* @param count the number of structs in {@code array}
|
||||
*/
|
||||
public static void validate(long array, int count) {
|
||||
for (int i = 0; i < count; i++) {
|
||||
validate(array + Integer.toUnsignedLong(i) * SIZEOF);
|
||||
}
|
||||
}
|
||||
|
||||
// -----------------------------------
|
||||
|
||||
/** 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.
|
||||
*
|
||||
* 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>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;
|
||||
}
|
||||
|
||||
/** Returns the value of the {@code width} field. */
|
||||
public int width() { return GLFWImage.nwidth(address()); }
|
||||
/** Returns the value of the {@code height} field. */
|
||||
public int height() { return GLFWImage.nheight(address()); }
|
||||
/**
|
||||
* Returns a {@link ByteBuffer} view of the data pointed to by the {@code 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 {@code width} field. */
|
||||
public GLFWImage.Buffer width(int value) { GLFWImage.nwidth(address(), value); return this; }
|
||||
/** Sets the specified value to the {@code height} field. */
|
||||
public GLFWImage.Buffer height(int value) { GLFWImage.nheight(address(), value); return this; }
|
||||
/** Sets the address of the specified {@link ByteBuffer} to the {@code pixels} field. */
|
||||
public GLFWImage.Buffer pixels(@NativeType("unsigned char *") ByteBuffer value) { GLFWImage.npixels(address(), value); return this; }
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -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 (*) (
|
||||
* 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(SIGNATURE);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,50 +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.dyncall.DynCallback.*;
|
||||
|
||||
/**
|
||||
* Instances of this interface may be passed to the {@link GLFW#glfwSetJoystickCallback SetJoystickCallback} method.
|
||||
*
|
||||
* <h3>Type</h3>
|
||||
*
|
||||
* <pre><code>
|
||||
* void (*) (
|
||||
* int jid,
|
||||
* int event
|
||||
* )</code></pre>
|
||||
*
|
||||
* @since version 3.2
|
||||
*/
|
||||
@FunctionalInterface
|
||||
@NativeType("GLFWjoystickfun")
|
||||
public interface GLFWJoystickCallbackI extends CallbackI.V {
|
||||
|
||||
String SIGNATURE = "(ii)v";
|
||||
|
||||
@Override
|
||||
default String getSignature() { return SIGNATURE; }
|
||||
|
||||
@Override
|
||||
default void callback(long args) {
|
||||
invoke(
|
||||
dcbArgInt(args),
|
||||
dcbArgInt(args)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
}
|
||||
@ -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 (*) (
|
||||
* 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(SIGNATURE);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -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 static org.lwjgl.system.dyncall.DynCallback.*;
|
||||
|
||||
/**
|
||||
* Instances of this interface may be passed to the {@link GLFW#glfwSetKeyCallback SetKeyCallback} method.
|
||||
*
|
||||
* <h3>Type</h3>
|
||||
*
|
||||
* <pre><code>
|
||||
* void (*) (
|
||||
* GLFWwindow *window,
|
||||
* int key,
|
||||
* int scancode,
|
||||
* int action,
|
||||
* int mods
|
||||
* )</code></pre>
|
||||
*/
|
||||
@FunctionalInterface
|
||||
@NativeType("GLFWkeyfun")
|
||||
public interface GLFWKeyCallbackI extends CallbackI.V {
|
||||
|
||||
String SIGNATURE = "(piiii)v";
|
||||
|
||||
@Override
|
||||
default String getSignature() { return SIGNATURE; }
|
||||
|
||||
@Override
|
||||
default void callback(long args) {
|
||||
invoke(
|
||||
dcbArgPointer(args),
|
||||
dcbArgInt(args),
|
||||
dcbArgInt(args),
|
||||
dcbArgInt(args),
|
||||
dcbArgInt(args)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 system-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);
|
||||
|
||||
}
|
||||
@ -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 (*) (
|
||||
* 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(SIGNATURE);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,50 +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.dyncall.DynCallback.*;
|
||||
|
||||
/**
|
||||
* Instances of this interface may be passed to the {@link GLFW#glfwSetMonitorCallback SetMonitorCallback} method.
|
||||
*
|
||||
* <h3>Type</h3>
|
||||
*
|
||||
* <pre><code>
|
||||
* void (*) (
|
||||
* GLFWmonitor *monitor,
|
||||
* int event
|
||||
* )</code></pre>
|
||||
*
|
||||
* @since version 3.0
|
||||
*/
|
||||
@FunctionalInterface
|
||||
@NativeType("GLFWmonitorfun")
|
||||
public interface GLFWMonitorCallbackI extends CallbackI.V {
|
||||
|
||||
String SIGNATURE = "(pi)v";
|
||||
|
||||
@Override
|
||||
default String getSignature() { return SIGNATURE; }
|
||||
|
||||
@Override
|
||||
default void callback(long args) {
|
||||
invoke(
|
||||
dcbArgPointer(args),
|
||||
dcbArgInt(args)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
}
|
||||
@ -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 (*) (
|
||||
* 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(SIGNATURE);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -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 static org.lwjgl.system.dyncall.DynCallback.*;
|
||||
|
||||
/**
|
||||
* Instances of this interface may be passed to the {@link GLFW#glfwSetMouseButtonCallback SetMouseButtonCallback} method.
|
||||
*
|
||||
* <h3>Type</h3>
|
||||
*
|
||||
* <pre><code>
|
||||
* void (*) (
|
||||
* GLFWwindow *window,
|
||||
* int button,
|
||||
* int action,
|
||||
* int mods
|
||||
* )</code></pre>
|
||||
*/
|
||||
@FunctionalInterface
|
||||
@NativeType("GLFWmousebuttonfun")
|
||||
public interface GLFWMouseButtonCallbackI extends CallbackI.V {
|
||||
|
||||
String SIGNATURE = "(piii)v";
|
||||
|
||||
@Override
|
||||
default String getSignature() { return SIGNATURE; }
|
||||
|
||||
@Override
|
||||
default void callback(long args) {
|
||||
invoke(
|
||||
dcbArgPointer(args),
|
||||
dcbArgInt(args),
|
||||
dcbArgInt(args),
|
||||
dcbArgInt(args)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
}
|
||||
@ -1,125 +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 {
|
||||
|
||||
protected GLFWNativeGLX() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/** 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");
|
||||
|
||||
}
|
||||
|
||||
// --- [ 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.
|
||||
*
|
||||
* @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.
|
||||
*
|
||||
* @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);
|
||||
}
|
||||
|
||||
/** Calls {@link #setPath(String)} with the path of the OpenGL shared library loaded by LWJGL. */
|
||||
public static void setPathLWJGL() {
|
||||
FunctionProvider fp = GL.getFunctionProvider();
|
||||
if (!(fp instanceof SharedLibrary)) {
|
||||
apiLog("GLFW OpenGL path override not set: OpenGL function provider is not a shared library.");
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
String path = ((SharedLibrary)fp).getPath();
|
||||
if (path == null) {
|
||||
apiLog("GLFW OpenGL path override not set: Could not resolve the OpenGL 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)));
|
||||
}
|
||||
|
||||
}
|
||||
@ -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 (*) (
|
||||
* 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(SIGNATURE);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,53 +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.dyncall.DynCallback.*;
|
||||
|
||||
/**
|
||||
* Instances of this interface may be passed to the {@link GLFW#glfwSetScrollCallback SetScrollCallback} method.
|
||||
*
|
||||
* <h3>Type</h3>
|
||||
*
|
||||
* <pre><code>
|
||||
* void (*) (
|
||||
* GLFWwindow *window,
|
||||
* double xoffset,
|
||||
* double yoffset
|
||||
* )</code></pre>
|
||||
*
|
||||
* @since version 3.0
|
||||
*/
|
||||
@FunctionalInterface
|
||||
@NativeType("GLFWscrollfun")
|
||||
public interface GLFWScrollCallbackI extends CallbackI.V {
|
||||
|
||||
String SIGNATURE = "(pdd)v";
|
||||
|
||||
@Override
|
||||
default String getSignature() { return SIGNATURE; }
|
||||
|
||||
@Override
|
||||
default void callback(long args) {
|
||||
invoke(
|
||||
dcbArgPointer(args),
|
||||
dcbArgDouble(args),
|
||||
dcbArgDouble(args)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
}
|
||||
@ -1,204 +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>Member documentation</h3>
|
||||
*
|
||||
* <ul>
|
||||
* <li>{@code width} – the width, in screen coordinates, of the video mode</li>
|
||||
* <li>{@code height} – the height, in screen coordinates, of the video mode</li>
|
||||
* <li>{@code redBits} – the bit depth of the red channel of the video mode</li>
|
||||
* <li>{@code greenBits} – the bit depth of the green channel of the video mode</li>
|
||||
* <li>{@code blueBits} – the bit depth of the blue channel of the video mode</li>
|
||||
* <li>{@code refreshRate} – the refresh rate, in Hz, of the video mode</li>
|
||||
* </ul>
|
||||
*
|
||||
* <h3>Layout</h3>
|
||||
*
|
||||
* <pre><code>
|
||||
* struct GLFWvidmode {
|
||||
* int width;
|
||||
* int height;
|
||||
* int redBits;
|
||||
* int greenBits;
|
||||
* int blueBits;
|
||||
* int refreshRate;
|
||||
* }</code></pre>
|
||||
*/
|
||||
@NativeType("struct GLFWvidmode")
|
||||
public class GLFWVidMode extends Struct {
|
||||
|
||||
/** 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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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; }
|
||||
|
||||
/** Returns the value of the {@code width} field. */
|
||||
public int width() { return nwidth(address()); }
|
||||
/** Returns the value of the {@code height} field. */
|
||||
public int height() { return nheight(address()); }
|
||||
/** Returns the value of the {@code redBits} field. */
|
||||
public int redBits() { return nredBits(address()); }
|
||||
/** Returns the value of the {@code greenBits} field. */
|
||||
public int greenBits() { return ngreenBits(address()); }
|
||||
/** Returns the value of the {@code blueBits} field. */
|
||||
public int blueBits() { return nblueBits(address()); }
|
||||
/** Returns the value of the {@code refreshRate} field. */
|
||||
public int refreshRate() { return nrefreshRate(address()); }
|
||||
|
||||
// -----------------------------------
|
||||
|
||||
/** Returns a new {@code GLFWVidMode} instance for the specified memory address. */
|
||||
public static GLFWVidMode create(long address) {
|
||||
return wrap(GLFWVidMode.class, address);
|
||||
}
|
||||
|
||||
/** 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 : wrap(GLFWVidMode.class, address);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a {@link GLFWVidMode.Buffer} instance at the specified memory.
|
||||
*
|
||||
* @param address the memory address
|
||||
* @param capacity the buffer capacity
|
||||
*/
|
||||
public static GLFWVidMode.Buffer create(long address, int capacity) {
|
||||
return wrap(Buffer.class, address, capacity);
|
||||
}
|
||||
|
||||
/** Like {@link #create(long, int) create}, but returns {@code null} if {@code address} is {@code NULL}. */
|
||||
@Nullable
|
||||
public static GLFWVidMode.Buffer createSafe(long address, int capacity) {
|
||||
return address == NULL ? null : wrap(Buffer.class, 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.
|
||||
*
|
||||
* 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>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;
|
||||
}
|
||||
|
||||
/** Returns the value of the {@code width} field. */
|
||||
public int width() { return GLFWVidMode.nwidth(address()); }
|
||||
/** Returns the value of the {@code height} field. */
|
||||
public int height() { return GLFWVidMode.nheight(address()); }
|
||||
/** Returns the value of the {@code redBits} field. */
|
||||
public int redBits() { return GLFWVidMode.nredBits(address()); }
|
||||
/** Returns the value of the {@code greenBits} field. */
|
||||
public int greenBits() { return GLFWVidMode.ngreenBits(address()); }
|
||||
/** Returns the value of the {@code blueBits} field. */
|
||||
public int blueBits() { return GLFWVidMode.nblueBits(address()); }
|
||||
/** Returns the value of the {@code refreshRate} field. */
|
||||
public int refreshRate() { return GLFWVidMode.nrefreshRate(address()); }
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,4 +0,0 @@
|
||||
package org.lwjgl.glfw;
|
||||
|
||||
public class GLFWVulkan {
|
||||
}
|
||||
@ -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 (*) (
|
||||
* 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(SIGNATURE);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,47 +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.dyncall.DynCallback.*;
|
||||
|
||||
/**
|
||||
* Instances of this interface may be passed to the {@link GLFW#glfwSetWindowCloseCallback SetWindowCloseCallback} method.
|
||||
*
|
||||
* <h3>Type</h3>
|
||||
*
|
||||
* <pre><code>
|
||||
* void (*) (
|
||||
* GLFWwindow *window
|
||||
* )</code></pre>
|
||||
*
|
||||
* @since version 2.5
|
||||
*/
|
||||
@FunctionalInterface
|
||||
@NativeType("GLFWwindowclosefun")
|
||||
public interface GLFWWindowCloseCallbackI extends CallbackI.V {
|
||||
|
||||
String SIGNATURE = "(p)v";
|
||||
|
||||
@Override
|
||||
default String getSignature() { return SIGNATURE; }
|
||||
|
||||
@Override
|
||||
default void callback(long args) {
|
||||
invoke(
|
||||
dcbArgPointer(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);
|
||||
|
||||
}
|
||||
@ -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 (*) (
|
||||
* 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(SIGNATURE);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,53 +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.dyncall.DynCallback.*;
|
||||
|
||||
/**
|
||||
* Instances of this interface may be passed to the {@link GLFW#glfwSetWindowContentScaleCallback SetWindowContentScaleCallback} method.
|
||||
*
|
||||
* <h3>Type</h3>
|
||||
*
|
||||
* <pre><code>
|
||||
* void (*) (
|
||||
* GLFWwindow *window,
|
||||
* float xscale,
|
||||
* float yscale
|
||||
* )</code></pre>
|
||||
*
|
||||
* @since version 3.3
|
||||
*/
|
||||
@FunctionalInterface
|
||||
@NativeType("GLFWwindowcontentscalefun")
|
||||
public interface GLFWWindowContentScaleCallbackI extends CallbackI.V {
|
||||
|
||||
String SIGNATURE = "(pff)v";
|
||||
|
||||
@Override
|
||||
default String getSignature() { return SIGNATURE; }
|
||||
|
||||
@Override
|
||||
default void callback(long args) {
|
||||
invoke(
|
||||
dcbArgPointer(args),
|
||||
dcbArgFloat(args),
|
||||
dcbArgFloat(args)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
}
|
||||
@ -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 (*) (
|
||||
* 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(SIGNATURE);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,50 +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.dyncall.DynCallback.*;
|
||||
|
||||
/**
|
||||
* Instances of this interface may be passed to the {@link GLFW#glfwSetWindowFocusCallback SetWindowFocusCallback} method.
|
||||
*
|
||||
* <h3>Type</h3>
|
||||
*
|
||||
* <pre><code>
|
||||
* void (*) (
|
||||
* GLFWwindow *window,
|
||||
* int focused
|
||||
* )</code></pre>
|
||||
*
|
||||
* @since version 3.0
|
||||
*/
|
||||
@FunctionalInterface
|
||||
@NativeType("GLFWwindowfocusfun")
|
||||
public interface GLFWWindowFocusCallbackI extends CallbackI.V {
|
||||
|
||||
String SIGNATURE = "(pi)v";
|
||||
|
||||
@Override
|
||||
default String getSignature() { return SIGNATURE; }
|
||||
|
||||
@Override
|
||||
default void callback(long args) {
|
||||
invoke(
|
||||
dcbArgPointer(args),
|
||||
dcbArgInt(args) != 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);
|
||||
|
||||
}
|
||||
@ -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 (*) (
|
||||
* 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(SIGNATURE);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,50 +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.dyncall.DynCallback.*;
|
||||
|
||||
/**
|
||||
* Instances of this interface may be passed to the {@link GLFW#glfwSetWindowIconifyCallback SetWindowIconifyCallback} method.
|
||||
*
|
||||
* <h3>Type</h3>
|
||||
*
|
||||
* <pre><code>
|
||||
* void (*) (
|
||||
* GLFWwindow *window,
|
||||
* int iconified
|
||||
* )</code></pre>
|
||||
*
|
||||
* @since version 3.0
|
||||
*/
|
||||
@FunctionalInterface
|
||||
@NativeType("GLFWwindowiconifyfun")
|
||||
public interface GLFWWindowIconifyCallbackI extends CallbackI.V {
|
||||
|
||||
String SIGNATURE = "(pi)v";
|
||||
|
||||
@Override
|
||||
default String getSignature() { return SIGNATURE; }
|
||||
|
||||
@Override
|
||||
default void callback(long args) {
|
||||
invoke(
|
||||
dcbArgPointer(args),
|
||||
dcbArgInt(args) != 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);
|
||||
|
||||
}
|
||||
@ -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 (*) (
|
||||
* 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(SIGNATURE);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,50 +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.dyncall.DynCallback.*;
|
||||
|
||||
/**
|
||||
* Instances of this interface may be passed to the {@link GLFW#glfwSetWindowMaximizeCallback SetWindowMaximizeCallback} method.
|
||||
*
|
||||
* <h3>Type</h3>
|
||||
*
|
||||
* <pre><code>
|
||||
* void (*) (
|
||||
* GLFWwindow *window,
|
||||
* int maximized
|
||||
* )</code></pre>
|
||||
*
|
||||
* @since version 3.3
|
||||
*/
|
||||
@FunctionalInterface
|
||||
@NativeType("GLFWwindowmaximizefun")
|
||||
public interface GLFWWindowMaximizeCallbackI extends CallbackI.V {
|
||||
|
||||
String SIGNATURE = "(pi)v";
|
||||
|
||||
@Override
|
||||
default String getSignature() { return SIGNATURE; }
|
||||
|
||||
@Override
|
||||
default void callback(long args) {
|
||||
invoke(
|
||||
dcbArgPointer(args),
|
||||
dcbArgInt(args) != 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);
|
||||
|
||||
}
|
||||
@ -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 (*) (
|
||||
* 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(SIGNATURE);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,53 +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.dyncall.DynCallback.*;
|
||||
|
||||
/**
|
||||
* Instances of this interface may be passed to the {@link GLFW#glfwSetWindowPosCallback SetWindowPosCallback} method.
|
||||
*
|
||||
* <h3>Type</h3>
|
||||
*
|
||||
* <pre><code>
|
||||
* void (*) (
|
||||
* GLFWwindow *window,
|
||||
* int xpos,
|
||||
* int ypos
|
||||
* )</code></pre>
|
||||
*
|
||||
* @since version 3.0
|
||||
*/
|
||||
@FunctionalInterface
|
||||
@NativeType("GLFWwindowposfun")
|
||||
public interface GLFWWindowPosCallbackI extends CallbackI.V {
|
||||
|
||||
String SIGNATURE = "(pii)v";
|
||||
|
||||
@Override
|
||||
default String getSignature() { return SIGNATURE; }
|
||||
|
||||
@Override
|
||||
default void callback(long args) {
|
||||
invoke(
|
||||
dcbArgPointer(args),
|
||||
dcbArgInt(args),
|
||||
dcbArgInt(args)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
}
|
||||
@ -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 (*) (
|
||||
* 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(SIGNATURE);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,48 +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.dyncall.DynCallback.*;
|
||||
|
||||
/**
|
||||
* Instances of this interface may be passed to the {@link GLFW#glfwSetWindowRefreshCallback SetWindowRefreshCallback} method.
|
||||
*
|
||||
* <h3>Type</h3>
|
||||
*
|
||||
* <pre><code>
|
||||
* void (*) (
|
||||
* GLFWwindow *window
|
||||
* )</code></pre>
|
||||
*
|
||||
* @since version 2.5
|
||||
*/
|
||||
@FunctionalInterface
|
||||
@NativeType("GLFWwindowrefreshfun")
|
||||
public interface GLFWWindowRefreshCallbackI extends CallbackI.V {
|
||||
|
||||
String SIGNATURE = "(p)v";
|
||||
|
||||
@Override
|
||||
default String getSignature() { return SIGNATURE; }
|
||||
|
||||
@Override
|
||||
default void callback(long args) {
|
||||
invoke(
|
||||
dcbArgPointer(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);
|
||||
|
||||
}
|
||||
@ -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 (*) (
|
||||
* 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(SIGNATURE);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,51 +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.dyncall.DynCallback.*;
|
||||
|
||||
/**
|
||||
* Instances of this interface may be passed to the {@link GLFW#glfwSetWindowSizeCallback SetWindowSizeCallback} method.
|
||||
*
|
||||
* <h3>Type</h3>
|
||||
*
|
||||
* <pre><code>
|
||||
* void (*) (
|
||||
* GLFWwindow *window,
|
||||
* int width,
|
||||
* int height
|
||||
* )</code></pre>
|
||||
*/
|
||||
@FunctionalInterface
|
||||
@NativeType("GLFWwindowsizefun")
|
||||
public interface GLFWWindowSizeCallbackI extends CallbackI.V {
|
||||
|
||||
String SIGNATURE = "(pii)v";
|
||||
|
||||
@Override
|
||||
default String getSignature() { return SIGNATURE; }
|
||||
|
||||
@Override
|
||||
default void callback(long args) {
|
||||
invoke(
|
||||
dcbArgPointer(args),
|
||||
dcbArgInt(args),
|
||||
dcbArgInt(args)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
}
|
||||
@ -1,20 +0,0 @@
|
||||
/*
|
||||
* Copyright LWJGL. All rights reserved.
|
||||
* License terms: https://www.lwjgl.org/license
|
||||
* MACHINE GENERATED FILE, DO NOT EDIT
|
||||
*/
|
||||
|
||||
/**
|
||||
* Contains bindings to the <a target="_blank" href="http://www.glfw.org/">GLFW</a> library.
|
||||
*
|
||||
* <p>GLFW comes with extensive documentation, which you can read online <a target="_blank" href="http://www.glfw.org/docs/latest/">here</a>. The
|
||||
* <a target="_blank" href="http://www.glfw.org/faq.html">Frequently Asked Questions</a> are also useful.</p>
|
||||
*
|
||||
* <p>On macOS the JVM must be started with the {@code -XstartOnFirstThread} argument for GLFW to work. This is necessary because most GLFW functions must be
|
||||
* called on the main thread and the Cocoa API on macOS requires that thread to be the first thread in the process. For this reason, on-screen GLFW
|
||||
* windows and the GLFW event loop are incompatible with other window toolkits (such as AWT/Swing or JavaFX) on macOS. Off-screen GLFW windows can be used
|
||||
* with other window toolkits, but only if the window toolkit is initialized before GLFW.</p>
|
||||
*/
|
||||
@org.lwjgl.system.NonnullDefault
|
||||
package org.lwjgl.glfw;
|
||||
|
||||
@ -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);
|
||||
}
|
||||
@ -1,78 +0,0 @@
|
||||
package org.lwjgl.input;
|
||||
|
||||
import org.lwjgl.Sys;
|
||||
import org.lwjgl.glfw.GLFWJoystickCallback;
|
||||
|
||||
public class Controllers {
|
||||
static GLFWController ctrlr;
|
||||
public static void create() {
|
||||
ctrlr = new GLFWController();
|
||||
ctrlr.jid = 0;
|
||||
}
|
||||
public static Controller getController(int ctrl) {
|
||||
return ctrlr;
|
||||
}
|
||||
public static int getControllerCount() {
|
||||
return 1;
|
||||
}
|
||||
public static void poll() {
|
||||
ctrlr.poll();
|
||||
}
|
||||
public static boolean next() {
|
||||
return false;
|
||||
}
|
||||
public static boolean isCreated() {
|
||||
return true;
|
||||
}
|
||||
public static void destroy() {
|
||||
|
||||
}
|
||||
public static void clearEvents() {}
|
||||
public static Controller getEventSource() {
|
||||
return ctrlr;
|
||||
}
|
||||
|
||||
public static int getEventControlIndex() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static boolean isEventButton() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean isEventAxis() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean isEventXAxis() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean isEventYAxis() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean isEventPovX() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean isEventPovY() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static long getEventNanoseconds() {
|
||||
return Sys.getNanoTime();
|
||||
}
|
||||
|
||||
public static boolean getEventButtonState() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static float getEventXAxisValue() {
|
||||
return ctrlr.getXAxisValue();
|
||||
}
|
||||
|
||||
public static float getEventYAxisValue() {
|
||||
return ctrlr.getYAxisValue();
|
||||
}
|
||||
}
|
||||
@ -1,285 +0,0 @@
|
||||
package org.lwjgl.input;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.IntBuffer;
|
||||
|
||||
import org.lwjgl.BufferUtils;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
import org.lwjgl.glfw.GLFWImage;
|
||||
import org.lwjgl.system.MemoryUtil;
|
||||
import org.lwjgl.LWJGLException;
|
||||
|
||||
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");
|
||||
}
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user