mirror of
https://github.com/GTNewHorizons/lwjgl3ify.git
synced 2026-11-26 23:13:01 +00:00
Adjustments needed to get Angelica (Iris/Oculus backport) working (#88)
* WIP Adjustments needed to get Angelica (Iris/Oculus backport) working * Move to GL20 * Hacky lwjglx.debug support since its transformer doesn't like lwjgl3ify's init call * Don't submit invalid keycodes * Add missing glTextureParameter * Update buildscript * Better setupDebugMessageCallback. * Fix up the isKeyDown patch * Better glGetActiveUniform sizetype impl * Clean up the debug handler code * Update the buildscript --------- Co-authored-by: Raven Szewczyk <[email protected]>
This commit is contained in:
1 parent
f5906d082e
commit
f8c4a5e330
14 files changed
+336
-18
No files matched your search
@@ -454,6 +454,10 @@ public class ARBDirectStateAccess {
|
||||
org.lwjgl.opengl.ARBDirectStateAccess.glTextureParameteri(texture, pname, param);
|
||||
}
|
||||
|
||||
public static void glTextureParameter(int texture, int pname, java.nio.IntBuffer params) {
|
||||
org.lwjgl.opengl.ARBDirectStateAccess.glTextureParameteriv(texture, pname, params);
|
||||
}
|
||||
|
||||
public static void glTextureStorage1D(int texture, int levels, int internalformat, int width) {
|
||||
org.lwjgl.opengl.ARBDirectStateAccess.glTextureStorage1D(texture, levels, internalformat, width);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package org.lwjglx.opengl;
|
||||
|
||||
import org.lwjgl.system.MemoryUtil;
|
||||
|
||||
public class GL20 {
|
||||
|
||||
public static final int GL_ACTIVE_ATTRIBUTES = (int) 35721;
|
||||
@@ -154,6 +156,15 @@ public class GL20 {
|
||||
org.lwjgl.opengl.GL20.glGetActiveUniform(program, index, length, size, type, name);
|
||||
}
|
||||
|
||||
public static String glGetActiveUniform(int program, int index, int maxLength, java.nio.IntBuffer sizeType) {
|
||||
return org.lwjgl.opengl.GL20.glGetActiveUniform(
|
||||
program,
|
||||
index,
|
||||
maxLength,
|
||||
MemoryUtil.memSlice(sizeType, 0, 1),
|
||||
MemoryUtil.memSlice(sizeType, 1, 1));
|
||||
}
|
||||
|
||||
public static void glGetAttachedShaders(int program, java.nio.IntBuffer count, java.nio.IntBuffer shaders) {
|
||||
org.lwjgl.opengl.GL20.glGetAttachedShaders(program, count, shaders);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package org.lwjglx.opengl;
|
||||
|
||||
import org.lwjgl.opengl.GLDebugMessageCallback;
|
||||
|
||||
public class GL43 {
|
||||
|
||||
public static final int GL_ACTIVE_RESOURCES = (int) 37621;
|
||||
@@ -520,4 +522,20 @@ public class GL43 {
|
||||
org.lwjgl.opengl.GL43.glVertexBindingDivisor(bindingindex, divisor);
|
||||
}
|
||||
|
||||
// Callbacks have to be kept alive, a GC collection could falsely collect them.
|
||||
private static ThreadLocal<GLDebugMessageCallback> glDebugMessageCallbackStorage = new ThreadLocal<>();
|
||||
|
||||
public static void glDebugMessageCallback(org.lwjglx.opengl.KHRDebugCallback callback) {
|
||||
if (callback == null) {
|
||||
org.lwjgl.opengl.GL43.glDebugMessageCallback(null, 0L);
|
||||
return;
|
||||
}
|
||||
GLDebugMessageCallback cb = glDebugMessageCallbackStorage.get();
|
||||
if (cb == null) {
|
||||
cb = GLDebugMessageCallback.create(callback);
|
||||
glDebugMessageCallbackStorage.set(cb);
|
||||
}
|
||||
org.lwjgl.opengl.GL43.glDebugMessageCallback(cb, 0L);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -54,6 +54,10 @@ public class KHRDebug {
|
||||
org.lwjgl.opengl.KHRDebug.glDebugMessageInsert(source, type, id, severity, buf);
|
||||
}
|
||||
|
||||
public static void glDebugMessageCallback(org.lwjglx.opengl.KHRDebugCallback callback) {
|
||||
org.lwjglx.opengl.GL43.glDebugMessageCallback(callback);
|
||||
}
|
||||
|
||||
public static int glGetDebugMessageLog(int count, java.nio.IntBuffer sources, java.nio.IntBuffer types,
|
||||
java.nio.IntBuffer ids, java.nio.IntBuffer severities, java.nio.IntBuffer lengths,
|
||||
java.nio.ByteBuffer messageLog) {
|
||||
|
||||
@@ -0,0 +1,139 @@
|
||||
package org.lwjglx.opengl;
|
||||
|
||||
import org.lwjgl.opengl.GLDebugMessageCallback;
|
||||
import org.lwjgl.opengl.GLDebugMessageCallbackI;
|
||||
|
||||
public class KHRDebugCallback extends org.lwjglx.PointerWrapperAbstract implements GLDebugMessageCallbackI {
|
||||
|
||||
/** Severity levels. */
|
||||
private static final int GL_DEBUG_SEVERITY_HIGH = 0x9146, GL_DEBUG_SEVERITY_MEDIUM = 0x9147,
|
||||
GL_DEBUG_SEVERITY_LOW = 0x9148, GL_DEBUG_SEVERITY_NOTIFICATION = 0x826B;
|
||||
|
||||
/** Sources. */
|
||||
private static final int GL_DEBUG_SOURCE_API = 0x8246, GL_DEBUG_SOURCE_WINDOW_SYSTEM = 0x8247,
|
||||
GL_DEBUG_SOURCE_SHADER_COMPILER = 0x8248, GL_DEBUG_SOURCE_THIRD_PARTY = 0x8249,
|
||||
GL_DEBUG_SOURCE_APPLICATION = 0x824A, GL_DEBUG_SOURCE_OTHER = 0x824B;
|
||||
|
||||
/** Types. */
|
||||
private static final int GL_DEBUG_TYPE_ERROR = 0x824C, GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR = 0x824D,
|
||||
GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR = 0x824E, GL_DEBUG_TYPE_PORTABILITY = 0x824F,
|
||||
GL_DEBUG_TYPE_PERFORMANCE = 0x8250, GL_DEBUG_TYPE_OTHER = 0x8251, GL_DEBUG_TYPE_MARKER = 0x8268;
|
||||
|
||||
private static final long CALLBACK_POINTER;
|
||||
|
||||
static {
|
||||
long pointer = 0;
|
||||
try {
|
||||
// Call reflectively so that we can compile this class for the Generator.
|
||||
pointer = (Long) Class.forName("org.lwjgl.opengl.CallbackUtil")
|
||||
.getDeclaredMethod("getDebugCallbackKHR")
|
||||
.invoke(null);
|
||||
} catch (Exception e) {
|
||||
// ignore
|
||||
}
|
||||
CALLBACK_POINTER = pointer;
|
||||
}
|
||||
|
||||
private final Handler handler;
|
||||
|
||||
/**
|
||||
* Creates an KHRebugCallback with a default callback handler.
|
||||
* The default handler will simply print the message on System.err.
|
||||
*/
|
||||
public KHRDebugCallback() {
|
||||
this(new Handler() {
|
||||
|
||||
public void handleMessage(final int source, final int type, final int id, final int severity,
|
||||
final String message) {
|
||||
System.err.println("[LWJGL] KHR_debug message");
|
||||
System.err.println("\tID: " + id);
|
||||
|
||||
String description = switch (source) {
|
||||
case GL_DEBUG_SOURCE_API -> "API";
|
||||
case GL_DEBUG_SOURCE_WINDOW_SYSTEM -> "WINDOW SYSTEM";
|
||||
case GL_DEBUG_SOURCE_SHADER_COMPILER -> "SHADER COMPILER";
|
||||
case GL_DEBUG_SOURCE_THIRD_PARTY -> "THIRD PARTY";
|
||||
case GL_DEBUG_SOURCE_APPLICATION -> "APPLICATION";
|
||||
case GL_DEBUG_SOURCE_OTHER -> "OTHER";
|
||||
default -> printUnknownToken(source);
|
||||
};
|
||||
System.err.println("\tSource: " + description);
|
||||
|
||||
description = switch (type) {
|
||||
case GL_DEBUG_TYPE_ERROR -> "ERROR";
|
||||
case GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR -> "DEPRECATED BEHAVIOR";
|
||||
case GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR -> "UNDEFINED BEHAVIOR";
|
||||
case GL_DEBUG_TYPE_PORTABILITY -> "PORTABILITY";
|
||||
case GL_DEBUG_TYPE_PERFORMANCE -> "PERFORMANCE";
|
||||
case GL_DEBUG_TYPE_OTHER -> "OTHER";
|
||||
case GL_DEBUG_TYPE_MARKER -> "MARKER";
|
||||
default -> printUnknownToken(type);
|
||||
};
|
||||
System.err.println("\tType: " + description);
|
||||
|
||||
description = switch (severity) {
|
||||
case GL_DEBUG_SEVERITY_HIGH -> "HIGH";
|
||||
case GL_DEBUG_SEVERITY_MEDIUM -> "MEDIUM";
|
||||
case GL_DEBUG_SEVERITY_LOW -> "LOW";
|
||||
case GL_DEBUG_SEVERITY_NOTIFICATION -> "NOTIFICATION";
|
||||
default -> printUnknownToken(severity);
|
||||
};
|
||||
System.err.println("\tSeverity: " + description);
|
||||
|
||||
System.err.println("\tMessage: " + message);
|
||||
}
|
||||
|
||||
private String printUnknownToken(final int token) {
|
||||
return "Unknown (0x" + Integer.toHexString(token)
|
||||
.toUpperCase() + ")";
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an ARBDebugOutputCallback with the specified callback handler.
|
||||
* The handler's {@code handleMessage} method will be called whenever
|
||||
* debug output is generated by the GL.
|
||||
*
|
||||
* @param handler the callback handler
|
||||
*/
|
||||
public KHRDebugCallback(final Handler handler) {
|
||||
super(CALLBACK_POINTER);
|
||||
|
||||
this.handler = handler;
|
||||
}
|
||||
|
||||
Handler getHandler() {
|
||||
return handler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invoke(int source, int type, int id, int severity, int length, long message, long userParam) {
|
||||
if (this.handler == null) {
|
||||
return;
|
||||
}
|
||||
this.handler.handleMessage(source, type, id, severity, GLDebugMessageCallback.getMessage(length, message));
|
||||
}
|
||||
|
||||
@Override
|
||||
public long address() {
|
||||
return GLDebugMessageCallbackI.super.address();
|
||||
}
|
||||
|
||||
/** Implementations of this interface can be used to receive ARB_debug_output notifications. */
|
||||
public interface Handler {
|
||||
|
||||
/**
|
||||
* This method will be called when an ARB_debug_output message is generated.
|
||||
*
|
||||
* @param source the message source
|
||||
* @param type the message type
|
||||
* @param id the message ID
|
||||
* @param severity the message severity
|
||||
* @param message the string representation of the message.
|
||||
*/
|
||||
void handleMessage(int source, int type, int id, int severity, String message);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user