mirror of
https://github.com/shadowfacts/lwjgl2-arm64.git
synced 2026-04-08 16:04:39 +00:00
Added support for OpenGL 3.3 and OpenGL 4.0.
This commit is contained in:
parent
0eed407ef8
commit
c3d6d43d2a
36 changed files with 2217 additions and 36 deletions
|
|
@ -85,6 +85,13 @@ public class BufferChecks {
|
|||
throw new IllegalArgumentException("Missing null termination");
|
||||
}
|
||||
|
||||
/** Helper methods to ensure an IntBuffer is null-terminated */
|
||||
public static void checkNullTerminated(IntBuffer buf) {
|
||||
if ( buf.get(buf.limit() - 1) != 0 ) {
|
||||
throw new IllegalArgumentException("Missing null termination");
|
||||
}
|
||||
}
|
||||
|
||||
public static void checkNotNull(Object o) {
|
||||
if (o == null)
|
||||
throw new IllegalArgumentException("Null argument");
|
||||
|
|
|
|||
|
|
@ -46,6 +46,8 @@ class BaseReferences {
|
|||
int pixelPackBuffer;
|
||||
int pixelUnpackBuffer;
|
||||
|
||||
int indirectBuffer;
|
||||
|
||||
BaseReferences(ContextCapabilities caps) {
|
||||
IntBuffer temp = caps.scratch_int_buffer;
|
||||
|
||||
|
|
@ -78,6 +80,8 @@ class BaseReferences {
|
|||
|
||||
this.pixelPackBuffer = 0;
|
||||
this.pixelUnpackBuffer = 0;
|
||||
|
||||
this.indirectBuffer = 0;
|
||||
}
|
||||
|
||||
void copy(BaseReferences references, int mask) {
|
||||
|
|
@ -87,6 +91,8 @@ class BaseReferences {
|
|||
this.glClientActiveTexture = references.glClientActiveTexture;
|
||||
System.arraycopy(references.glVertexAttribPointer_buffer, 0, glVertexAttribPointer_buffer, 0, glVertexAttribPointer_buffer.length);
|
||||
System.arraycopy(references.glTexCoordPointer_buffer, 0, glTexCoordPointer_buffer, 0, glTexCoordPointer_buffer.length);
|
||||
|
||||
this.indirectBuffer = references.indirectBuffer;
|
||||
}
|
||||
|
||||
if ( (mask & GL11.GL_CLIENT_PIXEL_STORE_BIT) != 0 ) {
|
||||
|
|
|
|||
|
|
@ -114,6 +114,18 @@ class GLChecks {
|
|||
throw new OpenGLException("Cannot use offsets when Element Array Buffer Object is disabled");
|
||||
}
|
||||
|
||||
/** Helper method to ensure that array buffer objects are disabled. If they are enabled, we'll throw an OpenGLException */
|
||||
static void ensureIndirectBOdisabled(ContextCapabilities caps) {
|
||||
if ( StateTracker.getReferencesStack(caps).getReferences().indirectBuffer != 0 )
|
||||
throw new OpenGLException("Cannot use Buffers when Draw Indirect Object is enabled");
|
||||
}
|
||||
|
||||
/** Helper method to ensure that array buffer objects are enabled. If they are disabled, we'll throw an OpenGLException */
|
||||
static void ensureIndirectBOenabled(ContextCapabilities caps) {
|
||||
if ( StateTracker.getReferencesStack(caps).getReferences().indirectBuffer == 0 )
|
||||
throw new OpenGLException("Cannot use offsets when Draw Indirect Object is disabled");
|
||||
}
|
||||
|
||||
/** Helper method to ensure that pixel pack buffer objects are disabled. If they are enabled, we'll throw an OpenGLException */
|
||||
static void ensurePackPBOdisabled(ContextCapabilities caps) {
|
||||
if ( StateTracker.getReferencesStack(caps).getReferences().pixelPackBuffer != 0 )
|
||||
|
|
|
|||
|
|
@ -199,7 +199,13 @@ 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");
|
||||
|
||||
// ----------------------[ 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) )
|
||||
|
|
|
|||
|
|
@ -76,6 +76,9 @@ final class StateTracker {
|
|||
case GL21.GL_PIXEL_UNPACK_BUFFER:
|
||||
references_stack.getReferences().pixelUnpackBuffer = buffer;
|
||||
break;
|
||||
case GL40.GL_DRAW_INDIRECT_BUFFER:
|
||||
references_stack.getReferences().indirectBuffer = buffer;
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
47
src/java/org/lwjgl/util/generator/Alternate.java
Normal file
47
src/java/org/lwjgl/util/generator/Alternate.java
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
* 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.util.generator;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* When a method is annonated with @Alternate, no native stub will be created and the Java method will be renamed to value().
|
||||
* This can be useful when we want to provide an alternate GL call with different arguments (created by different annotations)
|
||||
*
|
||||
* @author spasi <spasi@users.sourceforge.net>
|
||||
*/
|
||||
@Target({ ElementType.METHOD })
|
||||
public @interface Alternate {
|
||||
/** This must match an existing GL method name. */
|
||||
String value();
|
||||
}
|
||||
|
|
@ -42,5 +42,6 @@ public enum BufferKind {
|
|||
UnpackPBO,
|
||||
PackPBO,
|
||||
ElementVBO,
|
||||
ArrayVBO
|
||||
ArrayVBO,
|
||||
IndirectBO
|
||||
}
|
||||
|
|
|
|||
|
|
@ -188,7 +188,7 @@ public class GLTypeMap implements TypeMap {
|
|||
private static Class[] getValidBufferTypes(Class type) {
|
||||
if ( type.equals(IntBuffer.class) )
|
||||
return new Class[] { GLbitfield.class, GLenum.class, GLhandleARB.class, GLint.class,
|
||||
GLsizei.class, GLuint.class };
|
||||
GLsizei.class, GLuint.class, GLvoid.class };
|
||||
else if ( type.equals(FloatBuffer.class) )
|
||||
return new Class[] { GLclampf.class, GLfloat.class };
|
||||
else if ( type.equals(ByteBuffer.class) )
|
||||
|
|
|
|||
|
|
@ -41,7 +41,10 @@ package org.lwjgl.util.generator;
|
|||
import java.lang.annotation.Target;
|
||||
import java.lang.annotation.ElementType;
|
||||
|
||||
import com.sun.mirror.type.PrimitiveType;
|
||||
|
||||
@NativeType
|
||||
@Target({ElementType.PARAMETER, ElementType.METHOD})
|
||||
public @interface GLvoid {
|
||||
PrimitiveType.Kind value() default PrimitiveType.Kind.BYTE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -138,7 +138,7 @@ public class GeneratorVisitor extends SimpleDeclarationVisitor {
|
|||
break;
|
||||
}
|
||||
}
|
||||
if (!found_auto_size_param && param.getAnnotation(Result.class) == null)
|
||||
if (!found_auto_size_param && param.getAnnotation(Result.class) == null && param.getAnnotation(Constant.class) == null)
|
||||
throw new RuntimeException(param + " has no Check, Result nor Constant annotation and no other parameters has" +
|
||||
" an @AutoSize annotation on it in method " + method);
|
||||
}
|
||||
|
|
@ -146,8 +146,8 @@ public class GeneratorVisitor extends SimpleDeclarationVisitor {
|
|||
throw new RuntimeException(param + " can't be annotated with both CachedReference and Result");
|
||||
if (param.getAnnotation(BufferObject.class) != null && param.getAnnotation(Result.class) != null)
|
||||
throw new RuntimeException(param + " can't be annotated with both BufferObject and Result");
|
||||
if (param.getAnnotation(Constant.class) != null)
|
||||
throw new RuntimeException("Buffer parameter " + param + " cannot be Constant");
|
||||
//if (param.getAnnotation(Constant.class) != null)
|
||||
//throw new RuntimeException("Buffer parameter " + param + " cannot be Constant");
|
||||
} else {
|
||||
if (param.getAnnotation(BufferObject.class) != null)
|
||||
throw new RuntimeException(param + " type is not a buffer, but annotated as a BufferObject");
|
||||
|
|
|
|||
|
|
@ -71,10 +71,12 @@ public class JavaMethodsGenerator {
|
|||
if ( method.getAnnotation(CachedResult.class) != null && !method.getAnnotation(CachedResult.class).isRange() ) {
|
||||
printMethodWithMultiType(env, type_map, writer, interface_decl, method, TypeInfo.getDefaultTypeInfoMap(method), Mode.CACHEDRESULT, generate_error_checks, context_specific);
|
||||
}
|
||||
printJavaNativeStub(writer, method, Mode.NORMAL, generate_error_checks, context_specific);
|
||||
if (Utils.hasMethodBufferObjectParameter(method)) {
|
||||
printMethodWithMultiType(env, type_map, writer, interface_decl, method, TypeInfo.getDefaultTypeInfoMap(method), Mode.BUFFEROBJECT, generate_error_checks, context_specific);
|
||||
printJavaNativeStub(writer, method, Mode.BUFFEROBJECT, generate_error_checks, context_specific);
|
||||
if ( method.getAnnotation(Alternate.class) == null ) {
|
||||
printJavaNativeStub(writer, method, Mode.NORMAL, generate_error_checks, context_specific);
|
||||
if (Utils.hasMethodBufferObjectParameter(method)) {
|
||||
printMethodWithMultiType(env, type_map, writer, interface_decl, method, TypeInfo.getDefaultTypeInfoMap(method), Mode.BUFFEROBJECT, generate_error_checks, context_specific);
|
||||
printJavaNativeStub(writer, method, Mode.BUFFEROBJECT, generate_error_checks, context_specific);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -194,7 +196,9 @@ public class JavaMethodsGenerator {
|
|||
writer.print("\tpublic static ");
|
||||
printResultType(writer, method, false);
|
||||
StripPostfix strip_annotation = method.getAnnotation(StripPostfix.class);
|
||||
String method_name = method.getSimpleName();
|
||||
String method_name;
|
||||
Alternate alt_annotation = method.getAnnotation(Alternate.class);
|
||||
method_name = alt_annotation == null ? method.getSimpleName() : alt_annotation.value();
|
||||
if (strip_annotation != null && mode == Mode.NORMAL)
|
||||
method_name = getPostfixStrippedName(type_map, interface_decl, method);
|
||||
writer.print(" " + method_name + "(");
|
||||
|
|
@ -298,7 +302,10 @@ public class JavaMethodsGenerator {
|
|||
postfix_parameter.getType().accept(translator);
|
||||
postfix = translator.getSignature();
|
||||
}
|
||||
String method_name = method.getSimpleName();
|
||||
String method_name;
|
||||
Alternate alt_annotation = method.getAnnotation(Alternate.class);
|
||||
method_name = alt_annotation == null ? method.getSimpleName() : alt_annotation.value();
|
||||
|
||||
String extension_postfix = "NULL".equals(strip_annotation.extension()) ? getExtensionPostfix(interface_decl) : strip_annotation.extension();
|
||||
String result;
|
||||
|
||||
|
|
@ -491,7 +498,7 @@ public class JavaMethodsGenerator {
|
|||
can_be_null = check_annotation.canBeNull();
|
||||
}
|
||||
NullTerminated null_terminated = param.getAnnotation(NullTerminated.class);
|
||||
if (Buffer.class.isAssignableFrom(java_type)) {
|
||||
if (Buffer.class.isAssignableFrom(java_type) && param.getAnnotation(Constant.class) == null) {
|
||||
boolean indirect_buffer_allowed = false && param.getAnnotation(CachedReference.class) == null; // DISABLED: indirect buffer support
|
||||
boolean out_parameter = param.getAnnotation(OutParameter.class) != null;
|
||||
TypeInfo typeinfo = typeinfos.get(param);
|
||||
|
|
|
|||
|
|
@ -168,7 +168,9 @@ public class TypeInfo {
|
|||
}
|
||||
}
|
||||
Class type;
|
||||
PrimitiveType.Kind kind = type_map.getPrimitiveTypeFromNativeType(annotation_type);
|
||||
PrimitiveType.Kind kind;
|
||||
GLvoid void_annotation = param.getAnnotation(GLvoid.class);
|
||||
kind = void_annotation == null ? type_map.getPrimitiveTypeFromNativeType(annotation_type) : void_annotation.value();
|
||||
if (Utils.getNIOBufferType(decl_type) != null)
|
||||
type = getBufferTypeFromPrimitiveKind(kind);
|
||||
else
|
||||
|
|
|
|||
|
|
@ -253,7 +253,9 @@ public class Utils {
|
|||
}
|
||||
|
||||
public static String getSimpleNativeMethodName(MethodDeclaration method, boolean generate_error_checks, boolean context_specific) {
|
||||
String method_name = method.getSimpleName();
|
||||
String method_name;
|
||||
Alternate alt_annotation = method.getAnnotation(Alternate.class);
|
||||
method_name = alt_annotation == null ? method.getSimpleName() : alt_annotation.value();
|
||||
if (isMethodIndirect(generate_error_checks, context_specific, method))
|
||||
method_name = OVERLOADED_METHOD_PREFIX + method_name;
|
||||
return method_name;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue