mirror of
https://github.com/shadowfacts/lwjgl2-arm64.git
synced 2026-04-08 07:54:05 +00:00
Added support for OpenGL 4.1 and new extensions.
This commit is contained in:
parent
19b501fc46
commit
5842103580
23 changed files with 1874 additions and 78 deletions
|
|
@ -59,7 +59,7 @@ public final class AMDDebugOutputCallback implements PointerWrapper {
|
|||
private final long pointer;
|
||||
|
||||
/**
|
||||
* Creates a AMDDebugOutputCallback with a default callback handler.
|
||||
* Creates an AMDDebugOutputCallback with a default callback handler.
|
||||
* The default handler will simply print the message on System.err.
|
||||
*/
|
||||
public AMDDebugOutputCallback() {
|
||||
|
|
@ -120,7 +120,7 @@ public final class AMDDebugOutputCallback implements PointerWrapper {
|
|||
}
|
||||
|
||||
/**
|
||||
* Creates a AMDDebugOutputCallback with the specified callback handlers.
|
||||
* Creates an AMDDebugOutputCallback with the specified callback handlers.
|
||||
* The handler's {@code handleMessage} method will be called whenever
|
||||
* debug output is generated by the GL.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ final class AMDDebugOutputUtil {
|
|||
if ( !ctx.getContextAttribs().isDebug() )
|
||||
throw new IllegalStateException("The current context is not a debug context.");
|
||||
|
||||
if ( !GLContext.getCapabilities().GL_AMD_debug_output )
|
||||
if ( !GLContext.getCapabilities().GL_AMD_debug_output )
|
||||
throw new IllegalStateException("AMD_debug_output is not supported.");
|
||||
|
||||
handlers.put(ctx, handler);
|
||||
|
|
|
|||
190
src/java/org/lwjgl/opengl/ARBDebugOutputCallback.java
Normal file
190
src/java/org/lwjgl/opengl/ARBDebugOutputCallback.java
Normal file
|
|
@ -0,0 +1,190 @@
|
|||
/*
|
||||
* 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.opengl;
|
||||
|
||||
/**
|
||||
* Instances of this class are needed to use the callback functionality of the ARB_debug_output extension.
|
||||
* A debug context must be current before creating instances of this class. Users of this class may provide
|
||||
* implementations of the {@code Handler} interface to receive notifications. The same {@code Handler}
|
||||
* instance may be used by different contexts but it is not recommended. Handler notifications are synchronized.
|
||||
*
|
||||
* @author Spasi
|
||||
*/
|
||||
public final class ARBDebugOutputCallback implements PointerWrapper {
|
||||
|
||||
/** Severity levels. */
|
||||
private static final int
|
||||
GL_DEBUG_SEVERITY_HIGH_ARB = 0x9146,
|
||||
GL_DEBUG_SEVERITY_MEDIUM_ARB = 0x9147,
|
||||
GL_DEBUG_SEVERITY_LOW_ARB = 0x9148;
|
||||
|
||||
/** Sources. */
|
||||
private static final int
|
||||
GL_DEBUG_SOURCE_API_ARB = 0x8246,
|
||||
GL_DEBUG_SOURCE_WINDOW_SYSTEM_ARB = 0x8247,
|
||||
GL_DEBUG_SOURCE_SHADER_COMPILER_ARB = 0x8248,
|
||||
GL_DEBUG_SOURCE_THIRD_PARTY_ARB = 0x8249,
|
||||
GL_DEBUG_SOURCE_APPLICATION_ARB = 0x824A,
|
||||
GL_DEBUG_SOURCE_OTHER_ARB = 0x824B;
|
||||
|
||||
/** Types. */
|
||||
private static final int
|
||||
GL_DEBUG_TYPE_ERROR_ARB = 0x824C,
|
||||
GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB = 0x824D,
|
||||
GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB = 0x824E,
|
||||
GL_DEBUG_TYPE_PORTABILITY_ARB = 0x824F,
|
||||
GL_DEBUG_TYPE_PERFORMANCE_ARB = 0x8250,
|
||||
GL_DEBUG_TYPE_OTHER_ARB = 0x8251;
|
||||
|
||||
private final long pointer;
|
||||
|
||||
/**
|
||||
* Creates an ARBDebugOutputCallback with a default callback handler.
|
||||
* The default handler will simply print the message on System.err.
|
||||
*/
|
||||
public ARBDebugOutputCallback() {
|
||||
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] ARB_debug_output message");
|
||||
System.err.println("\tID: " + id);
|
||||
|
||||
String description;
|
||||
switch ( source ) {
|
||||
case GL_DEBUG_SOURCE_API_ARB:
|
||||
description = "API";
|
||||
break;
|
||||
case GL_DEBUG_SOURCE_WINDOW_SYSTEM_ARB:
|
||||
description = "WINDOW SYSTEM";
|
||||
break;
|
||||
case GL_DEBUG_SOURCE_SHADER_COMPILER_ARB:
|
||||
description = "SHADER COMPILER";
|
||||
break;
|
||||
case GL_DEBUG_SOURCE_THIRD_PARTY_ARB:
|
||||
description = "THIRD PARTY";
|
||||
break;
|
||||
case GL_DEBUG_SOURCE_APPLICATION_ARB:
|
||||
description = "APPLICATION";
|
||||
break;
|
||||
case GL_DEBUG_SOURCE_OTHER_ARB:
|
||||
description = "OTHER";
|
||||
break;
|
||||
default:
|
||||
description = "Unknown (" + Integer.toHexString(source) + ")";
|
||||
}
|
||||
System.err.println("\tSource: " + description);
|
||||
|
||||
switch ( type ) {
|
||||
case GL_DEBUG_TYPE_ERROR_ARB:
|
||||
description = "ERROR";
|
||||
break;
|
||||
case GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB:
|
||||
description = "DEPRECATED BEHAVIOR";
|
||||
break;
|
||||
case GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB:
|
||||
description = "UNDEFINED BEHAVIOR";
|
||||
break;
|
||||
case GL_DEBUG_TYPE_PORTABILITY_ARB:
|
||||
description = "PORTABILITY";
|
||||
break;
|
||||
case GL_DEBUG_TYPE_PERFORMANCE_ARB:
|
||||
description = "PERFORMANCE";
|
||||
break;
|
||||
case GL_DEBUG_TYPE_OTHER_ARB:
|
||||
description = "OTHER";
|
||||
break;
|
||||
default:
|
||||
description = "Unknown (" + Integer.toHexString(source) + ")";
|
||||
}
|
||||
System.err.println("\tType: " + description);
|
||||
|
||||
switch ( severity ) {
|
||||
case GL_DEBUG_SEVERITY_HIGH_ARB:
|
||||
description = "HIGH";
|
||||
break;
|
||||
case GL_DEBUG_SEVERITY_MEDIUM_ARB:
|
||||
description = "MEDIUM";
|
||||
break;
|
||||
case GL_DEBUG_SEVERITY_LOW_ARB:
|
||||
description = "LOW";
|
||||
break;
|
||||
default:
|
||||
description = "Unknown (" + Integer.toHexString(source) + ")";
|
||||
}
|
||||
System.err.println("\tSeverity: " + description);
|
||||
|
||||
System.err.println("\tMessage: " + message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an ARBDebugOutputCallback with the specified callback handlers.
|
||||
* The handler's {@code handleMessage} method will be called whenever
|
||||
* debug output is generated by the GL.
|
||||
*
|
||||
* @param handler the callback handler
|
||||
*/
|
||||
public ARBDebugOutputCallback(final Handler handler) {
|
||||
try {
|
||||
// We have to call registerHandler reflectively because we need this class to compile before we run the Generator.
|
||||
// The registerHandler method depends on org.lwjgl.opengl.Context, if we touched that we would need to compile
|
||||
// the whole library (which is not possible).
|
||||
Class.forName("org.lwjgl.opengl.ARBDebugOutputUtil").getMethod("registerHandler", new Class[] { Handler.class }).invoke(null, new Object[] { handler });
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e.getCause() != null ? e.getCause() : e);
|
||||
}
|
||||
this.pointer = getFunctionPointer();
|
||||
}
|
||||
|
||||
public long getPointer() {
|
||||
return pointer;
|
||||
}
|
||||
|
||||
private static native long getFunctionPointer();
|
||||
|
||||
/** Implementations of this interface can be used to receive ARB_debug_output notifications. */
|
||||
public interface Handler {
|
||||
|
||||
/**
|
||||
* This method will be called when an AMD_debug_output message is generated.
|
||||
*
|
||||
* @param id the message ID
|
||||
* @param source the message source
|
||||
* @param type the message type
|
||||
* @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);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
60
src/java/org/lwjgl/opengl/ARBDebugOutputUtil.java
Normal file
60
src/java/org/lwjgl/opengl/ARBDebugOutputUtil.java
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
package org.lwjgl.opengl;
|
||||
|
||||
import org.lwjgl.opengl.ARBDebugOutputCallback.Handler;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.Map;
|
||||
import java.util.WeakHashMap;
|
||||
|
||||
/**
|
||||
* This class handles ARBDebugOutputCallback.Handler registration and notification.
|
||||
* We could have put this in ARBDebugOutputCallback, but we need to compile it for
|
||||
* the generator. Registration is done reflectively in the ARBDebugOutputCallback
|
||||
* constructor.
|
||||
*
|
||||
* @author Spasi
|
||||
*/
|
||||
final class ARBDebugOutputUtil {
|
||||
|
||||
private static final Map handlers = new WeakHashMap();
|
||||
|
||||
private ARBDebugOutputUtil() {}
|
||||
|
||||
public static void registerHandler(final Handler handler) {
|
||||
final Context ctx = Context.getCurrentContext();
|
||||
if ( ctx == null )
|
||||
throw new IllegalStateException("No context is current.");
|
||||
|
||||
if ( !ctx.getContextAttribs().isDebug() )
|
||||
throw new IllegalStateException("The current context is not a debug context.");
|
||||
|
||||
if ( !GLContext.getCapabilities().GL_ARB_debug_output )
|
||||
throw new IllegalStateException("ARB_debug_output is not supported.");
|
||||
|
||||
handlers.put(ctx, handler);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called by native code. If finds the callback handler associated
|
||||
* with the current Thread and calls its {@code handleMessage} method.
|
||||
*
|
||||
* @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.
|
||||
* @param userParam the user-specified data specified in glDebugMessageCallbackAMD. For the current implementation this is always null and we ignore it.
|
||||
*/
|
||||
private static void messageCallback(final int source, final int type, final int id, final int severity, final String message, final ByteBuffer userParam) {
|
||||
synchronized ( GlobalLock.lock ) {
|
||||
final Context ctx = Context.getCurrentContext();
|
||||
if ( ctx == null )
|
||||
return;
|
||||
|
||||
final Handler handler = (Handler)handlers.get(ctx);
|
||||
if ( handler != null )
|
||||
handler.handleMessage(source, type, id, severity, message);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -56,6 +56,13 @@ import java.nio.IntBuffer;
|
|||
*/
|
||||
public final class ContextAttribs {
|
||||
|
||||
// Same values for GLX & WGL
|
||||
private static final int CONTEXT_ROBUST_ACCESS_BIT_ARB = 0x00000004;
|
||||
private static final int CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB = 0x8256;
|
||||
private static final int
|
||||
NO_RESET_NOTIFICATION_ARB = 0x8261,
|
||||
LOSE_CONTEXT_ON_RESET_ARB = 0x8252;
|
||||
|
||||
private int majorVersion;
|
||||
private int minorVersion;
|
||||
|
||||
|
|
@ -63,10 +70,13 @@ public final class ContextAttribs {
|
|||
|
||||
private boolean debug;
|
||||
private boolean forwardCompatible;
|
||||
private boolean robustAccess;
|
||||
|
||||
private boolean profileCore;
|
||||
private boolean profileCompatibility;
|
||||
|
||||
private boolean loseContextOnReset;
|
||||
|
||||
public ContextAttribs() {
|
||||
this(1, 0);
|
||||
}
|
||||
|
|
@ -82,14 +92,6 @@ public final class ContextAttribs {
|
|||
|
||||
this.majorVersion = majorVersion;
|
||||
this.minorVersion = minorVersion;
|
||||
|
||||
this.layerPlane = 0;
|
||||
|
||||
this.debug = false;
|
||||
this.forwardCompatible = false;
|
||||
|
||||
this.profileCore = false;
|
||||
this.profileCompatibility = false;
|
||||
}
|
||||
|
||||
private ContextAttribs(final ContextAttribs attribs) {
|
||||
|
|
@ -100,9 +102,12 @@ public final class ContextAttribs {
|
|||
|
||||
this.debug = attribs.debug;
|
||||
this.forwardCompatible = attribs.forwardCompatible;
|
||||
this.robustAccess = attribs.robustAccess;
|
||||
|
||||
this.profileCore = attribs.profileCore;
|
||||
this.profileCompatibility = attribs.profileCompatibility;
|
||||
|
||||
this.loseContextOnReset = attribs.loseContextOnReset;
|
||||
}
|
||||
|
||||
public int getMajorVersion() {
|
||||
|
|
@ -193,6 +198,24 @@ public final class ContextAttribs {
|
|||
return attribs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a ContextAttribs instance with CONTEXT_RESET_NOTIFICATION_STRATEGY set
|
||||
* to LOSE_CONTEXT_ON_RESET if the parameter is true or to NO_RESET_NOTIFICATION
|
||||
* if the parameter is false.
|
||||
*
|
||||
* @param loseContextOnReset
|
||||
*
|
||||
* @return the new ContextAttribs
|
||||
*/
|
||||
public ContextAttribs withLoseContextOnReset(final boolean loseContextOnReset) {
|
||||
if ( loseContextOnReset == this.loseContextOnReset )
|
||||
return this;
|
||||
|
||||
final ContextAttribs attribs = new ContextAttribs(this);
|
||||
attribs.loseContextOnReset = loseContextOnReset;
|
||||
return attribs;
|
||||
}
|
||||
|
||||
private static ContextAttribsImplementation getImplementation() {
|
||||
switch ( LWJGLUtil.getPlatform() ) {
|
||||
case LWJGLUtil.PLATFORM_LINUX:
|
||||
|
|
@ -221,6 +244,8 @@ public final class ContextAttribs {
|
|||
flags |= implementation.getDebugBit();
|
||||
if ( forwardCompatible )
|
||||
flags |= implementation.getForwardCompatibleBit();
|
||||
if ( robustAccess )
|
||||
flags |= CONTEXT_ROBUST_ACCESS_BIT_ARB;
|
||||
if ( 0 < flags )
|
||||
attribCount++;
|
||||
|
||||
|
|
@ -247,6 +272,8 @@ public final class ContextAttribs {
|
|||
attribs.put(implementation.getFlagsAttrib()).put(flags);
|
||||
if ( 0 < profileMask )
|
||||
attribs.put(implementation.getProfileMaskAttrib()).put(profileMask);
|
||||
if ( loseContextOnReset )
|
||||
attribs.put(CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB).put(LOSE_CONTEXT_ON_RESET_ARB);
|
||||
|
||||
attribs.put(0);
|
||||
attribs.rewind();
|
||||
|
|
@ -261,6 +288,9 @@ public final class ContextAttribs {
|
|||
sb.append(" - Layer=").append(layerPlane);
|
||||
sb.append(" - Debug=").append(debug);
|
||||
sb.append(" - ForwardCompatible=").append(forwardCompatible);
|
||||
sb.append(" - RobustAccess=").append(robustAccess);
|
||||
if ( robustAccess )
|
||||
sb.append(" (").append(loseContextOnReset ? "LOSE_CONTEXT_ON_RESET" : "NO_RESET_NOTIFICATION");
|
||||
sb.append(" - Profile=");
|
||||
if ( profileCore )
|
||||
sb.append("Core");
|
||||
|
|
|
|||
|
|
@ -215,37 +215,21 @@ public final class GLContext {
|
|||
LWJGLUtil.log("The major and/or minor OpenGL version is malformed: " + e.getMessage());
|
||||
}
|
||||
|
||||
// ----------------------[ 4.X ]----------------------
|
||||
if ( 4 <= majorVersion )
|
||||
supported_extensions.add("OpenGL40");
|
||||
final int[][] GL_VERSIONS = {
|
||||
{ 1, 2, 3, 4, 5 }, // OpenGL 1
|
||||
{ 0, 1 }, // OpenGL 2
|
||||
{ 0, 1, 2, 3 }, // OpenGL 3
|
||||
{ 0, 1 }, // OpenGL 4
|
||||
};
|
||||
|
||||
// ----------------------[ 3.X ]----------------------
|
||||
if ( 3 < majorVersion || (3 == majorVersion && 3 <= minorVersion) )
|
||||
supported_extensions.add("OpenGL33");
|
||||
if ( 3 < majorVersion || (3 == majorVersion && 2 <= minorVersion) )
|
||||
supported_extensions.add("OpenGL32");
|
||||
if ( 3 < majorVersion || (3 == majorVersion && 1 <= minorVersion) )
|
||||
supported_extensions.add("OpenGL31");
|
||||
if ( 3 <= majorVersion )
|
||||
supported_extensions.add("OpenGL30");
|
||||
|
||||
// ----------------------[ 2.X ]----------------------
|
||||
if ( 2 < majorVersion || (2 == majorVersion && 1 <= minorVersion) )
|
||||
supported_extensions.add("OpenGL21");
|
||||
if ( 2 <= majorVersion )
|
||||
supported_extensions.add("OpenGL20");
|
||||
|
||||
// ----------------------[ 1.X ]----------------------
|
||||
if ( 1 < majorVersion || 5 <= minorVersion )
|
||||
supported_extensions.add("OpenGL15");
|
||||
if ( 1 < majorVersion || 4 <= minorVersion )
|
||||
supported_extensions.add("OpenGL14");
|
||||
if ( 1 < majorVersion || 3 <= minorVersion )
|
||||
supported_extensions.add("OpenGL13");
|
||||
if ( 1 < majorVersion || 2 <= minorVersion )
|
||||
supported_extensions.add("OpenGL12");
|
||||
if ( 1 < majorVersion || 1 <= minorVersion )
|
||||
supported_extensions.add("OpenGL11");
|
||||
for ( int major = 1; major <= GL_VERSIONS.length; major++ ) {
|
||||
int[] minors = GL_VERSIONS[major - 1];
|
||||
for ( int i = 0; i < minors.length; i++ ) {
|
||||
int minor = minors[i];
|
||||
if ( major < majorVersion || (major == majorVersion && minor <= minorVersion) )
|
||||
supported_extensions.add("OpenGL" + Integer.toString(major) + Integer.toString(minor));
|
||||
}
|
||||
}
|
||||
|
||||
int profileMask = 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -133,9 +133,9 @@ public class GLTypeMap implements TypeMap {
|
|||
return "s";
|
||||
else if ( annotation_type.equals(GLubyte.class) || annotation_type.equals(GLbyte.class) )
|
||||
return "b";
|
||||
else if ( annotation_type.equals(GLfloat.class) )
|
||||
else if ( annotation_type.equals(GLfloat.class) || annotation_type.equals(GLclampf.class) )
|
||||
return "f";
|
||||
else if ( annotation_type.equals(GLdouble.class) )
|
||||
else if ( annotation_type.equals(GLdouble.class) || annotation_type.equals(GLclampd.class) )
|
||||
return "d";
|
||||
else if ( annotation_type.equals(GLhalf.class) )
|
||||
return "h";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue