mirror of
https://github.com/shadowfacts/lwjgl2-arm64.git
synced 2026-04-06 06:53:59 +00:00
Added EXT_timer_query extension
Added support for long (int64) types
This commit is contained in:
parent
cce631748d
commit
843ce1bc27
21 changed files with 369 additions and 103 deletions
|
|
@ -37,6 +37,7 @@ import java.nio.DoubleBuffer;
|
|||
import java.nio.FloatBuffer;
|
||||
import java.nio.IntBuffer;
|
||||
import java.nio.ShortBuffer;
|
||||
import java.nio.LongBuffer;
|
||||
|
||||
/**
|
||||
* <p>A class to check buffer boundaries in general. If there is unsufficient space
|
||||
|
|
@ -46,7 +47,7 @@ import java.nio.ShortBuffer;
|
|||
* @author cix_foo <cix_foo@users.sourceforge.net>
|
||||
* @author elias_naur <elias_naur@users.sourceforge.net>
|
||||
* @version $Revision$
|
||||
* $Id$
|
||||
* $Id$
|
||||
*/
|
||||
public class BufferChecks {
|
||||
/** Static methods only! */
|
||||
|
|
@ -80,7 +81,7 @@ public class BufferChecks {
|
|||
if (o == null)
|
||||
throw new IllegalArgumentException("Null argument");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Helper methods to ensure a buffer is direct or null.
|
||||
*/
|
||||
|
|
@ -90,12 +91,6 @@ public class BufferChecks {
|
|||
}
|
||||
}
|
||||
|
||||
public static void checkDirectOrNull(FloatBuffer buf) {
|
||||
if (buf != null) {
|
||||
checkDirect(buf);
|
||||
}
|
||||
}
|
||||
|
||||
public static void checkDirectOrNull(ShortBuffer buf) {
|
||||
if (buf != null) {
|
||||
checkDirect(buf);
|
||||
|
|
@ -108,6 +103,18 @@ public class BufferChecks {
|
|||
}
|
||||
}
|
||||
|
||||
public static void checkDirectOrNull(LongBuffer buf) {
|
||||
if (buf != null) {
|
||||
checkDirect(buf);
|
||||
}
|
||||
}
|
||||
|
||||
public static void checkDirectOrNull(FloatBuffer buf) {
|
||||
if (buf != null) {
|
||||
checkDirect(buf);
|
||||
}
|
||||
}
|
||||
|
||||
public static void checkDirectOrNull(DoubleBuffer buf) {
|
||||
if (buf != null) {
|
||||
checkDirect(buf);
|
||||
|
|
@ -118,14 +125,16 @@ public class BufferChecks {
|
|||
* Helper methods to ensure a buffer is direct (and, implicitly, non-null).
|
||||
*/
|
||||
public static void checkDirectBuffer(Buffer buf) {
|
||||
if (buf instanceof ByteBuffer)
|
||||
if (buf instanceof FloatBuffer)
|
||||
checkDirect((FloatBuffer)buf);
|
||||
else if (buf instanceof ByteBuffer)
|
||||
checkDirect((ByteBuffer)buf);
|
||||
else if (buf instanceof ShortBuffer)
|
||||
checkDirect((ShortBuffer)buf);
|
||||
else if (buf instanceof IntBuffer)
|
||||
checkDirect((IntBuffer)buf);
|
||||
else if (buf instanceof FloatBuffer)
|
||||
checkDirect((FloatBuffer)buf);
|
||||
else if (buf instanceof LongBuffer)
|
||||
checkDirect((LongBuffer)buf);
|
||||
else if (buf instanceof DoubleBuffer)
|
||||
checkDirect((DoubleBuffer)buf);
|
||||
else
|
||||
|
|
@ -138,12 +147,6 @@ public class BufferChecks {
|
|||
}
|
||||
}
|
||||
|
||||
public static void checkDirect(FloatBuffer buf) {
|
||||
if (!buf.isDirect()) {
|
||||
throw new IllegalArgumentException("FloatBuffer is not direct");
|
||||
}
|
||||
}
|
||||
|
||||
public static void checkDirect(ShortBuffer buf) {
|
||||
if (!buf.isDirect()) {
|
||||
throw new IllegalArgumentException("ShortBuffer is not direct");
|
||||
|
|
@ -156,9 +159,21 @@ public class BufferChecks {
|
|||
}
|
||||
}
|
||||
|
||||
public static void checkDirect(LongBuffer buf) {
|
||||
if (!buf.isDirect()) {
|
||||
throw new IllegalArgumentException("LongBuffer is not direct");
|
||||
}
|
||||
}
|
||||
|
||||
public static void checkDirect(FloatBuffer buf) {
|
||||
if (!buf.isDirect()) {
|
||||
throw new IllegalArgumentException("FloatBuffer is not direct");
|
||||
}
|
||||
}
|
||||
|
||||
public static void checkDirect(DoubleBuffer buf) {
|
||||
if (!buf.isDirect()) {
|
||||
throw new IllegalArgumentException("IntBuffer is not direct");
|
||||
throw new IllegalArgumentException("DoubleBuffer is not direct");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -183,12 +198,17 @@ public class BufferChecks {
|
|||
checkDirect(buf);
|
||||
}
|
||||
|
||||
public static void checkBuffer(ShortBuffer buf, int size) {
|
||||
checkBufferSize(buf, size);
|
||||
checkDirect(buf);
|
||||
}
|
||||
|
||||
public static void checkBuffer(IntBuffer buf, int size) {
|
||||
checkBufferSize(buf, size);
|
||||
checkDirect(buf);
|
||||
}
|
||||
|
||||
public static void checkBuffer(ShortBuffer buf, int size) {
|
||||
public static void checkBuffer(LongBuffer buf, int size) {
|
||||
checkBufferSize(buf, size);
|
||||
checkDirect(buf);
|
||||
}
|
||||
|
|
@ -221,11 +241,15 @@ public class BufferChecks {
|
|||
checkBuffer(buf, DEFAULT_BUFFER_SIZE);
|
||||
}
|
||||
|
||||
public static void checkBuffer(FloatBuffer buf) {
|
||||
public static void checkBuffer(IntBuffer buf) {
|
||||
checkBuffer(buf, DEFAULT_BUFFER_SIZE);
|
||||
}
|
||||
|
||||
public static void checkBuffer(IntBuffer buf) {
|
||||
public static void checkBuffer(LongBuffer buf) {
|
||||
checkBuffer(buf, DEFAULT_BUFFER_SIZE);
|
||||
}
|
||||
|
||||
public static void checkBuffer(FloatBuffer buf) {
|
||||
checkBuffer(buf, DEFAULT_BUFFER_SIZE);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,31 +1,31 @@
|
|||
/*
|
||||
/*
|
||||
* Copyright (c) 2002-2004 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
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
*
|
||||
* * 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
|
||||
* * 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
|
||||
* 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
|
||||
* 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.
|
||||
*/
|
||||
|
|
@ -50,16 +50,16 @@ import java.nio.ShortBuffer;
|
|||
*/
|
||||
|
||||
public final class BufferUtils {
|
||||
|
||||
|
||||
/**
|
||||
* Construct a direct native-ordered bytebuffer with the specified size.
|
||||
* @param size The size, in bytes
|
||||
* @return a ByteBuffer
|
||||
*/
|
||||
*/
|
||||
public static ByteBuffer createByteBuffer(int size) {
|
||||
return ByteBuffer.allocateDirect(size).order(ByteOrder.nativeOrder());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Construct a direct native-order shortbuffer with the specified number
|
||||
* of elements.
|
||||
|
|
@ -80,6 +80,16 @@ public final class BufferUtils {
|
|||
return createByteBuffer(size << 2).asIntBuffer();
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a direct native-order intbuffer with the specified number
|
||||
* of elements.
|
||||
* @param size The size, in ints
|
||||
* @return an IntBuffer
|
||||
*/
|
||||
public static LongBuffer createLongBuffer(int size) {
|
||||
return createByteBuffer(size << 3).asLongBuffer();
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a direct native-order floatbuffer with the specified number
|
||||
* of elements.
|
||||
|
|
@ -90,6 +100,16 @@ public final class BufferUtils {
|
|||
return createByteBuffer(size << 2).asFloatBuffer();
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a direct native-order doublebuffer with the specified number
|
||||
* of elements.
|
||||
* @param size The size, in floats
|
||||
* @return a FloatBuffer
|
||||
*/
|
||||
public static DoubleBuffer createDoubleBuffer(int size) {
|
||||
return createByteBuffer(size << 3).asDoubleBuffer();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return n, where buffer_element_size=2^n.
|
||||
*/
|
||||
|
|
@ -106,16 +126,6 @@ public final class BufferUtils {
|
|||
throw new IllegalStateException("Unsupported buffer type");
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a direct native-order doublebuffer with the specified number
|
||||
* of elements.
|
||||
* @param size The size, in floats
|
||||
* @return a FloatBuffer
|
||||
*/
|
||||
public static DoubleBuffer createDoubleBuffer(int size) {
|
||||
return createByteBuffer(size << 3).asDoubleBuffer();
|
||||
}
|
||||
|
||||
/**
|
||||
* A helper function which is used to get the byte offset in an arbitrary buffer
|
||||
* based on its position
|
||||
|
|
|
|||
|
|
@ -76,6 +76,8 @@ public class GLTypeMap implements TypeMap {
|
|||
native_types_to_primitive.put(GLsizeiptrARB.class, PrimitiveType.Kind.LONG);
|
||||
native_types_to_primitive.put(GLubyte.class, PrimitiveType.Kind.BYTE);
|
||||
native_types_to_primitive.put(GLvoid.class, PrimitiveType.Kind.BYTE);
|
||||
native_types_to_primitive.put(GLint64EXT.class, PrimitiveType.Kind.LONG);
|
||||
native_types_to_primitive.put(GLuint64EXT.class, PrimitiveType.Kind.LONG);
|
||||
}
|
||||
|
||||
public PrimitiveType.Kind getPrimitiveTypeFromNativeType(Class native_type) {
|
||||
|
|
@ -106,6 +108,10 @@ public class GLTypeMap implements TypeMap {
|
|||
return Signedness.UNSIGNED;
|
||||
else if (GLbyte.class.equals(type))
|
||||
return Signedness.SIGNED;
|
||||
else if (GLuint64EXT.class.equals(type))
|
||||
return Signedness.UNSIGNED;
|
||||
else if (GLint64EXT.class.equals(type))
|
||||
return Signedness.SIGNED;
|
||||
else
|
||||
return Signedness.NONE;
|
||||
}
|
||||
|
|
@ -129,6 +135,10 @@ public class GLTypeMap implements TypeMap {
|
|||
return "d";
|
||||
else if (annotation_type.equals(GLhalf.class))
|
||||
return "h";
|
||||
else if (annotation_type.equals(GLuint64EXT.class))
|
||||
return "l";
|
||||
else if (annotation_type.equals(GLint64EXT.class))
|
||||
return "l";
|
||||
else if (annotation_type.equals(GLboolean.class) || annotation_type.equals(GLvoid.class))
|
||||
return "";
|
||||
else
|
||||
|
|
@ -153,6 +163,9 @@ public class GLTypeMap implements TypeMap {
|
|||
case BYTE:
|
||||
type = GLbyte.class;
|
||||
break;
|
||||
case LONG:
|
||||
type = GLint64EXT.class;
|
||||
break;
|
||||
case BOOLEAN:
|
||||
type = GLboolean.class;
|
||||
break;
|
||||
|
|
@ -182,13 +195,15 @@ public class GLTypeMap implements TypeMap {
|
|||
return new Class[]{GLhalf.class, GLshort.class, GLushort.class};
|
||||
else if (type.equals(DoubleBuffer.class))
|
||||
return new Class[]{GLclampd.class, GLdouble.class};
|
||||
else if (type.equals(LongBuffer.class))
|
||||
return new Class[]{GLint64EXT.class, GLuint64EXT.class};
|
||||
else
|
||||
return new Class[]{};
|
||||
}
|
||||
|
||||
private static Class[] getValidPrimitiveTypes(Class type) {
|
||||
if (type.equals(long .class))
|
||||
return new Class[]{GLintptrARB.class, GLuint.class, GLintptr.class, GLsizeiptrARB.class, GLsizeiptr.class};
|
||||
if (type.equals(long.class))
|
||||
return new Class[]{GLintptrARB.class, GLuint.class, GLintptr.class, GLsizeiptrARB.class, GLsizeiptr.class, GLint64EXT.class, GLuint64EXT.class};
|
||||
else if (type.equals(int.class))
|
||||
return new Class[]{GLbitfield.class, GLenum.class, GLhandleARB.class, GLint.class, GLuint.class,
|
||||
GLsizei.class};
|
||||
|
|
@ -242,6 +257,10 @@ public class GLTypeMap implements TypeMap {
|
|||
return GLbyte.class;
|
||||
else if (GLbyte.class.equals(type))
|
||||
return GLubyte.class;
|
||||
else if (GLuint64EXT.class.equals(type))
|
||||
return GLint64EXT.class;
|
||||
else if (GLint64EXT.class.equals(type))
|
||||
return GLuint64EXT.class;
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
|
|
|||
40
src/java/org/lwjgl/util/generator/GLint64EXT.java
Normal file
40
src/java/org/lwjgl/util/generator/GLint64EXT.java
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* Copyright (c) 2002-2004 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.Target;
|
||||
import java.lang.annotation.ElementType;
|
||||
|
||||
@NativeType
|
||||
@Target({ElementType.PARAMETER, ElementType.METHOD})
|
||||
public @interface GLint64EXT {
|
||||
}
|
||||
40
src/java/org/lwjgl/util/generator/GLuint64EXT.java
Normal file
40
src/java/org/lwjgl/util/generator/GLuint64EXT.java
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* Copyright (c) 2002-2004 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.Target;
|
||||
import java.lang.annotation.ElementType;
|
||||
|
||||
@NativeType
|
||||
@Target({ElementType.PARAMETER, ElementType.METHOD})
|
||||
public @interface GLuint64EXT {
|
||||
}
|
||||
|
|
@ -106,6 +106,8 @@ public class NativeTypeTranslator implements TypeVisitor {
|
|||
return PrimitiveType.Kind.BYTE;
|
||||
else if (FloatBuffer.class.equals(c))
|
||||
return PrimitiveType.Kind.FLOAT;
|
||||
else if (LongBuffer.class.equals(c))
|
||||
return PrimitiveType.Kind.LONG;
|
||||
else
|
||||
throw new RuntimeException(c + " is not allowed");
|
||||
}
|
||||
|
|
@ -183,7 +185,7 @@ public class NativeTypeTranslator implements TypeVisitor {
|
|||
public void visitReferenceType(ReferenceType t) {
|
||||
throw new RuntimeException(t + " is not allowed");
|
||||
}
|
||||
|
||||
|
||||
public void visitTypeMirror(TypeMirror t) {
|
||||
throw new RuntimeException(t + " is not allowed");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -81,6 +81,8 @@ public class PostfixTranslator implements TypeVisitor {
|
|||
return PrimitiveType.Kind.BYTE;
|
||||
else if (FloatBuffer.class.equals(c))
|
||||
return PrimitiveType.Kind.FLOAT;
|
||||
else if (LongBuffer.class.equals(c))
|
||||
return PrimitiveType.Kind.LONG;
|
||||
else
|
||||
throw new RuntimeException(c + " is not allowed");
|
||||
}
|
||||
|
|
@ -150,6 +152,9 @@ public class PostfixTranslator implements TypeVisitor {
|
|||
case BYTE:
|
||||
type = "b";
|
||||
break;
|
||||
case LONG:
|
||||
type = "l";
|
||||
break;
|
||||
default:
|
||||
throw new RuntimeException(kind + " is not allowed");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -116,6 +116,9 @@ public class TypeInfo {
|
|||
case SHORT:
|
||||
type = ShortBuffer.class;
|
||||
break;
|
||||
case LONG:
|
||||
type = LongBuffer.class;
|
||||
break;
|
||||
case BYTE: /* fall through */
|
||||
case BOOLEAN:
|
||||
type = ByteBuffer.class;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue