diff --git a/build.xml b/build.xml new file mode 100644 index 0000000..60d236a --- /dev/null +++ b/build.xml @@ -0,0 +1,499 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Build aborted by user. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + lwjgl.java.windows.version = ${lwjgl.java.windows.version} + lwjgl.native.windows.version = ${lwjgl.native.windows.version} + lwjgl.java.linux.version = ${lwjgl.java.linux.version} + lwjgl.native.linux.version = ${lwjgl.native.linux.version} + lwjgl.java.macosx.version = ${lwjgl.java.macosx.version} + lwjgl.native.macosx.version = ${lwjgl.native.macosx.version} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Lightweight Java Game Toolkit]]> + Copyright © 2002-2009 lwjgl.org. All Rights Reserved.]]> + + + diff --git a/platform_build/build-applet.xml b/platform_build/build-applet.xml new file mode 100644 index 0000000..eb2e085 --- /dev/null +++ b/platform_build/build-applet.xml @@ -0,0 +1,151 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/platform_build/build-definitions.xml b/platform_build/build-definitions.xml new file mode 100644 index 0000000..8c52402 --- /dev/null +++ b/platform_build/build-definitions.xml @@ -0,0 +1,159 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/platform_build/build-generator.xml b/platform_build/build-generator.xml new file mode 100644 index 0000000..67bfe17 --- /dev/null +++ b/platform_build/build-generator.xml @@ -0,0 +1,143 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/platform_build/build-webstart.xml b/platform_build/build-webstart.xml new file mode 100644 index 0000000..ad3bf05 --- /dev/null +++ b/platform_build/build-webstart.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/platform_build/build-webstart.xml.bak b/platform_build/build-webstart.xml.bak new file mode 100644 index 0000000..337b22a --- /dev/null +++ b/platform_build/build-webstart.xml.bak @@ -0,0 +1,85 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/platform_build/linux_ant/build.xml b/platform_build/linux_ant/build.xml new file mode 100644 index 0000000..7e45c52 --- /dev/null +++ b/platform_build/linux_ant/build.xml @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/platform_build/macosx_ant/build-symbol-list b/platform_build/macosx_ant/build-symbol-list new file mode 100644 index 0000000..ca14359 --- /dev/null +++ b/platform_build/macosx_ant/build-symbol-list @@ -0,0 +1,4 @@ +#!/bin/sh + +nm -g "$1"/*.o | grep "Java_" | cut -d ' ' -f3 | cut -c 1- +nm -g "$1"/*.o | grep "JNI_" | cut -d ' ' -f3 | cut -c 1- diff --git a/platform_build/macosx_ant/build.xml b/platform_build/macosx_ant/build.xml new file mode 100644 index 0000000..a3d0385 --- /dev/null +++ b/platform_build/macosx_ant/build.xml @@ -0,0 +1,100 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/platform_build/mingw_ant/build.xml b/platform_build/mingw_ant/build.xml new file mode 100644 index 0000000..2244ce9 --- /dev/null +++ b/platform_build/mingw_ant/build.xml @@ -0,0 +1,66 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + EXPORTS + JAWT_GetAWT + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/platform_build/windows_ant/build.xml b/platform_build/windows_ant/build.xml new file mode 100644 index 0000000..83a8f10 --- /dev/null +++ b/platform_build/windows_ant/build.xml @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java/org/lwjgl/BufferChecks.java b/src/java/org/lwjgl/BufferChecks.java new file mode 100644 index 0000000..16141d1 --- /dev/null +++ b/src/java/org/lwjgl/BufferChecks.java @@ -0,0 +1,191 @@ +/* + * 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.Buffer; +import java.nio.ByteBuffer; +import java.nio.DoubleBuffer; +import java.nio.FloatBuffer; +import java.nio.IntBuffer; +import java.nio.ShortBuffer; +import java.nio.LongBuffer; + +/** + *

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. + *

+ * @author cix_foo + * @author elias_naur + * @version $Revision: 3279 $ + * $Id: BufferChecks.java 3279 2010-03-11 21:06:49Z spasi $ + */ +public class BufferChecks { + /** Static methods only! */ + private BufferChecks() { + } + + /** + * Helper methods to ensure a function pointer is not-null (0) + */ + public static void checkFunctionAddress(long pointer) { + if (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 (buf.get(buf.limit() - 1) != 0) { + throw new IllegalArgumentException("Missing null termination"); + } + } + + public static void checkNullTerminated(ByteBuffer buf, int count) { + 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 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"); + } + + /** + * Helper methods to ensure a buffer is direct (and, implicitly, non-null). + */ + public static void checkDirect(ByteBuffer buf) { + if (!buf.isDirect()) { + throw new IllegalArgumentException("ByteBuffer is not direct"); + } + } + + public static void checkDirect(ShortBuffer buf) { + if (!buf.isDirect()) { + throw new IllegalArgumentException("ShortBuffer is not direct"); + } + } + + public static void checkDirect(IntBuffer buf) { + if (!buf.isDirect()) { + throw new IllegalArgumentException("IntBuffer is not direct"); + } + } + + 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("DoubleBuffer is not direct"); + } + } + + /** + * 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); + } + + /** + * 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 (buf.remaining() < size) { + throwBufferSizeException(buf, size); + } + } + + public static void checkBuffer(ByteBuffer buf, int size) { + checkBufferSize(buf, size); + 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(LongBuffer buf, int size) { + checkBufferSize(buf, size); + checkDirect(buf); + } + + public static void checkBuffer(FloatBuffer buf, int size) { + checkBufferSize(buf, size); + checkDirect(buf); + } + + public static void checkBuffer(DoubleBuffer buf, int size) { + checkBufferSize(buf, size); + checkDirect(buf); + } +} diff --git a/src/java/org/lwjgl/BufferUtils.java b/src/java/org/lwjgl/BufferUtils.java new file mode 100644 index 0000000..a5caf01 --- /dev/null +++ b/src/java/org/lwjgl/BufferUtils.java @@ -0,0 +1,148 @@ +/* + * 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.Buffer; +import java.nio.ByteBuffer; +import java.nio.ByteOrder; +import java.nio.CharBuffer; +import java.nio.DoubleBuffer; +import java.nio.FloatBuffer; +import java.nio.IntBuffer; +import java.nio.LongBuffer; +import java.nio.ShortBuffer; + +/** + * Some often-used Buffer code for creating native buffers of the appropriate size. + * + * @author $Author: matzon $ + * @version $Revision: 2983 $ + * $Id: BufferUtils.java 2983 2008-04-07 18:36:09Z matzon $ + */ + +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. + * @param size The size, in shorts + * @return a ShortBuffer + */ + public static ShortBuffer createShortBuffer(int size) { + return createByteBuffer(size << 1).asShortBuffer(); + } + + /** + * Construct a direct native-order charbuffer with the specified number + * of elements. + * @param size The size, in chars + * @return an CharBuffer + */ + public static CharBuffer createCharBuffer(int size) { + return createByteBuffer(size << 1).asCharBuffer(); + } + + /** + * Construct a direct native-order intbuffer with the specified number + * of elements. + * @param size The size, in ints + * @return an IntBuffer + */ + public static IntBuffer createIntBuffer(int size) { + return createByteBuffer(size << 2).asIntBuffer(); + } + + /** + * Construct a direct native-order longbuffer with the specified number + * of elements. + * @param size The size, in longs + * @return an LongBuffer + */ + public static LongBuffer createLongBuffer(int size) { + return createByteBuffer(size << 3).asLongBuffer(); + } + + /** + * Construct a direct native-order floatbuffer with the specified number + * of elements. + * @param size The size, in floats + * @return a FloatBuffer + */ + public static FloatBuffer createFloatBuffer(int size) { + 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. + */ + 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); + } + +} diff --git a/src/java/org/lwjgl/DefaultSysImplementation.java b/src/java/org/lwjgl/DefaultSysImplementation.java new file mode 100644 index 0000000..98f7260 --- /dev/null +++ b/src/java/org/lwjgl/DefaultSysImplementation.java @@ -0,0 +1,56 @@ +/* + * 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; + + +/** + * + * @author elias_naur + * @version $Revision: 3055 $ + * $Id: DefaultSysImplementation.java 3055 2008-04-30 14:58:47Z elias_naur $ + */ +abstract class DefaultSysImplementation implements SysImplementation { + public native int getJNIVersion(); + public native void setDebug(boolean debug); + + public long getTimerResolution() { + return 1000; + } + + public boolean has64Bit() { + return false; + } + + public abstract long getTime(); + public abstract void alert(String title, String message); + public abstract String getClipboard(); +} diff --git a/src/java/org/lwjgl/J2SESysImplementation.java b/src/java/org/lwjgl/J2SESysImplementation.java new file mode 100644 index 0000000..bf1b669 --- /dev/null +++ b/src/java/org/lwjgl/J2SESysImplementation.java @@ -0,0 +1,73 @@ +/* + * 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 javax.swing.JOptionPane; +import javax.swing.UIManager; + +/** + * A SysImplementation which delegates as much as it can to J2SE. + *

+ * @author $Author: matzon $ + * @version $Revision: 2983 $ + * $Id: J2SESysImplementation.java 2983 2008-04-07 18:36:09Z matzon $ + */ +abstract class J2SESysImplementation extends DefaultSysImplementation { + + public long getTime() { + return System.currentTimeMillis(); + } + + public void alert(String title, String message) { + try { + UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); + } catch(Exception e) { + LWJGLUtil.log("Caught exception while setting LAF: " + e); + } + JOptionPane.showMessageDialog(null, message, title, JOptionPane.WARNING_MESSAGE); + } + + public String getClipboard() { + try { + java.awt.datatransfer.Clipboard clipboard = java.awt.Toolkit.getDefaultToolkit().getSystemClipboard(); + java.awt.datatransfer.Transferable transferable = clipboard.getContents(null); + if (transferable.isDataFlavorSupported(java.awt.datatransfer.DataFlavor.stringFlavor)) { + return (String)transferable.getTransferData(java.awt.datatransfer.DataFlavor.stringFlavor); + } + } catch (Exception e) { + LWJGLUtil.log("Exception while getting clipboard: " + e); + } + return null; + } + + +} diff --git a/src/java/org/lwjgl/LWJGLException.java b/src/java/org/lwjgl/LWJGLException.java new file mode 100644 index 0000000..d104152 --- /dev/null +++ b/src/java/org/lwjgl/LWJGLException.java @@ -0,0 +1,79 @@ +/* + * 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; + +/** + *

+ * This exception is supplied to make exception handling more generic for LWJGL + * specific exceptions + *

+ * + * @author Brian Matzon + * @version $Revision: 2983 $ + * $Id: LWJGLException.java 2983 2008-04-07 18:36:09Z matzon $ + */ +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); + } +} diff --git a/src/java/org/lwjgl/LWJGLUtil.java b/src/java/org/lwjgl/LWJGLUtil.java new file mode 100644 index 0000000..3515478 --- /dev/null +++ b/src/java/org/lwjgl/LWJGLUtil.java @@ -0,0 +1,491 @@ +/* + * 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.Method; +import java.nio.ByteBuffer; +import java.security.AccessController; +import java.security.PrivilegedAction; +import java.security.PrivilegedActionException; +import java.security.PrivilegedExceptionAction; +import java.util.ArrayList; +import java.util.List; +import java.util.StringTokenizer; + + +/** + *

+ * Internal library methods + *

+ * + * @author Brian Matzon + * @version $Revision: 2983 $ + * $Id: LWJGLUtil.java 2983 2008-04-07 18:36:09Z matzon $ + */ +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"; + + /** LWJGL Logo - 16 by 16 pixels */ + public static final ByteBuffer LWJGLIcon16x16 = BufferUtils.createByteBuffer(16 * 16 * 4).put(new byte[] { + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -2, -1, -1, -1, -62, -41, -24, -1, 116, -92, -53, -1, 80, -117, + -67, -1, 84, -114, -65, -1, -122, -81, -46, -1, -25, -17, -10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -11, -11, -11, -1, + -115, -113, -111, -1, 118, -126, -115, -1, 125, -115, -101, -1, -124, -103, -86, -1, -108, -73, -43, -1, + 58, 125, -75, -1, 72, -122, -70, -1, -38, -25, -15, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -12, -8, -5, -1, -100, -98, -96, -1, 0, 0, 0, -1, 0, 0, 0, -1, + 0, 0, 0, -1, 0, 0, 0, -1, -28, -28, -28, -1, -124, -83, -48, -1, 58, 125, -75, -1, 91, -110, -63, -1, -4, + -3, -2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -111, -74, -43, + -1, 95, 95, 95, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 34, 34, 34, -1, -1, -1, -1, -1, -24, -16, -10, + -1, 57, 124, -75, -1, 58, 125, -75, -1, -60, -40, -23, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -58, -39, -23, -1, -127, -85, -50, -1, 29, 29, 29, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, + -1, 102, 102, 102, -1, -1, -1, -1, -1, -48, -32, -19, -1, 58, 125, -75, -1, 58, 125, -75, -1, -115, -76, + -44, -1, -1, -1, -1, -1, -14, -14, -14, -1, -91, -91, -91, -1, -33, -33, -33, -1, -94, -63, -36, -1, -80, + -59, -42, -1, 10, 10, 10, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, -88, -88, -88, -1, -1, -1, -1, -1, + -105, -70, -40, -1, 58, 125, -75, -1, 58, 125, -75, -1, 113, -95, -54, -1, -1, -1, -1, -1, -95, -95, -95, + -1, 0, 0, 0, -1, 1, 1, 1, -1, 35, 35, 35, -1, -52, -52, -52, -1, -48, -48, -48, -1, -91, -91, -91, -1, + -124, -124, -124, -1, 92, 92, 92, -1, -17, -17, -17, -1, -1, -1, -1, -1, 96, -106, -61, -1, 58, 125, -75, + -1, 58, 125, -75, -1, 109, -98, -56, -1, -1, -1, -1, -1, 94, 94, 94, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, + -1, -49, -49, -49, -1, 31, 31, 31, -1, 3, 3, 3, -1, 43, 43, 43, -1, 108, 108, 108, -1, -58, -58, -58, -1, + -6, -4, -3, -1, -98, -65, -38, -1, 119, -91, -52, -1, 76, -119, -68, -1, 124, -88, -50, -1, -1, -1, -1, -1, + 27, 27, 27, -1, 0, 0, 0, -1, 0, 0, 0, -1, 23, 23, 23, -1, -42, -42, -42, -1, 1, 1, 1, -1, 0, 0, 0, -1, 0, + 0, 0, -1, 0, 0, 0, -1, 82, 82, 82, -1, -27, -27, -27, -1, 61, 61, 61, -1, 104, 104, 104, -1, -90, -90, -89, + -1, -38, -34, -31, -1, -1, -1, -1, -1, 116, 116, 116, -1, 14, 14, 14, -1, 0, 0, 0, -1, 89, 89, 89, -1, + -107, -107, -107, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, -111, -111, -111, -1, -101, -101, + -101, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 2, 2, 2, -1, 67, 67, 67, -1, -1, -1, -1, -1, -18, -18, + -18, -1, -116, -116, -116, -1, -65, -65, -65, -1, 86, 86, 86, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, + 0, 0, -1, -45, -45, -45, -1, 88, 88, 88, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 51, 51, + 51, -1, -1, -1, -1, -1, -1, -1, -1, -1, -4, -3, -2, -1, -1, -1, -1, -1, -64, -64, -64, -1, 64, 64, 64, -1, + 2, 2, 2, -1, 0, 0, 0, -1, 27, 27, 27, -1, -5, -5, -5, -1, 23, 23, 23, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, + 0, -1, 0, 0, 0, -1, 120, 120, 120, -1, -1, -1, -1, -1, -1, -1, -1, -1, -46, -31, -18, -1, 126, -87, -50, + -1, -32, -22, -13, -1, -1, -1, -1, -1, -44, -44, -44, -1, 109, 109, 109, -1, -124, -124, -124, -1, -45, + -45, -45, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, -67, -67, -67, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -2, -2, -2, -1, 102, -102, -59, -1, 61, 127, -74, -1, -126, -84, -48, -1, -28, -19, + -11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -27, -27, -27, -1, 45, 45, 45, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, + 0, -1, 12, 12, 12, -1, -10, -10, -10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -30, -20, -12, + -1, 77, -119, -68, -1, 58, 125, -75, -1, 62, -128, -74, -1, -121, -80, -46, -1, -25, -17, -10, -1, -1, -1, + -1, -1, -2, -2, -2, -1, -68, -68, -68, -1, 79, 79, 79, -1, 3, 3, 3, -1, 74, 74, 74, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -21, -14, -8, -1, -116, -77, -44, -1, 86, -112, + -64, -1, 80, -116, -67, -1, 119, -91, -52, -1, -19, -13, -8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -33, -33, -33, -1, -26, -26, -26, -1, -1, -1, -1, -1 + }); + + /** LWJGL Logo - 32 by 32 pixels */ + public static final ByteBuffer LWJGLIcon32x32 = BufferUtils.createByteBuffer(32 * 32 * 4).put(new byte[] { + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -6, -4, -3, -1, -53, -35, + -20, -1, -109, -73, -42, -1, 111, -96, -55, -1, 92, -109, -62, -1, 96, -106, -61, -1, 122, -89, -51, -1, + -84, -56, -32, -1, -19, -13, -8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -4, -3, -2, -1, -75, -50, -29, -1, 90, -110, -63, -1, + 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1, + 58, 125, -75, -1, 69, -123, -71, -1, -95, -63, -36, -1, -4, -3, -2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -4, -4, -4, -1, -30, -22, -15, -1, -72, -49, -29, -1, -82, -55, -32, + -1, -93, -62, -36, -1, -104, -70, -40, -1, -116, -77, -45, -1, -127, -84, -49, -1, 110, -97, -56, -1, 61, + 127, -74, -1, 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1, 114, -94, -54, -1, -11, -8, -5, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -40, -40, -40, -1, 49, 49, 49, -1, 36, 36, 36, -1, 49, 49, 49, -1, 64, + 64, 64, -1, 82, 82, 82, -1, 101, 101, 101, -1, 116, 116, 116, -1, -113, -113, -113, -1, -9, -8, -8, -1, + -84, -56, -33, -1, 59, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1, 121, -89, -51, + -1, -4, -3, -2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -2, -2, -2, -1, 104, 104, 104, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, + 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, -74, -74, -74, -1, -2, -2, -2, -1, -122, -82, + -47, -1, 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1, -82, -54, -31, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -45, -30, -18, + -1, -31, -22, -14, -1, 40, 40, 40, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, + 0, 0, -1, 0, 0, 0, -1, 2, 2, 2, -1, -34, -34, -34, -1, -1, -1, -1, -1, -11, -8, -5, -1, 91, -110, -63, -1, + 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1, 72, -122, -70, -1, -12, -8, -5, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -20, -13, -8, -1, 100, -103, -59, -1, -41, -39, -37, + -1, 5, 5, 5, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, + 36, 36, 36, -1, -2, -2, -2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -64, -43, -25, -1, 57, 124, -75, -1, 58, + 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1, -85, -56, -32, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -2, -1, -1, -1, 120, -90, -52, -1, 123, -89, -51, -1, -98, -98, -98, -1, 0, 0, 0, -1, 0, 0, + 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 101, 101, 101, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -30, -20, -12, -1, 55, 123, -76, -1, 58, 125, -75, -1, 58, 125, + -75, -1, 58, 125, -75, -1, 102, -102, -59, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -61, + -41, -24, -1, 57, 125, -75, -1, -78, -52, -31, -1, 88, 88, 88, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, + 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, -87, -87, -87, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -68, -46, -27, -1, 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, + -75, -1, 64, -127, -73, -1, -18, -12, -7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -6, -4, -3, -1, 90, -110, -63, -1, 61, + 127, -74, -1, -35, -27, -19, -1, 28, 28, 28, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, + 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 7, 7, 7, -1, -25, -25, -25, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -123, -82, -47, -1, 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1, 57, + 125, -75, -1, -52, -34, -20, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -2, -2, + -2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -70, -46, -27, -1, 58, 125, -75, -1, 87, -112, -65, + -1, -48, -47, -47, -1, 3, 3, 3, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, + 0, -1, 0, 0, 0, -1, 51, 51, 51, -1, -3, -3, -3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -5, -4, -3, -1, 80, + -117, -67, -1, 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1, 57, 125, -75, -1, + -79, -52, -30, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -54, -54, -54, -1, 55, 55, 55, -1, 97, + 97, 97, -1, -94, -94, -94, -1, -35, -35, -35, -1, -28, -20, -13, -1, -79, -53, -31, -1, -76, -51, -30, -1, + -26, -26, -26, -1, 35, 35, 35, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, + 0, -1, 0, 0, 0, -1, 114, 114, 114, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -40, -27, -16, -1, + 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1, + -96, -64, -37, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 102, 102, 102, -1, 0, 0, 0, -1, 0, 0, 0, + -1, 0, 0, 0, -1, 6, 6, 6, -1, 39, 39, 39, -1, 102, 102, 102, -1, -44, -44, -44, -1, -1, -1, -1, -1, -10, + -10, -10, -1, -48, -48, -48, -1, -105, -105, -105, -1, 94, 94, 94, -1, 39, 39, 39, -1, 4, 4, 4, -1, 0, 0, + 0, -1, 3, 3, 3, -1, -64, -64, -64, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -94, -63, -37, -1, + 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1, + -98, -65, -38, -1, -1, -1, -1, -1, -1, -1, -1, -1, -5, -5, -5, -1, 37, 37, 37, -1, 0, 0, 0, -1, 0, 0, 0, + -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 92, 92, 92, -1, -1, -1, -1, -1, -22, -22, -22, -1, + -113, -113, -113, -1, -75, -75, -75, -1, -23, -23, -23, -1, -3, -3, -3, -1, -25, -25, -25, -1, -78, -78, + -78, -1, -67, -67, -67, -1, -2, -2, -2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 107, -99, -57, + -1, 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, + -1, -95, -63, -36, -1, -1, -1, -1, -1, -1, -1, -1, -1, -37, -37, -37, -1, 3, 3, 3, -1, 0, 0, 0, -1, 0, 0, + 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, -125, -125, -125, -1, -1, -1, -1, -1, 95, 95, + 95, -1, 0, 0, 0, -1, 0, 0, 0, -1, 11, 11, 11, -1, 55, 55, 55, -1, 118, 118, 118, -1, -73, -73, -73, -1, + -16, -16, -16, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -16, -11, -7, -1, 75, -120, -69, -1, 61, + 127, -74, -1, 57, 124, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1, + -78, -52, -30, -1, -1, -1, -1, -1, -1, -1, -1, -1, -102, -102, -102, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, + -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, -59, -59, -59, -1, -9, -9, -9, -1, 29, 29, 29, -1, + 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 7, 7, 7, -1, 60, 60, 60, -1, + -33, -33, -33, -1, -1, -1, -1, -1, -5, -4, -3, -1, -4, -3, -2, -1, -13, -9, -6, -1, -52, -35, -21, -1, -98, + -66, -38, -1, 114, -95, -55, -1, 76, -119, -69, -1, 58, 125, -75, -1, -55, -36, -21, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 86, 86, 86, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, + -1, 15, 15, 15, -1, -7, -7, -7, -1, -47, -47, -47, -1, 3, 3, 3, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, + 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, -114, -114, -114, -1, -1, -1, -1, -1, -7, + -7, -7, -1, -124, -124, -124, -1, 112, 112, 112, -1, -80, -80, -80, -1, -22, -22, -22, -1, -1, -1, -1, -1, + -7, -5, -4, -1, -36, -24, -14, -1, -10, -7, -4, -1, -1, -1, -1, -1, -1, -1, -1, -1, 21, 21, 21, -1, 0, 0, + 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 78, 78, 78, -1, -1, -1, -1, -1, + -111, -111, -111, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, + 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, -69, -69, -69, -1, -1, -1, -1, -1, -98, -98, -98, -1, 0, 0, 0, -1, 0, 0, + 0, -1, 0, 0, 0, -1, 4, 4, 4, -1, 47, 47, 47, -1, 112, 112, 112, -1, -80, -80, -80, -1, -26, -26, -26, -1, + -2, -2, -2, -1, -1, -1, -1, -1, 57, 57, 57, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, + 0, -1, 0, 0, 0, -1, -112, -112, -112, -1, -1, -1, -1, -1, 77, 77, 77, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, + 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 16, 16, 16, -1, -16, -16, -16, -1, + -1, -1, -1, -1, 90, 90, 90, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, + -1, 0, 0, 0, -1, 9, 9, 9, -1, 50, 50, 50, -1, -79, -79, -79, -1, -10, -10, -10, -1, -95, -95, -95, -1, 53, + 53, 53, -1, 2, 2, 2, -1, 0, 0, 0, -1, 0, 0, 0, -1, 2, 2, 2, -1, -47, -47, -47, -1, -11, -11, -11, -1, 19, + 19, 19, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, + 0, 0, -1, 69, 69, 69, -1, -2, -2, -2, -1, -8, -8, -8, -1, 29, 29, 29, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, + 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 43, 43, 43, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -4, -4, -4, -1, -66, -66, -66, -1, 80, 80, 80, -1, 5, 5, 5, -1, 37, 37, 37, -1, + -7, -7, -7, -1, -62, -62, -62, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, + 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, -122, -122, -122, -1, -1, -1, -1, -1, -46, -46, -46, -1, 1, + 1, 1, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, + 0, -1, 0, 0, 0, -1, 67, 67, 67, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -2, -2, + -2, -1, -36, -36, -36, -1, -32, -32, -32, -1, -1, -1, -1, -1, -107, -107, -107, -1, 0, 0, 0, -1, 0, 0, 0, + -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 1, 1, 1, -1, -56, -56, + -56, -1, -1, -1, -1, -1, -114, -114, -114, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, + -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, -120, -120, -120, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -33, -33, -33, -1, 41, 41, 41, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, + 0, 0, -1, 0, 0, 0, -1, 24, 24, 24, -1, -11, -11, -11, -1, -1, -1, -1, -1, 74, 74, 74, -1, 0, 0, 0, -1, 0, + 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, + 0, -1, -49, -49, -49, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -15, -10, -6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -7, -7, -7, -1, -75, -75, -75, -1, 75, + 75, 75, -1, 6, 6, 6, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 82, 82, 82, -1, -1, -1, -1, + -1, -8, -8, -8, -1, 16, 16, 16, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, + 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 28, 28, 28, -1, -8, -8, -8, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -122, -81, -47, -1, -112, -75, -43, -1, -22, -15, -9, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -37, -37, -37, -1, 120, 120, 120, -1, + 27, 27, 27, -1, 0, 0, 0, -1, 0, 0, 0, -1, -106, -106, -106, -1, -1, -1, -1, -1, -58, -58, -58, -1, 0, 0, 0, + -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, + 0, 0, 0, -1, 90, 90, 90, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -61, -40, -23, -1, 58, 125, -75, -1, 67, -125, -72, -1, -108, -72, -42, -1, -19, -13, + -8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -12, -12, -12, -1, -89, -89, -89, + -1, -123, -123, -123, -1, -12, -12, -12, -1, -1, -1, -1, -1, -122, -122, -122, -1, 0, 0, 0, -1, 0, 0, 0, + -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, + -99, -99, -99, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -6, -5, -3, -1, 93, -108, -62, -1, 58, 125, -75, -1, 58, 125, -75, -1, 70, -123, -71, -1, -104, + -69, -40, -1, -17, -12, -7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -101, -101, -101, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, + -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 5, 5, 5, -1, -35, -35, -35, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -59, -39, -23, -1, 59, 126, -74, -1, 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1, 72, -122, -70, + -1, -98, -66, -38, -1, -14, -10, -6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -5, -5, -5, -1, -114, -114, -114, -1, 37, 37, 37, -1, 1, 1, 1, -1, 0, 0, 0, -1, 0, 0, 0, + -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 44, 44, 44, -1, -4, -4, -4, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -113, -75, -43, -1, 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, + -1, 74, -121, -69, -1, -93, -62, -36, -1, -13, -9, -6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -6, -6, -6, -1, -80, -80, -80, -1, 69, 69, 69, -1, 4, 4, 4, -1, 0, 0, 0, + -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 110, 110, 110, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -4, -3, + -2, -1, -123, -81, -47, -1, 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1, 58, + 125, -75, -1, 58, 125, -75, -1, 77, -119, -68, -1, -88, -59, -34, -1, -10, -7, -4, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -2, -2, -2, -1, -46, -46, -46, -1, 104, 104, + 104, -1, 14, 14, 14, -1, 0, 0, 0, -1, 1, 1, 1, -1, -72, -72, -72, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -2, -2, -1, -1, -79, -53, -30, -1, 76, -119, -68, -1, 57, 125, -75, -1, 58, 125, -75, -1, + 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1, 58, 125, -75, -1, 77, -119, -68, -1, -65, -44, -25, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -20, -20, -20, -1, -109, -109, -109, -1, -101, -101, -101, -1, -3, -3, -3, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -13, -9, -6, -1, -75, -50, -29, -1, -127, + -84, -48, -1, 101, -103, -59, -1, 97, -105, -60, -1, 108, -98, -56, -1, -113, -75, -43, -1, -59, -39, -23, + -1, -9, -6, -4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1 + }); + + /** Debug flag. */ + public static final boolean DEBUG = getPrivilegedBoolean("org.lwjgl.util.Debug"); + + static { + LWJGLIcon16x16.flip(); + LWJGLIcon32x32.flip(); + } + + /** + * @see #PLATFORM_WINDOWS + * @see #PLATFORM_LINUX + * @see #PLATFORM_MACOSX + * @return the current platform type + */ + public static int getPlatform() { + String osName = getPrivilegedProperty("os.name"); + + if (osName.startsWith("Windows")) { + return PLATFORM_WINDOWS; + } else if (osName.startsWith("Linux") || osName.startsWith("FreeBSD") || osName.startsWith("SunOS")) { + return PLATFORM_LINUX; + } else if (osName.startsWith("Mac OS X")) { + return PLATFORM_MACOSX; + } else { + throw new LinkageError("Unknown platform: " + osName); + } + } + + + /** + * @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 possible_paths = new ArrayList(); + + String classloader_path = getPathFromClassLoader(libname, classloader); + if (classloader_path != null) { + log("getPathFromClassLoader: Path found: " + classloader_path); + possible_paths.add(classloader_path); + } + + for (int i = 0; i < platform_lib_names.length; i++) { + String platform_lib_name = platform_lib_names[i]; + 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 + String[] paths = new String[possible_paths.size()]; + possible_paths.toArray(paths); + return paths; + } + + static void execPrivileged(final String[] cmd_array) throws Exception { + try { + Process process = (Process)AccessController.doPrivileged(new PrivilegedExceptionAction() { + public Object 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 (String)AccessController.doPrivileged(new PrivilegedAction() { + public Object 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 (String)AccessController.doPrivileged(new PrivilegedExceptionAction() { + public Object run() throws Exception { + Method findLibrary = clazz.getDeclaredMethod("findLibrary", new Class[]{String.class}); + findLibrary.setAccessible(true); + Object[] arguments = new Object[] {libname}; + String path = (String)findLibrary.invoke(classloader, arguments); + 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. + */ + private static boolean getPrivilegedBoolean(final String property_name) { + Boolean value = (Boolean)AccessController.doPrivileged(new PrivilegedAction() { + public Object run() { + return new Boolean(Boolean.getBoolean(property_name)); + } + }); + return value.booleanValue(); + } + + /** + * Prints the given message to System.err if DEBUG is true. + * + * @param msg Message to print + */ + public static void log(String msg) { + if (DEBUG) { + System.err.println(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); + } + +} diff --git a/src/java/org/lwjgl/LinuxSysImplementation.java b/src/java/org/lwjgl/LinuxSysImplementation.java new file mode 100644 index 0000000..fc9bb97 --- /dev/null +++ b/src/java/org/lwjgl/LinuxSysImplementation.java @@ -0,0 +1,76 @@ +/* + * 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; + + +/** + * + * @author elias_naur + * @version $Revision: 3298 $ + * $Id: LinuxSysImplementation.java 3298 2010-03-28 23:11:17Z matzon $ + */ +final class LinuxSysImplementation extends J2SESysImplementation { + private final static int JNI_VERSION = 18; + + static { + java.awt.Toolkit.getDefaultToolkit(); // This will make sure libjawt.so is loaded + } + + public int getRequiredJNIVersion() { + return JNI_VERSION; + } + + public boolean openURL(final String url) { + // Linux may as well resort to pure Java hackery, as there's no Linux native way of doing it + // right anyway. + + String[] browsers = {"xdg-open", "firefox", "mozilla", "opera", "konqueror", "nautilus", "galeon", "netscape"}; + + for (int i = 0; i < browsers.length; i ++) { + final String browser = browsers[i]; + try { + LWJGLUtil.execPrivileged(new String[] { browser, url }); + return true; + } catch (Exception e) { + // Ignore + e.printStackTrace(System.err); + } + } + + // Seems to have failed + return false; + } + + public boolean has64Bit() { + return true; + } +} diff --git a/src/java/org/lwjgl/MacOSXSysImplementation.java b/src/java/org/lwjgl/MacOSXSysImplementation.java new file mode 100644 index 0000000..fdf2fe3 --- /dev/null +++ b/src/java/org/lwjgl/MacOSXSysImplementation.java @@ -0,0 +1,65 @@ +/* + * 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.awt.Toolkit; + +import com.apple.eio.FileManager; + +/** + * + * @author elias_naur + * @version $Revision: 3298 $ + * $Id: MacOSXSysImplementation.java 3298 2010-03-28 23:11:17Z matzon $ + */ +final class MacOSXSysImplementation extends J2SESysImplementation { + private final static int JNI_VERSION = 18; + + static { + // Make sure AWT is properly initialized. This avoids hangs on Mac OS X 10.3 + Toolkit.getDefaultToolkit(); + } + + public int getRequiredJNIVersion() { + return JNI_VERSION; + } + + public boolean openURL(String url) { + try { + FileManager.openURL(url); + return true; + } catch (Exception e) { + LWJGLUtil.log("Exception occurred while trying to invoke browser: " + e); + return false; + } + } +} diff --git a/src/java/org/lwjgl/NondirectBufferWrapper.java b/src/java/org/lwjgl/NondirectBufferWrapper.java new file mode 100644 index 0000000..5b73e2e --- /dev/null +++ b/src/java/org/lwjgl/NondirectBufferWrapper.java @@ -0,0 +1,409 @@ +/* + * 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.ByteBuffer; +import java.nio.ShortBuffer; +import java.nio.IntBuffer; +import java.nio.FloatBuffer; +import java.nio.LongBuffer; +import java.nio.DoubleBuffer; +import java.nio.ByteOrder; + +/** + * Utility class to cache thread local direct buffers so when we are passed a non-direct buffer, + * we can put its contents into a cached direct buffer and use that at the native side instead. + * + * Internal class, don't use. + * @author elias_naur + * @version $Revision: 2762 $ + * $Id: BufferChecks.java 2762 2007-04-11 16:13:05Z elias_naur $ + */ +public final class NondirectBufferWrapper { + private final static int INITIAL_BUFFER_SIZE = 1; + + private final static ThreadLocal thread_buffer = new ThreadLocal() { + protected Object initialValue() { + return new CachedBuffers(INITIAL_BUFFER_SIZE); + } + }; + + private static CachedBuffers getCachedBuffers(int minimum_byte_size) { + CachedBuffers buffers = (CachedBuffers)thread_buffer.get(); + int current_byte_size = buffers.byte_buffer.capacity(); + if (minimum_byte_size > current_byte_size) { + buffers = new CachedBuffers(minimum_byte_size); + thread_buffer.set(buffers); + } + return buffers; + } + + public static ByteBuffer wrapNoCopyBuffer(ByteBuffer buf, int size) { + BufferChecks.checkBufferSize(buf, size); + return wrapNoCopyDirect(buf); + } + + public static ShortBuffer wrapNoCopyBuffer(ShortBuffer buf, int size) { + BufferChecks.checkBufferSize(buf, size); + return wrapNoCopyDirect(buf); + } + + public static IntBuffer wrapNoCopyBuffer(IntBuffer buf, int size) { + BufferChecks.checkBufferSize(buf, size); + return wrapNoCopyDirect(buf); + } + + public static LongBuffer wrapNoCopyBuffer(LongBuffer buf, int size) { + BufferChecks.checkBufferSize(buf, size); + return wrapNoCopyDirect(buf); + } + + public static FloatBuffer wrapNoCopyBuffer(FloatBuffer buf, int size) { + BufferChecks.checkBufferSize(buf, size); + return wrapNoCopyDirect(buf); + } + + public static DoubleBuffer wrapNoCopyBuffer(DoubleBuffer buf, int size) { + BufferChecks.checkBufferSize(buf, size); + return wrapNoCopyDirect(buf); + } + + public static ByteBuffer wrapBuffer(ByteBuffer buf, int size) { + BufferChecks.checkBufferSize(buf, size); + return wrapDirect(buf); + } + + public static ShortBuffer wrapBuffer(ShortBuffer buf, int size) { + BufferChecks.checkBufferSize(buf, size); + return wrapDirect(buf); + } + + public static IntBuffer wrapBuffer(IntBuffer buf, int size) { + BufferChecks.checkBufferSize(buf, size); + return wrapDirect(buf); + } + + public static LongBuffer wrapBuffer(LongBuffer buf, int size) { + BufferChecks.checkBufferSize(buf, size); + return wrapDirect(buf); + } + + public static FloatBuffer wrapBuffer(FloatBuffer buf, int size) { + BufferChecks.checkBufferSize(buf, size); + return wrapDirect(buf); + } + + public static DoubleBuffer wrapBuffer(DoubleBuffer buf, int size) { + BufferChecks.checkBufferSize(buf, size); + return wrapDirect(buf); + } + + public static ByteBuffer wrapDirect(ByteBuffer buffer) { + if (!buffer.isDirect()) + return doWrap(buffer); + return buffer; + } + + public static ShortBuffer wrapDirect(ShortBuffer buffer) { + if (!buffer.isDirect()) + return doWrap(buffer); + return buffer; + } + + public static FloatBuffer wrapDirect(FloatBuffer buffer) { + if (!buffer.isDirect()) + return doWrap(buffer); + return buffer; + } + + public static IntBuffer wrapDirect(IntBuffer buffer) { + if (!buffer.isDirect()) + return doWrap(buffer); + return buffer; + } + + public static LongBuffer wrapDirect(LongBuffer buffer) { + if (!buffer.isDirect()) + return doWrap(buffer); + return buffer; + } + + public static DoubleBuffer wrapDirect(DoubleBuffer buffer) { + if (!buffer.isDirect()) + return doWrap(buffer); + return buffer; + } + + public static ByteBuffer wrapNoCopyDirect(ByteBuffer buffer) { + if (!buffer.isDirect()) + return doNoCopyWrap(buffer); + return buffer; + } + + public static ShortBuffer wrapNoCopyDirect(ShortBuffer buffer) { + if (!buffer.isDirect()) + return doNoCopyWrap(buffer); + return buffer; + } + + public static FloatBuffer wrapNoCopyDirect(FloatBuffer buffer) { + if (!buffer.isDirect()) + return doNoCopyWrap(buffer); + return buffer; + } + + public static IntBuffer wrapNoCopyDirect(IntBuffer buffer) { + if (!buffer.isDirect()) + return doNoCopyWrap(buffer); + return buffer; + } + + public static LongBuffer wrapNoCopyDirect(LongBuffer buffer) { + if (!buffer.isDirect()) + return doNoCopyWrap(buffer); + return buffer; + } + + public static DoubleBuffer wrapNoCopyDirect(DoubleBuffer buffer) { + if (!buffer.isDirect()) + return doNoCopyWrap(buffer); + return buffer; + } + + public static void copy(ByteBuffer src, ByteBuffer dst) { + if (dst != null && !dst.isDirect()) { + int saved_position = dst.position(); + dst.put(src); + dst.position(saved_position); + } + } + + public static void copy(ShortBuffer src, ShortBuffer dst) { + if (dst != null && !dst.isDirect()) { + int saved_position = dst.position(); + dst.put(src); + dst.position(saved_position); + } + } + + public static void copy(IntBuffer src, IntBuffer dst) { + if (dst != null && !dst.isDirect()) { + int saved_position = dst.position(); + dst.put(src); + dst.position(saved_position); + } + } + + public static void copy(FloatBuffer src, FloatBuffer dst) { + if (dst != null && !dst.isDirect()) { + int saved_position = dst.position(); + dst.put(src); + dst.position(saved_position); + } + } + + public static void copy(LongBuffer src, LongBuffer dst) { + if (dst != null && !dst.isDirect()) { + int saved_position = dst.position(); + dst.put(src); + dst.position(saved_position); + } + } + + public static void copy(DoubleBuffer src, DoubleBuffer dst) { + if (dst != null && !dst.isDirect()) { + int saved_position = dst.position(); + dst.put(src); + dst.position(saved_position); + } + } + + private static ByteBuffer doNoCopyWrap(ByteBuffer buffer) { + ByteBuffer direct_buffer = lookupBuffer(buffer); + direct_buffer.limit(buffer.limit()); + direct_buffer.position(buffer.position()); + return direct_buffer; + } + + private static ShortBuffer doNoCopyWrap(ShortBuffer buffer) { + ShortBuffer direct_buffer = lookupBuffer(buffer); + direct_buffer.limit(buffer.limit()); + direct_buffer.position(buffer.position()); + return direct_buffer; + } + + private static IntBuffer doNoCopyWrap(IntBuffer buffer) { + IntBuffer direct_buffer = lookupBuffer(buffer); + direct_buffer.limit(buffer.limit()); + direct_buffer.position(buffer.position()); + return direct_buffer; + } + + private static FloatBuffer doNoCopyWrap(FloatBuffer buffer) { + FloatBuffer direct_buffer = lookupBuffer(buffer); + direct_buffer.limit(buffer.limit()); + direct_buffer.position(buffer.position()); + return direct_buffer; + } + + private static LongBuffer doNoCopyWrap(LongBuffer buffer) { + LongBuffer direct_buffer = lookupBuffer(buffer); + direct_buffer.limit(buffer.limit()); + direct_buffer.position(buffer.position()); + return direct_buffer; + } + + private static DoubleBuffer doNoCopyWrap(DoubleBuffer buffer) { + DoubleBuffer direct_buffer = lookupBuffer(buffer); + direct_buffer.limit(buffer.limit()); + direct_buffer.position(buffer.position()); + return direct_buffer; + } + + private static ByteBuffer lookupBuffer(ByteBuffer buffer) { + return getCachedBuffers(buffer.remaining()).byte_buffer; + } + + private static ByteBuffer doWrap(ByteBuffer buffer) { + ByteBuffer direct_buffer = lookupBuffer(buffer); + direct_buffer.clear(); + int saved_position = buffer.position(); + direct_buffer.put(buffer); + buffer.position(saved_position); + direct_buffer.flip(); + return direct_buffer; + } + + private static ShortBuffer lookupBuffer(ShortBuffer buffer) { + CachedBuffers buffers = getCachedBuffers(buffer.remaining()*2); + return buffer.order() == ByteOrder.LITTLE_ENDIAN ? buffers.short_buffer_little : buffers.short_buffer_big; + } + + private static ShortBuffer doWrap(ShortBuffer buffer) { + ShortBuffer direct_buffer = lookupBuffer(buffer); + direct_buffer.clear(); + int saved_position = buffer.position(); + direct_buffer.put(buffer); + buffer.position(saved_position); + direct_buffer.flip(); + return direct_buffer; + } + + private static FloatBuffer lookupBuffer(FloatBuffer buffer) { + CachedBuffers buffers = getCachedBuffers(buffer.remaining()*4); + return buffer.order() == ByteOrder.LITTLE_ENDIAN ? buffers.float_buffer_little : buffers.float_buffer_big; + } + + private static FloatBuffer doWrap(FloatBuffer buffer) { + FloatBuffer direct_buffer = lookupBuffer(buffer); + direct_buffer.clear(); + int saved_position = buffer.position(); + direct_buffer.put(buffer); + buffer.position(saved_position); + direct_buffer.flip(); + return direct_buffer; + } + + private static IntBuffer lookupBuffer(IntBuffer buffer) { + CachedBuffers buffers = getCachedBuffers(buffer.remaining()*4); + return buffer.order() == ByteOrder.LITTLE_ENDIAN ? buffers.int_buffer_little : buffers.int_buffer_big; + } + + private static IntBuffer doWrap(IntBuffer buffer) { + IntBuffer direct_buffer = lookupBuffer(buffer); + direct_buffer.clear(); + int saved_position = buffer.position(); + direct_buffer.put(buffer); + buffer.position(saved_position); + direct_buffer.flip(); + return direct_buffer; + } + + private static LongBuffer lookupBuffer(LongBuffer buffer) { + CachedBuffers buffers = getCachedBuffers(buffer.remaining()*8); + return buffer.order() == ByteOrder.LITTLE_ENDIAN ? buffers.long_buffer_little : buffers.long_buffer_big; + } + + private static LongBuffer doWrap(LongBuffer buffer) { + LongBuffer direct_buffer = lookupBuffer(buffer); + direct_buffer.clear(); + int saved_position = buffer.position(); + direct_buffer.put(buffer); + buffer.position(saved_position); + direct_buffer.flip(); + return direct_buffer; + } + + private static DoubleBuffer lookupBuffer(DoubleBuffer buffer) { + CachedBuffers buffers = getCachedBuffers(buffer.remaining()*8); + return buffer.order() == ByteOrder.LITTLE_ENDIAN ? buffers.double_buffer_little : buffers.double_buffer_big; + } + + private static DoubleBuffer doWrap(DoubleBuffer buffer) { + DoubleBuffer direct_buffer = lookupBuffer(buffer); + direct_buffer.clear(); + int saved_position = buffer.position(); + direct_buffer.put(buffer); + buffer.position(saved_position); + direct_buffer.flip(); + return direct_buffer; + } + + private final static class CachedBuffers { + private final ByteBuffer byte_buffer; + private final ShortBuffer short_buffer_big; + private final IntBuffer int_buffer_big; + private final FloatBuffer float_buffer_big; + private final LongBuffer long_buffer_big; + private final DoubleBuffer double_buffer_big; + private final ShortBuffer short_buffer_little; + private final IntBuffer int_buffer_little; + private final FloatBuffer float_buffer_little; + private final LongBuffer long_buffer_little; + private final DoubleBuffer double_buffer_little; + + private CachedBuffers(int size) { + this.byte_buffer = ByteBuffer.allocateDirect(size); + this.short_buffer_big = byte_buffer.asShortBuffer(); + this.int_buffer_big = byte_buffer.asIntBuffer(); + this.float_buffer_big = byte_buffer.asFloatBuffer(); + this.long_buffer_big = byte_buffer.asLongBuffer(); + this.double_buffer_big = byte_buffer.asDoubleBuffer(); + this.byte_buffer.order(ByteOrder.LITTLE_ENDIAN); + this.short_buffer_little = byte_buffer.asShortBuffer(); + this.int_buffer_little = byte_buffer.asIntBuffer(); + this.float_buffer_little = byte_buffer.asFloatBuffer(); + this.long_buffer_little = byte_buffer.asLongBuffer(); + this.double_buffer_little = byte_buffer.asDoubleBuffer(); + } + } +} diff --git a/src/java/org/lwjgl/Sys.java b/src/java/org/lwjgl/Sys.java new file mode 100644 index 0000000..51916ce --- /dev/null +++ b/src/java/org/lwjgl/Sys.java @@ -0,0 +1,247 @@ +/* + * 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.Method; +import java.net.MalformedURLException; +import java.net.URL; +import java.security.AccessController; +import java.security.PrivilegedAction; +import java.security.PrivilegedExceptionAction; + +import org.lwjgl.input.Mouse; + +/** + *

+ * System class (named Sys so as not to conflict with java.lang.System) + *

+ * @author cix_foo + * @version $Revision: 3328 $ + * $Id: Sys.java 3328 2010-04-15 18:03:54Z matzon $ + */ +public final class Sys { + /** The native library name */ + private static final String JNI_LIBRARY_NAME = "lwjgl"; + + /** Current version of library */ + private static final String VERSION = "2.4.2"; + + /** The implementation instance to delegate platform specific behavior to */ + private final static SysImplementation implementation; + + private final static String POSTFIX64BIT = "64"; + + private static void doLoadLibrary(final String lib_name) { + AccessController.doPrivileged(new PrivilegedAction() { + public Object run() { + String library_path = System.getProperty("org.lwjgl.librarypath"); + if (library_path != null) { + System.load(library_path + File.separator + + System.mapLibraryName(lib_name)); + } else { + System.loadLibrary(lib_name); + } + return null; + } + }); + } + + private static void loadLibrary(final String lib_name) { + try { + doLoadLibrary(lib_name); + } catch (UnsatisfiedLinkError e) { + if (implementation.has64Bit()) { + try { + doLoadLibrary(lib_name + POSTFIX64BIT); + return; + } catch (UnsatisfiedLinkError e2) { + LWJGLUtil.log("Failed to load 64 bit library: " + e2.getMessage()); + } + } + // Throw original error + throw e; + } + } + + static { + implementation = createImplementation(); + loadLibrary(JNI_LIBRARY_NAME); + + int native_jni_version = implementation.getJNIVersion(); + int required_version = implementation.getRequiredJNIVersion(); + if (native_jni_version != required_version) + throw new LinkageError("Version mismatch: jar version is '" + required_version + + "', native libary version is '" + native_jni_version + "'"); + implementation.setDebug(LWJGLUtil.DEBUG); + } + + private static SysImplementation createImplementation() { + switch (LWJGLUtil.getPlatform()) { + case LWJGLUtil.PLATFORM_LINUX: + return new LinuxSysImplementation(); + case LWJGLUtil.PLATFORM_WINDOWS: + return new WindowsSysImplementation(); + case LWJGLUtil.PLATFORM_MACOSX: + return new MacOSXSysImplementation(); + default: + throw new IllegalStateException("Unsupported platform"); + } + } + + /** + * No constructor for Sys. + */ + private Sys() { + } + + /** + * Return the version of the core LWJGL libraries as a String. + */ + public static String getVersion() { + return VERSION; + } + + /** + * Initialization. This is just a dummy method to trigger the static constructor. + */ + public static void initialize() { + } + + /** + * Obtains the number of ticks that the hires timer does in a second. This method is fast; + * it should be called as frequently as possible, as it recalibrates the timer. + * + * @return timer resolution in ticks per second or 0 if no timer is present. + */ + public static long getTimerResolution() { + return implementation.getTimerResolution(); + } + + /** + * Gets the current value of the hires timer, in ticks. When the Sys class is first loaded + * the hires timer is reset to 0. If no hires timer is present then this method will always + * return 0.

NOTEZ BIEN that the hires timer WILL wrap around. + * + * @return the current hires time, in ticks (always >= 0) + */ + public static long getTime() { + return implementation.getTime() & 0x7FFFFFFFFFFFFFFFL; + } + + /** + * Attempt to display a modal alert to the user. This method should be used + * when a game fails to initialize properly or crashes out losing its display + * in the process. It is provided because AWT may not be available on the target + * platform, although on Mac and Linux and other platforms supporting AWT we + * delegate the task to AWT instead of doing it ourselves. + *

+ * The alert should display the title and the message and then the current + * thread should block until the user dismisses the alert - typically with an + * OK button click. + *

+ * It may be that the user's system has no windowing system installed for some + * reason, in which case this method may do nothing at all, or attempt to provide + * some console output. + * + * @param title The title of the alert. We suggest using the title of your game. + * @param message The message text for the alert. + */ + public static void alert(String title, String message) { + boolean grabbed = Mouse.isGrabbed(); + if (grabbed) { + Mouse.setGrabbed(false); + } + if (title == null) + title = ""; + if (message == null) + message = ""; + implementation.alert(title, message); + if (grabbed) { + Mouse.setGrabbed(true); + } + } + + /** + * Open the system web browser and point it at the specified URL. It is recommended + * that this not be called whilst your game is running, but on application exit in + * a shutdown hook, as the screen resolution will not be reset when the browser is + * brought into view. + *

+ * There is no guarantee that this will work, nor that we can detect if it has + * failed - hence we don't return success code or throw an Exception. This is just a + * best attempt at opening the URL given - don't rely on it to work! + *

+ * @param url The URL. Ensure that the URL is properly encoded. + * @return false if we are CERTAIN the call has failed + */ + public static boolean openURL(String url) { + // Attempt to use Webstart if we have it available + try { + // Lookup the javax.jnlp.BasicService object + final Class serviceManagerClass = Class.forName("javax.jnlp.ServiceManager"); + Method lookupMethod = (Method)AccessController.doPrivileged(new PrivilegedExceptionAction() { + public Object run() throws Exception { + return serviceManagerClass.getMethod("lookup", new Class[] {String.class}); + } + }); + Object basicService = lookupMethod.invoke(serviceManagerClass, new Object[] {"javax.jnlp.BasicService"}); + final Class basicServiceClass = Class.forName("javax.jnlp.BasicService"); + Method showDocumentMethod = (Method)AccessController.doPrivileged(new PrivilegedExceptionAction() { + public Object run() throws Exception { + return basicServiceClass.getMethod("showDocument", new Class[] {URL.class}); + } + }); + try { + Boolean ret = (Boolean) showDocumentMethod.invoke(basicService, new Object[] {new URL(url)}); + return ret.booleanValue(); + } catch (MalformedURLException e) { + e.printStackTrace(System.err); + return false; + } + } catch (Exception ue) { + return implementation.openURL(url); + } + } + + /** + * Get the contents of the system clipboard. The system might not have a + * clipboard (particularly if it doesn't even have a keyboard) in which case + * we return null. Otherwise we return a String, which may be the empty + * string "". + * + * @return a String, or null if there is no system clipboard. + */ + public static String getClipboard() { + return implementation.getClipboard(); + } +} diff --git a/src/java/org/lwjgl/SysImplementation.java b/src/java/org/lwjgl/SysImplementation.java new file mode 100644 index 0000000..10a1c7b --- /dev/null +++ b/src/java/org/lwjgl/SysImplementation.java @@ -0,0 +1,76 @@ +/* + * 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; + +/** + * + * System class platform specific method interface + * + * @author cix_foo + * @author elias_naur + * @version $Revision: 3054 $ + * $Id: SysImplementation.java 3054 2008-04-30 14:34:54Z elias_naur $ + */ +interface SysImplementation { + /** + * Return the required version of the native library + */ + int getRequiredJNIVersion(); + + /** + * Return the version of the native library + */ + int getJNIVersion(); + + void setDebug(boolean debug); + + /** + * Obtains the number of ticks that the hires timer does in a second. + * + * @return timer resolution in ticks per second or 0 if no timer is present. + */ + long getTimerResolution(); + + long getTime(); + + void alert(String title, String message); + + boolean openURL(String url); + + String getClipboard(); + + /** + * Returns true there exists a separate 64 bit library + * on the platform + */ + boolean has64Bit(); +} diff --git a/src/java/org/lwjgl/WindowsSysImplementation.java b/src/java/org/lwjgl/WindowsSysImplementation.java new file mode 100644 index 0000000..0c9cac9 --- /dev/null +++ b/src/java/org/lwjgl/WindowsSysImplementation.java @@ -0,0 +1,119 @@ +/* + * 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.security.PrivilegedExceptionAction; +import java.security.PrivilegedActionException; +import java.security.AccessController; +import java.lang.reflect.Method; + +import org.lwjgl.opengl.Display; + +/** + *

+ * @author $Author: spasi $ + * @version $Revision: 3300 $ + * $Id: WindowsSysImplementation.java 3300 2010-03-31 20:56:07Z spasi $ + */ +final class WindowsSysImplementation extends DefaultSysImplementation { + private final static int JNI_VERSION = 22; + + static { + Sys.initialize(); + } + + public int getRequiredJNIVersion() { + return JNI_VERSION; + } + + public long getTimerResolution() { + return 1000; + } + + public long getTime() { + return nGetTime(); + } + private static native long nGetTime(); + + public final boolean has64Bit() { + return true; + } + + private static long getHwnd() { + if (!Display.isCreated()) + return 0; + /* Use reflection since we can't make Display.getImplementation + * public + */ + try { + Long hwnd_obj = (Long)AccessController.doPrivileged(new PrivilegedExceptionAction() { + public Object run() throws Exception { + Method getImplementation_method = Display.class.getDeclaredMethod("getImplementation", null); + getImplementation_method.setAccessible(true); + Object display_impl = getImplementation_method.invoke(null, null); + Class WindowsDisplay_class = Class.forName("org.lwjgl.opengl.WindowsDisplay"); + Method getHwnd_method = WindowsDisplay_class.getDeclaredMethod("getHwnd", null); + getHwnd_method.setAccessible(true); + Long hwnd = (Long)getHwnd_method.invoke(display_impl, null); + return hwnd; + } + }); + return hwnd_obj.longValue(); + } catch (PrivilegedActionException e) { + throw new Error(e); + } + } + + public void alert(String title, String message) { + if(!Display.isCreated()) { + initCommonControls(); + } + nAlert(getHwnd(), title, message); + } + private static native void nAlert(long parent_hwnd, String title, String message); + private static native void initCommonControls(); + + public boolean openURL(final String url) { + try { + LWJGLUtil.execPrivileged(new String[]{"rundll32", "url.dll,FileProtocolHandler", url}); + return true; + } catch (Exception e) { + LWJGLUtil.log("Failed to open url (" + url + "): " + e.getMessage()); + return false; + } + } + + public String getClipboard() { + return nGetClipboard(); + } + private static native String nGetClipboard(); +} diff --git a/src/java/org/lwjgl/examples/Game.java b/src/java/org/lwjgl/examples/Game.java new file mode 100644 index 0000000..8dc2147 --- /dev/null +++ b/src/java/org/lwjgl/examples/Game.java @@ -0,0 +1,193 @@ +/* + * 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.examples; + +import org.lwjgl.Sys; +import org.lwjgl.input.Keyboard; +import org.lwjgl.openal.AL; +import org.lwjgl.opengl.Display; +import org.lwjgl.opengl.GL11; + +/** + * + * This is a very basic skeleton to init a game and run it. + * + * @author $Author: matzon $ + * @version $Revision: 3108 $ + * $Id: Game.java 3108 2008-07-02 20:00:49Z matzon $ + */ +public class Game { + + /** Game title */ + public static final String GAME_TITLE = "My Game"; + + /** Desired frame time */ + private static final int FRAMERATE = 60; + + /** Exit the game */ + private static boolean finished; + + /** A rotating square! */ + private static float angle; + + /** + * No constructor needed - this class is static + */ + private Game() {} + + /** + * Application init + * @param args Commandline args + */ + public static void main(String[] args) { + try { + init(); + run(); + } catch (Exception e) { + e.printStackTrace(System.err); + Sys.alert(GAME_TITLE, "An error occured and the game will exit."); + } finally { + cleanup(); + } + + System.exit(0); + } + + /** + * Initialise the game + * @throws Exception if init fails + */ + private static void init() throws Exception { + // Create a fullscreen window with 1:1 orthographic 2D projection, and with + // mouse, keyboard, and gamepad inputs. + Display.setTitle(GAME_TITLE); + Display.setFullscreen(true); + + // Enable vsync if we can + Display.setVSyncEnabled(true); + + Display.create(); + + // Start up the sound system + AL.create(); + + // TODO: Load in your textures etc here + + // Put the window into orthographic projection mode with 1:1 pixel ratio. + // We haven't used GLU here to do this to avoid an unnecessary dependency. + GL11.glMatrixMode(GL11.GL_PROJECTION); + GL11.glLoadIdentity(); + GL11.glOrtho(0.0, Display.getDisplayMode().getWidth(), 0.0, Display.getDisplayMode().getHeight(), -1.0, 1.0); + GL11.glMatrixMode(GL11.GL_MODELVIEW); + GL11.glLoadIdentity(); + GL11.glViewport(0, 0, Display.getDisplayMode().getWidth(), Display.getDisplayMode().getHeight()); + + } + + /** + * Runs the game (the "main loop") + */ + private static void run() { + while (!finished) { + // Always call Window.update(), all the time + Display.update(); + + if (Display.isCloseRequested()) { + // Check for O/S close requests + finished = true; + } else if (Display.isActive()) { + // The window is in the foreground, so we should play the game + logic(); + render(); + Display.sync(FRAMERATE); + } else { + // The window is not in the foreground, so we can allow other stuff to run and + // infrequently update + try { + Thread.sleep(100); + } catch (InterruptedException e) { + } + logic(); + if (Display.isVisible() || Display.isDirty()) { + // Only bother rendering if the window is visible or dirty + render(); + } + } + } + } + + /** + * Do any game-specific cleanup + */ + private static void cleanup() { + // TODO: save anything you want to disk here + + // Stop the sound + AL.destroy(); + + // Close the window + Display.destroy(); + } + + /** + * Do all calculations, handle input, etc. + */ + private static void logic() { + // Example input handler: we'll check for the ESC key and finish the game instantly when it's pressed + if (Keyboard.isKeyDown(Keyboard.KEY_ESCAPE)) { + finished = true; + } + + // TODO: all your game logic goes here. + angle += 2.0f % 360; + } + + /** + * Render the current frame + */ + private static void render() { + GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_STENCIL_BUFFER_BIT); + + // TODO: all your rendering goes here + GL11.glClear(GL11.GL_COLOR_BUFFER_BIT); + GL11.glPushMatrix(); + GL11.glTranslatef(Display.getDisplayMode().getWidth() / 2, Display.getDisplayMode().getHeight() / 2, 0.0f); + GL11.glRotatef(angle, 0, 0, 1.0f); + GL11.glBegin(GL11.GL_QUADS); + GL11.glVertex2i(-50, -50); + GL11.glVertex2i(50, -50); + GL11.glVertex2i(50, 50); + GL11.glVertex2i(-50, 50); + GL11.glEnd(); + GL11.glPopMatrix(); + } +} diff --git a/src/java/org/lwjgl/examples/spaceinvaders/AlienEntity.java b/src/java/org/lwjgl/examples/spaceinvaders/AlienEntity.java new file mode 100644 index 0000000..f1db4b7 --- /dev/null +++ b/src/java/org/lwjgl/examples/spaceinvaders/AlienEntity.java @@ -0,0 +1,157 @@ +/* + * 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.examples.spaceinvaders; + +/** + * An entity which represents one of our space invader aliens. + * + * @author Kevin Glass + * @author Brian Matzon + */ +public class AlienEntity extends Entity { + + /** Movement made downwards when a border is hit */ + private static final int DOWNWARD_MOVEMENT = 10; + + /** Border at which player dies */ + private static final int BOTTOM_BORDER = 570; + + /** Right border at which to shift direction */ + private static final int RIGHT_BORDER = 750; + + /** Left border at which to shift direction */ + private static final int LEFT_BORDER = 10; + + /** The speed at which the alient moves horizontally */ + private float moveSpeed = 75; + + /** The game in which the entity exists */ + private Game game; + + /** The animation frames */ + private Sprite[] frames = new Sprite[4]; + + /** The time since the last frame change took place */ + private long lastFrameChange; + + /** The frame duration in milliseconds, i.e. how long any given frame of animation lasts */ + private long frameDuration = 250; + + /** The current frame of animation being displayed */ + private int frameNumber; + + /** + * Create a new alien entity + * + * @param game The game in which this entity is being created + * @param x The intial x location of this alien + * @param y The intial y location of this alient + */ + public AlienEntity(Game game, int x, int y) { + super(game.getSprite("alien.gif"), x, y); + + // setup the animatin frames + frames[0] = sprite; + frames[1] = game.getSprite("alien2.gif"); + frames[2] = sprite; + frames[3] = game.getSprite("alien3.gif"); + + this.game = game; + dx = -moveSpeed; + } + + /** + * Request that this alien moved based on time elapsed + * + * @param delta The time that has elapsed since last move + */ + public void move(long delta) { + // since the move tells us how much time has passed + // by we can use it to drive the animation, however + // its the not the prettiest solution + lastFrameChange += delta; + + // if we need to change the frame, update the frame number + // and flip over the sprite in use + if (lastFrameChange > frameDuration) { + // reset our frame change time counter + lastFrameChange = 0; + + // update the frame + frameNumber++; + if (frameNumber >= frames.length) { + frameNumber = 0; + } + + sprite = frames[frameNumber]; + } + + // if we have reached the left hand side of the screen and + // are moving left then request a logic update + if ((dx < 0) && (x < LEFT_BORDER)) { + game.updateLogic(); + } + // and vice vesa, if we have reached the right hand side of + // the screen and are moving right, request a logic update + if ((dx > 0) && (x > RIGHT_BORDER)) { + game.updateLogic(); + } + + // proceed with normal move + super.move(delta); + } + + /** + * Update the game logic related to aliens + */ + public void doLogic() { + // swap over horizontal movement and move down the + // screen a bit + dx = -dx; + y += DOWNWARD_MOVEMENT; + + // if we've reached the bottom of the screen then the player + // dies + if (y > BOTTOM_BORDER) { + game.notifyDeath(); + } + } + + /** + * Notification that this alien has collided with another entity + * + * @param other The other entity + */ + public void collidedWith(Entity other) { + // collisions with aliens are handled elsewhere + } +} \ No newline at end of file diff --git a/src/java/org/lwjgl/examples/spaceinvaders/Entity.java b/src/java/org/lwjgl/examples/spaceinvaders/Entity.java new file mode 100644 index 0000000..cfc54ed --- /dev/null +++ b/src/java/org/lwjgl/examples/spaceinvaders/Entity.java @@ -0,0 +1,184 @@ +/* + * 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.examples.spaceinvaders; + +import java.awt.Rectangle; + +/** + * An entity represents any element that appears in the game. The + * entity is responsible for resolving collisions and movement + * based on a set of properties defined either by subclass or externally. + * + * Note that doubles are used for positions. This may seem strange + * given that pixels locations are integers. However, using double means + * that an entity can move a partial pixel. It doesn't of course mean that + * they will be display half way through a pixel but allows us not lose + * accuracy as we move. + * + * @author Kevin Glass + */ +public abstract class Entity { + + /** The current x location of this entity */ + protected float x; + + /** The current y location of this entity */ + protected float y; + + /** The sprite that represents this entity */ + protected Sprite sprite; + + /** The current speed of this entity horizontally (pixels/sec) */ + protected float dx; + + /** The current speed of this entity vertically (pixels/sec) */ + protected float dy; + + /** The rectangle used for this entity during collisions resolution */ + private Rectangle me = new Rectangle(); + + /** The rectangle used for other entities during collision resolution */ + private Rectangle him = new Rectangle(); + + /** + * Construct a entity based on a sprite image and a location. + * + * @param ref The reference to the image to be displayed for this entity + * @param x The initial x location of this entity + * @param y The initial y location of this entity + */ + public Entity(Sprite sprite, int x, int y) { + this.sprite = sprite; + this.x = x; + this.y = y; + } + + /** + * Request that this entity move itself based on a certain ammount + * of time passing. + * + * @param delta The ammount of time that has passed in milliseconds + */ + public void move(long delta) { + // update the location of the entity based on move speeds + x += (delta * dx) / 1000; + y += (delta * dy) / 1000; + } + + /** + * Set the horizontal speed of this entity + * + * @param dx The horizontal speed of this entity (pixels/sec) + */ + public void setHorizontalMovement(float dx) { + this.dx = dx; + } + + /** + * Set the vertical speed of this entity + * + * @param dy The vertical speed of this entity (pixels/sec) + */ + public void setVerticalMovement(float dy) { + this.dy = dy; + } + + /** + * Get the horizontal speed of this entity + * + * @return The horizontal speed of this entity (pixels/sec) + */ + public float getHorizontalMovement() { + return dx; + } + + /** + * Get the vertical speed of this entity + * + * @return The vertical speed of this entity (pixels/sec) + */ + public float getVerticalMovement() { + return dy; + } + + /** + * Draw this entity to the graphics context provided + */ + public void draw() { + sprite.draw((int) x, (int) y); + } + + /** + * Do the logic associated with this entity. This method + * will be called periodically based on game events + */ + public void doLogic() { + } + + /** + * Get the x location of this entity + * + * @return The x location of this entity + */ + public int getX() { + return (int) x; + } + + /** + * Get the y location of this entity + * + * @return The y location of this entity + */ + public int getY() { + return (int) y; + } + + /** + * Check if this entity collised with another. + * + * @param other The other entity to check collision against + * @return True if the entities collide with each other + */ + public boolean collidesWith(Entity other) { + me.setBounds((int) x, (int) y, sprite.getWidth(), sprite.getHeight()); + him.setBounds((int) other.x, (int) other.y, other.sprite.getWidth(), other.sprite.getHeight()); + + return me.intersects(him); + } + + /** + * Notification that this entity collided with another. + * + * @param other The entity with which this entity collided. + */ + public abstract void collidedWith(Entity other); +} \ No newline at end of file diff --git a/src/java/org/lwjgl/examples/spaceinvaders/Game.java b/src/java/org/lwjgl/examples/spaceinvaders/Game.java new file mode 100644 index 0000000..f4c9e29 --- /dev/null +++ b/src/java/org/lwjgl/examples/spaceinvaders/Game.java @@ -0,0 +1,614 @@ +/* + * 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.examples.spaceinvaders; + +import java.util.ArrayList; + +import org.lwjgl.LWJGLException; +import org.lwjgl.Sys; +import org.lwjgl.input.Keyboard; +import org.lwjgl.input.Mouse; +import org.lwjgl.opengl.Display; +import org.lwjgl.opengl.DisplayMode; +import org.lwjgl.opengl.GL11; + +/** + * The main hook of our game. This class with both act as a manager + * for the display and central mediator for the game logic. + * + * Display management will consist of a loop that cycles round all + * entities in the game asking them to move and then drawing them + * in the appropriate place. With the help of an inner class it + * will also allow the player to control the main ship. + * + * As a mediator it will be informed when entities within our game + * detect events (e.g. alient killed, played died) and will take + * appropriate game actions. + * + *

+ * NOTE:
+ * This game is a LWJGLized implementation of the Space Invaders game by Kevin + * Glass. The original implementation is renderer agnostic and supports other + * OpenGL implementations as well as Java2D. This version has been made specific + * for LWJGL, and has added input control as well as sound (which the original doesn't, + * at the time of writing). + * You can find the original article here:
+ * http://www.cokeandcode.com + *

+ * + * @author Kevin Glass + * @author Brian Matzon + */ +public class Game { + + /** The normal title of the window */ + private String WINDOW_TITLE = "Space Invaders 104 (for LWJGL)"; + + /** The width of the game display area */ + private int width = 800; + + /** The height of the game display area */ + private int height = 600; + + /** The loader responsible for converting images into OpenGL textures */ + private TextureLoader textureLoader; + + /** The list of all the entities that exist in our game */ + private ArrayList entities = new ArrayList(); + + /** The list of entities that need to be removed from the game this loop */ + private ArrayList removeList = new ArrayList(); + + /** The entity representing the player */ + private ShipEntity ship; + + /** List of shots */ + private ShotEntity[] shots; + + /** The message to display which waiting for a key press */ + private Sprite message; + + /** The sprite containing the "Press Any Key" message */ + private Sprite pressAnyKey; + + /** The sprite containing the "You win!" message */ + private Sprite youWin; + + /** The sprite containing the "You lose!" message */ + private Sprite gotYou; + + /** Last shot index */ + private int shotIndex; + + /** The speed at which the player's ship should move (pixels/sec) */ + private float moveSpeed = 300; + + /** The time at which last fired a shot */ + private long lastFire = 0; + + /** The interval between our players shot (ms) */ + private long firingInterval = 500; + + /** The number of aliens left on the screen */ + private int alienCount; + + /** True if we're holding up game play until a key has been pressed */ + private boolean waitingForKeyPress = true; + + /** True if game logic needs to be applied this loop, normally as a result of a game event */ + private boolean logicRequiredThisLoop = false; + + /** The time at which the last rendering looped started from the point of view of the game logic */ + private long lastLoopTime = getTime(); + + /** True if the fire key has been released */ + private boolean fireHasBeenReleased = false; + + /** The time since the last record of fps */ + private long lastFpsTime = 0; + + /** The recorded fps */ + private int fps; + + private static long timerTicksPerSecond = Sys.getTimerResolution(); + + /** True if the game is currently "running", i.e. the game loop is looping */ + public static boolean gameRunning = true; + + /** SoundManager to make sound with */ + private SoundManager soundManager; + + /** Whether we're running in fullscreen mode */ + private boolean fullscreen; + + /** ID of shot effect */ + private int SOUND_SHOT; + + /** ID of hit effect */ + private int SOUND_HIT; + + /** ID of start sound */ + private int SOUND_START; + + /** ID of win sound */ + private int SOUND_WIN; + + /** ID of loose sound */ + private int SOUND_LOOSE; + + /** Mouse movement on x axis */ + private int mouseX; + + /** Is this an application or applet */ + private static boolean isApplication = false; + + /** + * Construct our game and set it running. + * @param fullscreen + * + * @param renderingType The type of rendering to use (should be one of the contansts from ResourceFactory) + */ + public Game(boolean fullscreen) { + this.fullscreen = fullscreen; + initialize(); + } + + /** + * Get the high resolution time in milliseconds + * + * @return The high resolution time in milliseconds + */ + public static long getTime() { + // we get the "timer ticks" from the high resolution timer + // multiply by 1000 so our end result is in milliseconds + // then divide by the number of ticks in a second giving + // us a nice clear time in milliseconds + return (Sys.getTime() * 1000) / timerTicksPerSecond; + } + + /** + * Sleep for a fixed number of milliseconds. + * + * @param duration The amount of time in milliseconds to sleep for + */ + public static void sleep(long duration) { + try { + Thread.sleep((duration * timerTicksPerSecond) / 1000); + } catch (InterruptedException inte) { + } + } + + /** + * Intialise the common elements for the game + */ + public void initialize() { + // initialize the window beforehand + try { + setDisplayMode(); + Display.setTitle(WINDOW_TITLE); + Display.setFullscreen(fullscreen); + Display.create(); + + // grab the mouse, dont want that hideous cursor when we're playing! + if (isApplication) { + Mouse.setGrabbed(true); + } + + // enable textures since we're going to use these for our sprites + GL11.glEnable(GL11.GL_TEXTURE_2D); + + // disable the OpenGL depth test since we're rendering 2D graphics + GL11.glDisable(GL11.GL_DEPTH_TEST); + + GL11.glMatrixMode(GL11.GL_PROJECTION); + GL11.glLoadIdentity(); + + GL11.glOrtho(0, width, height, 0, -1, 1); + GL11.glMatrixMode(GL11.GL_MODELVIEW); + GL11.glLoadIdentity(); + GL11.glViewport(0, 0, width, height); + + textureLoader = new TextureLoader(); + + // create our sound manager, and initialize it with 7 channels + // 1 channel for sounds, 6 for effects - this should be enough + // since we have a most 4 shots on screen at any one time, which leaves + // us with 2 channels for explosions. + soundManager = new SoundManager(); + soundManager.initialize(8); + + // load our sound data + SOUND_SHOT = soundManager.addSound("shot.wav"); + SOUND_HIT = soundManager.addSound("hit.wav"); + SOUND_START = soundManager.addSound("start.wav"); + SOUND_WIN = soundManager.addSound("win.wav"); + SOUND_LOOSE = soundManager.addSound("loose.wav"); + } catch (LWJGLException le) { + System.out.println("Game exiting - exception in initialization:"); + le.printStackTrace(); + Game.gameRunning = false; + return; + } + + // get our sprites + gotYou = getSprite("gotyou.gif"); + pressAnyKey = getSprite("pressanykey.gif"); + youWin = getSprite("youwin.gif"); + + message = pressAnyKey; + + // setup 5 shots + shots = new ShotEntity[5]; + for (int i = 0; i < shots.length; i++) { + shots[i] = new ShotEntity(this, "shot.gif", 0, 0); + } + + // setup the initial game state + startGame(); + } + + /** + * Sets the display mode for fullscreen mode + */ + private boolean setDisplayMode() { + try { + // get modes + DisplayMode[] dm = org.lwjgl.util.Display.getAvailableDisplayModes(width, height, -1, -1, -1, -1, 60, 60); + + org.lwjgl.util.Display.setDisplayMode(dm, new String[] { + "width=" + width, + "height=" + height, + "freq=" + 60, + "bpp=" + org.lwjgl.opengl.Display.getDisplayMode().getBitsPerPixel() + }); + return true; + } catch (Exception e) { + e.printStackTrace(); + System.out.println("Unable to enter fullscreen, continuing in windowed mode"); + } + + return false; + } + + /** + * Start a fresh game, this should clear out any old data and + * create a new set. + */ + private void startGame() { + // clear out any existing entities and intialise a new set + entities.clear(); + initEntities(); + } + + /** + * Initialise the starting state of the entities (ship and aliens). Each + * entitiy will be added to the overall list of entities in the game. + */ + private void initEntities() { + // create the player ship and place it roughly in the center of the screen + ship = new ShipEntity(this, "ship.gif", 370, 550); + entities.add(ship); + + // create a block of aliens (5 rows, by 12 aliens, spaced evenly) + alienCount = 0; + for (int row = 0; row < 5; row++) { + for (int x = 0; x < 12; x++) { + Entity alien = new AlienEntity(this, 100 + (x * 50), (50) + row * 30); + entities.add(alien); + alienCount++; + } + } + } + + /** + * Notification from a game entity that the logic of the game + * should be run at the next opportunity (normally as a result of some + * game event) + */ + public void updateLogic() { + logicRequiredThisLoop = true; + } + + /** + * Remove an entity from the game. The entity removed will + * no longer move or be drawn. + * + * @param entity The entity that should be removed + */ + public void removeEntity(Entity entity) { + removeList.add(entity); + } + + /** + * Notification that the player has died. + */ + public void notifyDeath() { + if (!waitingForKeyPress) { + soundManager.playSound(SOUND_LOOSE); + } + message = gotYou; + waitingForKeyPress = true; + } + + /** + * Notification that the player has won since all the aliens + * are dead. + */ + public void notifyWin() { + message = youWin; + waitingForKeyPress = true; + soundManager.playSound(SOUND_WIN); + } + + /** + * Notification that an alien has been killed + */ + public void notifyAlienKilled() { + // reduce the alient count, if there are none left, the player has won! + alienCount--; + + if (alienCount == 0) { + notifyWin(); + } + + // if there are still some aliens left then they all need to get faster, so + // speed up all the existing aliens + for (int i = 0; i < entities.size(); i++) { + Entity entity = (Entity) entities.get(i); + + if (entity instanceof AlienEntity) { + // speed up by 2% + entity.setHorizontalMovement(entity.getHorizontalMovement() * 1.02f); + } + } + + soundManager.playEffect(SOUND_HIT); + } + + /** + * Attempt to fire a shot from the player. Its called "try" + * since we must first check that the player can fire at this + * point, i.e. has he/she waited long enough between shots + */ + public void tryToFire() { + // check that we have waiting long enough to fire + if (System.currentTimeMillis() - lastFire < firingInterval) { + return; + } + + // if we waited long enough, create the shot entity, and record the time. + lastFire = System.currentTimeMillis(); + ShotEntity shot = shots[shotIndex++ % shots.length]; + shot.reinitialize(ship.getX() + 10, ship.getY() - 30); + entities.add(shot); + + soundManager.playEffect(SOUND_SHOT); + } + + /** + * Run the main game loop. This method keeps rendering the scene + * and requesting that the callback update its screen. + */ + private void gameLoop() { + while (Game.gameRunning) { + // clear screen + GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); + GL11.glMatrixMode(GL11.GL_MODELVIEW); + GL11.glLoadIdentity(); + + // let subsystem paint + frameRendering(); + + // update window contents + Display.update(); + } + + // clean up + soundManager.destroy(); + Display.destroy(); + } + + /** + * Notification that a frame is being rendered. Responsible for + * running game logic and rendering the scene. + */ + public void frameRendering() { + //SystemTimer.sleep(lastLoopTime+10-SystemTimer.getTime()); + Display.sync(60); + + // work out how long its been since the last update, this + // will be used to calculate how far the entities should + // move this loop + long delta = getTime() - lastLoopTime; + lastLoopTime = getTime(); + lastFpsTime += delta; + fps++; + + // update our FPS counter if a second has passed + if (lastFpsTime >= 1000) { + Display.setTitle(WINDOW_TITLE + " (FPS: " + fps + ")"); + lastFpsTime = 0; + fps = 0; + } + + // cycle round asking each entity to move itself + if (!waitingForKeyPress && !soundManager.isPlayingSound()) { + for (int i = 0; i < entities.size(); i++) { + Entity entity = (Entity) entities.get(i); + entity.move(delta); + } + } + + // cycle round drawing all the entities we have in the game + for (int i = 0; i < entities.size(); i++) { + Entity entity = (Entity) entities.get(i); + entity.draw(); + } + + // brute force collisions, compare every entity against + // every other entity. If any of them collide notify + // both entities that the collision has occured + for (int p = 0; p < entities.size(); p++) { + for (int s = p + 1; s < entities.size(); s++) { + Entity me = (Entity) entities.get(p); + Entity him = (Entity) entities.get(s); + + if (me.collidesWith(him)) { + me.collidedWith(him); + him.collidedWith(me); + } + } + } + + // remove any entity that has been marked for clear up + entities.removeAll(removeList); + removeList.clear(); + + // if a game event has indicated that game logic should + // be resolved, cycle round every entity requesting that + // their personal logic should be considered. + if (logicRequiredThisLoop) { + for (int i = 0; i < entities.size(); i++) { + Entity entity = (Entity) entities.get(i); + entity.doLogic(); + } + + logicRequiredThisLoop = false; + } + + // if we're waiting for an "any key" press then draw the + // current message + if (waitingForKeyPress) { + message.draw(325, 250); + } + + // resolve the movemfent of the ship. First assume the ship + // isn't moving. If either cursor key is pressed then + // update the movement appropraitely + ship.setHorizontalMovement(0); + + // get mouse movement on x axis. We need to get it now, since + // we can only call getDX ONCE! - secondary calls will yield 0, since + // there haven't been any movement since last call. + mouseX = Mouse.getDX(); + + // we delegate input checking to submethod since we want to check + // for keyboard, mouse & controller + boolean leftPressed = hasInput(Keyboard.KEY_LEFT); + boolean rightPressed = hasInput(Keyboard.KEY_RIGHT); + boolean firePressed = hasInput(Keyboard.KEY_SPACE); + + if (!waitingForKeyPress && !soundManager.isPlayingSound()) { + if ((leftPressed) && (!rightPressed)) { + ship.setHorizontalMovement(-moveSpeed); + } else if ((rightPressed) && (!leftPressed)) { + ship.setHorizontalMovement(moveSpeed); + } + + // if we're pressing fire, attempt to fire + if (firePressed) { + tryToFire(); + } + } else { + if (!firePressed) { + fireHasBeenReleased = true; + } + if ((firePressed) && (fireHasBeenReleased) && !soundManager.isPlayingSound()) { + waitingForKeyPress = false; + fireHasBeenReleased = false; + startGame(); + soundManager.playSound(SOUND_START); + } + } + + // if escape has been pressed, stop the game + if ((Display.isCloseRequested() || Keyboard.isKeyDown(Keyboard.KEY_ESCAPE)) && isApplication) { + Game.gameRunning = false; + } + } + + /** + * @param key_left + * @return + */ + private boolean hasInput(int direction) { + switch(direction) { + case Keyboard.KEY_LEFT: + return + Keyboard.isKeyDown(Keyboard.KEY_LEFT) || + mouseX < 0; + + case Keyboard.KEY_RIGHT: + return + Keyboard.isKeyDown(Keyboard.KEY_RIGHT) || + mouseX > 0; + + case Keyboard.KEY_SPACE: + return + Keyboard.isKeyDown(Keyboard.KEY_SPACE) || + Mouse.isButtonDown(0); + } + return false; + } + + /** + * The entry point into the game. We'll simply create an + * instance of class which will start the display and game + * loop. + * + * @param argv The arguments that are passed into our game + */ + public static void main(String argv[]) { + isApplication = true; + System.out.println("Use -fullscreen for fullscreen mode"); + new Game((argv.length > 0 && argv[0].equalsIgnoreCase("-fullscreen"))).execute(); + System.exit(0); + } + + /** + * + */ + public void execute() { + gameLoop(); + } + + /** + * Create or get a sprite which displays the image that is pointed + * to in the classpath by "ref" + * + * @param ref A reference to the image to load + * @return A sprite that can be drawn onto the current graphics context. + */ + public Sprite getSprite(String ref) { + return new Sprite(textureLoader, ref); + } +} diff --git a/src/java/org/lwjgl/examples/spaceinvaders/GameApplet.java b/src/java/org/lwjgl/examples/spaceinvaders/GameApplet.java new file mode 100644 index 0000000..a1ac0cc --- /dev/null +++ b/src/java/org/lwjgl/examples/spaceinvaders/GameApplet.java @@ -0,0 +1,104 @@ +package org.lwjgl.examples.spaceinvaders; + + +import java.applet.Applet; +import java.awt.BorderLayout; +import java.awt.Canvas; +import org.lwjgl.LWJGLException; +import org.lwjgl.opengl.Display; + +public class GameApplet extends Applet { + + /** The Canvas where the LWJGL Display is added */ + Canvas display_parent; + + /** Thread which runs the main game loop */ + Thread gameThread; + + /** The Game instance */ + Game game; + + /** + * Once the Canvas is created its add notify method will call this method to + * start the LWJGL Display and game loop in another thread. + */ + public void startLWJGL() { + gameThread = new Thread() { + public void run() { + + try { + Display.setParent(display_parent); + + } catch (LWJGLException e) { + e.printStackTrace(); + } + // start game + game = new Game(false); + game.execute(); + } + }; + gameThread.start(); + } + + + /** + * Tell game loop to stop running, after which the LWJGL Display will be destoryed. + * The main thread will wait for the Display.destroy() to complete + */ + private void stopLWJGL() { + Game.gameRunning = false; + try { + gameThread.join(); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + + public void start() { + + } + + public void stop() { + + } + + /** + * Applet Destroy method will remove the canvas, before canvas is destroyed it will notify + * stopLWJGL() to stop main game loop and to destroy the Display + */ + public void destroy() { + remove(display_parent); + super.destroy(); + System.out.println("Clear up"); + } + + /** + * initialise applet by adding a canvas to it, this canvas will start the LWJGL Display and game loop + * in another thread. It will also stop the game loop and destroy the display on canvas removal when + * applet is destroyed. + */ + public void init() { + setLayout(new BorderLayout()); + try { + display_parent = new Canvas() { + public final void addNotify() { + super.addNotify(); + startLWJGL(); + } + public final void removeNotify() { + stopLWJGL(); + super.removeNotify(); + } + }; + display_parent.setSize(getWidth(),getHeight()); + add(display_parent); + display_parent.setFocusable(true); + display_parent.requestFocus(); + display_parent.setIgnoreRepaint(true); + setVisible(true); + } catch (Exception e) { + System.err.println(e); + throw new RuntimeException("Unable to create display"); + } + } +} \ No newline at end of file diff --git a/src/java/org/lwjgl/examples/spaceinvaders/ShipEntity.java b/src/java/org/lwjgl/examples/spaceinvaders/ShipEntity.java new file mode 100644 index 0000000..0e33a3b --- /dev/null +++ b/src/java/org/lwjgl/examples/spaceinvaders/ShipEntity.java @@ -0,0 +1,98 @@ +/* + * 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.examples.spaceinvaders; + +/** + * The entity that represents the players ship + * + * @author Kevin Glass + * @author Brian Matzon + */ +public class ShipEntity extends Entity { + + /** Right border at which to disallow further movement */ + private static final int RIGHT_BORDER = 750; + + /** Left border at which to disallow further movement */ + private static final int LEFT_BORDER = 10; + + /** The game in which the ship exists */ + private Game game; + + /** + * Create a new entity to represent the players ship + * + * @param game The game in which the ship is being created + * @param ref The reference to the sprite to show for the ship + * @param x The initial x location of the player's ship + * @param y The initial y location of the player's ship + */ + public ShipEntity(Game game,String ref,int x,int y) { + super(game.getSprite(ref), x, y); + + this.game = game; + } + + /** + * Request that the ship move itself based on an elapsed ammount of + * time + * + * @param delta The time that has elapsed since last move (ms) + */ + public void move(long delta) { + // if we're moving left and have reached the left hand side + // of the screen, don't move + if ((dx < 0) && (x < LEFT_BORDER)) { + return; + } + // if we're moving right and have reached the right hand side + // of the screen, don't move + if ((dx > 0) && (x > RIGHT_BORDER)) { + return; + } + + super.move(delta); + } + + /** + * Notification that the player's ship has collided with something + * + * @param other The entity with which the ship has collided + */ + public void collidedWith(Entity other) { + // if its an alien, notify the game that the player + // is dead + if (other instanceof AlienEntity) { + game.notifyDeath(); + } + } +} \ No newline at end of file diff --git a/src/java/org/lwjgl/examples/spaceinvaders/ShotEntity.java b/src/java/org/lwjgl/examples/spaceinvaders/ShotEntity.java new file mode 100644 index 0000000..1d3335e --- /dev/null +++ b/src/java/org/lwjgl/examples/spaceinvaders/ShotEntity.java @@ -0,0 +1,120 @@ +/* + * 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.examples.spaceinvaders; + +/** + * An entity representing a shot fired by the player's ship + * + * @author Kevin Glass + * @author Brian Matzon + */ +public class ShotEntity extends Entity { + + /** Top border at which shots are outside */ + private static final int TOP_BORDER = -100; + + /** The vertical speed at which the players shot moves */ + private float moveSpeed = -300; + + /** The game in which this entity exists */ + private Game game; + + /** True if this shot has been "used", i.e. its hit something */ + private boolean used = false; + + /** + * Create a new shot from the player + * + * @param game The game in which the shot has been created + * @param sprite The sprite representing this shot + * @param x The initial x location of the shot + * @param y The initial y location of the shot + */ + public ShotEntity(Game game, String sprite, int x, int y) { + super(game.getSprite(sprite), x, y); + + this.game = game; + dy = moveSpeed; + } + + /** + * Reinitializes this entity, for reuse + * + * @param x new x coordinate + * @param y new y coordinate + */ + public void reinitialize(int x, int y) { + this.x = x; + this.y = y; + used = false; + } + + /** + * Request that this shot moved based on time elapsed + * + * @param delta The time that has elapsed since last move + */ + public void move(long delta) { + // proceed with normal move + super.move(delta); + + // if we shot off the screen, remove ourselfs + if (y < TOP_BORDER) { + game.removeEntity(this); + } + } + + /** + * Notification that this shot has collided with another + * entity + * + * @param other The other entity with which we've collided + */ + public void collidedWith(Entity other) { + // prevents double kills, if we've already hit something, + // don't collide + if (used) { + return; + } + + // if we've hit an alien, kill it! + if (other instanceof AlienEntity) { + // remove the affected entities + game.removeEntity(this); + game.removeEntity(other); + + // notify the game that the alien has been killed + game.notifyAlienKilled(); + used = true; + } + } +} \ No newline at end of file diff --git a/src/java/org/lwjgl/examples/spaceinvaders/SoundManager.java b/src/java/org/lwjgl/examples/spaceinvaders/SoundManager.java new file mode 100644 index 0000000..d3bcae3 --- /dev/null +++ b/src/java/org/lwjgl/examples/spaceinvaders/SoundManager.java @@ -0,0 +1,189 @@ +/* + * 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.examples.spaceinvaders; + +import java.nio.IntBuffer; + +import org.lwjgl.BufferUtils; +import org.lwjgl.LWJGLException; +import org.lwjgl.openal.AL; +import org.lwjgl.openal.AL10; +import org.lwjgl.util.WaveData; + + +/** + *

+ * Simple sound manager for OpenAL using n sources accessed in + * a round robin schedule. Source n is reserved for a single buffer and checking for + * whether it's playing. + *

+ * @author Brian Matzon + * @version $Revision: 2983 $ + * $Id: SoundManager.java 2983 2008-04-07 18:36:09Z matzon $ + */ +public class SoundManager { + + /** We support at most 256 buffers*/ + private int[] buffers = new int[256]; + + /** Number of sources is limited tby user (and hardware) */ + private int[] sources; + + /** Our internal scratch buffer */ + private IntBuffer scratchBuffer = BufferUtils.createIntBuffer(256); + + /** Whether we're running in no sound mode */ + private boolean soundOutput; + + /** Current index in our buffers */ + private int bufferIndex; + + /** Current index in our source list */ + private int sourceIndex; + + /** + * Creates a new SoundManager + */ + public SoundManager() { + } + + /** + * Plays a sound effect + * @param buffer Buffer index to play gotten from addSound + */ + public void playEffect(int buffer) { + if(soundOutput) { + // make sure we never choose last channel, since it is used for special sounds + int channel = sources[(sourceIndex++ % (sources.length-1))]; + + // link buffer and source, and play it + AL10.alSourcei(channel, AL10.AL_BUFFER, buffers[buffer]); + AL10.alSourcePlay(channel); + } + } + + /** + * Plays a sound on last source + * @param buffer Buffer index to play gotten from addSound + */ + public void playSound(int buffer) { + if(soundOutput) { + AL10.alSourcei(sources[sources.length-1], AL10.AL_BUFFER, buffers[buffer]); + AL10.alSourcePlay(sources[sources.length-1]); + } + } + + /** + * Whether a sound is playing on last source + * @return true if a source is playing right now on source n + */ + public boolean isPlayingSound() { + return AL10.alGetSourcei(sources[sources.length-1], AL10.AL_SOURCE_STATE) == AL10.AL_PLAYING; + } + + /** + * Initializes the SoundManager + * + * @param sources Number of sources to create + */ + public void initialize(int channels) { + try { + AL.create(); + + // allocate sources + scratchBuffer.limit(channels); + AL10.alGenSources(scratchBuffer); + scratchBuffer.rewind(); + scratchBuffer.get(sources = new int[channels]); + + // could we allocate all channels? + if(AL10.alGetError() != AL10.AL_NO_ERROR) { + throw new LWJGLException("Unable to allocate " + channels + " sources"); + } + + // we have sound + soundOutput = true; + } catch (LWJGLException le) { + le.printStackTrace(); + System.out.println("Sound disabled"); + } + } + + /** + * Adds a sound to the Sound Managers pool + * + * @param path Path to file to load + * @return index into SoundManagers buffer list + */ + public int addSound(String path) { + // Generate 1 buffer entry + scratchBuffer.rewind().position(0).limit(1); + AL10.alGenBuffers(scratchBuffer); + buffers[bufferIndex] = scratchBuffer.get(0); + + // load wave data from buffer + WaveData wavefile = WaveData.create("spaceinvaders/" + path); + + // copy to buffers + AL10.alBufferData(buffers[bufferIndex], wavefile.format, wavefile.data, wavefile.samplerate); + + // unload file again + wavefile.dispose(); + + // return index for this sound + return bufferIndex++; + } + + /** + * Destroy this SoundManager + */ + public void destroy() { + if(soundOutput) { + + // stop playing sounds + scratchBuffer.position(0).limit(sources.length); + scratchBuffer.put(sources).flip(); + AL10.alSourceStop(scratchBuffer); + + // destroy sources + AL10.alDeleteSources(scratchBuffer); + + // destroy buffers + scratchBuffer.position(0).limit(bufferIndex); + scratchBuffer.put(buffers, 0, bufferIndex).flip(); + AL10.alDeleteBuffers(scratchBuffer); + + // destory OpenAL + AL.destroy(); + } + } +} diff --git a/src/java/org/lwjgl/examples/spaceinvaders/Sprite.java b/src/java/org/lwjgl/examples/spaceinvaders/Sprite.java new file mode 100644 index 0000000..162af89 --- /dev/null +++ b/src/java/org/lwjgl/examples/spaceinvaders/Sprite.java @@ -0,0 +1,127 @@ +/* + * 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.examples.spaceinvaders; + +import java.io.IOException; + +import org.lwjgl.opengl.GL11; + +/** + * Implementation of sprite that uses an OpenGL quad and a texture + * to render a given image to the screen. + * + * @author Kevin Glass + * @author Brian Matzon + */ +public class Sprite { + + /** The texture that stores the image for this sprite */ + private Texture texture; + + /** The width in pixels of this sprite */ + private int width; + + /** The height in pixels of this sprite */ + private int height; + + /** + * Create a new sprite from a specified image. + * + * @param window The window in which the sprite will be displayed + * @param ref A reference to the image on which this sprite should be based + */ + public Sprite(TextureLoader loader, String ref) { + try { + texture = loader.getTexture("spaceinvaders/" + ref); + width = texture.getImageWidth(); + height = texture.getImageHeight(); + } catch (IOException ioe) { + ioe.printStackTrace(); + System.exit(-1); + } + } + + /** + * Get the width of this sprite in pixels + * + * @return The width of this sprite in pixels + */ + public int getWidth() { + return texture.getImageWidth(); + } + + /** + * Get the height of this sprite in pixels + * + * @return The height of this sprite in pixels + */ + public int getHeight() { + return texture.getImageHeight(); + } + + /** + * Draw the sprite at the specified location + * + * @param x The x location at which to draw this sprite + * @param y The y location at which to draw this sprite + */ + public void draw(int x, int y) { + // store the current model matrix + GL11.glPushMatrix(); + + // bind to the appropriate texture for this sprite + texture.bind(); + + // translate to the right location and prepare to draw + GL11.glTranslatef(x, y, 0); + + // draw a quad textured to match the sprite + GL11.glBegin(GL11.GL_QUADS); + { + GL11.glTexCoord2f(0, 0); + GL11.glVertex2f(0, 0); + + GL11.glTexCoord2f(0, texture.getHeight()); + GL11.glVertex2f(0, height); + + GL11.glTexCoord2f(texture.getWidth(), texture.getHeight()); + GL11.glVertex2f(width, height); + + GL11.glTexCoord2f(texture.getWidth(), 0); + GL11.glVertex2f(width, 0); + } + GL11.glEnd(); + + // restore the model view matrix to prevent contamination + GL11.glPopMatrix(); + } +} \ No newline at end of file diff --git a/src/java/org/lwjgl/examples/spaceinvaders/Texture.java b/src/java/org/lwjgl/examples/spaceinvaders/Texture.java new file mode 100644 index 0000000..58a964d --- /dev/null +++ b/src/java/org/lwjgl/examples/spaceinvaders/Texture.java @@ -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.examples.spaceinvaders; + +import org.lwjgl.opengl.GL11; + +/** + * A texture to be bound within OpenGL. This object is responsible for + * keeping track of a given OpenGL texture and for calculating the + * texturing mapping coordinates of the full image. + * + * Since textures need to be powers of 2 the actual texture may be + * considerably bigged that the source image and hence the texture + * mapping coordinates need to be adjusted to matchup drawing the + * sprite against the texture. + * + * @author Kevin Glass + * @author Brian Matzon + */ +public class Texture { + + /** The GL target type */ + private int target; + + /** The GL texture ID */ + private int textureID; + + /** The height of the image */ + private int height; + + /** The width of the image */ + private int width; + + /** The width of the texture */ + private int texWidth; + + /** The height of the texture */ + private int texHeight; + + /** The ratio of the width of the image to the texture */ + private float widthRatio; + + /** The ratio of the height of the image to the texture */ + private float heightRatio; + + /** + * Create a new texture + * + * @param target The GL target + * @param textureID The GL texture ID + */ + public Texture(int target, int textureID) { + this.target = target; + this.textureID = textureID; + } + + /** + * Bind the specified GL context to a texture + * + * @param gl The GL context to bind to + */ + public void bind() { + GL11.glBindTexture(target, textureID); + } + + /** + * Set the height of the image + * + * @param height The height of the image + */ + public void setHeight(int height) { + this.height = height; + setHeight(); + } + + /** + * Set the width of the image + * + * @param width The width of the image + */ + public void setWidth(int width) { + this.width = width; + setWidth(); + } + + /** + * Get the height of the original image + * + * @return The height of the original image + */ + public int getImageHeight() { + return height; + } + + /** + * Get the width of the original image + * + * @return The width of the original image + */ + public int getImageWidth() { + return width; + } + + /** + * Get the height of the physical texture + * + * @return The height of physical texture + */ + public float getHeight() { + return heightRatio; + } + + /** + * Get the width of the physical texture + * + * @return The width of physical texture + */ + public float getWidth() { + return widthRatio; + } + + /** + * Set the height of this texture + * + * @param texHeight The height of the texture + */ + public void setTextureHeight(int texHeight) { + this.texHeight = texHeight; + setHeight(); + } + + /** + * Set the width of this texture + * + * @param texWidth The width of the texture + */ + public void setTextureWidth(int texWidth) { + this.texWidth = texWidth; + setWidth(); + } + + /** + * Set the height of the texture. This will update the + * ratio also. + */ + private void setHeight() { + if (texHeight != 0) { + heightRatio = ((float) height) / texHeight; + } + } + + /** + * Set the width of the texture. This will update the + * ratio also. + */ + private void setWidth() { + if (texWidth != 0) { + widthRatio = ((float) width) / texWidth; + } + } +} \ No newline at end of file diff --git a/src/java/org/lwjgl/examples/spaceinvaders/TextureLoader.java b/src/java/org/lwjgl/examples/spaceinvaders/TextureLoader.java new file mode 100644 index 0000000..fb3af5e --- /dev/null +++ b/src/java/org/lwjgl/examples/spaceinvaders/TextureLoader.java @@ -0,0 +1,285 @@ +/* + * 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.examples.spaceinvaders; + +import java.awt.Color; +import java.awt.Graphics; +import java.awt.color.ColorSpace; +import java.awt.image.BufferedImage; +import java.awt.image.ColorModel; +import java.awt.image.ComponentColorModel; +import java.awt.image.DataBuffer; +import java.awt.image.DataBufferByte; +import java.awt.image.Raster; +import java.awt.image.WritableRaster; +import java.io.BufferedInputStream; +import java.io.IOException; +import java.net.URL; +import java.nio.ByteBuffer; +import java.nio.ByteOrder; +import java.nio.IntBuffer; +import java.util.HashMap; +import java.util.Hashtable; + +import javax.imageio.ImageIO; + +import org.lwjgl.BufferUtils; +import org.lwjgl.opengl.GL11; + +/** + * A utility class to load textures for OpenGL. This source is based + * on a texture that can be found in the Java Gaming (www.javagaming.org) + * Wiki. It has been simplified slightly for explicit 2D graphics use. + * + * OpenGL uses a particular image format. Since the images that are + * loaded from disk may not match this format this loader introduces + * a intermediate image which the source image is copied into. In turn, + * this image is used as source for the OpenGL texture. + * + * @author Kevin Glass + * @author Brian Matzon + */ +public class TextureLoader { + /** The table of textures that have been loaded in this loader */ + private HashMap table = new HashMap(); + + /** The colour model including alpha for the GL image */ + private ColorModel glAlphaColorModel; + + /** The colour model for the GL image */ + private ColorModel glColorModel; + + /** Scratch buffer for texture ID's */ + private IntBuffer textureIDBuffer = BufferUtils.createIntBuffer(1); + + /** + * Create a new texture loader based on the game panel + * + * @param gl The GL content in which the textures should be loaded + */ + public TextureLoader() { + glAlphaColorModel = new ComponentColorModel(ColorSpace.getInstance(ColorSpace.CS_sRGB), + new int[] {8,8,8,8}, + true, + false, + ComponentColorModel.TRANSLUCENT, + DataBuffer.TYPE_BYTE); + + glColorModel = new ComponentColorModel(ColorSpace.getInstance(ColorSpace.CS_sRGB), + new int[] {8,8,8,0}, + false, + false, + ComponentColorModel.OPAQUE, + DataBuffer.TYPE_BYTE); + } + + /** + * Create a new texture ID + * + * @return A new texture ID + */ + private int createTextureID() { + GL11.glGenTextures(textureIDBuffer); + return textureIDBuffer.get(0); + } + + /** + * Load a texture + * + * @param resourceName The location of the resource to load + * @return The loaded texture + * @throws IOException Indicates a failure to access the resource + */ + public Texture getTexture(String resourceName) throws IOException { + Texture tex = (Texture) table.get(resourceName); + + if (tex != null) { + return tex; + } + + tex = getTexture(resourceName, + GL11.GL_TEXTURE_2D, // target + GL11.GL_RGBA, // dst pixel format + GL11.GL_LINEAR, // min filter (unused) + GL11.GL_LINEAR); + + table.put(resourceName,tex); + + return tex; + } + + /** + * Load a texture into OpenGL from a image reference on + * disk. + * + * @param resourceName The location of the resource to load + * @param target The GL target to load the texture against + * @param dstPixelFormat The pixel format of the screen + * @param minFilter The minimising filter + * @param magFilter The magnification filter + * @return The loaded texture + * @throws IOException Indicates a failure to access the resource + */ + public Texture getTexture(String resourceName, + int target, + int dstPixelFormat, + int minFilter, + int magFilter) throws IOException { + int srcPixelFormat = 0; + + // create the texture ID for this texture + int textureID = createTextureID(); + Texture texture = new Texture(target,textureID); + + // bind this texture + GL11.glBindTexture(target, textureID); + + BufferedImage bufferedImage = loadImage(resourceName); + texture.setWidth(bufferedImage.getWidth()); + texture.setHeight(bufferedImage.getHeight()); + + if (bufferedImage.getColorModel().hasAlpha()) { + srcPixelFormat = GL11.GL_RGBA; + } else { + srcPixelFormat = GL11.GL_RGB; + } + + // convert that image into a byte buffer of texture data + ByteBuffer textureBuffer = convertImageData(bufferedImage,texture); + + if (target == GL11.GL_TEXTURE_2D) { + GL11.glTexParameteri(target, GL11.GL_TEXTURE_MIN_FILTER, minFilter); + GL11.glTexParameteri(target, GL11.GL_TEXTURE_MAG_FILTER, magFilter); + } + + // produce a texture from the byte buffer + GL11.glTexImage2D(target, + 0, + dstPixelFormat, + get2Fold(bufferedImage.getWidth()), + get2Fold(bufferedImage.getHeight()), + 0, + srcPixelFormat, + GL11.GL_UNSIGNED_BYTE, + textureBuffer ); + + return texture; + } + + /** + * Get the closest greater power of 2 to the fold number + * + * @param fold The target number + * @return The power of 2 + */ + private int get2Fold(int fold) { + int ret = 2; + while (ret < fold) { + ret *= 2; + } + return ret; + } + + /** + * Convert the buffered image to a texture + * + * @param bufferedImage The image to convert to a texture + * @param texture The texture to store the data into + * @return A buffer containing the data + */ + private ByteBuffer convertImageData(BufferedImage bufferedImage,Texture texture) { + ByteBuffer imageBuffer = null; + WritableRaster raster; + BufferedImage texImage; + + int texWidth = 2; + int texHeight = 2; + + // find the closest power of 2 for the width and height + // of the produced texture + while (texWidth < bufferedImage.getWidth()) { + texWidth *= 2; + } + while (texHeight < bufferedImage.getHeight()) { + texHeight *= 2; + } + + texture.setTextureHeight(texHeight); + texture.setTextureWidth(texWidth); + + // create a raster that can be used by OpenGL as a source + // for a texture + if (bufferedImage.getColorModel().hasAlpha()) { + raster = Raster.createInterleavedRaster(DataBuffer.TYPE_BYTE,texWidth,texHeight,4,null); + texImage = new BufferedImage(glAlphaColorModel,raster,false,new Hashtable()); + } else { + raster = Raster.createInterleavedRaster(DataBuffer.TYPE_BYTE,texWidth,texHeight,3,null); + texImage = new BufferedImage(glColorModel,raster,false,new Hashtable()); + } + + // copy the source image into the produced image + Graphics g = texImage.getGraphics(); + g.setColor(new Color(0f,0f,0f,0f)); + g.fillRect(0,0,texWidth,texHeight); + g.drawImage(bufferedImage,0,0,null); + + // build a byte buffer from the temporary image + // that be used by OpenGL to produce a texture. + byte[] data = ((DataBufferByte) texImage.getRaster().getDataBuffer()).getData(); + + imageBuffer = ByteBuffer.allocateDirect(data.length); + imageBuffer.order(ByteOrder.nativeOrder()); + imageBuffer.put(data, 0, data.length); + imageBuffer.flip(); + + return imageBuffer; + } + + /** + * Load a given resource as a buffered image + * + * @param ref The location of the resource to load + * @return The loaded buffered image + * @throws IOException Indicates a failure to find a resource + */ + private BufferedImage loadImage(String ref) throws IOException { + URL url = TextureLoader.class.getClassLoader().getResource(ref); + + if (url == null) { + throw new IOException("Cannot find: " + ref); + } + + BufferedImage bufferedImage = ImageIO.read(new BufferedInputStream(getClass().getClassLoader().getResourceAsStream(ref))); + + return bufferedImage; + } +} diff --git a/src/java/org/lwjgl/input/Controller.java b/src/java/org/lwjgl/input/Controller.java new file mode 100644 index 0000000..9649df6 --- /dev/null +++ b/src/java/org/lwjgl/input/Controller.java @@ -0,0 +1,273 @@ +/* + * 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 + */ + public String getName(); + + /** + * Get the index of this controller in the collection + * + * @return The index of this controller in the collection + */ + public int getIndex(); + + /** + * Retrieve the number of buttons available on this controller + * + * @return The number of butotns available on this controller + */ + public 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 + */ + public 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 + */ + public boolean isButtonPressed(int index); + + /** + * Poll the controller for new data. This will also update + * events + */ + public void poll(); + + /** + * Get the X-Axis value of the POV on this controller + * + * @return The X-Axis value of the POV on this controller + */ + public float getPovX(); + + /** + * Get the Y-Axis value of the POV on this controller + * + * @return The Y-Axis value of the POV on this controller + */ + public 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 + */ + public 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 + */ + public void setDeadZone(int index,float zone); + + /** + * Retrieve the number of axes available on this controller. + * + * @return The number of axes available on this controller. + */ + public 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. + */ + public 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. + */ + public 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 + */ + public float getXAxisValue(); + + /** + * Get the dead zone for the X axis. + * + * @return The dead zone for the X axis + */ + public float getXAxisDeadZone(); + + /** + * Set the dead zone for the X axis + * + * @param zone The dead zone to use for the X axis + */ + public 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 + */ + public float getYAxisValue(); + + /** + * Get the dead zone for the Y axis. + * + * @return The dead zone for the Y axis + */ + public float getYAxisDeadZone(); + + /** + * Set the dead zone for the Y axis + * + * @param zone The dead zone to use for the Y axis + */ + public 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 + */ + public float getZAxisValue(); + + /** + * Get the dead zone for the Z axis. + * + * @return The dead zone for the Z axis + */ + public float getZAxisDeadZone(); + + /** + * Set the dead zone for the Z axis + * + * @param zone The dead zone to use for the Z axis + */ + public 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 + */ + public float getRXAxisValue(); + + /** + * Get the dead zone for the RX axis. + * + * @return The dead zone for the RX axis + */ + public float getRXAxisDeadZone(); + + /** + * Set the dead zone for the RX axis + * + * @param zone The dead zone to use for the RX axis + */ + public 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 + */ + public float getRYAxisValue(); + + /** + * Get the dead zone for the RY axis. + * + * @return The dead zone for the RY axis + */ + public float getRYAxisDeadZone(); + + /** + * Set the dead zone for the RY axis + * + * @param zone The dead zone to use for the RY axis + */ + public 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 + */ + public float getRZAxisValue(); + + /** + * Get the dead zone for the RZ axis. + * + * @return The dead zone for the RZ axis + */ + public float getRZAxisDeadZone(); + + /** + * Set the dead zone for the RZ axis + * + * @param zone The dead zone to use for the RZ axis + */ + public void setRZAxisDeadZone(float zone); +} diff --git a/src/java/org/lwjgl/input/ControllerEvent.java b/src/java/org/lwjgl/input/ControllerEvent.java new file mode 100644 index 0000000..b4c2d3b --- /dev/null +++ b/src/java/org/lwjgl/input/ControllerEvent.java @@ -0,0 +1,169 @@ +/* + * 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; + +/** + * An event occuring on a controller. + * + * @author Kevin Glass + */ +class ControllerEvent { + /** Indicates the event was caused by a button */ + public static final int BUTTON = 1; + /** Indicates the event was caused by a axis */ + public static final int AXIS = 2; + /** Indicates the event was caused by a pov X */ + public static final int POVX = 3; + /** Indicates the event was caused by a pov Y */ + public static final int POVY = 4; + + /** The controller generating the event */ + private Controller source; + /** The index of the input (axis or button) that generated the event */ + private int index; + /** Type of control that generated the event */ + private int type; + /** True if this event was caused by the x axis */ + private boolean xaxis; + /** True if this event was caused by the y axis */ + private boolean yaxis; + /** The time stamp of this event */ + private long timeStamp; + + /** + * Create a new event + * + * @param source The source of the event + * @param timeStamp The time stamp given for this event + * @param type The type of control generating this event + * @param index The index of the input that generated the event + * @param xaxis True if this event was caused by the x-axis + * @param yaxis True if this event was caused by the y-axis + */ + public ControllerEvent(Controller source,long timeStamp, int type,int index,boolean xaxis,boolean yaxis) { + this.source = source; + this.timeStamp = timeStamp; + this.type = type; + this.index = index; + this.xaxis = xaxis; + this.yaxis = yaxis; + } + + /** + * Get the time stamp given for this event. As with nanoTime() + * this value means nothing other than giving ordering + * + * @return The time stamp given for this event + */ + public long getTimeStamp() { + return timeStamp; + } + + /** + * Get the controller that generated this event + * + * @return The controller that generated this event + */ + public Controller getSource() { + return source; + } + + /** + * Get the index of the control generating this event + * + * @return The index of the control generating this event + */ + public int getControlIndex() { + return index; + } + + /** + * Check if this event was generated by a button + * + * @return True if this event was generated by a button + */ + public boolean isButton() { + return type == BUTTON; + } + + /** + * Check if this event was generated by a axis + * + * @return True if this event was generated by a axis + */ + public boolean isAxis() { + return type == AXIS; + } + + /** + * Check if this event was generated by a pov + * + * @return True if this event was generated by a pov + */ + public boolean isPovY() { + return type == POVY; + } + /** + * + * Check if this event was generated by a pov + * + * @return True if this event was generated by a pov + */ + public boolean isPovX() { + return type == POVX; + } + + /** + * Check if this event was caused by the X axis + * + * @return True if this event was caused by the X axis + */ + public boolean isXAxis() { + return xaxis; + } + + /** + * Check if this event was caused by the Y axis + * + * @return True if this event was caused by the Y axis + */ + public boolean isYAxis() { + return yaxis; + } + + /* + * @see java.lang.Object#toString() + */ + public String toString() { + return "["+source+" type="+type+" xaxis="+xaxis+" yaxis="+yaxis+"]"; + } +} diff --git a/src/java/org/lwjgl/input/Controllers.java b/src/java/org/lwjgl/input/Controllers.java new file mode 100644 index 0000000..c43bfc0 --- /dev/null +++ b/src/java/org/lwjgl/input/Controllers.java @@ -0,0 +1,287 @@ +/* + * 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; + +import java.util.ArrayList; + +import net.java.games.input.ControllerEnvironment; + +import org.lwjgl.LWJGLException; + +/** + * The collection of controllers currently connected. + * + * @author Kevin Glass + */ +public class Controllers { + /** The controllers available */ + private static ArrayList controllers = new ArrayList(); + /** The number of controllers */ + private static int controllerCount; + + /** The current list of events */ + private static ArrayList events = new ArrayList(); + /** The current event */ + private static ControllerEvent event; + + /** Whether controllers were created */ + private static boolean created; + + /** + * Initialise the controllers collection + * + * @throws LWJGLException Indicates a failure to initialise the controller library. + */ + public static void create() throws LWJGLException { + if (created) + return; + + try { + ControllerEnvironment env = ControllerEnvironment.getDefaultEnvironment(); + + net.java.games.input.Controller[] found = env.getControllers(); + ArrayList lollers = new ArrayList(); + for (int i=0;i + * @version $Revision: 2983 $ + * $Id: Cursor.java 2983 2008-04-07 18:36:09Z matzon $ + */ + +public class Cursor { + /** 1 bit transparency for native cursor */ + public static final int CURSOR_ONE_BIT_TRANSPARENCY = 1; + + /** 8 bit alhpa native cursor */ + public static final int CURSOR_8_BIT_ALPHA = 2; + + /** animation native cursor */ + public static final int CURSOR_ANIMATION = 4; + + /** First element to display */ + private final CursorElement[] cursors; + + /** Index into list of cursors */ + private int index = 0; + + private boolean destroyed; + + /** + * 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 transparancy 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 { + synchronized (OpenGLPackageAccess.global_lock) { + if ((getCapabilities() & CURSOR_ONE_BIT_TRANSPARENCY) == 0) + throw new LWJGLException("Native cursors not supported"); + images = NondirectBufferWrapper.wrapBuffer(images, width*height*numImages); + if (delays != null) + delays = NondirectBufferWrapper.wrapBuffer(delays, numImages); + if (!Mouse.isCreated()) + throw new IllegalStateException("Mouse must be created before creating cursor objects"); + if (width*height*numImages > images.remaining()) + throw new IllegalArgumentException("width*height*numImages > images.remaining()"); + if (xHotspot >= width || xHotspot < 0) + throw new IllegalArgumentException("xHotspot > width || xHotspot < 0"); + if (yHotspot >= height || yHotspot < 0) + throw new IllegalArgumentException("yHotspot > height || yHotspot < 0"); + + Sys.initialize(); + + // Hmm + yHotspot = height - 1 - yHotspot; + + // create cursor (or cursors if multiple images supplied) + cursors = createCursors(width, height, xHotspot, yHotspot, numImages, images, delays); + } + } + + /** + * 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 maximum size of a native cursor + */ + public static int getMinCursorSize() { + synchronized (OpenGLPackageAccess.global_lock) { + if (!Mouse.isCreated()) + throw new IllegalStateException("Mouse must be created."); + return Mouse.getImplementation().getMinCursorSize(); + } + } + + /** + * Gets the maximum 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 maximum size of a native cursor + */ + public static int getMaxCursorSize() { + synchronized (OpenGLPackageAccess.global_lock) { + if (!Mouse.isCreated()) + throw new IllegalStateException("Mouse must be created."); + return Mouse.getImplementation().getMaxCursorSize(); + } + } + + /** + * Get the capabilities of the native cursor. Return a bit mask of the native cursor capabilities. + * The CURSOR_ONE_BIT_TRANSPARANCY indicates support for cursors with one bit transparancy, + * the CURSOR_8_BIT_ALPHA indicates support for 8 bit alpha and CURSOR_ANIMATION indicates + * support for cursor animations. + * + * @return A bit mask with native cursor capabilities. + */ + public static int getCapabilities() { + synchronized (OpenGLPackageAccess.global_lock) { + if (Mouse.getImplementation() != null) + return Mouse.getImplementation().getNativeCursorCapabilities(); + else + return OpenGLPackageAccess.createImplementation().getNativeCursorCapabilities(); + } + } + + /** + * Creates the actual cursor, using a platform specific class + */ + private static CursorElement[] createCursors(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, IntBuffer delays) throws LWJGLException { + // create copy and flip images to match ogl + IntBuffer images_copy = BufferUtils.createIntBuffer(images.remaining()); + flipImages(width, height, numImages, images, images_copy); + + // Win32 doesn't (afaik) allow for animation based cursors, except when they're + // in the .ani format, which we don't support. + // The cursor animation was therefor developed using java side time tracking. + // unfortunately X flickers when changing cursor. We therefore check for either + // Win32 or X and do accordingly. This hasn't been implemented on Mac, but we + // might want to split it into a X/Win/Mac cursor if it gets too cluttered + + CursorElement[] cursors; + switch (LWJGLUtil.getPlatform()) { + case LWJGLUtil.PLATFORM_MACOSX: + /* Fall through */ + case LWJGLUtil.PLATFORM_WINDOWS: + // create our cursor elements + cursors = new CursorElement[numImages]; + for(int i=0; i> 24 & 0xff; + if(alpha != 0xff) { + images_copy.put(index, 0); + } + } + + Object handle = Mouse.getImplementation().createCursor(width, height, xHotspot, yHotspot, 1, images_copy, null); + long delay = (delays != null) ? delays.get(i) : 0; + long timeout = System.currentTimeMillis(); + cursors[i] = new CursorElement(handle, delay, timeout); + + // offset to next image + images_copy.position(width*height*(i+1)); + } + break; + case LWJGLUtil.PLATFORM_LINUX: + // create our cursor elements + Object handle = Mouse.getImplementation().createCursor(width, height, xHotspot, yHotspot, numImages, images_copy, delays); + CursorElement cursor_element = new CursorElement(handle, -1, -1); + cursors = new CursorElement[]{cursor_element}; + break; + default: + throw new RuntimeException("Unknown OS"); + } + return cursors; + } + + /** + * 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. + */ + Object getHandle() { + checkValid(); + return cursors[index].cursorHandle; + } + + private void checkValid() { + if (destroyed) + throw new IllegalStateException("The cursor is destroyed"); + } + + /** + * Destroy the native cursor. If the cursor is current, + * the current native cursor is set to null (the default + * OS cursor) + */ + public void destroy() { + synchronized (OpenGLPackageAccess.global_lock) { + if (destroyed) + return; + if (Mouse.getNativeCursor() == this) { + try { + Mouse.setNativeCursor(null); + } catch (LWJGLException e) { + // ignore + } + } + for(int i=0; i 1 && cursors[index].timeout < System.currentTimeMillis(); + } + + /** + * Changes to the next cursor + */ + protected void nextCursor() { + checkValid(); + index = ++index % cursors.length; + } + + /** + * A single cursor element, used when animating + */ + private static class CursorElement { + /** Handle to cursor */ + final Object cursorHandle; + + /** How long a delay this element should have */ + final long delay; + + /** Absolute time this element times out */ + long timeout; + + CursorElement(Object cursorHandle, long delay, long timeout) { + this.cursorHandle = cursorHandle; + this.delay = delay; + this.timeout = timeout; + } + } +} diff --git a/src/java/org/lwjgl/input/JInputController.java b/src/java/org/lwjgl/input/JInputController.java new file mode 100644 index 0000000..7a9aba9 --- /dev/null +++ b/src/java/org/lwjgl/input/JInputController.java @@ -0,0 +1,512 @@ +/* + * 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; + +import java.util.ArrayList; + +import net.java.games.input.Component; +import net.java.games.input.Event; +import net.java.games.input.EventQueue; + +/** + * A wrapper round a JInput controller that attempts to make the interface + * more useable. + * + * @author Kevin Glass + */ +class JInputController implements Controller { + /** The JInput controller this class is wrapping */ + private net.java.games.input.Controller target; + /** The index that has been assigned to this controller */ + private int index; + /** The Buttons that have been detected on the JInput controller */ + private ArrayList buttons = new ArrayList(); + /** The Axes that have been detected on the JInput controller */ + private ArrayList axes = new ArrayList(); + /** The POVs that have been detected on the JInput controller */ + private ArrayList pov = new ArrayList(); + /** The state of the buttons last check */ + private boolean[] buttonState; + /** The values that were read from the pov last check */ + private float[] povValues; + /** The values that were read from the axes last check */ + private float[] axesValue; + /** The maximum values read for each axis */ + private float[] axesMax; + /** The dead zones for each axis */ + private float[] deadZones; + /** The index of the X axis or -1 if no X axis is defined */ + private int xaxis = -1; + /** The index of the Y axis or -1 if no Y axis is defined */ + private int yaxis = -1; + /** The index of the X axis or -1 if no Z axis is defined */ + private int zaxis = -1; + /** The index of the RX axis or -1 if no RX axis is defined */ + private int rxaxis = -1; + /** The index of the RY axis or -1 if no RY axis is defined */ + private int ryaxis = -1; + /** The index of the RZ axis or -1 if no RZ axis is defined */ + private int rzaxis = -1; + + /** + * Create a new controller that wraps round a JInput controller and hopefully + * makes it easier to use. + * + * @param index The index this controller has been assigned to + * @param target The target JInput controller this class is wrapping + */ + public JInputController(int index,net.java.games.input.Controller target) { + this.target = target; + this.index = index; + + Component[] sourceAxes = target.getComponents(); + + for (int i=0;i axesMax[axisIndex]) { + axesMax[axisIndex] = Math.abs(value); + } + + // normalize the value based on maximum value read in the past + value /= axesMax[axisIndex]; + // fire event + Controllers.addEvent(new ControllerEvent(this,event.getNanos(),ControllerEvent.AXIS,axisIndex, + axisIndex == xaxis,axisIndex == yaxis)); + axesValue[axisIndex] = value; + } + } + } + + /* + * @see org.lwjgl.input.Controller#getAxisCount() + */ + public int getAxisCount() { + return axes.size(); + } + + /* + * @see org.lwjgl.input.Controller#getAxisName(int) + */ + public String getAxisName(int index) { + Component axis = (Component) axes.get(index); + + return axis.getName(); + } + + /* + * @see org.lwjgl.input.Controller#getAxisValue(int) + */ + public float getAxisValue(int index) { + return axesValue[index]; + } + + /* + * @see org.lwjgl.input.Controller#getXAxisValue() + */ + public float getXAxisValue() { + if (xaxis == -1) { + return 0; + } + + return getAxisValue(xaxis); + } + + /* + * @see org.lwjgl.input.Controller#getYAxisValue() + */ + public float getYAxisValue() { + if (yaxis == -1) { + return 0; + } + + return getAxisValue(yaxis); + } + + /* + * @see org.lwjgl.input.Controller#getXAxisDeadZone() + */ + public float getXAxisDeadZone() { + if (xaxis == -1) { + return 0; + } + + return getDeadZone(xaxis); + } + + /* + * @see org.lwjgl.input.Controller#getYAxisDeadZone() + */ + public float getYAxisDeadZone() { + if (yaxis == -1) { + return 0; + } + + return getDeadZone(yaxis); + } + + /* + * @see org.lwjgl.input.Controller#setXAxisDeadZone(float) + */ + public void setXAxisDeadZone(float zone) { + setDeadZone(xaxis,zone); + } + + /* + * @see org.lwjgl.input.Controller#setYAxisDeadZone(float) + */ + public void setYAxisDeadZone(float zone) { + setDeadZone(yaxis,zone); + } + + /* + * @see org.lwjgl.input.Controller#getDeadZone(int) + */ + public float getDeadZone(int index) { + return deadZones[index]; + } + + /* + * @see org.lwjgl.input.Controller#setDeadZone(int, float) + */ + public void setDeadZone(int index, float zone) { + deadZones[index] = zone; + } + + /* + * @see org.lwjgl.input.Controller#getZAxisValue() + */ + public float getZAxisValue() { + if (zaxis == -1) { + return 0; + } + + return getAxisValue(zaxis); + } + + /* + * @see org.lwjgl.input.Controller#getZAxisDeadZone() + */ + public float getZAxisDeadZone() { + if (zaxis == -1) { + return 0; + } + + return getDeadZone(zaxis); + } + + /* + * @see org.lwjgl.input.Controller#setZAxisDeadZone(float) + */ + public void setZAxisDeadZone(float zone) { + setDeadZone(zaxis,zone); + } + + /* + * @see org.lwjgl.input.Controller#getRXAxisValue() + */ + public float getRXAxisValue() { + if (rxaxis == -1) { + return 0; + } + + return getAxisValue(rxaxis); + } + + /* + * @see org.lwjgl.input.Controller#getRXAxisDeadZone() + */ + public float getRXAxisDeadZone() { + if (rxaxis == -1) { + return 0; + } + + return getDeadZone(rxaxis); + } + + /* + * @see org.lwjgl.input.Controller#setRXAxisDeadZone(float) + */ + public void setRXAxisDeadZone(float zone) { + setDeadZone(rxaxis,zone); + } + + /* + * @see org.lwjgl.input.Controller#getRYAxisValue() + */ + public float getRYAxisValue() { + if (ryaxis == -1) { + return 0; + } + + return getAxisValue(ryaxis); + } + + /* + * @see org.lwjgl.input.Controller#getRYAxisDeadZone() + */ + public float getRYAxisDeadZone() { + if (ryaxis == -1) { + return 0; + } + + return getDeadZone(ryaxis); + } + + /* + * @see org.lwjgl.input.Controller#setRYAxisDeadZone(float) + */ + public void setRYAxisDeadZone(float zone) { + setDeadZone(ryaxis,zone); + } + + /* + * @see org.lwjgl.input.Controller#getRZAxisValue() + */ + public float getRZAxisValue() { + if (rzaxis == -1) { + return 0; + } + + return getAxisValue(rzaxis); + } + + /* + * @see org.lwjgl.input.Controller#getRZAxisDeadZone() + */ + public float getRZAxisDeadZone() { + if (rzaxis == -1) { + return 0; + } + + return getDeadZone(rzaxis); + } + + /* + * @see org.lwjgl.input.Controller#setRZAxisDeadZone(float) + */ + public void setRZAxisDeadZone(float zone) { + setDeadZone(rzaxis,zone); + } + + /* + * @see org.lwjgl.input.Controller#getPovX() + */ + public float getPovX() { + if (pov.size() == 0) { + return 0; + } + + float value = povValues[0]; + + if ((value == Component.POV.DOWN_LEFT) || + (value == Component.POV.UP_LEFT) || + (value == Component.POV.LEFT)) { + return -1; + } + if ((value == Component.POV.DOWN_RIGHT) || + (value == Component.POV.UP_RIGHT) || + (value == Component.POV.RIGHT)) { + return 1; + } + + return 0; + } + + /* + * @see org.lwjgl.input.Controller#getPovY() + */ + public float getPovY() { + if (pov.size() == 0) { + return 0; + } + + float value = povValues[0]; + + if ((value == Component.POV.DOWN_LEFT) || + (value == Component.POV.DOWN_RIGHT) || + (value == Component.POV.DOWN)) { + return 1; + } + if ((value == Component.POV.UP_LEFT) || + (value == Component.POV.UP_RIGHT) || + (value == Component.POV.UP)) { + return -1; + } + + return 0; + } + + +} diff --git a/src/java/org/lwjgl/input/Keyboard.java b/src/java/org/lwjgl/input/Keyboard.java new file mode 100644 index 0000000..bc7ee26 --- /dev/null +++ b/src/java/org/lwjgl/input/Keyboard.java @@ -0,0 +1,602 @@ +/* + * 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; + +import java.lang.reflect.Field; +import java.lang.reflect.Modifier; +import java.nio.ByteBuffer; +import java.util.HashMap; +import java.util.Map; + +import org.lwjgl.BufferUtils; +import org.lwjgl.LWJGLException; +import org.lwjgl.Sys; +import org.lwjgl.opengl.Display; +import org.lwjgl.opengl.InputImplementation; + +/** + *
+ * A raw Keyboard interface. This can be used to poll the current state of the + * keys, or read all the keyboard presses / releases since the last read. + * + * @author cix_foo + * @author elias_naur + * @author Brian Matzon + * @version $Revision: 2983 $ + * $Id: Keyboard.java 2983 2008-04-07 18:36:09Z matzon $ + */ +public class Keyboard { + /** Internal use - event size in bytes */ + public static final int EVENT_SIZE = 4 + 1 + 4 + 8 + 1; + + /** + * The special character meaning that no + * character was translated for the event. + */ + public static final int CHAR_NONE = '\0'; + + /** + * The special keycode meaning that only the + * translated character is valid. + */ + public static final int KEY_NONE = 0x00; + + public static final int KEY_ESCAPE = 0x01; + public static final int KEY_1 = 0x02; + public static final int KEY_2 = 0x03; + public static final int KEY_3 = 0x04; + public static final int KEY_4 = 0x05; + public static final int KEY_5 = 0x06; + public static final int KEY_6 = 0x07; + public static final int KEY_7 = 0x08; + public static final int KEY_8 = 0x09; + public static final int KEY_9 = 0x0A; + public static final int KEY_0 = 0x0B; + public static final int KEY_MINUS = 0x0C; /* - on main keyboard */ + public static final int KEY_EQUALS = 0x0D; + public static final int KEY_BACK = 0x0E; /* backspace */ + public static final int KEY_TAB = 0x0F; + public static final int KEY_Q = 0x10; + public static final int KEY_W = 0x11; + public static final int KEY_E = 0x12; + public static final int KEY_R = 0x13; + public static final int KEY_T = 0x14; + public static final int KEY_Y = 0x15; + public static final int KEY_U = 0x16; + public static final int KEY_I = 0x17; + public static final int KEY_O = 0x18; + public static final int KEY_P = 0x19; + public static final int KEY_LBRACKET = 0x1A; + public static final int KEY_RBRACKET = 0x1B; + public static final int KEY_RETURN = 0x1C; /* Enter on main keyboard */ + public static final int KEY_LCONTROL = 0x1D; + public static final int KEY_A = 0x1E; + public static final int KEY_S = 0x1F; + public static final int KEY_D = 0x20; + public static final int KEY_F = 0x21; + public static final int KEY_G = 0x22; + public static final int KEY_H = 0x23; + public static final int KEY_J = 0x24; + public static final int KEY_K = 0x25; + public static final int KEY_L = 0x26; + public static final int KEY_SEMICOLON = 0x27; + public static final int KEY_APOSTROPHE = 0x28; + public static final int KEY_GRAVE = 0x29; /* accent grave */ + public static final int KEY_LSHIFT = 0x2A; + public static final int KEY_BACKSLASH = 0x2B; + public static final int KEY_Z = 0x2C; + public static final int KEY_X = 0x2D; + public static final int KEY_C = 0x2E; + public static final int KEY_V = 0x2F; + public static final int KEY_B = 0x30; + public static final int KEY_N = 0x31; + public static final int KEY_M = 0x32; + public static final int KEY_COMMA = 0x33; + public static final int KEY_PERIOD = 0x34; /* . on main keyboard */ + public static final int KEY_SLASH = 0x35; /* / on main keyboard */ + public static final int KEY_RSHIFT = 0x36; + public static final int KEY_MULTIPLY = 0x37; /* * on numeric keypad */ + public static final int KEY_LMENU = 0x38; /* left Alt */ + public static final int KEY_SPACE = 0x39; + public static final int KEY_CAPITAL = 0x3A; + public static final int KEY_F1 = 0x3B; + public static final int KEY_F2 = 0x3C; + public static final int KEY_F3 = 0x3D; + public static final int KEY_F4 = 0x3E; + public static final int KEY_F5 = 0x3F; + public static final int KEY_F6 = 0x40; + public static final int KEY_F7 = 0x41; + public static final int KEY_F8 = 0x42; + public static final int KEY_F9 = 0x43; + public static final int KEY_F10 = 0x44; + public static final int KEY_NUMLOCK = 0x45; + public static final int KEY_SCROLL = 0x46; /* Scroll Lock */ + public static final int KEY_NUMPAD7 = 0x47; + public static final int KEY_NUMPAD8 = 0x48; + public static final int KEY_NUMPAD9 = 0x49; + public static final int KEY_SUBTRACT = 0x4A; /* - on numeric keypad */ + public static final int KEY_NUMPAD4 = 0x4B; + public static final int KEY_NUMPAD5 = 0x4C; + public static final int KEY_NUMPAD6 = 0x4D; + public static final int KEY_ADD = 0x4E; /* + on numeric keypad */ + public static final int KEY_NUMPAD1 = 0x4F; + public static final int KEY_NUMPAD2 = 0x50; + public static final int KEY_NUMPAD3 = 0x51; + public static final int KEY_NUMPAD0 = 0x52; + public static final int KEY_DECIMAL = 0x53; /* . on numeric keypad */ + public static final int KEY_F11 = 0x57; + public static final int KEY_F12 = 0x58; + public static final int KEY_F13 = 0x64; /* (NEC PC98) */ + public static final int KEY_F14 = 0x65; /* (NEC PC98) */ + public static final int KEY_F15 = 0x66; /* (NEC PC98) */ + public static final int KEY_KANA = 0x70; /* (Japanese keyboard) */ + public static final int KEY_CONVERT = 0x79; /* (Japanese keyboard) */ + public static final int KEY_NOCONVERT = 0x7B; /* (Japanese keyboard) */ + public static final int KEY_YEN = 0x7D; /* (Japanese keyboard) */ + public static final int KEY_NUMPADEQUALS = 0x8D; /* = on numeric keypad (NEC PC98) */ + public static final int KEY_CIRCUMFLEX = 0x90; /* (Japanese keyboard) */ + public static final int KEY_AT = 0x91; /* (NEC PC98) */ + public static final int KEY_COLON = 0x92; /* (NEC PC98) */ + public static final int KEY_UNDERLINE = 0x93; /* (NEC PC98) */ + public static final int KEY_KANJI = 0x94; /* (Japanese keyboard) */ + public static final int KEY_STOP = 0x95; /* (NEC PC98) */ + public static final int KEY_AX = 0x96; /* (Japan AX) */ + public static final int KEY_UNLABELED = 0x97; /* (J3100) */ + public static final int KEY_NUMPADENTER = 0x9C; /* Enter on numeric keypad */ + public static final int KEY_RCONTROL = 0x9D; + public static final int KEY_NUMPADCOMMA = 0xB3; /* , on numeric keypad (NEC PC98) */ + public static final int KEY_DIVIDE = 0xB5; /* / on numeric keypad */ + public static final int KEY_SYSRQ = 0xB7; + public static final int KEY_RMENU = 0xB8; /* right Alt */ + public static final int KEY_PAUSE = 0xC5; /* Pause */ + public static final int KEY_HOME = 0xC7; /* Home on arrow keypad */ + public static final int KEY_UP = 0xC8; /* UpArrow on arrow keypad */ + public static final int KEY_PRIOR = 0xC9; /* PgUp on arrow keypad */ + public static final int KEY_LEFT = 0xCB; /* LeftArrow on arrow keypad */ + public static final int KEY_RIGHT = 0xCD; /* RightArrow on arrow keypad */ + public static final int KEY_END = 0xCF; /* End on arrow keypad */ + public static final int KEY_DOWN = 0xD0; /* DownArrow on arrow keypad */ + public static final int KEY_NEXT = 0xD1; /* PgDn on arrow keypad */ + public static final int KEY_INSERT = 0xD2; /* Insert on arrow keypad */ + public static final int KEY_DELETE = 0xD3; /* Delete on arrow keypad */ + public static final int KEY_LMETA = 0xDB; /* Left Windows/Option key */ + /** + * The left windows key, mapped to KEY_LMETA + * + * @deprecated Use KEY_LMETA instead + */ + public static final int KEY_LWIN = KEY_LMETA; /* Left Windows key */ + public static final int KEY_RMETA = 0xDC; /* Right Windows/Option key */ + /** + * The right windows key, mapped to KEY_RMETA + * + * @deprecated Use KEY_RMETA instead + */ + public static final int KEY_RWIN = KEY_RMETA; /* Right Windows key */ + public static final int KEY_APPS = 0xDD; /* AppMenu key */ + public static final int KEY_POWER = 0xDE; + public static final int KEY_SLEEP = 0xDF; + +/* public static final int STATE_ON = 0; + public static final int STATE_OFF = 1; + public static final int STATE_UNKNOWN = 2; +*/ + public static final int KEYBOARD_SIZE = 256; + + /** Buffer size in events */ + private static final int BUFFER_SIZE = 50; + + /** Key names */ + private static final String[] keyName = new String[255]; + private static final Map keyMap = new HashMap(253); + private static int counter; + + static { + // Use reflection to find out key names + Field[] field = Keyboard.class.getFields(); + try { + for (int i = 0; i < field.length; i++) { + if (Modifier.isStatic(field[i].getModifiers()) + && Modifier.isPublic(field[i].getModifiers()) + && Modifier.isFinal(field[i].getModifiers()) + && field[i].getType().equals(int.class) + && field[i].getName().startsWith("KEY_")) { + + int key = field[i].getInt(null); + String name = field[i].getName().substring(4); + keyName[key] = name; + keyMap.put(name, new Integer(key)); + counter ++; + } + + } + } catch (Exception e) { + } + + } + + /** The number of keys supported */ + private static final int keyCount = counter; + + /** Has the keyboard been created? */ + private static boolean created; + + /** Are repeat events enabled? */ + private static boolean repeat_enabled; + + /** The keys status from the last poll */ + private static final ByteBuffer keyDownBuffer = BufferUtils.createByteBuffer(KEYBOARD_SIZE); + + /** + * The key events from the last read: a sequence of pairs of key number, + * followed by state. The state is followed by + * a 4 byte code point representing the translated character. + */ + private static ByteBuffer readBuffer; + + /** current event */ + private static KeyEvent current_event = new KeyEvent(); + + /** scratch event */ + private static KeyEvent tmp_event = new KeyEvent(); + + /** One time initialization */ + private static boolean initialized; + + private static InputImplementation implementation; + + /** + * Keyboard cannot be constructed. + */ + private Keyboard() { + } + + /** + * Static initialization + */ + private static void initialize() { + if (initialized) + return; + Sys.initialize(); + initialized = true; + } + + /** + * "Create" the keyboard with the given implementation. This is used + * reflectively from AWTInputAdapter. + * + * @throws LWJGLException if the keyboard could not be created for any reason + */ + private static void create(InputImplementation impl) throws LWJGLException { + if (created) + return; + if (!initialized) + initialize(); + implementation = impl; + implementation.createKeyboard(); + created = true; + readBuffer = ByteBuffer.allocate(EVENT_SIZE*BUFFER_SIZE); + reset(); + } + + /** + * "Create" the keyboard. The display must first have been created. The + * reason for this is so the keyboard has a window to "focus" in. + * + * @throws LWJGLException if the keyboard could not be created for any reason + */ + public static void create() throws LWJGLException { + synchronized (OpenGLPackageAccess.global_lock) { + if (!Display.isCreated()) throw new IllegalStateException("Display must be created."); + + create(OpenGLPackageAccess.createImplementation()); + } + } + + private static void reset() { + readBuffer.limit(0); + for (int i = 0; i < keyDownBuffer.remaining(); i++) + keyDownBuffer.put(i, (byte)0); + current_event.reset(); + } + + /** + * @return true if the keyboard has been created + */ + public static boolean isCreated() { + synchronized (OpenGLPackageAccess.global_lock) { + return created; + } + } + + /** + * "Destroy" the keyboard + */ + public static void destroy() { + synchronized (OpenGLPackageAccess.global_lock) { + if (!created) + return; + created = false; + implementation.destroyKeyboard(); + reset(); + } + } + + /** + * Polls the keyboard for its current state. Access the polled values using the + * isKeyDown method. + * By using this method, it is possible to "miss" keyboard keys if you don't + * poll fast enough. + * + * To use buffered values, you have to call next for each event you + * want to read. You can query which key caused the event by using + * getEventKey. To get the state of that key, for that event, use + * getEventKeyState - finally use getEventCharacter to get the + * character for that event. + * + * NOTE: This method does not query the operating system for new events. To do that, + * Display.processMessages() (or Display.update()) must be called first. + * + * @see org.lwjgl.input.Keyboard#isKeyDown(int key) + * @see org.lwjgl.input.Keyboard#next() + * @see org.lwjgl.input.Keyboard#getEventKey() + * @see org.lwjgl.input.Keyboard#getEventKeyState() + * @see org.lwjgl.input.Keyboard#getEventCharacter() + */ + public static void poll() { + synchronized (OpenGLPackageAccess.global_lock) { + if (!created) + throw new IllegalStateException("Keyboard must be created before you can poll the device"); + implementation.pollKeyboard(keyDownBuffer); + read(); + } + } + + private static void read() { + readBuffer.compact(); + implementation.readKeyboard(readBuffer); + readBuffer.flip(); + } + + /** + * Checks to see if a key is down. + * @param key Keycode to check + * @return true if the key is down according to the last poll() + */ + public static boolean isKeyDown(int key) { + synchronized (OpenGLPackageAccess.global_lock) { + if (!created) + throw new IllegalStateException("Keyboard must be created before you can query key state"); + return keyDownBuffer.get(key) != 0; + } + } + + /** + * Checks whether one of the state keys are "active" + * + * @param key State key to test (KEY_CAPITAL | KEY_NUMLOCK | KEY_SYSRQ) + * @return STATE_ON if on, STATE_OFF if off and STATE_UNKNOWN if the state is unknown + */ +/* public static int isStateKeySet(int key) { + if (!created) + throw new IllegalStateException("Keyboard must be created before you can query key state"); + return implementation.isStateKeySet(key); + } +*/ + /** + * Gets a key's name + * @param key The key + * @return a String with the key's human readable name in it or null if the key is unnamed + */ + public static synchronized String getKeyName(int key) { + return keyName[key]; + } + + /** + * Get's a key's index. If the key is unrecognised then KEY_NONE is returned. + * @param keyName The key name + */ + public static synchronized int getKeyIndex(String keyName) { + Integer ret = (Integer) keyMap.get(keyName); + if (ret == null) + return KEY_NONE; + else + return ret.intValue(); + } + + /** + * Gets the number of keyboard events waiting after doing a buffer enabled poll(). + * @return the number of keyboard events + */ + public static int getNumKeyboardEvents() { + synchronized (OpenGLPackageAccess.global_lock) { + if (!created) + throw new IllegalStateException("Keyboard must be created before you can read events"); + int old_position = readBuffer.position(); + int num_events = 0; + while (readNext(tmp_event) && (!tmp_event.repeat || repeat_enabled)) + num_events++; + readBuffer.position(old_position); + return num_events; + } + } + + /** + * Gets the next keyboard event. You can query which key caused the event by using + * getEventKey. To get the state of that key, for that event, use + * getEventKeyState - finally use getEventCharacter to get the + * character for that event. + * + * @see org.lwjgl.input.Keyboard#getEventKey() + * @see org.lwjgl.input.Keyboard#getEventKeyState() + * @see org.lwjgl.input.Keyboard#getEventCharacter() + * @return true if a keyboard event was read, false otherwise + */ + public static boolean next() { + synchronized (OpenGLPackageAccess.global_lock) { + if (!created) + throw new IllegalStateException("Keyboard must be created before you can read events"); + + boolean result; + while ((result = readNext(current_event)) && current_event.repeat && !repeat_enabled) + ; + return result; + } + } + + /** + * Controls whether repeat events are reported or not. If repeat events + * are enabled, key down events are reported when a key is pressed and held for + * a OS dependent amount of time. To distinguish a repeat event from a normal event, + * use isRepeatEvent(). + * + * @see org.lwjgl.input.Keyboard#getEventKey() + */ + public static void enableRepeatEvents(boolean enable) { + synchronized (OpenGLPackageAccess.global_lock) { + repeat_enabled = enable; + } + } + + /** + * Check whether repeat events are currently reported or not. + * + * @return true is repeat events are reported, false if not. + * @see org.lwjgl.input.Keyboard#getEventKey() + */ + public static boolean areRepeatEventsEnabled() { + synchronized (OpenGLPackageAccess.global_lock) { + return repeat_enabled; + } + } + + private static boolean readNext(KeyEvent event) { + if (readBuffer.hasRemaining()) { + event.key = readBuffer.getInt() & 0xFF; + event.state = readBuffer.get() != 0; + event.character = readBuffer.getInt(); + event.nanos = readBuffer.getLong(); + event.repeat = readBuffer.get() == 1; + return true; + } else + return false; + } + + /** + * @return Number of keys on this keyboard + */ + public static int getKeyCount() { + return keyCount; + } + + /** + * @return The character from the current event + */ + public static char getEventCharacter() { + synchronized (OpenGLPackageAccess.global_lock) { + return (char)current_event.character; + } + } + + /** + * Please note that the key code returned is NOT valid against the + * current keyboard layout. To get the actual character pressed call + * getEventCharacter + * + * @return The key from the current event + */ + public static int getEventKey() { + synchronized (OpenGLPackageAccess.global_lock) { + return current_event.key; + } + } + + /** + * Gets the state of the tkey that generated the + * current event + * + * @return True if key was down, or false if released + */ + public static boolean getEventKeyState() { + synchronized (OpenGLPackageAccess.global_lock) { + return current_event.state; + } + } + + /** + * Gets the time in nanoseconds of the current event. + * Only useful for relative comparisons with other + * Keyboard events, as the absolute time has no defined + * origin. + * @return The time in nanoseconds of the current event + */ + public static long getEventNanoseconds() { + synchronized (OpenGLPackageAccess.global_lock) { + return current_event.nanos; + } + } + + /** + * @see org.lwjgl.input.Keyboard#enableRepeatEvents(boolean) + * @return true if the current event is a repeat event, false if + * the current event is not a repeat even or if repeat events are disabled. + */ + public static boolean isRepeatEvent() { + synchronized (OpenGLPackageAccess.global_lock) { + return current_event.repeat; + } + } + + private final static class KeyEvent { + /** The current keyboard character being examined */ + private int character; + + /** The current keyboard event key being examined */ + private int key; + + /** The current state of the key being examined in the event queue */ + private boolean state; + + /** The current event time */ + private long nanos; + + /** Is the current event a repeated event? */ + private boolean repeat; + + private void reset() { + character = 0; + key = 0; + state = false; + repeat = false; + } + } +} diff --git a/src/java/org/lwjgl/input/Mouse.java b/src/java/org/lwjgl/input/Mouse.java new file mode 100644 index 0000000..9195a2e --- /dev/null +++ b/src/java/org/lwjgl/input/Mouse.java @@ -0,0 +1,683 @@ +/* + * 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; + +import java.nio.ByteBuffer; +import java.nio.IntBuffer; +import java.security.AccessController; +import java.security.PrivilegedAction; +import java.util.HashMap; +import java.util.Map; + +import org.lwjgl.BufferUtils; +import org.lwjgl.LWJGLException; +import org.lwjgl.LWJGLUtil; +import org.lwjgl.Sys; +import org.lwjgl.opengl.Display; +import org.lwjgl.opengl.InputImplementation; + + +/** + *
+ * A raw Mouse interface. This can be used to poll the current state of the + * mouse buttons, and determine the mouse movement delta since the last poll. + * + * n buttons supported, n being a native limit. A scrolly wheel is also + * supported, if one such is available. Movement is reported as delta from + * last position or as an absolute position. If the window has been created + * the absolute position will be clamped to 0 - width | height. + * + * @author cix_foo + * @author elias_naur + * @author Brian Matzon + * @version $Revision: 3297 $ + * $Id: Mouse.java 3297 2010-03-27 16:04:30Z kappa1 $ + */ +public class Mouse { + /** Internal use - event size in bytes */ + public static final int EVENT_SIZE = 1 + 1 + 4 + 4 + 4 + 8; + + /** Has the mouse been created? */ + private static boolean created; + + /** The mouse buttons status from the last poll */ + private static ByteBuffer buttons; + + /** Mouse absolute X position in pixels */ + private static int x; + + /** Mouse absolute Y position in pixels */ + private static int y; + + /** Buffer to hold the deltas dx, dy and dwheel */ + private static IntBuffer coord_buffer; + + /** Delta X */ + private static int dx; + + /** Delta Y */ + private static int dy; + + /** Delta Z */ + private static int dwheel; + + /** Number of buttons supported by the mouse */ + private static int buttonCount = -1; + + /** Does this mouse support a scroll wheel */ + private static boolean hasWheel; + + /** The current native cursor, if any */ + private static Cursor currentCursor; + + /** Button names. These are set upon create(), to names like BUTTON0, BUTTON1, etc. */ + private static String[] buttonName; + + /** hashmap of button names, for fast lookup */ + private static final Map buttonMap = new HashMap(16); + + /** Lazy initialization */ + private static boolean initialized; + + /** The mouse button events from the last read */ + private static ByteBuffer readBuffer; + + /** The current mouse event button being examined */ + private static int eventButton; + + /** The current state of the button being examined in the event queue */ + private static boolean eventState; + + /** The current delta of the mouse in the event queue */ + private static int event_dx; + private static int event_dy; + private static int event_dwheel; + /** The current absolute position of the mouse in the event queue */ + private static int event_x; + private static int event_y; + private static long event_nanos; + /** The position of the mouse it was grabbed at */ + private static int grab_x; + private static int grab_y; + + /** Buffer size in events */ + private static final int BUFFER_SIZE = 50; + + private static boolean isGrabbed; + + private static InputImplementation implementation; + + /** Whether we need cursor animation emulation */ + private static final boolean emulateCursorAnimation = LWJGLUtil.getPlatform() == LWJGLUtil.PLATFORM_WINDOWS || + LWJGLUtil.getPlatform() == LWJGLUtil.PLATFORM_MACOSX; + + private static final boolean allowNegativeMouseCoords = getPrivilegedBoolean("org.lwjgl.input.Mouse.allowNegativeMouseCoords"); + + /** + * Mouse cannot be constructed. + */ + private Mouse() { + } + + /** + * Gets the currently bound native cursor, if any. + * + * @return the currently bound native cursor, if any. + */ + public static Cursor getNativeCursor() { + synchronized (OpenGLPackageAccess.global_lock) { + return currentCursor; + } + } + + /** + * Binds a native cursor. If the cursor argument is null, any + * currently bound native cursor is disabled, and the cursor reverts + * to the default operating system supplied cursor. + * + * NOTE: The native cursor is not constrained to the window, but + * relative events will not be generated if the cursor is outside. + * + * @param cursor the native cursor object to bind. May be null. + * @return The previous Cursor object set, or null. + * @throws LWJGLException if the cursor could not be set for any reason + */ + public static Cursor setNativeCursor(Cursor cursor) throws LWJGLException { + synchronized (OpenGLPackageAccess.global_lock) { + if ((Cursor.getCapabilities() & Cursor.CURSOR_ONE_BIT_TRANSPARENCY) == 0) + throw new IllegalStateException("Mouse doesn't support native cursors"); + Cursor oldCursor = currentCursor; + currentCursor = cursor; + if (isCreated()) { + if (currentCursor != null) { + implementation.setNativeCursor(currentCursor.getHandle()); + currentCursor.setTimeout(); + } else { + implementation.setNativeCursor(null); + } + } + return oldCursor; + } + } + + /** + * Set the position of the cursor. If the cursor is not grabbed, + * the native cursor is moved to the new position. + * + * @param new_x The x coordinate of the new cursor position in OpenGL coordinates relative + * to the window origin. + * @param new_y The y coordinate of the new cursor position in OpenGL coordinates relative + * to the window origin. + */ + public static void setCursorPosition(int new_x, int new_y) { + synchronized (OpenGLPackageAccess.global_lock) { + if (!isCreated()) + throw new IllegalStateException("Mouse is not created"); + x = event_x = new_x; + y = event_y = new_y; + if (!isGrabbed() && (Cursor.getCapabilities() & Cursor.CURSOR_ONE_BIT_TRANSPARENCY) != 0) { + implementation.setCursorPosition(x, y); + } + else { + grab_x = new_x; + grab_y = new_y; + } + } + } + + /** + * Static initialization + */ + private static void initialize() { + Sys.initialize(); + + // Assign names to all the buttons + buttonName = new String[16]; + for (int i = 0; i < 16; i++) { + buttonName[i] = "BUTTON" + i; + buttonMap.put(buttonName[i], new Integer(i)); + } + + initialized = true; + } + + private static void resetMouse() { + dx = dy = dwheel = 0; + readBuffer.position(readBuffer.limit()); + } + + static InputImplementation getImplementation() { + return implementation; + } + + /** + * "Create" the mouse with the given custom implementation. This is used + * reflectively by AWTInputAdapter. + * + * @throws LWJGLException if the mouse could not be created for any reason + */ + private static void create(InputImplementation impl) throws LWJGLException { + if (created) + return; + if (!initialized) + initialize(); + implementation = impl; + implementation.createMouse(); + hasWheel = implementation.hasWheel(); + created = true; + + // set mouse buttons + buttonCount = implementation.getButtonCount(); + buttons = BufferUtils.createByteBuffer(buttonCount); + coord_buffer = BufferUtils.createIntBuffer(3); + if (currentCursor != null && implementation.getNativeCursorCapabilities() != 0) + setNativeCursor(currentCursor); + readBuffer = ByteBuffer.allocate(EVENT_SIZE * BUFFER_SIZE); + readBuffer.limit(0); + setGrabbed(isGrabbed); + } + + /** + * "Create" the mouse. The display must first have been created. + * Initially, the mouse is not grabbed and the delta values are reported + * with respect to the center of the display. + * + * @throws LWJGLException if the mouse could not be created for any reason + */ + public static void create() throws LWJGLException { + synchronized (OpenGLPackageAccess.global_lock) { + if (!Display.isCreated()) throw new IllegalStateException("Display must be created."); + + create(OpenGLPackageAccess.createImplementation()); + } + } + + /** + * @return true if the mouse has been created + */ + public static boolean isCreated() { + synchronized (OpenGLPackageAccess.global_lock) { + return created; + } + } + + /** + * "Destroy" the mouse. + */ + public static void destroy() { + synchronized (OpenGLPackageAccess.global_lock) { + if (!created) return; + created = false; + buttons = null; + coord_buffer = null; + + implementation.destroyMouse(); + } + } + + /** + * Polls the mouse for its current state. Access the polled values using the + * get methods. + * By using this method, it is possible to "miss" mouse click events if you don't + * poll fast enough. + * + * To use buffered values, you have to call next for each event you + * want to read. You can query which button caused the event by using + * getEventButton. To get the state of that button, for that event, use + * getEventButtonState. + * + * NOTE: This method does not query the operating system for new events. To do that, + * Display.processMessages() (or Display.update()) must be called first. + * + * @see org.lwjgl.input.Mouse#next() + * @see org.lwjgl.input.Mouse#getEventButton() + * @see org.lwjgl.input.Mouse#getEventButtonState() + * @see org.lwjgl.input.Mouse#isButtonDown(int button) + * @see org.lwjgl.input.Mouse#getX() + * @see org.lwjgl.input.Mouse#getY() + * @see org.lwjgl.input.Mouse#getDX() + * @see org.lwjgl.input.Mouse#getDY() + * @see org.lwjgl.input.Mouse#getDWheel() + */ + public static void poll() { + synchronized (OpenGLPackageAccess.global_lock) { + if (!created) throw new IllegalStateException("Mouse must be created before you can poll it"); + implementation.pollMouse(coord_buffer, buttons); + + /* If we're grabbed, poll returns mouse deltas, if not it returns absolute coordinates */ + int poll_coord1 = coord_buffer.get(0); + int poll_coord2 = coord_buffer.get(1); + /* The wheel is always relative */ + int poll_dwheel = coord_buffer.get(2); + + if (isGrabbed()) { + dx += poll_coord1; + dy += poll_coord2; + x += poll_coord1; + y += poll_coord2; + } else { + dx = poll_coord1 - x; + dy = poll_coord2 - y; + x = poll_coord1; + y = poll_coord2; + } + if(!allowNegativeMouseCoords) { + x = Math.min(implementation.getWidth() - 1, Math.max(0, x)); + y = Math.min(implementation.getHeight() - 1, Math.max(0, y)); + } + dwheel += poll_dwheel; + read(); + } + } + + private static void read() { + readBuffer.compact(); + implementation.readMouse(readBuffer); + readBuffer.flip(); + } + + /** + * See if a particular mouse button is down. + * + * @param button The index of the button you wish to test (0..getButtonCount-1) + * @return true if the specified button is down + */ + public static boolean isButtonDown(int button) { + synchronized (OpenGLPackageAccess.global_lock) { + if (!created) throw new IllegalStateException("Mouse must be created before you can poll the button state"); + if (button >= buttonCount || button < 0) + return false; + else + return buttons.get(button) == 1; + } + } + + /** + * Gets a button's name + * @param button The button + * @return a String with the button's human readable name in it or null if the button is unnamed + */ + public static String getButtonName(int button) { + synchronized (OpenGLPackageAccess.global_lock) { + if (button >= buttonName.length || button < 0) + return null; + else + return buttonName[button]; + } + } + + /** + * Get's a button's index. If the button is unrecognised then -1 is returned. + * @param buttonName The button name + */ + public static int getButtonIndex(String buttonName) { + synchronized (OpenGLPackageAccess.global_lock) { + Integer ret = (Integer) buttonMap.get(buttonName); + if (ret == null) + return -1; + else + return ret.intValue(); + } + } + + /** + * Gets the next mouse event. You can query which button caused the event by using + * getEventButton() (if any). To get the state of that key, for that event, use + * getEventButtonState. To get the current mouse delta values use getEventDX(), + * getEventDY() and getEventDZ(). + * @see org.lwjgl.input.Mouse#getEventButton() + * @see org.lwjgl.input.Mouse#getEventButtonState() + * @return true if a mouse event was read, false otherwise + */ + public static boolean next() { + synchronized (OpenGLPackageAccess.global_lock) { + if (!created) throw new IllegalStateException("Mouse must be created before you can read events"); + if (readBuffer.hasRemaining()) { + eventButton = readBuffer.get(); + eventState = readBuffer.get() != 0; + if (isGrabbed()) { + event_dx = readBuffer.getInt(); + event_dy = readBuffer.getInt(); + event_x += event_dx; + event_y += event_dy; + } else { + int new_event_x = readBuffer.getInt(); + int new_event_y = readBuffer.getInt(); + event_dx = new_event_x - event_x; + event_dy = new_event_y - event_y; + event_x = new_event_x; + event_y = new_event_y; + } + event_x = Math.min(implementation.getWidth() - 1, Math.max(0, event_x)); + event_y = Math.min(implementation.getHeight() - 1, Math.max(0, event_y)); + event_dwheel = readBuffer.getInt(); + event_nanos = readBuffer.getLong(); + return true; + } else + return false; + } + } + + /** + * @return Current events button. Returns -1 if no button state was changed + */ + public static int getEventButton() { + synchronized (OpenGLPackageAccess.global_lock) { + return eventButton; + } + } + + /** + * Get the current events button state. + * @return Current events button state. + */ + public static boolean getEventButtonState() { + synchronized (OpenGLPackageAccess.global_lock) { + return eventState; + } + } + + /** + * @return Current events delta x. Only valid when the mouse is grabbed. + */ + public static int getEventDX() { + synchronized (OpenGLPackageAccess.global_lock) { + return event_dx; + } + } + + /** + * @return Current events delta y. Only valid when the mouse is grabbed. + */ + public static int getEventDY() { + synchronized (OpenGLPackageAccess.global_lock) { + return event_dy; + } + } + + /** + * @return Current events absolute x. Only valid when the mouse is not grabbed. + */ + public static int getEventX() { + synchronized (OpenGLPackageAccess.global_lock) { + return event_x; + } + } + + /** + * @return Current events absolute y. Only valid when the mouse is not grabbed. + */ + public static int getEventY() { + synchronized (OpenGLPackageAccess.global_lock) { + return event_y; + } + } + + /** + * @return Current events delta z + */ + public static int getEventDWheel() { + synchronized (OpenGLPackageAccess.global_lock) { + return event_dwheel; + } + } + + /** + * Gets the time in nanoseconds of the current event. + * Only useful for relative comparisons with other + * Mouse events, as the absolute time has no defined + * origin. + * + * @return The time in nanoseconds of the current event + */ + public static long getEventNanoseconds() { + synchronized (OpenGLPackageAccess.global_lock) { + return event_nanos; + } + } + + /** + * Retrieves the absolute position. It will be clamped to + * 0...width-1. + * + * @return Absolute x axis position of mouse + */ + public static int getX() { + synchronized (OpenGLPackageAccess.global_lock) { + return x; + } + } + + /** + * Retrieves the absolute position. It will be clamped to + * 0...height-1. + * + * @return Absolute y axis position of mouse + */ + public static int getY() { + synchronized (OpenGLPackageAccess.global_lock) { + return y; + } + } + + /** + * @return Movement on the x axis since last time getDX() was called. Only valid when the mouse is grabbed. + */ + public static int getDX() { + synchronized (OpenGLPackageAccess.global_lock) { + int result = dx; + dx = 0; + return result; + } + } + + /** + * @return Movement on the y axis since last time getDY() was called. Only valid when the mouse is grabbed. + */ + public static int getDY() { + synchronized (OpenGLPackageAccess.global_lock) { + int result = dy; + dy = 0; + return result; + } + } + + /** + * @return Movement of the wheel since last time getDWheel() was called + */ + public static int getDWheel() { + synchronized (OpenGLPackageAccess.global_lock) { + int result = dwheel; + dwheel = 0; + return result; + } + } + + /** + * @return Number of buttons on this mouse + */ + public static int getButtonCount() { + synchronized (OpenGLPackageAccess.global_lock) { + return buttonCount; + } + } + + /** + * @return Whether or not this mouse has wheel support + */ + public static boolean hasWheel() { + synchronized (OpenGLPackageAccess.global_lock) { + return hasWheel; + } + } + + /** + * @return whether or not the mouse has grabbed the cursor + */ + public static boolean isGrabbed() { + synchronized (OpenGLPackageAccess.global_lock) { + return isGrabbed; + } + } + + /** + * Sets whether or not the mouse has grabbed the cursor + * (and thus hidden). If grab is false, the getX() and getY() + * will return delta movement in pixels clamped to the display + * dimensions, from the center of the display. + * + * @param grab whether the mouse should be grabbed + */ + public static void setGrabbed(boolean grab) { + synchronized (OpenGLPackageAccess.global_lock) { + boolean grabbed = isGrabbed; + isGrabbed = grab; + if (isCreated()) { + if (grab && !grabbed) { + // store location mouse was grabbed + grab_x = x; + grab_y = y; + } + else if (!grab && grabbed) { + // move mouse back to location it was grabbed before ungrabbing + if ((Cursor.getCapabilities() & Cursor.CURSOR_ONE_BIT_TRANSPARENCY) != 0) + implementation.setCursorPosition(grab_x, grab_y); + } + + implementation.grabMouse(grab); + // Get latest values from native side + poll(); + event_x = x; + event_y = y; + resetMouse(); + } + } + } + + /** + * Updates the cursor, so that animation can be changed if needed. + * This method is called automatically by the window on its update, and + * shouldn't be called otherwise + */ + public static void updateCursor() { + synchronized (OpenGLPackageAccess.global_lock) { + if (emulateCursorAnimation && currentCursor != null && currentCursor.hasTimedOut() && Mouse.isInsideWindow()) { + currentCursor.nextCursor(); + try { + setNativeCursor(currentCursor); + } catch (LWJGLException e) { + if (LWJGLUtil.DEBUG) e.printStackTrace(); + } + } + } + } + + /** Gets a boolean property as a privileged action. */ + static boolean getPrivilegedBoolean(final String property_name) { + Boolean value = (Boolean)AccessController.doPrivileged(new PrivilegedAction() { + public Object run() { + return new Boolean(Boolean.getBoolean(property_name)); + } + }); + return value.booleanValue(); + } + + /** + * Retrieves whether or not the mouse cursor is within the bounds of the window. + * If the mouse cursor was moved outside the display during a drag, then the result of calling + * this method will be true until the button is released. + * @return true if mouse is inside display, false otherwise. + */ + public static boolean isInsideWindow() { + return implementation.isInsideWindow(); + } +} diff --git a/src/java/org/lwjgl/input/OpenGLPackageAccess.java b/src/java/org/lwjgl/input/OpenGLPackageAccess.java new file mode 100644 index 0000000..c4cb792 --- /dev/null +++ b/src/java/org/lwjgl/input/OpenGLPackageAccess.java @@ -0,0 +1,80 @@ +/* + * 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; + +import org.lwjgl.opengl.InputImplementation; +import org.lwjgl.opengl.Display; + +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.security.AccessController; +import java.security.PrivilegedExceptionAction; +import java.security.PrivilegedActionException; + +/** + * This class contains utilities for accessing the org.lwjgl.opengl + * package through (privileged) reflection. + */ +final class OpenGLPackageAccess { + final static Object global_lock; + + static { + try { + global_lock = AccessController.doPrivileged(new PrivilegedExceptionAction() { + public Object run() throws Exception { + Field lock_field = Class.forName("org.lwjgl.opengl.GlobalLock").getDeclaredField("lock"); + lock_field.setAccessible(true); + return lock_field.get(null); + } + }); + } catch (PrivilegedActionException e) { + throw new Error(e); + } + } + + static InputImplementation createImplementation() { + /* Use reflection since we can't make Display.getImplementation + * public + */ + try { + return (InputImplementation)AccessController.doPrivileged(new PrivilegedExceptionAction() { + public Object run() throws Exception { + Method getImplementation_method = Display.class.getDeclaredMethod("getImplementation", null); + getImplementation_method.setAccessible(true); + return getImplementation_method.invoke(null, null); + } + }); + } catch (PrivilegedActionException e) { + throw new Error(e); + } + } +} diff --git a/src/java/org/lwjgl/openal/AL.java b/src/java/org/lwjgl/openal/AL.java new file mode 100644 index 0000000..a25a080 --- /dev/null +++ b/src/java/org/lwjgl/openal/AL.java @@ -0,0 +1,231 @@ +/* + * 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.openal; + +import org.lwjgl.LWJGLException; +import org.lwjgl.LWJGLUtil; +import org.lwjgl.Sys; + +/** + *

+ * The AL class implements the actual creation code for linking to the native library + * OpenAL. + *

+ * + * @author Brian Matzon + * @version $Revision: 3182 $ + * $Id: AL.java 3182 2009-03-17 21:36:18Z matzon $ + */ +public final class AL { + /** ALCdevice instance. */ + protected static ALCdevice device; + + /** Current ALCcontext. */ + protected static ALCcontext context; + + /** Have we been created? */ + private static boolean created; + + static { + Sys.initialize(); + } + + private AL() { + } + + /** + * Native method to create AL instance + * + * @param oalPaths Array of strings containing paths to search for OpenAL library + */ + private static native void nCreate(String oalPath) throws LWJGLException; + + /** + * Native method to create AL instance from the Mac OS X 10.4 OpenAL framework. + * It is only defined in the Mac OS X native library. + * + * @param oalPaths Array of strings containing paths to search for OpenAL library + */ + private static native void nCreateDefault() throws LWJGLException; + + /** + * Native method the destroy the AL + */ + private static native void nDestroy(); + + /** + * @return true if AL has been created + */ + public static boolean isCreated() { + return created; + } + + /** + * Creates an OpenAL instance. Using this constructor will cause OpenAL to + * open the device using supplied device argument, and create a context using the context values + * supplied. + * + * @param deviceArguments Arguments supplied to native device + * @param contextFrequency Frequency for mixing output buffer, in units of Hz (Common values include 11025, 22050, and 44100). + * @param contextRefresh Refresh intervalls, in units of Hz. + * @param contextSynchronized Flag, indicating a synchronous context.* + */ + public static void create(String deviceArguments, int contextFrequency, int contextRefresh, boolean contextSynchronized) + throws LWJGLException { + create(deviceArguments, contextFrequency, contextRefresh, contextSynchronized, true); + } + + /** + * @param openDevice Whether to automatically open the device + * @see #create(String, int, int, boolean) + */ + public static void create(String deviceArguments, int contextFrequency, int contextRefresh, boolean contextSynchronized, boolean openDevice) + throws LWJGLException { + + if (created) + throw new IllegalStateException("Only one OpenAL context may be instantiated at any one time."); + String libname; + String[] library_names; + switch (LWJGLUtil.getPlatform()) { + case LWJGLUtil.PLATFORM_WINDOWS: + libname = "OpenAL32"; + library_names = new String[]{"OpenAL64.dll", "OpenAL32.dll"}; + break; + case LWJGLUtil.PLATFORM_LINUX: + libname = "openal"; + library_names = new String[]{"libopenal64.so", "libopenal.so", "libopenal.so.0"}; + break; + case LWJGLUtil.PLATFORM_MACOSX: + libname = "openal"; + library_names = new String[]{"openal.dylib"}; + break; + default: + throw new LWJGLException("Unknown platform: " + LWJGLUtil.getPlatform()); + } + String[] oalPaths = LWJGLUtil.getLibraryPaths(libname, library_names, AL.class.getClassLoader()); + LWJGLUtil.log("Found " + oalPaths.length + " OpenAL paths"); + for (int i = 0; i < oalPaths.length; i++) { + try { + nCreate(oalPaths[i]); + created = true; + init(deviceArguments, contextFrequency, contextRefresh, contextSynchronized, openDevice); + break; + } catch (LWJGLException e) { + LWJGLUtil.log("Failed to load " + oalPaths[i] + ": " + e.getMessage()); + } + } + if (!created && LWJGLUtil.getPlatform() == LWJGLUtil.PLATFORM_MACOSX) { + // Try to load OpenAL from the framework instead + nCreateDefault(); + created = true; + init(deviceArguments, contextFrequency, contextRefresh, contextSynchronized, openDevice); + } + if (!created) + throw new LWJGLException("Could not locate OpenAL library."); + } + + private static void init(String deviceArguments, int contextFrequency, int contextRefresh, boolean contextSynchronized, boolean openDevice) throws LWJGLException { + try { + AL10.initNativeStubs(); + ALC10.initNativeStubs(); + + if(openDevice) { + device = ALC10.alcOpenDevice(deviceArguments); + if (device == null) + throw new LWJGLException("Could not open ALC device"); + + if (contextFrequency == -1) { + context = ALC10.alcCreateContext(device, null); + } else { + context = ALC10.alcCreateContext(device, + ALCcontext.createAttributeList(contextFrequency, contextRefresh, + contextSynchronized ? ALC10.ALC_TRUE : ALC10.ALC_FALSE)); + } + ALC10.alcMakeContextCurrent(context); + } + } catch (LWJGLException e) { + destroy(); + throw e; + } + + ALC11.initialize(); + } + + /** + * Creates an OpenAL instance. The empty create will cause OpenAL to + * open the default device, and create a context using default values. + * This method used to use default values that the OpenAL implementation + * chose but this produces unexpected results on some systems; so now + * it defaults to 44100Hz mixing @ 60Hz refresh. + */ + public static void create() throws LWJGLException { + create(null, 44100, 60, false); + } + + /** + * Exit cleanly by calling destroy. + */ + public static void destroy() { + if (context != null) { + ALC10.alcMakeContextCurrent(null); + ALC10.alcDestroyContext(context); + context = null; + } + if (device != null) { + boolean result = ALC10.alcCloseDevice(device); + device = null; + } + resetNativeStubs(AL10.class); + resetNativeStubs(ALC10.class); + resetNativeStubs(ALC11.class); + + if (created) + nDestroy(); + created = false; + } + + private static native void resetNativeStubs(Class clazz); + + /** + * @return handle to the default AL context. + */ + public static ALCcontext getContext() { + return context; + } + + /** + * @return handle to the default AL device. + */ + public static ALCdevice getDevice() { + return device; + } +} diff --git a/src/java/org/lwjgl/openal/ALC10.java b/src/java/org/lwjgl/openal/ALC10.java new file mode 100644 index 0000000..45f81b8 --- /dev/null +++ b/src/java/org/lwjgl/openal/ALC10.java @@ -0,0 +1,436 @@ +/* + * 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.openal; + +import java.nio.Buffer; +import java.nio.IntBuffer; +import java.util.HashMap; + +import org.lwjgl.BufferChecks; +import org.lwjgl.LWJGLException; + +/** + * + *

+ * ALC introduces the notion of a Device. A Device can be, depending on the + * implementation, a hardware device, or a daemon/OS service/actual server. This + * mechanism also permits different drivers (and hardware) to coexist within the same + * system, as well as allowing several applications to share system resources for audio, + * including a single hardware output device. The details are left to the + * implementation, which has to map the available backends to unique device + * specifiers (represented as strings). + *

+ * + * @author Brian Matzon + * @version $Revision: 2286 $ + * $Id: ALC.java 2286 2006-03-23 19:32:21 +0000 (to, 23 mar 2006) matzon $ + */ +public final class ALC10 { + + /** List of active contexts */ + static HashMap contexts = new HashMap(); + + /** List of active devices */ + static HashMap devices = new HashMap(); + + /** Bad value */ + public static final int ALC_INVALID = 0; + + /** Boolean False */ + public static final int ALC_FALSE = 0; + + /** Boolean True */ + public static final int ALC_TRUE = 1; + + /** Errors: No Error */ + public static final int ALC_NO_ERROR = ALC_FALSE; + + /** Major version query. */ + public static final int ALC_MAJOR_VERSION = 0x1000; + + /** Minor version query. */ + public static final int ALC_MINOR_VERSION = 0x1001; + + /** + * The size required for the zero-terminated attributes list, for the current context. + **/ + public static final int ALC_ATTRIBUTES_SIZE = 0x1002; + + /** + * Expects a destination of ALC_CURRENT_ATTRIBUTES_SIZE, + * and provides the attribute list for the current context of the specified device. + */ + public static final int ALC_ALL_ATTRIBUTES = 0x1003; + + /** The specifier string for the default device */ + public static final int ALC_DEFAULT_DEVICE_SPECIFIER = 0x1004; + + /** The specifier string for the device */ + public static final int ALC_DEVICE_SPECIFIER = 0x1005; + + /** The extensions string for diagnostics and printing */ + public static final int ALC_EXTENSIONS = 0x1006; + + /** Frequency for mixing output buffer, in units of Hz. */ + public static final int ALC_FREQUENCY = 0x1007; + + /** Refresh intervalls, in units of Hz. */ + public static final int ALC_REFRESH = 0x1008; + + /** Flag, indicating a synchronous context. */ + public static final int ALC_SYNC = 0x1009; + + /** The device argument does not name a valid device */ + public static final int ALC_INVALID_DEVICE = 0xA001; + + /** The context argument does not name a valid context */ + public static final int ALC_INVALID_CONTEXT = 0xA002; + + /** + * A function was called at inappropriate time, or in an inappropriate way, + * causing an illegal state. This can be an incompatible ALenum, object ID, + * and/or function. + */ + public static final int ALC_INVALID_ENUM = 0xA003; + + /** + * Illegal value passed as an argument to an AL call. + * Applies to parameter values, but not to enumerations. + */ + public static final int ALC_INVALID_VALUE = 0xA004; + + /** + * A function could not be completed, because there is not enough + * memory available. + */ + public static final int ALC_OUT_OF_MEMORY = 0xA005; + + static native void initNativeStubs() throws LWJGLException; + + /** + * The application can obtain certain strings from ALC. + * + * ALC_DEFAULT_DEVICE_SPECIFIER - The specifer string for the default device + * ALC_DEVICE_SPECIFIER - The specifer string for the device + * ALC_EXTENSIONS - The extensions string for diagnostics and printing. + * + * In addition, printable error message strings are provided for all valid error tokens, + * including ALC_NO_ERROR,ALC_INVALID_DEVICE, ALC_INVALID_CONTEXT, + * ALC_INVALID_ENUM, ALC_INVALID_VALUE. + * + * @param pname Property to get + * @return String property from device + */ + public static String alcGetString(ALCdevice device, int pname) { + String result; + result = nalcGetString(getDevice(device), pname); + Util.checkALCError(device); + return result; + } + native static String nalcGetString(long device, int pname); + + /** + * The application can query ALC for information using an integer query function. + * For some tokens, null is a legal deviceHandle. In other cases, specifying a null + * device will generate an ALC_INVALID_DEVICE error. The application has to + * specify the size of the destination buffer provided. A null destination or a zero + * size parameter will cause ALC to ignore the query. + * + * ALC_MAJOR_VERSION - Major version query. + * ALC_MINOR_VERSION - Minor version query. + * ALC_ATTRIBUTES_SIZE - The size required for the zero-terminated attributes list, + * for the current context. null is an invalid device. null (no current context + * for the specified device) is legal. + * ALC_ALL_ATTRIBUTES - Expects a destination of ALC_CURRENT_ATTRIBUTES_SIZE, + * and provides the attribute list for the current context of the specified device. + * null is an invalid device. null (no current context for the specified device) + * will return the default attributes defined by the specified device. + * + * @param pname Property to get + * @param integerdata ByteBuffer to write integers to + */ + public static void alcGetInteger(ALCdevice device, int pname, IntBuffer integerdata) { + BufferChecks.checkDirect(integerdata); + nalcGetIntegerv(getDevice(device), pname, integerdata.remaining(), integerdata, integerdata.position()); + Util.checkALCError(device); + } + native static void nalcGetIntegerv(long device, int pname, int size, Buffer integerdata, int offset); + + /** + * The alcOpenDevice function allows the application (i.e. the client program) to + * connect to a device (i.e. the server). + * + * If the function returns null, then no sound driver/device has been found. The + * argument is a null terminated string that requests a certain device or device + * configuration. If null is specified, the implementation will provide an + * implementation specific default. + * + * @param devicename name of device to open + * @return opened device, or null + */ + public static ALCdevice alcOpenDevice(String devicename) { + long device_address = nalcOpenDevice(devicename); + if(device_address != 0) { + ALCdevice device = new ALCdevice(device_address); + synchronized (ALC10.devices) { + devices.put(new Long(device_address), device); + } + return device; + } + return null; + } + native static long nalcOpenDevice(String devicename); + + /** + * The alcCloseDevice function allows the application (i.e. the client program) to + * disconnect from a device (i.e. the server). + * + * If deviceHandle is null or invalid, an ALC_INVALID_DEVICE error will be + * generated. Once closed, a deviceHandle is invalid. + * + * @param device address of native device to close + */ + public static boolean alcCloseDevice(ALCdevice device) { + boolean result = nalcCloseDevice(getDevice(device)); + synchronized (devices) { + device.setInvalid(); + devices.remove(new Long(device.device)); + } + return result; + + } + native static boolean nalcCloseDevice(long device); + + /** + * A context is created using alcCreateContext. The device parameter has to be a valid + * device. The attribute list can be null, or a zero terminated list of integer pairs + * composed of valid ALC attribute tokens and requested values. + * + * Context creation will fail if the application requests attributes that, by themselves, + * can not be provided. Context creation will fail if the combination of specified + * attributes can not be provided. Context creation will fail if a specified attribute, or + * the combination of attributes, does not match the default values for unspecified + * attributes. + * + * @param device address of device to associate context to + * @param attrList Buffer to read attributes from + * @return New context, or null if creation failed + */ + public static ALCcontext alcCreateContext(ALCdevice device, IntBuffer attrList) { + long context_address = nalcCreateContext(getDevice(device), attrList); + Util.checkALCError(device); + + if(context_address != 0) { + ALCcontext context = new ALCcontext(context_address); + synchronized (ALC10.contexts) { + contexts.put(new Long(context_address), context); + device.addContext(context); + } + return context; + } + return null; + } + native static long nalcCreateContext(long device, IntBuffer attrList); + + /** + * To make a Context current with respect to AL Operation (state changes by issueing + * commands), alcMakeContextCurrent is used. The context parameter can be null + * or a valid context pointer. The operation will apply to the device that the context + * was created for. + * + * For each OS process (usually this means for each application), only one context can + * be current at any given time. All AL commands apply to the current context. + * Commands that affect objects shared among contexts (e.g. buffers) have side effects + * on other contexts. + * + * @param context address of context to make current + * @return true if successfull, false if not + */ + public static int alcMakeContextCurrent(ALCcontext context) { + return nalcMakeContextCurrent(getContext(context)); + } + native static int nalcMakeContextCurrent(long context); + + /** + * The current context is the only context accessible to state changes by AL commands + * (aside from state changes affecting shared objects). However, multiple contexts can + * be processed at the same time. To indicate that a context should be processed (i.e. + * that internal execution state like offset increments are supposed to be performed), + * the application has to use alcProcessContext. + * + * Repeated calls to alcProcessContext are legal, and do not affect a context that is + * already marked as processing. The default state of a context created by + * alcCreateContext is that it is not marked as processing. + */ + public static void alcProcessContext(ALCcontext context) { + nalcProcessContext(getContext(context)); + } + native static void nalcProcessContext(long context); + + /** + * The application can query for, and obtain an handle to, the current context for the + * application. If there is no current context, null is returned. + * + * @return Current ALCcontext + */ + public static ALCcontext alcGetCurrentContext() { + ALCcontext context = null; + long context_address = nalcGetCurrentContext(); + if(context_address != 0) { + synchronized (ALC10.contexts) { + context = (ALCcontext) ALC10.contexts.get(new Long(context_address)); + } + } + return context; + } + native static long nalcGetCurrentContext(); + + /** + * The application can query for, and obtain an handle to, the device of a given context. + * + * @param context address of context to get device for + */ + public static ALCdevice alcGetContextsDevice(ALCcontext context) { + ALCdevice device = null; + long device_address = nalcGetContextsDevice(getContext(context)); + if (device_address != 0) { + synchronized (ALC10.devices) { + device = (ALCdevice) ALC10.devices.get(new Long(device_address)); + } + } + return device; + } + native static long nalcGetContextsDevice(long context); + + /** + * The application can suspend any context from processing (including the current + * one). To indicate that a context should be suspended from processing (i.e. that + * internal execution state like offset increments is not supposed to be changed), the + * application has to use alcSuspendContext. + * + * Repeated calls to alcSuspendContext are legal, and do not affect a context that is + * already marked as suspended. The default state of a context created by + * alcCreateContext is that it is marked as suspended. + * + * @param context address of context to suspend + */ + public static void alcSuspendContext(ALCcontext context) { + nalcSuspendContext(getContext(context)); + } + native static void nalcSuspendContext(long context); + + /** + * The correct way to destroy a context is to first release it using alcMakeCurrent and + * null. Applications should not attempt to destroy a current context. + * + * @param context address of context to Destroy + */ + public static void alcDestroyContext(ALCcontext context) { + synchronized(ALC10.contexts) { + ALCdevice device = alcGetContextsDevice(context); + nalcDestroyContext(getContext(context)); + device.removeContext(context); + context.setInvalid(); + } + } + native static void nalcDestroyContext(long context); + + /** + * ALC uses the same conventions and mechanisms as AL for error handling. In + * particular, ALC does not use conventions derived from X11 (GLX) or Windows + * (WGL). The alcGetError function can be used to query ALC errors. + * + * Error conditions are specific to the device. + * + * ALC_NO_ERROR - The device handle or specifier does name an accessible driver/server. + * ALC_INVALID_DEVICE - The Context argument does not name a valid context. + * ALC_INVALID_CONTEXT - The Context argument does not name a valid context. + * ALC_INVALID_ENUM - A token used is not valid, or not applicable. + * ALC_INVALID_VALUE - An value (e.g. attribute) is not valid, or not applicable. + * + * @return Errorcode from ALC statemachine + */ + public static int alcGetError(ALCdevice device) { + return nalcGetError(getDevice(device)); + } + native static int nalcGetError(long device); + + /** + * Verify that a given extension is available for the current context and the device it + * is associated with. + * A null name argument returns ALC_FALSE, as do invalid and unsupported string + * tokens. + * + * @param extName name of extension to find + * @return true if extension is available, false if not + */ + public static boolean alcIsExtensionPresent(ALCdevice device, String extName) { + boolean result = nalcIsExtensionPresent(getDevice(device), extName); + Util.checkALCError(device); + return result; + } + native static boolean nalcIsExtensionPresent(long device, String extName); + + /** + * Enumeration/token values are device independend, but tokens defined for + * extensions might not be present for a given device. But only the tokens defined + * by the AL core are guaranteed. Availability of extension tokens dependends on the ALC extension. + * + * Specifying a null name parameter will cause an ALC_INVALID_VALUE error. + * + * @param enumName name of enum to find + * @return value of enumeration + */ + public static int alcGetEnumValue(ALCdevice device, String enumName) { + int result = nalcGetEnumValue(getDevice(device), enumName); + Util.checkALCError(device); + return result; + } + native static int nalcGetEnumValue(long device, String enumName); + + static long getDevice(ALCdevice device) { + if(device != null) { + Util.checkALCValidDevice(device); + return device.device; + } + return 0L; + } + + static long getContext(ALCcontext context) { + if(context != null) { + Util.checkALCValidContext(context); + return context.context; + } + return 0L; + } + +} diff --git a/src/java/org/lwjgl/openal/ALC11.java b/src/java/org/lwjgl/openal/ALC11.java new file mode 100644 index 0000000..9b0bf09 --- /dev/null +++ b/src/java/org/lwjgl/openal/ALC11.java @@ -0,0 +1,197 @@ +/* + * 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.openal; + +import java.nio.ByteBuffer; +import java.nio.IntBuffer; + +import org.lwjgl.BufferUtils; +import org.lwjgl.LWJGLException; +import org.lwjgl.LWJGLUtil; + + +/** + *

+ * The ALC11 class implements features in OpenAL 1.1, specifically + * ALC methods and properties. + *

+ * + * @author Brian Matzon + * @see ALC10 + * @version $Revision: 2286 $ + * $Id: ALC.java 2286 2006-03-23 19:32:21 +0000 (to, 23 mar 2006) matzon $ + */ +public final class ALC11 { + + public static final int ALC_DEFAULT_ALL_DEVICES_SPECIFIER = 0x1012; + public static final int ALC_ALL_DEVICES_SPECIFIER = 0x1013; + + public static final int ALC_CAPTURE_DEVICE_SPECIFIER = 0x310; + public static final int ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER = 0x311; + public static final int ALC_CAPTURE_SAMPLES = 0x312; + + /** + * The alcCaptureOpenDevice function allows the application to connect to a capture + * device. To obtain a list of all available capture devices, use getCaptureDevices a list of all + * capture devices will be returned. Retrieving ALC_CAPTURE_DEVICE_SPECIFIER with a valid capture device specified will result + * in the name of that device being returned as a single string. + * + * If the function returns null, then no sound driver/device has been found, or the + * requested format could not be fulfilled. + * The "deviceName" argument is a string that requests a certain device or + * device configuration. If null is specified, the implementation will provide an + * implementation specific default. The "frequency" and "format" arguments specify the format that + * audio data will be presented to the application, and match the values that can be passed to + * alBufferData. The implementation is expected to convert and resample to this format on + * behalf of the application. The "buffersize" argument specifies the number of sample frames + * to buffer in the AL, for example, requesting a format of AL_FORMAT_STEREO16 and + * a buffer size of 1024 would require the AL to store up to 1024 * 4 bytes of audio data. + * Note that the implementation may use a larger buffer than requested if it needs to, but the + * implementation will set up a buffer of at least the requested size. + * Specifying a compressed or extension-supplied format may result in failure, even if the + * extension is supplied for rendering. + * + * LWJGL SPECIFIC: the actual created device is managed internally in lwjgl + * + * @param devicename Name of device to open for capture + * @param frequency Frequency of samples to capture + * @param format Format of samples to capture + * @param buffersize Size of buffer to capture to + * @return ALCdevice if it was possible to open a device + */ + public static ALCdevice alcCaptureOpenDevice(String devicename, int frequency, int format, int buffersize) { + long device_address = nalcCaptureOpenDevice(devicename, frequency, format, buffersize); + if(device_address != 0) { + ALCdevice device = new ALCdevice(device_address); + synchronized (ALC10.devices) { + ALC10.devices.put(new Long(device_address), device); + } + return device; + } + return null; + } + static native long nalcCaptureOpenDevice( String devicename, int frequency, int format, int buffersize); + + /** + * The alcCaptureCloseDevice function allows the application to disconnect from a capture + * device. + * + * The return code will be true or false, indicating success or failure. If + * the device is null or invalid, an ALC_INVALID_DEVICE error will be generated. + * Once closed, a capture device is invalid. + * @return true if device was successfully closed + */ + public static boolean alcCaptureCloseDevice(ALCdevice device) { + boolean result = nalcCaptureCloseDevice(ALC10.getDevice(device)); + synchronized (ALC10.devices) { + device.setInvalid(); + ALC10.devices.remove(new Long(device.device)); + } + return result; + } + static native boolean nalcCaptureCloseDevice(long device); + + /** + * Once a capture device has been opened via alcCaptureOpenDevice, it is made to start + * recording audio via the alcCaptureStart entry point: + * + * Once started, the device will record audio to an internal ring buffer, the size of which was + * specified when opening the device. + * The application may query the capture device to discover how much data is currently + * available via the alcGetInteger with the ALC_CAPTURE_SAMPLES token. This will + * report the number of sample frames currently available. + */ + public static void alcCaptureStart(ALCdevice device) { + nalcCaptureStart(ALC10.getDevice(device)); + } + static native void nalcCaptureStart(long device); + + /** + * If the application doesn't need to capture more audio for an amount of time, they can halt + * the device without closing it via the alcCaptureStop entry point. + * The implementation is encouraged to optimize for this case. The amount of audio + * samples available after restarting a stopped capture device is reset to zero. The + * application does not need to stop the capture device to read from it. + */ + public static void alcCaptureStop(ALCdevice device) { + nalcCaptureStop(ALC10.getDevice(device)); + } + static native void nalcCaptureStop(long device); + + /** + * When the application feels there are enough samples available to process, it can obtain + * them from the AL via the alcCaptureSamples entry point. + * + * The "buffer" argument specifies an application-allocated buffer that can contain at least + * "samples" sample frames. The implementation may defer conversion and resampling until + * this point. Requesting more sample frames than are currently available is an error. + * + * @param buffer Buffer to store samples in + * @param samples Number of samples to request + */ + public static void alcCaptureSamples(ALCdevice device, ByteBuffer buffer, int samples ) { + nalcCaptureSamples(ALC10.getDevice(device), buffer, buffer.position(), samples); + } + static native void nalcCaptureSamples(long device, ByteBuffer buffer, int position, int samples ); + + static native void initNativeStubs() throws LWJGLException; + + /** + * Initializes ALC11, including any extensions + * @return true if initialization was successfull + */ + static boolean initialize() { + try { + IntBuffer ib = BufferUtils.createIntBuffer(2); + ALC10.alcGetInteger(AL.getDevice(), ALC10.ALC_MAJOR_VERSION, ib); + ib.position(1); + ALC10.alcGetInteger(AL.getDevice(), ALC10.ALC_MINOR_VERSION, ib); + + int major = ib.get(0); + int minor = ib.get(1); + + // checking for version 1.x+ + if(major >= 1) { + + // checking for version 1.1+ + if(major > 1 || minor >= 1) { + ALC11.initNativeStubs(); + AL11.initNativeStubs(); + } + } + } catch (LWJGLException le) { + LWJGLUtil.log("failed to initialize ALC11: " + le); + return false; + } + return true; + } +} diff --git a/src/java/org/lwjgl/openal/ALCcontext.java b/src/java/org/lwjgl/openal/ALCcontext.java new file mode 100644 index 0000000..b587f8c --- /dev/null +++ b/src/java/org/lwjgl/openal/ALCcontext.java @@ -0,0 +1,115 @@ +/* + * 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.openal; + +import java.nio.IntBuffer; + +import org.lwjgl.BufferUtils; + +/** + * The ALCcontext class represents a context opened in OpenAL space. + * + * All operations of the AL core API affect a current AL context. Within the scope of AL, + * the ALC is implied - it is not visible as a handle or function parameter. Only one AL + * Context per process can be current at a time. Applications maintaining multiple AL + * Contexts, whether threaded or not, have to set the current context accordingly. + * Applications can have multiple threads that share one more or contexts. In other words, + * AL and ALC are threadsafe. + * + * @author Brian Matzon + * @version $Revision: 2983 $ + * $Id: ALCcontext.java 2983 2008-04-07 18:36:09Z matzon $ + */ +public final class ALCcontext { + + /** Address of actual context */ + final long context; + + /** Whether this context is valid */ + private boolean valid = false; + + /** + * Creates a new instance of ALCcontext + * + * @param context address of actual context + */ + ALCcontext(long context) { + this.context = context; + this.valid = true; + } + + /* + * @see java.lang.Object#equals(java.lang.Object) + */ + public boolean equals(Object context) { + if(context instanceof ALCcontext) { + return ((ALCcontext)context).context == this.context; + } + return super.equals(context); + } + + /** + * Creates an attribute list in a ByteBuffer + * @param contextFrequency Frequency to add + * @param contextRefresh Refresh rate to add + * @param contextSynchronized Whether to synchronize the context + * @return + */ + static IntBuffer createAttributeList(int contextFrequency, int contextRefresh, int contextSynchronized) { + IntBuffer attribList = BufferUtils.createIntBuffer(7); + + attribList.put(ALC10.ALC_FREQUENCY); + attribList.put(contextFrequency); + attribList.put(ALC10.ALC_REFRESH); + attribList.put(contextRefresh); + attribList.put(ALC10.ALC_SYNC); + attribList.put(contextSynchronized); + attribList.put(0); //terminating int + + return attribList; + } + + /** + * Marks this context as invalid + * + */ + void setInvalid() { + valid = false; + } + + /** + * @return true if this context is still valid + */ + public boolean isValid() { + return valid; + } +} diff --git a/src/java/org/lwjgl/openal/ALCdevice.java b/src/java/org/lwjgl/openal/ALCdevice.java new file mode 100644 index 0000000..4a6b535 --- /dev/null +++ b/src/java/org/lwjgl/openal/ALCdevice.java @@ -0,0 +1,124 @@ +/* + * 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.openal; + +import java.util.HashMap; +import java.util.Iterator; + +/** + * The ALCdevice class represents a device opened in OpenAL space. + * + * ALC introduces the notion of a Device. A Device can be, depending on the + * implementation, a hardware device, or a daemon/OS service/actual server. This + * mechanism also permits different drivers (and hardware) to coexist within the same + * system, as well as allowing several applications to share system resources for audio, + * including a single hardware output device. The details are left to the implementation, + * which has to map the available backends to unique device specifiers. + * + * @author Brian Matzon + * @version $Revision: 2983 $ + * $Id: ALCdevice.java 2983 2008-04-07 18:36:09Z matzon $ + */ +public final class ALCdevice { + + /** Address of actual device */ + final long device; + + /** Whether this device is valid */ + private boolean valid = false; + + /** List of contexts belonging to the device */ + private HashMap contexts = new HashMap(); + + /** + * Creates a new instance of ALCdevice + * + * @param device address of actual device + */ + ALCdevice(long device) { + this.device = device; + this.valid = true; + } + + /* + * @see java.lang.Object#equals(java.lang.Object) + */ + public boolean equals(Object device) { + if(device instanceof ALCdevice) { + return ((ALCdevice)device).device == this.device; + } + return super.equals(device); + } + + /** + * Adds a context to the device + * + * @param context context to add to the list of contexts for this device + */ + void addContext(ALCcontext context) { + synchronized (contexts) { + contexts.put(new Long(context.context), context); + } + } + + /** + * Remove context associated with device + * + * @param context Context to disassociate with device + */ + void removeContext(ALCcontext context) { + synchronized (contexts) { + contexts.remove(new Long(context.context)); + } + } + + /** + * Marks this device and all of its contexts invalid + */ + void setInvalid() { + valid = false; + synchronized (contexts) { + for(Iterator i = contexts.values().iterator(); i.hasNext();) { + ALCcontext context = (ALCcontext) i.next(); + context.setInvalid(); + } + } + contexts.clear(); + } + + /** + * @return true if this device is still valid + */ + public boolean isValid() { + return valid; + } +} diff --git a/src/java/org/lwjgl/openal/OpenALException.java b/src/java/org/lwjgl/openal/OpenALException.java new file mode 100644 index 0000000..dcbcf1e --- /dev/null +++ b/src/java/org/lwjgl/openal/OpenALException.java @@ -0,0 +1,85 @@ +/* + * 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.openal; + +/** + *
+ * Thrown by the debug build library of the LWJGL if any OpenAL operation + * causes an error. + * + * @author Brian Matzon + * @version $Revision: 2983 $ + * $Id: OpenALException.java 2983 2008-04-07 18:36:09Z matzon $ + */ +public class OpenALException extends RuntimeException { + + private static final long serialVersionUID = 1L; + + /** + * Constructor for OpenALException. + */ + public OpenALException() { + super(); + } + + /** + * Constructor that takes an AL error number + */ + public OpenALException(int error_code) { + super("OpenAL error: " + AL10.alGetString(error_code) + " (" + error_code + ")"); + } + + /** + * Constructor for OpenALException. + * @param message + */ + public OpenALException(String message) { + super(message); + } + + /** + * Constructor for OpenALException. + * @param message + * @param cause + */ + public OpenALException(String message, Throwable cause) { + super(message, cause); + } + + /** + * Constructor for OpenALException. + * @param cause + */ + public OpenALException(Throwable cause) { + super(cause); + } +} diff --git a/src/java/org/lwjgl/openal/Util.java b/src/java/org/lwjgl/openal/Util.java new file mode 100644 index 0000000..3d8bf9a --- /dev/null +++ b/src/java/org/lwjgl/openal/Util.java @@ -0,0 +1,86 @@ +/* + * 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.openal; + + +/** + * Simple utility class for checking AL/ALC errors + * + * @author cix_foo + * @author Brian Matzon + * @version $Revision: 2983 $ + */ + +public final class Util { + /** No c'tor */ + private Util() { + } + + /** + * Checks for any ALC errors and throws an unchecked exception on errors + * @param device Device for which to check ALC errors + */ + public static void checkALCError(ALCdevice device) { + int err = ALC10.alcGetError(device); + if (err != ALC10.ALC_NO_ERROR) + throw new OpenALException(ALC10.alcGetString(AL.getDevice(), err)); + } + + /** + * Checks for any AL errors and throws an unchecked exception on errors + */ + public static void checkALError() { + int err = AL10.alGetError(); + if (err != AL10.AL_NO_ERROR) + throw new OpenALException(err); + } + + /** + * Checks for a valid device + * @param device ALCdevice to check the validity of + */ + public static void checkALCValidDevice(ALCdevice device) { + if(!device.isValid()) { + throw new OpenALException("Invalid device: " + device); + } + } + + /** + * Checks for a valid context + * @param context ALCcontext to check the validity of + */ + public static void checkALCValidContext(ALCcontext context) { + if(!context.isValid()) { + throw new OpenALException("Invalid context: " + context); + } + } +} diff --git a/src/java/org/lwjgl/opengl/APIUtils.java b/src/java/org/lwjgl/opengl/APIUtils.java new file mode 100644 index 0000000..730b801 --- /dev/null +++ b/src/java/org/lwjgl/opengl/APIUtils.java @@ -0,0 +1,354 @@ +/* + * 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; + +import org.lwjgl.BufferUtils; + +import java.nio.*; +import java.nio.charset.Charset; +import java.nio.charset.CharsetEncoder; + +/** @author spasi */ +final class APIUtils { + + private static final int INITIAL_BUFFER_SIZE = 256; + private static final int INITIAL_LENGTHS_SIZE = 4; + + private static final int BUFFERS_SIZE = 32; + + private static final ThreadLocal arrayTL = new ThreadLocal() { + protected Object initialValue() { return new char[INITIAL_BUFFER_SIZE]; } + }; + + private static final ThreadLocal bufferTL = new ThreadLocal() { + protected Object initialValue() { return BufferUtils.createByteBuffer(INITIAL_BUFFER_SIZE); } + }; + + private static final ThreadLocal lengthsTL = new ThreadLocal() { + protected Object initialValue() { return BufferUtils.createIntBuffer(INITIAL_LENGTHS_SIZE); } + }; + + private static final ThreadLocal infiniteSeqTL = new ThreadLocal() { + protected Object initialValue() { return new InfiniteCharSequence(); } + }; + + private static final ThreadLocal buffersTL = new ThreadLocal() { + protected Object initialValue() { return new Buffers(); } + }; + + private static CharsetEncoder encoder = Charset.forName("US-ASCII").newEncoder(); + + private APIUtils() { + } + + private static char[] getArray(final int size) { + char[] array = (char[])arrayTL.get(); + + if ( array.length < size ) { + int sizeNew = array.length << 1; + while ( sizeNew < size ) + sizeNew <<= 1; + + array = new char[size]; + arrayTL.set(array); + } + + return array; + } + + static ByteBuffer getBufferByte(final int size) { + ByteBuffer buffer = (ByteBuffer)bufferTL.get(); + + if ( buffer.capacity() < size ) { + int sizeNew = buffer.capacity() << 1; + while ( sizeNew < size ) + sizeNew <<= 1; + + buffer = BufferUtils.createByteBuffer(size); + bufferTL.set(buffer); + } else + buffer.clear(); + + return buffer; + } + + private static ByteBuffer getBufferByteOffset(final int size) { + ByteBuffer buffer = (ByteBuffer)bufferTL.get(); + + if ( buffer.capacity() < size ) { + int sizeNew = buffer.capacity() << 1; + while ( sizeNew < size ) + sizeNew <<= 1; + + final ByteBuffer bufferNew = BufferUtils.createByteBuffer(size); + bufferNew.put(buffer); + bufferTL.set(buffer = bufferNew); + } else { + buffer.position(buffer.limit()); + buffer.limit(buffer.capacity()); + } + + return buffer; + } + + static ShortBuffer getBufferShort() { return ((Buffers)buffersTL.get()).shorts; } + + static IntBuffer getBufferInt() { return ((Buffers)buffersTL.get()).ints; } + + static LongBuffer getBufferLong() { return ((Buffers)buffersTL.get()).longs; } + + static FloatBuffer getBufferFloat() { return ((Buffers)buffersTL.get()).floats; } + + static DoubleBuffer getBufferDouble() { return ((Buffers)buffersTL.get()).doubles; } + + static IntBuffer getLengths() { + return getLengths(1); + } + + static IntBuffer getLengths(final int size) { + IntBuffer lengths = (IntBuffer)lengthsTL.get(); + + if ( lengths.capacity() < size ) { + int sizeNew = lengths.capacity(); + while ( sizeNew < size ) + sizeNew <<= 1; + + lengths = BufferUtils.createIntBuffer(size); + lengthsTL.set(lengths); + } else + lengths.clear(); + + return lengths; + } + + private static InfiniteCharSequence getInfiniteSeq() { + return (InfiniteCharSequence)infiniteSeqTL.get(); + } + + private static void encode(final ByteBuffer buffer, final CharSequence string) { + final InfiniteCharSequence infiniteSeq = getInfiniteSeq(); + infiniteSeq.setString(string); + encoder.encode(infiniteSeq.buffer, buffer, true); + } + + /** + * Reads a byte string from the specified buffer. + * + * @param buffer + * + * @return the buffer as a String. + */ + static String getString(final ByteBuffer buffer) { + final int length = buffer.remaining(); + final char[] charArray = getArray(length); + + for ( int i = buffer.position(); i < buffer.limit(); i++ ) + charArray[i - buffer.position()] = (char)buffer.get(i); + + return new String(charArray, 0, length); + } + + /** + * Returns a buffer containing the specified string as bytes. + * + * @param string + * + * @return the String as a ByteBuffer + */ + static ByteBuffer getBuffer(final CharSequence string) { + final ByteBuffer buffer = getBufferByte(string.length()); + + encode(buffer, string); + + buffer.flip(); + return buffer; + } + + /** + * Returns a buffer containing the specified string as bytes, starting at the specified offset. + * + * @param string + * + * @return the String as a ByteBuffer + */ + static ByteBuffer getBuffer(final CharSequence string, final int offset) { + final ByteBuffer buffer = getBufferByteOffset(offset + string.length()); + + encode(buffer, string); + + buffer.flip(); + return buffer; + } + + /** + * Returns a buffer containing the specified string as bytes, including null-termination. + * + * @param string + * + * @return the String as a ByteBuffer + */ + static ByteBuffer getBufferNT(final CharSequence string) { + final ByteBuffer buffer = getBufferByte(string.length() + 1); + + encode(buffer, string); + + buffer.put((byte)0); + buffer.flip(); + return buffer; + } + + static int getTotalLength(final CharSequence[] strings) { + int length = 0; + for ( int i = 0; i < strings.length; i++ ) + length += strings[i].length(); + + return length; + } + + /** + * Returns a buffer containing the specified strings as bytes. + * + * @param strings + * + * @return the Strings as a ByteBuffer + */ + static ByteBuffer getBuffer(final CharSequence[] strings) { + final ByteBuffer buffer = getBufferByte(getTotalLength(strings)); + + final InfiniteCharSequence infiniteSeq = getInfiniteSeq(); + for ( int i = 0; i < strings.length; i++ ) { + infiniteSeq.setString(strings[i]); + encoder.encode(infiniteSeq.buffer, buffer, true); + } + infiniteSeq.clear(); + + buffer.flip(); + return buffer; + } + + /** + * Returns a buffer containing the specified strings as bytes, including null-termination. + * + * @param strings + * + * @return the Strings as a ByteBuffer + */ + static ByteBuffer getBufferNT(final CharSequence[] strings) { + final ByteBuffer buffer = getBufferByte(getTotalLength(strings) + strings.length); + + final InfiniteCharSequence infiniteSeq = getInfiniteSeq(); + for ( int i = 0; i < strings.length; i++ ) { + infiniteSeq.setString(strings[i]); + encoder.encode(infiniteSeq.buffer, buffer, true); + buffer.put((byte)0); + } + infiniteSeq.clear(); + + buffer.flip(); + return buffer; + } + + /** + * Returns a buffer containing the lengths of the specified strings. + * + * @param strings + * + * @return the String lengths in an IntBuffer + */ + static IntBuffer getLengths(final CharSequence[] strings) { + IntBuffer buffer = getLengths(strings.length); + + for ( int i = 0; i < strings.length; i++ ) + buffer.put(strings[i].length()); + + buffer.flip(); + return buffer; + } + + /** + * A mutable CharSequence with very large initial length. We can wrap this in a re-usable CharBuffer for decoding. + * We cannot subclass CharBuffer because of {@link CharBuffer#toString(int,int)}. + */ + private static class InfiniteCharSequence implements CharSequence { + + final CharBuffer buffer; + + CharSequence string; + + InfiniteCharSequence() { + buffer = CharBuffer.wrap(this); + } + + void setString(final CharSequence string) { + this.string = string; + this.buffer.position(0); + this.buffer.limit(string.length()); + } + + void clear() { + this.string = null; + } + + public int length() { + return Integer.MAX_VALUE; + } + + public char charAt(final int index) { + return string.charAt(index); + } + + public CharSequence subSequence(final int start, final int end) { + return string.subSequence(start, end); + } + } + + private static class Buffers { + + final ShortBuffer shorts; + final IntBuffer ints; + final LongBuffer longs; + + final FloatBuffer floats; + final DoubleBuffer doubles; + + Buffers() { + shorts = BufferUtils.createShortBuffer(BUFFERS_SIZE); + ints = BufferUtils.createIntBuffer(BUFFERS_SIZE); + longs = BufferUtils.createLongBuffer(BUFFERS_SIZE); + + floats = BufferUtils.createFloatBuffer(BUFFERS_SIZE); + doubles = BufferUtils.createDoubleBuffer(BUFFERS_SIZE); + } + + } + +} \ No newline at end of file diff --git a/src/java/org/lwjgl/opengl/AWTCanvasImplementation.java b/src/java/org/lwjgl/opengl/AWTCanvasImplementation.java new file mode 100644 index 0000000..b51b811 --- /dev/null +++ b/src/java/org/lwjgl/opengl/AWTCanvasImplementation.java @@ -0,0 +1,59 @@ +/* + * 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; + +import java.awt.GraphicsConfiguration; +import java.awt.GraphicsDevice; +import java.awt.Canvas; + +import org.lwjgl.LWJGLException; + +/** + * + * @author elias_naur + * @version $Revision: 3002 $ + * $Id: AWTCanvasImplementation.java 3002 2008-04-10 20:25:54Z elias_naur $ + */ +interface AWTCanvasImplementation { + /** + * Return an opaque handle to the canvas peer information required to create a context from it. + */ + PeerInfo createPeerInfo(Canvas component, PixelFormat pixel_format) throws LWJGLException; + + /** + * Find a proper GraphicsConfiguration from the given GraphicsDevice and PixelFormat. + * + * @return A GraphicsConfiguration matching the given GraphicsConfiguration and PixelFormat. + * @throws LWJGLException if no suitable configuration could be found. + */ + GraphicsConfiguration findConfiguration(GraphicsDevice device, PixelFormat pixel_format) throws LWJGLException; +} diff --git a/src/java/org/lwjgl/opengl/AWTGLCanvas.java b/src/java/org/lwjgl/opengl/AWTGLCanvas.java new file mode 100644 index 0000000..2121247 --- /dev/null +++ b/src/java/org/lwjgl/opengl/AWTGLCanvas.java @@ -0,0 +1,363 @@ +/* + * 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; + +import org.lwjgl.LWJGLException; +import org.lwjgl.LWJGLUtil; +import org.lwjgl.Sys; + +import java.awt.*; +import java.awt.event.ComponentEvent; +import java.awt.event.ComponentListener; +import java.awt.event.HierarchyEvent; +import java.awt.event.HierarchyListener; + +/** + *

+ * An AWT rendering context. + *

+ * + * @author $Author: spasi $ + * $Id: AWTGLCanvas.java 3116 2008-08-19 16:46:03Z spasi $ + * @version $Revision: 3116 $ + */ +public class AWTGLCanvas extends Canvas implements Drawable, ComponentListener, HierarchyListener { + + private static final long serialVersionUID = 1L; + + private final static AWTCanvasImplementation implementation; + private boolean update_context; + private Object SYNC_LOCK = new Object(); + + /** The requested pixel format */ + private final PixelFormat pixel_format; + + /** The drawable to share context with */ + private final Drawable drawable; + + /** The ContextAttribs to use when creating the context */ + private final ContextAttribs attribs; + + /** Context handle */ + private PeerInfo peer_info; + private Context context; + + /** + * re-entry counter for support for re-entrant + * redrawing in paint(). It happens when using dialog boxes. + */ + private int reentry_count; + + /** Tracks whether initGL() needs to be called */ + private boolean first_run; + + static { + Sys.initialize(); + implementation = createImplementation(); + } + + static AWTCanvasImplementation createImplementation() { + switch ( LWJGLUtil.getPlatform() ) { + case LWJGLUtil.PLATFORM_LINUX: + return new LinuxCanvasImplementation(); + case LWJGLUtil.PLATFORM_WINDOWS: + return new WindowsCanvasImplementation(); + case LWJGLUtil.PLATFORM_MACOSX: + return new MacOSXCanvasImplementation(); + default: + throw new IllegalStateException("Unsupported platform"); + } + } + + private void setUpdate() { + synchronized ( SYNC_LOCK ) { + update_context = true; + } + } + + /** This method should only be called internally. */ + public Context getContext() { + return context; + } + + /** Constructor using the default PixelFormat. */ + public AWTGLCanvas() throws LWJGLException { + this(new PixelFormat()); + } + + /** + * Create an AWTGLCanvas with the requested PixelFormat on the default GraphicsDevice. + * + * @param pixel_format The desired pixel format. May not be null + */ + public AWTGLCanvas(PixelFormat pixel_format) throws LWJGLException { + this(GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice(), pixel_format); + } + + /** + * Create an AWTGLCanvas with the requested PixelFormat on the default GraphicsDevice. + * + * @param device the device to create the canvas on. + * @param pixel_format The desired pixel format. May not be null + */ + public AWTGLCanvas(GraphicsDevice device, PixelFormat pixel_format) throws LWJGLException { + this(device, pixel_format, null); + } + + /** + * Create an AWTGLCanvas with the requested PixelFormat on the specified GraphicsDevice. + * + * @param device the device to create the canvas on. + * @param pixel_format The desired pixel format. May not be null + * @param drawable The Drawable to share context with + */ + public AWTGLCanvas(GraphicsDevice device, PixelFormat pixel_format, Drawable drawable) throws LWJGLException { + this(device, pixel_format, drawable, null); + } + + /** + * Create an AWTGLCanvas with the requested PixelFormat on the specified GraphicsDevice. + * + * @param device the device to create the canvas on. + * @param pixel_format The desired pixel format. May not be null + * @param drawable The Drawable to share context with + * @param attribs The ContextAttribs to use when creating the context. (optional, may be null) + */ + public AWTGLCanvas(GraphicsDevice device, PixelFormat pixel_format, Drawable drawable, ContextAttribs attribs) throws LWJGLException { + super(implementation.findConfiguration(device, pixel_format)); + if ( pixel_format == null ) + throw new NullPointerException("Pixel format must be non-null"); + addHierarchyListener(this); + addComponentListener(this); + this.drawable = drawable; + this.pixel_format = pixel_format; + this.attribs = attribs; + } + + /* (non-Javadoc) + * @see java.awt.Canvas#addNotify() + */ + public void addNotify() { + super.addNotify(); + } + + /* (non-Javadoc) + * @see java.awt.Component#removeNotify() + */ + public void removeNotify() { + synchronized ( SYNC_LOCK ) { + destroyContext(); + super.removeNotify(); + } + } + + /** Set swap interval. */ + public void setSwapInterval(int swap_interval) { + synchronized ( SYNC_LOCK ) { + if ( context == null ) + throw new IllegalStateException("Canvas not yet displayable"); + Context.setSwapInterval(swap_interval); + } + } + + /** Enable vsync */ + public void setVSyncEnabled(boolean enabled) { + setSwapInterval(enabled ? 1 : 0); + } + + /** Swap the canvas' buffer */ + public void swapBuffers() throws LWJGLException { + synchronized ( SYNC_LOCK ) { + if ( context == null ) + throw new IllegalStateException("Canvas not yet displayable"); + Context.swapBuffers(); + } + } + + public void releaseContext() throws LWJGLException { + synchronized ( SYNC_LOCK ) { + if ( context == null ) + throw new IllegalStateException("Canvas not yet displayable"); + if ( context.isCurrent() ) + Context.releaseCurrentContext(); + } + } + + /** + * Make the canvas' context current. It is highly recommended that the context + * is only made current inside the AWT thread (for example in an overridden paintGL()). + */ + public void makeCurrent() throws LWJGLException { + synchronized ( SYNC_LOCK ) { + if ( context == null ) + throw new IllegalStateException("Canvas not yet displayable"); + context.makeCurrent(); + } + } + + /** Destroy the OpenGL context. This happens when the component becomes undisplayable */ + private void destroyContext() { + synchronized ( SYNC_LOCK ) { + try { + if ( context != null ) { + context.forceDestroy(); + context = null; + reentry_count = 0; + peer_info.destroy(); + peer_info = null; + } + } catch (LWJGLException e) { + throw new RuntimeException(e); + } + } + } + + /** + * Override this to do initialising of the context. + * It will be called once from paint(), immediately after + * the context is created and made current. + */ + protected void initGL() { + } + + /** Override this to do painting */ + protected void paintGL() { + } + + /** + * The default paint() operation makes the context current and calls paintGL() which should + * be overridden to do GL operations. + */ + public final void paint(Graphics g) { + LWJGLException exception = null; + synchronized ( SYNC_LOCK ) { + if ( !isDisplayable() ) + return; + try { + if ( peer_info == null ) { + this.peer_info = implementation.createPeerInfo(this, pixel_format); + } + peer_info.lockAndGetHandle(); + try { + if ( context == null ) { + this.context = new Context(peer_info, attribs, drawable != null ? drawable.getContext() : null); + first_run = true; + } + + if ( reentry_count == 0 ) + context.makeCurrent(); + reentry_count++; + try { + if ( update_context ) { + context.update(); + update_context = false; + } + if ( first_run ) { + first_run = false; + initGL(); + } + paintGL(); + } finally { + reentry_count--; + if ( reentry_count == 0 ) + Context.releaseCurrentContext(); + } + } finally { + peer_info.unlock(); + } + } catch (LWJGLException e) { + exception = e; + } + } + if ( exception != null ) + exceptionOccurred(exception); + } + + /** + * This method will be called if an unhandled LWJGLException occurs in paint(). + * Override this method to be notified of this. + * + * @param exception The exception that occurred. + */ + protected void exceptionOccurred(LWJGLException exception) { + LWJGLUtil.log("Unhandled exception occurred, skipping paint(): " + exception); + } + + /** override update to avoid clearing */ + public void update(Graphics g) { + paint(g); + } + + public void componentShown(ComponentEvent e) { + } + + public void componentHidden(ComponentEvent e) { + } + + public void componentResized(ComponentEvent e) { + setUpdate(); + } + + public void componentMoved(ComponentEvent e) { + setUpdate(); + } + + public void setLocation(int x, int y) { + super.setLocation(x, y); + setUpdate(); + } + + public void setLocation(Point p) { + super.setLocation(p); + setUpdate(); + } + + public void setSize(Dimension d) { + super.setSize(d); + setUpdate(); + } + + public void setSize(int width, int height) { + super.setSize(width, height); + setUpdate(); + } + + public void setBounds(int x, int y, int width, int height) { + super.setBounds(x, y, width, height); + setUpdate(); + } + + public void hierarchyChanged(HierarchyEvent e) { + setUpdate(); + } + +} \ No newline at end of file diff --git a/src/java/org/lwjgl/opengl/AWTSurfaceLock.java b/src/java/org/lwjgl/opengl/AWTSurfaceLock.java new file mode 100644 index 0000000..64f02c6 --- /dev/null +++ b/src/java/org/lwjgl/opengl/AWTSurfaceLock.java @@ -0,0 +1,106 @@ +/* + * 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; + +import java.awt.Canvas; +import java.nio.ByteBuffer; +import java.security.AccessController; +import java.security.PrivilegedActionException; +import java.security.PrivilegedExceptionAction; + +import org.lwjgl.LWJGLException; +import org.lwjgl.LWJGLUtil; + +/** + * + * @author elias_naur + * @version $Revision: 3116 $ + * $Id: AWTSurfaceLock.java 3116 2008-08-19 16:46:03Z spasi $ + */ +final class AWTSurfaceLock { + + private final static int WAIT_DELAY_MILLIS = 100; + + private final ByteBuffer lock_buffer; + + private boolean firstLockSucceeded = false; + + AWTSurfaceLock() { + lock_buffer = createHandle(); + } + + private static native ByteBuffer createHandle(); + + public ByteBuffer lockAndGetHandle(Canvas component) throws LWJGLException { + while (!privilegedLockAndInitHandle(component)) { + LWJGLUtil.log("Could not get drawing surface info, retrying..."); + try { + Thread.sleep(WAIT_DELAY_MILLIS); + } catch (InterruptedException e) { + LWJGLUtil.log("Interrupted while retrying: " + e); + } + } + + return lock_buffer; + } + + private boolean privilegedLockAndInitHandle(final Canvas component) throws LWJGLException { + // Workaround for Sun JDK bug 4796548 which still exists in java for OS X + // We need to elevate privileges because of an AWT bug. Please see + // http://192.18.37.44/forums/index.php?topic=10572 for a discussion. + // It is only needed on first call, so we avoid it on all subsequent calls + // due to performance. + if (firstLockSucceeded) + return lockAndInitHandle(lock_buffer, component); + else + try { + final Object result = AccessController.doPrivileged(new PrivilegedExceptionAction() { + + public Object run() throws LWJGLException { + return Boolean.valueOf(lockAndInitHandle(lock_buffer, component)); + } + }); + firstLockSucceeded = ((Boolean) result).booleanValue(); + return firstLockSucceeded; + } catch (PrivilegedActionException e) { + throw (LWJGLException) e.getException(); + } + } + + private static native boolean lockAndInitHandle(ByteBuffer lock_buffer, Canvas component) throws LWJGLException; + + void unlock() throws LWJGLException { + nUnlock(lock_buffer); + } + + private static native void nUnlock(ByteBuffer lock_buffer) throws LWJGLException; +} diff --git a/src/java/org/lwjgl/opengl/AWTUtil.java b/src/java/org/lwjgl/opengl/AWTUtil.java new file mode 100644 index 0000000..1185523 --- /dev/null +++ b/src/java/org/lwjgl/opengl/AWTUtil.java @@ -0,0 +1,186 @@ +/* + * 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; + +/** + * @author elias_naur + */ + +import java.awt.Component; +import java.awt.Cursor; +import java.awt.Dimension; +import java.awt.GraphicsConfiguration; +import java.awt.GraphicsDevice; +import java.awt.IllegalComponentStateException; +import java.awt.MouseInfo; +import java.awt.Point; +import java.awt.PointerInfo; +import java.awt.Robot; +import java.awt.Toolkit; +import java.awt.image.BufferedImage; +import java.nio.IntBuffer; +import java.security.AccessController; +import java.security.PrivilegedActionException; +import java.security.PrivilegedExceptionAction; + +import org.lwjgl.LWJGLException; +import org.lwjgl.LWJGLUtil; + +final class AWTUtil { + public static boolean hasWheel() { + return true; + } + + public static int getButtonCount() { + return MouseEventQueue.NUM_BUTTONS; + } + + public static int getNativeCursorCapabilities() { + if (LWJGLUtil.getPlatform() != LWJGLUtil.PLATFORM_MACOSX || LWJGLUtil.isMacOSXEqualsOrBetterThan(10, 4)) { + int cursor_colors = Toolkit.getDefaultToolkit().getMaximumCursorColors(); + boolean supported = cursor_colors >= Short.MAX_VALUE && getMaxCursorSize() > 0; + int caps = supported ? org.lwjgl.input.Cursor.CURSOR_8_BIT_ALPHA | org.lwjgl.input.Cursor.CURSOR_ONE_BIT_TRANSPARENCY: 0 | org.lwjgl.input.Cursor.CURSOR_ANIMATION; + return caps; + } else { + /* Return no capability in Mac OS X 10.3 and earlier , as there are two unsolved bugs (both reported to apple along with + minimal test case): + 1. When a custom cursor (or some standard) java.awt.Cursor is assigned to a + Componennt, it is reset to the default pointer cursor when the window is de- + activated and the re-activated. The Cursor can not be reset to the custom cursor, + with another setCursor. + 2. When the cursor is moving in the top pixel row (y = 0 in AWT coordinates) in fullscreen + mode, no mouse moved events are reported, even though mouse pressed/released and dragged + events are reported + */ + return 0; + } + } + + public static Robot createRobot(final Component component) { + try { + Robot robot = (Robot)AccessController.doPrivileged(new PrivilegedExceptionAction() { + public Object run() throws Exception { + return new Robot(component.getGraphicsConfiguration().getDevice()); + } + }); + return robot; + } catch (PrivilegedActionException e) { + LWJGLUtil.log("Got exception while creating robot: " + e.getCause()); + return null; + } + } + + private static int transformY(Component component, int y) { + return component.getHeight() - 1 - y; + } + + /** + * Use reflection to access the JDK 1.5 pointer location, if possible and + * only if the given component is on the same screen as the cursor. Return + * null otherwise. + */ + private static Point getPointerLocation(final Component component) { + try { + final GraphicsConfiguration config = component.getGraphicsConfiguration(); + if (config != null) { + PointerInfo pointer_info = (PointerInfo)AccessController.doPrivileged(new PrivilegedExceptionAction() { + public Object run() throws Exception { + return MouseInfo.getPointerInfo(); + } + }); + GraphicsDevice device = pointer_info.getDevice(); + if (device == config.getDevice()) { + return pointer_info.getLocation(); + } + return null; + } + } catch (PrivilegedActionException e) { + LWJGLUtil.log("Failed to query pointer location: " + e.getCause()); + } + return null; + } + + /** + * Use the 1.5 API to get the cursor position relative to the component. Return null + * if it fails (JDK <= 1.4). + */ + public static Point getCursorPosition(Component component) { + try { + Point pointer_location = getPointerLocation(component); + if (pointer_location != null) { + Point location = component.getLocationOnScreen(); + pointer_location.translate(-location.x, -location.y); + pointer_location.move(pointer_location.x, transformY(component, pointer_location.y)); + return pointer_location; + } + } catch (IllegalComponentStateException e) { + LWJGLUtil.log("Failed to set cursor position: " + e); + } catch (NoClassDefFoundError e) { // Not JDK 1.5 + LWJGLUtil.log("Failed to query cursor position: " + e); + } + return null; + } + + public static void setCursorPosition(Component component, Robot robot, int x, int y) { + if (robot != null) { + try { + Point location = component.getLocationOnScreen(); + int transformed_x = location.x + x; + int transformed_y = location.y + transformY(component, y); + robot.mouseMove(transformed_x, transformed_y); + } catch (IllegalComponentStateException e) { + LWJGLUtil.log("Failed to set cursor position: " + e); + } + } + } + + public static int getMinCursorSize() { + Dimension min_size = Toolkit.getDefaultToolkit().getBestCursorSize(0, 0); + return Math.max(min_size.width, min_size.height); + } + + public static int getMaxCursorSize() { + Dimension max_size = Toolkit.getDefaultToolkit().getBestCursorSize(10000, 10000); + return Math.min(max_size.width, max_size.height); + } + + /** Native cursor handles */ + public static Cursor createCursor(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, IntBuffer delays) throws LWJGLException { + BufferedImage cursor_image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); + int[] pixels = new int[images.remaining()]; + int old_position = images.position(); + images.get(pixels); + images.position(old_position); + cursor_image.setRGB(0, 0, width, height, pixels, 0, width); + return Toolkit.getDefaultToolkit().createCustomCursor(cursor_image, new Point(xHotspot, yHotspot), "LWJGL Custom cursor"); + } +} diff --git a/src/java/org/lwjgl/opengl/BaseReferences.java b/src/java/org/lwjgl/opengl/BaseReferences.java new file mode 100644 index 0000000..343b2c9 --- /dev/null +++ b/src/java/org/lwjgl/opengl/BaseReferences.java @@ -0,0 +1,103 @@ +/* + * 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; + +import java.nio.Buffer; +import java.nio.IntBuffer; +import java.util.Arrays; + +class BaseReferences { + + int elementArrayBuffer; + int arrayBuffer; + Buffer[] glVertexAttribPointer_buffer; + Buffer[] glTexCoordPointer_buffer; + int glClientActiveTexture; + + int pixelPackBuffer; + int pixelUnpackBuffer; + + int indirectBuffer; + + BaseReferences(ContextCapabilities caps) { + IntBuffer temp = caps.scratch_int_buffer; + + int max_vertex_attribs; + if (caps.OpenGL20 || caps.GL_ARB_vertex_shader) { + GL11.glGetInteger(ARBVertexShader.GL_MAX_VERTEX_ATTRIBS_ARB, temp); + max_vertex_attribs = temp.get(0); + } else + max_vertex_attribs = 0; + glVertexAttribPointer_buffer = new Buffer[max_vertex_attribs]; + + int max_texture_units; + if (caps.OpenGL20) { + GL11.glGetInteger(GL20.GL_MAX_TEXTURE_IMAGE_UNITS, temp); + max_texture_units = temp.get(0); + } else if (caps.OpenGL13 || caps.GL_ARB_multitexture) { + GL11.glGetInteger(GL13.GL_MAX_TEXTURE_UNITS, temp); + max_texture_units = temp.get(0); + } else + max_texture_units = 1; + glTexCoordPointer_buffer = new Buffer[max_texture_units]; + } + + void clear() { + this.elementArrayBuffer = 0; + this.arrayBuffer = 0; + this.glClientActiveTexture = 0; + Arrays.fill(glVertexAttribPointer_buffer, null); + Arrays.fill(glTexCoordPointer_buffer, null); + + this.pixelPackBuffer = 0; + this.pixelUnpackBuffer = 0; + + this.indirectBuffer = 0; + } + + void copy(BaseReferences references, int mask) { + if ( (mask & GL11.GL_CLIENT_VERTEX_ARRAY_BIT) != 0 ) { + this.elementArrayBuffer = references.elementArrayBuffer; + this.arrayBuffer = references.arrayBuffer; + 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 ) { + this.pixelPackBuffer = references.pixelPackBuffer; + this.pixelUnpackBuffer = references.pixelUnpackBuffer; + } + } +} diff --git a/src/java/org/lwjgl/opengl/Context.java b/src/java/org/lwjgl/opengl/Context.java new file mode 100644 index 0000000..36119ab --- /dev/null +++ b/src/java/org/lwjgl/opengl/Context.java @@ -0,0 +1,252 @@ +/* + * 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; + +import org.lwjgl.LWJGLException; +import org.lwjgl.LWJGLUtil; +import org.lwjgl.Sys; + +import java.nio.ByteBuffer; +import java.nio.IntBuffer; + +/** + *

+ * Context encapsulates an OpenGL context. + *

+ *

+ * This class is thread-safe. + * + * @author elias_naur + * @version $Revision: 3117 $ + * $Id: Context.java 3117 2008-08-19 17:47:24Z spasi $ + */ +final class Context { + + /** The platform specific implementation of context methods */ + private final static ContextImplementation implementation; + + /** The current Context */ + private final static ThreadLocal current_context_local = new ThreadLocal(); + + /** Handle to the native GL rendering context */ + private final ByteBuffer handle; + private final PeerInfo peer_info; + + private final IntBuffer attribList; + private final boolean forwardCompatible; + + /** Whether the context has been destroyed */ + private boolean destroyed; + + private boolean destroy_requested; + + /** The thread that has this context current, or null. */ + private Thread thread; + + static { + Sys.initialize(); + implementation = createImplementation(); + } + + private static ContextImplementation createImplementation() { + switch ( LWJGLUtil.getPlatform() ) { + case LWJGLUtil.PLATFORM_LINUX: + return new LinuxContextImplementation(); + case LWJGLUtil.PLATFORM_WINDOWS: + return new WindowsContextImplementation(); + case LWJGLUtil.PLATFORM_MACOSX: + return new MacOSXContextImplementation(); + default: + throw new IllegalStateException("Unsupported platform"); + } + } + + PeerInfo getPeerInfo() { + return peer_info; + } + + static Context getCurrentContext() { + return (Context)current_context_local.get(); + } + + /** Create a context with the specified peer info and shared context */ + Context(PeerInfo peer_info, ContextAttribs attribs, Context shared_context) throws LWJGLException { + Context context_lock = shared_context != null ? shared_context : this; + // If shared_context is not null, synchronize on it to make sure it is not deleted + // while this context is created. Otherwise, simply synchronize on ourself to avoid NPE + synchronized ( context_lock ) { + if ( shared_context != null && shared_context.destroyed ) + throw new IllegalArgumentException("Shared context is destroyed"); + GLContext.loadOpenGLLibrary(); + try { + this.peer_info = peer_info; + if ( attribs != null ) { + attribList = attribs.getAttribList(); + forwardCompatible = attribs.isForwardCompatible(); + } else { + attribList = null; + forwardCompatible = false; + } + + this.handle = implementation.create(peer_info, attribList, shared_context != null ? shared_context.handle : null); + } catch (LWJGLException e) { + GLContext.unloadOpenGLLibrary(); + throw e; + } + } + } + + /** Release the current context (if any). After this call, no context is current. */ + public static void releaseCurrentContext() throws LWJGLException { + Context current_context = getCurrentContext(); + if ( current_context != null ) { + implementation.releaseCurrentContext(); + GLContext.useContext(null); + current_context_local.set(null); + synchronized ( current_context ) { + current_context.thread = null; + current_context.checkDestroy(); + } + } + } + + /** + * Release the context from its drawable. This is necessary on some platforms, + * like Mac OS X, where binding the context to a drawable and binding the context + * for rendering are two distinct actions and where calling releaseDrawable + * on every releaseCurrentContext results in artifacts. + */ + public synchronized void releaseDrawable() throws LWJGLException { + if ( destroyed ) + throw new IllegalStateException("Context is destroyed"); + implementation.releaseDrawable(getHandle()); + } + + /** Update the context. Should be called whenever it's drawable is moved or resized */ + public synchronized void update() { + if ( destroyed ) + throw new IllegalStateException("Context is destroyed"); + implementation.update(getHandle()); + } + + /** Swap the buffers on the current context. Only valid for double-buffered contexts */ + public static void swapBuffers() throws LWJGLException { + implementation.swapBuffers(); + } + + private boolean canAccess() { + return thread == null || Thread.currentThread() == thread; + } + + private void checkAccess() { + if ( !canAccess() ) + throw new IllegalStateException("From thread " + Thread.currentThread() + ": " + thread + " already has the context current"); + } + + /** Make the context current */ + public synchronized void makeCurrent() throws LWJGLException { + checkAccess(); + if ( destroyed ) + throw new IllegalStateException("Context is destroyed"); + thread = Thread.currentThread(); + current_context_local.set(this); + implementation.makeCurrent(peer_info, handle); + GLContext.useContext(this, forwardCompatible); + } + + ByteBuffer getHandle() { + return handle; + } + + /** Query whether the context is current */ + public synchronized boolean isCurrent() throws LWJGLException { + if ( destroyed ) + throw new IllegalStateException("Context is destroyed"); + return implementation.isCurrent(handle); + } + + private void checkDestroy() { + if ( !destroyed && destroy_requested ) { + try { + releaseDrawable(); + implementation.destroy(peer_info, handle); + destroyed = true; + thread = null; + GLContext.unloadOpenGLLibrary(); + } catch (LWJGLException e) { + LWJGLUtil.log("Exception occurred while destroying context: " + e); + } + } + } + + /** + * Set the buffer swap interval. This call is a best-attempt at changing + * the monitor swap interval, which is the minimum periodicity of color buffer swaps, + * measured in video frame periods, and is not guaranteed to be successful. + *

+ * A video frame period is the time required to display a full frame of video data. + */ + public static void setSwapInterval(int value) { + implementation.setSwapInterval(value); + } + + /** + * Destroy the context. This method behaves the same as destroy() with the extra + * requirement that the context must be either current to the current thread or not + * current at all. + */ + public synchronized void forceDestroy() throws LWJGLException { + checkAccess(); + destroy(); + } + + /** + * Request destruction of the Context. If the context is current, no context will be current after this call. + * The context is destroyed when no thread has it current. + */ + public synchronized void destroy() throws LWJGLException { + if ( destroyed ) + return; + destroy_requested = true; + boolean was_current = isCurrent(); + int error = GL11.GL_NO_ERROR; + if ( was_current ) { + if ( GLContext.getCapabilities() != null && GLContext.getCapabilities().OpenGL11 ) + error = GL11.glGetError(); + releaseCurrentContext(); + } + checkDestroy(); + if ( was_current && error != GL11.GL_NO_ERROR ) + throw new OpenGLException(error); + } + +} \ No newline at end of file diff --git a/src/java/org/lwjgl/opengl/ContextAttribs.java b/src/java/org/lwjgl/opengl/ContextAttribs.java new file mode 100644 index 0000000..59d951f --- /dev/null +++ b/src/java/org/lwjgl/opengl/ContextAttribs.java @@ -0,0 +1,275 @@ +/* + * 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; + +import org.lwjgl.BufferUtils; +import org.lwjgl.LWJGLUtil; + +import java.nio.IntBuffer; + +/** + * This class represents the context attributes passed to CreateContextAttribs of the XGL_create_context extension. + * These attributes can be used to indicate at context creation which OpenGL interface will be used. This includes the + * OpenGL version, the layer plane on which rendering takes place and also optional debug and forward combatibility modes. + * (read the XGL_create_context spec for details) + *

+ * Use of this class is optional. If an OpenGL context is created without passing an instance of this class + * (or XGL_create_context is not supported), the old context creation code will be used. Use of ContextAttribs is required + * to create an OpenGL 3.0 or newer context. Support for debug and forward compatible mobes is not guaranteed by the OpenGL + * implementation. Developers may encounter debug contexts being the same as non-debug contexts or forward compatible + * contexts having support for deprecated functionality. + *

+ * If the forwardCompatible + * attribute is used, LWJGL will not load the deprecated functionality (as defined in the OpenGL 3.0 specification). This + * means that developers can start working on cleaning up their applications without an OpenGL 3.0 complaint driver. + * + * @author spasi + */ +public final class ContextAttribs { + + private int majorVersion; + private int minorVersion; + + private int layerPlane; + + private boolean debug; + private boolean forwardCompatible; + + private boolean profileCore; + private boolean profileCompatibility; + + public ContextAttribs() { + this(1, 0); + } + + public ContextAttribs(final int majorVersion, final int minorVersion) { + if ( majorVersion < 0 || + 3 < majorVersion || + minorVersion < 0 || + (majorVersion == 3 && 2 < minorVersion) || + (majorVersion == 2 && 1 < minorVersion) || + (majorVersion == 1 && 5 < minorVersion) ) + throw new IllegalArgumentException("Invalid OpenGL version specified: " + majorVersion + '.' + minorVersion); + + this.majorVersion = majorVersion; + this.minorVersion = minorVersion; + + this.layerPlane = 0; + + this.debug = false; + this.forwardCompatible = false; + + this.profileCore = 3 < majorVersion || (majorVersion == 3 && 2 <= minorVersion) ? true : false; + this.profileCompatibility = false; + } + + private ContextAttribs(final ContextAttribs attribs) { + this.majorVersion = attribs.majorVersion; + this.minorVersion = attribs.minorVersion; + + this.layerPlane = attribs.layerPlane; + + this.debug = attribs.debug; + this.forwardCompatible = attribs.forwardCompatible; + + this.profileCore = attribs.profileCore; + this.profileCompatibility = attribs.profileCompatibility; + } + + public int getMajorVersion() { + return majorVersion; + } + + public int getMinorVersion() { + return minorVersion; + } + + public int getLayerPlane() { + return layerPlane; + } + + public boolean isDebug() { + return debug; + } + + public boolean isForwardCompatible() { + return forwardCompatible; + } + + public boolean isProfileCore() { + return profileCore; + } + + public boolean isProfileCompatibility() { + return profileCompatibility; + } + + public ContextAttribs withLayer(final int layerPlane) { + if ( layerPlane < 0 ) + throw new IllegalArgumentException("Invalid layer plane specified: " + layerPlane); + + if ( layerPlane == this.layerPlane ) + return this; + + final ContextAttribs attribs = new ContextAttribs(this); + attribs.layerPlane = layerPlane; + return attribs; + } + + public ContextAttribs withDebug(final boolean debug) { + if ( debug == this.debug ) + return this; + + final ContextAttribs attribs = new ContextAttribs(this); + attribs.debug = debug; + return attribs; + } + + public ContextAttribs withForwardCompatible(final boolean forwardCompatible) { + if ( forwardCompatible == this.forwardCompatible ) + return this; + + final ContextAttribs attribs = new ContextAttribs(this); + attribs.forwardCompatible = forwardCompatible; + return attribs; + } + + public ContextAttribs withProfileCore(final boolean profileCore) { + if ( majorVersion < 3 || (majorVersion == 3 && minorVersion < 2) ) + throw new IllegalArgumentException("Profiles are only supported on OpenGL version 3.2 or higher."); + + if ( profileCore == this.profileCore ) + return this; + + final ContextAttribs attribs = new ContextAttribs(this); + attribs.profileCore = profileCore; + if ( profileCore ) + attribs.profileCompatibility = false; + + return attribs; + } + + public ContextAttribs withProfileCompatibility(final boolean profileCompatibility) { + if ( majorVersion < 3 || (majorVersion == 3 && minorVersion < 2) ) + throw new IllegalArgumentException("Profiles are only supported on OpenGL version 3.2 or higher."); + + if ( profileCompatibility == this.profileCompatibility ) + return this; + + final ContextAttribs attribs = new ContextAttribs(this); + attribs.profileCompatibility = profileCompatibility; + if ( profileCompatibility ) + attribs.profileCore = false; + + return attribs; + } + + private static ContextAttribsImplementation getImplementation() { + switch ( LWJGLUtil.getPlatform() ) { + case LWJGLUtil.PLATFORM_LINUX: + return new LinuxContextAttribs(); + case LWJGLUtil.PLATFORM_WINDOWS: + return new WindowsContextAttribs(); + case LWJGLUtil.PLATFORM_MACOSX: + return new MacOSXContextAttribs(); + default: + throw new IllegalStateException("Unsupported platform"); + } + } + + IntBuffer getAttribList() { + ContextAttribsImplementation implementation = getImplementation(); + + int attribCount = 0; + + if ( !(majorVersion == 1 && minorVersion == 0) ) + attribCount += 2; + if ( 0 < layerPlane ) + attribCount++; + + int flags = 0; + if ( debug ) + flags |= implementation.getDebugBit(); + if ( forwardCompatible ) + flags |= implementation.getForwardCompatibleBit(); + if ( 0 < flags ) + attribCount++; + + int profileMask = 0; + if ( profileCore ) + profileMask |= implementation.getProfileCoreBit(); + else if ( profileCompatibility ) + profileMask |= implementation.getProfileCompatibilityBit(); + if ( 0 < profileMask ) + attribCount++; + + if ( attribCount == 0 ) + return null; + + final IntBuffer attribs = BufferUtils.createIntBuffer((attribCount * 2) + 1); + + if ( !(majorVersion == 1 && minorVersion == 0) ) { + attribs.put(implementation.getMajorVersionAttrib()).put(majorVersion); + attribs.put(implementation.getMinorVersionAttrib()).put(minorVersion); + } + if ( 0 < layerPlane ) + attribs.put(implementation.getLayerPlaneAttrib()).put(layerPlane); + if ( 0 < flags ) + attribs.put(implementation.getFlagsAttrib()).put(flags); + if ( 0 < profileMask ) + attribs.put(implementation.getProfileMaskAttrib()).put(profileMask); + + attribs.put(0); + attribs.rewind(); + return attribs; + } + + public String toString() { + StringBuffer sb = new StringBuffer(32); + + sb.append("ContextAttribs:"); + sb.append(" Version=").append(majorVersion).append('.').append(minorVersion); + sb.append(" - Layer=").append(layerPlane); + sb.append(" - Debug=").append(debug); + sb.append(" - ForwardCompatible=").append(forwardCompatible); + sb.append(" - Profile="); + if ( profileCore ) + sb.append("Core"); + else if ( profileCompatibility ) + sb.append("Compatibility"); + else + sb.append("None"); + + return sb.toString(); + } + +} \ No newline at end of file diff --git a/src/java/org/lwjgl/opengl/ContextAttribsImplementation.java b/src/java/org/lwjgl/opengl/ContextAttribsImplementation.java new file mode 100644 index 0000000..44c320d --- /dev/null +++ b/src/java/org/lwjgl/opengl/ContextAttribsImplementation.java @@ -0,0 +1,56 @@ +/* + * 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; + +/** @author spasi */ +interface ContextAttribsImplementation { + + int getMajorVersionAttrib(); + + int getMinorVersionAttrib(); + + int getLayerPlaneAttrib(); + + int getFlagsAttrib(); + + int getDebugBit(); + + int getForwardCompatibleBit(); + + int getProfileMaskAttrib(); + + int getProfileCoreBit(); + + int getProfileCompatibilityBit(); + +} \ No newline at end of file diff --git a/src/java/org/lwjgl/opengl/ContextImplementation.java b/src/java/org/lwjgl/opengl/ContextImplementation.java new file mode 100644 index 0000000..2e98fbf --- /dev/null +++ b/src/java/org/lwjgl/opengl/ContextImplementation.java @@ -0,0 +1,90 @@ +/* + * 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; + +import java.nio.ByteBuffer; +import java.nio.IntBuffer; + +import org.lwjgl.LWJGLException; + +/** + *

+ * Context implementation interface. + *

+ * + * @author elias_naur + * @version $Revision: 3116 $ + * $Id: ContextImplementation.java 3116 2008-08-19 16:46:03Z spasi $ + */ +interface ContextImplementation { + /** + * Create a context. + */ + ByteBuffer create(PeerInfo peer_info, IntBuffer attribs, ByteBuffer shared_context_handle) throws LWJGLException; + + /** + * Swap the buffers of the current context. Only valid for double-buffered contexts. + */ + void swapBuffers() throws LWJGLException; + + /** + * Release the context from its drawable, if any. + */ + void releaseDrawable(ByteBuffer context_handle) throws LWJGLException; + + /** + * Release the current context (if any). After this call, no context is current. + */ + void releaseCurrentContext() throws LWJGLException; + + /** + * Update the context. Should be called whenever it's drawable is moved or resized + */ + void update(ByteBuffer context_handle); + + /** + * Query whether the context is current + */ + void makeCurrent(PeerInfo peer_info, ByteBuffer handle) throws LWJGLException; + + /** + * Query whether the context is current + */ + boolean isCurrent(ByteBuffer handle) throws LWJGLException; + + void setSwapInterval(int value); + + /** + * Destroys the Context. + */ + void destroy(PeerInfo peer_info, ByteBuffer handle) throws LWJGLException; +} diff --git a/src/java/org/lwjgl/opengl/Display.java b/src/java/org/lwjgl/opengl/Display.java new file mode 100644 index 0000000..c9b960e --- /dev/null +++ b/src/java/org/lwjgl/opengl/Display.java @@ -0,0 +1,1127 @@ +/* + * 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; + +/** + * This is the abstract class for a Display in LWJGL. LWJGL displays have some + * peculiar characteristics: + * + * - the display may be closeable by the user or operating system, and may be minimized + * by the user or operating system + * - only one display may ever be open at once + * - the operating system may or may not be able to do fullscreen or windowed displays. + * + * @author foo + */ + +import org.lwjgl.BufferUtils; +import org.lwjgl.LWJGLException; +import org.lwjgl.LWJGLUtil; +import org.lwjgl.Sys; +import org.lwjgl.input.Controllers; +import org.lwjgl.input.Keyboard; +import org.lwjgl.input.Mouse; + +import java.awt.*; +import java.awt.event.ComponentAdapter; +import java.awt.event.ComponentEvent; +import java.awt.event.ComponentListener; +import java.nio.ByteBuffer; +import java.nio.FloatBuffer; +import java.security.AccessController; +import java.security.PrivilegedAction; +import java.util.Arrays; +import java.util.HashSet; + +public final class Display { + + private static final Thread shutdown_hook = new Thread() { + public void run() { + reset(); + } + }; + + /** The display implementor */ + private static final DisplayImplementation display_impl; + + /** The initial display mode */ + private static final DisplayMode initial_mode; + + /** The parent, if any */ + private static Canvas parent; + + /** The current display mode, if created */ + private static DisplayMode current_mode; + + /** Timer for sync() */ + private static long timeThen; + + /** X coordinate of the window */ + private static int x = -1; + + /** Cached window icons, for when Display is recreated */ + private static ByteBuffer[] cached_icons; + + /** + * Y coordinate of the window. Y in window coordinates is from the top of the display down, + * unlike GL, where it is typically at the bottom of the display. + */ + private static int y = -1; + + /** Title of the window (never null) */ + private static String title = "Game"; + + /** Fullscreen */ + private static boolean fullscreen; + + /** Swap interval */ + private static int swap_interval; + + /** A unique context object, so we can track different contexts between creates() and destroys() */ + private static PeerInfo peer_info; + private static Context context; + + /** The Drawable instance that tracks the current Display context */ + private final static Drawable drawable; + + private static boolean window_created = false; + + private static boolean parent_resized; + + /** Initial Background Color of Display */ + private static float r = 0, g = 0, b = 0; + + private static ComponentListener component_listener = new ComponentAdapter() { + public void componentResized(ComponentEvent e) { + synchronized ( GlobalLock.lock ) { + parent_resized = true; + } + } + }; + + static { + Sys.initialize(); + display_impl = createDisplayImplementation(); + try { + current_mode = initial_mode = display_impl.init(); + LWJGLUtil.log("Initial mode: " + initial_mode); + } catch (LWJGLException e) { + throw new RuntimeException(e); + } + drawable = new Drawable() { + public Context getContext() { + synchronized ( GlobalLock.lock ) { + return isCreated() ? context : null; + } + } + }; + } + + /** + * Fetch the Drawable from the Display. + * + * @return the Drawable corresponding to the Display context + */ + public static Drawable getDrawable() { + return drawable; + } + + private static DisplayImplementation createDisplayImplementation() { + switch ( LWJGLUtil.getPlatform() ) { + case LWJGLUtil.PLATFORM_LINUX: + return new LinuxDisplay(); + case LWJGLUtil.PLATFORM_WINDOWS: + return new WindowsDisplay(); + case LWJGLUtil.PLATFORM_MACOSX: + return new MacOSXDisplay(); + default: + throw new IllegalStateException("Unsupported platform"); + } + } + + /** Only constructed by ourselves */ + private Display() { + } + + /** + * Returns the entire list of possible fullscreen display modes as an array, in no + * particular order. Although best attempts to filter out invalid modes are done, any + * given mode is not guaranteed to be available nor is it guaranteed to be within the + * current monitor specs (this is especially a problem with the frequency parameter). + * Furthermore, it is not guaranteed that create() will detect an illegal display mode. + *

+ * The only certain way to check + * is to call create() and make sure it works. + * Only non-palette-indexed modes are returned (ie. bpp will be 16, 24, or 32). + * Only DisplayModes from this call can be used when the Display is in fullscreen + * mode. + * + * @return an array of all display modes the system reckons it can handle. + */ + public static DisplayMode[] getAvailableDisplayModes() throws LWJGLException { + synchronized ( GlobalLock.lock ) { + DisplayMode[] unfilteredModes = display_impl.getAvailableDisplayModes(); + + if ( unfilteredModes == null ) { + return new DisplayMode[0]; + } + + // We'll use a HashSet to filter out the duplicated modes + HashSet modes = new HashSet(unfilteredModes.length); + + modes.addAll(Arrays.asList(unfilteredModes)); + DisplayMode[] filteredModes = new DisplayMode[modes.size()]; + modes.toArray(filteredModes); + + LWJGLUtil.log("Removed " + (unfilteredModes.length - filteredModes.length) + " duplicate displaymodes"); + + return filteredModes; + } + } + + /** + * Return the initial desktop display mode. + * + * @return The desktop display mode + */ + public static DisplayMode getDesktopDisplayMode() { + return initial_mode; + } + + /** + * Return the current display mode, as set by setDisplayMode(). + * + * @return The current display mode + */ + public static DisplayMode getDisplayMode() { + return current_mode; + } + + /** + * Set the current display mode. If no OpenGL context has been created, the given mode will apply to + * the context when create() is called, and no immediate mode switching will happen. If there is a + * context already, it will be resized according to the given mode. If the context is also a + * fullscreen context, the mode will also be switched immediately. The native cursor position + * is also reset. + * + * @param mode The new display mode to set + * + * @throws LWJGLException if the display mode could not be set + */ + public static void setDisplayMode(DisplayMode mode) throws LWJGLException { + synchronized (GlobalLock.lock) { + if (mode == null) + throw new NullPointerException("mode must be non-null"); + boolean was_fullscreen = isFullscreen(); + current_mode = mode; + if (isCreated()) { + destroyWindow(); + // If mode is not fullscreen capable, make sure we are in windowed mode + try { + if (was_fullscreen && !isFullscreen()) + display_impl.resetDisplayMode(); + else if (isFullscreen()) + switchDisplayMode(); + createWindow(); + makeCurrentAndSetSwapInterval(); + } catch (LWJGLException e) { + destroyContext(); + destroyPeerInfo(); + display_impl.resetDisplayMode(); + throw e; + } + } + } + } + + private static DisplayMode getEffectiveMode() { + return !isFullscreen() && parent != null ? new DisplayMode(parent.getWidth(), parent.getHeight()) : current_mode; + } + + private static int getWindowX() { + if (!isFullscreen() && parent == null) { + // if no display location set, center window + if (x == -1) { + return Math.max(0, (initial_mode.getWidth() - current_mode.getWidth()) / 2); + } else { + return x; + } + } else { + return 0; + } + } + + private static int getWindowY() { + if (!isFullscreen() && parent == null) { + // if no display location set, center window + if ( y == -1 ) { + return Math.max(0, (initial_mode.getHeight() - current_mode.getHeight()) / 2); + } else { + return y; + } + } else { + return 0; + } + } + + /** + * Create the native window peer from the given mode and fullscreen flag. + * A native context must exist, and it will be attached to the window. + */ + private static void createWindow() throws LWJGLException { + if ( window_created ) { + return; + } + Canvas tmp_parent = isFullscreen() ? null : parent; + if ( tmp_parent != null && !tmp_parent.isDisplayable() ) // Only a best effort check, since the parent can turn undisplayable hereafter + throw new LWJGLException("Parent.isDisplayable() must be true"); + if ( tmp_parent != null ) { + tmp_parent.addComponentListener(component_listener); + } + DisplayMode mode = getEffectiveMode(); + display_impl.createWindow(mode, tmp_parent, getWindowX(), getWindowY()); + window_created = true; + + setTitle(title); + initControls(); + + // set cached window icon if exists + if ( cached_icons != null ) { + setIcon(cached_icons); + } else { + setIcon(new ByteBuffer[] { LWJGLUtil.LWJGLIcon32x32, LWJGLUtil.LWJGLIcon16x16 }); + } + } + + private static void releaseDrawable() { + try { + if ( context != null && context.isCurrent() ) { + Context.releaseCurrentContext(); + context.releaseDrawable(); + } + } catch (LWJGLException e) { + LWJGLUtil.log("Exception occurred while trying to release context: " + e); + } + } + + private static void destroyWindow() { + if ( !window_created ) { + return; + } + if ( parent != null ) { + parent.removeComponentListener(component_listener); + } + releaseDrawable(); + + // Automatically destroy keyboard & mouse + if ( Mouse.isCreated() ) { + Mouse.destroy(); + } + if ( Keyboard.isCreated() ) { + Keyboard.destroy(); + } + display_impl.destroyWindow(); + window_created = false; + } + + private static void switchDisplayMode() throws LWJGLException { + if ( !current_mode.isFullscreenCapable() ) { + throw new IllegalStateException("Only modes acquired from getAvailableDisplayModes() can be used for fullscreen display"); + } + display_impl.switchDisplayMode(current_mode); + } + + /** + * Set the display configuration to the specified gamma, brightness and contrast. + * The configuration changes will be reset when destroy() is called. + * + * @param gamma The gamma value + * @param brightness The brightness value between -1.0 and 1.0, inclusive + * @param contrast The contrast, larger than 0.0. + */ + public static void setDisplayConfiguration(float gamma, float brightness, float contrast) throws LWJGLException { + synchronized ( GlobalLock.lock ) { + if ( !isCreated() ) { + throw new LWJGLException("Display not yet created."); + } + if ( brightness < -1.0f || brightness > 1.0f ) + throw new IllegalArgumentException("Invalid brightness value"); + if ( contrast < 0.0f ) + throw new IllegalArgumentException("Invalid contrast value"); + int rampSize = display_impl.getGammaRampLength(); + if ( rampSize == 0 ) { + throw new LWJGLException("Display configuration not supported"); + } + FloatBuffer gammaRamp = BufferUtils.createFloatBuffer(rampSize); + for ( int i = 0; i < rampSize; i++ ) { + float intensity = (float)i / (rampSize - 1); + // apply gamma + float rampEntry = (float)java.lang.Math.pow(intensity, gamma); + // apply brightness + rampEntry += brightness; + // apply contrast + rampEntry = (rampEntry - 0.5f) * contrast + 0.5f; + // Clamp entry to [0, 1] + if ( rampEntry > 1.0f ) + rampEntry = 1.0f; + else if ( rampEntry < 0.0f ) + rampEntry = 0.0f; + gammaRamp.put(i, rampEntry); + } + display_impl.setGammaRamp(gammaRamp); + LWJGLUtil.log("Gamma set, gamma = " + gamma + ", brightness = " + brightness + ", contrast = " + contrast); + } + } + + private static long timeLate; + + /** + * Best sync method that works reliably. + * + * @param fps The desired frame rate, in frames per second + */ + public static void sync(int fps) { + long timeNow; + long gapTo; + long savedTimeLate; + synchronized ( GlobalLock.lock ) { + gapTo = Sys.getTimerResolution() / fps + timeThen; + timeNow = Sys.getTime(); + savedTimeLate = timeLate; + } + + while ( gapTo > timeNow + savedTimeLate ) { + try { + Thread.sleep(1); + } catch (InterruptedException e) { + } + timeNow = Sys.getTime(); + } + + synchronized ( GlobalLock.lock ) { + if ( gapTo < timeNow ) + timeLate = timeNow - gapTo; + else + timeLate = 0; + + timeThen = timeNow; + } + } + + /** @return the title of the window */ + public static String getTitle() { + synchronized ( GlobalLock.lock ) { + return title; + } + } + + /** Return the last parent set with setParent(). */ + public static Canvas getParent() { + synchronized ( GlobalLock.lock ) { + return parent; + } + } + + /** + * Set the parent of the Display. If parent is null, the Display will appear as a top level window. + * If parent is not null, the Display is made a child of the parent. A parent's isDisplayable() must be true when + * setParent() is called and remain true until setParent() is called again with + * null or a different parent. This generally means that the parent component must remain added to it's parent container.

+ * It is not advisable to call this method from an AWT thread, since the context will be made current on the thread + * and it is difficult to predict which AWT thread will process any given AWT event.

+ * While the Display is in fullscreen mode, the current parent will be ignored. Additionally, when a non null parent is specified, + * the Dispaly will inherit the size of the parent, disregarding the currently set display mode.

+ */ + public static void setParent(Canvas parent) throws LWJGLException { + synchronized ( GlobalLock.lock ) { + if (Display.parent != parent) { + Display.parent = parent; + if ( !isCreated() ) + return; + destroyWindow(); + try { + if (isFullscreen()) { + switchDisplayMode(); + } else { + display_impl.resetDisplayMode(); + } + createWindow(); + makeCurrentAndSetSwapInterval(); + } catch (LWJGLException e) { + destroyContext(); + destroyPeerInfo(); + display_impl.resetDisplayMode(); + throw e; + } + } + } + } + + /** + * Set the fullscreen mode of the context. If no context has been created through create(), + * the mode will apply when create() is called. If fullscreen is true, the context will become + * a fullscreen context and the display mode is switched to the mode given by getDisplayMode(). If + * fullscreen is false, the context will become a windowed context with the dimensions given in the + * mode returned by getDisplayMode(). The native cursor position is also reset. + * + * @param fullscreen Specify the fullscreen mode of the context. + * + * @throws LWJGLException If fullscreen is true, and the current DisplayMode instance is not + * from getAvailableDisplayModes() or if the mode switch fails. + */ + public static void setFullscreen(boolean fullscreen) throws LWJGLException { + setDisplayModeAndFullscreenInternal(fullscreen, current_mode); + } + + /** + * Set the mode of the context. If no context has been created through create(), + * the mode will apply when create() is called. If mode.isFullscreenCapable() is true, the context will become + * a fullscreen context and the display mode is switched to the mode given by getDisplayMode(). If + * mode.isFullscreenCapable() is false, the context will become a windowed context with the dimensions given in the + * mode returned by getDisplayMode(). The native cursor position is also reset. + * + * @param mode The new display mode to set. Must be non-null. + * + * @throws LWJGLException If the mode switch fails. + */ + public static void setDisplayModeAndFullscreen(DisplayMode mode) throws LWJGLException { + setDisplayModeAndFullscreenInternal(mode.isFullscreenCapable(), mode); + } + + private static void setDisplayModeAndFullscreenInternal(boolean fullscreen, DisplayMode mode) throws LWJGLException { + synchronized ( GlobalLock.lock ) { + if (mode == null) + throw new NullPointerException("mode must be non-null"); + DisplayMode old_mode = current_mode; + current_mode = mode; + boolean was_fullscreen = isFullscreen(); + Display.fullscreen = fullscreen; + if (was_fullscreen != isFullscreen() || !mode.equals(old_mode)) { + if (!isCreated()) + return; + destroyWindow(); + try { + if (isFullscreen()) { + switchDisplayMode(); + } else { + display_impl.resetDisplayMode(); + } + createWindow(); + makeCurrentAndSetSwapInterval(); + } catch (LWJGLException e) { + destroyContext(); + destroyPeerInfo(); + display_impl.resetDisplayMode(); + throw e; + } + } + } + } + + /** @return whether the Display is in fullscreen mode */ + public static boolean isFullscreen() { + synchronized (GlobalLock.lock) { + return fullscreen && current_mode.isFullscreenCapable(); + } + } + + /** + * Set the title of the window. This may be ignored by the underlying OS. + * + * @param newTitle The new window title + */ + public static void setTitle(String newTitle) { + synchronized ( GlobalLock.lock ) { + if ( newTitle == null ) { + newTitle = ""; + } + title = newTitle; + if ( isCreated() ) + display_impl.setTitle(title); + } + } + + /** @return true if the user or operating system has asked the window to close */ + public static boolean isCloseRequested() { + synchronized ( GlobalLock.lock ) { + if ( !isCreated() ) + throw new IllegalStateException("Cannot determine close requested state of uncreated window"); + return display_impl.isCloseRequested(); + } + } + + /** @return true if the window is visible, false if not */ + public static boolean isVisible() { + synchronized ( GlobalLock.lock ) { + if ( !isCreated() ) + throw new IllegalStateException("Cannot determine minimized state of uncreated window"); + return display_impl.isVisible(); + } + } + + /** @return true if window is active, that is, the foreground display of the operating system. */ + public static boolean isActive() { + synchronized ( GlobalLock.lock ) { + if ( !isCreated() ) + throw new IllegalStateException("Cannot determine focused state of uncreated window"); + return display_impl.isActive(); + } + } + + /** + * Determine if the window's contents have been damaged by external events. + * If you are writing a straightforward game rendering loop and simply paint + * every frame regardless, you can ignore this flag altogether. If you are + * trying to be kind to other processes you can check this flag and only + * redraw when it returns true. The flag is cleared when update() or isDirty() is called. + * + * @return true if the window has been damaged by external changes + * and needs to repaint itself + */ + public static boolean isDirty() { + synchronized ( GlobalLock.lock ) { + if ( !isCreated() ) + throw new IllegalStateException("Cannot determine dirty state of uncreated window"); + return display_impl.isDirty(); + } + } + + /** + * Process operating system events. Call this to update the Display's state and to receive new + * input device events. This method is called from update(), so it is not necessary to call + * this method if update() is called periodically. + */ + public static void processMessages() { + synchronized ( GlobalLock.lock ) { + if ( !isCreated() ) + throw new IllegalStateException("Display not created"); + + display_impl.update(); + } + pollDevices(); + } + + /** + * Swap the display buffers. This method is called from update(), and should normally not be called by + * the application. + * + * @throws OpenGLException if an OpenGL error has occured since the last call to GL11.glGetError() + */ + public static void swapBuffers() throws LWJGLException { + synchronized ( GlobalLock.lock ) { + if ( !isCreated() ) + throw new IllegalStateException("Display not created"); + + if ( LWJGLUtil.DEBUG ) + Util.checkGLError(); + Context.swapBuffers(); + } + } + + /** + * Update the window. If the window is visible clears + * the dirty flag and calls swapBuffers() and finally + * polls the input devices. + * + */ + public static void update() { + update(true); + } + + /** + * Update the window. If the window is visible clears + * the dirty flag and calls swapBuffers() and finally + * polls the input devices if processMessages is true. + * + * @param processMessages Poll input devices if true + */ + public static void update(boolean processMessages) { + synchronized ( GlobalLock.lock ) { + if ( !isCreated() ) + throw new IllegalStateException("Display not created"); + + // We paint only when the window is visible or dirty + if ( display_impl.isVisible() || display_impl.isDirty() ) { + try { + swapBuffers(); + } catch (LWJGLException e) { + throw new RuntimeException(e); + } + } + + if ( parent_resized ) { + reshape(); + parent_resized = false; + } + + if ( processMessages ) + processMessages(); + } + } + + static void pollDevices() { + // Poll the input devices while we're here + if ( Mouse.isCreated() ) { + Mouse.poll(); + Mouse.updateCursor(); + } + + if ( Keyboard.isCreated() ) { + Keyboard.poll(); + } + + if ( Controllers.isCreated() ) { + Controllers.poll(); + } + } + + /** + * Release the Display context. + * + * @throws LWJGLException If the context could not be released + */ + public static void releaseContext() throws LWJGLException { + synchronized ( GlobalLock.lock ) { + if ( !isCreated() ) + throw new IllegalStateException("Display is not created"); + if ( context.isCurrent() ) + Context.releaseCurrentContext(); + } + } + + /** + * Make the Display the current rendering context for GL calls. + * + * @throws LWJGLException If the context could not be made current + */ + public static void makeCurrent() throws LWJGLException { + synchronized ( GlobalLock.lock ) { + if ( !isCreated() ) + throw new IllegalStateException("Display is not created"); + context.makeCurrent(); + } + } + + private static void removeShutdownHook() { + AccessController.doPrivileged(new PrivilegedAction() { + public Object run() { + Runtime.getRuntime().removeShutdownHook(shutdown_hook); + return null; + } + }); + } + + private static void registerShutdownHook() { + AccessController.doPrivileged(new PrivilegedAction() { + public Object run() { + Runtime.getRuntime().addShutdownHook(shutdown_hook); + return null; + } + }); + } + + /** + * Create the OpenGL context. If isFullscreen() is true or if windowed + * context are not supported on the platform, the display mode will be switched to the mode returned by + * getDisplayMode(), and a fullscreen context will be created. If isFullscreen() is false, a windowed context + * will be created with the dimensions given in the mode returned by getDisplayMode(). If a context can't be + * created with the given parameters, a LWJGLException will be thrown. + *

+ *

The window created will be set up in orthographic 2D projection, with 1:1 pixel ratio with GL coordinates. + * + * @throws LWJGLException + */ + public static void create() throws LWJGLException { + synchronized ( GlobalLock.lock ) { + create(new PixelFormat()); + } + } + + /** + * Create the OpenGL context with the given minimum parameters. If isFullscreen() is true or if windowed + * context are not supported on the platform, the display mode will be switched to the mode returned by + * getDisplayMode(), and a fullscreen context will be created. If isFullscreen() is false, a windowed context + * will be created with the dimensions given in the mode returned by getDisplayMode(). If a context can't be + * created with the given parameters, a LWJGLException will be thrown. + *

+ *

The window created will be set up in orthographic 2D projection, with 1:1 pixel ratio with GL coordinates. + * + * @param pixel_format Describes the minimum specifications the context must fulfill. + * + * @throws LWJGLException + */ + public static void create(PixelFormat pixel_format) throws LWJGLException { + synchronized ( GlobalLock.lock ) { + create(pixel_format, null, null); + } + } + + /** + * Create the OpenGL context with the given minimum parameters. If isFullscreen() is true or if windowed + * context are not supported on the platform, the display mode will be switched to the mode returned by + * getDisplayMode(), and a fullscreen context will be created. If isFullscreen() is false, a windowed context + * will be created with the dimensions given in the mode returned by getDisplayMode(). If a context can't be + * created with the given parameters, a LWJGLException will be thrown. + *

+ *

The window created will be set up in orthographic 2D projection, with 1:1 pixel ratio with GL coordinates. + * + * @param pixel_format Describes the minimum specifications the context must fulfill. + * @param shared_drawable The Drawable to share context with. (optional, may be null) + * + * @throws LWJGLException + */ + public static void create(PixelFormat pixel_format, Drawable shared_drawable) throws LWJGLException { + synchronized ( GlobalLock.lock ) { + create(pixel_format, shared_drawable, null); + } + } + + /** + * Create the OpenGL context with the given minimum parameters. If isFullscreen() is true or if windowed + * context are not supported on the platform, the display mode will be switched to the mode returned by + * getDisplayMode(), and a fullscreen context will be created. If isFullscreen() is false, a windowed context + * will be created with the dimensions given in the mode returned by getDisplayMode(). If a context can't be + * created with the given parameters, a LWJGLException will be thrown. + *

+ *

The window created will be set up in orthographic 2D projection, with 1:1 pixel ratio with GL coordinates. + * + * @param pixel_format Describes the minimum specifications the context must fulfill. + * @param attribs The ContextAttribs to use when creating the context. (optional, may be null) + * + * @throws LWJGLException + */ + public static void create(PixelFormat pixel_format, ContextAttribs attribs) throws LWJGLException { + synchronized ( GlobalLock.lock ) { + create(pixel_format, null, attribs); + } + } + + /** + * Create the OpenGL context with the given minimum parameters. If isFullscreen() is true or if windowed + * context are not supported on the platform, the display mode will be switched to the mode returned by + * getDisplayMode(), and a fullscreen context will be created. If isFullscreen() is false, a windowed context + * will be created with the dimensions given in the mode returned by getDisplayMode(). If a context can't be + * created with the given parameters, a LWJGLException will be thrown. + *

+ *

The window created will be set up in orthographic 2D projection, with 1:1 pixel ratio with GL coordinates. + * + * @param pixel_format Describes the minimum specifications the context must fulfill. + * @param shared_drawable The Drawable to share context with. (optional, may be null) + * @param attribs The ContextAttribs to use when creating the context. (optional, may be null) + * + * @throws LWJGLException + */ + public static void create(PixelFormat pixel_format, Drawable shared_drawable, ContextAttribs attribs) throws LWJGLException { + synchronized ( GlobalLock.lock ) { + if ( isCreated() ) + throw new IllegalStateException("Only one LWJGL context may be instantiated at any one time."); + if ( pixel_format == null ) + throw new NullPointerException("pixel_format cannot be null"); + removeShutdownHook(); + registerShutdownHook(); + if (isFullscreen()) + switchDisplayMode(); + try { + peer_info = display_impl.createPeerInfo(pixel_format); + try { + createWindow(); + try { + context = new Context(peer_info, attribs, shared_drawable != null ? shared_drawable.getContext() : null); + try { + makeCurrentAndSetSwapInterval(); + initContext(); + } catch (LWJGLException e) { + destroyContext(); + throw e; + } + } catch (LWJGLException e) { + destroyWindow(); + throw e; + } + } catch (LWJGLException e) { + destroyPeerInfo(); + throw e; + } + } catch (LWJGLException e) { + display_impl.resetDisplayMode(); + throw e; + } + } + } + + /** + * Set the initial color of the Display. This method is called before the Display is created and will set the + * background color to the one specified in this method. + * + * @param red - color value between 0 - 1 + * @param green - color value between 0 - 1 + * @param blue - color value between 0 - 1 + */ + public static void setInitialBackground(float red, float green, float blue) { + r = red; + g = green; + b = blue; + } + + private static void makeCurrentAndSetSwapInterval() throws LWJGLException { + makeCurrent(); + try { + Util.checkGLError(); + } catch (OpenGLException e) { + LWJGLUtil.log("OpenGL error during context creation: " + e.getMessage()); + } + setSwapInterval(swap_interval); + } + + private static void initContext() { + // set background clear color + GL11.glClearColor(r, g, b, 1.0f); + // Clear window to avoid the desktop "showing through" + GL11.glClear(GL11.GL_COLOR_BUFFER_BIT); + update(); + } + + static DisplayImplementation getImplementation() { + return display_impl; + } + + /** Gets a boolean property as a privileged action. */ + static boolean getPrivilegedBoolean(final String property_name) { + Boolean value = (Boolean)AccessController.doPrivileged(new PrivilegedAction() { + public Object run() { + return new Boolean(Boolean.getBoolean(property_name)); + } + }); + return value.booleanValue(); + } + + private static void initControls() { + // Automatically create mouse, keyboard and controller + if ( !getPrivilegedBoolean("org.lwjgl.opengl.Display.noinput") ) { + if ( !Mouse.isCreated() && !getPrivilegedBoolean("org.lwjgl.opengl.Display.nomouse") ) { + try { + Mouse.create(); + } catch (LWJGLException e) { + if ( LWJGLUtil.DEBUG ) { + e.printStackTrace(System.err); + } else { + LWJGLUtil.log("Failed to create Mouse: " + e); + } + } + } + if ( !Keyboard.isCreated() && !getPrivilegedBoolean("org.lwjgl.opengl.Display.nokeyboard") ) { + try { + Keyboard.create(); + } catch (LWJGLException e) { + if ( LWJGLUtil.DEBUG ) { + e.printStackTrace(System.err); + } else { + LWJGLUtil.log("Failed to create Keyboard: " + e); + } + } + } + } + } + + /** + * Destroy the Display. After this call, there will be no current GL rendering context, + * regardless of whether the Display was the current rendering context. + */ + public static void destroy() { + synchronized ( GlobalLock.lock ) { + if ( !isCreated() ) { + return; + } + + releaseDrawable(); + destroyContext(); + destroyWindow(); + destroyPeerInfo(); + x = y = -1; + cached_icons = null; + reset(); + removeShutdownHook(); + } + } + + private static void destroyPeerInfo() { + peer_info.destroy(); + peer_info = null; + } + + private static void destroyContext() { + try { + context.forceDestroy(); + } catch (LWJGLException e) { + throw new RuntimeException(e); + } finally { + context = null; + } + } + + /* + * Reset display mode if fullscreen. This method is also called from the shutdown hook added + * in the static constructor + */ + private static void reset() { + display_impl.resetDisplayMode(); + current_mode = initial_mode; + } + + /** @return true if the window's native peer has been created */ + public static boolean isCreated() { + synchronized ( GlobalLock.lock ) { + return window_created; + } + } + + /** + * Set the buffer swap interval. This call is a best-attempt at changing + * the monitor swap interval, which is the minimum periodicity of color buffer swaps, + * measured in video frame periods, and is not guaranteed to be successful. + *

+ * A video frame period is the time required to display a full frame of video data. + * + * @param value The swap interval in frames, 0 to disable + */ + public static void setSwapInterval(int value) { + synchronized ( GlobalLock.lock ) { + swap_interval = value; + if ( isCreated() ) + Context.setSwapInterval(swap_interval); + } + } + + /** + * Enable or disable vertical monitor synchronization. This call is a best-attempt at changing + * the vertical refresh synchronization of the monitor, and is not guaranteed to be successful. + * + * @param sync true to synchronize; false to ignore synchronization + */ + public static void setVSyncEnabled(boolean sync) { + synchronized ( GlobalLock.lock ) { + setSwapInterval(sync ? 1 : 0); + } + } + + /** + * Set the window's location. This is a no-op on fullscreen windows or when getParent() != null. + * The window is clamped to remain entirely on the screen. If you attempt + * to position the window such that it would extend off the screen, the window + * is simply placed as close to the edge as possible. + *
noteIf no location has been specified (or x == y == -1) the window will be centered + * + * @param new_x The new window location on the x axis + * @param new_y The new window location on the y axis + */ + public static void setLocation(int new_x, int new_y) { + synchronized ( GlobalLock.lock ) { + // cache position + x = new_x; + y = new_y; + + // offset if already created + if (isCreated() && !isFullscreen()) { + reshape(); + } + } + } + + private static void reshape() { + DisplayMode mode = getEffectiveMode(); + display_impl.reshape(getWindowX(), getWindowY(), mode.getWidth(), mode.getHeight()); + } + + /** + * Get the driver adapter string. This is a unique string describing the actual card's hardware, eg. "Geforce2", "PS2", + * "Radeon9700". If the adapter cannot be determined, this function returns null. + * + * @return a String + */ + public static String getAdapter() { + synchronized ( GlobalLock.lock ) { + return display_impl.getAdapter(); + } + } + + /** + * Get the driver version. This is a vendor/adapter specific version string. If the version cannot be determined, + * this function returns null. + * + * @return a String + */ + public static String getVersion() { + synchronized ( GlobalLock.lock ) { + return display_impl.getVersion(); + } + } + + /** + * Sets one or more icons for the Display. + *

    + *
  • On Windows you should supply at least one 16x16 icon and one 32x32.
  • + *
  • Linux (and similar platforms) expect one 32x32 icon.
  • + *
  • Mac OS X should be supplied one 128x128 icon
  • + *
+ * The implementation will use the supplied ByteBuffers with image data in RGBA and perform any conversions nescesarry for the specific platform. + *

+ * NOTE: The display will make a deep copy of the supplied byte buffer array, for the purpose + * of recreating the icons when you go back and forth fullscreen mode. You therefore only need to + * set the icon once per instance. + * + * @param icons Array of icons in RGBA mode. Pass the icons in order of preference. + * + * @return number of icons used, or 0 if display hasn't been created + */ + public static int setIcon(ByteBuffer[] icons) { + synchronized ( GlobalLock.lock ) { + // make deep copy so we dont rely on the supplied buffers later on + // don't recache! + if ( cached_icons != icons ) { + cached_icons = new ByteBuffer[icons.length]; + for ( int i = 0; i < icons.length; i++ ) { + cached_icons[i] = BufferUtils.createByteBuffer(icons[i].capacity()); + int old_position = icons[i].position(); + cached_icons[i].put(icons[i]); + icons[i].position(old_position); + cached_icons[i].flip(); + } + } + + if ( Display.isCreated() && parent == null ) { + return display_impl.setIcon(cached_icons); + } else { + return 0; + } + } + } +} diff --git a/src/java/org/lwjgl/opengl/DisplayImplementation.java b/src/java/org/lwjgl/opengl/DisplayImplementation.java new file mode 100644 index 0000000..2c1c6f0 --- /dev/null +++ b/src/java/org/lwjgl/opengl/DisplayImplementation.java @@ -0,0 +1,162 @@ +/* + * 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; + +/** + * This is the Display implementation interface. Display delegates + * to implementors of this interface. There is one DisplayImplementation + * for each supported platform. + * @author elias_naur + */ + +import java.nio.ByteBuffer; +import java.nio.FloatBuffer; +import java.nio.IntBuffer; +import java.awt.Canvas; + +import org.lwjgl.LWJGLException; + +interface DisplayImplementation extends InputImplementation { + + void createWindow(DisplayMode mode, Canvas parent, int x, int y) throws LWJGLException; + + void destroyWindow(); + + void switchDisplayMode(DisplayMode mode) throws LWJGLException; + + /** + * Reset the display mode to whatever it was when LWJGL was initialized. + * Fails silently. + */ + void resetDisplayMode(); + + /** + * Return the length of the gamma ramp arrays. Returns 0 if gamma settings are + * unsupported. + * + * @return the length of each gamma ramp array, or 0 if gamma settings are unsupported. + */ + int getGammaRampLength(); + + /** + * Method to set the gamma ramp. + */ + void setGammaRamp(FloatBuffer gammaRamp) throws LWJGLException; + + /** + * Get the driver adapter string. This is a unique string describing the actual card's hardware, eg. "Geforce2", "PS2", + * "Radeon9700". If the adapter cannot be determined, this function returns null. + * @return a String + */ + String getAdapter(); + + /** + * Get the driver version. This is a vendor/adapter specific version string. If the version cannot be determined, + * this function returns null. + * @return a String + */ + String getVersion(); + + /** + * Initialize and return the current display mode. + */ + DisplayMode init() throws LWJGLException; + + /** + * Implementation of setTitle(). This will read the window's title member + * and stash it in the native title of the window. + */ + void setTitle(String title); + + boolean isCloseRequested(); + + boolean isVisible(); + boolean isActive(); + + boolean isDirty(); + + /** + * Create the native PeerInfo. + * @throws LWJGLException + */ + PeerInfo createPeerInfo(PixelFormat pixel_format) throws LWJGLException; + +// void destroyPeerInfo(); + + /** + * Updates the windows internal state. This must be called at least once per video frame + * to handle window close requests, moves, paints, etc. + */ + void update(); + + void reshape(int x, int y, int width, int height); + + /** + * Method for getting displaymodes + */ + DisplayMode[] getAvailableDisplayModes() throws LWJGLException; + + /* Pbuffer */ + int getPbufferCapabilities(); + + /** + * Method to test for buffer integrity + */ + boolean isBufferLost(PeerInfo handle); + + /** + * Method to create a Pbuffer + */ + PeerInfo createPbuffer(int width, int height, PixelFormat pixel_format, + IntBuffer pixelFormatCaps, + IntBuffer pBufferAttribs) throws LWJGLException; + + void setPbufferAttrib(PeerInfo handle, int attrib, int value); + + void bindTexImageToPbuffer(PeerInfo handle, int buffer); + + void releaseTexImageFromPbuffer(PeerInfo handle, int buffer); + + /** + * Sets one or more icons for the Display. + *

    + *
  • On Windows you should supply at least one 16x16 icon and one 32x32.
  • + *
  • Linux (and similar platforms) expect one 32x32 icon.
  • + *
  • Mac OS X should be supplied one 128x128 icon
  • + *
+ * The implementation will use the supplied ByteBuffers with image data in RGBA and perform any conversions nescesarry for the specific platform. + * + * @param icons Array of icons in RGBA mode + * @return number of icons used. + */ + int setIcon(ByteBuffer[] icons); +} diff --git a/src/java/org/lwjgl/opengl/DisplayMode.java b/src/java/org/lwjgl/opengl/DisplayMode.java new file mode 100644 index 0000000..ca59acc --- /dev/null +++ b/src/java/org/lwjgl/opengl/DisplayMode.java @@ -0,0 +1,142 @@ +/* + * 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; + +/** + * + * This class encapsulates the properties for a given display mode. + * This class is not instantiable, and is aquired from the Display. + * getAvailableDisplayModes() method. + * + * @author cix_foo + * @version $Revision: 3171 $ + * $Id: DisplayMode.java 3171 2008-12-28 17:50:08Z elias_naur $ + */ + +public final class DisplayMode { + + /** properties of the display mode */ + private final int width, height, bpp, freq; + /** If true, this instance can be used for fullscreen modes */ + private final boolean fullscreen; + + /** + * Construct a display mode. DisplayModes constructed through the + * public constructor can only be used to specify the dimensions of + * the Display in windowed mode. To get the available DisplayModes for + * fullscreen modes, use Display.getAvailableDisplayModes(). + * + * @param width The Display width. + * @param height The Display height. + * @see Display + */ + public DisplayMode(int width, int height) { + this(width, height, 0, 0, false); + } + + DisplayMode(int width, int height, int bpp, int freq) { + this(width, height, bpp, freq, true); + } + + private DisplayMode(int width, int height, int bpp, int freq, boolean fullscreen) { + this.width = width; + this.height = height; + this.bpp = bpp; + this.freq = freq; + this.fullscreen = fullscreen; + } + + /** True iff this instance can be used for fullscreen modes */ + public boolean isFullscreenCapable() { + return fullscreen; + } + + public int getWidth() { + return width; + } + + public int getHeight() { + return height; + } + + public int getBitsPerPixel() { + return bpp; + } + + public int getFrequency() { + return freq; + } + + /** + * Tests for DisplayMode equality + * + * @see java.lang.Object#equals(Object) + */ + public boolean equals(Object obj) { + if (obj == null || !(obj instanceof DisplayMode)) { + return false; + } + + DisplayMode dm = (DisplayMode) obj; + return dm.width == width + && dm.height == height + && dm.bpp == bpp + && dm.freq == freq; + } + + /** + * Retrieves the hashcode for this object + * + * @see java.lang.Object#hashCode() + */ + public int hashCode() { + return width ^ height ^ freq ^ bpp; + } + + /** + * Retrieves a String representation of this DisplayMode + * + * @see java.lang.Object#toString() + */ + public String toString() { + StringBuffer sb = new StringBuffer(32); + sb.append(width); + sb.append(" x "); + sb.append(height); + sb.append(" x "); + sb.append(bpp); + sb.append(" @"); + sb.append(freq); + sb.append("Hz"); + return sb.toString(); + } +} diff --git a/src/java/org/lwjgl/opengl/Drawable.java b/src/java/org/lwjgl/opengl/Drawable.java new file mode 100644 index 0000000..a4681bb --- /dev/null +++ b/src/java/org/lwjgl/opengl/Drawable.java @@ -0,0 +1,43 @@ +/* + * 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; + +/** + * The Drawable interface describes an OpenGL drawable with an associated + * Context. + * + * @author elias_naur + */ + +public interface Drawable { + Context getContext(); +} diff --git a/src/java/org/lwjgl/opengl/EventQueue.java b/src/java/org/lwjgl/opengl/EventQueue.java new file mode 100644 index 0000000..60ec1f2 --- /dev/null +++ b/src/java/org/lwjgl/opengl/EventQueue.java @@ -0,0 +1,83 @@ +/* + * 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; + +/** + * A java implementation of a LWJGL compatible event queue. + * @author elias_naur + */ + +import java.nio.ByteBuffer; + +class EventQueue { + private static final int QUEUE_SIZE = 200; + + private final int event_size; + + private final ByteBuffer queue; + + protected EventQueue(int event_size) { + this.event_size = event_size; + this.queue = ByteBuffer.allocate(QUEUE_SIZE*event_size); + } + + protected synchronized void clearEvents() { + queue.clear(); + } + + /** + * Copy available events into the specified buffer. + */ + public synchronized void copyEvents(ByteBuffer dest) { + queue.flip(); + int old_limit = queue.limit(); + if (dest.remaining() < queue.remaining()) + queue.limit(dest.remaining() + queue.position()); + dest.put(queue); + queue.limit(old_limit); + queue.compact(); + } + + /** + * Put an event into the queue. + * @return true if the event fitted into the queue, false otherwise + */ + public synchronized boolean putEvent(ByteBuffer event) { + if (event.remaining() != event_size) + throw new IllegalArgumentException("Internal error: event size " + event_size + " does not equal the given event size " + event.remaining()); + if (queue.remaining() >= event.remaining()) { + queue.put(event); + return true; + } else + return false; + } +} diff --git a/src/java/org/lwjgl/opengl/GLChecks.java b/src/java/org/lwjgl/opengl/GLChecks.java new file mode 100644 index 0000000..df51ee5 --- /dev/null +++ b/src/java/org/lwjgl/opengl/GLChecks.java @@ -0,0 +1,256 @@ +/* + * 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; + +import java.nio.Buffer; +import java.nio.IntBuffer; + +import org.lwjgl.BufferUtils; + +/** + * A class to check buffer boundaries in GL methods. Many GL + * methods read data from the GL into a native Buffer at its current position. 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. Therefore in those methods where GL reads data back into a buffer, we will call a bounds check method from this class + * to ensure that there is sufficient space in the buffer. + *

+ * Thrown by the debug build library of the LWJGL if any OpenGL operation causes an error. + * + * @author cix_foo + * @version $Revision: 3279 $ + * $Id: GLChecks.java 3279 2010-03-11 21:06:49Z spasi $ + */ +class GLChecks { + + /** Static methods only! */ + private GLChecks() { + } + + static References getReferences(ContextCapabilities caps) { + return StateTracker.getReferencesStack(caps).getReferences(); + } + + static int getBufferObjectSize(ContextCapabilities caps, int buffer_enum) { + IntBuffer scratch_buffer = caps.scratch_int_buffer; + GL15.glGetBufferParameter(buffer_enum, GL15.GL_BUFFER_SIZE, scratch_buffer); + return scratch_buffer.get(0); + } + + static int getBufferObjectSizeARB(ContextCapabilities caps, int buffer_enum) { + IntBuffer scratch_buffer = caps.scratch_int_buffer; + ARBBufferObject.glGetBufferParameterARB(buffer_enum, ARBBufferObject.GL_BUFFER_SIZE_ARB, scratch_buffer); + return scratch_buffer.get(0); + } + + static int getBufferObjectSizeATI(ContextCapabilities caps, int buffer) { + IntBuffer scratch_buffer = caps.scratch_int_buffer; + ATIVertexArrayObject.glGetObjectBufferATI(buffer, ATIVertexArrayObject.GL_OBJECT_BUFFER_SIZE_ATI, scratch_buffer); + return scratch_buffer.get(0); + } + + static int getNamedBufferObjectSize(ContextCapabilities caps, int buffer) { + IntBuffer scratch_buffer = caps.scratch_int_buffer; + EXTDirectStateAccess.glGetNamedBufferParameterEXT(buffer, GL15.GL_BUFFER_SIZE, scratch_buffer); + return scratch_buffer.get(0); + } + + private static boolean checkBufferObject(ContextCapabilities caps, int buffer_enum, boolean state) { + IntBuffer scratch_buffer = caps.scratch_int_buffer; + GL11.glGetInteger(buffer_enum, scratch_buffer); + boolean is_enabled = scratch_buffer.get(0) != 0; + return state == is_enabled; + } + + /** Helper method to ensure that array buffer objects are disabled. If they are enabled, we'll throw an OpenGLException */ + static void ensureArrayVBOdisabled(ContextCapabilities caps) { + if(StateTracker.getReferencesStack(caps).getReferences().arrayBuffer != 0) + throw new OpenGLException("Cannot use Buffers when Array Buffer Object is enabled"); + } + + /** Helper method to ensure that array buffer objects are enabled. If they are disabled, we'll throw an OpenGLException */ + static void ensureArrayVBOenabled(ContextCapabilities caps) { + if(StateTracker.getReferencesStack(caps).getReferences().arrayBuffer == 0) + throw new OpenGLException("Cannot use offsets when Array Buffer Object is disabled"); + } + + /** Helper method to ensure that element array buffer objects are disabled. If they are enabled, we'll throw an OpenGLException */ + static void ensureElementVBOdisabled(ContextCapabilities caps) { + if(StateTracker.getReferencesStack(caps).getReferences().elementArrayBuffer != 0) + throw new OpenGLException("Cannot use Buffers when Element Array Buffer Object is enabled"); + } + + /** Helper method to ensure that element array buffer objects are enabled. If they are disabled, we'll throw an OpenGLException */ + static void ensureElementVBOenabled(ContextCapabilities caps) { + if(StateTracker.getReferencesStack(caps).getReferences().elementArrayBuffer == 0) + 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 ) + throw new OpenGLException("Cannot use Buffers when Pixel Pack Buffer Object is enabled"); + } + + /** Helper method to ensure that pixel pack buffer objects are enabled. If they are disabled, we'll throw an OpenGLException */ + static void ensurePackPBOenabled(ContextCapabilities caps) { + if ( StateTracker.getReferencesStack(caps).getReferences().pixelPackBuffer == 0 ) + throw new OpenGLException("Cannot use offsets when Pixel Pack Buffer Object is disabled"); + } + + /** Helper method to ensure that pixel unpack buffer objects are disabled. If they are enabled, we'll throw an OpenGLException */ + static void ensureUnpackPBOdisabled(ContextCapabilities caps) { + if ( StateTracker.getReferencesStack(caps).getReferences().pixelUnpackBuffer != 0 ) + throw new OpenGLException("Cannot use Buffers when Pixel Unpack Buffer Object is enabled"); + } + + /** Helper method to ensure that pixel unpack buffer objects are enabled. If they are disabled, we'll throw an OpenGLException */ + static void ensureUnpackPBOenabled(ContextCapabilities caps) { + if ( StateTracker.getReferencesStack(caps).getReferences().pixelUnpackBuffer == 0 ) + throw new OpenGLException("Cannot use offsets when Pixel Unpack Buffer Object is disabled"); + } + + /** + * Calculate the storage required for an image in elements + * + * @param format The format of the image (example: GL_RGBA) + * @param type The type of the image elements (example: GL_UNSIGNED_BYTE) + * @param width The width of the image + * @param height The height of the image (1 for 1D images) + * @param depth The depth of the image (1 for 2D images) + * + * @return the size, in elements, of the image + */ + static int calculateImageStorage(Buffer buffer, int format, int type, int width, int height, int depth) { + return calculateImageStorage(format, type, width, height, depth) >> BufferUtils.getElementSizeExponent(buffer); + } + + static int calculateTexImage1DStorage(Buffer buffer, int format, int type, int width) { + return calculateTexImage1DStorage(format, type, width) >> BufferUtils.getElementSizeExponent(buffer); + } + + static int calculateTexImage2DStorage(Buffer buffer, int format, int type, int width, int height) { + return calculateTexImage2DStorage(format, type, width, height) >> BufferUtils.getElementSizeExponent(buffer); + } + + static int calculateTexImage3DStorage(Buffer buffer, int format, int type, int width, int height, int depth) { + return calculateTexImage3DStorage(format, type, width, height, depth) >> BufferUtils.getElementSizeExponent(buffer); + } + + /** + * Calculate the storage required for an image in bytes. + * + * @param format The format of the image (example: GL_RGBA) + * @param type The type of the image elements (example: GL_UNSIGNED_BYTE) + * @param width The width of the image + * @param height The height of the image (1 for 1D images) + * @param depth The depth of the image (1 for 2D images) + * + * @return the size, in bytes, of the image + */ + private static int calculateImageStorage(int format, int type, int width, int height, int depth) { + return calculateBytesPerPixel(format, type) * width * height * depth; + } + + private static int calculateTexImage1DStorage(int format, int type, int width) { + return calculateBytesPerPixel(format, type) * width; + } + + private static int calculateTexImage2DStorage(int format, int type, int width, int height) { + return calculateTexImage1DStorage(format, type, width) * height; + } + + private static int calculateTexImage3DStorage(int format, int type, int width, int height, int depth) { + return calculateTexImage2DStorage(format, type, width, height) * depth; + } + + private static int calculateBytesPerPixel(int format, int type) { + int bpe; + switch ( type ) { + case GL11.GL_UNSIGNED_BYTE: + case GL11.GL_BYTE: + bpe = 1; + break; + case GL11.GL_UNSIGNED_SHORT: + case GL11.GL_SHORT: + bpe = 2; + break; + case GL11.GL_UNSIGNED_INT: + case GL11.GL_INT: + case GL11.GL_FLOAT: + bpe = 4; + break; + default : + // TODO: Add more types (like the GL12 types GL_UNSIGNED_INT_8_8_8_8 + return 0; + // throw new IllegalArgumentException("Unknown type " + type); + } + int epp; + switch ( format ) { + case GL11.GL_LUMINANCE: + case GL11.GL_ALPHA: + epp = 1; + break; + + case GL11.GL_LUMINANCE_ALPHA: + epp = 2; + break; + case GL11.GL_RGB: + case EXTBgra.GL_BGR_EXT: + epp = 3; + break; + case GL11.GL_RGBA: + case EXTAbgr.GL_ABGR_EXT: + case EXTBgra.GL_BGRA_EXT: + epp = 4; + break; + default : + // TODO: Add more formats. Assuming 4 is too wasteful on buffer sizes where e.g. 1 is enough (like GL_DEPTH_COMPONENT) + return 0; +/* // Assume 4 elements per pixel + epp = 4;*/ + } + + return bpe * epp; + } +} diff --git a/src/java/org/lwjgl/opengl/GLContext.java b/src/java/org/lwjgl/opengl/GLContext.java new file mode 100644 index 0000000..35158f5 --- /dev/null +++ b/src/java/org/lwjgl/opengl/GLContext.java @@ -0,0 +1,393 @@ +/* + * 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; + +import org.lwjgl.BufferUtils; +import org.lwjgl.LWJGLException; +import org.lwjgl.LWJGLUtil; +import org.lwjgl.Sys; + +import java.lang.reflect.Method; +import java.nio.IntBuffer; +import java.security.AccessController; +import java.security.PrivilegedAction; +import java.security.PrivilegedExceptionAction; +import java.util.*; + +/** + *

+ * Manages GL contexts. Before any rendering is done by a LWJGL system, a call should be made to GLContext.useContext() with a + * context. This will ensure that GLContext has an accurate reflection of the current context's capabilities and function + * pointers. + *

+ * This class is thread-safe in the sense that multiple threads can safely call all public methods. The class is also + * thread-aware in the sense that it tracks a per-thread current context (including capabilities and function pointers). + * That way, multiple threads can have multiple contexts current and render to them concurrently. + * + * @author elias_naur + * @version $Revision: 3279 $ + * $Id: GLContext.java 3279 2010-03-11 21:06:49Z spasi $ + */ +public final class GLContext { + + /** Maps threads to their current context's ContextCapabilities, if any */ + private final static ThreadLocal current_capabilities = new ThreadLocal(); + + /** + * The getCapabilities() method is a potential hot spot in any LWJGL application, since + * it is needed for context capability discovery (e.g. is OpenGL 2.0 supported?), and + * for the function pointers of gl functions. However, the 'current_capabilities' ThreadLocal + * is (relatively) expensive to look up, and since most OpenGL applications use are single threaded + * rendering, the following two is an optimization for this case. + *

+ * ThreadLocals can be thought of as a mapping between threads and values, so the idea + * is to use a lock-less cache of mappings between threads and the current ContextCapabilities. The cache + * could be any size, but in our case, we want a single sized cache for optimal performance + * in the single threaded case. + *

+ * 'fast_path_cache' is the most recent ContextCapabilities (potentially null) and its owner. By + * recent I mean the last thread setting the value in setCapabilities(). When getCapabilities() + * is called, a check to see if the current is the owner of the ContextCapabilities instance in + * fast_path_cache. If so, the instance is returned, if not, some thread has since taken ownership + * of the cache entry and the slower current_capabilities ThreadLocal is queried instead. + *

+ * No locks are needed in get/setCapabilities, because even though fast_path_cache can be accessed + * from multiple threads at once, we are guaranteed by the JVM spec that its value is always valid. + * Furthermore, if the ownership test in getCapabilities() succeeds, the cache entry can only contain + * the correct ContextCapabilites (that is, the one from getThreadLocalCapabilites()), + * since no other thread can set the owner to anyone else than itself. + */ + private static CapabilitiesCacheEntry fast_path_cache = new CapabilitiesCacheEntry(); + + /** + * Simple lock-free cache of CapabilitesEntryCache to avoid allocating more than one + * cache entry per thread + */ + private final static ThreadLocal thread_cache_entries = new ThreadLocal(); + + /** + * The weak mapping from context Object instances to ContextCapabilities. Used + * to avoid recreating a ContextCapabilities every time a context is made current. + */ + private final static Map capability_cache = new WeakHashMap(); + + /** Reference count of the native opengl implementation library */ + private static int gl_ref_count; + private static boolean did_auto_load; + + static { + Sys.initialize(); + } + + /** + * Get the current capabilities instance. It contains the flags used + * to test for support of a particular extension. + * + * @return The current capabilities instance. + */ + public static ContextCapabilities getCapabilities() { + CapabilitiesCacheEntry recent_cache_entry = fast_path_cache; + // Check owner of cache entry + if ( recent_cache_entry.owner == Thread.currentThread() ) { + /* The owner ship test succeeded, so the cache must contain the current ContextCapabilities instance + * assert recent_cache_entry.capabilities == getThreadLocalCapabilities(); + */ + return recent_cache_entry.capabilities; + } else // Some other thread has written to the cache since, and we fall back to the slower path + return getThreadLocalCapabilities(); + } + + private static ContextCapabilities getThreadLocalCapabilities() { + return ((ContextCapabilities)current_capabilities.get()); + } + + /** + * Set the current capabilities instance. It contains the flags used + * to test for support of a particular extension. + * + * @return The current capabilities instance. + */ + static void setCapabilities(ContextCapabilities capabilities) { + current_capabilities.set(capabilities); + + CapabilitiesCacheEntry thread_cache_entry = (CapabilitiesCacheEntry)thread_cache_entries.get(); + if ( thread_cache_entry == null ) { + thread_cache_entry = new CapabilitiesCacheEntry(); + thread_cache_entries.set(thread_cache_entry); + } + thread_cache_entry.owner = Thread.currentThread(); + thread_cache_entry.capabilities = capabilities; + + fast_path_cache = thread_cache_entry; + } + + /** + * Helper method to get a pointer to a named function in the OpenGL library + * with a name dependent on the current platform + */ + static long getPlatformSpecificFunctionAddress(String function_prefix, String[] os_prefixes, String[] os_function_prefixes, String function) { + String os_name = (String)AccessController.doPrivileged(new PrivilegedAction() { + public Object run() { + return System.getProperty("os.name"); + } + }); + for ( int i = 0; i < os_prefixes.length; i++ ) + if ( os_name.startsWith(os_prefixes[i]) ) { + String platform_function_name = function.replaceFirst(function_prefix, os_function_prefixes[i]); + long address = getFunctionAddress(platform_function_name); + return address; + } + return 0; + } + + /** Helper method to get a pointer to a named function in the OpenGL library */ + static native long getFunctionAddress(String name); + + /** + * Determine which extensions are available and returns the context profile mask. Helper method to ContextCapabilities. + * + * @param supported_extensions the Set to fill with the available extension names + * + * @return the context profile mask, will be 0 for any version < 3.2 + */ + static int getSupportedExtensions(final Set supported_extensions) { + // Detect OpenGL version first + + final String version = GL11.glGetString(GL11.GL_VERSION); + if ( version == null ) + throw new IllegalStateException("glGetString(GL_VERSION) returned null - possibly caused by missing current context."); + + final StringTokenizer version_tokenizer = new StringTokenizer(version, ". "); + final String major_string = version_tokenizer.nextToken(); + final String minor_string = version_tokenizer.nextToken(); + + int majorVersion = 0; + int minorVersion = 0; + try { + majorVersion = Integer.parseInt(major_string); + minorVersion = Integer.parseInt(minor_string); + } catch (NumberFormatException e) { + 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) ) + 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"); + + int profileMask = 0; + + if ( majorVersion < 3 ) { + // Parse EXTENSIONS string + final String extensions_string = GL11.glGetString(GL11.GL_EXTENSIONS); + if ( extensions_string == null ) + throw new IllegalStateException("glGetString(GL_EXTENSIONS) returned null - is there a context current?"); + + final StringTokenizer tokenizer = new StringTokenizer(extensions_string); + while ( tokenizer.hasMoreTokens() ) + supported_extensions.add(tokenizer.nextToken()); + } else { + // Use forward compatible indexed EXTENSIONS + final IntBuffer buffer = BufferUtils.createIntBuffer(16); + GL11.glGetInteger(GL30.GL_NUM_EXTENSIONS, buffer); + final int extensionCount = buffer.get(0); + + for ( int i = 0; i < extensionCount; i++ ) + supported_extensions.add(GL30.glGetStringi(GL11.GL_EXTENSIONS, i)); + + // Get the context profile mask for versions >= 3.2 + if ( 3 < majorVersion || 2 <= minorVersion ) { + Util.checkGLError(); // Make sure we have no errors up to this point + + GL11.glGetInteger(GL32.GL_CONTEXT_PROFILE_MASK, buffer); + + try { + // Retrieving GL_CONTEXT_PROFILE_MASK may generate an INVALID_OPERATION error on certain implementations, ignore. + // Happens on pre10.1 ATI drivers, when ContextAttribs.withProfileCompatibility is not used + Util.checkGLError(); + profileMask = buffer.get(0); + } catch (OpenGLException e) { + LWJGLUtil.log("Failed to retrieve CONTEXT_PROFILE_MASK"); + } + } + } + + return profileMask; + } + + /** + * Helper method to ContextCapabilities. It will try to initialize the native stubs, + * and remove the given extension name from the extension set if the initialization fails. + */ + static void initNativeStubs(final Class extension_class, Set supported_extensions, String ext_name) { + resetNativeStubs(extension_class); + if ( supported_extensions.contains(ext_name) ) { + try { + AccessController.doPrivileged(new PrivilegedExceptionAction() { + public Object run() throws Exception { + Method init_stubs_method = extension_class.getDeclaredMethod("initNativeStubs", null); + init_stubs_method.invoke(null, null); + return null; + } + }); + } catch (Exception e) { + LWJGLUtil.log("Failed to initialize extension " + extension_class + " - exception: " + e); + supported_extensions.remove(ext_name); + } + } + } + + /** + * Makes a GL context the current LWJGL context by loading GL function pointers. The context must be current before a call to + * this method! Instead it simply ensures that the current context is reflected accurately by GLContext's extension caps and + * function pointers. Use useContext(null) when no context is active.

If the context is the same as last time, then this is + * a no-op.

If the context has not been encountered before it will be fully initialized from scratch. Otherwise a cached set + * of caps and function pointers will be used.

The reference to the context is held in a weak reference; therefore if no + * strong reference exists to the GL context it will automatically be forgotten by the VM at an indeterminate point in the + * future, freeing up a little RAM. + * + * @param context The context object, which uniquely identifies a GL context. If context is null, the native stubs are + * unloaded. + * + * @throws LWJGLException if context non-null, and the gl library can't be loaded or the basic GL11 functions can't be loaded + */ + public static synchronized void useContext(Object context) throws LWJGLException { + useContext(context, false); + } + + /** + * Makes a GL context the current LWJGL context by loading GL function pointers. The context must be current before a call to + * this method! Instead it simply ensures that the current context is reflected accurately by GLContext's extension caps and + * function pointers. Use useContext(null) when no context is active.

If the context is the same as last time, then this is + * a no-op.

If the context has not been encountered before it will be fully initialized from scratch. Otherwise a cached set + * of caps and function pointers will be used.

The reference to the context is held in a weak reference; therefore if no + * strong reference exists to the GL context it will automatically be forgotten by the VM at an indeterminate point in the + * future, freeing up a little RAM. + *

If forwardCompatible is true, function pointers of deprecated GL11-GL21 functionality will not be loaded. Calling a deprecated + * function using the specified context will result in an IllegalStateException. + * + * @param context The context object, which uniquely identifies a GL context. If context is null, the native stubs are + * unloaded. + * @param forwardCompatible If the context is a forward compatible context (does not expose deprecated functionality, see XGL_ARB_create_context) + * + * @throws LWJGLException if context non-null, and the gl library can't be loaded or the basic GL11 functions can't be loaded + */ + public static synchronized void useContext(Object context, boolean forwardCompatible) throws LWJGLException { + if ( context == null ) { + ContextCapabilities.unloadAllStubs(); + setCapabilities(null); + if ( did_auto_load ) + unloadOpenGLLibrary(); + return; + } + if ( gl_ref_count == 0 ) { + loadOpenGLLibrary(); + did_auto_load = true; + } + try { + ContextCapabilities capabilities = (ContextCapabilities)capability_cache.get(context); + if ( capabilities == null ) { + /* + * The capabilities object registers itself as current. This behaviour is caused + * by a chicken-and-egg situation where the constructor needs to call GL functions + * as part of its capability discovery, but GL functions cannot be called before + * a capabilities object has been set. + */ + new ContextCapabilities(forwardCompatible); + capability_cache.put(context, getCapabilities()); + } else + setCapabilities(capabilities); + } catch (LWJGLException e) { + if ( did_auto_load ) + unloadOpenGLLibrary(); + throw e; + } + } + + /** If the OpenGL reference count is 0, the library is loaded. The reference count is then incremented. */ + public static synchronized void loadOpenGLLibrary() throws LWJGLException { + if ( gl_ref_count == 0 ) + nLoadOpenGLLibrary(); + gl_ref_count++; + } + + private static native void nLoadOpenGLLibrary() throws LWJGLException; + + /** The OpenGL library reference count is decremented, and if it reaches 0, the library is unloaded. */ + public static synchronized void unloadOpenGLLibrary() { + gl_ref_count--; + /* + * Unload the native OpenGL library unless we're on linux, since + * some drivers (NVIDIA proprietary) crash on exit when unloading the library. + */ + if ( gl_ref_count == 0 && LWJGLUtil.getPlatform() != LWJGLUtil.PLATFORM_LINUX ) + nUnloadOpenGLLibrary(); + } + + private static native void nUnloadOpenGLLibrary(); + + /** Native method to clear native stub bindings */ + static native void resetNativeStubs(Class clazz); + + private final static class CapabilitiesCacheEntry { + + Thread owner; + ContextCapabilities capabilities; + } +} \ No newline at end of file diff --git a/src/java/org/lwjgl/opengl/GLSync.java b/src/java/org/lwjgl/opengl/GLSync.java new file mode 100644 index 0000000..721990e --- /dev/null +++ b/src/java/org/lwjgl/opengl/GLSync.java @@ -0,0 +1,49 @@ +/* + * 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; + +/** + * @author spasi + */ +public final class GLSync implements PointerWrapper { + + private final long sync; + + GLSync(final long sync) { + this.sync = sync; + } + + public long getPointer() { + return sync; + } + +} \ No newline at end of file diff --git a/src/java/org/lwjgl/opengl/GLUConstants.java b/src/java/org/lwjgl/opengl/GLUConstants.java new file mode 100644 index 0000000..c2a8bcf --- /dev/null +++ b/src/java/org/lwjgl/opengl/GLUConstants.java @@ -0,0 +1,58 @@ +/* + * 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; + +/** + *

+ * GLU constants. + * + * @author cix_foo + * @version $Revision: 2983 $ + * $Id: GLUConstants.java 2983 2008-04-07 18:36:09Z matzon $ + */ +public interface GLUConstants { + + /* Errors: (return value 0 = no error) */ + int GLU_INVALID_ENUM = 100900; + int GLU_INVALID_VALUE = 100901; + int GLU_OUT_OF_MEMORY = 100902; + int GLU_INCOMPATIBLE_GL_VERSION = 100903; + + /* StringName */ + int GLU_VERSION = 100800; + int GLU_EXTENSIONS = 100801; + + /* Boolean */ + int GLU_TRUE = GL11.GL_TRUE; + int GLU_FALSE = GL11.GL_FALSE; + +} diff --git a/src/java/org/lwjgl/opengl/GlobalLock.java b/src/java/org/lwjgl/opengl/GlobalLock.java new file mode 100644 index 0000000..a834f01 --- /dev/null +++ b/src/java/org/lwjgl/opengl/GlobalLock.java @@ -0,0 +1,40 @@ +/* + * 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; + +/** + * This class contains the global lock that LWJGL will use to + * synchronize access to Display. + */ +final class GlobalLock { + final static Object lock = new Object(); +} diff --git a/src/java/org/lwjgl/opengl/InputImplementation.java b/src/java/org/lwjgl/opengl/InputImplementation.java new file mode 100644 index 0000000..3f7de2c --- /dev/null +++ b/src/java/org/lwjgl/opengl/InputImplementation.java @@ -0,0 +1,134 @@ +/* + * 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; + +/** + * This is the input implementation interface. Mouse and Keyboard delegates + * to implementors of this interface. There is one InputImplementation + * for each supported platform. + * @author elias_naur + */ + +import java.nio.ByteBuffer; +import java.nio.IntBuffer; + +import org.lwjgl.LWJGLException; + +public interface InputImplementation { + /* + * Mouse methods + */ + /** Query of wheel support */ + boolean hasWheel(); + + /** Query of button count */ + int getButtonCount(); + + /** + * Method to create the mouse. + */ + void createMouse() throws LWJGLException; + + /** + * Method the destroy the mouse + */ + void destroyMouse(); + + /** + * Method to poll the mouse + */ + void pollMouse(IntBuffer coord_buffer, ByteBuffer buttons); + + /** + * Method to read the keyboard buffer + */ + void readMouse(ByteBuffer buffer); + + void grabMouse(boolean grab); + + /** + * Function to determine native cursor support + */ + int getNativeCursorCapabilities(); + + /** Method to set the native cursor position */ + void setCursorPosition(int x, int y); + + /** Method to set the native cursor */ + void setNativeCursor(Object handle) throws LWJGLException; + + /** Method returning the minimum cursor size */ + int getMinCursorSize(); + + /** Method returning the maximum cursor size */ + int getMaxCursorSize(); + + /* + * Keyboard methods + */ + + /** + * Method to create the keyboard + */ + void createKeyboard() throws LWJGLException; + + /** + * Method to destroy the keyboard + */ + void destroyKeyboard(); + + /** + * Method to poll the keyboard. + * + * @param keyDownBuffer the address of a 256-byte buffer to place + * key states in. + */ + void pollKeyboard(ByteBuffer keyDownBuffer); + + /** + * Method to read the keyboard buffer + */ + void readKeyboard(ByteBuffer buffer); + +// int isStateKeySet(int key); + + /** Native cursor handles */ + Object createCursor(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, IntBuffer delays) throws LWJGLException; + + void destroyCursor(Object cursor_handle); + + int getWidth(); + + int getHeight(); + + boolean isInsideWindow(); +} diff --git a/src/java/org/lwjgl/opengl/KeyboardEventQueue.java b/src/java/org/lwjgl/opengl/KeyboardEventQueue.java new file mode 100644 index 0000000..12a2a5c --- /dev/null +++ b/src/java/org/lwjgl/opengl/KeyboardEventQueue.java @@ -0,0 +1,366 @@ +/* + * 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; + +/** + * An AWT implementation of a LWJGL compatible Keyboard event queue. + * @author elias_naur + */ + +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import java.awt.Component; +import java.nio.ByteBuffer; + +import org.lwjgl.input.Keyboard; + +final class KeyboardEventQueue extends EventQueue implements KeyListener { + private static final int[] KEY_MAP = new int[0xffff]; + + private final byte[] key_states = new byte[Keyboard.KEYBOARD_SIZE]; + + /** Event scratch array */ + private final ByteBuffer event = ByteBuffer.allocate(Keyboard.EVENT_SIZE); + + private final Component component; + + private boolean has_deferred_event; + private long deferred_nanos; + private int deferred_key_code; + private int deferred_key_location; + private byte deferred_key_state; + private int deferred_character; + + static { + KEY_MAP[KeyEvent.VK_0] = Keyboard.KEY_0; + KEY_MAP[KeyEvent.VK_1] = Keyboard.KEY_1; + KEY_MAP[KeyEvent.VK_2] = Keyboard.KEY_2; + KEY_MAP[KeyEvent.VK_3] = Keyboard.KEY_3; + KEY_MAP[KeyEvent.VK_4] = Keyboard.KEY_4; + KEY_MAP[KeyEvent.VK_5] = Keyboard.KEY_5; + KEY_MAP[KeyEvent.VK_6] = Keyboard.KEY_6; + KEY_MAP[KeyEvent.VK_7] = Keyboard.KEY_7; + KEY_MAP[KeyEvent.VK_8] = Keyboard.KEY_8; + KEY_MAP[KeyEvent.VK_9] = Keyboard.KEY_9; + KEY_MAP[KeyEvent.VK_A] = Keyboard.KEY_A; +// KEY_MAP[KeyEvent.VK_ACCEPT] = Keyboard.KEY_ACCEPT; + KEY_MAP[KeyEvent.VK_ADD] = Keyboard.KEY_ADD; +// KEY_MAP[KeyEvent.VK_AGAIN] = Keyboard.KEY_AGAIN; +// KEY_MAP[KeyEvent.VK_ALL_CANDIDATES] = Keyboard.KEY_ALL_CANDIDATES; +// KEY_MAP[KeyEvent.VK_ALPHANUMERIC] = Keyboard.KEY_ALPHANUMERIC; +// KEY_MAP[KeyEvent.VK_ALT] = Keyboard.KEY_LMENU; manually mapped + KEY_MAP[KeyEvent.VK_ALT_GRAPH] = Keyboard.KEY_RMENU; +// KEY_MAP[KeyEvent.VK_AMPERSAND] = Keyboard.KEY_AMPERSAND; +// KEY_MAP[KeyEvent.VK_ASTERISK] = Keyboard.KEY_ASTERISK; + KEY_MAP[KeyEvent.VK_AT] = Keyboard.KEY_AT; + KEY_MAP[KeyEvent.VK_B] = Keyboard.KEY_B; +// KEY_MAP[KeyEvent.VK_BACK_QUOTE] = Keyboard.KEY_BACK_QUOTE; + KEY_MAP[KeyEvent.VK_BACK_SLASH] = Keyboard.KEY_BACKSLASH; + KEY_MAP[KeyEvent.VK_BACK_SPACE] = Keyboard.KEY_BACK; +// KEY_MAP[KeyEvent.VK_BRACELEFT] = Keyboard.KEY_BRACELEFT; +// KEY_MAP[KeyEvent.VK_BRACERIGHT] = Keyboard.KEY_BRACERIGHT; + KEY_MAP[KeyEvent.VK_C] = Keyboard.KEY_C; +// KEY_MAP[KeyEvent.VK_CANCEL] = Keyboard.KEY_CANCEL; + KEY_MAP[KeyEvent.VK_CAPS_LOCK] = Keyboard.KEY_CAPITAL; + KEY_MAP[KeyEvent.VK_CIRCUMFLEX] = Keyboard.KEY_CIRCUMFLEX; +// KEY_MAP[KeyEvent.VK_CLEAR] = Keyboard.KEY_CLEAR; + KEY_MAP[KeyEvent.VK_CLOSE_BRACKET] = Keyboard.KEY_RBRACKET; +// KEY_MAP[KeyEvent.VK_CODE_INPUT] = Keyboard.KEY_CODE_INPUT; + KEY_MAP[KeyEvent.VK_COLON] = Keyboard.KEY_COLON; + KEY_MAP[KeyEvent.VK_COMMA] = Keyboard.KEY_COMMA; +// KEY_MAP[KeyEvent.VK_COMPOSE] = Keyboard.KEY_COMPOSE; +// KEY_MAP[KeyEvent.VK_CONTROL] = Keyboard.KEY_LCONTROL; manually mapped + KEY_MAP[KeyEvent.VK_CONVERT] = Keyboard.KEY_CONVERT; +// KEY_MAP[KeyEvent.VK_COPY] = Keyboard.KEY_COPY; +// KEY_MAP[KeyEvent.VK_CUT] = Keyboard.KEY_CUT; + KEY_MAP[KeyEvent.VK_D] = Keyboard.KEY_D; +// KEY_MAP[KeyEvent.VK_DEAD_ABOVEDOT] = Keyboard.KEY_DEAD_ABOVEDOT; +// KEY_MAP[KeyEvent.VK_DEAD_ABOVERING] = Keyboard.KEY_DEAD_ABOVERING; +// KEY_MAP[KeyEvent.VK_DEAD_ACUTE] = Keyboard.KEY_DEAD_ACUTE; +// KEY_MAP[KeyEvent.VK_DEAD_BREVE] = Keyboard.KEY_DEAD_BREVE; +// KEY_MAP[KeyEvent.VK_DEAD_CARON] = Keyboard.KEY_DEAD_CARON; +// KEY_MAP[KeyEvent.VK_DEAD_CEDILLA] = Keyboard.KEY_DEAD_CEDILLA; +// KEY_MAP[KeyEvent.VK_DEAD_CIRCUMFLEX] = Keyboard.KEY_DEAD_CIRCUMFLEX; +// KEY_MAP[KeyEvent.VK_DEAD_DIAERESIS] = Keyboard.KEY_DEAD_DIAERESIS; +// KEY_MAP[KeyEvent.VK_DEAD_DOUBLEACUTE] = Keyboard.KEY_DEAD_DOUBLEACUTE; +// KEY_MAP[KeyEvent.VK_DEAD_GRAVE] = Keyboard.KEY_DEAD_GRAVE; +// KEY_MAP[KeyEvent.VK_DEAD_IOTA] = Keyboard.KEY_DEAD_IOTA; +// KEY_MAP[KeyEvent.VK_DEAD_MACRON] = Keyboard.KEY_DEAD_MACRON; +// KEY_MAP[KeyEvent.VK_DEAD_OGONEK] = Keyboard.KEY_DEAD_OGONEK; +// KEY_MAP[KeyEvent.VK_DEAD_SEMIVOICED_SOUND] = Keyboard.KEY_DEAD_SEMIVOICED_SOUND; +// KEY_MAP[KeyEvent.VK_DEAD_TILDE] = Keyboard.KEY_DEAD_TILDE; +// KEY_MAP[KeyEvent.VK_DEAD_VOICED_SOUND] = Keyboard.KEY_DEAD_VOICED_SOUND; + KEY_MAP[KeyEvent.VK_DECIMAL] = Keyboard.KEY_DECIMAL; + KEY_MAP[KeyEvent.VK_DELETE] = Keyboard.KEY_DELETE; + KEY_MAP[KeyEvent.VK_DIVIDE] = Keyboard.KEY_DIVIDE; +// KEY_MAP[KeyEvent.VK_DOLLAR] = Keyboard.KEY_DOLLAR; + KEY_MAP[KeyEvent.VK_DOWN] = Keyboard.KEY_DOWN; + KEY_MAP[KeyEvent.VK_E] = Keyboard.KEY_E; + KEY_MAP[KeyEvent.VK_END] = Keyboard.KEY_END; + KEY_MAP[KeyEvent.VK_ENTER] = Keyboard.KEY_RETURN; + KEY_MAP[KeyEvent.VK_EQUALS] = Keyboard.KEY_EQUALS; + KEY_MAP[KeyEvent.VK_ESCAPE] = Keyboard.KEY_ESCAPE; +// KEY_MAP[KeyEvent.VK_EURO_SIGN] = Keyboard.KEY_EURO_SIGN; +// KEY_MAP[KeyEvent.VK_EXCLAMATION_MARK] = Keyboard.KEY_EXCLAMATION_MARK; + KEY_MAP[KeyEvent.VK_F] = Keyboard.KEY_F; + KEY_MAP[KeyEvent.VK_F1] = Keyboard.KEY_F1; + KEY_MAP[KeyEvent.VK_F10] = Keyboard.KEY_F10; + KEY_MAP[KeyEvent.VK_F11] = Keyboard.KEY_F11; + KEY_MAP[KeyEvent.VK_F12] = Keyboard.KEY_F12; + KEY_MAP[KeyEvent.VK_F13] = Keyboard.KEY_F13; + KEY_MAP[KeyEvent.VK_F14] = Keyboard.KEY_F14; + KEY_MAP[KeyEvent.VK_F15] = Keyboard.KEY_F15; +// KEY_MAP[KeyEvent.VK_F16] = Keyboard.KEY_F16; +// KEY_MAP[KeyEvent.VK_F17] = Keyboard.KEY_F17; +// KEY_MAP[KeyEvent.VK_F18] = Keyboard.KEY_F18; +// KEY_MAP[KeyEvent.VK_F19] = Keyboard.KEY_F19; + KEY_MAP[KeyEvent.VK_F2] = Keyboard.KEY_F2; +// KEY_MAP[KeyEvent.VK_F20] = Keyboard.KEY_F20; +// KEY_MAP[KeyEvent.VK_F21] = Keyboard.KEY_F21; +// KEY_MAP[KeyEvent.VK_F22] = Keyboard.KEY_F22; +// KEY_MAP[KeyEvent.VK_F23] = Keyboard.KEY_F23; +// KEY_MAP[KeyEvent.VK_F24] = Keyboard.KEY_F24; + KEY_MAP[KeyEvent.VK_F3] = Keyboard.KEY_F3; + KEY_MAP[KeyEvent.VK_F4] = Keyboard.KEY_F4; + KEY_MAP[KeyEvent.VK_F5] = Keyboard.KEY_F5; + KEY_MAP[KeyEvent.VK_F6] = Keyboard.KEY_F6; + KEY_MAP[KeyEvent.VK_F7] = Keyboard.KEY_F7; + KEY_MAP[KeyEvent.VK_F8] = Keyboard.KEY_F8; + KEY_MAP[KeyEvent.VK_F9] = Keyboard.KEY_F9; +// KEY_MAP[KeyEvent.VK_FINAL] = Keyboard.KEY_FINAL; +// KEY_MAP[KeyEvent.VK_FIND] = Keyboard.KEY_FIND; +// KEY_MAP[KeyEvent.VK_FULL_WIDTH] = Keyboard.KEY_FULL_WIDTH; + KEY_MAP[KeyEvent.VK_G] = Keyboard.KEY_G; +// KEY_MAP[KeyEvent.VK_GREATER] = Keyboard.KEY_GREATER; + KEY_MAP[KeyEvent.VK_H] = Keyboard.KEY_H; +// KEY_MAP[KeyEvent.VK_HALF_WIDTH] = Keyboard.KEY_HALF_WIDTH; +// KEY_MAP[KeyEvent.VK_HELP] = Keyboard.KEY_HELP; +// KEY_MAP[KeyEvent.VK_HIRAGANA] = Keyboard.KEY_HIRAGANA; + KEY_MAP[KeyEvent.VK_HOME] = Keyboard.KEY_HOME; + KEY_MAP[KeyEvent.VK_I] = Keyboard.KEY_I; +// KEY_MAP[KeyEvent.VK_INPUT_METHOD_ON_OFF] = Keyboard.KEY_INPUT_METHOD_ON_OFF; + KEY_MAP[KeyEvent.VK_INSERT] = Keyboard.KEY_INSERT; +// KEY_MAP[KeyEvent.VK_INVERTED_EXCLAMATION_MARK] = Keyboard.KEY_INVERTED_EXCLAMATION_MARK; + KEY_MAP[KeyEvent.VK_J] = Keyboard.KEY_J; +// KEY_MAP[KeyEvent.VK_JAPANESE_HIRAGANA] = Keyboard.KEY_JAPANESE_HIRAGANA; +// KEY_MAP[KeyEvent.VK_JAPANESE_KATAKANA] = Keyboard.KEY_JAPANESE_KATAKANA; +// KEY_MAP[KeyEvent.VK_JAPANESE_ROMAN] = Keyboard.KEY_JAPANESE_ROMAN; + KEY_MAP[KeyEvent.VK_K] = Keyboard.KEY_K; + KEY_MAP[KeyEvent.VK_KANA] = Keyboard.KEY_KANA; +// KEY_MAP[KeyEvent.VK_KANA_LOCK] = Keyboard.KEY_KANA_LOCK; + KEY_MAP[KeyEvent.VK_KANJI] = Keyboard.KEY_KANJI; +// KEY_MAP[KeyEvent.VK_KATAKANA] = Keyboard.KEY_KATAKANA; +// KEY_MAP[KeyEvent.VK_KP_DOWN] = Keyboard.KEY_KP_DOWN; +// KEY_MAP[KeyEvent.VK_KP_LEFT] = Keyboard.KEY_KP_LEFT; +// KEY_MAP[KeyEvent.VK_KP_RIGHT] = Keyboard.KEY_KP_RIGHT; +// KEY_MAP[KeyEvent.VK_KP_UP] = Keyboard.KEY_KP_UP; + KEY_MAP[KeyEvent.VK_L] = Keyboard.KEY_L; + KEY_MAP[KeyEvent.VK_LEFT] = Keyboard.KEY_LEFT; +// KEY_MAP[KeyEvent.VK_LEFT_PARENTHESIS] = Keyboard.KEY_LEFT_PARENTHESIS; +// KEY_MAP[KeyEvent.VK_LESS] = Keyboard.KEY_LESS; + KEY_MAP[KeyEvent.VK_M] = Keyboard.KEY_M; +// KEY_MAP[KeyEvent.VK_META] = Keyboard.KEY_LMENU; manually mapped + KEY_MAP[KeyEvent.VK_MINUS] = Keyboard.KEY_MINUS; +// KEY_MAP[KeyEvent.VK_MODECHANGE] = Keyboard.KEY_MODECHANGE; + KEY_MAP[KeyEvent.VK_MULTIPLY] = Keyboard.KEY_MULTIPLY; + KEY_MAP[KeyEvent.VK_N] = Keyboard.KEY_N; +// KEY_MAP[KeyEvent.VK_NONCONVERT] = Keyboard.KEY_NONCONVERT; + KEY_MAP[KeyEvent.VK_NUM_LOCK] = Keyboard.KEY_NUMLOCK; +// KEY_MAP[KeyEvent.VK_NUMBER_SIGN] = Keyboard.KEY_NUMBER_SIGN; + KEY_MAP[KeyEvent.VK_NUMPAD0] = Keyboard.KEY_NUMPAD0; + KEY_MAP[KeyEvent.VK_NUMPAD1] = Keyboard.KEY_NUMPAD1; + KEY_MAP[KeyEvent.VK_NUMPAD2] = Keyboard.KEY_NUMPAD2; + KEY_MAP[KeyEvent.VK_NUMPAD3] = Keyboard.KEY_NUMPAD3; + KEY_MAP[KeyEvent.VK_NUMPAD4] = Keyboard.KEY_NUMPAD4; + KEY_MAP[KeyEvent.VK_NUMPAD5] = Keyboard.KEY_NUMPAD5; + KEY_MAP[KeyEvent.VK_NUMPAD6] = Keyboard.KEY_NUMPAD6; + KEY_MAP[KeyEvent.VK_NUMPAD7] = Keyboard.KEY_NUMPAD7; + KEY_MAP[KeyEvent.VK_NUMPAD8] = Keyboard.KEY_NUMPAD8; + KEY_MAP[KeyEvent.VK_NUMPAD9] = Keyboard.KEY_NUMPAD9; + KEY_MAP[KeyEvent.VK_O] = Keyboard.KEY_O; + KEY_MAP[KeyEvent.VK_OPEN_BRACKET] = Keyboard.KEY_LBRACKET; + KEY_MAP[KeyEvent.VK_P] = Keyboard.KEY_P; + KEY_MAP[KeyEvent.VK_PAGE_DOWN] = Keyboard.KEY_NEXT; + KEY_MAP[KeyEvent.VK_PAGE_UP] = Keyboard.KEY_PRIOR; +// KEY_MAP[KeyEvent.VK_PASTE] = Keyboard.KEY_PASTE; + KEY_MAP[KeyEvent.VK_PAUSE] = Keyboard.KEY_PAUSE; + KEY_MAP[KeyEvent.VK_PERIOD] = Keyboard.KEY_PERIOD; +// KEY_MAP[KeyEvent.VK_PLUS] = Keyboard.KEY_PLUS; +// KEY_MAP[KeyEvent.VK_PREVIOUS_CANDIDATE] = Keyboard.KEY_PREVIOUS_CANDIDATE; +// KEY_MAP[KeyEvent.VK_PRINTSCREEN] = Keyboard.KEY_PRINTSCREEN; +// KEY_MAP[KeyEvent.VK_PROPS] = Keyboard.KEY_PROPS; + KEY_MAP[KeyEvent.VK_Q] = Keyboard.KEY_Q; +// KEY_MAP[KeyEvent.VK_QUOTE] = Keyboard.KEY_QUOTE; +// KEY_MAP[KeyEvent.VK_QUOTEDBL] = Keyboard.KEY_QUOTEDBL; + KEY_MAP[KeyEvent.VK_R] = Keyboard.KEY_R; + KEY_MAP[KeyEvent.VK_RIGHT] = Keyboard.KEY_RIGHT; +// KEY_MAP[KeyEvent.VK_RIGHT_PARENTHESIS] = Keyboard.KEY_RIGHT_PARENTHESIS; +// KEY_MAP[KeyEvent.VK_ROMAN_CHARACTERS] = Keyboard.KEY_ROMAN_CHARACTERS; + KEY_MAP[KeyEvent.VK_S] = Keyboard.KEY_S; + KEY_MAP[KeyEvent.VK_SCROLL_LOCK] = Keyboard.KEY_SCROLL; + KEY_MAP[KeyEvent.VK_SEMICOLON] = Keyboard.KEY_SEMICOLON; + KEY_MAP[KeyEvent.VK_SEPARATOR] = Keyboard.KEY_DECIMAL; +// KEY_MAP[KeyEvent.VK_SHIFT] = Keyboard.KEY_LSHIFT; manually mapped + KEY_MAP[KeyEvent.VK_SLASH] = Keyboard.KEY_SLASH; + KEY_MAP[KeyEvent.VK_SPACE] = Keyboard.KEY_SPACE; + KEY_MAP[KeyEvent.VK_STOP] = Keyboard.KEY_STOP; + KEY_MAP[KeyEvent.VK_SUBTRACT] = Keyboard.KEY_SUBTRACT; + KEY_MAP[KeyEvent.VK_T] = Keyboard.KEY_T; + KEY_MAP[KeyEvent.VK_TAB] = Keyboard.KEY_TAB; + KEY_MAP[KeyEvent.VK_U] = Keyboard.KEY_U; +// KEY_MAP[KeyEvent.VK_UNDERSCORE] = Keyboard.KEY_UNDERSCORE; +// KEY_MAP[KeyEvent.VK_UNDO] = Keyboard.KEY_UNDO; + KEY_MAP[KeyEvent.VK_UP] = Keyboard.KEY_UP; + KEY_MAP[KeyEvent.VK_V] = Keyboard.KEY_V; + KEY_MAP[KeyEvent.VK_W] = Keyboard.KEY_W; + KEY_MAP[KeyEvent.VK_X] = Keyboard.KEY_X; + KEY_MAP[KeyEvent.VK_Y] = Keyboard.KEY_Y; + KEY_MAP[KeyEvent.VK_Z] = Keyboard.KEY_Z; + } + + KeyboardEventQueue(Component component) { + super(Keyboard.EVENT_SIZE); + this.component = component; + } + + public void register() { + component.addKeyListener(this); + } + + public void unregister() { + /* + * This line is commented out to work around AWT bug 4867453: + * http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4867453 + */ + //component.removeKeyListener(this); + } + + private void putKeyboardEvent(int key_code, byte state, int character, long nanos, boolean repeat) { + event.clear(); + event.putInt(key_code).put(state).putInt(character).putLong(nanos).put(repeat ? (byte)1 : (byte)0); + event.flip(); + putEvent(event); + } + + public synchronized void poll(ByteBuffer key_down_buffer) { + flushDeferredEvent(); + int old_position = key_down_buffer.position(); + key_down_buffer.put(key_states); + key_down_buffer.position(old_position); + } + + public synchronized void copyEvents(ByteBuffer dest) { + flushDeferredEvent(); + super.copyEvents(dest); + } + + private synchronized void handleKey(int key_code, int key_location, byte state, int character, long nanos) { + if (character == KeyEvent.CHAR_UNDEFINED) + character = Keyboard.CHAR_NONE; + if (state == 1) { + boolean repeat = false; + if (has_deferred_event) { + if ((nanos == deferred_nanos && deferred_key_code == key_code && + deferred_key_location == key_location)) { + has_deferred_event = false; + repeat = true; // Repeat event + } else + flushDeferredEvent(); + } + putKeyEvent(key_code, key_location, state, character, nanos, repeat); + } else { + flushDeferredEvent(); + has_deferred_event = true; + deferred_nanos = nanos; + deferred_key_code = key_code; + deferred_key_location = key_location; + deferred_key_state = state; + deferred_character = character; + } + } + + private void flushDeferredEvent() { + if (has_deferred_event) { + putKeyEvent(deferred_key_code, deferred_key_location, deferred_key_state, deferred_character, deferred_nanos, false); + has_deferred_event = false; + } + } + + private void putKeyEvent(int key_code, int key_location, byte state, int character, long nanos, boolean repeat) { + int key_code_mapped = getMappedKeyCode(key_code, key_location); + /* Ignore repeating presses */ + if ( key_states[key_code_mapped] == state ) + repeat = true; + key_states[key_code_mapped] = state; + int key_int_char = character & 0xffff; + putKeyboardEvent(key_code_mapped, state, key_int_char, nanos, repeat); + } + + private int getMappedKeyCode(int key_code, int position) { + // manually map positioned keys + switch (key_code) { + case KeyEvent.VK_ALT: // fall through + if (position == KeyEvent.KEY_LOCATION_RIGHT) + return Keyboard.KEY_RMENU; + else + return Keyboard.KEY_LMENU; + case KeyEvent.VK_META: + if (position == KeyEvent.KEY_LOCATION_RIGHT) + return Keyboard.KEY_RMETA; + else + return Keyboard.KEY_LMETA; + case KeyEvent.VK_SHIFT: + if (position == KeyEvent.KEY_LOCATION_RIGHT) + return Keyboard.KEY_RSHIFT; + else + return Keyboard.KEY_LSHIFT; + case KeyEvent.VK_CONTROL: + if (position == KeyEvent.KEY_LOCATION_RIGHT) + return Keyboard.KEY_RCONTROL; + else + return Keyboard.KEY_LCONTROL; + default: + return KEY_MAP[key_code]; + } + } + + public void keyPressed(KeyEvent e) { + handleKey(e.getKeyCode(), e.getKeyLocation(), (byte)1, e.getKeyChar(), e.getWhen()*1000000); + } + + public void keyReleased(KeyEvent e) { + handleKey(e.getKeyCode(), e.getKeyLocation(), (byte)0, Keyboard.CHAR_NONE, e.getWhen()*1000000); + } + + public void keyTyped(KeyEvent e) { + } +} diff --git a/src/java/org/lwjgl/opengl/LinuxAWTGLCanvasPeerInfo.java b/src/java/org/lwjgl/opengl/LinuxAWTGLCanvasPeerInfo.java new file mode 100644 index 0000000..8258c77 --- /dev/null +++ b/src/java/org/lwjgl/opengl/LinuxAWTGLCanvasPeerInfo.java @@ -0,0 +1,73 @@ +/* + * 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; + +import java.nio.ByteBuffer; + +import org.lwjgl.LWJGLException; +import org.lwjgl.LWJGLUtil; +import java.awt.Canvas; + +/** + * + * @author elias_naur + * @version $Revision: 3116 $ + * $Id: LinuxAWTGLCanvasPeerInfo.java 3116 2008-08-19 16:46:03Z spasi $ + */ +final class LinuxAWTGLCanvasPeerInfo extends LinuxPeerInfo { + private final Canvas component; + private final AWTSurfaceLock awt_surface = new AWTSurfaceLock(); + private int screen = -1; + + LinuxAWTGLCanvasPeerInfo(Canvas component) { + this.component = component; + } + + protected void doLockAndInitHandle() throws LWJGLException { + ByteBuffer surface_handle = awt_surface.lockAndGetHandle(component); + if (screen == -1) { + try { + screen = getScreenFromSurfaceInfo(surface_handle); + } catch (LWJGLException e) { + LWJGLUtil.log("Got exception while trying to determine screen: " + e); + screen = 0; + } + } + nInitHandle(screen, surface_handle, getHandle()); + } + private static native int getScreenFromSurfaceInfo(ByteBuffer surface_handle) throws LWJGLException; + private static native void nInitHandle(int screen, ByteBuffer surface_buffer, ByteBuffer peer_info_handle) throws LWJGLException; + + protected void doUnlock() throws LWJGLException { + awt_surface.unlock(); + } +} diff --git a/src/java/org/lwjgl/opengl/LinuxCanvasImplementation.java b/src/java/org/lwjgl/opengl/LinuxCanvasImplementation.java new file mode 100644 index 0000000..42b610d --- /dev/null +++ b/src/java/org/lwjgl/opengl/LinuxCanvasImplementation.java @@ -0,0 +1,123 @@ +/* + * 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; + +import java.awt.GraphicsConfiguration; +import java.awt.GraphicsDevice; +import java.awt.Canvas; +import java.lang.reflect.Method; +import java.security.AccessController; +import java.security.PrivilegedExceptionAction; + +import org.lwjgl.LWJGLException; +import org.lwjgl.LWJGLUtil; + +/** + * + * @author elias_naur + * @version $Revision: 3002 $ + * $Id: LinuxCanvasImplementation.java 3002 2008-04-10 20:25:54Z elias_naur $ + */ +final class LinuxCanvasImplementation implements AWTCanvasImplementation { + static int getScreenFromDevice(final GraphicsDevice device) throws LWJGLException { + try { + Method getScreen_method = (Method)AccessController.doPrivileged(new PrivilegedExceptionAction() { + public Object run() throws Exception { + return device.getClass().getMethod("getScreen", null); + } + }); + Integer screen = (Integer)getScreen_method.invoke(device, null); + return screen.intValue(); + } catch (Exception e) { + throw new LWJGLException(e); + } + } + + private static int getVisualIDFromConfiguration(final GraphicsConfiguration configuration) throws LWJGLException { + try { + Method getVisual_method = (Method)AccessController.doPrivileged(new PrivilegedExceptionAction() { + public Object run() throws Exception { + return configuration.getClass().getMethod("getVisual", null); + } + }); + Integer visual = (Integer)getVisual_method.invoke(configuration, null); + return visual.intValue(); + } catch (Exception e) { + throw new LWJGLException(e); + } + } + + public PeerInfo createPeerInfo(Canvas component, PixelFormat pixel_format) throws LWJGLException { + return new LinuxAWTGLCanvasPeerInfo(component); + } + + /** + * Find a proper GraphicsConfiguration from the given GraphicsDevice and PixelFormat. + * + * @return The GraphicsConfiguration corresponding to a visual that matches the pixel format. + */ + public GraphicsConfiguration findConfiguration(GraphicsDevice device, PixelFormat pixel_format) throws LWJGLException { + try { + int screen = getScreenFromDevice(device); + int visual_id_matching_format = findVisualIDFromFormat(screen, pixel_format); + GraphicsConfiguration[] configurations = device.getConfigurations(); + for (int i = 0; i < configurations.length; i++) { + int visual_id = getVisualIDFromConfiguration(configurations[i]); + if (visual_id == visual_id_matching_format) + return configurations[i]; + } + } catch (LWJGLException e) { + LWJGLUtil.log("Got exception while trying to determine configuration: " + e); + } + return null; // In case we failed to locate the visual, or if we're not on a SUN JDK + } + + private static int findVisualIDFromFormat(int screen, PixelFormat pixel_format) throws LWJGLException { + try { + LinuxDisplay.lockAWT(); + try { + GLContext.loadOpenGLLibrary(); + try { + LinuxDisplay.incDisplay(); + return nFindVisualIDFromFormat(LinuxDisplay.getDisplay(), screen, pixel_format); + } finally { + LinuxDisplay.decDisplay(); + } + } finally { + GLContext.unloadOpenGLLibrary(); + } + } finally { + LinuxDisplay.unlockAWT(); + } + } + private static native int nFindVisualIDFromFormat(long display, int screen, PixelFormat pixel_format) throws LWJGLException; +} diff --git a/src/java/org/lwjgl/opengl/LinuxContextAttribs.java b/src/java/org/lwjgl/opengl/LinuxContextAttribs.java new file mode 100644 index 0000000..d8fa015 --- /dev/null +++ b/src/java/org/lwjgl/opengl/LinuxContextAttribs.java @@ -0,0 +1,94 @@ +/* + * 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; + +/** + * An implementation of ContextAttribs using GLX_create_context. + *

+ * ---- WIP - GLX_create_context has not been defined yet ---- + * + * @author spasi + */ +final class LinuxContextAttribs implements ContextAttribsImplementation { + + private static final int GLX_CONTEXT_MAJOR_VERSION_ARB = 0x2091; + private static final int GLX_CONTEXT_MINOR_VERSION_ARB = 0x2092; + private static final int GLX_CONTEXT_LAYER_PLANE_ARB = 0x2093; + private static final int GLX_CONTEXT_FLAGS_ARB = 0x2094; + private static final int GLX_CONTEXT_PROFILE_MASK_ARB = 0x9126; + + private static final int GLX_CONTEXT_DEBUG_BIT_ARB = 0x0001; + private static final int GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB = 0x0002; + + private static final int GLX_CONTEXT_CORE_PROFILE_BIT_ARB = 0x00000001; + private static final int GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB = 0x00000002; + + LinuxContextAttribs() { + } + + public int getMajorVersionAttrib() { + return GLX_CONTEXT_MAJOR_VERSION_ARB; + } + + public int getMinorVersionAttrib() { + return GLX_CONTEXT_MINOR_VERSION_ARB; + } + + public int getLayerPlaneAttrib() { + return GLX_CONTEXT_LAYER_PLANE_ARB; + } + + public int getFlagsAttrib() { + return GLX_CONTEXT_FLAGS_ARB; + } + + public int getDebugBit() { + return GLX_CONTEXT_DEBUG_BIT_ARB; + } + + public int getForwardCompatibleBit() { + return GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB; + } + + public int getProfileMaskAttrib() { + return GLX_CONTEXT_PROFILE_MASK_ARB; + } + + public int getProfileCoreBit() { + return GLX_CONTEXT_CORE_PROFILE_BIT_ARB; + } + + public int getProfileCompatibilityBit() { + return GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB; + } + +} \ No newline at end of file diff --git a/src/java/org/lwjgl/opengl/LinuxContextImplementation.java b/src/java/org/lwjgl/opengl/LinuxContextImplementation.java new file mode 100644 index 0000000..1704dce --- /dev/null +++ b/src/java/org/lwjgl/opengl/LinuxContextImplementation.java @@ -0,0 +1,168 @@ +/* + * 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; + +import org.lwjgl.LWJGLException; + +import java.nio.ByteBuffer; +import java.nio.IntBuffer; + +/** + * @author elias_naur + * @version $Revision: 3116 $ + * $Id: LinuxContextImplementation.java 3116 2008-08-19 16:46:03Z spasi $ + */ +final class LinuxContextImplementation implements ContextImplementation { + + public ByteBuffer create(PeerInfo peer_info, IntBuffer attribs, ByteBuffer shared_context_handle) throws LWJGLException { + LinuxDisplay.lockAWT(); + try { + ByteBuffer peer_handle = peer_info.lockAndGetHandle(); + try { + return nCreate(peer_handle, attribs, shared_context_handle); + } finally { + peer_info.unlock(); + } + } finally { + LinuxDisplay.unlockAWT(); + } + } + + private static native ByteBuffer nCreate(ByteBuffer peer_handle, IntBuffer attribs, ByteBuffer shared_context_handle) throws LWJGLException; + + public void releaseDrawable(ByteBuffer context_handle) throws LWJGLException { + } + + public void swapBuffers() throws LWJGLException { + Context current_context = Context.getCurrentContext(); + if ( current_context == null ) + throw new IllegalStateException("No context is current"); + synchronized ( current_context ) { + PeerInfo current_peer_info = current_context.getPeerInfo(); + LinuxDisplay.lockAWT(); + try { + ByteBuffer peer_handle = current_peer_info.lockAndGetHandle(); + try { + nSwapBuffers(peer_handle); + } finally { + current_peer_info.unlock(); + } + } finally { + LinuxDisplay.unlockAWT(); + } + } + } + + private static native void nSwapBuffers(ByteBuffer peer_info_handle) throws LWJGLException; + + public void releaseCurrentContext() throws LWJGLException { + Context current_context = Context.getCurrentContext(); + if ( current_context == null ) + throw new IllegalStateException("No context is current"); + synchronized ( current_context ) { + PeerInfo current_peer_info = current_context.getPeerInfo(); + LinuxDisplay.lockAWT(); + try { + ByteBuffer peer_handle = current_peer_info.lockAndGetHandle(); + try { + nReleaseCurrentContext(peer_handle); + } finally { + current_peer_info.unlock(); + } + } finally { + LinuxDisplay.unlockAWT(); + } + } + } + + private static native void nReleaseCurrentContext(ByteBuffer peer_info_handle) throws LWJGLException; + + public void update(ByteBuffer context_handle) { + } + + public void makeCurrent(PeerInfo peer_info, ByteBuffer handle) throws LWJGLException { + LinuxDisplay.lockAWT(); + try { + ByteBuffer peer_handle = peer_info.lockAndGetHandle(); + try { + nMakeCurrent(peer_handle, handle); + } finally { + peer_info.unlock(); + } + } finally { + LinuxDisplay.unlockAWT(); + } + } + + private static native void nMakeCurrent(ByteBuffer peer_handle, ByteBuffer context_handle) throws LWJGLException; + + public boolean isCurrent(ByteBuffer handle) throws LWJGLException { + LinuxDisplay.lockAWT(); + try { + boolean result = nIsCurrent(handle); + return result; + } finally { + LinuxDisplay.unlockAWT(); + } + } + + private static native boolean nIsCurrent(ByteBuffer context_handle) throws LWJGLException; + + public void setSwapInterval(int value) { + Context current_context = Context.getCurrentContext(); + if ( current_context == null ) + throw new IllegalStateException("No context is current"); + synchronized ( current_context ) { + LinuxDisplay.lockAWT(); + nSetSwapInterval(current_context.getHandle(), value); + LinuxDisplay.unlockAWT(); + } + } + + private static native void nSetSwapInterval(ByteBuffer context_handle, int value); + + public void destroy(PeerInfo peer_info, ByteBuffer handle) throws LWJGLException { + LinuxDisplay.lockAWT(); + try { + ByteBuffer peer_handle = peer_info.lockAndGetHandle(); + try { + nDestroy(peer_handle, handle); + } finally { + peer_info.unlock(); + } + } finally { + LinuxDisplay.unlockAWT(); + } + } + + private static native void nDestroy(ByteBuffer peer_handle, ByteBuffer context_handle) throws LWJGLException; +} diff --git a/src/java/org/lwjgl/opengl/LinuxDisplay.java b/src/java/org/lwjgl/opengl/LinuxDisplay.java new file mode 100644 index 0000000..609d86f --- /dev/null +++ b/src/java/org/lwjgl/opengl/LinuxDisplay.java @@ -0,0 +1,1215 @@ +/* + * 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.opengl; + +/** + * This is the Display implementation interface. Display delegates + * to implementors of this interface. There is one DisplayImplementation + * for each supported platform. + * @author elias_naur + */ + +import java.awt.Canvas; +import java.nio.ByteBuffer; +import java.nio.FloatBuffer; +import java.nio.IntBuffer; + +import org.lwjgl.BufferUtils; +import org.lwjgl.LWJGLException; +import org.lwjgl.LWJGLUtil; +import org.lwjgl.opengl.XRandR.Screen; + +final class LinuxDisplay implements DisplayImplementation { + /* X11 constants */ + public final static int CurrentTime = 0; + public final static int GrabSuccess = 0; + public final static int AutoRepeatModeOff = 0; + public final static int AutoRepeatModeOn = 1; + public final static int AutoRepeatModeDefault = 2; + public final static int None = 0; + + private final static int KeyPressMask = 1 << 0; + private final static int KeyReleaseMask = 1 << 1; + private final static int ButtonPressMask = 1 << 2; + private final static int ButtonReleaseMask = 1 << 3; + + private final static int NotifyAncestor = 0; + private final static int NotifyNonlinear = 3; + private final static int NotifyPointer = 5; + private final static int NotifyPointerRoot = 6; + private final static int NotifyDetailNone = 7; + + private final static int SetModeInsert = 0; + private final static int SaveSetRoot = 1; + private final static int SaveSetUnmap = 1; + + /** Window mode enum */ + private static final int FULLSCREEN_LEGACY = 1; + private static final int FULLSCREEN_NETWM = 2; + private static final int WINDOWED = 3; + + /** Current window mode */ + private static int current_window_mode = WINDOWED; + + /** Display mode switching API */ + private static final int XRANDR = 10; + private static final int XF86VIDMODE = 11; + private static final int NONE = 12; + + /** Current X11 Display pointer */ + private static long display; + private static long current_window; + private static long saved_error_handler; + + private static int display_connection_usage_count = 0; + + /** Event buffer */ + private final LinuxEvent event_buffer = new LinuxEvent(); + private final LinuxEvent tmp_event_buffer = new LinuxEvent(); + + /** Current mode swithcing API */ + private int current_displaymode_extension = NONE; + + /** Atom used for the pointer warp messages */ + private long delete_atom; + + private PeerInfo peer_info; + + /** Saved gamma used to restore display settings */ + private ByteBuffer saved_gamma; + private ByteBuffer current_gamma; + + /** Saved mode to restore with */ + private DisplayMode saved_mode; + private DisplayMode current_mode; + + private Screen[] savedXrandrConfig; + + private boolean keyboard_grabbed; + private boolean pointer_grabbed; + private boolean input_released; + private boolean grab; + private boolean focused; + private boolean minimized; + private boolean dirty; + private boolean close_requested; + private long current_cursor; + private long blank_cursor; + private Canvas parent; + private long parent_window; + private boolean xembedded; + private boolean parent_focus; + + private LinuxKeyboard keyboard; + private LinuxMouse mouse; + + private static ByteBuffer getCurrentGammaRamp() throws LWJGLException { + lockAWT(); + try { + incDisplay(); + try { + if (isXF86VidModeSupported()) + return nGetCurrentGammaRamp(getDisplay(), getDefaultScreen()); + else + return null; + } finally { + decDisplay(); + } + } finally { + unlockAWT(); + } + } + private static native ByteBuffer nGetCurrentGammaRamp(long display, int screen) throws LWJGLException; + + private static int getBestDisplayModeExtension() { + int result; + if (isXrandrSupported()) { + LWJGLUtil.log("Using Xrandr for display mode switching"); + result = XRANDR; + } else if (isXF86VidModeSupported()) { + LWJGLUtil.log("Using XF86VidMode for display mode switching"); + result = XF86VIDMODE; + } else { + LWJGLUtil.log("No display mode extensions available"); + result = NONE; + } + return result; + } + + private static boolean isXrandrSupported() { + if (Display.getPrivilegedBoolean("LWJGL_DISABLE_XRANDR")) + return false; + lockAWT(); + try { + incDisplay(); + try { + return nIsXrandrSupported(getDisplay()); + } finally { + decDisplay(); + } + } catch (LWJGLException e) { + LWJGLUtil.log("Got exception while querying Xrandr support: " + e); + return false; + } finally { + unlockAWT(); + } + } + private static native boolean nIsXrandrSupported(long display) throws LWJGLException; + + private static boolean isXF86VidModeSupported() { + lockAWT(); + try { + incDisplay(); + try { + return nIsXF86VidModeSupported(getDisplay()); + } finally { + decDisplay(); + } + } catch (LWJGLException e) { + LWJGLUtil.log("Got exception while querying XF86VM support: " + e); + return false; + } finally { + unlockAWT(); + } + } + private static native boolean nIsXF86VidModeSupported(long display) throws LWJGLException; + + private static boolean isNetWMFullscreenSupported() throws LWJGLException { + if (Display.getPrivilegedBoolean("LWJGL_DISABLE_NETWM")) + return false; + lockAWT(); + try { + incDisplay(); + try { + return nIsNetWMFullscreenSupported(getDisplay(), getDefaultScreen()); + } finally { + decDisplay(); + } + } catch (LWJGLException e) { + LWJGLUtil.log("Got exception while querying NetWM support: " + e); + return false; + } finally { + unlockAWT(); + } + } + private static native boolean nIsNetWMFullscreenSupported(long display, int screen) throws LWJGLException; + + /* Since Xlib is not guaranteed to be thread safe, we need a way to synchronize LWJGL + * Xlib calls with AWT Xlib calls. Fortunately, JAWT implements Lock()/Unlock() to + * do just that. + */ + static void lockAWT() { + try { + nLockAWT(); + } catch (LWJGLException e) { + LWJGLUtil.log("Caught exception while locking AWT: " + e); + } + } + private static native void nLockAWT() throws LWJGLException; + + static void unlockAWT() { + try { + nUnlockAWT(); + } catch (LWJGLException e) { + LWJGLUtil.log("Caught exception while unlocking AWT: " + e); + } + } + private static native void nUnlockAWT() throws LWJGLException; + + /** + * increment and decrement display usage. + */ + static void incDisplay() throws LWJGLException { + if (display_connection_usage_count == 0) { + GLContext.loadOpenGLLibrary(); + saved_error_handler = setErrorHandler(); + display = openDisplay(); +// synchronize(display, true); + } + display_connection_usage_count++; + } + private static native int callErrorHandler(long handler, long display, long error_ptr); + private static native long setErrorHandler(); + private static native long resetErrorHandler(long handler); + private static native void synchronize(long display, boolean synchronize); + + private static int globalErrorHandler(long display, long event_ptr, long error_display, long serial, long error_code, long request_code, long minor_code) throws LWJGLException { + if (display == getDisplay()) { + String error_msg = getErrorText(display, error_code); + throw new LWJGLException("X Error - disp: 0x" + Long.toHexString(error_display) + " serial: " + serial + " error: " + error_msg + " request_code: " + request_code + " minor_code: " + minor_code); + } else if (saved_error_handler != 0) + return callErrorHandler(saved_error_handler, display, event_ptr); + return 0; + } + private static native String getErrorText(long display, long error_code); + + static void decDisplay() { + /* + * Some drivers (at least some versions of the radeon dri driver) + * don't like it when the display is closed and later re-opened, + * so we'll just let the singleton display connection leak. + */ +/* display_connection_usage_count--; + if (display_connection_usage_count < 0) + throw new InternalError("display_connection_usage_count < 0: " + display_connection_usage_count); + if (display_connection_usage_count == 0) { + closeDisplay(display); + resetErrorHandler(saved_error_handler); + display = 0; + GLContext.unloadOpenGLLibrary(); + }*/ + } + + static native long openDisplay() throws LWJGLException; + static native void closeDisplay(long display); + + private int getWindowMode(boolean fullscreen) throws LWJGLException { + if (fullscreen) { + if (current_displaymode_extension == XRANDR && isNetWMFullscreenSupported()) { + LWJGLUtil.log("Using NetWM for fullscreen window"); + return FULLSCREEN_NETWM; + } else { + LWJGLUtil.log("Using legacy mode for fullscreen window"); + return FULLSCREEN_LEGACY; + } + } else + return WINDOWED; + } + + static long getDisplay() { + if (display_connection_usage_count <= 0) + throw new InternalError("display_connection_usage_count = " + display_connection_usage_count); + return display; + } + + static int getDefaultScreen() { + return nGetDefaultScreen(getDisplay()); + } + static native int nGetDefaultScreen(long display); + + static long getWindow() { + return current_window; + } + + private void ungrabKeyboard() { + if (keyboard_grabbed) { + nUngrabKeyboard(getDisplay()); + keyboard_grabbed = false; + } + } + static native int nUngrabKeyboard(long display); + + private void grabKeyboard() { + if (!keyboard_grabbed) { + int res = nGrabKeyboard(getDisplay(), getWindow()); + if (res == GrabSuccess) + keyboard_grabbed = true; + } + } + static native int nGrabKeyboard(long display, long window); + + private void grabPointer() { + if (!pointer_grabbed) { + int result = nGrabPointer(getDisplay(), getWindow(), None); + if (result == GrabSuccess) { + pointer_grabbed = true; + // make sure we have a centered window + if (isLegacyFullscreen()) { + nSetViewPort(getDisplay(), getWindow(), getDefaultScreen()); + } + } + } + } + static native int nGrabPointer(long display, long window, long cursor); + private static native void nSetViewPort(long display, long window, int screen); + + private void ungrabPointer() { + if (pointer_grabbed) { + pointer_grabbed = false; + nUngrabPointer(getDisplay()); + } + } + static native int nUngrabPointer(long display); + + private boolean isFullscreen() { + return current_window_mode == FULLSCREEN_LEGACY || current_window_mode == FULLSCREEN_NETWM; + } + + private boolean shouldGrab() { + return !input_released && grab && mouse != null; + } + + private void updatePointerGrab() { + if (isFullscreen() || shouldGrab()) { + grabPointer(); + } else { + ungrabPointer(); + } + updateCursor(); + } + + private void updateCursor() { + long cursor; + if (shouldGrab()) { + cursor = blank_cursor; + } else { + cursor = current_cursor; + } + nDefineCursor(getDisplay(), getWindow(), cursor); + } + private static native void nDefineCursor(long display, long window, long cursor_handle); + + private boolean isLegacyFullscreen() { + return current_window_mode == FULLSCREEN_LEGACY; + } + + private void updateKeyboardGrab() { + if (isLegacyFullscreen()) + grabKeyboard(); + else + ungrabKeyboard(); + } + + public void createWindow(DisplayMode mode, Canvas parent, int x, int y) throws LWJGLException { + lockAWT(); + try { + incDisplay(); + try { + ByteBuffer handle = peer_info.lockAndGetHandle(); + try { + current_window_mode = getWindowMode(Display.isFullscreen()); + boolean undecorated = Display.getPrivilegedBoolean("org.lwjgl.opengl.Window.undecorated") || current_window_mode != WINDOWED; + this.parent = parent; + parent_window = parent != null ? getHandle(parent) : getRootWindow(getDisplay(), getDefaultScreen()); + current_window = nCreateWindow(getDisplay(), getDefaultScreen(), handle, mode, current_window_mode, x, y, undecorated, parent_window); + mapRaised(getDisplay(), current_window); + xembedded = parent != null && isAncestorXEmbedded(parent_window); + blank_cursor = createBlankCursor(); + current_cursor = None; + focused = false; + input_released = false; + pointer_grabbed = false; + keyboard_grabbed = false; + close_requested = false; + grab = false; + minimized = false; + dirty = true; + } finally { + peer_info.unlock(); + } + } catch (LWJGLException e) { + decDisplay(); + throw e; + } + } finally { + unlockAWT(); + } + } + private static native long nCreateWindow(long display, int screen, ByteBuffer peer_info_handle, DisplayMode mode, int window_mode, int x, int y, boolean undecorated, long parent_handle) throws LWJGLException; + private static native long getRootWindow(long display, int screen); + private static native boolean hasProperty(long display, long window, long property); + private static native long getParentWindow(long display, long window) throws LWJGLException; + private static native void mapRaised(long display, long window); + private static native void reparentWindow(long display, long window, long parent, int x, int y); + + private boolean isAncestorXEmbedded(long window) throws LWJGLException { + long xembed_atom = internAtom("_XEMBED_INFO", true); + if (xembed_atom != None) { + long w = window; + while (w != None) { + if (hasProperty(getDisplay(), w, xembed_atom)) + return true; + w = getParentWindow(getDisplay(), w); + } + } + return false; + } + + private static long getHandle(Canvas parent) throws LWJGLException { + AWTCanvasImplementation awt_impl = AWTGLCanvas.createImplementation(); + LinuxPeerInfo parent_peer_info = (LinuxPeerInfo)awt_impl.createPeerInfo(parent, null); + ByteBuffer parent_peer_info_handle = parent_peer_info.lockAndGetHandle(); + try { + return parent_peer_info.getDrawable(); + } finally { + parent_peer_info.unlock(); + } + } + + private void updateInputGrab() { + updatePointerGrab(); + updateKeyboardGrab(); + } + + public void destroyWindow() { + lockAWT(); + try { + try { + setNativeCursor(null); + } catch (LWJGLException e) { + LWJGLUtil.log("Failed to reset cursor: " + e.getMessage()); + } + nDestroyCursor(getDisplay(), blank_cursor); + blank_cursor = None; + ungrabKeyboard(); + nDestroyWindow(getDisplay(), getWindow()); + decDisplay(); + } finally { + unlockAWT(); + } + } + static native void nDestroyWindow(long display, long window); + + public void switchDisplayMode(DisplayMode mode) throws LWJGLException { + lockAWT(); + try { + switchDisplayModeOnTmpDisplay(mode); + current_mode = mode; + } finally { + unlockAWT(); + } + } + + private void switchDisplayModeOnTmpDisplay(DisplayMode mode) throws LWJGLException { + incDisplay(); + try { + nSwitchDisplayMode(getDisplay(), getDefaultScreen(), current_displaymode_extension, mode); + } finally { + decDisplay(); + } + } + private static native void nSwitchDisplayMode(long display, int screen, int extension, DisplayMode mode) throws LWJGLException; + + private static long internAtom(String atom_name, boolean only_if_exists) throws LWJGLException { + incDisplay(); + try { + return nInternAtom(getDisplay(), atom_name, only_if_exists); + } finally { + decDisplay(); + } + } + static native long nInternAtom(long display, String atom_name, boolean only_if_exists); + + public void resetDisplayMode() { + lockAWT(); + try { + if( current_displaymode_extension == XRANDR && savedXrandrConfig.length > 0 ) + { + XRandR.setConfiguration( savedXrandrConfig ); + } + else + { + switchDisplayMode(saved_mode); + } + if (isXF86VidModeSupported()) + doSetGamma(saved_gamma); + } catch (LWJGLException e) { + LWJGLUtil.log("Caught exception while resetting mode: " + e); + } finally { + unlockAWT(); + } + } + + public int getGammaRampLength() { + if (!isXF86VidModeSupported()) + return 0; + lockAWT(); + try { + try { + incDisplay(); + try { + return nGetGammaRampLength(getDisplay(), getDefaultScreen()); + } catch (LWJGLException e) { + LWJGLUtil.log("Got exception while querying gamma length: " + e); + return 0; + } finally { + decDisplay(); + } + } catch (LWJGLException e) { + LWJGLUtil.log("Failed to get gamma ramp length: " + e); + return 0; + } + } finally { + unlockAWT(); + } + } + private static native int nGetGammaRampLength(long display, int screen) throws LWJGLException; + + public void setGammaRamp(FloatBuffer gammaRamp) throws LWJGLException { + if (!isXF86VidModeSupported()) + throw new LWJGLException("No gamma ramp support (Missing XF86VM extension)"); + doSetGamma(convertToNativeRamp(gammaRamp)); + } + + private void doSetGamma(ByteBuffer native_gamma) throws LWJGLException { + lockAWT(); + try { + setGammaRampOnTmpDisplay(native_gamma); + current_gamma = native_gamma; + } finally { + unlockAWT(); + } + } + + private void setGammaRampOnTmpDisplay(ByteBuffer native_gamma) throws LWJGLException { + incDisplay(); + try { + nSetGammaRamp(getDisplay(), getDefaultScreen(), native_gamma); + } finally { + decDisplay(); + } + } + private static native void nSetGammaRamp(long display, int screen, ByteBuffer gammaRamp) throws LWJGLException; + + private static ByteBuffer convertToNativeRamp(FloatBuffer ramp) throws LWJGLException { + return nConvertToNativeRamp(ramp, ramp.position(), ramp.remaining()); + } + private static native ByteBuffer nConvertToNativeRamp(FloatBuffer ramp, int offset, int length) throws LWJGLException; + + public String getAdapter() { + return null; + } + + public String getVersion() { + return null; + } + + public DisplayMode init() throws LWJGLException { + lockAWT(); + try { + delete_atom = internAtom("WM_DELETE_WINDOW", false); + current_displaymode_extension = getBestDisplayModeExtension(); + if (current_displaymode_extension == NONE) + throw new LWJGLException("No display mode extension is available"); + DisplayMode[] modes = getAvailableDisplayModes(); + if (modes == null || modes.length == 0) + throw new LWJGLException("No modes available"); + switch (current_displaymode_extension) { + case XRANDR: + savedXrandrConfig = XRandR.getConfiguration(); + saved_mode = getCurrentXRandrMode(); + break; + case XF86VIDMODE: + saved_mode = modes[0]; + break; + default: + throw new LWJGLException("Unknown display mode extension: " + current_displaymode_extension); + } + current_mode = saved_mode; + saved_gamma = getCurrentGammaRamp(); + current_gamma = saved_gamma; + return saved_mode; + } finally { + unlockAWT(); + } + } + + private static DisplayMode getCurrentXRandrMode() throws LWJGLException { + lockAWT(); + try { + incDisplay(); + try { + return nGetCurrentXRandrMode(getDisplay(), getDefaultScreen()); + } finally { + decDisplay(); + } + } finally { + unlockAWT(); + } + } + + /** Assumes extension == XRANDR */ + private static native DisplayMode nGetCurrentXRandrMode(long display, int screen) throws LWJGLException; + + public void setTitle(String title) { + lockAWT(); + try { + nSetTitle(getDisplay(), getWindow(), title); + } finally { + unlockAWT(); + } + } + private static native void nSetTitle(long display, long window, String title); + + public boolean isCloseRequested() { + boolean result = close_requested; + close_requested = false; + return result; + } + + public boolean isVisible() { + return !minimized; + } + + public boolean isActive() { + return focused || isLegacyFullscreen(); + } + + public boolean isDirty() { + boolean result = dirty; + dirty = false; + return result; + } + + public PeerInfo createPeerInfo(PixelFormat pixel_format) throws LWJGLException { + peer_info = new LinuxDisplayPeerInfo(pixel_format); + return peer_info; + } + + static native void setInputFocus(long display, long window, long time); + + private void relayEventToParent(LinuxEvent event_buffer, int event_mask) { + tmp_event_buffer.copyFrom(event_buffer); + tmp_event_buffer.setWindow(parent_window); + tmp_event_buffer.sendEvent(getDisplay(), parent_window, true, event_mask); + } + + private void relayEventToParent(LinuxEvent event_buffer) { + if (parent == null) + return; + switch (event_buffer.getType()) { + case LinuxEvent.KeyPress: + relayEventToParent(event_buffer, KeyPressMask); + break; + case LinuxEvent.KeyRelease: + relayEventToParent(event_buffer, KeyPressMask); + break; + case LinuxEvent.ButtonPress: + relayEventToParent(event_buffer, KeyPressMask); + break; + case LinuxEvent.ButtonRelease: + relayEventToParent(event_buffer, KeyPressMask); + break; + default: + break; + } + } + + private void processEvents() { + while (LinuxEvent.getPending(getDisplay()) > 0) { + event_buffer.nextEvent(getDisplay()); + long event_window = event_buffer.getWindow(); + relayEventToParent(event_buffer); + if (event_window != getWindow() || event_buffer.filterEvent(event_window) || + (mouse != null && mouse.filterEvent(grab, shouldWarpPointer(), event_buffer)) || + (keyboard != null && keyboard.filterEvent(event_buffer))) + continue; + switch (event_buffer.getType()) { + case LinuxEvent.FocusIn: + setFocused(true, event_buffer.getFocusDetail()); + break; + case LinuxEvent.FocusOut: + setFocused(false, event_buffer.getFocusDetail()); + break; + case LinuxEvent.ClientMessage: + if ((event_buffer.getClientFormat() == 32) && (event_buffer.getClientData(0) == delete_atom)) + close_requested = true; + break; + case LinuxEvent.MapNotify: + dirty = true; + minimized = false; + break; + case LinuxEvent.UnmapNotify: + dirty = true; + minimized = true; + break; + case LinuxEvent.Expose: + dirty = true; + break; + default: + break; + } + } + } + + public void update() { + lockAWT(); + try { + processEvents(); + checkInput(); + } finally { + unlockAWT(); + } + } + + public void reshape(int x, int y, int width, int height) { + lockAWT(); + try { + nReshape(getDisplay(), getWindow(), x, y, width, height); + } finally { + unlockAWT(); + } + } + private static native void nReshape(long display, long window, int x, int y, int width, int height); + + public DisplayMode[] getAvailableDisplayModes() throws LWJGLException { + lockAWT(); + try { + incDisplay(); + try { + DisplayMode[] modes = nGetAvailableDisplayModes(getDisplay(), getDefaultScreen(), current_displaymode_extension); + return modes; + } finally { + decDisplay(); + } + } finally { + unlockAWT(); + } + } + private static native DisplayMode[] nGetAvailableDisplayModes(long display, int screen, int extension) throws LWJGLException; + + /* Mouse */ + public boolean hasWheel() { + return true; + } + + public int getButtonCount() { + return mouse.getButtonCount(); + } + + public void createMouse() throws LWJGLException { + lockAWT(); + try { + mouse = new LinuxMouse(getDisplay(), getWindow(), getWindow()); + } finally { + unlockAWT(); + } + } + + public void destroyMouse() { + mouse = null; + updateInputGrab(); + } + + public void pollMouse(IntBuffer coord_buffer, ByteBuffer buttons) { + lockAWT(); + try { + mouse.poll(grab, coord_buffer, buttons); + } finally { + unlockAWT(); + } + } + + public void readMouse(ByteBuffer buffer) { + lockAWT(); + try { + mouse.read(buffer); + } finally { + unlockAWT(); + } + } + + public void setCursorPosition(int x, int y) { + lockAWT(); + try { + mouse.setCursorPosition(x, y); + } finally { + unlockAWT(); + } + } + + private void checkInput() { + if (parent == null) return; + + if (parent_focus != parent.hasFocus()) { + parent_focus = parent.hasFocus(); + + if (parent_focus) { + setInputFocusUnsafe(current_window); + } + else if (xembedded) { + setInputFocusUnsafe(0); + } + } + else if (parent_focus && !focused) { + setInputFocusUnsafe(current_window); + } + } + + private void setFocused(boolean got_focus, int focus_detail) { + if (focused == got_focus || focus_detail == NotifyDetailNone || focus_detail == NotifyPointer || focus_detail == NotifyPointerRoot) + return; + focused = got_focus; + + if (focused) { + acquireInput(); + } + else { + releaseInput(); + } + } + static native long nGetInputFocus(long display); + + private void setInputFocusUnsafe(long window) { + try { + setInputFocus(getDisplay(), window, CurrentTime); + sync(getDisplay(), false); + } catch (LWJGLException e) { + // Since we don't have any event timings for XSetInputFocus, a race condition might give a BadMatch, which we'll catch and ignore + LWJGLUtil.log("Got exception while trying to focus: " + e); + } + } + private static native void sync(long display, boolean throw_away_events) throws LWJGLException; + + private void releaseInput() { + if (isLegacyFullscreen() || input_released) + return; + input_released = true; + updateInputGrab(); + if (current_window_mode == FULLSCREEN_NETWM) { + nIconifyWindow(getDisplay(), getWindow(), getDefaultScreen()); + try { + if( current_displaymode_extension == XRANDR && savedXrandrConfig.length > 0 ) + { + XRandR.setConfiguration( savedXrandrConfig ); + } + else + { + switchDisplayModeOnTmpDisplay(saved_mode); + } + setGammaRampOnTmpDisplay(saved_gamma); + } catch (LWJGLException e) { + LWJGLUtil.log("Failed to restore saved mode: " + e.getMessage()); + } + } + } + private static native void nIconifyWindow(long display, long window, int screen); + + private void acquireInput() { + if (isLegacyFullscreen() || !input_released) + return; + input_released = false; + updateInputGrab(); + if (current_window_mode == FULLSCREEN_NETWM) { + try { + switchDisplayModeOnTmpDisplay(current_mode); + setGammaRampOnTmpDisplay(current_gamma); + } catch (LWJGLException e) { + LWJGLUtil.log("Failed to restore mode: " + e.getMessage()); + } + } + } + + public void grabMouse(boolean new_grab) { + lockAWT(); + try { + if (new_grab != grab) { + grab = new_grab; + updateInputGrab(); + mouse.changeGrabbed(grab, shouldWarpPointer()); + } + } finally { + unlockAWT(); + } + } + + private boolean shouldWarpPointer() { + return pointer_grabbed && shouldGrab(); + } + + public int getNativeCursorCapabilities() { + lockAWT(); + try { + incDisplay(); + try { + return nGetNativeCursorCapabilities(getDisplay()); + } finally { + decDisplay(); + } + } catch (LWJGLException e) { + throw new RuntimeException(e); + } finally { + unlockAWT(); + } + } + private static native int nGetNativeCursorCapabilities(long display) throws LWJGLException; + + public void setNativeCursor(Object handle) throws LWJGLException { + current_cursor = getCursorHandle(handle); + lockAWT(); + try { + updateCursor(); + } finally { + unlockAWT(); + } + } + + public int getMinCursorSize() { + lockAWT(); + try { + incDisplay(); + try { + return nGetMinCursorSize(getDisplay(), getWindow()); + } finally { + decDisplay(); + } + } catch (LWJGLException e) { + LWJGLUtil.log("Exception occurred in getMinCursorSize: " + e); + return 0; + } finally { + unlockAWT(); + } + } + private static native int nGetMinCursorSize(long display, long window); + + public int getMaxCursorSize() { + lockAWT(); + try { + incDisplay(); + try { + return nGetMaxCursorSize(getDisplay(), getWindow()); + } finally { + decDisplay(); + } + } catch (LWJGLException e) { + LWJGLUtil.log("Exception occurred in getMaxCursorSize: " + e); + return 0; + } finally { + unlockAWT(); + } + } + private static native int nGetMaxCursorSize(long display, long window); + + /* Keyboard */ + public void createKeyboard() throws LWJGLException { + lockAWT(); + try { + keyboard = new LinuxKeyboard(getDisplay(), getWindow()); + } finally { + unlockAWT(); + } + } + + public void destroyKeyboard() { + lockAWT(); + try { + keyboard.destroy(getDisplay()); + keyboard = null; + } finally { + unlockAWT(); + } + } + + public void pollKeyboard(ByteBuffer keyDownBuffer) { + lockAWT(); + try { + keyboard.poll(keyDownBuffer); + } finally { + unlockAWT(); + } + } + + public void readKeyboard(ByteBuffer buffer) { + lockAWT(); + try { + keyboard.read(buffer); + } finally { + unlockAWT(); + } + } + + private static native long nCreateCursor(long display, int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, int images_offset, IntBuffer delays, int delays_offset) throws LWJGLException; + + private static long createBlankCursor() { + return nCreateBlankCursor(getDisplay(), getWindow()); + } + static native long nCreateBlankCursor(long display, long window); + + public Object createCursor(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, IntBuffer delays) throws LWJGLException { + lockAWT(); + try { + incDisplay(); + try { + long cursor = nCreateCursor(getDisplay(), width, height, xHotspot, yHotspot, numImages, images, images.position(), delays, delays != null ? delays.position() : -1); + return new Long(cursor); + } catch (LWJGLException e) { + decDisplay(); + throw e; + } + } finally { + unlockAWT(); + } + } + + private static long getCursorHandle(Object cursor_handle) { + return cursor_handle != null ? ((Long)cursor_handle).longValue() : None; + } + + public void destroyCursor(Object cursorHandle) { + lockAWT(); + try { + nDestroyCursor(getDisplay(), getCursorHandle(cursorHandle)); + decDisplay(); + } finally { + unlockAWT(); + } + } + static native void nDestroyCursor(long display, long cursorHandle); + + public int getPbufferCapabilities() { + lockAWT(); + try { + incDisplay(); + try { + return nGetPbufferCapabilities(getDisplay(), getDefaultScreen()); + } finally { + decDisplay(); + } + } catch (LWJGLException e) { + LWJGLUtil.log("Exception occurred in getPbufferCapabilities: " + e); + return 0; + } finally { + unlockAWT(); + } + } + private static native int nGetPbufferCapabilities(long display, int screen); + + public boolean isBufferLost(PeerInfo handle) { + return false; + } + + public PeerInfo createPbuffer(int width, int height, PixelFormat pixel_format, + IntBuffer pixelFormatCaps, + IntBuffer pBufferAttribs) throws LWJGLException { + return new LinuxPbufferPeerInfo(width, height, pixel_format); + } + + public void setPbufferAttrib(PeerInfo handle, int attrib, int value) { + throw new UnsupportedOperationException(); + } + + public void bindTexImageToPbuffer(PeerInfo handle, int buffer) { + throw new UnsupportedOperationException(); + } + + public void releaseTexImageFromPbuffer(PeerInfo handle, int buffer) { + throw new UnsupportedOperationException(); + } + + private static ByteBuffer convertIcon(ByteBuffer icon, int width, int height) { + ByteBuffer icon_rgb = BufferUtils.createByteBuffer(icon.capacity()); + int x; + int y; + byte r,g,b; + + int depth = 4; + + for (y = 0; y < height; y++) { + for (x = 0; x < width; x++) { + r = icon.get((x*4)+(y*width*4)); + g = icon.get((x*4)+(y*width*4)+1); + b = icon.get((x*4)+(y*width*4)+2); + + icon_rgb.put((x*depth)+(y*width*depth), b); // blue + icon_rgb.put((x*depth)+(y*width*depth)+1, g); // green + icon_rgb.put((x*depth)+(y*width*depth)+2, r); + } + } + return icon_rgb; + } + + private static ByteBuffer convertIconMask(ByteBuffer icon, int width, int height) { + ByteBuffer icon_mask = BufferUtils.createByteBuffer((icon.capacity()/4)/8); + int x; + int y; + byte a; + + int depth = 4; + + for (y = 0; y < height; y++) { + for (x = 0; x < width; x++) { + a = icon.get((x*4)+(y*width*4)+3); + + int mask_index = x + y*width; + int mask_byte_index = mask_index/8; + int mask_bit_index = mask_index%8; + byte bit = (((int)a) & 0xff) >= 127 ? (byte)1 : (byte)0; + byte new_byte = (byte)((icon_mask.get(mask_byte_index) | (bit< + *

  • On Windows you should supply at least one 16x16 icon and one 32x32.
  • + *
  • Linux (and similar platforms) expect one 32x32 icon.
  • + *
  • Mac OS X should be supplied one 128x128 icon
  • + * + * The implementation will use the supplied ByteBuffers with image data in RGBA and perform any conversions necessary for the specific platform. + * + * @param icons Array of icons in RGBA mode + * @return number of icons used. + */ + public int setIcon(ByteBuffer[] icons) { + lockAWT(); + try { + incDisplay(); + try { + for (int i=0;i 0) { + ByteBuffer icon_rgb = convertIcon(icons[i], dimension, dimension); + ByteBuffer icon_mask = convertIconMask(icons[i], dimension, dimension); + nSetWindowIcon(getDisplay(), getWindow(), icon_rgb, icon_rgb.capacity(), icon_mask, icon_mask.capacity(), dimension, dimension); + return 1; + } + } + return 0; + } finally { + decDisplay(); + } + } catch (LWJGLException e) { + LWJGLUtil.log("Failed to set display icon: " + e); + return 0; + } finally { + unlockAWT(); + } + } + + private static native void nSetWindowIcon(long display, long window, ByteBuffer icon_rgb, int icon_rgb_size, ByteBuffer icon_mask, int icon_mask_size, int width, int height); + + public int getWidth() { + return Display.getDisplayMode().getWidth(); + } + + public int getHeight() { + return Display.getDisplayMode().getHeight(); + } + + public boolean isInsideWindow() { + return true; + } +} diff --git a/src/java/org/lwjgl/opengl/LinuxDisplayPeerInfo.java b/src/java/org/lwjgl/opengl/LinuxDisplayPeerInfo.java new file mode 100644 index 0000000..d702170 --- /dev/null +++ b/src/java/org/lwjgl/opengl/LinuxDisplayPeerInfo.java @@ -0,0 +1,88 @@ +/* + * 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; + +import java.nio.ByteBuffer; + +import org.lwjgl.LWJGLException; + +/** + * + * @author elias_naur + * @version $Revision: 3116 $ + * $Id: LinuxDisplayPeerInfo.java 3116 2008-08-19 16:46:03Z spasi $ + */ +final class LinuxDisplayPeerInfo extends LinuxPeerInfo { + LinuxDisplayPeerInfo(PixelFormat pixel_format) throws LWJGLException { + LinuxDisplay.lockAWT(); + try { + GLContext.loadOpenGLLibrary(); + try { + LinuxDisplay.incDisplay(); + try { + initDefaultPeerInfo(LinuxDisplay.getDisplay(), LinuxDisplay.getDefaultScreen(), getHandle(), pixel_format); + } catch (LWJGLException e) { + LinuxDisplay.decDisplay(); + throw e; + } + } catch (LWJGLException e) { + GLContext.unloadOpenGLLibrary(); + throw e; + } + } finally { + LinuxDisplay.unlockAWT(); + } + } + private static native void initDefaultPeerInfo(long display, int screen, ByteBuffer peer_info_handle, PixelFormat pixel_format) throws LWJGLException; + + protected void doLockAndInitHandle() throws LWJGLException { + LinuxDisplay.lockAWT(); + try { + initDrawable(LinuxDisplay.getWindow(), getHandle()); + } finally { + LinuxDisplay.unlockAWT(); + } + } + private static native void initDrawable(long window, ByteBuffer peer_info_handle); + + protected void doUnlock() throws LWJGLException { + // NO-OP + } + + public void destroy() { + super.destroy(); + LinuxDisplay.lockAWT(); + LinuxDisplay.decDisplay(); + GLContext.unloadOpenGLLibrary(); + LinuxDisplay.unlockAWT(); + } +} diff --git a/src/java/org/lwjgl/opengl/LinuxEvent.java b/src/java/org/lwjgl/opengl/LinuxEvent.java new file mode 100644 index 0000000..a29b76e --- /dev/null +++ b/src/java/org/lwjgl/opengl/LinuxEvent.java @@ -0,0 +1,205 @@ +/* + * 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; + +import java.nio.ByteBuffer; + +/** + * Wrapper class for X11 events. + * + * @author elias_naur + * @version $Revision: 2286 $ + * $Id: LinuxPeerInfo.java 2286 2006-03-23 19:32:21Z matzon $ + */ +final class LinuxEvent { + public final static int FocusIn = 9; + public final static int FocusOut = 10; + public final static int KeyPress = 2; + public final static int KeyRelease = 3; + public final static int ButtonPress = 4; + public final static int ButtonRelease = 5; + public final static int MotionNotify = 6; + public final static int UnmapNotify = 18; + public final static int MapNotify = 19; + public final static int Expose = 12; + public final static int ClientMessage = 33; + + private final ByteBuffer event_buffer; + + LinuxEvent() { + this.event_buffer = createEventBuffer(); + } + private static native ByteBuffer createEventBuffer(); + + public void copyFrom(LinuxEvent event) { + int pos = event_buffer.position(); + int event_pos = event.event_buffer.position(); + event_buffer.put(event.event_buffer); + event_buffer.position(pos); + event.event_buffer.position(event_pos); + } + + public static native int getPending(long display); + + public void sendEvent(long display, long window, boolean propagate, long event_mask) { + nSendEvent(event_buffer, display, window, propagate, event_mask); + } + private static native void nSendEvent(ByteBuffer event_buffer, long display, long window, boolean propagate, long event_mask); + + public boolean filterEvent(long window) { + return nFilterEvent(event_buffer, window); + } + private static native boolean nFilterEvent(ByteBuffer event_buffer, long window); + + public void nextEvent(long display) { + nNextEvent(display, event_buffer); + } + private static native void nNextEvent(long display, ByteBuffer event_buffer); + + public int getType() { + return nGetType(event_buffer); + } + private static native int nGetType(ByteBuffer event_buffer); + + public long getWindow() { + return nGetWindow(event_buffer); + } + private static native long nGetWindow(ByteBuffer event_buffer); + + public void setWindow(long window) { + nSetWindow(event_buffer, window); + } + private static native void nSetWindow(ByteBuffer event_buffer, long window); + + /* Focus methods */ + + public int getFocusMode() { + return nGetFocusMode(event_buffer); + } + private static native int nGetFocusMode(ByteBuffer event_buffer); + + public int getFocusDetail() { + return nGetFocusDetail(event_buffer); + } + private static native int nGetFocusDetail(ByteBuffer event_buffer); + + /* ClientMessage methods */ + + public long getClientMessageType() { + return nGetClientMessageType(event_buffer); + } + private static native long nGetClientMessageType(ByteBuffer event_buffer); + + public int getClientData(int index) { + return nGetClientData(event_buffer, index); + } + private static native int nGetClientData(ByteBuffer event_buffer, int index); + + public int getClientFormat() { + return nGetClientFormat(event_buffer); + } + private static native int nGetClientFormat(ByteBuffer event_buffer); + + /* Button methods */ + + public long getButtonTime() { + return nGetButtonTime(event_buffer); + } + private static native long nGetButtonTime(ByteBuffer event_buffer); + + public int getButtonState() { + return nGetButtonState(event_buffer); + } + private static native int nGetButtonState(ByteBuffer event_buffer); + + public int getButtonType() { + return nGetButtonType(event_buffer); + } + private static native int nGetButtonType(ByteBuffer event_buffer); + + public int getButtonButton() { + return nGetButtonButton(event_buffer); + } + private static native int nGetButtonButton(ByteBuffer event_buffer); + + public long getButtonRoot() { + return nGetButtonRoot(event_buffer); + } + private static native long nGetButtonRoot(ByteBuffer event_buffer); + + public int getButtonXRoot() { + return nGetButtonXRoot(event_buffer); + } + private static native int nGetButtonXRoot(ByteBuffer event_buffer); + + public int getButtonYRoot() { + return nGetButtonYRoot(event_buffer); + } + private static native int nGetButtonYRoot(ByteBuffer event_buffer); + + public int getButtonX() { + return nGetButtonX(event_buffer); + } + private static native int nGetButtonX(ByteBuffer event_buffer); + + public int getButtonY() { + return nGetButtonY(event_buffer); + } + private static native int nGetButtonY(ByteBuffer event_buffer); + + /* Key methods */ + + public long getKeyAddress() { + return nGetKeyAddress(event_buffer); + } + private static native long nGetKeyAddress(ByteBuffer event_buffer); + + public long getKeyTime() { + return nGetKeyTime(event_buffer); + } + private static native int nGetKeyTime(ByteBuffer event_buffer); + + public int getKeyType() { + return nGetKeyType(event_buffer); + } + private static native int nGetKeyType(ByteBuffer event_buffer); + + public int getKeyKeyCode() { + return nGetKeyKeyCode(event_buffer); + } + private static native int nGetKeyKeyCode(ByteBuffer event_buffer); + + public int getKeyState() { + return nGetKeyState(event_buffer); + } + private static native int nGetKeyState(ByteBuffer event_buffer); +} diff --git a/src/java/org/lwjgl/opengl/LinuxKeyboard.java b/src/java/org/lwjgl/opengl/LinuxKeyboard.java new file mode 100644 index 0000000..2777671 --- /dev/null +++ b/src/java/org/lwjgl/opengl/LinuxKeyboard.java @@ -0,0 +1,353 @@ +/* + * 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; + +/** + * @author elias_naur + */ + +import java.nio.ByteBuffer; +import java.nio.CharBuffer; +import java.nio.charset.Charset; +import java.nio.charset.CharsetDecoder; + +import org.lwjgl.BufferUtils; +import org.lwjgl.LWJGLUtil; +import org.lwjgl.input.Keyboard; + +final class LinuxKeyboard { + private static final int LockMapIndex = 1; + private static final long NoSymbol = 0; + private static final long ShiftMask = 1 << 0; + private static final long LockMask = 1 << 1; + private static final int XLookupChars = 2; + private static final int XLookupBoth = 4; + + private static final int KEYBOARD_BUFFER_SIZE = 50; + + private final long xim; + private final long xic; + + private final int numlock_mask; + private final int modeswitch_mask; + private final int caps_lock_mask; + private final int shift_lock_mask; + + private final ByteBuffer compose_status; + + private final byte[] key_down_buffer = new byte[Keyboard.KEYBOARD_SIZE]; + private final EventQueue event_queue = new EventQueue(Keyboard.EVENT_SIZE); + + private final ByteBuffer tmp_event = ByteBuffer.allocate(Keyboard.EVENT_SIZE); + private final int[] temp_translation_buffer = new int[KEYBOARD_BUFFER_SIZE]; + private final ByteBuffer native_translation_buffer = BufferUtils.createByteBuffer(KEYBOARD_BUFFER_SIZE); + private final CharsetDecoder utf8_decoder = Charset.forName("UTF-8").newDecoder(); + private final CharBuffer char_buffer = CharBuffer.allocate(KEYBOARD_BUFFER_SIZE); + + // Deferred key released event, to detect key repeat + private boolean has_deferred_event; + private int deferred_keycode; + private int deferred_event_keycode; + private long deferred_nanos; + private byte deferred_key_state; + + LinuxKeyboard(long display, long window) { + long modifier_map = getModifierMapping(display); + int tmp_numlock_mask = 0; + int tmp_modeswitch_mask = 0; + int tmp_caps_lock_mask = 0; + int tmp_shift_lock_mask = 0; + if (modifier_map != 0) { + int max_keypermod = getMaxKeyPerMod(modifier_map); + // Find modifier masks + int i, j; + for (i = 0; i < 8; i++) { + for (j = 0; j < max_keypermod; j++) { + int key_code = lookupModifierMap(modifier_map, i*max_keypermod + j); + int key_sym = (int)keycodeToKeySym(display, key_code); + int mask = 1 << i; + switch (key_sym) { + case LinuxKeycodes.XK_Num_Lock: + tmp_numlock_mask |= mask; + break; + case LinuxKeycodes.XK_Mode_switch: + tmp_modeswitch_mask |= mask; + break; + case LinuxKeycodes.XK_Caps_Lock: + if (i == LockMapIndex) { + tmp_caps_lock_mask = mask; + tmp_shift_lock_mask = 0; + } + break; + case LinuxKeycodes.XK_Shift_Lock: + if (i == LockMapIndex && tmp_caps_lock_mask == 0) + tmp_shift_lock_mask = mask; + break; + default: + break; + } + } + } + freeModifierMapping(modifier_map); + } + numlock_mask = tmp_numlock_mask; + modeswitch_mask = tmp_modeswitch_mask; + caps_lock_mask = tmp_caps_lock_mask; + shift_lock_mask = tmp_shift_lock_mask; + setDetectableKeyRepeat(display, true); + xim = openIM(display); + if (xim != 0) { + xic = createIC(xim, window); + if (xic != 0) { + setupIMEventMask(display, window, xic); + } else { + destroy(display); + } + } else { + xic = 0; + } + compose_status = allocateComposeStatus(); + } + private static native long getModifierMapping(long display); + private static native void freeModifierMapping(long modifier_map); + private static native int getMaxKeyPerMod(long modifier_map); + private static native int lookupModifierMap(long modifier_map, int index); + private static native long keycodeToKeySym(long display, int key_code); + + private static native long openIM(long display); + private static native long createIC(long xim, long window); + private static native void setupIMEventMask(long display, long window, long xic); + private static native ByteBuffer allocateComposeStatus(); + + private static void setDetectableKeyRepeat(long display, boolean enabled) { + boolean success = nSetDetectableKeyRepeat(display, enabled); + if (!success) + LWJGLUtil.log("Failed to set detectable key repeat to " + enabled); + } + private static native boolean nSetDetectableKeyRepeat(long display, boolean enabled); + + public void destroy(long display) { + if (xic != 0) + destroyIC(xic); + if (xim != 0) + closeIM(xim); + setDetectableKeyRepeat(display, false); + } + private static native void destroyIC(long xic); + private static native void closeIM(long xim); + + public void read(ByteBuffer buffer) { + flushDeferredEvent(); + event_queue.copyEvents(buffer); + } + + public void poll(ByteBuffer keyDownBuffer) { + flushDeferredEvent(); + int old_position = keyDownBuffer.position(); + keyDownBuffer.put(key_down_buffer); + keyDownBuffer.position(old_position); + } + + private void putKeyboardEvent(int keycode, byte state, int ch, long nanos, boolean repeat) { + tmp_event.clear(); + tmp_event.putInt(keycode).put(state).putInt(ch).putLong(nanos).put(repeat ? (byte)1 : (byte)0); + tmp_event.flip(); + event_queue.putEvent(tmp_event); + } + + private int lookupStringISO88591(long event_ptr, int[] translation_buffer) { + int i; + + int num_chars = lookupString(event_ptr, native_translation_buffer, compose_status); + for (i = 0; i < num_chars; i++) { + translation_buffer[i] = ((int)native_translation_buffer.get(i)) & 0xff; + } + return num_chars; + } + private static native int lookupString(long event_ptr, ByteBuffer buffer, ByteBuffer compose_status); + + private int lookupStringUnicode(long event_ptr, int[] translation_buffer) { + int status = utf8LookupString(xic, event_ptr, native_translation_buffer, native_translation_buffer.position(), native_translation_buffer.remaining()); + if (status != XLookupChars && status != XLookupBoth) + return 0; + native_translation_buffer.flip(); + utf8_decoder.decode(native_translation_buffer, char_buffer, true); + native_translation_buffer.compact(); + char_buffer.flip(); + int i = 0; + while (char_buffer.hasRemaining() && i < translation_buffer.length) { + translation_buffer[i++] = char_buffer.get(); + } + char_buffer.compact(); + return i; + } + private static native int utf8LookupString(long xic, long event_ptr, ByteBuffer buffer, int pos, int size); + + private int lookupString(long event_ptr, int[] translation_buffer) { + if (xic != 0) { + return lookupStringUnicode(event_ptr, translation_buffer); + } else + return lookupStringISO88591(event_ptr, translation_buffer); + } + + private void translateEvent(long event_ptr, int keycode, byte key_state, long nanos, boolean repeat) { + int num_chars, i; + int ch; + + num_chars = lookupString(event_ptr, temp_translation_buffer); + if (num_chars > 0) { + ch = temp_translation_buffer[0]; + putKeyboardEvent(keycode, key_state, ch, nanos, repeat); + for (i = 1; i < num_chars; i++) { + ch = temp_translation_buffer[i]; + putKeyboardEvent(0, (byte)0, ch, nanos, repeat); + } + } else { + putKeyboardEvent(keycode, key_state, 0, nanos, repeat); + } + } + + private static boolean isKeypadKeysym(long keysym) { + return (0xFF80 <= keysym && keysym <= 0xFFBD) || + (0x11000000 <= keysym && keysym <= 0x1100FFFF); + } + + private static boolean isNoSymbolOrVendorSpecific(long keysym) { + return keysym == NoSymbol || (keysym & (1 << 28)) != 0; + } + + private static long getKeySym(long event_ptr, int group, int index) { + long keysym = lookupKeysym(event_ptr, group*2 + index); + if (isNoSymbolOrVendorSpecific(keysym) && index == 1) { + keysym = lookupKeysym(event_ptr, group*2 + 0); + } + if (isNoSymbolOrVendorSpecific(keysym) && group == 1) + keysym = getKeySym(event_ptr, 0, index); + return keysym; + } + private static native long lookupKeysym(long event_ptr, int index); + private static native long toUpper(long keysym); + + private long mapEventToKeySym(long event_ptr, int event_state) { + int group; + long keysym; + if ((event_state & modeswitch_mask) != 0) + group = 1; + else + group = 0; + if ((event_state & numlock_mask) != 0 && isKeypadKeysym(keysym = getKeySym(event_ptr, group, 1))) { + if ((event_state & (ShiftMask | shift_lock_mask)) != 0) { + return getKeySym(event_ptr, group, 0); + } else { + return keysym; + } + } else if ((event_state & (ShiftMask | LockMask)) == 0) { + return getKeySym(event_ptr, group, 0); + } else if ((event_state & ShiftMask) == 0) { + keysym = getKeySym(event_ptr, group, 0); + if ((event_state & caps_lock_mask) != 0) + keysym = toUpper(keysym); + return keysym; + } else { + keysym = getKeySym(event_ptr, group, 1); + if ((event_state & caps_lock_mask) != 0) + keysym = toUpper(keysym); + return keysym; + } + } + + private int getKeycode(long event_ptr, int event_state) { + long keysym = mapEventToKeySym(event_ptr, event_state); + int keycode = LinuxKeycodes.mapKeySymToLWJGLKeyCode(keysym); + if (keycode == Keyboard.KEY_NONE) { + // Try unshifted keysym mapping + keysym = lookupKeysym(event_ptr, 0); + keycode = LinuxKeycodes.mapKeySymToLWJGLKeyCode(keysym); + } + return keycode; + } + + private byte getKeyState(int event_type) { + switch (event_type) { + case LinuxEvent.KeyPress: + return 1; + case LinuxEvent.KeyRelease: + return 0; + default: + throw new IllegalArgumentException("Unknown event_type: " + event_type); + } + } + + private void handleKeyEvent(long event_ptr, long millis, int event_type, int event_keycode, int event_state) { + int keycode = getKeycode(event_ptr, event_state); + byte key_state = getKeyState(event_type); + boolean repeat = key_state == key_down_buffer[keycode]; + key_down_buffer[keycode] = key_state; + long nanos = millis*1000000; + if (event_type == LinuxEvent.KeyPress) { + if (has_deferred_event) { + if (nanos == deferred_nanos && event_keycode == deferred_event_keycode) { + has_deferred_event = false; + repeat = true; // Repeated event + } else + flushDeferredEvent(); + } + translateEvent(event_ptr, keycode, key_state, nanos, repeat); + } else { + flushDeferredEvent(); + has_deferred_event = true; + deferred_keycode = keycode; + deferred_event_keycode = event_keycode; + deferred_nanos = nanos; + deferred_key_state = key_state; + } + } + + private void flushDeferredEvent() { + if (has_deferred_event) { + putKeyboardEvent(deferred_keycode, deferred_key_state, 0, deferred_nanos, false); + has_deferred_event = false; + } + } + + public boolean filterEvent(LinuxEvent event) { + switch (event.getType()) { + case LinuxEvent.KeyPress: /* Fall through */ + case LinuxEvent.KeyRelease: + handleKeyEvent(event.getKeyAddress(), event.getKeyTime(), event.getKeyType(), event.getKeyKeyCode(), event.getKeyState()); + return true; + default: + break; + } + return false; + } +} diff --git a/src/java/org/lwjgl/opengl/LinuxKeycodes.java b/src/java/org/lwjgl/opengl/LinuxKeycodes.java new file mode 100644 index 0000000..9542d08 --- /dev/null +++ b/src/java/org/lwjgl/opengl/LinuxKeycodes.java @@ -0,0 +1,763 @@ +/* + * 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; + +/** + * @author elias_naur + */ + +import org.lwjgl.input.Keyboard; + +final class LinuxKeycodes { + public final static int XK_Kanji = 0xff21; + + public final static int XK_ISO_Left_Tab = 0xfe20; + + public final static int XK_dead_grave = 0xfe50; + public final static int XK_dead_acute = 0xfe51; + public final static int XK_dead_circumflex = 0xfe52; + public final static int XK_dead_tilde = 0xfe53; + public final static int XK_dead_macron = 0xfe54; + public final static int XK_dead_breve = 0xfe55; + public final static int XK_dead_abovedot = 0xfe56; + public final static int XK_dead_diaeresis = 0xfe57; + public final static int XK_dead_abovering = 0xfe58; + public final static int XK_dead_doubleacute = 0xfe59; + public final static int XK_dead_caron = 0xfe5a; + public final static int XK_dead_cedilla = 0xfe5b; + public final static int XK_dead_ogonek = 0xfe5c; + public final static int XK_dead_iota = 0xfe5d; + public final static int XK_dead_voiced_sound = 0xfe5e; + public final static int XK_dead_semivoiced_sound = 0xfe5f; + public final static int XK_dead_belowdot = 0xfe60; + public final static int XK_dead_hook = 0xfe61; + public final static int XK_dead_horn = 0xfe62; + + public final static int XK_BackSpace = 0xff08; + public final static int XK_Tab = 0xff09; + public final static int XK_Linefeed = 0xff0a; + public final static int XK_Clear = 0xff0b; + public final static int XK_Return = 0xff0d; + public final static int XK_Pause = 0xff13; + public final static int XK_Scroll_Lock = 0xff14; + public final static int XK_Sys_Req = 0xff15; + public final static int XK_Escape = 0xff1b; + public final static int XK_Delete = 0xffff; + + public final static int XK_Home = 0xff50; + public final static int XK_Left = 0xff51; + public final static int XK_Up = 0xff52; + public final static int XK_Right = 0xff53; + public final static int XK_Down = 0xff54; + public final static int XK_Prior = 0xff55; + public final static int XK_Page_Up = 0xff55; + public final static int XK_Next = 0xff56; + public final static int XK_Page_Down = 0xff56; + public final static int XK_End = 0xff57; + public final static int XK_Begin = 0xff58; + + +/* Misc functions */ + + public final static int XK_Select = 0xff60; + public final static int XK_Print = 0xff61; + public final static int XK_Execute = 0xff62; + public final static int XK_Insert = 0xff63; + public final static int XK_Undo = 0xff65; + public final static int XK_Redo = 0xff66; + public final static int XK_Menu = 0xff67; + public final static int XK_Find = 0xff68; + public final static int XK_Cancel = 0xff69; + public final static int XK_Help = 0xff6a; + public final static int XK_Break = 0xff6b; + public final static int XK_Mode_switch = 0xff7e; + public final static int XK_script_switch = 0xff7e; + public final static int XK_Num_Lock = 0xff7f; + +/* Keypad functions, keypad numbers cleverly chosen to map to ASCII */ + + public final static int XK_KP_Space = 0xff80; + public final static int XK_KP_Tab = 0xff89; + public final static int XK_KP_Enter = 0xff8d; + public final static int XK_KP_F1 = 0xff91; + public final static int XK_KP_F2 = 0xff92; + public final static int XK_KP_F3 = 0xff93; + public final static int XK_KP_F4 = 0xff94; + public final static int XK_KP_Home = 0xff95; + public final static int XK_KP_Left = 0xff96; + public final static int XK_KP_Up = 0xff97; + public final static int XK_KP_Right = 0xff98; + public final static int XK_KP_Down = 0xff99; + public final static int XK_KP_Prior = 0xff9a; + public final static int XK_KP_Page_Up = 0xff9a; + public final static int XK_KP_Next = 0xff9b; + public final static int XK_KP_Page_Down = 0xff9b; + public final static int XK_KP_End = 0xff9c; + public final static int XK_KP_Begin = 0xff9d; + public final static int XK_KP_Insert = 0xff9e; + public final static int XK_KP_Delete = 0xff9f; + public final static int XK_KP_Equal = 0xffbd; + public final static int XK_KP_Multiply = 0xffaa; + public final static int XK_KP_Add = 0xffab; + public final static int XK_KP_Separator = 0xffac; + public final static int XK_KP_Subtract = 0xffad; + public final static int XK_KP_Decimal = 0xffae; + public final static int XK_KP_Divide = 0xffaf; + + public final static int XK_KP_0 = 0xffb0; + public final static int XK_KP_1 = 0xffb1; + public final static int XK_KP_2 = 0xffb2; + public final static int XK_KP_3 = 0xffb3; + public final static int XK_KP_4 = 0xffb4; + public final static int XK_KP_5 = 0xffb5; + public final static int XK_KP_6 = 0xffb6; + public final static int XK_KP_7 = 0xffb7; + public final static int XK_KP_8 = 0xffb8; + public final static int XK_KP_9 = 0xffb9; + + + +/* + * Auxilliary functions; note the duplicate definitions for left and right + * function keys; Sun keyboards and a few other manufactures have such + * function key groups on the left and/or right sides of the keyboard. + * We've not found a keyboard with more than 35 function keys total. + */ + + public final static int XK_F1 = 0xffbe; + public final static int XK_F2 = 0xffbf; + public final static int XK_F3 = 0xffc0; + public final static int XK_F4 = 0xffc1; + public final static int XK_F5 = 0xffc2; + public final static int XK_F6 = 0xffc3; + public final static int XK_F7 = 0xffc4; + public final static int XK_F8 = 0xffc5; + public final static int XK_F9 = 0xffc6; + public final static int XK_F10 = 0xffc7; + public final static int XK_F11 = 0xffc8; + public final static int XK_L1 = 0xffc8; + public final static int XK_F12 = 0xffc9; + public final static int XK_L2 = 0xffc9; + public final static int XK_F13 = 0xffca; + public final static int XK_L3 = 0xffca; + public final static int XK_F14 = 0xffcb; + public final static int XK_L4 = 0xffcb; + public final static int XK_F15 = 0xffcc; + public final static int XK_L5 = 0xffcc; + public final static int XK_F16 = 0xffcd; + public final static int XK_L6 = 0xffcd; + public final static int XK_F17 = 0xffce; + public final static int XK_L7 = 0xffce; + public final static int XK_F18 = 0xffcf; + public final static int XK_L8 = 0xffcf; + public final static int XK_F19 = 0xffd0; + public final static int XK_L9 = 0xffd0; + public final static int XK_F20 = 0xffd1; + public final static int XK_L10 = 0xffd1; + public final static int XK_F21 = 0xffd2; + public final static int XK_R1 = 0xffd2; + public final static int XK_F22 = 0xffd3; + public final static int XK_R2 = 0xffd3; + public final static int XK_F23 = 0xffd4; + public final static int XK_R3 = 0xffd4; + public final static int XK_F24 = 0xffd5; + public final static int XK_R4 = 0xffd5; + public final static int XK_F25 = 0xffd6; + public final static int XK_R5 = 0xffd6; + public final static int XK_F26 = 0xffd7; + public final static int XK_R6 = 0xffd7; + public final static int XK_F27 = 0xffd8; + public final static int XK_R7 = 0xffd8; + public final static int XK_F28 = 0xffd9; + public final static int XK_R8 = 0xffd9; + public final static int XK_F29 = 0xffda; + public final static int XK_R9 = 0xffda; + public final static int XK_F30 = 0xffdb; + public final static int XK_R10 = 0xffdb; + public final static int XK_F31 = 0xffdc; + public final static int XK_R11 = 0xffdc; + public final static int XK_F32 = 0xffdd; + public final static int XK_R12 = 0xffdd; + public final static int XK_F33 = 0xffde; + public final static int XK_R13 = 0xffde; + public final static int XK_F34 = 0xffdf; + public final static int XK_R14 = 0xffdf; + public final static int XK_F35 = 0xffe0; + public final static int XK_R15 = 0xffe0; + +/* Modifiers */ + + public final static int XK_Shift_L = 0xffe1; + public final static int XK_Shift_R = 0xffe2; + public final static int XK_Control_L = 0xffe3; + public final static int XK_Control_R = 0xffe4; + public final static int XK_Caps_Lock = 0xffe5; + public final static int XK_Shift_Lock = 0xffe6; + + public final static int XK_Meta_L = 0xffe7; + public final static int XK_Meta_R = 0xffe8; + public final static int XK_Alt_L = 0xffe9; + public final static int XK_Alt_R = 0xffea; + public final static int XK_Super_L = 0xffeb; + public final static int XK_Super_R = 0xffec; + public final static int XK_Hyper_L = 0xffed; + public final static int XK_Hyper_R = 0xffee; + public final static int XK_space = 0x0020; + public final static int XK_exclam = 0x0021; + public final static int XK_quotedbl = 0x0022; + public final static int XK_numbersign = 0x0023; + public final static int XK_dollar = 0x0024; + public final static int XK_percent = 0x0025; + public final static int XK_ampersand = 0x0026; + public final static int XK_apostrophe = 0x0027; + public final static int XK_quoteright = 0x0027; + public final static int XK_parenleft = 0x0028; + public final static int XK_parenright = 0x0029; + public final static int XK_asterisk = 0x002a; + public final static int XK_plus = 0x002b; + public final static int XK_comma = 0x002c; + public final static int XK_minus = 0x002d; + public final static int XK_period = 0x002e; + public final static int XK_slash = 0x002f; + + public final static int XK_0 = 0x0030; + public final static int XK_1 = 0x0031; + public final static int XK_2 = 0x0032; + public final static int XK_3 = 0x0033; + public final static int XK_4 = 0x0034; + public final static int XK_5 = 0x0035; + public final static int XK_6 = 0x0036; + public final static int XK_7 = 0x0037; + public final static int XK_8 = 0x0038; + public final static int XK_9 = 0x0039; + public final static int XK_colon = 0x003a; + public final static int XK_semicolon = 0x003b; + public final static int XK_less = 0x003c; + public final static int XK_equal = 0x003d; + public final static int XK_greater = 0x003e; + public final static int XK_question = 0x003f; + public final static int XK_at = 0x0040; + public final static int XK_A = 0x0041; + public final static int XK_B = 0x0042; + public final static int XK_C = 0x0043; + public final static int XK_D = 0x0044; + public final static int XK_E = 0x0045; + public final static int XK_F = 0x0046; + public final static int XK_G = 0x0047; + public final static int XK_H = 0x0048; + public final static int XK_I = 0x0049; + public final static int XK_J = 0x004a; + public final static int XK_K = 0x004b; + public final static int XK_L = 0x004c; + public final static int XK_M = 0x004d; + public final static int XK_N = 0x004e; + public final static int XK_O = 0x004f; + public final static int XK_P = 0x0050; + public final static int XK_Q = 0x0051; + public final static int XK_R = 0x0052; + public final static int XK_S = 0x0053; + public final static int XK_T = 0x0054; + public final static int XK_U = 0x0055; + public final static int XK_V = 0x0056; + public final static int XK_W = 0x0057; + public final static int XK_X = 0x0058; + public final static int XK_Y = 0x0059; + public final static int XK_Z = 0x005a; + public final static int XK_bracketleft = 0x005b; + public final static int XK_backslash = 0x005c; + public final static int XK_bracketright = 0x005d; + public final static int XK_asciicircum = 0x005e; + public final static int XK_underscore = 0x005f; + public final static int XK_grave = 0x0060; + public final static int XK_quoteleft = 0x0060; + public final static int XK_a = 0x0061; + public final static int XK_b = 0x0062; + public final static int XK_c = 0x0063; + public final static int XK_d = 0x0064; + public final static int XK_e = 0x0065; + public final static int XK_f = 0x0066; + public final static int XK_g = 0x0067; + public final static int XK_h = 0x0068; + public final static int XK_i = 0x0069; + public final static int XK_j = 0x006a; + public final static int XK_k = 0x006b; + public final static int XK_l = 0x006c; + public final static int XK_m = 0x006d; + public final static int XK_n = 0x006e; + public final static int XK_o = 0x006f; + public final static int XK_p = 0x0070; + public final static int XK_q = 0x0071; + public final static int XK_r = 0x0072; + public final static int XK_s = 0x0073; + public final static int XK_t = 0x0074; + public final static int XK_u = 0x0075; + public final static int XK_v = 0x0076; + public final static int XK_w = 0x0077; + public final static int XK_x = 0x0078; + public final static int XK_y = 0x0079; + public final static int XK_z = 0x007a; + public final static int XK_braceleft = 0x007b; + public final static int XK_bar = 0x007c; + public final static int XK_braceright = 0x007d; + public final static int XK_asciitilde = 0x007e; + + public final static int XK_nobreakspace = 0x00a0; + public final static int XK_exclamdown = 0x00a1; + public final static int XK_cent = 0x00a2; + public final static int XK_sterling = 0x00a3; + public final static int XK_currency = 0x00a4; + public final static int XK_yen = 0x00a5; + public final static int XK_brokenbar = 0x00a6; + public final static int XK_section = 0x00a7; + public final static int XK_diaeresis = 0x00a8; + public final static int XK_copyright = 0x00a9; + public final static int XK_ordfeminine = 0x00aa; + public final static int XK_guillemotleft = 0x00ab; + public final static int XK_notsign = 0x00ac; + public final static int XK_hyphen = 0x00ad; + public final static int XK_registered = 0x00ae; + public final static int XK_macron = 0x00af; + public final static int XK_degree = 0x00b0; + public final static int XK_plusminus = 0x00b1; + public final static int XK_twosuperior = 0x00b2; + public final static int XK_threesuperior = 0x00b3; + public final static int XK_acute = 0x00b4; + public final static int XK_mu = 0x00b5; + public final static int XK_paragraph = 0x00b6; + public final static int XK_periodcentered = 0x00b7; + public final static int XK_cedilla = 0x00b8; + public final static int XK_onesuperior = 0x00b9; + public final static int XK_masculine = 0x00ba; + public final static int XK_guillemotright = 0x00bb; + public final static int XK_onequarter = 0x00bc; + public final static int XK_onehalf = 0x00bd; + public final static int XK_threequarters = 0x00be; + public final static int XK_questiondown = 0x00bf; + public final static int XK_Agrave = 0x00c0; + public final static int XK_Aacute = 0x00c1; + public final static int XK_Acircumflex = 0x00c2; + public final static int XK_Atilde = 0x00c3; + public final static int XK_Adiaeresis = 0x00c4; + public final static int XK_Aring = 0x00c5; + public final static int XK_AE = 0x00c6; + public final static int XK_Ccedilla = 0x00c7; + public final static int XK_Egrave = 0x00c8; + public final static int XK_Eacute = 0x00c9; + public final static int XK_Ecircumflex = 0x00ca; + public final static int XK_Ediaeresis = 0x00cb; + public final static int XK_Igrave = 0x00cc; + public final static int XK_Iacute = 0x00cd; + public final static int XK_Icircumflex = 0x00ce; + public final static int XK_Idiaeresis = 0x00cf; + public final static int XK_ETH = 0x00d0; + public final static int XK_Eth = 0x00d0; + public final static int XK_Ntilde = 0x00d1; + public final static int XK_Ograve = 0x00d2; + public final static int XK_Oacute = 0x00d3; + public final static int XK_Ocircumflex = 0x00d4; + public final static int XK_Otilde = 0x00d5; + public final static int XK_Odiaeresis = 0x00d6; + public final static int XK_multiply = 0x00d7; + public final static int XK_Oslash = 0x00d8; + public final static int XK_Ooblique = 0x00d8; + public final static int XK_Ugrave = 0x00d9; + public final static int XK_Uacute = 0x00da; + public final static int XK_Ucircumflex = 0x00db; + public final static int XK_Udiaeresis = 0x00dc; + public final static int XK_Yacute = 0x00dd; + public final static int XK_THORN = 0x00de; + public final static int XK_Thorn = 0x00de; + public final static int XK_ssharp = 0x00df; + public final static int XK_agrave = 0x00e0; + public final static int XK_aacute = 0x00e1; + public final static int XK_acircumflex = 0x00e2; + public final static int XK_atilde = 0x00e3; + public final static int XK_adiaeresis = 0x00e4; + public final static int XK_aring = 0x00e5; + public final static int XK_ae = 0x00e6; + public final static int XK_ccedilla = 0x00e7; + public final static int XK_egrave = 0x00e8; + public final static int XK_eacute = 0x00e9; + public final static int XK_ecircumflex = 0x00ea; + public final static int XK_ediaeresis = 0x00eb; + public final static int XK_igrave = 0x00ec; + public final static int XK_iacute = 0x00ed; + public final static int XK_icircumflex = 0x00ee; + public final static int XK_idiaeresis = 0x00ef; + public final static int XK_eth = 0x00f0; + public final static int XK_ntilde = 0x00f1; + public final static int XK_ograve = 0x00f2; + public final static int XK_oacute = 0x00f3; + public final static int XK_ocircumflex = 0x00f4; + public final static int XK_otilde = 0x00f5; + public final static int XK_odiaeresis = 0x00f6; + public final static int XK_division = 0x00f7; + public final static int XK_oslash = 0x00f8; + public final static int XK_ooblique = 0x00f8; + public final static int XK_ugrave = 0x00f9; + public final static int XK_uacute = 0x00fa; + public final static int XK_ucircumflex = 0x00fb; + public final static int XK_udiaeresis = 0x00fc; + public final static int XK_yacute = 0x00fd; + public final static int XK_thorn = 0x00fe; + public final static int XK_ydiaeresis = 0x00ff; + + public final static int XK_ISO_Level3_Shift = 0xfe03; + + public static int mapKeySymToLWJGLKeyCode(long keysym) { + switch ((int)keysym) { + case XK_BackSpace: + return Keyboard.KEY_BACK; + case XK_ISO_Left_Tab: + case XK_Tab: + return Keyboard.KEY_TAB; + case XK_Return: + return Keyboard.KEY_RETURN; + case XK_Pause: + return Keyboard.KEY_PAUSE; + case XK_Scroll_Lock: + return Keyboard.KEY_SCROLL; + case XK_Sys_Req: + return Keyboard.KEY_SYSRQ; + case XK_Escape: + return Keyboard.KEY_ESCAPE; + case XK_Delete: + return Keyboard.KEY_DELETE; + + /* Japanese keyboard support */ + + case XK_Kanji: + return Keyboard.KEY_KANJI; + + /* Cursor control & motion */ + + case XK_Home: + return Keyboard.KEY_HOME; + case XK_Left: + return Keyboard.KEY_LEFT; + case XK_Up: + return Keyboard.KEY_UP; + case XK_Right: + return Keyboard.KEY_RIGHT; + case XK_Down: + return Keyboard.KEY_DOWN; + case XK_Page_Up: + return Keyboard.KEY_PRIOR; + case XK_Page_Down: + return Keyboard.KEY_NEXT; + case XK_End: + return Keyboard.KEY_END; + + + /* Misc Functions */ + + case XK_Break: + return Keyboard.KEY_PAUSE; + case XK_Insert: + return Keyboard.KEY_INSERT; + case XK_Num_Lock: + return Keyboard.KEY_NUMLOCK; + + /* Keypad Functions, keypad numbers cleverly chosen to map to ascii */ + + case XK_KP_Space: + return Keyboard.KEY_SPACE; + case XK_KP_Tab: + return Keyboard.KEY_TAB; + case XK_KP_Enter: + return Keyboard.KEY_NUMPADENTER; + case XK_KP_F1: + return Keyboard.KEY_F1; + case XK_KP_F2: + return Keyboard.KEY_F2; + case XK_KP_F3: + return Keyboard.KEY_F3; + case XK_KP_F4: + return Keyboard.KEY_F4; + case XK_KP_Home: + return Keyboard.KEY_HOME; + case XK_KP_Left: + return Keyboard.KEY_LEFT; + case XK_KP_Up: + return Keyboard.KEY_UP; + case XK_KP_Right: + return Keyboard.KEY_RIGHT; + case XK_KP_Down: + return Keyboard.KEY_DOWN; + case XK_KP_Page_Up: + return Keyboard.KEY_PRIOR; + case XK_KP_Page_Down: + return Keyboard.KEY_NEXT; + case XK_KP_End: + return Keyboard.KEY_END; + case XK_KP_Insert: + return Keyboard.KEY_INSERT; + case XK_KP_Delete: + return Keyboard.KEY_DELETE; + case XK_KP_Equal: + return Keyboard.KEY_NUMPADEQUALS; + case XK_KP_Multiply: + return Keyboard.KEY_MULTIPLY; + case XK_KP_Add: + return Keyboard.KEY_ADD; + case XK_KP_Subtract: + return Keyboard.KEY_SUBTRACT; + case XK_KP_Decimal: + return Keyboard.KEY_DECIMAL; + case XK_KP_Divide: + return Keyboard.KEY_DIVIDE; + + case XK_KP_0: + return Keyboard.KEY_NUMPAD0; + case XK_KP_1: + return Keyboard.KEY_NUMPAD1; + case XK_KP_2: + return Keyboard.KEY_NUMPAD2; + case XK_KP_3: + return Keyboard.KEY_NUMPAD3; + case XK_KP_4: + return Keyboard.KEY_NUMPAD4; + case XK_KP_5: + return Keyboard.KEY_NUMPAD5; + case XK_KP_6: + return Keyboard.KEY_NUMPAD6; + case XK_KP_7: + return Keyboard.KEY_NUMPAD7; + case XK_KP_8: + return Keyboard.KEY_NUMPAD8; + case XK_KP_9: + return Keyboard.KEY_NUMPAD9; + + /* + * Auxilliary Functions; note the duplicate definitions for left and right + * function keys; Sun keyboards and a few other manufactures have such + * function key groups on the left and/or right sides of the keyboard. + * We've not found a keyboard with more than 35 function keys total. + */ + + case XK_F1: + return Keyboard.KEY_F1; + case XK_F2: + return Keyboard.KEY_F2; + case XK_F3: + return Keyboard.KEY_F3; + case XK_F4: + return Keyboard.KEY_F4; + case XK_F5: + return Keyboard.KEY_F5; + case XK_F6: + return Keyboard.KEY_F6; + case XK_F7: + return Keyboard.KEY_F7; + case XK_F8: + return Keyboard.KEY_F8; + case XK_F9: + return Keyboard.KEY_F9; + case XK_F10: + return Keyboard.KEY_F10; + case XK_F11: + return Keyboard.KEY_F11; + case XK_F12: + return Keyboard.KEY_F12; + case XK_F13: + return Keyboard.KEY_F13; + case XK_F14: + return Keyboard.KEY_F14; + case XK_F15: + return Keyboard.KEY_F15; + + /* Modifiers */ + + case XK_Shift_L: + return Keyboard.KEY_LSHIFT; + case XK_Shift_R: + return Keyboard.KEY_RSHIFT; + case XK_Control_L: + return Keyboard.KEY_LCONTROL; + case XK_Control_R: + return Keyboard.KEY_RCONTROL; + case XK_Caps_Lock: + return Keyboard.KEY_CAPITAL; + + case XK_Meta_L: + return Keyboard.KEY_LMENU; + case XK_ISO_Level3_Shift: + case XK_Meta_R: + return Keyboard.KEY_RMENU; + case XK_Alt_L: + return Keyboard.KEY_LMENU; + case XK_Alt_R: + return Keyboard.KEY_RMENU; + + case XK_dead_grave: + return Keyboard.KEY_GRAVE; + case XK_dead_circumflex: + return Keyboard.KEY_CIRCUMFLEX; + + /* + * Latin 1 + * Byte 3 = 0 + */ + case XK_space: + return Keyboard.KEY_SPACE; + case XK_apostrophe: + return Keyboard.KEY_APOSTROPHE; + case XK_comma: + return Keyboard.KEY_COMMA; + case XK_minus: + return Keyboard.KEY_MINUS; + case XK_period: + return Keyboard.KEY_PERIOD; + case XK_slash: + return Keyboard.KEY_SLASH; + case XK_0: + return Keyboard.KEY_0; + case XK_1: + return Keyboard.KEY_1; + case XK_2: + return Keyboard.KEY_2; + case XK_3: + return Keyboard.KEY_3; + case XK_4: + return Keyboard.KEY_4; + case XK_5: + return Keyboard.KEY_5; + case XK_6: + return Keyboard.KEY_6; + case XK_7: + return Keyboard.KEY_7; + case XK_8: + return Keyboard.KEY_8; + case XK_9: + return Keyboard.KEY_9; + case XK_colon: + return Keyboard.KEY_COLON; + case XK_semicolon: + return Keyboard.KEY_SEMICOLON; + case XK_equal: + return Keyboard.KEY_EQUALS; + case XK_at: + return Keyboard.KEY_AT; + case XK_bracketleft: + return Keyboard.KEY_LBRACKET; + case XK_bracketright: + return Keyboard.KEY_RBRACKET; + case XK_asciicircum: + return Keyboard.KEY_CIRCUMFLEX; + case XK_underscore: + return Keyboard.KEY_UNDERLINE; + case XK_grave: + return Keyboard.KEY_GRAVE; + case XK_a: + case XK_A: + return Keyboard.KEY_A; + case XK_b: + case XK_B: + return Keyboard.KEY_B; + case XK_c: + case XK_C: + return Keyboard.KEY_C; + case XK_d: + case XK_D: + return Keyboard.KEY_D; + case XK_e: + case XK_E: + return Keyboard.KEY_E; + case XK_f: + case XK_F: + return Keyboard.KEY_F; + case XK_g: + case XK_G: + return Keyboard.KEY_G; + case XK_h: + case XK_H: + return Keyboard.KEY_H; + case XK_i: + case XK_I: + return Keyboard.KEY_I; + case XK_j: + case XK_J: + return Keyboard.KEY_J; + case XK_k: + case XK_K: + return Keyboard.KEY_K; + case XK_l: + case XK_L: + return Keyboard.KEY_L; + case XK_m: + case XK_M: + return Keyboard.KEY_M; + case XK_n: + case XK_N: + return Keyboard.KEY_N; + case XK_o: + case XK_O: + return Keyboard.KEY_O; + case XK_p: + case XK_P: + return Keyboard.KEY_P; + case XK_q: + case XK_Q: + return Keyboard.KEY_Q; + case XK_r: + case XK_R: + return Keyboard.KEY_R; + case XK_s: + case XK_S: + return Keyboard.KEY_S; + case XK_t: + case XK_T: + return Keyboard.KEY_T; + case XK_u: + case XK_U: + return Keyboard.KEY_U; + case XK_v: + case XK_V: + return Keyboard.KEY_V; + case XK_w: + case XK_W: + return Keyboard.KEY_W; + case XK_x: + case XK_X: + return Keyboard.KEY_X; + case XK_y: + case XK_Y: + return Keyboard.KEY_Y; + case XK_z: + case XK_Z: + return Keyboard.KEY_Z; + default: + return Keyboard.KEY_NONE; + } + } + +} diff --git a/src/java/org/lwjgl/opengl/LinuxMouse.java b/src/java/org/lwjgl/opengl/LinuxMouse.java new file mode 100644 index 0000000..407d926 --- /dev/null +++ b/src/java/org/lwjgl/opengl/LinuxMouse.java @@ -0,0 +1,292 @@ +/* + * 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; + +/** + * @author elias_naur + */ + +import java.nio.ByteBuffer; +import java.nio.IntBuffer; + +import org.lwjgl.BufferUtils; +import org.lwjgl.LWJGLException; +import org.lwjgl.input.Mouse; + +final class LinuxMouse { + private static final int NUM_BUTTONS = 3; + private static final int POINTER_WARP_BORDER = 10; + // scale the mouse wheel according to DirectInput + private static final int WHEEL_SCALE = 120; + + /* X11 constants */ + private final static int Button1 = 1; + private final static int Button2 = 2; + private final static int Button3 = 3; + private final static int Button4 = 4; + private final static int Button5 = 5; + + private final static int ButtonPress = 4; + private final static int ButtonRelease = 5; + + private final long display; + private final long window; + private final long input_window; + private final long warp_atom; + private final IntBuffer query_pointer_buffer = BufferUtils.createIntBuffer(4); + private final ByteBuffer event_buffer = ByteBuffer.allocate(Mouse.EVENT_SIZE); + + private int last_x; + private int last_y; + private int accum_dx; + private int accum_dy; + private int accum_dz; + private byte[] buttons = new byte[NUM_BUTTONS]; + private EventQueue event_queue; + private long last_event_nanos; + + LinuxMouse(long display, long window, long input_window) throws LWJGLException { + this.display = display; + this.window = window; + this.input_window = input_window; + this.warp_atom = LinuxDisplay.nInternAtom(display, "_LWJGL", false); + reset(false, false); + } + + private void reset(boolean grab, boolean warp_pointer) { + event_queue = new EventQueue(event_buffer.capacity()); + accum_dx = accum_dy = 0; + long root_window = nQueryPointer(display, window, query_pointer_buffer); + + int root_x = query_pointer_buffer.get(0); + int root_y = query_pointer_buffer.get(1); + int win_x = query_pointer_buffer.get(2); + int win_y = query_pointer_buffer.get(3); + // Pretend that the cursor never moved + last_x = win_x; + last_y = transformY(win_y); + doHandlePointerMotion(grab, warp_pointer, root_window, root_x, root_y, win_x, win_y, last_event_nanos); + } + + public void read(ByteBuffer buffer) { + event_queue.copyEvents(buffer); + } + + public void poll(boolean grab, IntBuffer coord_buffer, ByteBuffer buttons_buffer) { + if (grab) { + coord_buffer.put(0, accum_dx); + coord_buffer.put(1, accum_dy); + } else { + coord_buffer.put(0, last_x); + coord_buffer.put(1, last_y); + } + coord_buffer.put(2, accum_dz); + accum_dx = accum_dy = accum_dz = 0; + for (int i = 0; i < buttons.length; i++) + buttons_buffer.put(i, buttons[i]); + } + + private void putMouseEventWithCoords(byte button, byte state, int coord1, int coord2, int dz, long nanos) { + event_buffer.clear(); + event_buffer.put(button).put(state).putInt(coord1).putInt(coord2).putInt(dz).putLong(nanos); + event_buffer.flip(); + event_queue.putEvent(event_buffer); + last_event_nanos = nanos; + } + + private void setCursorPos(boolean grab, int x, int y, long nanos) { + y = transformY(y); + int dx = x - last_x; + int dy = y - last_y; + if (dx != 0 || dy != 0) { + accum_dx += dx; + accum_dy += dy; + last_x = x; + last_y = y; + if (grab) { + putMouseEventWithCoords((byte)-1, (byte)0, dx, dy, 0, nanos); + } else { + putMouseEventWithCoords((byte)-1, (byte)0, x, y, 0, nanos); + } + } + } + + private void doWarpPointer(int center_x, int center_y) { + nSendWarpEvent(display, input_window, warp_atom, center_x, center_y); + nWarpCursor(display, window, center_x, center_y); + } + private static native void nSendWarpEvent(long display, long window, long warp_atom, int center_x, int center_y); + + private void doHandlePointerMotion(boolean grab, boolean warp_pointer, long root_window, int root_x, int root_y, int win_x, int win_y, long nanos) { + setCursorPos(grab, win_x, win_y, nanos); + if (!warp_pointer) + return; + int root_window_height = nGetWindowHeight(display, root_window); + int root_window_width = nGetWindowWidth(display, root_window); + int window_height = nGetWindowHeight(display, window); + int window_width = nGetWindowWidth(display, window); + + // find the window position in root coordinates + int win_left = root_x - win_x; + int win_top = root_y - win_y; + int win_right = win_left + window_width; + int win_bottom = win_top + window_height; + // cap the window position to the screen dimensions + int border_left = Math.max(0, win_left); + int border_top = Math.max(0, win_top); + int border_right = Math.min(root_window_width, win_right); + int border_bottom = Math.min(root_window_height, win_bottom); + // determine whether the cursor is outside the bounds + boolean outside_limits = root_x < border_left + POINTER_WARP_BORDER || root_y < border_top + POINTER_WARP_BORDER || + root_x > border_right - POINTER_WARP_BORDER || root_y > border_bottom - POINTER_WARP_BORDER; + if (outside_limits) { + // Find the center of the limits in window coordinates + int center_x = (border_right - border_left)/2; + int center_y = (border_bottom - border_top)/2; + doWarpPointer(center_x, center_y); + } + } + + public void changeGrabbed(boolean grab, boolean warp_pointer) { + reset(grab, warp_pointer); + } + + public int getButtonCount() { + return buttons.length; + } + + private int transformY(int y) { + return nGetWindowHeight(display, window) - 1 - y; + } + private static native int nGetWindowHeight(long display, long window); + private static native int nGetWindowWidth(long display, long window); + + private static native long nQueryPointer(long display, long window, IntBuffer result); + + public void setCursorPosition(int x, int y) { + nWarpCursor(display, window, x, transformY(y)); + } + private static native void nWarpCursor(long display, long window, int x, int y); + + private void handlePointerMotion(boolean grab, boolean warp_pointer, long millis, long root_window, int x_root, int y_root, int x, int y) { + doHandlePointerMotion(grab, warp_pointer, root_window, x_root, y_root, x, y, millis*1000000); + } + + private void handleButton(boolean grab, int button, byte state, long nanos) { + byte button_num; + switch (button) { + case Button1: + button_num = (byte)0; + break; + case Button2: + button_num = (byte)2; + break; + case Button3: + button_num = (byte)1; + break; + default: + return; + } + buttons[button_num] = state; + putMouseEvent(grab, button_num, state, 0, nanos); + } + + private void putMouseEvent(boolean grab, byte button, byte state, int dz, long nanos) { + if (grab) + putMouseEventWithCoords(button, state, 0, 0, dz, nanos); + else + putMouseEventWithCoords(button, state, last_x, last_y, dz, nanos); + } + + private void handleButtonPress(boolean grab, byte button, long nanos) { + int delta = 0; + switch (button) { + case Button4: + delta = WHEEL_SCALE; + putMouseEvent(grab, (byte)-1, (byte)0, delta, nanos); + accum_dz += delta; + break; + case Button5: + delta = -WHEEL_SCALE; + putMouseEvent(grab, (byte)-1, (byte)0, delta, nanos); + accum_dz += delta; + break; + default: + handleButton(grab, button, (byte)1, nanos); + break; + } + } + + private void handleButtonEvent(boolean grab, long millis, int type, byte button) { + long nanos = millis*1000000; + switch (type) { + case ButtonRelease: + handleButton(grab, button, (byte)0, nanos); + break; + case ButtonPress: + handleButtonPress(grab, button, nanos); + break; + default: + break; + } + } + + private void resetCursor(int x, int y) { + last_x = x; + last_y = transformY(y); + } + + private void handleWarpEvent(int x, int y) { + resetCursor(x, y); + } + + public boolean filterEvent(boolean grab, boolean warp_pointer, LinuxEvent event) { + switch (event.getType()) { + case LinuxEvent.ClientMessage: + if (event.getClientMessageType() == warp_atom) { + handleWarpEvent(event.getClientData(0), event.getClientData(1)); + return true; + } + break; + case LinuxEvent.ButtonPress: /* Fall through */ + case LinuxEvent.ButtonRelease: + handleButtonEvent(grab, event.getButtonTime(), event.getButtonType(), (byte)event.getButtonButton()); + return true; + case LinuxEvent.MotionNotify: + handlePointerMotion(grab, warp_pointer, event.getButtonTime(), event.getButtonRoot(), event.getButtonXRoot(), event.getButtonYRoot(), event.getButtonX(), event.getButtonY()); + return true; + default: + break; + } + return false; + } +} diff --git a/src/java/org/lwjgl/opengl/LinuxPbufferPeerInfo.java b/src/java/org/lwjgl/opengl/LinuxPbufferPeerInfo.java new file mode 100644 index 0000000..6e3e2b7 --- /dev/null +++ b/src/java/org/lwjgl/opengl/LinuxPbufferPeerInfo.java @@ -0,0 +1,83 @@ +/* + * 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; + +import java.nio.ByteBuffer; + +import org.lwjgl.LWJGLException; + +/** + * + * @author elias_naur + * @version $Revision: 3116 $ + * $Id: LinuxPbufferPeerInfo.java 3116 2008-08-19 16:46:03Z spasi $ + */ +final class LinuxPbufferPeerInfo extends LinuxPeerInfo { + LinuxPbufferPeerInfo(int width, int height, PixelFormat pixel_format) throws LWJGLException { + LinuxDisplay.lockAWT(); + try { + GLContext.loadOpenGLLibrary(); + try { + LinuxDisplay.incDisplay(); + try { + nInitHandle(LinuxDisplay.getDisplay(), LinuxDisplay.getDefaultScreen(), getHandle(), width, height, pixel_format); + } catch (LWJGLException e) { + LinuxDisplay.decDisplay(); + throw e; + } + } catch (LWJGLException e) { + GLContext.unloadOpenGLLibrary(); + throw e; + } + } finally { + LinuxDisplay.unlockAWT(); + } + } + private static native void nInitHandle(long display, int screen, ByteBuffer handle, int width, int height, PixelFormat pixel_format) throws LWJGLException; + + public void destroy() { + LinuxDisplay.lockAWT(); + nDestroy(getHandle()); + LinuxDisplay.decDisplay(); + GLContext.unloadOpenGLLibrary(); + LinuxDisplay.unlockAWT(); + } + private static native void nDestroy(ByteBuffer handle); + + protected void doLockAndInitHandle() throws LWJGLException { + // NO-OP + } + + protected void doUnlock() throws LWJGLException { + // NO-OP + } +} diff --git a/src/java/org/lwjgl/opengl/LinuxPeerInfo.java b/src/java/org/lwjgl/opengl/LinuxPeerInfo.java new file mode 100644 index 0000000..2654f73 --- /dev/null +++ b/src/java/org/lwjgl/opengl/LinuxPeerInfo.java @@ -0,0 +1,57 @@ +/* + * 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; + +import java.nio.ByteBuffer; + +/** + * + * @author elias_naur + * @version $Revision: 3116 $ + * $Id: LinuxPeerInfo.java 3116 2008-08-19 16:46:03Z spasi $ + */ +abstract class LinuxPeerInfo extends PeerInfo { + LinuxPeerInfo() { + super(createHandle()); + } + private static native ByteBuffer createHandle(); + + public final long getDisplay() { + return nGetDisplay(getHandle()); + } + private static native long nGetDisplay(ByteBuffer handle); + + public final long getDrawable() { + return nGetDrawable(getHandle()); + } + private static native long nGetDrawable(ByteBuffer handle); +} diff --git a/src/java/org/lwjgl/opengl/MacOSXAWTGLCanvasPeerInfo.java b/src/java/org/lwjgl/opengl/MacOSXAWTGLCanvasPeerInfo.java new file mode 100644 index 0000000..4f09051 --- /dev/null +++ b/src/java/org/lwjgl/opengl/MacOSXAWTGLCanvasPeerInfo.java @@ -0,0 +1,55 @@ +/* + * 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; + +import org.lwjgl.LWJGLException; + +import java.awt.Canvas; + +/** + * + * @author elias_naur + * @version $Revision: 3116 $ + * $Id: MacOSXAWTGLCanvasPeerInfo.java 3116 2008-08-19 16:46:03Z spasi $ + */ +final class MacOSXAWTGLCanvasPeerInfo extends MacOSXCanvasPeerInfo { + private final Canvas component; + + MacOSXAWTGLCanvasPeerInfo(Canvas component, PixelFormat pixel_format, boolean support_pbuffer) throws LWJGLException { + super(pixel_format, support_pbuffer); + this.component = component; + } + + protected void doLockAndInitHandle() throws LWJGLException { + initHandle(component); + } +} diff --git a/src/java/org/lwjgl/opengl/MacOSXCanvasImplementation.java b/src/java/org/lwjgl/opengl/MacOSXCanvasImplementation.java new file mode 100644 index 0000000..e040bfe --- /dev/null +++ b/src/java/org/lwjgl/opengl/MacOSXCanvasImplementation.java @@ -0,0 +1,66 @@ +/* + * 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; + +import java.awt.GraphicsConfiguration; +import java.awt.GraphicsDevice; +import java.awt.Canvas; + +import org.lwjgl.LWJGLException; + +/** + * + * @author elias_naur + * @version $Revision: 3002 $ + * $Id: MacOSXCanvasImplementation.java 3002 2008-04-10 20:25:54Z elias_naur $ + */ +final class MacOSXCanvasImplementation implements AWTCanvasImplementation { + public PeerInfo createPeerInfo(Canvas component, PixelFormat pixel_format) throws LWJGLException { + try { + return new MacOSXAWTGLCanvasPeerInfo(component, pixel_format, true); + } catch (LWJGLException e) { + return new MacOSXAWTGLCanvasPeerInfo(component, pixel_format, false); + } + } + + /** + * Find a proper GraphicsConfiguration from the given GraphicsDevice and PixelFormat. + * + * @return The GraphicsConfiguration corresponding to a visual that matches the pixel format. + */ + public GraphicsConfiguration findConfiguration(GraphicsDevice device, PixelFormat pixel_format) throws LWJGLException { + /* + * It seems like the best way is to simply return null + */ + return null; + } +} diff --git a/src/java/org/lwjgl/opengl/MacOSXCanvasListener.java b/src/java/org/lwjgl/opengl/MacOSXCanvasListener.java new file mode 100644 index 0000000..c0111bf --- /dev/null +++ b/src/java/org/lwjgl/opengl/MacOSXCanvasListener.java @@ -0,0 +1,114 @@ +/* + * 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; + +/** + * The AWT compatible Canvas for Mac OS X. + * @author elias_naur + */ + +import java.awt.Canvas; +import java.awt.event.ComponentEvent; +import java.awt.event.ComponentListener; +import java.awt.event.HierarchyEvent; +import java.awt.event.HierarchyListener; + +final class MacOSXCanvasListener implements ComponentListener, HierarchyListener { + private final Canvas canvas; + private int width; + private int height; + private boolean context_update; + + MacOSXCanvasListener(Canvas canvas) { + this.canvas = canvas; + canvas.addComponentListener(this); + canvas.addHierarchyListener(this); + setUpdate(); + } + + public void disableListeners() { + // Mac OS X applets will hang in Display.destroy() when parented when removing the listeners directly + java.awt.EventQueue.invokeLater(new Runnable() { + public void run() { + canvas.removeComponentListener(MacOSXCanvasListener.this); + canvas.removeHierarchyListener(MacOSXCanvasListener.this); + } + }); + } + + public boolean syncShouldUpdateContext() { + boolean should_update; + synchronized ( this ) { + should_update = context_update; + context_update = false; + } + return should_update; + } + + private synchronized void setUpdate() { + synchronized ( this ) { + width = canvas.getWidth(); + height = canvas.getHeight(); + context_update = true; + } + } + + public int syncGetWidth() { + synchronized ( this ) { + return width; + } + } + + public int syncGetHeight() { + synchronized ( this ) { + return height; + } + } + + public void componentShown(ComponentEvent e) { + } + + public void componentHidden(ComponentEvent e) { + } + + public void componentResized(ComponentEvent e) { + setUpdate(); + } + + public void componentMoved(ComponentEvent e) { + setUpdate(); + } + + public void hierarchyChanged(HierarchyEvent e) { + setUpdate(); + } +} diff --git a/src/java/org/lwjgl/opengl/MacOSXCanvasPeerInfo.java b/src/java/org/lwjgl/opengl/MacOSXCanvasPeerInfo.java new file mode 100644 index 0000000..95e8014 --- /dev/null +++ b/src/java/org/lwjgl/opengl/MacOSXCanvasPeerInfo.java @@ -0,0 +1,60 @@ +/* + * 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; + +import java.awt.Canvas; +import java.nio.ByteBuffer; + +import org.lwjgl.LWJGLException; + +/** + * + * @author elias_naur + * @version $Revision: 3116 $ + * $Id: MacOSXCanvasPeerInfo.java 3116 2008-08-19 16:46:03Z spasi $ + */ +abstract class MacOSXCanvasPeerInfo extends MacOSXPeerInfo { + private final AWTSurfaceLock awt_surface = new AWTSurfaceLock(); + + protected MacOSXCanvasPeerInfo(PixelFormat pixel_format, boolean support_pbuffer) throws LWJGLException { + super(pixel_format, true, true, support_pbuffer, true); + } + + protected void initHandle(Canvas component) throws LWJGLException { + nInitHandle(awt_surface.lockAndGetHandle(component), getHandle()); + } + private static native void nInitHandle(ByteBuffer surface_buffer, ByteBuffer peer_info_handle) throws LWJGLException; + + protected void doUnlock() throws LWJGLException { + awt_surface.unlock(); + } +} diff --git a/src/java/org/lwjgl/opengl/MacOSXContextAttribs.java b/src/java/org/lwjgl/opengl/MacOSXContextAttribs.java new file mode 100644 index 0000000..01a5c5a --- /dev/null +++ b/src/java/org/lwjgl/opengl/MacOSXContextAttribs.java @@ -0,0 +1,94 @@ +/* + * 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; + +/** + * An implementation of ContextAttribs for MacOS X. + *

    + * ---- WIP - No XGL_create_context has been defined for MacOS X yet ---- + * + * @author spasi + */ +final class MacOSXContextAttribs implements ContextAttribsImplementation { + + private static final int XGL_CONTEXT_MAJOR_VERSION_ARB = 0x2091; + private static final int XGL_CONTEXT_MINOR_VERSION_ARB = 0x2092; + private static final int XGL_CONTEXT_LAYER_PLANE_ARB = 0x2093; + private static final int XGL_CONTEXT_FLAGS_ARB = 0x2094; + private static final int XGL_CONTEXT_PROFILE_MASK_ARB = 0x9126; + + private static final int XGL_CONTEXT_DEBUG_BIT_ARB = 0x0001; + private static final int XGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB = 0x0002; + + private static final int XGL_CONTEXT_CORE_PROFILE_BIT_ARB = 0x00000001; + private static final int XGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB = 0x00000002; + + MacOSXContextAttribs() { + } + + public int getMajorVersionAttrib() { + return XGL_CONTEXT_MAJOR_VERSION_ARB; + } + + public int getMinorVersionAttrib() { + return XGL_CONTEXT_MINOR_VERSION_ARB; + } + + public int getLayerPlaneAttrib() { + return XGL_CONTEXT_LAYER_PLANE_ARB; + } + + public int getFlagsAttrib() { + return XGL_CONTEXT_FLAGS_ARB; + } + + public int getDebugBit() { + return XGL_CONTEXT_DEBUG_BIT_ARB; + } + + public int getForwardCompatibleBit() { + return XGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB; + } + + public int getProfileMaskAttrib() { + return XGL_CONTEXT_PROFILE_MASK_ARB; + } + + public int getProfileCoreBit() { + return XGL_CONTEXT_CORE_PROFILE_BIT_ARB; + } + + public int getProfileCompatibilityBit() { + return XGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB; + } + +} \ No newline at end of file diff --git a/src/java/org/lwjgl/opengl/MacOSXContextImplementation.java b/src/java/org/lwjgl/opengl/MacOSXContextImplementation.java new file mode 100644 index 0000000..70ff274 --- /dev/null +++ b/src/java/org/lwjgl/opengl/MacOSXContextImplementation.java @@ -0,0 +1,133 @@ +/* + * 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; + +import org.lwjgl.LWJGLException; + +import java.nio.ByteBuffer; +import java.nio.IntBuffer; + +/** + * @author elias_naur + * @version $Revision: 3116 $ + * $Id: MacOSXContextImplementation.java 3116 2008-08-19 16:46:03Z spasi $ + */ +final class MacOSXContextImplementation implements ContextImplementation { + + public ByteBuffer create(PeerInfo peer_info, IntBuffer attribs, ByteBuffer shared_context_handle) throws LWJGLException { + ByteBuffer peer_handle = peer_info.lockAndGetHandle(); + try { + return nCreate(peer_handle, attribs, shared_context_handle); + } finally { + peer_info.unlock(); + } + } + + private static native ByteBuffer nCreate(ByteBuffer peer_handle, IntBuffer attribs, ByteBuffer shared_context_handle) throws LWJGLException; + + public void swapBuffers() throws LWJGLException { + Context current_context = Context.getCurrentContext(); + if ( current_context == null ) + throw new IllegalStateException("No context is current"); + synchronized ( current_context ) { + nSwapBuffers(current_context.getHandle()); + } + } + + private static native void nSwapBuffers(ByteBuffer context_handle) throws LWJGLException; + + public void update(ByteBuffer context_handle) { + nUpdate(context_handle); + } + + private static native void nUpdate(ByteBuffer context_handle); + + public void releaseCurrentContext() throws LWJGLException { + nReleaseCurrentContext(); + } + + private static native void nReleaseCurrentContext() throws LWJGLException; + + public void releaseDrawable(ByteBuffer context_handle) throws LWJGLException { + clearDrawable(context_handle); + } + + private static native void clearDrawable(ByteBuffer handle) throws LWJGLException; + + static void resetView(PeerInfo peer_info, Context context) throws LWJGLException { + ByteBuffer peer_handle = peer_info.lockAndGetHandle(); + try { + synchronized ( context ) { + clearDrawable(context.getHandle()); + setView(peer_handle, context.getHandle()); + } + } finally { + peer_info.unlock(); + } + } + + public void makeCurrent(PeerInfo peer_info, ByteBuffer handle) throws LWJGLException { + ByteBuffer peer_handle = peer_info.lockAndGetHandle(); + try { + setView(peer_handle, handle); + nMakeCurrent(handle); + } finally { + peer_info.unlock(); + } + } + + private static native void setView(ByteBuffer peer_handle, ByteBuffer context_handle) throws LWJGLException; + + private static native void nMakeCurrent(ByteBuffer context_handle) throws LWJGLException; + + public boolean isCurrent(ByteBuffer handle) throws LWJGLException { + boolean result = nIsCurrent(handle); + return result; + } + + private static native boolean nIsCurrent(ByteBuffer context_handle) throws LWJGLException; + + public void setSwapInterval(int value) { + Context current_context = Context.getCurrentContext(); + synchronized ( current_context ) { + nSetSwapInterval(current_context.getHandle(), value); + } + } + + private static native void nSetSwapInterval(ByteBuffer context_handle, int value); + + public void destroy(PeerInfo peer_info, ByteBuffer handle) throws LWJGLException { + nDestroy(handle); + } + + private static native void nDestroy(ByteBuffer context_handle) throws LWJGLException; +} diff --git a/src/java/org/lwjgl/opengl/MacOSXDisplay.java b/src/java/org/lwjgl/opengl/MacOSXDisplay.java new file mode 100644 index 0000000..bdbeb96 --- /dev/null +++ b/src/java/org/lwjgl/opengl/MacOSXDisplay.java @@ -0,0 +1,508 @@ +/* + * 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; + +/** + * This is the Display implementation interface. Display delegates + * to implementors of this interface. There is one DisplayImplementation + * for each supported platform. + * @author elias_naur + */ + +import java.awt.Canvas; +import java.awt.Cursor; +import java.awt.Robot; +import java.nio.ByteBuffer; +import java.nio.FloatBuffer; +import java.nio.IntBuffer; +import java.security.AccessController; +import java.security.PrivilegedAction; +import java.security.PrivilegedExceptionAction; +import java.util.ArrayList; +import java.util.List; + +import org.lwjgl.BufferUtils; +import org.lwjgl.LWJGLException; +import org.lwjgl.LWJGLUtil; + +import com.apple.eawt.Application; +import com.apple.eawt.ApplicationAdapter; +import com.apple.eawt.ApplicationEvent; + +final class MacOSXDisplay implements DisplayImplementation { + private static final int PBUFFER_HANDLE_SIZE = 24; + private static final int GAMMA_LENGTH = 256; + + private MacOSXCanvasListener canvas_listener; + private MacOSXFrame frame; + private Canvas canvas; + private Robot robot; + private MacOSXMouseEventQueue mouse_queue; + private KeyboardEventQueue keyboard_queue; + private java.awt.DisplayMode requested_mode; + + /* States */ + private boolean close_requested; + + MacOSXDisplay() { + try { + AccessController.doPrivileged(new PrivilegedExceptionAction() { + public Object run() throws Exception { + Application.getApplication().addApplicationListener(new ApplicationAdapter() { + public final void handleQuit(ApplicationEvent event) { + doHandleQuit(); + } + }); + return null; + } + }); + } catch (Throwable e) { + /** + * In an applet environment, referencing com.apple.eawt.Application can fail with + * a native exception. So log any exceptions instead of re-throwing. + */ + LWJGLUtil.log("Failed to register quit handler: " + e.getMessage()); + } + } + + public void createWindow(DisplayMode mode, Canvas parent, int x, int y) throws LWJGLException { + boolean fullscreen = Display.isFullscreen(); + hideUI(fullscreen); + close_requested = false; + try { + if (parent == null) { + frame = new MacOSXFrame(mode, requested_mode, fullscreen, x, y); + canvas = frame.getCanvas(); + } else { + frame = null; + canvas = parent; + } + canvas_listener = new MacOSXCanvasListener(canvas); + robot = AWTUtil.createRobot(canvas); + } catch (LWJGLException e) { + destroyWindow(); + throw e; + } + } + + private void doHandleQuit() { + synchronized (this) { + close_requested = true; + } + } + + public void destroyWindow() { + if (canvas_listener != null) { + canvas_listener.disableListeners(); + canvas_listener = null; + } + if (frame != null) { + AccessController.doPrivileged(new PrivilegedAction() { + public Object run() { + if (MacOSXFrame.getDevice().getFullScreenWindow() == frame) + MacOSXFrame.getDevice().setFullScreenWindow(null); + return null; + } + }); + if (frame.isDisplayable()) + frame.dispose(); + frame = null; + } + hideUI(false); + } + + public int getGammaRampLength() { + return GAMMA_LENGTH; + } + + public native void setGammaRamp(FloatBuffer gammaRamp) throws LWJGLException; + + public String getAdapter() { + return null; + } + + public String getVersion() { + return null; + } + + private boolean equals(java.awt.DisplayMode awt_mode, DisplayMode mode) { + return awt_mode.getWidth() == mode.getWidth() && awt_mode.getHeight() == mode.getHeight() + && awt_mode.getBitDepth() == mode.getBitsPerPixel() && awt_mode.getRefreshRate() == mode.getFrequency(); + } + + public void switchDisplayMode(DisplayMode mode) throws LWJGLException { + java.awt.DisplayMode[] awt_modes = MacOSXFrame.getDevice().getDisplayModes(); + for (int i = 0; i < awt_modes.length; i++) + if (equals(awt_modes[i], mode)) { + requested_mode = awt_modes[i]; + return; + } + throw new LWJGLException(mode + " is not supported"); + } + + public void resetDisplayMode() { + if (MacOSXFrame.getDevice().getFullScreenWindow() != null) + MacOSXFrame.getDevice().setFullScreenWindow(null); + requested_mode = null; + restoreGamma(); + } + + private native void restoreGamma(); + + private DisplayMode createLWJGLDisplayMode(java.awt.DisplayMode awt_mode) { + int bit_depth; + int refresh_rate; + int awt_bit_depth = awt_mode.getBitDepth(); + int awt_refresh_rate = awt_mode.getRefreshRate(); + if (awt_bit_depth != java.awt.DisplayMode.BIT_DEPTH_MULTI) + bit_depth = awt_bit_depth; + else + bit_depth = 32; // Assume the best bit depth + if (awt_refresh_rate != java.awt.DisplayMode.REFRESH_RATE_UNKNOWN) + refresh_rate = awt_refresh_rate; + else + refresh_rate = 0; + return new DisplayMode(awt_mode.getWidth(), awt_mode.getHeight(), bit_depth, refresh_rate); + } + + public DisplayMode init() throws LWJGLException { + return createLWJGLDisplayMode(MacOSXFrame.getDevice().getDisplayMode()); + } + + public DisplayMode[] getAvailableDisplayModes() throws LWJGLException { + java.awt.DisplayMode[] awt_modes = MacOSXFrame.getDevice().getDisplayModes(); + List modes = new ArrayList(); + for (int i = 0; i < awt_modes.length; i++) + if (awt_modes[i].getBitDepth() >= 16) + modes.add(createLWJGLDisplayMode(awt_modes[i])); + DisplayMode[] mode_list = new DisplayMode[modes.size()]; + modes.toArray(mode_list); + return mode_list; + } + + public void setTitle(String title) { + if (frame != null) + frame.setTitle(title); + } + + public boolean isCloseRequested() { + boolean result; + synchronized (this) { + result = close_requested || (frame != null && frame.syncIsCloseRequested()); + close_requested = false; + } + return result; + } + + public boolean isVisible() { + return frame == null || frame.syncIsVisible(); + } + + public boolean isActive() { + return canvas.isFocusOwner(); + } + + public Canvas getCanvas() { + return canvas; + } + + public boolean isDirty() { + return frame != null && frame.getCanvas().syncIsDirty(); + } + + public PeerInfo createPeerInfo(PixelFormat pixel_format) throws LWJGLException { + try { + return new MacOSXDisplayPeerInfo(pixel_format, true); + } catch (LWJGLException e) { + return new MacOSXDisplayPeerInfo(pixel_format, false); + } + } + + private final static IntBuffer current_viewport = BufferUtils.createIntBuffer(16); + public void update() { + boolean should_update = canvas_listener.syncShouldUpdateContext(); + /* + * Workaround for the "white screen in fullscreen mode" problem + * + * Sometimes, switching from windowed mode to fullscreen or simply creating the Display + * in fullscreen mode will result in the context not being bound to the window correctly. + * The program runs fine, but the canvas background (white) is shown instead of the context + * front buffer. + * + * I've discovered that re-binding the context with another setView() won't fix the problem, while a + * clearDrawable() followed by a setView() does work. A straightforward workaround would be + * to simply run the combination at every update(). This is not sufficient, since the clearDrawable() + * call makes the the background appear shortly, causing visual artifacts. + * What we really need is a way to detect that a setView() failed, and then do the magic combo. I've not + * been able to find such a detection so alternatively I'm triggering the combo if the display is fullscreen + * (I've not seen the white screen problem in windowed mode) and if the canvas has gotten a paint message or + * if its update flag was set. + * + * My testing seems to indicate that the workaround works, since I've not seen the problem after the fix. + * + * - elias + */ + if (Display.isFullscreen() && (frame != null && frame.getCanvas().syncCanvasPainted() || should_update)) { + try { + MacOSXContextImplementation.resetView(Display.getDrawable().getContext().getPeerInfo(), Display.getDrawable().getContext()); + } catch (LWJGLException e) { + LWJGLUtil.log("Failed to reset context: " + e); + } + } + if (should_update) { + Display.getDrawable().getContext().update(); + /* This is necessary to make sure the context won't "forget" about the view size */ + GL11.glGetInteger(GL11.GL_VIEWPORT, current_viewport); + GL11.glViewport(current_viewport.get(0), current_viewport.get(1), current_viewport.get(2), current_viewport.get(3)); + } + if (frame != null && mouse_queue != null) { + if (frame.syncShouldReleaseCursor()) + MacOSXMouseEventQueue.nGrabMouse(false); + if (frame.syncShouldWarpCursor()) + mouse_queue.warpCursor(); + } + } + + /** + * This is an interface to the native Carbon call + * SetSystemUIMode. It is used to hide the dock in a way + * that will prevent AWT from shifting the fullscreen window + * + * The workaround is not necessary on 10.4, and since 10.4 shows + * instability problems calling SetSystemUIMode, we'll only call it + * when the OS version is 10.3 or lower. + */ + private void hideUI(boolean hide) { + if (!LWJGLUtil.isMacOSXEqualsOrBetterThan(10, 4)) + nHideUI(hide); + } + + private native void nHideUI(boolean hide); + + public void reshape(int x, int y, int width, int height) { + if (frame != null) + frame.resize(x, y, width, height); + } + + /* Mouse */ + public boolean hasWheel() { + return AWTUtil.hasWheel(); + } + + public int getButtonCount() { + return AWTUtil.getButtonCount(); + } + + public void createMouse() throws LWJGLException { + this.mouse_queue = new MacOSXMouseEventQueue(canvas); + mouse_queue.register(); + } + + public void destroyMouse() { + if (mouse_queue != null) { + MacOSXMouseEventQueue.nGrabMouse(false); + mouse_queue.unregister(); + } + this.mouse_queue = null; + } + + public void pollMouse(IntBuffer coord_buffer, ByteBuffer buttons_buffer) { + mouse_queue.poll(coord_buffer, buttons_buffer); + } + + public void readMouse(ByteBuffer buffer) { + mouse_queue.copyEvents(buffer); + } + + public void grabMouse(boolean grab) { + mouse_queue.setGrabbed(grab); + } + + public int getNativeCursorCapabilities() { + return AWTUtil.getNativeCursorCapabilities(); + } + + public void setCursorPosition(int x, int y) { + AWTUtil.setCursorPosition(canvas, robot, x, y); + } + + public void setNativeCursor(Object handle) throws LWJGLException { + Cursor awt_cursor = (Cursor)handle; + if (frame != null) + frame.setCursor(awt_cursor); + } + + public int getMinCursorSize() { + return AWTUtil.getMinCursorSize(); + } + + public int getMaxCursorSize() { + return AWTUtil.getMaxCursorSize(); + } + + /* Keyboard */ + public void createKeyboard() throws LWJGLException { + this.keyboard_queue = new KeyboardEventQueue(canvas); + keyboard_queue.register(); + } + + public void destroyKeyboard() { + if (keyboard_queue != null) + keyboard_queue.unregister(); + this.keyboard_queue = null; + } + + public void pollKeyboard(ByteBuffer keyDownBuffer) { + keyboard_queue.poll(keyDownBuffer); + } + + public void readKeyboard(ByteBuffer buffer) { + keyboard_queue.copyEvents(buffer); + } + +/* public int isStateKeySet(int key) { + int awt_key; + switch (key) { + case Keyboard.KEY_CAPITAL: + awt_key = KeyEvent.VK_CAPS_LOCK; + break; + case Keyboard.KEY_NUMLOCK: + awt_key = KeyEvent.VK_NUM_LOCK; + break; + case Keyboard.KEY_SYSRQ: + awt_key = KeyEvent.VK_SCROLL_LOCK; + break; + default: + return Keyboard.STATE_UNKNOWN; + } + try { + boolean state = Toolkit.getDefaultToolkit().getLockingKeyState(awt_key); + return state ? Keyboard.STATE_ON : Keyboard.STATE_OFF; + } catch (Exception e) { + LWJGLUtil.log("Failed to query key state: " + e); + return Keyboard.STATE_UNKNOWN; + } + } +*/ + /** Native cursor handles */ + public Object createCursor(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, IntBuffer delays) throws LWJGLException { + return AWTUtil.createCursor(width, height, xHotspot, yHotspot, numImages, images, delays); + } + + public void destroyCursor(Object cursor_handle) { + } + + public int getPbufferCapabilities() { + if (LWJGLUtil.isMacOSXEqualsOrBetterThan(10, 3)) + return Pbuffer.PBUFFER_SUPPORTED; + else + return 0; + } + + public boolean isBufferLost(PeerInfo handle) { + return false; + } + + public PeerInfo createPbuffer(int width, int height, PixelFormat pixel_format, + IntBuffer pixelFormatCaps, + IntBuffer pBufferAttribs) throws LWJGLException { + return new MacOSXPbufferPeerInfo(width, height, pixel_format); + } + + public void setPbufferAttrib(PeerInfo handle, int attrib, int value) { + throw new UnsupportedOperationException(); + } + + public void bindTexImageToPbuffer(PeerInfo handle, int buffer) { + throw new UnsupportedOperationException(); + } + + public void releaseTexImageFromPbuffer(PeerInfo handle, int buffer) { + throw new UnsupportedOperationException(); + } + + /** + * Sets one or more icons for the Display. + *

      + *
    • On Windows you should supply at least one 16x16 icon and one 32x32.
    • + *
    • Linux (and similar platforms) expect one 32x32 icon.
    • + *
    • Mac OS X should be supplied one 128x128 icon
    • + *
    + * The implementation will use the supplied ByteBuffers with image data in RGBA and perform any conversions nescesarry for the specific platform. + * + * @param icons Array of icons in RGBA mode + * @return number of icons used. + */ + public int setIcon(ByteBuffer[] icons) { +/* int size = 0; + int biggest = -1; + + for (int i=0;i size) { + biggest = i; + size = icons[i].remaining(); + } + } + + if (biggest == -1) { + return 0; + } + + int width; + int height; + + IntBuffer biggest_icon = icons[biggest].asIntBuffer(); + int[] imageData = new int[biggest_icon.remaining()]; + width = height = (int) Math.sqrt(imageData.length); + biggest_icon.get(imageData); + + BufferedImage img = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); + img.setRGB(0, 0, width, height, imageData, 0, width); + frame.setIconImage(img); + + return 1;*/ + // Don't use any icon, since Mac OS X windows don't have window icons + return 0; + } + + public int getWidth() { + return Display.getDisplayMode().getWidth(); + } + + public int getHeight() { + return Display.getDisplayMode().getHeight(); + } + + public boolean isInsideWindow() { + return true; + } +} diff --git a/src/java/org/lwjgl/opengl/MacOSXDisplayPeerInfo.java b/src/java/org/lwjgl/opengl/MacOSXDisplayPeerInfo.java new file mode 100644 index 0000000..853b520 --- /dev/null +++ b/src/java/org/lwjgl/opengl/MacOSXDisplayPeerInfo.java @@ -0,0 +1,67 @@ +/* + * 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; + +import java.awt.Canvas; + +import org.lwjgl.LWJGLException; + +/** + * + * @author elias_naur + * @version $Revision: 3116 $ + * $Id: MacOSXDisplayPeerInfo.java 3116 2008-08-19 16:46:03Z spasi $ + */ +final class MacOSXDisplayPeerInfo extends MacOSXCanvasPeerInfo { + private boolean locked = false; + + MacOSXDisplayPeerInfo(PixelFormat pixel_format, boolean support_pbuffer) throws LWJGLException { + super(pixel_format, support_pbuffer); + } + + protected void doLockAndInitHandle() throws LWJGLException { + if (locked) + throw new RuntimeException("Already locked"); + Canvas canvas = ((MacOSXDisplay)Display.getImplementation()).getCanvas(); + if (canvas != null) { + initHandle(canvas); + locked = true; + } + } + + protected void doUnlock() throws LWJGLException { + if (locked) { + super.doUnlock(); + locked = false; + } + } +} diff --git a/src/java/org/lwjgl/opengl/MacOSXFrame.java b/src/java/org/lwjgl/opengl/MacOSXFrame.java new file mode 100644 index 0000000..2ca1c72 --- /dev/null +++ b/src/java/org/lwjgl/opengl/MacOSXFrame.java @@ -0,0 +1,228 @@ +/* + * 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; + +/** + * This is the Mac OS X AWT Frame. It contains thread safe + * methods to manipulateit from non-AWT threads + * @author elias_naur + */ + +import java.awt.BorderLayout; +import java.awt.Frame; +import java.awt.GraphicsDevice; +import java.awt.GraphicsEnvironment; +import java.awt.Insets; +import java.awt.Rectangle; +import java.awt.event.ComponentEvent; +import java.awt.event.ComponentListener; +import java.awt.event.WindowEvent; +import java.awt.event.WindowListener; +import java.security.AccessController; +import java.security.PrivilegedActionException; +import java.security.PrivilegedExceptionAction; + +import org.lwjgl.LWJGLException; + +final class MacOSXFrame extends Frame implements WindowListener, ComponentListener { + + private static final long serialVersionUID = -5823294716668988777L; + + private final MacOSXGLCanvas canvas; + private boolean close_requested; + + /* States */ + private Rectangle bounds; + private boolean active; + private boolean minimized; + private boolean should_warp_cursor; + private boolean should_release_cursor; + + MacOSXFrame(DisplayMode mode, final java.awt.DisplayMode requested_mode, boolean fullscreen, int x, int y) throws LWJGLException { + setResizable(false); + addWindowListener(this); + addComponentListener(this); + canvas = new MacOSXGLCanvas(); + canvas.setFocusTraversalKeysEnabled(false); + add(canvas, BorderLayout.CENTER); + boolean undecorated = Display.getPrivilegedBoolean("org.lwjgl.opengl.Window.undecorated"); + setUndecorated(fullscreen || undecorated); + if ( fullscreen ) { + try { + AccessController.doPrivileged(new PrivilegedExceptionAction() { + public Object run() throws Exception { + getDevice().setFullScreenWindow(MacOSXFrame.this); + getDevice().setDisplayMode(requested_mode); + java.awt.DisplayMode real_mode = getDevice().getDisplayMode(); + /** For some strange reason, the display mode is sometimes silently capped even though the mode is reported as supported */ + if ( requested_mode.getWidth() != real_mode.getWidth() || requested_mode.getHeight() != real_mode.getHeight() ) { + getDevice().setFullScreenWindow(null); + if (isDisplayable()) + dispose(); + throw new LWJGLException("AWT capped mode: requested mode = " + requested_mode.getWidth() + "x" + requested_mode.getHeight() + + " but got " + real_mode.getWidth() + " " + real_mode.getHeight()); + } + return null; + } + }); + } catch (PrivilegedActionException e) { + throw new LWJGLException(e); + } + } + pack(); + resize(x, y, mode.getWidth(), mode.getHeight()); + setVisible(true); + requestFocus(); + canvas.requestFocus(); + updateBounds(); + } + + public void resize(int x, int y, int width, int height) { + Insets insets = getInsets(); + setBounds(x, y, width + insets.left + insets.right, height + insets.top + insets.bottom); + } + + public Rectangle syncGetBounds() { + synchronized ( this ) { + return bounds; + } + } + + public void componentShown(ComponentEvent e) { + } + + public void componentHidden(ComponentEvent e) { + } + + private void updateBounds() { + synchronized ( this ) { + bounds = getBounds(); + } + } + + public void componentResized(ComponentEvent e) { + updateBounds(); + } + + public void componentMoved(ComponentEvent e) { + updateBounds(); + } + + public static GraphicsDevice getDevice() { + GraphicsEnvironment g_env = GraphicsEnvironment.getLocalGraphicsEnvironment(); + GraphicsDevice device = g_env.getDefaultScreenDevice(); + return device; + } + + public void windowIconified(WindowEvent e) { + synchronized ( this ) { + minimized = true; + } + } + + public void windowDeiconified(WindowEvent e) { + synchronized ( this ) { + minimized = false; + } + } + + public void windowOpened(WindowEvent e) { + } + + public void windowClosed(WindowEvent e) { + } + + public void windowClosing(WindowEvent e) { + synchronized ( this ) { + close_requested = true; + } + } + + public void windowDeactivated(WindowEvent e) { + synchronized ( this ) { + active = false; + should_release_cursor = true; + should_warp_cursor = false; + } + } + + public void windowActivated(WindowEvent e) { + synchronized ( this ) { + active = true; + should_warp_cursor = true; + should_release_cursor = false; + } + } + + public boolean syncIsCloseRequested() { + boolean result; + synchronized ( this ) { + result = close_requested; + close_requested = false; + } + return result; + } + + public boolean syncIsVisible() { + synchronized ( this ) { + return !minimized; + } + } + + public boolean syncIsActive() { + synchronized ( this ) { + return active; + } + } + + public MacOSXGLCanvas getCanvas() { + return canvas; + } + + public boolean syncShouldReleaseCursor() { + boolean result; + synchronized ( this ) { + result = should_release_cursor; + should_release_cursor = false; + } + return result; + } + + public boolean syncShouldWarpCursor() { + boolean result; + synchronized ( this ) { + result = should_warp_cursor; + should_warp_cursor = false; + } + return result; + } +} diff --git a/src/java/org/lwjgl/opengl/MacOSXGLCanvas.java b/src/java/org/lwjgl/opengl/MacOSXGLCanvas.java new file mode 100644 index 0000000..39f8050 --- /dev/null +++ b/src/java/org/lwjgl/opengl/MacOSXGLCanvas.java @@ -0,0 +1,77 @@ +/* + * 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; + +/** + * The AWT compatible Canvas for Mac OS X. + * @author elias_naur + */ + +import java.awt.Canvas; +import java.awt.Graphics; + +final class MacOSXGLCanvas extends Canvas { + + private static final long serialVersionUID = 6916664741667434870L; + + private boolean canvas_painted; + private boolean dirty; + + public void update(Graphics g) { + paint(g); + } + + public void paint(Graphics g) { + synchronized ( this ) { + dirty = true; + canvas_painted = true; + } + } + + public boolean syncCanvasPainted() { + boolean result; + synchronized (this) { + result = canvas_painted; + canvas_painted = false; + } + return result; + } + + public boolean syncIsDirty() { + boolean result; + synchronized ( this ) { + result = dirty; + dirty = false; + } + return result; + } +} diff --git a/src/java/org/lwjgl/opengl/MacOSXMouseEventQueue.java b/src/java/org/lwjgl/opengl/MacOSXMouseEventQueue.java new file mode 100644 index 0000000..c6b6195 --- /dev/null +++ b/src/java/org/lwjgl/opengl/MacOSXMouseEventQueue.java @@ -0,0 +1,113 @@ +/* + * 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; + +/** + * An AWT implementation of a LWJGL compatible Mouse event queue. + * @author elias_naur + */ + +import java.awt.Component; +import java.awt.Point; +import java.awt.Rectangle; +import java.nio.IntBuffer; + +import org.lwjgl.BufferUtils; + +final class MacOSXMouseEventQueue extends MouseEventQueue { + private final IntBuffer delta_buffer = BufferUtils.createIntBuffer(2); + + private boolean skip_event; + private static boolean is_grabbed; + + MacOSXMouseEventQueue(Component component) { + super(component); + } + + public void setGrabbed(boolean grab) { + super.setGrabbed(grab); + warpCursor(); + grabMouse(grab); + } + + private static synchronized void grabMouse(boolean grab) { + if (is_grabbed != grab) { + is_grabbed = grab; + if (!grab) + nGrabMouse(grab); + } + } + + protected void resetCursorToCenter() { + super.resetCursorToCenter(); + /* Clear accumulated deltas */ + getMouseDeltas(delta_buffer); + } + + protected void updateDeltas(long nanos) { + super.updateDeltas(nanos); + synchronized ( this ) { + getMouseDeltas(delta_buffer); + int dx = delta_buffer.get(0); + int dy = -delta_buffer.get(1); + if (skip_event) { + skip_event = false; + nGrabMouse(isGrabbed()); + return; + } + if ( dx != 0 || dy != 0 ) { + putMouseEventWithCoords((byte)-1, (byte)0, dx, dy, 0, nanos); + addDelta(dx, dy); + } + } + } + + void warpCursor() { + synchronized (this) { + // If we're going to warp the cursor position, we'll skip the next event to avoid bogus delta values + skip_event = isGrabbed(); + } +/* if (isGrabbed()) { + Rectangle bounds = getComponent().getBounds(); + Point location_on_screen = getComponent().getLocationOnScreen(); + int x = location_on_screen.x + bounds.width/2; + int y = location_on_screen.y + bounds.height/2; + nWarpCursor(x, y); + }*/ + } + + private static native void getMouseDeltas(IntBuffer delta_buffer); + + private static native void nWarpCursor(int x, int y); + + static native void nGrabMouse(boolean grab); +} diff --git a/src/java/org/lwjgl/opengl/MacOSXPbufferPeerInfo.java b/src/java/org/lwjgl/opengl/MacOSXPbufferPeerInfo.java new file mode 100644 index 0000000..574853d --- /dev/null +++ b/src/java/org/lwjgl/opengl/MacOSXPbufferPeerInfo.java @@ -0,0 +1,63 @@ +/* + * 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; + +import java.nio.ByteBuffer; + +import org.lwjgl.LWJGLException; + +/** + * + * @author elias_naur + * @version $Revision: 3116 $ + * $Id: MacOSXPbufferPeerInfo.java 3116 2008-08-19 16:46:03Z spasi $ + */ +final class MacOSXPbufferPeerInfo extends MacOSXPeerInfo { + MacOSXPbufferPeerInfo(int width, int height, PixelFormat pixel_format) throws LWJGLException { + super(pixel_format, false, false, true, false); + nCreate(getHandle(), width, height); + } + private static native void nCreate(ByteBuffer handle, int width, int height) throws LWJGLException; + + public void destroy() { + nDestroy(getHandle()); + } + private static native void nDestroy(ByteBuffer handle); + + protected void doLockAndInitHandle() throws LWJGLException { + // NO-OP + } + + protected void doUnlock() throws LWJGLException { + // NO-OP + } +} diff --git a/src/java/org/lwjgl/opengl/MacOSXPeerInfo.java b/src/java/org/lwjgl/opengl/MacOSXPeerInfo.java new file mode 100644 index 0000000..f7e6ddb --- /dev/null +++ b/src/java/org/lwjgl/opengl/MacOSXPeerInfo.java @@ -0,0 +1,63 @@ +/* + * 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; + +import java.nio.ByteBuffer; + +import org.lwjgl.LWJGLException; +import org.lwjgl.LWJGLUtil; + +/** + * + * @author elias_naur + * @version $Revision: 3116 $ + * $Id: MacOSXPeerInfo.java 3116 2008-08-19 16:46:03Z spasi $ + */ +abstract class MacOSXPeerInfo extends PeerInfo { + MacOSXPeerInfo(PixelFormat pixel_format, boolean use_display_bpp, boolean support_window, boolean support_pbuffer, boolean double_buffered) throws LWJGLException { + super(createHandle()); + if (pixel_format.isFloatingPoint() && !LWJGLUtil.isMacOSXEqualsOrBetterThan(10, 4)) + throw new LWJGLException("Floating point pixel format requested, but is not supported"); + choosePixelFormat(pixel_format, use_display_bpp, support_window, support_pbuffer, double_buffered); + } + private static native ByteBuffer createHandle(); + + private void choosePixelFormat(PixelFormat pixel_format, boolean use_display_bpp, boolean support_window, boolean support_pbuffer, boolean double_buffered) throws LWJGLException { + nChoosePixelFormat(getHandle(), pixel_format, use_display_bpp, support_window, support_pbuffer, double_buffered); + } + private static native void nChoosePixelFormat(ByteBuffer peer_info_handle, PixelFormat pixel_format, boolean use_display_bpp, boolean support_window, boolean support_pbuffer, boolean double_buffered) throws LWJGLException; + + public void destroy() { + nDestroy(getHandle()); + } + private static native void nDestroy(ByteBuffer handle); +} diff --git a/src/java/org/lwjgl/opengl/MouseEventQueue.java b/src/java/org/lwjgl/opengl/MouseEventQueue.java new file mode 100644 index 0000000..167eee3 --- /dev/null +++ b/src/java/org/lwjgl/opengl/MouseEventQueue.java @@ -0,0 +1,261 @@ +/* + * 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; + +/** + * An AWT implementation of a LWJGL compatible Mouse event queue. + * @author elias_naur + */ + +import java.awt.Component; +import java.awt.Point; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.awt.event.MouseMotionListener; +import java.awt.event.MouseWheelEvent; +import java.awt.event.MouseWheelListener; +import java.nio.ByteBuffer; +import java.nio.IntBuffer; + +import org.lwjgl.input.Mouse; + +class MouseEventQueue extends EventQueue implements MouseListener, MouseMotionListener, MouseWheelListener { + private static final int WHEEL_SCALE = 120; + public static final int NUM_BUTTONS = 3; + + private final Component component; + + private boolean grabbed; + + /** The accumulated mouse deltas returned by poll() */ + private int accum_dx; + private int accum_dy; + private int accum_dz; + + /** The last mouse position */ + private int last_x; + private int last_y; + + /** Saved control key state for ctrl-click right button emulation */ + private boolean saved_control_state; + + /** Event scratch array */ + private final ByteBuffer event = ByteBuffer.allocate(Mouse.EVENT_SIZE); + + /** Buttons array */ + private final byte[] buttons = new byte[NUM_BUTTONS]; + + MouseEventQueue(Component component) { + super(Mouse.EVENT_SIZE); + this.component = component; + } + + public synchronized void register() { + resetCursorToCenter(); + component.addMouseListener(this); + component.addMouseMotionListener(this); + component.addMouseWheelListener(this); + } + + public synchronized void unregister() { + component.removeMouseListener(this); + component.removeMouseMotionListener(this); + component.removeMouseWheelListener(this); + } + + protected Component getComponent() { + return component; + } + + public synchronized void setGrabbed(boolean grabbed) { + this.grabbed = grabbed; + resetCursorToCenter(); + } + + public synchronized boolean isGrabbed() { + return grabbed; + } + + private int transformY(int y) { + return component.getHeight() - 1 - y; + } + + protected void resetCursorToCenter() { + clearEvents(); + accum_dx = accum_dy = 0; + Point cursor_location = AWTUtil.getCursorPosition(component); + if (cursor_location != null) { + last_x = cursor_location.x; + last_y = cursor_location.y; + } + } + + private void putMouseEvent(byte button, byte state, int dz, long nanos) { + if (grabbed) + putMouseEventWithCoords(button, state, 0, 0, dz, nanos); + else + putMouseEventWithCoords(button, state, last_x, last_y, dz, nanos); + } + + protected void putMouseEventWithCoords(byte button, byte state, int coord1, int coord2, int dz, long nanos) { + event.clear(); + event.put(button).put(state).putInt(coord1).putInt(coord2).putInt(dz).putLong(nanos); + event.flip(); + putEvent(event); + } + + public synchronized void poll(IntBuffer coord_buffer, ByteBuffer buttons_buffer) { + if ( grabbed ) { + coord_buffer.put(0, accum_dx); + coord_buffer.put(1, accum_dy); + } else { + coord_buffer.put(0, last_x); + coord_buffer.put(1, last_y); + } + coord_buffer.put(2, accum_dz); + accum_dx = accum_dy = accum_dz = 0; + int old_position = buttons_buffer.position(); + buttons_buffer.put(buttons, 0, buttons.length); + buttons_buffer.position(old_position); + } + + private void setCursorPos(int x, int y, long nanos) { + y = transformY(y); + if ( grabbed ) + return; + int dx = x - last_x; + int dy = y - last_y; + addDelta(dx, dy); + last_x = x; + last_y = y; + putMouseEventWithCoords((byte)-1, (byte)0, x, y, 0, nanos); + } + + protected void addDelta(int dx, int dy) { + accum_dx += dx; + accum_dy += dy; + } + + public void mouseClicked(MouseEvent e) { + } + + public void mouseEntered(MouseEvent e) { + } + + public void mouseExited(MouseEvent e) { + } + + private void handleButton(MouseEvent e) { + byte state; + switch (e.getID()) { + case MouseEvent.MOUSE_PRESSED: + state = 1; + break; + case MouseEvent.MOUSE_RELEASED: + state = 0; + break; + default: + throw new IllegalArgumentException("Not a valid event ID: " + e.getID()); + } + byte button; + switch (e.getButton()) { + case MouseEvent.NOBUTTON: + // Nothing to do, so return + return; + case MouseEvent.BUTTON1: + // Emulate right click if ctrl is down + if (state == 1) + saved_control_state = e.isControlDown(); + if (saved_control_state) { + if (buttons[1] == state) + return; // ignore + button = (byte)1; + } else { + button = (byte)0; + } + break; + case MouseEvent.BUTTON2: + button = (byte)2; + break; + case MouseEvent.BUTTON3: + if (buttons[1] == state) + return; // ignore + button = (byte)1; + break; + default: + throw new IllegalArgumentException("Not a valid button: " + e.getButton()); + } + setButton(button, state, e.getWhen()*1000000); + } + + public synchronized void mousePressed(MouseEvent e) { + handleButton(e); + } + + private void setButton(byte button, byte state, long nanos) { + buttons[button] = state; + putMouseEvent(button, state, 0, nanos); + } + + public synchronized void mouseReleased(MouseEvent e) { + handleButton(e); + } + + private void handleMotion(MouseEvent e) { + if (grabbed) { + updateDeltas(e.getWhen()*1000000); + } else { + setCursorPos(e.getX(), e.getY(), e.getWhen()*1000000); + } + } + + public synchronized void mouseDragged(MouseEvent e) { + handleMotion(e); + } + + public synchronized void mouseMoved(MouseEvent e) { + handleMotion(e); + } + + private void handleWheel(int amount, long nanos) { + accum_dz += amount; + putMouseEvent((byte)-1, (byte)0, amount, nanos); + } + + protected void updateDeltas(long nanos) { + } + + public synchronized void mouseWheelMoved(MouseWheelEvent e) { + int wheel_amount = -e.getWheelRotation() * WHEEL_SCALE; + handleWheel(wheel_amount, e.getWhen()*1000000); + } +} diff --git a/src/java/org/lwjgl/opengl/OpenGLException.java b/src/java/org/lwjgl/opengl/OpenGLException.java new file mode 100644 index 0000000..aad05fa --- /dev/null +++ b/src/java/org/lwjgl/opengl/OpenGLException.java @@ -0,0 +1,89 @@ +/* + * 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; + +/** + *

    + * Thrown by the debug build library of the LWJGL if any OpenGL operation causes an error. + * + * @author cix_foo + * @version $Revision: 2983 $ + * $Id: OpenGLException.java 2983 2008-04-07 18:36:09Z matzon $ + */ +public class OpenGLException extends RuntimeException { + + private static final long serialVersionUID = 1L; + + /** Constructor for OpenGLException. */ + public OpenGLException(int gl_error_code) { + this(createErrorMessage(gl_error_code)); + } + + private static String createErrorMessage(int gl_error_code) { + String error_string = Util.translateGLErrorString(gl_error_code); + return error_string + " (" + gl_error_code + ")"; + } + + /** Constructor for OpenGLException. */ + public OpenGLException() { + super(); + } + + /** + * Constructor for OpenGLException. + * + * @param message + */ + public OpenGLException(String message) { + super(message); + } + + /** + * Constructor for OpenGLException. + * + * @param message + * @param cause + */ + public OpenGLException(String message, Throwable cause) { + super(message, cause); + } + + /** + * Constructor for OpenGLException. + * + * @param cause + */ + public OpenGLException(Throwable cause) { + super(cause); + } + +} diff --git a/src/java/org/lwjgl/opengl/Pbuffer.java b/src/java/org/lwjgl/opengl/Pbuffer.java new file mode 100644 index 0000000..066328e --- /dev/null +++ b/src/java/org/lwjgl/opengl/Pbuffer.java @@ -0,0 +1,367 @@ +/* + * 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; + +import java.nio.IntBuffer; + +import org.lwjgl.BufferUtils; +import org.lwjgl.LWJGLException; +import org.lwjgl.LWJGLUtil; +import org.lwjgl.Sys; + +/** + *

    + * Pbuffer encapsulates an OpenGL pbuffer. + *

    + * + * This class is thread-safe. + * + * @author elias_naur + * @version $Revision: 3116 $ + * $Id: Pbuffer.java 3116 2008-08-19 16:46:03Z spasi $ + */ +public final class Pbuffer implements Drawable { + /** + * Indicates that Pbuffers can be created. + */ + public static final int PBUFFER_SUPPORTED = 1 << 0; + + /** + * Indicates that Pbuffers can be used as render-textures. + */ + public static final int RENDER_TEXTURE_SUPPORTED = 1 << 1; + + /** + * Indicates that Pbuffers can be used as non-power-of-two render-textures. + */ + public static final int RENDER_TEXTURE_RECTANGLE_SUPPORTED = 1 << 2; + + /** + * Indicates that Pbuffers can be used as depth render-textures. + */ + public static final int RENDER_DEPTH_TEXTURE_SUPPORTED = 1 << 3; + + /** + * The render-to-texture mipmap level attribute. + */ + public static final int MIPMAP_LEVEL = RenderTexture.WGL_MIPMAP_LEVEL_ARB; + + /** + * The render-to-texture cube map face attribute. + */ + public static final int CUBE_MAP_FACE = RenderTexture.WGL_CUBE_MAP_FACE_ARB; + + /** + * The render-to-texture cube map positive X face value. + */ + public static final int TEXTURE_CUBE_MAP_POSITIVE_X = RenderTexture.WGL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB; + + /** + * The render-to-texture cube map negative X face value. + */ + public static final int TEXTURE_CUBE_MAP_NEGATIVE_X = RenderTexture.WGL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB; + + /** + * The render-to-texture cube map positive Y face value. + */ + public static final int TEXTURE_CUBE_MAP_POSITIVE_Y = RenderTexture.WGL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB; + + /** + * The render-to-texture cube map negative Y face value. + */ + public static final int TEXTURE_CUBE_MAP_NEGATIVE_Y = RenderTexture.WGL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB; + + /** + * The render-to-texture cube map positive Z face value. + */ + public static final int TEXTURE_CUBE_MAP_POSITIVE_Z = RenderTexture.WGL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB; + + /** + * The render-to-texture cube map negative Z face value. + */ + public static final int TEXTURE_CUBE_MAP_NEGATIVE_Z = RenderTexture.WGL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB; + + /** + * The Pbuffer front left buffer. + */ + public static final int FRONT_LEFT_BUFFER = RenderTexture.WGL_FRONT_LEFT_ARB; + + /** + * The Pbuffer front right buffer. + */ + public static final int FRONT_RIGHT_BUFFER = RenderTexture.WGL_FRONT_RIGHT_ARB; + + /** + * The Pbuffer back left buffer. + */ + public static final int BACK_LEFT_BUFFER = RenderTexture.WGL_BACK_LEFT_ARB; + + /** + * The Pbuffer back right buffer. + */ + public static final int BACK_RIGHT_BUFFER = RenderTexture.WGL_BACK_RIGHT_ARB; + + /** + * The Pbuffer depth buffer. + */ + public static final int DEPTH_BUFFER = RenderTexture.WGL_DEPTH_COMPONENT_NV; + + /** + * Handle to the native GL rendering context + */ + private final PeerInfo peer_info; + + /** + * Width + */ + private final int width; + + /** + * Height + */ + private final int height; + + private final Context context; + + private boolean destroyed; + + static { + Sys.initialize(); + } + + /** + * Create an instance of a Pbuffer with a unique OpenGL context. The buffer is single-buffered. + *

    + * NOTE: The Pbuffer will have its own context that shares display lists and textures with shared_context, + * or, if shared_context is null, the Display context if it is created. The Pbuffer + * will have its own OpenGL state. Therefore, state changes to a pbuffer will not be seen in the window context and vice versa. + *

    + * + * @param width Pbuffer width + * @param height Pbuffer height + * @param pixel_format Minimum Pbuffer context properties + * @param shared_drawable If non-null the Pbuffer will share display lists and textures with it. Otherwise, the Pbuffer will share + * with the Display context (if created). + */ + public Pbuffer(int width, int height, PixelFormat pixel_format, Drawable shared_drawable) throws LWJGLException { + this(width, height, pixel_format, null, shared_drawable); + } + + /** + * Create an instance of a Pbuffer with a unique OpenGL context. The buffer is single-buffered. + *

    + * NOTE: The Pbuffer will have its own context that shares display lists and textures with shared_context, + * or, if shared_context is null, the Display context if it is created. The Pbuffer + * will have its own OpenGL state. Therefore, state changes to a pbuffer will not be seen in the window context and vice versa. + *

    + * The renderTexture parameter defines the necessary state for enabling render-to-texture. When this parameter is null, + * render-to-texture is not available. Before using render-to-texture, the Pbuffer capabilities must be queried to ensure that + * it is supported. Currently only windows platform can support this feature, so it is recommended that EXT_framebuffer_object + * or similar is used if available, for maximum portability. + *

    + * + * @param width Pbuffer width + * @param height Pbuffer height + * @param pixel_format Minimum Pbuffer context properties + * @param renderTexture + * @param shared_drawable If non-null the Pbuffer will share display lists and textures with it. Otherwise, the Pbuffer will share + * with the Display context (if created). + */ + public Pbuffer(int width, int height, PixelFormat pixel_format, RenderTexture renderTexture, Drawable shared_drawable) throws LWJGLException { + this(width, height, pixel_format, renderTexture, shared_drawable, null); + } + + /** + * Create an instance of a Pbuffer with a unique OpenGL context. The buffer is single-buffered. + *

    + * NOTE: The Pbuffer will have its own context that shares display lists and textures with shared_context, + * or, if shared_context is null, the Display context if it is created. The Pbuffer + * will have its own OpenGL state. Therefore, state changes to a pbuffer will not be seen in the window context and vice versa. + *

    + * The renderTexture parameter defines the necessary state for enabling render-to-texture. When this parameter is null, + * render-to-texture is not available. Before using render-to-texture, the Pbuffer capabilities must be queried to ensure that + * it is supported. Currently only windows platform can support this feature, so it is recommended that EXT_framebuffer_object + * or similar is used if available, for maximum portability. + *

    + * + * @param width Pbuffer width + * @param height Pbuffer height + * @param pixel_format Minimum Pbuffer context properties + * @param renderTexture + * @param shared_drawable If non-null the Pbuffer will share display lists and textures with it. Otherwise, the Pbuffer will share + * with the Display context (if created). + * @param attribs The ContextAttribs to use when creating the context. (optional, may be null) + */ + public Pbuffer(int width, int height, PixelFormat pixel_format, RenderTexture renderTexture, Drawable shared_drawable, ContextAttribs attribs) throws LWJGLException { + if (pixel_format == null) + throw new NullPointerException("Pixel format must be non-null"); + this.width = width; + this.height = height; + this.peer_info = createPbuffer(width, height, pixel_format, renderTexture); + Context shared_context = null; + if (shared_drawable != null) { + shared_context = shared_drawable.getContext(); + } else { + Drawable display_drawable = Display.getDrawable(); + if (display_drawable != null) + shared_context = display_drawable.getContext(); + } + this.context = new Context(peer_info, attribs, shared_context); + } + + private static PeerInfo createPbuffer(int width, int height, PixelFormat pixel_format, RenderTexture renderTexture) throws LWJGLException { + if ( renderTexture == null ) { + // Though null is a perfectly valid argument, Matrox Parhelia drivers expect + // a 0 terminated list, or else they crash. Supplying NULL or 0, should + // cause the drivers to use default settings + IntBuffer defaultAttribs = BufferUtils.createIntBuffer(1); + return Display.getImplementation().createPbuffer(width, height, pixel_format, null, defaultAttribs); + } else + return Display.getImplementation().createPbuffer(width, height, pixel_format, + renderTexture.pixelFormatCaps, + renderTexture.pBufferAttribs); + } + + public Context getContext() { + return context; + } + + private void checkDestroyed() { + if (destroyed) + throw new IllegalStateException("Pbuffer is destroyed"); + } + + /** + * Method to test for validity of the buffer. If this function returns true, the buffer contents is lost. The buffer can still + * be used, but the results are undefined. The application is expected to release the buffer if needed, destroy it and recreate + * a new buffer. + * + * @return true if the buffer is lost and destroyed, false if the buffer is valid. + */ + public synchronized boolean isBufferLost() { + checkDestroyed(); + return Display.getImplementation().isBufferLost(peer_info); + } + + /** + * Method to make the Pbuffer context current. All subsequent OpenGL calls will go to this buffer. + * @throws LWJGLException if the context could not be made current + */ + public synchronized void makeCurrent() throws LWJGLException { + checkDestroyed(); + context.makeCurrent(); + } + + /** + * Gets the Pbuffer capabilities. + * + * @return a bitmask of Pbuffer capabilities. + */ + public static int getCapabilities() { + return Display.getImplementation().getPbufferCapabilities(); + } + + /** + * Destroys the Pbuffer. After this call, there will be no valid GL rendering context - regardless of whether this Pbuffer was + * the current rendering context or not. + */ + public synchronized void destroy() { + if (destroyed) + return; + try { + context.forceDestroy(); + peer_info.destroy(); + destroyed = true; + } catch (LWJGLException e) { + LWJGLUtil.log("Exception occurred while destroying pbuffer: " + e); + } + } + + // ----------------------------------------------------------------------------------------- + // ------------------------------- Render-to-Texture Methods ------------------------------- + // ----------------------------------------------------------------------------------------- + + /** + * Sets a render-to-texture attribute. + *

    + * The attrib parameter can be one of MIPMAP_LEVEL and CUBE_MAP_FACE. When the attrib parameter is CUBE_MAP_FACE then the value + * parameter can be on of the following: + *

    + * TEXTURE_CUBE_MAP_POSITIVE_X TEXTURE_CUBE_MAP_NEGATIVE_X TEXTURE_CUBE_MAP_POSITIVE_Y TEXTURE_CUBE_MAP_NEGATIVE_Y + * TEXTURE_CUBE_MAP_POSITIVE_Z TEXTURE_CUBE_MAP_NEGATIVE_Z + * + * @param attrib + * @param value + */ + public synchronized void setAttrib(int attrib, int value) { + checkDestroyed(); + Display.getImplementation().setPbufferAttrib(peer_info, attrib, value); + } + + /** + * Binds the currently bound texture to the buffer specified. The buffer can be one of the following: + *

    + * FRONT_LEFT_BUFFER FRONT_RIGHT_BUFFER BACK_LEFT_BUFFER BACK_RIGHT_BUFFER DEPTH_BUFFER + * + * @param buffer + */ + public synchronized void bindTexImage(int buffer) { + checkDestroyed(); + Display.getImplementation().bindTexImageToPbuffer(peer_info, buffer); + } + + /** + * Releases the currently bound texture from the buffer specified. + * + * @param buffer + */ + public synchronized void releaseTexImage(int buffer) { + checkDestroyed(); + Display.getImplementation().releaseTexImageFromPbuffer(peer_info, buffer); + } + + /** + * @return Returns the height. + */ + public synchronized int getHeight() { + checkDestroyed(); + return height; + } + + /** + * @return Returns the width. + */ + public synchronized int getWidth() { + checkDestroyed(); + return width; + } +} diff --git a/src/java/org/lwjgl/opengl/PeerInfo.java b/src/java/org/lwjgl/opengl/PeerInfo.java new file mode 100644 index 0000000..26c9563 --- /dev/null +++ b/src/java/org/lwjgl/opengl/PeerInfo.java @@ -0,0 +1,97 @@ +/* + * 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; + +import java.nio.ByteBuffer; + +import org.lwjgl.LWJGLException; +import org.lwjgl.LWJGLUtil; + +/** + * + * @author elias_naur + * @version $Revision: 3116 $ + * $Id: PeerInfo.java 3116 2008-08-19 16:46:03Z spasi $ + */ +abstract class PeerInfo { + private final ByteBuffer handle; + private Thread locking_thread; // Thread that has locked this PeerInfo + private int lock_count; + + protected PeerInfo(ByteBuffer handle) { + this.handle = handle; + } + + private void lockAndInitHandle() throws LWJGLException { + doLockAndInitHandle(); + } + + public synchronized final void unlock() throws LWJGLException { + if (lock_count <= 0) + throw new IllegalStateException("PeerInfo not locked!"); + if (Thread.currentThread() != locking_thread) + throw new IllegalStateException("PeerInfo already locked by " + locking_thread); + lock_count--; + if (lock_count == 0) { + doUnlock(); + locking_thread = null; + notify(); + } + } + + protected abstract void doLockAndInitHandle() throws LWJGLException; + protected abstract void doUnlock() throws LWJGLException; + + public synchronized final ByteBuffer lockAndGetHandle() throws LWJGLException { + Thread this_thread = Thread.currentThread(); + while (locking_thread != null && locking_thread != this_thread) { + try { + wait(); + } catch (InterruptedException e) { + LWJGLUtil.log("Interrupted while waiting for PeerInfo lock: " + e); + } + } + if (lock_count == 0) { + locking_thread = this_thread; + doLockAndInitHandle(); + } + lock_count++; + return getHandle(); + } + + protected final ByteBuffer getHandle() { + return handle; + } + + public void destroy() { + } +} diff --git a/src/java/org/lwjgl/opengl/PixelFormat.java b/src/java/org/lwjgl/opengl/PixelFormat.java new file mode 100644 index 0000000..a94233f --- /dev/null +++ b/src/java/org/lwjgl/opengl/PixelFormat.java @@ -0,0 +1,378 @@ +/* + * 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; + +/** + * This class describes pixel format properties for an OpenGL context. Instances + * of this class is used as arguments to Display.create(), Pbuffer.create() and + * AWTGLCanvas, to indicate minimum required properties. + *

    + * Instants of this class are immutable. An example of the expected way to set + * the PixelFormat property values is the following: + * PixelFormat pf = new PixelFormat().withDepth(24).withSamples(4).withSRGB(true); + *

    + * WARNING: Some pixel formats are known to cause troubles on certain buggy drivers. + * Example: Under Windows, specifying samples != 0 will enable the ARB + * pixel format selection path, which could trigger a crash. + * + * @author elias_naur@sourceforge.net + * @version $Revision: 3116 $ + */ + +public final class PixelFormat { + + /** + * The number of bits per pixel, exluding alpha. + * This parameter is ignored in Display.create(). + */ + private int bpp; + /** The number of alpha bits. */ + private int alpha; + /** The number of depth buffer bits */ + private int depth; + /** The number of stencil bits */ + private int stencil; + /** + * The number of samples to use in anti-aliasing. + * 0 means that anti-aliasing is disabled. + */ + private int samples; + /** The number of auxiliary buffers */ + private int num_aux_buffers; + /** The number of bits per pixel in the accumulation buffer */ + private int accum_bpp; + /** The number of alpha bits in the accumulation buffer */ + private int accum_alpha; + /** Whether this format requires a stereo buffer */ + private boolean stereo; + /** Whether this format specifies a floating point format */ + private boolean floating_point; + /** Whether this format specifies a packed floating point format (32 bit unsigned - R11F_G11F_B10F) */ + private boolean floating_point_packed; + /** Whether this format specifies an sRGB format */ + private boolean sRGB; + + /** + * Default pixel format is minimum 8 bits depth, and no alpha + * nor stencil requirements. + */ + public PixelFormat() { + this(0, 8, 0); + } + + public PixelFormat(int alpha, int depth, int stencil) { + this(alpha, depth, stencil, 0); + } + + public PixelFormat(int alpha, int depth, int stencil, int samples) { + this(0, alpha, depth, stencil, samples); + } + + public PixelFormat(int bpp, int alpha, int depth, int stencil, int samples) { + this(bpp, alpha, depth, stencil, samples, 0, 0, 0, false); + } + + public PixelFormat(int bpp, int alpha, int depth, int stencil, int samples, int num_aux_buffers, int accum_bpp, int accum_alpha, boolean stereo) { + this(bpp, alpha, depth, stencil, samples, num_aux_buffers, accum_bpp, accum_alpha, stereo, false); + } + + public PixelFormat(int bpp, int alpha, int depth, int stencil, int samples, int num_aux_buffers, int accum_bpp, int accum_alpha, boolean stereo, boolean floating_point) { + this.bpp = bpp; + this.alpha = alpha; + this.depth = depth; + this.stencil = stencil; + + this.samples = samples; + + this.num_aux_buffers = num_aux_buffers; + + this.accum_bpp = accum_bpp; + this.accum_alpha = accum_alpha; + + this.stereo = stereo; + + this.floating_point = floating_point; + this.floating_point_packed = false; + this.sRGB = false; + } + + private PixelFormat(final PixelFormat pf) { + this.bpp = pf.bpp; + this.alpha = pf.alpha; + this.depth = pf.depth; + this.stencil = pf.stencil; + + this.samples = pf.samples; + + this.num_aux_buffers = pf.num_aux_buffers; + + this.accum_bpp = pf.accum_bpp; + this.accum_alpha = pf.accum_alpha; + + this.stereo = pf.stereo; + + this.floating_point = pf.floating_point; + this.floating_point_packed = pf.floating_point_packed; + this.sRGB = pf.sRGB; + } + + public int getBitsPerPixel() { + return bpp; + } + + /** + * Returns a new PixelFormat object with the same properties as this PixelFormat and the new bits per pixel value. + * + * @param bpp the new bits per pixel value. + * + * @return the new PixelFormat + */ + public PixelFormat withBitsPerPixel(final int bpp) { + if ( bpp < 0 ) + throw new IllegalArgumentException("Invalid number of bits per pixel specified: " + bpp); + + final PixelFormat pf = new PixelFormat(this); + pf.bpp = bpp; + return pf; + } + + public int getAlphaBits() { + return alpha; + } + + /** + * Returns a new PixelFormat object with the same properties as this PixelFormat and the new alpha bits value. + * + * @param alpha the new alpha bits value. + * + * @return the new PixelFormat + */ + public PixelFormat withAlphaBits(final int alpha) { + if ( alpha < 0 ) + throw new IllegalArgumentException("Invalid number of alpha bits specified: " + alpha); + + final PixelFormat pf = new PixelFormat(this); + pf.alpha = alpha; + return pf; + } + + public int getDepthBits() { + return depth; + } + + /** + * Returns a new PixelFormat object with the same properties as this PixelFormat and the new depth bits value. + * + * @param depth the new depth bits value. + * + * @return the new PixelFormat + */ + public PixelFormat withDepthBits(final int depth) { + if ( depth < 0 ) + throw new IllegalArgumentException("Invalid number of depth bits specified: " + depth); + + final PixelFormat pf = new PixelFormat(this); + pf.depth = depth; + return pf; + } + + public int getStencilBits() { + return stencil; + } + + /** + * Returns a new PixelFormat object with the same properties as this PixelFormat and the new stencil bits value. + * + * @param stencil the new stencil bits value. + * + * @return the new PixelFormat + */ + public PixelFormat withStencilBits(final int stencil) { + if ( stencil < 0 ) + throw new IllegalArgumentException("Invalid number of stencil bits specified: " + stencil); + + final PixelFormat pf = new PixelFormat(this); + pf.stencil = stencil; + return pf; + } + + public int getSamples() { + return samples; + } + + /** + * Returns a new PixelFormat object with the same properties as this PixelFormat and the new samples value. + * + * @param samples the new samples value. + * + * @return the new PixelFormat + */ + public PixelFormat withSamples(final int samples) { + if ( samples < 0 ) + throw new IllegalArgumentException("Invalid number of samples specified: " + samples); + + final PixelFormat pf = new PixelFormat(this); + pf.samples = samples; + return pf; + } + + public int getAuxBuffers() { + return num_aux_buffers; + } + + /** + * Returns a new PixelFormat object with the same properties as this PixelFormat and the new auxiliary buffers value. + * + * @param num_aux_buffers the new auxiliary buffers value. + * + * @return the new PixelFormat + */ + public PixelFormat withAuxBuffers(final int num_aux_buffers) { + if ( num_aux_buffers < 0 ) + throw new IllegalArgumentException("Invalid number of auxiliary buffers specified: " + num_aux_buffers); + + final PixelFormat pf = new PixelFormat(this); + pf.num_aux_buffers = num_aux_buffers; + return pf; + } + + public int getAccumulationBitsPerPixel() { + return accum_bpp; + } + + /** + * Returns a new PixelFormat object with the same properties as this PixelFormat and the new bits per pixel in the accumulation buffer value. + * + * @param accum_bpp the new bits per pixel in the accumulation buffer value. + * + * @return the new PixelFormat + */ + public PixelFormat withAccumulationBitsPerPixel(final int accum_bpp) { + if ( accum_bpp < 0 ) + throw new IllegalArgumentException("Invalid number of bits per pixel in the accumulation buffer specified: " + accum_bpp); + + final PixelFormat pf = new PixelFormat(this); + pf.accum_bpp = accum_bpp; + return pf; + } + + public int getAccumulationAlpha() { + return accum_alpha; + } + + /** + * Returns a new PixelFormat object with the same properties as this PixelFormat and the new alpha bits in the accumulation buffer value. + * + * @param accum_alpha the new alpha bits in the accumulation buffer value. + * + * @return the new PixelFormat + */ + public PixelFormat withAccumulationAlpha(final int accum_alpha) { + if ( accum_alpha < 0 ) + throw new IllegalArgumentException("Invalid number of alpha bits in the accumulation buffer specified: " + accum_alpha); + + final PixelFormat pf = new PixelFormat(this); + pf.accum_alpha = accum_alpha; + return pf; + } + + public boolean isStereo() { + return stereo; + } + + /** + * Returns a new PixelFormat object with the same properties as this PixelFormat and the new stereo value. + * + * @param stereo the new stereo value. + * + * @return the new PixelFormat + */ + public PixelFormat withStereo(final boolean stereo) { + final PixelFormat pf = new PixelFormat(this); + pf.stereo = stereo; + return pf; + } + + public boolean isFloatingPoint() { + return floating_point; + } + + /** + * Returns a new PixelFormat object with the same properties as this PixelFormat and the new floating point value. + * If floating_point is true, floating_point_packed will be reset to false. + * + * @param floating_point the new floating point value. + * + * @return the new PixelFormat + */ + public PixelFormat withFloatingPoint(final boolean floating_point) { + final PixelFormat pf = new PixelFormat(this); + pf.floating_point = floating_point; + if ( floating_point ) + pf.floating_point_packed = false; + return pf; + } + + /** + * Returns a new PixelFormat object with the same properties as this PixelFormat and the new packed floating point value. + * If floating_point_packed is true, floating_point will be reset to false. + * + * @param floating_point_packed the new packed floating point value. + * + * @return the new PixelFormat + */ + public PixelFormat withFloatingPointPacked(final boolean floating_point_packed) { + final PixelFormat pf = new PixelFormat(this); + pf.floating_point_packed = floating_point_packed; + if ( floating_point_packed ) + pf.floating_point = false; + return pf; + } + + public boolean isSRGB() { + return sRGB; + } + + /** + * Returns a new PixelFormat object with the same properties as this PixelFormat and the new sRGB value. + * + * @param sRGB the new floating point value. + * + * @return the new PixelFormat + */ + public PixelFormat withSRGB(final boolean sRGB) { + final PixelFormat pf = new PixelFormat(this); + pf.sRGB = sRGB; + return pf; + } + +} \ No newline at end of file diff --git a/src/java/org/lwjgl/opengl/PointerWrapper.java b/src/java/org/lwjgl/opengl/PointerWrapper.java new file mode 100644 index 0000000..123c602 --- /dev/null +++ b/src/java/org/lwjgl/opengl/PointerWrapper.java @@ -0,0 +1,39 @@ +/* + * 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; + +/** @author spasi */ +public interface PointerWrapper { + + long getPointer(); + +} \ No newline at end of file diff --git a/src/java/org/lwjgl/opengl/ReferencesStack.java b/src/java/org/lwjgl/opengl/ReferencesStack.java new file mode 100644 index 0000000..69936a8 --- /dev/null +++ b/src/java/org/lwjgl/opengl/ReferencesStack.java @@ -0,0 +1,73 @@ +/* + * 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; + +class ReferencesStack { + private References[] references_stack; + private int stack_pos; + + public References getReferences() { + return references_stack[stack_pos]; + } + + public void pushState() { + int pos = ++stack_pos; + if (pos == references_stack.length) { + growStack(); + } + references_stack[pos].copy(references_stack[pos - 1], GL11.GL_ALL_CLIENT_ATTRIB_BITS); + } + + public References popState(int mask) { + References result = references_stack[stack_pos--]; + + references_stack[stack_pos].copy(result, ~mask); + result.clear(); + + return result; + } + + private void growStack() { + References[] new_references_stack = new References[references_stack.length + 1]; + System.arraycopy(references_stack, 0, new_references_stack, 0, references_stack.length); + references_stack = new_references_stack; + references_stack[references_stack.length - 1] = new References(GLContext.getCapabilities()); + } + + ReferencesStack() { + ContextCapabilities caps = GLContext.getCapabilities(); + references_stack = new References[1]; + stack_pos = 0; + for (int i = 0; i < references_stack.length; i++) + references_stack[i] = new References(caps); + } +} diff --git a/src/java/org/lwjgl/opengl/RenderTexture.java b/src/java/org/lwjgl/opengl/RenderTexture.java new file mode 100644 index 0000000..008439d --- /dev/null +++ b/src/java/org/lwjgl/opengl/RenderTexture.java @@ -0,0 +1,249 @@ +/* + * 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; + +import java.nio.IntBuffer; + +import org.lwjgl.BufferUtils; + +/** This class represents the state necessary for render-to-texture. */ +public final class RenderTexture { + + // ---------------------------------------------------------------------------------- + // ----------------------------- WGL_ARB_render_texture ----------------------------- + // ---------------------------------------------------------------------------------- + + /* + Accepted by the parameter of wglGetPixelFormatAttribivARB, + wglGetPixelFormatAttribfvARB, and the and + parameters of wglChoosePixelFormatARB: + */ + private static final int WGL_BIND_TO_TEXTURE_RGB_ARB = 0x2070; + private static final int WGL_BIND_TO_TEXTURE_RGBA_ARB = 0x2071; + + /* + Accepted by the parameter of wglCreatePbufferARB and + by the parameter of wglQueryPbufferARB: + */ + private static final int WGL_TEXTURE_FORMAT_ARB = 0x2072; + private static final int WGL_TEXTURE_TARGET_ARB = 0x2073; + private static final int WGL_MIPMAP_TEXTURE_ARB = 0x2074; + + /* + Accepted as a value in the parameter of + wglCreatePbufferARB and returned in the value parameter of + wglQueryPbufferARB when is WGL_TEXTURE_FORMAT_ARB: + */ + private static final int WGL_TEXTURE_RGB_ARB = 0x2075; + private static final int WGL_TEXTURE_RGBA_ARB = 0x2076; + + /* + Accepted as a value in the parameter of + wglCreatePbufferARB and returned in the value parameter of + wglQueryPbufferARB when is WGL_TEXTURE_TARGET_ARB: + */ + private static final int WGL_TEXTURE_CUBE_MAP_ARB = 0x2078; + private static final int WGL_TEXTURE_1D_ARB = 0x2079; + private static final int WGL_TEXTURE_2D_ARB = 0x207A; + private static final int WGL_NO_TEXTURE_ARB = 0x2077; + + /* + Accepted by the parameter of wglSetPbufferAttribARB and + by the parameter of wglQueryPbufferARB: + */ + static final int WGL_MIPMAP_LEVEL_ARB = 0x207B; + static final int WGL_CUBE_MAP_FACE_ARB = 0x207C; + + /* + Accepted as a value in the parameter of + wglSetPbufferAttribARB and returned in the value parameter of + wglQueryPbufferARB when is WGL_CUBE_MAP_FACE_ARB: + */ + static final int WGL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB = 0x207D; + static final int WGL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB = 0x207E; + static final int WGL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB = 0x207F; + static final int WGL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB = 0x2080; + static final int WGL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB = 0x2081; + static final int WGL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB = 0x2082; + + /* + Accepted by the parameter of wglBindTexImageARB and + wglReleaseTexImageARB: + */ + static final int WGL_FRONT_LEFT_ARB = 0x2083; + static final int WGL_FRONT_RIGHT_ARB = 0x2084; + static final int WGL_BACK_LEFT_ARB = 0x2085; + static final int WGL_BACK_RIGHT_ARB = 0x2086; + + /* + private static final int WGL_AUX0_ARB = 0x2087; + private static final int WGL_AUX1_ARB = 0x2088; + private static final int WGL_AUX2_ARB = 0x2089; + private static final int WGL_AUX3_ARB = 0x208A; + private static final int WGL_AUX4_ARB = 0x208B; + private static final int WGL_AUX5_ARB = 0x208C; + private static final int WGL_AUX6_ARB = 0x208D; + private static final int WGL_AUX7_ARB = 0x208E; + private static final int WGL_AUX8_ARB = 0x208F; + private static final int WGL_AUX9_ARB = 0x2090; + */ + + // ------------------------------------------------------------------------------------------- + // ----------------------------- WGL_NV_render_texture_rectangle ----------------------------- + // ------------------------------------------------------------------------------------------- + + /* + Accepted by the parameter of wglGetPixelFormatAttribivARB, + wglGetPixelFormatAttribfvARB, and the and + parameters of wglChoosePixelFormatARB: + */ + private static final int WGL_BIND_TO_TEXTURE_RECTANGLE_RGB_NV = 0x20A0; + private static final int WGL_BIND_TO_TEXTURE_RECTANGLE_RGBA_NV = 0x20A1; + + /* + Accepted as a value in the parameter of wglCreatePbufferARB + and returned in the value parameter of wglQueryPbufferARB when + is WGL_TEXTURE_TARGET_ARB: + */ + private static final int WGL_TEXTURE_RECTANGLE_NV = 0x20A2; + + // --------------------------------------------------------------------------------------- + // ----------------------------- WGL_NV_render_depth_texture ----------------------------- + // --------------------------------------------------------------------------------------- + + /* + Accepted by the parameter of wglGetPixelFormatAttribivARB, + wglGetPixelFormatAttribfvARB, and the and + parameters of wglChoosePixelFormatARB: + */ + private static final int WGL_BIND_TO_TEXTURE_DEPTH_NV = 0x20A3; + private static final int WGL_BIND_TO_TEXTURE_RECTANGLE_DEPTH_NV = 0x20A4; + + /* + Accepted by the parameter of wglCreatePbufferARB and + by the parameter of wglQueryPbufferARB: + */ + private static final int WGL_DEPTH_TEXTURE_FORMAT_NV = 0x20A5; + + /* + Accepted as a value in the parameter of wglCreatePbufferARB + and returned in the value parameter of wglQueryPbufferARB when + is WGL_DEPTH_TEXTURE_FORMAT_NV: + */ + private static final int WGL_TEXTURE_DEPTH_COMPONENT_NV = 0x20A6; + + /* + Accepted by the parameter of wglBindTexImageARB: + */ + static final int WGL_DEPTH_COMPONENT_NV = 0x20A7; + + /** The TEXTURE_1D target. */ + public static final int RENDER_TEXTURE_1D = WGL_TEXTURE_1D_ARB; + + /** The TEXTURE_2D target. */ + public static final int RENDER_TEXTURE_2D = WGL_TEXTURE_2D_ARB; + + /** The TEXTURE_RECTANGLE target. */ + public static final int RENDER_TEXTURE_RECTANGLE = WGL_TEXTURE_RECTANGLE_NV; + + /** The TEXTURE_CUBE_MAP target. */ + public static final int RENDER_TEXTURE_CUBE_MAP = WGL_TEXTURE_CUBE_MAP_ARB; + + IntBuffer pixelFormatCaps; + IntBuffer pBufferAttribs; + + /** + * Creates a RenderTexture object for enabling render-to-texture on a P-buffer. + *

    + * NOTE: Only one of useRGB and useRGBA can be true at the same time. + *

    + * NOTE: useRGB(A) and useDepth can be true at the same time, thus allowing two different render textures. + *

    + * NOTE: The target parameter can be one of the following: + *

    + * RENDER_TEXTURE_1D RENDER_TEXTURE_2D RENDER_TEXTURE_RECTANGLE RENDER_TEXTURE_CUBE_MAP + * + * @param useRGB - When true the P-buffer can be used as an RGB render texture. + * @param useRGBA - When true the P-buffer can be used as an RGBA render texture. + * @param useDepth - When true the P-buffer can be used as a depth render texture. + * @param isRectangle - When true rectangle textures will be allowed on the P-buffer. + * @param target - The texture target of the render texture. + * @param mipmaps - How many mipmap levels to allocate on the P-buffer. + */ + public RenderTexture(boolean useRGB, boolean useRGBA, boolean useDepth, boolean isRectangle, int target, int mipmaps) { + if ( useRGB && useRGBA ) + throw new IllegalArgumentException("A RenderTexture can't be both RGB and RGBA."); + + if ( mipmaps < 0 ) + throw new IllegalArgumentException("The mipmap levels can't be negative."); + + if ( isRectangle && target != RENDER_TEXTURE_RECTANGLE ) + throw new IllegalArgumentException("When the RenderTexture is rectangle the target must be RENDER_TEXTURE_RECTANGLE."); + + pixelFormatCaps = BufferUtils.createIntBuffer(4); + pBufferAttribs = BufferUtils.createIntBuffer(8); + + if ( useRGB ) { + pixelFormatCaps.put(isRectangle ? WGL_BIND_TO_TEXTURE_RECTANGLE_RGB_NV : WGL_BIND_TO_TEXTURE_RGB_ARB); + pixelFormatCaps.put(GL11.GL_TRUE); + + pBufferAttribs.put(WGL_TEXTURE_FORMAT_ARB); + pBufferAttribs.put(WGL_TEXTURE_RGB_ARB); + } else if ( useRGBA ) { + pixelFormatCaps.put(isRectangle ? WGL_BIND_TO_TEXTURE_RECTANGLE_RGBA_NV : WGL_BIND_TO_TEXTURE_RGBA_ARB); + pixelFormatCaps.put(GL11.GL_TRUE); + + pBufferAttribs.put(WGL_TEXTURE_FORMAT_ARB); + pBufferAttribs.put(WGL_TEXTURE_RGBA_ARB); + } + + if ( useDepth ) { + pixelFormatCaps.put(isRectangle ? WGL_BIND_TO_TEXTURE_RECTANGLE_DEPTH_NV : WGL_BIND_TO_TEXTURE_DEPTH_NV); + pixelFormatCaps.put(GL11.GL_TRUE); + + pBufferAttribs.put(WGL_DEPTH_TEXTURE_FORMAT_NV); + pBufferAttribs.put(WGL_TEXTURE_DEPTH_COMPONENT_NV); + } + + pBufferAttribs.put(WGL_TEXTURE_TARGET_ARB); + pBufferAttribs.put(target); + + if ( mipmaps != 0 ) { + pBufferAttribs.put(WGL_MIPMAP_TEXTURE_ARB); + pBufferAttribs.put(mipmaps); + } + + pixelFormatCaps.flip(); + pBufferAttribs.flip(); + } + +} \ No newline at end of file diff --git a/src/java/org/lwjgl/opengl/StateStack.java b/src/java/org/lwjgl/opengl/StateStack.java new file mode 100644 index 0000000..9d7755d --- /dev/null +++ b/src/java/org/lwjgl/opengl/StateStack.java @@ -0,0 +1,65 @@ +/* + * 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; + +class StateStack { + private int[] state_stack; + private int stack_pos; + + public int getState() { + return state_stack[stack_pos]; + } + + public void pushState(int new_state) { + int pos = ++stack_pos; + if (pos == state_stack.length) { + growState(); + } + state_stack[pos] = new_state; + } + + public int popState() { + return state_stack[stack_pos--]; + } + + public void growState() { + int[] new_state_stack = new int[state_stack.length + 1]; + System.arraycopy(state_stack, 0, new_state_stack, 0, state_stack.length); + state_stack = new_state_stack; + } + + StateStack(int initial_value) { + state_stack = new int[1]; + stack_pos = 0; + state_stack[stack_pos] = initial_value; + } +} diff --git a/src/java/org/lwjgl/opengl/StateTracker.java b/src/java/org/lwjgl/opengl/StateTracker.java new file mode 100644 index 0000000..8918d27 --- /dev/null +++ b/src/java/org/lwjgl/opengl/StateTracker.java @@ -0,0 +1,99 @@ +/* + * 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; + +final class StateTracker { + private ReferencesStack references_stack; + private final StateStack attrib_stack; + + private boolean insideBeginEnd; + + StateTracker() { + attrib_stack = new StateStack(0); + } + + /** This is called after getting function addresses. */ + void init() { + references_stack = new ReferencesStack(); + } + + static void setBeginEnd(ContextCapabilities caps, boolean inside) { + caps.tracker.insideBeginEnd = inside; + } + + boolean isBeginEnd() { + return insideBeginEnd; + } + + static void popAttrib(ContextCapabilities caps) { + caps.tracker.doPopAttrib(); + } + + private void doPopAttrib() { + references_stack.popState(attrib_stack.popState()); + } + + static void pushAttrib(ContextCapabilities caps, int mask) { + caps.tracker.doPushAttrib(mask); + } + + private void doPushAttrib(int mask) { + attrib_stack.pushState(mask); + references_stack.pushState(); + } + + static ReferencesStack getReferencesStack(ContextCapabilities caps) { + return caps.tracker.references_stack; + } + + static void bindBuffer(ContextCapabilities caps, int target, int buffer) { + ReferencesStack references_stack = getReferencesStack(caps); + switch(target) { + case GL15.GL_ELEMENT_ARRAY_BUFFER: + references_stack.getReferences().elementArrayBuffer = buffer; + break; + case GL15.GL_ARRAY_BUFFER: + references_stack.getReferences().arrayBuffer = buffer; + break; + case GL21.GL_PIXEL_PACK_BUFFER: + references_stack.getReferences().pixelPackBuffer = buffer; + break; + case GL21.GL_PIXEL_UNPACK_BUFFER: + references_stack.getReferences().pixelUnpackBuffer = buffer; + break; + case GL40.GL_DRAW_INDIRECT_BUFFER: + references_stack.getReferences().indirectBuffer = buffer; + break; + + } + } +} diff --git a/src/java/org/lwjgl/opengl/Util.java b/src/java/org/lwjgl/opengl/Util.java new file mode 100644 index 0000000..04b4761 --- /dev/null +++ b/src/java/org/lwjgl/opengl/Util.java @@ -0,0 +1,87 @@ +/* + * 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; + + +/** + * Simple utility class. + * + * @author cix_foo + * @version $Revision: 3316 $ + */ + +public final class Util { + /** No c'tor */ + private Util() { + } + + /** + * Throws OpenGLException if GL11.glGetError() returns anything else than GL11.GL_NO_ERROR + * + */ + public static void checkGLError() throws OpenGLException { + if ( ContextCapabilities.DEBUG && GLContext.getCapabilities().tracker.isBeginEnd() ) // Do not call GetError inside a Begin/End pair. + return; + int err = GL11.glGetError(); + if ( err != GL11.GL_NO_ERROR ) { + throw new OpenGLException(err); + } + } + + /** + * Translate a GL error code to a String describing the error + */ + public static String translateGLErrorString(int error_code) { + switch (error_code) { + case GL11.GL_NO_ERROR: + return "No error"; + case GL11.GL_INVALID_ENUM: + return "Invalid enum"; + case GL11.GL_INVALID_VALUE: + return "Invalid value"; + case GL11.GL_INVALID_OPERATION: + return "Invalid operation"; + case GL11.GL_STACK_OVERFLOW: + return "Stack overflow"; + case GL11.GL_STACK_UNDERFLOW: + return "Stack underflow"; + case GL11.GL_OUT_OF_MEMORY: + return "Out of memory"; + case ARBImaging.GL_TABLE_TOO_LARGE: + return "Table too large"; + case EXTFramebufferObject.GL_INVALID_FRAMEBUFFER_OPERATION_EXT: + return "Invalid framebuffer operation"; + default: + return null; + } + } +} diff --git a/src/java/org/lwjgl/opengl/WindowsAWTGLCanvasPeerInfo.java b/src/java/org/lwjgl/opengl/WindowsAWTGLCanvasPeerInfo.java new file mode 100644 index 0000000..c7acf7e --- /dev/null +++ b/src/java/org/lwjgl/opengl/WindowsAWTGLCanvasPeerInfo.java @@ -0,0 +1,71 @@ +/* + * 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; + +import java.nio.ByteBuffer; + +import org.lwjgl.LWJGLException; + +import java.awt.Canvas; + +/** + * + * @author elias_naur + * @version $Revision: 3116 $ + * $Id: WindowsAWTGLCanvasPeerInfo.java 3116 2008-08-19 16:46:03Z spasi $ + */ +final class WindowsAWTGLCanvasPeerInfo extends WindowsPeerInfo { + private final Canvas component; + private final AWTSurfaceLock awt_surface = new AWTSurfaceLock(); + private final PixelFormat pixel_format; + private boolean has_pixel_format= false; + + WindowsAWTGLCanvasPeerInfo(Canvas component, PixelFormat pixel_format) { + this.component = component; + this.pixel_format = pixel_format; + } + + protected void doLockAndInitHandle() throws LWJGLException { + nInitHandle(awt_surface.lockAndGetHandle(component), getHandle()); + if (!has_pixel_format && pixel_format != null) { + // If we haven't applied a pixel format yet, do it now + int format = choosePixelFormat(getHdc(), component.getX(), component.getY(), pixel_format, null, true, true, false, true); + setPixelFormat(getHdc(), format); + has_pixel_format = true; + } + } + private static native void nInitHandle(ByteBuffer surface_buffer, ByteBuffer peer_info_handle) throws LWJGLException; + + protected void doUnlock() throws LWJGLException { + awt_surface.unlock(); + } +} diff --git a/src/java/org/lwjgl/opengl/WindowsCanvasImplementation.java b/src/java/org/lwjgl/opengl/WindowsCanvasImplementation.java new file mode 100644 index 0000000..56f2510 --- /dev/null +++ b/src/java/org/lwjgl/opengl/WindowsCanvasImplementation.java @@ -0,0 +1,85 @@ +/* + * 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; + +import java.awt.GraphicsConfiguration; +import java.awt.GraphicsDevice; +import java.awt.Toolkit; +import java.awt.Canvas; +import java.security.PrivilegedAction; +import java.security.AccessController; + +import org.lwjgl.LWJGLException; +import org.lwjgl.LWJGLUtil; + +/** + * + * @author elias_naur + * @version $Revision: 3002 $ + * $Id: WindowsCanvasImplementation.java 3002 2008-04-10 20:25:54Z elias_naur $ + */ +final class WindowsCanvasImplementation implements AWTCanvasImplementation { + static { + // Make sure the awt stuff is properly initialised (the jawt library in particular) + Toolkit.getDefaultToolkit(); + AccessController.doPrivileged(new PrivilegedAction() { + public Object run() { + try { + System.loadLibrary("jawt"); + } catch (UnsatisfiedLinkError e) { + /* It is probably already loaded, potentially by a different ClassLoader + * so just log the exception and continue + */ + LWJGLUtil.log("Failed to load jawt: " + e.getMessage()); + } + return null; + } + }); + } + + public PeerInfo createPeerInfo(Canvas component, PixelFormat pixel_format) throws LWJGLException { + return new WindowsAWTGLCanvasPeerInfo(component, pixel_format); + } + + /** + * Find a proper GraphicsConfiguration from the given GraphicsDevice and PixelFormat. + * + * @return The GraphicsConfiguration corresponding to a visual that matches the pixel format. + */ + public GraphicsConfiguration findConfiguration(GraphicsDevice device, PixelFormat pixel_format) throws LWJGLException { + /* + * It seems like the best way is to simply return null and + * use SetPixelFormat in JNI later. + */ + return null; + } +} diff --git a/src/java/org/lwjgl/opengl/WindowsContextAttribs.java b/src/java/org/lwjgl/opengl/WindowsContextAttribs.java new file mode 100644 index 0000000..3273144 --- /dev/null +++ b/src/java/org/lwjgl/opengl/WindowsContextAttribs.java @@ -0,0 +1,92 @@ +/* + * 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; + +/** + * An implementation of ContextAttribs using WGL_create_context. + * + * @author spasi + */ +final class WindowsContextAttribs implements ContextAttribsImplementation { + + private static final int WGL_CONTEXT_MAJOR_VERSION_ARB = 0x2091; + private static final int WGL_CONTEXT_MINOR_VERSION_ARB = 0x2092; + private static final int WGL_CONTEXT_LAYER_PLANE_ARB = 0x2093; + private static final int WGL_CONTEXT_FLAGS_ARB = 0x2094; + private static final int WGL_CONTEXT_PROFILE_MASK_ARB = 0x9126; + + private static final int WGL_CONTEXT_DEBUG_BIT_ARB = 0x0001; + private static final int WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB = 0x0002; + + private static final int WGL_CONTEXT_CORE_PROFILE_BIT_ARB = 0x00000001; + private static final int WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB = 0x00000002; + + WindowsContextAttribs() { + } + + public int getMajorVersionAttrib() { + return WGL_CONTEXT_MAJOR_VERSION_ARB; + } + + public int getMinorVersionAttrib() { + return WGL_CONTEXT_MINOR_VERSION_ARB; + } + + public int getLayerPlaneAttrib() { + return WGL_CONTEXT_LAYER_PLANE_ARB; + } + + public int getFlagsAttrib() { + return WGL_CONTEXT_FLAGS_ARB; + } + + public int getDebugBit() { + return WGL_CONTEXT_DEBUG_BIT_ARB; + } + + public int getForwardCompatibleBit() { + return WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB; + } + + public int getProfileMaskAttrib() { + return WGL_CONTEXT_PROFILE_MASK_ARB; + } + + public int getProfileCoreBit() { + return WGL_CONTEXT_CORE_PROFILE_BIT_ARB; + } + + public int getProfileCompatibilityBit() { + return WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB; + } + +} \ No newline at end of file diff --git a/src/java/org/lwjgl/opengl/WindowsContextImplementation.java b/src/java/org/lwjgl/opengl/WindowsContextImplementation.java new file mode 100644 index 0000000..33e535e --- /dev/null +++ b/src/java/org/lwjgl/opengl/WindowsContextImplementation.java @@ -0,0 +1,119 @@ +/* + * 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; + +import org.lwjgl.LWJGLException; +import org.lwjgl.LWJGLUtil; + +import java.nio.ByteBuffer; +import java.nio.IntBuffer; + +/** + * @author elias_naur + * @version $Revision: 3116 $ + * $Id: WindowsContextImplementation.java 3116 2008-08-19 16:46:03Z spasi $ + */ +final class WindowsContextImplementation implements ContextImplementation { + + public ByteBuffer create(PeerInfo peer_info, IntBuffer attribs, ByteBuffer shared_context_handle) throws LWJGLException { + ByteBuffer peer_handle = peer_info.lockAndGetHandle(); + try { + return nCreate(peer_handle, attribs, shared_context_handle); + } finally { + peer_info.unlock(); + } + } + + private static native ByteBuffer nCreate(ByteBuffer peer_handle, IntBuffer attribs_handle, ByteBuffer shared_context_handle) throws LWJGLException; + + public void swapBuffers() throws LWJGLException { + Context current_context = Context.getCurrentContext(); + if ( current_context == null ) + throw new IllegalStateException("No context is current"); + synchronized ( current_context ) { + PeerInfo current_peer_info = current_context.getPeerInfo(); + ByteBuffer peer_handle = current_peer_info.lockAndGetHandle(); + try { + nSwapBuffers(peer_handle); + } finally { + current_peer_info.unlock(); + } + } + } + + private static native void nSwapBuffers(ByteBuffer peer_info_handle) throws LWJGLException; + + public void releaseDrawable(ByteBuffer context_handle) throws LWJGLException { + } + + public void update(ByteBuffer context_handle) { + } + + public void releaseCurrentContext() throws LWJGLException { + nReleaseCurrentContext(); + } + + private static native void nReleaseCurrentContext() throws LWJGLException; + + public void makeCurrent(PeerInfo peer_info, ByteBuffer handle) throws LWJGLException { + ByteBuffer peer_handle = peer_info.lockAndGetHandle(); + try { + nMakeCurrent(peer_handle, handle); + } finally { + peer_info.unlock(); + } + } + + private static native void nMakeCurrent(ByteBuffer peer_handle, ByteBuffer context_handle) throws LWJGLException; + + public boolean isCurrent(ByteBuffer handle) throws LWJGLException { + boolean result = nIsCurrent(handle); + return result; + } + + private static native boolean nIsCurrent(ByteBuffer context_handle) throws LWJGLException; + + public void setSwapInterval(int value) { + boolean success = nSetSwapInterval(value); + if ( !success ) + LWJGLUtil.log("Failed to set swap interval"); + Util.checkGLError(); + } + + private static native boolean nSetSwapInterval(int value); + + public void destroy(PeerInfo peer_info, ByteBuffer handle) throws LWJGLException { + nDestroy(handle); + } + + private static native void nDestroy(ByteBuffer context_handle) throws LWJGLException; +} diff --git a/src/java/org/lwjgl/opengl/WindowsDisplay.java b/src/java/org/lwjgl/opengl/WindowsDisplay.java new file mode 100644 index 0000000..694cc28 --- /dev/null +++ b/src/java/org/lwjgl/opengl/WindowsDisplay.java @@ -0,0 +1,976 @@ +/* + * 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; + +/** + * This is the Display implementation interface. Display delegates + * to implementors of this interface. There is one DisplayImplementation + * for each supported platform. + * @author elias_naur + */ + +import java.nio.ByteBuffer; +import java.nio.FloatBuffer; +import java.nio.IntBuffer; +import java.awt.Canvas; + +import org.lwjgl.LWJGLException; +import org.lwjgl.LWJGLUtil; +import org.lwjgl.BufferUtils; +import org.lwjgl.input.Cursor; +import org.lwjgl.input.Keyboard; +import org.lwjgl.input.Mouse; + +final class WindowsDisplay implements DisplayImplementation { + private final static int GAMMA_LENGTH = 256; + + private final static int WM_CANCELMODE = 0x001F; + private final static int WM_MOUSEMOVE = 0x0200; + private final static int WM_LBUTTONDOWN = 0x0201; + private final static int WM_LBUTTONUP = 0x0202; + private final static int WM_LBUTTONDBLCLK = 0x0203; + private final static int WM_RBUTTONDOWN = 0x0204; + private final static int WM_RBUTTONUP = 0x0205; + private final static int WM_RBUTTONDBLCLK = 0x0206; + private final static int WM_MBUTTONDOWN = 0x0207; + private final static int WM_MBUTTONUP = 0x0208; + private final static int WM_MBUTTONDBLCLK = 0x0209; + private final static int WM_MOUSEWHEEL = 0x020A; + private final static int WM_CAPTURECHANGED = 0x0215; + private final static int WM_MOUSELEAVE = 0x02A3; + private final static int WM_KEYDOWN = 256; + private final static int WM_KEYUP = 257; + private final static int WM_SYSKEYUP = 261; + private final static int WM_SYSKEYDOWN = 260; + private final static int WM_SYSCHAR = 262; + private final static int WM_CHAR = 258; + private final static int WM_SETICON = 0x0080; + + private final static int WM_QUIT = 0x0012; + private final static int WM_SYSCOMMAND = 0x0112; + private final static int WM_PAINT = 0x000F; + private final static int WM_KILLFOCUS = 8; + private final static int WM_SETFOCUS = 7; + + private final static int SC_SIZE = 0xF000; + private final static int SC_MOVE = 0xF010; + private final static int SC_MINIMIZE = 0xF020; + private final static int SC_MAXIMIZE = 0xF030; + private final static int SC_NEXTWINDOW = 0xF040; + private final static int SC_PREVWINDOW = 0xF050; + private final static int SC_CLOSE = 0xF060; + private final static int SC_VSCROLL = 0xF070; + private final static int SC_HSCROLL = 0xF080; + private final static int SC_MOUSEMENU = 0xF090; + private final static int SC_KEYMENU = 0xF100; + private final static int SC_ARRANGE = 0xF110; + private final static int SC_RESTORE = 0xF120; + private final static int SC_TASKLIST = 0xF130; + private final static int SC_SCREENSAVE = 0xF140; + private final static int SC_HOTKEY = 0xF150; + private final static int SC_DEFAULT = 0xF160; + private final static int SC_MONITORPOWER = 0xF170; + private final static int SC_CONTEXTHELP = 0xF180; + private final static int SC_SEPARATOR = 0xF00F; + + final static int SM_CXCURSOR = 13; + final static int SM_CYCURSOR = 14; + final static int SM_CMOUSEBUTTONS = 43; + final static int SM_MOUSEWHEELPRESENT = 75; + + private final static int SIZE_RESTORED = 0; + private final static int SIZE_MINIMIZED = 1; + private final static int SIZE_MAXIMIZED = 2; + private final static int WM_SIZE = 0x0005; + private final static int WM_ACTIVATE = 0x0006; + private final static int WA_INACTIVE = 0; + private final static int WA_ACTIVE = 1; + private final static int WA_CLICKACTIVE = 2; + private final static int SW_SHOWMINNOACTIVE = 7; + private final static int SW_SHOWDEFAULT = 10; + private final static int SW_RESTORE = 9; + + private final static int ICON_SMALL = 0; + private final static int ICON_BIG = 1; + + private final static IntBuffer rect_buffer = BufferUtils.createIntBuffer(4); + private final static Rect rect = new Rect(); + private final static Rect rect2 = new Rect(); + private static WindowsDisplay current_display; + + private static boolean cursor_clipped; + private WindowsDisplayPeerInfo peer_info; + private Object current_cursor; + private Canvas parent; + private static boolean hasParent = false; + + private WindowsKeyboard keyboard; + private WindowsMouse mouse; + + private boolean close_requested; + private boolean is_dirty; + + private ByteBuffer current_gamma; + private ByteBuffer saved_gamma; + private DisplayMode current_mode; + + private boolean mode_set; + private boolean isMinimized; + private boolean isFocused; + private boolean did_maximize; + private boolean inAppActivate; + + private long hwnd; + private long hdc; + + private long small_icon; + private long large_icon; + + private int captureMouse = -1; + private boolean trackingMouse = false; + private boolean mouseInside = false; + + WindowsDisplay() { + current_display = this; + } + + public void createWindow(DisplayMode mode, Canvas parent, int x, int y) throws LWJGLException { + close_requested = false; + is_dirty = false; + isMinimized = false; + isFocused = false; + did_maximize = false; + this.parent = parent; + hasParent = parent != null; + long parent_hwnd = parent != null ? getHwnd(parent) : 0; + this.hwnd = nCreateWindow(x, y, mode.getWidth(), mode.getHeight(), Display.isFullscreen() || isUndecorated(), parent != null, parent_hwnd); + if (hwnd == 0) { + throw new LWJGLException("Failed to create window"); + } + this.hdc = getDC(hwnd); + if (hdc == 0) { + nDestroyWindow(hwnd); + throw new LWJGLException("Failed to get dc"); + } + try { + int format = WindowsPeerInfo.choosePixelFormat(getHdc(), 0, 0, peer_info.getPixelFormat(), null, true, true, false, true); + WindowsPeerInfo.setPixelFormat(getHdc(), format); + peer_info.initDC(getHwnd(), getHdc()); + showWindow(getHwnd(), SW_SHOWDEFAULT); + if (parent == null) { + setForegroundWindow(getHwnd()); + setFocus(getHwnd()); + } + } catch (LWJGLException e) { + nReleaseDC(hwnd, hdc); + nDestroyWindow(hwnd); + throw e; + } + } + private static native long nCreateWindow(int x, int y, int width, int height, boolean undecorated, boolean child_window, long parent_hwnd) throws LWJGLException; + + private static boolean isUndecorated() { + return Display.getPrivilegedBoolean("org.lwjgl.opengl.Window.undecorated"); + } + + private static long getHwnd(Canvas parent) throws LWJGLException { + AWTCanvasImplementation awt_impl = AWTGLCanvas.createImplementation(); + WindowsPeerInfo parent_peer_info = (WindowsPeerInfo)awt_impl.createPeerInfo(parent, null); + ByteBuffer parent_peer_info_handle = parent_peer_info.lockAndGetHandle(); + try { + return parent_peer_info.getHwnd(); + } finally { + parent_peer_info.unlock(); + } + } + + public void destroyWindow() { + nReleaseDC(hwnd, hdc); + nDestroyWindow(hwnd); + freeLargeIcon(); + freeSmallIcon(); + resetCursorClipping(); + } + private static native void nReleaseDC(long hwnd, long hdc); + private static native void nDestroyWindow(long hwnd); + static void resetCursorClipping() { + if (cursor_clipped) { + try { + clipCursor(null); + } catch (LWJGLException e) { + LWJGLUtil.log("Failed to reset cursor clipping: " + e); + } + cursor_clipped = false; + } + } + + private static void getGlobalClientRect(long hwnd, Rect rect) { + rect_buffer.put(0, 0).put(1, 0); + clientToScreen(hwnd, rect_buffer); + int offset_x = rect_buffer.get(0); + int offset_y = rect_buffer.get(1); + getClientRect(hwnd, rect_buffer); + rect.copyFromBuffer(rect_buffer); + rect.offset(offset_x, offset_y); + } + + static void setupCursorClipping(long hwnd) throws LWJGLException { + cursor_clipped = true; + getGlobalClientRect(hwnd, rect); + rect.copyToBuffer(rect_buffer); + clipCursor(rect_buffer); + } + private static native void clipCursor(IntBuffer rect) throws LWJGLException; + + public void switchDisplayMode(DisplayMode mode) throws LWJGLException { + nSwitchDisplayMode(mode); + current_mode = mode; + mode_set = true; + } + private static native void nSwitchDisplayMode(DisplayMode mode) throws LWJGLException; + + /* + * Called when the application is alt-tabbed to or from + */ + private void appActivate(boolean active) { + if (inAppActivate) { + return; + } + inAppActivate = true; + isFocused = active; + if (active) { + if (Display.isFullscreen()) { + restoreDisplayMode(); + } + if (parent == null) { + showWindow(getHwnd(), SW_RESTORE); + setForegroundWindow(getHwnd()); + setFocus(getHwnd()); + } + did_maximize = true; + if (Display.isFullscreen()) + updateClipping(); + } else if (Display.isFullscreen()) { + showWindow(getHwnd(), SW_SHOWMINNOACTIVE); + resetDisplayMode(); + } else + updateClipping(); + updateCursor(); + inAppActivate = false; + } + private static native void showWindow(long hwnd, int mode); + private static native void setForegroundWindow(long hwnd); + private static native void setFocus(long hwnd); + + private void restoreDisplayMode() { + try { + doSetGammaRamp(current_gamma); + } catch (LWJGLException e) { + LWJGLUtil.log("Failed to restore gamma: " + e.getMessage()); + } + + if (!mode_set) { + mode_set = true; + try { + nSwitchDisplayMode(current_mode); + } catch (LWJGLException e) { + LWJGLUtil.log("Failed to restore display mode: " + e.getMessage()); + } + } + } + + public void resetDisplayMode() { + try { + doSetGammaRamp(saved_gamma); + } catch (LWJGLException e) { + LWJGLUtil.log("Failed to reset gamma ramp: " + e.getMessage()); + } + current_gamma = saved_gamma; + if (mode_set) { + mode_set = false; + nResetDisplayMode(); + } + resetCursorClipping(); + } + private static native void nResetDisplayMode(); + + public int getGammaRampLength() { + return GAMMA_LENGTH; + } + + public void setGammaRamp(FloatBuffer gammaRamp) throws LWJGLException { + doSetGammaRamp(convertToNativeRamp(gammaRamp)); + } + private static native ByteBuffer convertToNativeRamp(FloatBuffer gamma_ramp) throws LWJGLException; + private static native ByteBuffer getCurrentGammaRamp() throws LWJGLException; + + private void doSetGammaRamp(ByteBuffer native_gamma) throws LWJGLException { + nSetGammaRamp(native_gamma); + current_gamma = native_gamma; + } + private static native void nSetGammaRamp(ByteBuffer native_ramp) throws LWJGLException; + + public String getAdapter() { + try { + String maxObjNo = WindowsRegistry.queryRegistrationKey( + WindowsRegistry.HKEY_LOCAL_MACHINE, + "HARDWARE\\DeviceMap\\Video", + "MaxObjectNumber"); + int maxObjectNumber = maxObjNo.charAt(0); + String vga_driver_value = ""; + for(int i=0;i0) { + WindowsFileVersion version = nGetVersion(drivers[0] + ".dll"); + if (version != null) + return version.toString(); + } + } + return null; + } + private native WindowsFileVersion nGetVersion(String driver); + + public DisplayMode init() throws LWJGLException { + current_gamma = saved_gamma = getCurrentGammaRamp(); + return current_mode = getCurrentDisplayMode(); + } + private static native DisplayMode getCurrentDisplayMode() throws LWJGLException; + + public void setTitle(String title) { + nSetTitle(hwnd, title); + } + private static native void nSetTitle(long hwnd, String title); + + public boolean isCloseRequested() { + boolean saved = close_requested; + close_requested = false; + return saved; + } + + public boolean isVisible() { + return !isMinimized; + } + + public boolean isActive() { + return isFocused; + } + + public boolean isDirty() { + boolean saved = is_dirty; + is_dirty = false; + return saved; + } + + public PeerInfo createPeerInfo(PixelFormat pixel_format) throws LWJGLException { + peer_info = new WindowsDisplayPeerInfo(pixel_format); + return peer_info; + } + + public void update() { + nUpdate(); + if (parent != null && parent.isFocusOwner()) { + setFocus(getHwnd()); + } + if (did_maximize) { + did_maximize = false; + /** + * WORKAROUND: + * Making the context current (redundantly) when the window + * is maximized helps some gfx cards recover from fullscreen + */ + try { + if (Display.getDrawable().getContext() != null && Display.getDrawable().getContext().isCurrent()) + Display.getDrawable().getContext().makeCurrent(); + } catch (LWJGLException e) { + LWJGLUtil.log("Exception occurred while trying to make context current: " + e); + } + } + } + private static native void nUpdate(); + + public void reshape(int x, int y, int width, int height) { + nReshape(getHwnd(), x, y, width, height, Display.isFullscreen() || isUndecorated(), parent != null); + } + private static native void nReshape(long hwnd, int x, int y, int width, int height, boolean undecorated, boolean child); + public native DisplayMode[] getAvailableDisplayModes() throws LWJGLException; + + /* Mouse */ + public boolean hasWheel() { + return mouse.hasWheel(); + } + + public int getButtonCount() { + return mouse.getButtonCount(); + } + + public void createMouse() throws LWJGLException { + mouse = new WindowsMouse(getHwnd()); + } + + public void destroyMouse() { + if (mouse != null) + mouse.destroy(); + mouse = null; + } + + public void pollMouse(IntBuffer coord_buffer, ByteBuffer buttons) { + mouse.poll(coord_buffer, buttons); + } + + public void readMouse(ByteBuffer buffer) { + mouse.read(buffer); + } + + public void grabMouse(boolean grab) { + mouse.grab(grab, shouldGrab()); + updateCursor(); + } + + public int getNativeCursorCapabilities() { + return Cursor.CURSOR_ONE_BIT_TRANSPARENCY; + } + + public void setCursorPosition(int x, int y) { + getGlobalClientRect(getHwnd(), rect); + int transformed_x = rect.left + x; + int transformed_y = rect.bottom - 1 - y; + nSetCursorPosition(transformed_x, transformed_y); + setMousePosition(x, y); + } + private static native void nSetCursorPosition(int x, int y); + + public void setNativeCursor(Object handle) throws LWJGLException { + current_cursor = handle; + updateCursor(); + } + + private void updateCursor() { + try { + if (mouse != null && shouldGrab()) + nSetNativeCursor(getHwnd(), mouse.getBlankCursor()); + else + nSetNativeCursor(getHwnd(), current_cursor); + } catch (LWJGLException e) { + LWJGLUtil.log("Failed to update cursor: " + e); + } + } + static native void nSetNativeCursor(long hwnd, Object handle) throws LWJGLException; + + public int getMinCursorSize() { + return getSystemMetrics(SM_CXCURSOR); + } + + public int getMaxCursorSize() { + return getSystemMetrics(SM_CXCURSOR); + } + + static native int getSystemMetrics(int index); + + private static native long getDllInstance(); + + private long getHwnd() { + return hwnd; + } + + private long getHdc() { + return hdc; + } + + private static native long getDC(long hwnd); + private static native long getDesktopWindow(); + private static native long getForegroundWindow(); + + static void centerCursor(long hwnd) { + if (getForegroundWindow() != hwnd && !hasParent) + return; + getGlobalClientRect(hwnd, rect); + int local_offset_x = rect.left; + int local_offset_y = rect.top; + /* -- This is wrong on multi-monitor setups + getGlobalClientRect(getDesktopWindow(), rect2); + Rect.intersect(rect, rect2, rect); + */ + int center_x = (rect.left + rect.right)/2; + int center_y = (rect.top + rect.bottom)/2; + nSetCursorPosition(center_x, center_y); + int local_x = center_x - local_offset_x; + int local_y = center_y - local_offset_y; + if (current_display != null) + current_display.setMousePosition(local_x, transformY(hwnd, local_y)); + } + + private void setMousePosition(int x, int y) { + if (mouse != null) + mouse.setPosition(x, y); + } + + /* Keyboard */ + public void createKeyboard() throws LWJGLException { + keyboard = new WindowsKeyboard(getHwnd()); + } + + public void destroyKeyboard() { + keyboard.destroy(); + keyboard = null; + } + + public void pollKeyboard(ByteBuffer keyDownBuffer) { + keyboard.poll(keyDownBuffer); + } + + public void readKeyboard(ByteBuffer buffer) { + keyboard.read(buffer); + } + +// public native int isStateKeySet(int key); + + public static native ByteBuffer nCreateCursor(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, int images_offset, IntBuffer delays, int delays_offset) throws LWJGLException; + + public Object createCursor(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, IntBuffer delays) throws LWJGLException { + return doCreateCursor(width, height, xHotspot, yHotspot, numImages, images, delays); + } + + static Object doCreateCursor(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, IntBuffer delays) throws LWJGLException { + return nCreateCursor(width, height, xHotspot, yHotspot, numImages, images, images.position(), delays, delays != null ? delays.position() : -1); + } + + public void destroyCursor(Object cursorHandle) { + doDestroyCursor(cursorHandle); + } + static native void doDestroyCursor(Object cursorHandle); + + public int getPbufferCapabilities() { + try { + // Return the capabilities of a minimum pixel format + return nGetPbufferCapabilities(new PixelFormat(0, 0, 0, 0, 0, 0, 0, 0, false)); + } catch (LWJGLException e) { + LWJGLUtil.log("Exception occurred while determining pbuffer capabilities: " + e); + return 0; + } + } + private native int nGetPbufferCapabilities(PixelFormat format) throws LWJGLException; + + public boolean isBufferLost(PeerInfo handle) { + return ((WindowsPbufferPeerInfo)handle).isBufferLost(); + } + + public PeerInfo createPbuffer(int width, int height, PixelFormat pixel_format, + IntBuffer pixelFormatCaps, + IntBuffer pBufferAttribs) throws LWJGLException { + return new WindowsPbufferPeerInfo(width, height, pixel_format, pixelFormatCaps, pBufferAttribs); + } + + public void setPbufferAttrib(PeerInfo handle, int attrib, int value) { + ((WindowsPbufferPeerInfo)handle).setPbufferAttrib(attrib, value); + } + + public void bindTexImageToPbuffer(PeerInfo handle, int buffer) { + ((WindowsPbufferPeerInfo)handle).bindTexImageToPbuffer(buffer); + } + + public void releaseTexImageFromPbuffer(PeerInfo handle, int buffer) { + ((WindowsPbufferPeerInfo)handle).releaseTexImageFromPbuffer(buffer); + } + + private void freeSmallIcon() { + if (small_icon != 0) { + destroyIcon(small_icon); + small_icon = 0; + } + } + + private void freeLargeIcon() { + if (large_icon != 0) { + destroyIcon(large_icon); + large_icon = 0; + } + } + + /** + * Sets one or more icons for the Display. + *

      + *
    • On Windows you should supply at least one 16x16 icon and one 32x32.
    • + *
    • Linux (and similar platforms) expect one 32x32 icon.
    • + *
    • Mac OS X should be supplied one 128x128 icon
    • + *
    + * The implementation will use the supplied ByteBuffers with image data in RGBA and perform any conversions nescesarry for the specific platform. + * + * @param icons Array of icons in RGBA mode + * @return number of icons used. + */ + public int setIcon(ByteBuffer[] icons) { + boolean done_small = false; + boolean done_large = false; + int used = 0; + + int small_icon_size = 16; + int large_icon_size = 32; + for (int i=0;i>> 30) & 0x1); + byte state = (byte)(1 - ((lParam >>> 31) & 0x1)); + boolean repeat = state == previous_state; + if (keyboard != null) + keyboard.handleChar((int)(wParam & 0xFF), millis, repeat); + } + + private void handleKeyButton(long wParam, long lParam, long millis) { + byte previous_state = (byte)((lParam >>> 30) & 0x1); + byte state = (byte)(1 - ((lParam >>> 31) & 0x1)); + boolean repeat = state == previous_state; // Repeat message + byte extended = (byte)((lParam >>> 24) & 0x1); + int scan_code = (int)((lParam >>> 16) & 0xFF); + if (keyboard != null) { + keyboard.handleKey((int)wParam, scan_code, extended != 0, state, millis, repeat); + + if(captureMouse != -1 && keyboard.isKeyDown(Keyboard.KEY_ESCAPE)) { + nReleaseCapture(); + captureMouse = -1; + } + } + } + + private static int transformY(long hwnd, int y) { + getClientRect(hwnd, rect_buffer); + rect.copyFromBuffer(rect_buffer); + return (rect.bottom - rect.top) - 1 - y; + } + + private static native void clientToScreen(long hwnd, IntBuffer point); + + private static int handleMessage(long hwnd, int msg, long wParam, long lParam, long millis) { + if (current_display != null) + return current_display.doHandleMessage(hwnd, msg, wParam, lParam, millis); + else + return defWindowProc(hwnd, msg, wParam, lParam); + } + + private static native int defWindowProc(long hwnd, int msg, long wParam, long lParam); + + private void checkCursorState() { + updateClipping(); + } + + private void updateClipping() { + if ((Display.isFullscreen() || (mouse != null && mouse.isGrabbed())) && !isMinimized && isFocused && (getForegroundWindow() == getHwnd() || hasParent)) { + try { + setupCursorClipping(getHwnd()); + } catch (LWJGLException e) { + LWJGLUtil.log("setupCursorClipping failed: " + e.getMessage()); + } + } else { + resetCursorClipping(); + } + } + + private void setMinimized(boolean m) { + isMinimized = m; + checkCursorState(); + } + + private int doHandleMessage(long hwnd, int msg, long wParam, long lParam, long millis) { + switch (msg) { + // disable screen saver and monitor power down messages which wreak havoc + case WM_ACTIVATE: + switch ((int)wParam) { + case WA_ACTIVE: + case WA_CLICKACTIVE: + appActivate(true); + break; + case WA_INACTIVE: + appActivate(false); + break; + } + return 0; + case WM_SIZE: + switch ((int)wParam) { + case SIZE_RESTORED: + case SIZE_MAXIMIZED: + setMinimized(false); + break; + case SIZE_MINIMIZED: + setMinimized(true); + break; + } + return defWindowProc(hwnd, msg, wParam, lParam); + case WM_KILLFOCUS: + appActivate(false); + return 0; + case WM_SETFOCUS: + appActivate(true); + return 0; + case WM_MOUSEMOVE: + int xPos = (int)(short)(lParam & 0xFFFF); + int yPos = transformY(getHwnd(), (int)(short)((lParam >> 16) & 0xFFFF)); + handleMouseMoved(xPos, yPos, millis); + checkCursorState(); + mouseInside = true; + if(!trackingMouse) { + trackingMouse = nTrackMouseEvent(hwnd); + } + return 0; + case WM_MOUSEWHEEL: + int dwheel = (int)(short)((wParam >> 16) & 0xFFFF); + handleMouseScrolled(dwheel, millis); + return 0; + case WM_LBUTTONDOWN: + handleMouseButton(0, 1, millis); + return 0; + case WM_LBUTTONUP: + handleMouseButton(0, 0, millis); + return 0; + case WM_RBUTTONDOWN: + handleMouseButton(1, 1, millis); + return 0; + case WM_RBUTTONUP: + handleMouseButton(1, 0, millis); + return 0; + case WM_MBUTTONDOWN: + handleMouseButton(2, 1, millis); + return 0; + case WM_MBUTTONUP: + handleMouseButton(2, 0, millis); + return 0; + case WM_SYSCHAR: + case WM_CHAR: + handleChar(wParam, lParam, millis); + return 0; + case WM_SYSKEYUP: + /* Fall through */ + case WM_KEYUP: + // SysRq apparently only generates WM_KEYUP, so we'll fake a WM_KEYDOWN + if (wParam == WindowsKeycodes.VK_SNAPSHOT && keyboard != null && + !keyboard.isKeyDown(org.lwjgl.input.Keyboard.KEY_SYSRQ)) { + // Set key state to pressed + long fake_lparam = lParam & ~(1 << 31); + // Set key previous state to released + fake_lparam = fake_lparam & ~(1 << 30); + handleKeyButton(wParam, fake_lparam, millis); + } + /* Fall through */ + case WM_SYSKEYDOWN: + /* Fall through */ + case WM_KEYDOWN: + handleKeyButton(wParam, lParam, millis); + return defWindowProc(hwnd, msg, wParam, lParam); + case WM_QUIT: + close_requested = true; + return 0; + case WM_SYSCOMMAND: + switch ((int)(wParam & 0xfff0)) { + case SC_KEYMENU: + case SC_MOUSEMENU: + case SC_SCREENSAVE: + case SC_MONITORPOWER: + return 0; + case SC_CLOSE: + close_requested = true; + return 0; + default: + break; + } + return defWindowProc(hwnd, msg, wParam, lParam); + case WM_PAINT: + is_dirty = true; + return defWindowProc(hwnd, msg, wParam, lParam); + case WM_MOUSELEAVE: + mouseInside = false; + trackingMouse = false; + return defWindowProc(hwnd, msg, wParam, lParam); + case WM_CANCELMODE: + nReleaseCapture(); + /* fall through */ + case WM_CAPTURECHANGED: + if(captureMouse != -1) { + handleMouseButton(captureMouse, 0, millis); + captureMouse = -1; + } + return 0; + default: + return defWindowProc(hwnd, msg, wParam, lParam); + } + } + + public int getWidth() { + return Display.getDisplayMode().getWidth(); + } + + public int getHeight() { + return Display.getDisplayMode().getHeight(); + } + + private int firstMouseButtonDown() { + for(int i=0; i + * @version $Revision: 3116 $ + * $Id: WindowsDisplayPeerInfo.java 3116 2008-08-19 16:46:03Z spasi $ + */ +final class WindowsDisplayPeerInfo extends WindowsPeerInfo { + private final PixelFormat pixel_format; + + WindowsDisplayPeerInfo(PixelFormat pixel_format) throws LWJGLException { + this.pixel_format = pixel_format; + GLContext.loadOpenGLLibrary(); + } + + PixelFormat getPixelFormat() { + return pixel_format; + } + + void initDC(long hwnd, long hdc) throws LWJGLException { + nInitDC(getHandle(), hwnd, hdc); + } + private static native void nInitDC(ByteBuffer peer_info_handle, long hwnd, long hdc); + + protected void doLockAndInitHandle() throws LWJGLException { + // NO-OP + } + + protected void doUnlock() throws LWJGLException { + // NO-OP + } + + public void destroy() { + super.destroy(); + GLContext.unloadOpenGLLibrary(); + } +} diff --git a/src/java/org/lwjgl/opengl/WindowsFileVersion.java b/src/java/org/lwjgl/opengl/WindowsFileVersion.java new file mode 100644 index 0000000..8ed5cc4 --- /dev/null +++ b/src/java/org/lwjgl/opengl/WindowsFileVersion.java @@ -0,0 +1,54 @@ +/* + * 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; + +/** + * @author elias_naur + */ + +final class WindowsFileVersion { + private final int product_version_ms; + private final int product_version_ls; + + WindowsFileVersion(int product_version_ms, int product_version_ls) { + this.product_version_ms = product_version_ms; + this.product_version_ls = product_version_ls; + } + + public String toString() { + int f1 = (product_version_ms >> 16) & 0xFFFF; + int f2 = product_version_ms & 0xFFFF; + int f3 = (product_version_ls >> 16) & 0xFFFF; + int f4 = product_version_ls & 0xFFFF; + return f1 + "." + f2 + "." + f3 + "." + f4; + } +} diff --git a/src/java/org/lwjgl/opengl/WindowsKeyboard.java b/src/java/org/lwjgl/opengl/WindowsKeyboard.java new file mode 100644 index 0000000..6820f91 --- /dev/null +++ b/src/java/org/lwjgl/opengl/WindowsKeyboard.java @@ -0,0 +1,180 @@ +/* + * 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; + +/** + * This is the Windows implementation of the Keyboard. + * @author elias_naur + */ + +import java.nio.ByteBuffer; +import java.nio.CharBuffer; + +import org.lwjgl.BufferUtils; +import org.lwjgl.LWJGLException; +import org.lwjgl.input.Keyboard; + +final class WindowsKeyboard { + private final static int MAPVK_VK_TO_VSC = 0; + + private final static int BUFFER_SIZE = 50; + + private final long hwnd; + private final ByteBuffer keyboard_state; + private final byte[] key_down_buffer = new byte[Keyboard.KEYBOARD_SIZE]; + private final EventQueue event_queue = new EventQueue(Keyboard.EVENT_SIZE); + private final ByteBuffer tmp_event = ByteBuffer.allocate(Keyboard.EVENT_SIZE); + + private boolean grabbed; + + private boolean has_retained_event; // Indicates if we're waiting for a WM_CHAR + private int retained_key_code; + private byte retained_state; + private int retained_char; + private long retained_millis; + private boolean retained_repeat; + + WindowsKeyboard(long hwnd) throws LWJGLException { + this.hwnd = hwnd; + keyboard_state = BufferUtils.createByteBuffer(256); + } + private static native boolean isWindowsNT(); + + public void destroy() { + } + + boolean isKeyDown(int lwjgl_keycode) { + return key_down_buffer[lwjgl_keycode] == 1; + } + + public void grab(boolean grab) { + if(grab) { + if (!grabbed) { + grabbed = true; + } + } else { + if (grabbed) { + grabbed = false; + } + } + } + + public void poll(ByteBuffer keyDownBuffer) { + int old_position = keyDownBuffer.position(); + keyDownBuffer.put(key_down_buffer); + keyDownBuffer.position(old_position); + } + + private static native int MapVirtualKey(int uCode, int uMapType); + private static native int ToUnicode(int wVirtKey, int wScanCode, ByteBuffer lpKeyState, CharBuffer pwszBuff, int cchBuff, int flags); + private static native int ToAscii(int wVirtKey, int wScanCode, ByteBuffer lpKeyState, ByteBuffer lpChar, int flags); + private static native int GetKeyboardState(ByteBuffer lpKeyState); + private static native int GetKeyState(int virt_key); + + private void putEvent(int keycode, byte state, int ch, long millis, boolean repeat) { + tmp_event.clear(); + tmp_event.putInt(keycode).put(state).putInt(ch).putLong(millis*1000000).put(repeat ? (byte)1 : (byte)0); + tmp_event.flip(); + event_queue.putEvent(tmp_event); + } + + private boolean checkShiftKey(int virt_key, byte state) { + int key_state = (GetKeyState(virt_key) >>> 15) & 0x1; + int lwjgl_code = WindowsKeycodes.mapVirtualKeyToLWJGLCode(virt_key); + return (key_down_buffer[lwjgl_code] == 1 - state) && (key_state == state); + } + + private int translateShift(int scan_code, byte state) { + if (checkShiftKey(WindowsKeycodes.VK_LSHIFT, state)) { + return WindowsKeycodes.VK_LSHIFT; + } else if (checkShiftKey(WindowsKeycodes.VK_RSHIFT, state)) { + return WindowsKeycodes.VK_RSHIFT; + } else { + if (scan_code== 0x2A) + return WindowsKeycodes.VK_LSHIFT; + else { + if (scan_code == 0x36) + return WindowsKeycodes.VK_RSHIFT; + else + return WindowsKeycodes.VK_LSHIFT; + } + } + } + + private int translateExtended(int virt_key, int scan_code, byte state, boolean extended) { + switch (virt_key) { + case WindowsKeycodes.VK_SHIFT: + return translateShift(scan_code, state); + case WindowsKeycodes.VK_CONTROL: + return extended ? WindowsKeycodes.VK_RCONTROL : WindowsKeycodes.VK_LCONTROL; + case WindowsKeycodes.VK_MENU: + return extended ? WindowsKeycodes.VK_RMENU : WindowsKeycodes.VK_LMENU; + default: + return virt_key; + } + } + + private void flushRetained() { + if (has_retained_event) { + has_retained_event = false; + putEvent(retained_key_code, retained_state, retained_char, retained_millis, retained_repeat); + } + } + + public void handleKey(int virt_key, int scan_code, boolean extended, byte event_state, long millis, boolean repeat) { + virt_key = translateExtended(virt_key, scan_code, event_state, extended); + flushRetained(); + has_retained_event = true; + int keycode = WindowsKeycodes.mapVirtualKeyToLWJGLCode(virt_key); + if (keycode < key_down_buffer.length) + key_down_buffer[keycode] = event_state; + retained_key_code = keycode; + retained_state = event_state; + retained_millis = millis; + retained_char = 0; + retained_repeat = repeat; + } + + public void handleChar(int event_char, long millis, boolean repeat) { + if (has_retained_event && retained_char != 0) + flushRetained(); + if (!has_retained_event) { + putEvent(0, (byte)0, event_char, millis, repeat); + } else + retained_char = event_char; + } + + public void read(ByteBuffer buffer) { + flushRetained(); + event_queue.copyEvents(buffer); + } +} diff --git a/src/java/org/lwjgl/opengl/WindowsKeycodes.java b/src/java/org/lwjgl/opengl/WindowsKeycodes.java new file mode 100644 index 0000000..fb4f057 --- /dev/null +++ b/src/java/org/lwjgl/opengl/WindowsKeycodes.java @@ -0,0 +1,578 @@ +/* + * 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; + +/** + * @author elias_naur + */ + +import org.lwjgl.input.Keyboard; + +final class WindowsKeycodes { + public final static int VK_LBUTTON = 0x01; + public final static int VK_RBUTTON = 0x02; + public final static int VK_CANCEL = 0x03; + public final static int VK_MBUTTON = 0x04; /* NOT contiguous with L & RBUTTON */ + + public final static int VK_XBUTTON1 = 0x05; /* NOT contiguous with L & RBUTTON */ + public final static int VK_XBUTTON2 = 0x06; /* NOT contiguous with L & RBUTTON */ + +/* + * 0x07 : unassigned + */ + + public final static int VK_BACK = 0x08; + public final static int VK_TAB = 0x09; + +/* + * 0x0A - 0x0B : reserved + */ + + public final static int VK_CLEAR = 0x0C; + public final static int VK_RETURN = 0x0D; + + public final static int VK_SHIFT = 0x10; + public final static int VK_CONTROL = 0x11; + public final static int VK_MENU = 0x12; + public final static int VK_PAUSE = 0x13; + public final static int VK_CAPITAL = 0x14; + + public final static int VK_KANA = 0x15; + public final static int VK_HANGEUL = 0x15; /* old name - should be here for compatibility */ + public final static int VK_HANGUL = 0x15; + public final static int VK_JUNJA = 0x17; + public final static int VK_FINAL = 0x18; + public final static int VK_HANJA = 0x19; + public final static int VK_KANJI = 0x19; + + public final static int VK_ESCAPE = 0x1B; + + public final static int VK_CONVERT = 0x1C; + public final static int VK_NONCONVERT = 0x1D; + public final static int VK_ACCEPT = 0x1E; + public final static int VK_MODECHANGE = 0x1F; + + public final static int VK_SPACE = 0x20; + public final static int VK_PRIOR = 0x21; + public final static int VK_NEXT = 0x22; + public final static int VK_END = 0x23; + public final static int VK_HOME = 0x24; + public final static int VK_LEFT = 0x25; + public final static int VK_UP = 0x26; + public final static int VK_RIGHT = 0x27; + public final static int VK_DOWN = 0x28; + public final static int VK_SELECT = 0x29; + public final static int VK_PRINT = 0x2A; + public final static int VK_EXECUTE = 0x2B; + public final static int VK_SNAPSHOT = 0x2C; + public final static int VK_INSERT = 0x2D; + public final static int VK_DELETE = 0x2E; + public final static int VK_HELP = 0x2F; +/* + * VK_0 - VK_9 are the same as ASCII '0' - '9' (0x30 - 0x39) + * 0x40 : unassigned + * VK_A - VK_Z are the same as ASCII 'A' - 'Z' (0x41 - 0x5A) + */ + public final static int VK_0 = 0x30; + public final static int VK_1 = 0x31; + public final static int VK_2 = 0x32; + public final static int VK_3 = 0x33; + public final static int VK_4 = 0x34; + public final static int VK_5 = 0x35; + public final static int VK_6 = 0x36; + public final static int VK_7 = 0x37; + public final static int VK_8 = 0x38; + public final static int VK_9 = 0x39; + + public final static int VK_A = 0x41; + public final static int VK_B = 0x42; + public final static int VK_C = 0x43; + public final static int VK_D = 0x44; + public final static int VK_E = 0x45; + public final static int VK_F = 0x46; + public final static int VK_G = 0x47; + public final static int VK_H = 0x48; + public final static int VK_I = 0x49; + public final static int VK_J = 0x4A; + public final static int VK_K = 0x4B; + public final static int VK_L = 0x4C; + public final static int VK_M = 0x4D; + public final static int VK_N = 0x4E; + public final static int VK_O = 0x4F; + public final static int VK_P = 0x50; + public final static int VK_Q = 0x51; + public final static int VK_R = 0x52; + public final static int VK_S = 0x53; + public final static int VK_T = 0x54; + public final static int VK_U = 0x55; + public final static int VK_V = 0x56; + public final static int VK_W = 0x57; + public final static int VK_X = 0x58; + public final static int VK_Y = 0x59; + public final static int VK_Z = 0x5A; + + public final static int VK_LWIN = 0x5B; + public final static int VK_RWIN = 0x5C; + public final static int VK_APPS = 0x5D; +/* + * 0x5E : reserved; + */ + + public final static int VK_SLEEP = 0x5F; + + public final static int VK_NUMPAD0 = 0x60; + public final static int VK_NUMPAD1 = 0x61; + public final static int VK_NUMPAD2 = 0x62; + public final static int VK_NUMPAD3 = 0x63; + public final static int VK_NUMPAD4 = 0x64; + public final static int VK_NUMPAD5 = 0x65; + public final static int VK_NUMPAD6 = 0x66; + public final static int VK_NUMPAD7 = 0x67; + public final static int VK_NUMPAD8 = 0x68; + public final static int VK_NUMPAD9 = 0x69; + public final static int VK_MULTIPLY = 0x6A; + public final static int VK_ADD = 0x6B; + public final static int VK_SEPARATOR = 0x6C; + public final static int VK_SUBTRACT = 0x6D; + public final static int VK_DECIMAL = 0x6E; + public final static int VK_DIVIDE = 0x6F; + public final static int VK_F1 = 0x70; + public final static int VK_F2 = 0x71; + public final static int VK_F3 = 0x72; + public final static int VK_F4 = 0x73; + public final static int VK_F5 = 0x74; + public final static int VK_F6 = 0x75; + public final static int VK_F7 = 0x76; + public final static int VK_F8 = 0x77; + public final static int VK_F9 = 0x78; + public final static int VK_F10 = 0x79; + public final static int VK_F11 = 0x7A; + public final static int VK_F12 = 0x7B; + public final static int VK_F13 = 0x7C; + public final static int VK_F14 = 0x7D; + public final static int VK_F15 = 0x7E; + public final static int VK_F16 = 0x7F; + public final static int VK_F17 = 0x80; + public final static int VK_F18 = 0x81; + public final static int VK_F19 = 0x82; + public final static int VK_F20 = 0x83; + public final static int VK_F21 = 0x84; + public final static int VK_F22 = 0x85; + public final static int VK_F23 = 0x86; + public final static int VK_F24 = 0x87; + +/* + * 0x88 - 0x8F : unassigned; + */ + + public final static int VK_NUMLOCK = 0x90; + public final static int VK_SCROLL = 0x91; + +/* + * NEC PC-9800 kbd definitions + */ + public final static int VK_OEM_NEC_EQUAL = 0x92; // '=' key on numpad +/* + * Fujitsu/OASYS kbd definitions + */ + public final static int VK_OEM_FJ_JISHO = 0x92; // 'Dictionary' key + public final static int VK_OEM_FJ_MASSHOU = 0x93; // 'Unregister word' key + public final static int VK_OEM_FJ_TOUROKU = 0x94; // 'Register word' key + public final static int VK_OEM_FJ_LOYA = 0x95; // 'Left OYAYUBI' key + public final static int VK_OEM_FJ_ROYA = 0x96; // 'Right OYAYUBI' key + +/* + * 0x97 - 0x9F : unassigned + */ + +/* + * VK_L* & VK_R* - left and right Alt, Ctrl and Shift virtual keys. + * Used only as parameters to GetAsyncKeyState() and GetKeyState(). + * No other API or message will distinguish left and right keys in this way. + */ + public final static int VK_LSHIFT = 0xA0; + public final static int VK_RSHIFT = 0xA1; + public final static int VK_LCONTROL = 0xA2; + public final static int VK_RCONTROL = 0xA3; + public final static int VK_LMENU = 0xA4; + public final static int VK_RMENU = 0xA5; + + public final static int VK_BROWSER_BACK = 0xA6; + public final static int VK_BROWSER_FORWARD = 0xA7; + public final static int VK_BROWSER_REFRESH = 0xA8; + public final static int VK_BROWSER_STOP = 0xA9; + public final static int VK_BROWSER_SEARCH = 0xAA; + public final static int VK_BROWSER_FAVORITES = 0xAB; + public final static int VK_BROWSER_HOME = 0xAC; + + public final static int VK_VOLUME_MUTE = 0xAD; + public final static int VK_VOLUME_DOWN = 0xAE; + public final static int VK_VOLUME_UP = 0xAF; + public final static int VK_MEDIA_NEXT_TRACK = 0xB0; + public final static int VK_MEDIA_PREV_TRACK = 0xB1; + public final static int VK_MEDIA_STOP = 0xB2; + public final static int VK_MEDIA_PLAY_PAUSE = 0xB3; + public final static int VK_LAUNCH_MAIL = 0xB4; + public final static int VK_LAUNCH_MEDIA_SELECT = 0xB5; + public final static int VK_LAUNCH_APP1 = 0xB6; + public final static int VK_LAUNCH_APP2 = 0xB7; + +/* + * 0xB8 - 0xB9 : reserved + */ + + public final static int VK_OEM_1 = 0xBA; // ';:' for US + public final static int VK_OEM_PLUS = 0xBB; // '+' any country + public final static int VK_OEM_COMMA = 0xBC; // ',' any country + public final static int VK_OEM_MINUS = 0xBD; // '-' any country + public final static int VK_OEM_PERIOD = 0xBE; // '.' any country + public final static int VK_OEM_2 = 0xBF; // '/?' for US + public final static int VK_OEM_3 = 0xC0; // '`~' for US + +/* + * 0xC1 - 0xD7 : reserved + */ + +/* + * 0xD8 - 0xDA : unassigned + */ + + public final static int VK_OEM_4 = 0xDB; // '[{' for US + public final static int VK_OEM_5 = 0xDC; // '\|' for US + public final static int VK_OEM_6 = 0xDD; // ']}' for US + public final static int VK_OEM_7 = 0xDE; // ''"' for US + public final static int VK_OEM_8 = 0xDF; + +/* + * 0xE0 : reserved + */ + +/* + * Various extended or enhanced keyboards + */ + public final static int VK_OEM_AX = 0xE1; // 'AX' key on Japanese AX kbd + public final static int VK_OEM_102 = 0xE2; // "<>" or "\|" on RT 102-key kbd. + public final static int VK_ICO_HELP = 0xE3; // Help key on ICO + public final static int VK_ICO_00 = 0xE4; // 00 key on ICO + + public final static int VK_PROCESSKEY = 0xE5; + + public final static int VK_ICO_CLEAR = 0xE6; + + + public final static int VK_PACKET = 0xE7; + +/* + * 0xE8 : unassigned + */ + +/* + * Nokia/Ericsson definitions + */ + public final static int VK_OEM_RESET = 0xE9; + public final static int VK_OEM_JUMP = 0xEA; + public final static int VK_OEM_PA1 = 0xEB; + public final static int VK_OEM_PA2 = 0xEC; + public final static int VK_OEM_PA3 = 0xED; + public final static int VK_OEM_WSCTRL = 0xEE; + public final static int VK_OEM_CUSEL = 0xEF; + public final static int VK_OEM_ATTN = 0xF0; + public final static int VK_OEM_FINISH = 0xF1; + public final static int VK_OEM_COPY = 0xF2; + public final static int VK_OEM_AUTO = 0xF3; + public final static int VK_OEM_ENLW = 0xF4; + public final static int VK_OEM_BACKTAB = 0xF5; + + public final static int VK_ATTN = 0xF6; + public final static int VK_CRSEL = 0xF7; + public final static int VK_EXSEL = 0xF8; + public final static int VK_EREOF = 0xF9; + public final static int VK_PLAY = 0xFA; + public final static int VK_ZOOM = 0xFB; + public final static int VK_NONAME = 0xFC; + public final static int VK_PA1 = 0xFD; + public final static int VK_OEM_CLEAR = 0xFE; + + public static int mapVirtualKeyToLWJGLCode(int virt_key) { + switch (virt_key) { + case VK_ESCAPE: + return Keyboard.KEY_ESCAPE; + case VK_1: + return Keyboard.KEY_1; + case VK_2: + return Keyboard.KEY_2; + case VK_3: + return Keyboard.KEY_3; + case VK_4: + return Keyboard.KEY_4; + case VK_5: + return Keyboard.KEY_5; + case VK_6: + return Keyboard.KEY_6; + case VK_7: + return Keyboard.KEY_7; + case VK_8: + return Keyboard.KEY_8; + case VK_9: + return Keyboard.KEY_9; + case VK_0: + return Keyboard.KEY_0; + case VK_OEM_MINUS: + return Keyboard.KEY_MINUS; + case VK_OEM_PLUS: + return Keyboard.KEY_EQUALS; + case VK_BACK: + return Keyboard.KEY_BACK; + case VK_TAB: + return Keyboard.KEY_TAB; + case VK_Q: + return Keyboard.KEY_Q; + case VK_W: + return Keyboard.KEY_W; + case VK_E: + return Keyboard.KEY_E; + case VK_R: + return Keyboard.KEY_R; + case VK_T: + return Keyboard.KEY_T; + case VK_Y: + return Keyboard.KEY_Y; + case VK_U: + return Keyboard.KEY_U; + case VK_I: + return Keyboard.KEY_I; + case VK_O: + return Keyboard.KEY_O; + case VK_P: + return Keyboard.KEY_P; + case VK_OEM_4: + return Keyboard.KEY_LBRACKET; + case VK_OEM_6: + return Keyboard.KEY_RBRACKET; + case VK_RETURN: + return Keyboard.KEY_RETURN; + case VK_LCONTROL: + return Keyboard.KEY_LCONTROL; + case VK_A: + return Keyboard.KEY_A; + case VK_S: + return Keyboard.KEY_S; + case VK_D: + return Keyboard.KEY_D; + case VK_F: + return Keyboard.KEY_F; + case VK_G: + return Keyboard.KEY_G; + case VK_H: + return Keyboard.KEY_H; + case VK_J: + return Keyboard.KEY_J; + case VK_K: + return Keyboard.KEY_K; + case VK_L: + return Keyboard.KEY_L; + case VK_OEM_1: + return Keyboard.KEY_SEMICOLON; + case VK_OEM_7: + return Keyboard.KEY_APOSTROPHE; + case VK_OEM_3: + case VK_OEM_8: + return Keyboard.KEY_GRAVE; + case VK_LSHIFT: + return Keyboard.KEY_LSHIFT; + case VK_OEM_5: + return Keyboard.KEY_BACKSLASH; + case VK_Z: + return Keyboard.KEY_Z; + case VK_X: + return Keyboard.KEY_X; + case VK_C: + return Keyboard.KEY_C; + case VK_V: + return Keyboard.KEY_V; + case VK_B: + return Keyboard.KEY_B; + case VK_N: + return Keyboard.KEY_N; + case VK_M: + return Keyboard.KEY_M; + case VK_OEM_COMMA: + return Keyboard.KEY_COMMA; + case VK_OEM_PERIOD: + return Keyboard.KEY_PERIOD; + case VK_OEM_2: + return Keyboard.KEY_SLASH; + case VK_RSHIFT: + return Keyboard.KEY_RSHIFT; + case VK_MULTIPLY: + return Keyboard.KEY_MULTIPLY; + case VK_LMENU: + return Keyboard.KEY_LMENU; + case VK_SPACE: + return Keyboard.KEY_SPACE; + case VK_CAPITAL: + return Keyboard.KEY_CAPITAL; + case VK_F1: + return Keyboard.KEY_F1; + case VK_F2: + return Keyboard.KEY_F2; + case VK_F3: + return Keyboard.KEY_F3; + case VK_F4: + return Keyboard.KEY_F4; + case VK_F5: + return Keyboard.KEY_F5; + case VK_F6: + return Keyboard.KEY_F6; + case VK_F7: + return Keyboard.KEY_F7; + case VK_F8: + return Keyboard.KEY_F8; + case VK_F9: + return Keyboard.KEY_F9; + case VK_F10: + return Keyboard.KEY_F10; + case VK_NUMLOCK: + return Keyboard.KEY_NUMLOCK; + case VK_SCROLL: + return Keyboard.KEY_SCROLL; + case VK_NUMPAD7: + return Keyboard.KEY_NUMPAD7; + case VK_NUMPAD8: + return Keyboard.KEY_NUMPAD8; + case VK_NUMPAD9: + return Keyboard.KEY_NUMPAD9; + case VK_SUBTRACT: + return Keyboard.KEY_SUBTRACT; + case VK_NUMPAD4: + return Keyboard.KEY_NUMPAD4; + case VK_NUMPAD5: + return Keyboard.KEY_NUMPAD5; + case VK_NUMPAD6: + return Keyboard.KEY_NUMPAD6; + case VK_ADD: + return Keyboard.KEY_ADD; + case VK_NUMPAD1: + return Keyboard.KEY_NUMPAD1; + case VK_NUMPAD2: + return Keyboard.KEY_NUMPAD2; + case VK_NUMPAD3: + return Keyboard.KEY_NUMPAD3; + case VK_NUMPAD0: + return Keyboard.KEY_NUMPAD0; + case VK_DECIMAL: + return Keyboard.KEY_DECIMAL; + case VK_F11: + return Keyboard.KEY_F11; + case VK_F12: + return Keyboard.KEY_F12; + case VK_F13: + return Keyboard.KEY_F13; + case VK_F14: + return Keyboard.KEY_F14; + case VK_F15: + return Keyboard.KEY_F15; + case VK_KANA: + return Keyboard.KEY_KANA; + case VK_CONVERT: + return Keyboard.KEY_CONVERT; + case VK_NONCONVERT: + return Keyboard.KEY_NOCONVERT; +/* case VK_YEN: + return Keyboard.KEY_YEN; + case VK_NUMPADEQUALS: + return Keyboard.KEY_NUMPADEQUALS; + case VK_CIRCUMFLEX: + return Keyboard.KEY_CIRCUMFLEX; + case VK_AT: + return Keyboard.KEY_AT; + case VK_COLON: + return Keyboard.KEY_COLON; + case VK_UNDERLINE: + return Keyboard.KEY_UNDERLINE;*/ + case VK_KANJI: + return Keyboard.KEY_KANJI; +/* case VK_STOP: + return Keyboard.KEY_STOP; + case VK_AX: + return Keyboard.KEY_AX; + case VK_UNLABELED: + return Keyboard.KEY_UNLABELED; + case VK_NUMPADENTER: + return Keyboard.KEY_NUMPADENTER;*/ + case VK_RCONTROL: + return Keyboard.KEY_RCONTROL; + case VK_SEPARATOR: + return Keyboard.KEY_NUMPADCOMMA; + case VK_DIVIDE: + return Keyboard.KEY_DIVIDE; + case VK_SNAPSHOT: + return Keyboard.KEY_SYSRQ; + case VK_RMENU: + return Keyboard.KEY_RMENU; + case VK_PAUSE: + return Keyboard.KEY_PAUSE; + case VK_HOME: + return Keyboard.KEY_HOME; + case VK_UP: + return Keyboard.KEY_UP; + case VK_PRIOR: + return Keyboard.KEY_PRIOR; + case VK_LEFT: + return Keyboard.KEY_LEFT; + case VK_RIGHT: + return Keyboard.KEY_RIGHT; + case VK_END: + return Keyboard.KEY_END; + case VK_DOWN: + return Keyboard.KEY_DOWN; + case VK_NEXT: + return Keyboard.KEY_NEXT; + case VK_INSERT: + return Keyboard.KEY_INSERT; + case VK_DELETE: + return Keyboard.KEY_DELETE; + case VK_LWIN: + return Keyboard.KEY_LMETA; + case VK_RWIN: + return Keyboard.KEY_RMETA; + case VK_APPS: + return Keyboard.KEY_APPS; +/* case VK_POWER: + return Keyboard.KEY_POWER;*/ + case VK_SLEEP: + return Keyboard.KEY_SLEEP; + default: + return Keyboard.KEY_NONE; + } + } +} diff --git a/src/java/org/lwjgl/opengl/WindowsMouse.java b/src/java/org/lwjgl/opengl/WindowsMouse.java new file mode 100644 index 0000000..6aa3354 --- /dev/null +++ b/src/java/org/lwjgl/opengl/WindowsMouse.java @@ -0,0 +1,199 @@ +/* + * 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; + +/** + * This is the Windows implementation of the Mouse. + * @author elias_naur + */ + +import java.nio.ByteBuffer; +import java.nio.IntBuffer; + +import org.lwjgl.BufferUtils; +import org.lwjgl.LWJGLException; +import org.lwjgl.LWJGLUtil; +import org.lwjgl.input.Mouse; + +final class WindowsMouse { + private final long hwnd; + + private final int mouse_button_count; + private final boolean has_wheel; + + private final EventQueue event_queue = new EventQueue(Mouse.EVENT_SIZE); + + private final ByteBuffer mouse_event = ByteBuffer.allocate(Mouse.EVENT_SIZE); + private final Object blank_cursor; + + private boolean mouse_grabbed; + private byte[] button_states; + private int accum_dx; + private int accum_dy; + private int accum_dwheel; + private int last_x; + private int last_y; + + WindowsMouse(long hwnd) throws LWJGLException { + this.hwnd = hwnd; + this.mouse_button_count = WindowsDisplay.getSystemMetrics(WindowsDisplay.SM_CMOUSEBUTTONS); + this.has_wheel = WindowsDisplay.getSystemMetrics(WindowsDisplay.SM_MOUSEWHEELPRESENT) != 0; + this.blank_cursor = createBlankCursor(); + this.button_states = new byte[mouse_button_count]; + } + + private Object createBlankCursor() throws LWJGLException { + int width = WindowsDisplay.getSystemMetrics(WindowsDisplay.SM_CXCURSOR); + int height = WindowsDisplay.getSystemMetrics(WindowsDisplay.SM_CYCURSOR); + IntBuffer pixels = BufferUtils.createIntBuffer(width*height); + return WindowsDisplay.doCreateCursor(width, height, 0, 0, 1, pixels, null); + } + + public boolean isGrabbed() { + return mouse_grabbed; + } + + public boolean hasWheel() { + return has_wheel; + } + + public int getButtonCount() { + return mouse_button_count; + } + + public void poll(IntBuffer coord_buffer, ByteBuffer buttons) { + for (int i = 0; i < coord_buffer.remaining(); i++) + coord_buffer.put(coord_buffer.position() + i, 0); + int num_buttons = mouse_button_count; + coord_buffer.put(coord_buffer.position() + 2, accum_dwheel); + if (num_buttons > button_states.length) + num_buttons = button_states.length; + for (int j = 0; j < num_buttons; j++) { + buttons.put(buttons.position() + j, button_states[j]); + } + if (isGrabbed()) { + coord_buffer.put(coord_buffer.position() + 0, accum_dx); + coord_buffer.put(coord_buffer.position() + 1, accum_dy); + } else { + coord_buffer.put(coord_buffer.position() + 0, last_x); + coord_buffer.put(coord_buffer.position() + 1, last_y); + } + accum_dx = accum_dy = accum_dwheel = 0; + } + + private void putMouseEventWithCoords(byte button, byte state, int coord1, int coord2, int dz, long nanos) { + mouse_event.clear(); + mouse_event.put(button).put(state).putInt(coord1).putInt(coord2).putInt(dz).putLong(nanos); + mouse_event.flip(); + event_queue.putEvent(mouse_event); + } + + private void putMouseEvent(byte button, byte state, int dz, long nanos) { + if (mouse_grabbed) + putMouseEventWithCoords(button, state, 0, 0, dz, nanos); + else + putMouseEventWithCoords(button, state, last_x, last_y, dz, nanos); + } + + public void read(ByteBuffer buffer) { + event_queue.copyEvents(buffer); + } + + public Object getBlankCursor() { + return blank_cursor; + } + + public void grab(boolean grab, boolean should_center) { + if (grab) { + if (!mouse_grabbed) { + mouse_grabbed = true; + if (should_center) { + try { + WindowsDisplay.setupCursorClipping(hwnd); + } catch (LWJGLException e) { + LWJGLUtil.log("Failed to setup cursor clipping: " + e); + } + centerCursor(); + } + } + } else { + if (mouse_grabbed) { + mouse_grabbed = false; + WindowsDisplay.resetCursorClipping(); + } + } + event_queue.clearEvents(); + } + + public void handleMouseScrolled(int event_dwheel, long millis) { + accum_dwheel += event_dwheel; + putMouseEvent((byte)-1, (byte)0, event_dwheel, millis*1000000); + } + + private void centerCursor() { + WindowsDisplay.centerCursor(hwnd); + } + + public void setPosition(int x, int y) { + this.last_x = x; + this.last_y = y; + } + + public void destroy() { + WindowsDisplay.doDestroyCursor(blank_cursor); + } + + public void handleMouseMoved(int x, int y, long millis, boolean should_center) { + int dx = x - last_x; + int dy = y - last_y; + if (dx != 0 || dy != 0) { + accum_dx += dx; + accum_dy += dy; + last_x = x; + last_y = y; + long nanos = millis*1000000; + if (mouse_grabbed) { + putMouseEventWithCoords((byte)-1, (byte)0, dx, dy, 0, nanos); + if (should_center) + centerCursor(); + } else { + putMouseEventWithCoords((byte)-1, (byte)0, x, y, 0, nanos); + } + } + } + + public void handleMouseButton(byte button, byte state, long millis) { + putMouseEvent(button, state, 0, millis*1000000); + if (button < button_states.length) + button_states[button] = state != 0 ? (byte)1 : (byte)0; + } +} diff --git a/src/java/org/lwjgl/opengl/WindowsPbufferPeerInfo.java b/src/java/org/lwjgl/opengl/WindowsPbufferPeerInfo.java new file mode 100644 index 0000000..967dd84 --- /dev/null +++ b/src/java/org/lwjgl/opengl/WindowsPbufferPeerInfo.java @@ -0,0 +1,83 @@ +/* + * 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; + +import java.nio.ByteBuffer; +import java.nio.IntBuffer; + +import org.lwjgl.LWJGLException; + +/** + * + * @author elias_naur + * @version $Revision: 3116 $ + * $Id: WindowsPbufferPeerInfo.java 3116 2008-08-19 16:46:03Z spasi $ + */ +final class WindowsPbufferPeerInfo extends WindowsPeerInfo { + WindowsPbufferPeerInfo(int width, int height, PixelFormat pixel_format, IntBuffer pixelFormatCaps, IntBuffer pBufferAttribs) throws LWJGLException { + nCreate(getHandle(), width, height, pixel_format, pixelFormatCaps, pBufferAttribs); + } + private static native void nCreate(ByteBuffer handle, int width, int height, PixelFormat pixel_format, IntBuffer pixelFormatCaps, IntBuffer pBufferAttribs) throws LWJGLException; + + public boolean isBufferLost() { + return nIsBufferLost(getHandle()); + } + private static native boolean nIsBufferLost(ByteBuffer handle); + + public void setPbufferAttrib(int attrib, int value) { + nSetPbufferAttrib(getHandle(), attrib, value); + } + private static native void nSetPbufferAttrib(ByteBuffer handle, int attrib, int value); + + public void bindTexImageToPbuffer(int buffer) { + nBindTexImageToPbuffer(getHandle(), buffer); + } + private static native void nBindTexImageToPbuffer(ByteBuffer handle, int buffer); + + public void releaseTexImageFromPbuffer(int buffer) { + nReleaseTexImageFromPbuffer(getHandle(), buffer); + } + private static native void nReleaseTexImageFromPbuffer(ByteBuffer handle, int buffer); + + public void destroy() { + nDestroy(getHandle()); + } + private static native void nDestroy(ByteBuffer handle); + + protected void doLockAndInitHandle() throws LWJGLException { + // NO-OP + } + + protected void doUnlock() throws LWJGLException { + // NO-OP + } +} diff --git a/src/java/org/lwjgl/opengl/WindowsPeerInfo.java b/src/java/org/lwjgl/opengl/WindowsPeerInfo.java new file mode 100644 index 0000000..d3533c5 --- /dev/null +++ b/src/java/org/lwjgl/opengl/WindowsPeerInfo.java @@ -0,0 +1,66 @@ +/* + * 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; + +import java.nio.ByteBuffer; +import java.nio.IntBuffer; + +import org.lwjgl.LWJGLException; + +/** + * + * @author elias_naur + * @version $Revision: 3116 $ + * $Id: WindowsPeerInfo.java 3116 2008-08-19 16:46:03Z spasi $ + */ +abstract class WindowsPeerInfo extends PeerInfo { + protected WindowsPeerInfo() { + super(createHandle()); + } + private static native ByteBuffer createHandle(); + + protected static int choosePixelFormat(long hdc, int origin_x, int origin_y, PixelFormat pixel_format, IntBuffer pixel_format_caps, boolean use_hdc_bpp, boolean support_window, boolean support_pbuffer, boolean double_buffered) throws LWJGLException { + return nChoosePixelFormat(hdc, origin_x, origin_y, pixel_format, pixel_format_caps, use_hdc_bpp, support_window, support_pbuffer, double_buffered); + } + private static native int nChoosePixelFormat(long hdc, int origin_x, int origin_y, PixelFormat pixel_format, IntBuffer pixel_format_caps, boolean use_hdc_bpp, boolean support_window, boolean support_pbuffer, boolean double_buffered) throws LWJGLException; + protected static native void setPixelFormat(long hdc, int pixel_format) throws LWJGLException; + + public final long getHdc() { + return nGetHdc(getHandle()); + } + private static native long nGetHdc(ByteBuffer handle); + + public final long getHwnd() { + return nGetHwnd(getHandle()); + } + private static native long nGetHwnd(ByteBuffer handle); +} diff --git a/src/java/org/lwjgl/opengl/WindowsRegistry.java b/src/java/org/lwjgl/opengl/WindowsRegistry.java new file mode 100644 index 0000000..f39c3a3 --- /dev/null +++ b/src/java/org/lwjgl/opengl/WindowsRegistry.java @@ -0,0 +1,69 @@ +/* + * 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; + +/** + * This is an interface to the windows registry + * @author elias_naur + */ + +import org.lwjgl.LWJGLException; +import org.lwjgl.Sys; + +final class WindowsRegistry { + final static int HKEY_CLASSES_ROOT = 1; + final static int HKEY_CURRENT_USER = 2; + final static int HKEY_LOCAL_MACHINE = 3; + final static int HKEY_USERS = 4; + + static { + Sys.initialize(); + } + + /** + * Query the registry value specified by the root key, subkey, value tuple + */ + static String queryRegistrationKey(int root_key, String subkey, String value) throws LWJGLException { + switch (root_key) { + case HKEY_CLASSES_ROOT: + case HKEY_CURRENT_USER: + case HKEY_LOCAL_MACHINE: + case HKEY_USERS: + break; + default: + throw new IllegalArgumentException("Invalid enum: " + root_key); + } + return nQueryRegistrationKey(root_key, subkey, value); + } + + private static native String nQueryRegistrationKey(int root_key, String subkey, String value) throws LWJGLException; +} diff --git a/src/java/org/lwjgl/opengl/XRandR.java b/src/java/org/lwjgl/opengl/XRandR.java new file mode 100644 index 0000000..d9876b9 --- /dev/null +++ b/src/java/org/lwjgl/opengl/XRandR.java @@ -0,0 +1,257 @@ +/* + * 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.opengl; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.regex.Pattern; +import java.security.AccessController; +import java.security.PrivilegedAction; + +/** + * Utility for working with the xrandr commmand-line utility. Assumes + * xrandr v1.2 or higher. + * + * @author ryanm + */ +public class XRandR { + + private static Screen[] current; + + private static Map /* */screens; + + private static void populate() { + if (screens == null) { + screens = new HashMap/* */(); + + // ProcessBuilder pb = new ProcessBuilder( "xrandr", "-q" ); + // pb.redirectErrorStream(); + try { + // Process p= pb.start(); + Process p = Runtime.getRuntime().exec(new String[] { "xrandr", "-q"}); + + List/* */currentList = new ArrayList/* */(); + List/* */possibles = new ArrayList/* */(); + String name = null; + + BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream())); + String line; + while ((line = br.readLine()) != null) { + line = line.trim(); + String[] sa = line.split("\\s+"); + + if (sa[1].equals("connected")) { + // found a new screen block + if (name != null) { + screens.put(name, possibles.toArray(new Screen[possibles.size()])); + possibles.clear(); + } + name = sa[0]; + + // record the current config + currentList.add(new Screen(name, sa[2])); + } else if (Pattern.matches("\\d*x\\d*", sa[0])) { + // found a new mode line + possibles.add(new Screen(name, sa[0])); + } + } + + screens.put(name, possibles.toArray(new Screen[possibles.size()])); + + current = (Screen[]) currentList.toArray(new Screen[currentList.size()]); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + + /** + * @return The current screen configuration, or an empty array if + * xrandr is not supported + */ + public static Screen[] getConfiguration() { + AccessController.doPrivileged(new PrivilegedAction() { + public Object run() { + populate(); + return null; + } + }); + + return (Screen[]) current.clone(); + } + + /** + * @param screens + * The desired screen set, may not be null + */ + public static void setConfiguration(Screen[]/* ... */screens) { + if (screens.length == 0) { + throw new IllegalArgumentException("Must specify at least one screen"); + } + + List/* */cmd = new ArrayList/* */(); + cmd.add("xrandr"); + + // switch off those in the current set not in the new set + for (int i = 0; i < current.length; i++) { + boolean found = false; + for (int j = 0; j < screens.length; j++) { + if (screens[j].name.equals(current[i].name)) { + found = true; + break; + } + } + + if (!found) { + cmd.add("--output"); + cmd.add(current[i].name); + cmd.add("--off"); + } + } + + // set up new set + for (int i = 0; i < screens.length; i++) { + screens[i].getArgs(cmd); + } + + try { + // ProcessBuilder pb = new ProcessBuilder( cmd ); + // pb.redirectErrorStream(); + // Process p = pb.start(); + Process p = Runtime.getRuntime().exec((String[]) cmd.toArray(new String[cmd.size()])); + // no output is expected, but check anyway + BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream())); + String line; + while ((line = br.readLine()) != null) { + System.out.println(line); + } + current = screens; + } catch (IOException e) { + e.printStackTrace(); + } + + } + + /** + * @return the name of connected screens, or an empty array if + * xrandr is not supported + */ + public static String[] getScreenNames() { + populate(); + return (String[]) screens.keySet().toArray(new String[screens.size()]); + } + + /** + * @param name + * @return the possible resolutions of the named screen, or + * null if there is no such screen + */ + public static Screen[] getResolutions(String name) { + populate(); + // clone the array to prevent held copies being altered + return (Screen[]) ((Screen[]) screens.get(name)).clone(); + } + + /** + * Encapsulates the configuration of a monitor. Resolution is + * fixed, position is mutable + * + * @author ryanm + */ + public static class Screen implements Cloneable { + + /** + * Name for this output + */ + public final String name; + + /** + * Width in pixels + */ + public final int width; + + /** + * Height in pixels + */ + public final int height; + + /** + * Position on the x-axis, in pixels + */ + public int xPos = 0; + + /** + * Position on the y-axis, in pixels + */ + public int yPos = 0; + + /** + * @param name + * name of the screen + * @param conf + * config string, format either widthxheight or + * widthxheight+xPos+yPos + */ + private Screen(String name, String conf) { + this.name = name; + + String[] sa = conf.split("\\D"); + width = Integer.parseInt(sa[0]); + height = Integer.parseInt(sa[1]); + + if (sa.length > 2) { + xPos = Integer.parseInt(sa[2]); + yPos = Integer.parseInt(sa[3]); + } + } + + private void getArgs(List/* */argList) { + argList.add("--output"); + argList.add(name); + argList.add("--mode"); + argList.add(width + "x" + height); + argList.add("--pos"); + argList.add(xPos + "x" + yPos); + } + + // @Override + public String toString() { + return name + " " + width + "x" + height + " @ " + xPos + "x" + yPos; + } + } +} diff --git a/src/java/org/lwjgl/test/DisplayTest.java b/src/java/org/lwjgl/test/DisplayTest.java new file mode 100644 index 0000000..7d6abf7 --- /dev/null +++ b/src/java/org/lwjgl/test/DisplayTest.java @@ -0,0 +1,252 @@ +/* + * 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.test; + +import org.lwjgl.LWJGLException; +import org.lwjgl.opengl.Display; +import org.lwjgl.opengl.DisplayMode; + +/** + *
    + * Test class for Display & DisplayMode + * + * @author Brian Matzon + * @version $Revision: 2983 $ + * $Id: DisplayTest.java 2983 2008-04-07 18:36:09Z matzon $ + */ +public class DisplayTest { + + /** + * Creates a new DisplayTest + */ + public DisplayTest() { + } + + /** + * Runs the tests + */ + public void executeTest() throws LWJGLException { + currentTest(); + queryModesTest(); + setDisplayModeTest(); + setDisplayConfigurationTest(); + } + + /** + * Prints some info about the current mode + */ + private void currentTest() { + System.out.println("==== Test Current ===="); + + System.out.println("Info about current:"); + System.out.println("Graphics card: " + Display.getAdapter() + ", version: " + Display.getVersion()); + System.out.println("Resolution: " + + Display.getDisplayMode().getWidth() + "x" + + Display.getDisplayMode().getHeight() + "x" + + Display.getDisplayMode().getBitsPerPixel() + "@" + + Display.getDisplayMode().getFrequency() + "Hz"); + System.out.println("---- Test Current ----"); + } + + /** + * Tests querying for modes + */ + private void queryModesTest() throws LWJGLException { + DisplayMode[] modes = null; + + System.out.println("==== Test query ===="); + System.out.println("Retrieving available displaymodes"); + modes = Display.getAvailableDisplayModes(); + + // no modes check + if (modes == null) { + System.out.println("FATAL: unable to find any modes!"); + System.exit(-1); + } + + // write some info + System.out.println("Found " + modes.length + " modes"); + System.out.println("The first 5 are:"); + for(int i=0;i + * Simple test that just checks that the native library loads + * + * @author Brian Matzon + * @version $Revision: 2983 $ + * $Id: SysTest.java 2983 2008-04-07 18:36:09Z matzon $ + */ +public class NativeTest { + + public void invokeSys() { + Sys.getVersion(); + } + + /** + * Entry point for test + * + * @param args ignored + */ + public static void main(String[] args) { + // try to "load" awt - work around for headless issue on linux + Toolkit.getDefaultToolkit(); + new NativeTest().invokeSys(); + System.out.println("OK"); + } +} diff --git a/src/java/org/lwjgl/test/SysTest.java b/src/java/org/lwjgl/test/SysTest.java new file mode 100644 index 0000000..97fe6a4 --- /dev/null +++ b/src/java/org/lwjgl/test/SysTest.java @@ -0,0 +1,180 @@ +/* + * 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.test; + +import org.lwjgl.LWJGLException; +import org.lwjgl.LWJGLUtil; +import org.lwjgl.Sys; +import org.lwjgl.opengl.Display; + +/** + *
    + * Test class for Sys + * + * @author Brian Matzon + * @version $Revision: 2983 $ + * $Id: SysTest.java 2983 2008-04-07 18:36:09Z matzon $ + */ +public class SysTest { + + /** + * Creates a new SysTest + */ + public SysTest() { + } + + /** + * Runs the tests + */ + public void executeTest() { + testAlert(); + testDebug(); + testTimer(); + testUrl(); + testClipboard(); + } + + /** + * Tests debug mode + */ + private void testDebug() { + System.out.println("==== Test Debug ===="); + if (LWJGLUtil.DEBUG) { + LWJGLUtil.log("Debug is enabled, you should now see output from LWJGL during the following tests."); + } else { + System.out.println("Debug is not enabled. Please set the org.lwjgl.Sys.debug property to true to enable debugging"); + System.out.println("Example:\n java -Dorg.lwjgl.util.Debug=true ..."); + System.out.println("You will not see any debug output in the following tests."); + } + + // get some display modes, to force some debug info + try { + Display.getAvailableDisplayModes(); + } catch (LWJGLException e) { + throw new RuntimeException(e); + } + + System.out.println("---- Test Debug ----\n"); + } + + /** + * Tests the timer + */ + private void testTimer() { + long resolution = Sys.getTimerResolution(); + long time = Sys.getTime(); + + System.out.println("==== Test Timer ===="); + System.out.println("Resolution of timer (ticks per second): " + resolution); + System.out.println("Current time: " + time); + System.out.println("Sleeping for 2 seconds, using Thread.sleep()"); + + pause(2000); + + long time2 = Sys.getTime(); + System.out.println("Current time: " + time2); + System.out.println("Actually slept for: " + ((time2 - time) / (float) resolution) + " seconds"); + System.out.println("---- Test Timer ----\n"); + } + + /** + * Tests the alert + */ + private void testAlert() { + System.out.println("==== Test Alert ===="); + + System.out.println("Opening native alert window"); + Sys.alert("SysTest", "Hello World!"); + + System.out.println("---- Test Alert ----\n"); + } + + /** + * Tests the openUrl + */ + private void testUrl() { + System.out.println("==== Test URL ===="); + + System.out.println("Opening a browser window to http://www.lwjgl.org"); + Sys.openURL("http://www.lwjgl.org"); + + System.out.println("---- Test URL ----\n"); + } + + /** + * Busy waits for a specified number of seconds + * + * @param priority Priority to busy wait in + * @param seconds Number of seconds to busy wait + * @param message Message to print to user + */ + private void busyWait(int priority, int seconds, String message) { + long future = Sys.getTime() + (Sys.getTimerResolution() * seconds); + + System.out.print(message); + + // waste some cycles + while (Sys.getTime() < future) { + } + + System.out.println("done"); + } + + /** + * Pause current thread for a specified time + * + * @param time milliseconds to sleep + */ + private void pause(long time) { + try { + Thread.sleep(time); + } catch (InterruptedException inte) { + } + } + + /** + * Tests the clipboard. Helps to have something in it first... + */ + private void testClipboard() { + System.out.println("Contents of clipboard: '"+Sys.getClipboard()+"'"); + } + + /** + * Tests the Sys class, and serves as basic usage test + * + * @param args ignored + */ + public static void main(String[] args) { + new SysTest().executeTest(); + System.exit(0); + } +} diff --git a/src/java/org/lwjgl/test/WaveDataTest.java b/src/java/org/lwjgl/test/WaveDataTest.java new file mode 100644 index 0000000..43abc99 --- /dev/null +++ b/src/java/org/lwjgl/test/WaveDataTest.java @@ -0,0 +1,135 @@ +/* + * 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.test; + +import java.io.File; + +import javax.sound.sampled.AudioInputStream; +import javax.sound.sampled.AudioSystem; + +import org.lwjgl.LWJGLException; +import org.lwjgl.util.WaveData; + +/** + *
    + * Test class WaveDataTest + * + * @author Brian Matzon + */ +public class WaveDataTest { + + String filePath = "Footsteps.wav"; + + /** + * Creates a new DisplayTest + */ + public WaveDataTest() { + } + + /** + * Runs the tests + */ + public void executeTest() throws LWJGLException { + executeCreationTest(); + executeBrokenCreationTest(); + executeMidStreamCreationTest(); + } + + + private void executeCreationTest() { + WaveData wd = WaveData.create(filePath); + if(wd != null) { + System.out.println("executeCreationTest::success"); + } + } + + private void executeBrokenCreationTest() { + WaveData wd = WaveData.create(""); + if(wd == null) { + System.out.println("executeBrokenCreationTest::success"); + } + } + + private void executeStreamCreationTest() { + try { + AudioInputStream ais = AudioSystem.getAudioInputStream(new File(filePath)); + WaveData wd = WaveData.create(ais); + if(wd == null) { + System.out.println("executeMidStreamCreationTest::success"); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + private void executeMidStreamCreationTest() { + try { + + AudioInputStream ais = AudioSystem.getAudioInputStream(WaveDataTest.class.getClassLoader().getResource(filePath)); + int totalSize = ais.getFormat().getChannels() * (int) ais.getFrameLength() * ais.getFormat().getSampleSizeInBits() / 8; + + // skip 1/4 of the stream + int skip = totalSize / 4; + long skipped = ais.skip(skip); + + WaveData wd = WaveData.create(ais); + if(wd == null) { + System.out.println("executeMidStreamCreationTest::success"); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * Pause current thread for a specified time + * + * @param time milliseconds to sleep + */ + private void pause(long time) { + try { + Thread.sleep(time); + } catch (InterruptedException inte) { + /* ignored */ + } + } + + /** + * Tests the Sys class, and serves as basic usage test + * + * @param args ignored + */ + public static void main(String[] args) throws LWJGLException { + new WaveDataTest().executeTest(); + System.exit(0); + } +} diff --git a/src/java/org/lwjgl/test/WindowCreationTest.java b/src/java/org/lwjgl/test/WindowCreationTest.java new file mode 100644 index 0000000..7fb9a90 --- /dev/null +++ b/src/java/org/lwjgl/test/WindowCreationTest.java @@ -0,0 +1,324 @@ +/* + * 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.test; + +import org.lwjgl.LWJGLException; +import org.lwjgl.input.Keyboard; +import org.lwjgl.opengl.Display; +import org.lwjgl.opengl.DisplayMode; +import org.lwjgl.opengl.GL11; + +/** + * Small class for testing that the Window is creatable + * If this class can't run, LWJGL wont work! + * + * @author Brian Matzon + */ +public class WindowCreationTest { + + /** Locatable modes */ + private DisplayMode[] located_modes; + + /** Fixed selectable modes */ + private DisplayMode[] fixed_modes = new DisplayMode[10]; + + + /** Window position x */ + private int window_x = 0; + + /** Window position y */ + private int window_y = 0; + + /** Color being cleared to */ + private float color = 0f; + + /** Direction moving clearing color */ + private int direction = 1; + + /** Whether we're running */ + private boolean running = false; + + /** Whether we're in fullscreen mode */ + private boolean fullscreen = false; + + /** + * Initializes the test + * @return true if initialization was successfull + */ + public boolean initialize() { + try { + // get available modes, and print out + located_modes = Display.getAvailableDisplayModes(); + System.out.println("Found " + located_modes.length + " display modes"); + + // get 640x480, 800x600, 1024x768 modes + findFixedModes(); + + // create default windowed display 640*480 @ 100, 100 + setDefaultDisplayMode(); + + window_x = window_y = 100; + Display.setLocation(window_x, window_y); + + Display.create(); + return true; + } catch (LWJGLException le) { + le.printStackTrace(); + } + return false; + } + + /** Locate fixed modes */ + private void findFixedModes() { + // get 640*480 modes + fixed_modes[0] = getDisplayMode(640, 480, 16, -1); + fixed_modes[1] = getDisplayMode(640, 480, 24, -1); + fixed_modes[2] = getDisplayMode(640, 480, 32, -1); + + // get 800*600*16*60 + fixed_modes[3] = getDisplayMode(800, 600, 16, -1); + fixed_modes[4] = getDisplayMode(800, 600, 24, -1); + fixed_modes[5] = getDisplayMode(800, 600, 32, -1); + + // get 1024*768*16*60 + fixed_modes[6] = getDisplayMode(1024, 768, 16, -1); + fixed_modes[7] = getDisplayMode(1024, 768, 24, -1); + fixed_modes[8] = getDisplayMode(1024, 768, 32, -1); + } + + /** + * Executes the test + */ + private void execute() { + running = true; + + // wait for user to close window + while (!Display.isCloseRequested() && running) { + + // handle input accordingly + handleInput(); + + // render something + render(); + + // update display as needed + Display.update(); + + // no need to run at full speed + try { + Thread.sleep(100); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + + /** + * Destroys any resources used while running test + */ + public void destroy() { + // nuke window and get out + Display.destroy(); + } + + /** + * Handles the input + */ + private void handleInput() { + while (Keyboard.next()) { + + // we only want key down events + if (!Keyboard.getEventKeyState()) { + continue; + } + + // check for exit + if (Keyboard.getEventKey() == Keyboard.KEY_ESCAPE) { + running = false; + } + + // check for listing of modes + if (Keyboard.getEventKey() == Keyboard.KEY_L) { + for(int i=0;i 1f) { + color = 1f; + direction = -1 * direction; + } else if (color < 0f) { + direction = -1 * direction; + color = 0f; + } + } + + /** + * Main entry point + * + * @param args ignored params to app + */ + public static void main(String[] args) throws LWJGLException { + + System.out.println("The following keys are available:\n" + + "ESCAPE:\t\tExit test\n" + + "ARROW Keys:\tMove window when in non-fullscreen mode\n" + + "L:\t\tList selectable display modes\n" + + "0-8:\t\tSelection of display modes\n" + + "F:\t\tToggle fullscreen\n" + + "SHIFT-F:\tToggle fullscreen with Display.destroy()/create() cycle"); + + WindowCreationTest wct = new WindowCreationTest(); + if (wct.initialize()) { + wct.execute(); + wct.destroy(); + } + System.exit(0); + } + + /** + * Sets the display mode for fullscreen mode + */ + protected boolean setDefaultDisplayMode() { + try { + // get modes + DisplayMode[] dm = org.lwjgl.util.Display.getAvailableDisplayModes(640, 480, -1, -1, -1, -1, -1, -1); + + org.lwjgl.util.Display.setDisplayMode(dm, new String[] { "width=" + 640, "height=" + 480, "freq=" + 60, + "bpp=" + org.lwjgl.opengl.Display.getDisplayMode().getBitsPerPixel()}); + return true; + } catch (Exception e) { + e.printStackTrace(); + } + return false; + } + + /** + * Gets a specific display mode + */ + private DisplayMode getDisplayMode(int width, int height, int bpp, int freq) { + DisplayMode[] dm = null; + try { + dm = org.lwjgl.util.Display.getAvailableDisplayModes(width, height, width, height, bpp, bpp, freq, freq); + if(dm == null || dm.length == 0) { + System.out.println("Problem retrieving mode with " + width + "x" + height + "x" + bpp + "@" + freq); + } + } catch (LWJGLException le) { + le.printStackTrace(); + System.out.println("Problem retrieving mode with " + width + "x" + height + "x" + bpp + "@" + freq); + } + return (dm != null && dm.length != 0) ? dm[0] : null; + } +} diff --git a/src/java/org/lwjgl/test/applet/AppletLoaderTest.java b/src/java/org/lwjgl/test/applet/AppletLoaderTest.java new file mode 100644 index 0000000..60b847b --- /dev/null +++ b/src/java/org/lwjgl/test/applet/AppletLoaderTest.java @@ -0,0 +1,72 @@ +/* + * 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.test.applet; + +import java.applet.Applet; +import java.awt.BorderLayout; +import java.awt.Canvas; + +public class AppletLoaderTest extends Applet { + + Test test = null; + + public void destroy() { + super.destroy(); + System.out.println("*** destroy ***"); + } + + public void start() { + super.start(); + System.out.println("*** start ***"); + } + + public void stop() { + super.stop(); + System.out.println("*** stop ***"); + test.stop(); + } + + public void init() { + System.out.println("*** init ***"); + + setLayout(new BorderLayout()); + try { + test = (Test) Class.forName(getParameter("test")).newInstance(); + Canvas canvas = (Canvas) test; + canvas.setSize(getWidth(), getHeight()); + add(canvas); + } catch (Exception e) { + e.printStackTrace(); + } + test.start(); + } +} diff --git a/src/java/org/lwjgl/test/applet/ControllersTest.java b/src/java/org/lwjgl/test/applet/ControllersTest.java new file mode 100644 index 0000000..7f39ad6 --- /dev/null +++ b/src/java/org/lwjgl/test/applet/ControllersTest.java @@ -0,0 +1,52 @@ +/* + * 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.test.applet; + +import java.awt.Canvas; + +import org.lwjgl.LWJGLException; +import org.lwjgl.input.Controllers; + +public class ControllersTest extends Canvas implements Test { + public void start() { + try { + Controllers.create(); + } catch (LWJGLException e) { + e.printStackTrace(); + return; + } + System.out.println("Controllers.getControllerCount() = " + Controllers.getControllerCount()); + } + + public void stop() { + } +} diff --git a/src/java/org/lwjgl/test/applet/GearsApplet.java b/src/java/org/lwjgl/test/applet/GearsApplet.java new file mode 100644 index 0000000..95fb7d3 --- /dev/null +++ b/src/java/org/lwjgl/test/applet/GearsApplet.java @@ -0,0 +1,401 @@ +package org.lwjgl.test.applet; + +import java.applet.Applet; +import java.awt.BorderLayout; +import java.awt.Canvas; +import java.nio.FloatBuffer; +import org.lwjgl.BufferUtils; +import org.lwjgl.LWJGLException; +import org.lwjgl.opengl.ARBTransposeMatrix; +import org.lwjgl.opengl.Display; +import org.lwjgl.input.Keyboard; +import org.lwjgl.input.Mouse; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GLContext; + +public class GearsApplet extends Applet { + + /** The Canvas where the LWJGL Display is added */ + Canvas display_parent; + + /** Thread which runs the main game loop */ + Thread gameThread; + + /** is the game loop running */ + boolean running = false; + + /** variables used to rotate the view */ + private float view_rotx = 20.0f; + private float view_roty = 30.0f; + private float view_rotz = 0.0f; + + private int gear1; + private int gear2; + private int gear3; + private float angle; + + boolean keyDown = false; + + private int prevMouseX, prevMouseY; + private boolean mouseButtonDown = false; + + + /** + * Once the Canvas is created its add notify method will call this method to + * start the LWJGL Display and game loop in another thread. + */ + public void startLWJGL() { + gameThread = new Thread() { + public void run() { + running = true; + try { + Display.setParent(display_parent); + //Display.setVSyncEnabled(true); + Display.create(); + initGL(); + } catch (LWJGLException e) { + e.printStackTrace(); + } + gameLoop(); + } + }; + gameThread.start(); + } + + + /** + * Tell game loop to stop running, after which the LWJGL Display will be destoryed. + * The main thread will wait for the Display.destroy() to complete + */ + private void stopLWJGL() { + running = false; + try { + gameThread.join(); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + + public void start() { + + } + + public void stop() { + + } + + /** + * Applet Destroy method will remove the canvas, before canvas is destroyed it will notify + * stopLWJGL() to stop main game loop and to destroy the Display + */ + public void destroy() { + remove(display_parent); + super.destroy(); + System.out.println("Clear up"); + } + + /** + * initialise applet by adding a canvas to it, this canvas will start the LWJGL Display and game loop + * in another thread. It will also stop the game loop and destroy the display on canvas removal when + * applet is destroyed. + */ + public void init() { + setLayout(new BorderLayout()); + try { + display_parent = new Canvas() { + public final void addNotify() { + super.addNotify(); + startLWJGL(); + } + public final void removeNotify() { + stopLWJGL(); + super.removeNotify(); + } + }; + display_parent.setSize(getWidth(),getHeight()); + add(display_parent); + display_parent.setFocusable(true); + display_parent.requestFocus(); + display_parent.setIgnoreRepaint(true); + //setResizable(true); + setVisible(true); + } catch (Exception e) { + System.err.println(e); + throw new RuntimeException("Unable to create display"); + } + } + + public void gameLoop() { + long startTime = System.currentTimeMillis() + 5000; + long fps = 0; + + while(running) { + angle += 2.0f; + + // draw the gears + drawLoop(); + + Display.update(); + + if (startTime > System.currentTimeMillis()) { + fps++; + } else { + long timeUsed = 5000 + (startTime - System.currentTimeMillis()); + startTime = System.currentTimeMillis() + 5000; + System.out.println(fps + " frames 2 in " + (float) (timeUsed / 1000f) + " seconds = " + + (fps / (timeUsed / 1000f))); + fps = 0; + } + + if (Mouse.isButtonDown(0)) { + if (!mouseButtonDown) { + prevMouseX = Mouse.getX(); + prevMouseY= Mouse.getY(); + } + mouseButtonDown = true; + } + else { + mouseButtonDown = false; + } + + if (mouseButtonDown) { + int x = Mouse.getX(); + int y = Mouse.getY(); + + float thetaY = 360.0f * ( (float)(x-prevMouseX)/(float)display_parent.getWidth()); + float thetaX = 360.0f * ( (float)(prevMouseY-y)/(float)display_parent.getHeight()); + + prevMouseX = x; + prevMouseY = y; + + view_rotx += thetaX; + view_roty += thetaY; + } + + // F Key Pressed (i.e. released) + if (keyDown && !Keyboard.isKeyDown(Keyboard.KEY_F)) { + keyDown = false; + + try { + if (Display.isFullscreen()) { + Display.setFullscreen(false); + } + else { + Display.setFullscreen(true); + } + } catch (LWJGLException e) { + e.printStackTrace(); + } + } + } + + Display.destroy(); + } + + public void drawLoop() { + GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); + + GL11.glPushMatrix(); + + GL11.glRotatef(view_rotx, 1.0f, 0.0f, 0.0f); + GL11.glRotatef(view_roty, 0.0f, 1.0f, 0.0f); + GL11.glRotatef(view_rotz, 0.0f, 0.0f, 1.0f); + + GL11.glPushMatrix(); + GL11.glTranslatef(-3.0f, -2.0f, 0.0f); + GL11.glRotatef(angle, 0.0f, 0.0f, 1.0f); + GL11.glCallList(gear1); + GL11.glPopMatrix(); + + GL11.glPushMatrix(); + GL11.glTranslatef(3.1f, -2.0f, 0.0f); + GL11.glRotatef(-2.0f * angle - 9.0f, 0.0f, 0.0f, 1.0f); + GL11.glCallList(gear2); + GL11.glPopMatrix(); + + GL11.glPushMatrix(); + GL11.glTranslatef(-3.1f, 4.2f, 0.0f); + GL11.glRotatef(-2.0f * angle - 25.0f, 0.0f, 0.0f, 1.0f); + GL11.glCallList(gear3); + GL11.glPopMatrix(); + + GL11.glPopMatrix(); + } + + protected void initGL() { + try { + // setup ogl + FloatBuffer pos = BufferUtils.createFloatBuffer(4).put(new float[] { 5.0f, 5.0f, 10.0f, 0.0f}); + FloatBuffer red = BufferUtils.createFloatBuffer(4).put(new float[] { 0.8f, 0.1f, 0.0f, 1.0f}); + FloatBuffer green = BufferUtils.createFloatBuffer(4).put(new float[] { 0.0f, 0.8f, 0.2f, 1.0f}); + FloatBuffer blue = BufferUtils.createFloatBuffer(4).put(new float[] { 0.2f, 0.2f, 1.0f, 1.0f}); + + pos.flip(); + red.flip(); + green.flip(); + blue.flip(); + + GL11.glLight(GL11.GL_LIGHT0, GL11.GL_POSITION, pos); + GL11.glEnable(GL11.GL_CULL_FACE); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_LIGHT0); + GL11.glEnable(GL11.GL_DEPTH_TEST); + + /* make the gears */ + gear1 = GL11.glGenLists(1); + GL11.glNewList(gear1, GL11.GL_COMPILE); + GL11.glMaterial(GL11.GL_FRONT, GL11.GL_AMBIENT_AND_DIFFUSE, red); + gear(1.0f, 4.0f, 1.0f, 20, 0.7f); + GL11.glEndList(); + + gear2 = GL11.glGenLists(1); + GL11.glNewList(gear2, GL11.GL_COMPILE); + GL11.glMaterial(GL11.GL_FRONT, GL11.GL_AMBIENT_AND_DIFFUSE, green); + gear(0.5f, 2.0f, 2.0f, 10, 0.7f); + GL11.glEndList(); + + gear3 = GL11.glGenLists(1); + GL11.glNewList(gear3, GL11.GL_COMPILE); + GL11.glMaterial(GL11.GL_FRONT, GL11.GL_AMBIENT_AND_DIFFUSE, blue); + gear(1.3f, 2.0f, 0.5f, 10, 0.7f); + GL11.glEndList(); + GL11.glEnable(GL11.GL_NORMALIZE); + GL11.glMatrixMode(GL11.GL_PROJECTION); + + System.err.println("GL_VENDOR: " + GL11.glGetString(GL11.GL_VENDOR)); + System.err.println("GL_RENDERER: " + GL11.glGetString(GL11.GL_RENDERER)); + System.err.println("GL_VERSION: " + GL11.glGetString(GL11.GL_VERSION)); + System.err.println(); + System.err.println("glLoadTransposeMatrixfARB() supported: " + GLContext.getCapabilities().GL_ARB_transpose_matrix); + + if (!GLContext.getCapabilities().GL_ARB_transpose_matrix) { + // --- not using extensions + GL11.glLoadIdentity(); + } else { + // --- using extensions + final FloatBuffer identityTranspose = BufferUtils.createFloatBuffer(16).put( + new float[] { 1, 0, 0, 0, 0, 1, 0, 0, + 0, 0, 1, 0, 0, 0, 0, 1}); + identityTranspose.flip(); + ARBTransposeMatrix.glLoadTransposeMatrixARB(identityTranspose); + } + float h = (float) display_parent.getHeight() / (float) display_parent.getWidth(); + GL11.glFrustum(-1.0f, 1.0f, -h, h, 5.0f, 60.0f); + GL11.glMatrixMode(GL11.GL_MODELVIEW); + GL11.glLoadIdentity(); + GL11.glTranslatef(0.0f, 0.0f, -40.0f); + } catch (Exception e) { + System.err.println(e); + running = false; + } + } + + /** + * Draw a gear wheel. You'll probably want to call this function when + * building a display list since we do a lot of trig here. + * + * @param inner_radius radius of hole at center + * @param outer_radius radius at center of teeth + * @param width width of gear + * @param teeth number of teeth + * @param tooth_depth depth of tooth + */ + private void gear(float inner_radius, float outer_radius, float width, int teeth, float tooth_depth) { + int i; + float r0, r1, r2; + float angle, da; + float u, v, len; + + r0 = inner_radius; + r1 = outer_radius - tooth_depth / 2.0f; + r2 = outer_radius + tooth_depth / 2.0f; + da = 2.0f * (float) Math.PI / teeth / 4.0f; + GL11.glShadeModel(GL11.GL_FLAT); + GL11.glNormal3f(0.0f, 0.0f, 1.0f); + /* draw front face */ + GL11.glBegin(GL11.GL_QUAD_STRIP); + for (i = 0; i <= teeth; i++) { + angle = i * 2.0f * (float) Math.PI / teeth; + GL11.glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), width * 0.5f); + GL11.glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), width * 0.5f); + if (i < teeth) { + GL11.glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), width * 0.5f); + GL11.glVertex3f(r1 * (float) Math.cos(angle + 3.0f * da), r1 * (float) Math.sin(angle + 3.0f * da), + width * 0.5f); + } + } + GL11.glEnd(); + + /* draw front sides of teeth */ + GL11.glBegin(GL11.GL_QUADS); + for (i = 0; i < teeth; i++) { + angle = i * 2.0f * (float) Math.PI / teeth; + GL11.glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), width * 0.5f); + GL11.glVertex3f(r2 * (float) Math.cos(angle + da), r2 * (float) Math.sin(angle + da), width * 0.5f); + GL11.glVertex3f(r2 * (float) Math.cos(angle + 2.0f * da), r2 * (float) Math.sin(angle + 2.0f * da), width * 0.5f); + GL11.glVertex3f(r1 * (float) Math.cos(angle + 3.0f * da), r1 * (float) Math.sin(angle + 3.0f * da), width * 0.5f); + } + GL11.glEnd(); + + /* draw back face */ + GL11.glBegin(GL11.GL_QUAD_STRIP); + for (i = 0; i <= teeth; i++) { + angle = i * 2.0f * (float) Math.PI / teeth; + GL11.glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), -width * 0.5f); + GL11.glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), -width * 0.5f); + GL11.glVertex3f(r1 * (float) Math.cos(angle + 3 * da), r1 * (float) Math.sin(angle + 3 * da), -width * 0.5f); + GL11.glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), -width * 0.5f); + } + GL11.glEnd(); + + /* draw back sides of teeth */ + GL11.glBegin(GL11.GL_QUADS); + for (i = 0; i < teeth; i++) { + angle = i * 2.0f * (float) Math.PI / teeth; + GL11.glVertex3f(r1 * (float) Math.cos(angle + 3 * da), r1 * (float) Math.sin(angle + 3 * da), -width * 0.5f); + GL11.glVertex3f(r2 * (float) Math.cos(angle + 2 * da), r2 * (float) Math.sin(angle + 2 * da), -width * 0.5f); + GL11.glVertex3f(r2 * (float) Math.cos(angle + da), r2 * (float) Math.sin(angle + da), -width * 0.5f); + GL11.glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), -width * 0.5f); + } + GL11.glEnd(); + + /* draw outward faces of teeth */ + GL11.glBegin(GL11.GL_QUAD_STRIP); + for (i = 0; i < teeth; i++) { + angle = i * 2.0f * (float) Math.PI / teeth; + GL11.glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), width * 0.5f); + GL11.glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), -width * 0.5f); + u = r2 * (float) Math.cos(angle + da) - r1 * (float) Math.cos(angle); + v = r2 * (float) Math.sin(angle + da) - r1 * (float) Math.sin(angle); + len = (float) Math.sqrt(u * u + v * v); + u /= len; + v /= len; + GL11.glNormal3f(v, -u, 0.0f); + GL11.glVertex3f(r2 * (float) Math.cos(angle + da), r2 * (float) Math.sin(angle + da), width * 0.5f); + GL11.glVertex3f(r2 * (float) Math.cos(angle + da), r2 * (float) Math.sin(angle + da), -width * 0.5f); + GL11.glNormal3f((float) Math.cos(angle), (float) Math.sin(angle), 0.0f); + GL11.glVertex3f(r2 * (float) Math.cos(angle + 2 * da), r2 * (float) Math.sin(angle + 2 * da), width * 0.5f); + GL11.glVertex3f(r2 * (float) Math.cos(angle + 2 * da), r2 * (float) Math.sin(angle + 2 * da), -width * 0.5f); + u = r1 * (float) Math.cos(angle + 3 * da) - r2 * (float) Math.cos(angle + 2 * da); + v = r1 * (float) Math.sin(angle + 3 * da) - r2 * (float) Math.sin(angle + 2 * da); + GL11.glNormal3f(v, -u, 0.0f); + GL11.glVertex3f(r1 * (float) Math.cos(angle + 3 * da), r1 * (float) Math.sin(angle + 3 * da), width * 0.5f); + GL11.glVertex3f(r1 * (float) Math.cos(angle + 3 * da), r1 * (float) Math.sin(angle + 3 * da), -width * 0.5f); + GL11.glNormal3f((float) Math.cos(angle), (float) Math.sin(angle), 0.0f); + } + GL11.glVertex3f(r1 * (float) Math.cos(0), r1 * (float) Math.sin(0), width * 0.5f); + GL11.glVertex3f(r1 * (float) Math.cos(0), r1 * (float) Math.sin(0), -width * 0.5f); + GL11.glEnd(); + + GL11.glShadeModel(GL11.GL_SMOOTH); + /* draw inside radius cylinder */ + GL11.glBegin(GL11.GL_QUAD_STRIP); + for (i = 0; i <= teeth; i++) { + angle = i * 2.0f * (float) Math.PI / teeth; + GL11.glNormal3f(-(float) Math.cos(angle), -(float) Math.sin(angle), 0.0f); + GL11.glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), -width * 0.5f); + GL11.glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), width * 0.5f); + } + GL11.glEnd(); + } +} \ No newline at end of file diff --git a/src/java/org/lwjgl/test/applet/OpenAL.java b/src/java/org/lwjgl/test/applet/OpenAL.java new file mode 100644 index 0000000..778900c --- /dev/null +++ b/src/java/org/lwjgl/test/applet/OpenAL.java @@ -0,0 +1,182 @@ +/* + * 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.test.applet; + +import java.nio.IntBuffer; + +import org.lwjgl.BufferUtils; +import org.lwjgl.LWJGLException; +import org.lwjgl.openal.AL; +import org.lwjgl.openal.AL10; +import org.lwjgl.opengl.AWTGLCanvas; +import org.lwjgl.opengl.Display; +import org.lwjgl.opengl.GL11; +import org.lwjgl.util.WaveData; + +public class OpenAL extends AWTGLCanvas implements Test { + + float angle = 0; + + // create 1 buffer and 1 source + IntBuffer buffers = BufferUtils.createIntBuffer(1); + IntBuffer sources = BufferUtils.createIntBuffer(1); + + public OpenAL() throws LWJGLException { + + try { + AL.create(); + } catch (Exception e) { + System.out.println("Unable to create OpenAL.\nPlease make sure that OpenAL is available on this system. Exception: " + e); + return; + } + + Thread t = new Thread() { + + public void run() { + while (true) { + if (isVisible()) + repaint(); + Display.sync(60); + } + } + }; + t.setDaemon(true); + t.start(); + } + + private void playOpenAL() { + int lastError; + + // al generate buffers and sources + buffers.position(0).limit(1); + AL10.alGenBuffers(buffers); + if((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) { + exit(lastError); + } + + sources.position(0).limit(1); + AL10.alGenSources(sources); + if((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) { + exit(lastError); + } + + // load wave data from buffer + WaveData wavefile = WaveData.create(getClass().getClassLoader().getResourceAsStream("Footsteps.wav")); + + //copy to buffers + AL10.alBufferData(buffers.get(0), wavefile.format, wavefile.data, wavefile.samplerate); + + //unload file again + wavefile.dispose(); + + if((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) { + exit(lastError); + } + + //set up source input + AL10.alSourcei(sources.get(0), AL10.AL_BUFFER, buffers.get(0)); + if((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) { + exit(lastError); + } + + //lets loop the sound + AL10.alSourcei(sources.get(0), AL10.AL_LOOPING, AL10.AL_TRUE); + if((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) { + exit(lastError); + } + + //play source 0 + AL10.alSourcePlay(sources.get(0)); + if((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) { + exit(lastError); + } + } + + private void exit(int error) { + System.out.println("OpenAL Error: " + AL10.alGetString(error)); + } + + public void paintGL() { + GL11.glClear(GL11.GL_COLOR_BUFFER_BIT); + GL11.glMatrixMode(GL11.GL_PROJECTION_MATRIX); + GL11.glLoadIdentity(); + GL11.glOrtho(0, 640, 0, 480, 1, -1); + GL11.glMatrixMode(GL11.GL_MODELVIEW_MATRIX); + + GL11.glPushMatrix(); + GL11.glTranslatef(320, 240, 0.0f); + GL11.glRotatef(angle, 0, 0, 1.0f); + GL11.glBegin(GL11.GL_QUADS); + GL11.glVertex2i(-50, -50); + GL11.glVertex2i(50, -50); + GL11.glVertex2i(50, 50); + GL11.glVertex2i(-50, 50); + GL11.glEnd(); + GL11.glPopMatrix(); + + angle += 1; + + try { + swapBuffers(); + } catch (Exception e) {/*OK*/ + } + } + + public void start() { + playOpenAL(); + } + + public void stop() { + int lastError; + + //stop source 0 + AL10.alSourceStop(sources.get(0)); + if((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) { + exit(lastError); + } + + //delete buffers and sources + sources.position(0).limit(1); + AL10.alDeleteSources(sources); + if((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) { + exit(lastError); + } + + buffers.position(0).limit(1); + AL10.alDeleteBuffers(buffers); + if((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) { + exit(lastError); + } + + AL.destroy(); + } +} diff --git a/src/java/org/lwjgl/test/applet/OpenGL.java b/src/java/org/lwjgl/test/applet/OpenGL.java new file mode 100644 index 0000000..88284c2 --- /dev/null +++ b/src/java/org/lwjgl/test/applet/OpenGL.java @@ -0,0 +1,128 @@ +/* + * 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.test.applet; + +import org.lwjgl.LWJGLException; +import org.lwjgl.input.Keyboard; +import org.lwjgl.input.Mouse; +import org.lwjgl.opengl.AWTGLCanvas; +import org.lwjgl.opengl.GL11; + +public class OpenGL extends AWTGLCanvas implements Test { + + float angle = 0; + float x; + float y; + + public OpenGL() throws LWJGLException { + } + + public void initGL() { + GL11.glMatrixMode(GL11.GL_PROJECTION_MATRIX); + GL11.glLoadIdentity(); + GL11.glOrtho(0, 640, 0, 480, 1, -1); + x = 320; + y = 240; + GL11.glMatrixMode(GL11.GL_MODELVIEW_MATRIX); + setVSyncEnabled(true); + } + + public void paintGL() { + GL11.glClear(GL11.GL_COLOR_BUFFER_BIT); + + GL11.glPushMatrix(); + GL11.glTranslatef(x, y, 0.0f); + GL11.glRotatef(angle, 0, 0, 1.0f); + GL11.glBegin(GL11.GL_QUADS); + GL11.glVertex2i(-50, -50); + GL11.glVertex2i(50, -50); + GL11.glVertex2i(50, 50); + GL11.glVertex2i(-50, 50); + GL11.glEnd(); + GL11.glPopMatrix(); + + angle += 1; + + if (Mouse.isCreated()) { + Mouse.poll(); + while (Mouse.next()) { + x += Mouse.getEventDX(); + y += Mouse.getEventDY(); + } + } + if (Keyboard.isCreated()) { + Keyboard.poll(); + } + while (Keyboard.isCreated() && Keyboard.next()) { + if (Keyboard.getEventKey() != Keyboard.KEY_NONE) { + String key_name = Keyboard.getKeyName(Keyboard.getEventKey()); + if (Keyboard.getEventKeyState()) { + switch (Keyboard.getEventKey()) { + case Keyboard.KEY_G: + Mouse.setGrabbed(!Mouse.isGrabbed()); + break; + default: + break; + } + System.out.println("Pressed: " + key_name); + } else + System.out.println("Released: " + key_name); + } + if (Keyboard.getEventCharacter() != Keyboard.CHAR_NONE) + System.out.println("Typed: " + Keyboard.getEventCharacter()); + } + if (Keyboard.isCreated()) { + if (Keyboard.isKeyDown(Keyboard.KEY_UP)) + y += 5; + else if (Keyboard.isKeyDown(Keyboard.KEY_DOWN)) + y -= 5; + if (Keyboard.isKeyDown(Keyboard.KEY_LEFT)) + x -= 5; + else if (Keyboard.isKeyDown(Keyboard.KEY_RIGHT)) + x += 5; + } + try { + swapBuffers(); + if (isVisible()) { + Thread.yield(); // Helps input responsiveness on linux + repaint(); + } + } catch (Exception e) {/*OK*/ + } + } + + public void start() { + } + + public void stop() { + } +} diff --git a/src/java/org/lwjgl/test/applet/Speed.java b/src/java/org/lwjgl/test/applet/Speed.java new file mode 100644 index 0000000..3c42ed7 --- /dev/null +++ b/src/java/org/lwjgl/test/applet/Speed.java @@ -0,0 +1,91 @@ +/* + * 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.test.applet; + +import org.lwjgl.LWJGLException; +import org.lwjgl.opengl.AWTGLCanvas; +import org.lwjgl.opengl.GL11; + +public class Speed extends AWTGLCanvas implements Test { + + private float angle = 0; + private long startTime = System.currentTimeMillis() + 5000; + private long fps = 0; + + public Speed() throws LWJGLException { + } + + public void paintGL() { + GL11.glClear(GL11.GL_COLOR_BUFFER_BIT); + GL11.glMatrixMode(GL11.GL_PROJECTION_MATRIX); + GL11.glLoadIdentity(); + GL11.glOrtho(0, 640, 0, 480, 1, -1); + GL11.glMatrixMode(GL11.GL_MODELVIEW_MATRIX); + + GL11.glPushMatrix(); + GL11.glTranslatef(320, 240, 0.0f); + GL11.glRotatef(angle, 0, 0, 1.0f); + GL11.glBegin(GL11.GL_QUADS); + GL11.glVertex2i(-50, -50); + GL11.glVertex2i(50, -50); + GL11.glVertex2i(50, 50); + GL11.glVertex2i(-50, 50); + GL11.glEnd(); + GL11.glPopMatrix(); + + angle += 1; + + try { + swapBuffers(); + if (isVisible()) { + Thread.yield(); // Helps input responsiveness on linux + repaint(); + } + } catch (Exception e) {/*OK*/ + } + if (startTime > System.currentTimeMillis()) { + fps++; + } else { + long timeUsed = 5000 + (startTime - System.currentTimeMillis()); + startTime = System.currentTimeMillis() + 5000; + System.out.println(fps + " frames in " + (float) (timeUsed / 1000f) + " seconds = " + + (fps / (timeUsed / 1000f))); + fps = 0; + } + } + + public void start() { + } + + public void stop() { + } +} diff --git a/src/java/org/lwjgl/test/applet/Test.java b/src/java/org/lwjgl/test/applet/Test.java new file mode 100644 index 0000000..35a79f1 --- /dev/null +++ b/src/java/org/lwjgl/test/applet/Test.java @@ -0,0 +1,38 @@ +/* + * 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.test.applet; + + +public interface Test { + public void start(); + public void stop(); +} diff --git a/src/java/org/lwjgl/test/glu/tessellation/TessCallback.java b/src/java/org/lwjgl/test/glu/tessellation/TessCallback.java new file mode 100644 index 0000000..15253d3 --- /dev/null +++ b/src/java/org/lwjgl/test/glu/tessellation/TessCallback.java @@ -0,0 +1,80 @@ +/* + * 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.test.glu.tessellation; + +import org.lwjgl.opengl.GL11; +import org.lwjgl.util.glu.GLUtessellatorCallbackAdapter; + +public class TessCallback extends GLUtessellatorCallbackAdapter { + + public void begin(int type) { + GL11.glBegin(type); + } + + public void combine(double[] coords, Object[] data, float[] weight, Object[] outData) { + for (int i=0;i + * @version $Revision: 2983 $ + * $Id: HWCursorTest.java 2983 2008-04-07 18:36:09Z matzon $ + */ +public class HWCursorTest { + + /** The native cursor */ + private static Cursor[] cursor = null; + + /** The mouse cursor position */ + private static int mouse_x; + private static int mouse_y; + private static int mouse_btn = 0; + + /** + * Executes the test + */ + public void execute() { + initialize(); + + mainLoop(); + + cleanup(); + } + + /** + * Sets the display mode for fullscreen mode + */ + protected boolean setDisplayMode() { + try { + // get modes + DisplayMode[] dm = org.lwjgl.util.Display.getAvailableDisplayModes(640, 480, -1, -1, -1, -1, 60, 60); + + org.lwjgl.util.Display.setDisplayMode(dm, new String[] { + "width=" + 640, + "height=" + 480, + "freq=" + 60, + "bpp=" + org.lwjgl.opengl.Display.getDisplayMode().getBitsPerPixel() + }); + return true; + } catch (Exception e) { + e.printStackTrace(); + } + + return false; + } + + /** + * Initializes the test + */ + private void initialize() { + try { + // start of in windowed mode + setDisplayMode(); + Display.create(); + + glInit(); + + initNativeCursors(); + + } catch (Exception e) { + e.printStackTrace(); + System.exit(-1); + } + } + + private static void initNativeCursors() throws Exception { + if ((Cursor.getCapabilities() & Cursor.CURSOR_ONE_BIT_TRANSPARENCY) == 0) { + System.out.println("No HW cursor support!"); + System.exit(0); + } + + cursor = new Cursor[3]; + + int cursorImageCount = 1; + int cursorWidth = Math.min(64, Cursor.getMaxCursorSize()); + int cursorHeight = cursorWidth; + IntBuffer cursorImages; + IntBuffer cursorDelays; + + + // Create a single cursor + // ================================== + cursorImages = ByteBuffer.allocateDirect(cursorWidth*cursorHeight*cursorImageCount*4).order(ByteOrder.nativeOrder()).asIntBuffer(); + cursorDelays = null; + for(int j=0; j= centerLeft && j < centerRight && l >= centerLeft && l < centerRight) { + cursorImages.put(offColor); + } else { + cursorImages.put(onColor); + } + } + } + } + cursorDelays.put(2000).put(2000).put(2000); + cursorDelays.flip(); + cursorImages.flip(); + + cursor[1] = new Cursor(cursorWidth, cursorHeight, cursorWidth/2, cursorHeight/2, cursorImageCount, cursorImages, cursorDelays); + // ---------------------------------- + + + // Create a 20 piece animation + // ================================== + cursorImageCount = 20; + cursorImages = ByteBuffer.allocateDirect(cursorWidth*cursorHeight*cursorImageCount*4).order(ByteOrder.nativeOrder()).asIntBuffer(); + cursorDelays = ByteBuffer.allocateDirect(cursorImageCount*4).order(ByteOrder.nativeOrder()).asIntBuffer(); + cursorDelays.put( + new int[] { + 100, 100, 100, 100, 100, + 100, 100, 100, 100, 100, + 100, 100, 100, 100, 100, + 100, 100, 100, 100, 100 + }); + + float step = 0xffffffff / 20.0f; + for(int i=0; i= 0 && button < 3 && Mouse.getEventButtonState()) { + mouse_btn = Mouse.getEventButton(); + switchCursor(); + } + } + } + + /** + * Processes keyboard input + */ + private void processKeyboard() { + //check for fullscreen key + if (Keyboard.isKeyDown(Keyboard.KEY_F)) { + + try { + try { + Mouse.setNativeCursor(null); + } catch (Exception e) { + e.printStackTrace(); + System.exit(1); + } + for(int i=0; i + * Keyboard test + * + * @author Brian Matzon + * @version $Revision: 3042 $ + * $Id: KeyboardTest.java 3042 2008-04-22 21:26:39Z elias_naur $ + */ +public class KeyboardTest { + + /** position of quad to draw */ + private Vector2f position = new Vector2f(320.0f, 240.0f); + + /** Display mode selected */ + private DisplayMode displayMode; + + /** Creates a new instance of MouseTest */ + public KeyboardTest() { + } + + private void initialize() { + // create display and opengl + setupDisplay(false); + + try { + Keyboard.create(); + } catch (Exception e) { + e.printStackTrace(); + System.exit(-1); + } + } + + /** + * Sets the display mode for fullscreen mode + */ + protected boolean setDisplayMode() { + try { + // get modes + DisplayMode[] dm = org.lwjgl.util.Display.getAvailableDisplayModes(640, 480, -1, -1, -1, -1, 60, 60); + + org.lwjgl.util.Display.setDisplayMode(dm, new String[] { + "width=" + 640, + "height=" + 480, + "freq=" + 60, + "bpp=" + org.lwjgl.opengl.Display.getDisplayMode().getBitsPerPixel() + }); + return true; + } catch (Exception e) { + e.printStackTrace(); + } + + return false; + } + + private void setupDisplay(boolean fullscreen) { + try { + setDisplayMode(); + Display.create(); + } catch (Exception e) { + e.printStackTrace(); + System.exit(-1); + } + + initializeOpenGL(); + } + + private void initializeOpenGL() { + GL11.glMatrixMode(GL11.GL_PROJECTION); + GL11.glLoadIdentity(); + GLU.gluOrtho2D(0, Display.getDisplayMode().getWidth(), 0, Display.getDisplayMode().getHeight()); + GL11.glMatrixMode(GL11.GL_MODELVIEW); + GL11.glLoadIdentity(); + GL11.glViewport(0, 0, Display.getDisplayMode().getWidth(), Display.getDisplayMode().getHeight()); + GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); + } + + public void executeTest() { + initialize(); + + createKeyboard(); + + wiggleKeyboard(); + + Keyboard.destroy(); + Display.destroy(); + } + + private void createKeyboard() { + try { + Keyboard.create(); + } catch (Exception e) { + e.printStackTrace(); + System.exit(-1); + } + } + + private void wiggleKeyboard() { + + while (!Display.isCloseRequested()) { + Display.update(); + + if (!Display.isVisible()) { + try { + Thread.sleep(100); + } catch (InterruptedException inte) { + inte.printStackTrace(); + } + continue; + } + + //check keys, buffered + Keyboard.poll(); + + int count = Keyboard.getNumKeyboardEvents(); + while (Keyboard.next()) { + int character_code = ((int)Keyboard.getEventCharacter()) & 0xffff; + System.out.println("Checking key:" + Keyboard.getKeyName(Keyboard.getEventKey())); + System.out.println("Pressed:" + Keyboard.getEventKeyState()); + System.out.println("Key character code: 0x" + Integer.toHexString(character_code)); + System.out.println("Key character: " + Keyboard.getEventCharacter()); + System.out.println("Repeat event: " + Keyboard.isRepeatEvent()); + + if (Keyboard.getEventKey() == Keyboard.KEY_R && Keyboard.getEventKeyState()) { + Keyboard.enableRepeatEvents(!Keyboard.areRepeatEventsEnabled()); + } + if (Keyboard.getEventKey() == Keyboard.KEY_ESCAPE) { + return; + } + } + if (Keyboard.isKeyDown(Keyboard.KEY_RIGHT)) { + position.x += 1; + } + + if (Keyboard.isKeyDown(Keyboard.KEY_LEFT)) { + position.x -= 1; + } + + if (Keyboard.isKeyDown(Keyboard.KEY_UP)) { + position.y += 1; + } + + if (Keyboard.isKeyDown(Keyboard.KEY_DOWN)) { + position.y -= 1; + } + + if (count > 0) { + System.out.println(); + } + + if (position.x < 0) { + position.x = 0; + } else if (position.x > 640 - 60) { + position.x = 640 - 60; + } + + if (position.y < 0) { + position.y = 0; + } else if (position.y > 480 - 30) { + position.y = 480 - 30; + } + + render(); + + try { + Thread.sleep(0); + } catch (Exception e) { + } + } + } + + private void render() { + GL11.glClear(GL11.GL_COLOR_BUFFER_BIT); + + GL11.glBegin(GL11.GL_POLYGON); + { + float color = 1.0f; + GL11.glColor3f(color, color, color); + + GL11.glVertex2f(position.x + 0.0f, position.y + 0.0f); + GL11.glVertex2f(position.x + 0.0f, position.y + 30.0f); + GL11.glVertex2f(position.x + 40.0f, position.y + 30.0f); + GL11.glVertex2f(position.x + 60.0f, position.y + 15.f); + GL11.glVertex2f(position.x + 40.0f, position.y + 0.0f); + } + GL11.glEnd(); + } + + /** + * @param args the command line arguments + */ + public static void main(String[] args) { + KeyboardTest kt = new KeyboardTest(); + kt.executeTest(); + System.exit(0); + } +} diff --git a/src/java/org/lwjgl/test/input/MouseCreationTest.java b/src/java/org/lwjgl/test/input/MouseCreationTest.java new file mode 100644 index 0000000..8e3553b --- /dev/null +++ b/src/java/org/lwjgl/test/input/MouseCreationTest.java @@ -0,0 +1,217 @@ +/* + * 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.test.input; + +import org.lwjgl.Sys; +import org.lwjgl.input.Mouse; +import org.lwjgl.opengl.Display; +import org.lwjgl.opengl.DisplayMode; +import org.lwjgl.opengl.GL11; +import org.lwjgl.util.vector.Vector2f; + +/** + *
    + * Mouse test + * + * @author Brian Matzon + * @version $Revision: 3108 $ + * $Id: MouseCreationTest.java 3108 2008-07-02 20:00:49Z matzon $ + */ +public class MouseCreationTest { + /** position of quad to draw */ + private Vector2f position = new Vector2f(320.0f, 240.0f); + + /** Creates a new instance of MouseTest */ + public MouseCreationTest() { + } + + private void initialize(boolean fullscreen) { + try { + setDisplayMode(); + Display.setFullscreen(fullscreen); + Display.create(); + Mouse.setGrabbed(true); + } catch (Exception e) { + e.printStackTrace(); + System.exit(-1); + } + + initializeOpenGL(); + } + + /** + * Sets the display mode for fullscreen mode + */ + protected boolean setDisplayMode() { + try { + // get modes + DisplayMode[] dm = org.lwjgl.util.Display.getAvailableDisplayModes(640, 480, -1, -1, -1, -1, 60, 60); + + org.lwjgl.util.Display.setDisplayMode(dm, new String[] { + "width=" + 640, + "height=" + 480, + "freq=" + 60, + "bpp=" + org.lwjgl.opengl.Display.getDisplayMode().getBitsPerPixel() + }); + return true; + } catch (Exception e) { + e.printStackTrace(); + } + + return false; + } + + private void initializeOpenGL() { + GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); + // Put the window into orthographic projection mode with 1:1 pixel ratio. + // We haven't used GLU here to do this to avoid an unnecessary dependency. + GL11.glMatrixMode(GL11.GL_PROJECTION); + GL11.glLoadIdentity(); + GL11.glOrtho(0.0, Display.getDisplayMode().getWidth(), 0.0, Display.getDisplayMode().getHeight(), -1.0, 1.0); + GL11.glMatrixMode(GL11.GL_MODELVIEW); + GL11.glLoadIdentity(); + GL11.glViewport(0, 0, Display.getDisplayMode().getWidth(), Display.getDisplayMode().getHeight()); + } + + public void executeTest() { + initialize(false); + + System.out.println("Test ready:\n"); + + // windowed mode + System.out.println("=========== WINDOWED MODE =============="); + for(int i=0; i<2; i++) { + System.out.println("Test " + (i+1) + ":"); + wiggleMouse(); + System.out.println(""); + } + + // recreate display in fullscreen mode + System.out.print("Destroying display..."); + + System.out.println("success"); + + System.out.print("Entering fullscreen mode..."); + try { + Display.destroy(); + initialize(true); + } catch (Exception e) { + e.printStackTrace(); + } + System.out.println("success"); + + + // fullscreen mode + System.out.println("=========== FULLSCREEN MODE =============="); + for(int i=0; i<2; i++) { + System.out.println("Test " + (i+3) + ":"); + wiggleMouse(); + System.out.println(""); + } + + System.out.println("Test completed successfully!"); + System.out.print("Shutting down..."); + Display.destroy(); + System.out.println("shutdown complete"); + } + + private void wiggleMouse() { + System.out.print("Please move the mouse around"); + + long statustime = Sys.getTime(); + long endtime = Sys.getTime() + Sys.getTimerResolution() * 5; + + while (Sys.getTime() < endtime) { + Display.update(); + + // empty mouse buffer + while(Mouse.next()); + + position.x += Mouse.getDX(); + position.y += Mouse.getDY(); + + if(position.x<0) { + position.x = 0; + } else if (position.x>640-60) { + position.x = 640-60; + } + + if(position.y < 0) { + position.y = 0; + } else if (position.y>480-30) { + position.y = 480-30; + } + + render(); + + if (Sys.getTime() - statustime > Sys.getTimerResolution()) { + System.out.print("."); + statustime = Sys.getTime(); + } + } + System.out.println("thank you"); + } + + private void render() { + GL11.glClear(GL11.GL_COLOR_BUFFER_BIT); + + GL11.glBegin(GL11.GL_POLYGON); + { + float color = 1.0f; + int buttonDown = 0; + + for(int i=0;i + * Mouse test + * + * @author Brian Matzon + * @version $Revision: 3240 $ + * $Id: MouseTest.java 3240 2009-09-12 22:15:21Z matzon $ + */ +public class MouseTest { + /** Direction mouse has moved */ + private int direction; + + /** Last button pressed */ + private int lastButton = 0; + + /** Last direction we scrolled in */ + private int lastScrollDirection = -1; + + /** Width of window */ + private static int WINDOW_WIDTH = 640; + + /** Height of window */ + private static int WINDOW_HEIGHT = 640; + + /** Triangle size */ + private Vector2f triangleSize = new Vector2f(120, 100); + + /** Triangle color */ + private Vector3f triangleColor[] = new Vector3f[] { + new Vector3f(1,1,1), + new Vector3f(1,0,0), + new Vector3f(0,1,0), + new Vector3f(0,0,1) + }; + + private Vector3f quadColor[] = new Vector3f[] { + new Vector3f(1,1,1), + new Vector3f(1,0,0), + new Vector3f(0,1,0), + new Vector3f(0,0,1) + }; + + /** Triangles to paint */ + private Vector2f[] triangles = { + new Vector2f(WINDOW_WIDTH/2, WINDOW_HEIGHT - triangleSize.y), + new Vector2f(triangleSize.y, WINDOW_HEIGHT/2), + new Vector2f(WINDOW_WIDTH/2, triangleSize.y), + new Vector2f(WINDOW_WIDTH-triangleSize.y, WINDOW_HEIGHT/2) + }; + + /** Whether the test is closing */ + private boolean closing = false; + + /** Fullscreen or not */ + public static final boolean FULLSCREEN = false; + + /** Creates a new instance of MouseTest */ + public MouseTest() { + } + + private void initialize() { + // create display and opengl + setupDisplay(); + + setupMouse(); + setupKeyboard(); + } + + /** + * Setup display + */ + private void setupDisplay() { + try { + setDisplayMode(); + Display.setFullscreen(FULLSCREEN); + Display.setVSyncEnabled(true); + Display.create(); + Mouse.setGrabbed(true); + } catch (Exception e) { + e.printStackTrace(); + System.exit(-1); + } + + initializeOpenGL(); + } + + /** + * Sets the display mode for fullscreen mode + */ + protected boolean setDisplayMode() { + // get modes + DisplayMode dm = new DisplayMode(WINDOW_WIDTH, WINDOW_HEIGHT); + + try { + Display.setDisplayMode(dm); + return true; + } catch (Exception e) { + e.printStackTrace(); + } + + return false; + } + + /** + * Initializes OpenGL + * + */ + private void initializeOpenGL() { + GL11.glMatrixMode(GL11.GL_PROJECTION); + GL11.glLoadIdentity(); + GLU.gluOrtho2D(0, Display.getDisplayMode().getWidth(), 0, Display.getDisplayMode().getHeight()); + GL11.glMatrixMode(GL11.GL_MODELVIEW); + GL11.glLoadIdentity(); + GL11.glViewport(0, 0, Display.getDisplayMode().getWidth(), Display.getDisplayMode().getHeight()); + GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); + } + + /** + * Executes the actual test + */ + public void executeTest() { + initialize(); + + runTest(); + + Display.destroy(); + } + + /** + * Creates the mouse + */ + private void setupMouse() { + } + + /** + * Creates the keyboard + */ + private void setupKeyboard() { + } + + /** + * Runs the test + */ + private void runTest() { + // while not exiting + while (!closing) { + handleWindow(); + + // secondary check + if(!closing) { + + // poll and check keyboard and mouse + handleKeyboard(); + handleMouse(); + + // pause and continue if minimized + if(!Display.isVisible()) { + if(Display.isDirty()) { + render(); + } + pause(100); + continue; + } + + // render and flip + logic(); + render(); + } + Thread.yield(); + } + } + + /** + * Pauses the current thread for a specified time + * + * @param time milliseconds to pause + */ + private void pause(long time) { + try { + Thread.sleep(time); + } catch (InterruptedException inte) { + inte.printStackTrace(); + } + } + + /** + * Handles the window + */ + private void handleWindow() { + Display.update(); + closing = Display.isCloseRequested(); + } + + /** + * handles the mouse + */ + private void handleMouse() { + readBufferedMouse(); + + Display.setTitle("x: " + Mouse.getX() + ", y: " + Mouse.getY() + ", [0]: " + Mouse.isButtonDown(0) + ", [1]: " + Mouse.isButtonDown(1) + ", [2]: " + Mouse.isButtonDown(2) + ", inside: " + Mouse.isInsideWindow()); + } + + /** + * reads a mouse in buffered mode + */ + private void readBufferedMouse() { + // iterate all events, use the last button down + while(Mouse.next()) { + if(Mouse.getEventButton() != -1 && Mouse.getEventButtonState()) { + lastButton = Mouse.getEventButton(); + } + } + + updateState(); + } + + /** + * Updates our "model" + * + */ + private void updateState() { + direction = -1; + + int dx = Mouse.getDX(); + int dy = Mouse.getDY(); + int dw = Mouse.getDWheel(); + + + // get out if no movement + if (dx == dy && dx == 0 && dw == 0) { + return; + } + + // determine direction moved + // ============================ + if(dx > 0) { + direction = 3; + } + + if(dx < 0) { + direction = 1; + } + + if(dy > 0) { + direction = 0; + } + + if(dy < 0) { + direction = 2; + } + + // ---------------------------- + if(direction > -1) { + + // based on which button was last pushed, update model + switch(lastButton) { + case -1: + break; + case 1: + triangleColor[direction].y = 1; + break; + case 2: + triangleColor[direction].z = 1; + break; + case 3: + triangleColor[direction].x = 1; + triangleColor[direction].y = 1; + triangleColor[direction].z = 1; + break; + case 0: // fall through + default: + triangleColor[direction].x = 1; + break; + } + } + + // get direction to update in + if (dw > 0) { + lastScrollDirection++; + } else if (dw < 0) { + lastScrollDirection--; + } else if (dw == 0) { + return; + } + + // over/underflow + if(lastScrollDirection < 0) { + lastScrollDirection = 3; + } + if(lastScrollDirection > 3) { + lastScrollDirection = 0; + } + + // update colors + quadColor[lastScrollDirection].x = (float) Math.random(); + quadColor[lastScrollDirection].y = (float) Math.random(); + quadColor[lastScrollDirection].z = (float) Math.random(); + } + + /** + * Handles the keyboard + */ + private void handleKeyboard() { + + while(Keyboard.next()) { + // closing on ESCAPE + if(Keyboard.getEventKey() == Keyboard.KEY_ESCAPE && Keyboard.getEventKeyState()) { + closing = true; + } + + if(Keyboard.getEventKey() == Keyboard.KEY_SPACE && Keyboard.getEventKeyState()) { + Mouse.setGrabbed(!Mouse.isGrabbed()); + } + } + } + + /** + * Does the "model logic" + */ + private void logic() { + // "we fade to black" + // =========================================== + for(int i=0; i + * @version $Revision: 2286 $ + * $Id: ALCTest.java 2286 2006-03-23 19:32:21Z matzon $ + */ +public class ALCCaptureTest extends BasicTest { + + /** + * Creates an instance of ALCTest + */ + public ALCCaptureTest() { + super(); + } + + /** + * Runs the actual test, using supplied arguments + */ + protected void execute(String[] args) { + int lastError = ALC10.ALC_NO_ERROR; + IntBuffer sampleCount = BufferUtils.createIntBuffer(1); + + int state = AL10.AL_PLAYING; + int FMT = AL10.AL_FORMAT_MONO16; + int FMTSIZE = 16/8; + int FREQ = 44100; + int TIME = 5; + int SAMPS = (FREQ * TIME); + ByteBuffer buf = BufferUtils.createByteBuffer(SAMPS * FMTSIZE); + + // check that capture is available + if(!ALC10.alcIsExtensionPresent(AL.getDevice(), "ALC_EXT_CAPTURE")) { + throw new OpenALException("ALC_EXT_CAPTURE extension not available"); + } + + // get list of devices + String[] captureDevices = ALC10.alcGetString(null, ALC11.ALC_CAPTURE_DEVICE_SPECIFIER).split("\0"); + System.out.println("Available Capture Devices: "); + for(int i=0; i + * @version $Revision: 2983 $ + * $Id: ALCTest.java 2983 2008-04-07 18:36:09Z matzon $ + */ +public class ALCTest extends BasicTest { + + /** + * Creates an instance of ALCTest + */ + public ALCTest() { + super(); + } + + /** + * Runs the actual test, using supplied arguments + */ + protected void execute(String[] args) { + //error stuff + int lastError = ALC10.ALC_NO_ERROR; + + //create attribute list for context creation + IntBuffer buffer = BufferUtils.createIntBuffer(7); + + if ((lastError = ALC10.alcGetError(AL.getDevice())) != ALC10.ALC_NO_ERROR) { + System.out.println("ALC Error: " + ALC10.alcGetString(AL.getDevice(), lastError)); + System.exit(-1); + } + + //query + System.out.println( + "DEFAULT_DEVICE_SPECIFIER: " + + ALC10.alcGetString(AL.getDevice(), ALC10.ALC_DEFAULT_DEVICE_SPECIFIER)); + System.out.println( + "DEVICE_SPECIFIER: " + ALC10.alcGetString(AL.getDevice(), ALC10.ALC_DEVICE_SPECIFIER)); + System.out.println("EXTENSIONS: " + ALC10.alcGetString(AL.getDevice(), ALC10.ALC_EXTENSIONS)); + + //mo query + buffer.rewind(); + buffer.position(0); + ALC10.alcGetInteger(AL.getDevice(), ALC10.ALC_MAJOR_VERSION, buffer); + ALC10.alcGetInteger(AL.getDevice(), ALC10.ALC_MINOR_VERSION, (IntBuffer) buffer.position(1)); + + System.out.println("ALC_MAJOR_VERSION: " + buffer.get(0)); + System.out.println("ALC_MINOR_VERSION: " + buffer.get(1)); + + //no check for ALC_ALL_ATTRIBUTES / ALC_ATTRIBUTES_SIZE since it + //is buggy on win32 - my dev platform + + //get an enumerstion value + System.out.println( + "Value of ALC_MAJOR_VERSION: " + + ALC10.alcGetEnumValue(AL.getDevice(), "ALC_MAJOR_VERSION")); + + alExit(); + } + + /** + * main entry point + * + * @param args String array containing arguments + */ + public static void main(String[] args) { + ALCTest alcTest = new ALCTest(); + alcTest.execute(args); + System.exit(0); + } +} \ No newline at end of file diff --git a/src/java/org/lwjgl/test/openal/BasicTest.java b/src/java/org/lwjgl/test/openal/BasicTest.java new file mode 100644 index 0000000..8ca68de --- /dev/null +++ b/src/java/org/lwjgl/test/openal/BasicTest.java @@ -0,0 +1,140 @@ +/* + * 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.test.openal; + +import java.nio.FloatBuffer; + +import org.lwjgl.BufferUtils; +import org.lwjgl.openal.AL; +import org.lwjgl.openal.AL10; +import org.lwjgl.openal.ALC10; +import org.lwjgl.opengl.DisplayMode; + +/** + * + * This is a basic test, which contains the most used stuff + * + * @author Brian Matzon + * @version $Revision: 2983 $ + * $Id: BasicTest.java 2983 2008-04-07 18:36:09Z matzon $ + */ +public abstract class BasicTest { + + /** + * Creates an instance of PlayTest + */ + public BasicTest() { + try { + AL.create(); + + System.out.println("Default device: " + ALC10.alcGetString(null, ALC10.ALC_DEFAULT_DEVICE_SPECIFIER)); + + if(ALC10.alcIsExtensionPresent(null, "ALC_ENUMERATION_EXT")) { + String[] devices = ALC10.alcGetString(null, ALC10.ALC_DEVICE_SPECIFIER).split("\0"); + System.out.println("Available devices: "); + for(int i=0; i + * @version $Revision: 2983 $ + * $Id: MovingSoundTest.java 2983 2008-04-07 18:36:09Z matzon $ + */ +public class MovingSoundTest extends BasicTest { + + public static float MOVEMENT = 50.00f; + + /** + * Creates an instance of MovingSoundTest + */ + public MovingSoundTest() { + super(); + } + + /** + * Runs the actual test, using supplied arguments + */ + protected void execute(String[] args) { + if (args.length < 1) { + System.out.println("no argument supplied, assuming Footsteps.wav"); + args = new String[] {"Footsteps.wav"}; + } + + try { + setDisplayMode(); + Display.create(); + } catch (Exception e) { + e.printStackTrace(); + } + + + int lastError; + Vector3f sourcePosition = new Vector3f(); + Vector3f listenerPosition = new Vector3f(); + + //initialize keyboard + try { + Keyboard.create(); + } catch (Exception e) { + e.printStackTrace(); + exit(-1); + } + + //create 1 buffer and 1 source + IntBuffer buffers = BufferUtils.createIntBuffer(1); + IntBuffer sources = BufferUtils.createIntBuffer(1); + + // al generate buffers and sources + buffers.position(0).limit(1); + AL10.alGenBuffers(buffers); + if ((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) { + exit(lastError); + } + + sources.position(0).limit(1); + AL10.alGenSources(sources); + if ((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) { + exit(lastError); + } + + //load wave data + WaveData wavefile = WaveData.create(args[0]); + + //copy to buffers + AL10.alBufferData( + buffers.get(0), + wavefile.format, + wavefile.data, + wavefile.samplerate); + if ((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) { + exit(lastError); + } + + //unload file again + wavefile.dispose(); + + //set up source input + AL10.alSourcei(sources.get(0), AL10.AL_BUFFER, buffers.get(0)); + if ((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) { + exit(lastError); + } + + AL10.alSourcef(sources.get(0), AL10.AL_REFERENCE_DISTANCE, 1024.0f); + AL10.alSourcef(sources.get(0), AL10.AL_ROLLOFF_FACTOR, 0.5f); + + //lets loop the sound + AL10.alSourcei(sources.get(0), AL10.AL_LOOPING, AL10.AL_TRUE); + if ((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) { + exit(lastError); + } + + //play source 0 + AL10.alSourcePlay(sources.get(0)); + if ((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) { + exit(lastError); + } + + System.out.println("Move source with arrow keys\nMove listener with right shift and arrowkeys\nExit with ESC"); + + while(!Keyboard.isKeyDown(Keyboard.KEY_ESCAPE)) { + Display.update(); + + Keyboard.poll(); + if(Keyboard.isKeyDown(Keyboard.KEY_LEFT)) { + if(Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) { + listenerPosition.x -= MOVEMENT; + AL10.alListener3f(AL10.AL_POSITION, listenerPosition.x, listenerPosition.y, listenerPosition.z); + System.out.println("listenerx: " + listenerPosition.x); + } else { + sourcePosition.x -= MOVEMENT; + AL10.alSource3f(sources.get(0), AL10.AL_POSITION, sourcePosition.x, sourcePosition.y, sourcePosition.z); + System.out.println("sourcex: " + sourcePosition.x); + } + } + if(Keyboard.isKeyDown(Keyboard.KEY_RIGHT)) { + if(Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) { + listenerPosition.x += MOVEMENT; + AL10.alListener3f(AL10.AL_POSITION, listenerPosition.x, listenerPosition.y, listenerPosition.z); + System.out.println("listenerx: " + listenerPosition.x); + } else { + sourcePosition.x += MOVEMENT; + AL10.alSource3f(sources.get(0), AL10.AL_POSITION, sourcePosition.x, sourcePosition.y, sourcePosition.z); + System.out.println("sourcex: " + sourcePosition.x); + } + } + + if(Display.isCloseRequested()) { + break; + } + + try { + Thread.sleep(100); + } catch (InterruptedException inte) { + } + } + + //stop source 0 + AL10.alSourceStop(sources.get(0)); + if ((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) { + exit(lastError); + } + + //delete buffers and sources + sources.position(0).limit(1); + AL10.alDeleteSources(sources); + if ((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) { + exit(lastError); + } + + buffers.position(0).limit(1); + AL10.alDeleteBuffers(buffers); + if ((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) { + exit(lastError); + } + + //shutdown + alExit(); + } + + /** + * main entry point + * + * @param args String array containing arguments + */ + public static void main(String[] args) { + MovingSoundTest movingSoundTest = new MovingSoundTest(); + movingSoundTest.execute(args); + System.exit(0); + } +} diff --git a/src/java/org/lwjgl/test/openal/OpenALCreationTest.java b/src/java/org/lwjgl/test/openal/OpenALCreationTest.java new file mode 100644 index 0000000..959a78e --- /dev/null +++ b/src/java/org/lwjgl/test/openal/OpenALCreationTest.java @@ -0,0 +1,225 @@ +/* + * 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.test.openal; + +import java.nio.ByteBuffer; +import java.nio.ByteOrder; +import java.nio.IntBuffer; + +import org.lwjgl.openal.AL; +import org.lwjgl.openal.AL10; +import org.lwjgl.util.WaveData; + +/** + *
    + * Performs a creation test, by creating and destroying OpenAL twice. + * We cannot inherit from BasicTest since it follows another structure. + * + * @author Brian Matzon + * @version $Revision: 2983 $ + * $Id: OpenALCreationTest.java 2983 2008-04-07 18:36:09Z matzon $ + */ +public class OpenALCreationTest { + + /** + * Creates an instance of OpenALCreationTest + */ + public OpenALCreationTest() { + } + + public void alInitialize() { + try { + AL.create(); + } catch (Exception e) { + e.printStackTrace(); + return; + } + } + + public void alExit() { + AL.destroy(); + } + + /** + * Creates an integer buffer to hold specified ints + * - strictly a utility method + * + * @param size how many int to contain + * @return created IntBuffer + */ + protected IntBuffer createIntBuffer(int size) { + ByteBuffer temp = ByteBuffer.allocateDirect(4 * size); + temp.order(ByteOrder.nativeOrder()); + + return temp.asIntBuffer(); + } + + /** + * Exits the test NOW, printing errorcode to stdout + * + * @param error Error code causing exit + */ + protected void exit(int error) { + System.out.println("OpenAL Error: " + AL10.alGetString(error)); + alExit(); + System.exit(-1); + } + + /** + * Runs the actual test, using supplied arguments + */ + protected void execute(String[] args) { + int lastError; + + //initialize AL, using ALC + System.out.print("initialize..."); + alInitialize(); + System.out.println("success"); + + //do some audio + executeAudioTest(); + + //shutdown + System.out.print("shutdown..."); + alExit(); + System.out.println("success"); + + //initialize AL, using ALC + System.out.print("initialize..."); + alInitialize(); + System.out.println("success"); + + //do some audio + executeAudioTest(); + + //shutdown + System.out.print("shutdown..."); + alExit(); + System.out.println("success"); + } + + /** + * Executes the audio test, which just plays some sound + */ + private void executeAudioTest() { + int lastError; + + //create 1 buffer and 1 source + IntBuffer buffers = createIntBuffer(1); + IntBuffer sources = createIntBuffer(1); + + // al generate buffers and sources + buffers.position(0).limit(1); + AL10.alGenBuffers(buffers); + if ((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) { + exit(lastError); + } + + sources.position(0).limit(1); + AL10.alGenSources(sources); + if ((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) { + exit(lastError); + } + + //load wave data + WaveData wavefile = WaveData.create("Footsteps.wav"); + + //copy to buffers + AL10.alBufferData( + buffers.get(0), + wavefile.format, + wavefile.data, + wavefile.samplerate); + if ((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) { + exit(lastError); + } + + //unload file again + wavefile.dispose(); + + //set up source input + AL10.alSourcei(sources.get(0), AL10.AL_BUFFER, buffers.get(0)); + if ((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) { + exit(lastError); + } + + //lets loop the sound + AL10.alSourcei(sources.get(0), AL10.AL_LOOPING, AL10.AL_TRUE); + if ((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) { + exit(lastError); + } + + //play source 0 + AL10.alSourcePlay(sources.get(0)); + if ((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) { + exit(lastError); + } + + //wait 5 secs + try { + System.out.print("Playing 'Footsteps.wav' for 2 seconds..."); + Thread.sleep(2000); + } catch (InterruptedException inte) { + } + System.out.println("done"); + + //stop source 0 + AL10.alSourceStop(sources.get(0)); + if ((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) { + exit(lastError); + } + + //delete buffers and sources + sources.position(0).limit(1); + AL10.alDeleteSources(sources); + if ((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) { + exit(lastError); + } + + buffers.position(0).limit(1); + AL10.alDeleteBuffers(buffers); + if ((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) { + exit(lastError); + } + } + + /** + * main entry point + * + * @param args String array containing arguments + */ + public static void main(String[] args) { + OpenALCreationTest oalCreationTest = new OpenALCreationTest(); + oalCreationTest.execute(args); + System.exit(0); + } +} diff --git a/src/java/org/lwjgl/test/openal/OpenALInfo.java b/src/java/org/lwjgl/test/openal/OpenALInfo.java new file mode 100644 index 0000000..8ef5f2c --- /dev/null +++ b/src/java/org/lwjgl/test/openal/OpenALInfo.java @@ -0,0 +1,173 @@ +/* + * 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.test.openal; + +import java.nio.IntBuffer; + +import org.lwjgl.BufferUtils; +import org.lwjgl.LWJGLException; +import org.lwjgl.openal.AL; +import org.lwjgl.openal.AL10; +import org.lwjgl.openal.ALC10; +import org.lwjgl.openal.ALC11; +import org.lwjgl.openal.ALCdevice; + +/** + * + * idea from openal-info + * + * @author Brian Matzon + * @version $Revision: 2983 $ + * $Id$ + */ +public class OpenALInfo { + + /** + * Creates an instance of OpenALInfo + */ + public OpenALInfo() { + } + + /** + * Runs the actual test, using supplied arguments + */ + protected void execute(String[] args) { + try { + AL.create(null, -1, 60, false); + checkForErrors(); + } catch (LWJGLException le) { + die("Init", le.getMessage()); + } + + printALCInfo(); + printALInfo(); + + checkForErrors(); + + AL.destroy(); + } + + private void printALCInfo() { + IntBuffer version = BufferUtils.createIntBuffer(2); + ALCdevice device; + + if(ALC10.alcIsExtensionPresent(null, "ALC_ENUMERATION_EXT")) { + if(ALC10.alcIsExtensionPresent(null, "ALC_ENUMERATE_ALL_EXT")) { + printDevices(ALC11.ALC_ALL_DEVICES_SPECIFIER, "playback"); + } else { + printDevices(ALC10.ALC_DEVICE_SPECIFIER, "playback"); + } + printDevices(ALC11.ALC_CAPTURE_DEVICE_SPECIFIER, "capture"); + } else { + System.out.println("No device enumeration available"); + } + + device = ALC10.alcGetContextsDevice(ALC10.alcGetCurrentContext()); + checkForErrors(); + + System.out.println("Default device: " + ALC10.alcGetString(device, ALC10.ALC_DEFAULT_DEVICE_SPECIFIER)); + + System.out.println("Default capture device: " + ALC10.alcGetString(device, ALC11.ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER)); + + ALC10.alcGetInteger(AL.getDevice(), ALC10.ALC_MAJOR_VERSION, version); + ALC10.alcGetInteger(AL.getDevice(), ALC10.ALC_MINOR_VERSION, (IntBuffer) version.position(1)); + checkForErrors(); + + System.out.println("ALC version: " + (int)version.get(0) + "." + (int)version.get(1)); + + System.out.println("ALC extensions:"); + String[] extensions = ALC10.alcGetString(device, ALC10.ALC_EXTENSIONS).split(" "); + for(int i=0; i + * @version $Revision: 2983 $ + * $Id: PlayTest.java 2983 2008-04-07 18:36:09Z matzon $ + */ +public class PlayTest extends BasicTest { + + private boolean usingVorbis; + + /** + * Creates an instance of PlayTest + */ + public PlayTest() { + super(); + } + + /** + * Runs the actual test, using supplied arguments + */ + protected void execute(String[] args) { + if(args.length < 1) { + System.out.println("no argument supplied, assuming Footsteps.wav"); + args = new String[] {"Footsteps.wav"}; + } + + if(args[0].endsWith(".ogg")) { + System.out.print("Attempting to load Ogg Vorbis file, checking for extension..."); + if(AL10.alIsExtensionPresent("AL_EXT_vorbis")) { + System.out.println("found"); + usingVorbis = true; + } else { + System.out.println("not supported"); + alExit(); + System.exit(-1); + } + } + + int lastError; + + //create 1 buffer and 1 source + IntBuffer buffers = BufferUtils.createIntBuffer(1); + IntBuffer sources = BufferUtils.createIntBuffer(1); + + // al generate buffers and sources + buffers.position(0).limit(1); + AL10.alGenBuffers(buffers); + if((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) { + exit(lastError); + } + + sources.position(0).limit(1); + AL10.alGenSources(sources); + if((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) { + exit(lastError); + } + + if(usingVorbis) { + ByteBuffer filebuffer = getData(args[0]); + + // pass directly to buffer data + AL10.alBufferData(buffers.get(0), AL10.AL_FORMAT_VORBIS_EXT, filebuffer, -1); + filebuffer.clear(); + } else { + // load wave data from buffer + WaveData wavefile = WaveData.create(args[0]); + + //copy to buffers + AL10.alBufferData(buffers.get(0), wavefile.format, wavefile.data, wavefile.samplerate); + + //unload file again + wavefile.dispose(); + } + + if((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) { + exit(lastError); + } + + //set up source input + AL10.alSourcei(sources.get(0), AL10.AL_BUFFER, buffers.get(0)); + if((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) { + exit(lastError); + } + + //lets loop the sound + AL10.alSourcei(sources.get(0), AL10.AL_LOOPING, AL10.AL_TRUE); + if((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) { + exit(lastError); + } + + //play source 0 + AL10.alSourcePlay(sources.get(0)); + if((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) { + exit(lastError); + } + + //wait 5 secs + try { + System.out.println("Waiting 5 seconds for sound to complete"); + Thread.sleep(5000); + } catch (InterruptedException inte) { + } + + //stop source 0 + AL10.alSourceStop(sources.get(0)); + if((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) { + exit(lastError); + } + + //delete buffers and sources + sources.position(0).limit(1); + AL10.alDeleteSources(sources); + if((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) { + exit(lastError); + } + + buffers.position(0).limit(1); + AL10.alDeleteBuffers(buffers); + if((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) { + exit(lastError); + } + + //no errorchecking from now on, since our context is gone. + //shutdown + alExit(); + } + + /** + * Reads the file into a ByteBuffer + * + * @param filename Name of file to load + * @return ByteBuffer containing file data + */ + protected ByteBuffer getData(String filename) { + ByteBuffer buffer = null; + + System.out.println("Attempting to load: " + filename); + + try { + BufferedInputStream bis = new BufferedInputStream(WaveData.class.getClassLoader().getResourceAsStream(filename)); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + + int bufferLength = 4096; + byte[] readBuffer = new byte[bufferLength]; + int read = -1; + + while((read = bis.read(readBuffer, 0, bufferLength)) != -1) { + baos.write(readBuffer, 0, read); + } + + //done reading, close + bis.close(); + + // if ogg vorbis data, we need to pass it unmodified to alBufferData + buffer = ByteBuffer.allocateDirect(baos.size()); + buffer.order(ByteOrder.nativeOrder()); + buffer.put(baos.toByteArray()); + buffer.rewind(); + } catch (Exception ioe) { + ioe.printStackTrace(); + } + return buffer; + } + + /** + * main entry point + * + * @param args String array containing arguments + */ + public static void main(String[] args) { + PlayTest playTest = new PlayTest(); + playTest.execute(args); + System.exit(0); + } +} diff --git a/src/java/org/lwjgl/test/openal/PlayTestMemory.java b/src/java/org/lwjgl/test/openal/PlayTestMemory.java new file mode 100644 index 0000000..aedc4c4 --- /dev/null +++ b/src/java/org/lwjgl/test/openal/PlayTestMemory.java @@ -0,0 +1,234 @@ +/* + * 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.test.openal; + +import java.io.BufferedInputStream; +import java.io.ByteArrayOutputStream; +import java.nio.ByteBuffer; +import java.nio.ByteOrder; +import java.nio.IntBuffer; + +import org.lwjgl.BufferUtils; +import org.lwjgl.openal.AL10; +import org.lwjgl.util.WaveData; + +/** + * + * This is a basic play test + * Yes, over zealous use of getError ;) + * + * @author Brian Matzon + * @version $Revision: 2983 $ + * $Id: PlayTestMemory.java 2983 2008-04-07 18:36:09Z matzon $ + */ +public class PlayTestMemory extends BasicTest { + + private boolean usingVorbis; + + /** + * Creates an instance of PlayTestMemory + */ + public PlayTestMemory() { + super(); + } + + /** + * Runs the actual test, using supplied arguments + */ + protected void execute(String[] args) { + if(args.length < 1) { + System.out.println("no argument supplied, assuming Footsteps.wav"); + args = new String[] {"Footsteps.wav"}; + } + + if(args[0].endsWith(".ogg")) { + System.out.print("Attempting to load Ogg Vorbis file, checking for extension..."); + if(AL10.alIsExtensionPresent("AL_EXT_vorbis")) { + System.out.println("found"); + usingVorbis = true; + } else { + System.out.println("not supported"); + alExit(); + System.exit(-1); + } + } + + int lastError; + + //create 1 buffer and 1 source + IntBuffer buffers = BufferUtils.createIntBuffer(1); + IntBuffer sources = BufferUtils.createIntBuffer(1); + + // al generate buffers and sources + buffers.position(0).limit(1); + AL10.alGenBuffers(buffers); + if((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) { + exit(lastError); + } + + sources.position(0).limit(1); + AL10.alGenSources(sources); + if((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) { + exit(lastError); + } + + //load wave data + ByteBuffer filebuffer = getData(args[0]); + if(filebuffer == null) { + System.out.println("Error loading file: " + args[0]); + System.exit(-1); + } + + System.out.println("loaded " + filebuffer.capacity()); + + //ALUTLoadWAVData file = alut.loadWAVMemory(Sys.getDirectBufferAddress(filebuffer)); + if(usingVorbis) { + // pass directly to buffer data + AL10.alBufferData(buffers.get(0), AL10.AL_FORMAT_VORBIS_EXT, filebuffer, -1); + filebuffer.clear(); + } else { + // load wave data from buffer + WaveData wavefile = WaveData.create(filebuffer.array()); + + //copy to buffers + AL10.alBufferData(buffers.get(0), wavefile.format, wavefile.data, wavefile.samplerate); + + //unload file again + wavefile.dispose(); + } + + // check for errors + if((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) { + exit(lastError); + } + + + //set up source input + AL10.alSourcei(sources.get(0), AL10.AL_BUFFER, buffers.get(0)); + if((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) { + exit(lastError); + } + + //lets loop the sound + AL10.alSourcei(sources.get(0), AL10.AL_LOOPING, AL10.AL_TRUE); + if((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) { + exit(lastError); + } + + //play source 0 + AL10.alSourcePlay(sources.get(0)); + if((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) { + exit(lastError); + } + + //wait 5 secs + try { + System.out.println("Waiting 5 seconds for sound to complete"); + Thread.sleep(5000); + } catch (InterruptedException inte) { + } + + //stop source 0 + AL10.alSourceStop(sources.get(0)); + if((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) { + exit(lastError); + } + + //delete buffers and sources + sources.position(0).limit(1); + AL10.alDeleteSources(sources); + if((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) { + exit(lastError); + } + + buffers.position(0).limit(1); + AL10.alDeleteBuffers(buffers); + if((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) { + exit(lastError); + } + + //no errorchecking from now on, since our context is gone. + alExit(); + } + + /** + * Reads the file into a ByteBuffer + * + * @param filename Name of file to load + * @return ByteBuffer containing file data + */ + protected ByteBuffer getData(String filename) { + ByteBuffer buffer = null; + + System.out.println("Attempting to load: " + filename); + + try { + BufferedInputStream bis = new BufferedInputStream(WaveData.class.getClassLoader().getResourceAsStream(filename)); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + + int bufferLength = 4096; + byte[] readBuffer = new byte[bufferLength]; + int read = -1; + + while((read = bis.read(readBuffer, 0, bufferLength)) != -1) { + baos.write(readBuffer, 0, read); + } + + //done reading, close + bis.close(); + + // if ogg vorbis data, we need to pass it unmodified to alBufferData + if(usingVorbis) { + buffer = ByteBuffer.allocateDirect(baos.size()); + } else { + buffer = ByteBuffer.allocate(baos.size()); + } + buffer.order(ByteOrder.nativeOrder()); + buffer.put(baos.toByteArray()); + buffer.rewind(); + } catch (Exception ioe) { + ioe.printStackTrace(); + } + return buffer; + } + + /** + * main entry point + * + * @param args String array containing arguments + */ + public static void main(String[] args) { + PlayTestMemory playTestMemory = new PlayTestMemory(); + playTestMemory.execute(args); + System.exit(0); + } +} diff --git a/src/java/org/lwjgl/test/openal/PositionTest.java b/src/java/org/lwjgl/test/openal/PositionTest.java new file mode 100644 index 0000000..18feffa --- /dev/null +++ b/src/java/org/lwjgl/test/openal/PositionTest.java @@ -0,0 +1,552 @@ +/* + * 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.test.openal; + +import java.nio.FloatBuffer; +import java.nio.IntBuffer; + +import org.lwjgl.BufferUtils; +import org.lwjgl.LWJGLUtil; +import org.lwjgl.input.Keyboard; +import org.lwjgl.input.Mouse; +import org.lwjgl.openal.AL; +import org.lwjgl.openal.AL10; +import org.lwjgl.opengl.Display; +import org.lwjgl.opengl.GL11; +import org.lwjgl.util.glu.GLU; +import org.lwjgl.util.WaveData; + +/** + *
    + * This test demonstrates OpenAL positioning Based on the example by Chad Armstrong + * (http://www.edenwaith.com/products/pige/tutorials/openal.php) + * + * @author Brian Matzon + * @version $Revision: 2983 $ + * $Id: PositionTest.java 2983 2008-04-07 18:36:09Z matzon $ + */ +public class PositionTest extends BasicTest { + + /** *Small* glut implementation :) */ + private GLUT glut; + + /** Width of window */ + public static final int WINDOW_WIDTH = 640; + + /** Height of window */ + public static final int WINDOW_HEIGHT = 480; + + /** LEFT enumeration */ + public static final int LEFT = 0; + + /** CENTER enumeration */ + public static final int CENTER = 1; + + /** RIGHT enumeration */ + public static final int RIGHT = 2; + + /** Whether the demo is done */ + private boolean finished = false; + + /** Whether in pause mode */ + private boolean pauseMode = false; + + // OpenAL stuff + // =================================================== + + /** OpenAL buffers */ + private IntBuffer soundBuffers = BufferUtils.createIntBuffer(3); + + /** OpenAL sources */ + private IntBuffer soundSources = BufferUtils.createIntBuffer(3); + + /** Position of listener */ + private FloatBuffer listenerPosition = createFloatBuffer(new float[] { 0.0f, 0.0f, 0.0f }); + + /** Velocity of listener */ + private FloatBuffer listenerVelocity = createFloatBuffer(new float[] { 0.0f, 0.0f, 0.0f }); + + /** Orientation of listener */ + private FloatBuffer listenerOrientation = + createFloatBuffer(new float[] { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f }); + + /** Position of left sound */ + private FloatBuffer leftPosition = createFloatBuffer(new float[] { -2.0f, 0.0f, 0.0f }); + + /** Velocity of left sound */ + private FloatBuffer leftVelocity = createFloatBuffer(new float[] { 0.0f, 0.0f, 0.0f }); + + /** Position of center sound */ + private FloatBuffer centerPosition = createFloatBuffer(new float[] { 0.0f, 0.0f, -4.0f }); + + /** Velocity of center sound */ + private FloatBuffer centerVelocity = createFloatBuffer(new float[] { 0.0f, 0.0f, 0.0f }); + + /** Position of right sound */ + private FloatBuffer rightPosition = createFloatBuffer(new float[] { 2.0f, 0.0f, 0.0f }); + + /** Velocity of right sound */ + private FloatBuffer rightVelocity = createFloatBuffer(new float[] { 0.0f, 0.0f, 0.0f }); + // --------------------------------------------------- + + /** + * Runs the actual test, using supplied arguments + */ + protected void execute(String[] args) { + // Setup needed stuff + try { + setup(); + } catch (Exception e) { + System.out.println("Error setting up demonstration: "); + e.printStackTrace(); + System.exit(-1); + } + + // run the actual demonstration + run(); + + // shutdown + shutdown(); + } + + /** + * Performs setup of demonstration + */ + private void setup() throws Exception { + + // Setup Window + // ===================================================== + LWJGLUtil.log("Setting up window"); + + // calc center + int centerX = (Display.getDisplayMode().getWidth() - WINDOW_WIDTH) / 2; + int centerY = (Display.getDisplayMode().getHeight() - WINDOW_HEIGHT) / 2; + + // setup window + setDisplayMode(); + Display.create(); + // ----------------------------------------------------- + + // Setup OpenGL + // ===================================================== + LWJGLUtil.log("Setting up OpenGL"); + + GL11.glViewport(0, 0, WINDOW_WIDTH, WINDOW_HEIGHT); + GL11.glMatrixMode(GL11.GL_PROJECTION); + GL11.glLoadIdentity(); + GLU.gluPerspective(50.0f, (float) WINDOW_WIDTH / WINDOW_HEIGHT, 0.0f, 50.0f); + GL11.glMatrixMode(GL11.GL_MODELVIEW); + GL11.glLoadIdentity(); + GL11.glTranslatef(0.0f, 0.0f, -6.6f); + GL11.glClearColor(0.0f, 0.0f, 0.0f, 1.0f); + glut = this.new GLUT(); + + Display.setVSyncEnabled(true); + // ----------------------------------------------------- + + // Setup OpenAL + // ===================================================== + LWJGLUtil.log("Setting up OpenAL"); + + AL10.alListener(AL10.AL_POSITION, listenerPosition); + AL10.alListener(AL10.AL_VELOCITY, listenerVelocity); + AL10.alListener(AL10.AL_ORIENTATION, listenerOrientation); + + // creating buffers + LWJGLUtil.log("Creating buffers"); + AL10.alGenBuffers(soundBuffers); + soundBuffers.rewind(); + + // creating sources + AL10.alGenSources(soundSources); + soundSources.rewind(); + + // load sound files (left, center, right).wav + LWJGLUtil.log("Loading soundfiles..."); + + LWJGLUtil.log("Loading left.wav"); + WaveData left = WaveData.create("left.wav"); + AL10.alBufferData(soundBuffers.get(LEFT), left.format, left.data, left.samplerate); + AL10.alSourcef(soundSources.get(LEFT), AL10.AL_PITCH, 1.0f); + AL10.alSourcef(soundSources.get(LEFT), AL10.AL_GAIN, 1.0f); + AL10.alSource(soundSources.get(LEFT), AL10.AL_POSITION, leftPosition); + AL10.alSource(soundSources.get(LEFT), AL10.AL_VELOCITY, leftVelocity); + AL10.alSourcei(soundSources.get(LEFT), AL10.AL_BUFFER, soundBuffers.get(LEFT)); + AL10.alSourcei(soundSources.get(LEFT), AL10.AL_LOOPING, AL10.AL_TRUE); + + LWJGLUtil.log("Loading center.wav"); + WaveData center = WaveData.create("center.wav"); + AL10.alBufferData(soundBuffers.get(CENTER), center.format, center.data, center.samplerate); + AL10.alSourcef(soundSources.get(CENTER), AL10.AL_PITCH, 1.0f); + AL10.alSourcef(soundSources.get(CENTER), AL10.AL_GAIN, 1.0f); + AL10.alSource(soundSources.get(CENTER), AL10.AL_POSITION, centerPosition); + AL10.alSource(soundSources.get(CENTER), AL10.AL_VELOCITY, centerVelocity); + AL10.alSourcei(soundSources.get(CENTER), AL10.AL_BUFFER, soundBuffers.get(CENTER)); + AL10.alSourcei(soundSources.get(CENTER), AL10.AL_LOOPING, AL10.AL_TRUE); + + LWJGLUtil.log("Loading right.wav"); + WaveData right = WaveData.create("right.wav"); + AL10.alBufferData(soundBuffers.get(RIGHT), right.format, right.data, right.samplerate); + AL10.alSourcef(soundSources.get(RIGHT), AL10.AL_PITCH, 1.0f); + AL10.alSourcef(soundSources.get(RIGHT), AL10.AL_GAIN, 1.0f); + AL10.alSource(soundSources.get(RIGHT), AL10.AL_POSITION, rightPosition); + AL10.alSource(soundSources.get(RIGHT), AL10.AL_VELOCITY, rightVelocity); + AL10.alSourcei(soundSources.get(RIGHT), AL10.AL_BUFFER, soundBuffers.get(RIGHT)); + AL10.alSourcei(soundSources.get(RIGHT), AL10.AL_LOOPING, AL10.AL_TRUE); + + LWJGLUtil.log("Soundfiles loaded successfully"); + // ----------------------------------------------------- + + Mouse.setGrabbed(true); + } + + /** + * Runs the actual demonstration + */ + private void run() { + boolean firstRun = true; + + System.out.println("Press 1/4 (left), 2/5 (center) or 3/6 (right) to toggle sound"); + System.out.println("Press LEFT/RIGHT to move along x axis"); + System.out.println("Press SHIFT and either UP/DOWN to move along y axis"); + System.out.println("Press UP/DOWN to move along z axis"); + System.out.println("Move along the x and y axis with the mouse"); + System.out.println("Press LEFT or RIGHT mouse button to move along z axis"); + System.out.println("Press ESC to exit demo"); + + LWJGLUtil.log( + "Listener position: " + + listenerPosition.get(0) + + ", " + + listenerPosition.get(1) + + ", " + + listenerPosition.get(2)); + LWJGLUtil.log("Left position: " + leftPosition.get(0) + ", " + leftPosition.get(1) + ", " + leftPosition.get(2)); + LWJGLUtil.log("Center position: " + centerPosition.get(0) + ", " + centerPosition.get(1) + ", " + centerPosition.get(2)); + LWJGLUtil.log("Right position: " + rightPosition.get(0) + ", " + rightPosition.get(1) + ", " + rightPosition.get(2)); + + while (!finished) { + // handle any input + handleInput(); + + // allow window to process internal messages + Display.update(); + + // render and paint if !minimized and not dirty + if(Display.isVisible()) { + render(); + } else { + // sleeeeeep + pause(100); + } + + // act on pause mode + paused(!(Display.isVisible() || Display.isActive())); + + // start sound after first paint, since we don't want + // the delay before something is painted on the screen + if (firstRun && !pauseMode) { + firstRun = false; + + // start sounds with delays + startSounds(); + } + } + } + + /** + * Starts playing the sounds at different times + */ + private void startSounds() { + AL10.alSourcePlay(soundSources.get(LEFT)); + pause(300); + AL10.alSourcePlay(soundSources.get(CENTER)); + pause(500); + AL10.alSourcePlay(soundSources.get(RIGHT)); + } + + /** + * Handles any changes in pause mode + * + * @param paused Which pause mode to enter + */ + private void paused(boolean paused) { + // if requesting pause, and not paused - pause and stop sound + if(paused && !pauseMode) { + pauseMode = true; + AL10.alSourcePause(soundSources); + System.out.println("pauseMode = true"); + } + + // else go out of pause mode and start sounds + else if(!paused && pauseMode) { + pauseMode = false; + startSounds(); + System.out.println("pauseMode = false"); + } + } + + /** + * Handles any input + */ + private void handleInput() { + // User wants to exit? + finished = Display.isCloseRequested() || Keyboard.isKeyDown(Keyboard.KEY_ESCAPE); + if (finished) { + return; + } + + boolean shift = Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT); + + // Test for play + // ============================================ + if (Keyboard.isKeyDown(Keyboard.KEY_1)) { + AL10.alSourcePlay(soundSources.get(LEFT)); + LWJGLUtil.log("Playing left.wav"); + } + + if (Keyboard.isKeyDown(Keyboard.KEY_2)) { + AL10.alSourcePlay(soundSources.get(CENTER)); + LWJGLUtil.log("Playing center.wav"); + } + + if (Keyboard.isKeyDown(Keyboard.KEY_3)) { + AL10.alSourcePlay(soundSources.get(RIGHT)); + LWJGLUtil.log("Playing right.wav"); + } + // -------------------------------------------- + + // Test for stop + // ============================================ + if (Keyboard.isKeyDown(Keyboard.KEY_4)) { + AL10.alSourceStop(soundSources.get(LEFT)); + LWJGLUtil.log("Stopped left.wav"); + } + + if (Keyboard.isKeyDown(Keyboard.KEY_5)) { + AL10.alSourceStop(soundSources.get(CENTER)); + LWJGLUtil.log("Stopped center.wav"); + } + + if (Keyboard.isKeyDown(Keyboard.KEY_6)) { + AL10.alSourceStop(soundSources.get(RIGHT)); + LWJGLUtil.log("Stopped right.wav"); + } + // -------------------------------------------- + + // Test for movement with keyboard + // ============================================ + if (Keyboard.isKeyDown(Keyboard.KEY_LEFT)) { + listenerPosition.put(0, listenerPosition.get(0) - 0.1f); + AL10.alListener(AL10.AL_POSITION, listenerPosition); + } + + if (Keyboard.isKeyDown(Keyboard.KEY_RIGHT)) { + listenerPosition.put(0, listenerPosition.get(0) + 0.1f); + AL10.alListener(AL10.AL_POSITION, listenerPosition); + } + + if (Keyboard.isKeyDown(Keyboard.KEY_UP)) { + if (shift) { + listenerPosition.put(1, listenerPosition.get(1) + 0.1f); + } else { + listenerPosition.put(2, listenerPosition.get(2) - 0.1f); + } + AL10.alListener(AL10.AL_POSITION, listenerPosition); + } + + if (Keyboard.isKeyDown(Keyboard.KEY_DOWN)) { + if (shift) { + listenerPosition.put(1, listenerPosition.get(1) - 0.1f); + } else { + listenerPosition.put(2, listenerPosition.get(2) + 0.1f); + } + AL10.alListener(AL10.AL_POSITION, listenerPosition); + } + // -------------------------------------------- + + // Test for movement with Mouse + // ============================================ + listenerPosition.put(0, listenerPosition.get(0) + (0.01f * Mouse.getDX())); + listenerPosition.put(1, listenerPosition.get(1) + (0.01f * Mouse.getDY())); + if (Mouse.isButtonDown(0)) { + listenerPosition.put(2, listenerPosition.get(2) - 0.1f); + } + if (Mouse.isButtonDown(1)) { + listenerPosition.put(2, listenerPosition.get(2) + 0.1f); + } + + AL10.alListener(AL10.AL_POSITION, listenerPosition); + + // empty mouse buffer + while(Mouse.next()); + } + + /** + * Render the scene + */ + private void render() { + GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); + GL11.glPushMatrix(); + { + GL11.glRotatef(20.0f, 1.0f, 1.0f, 0.0f); + + // left + GL11.glPushMatrix(); + { + GL11.glTranslatef(leftPosition.get(0), leftPosition.get(1), leftPosition.get(2)); + GL11.glColor3f(1.0f, 0.0f, 0.0f); + glut.glutWireCube(0.5f); + } + GL11.glPopMatrix(); + + // center + GL11.glPushMatrix(); + { + GL11.glTranslatef(centerPosition.get(0), centerPosition.get(1), centerPosition.get(2)); + GL11.glColor3f(0.0f, 0.0f, 1.0f); + glut.glutWireCube(0.5f); + } + GL11.glPopMatrix(); + + // right + GL11.glPushMatrix(); + { + GL11.glTranslatef(rightPosition.get(0), rightPosition.get(1), rightPosition.get(2)); + GL11.glColor3f(0.0f, 1.0f, 0.0f); + glut.glutWireCube(0.5f); + } + GL11.glPopMatrix(); + + // listener + GL11.glPushMatrix(); + { + GL11.glTranslatef(listenerPosition.get(0), listenerPosition.get(1), listenerPosition.get(2)); + GL11.glColor3f(1.0f, 1.0f, 1.0f); + glut.glutSolidCube(0.5f); + } + GL11.glPopMatrix(); + } + GL11.glPopMatrix(); + } + + /** + * Shutdown of demonstration + */ + private void shutdown() { + LWJGLUtil.log("Shutting down OpenAL"); + AL10.alSourceStop(soundSources); + AL10.alDeleteSources(soundSources); + AL10.alDeleteBuffers(soundBuffers); + AL.destroy(); + + LWJGLUtil.log("Shutting down Window"); + Display.destroy(); + } + + /** + * main entry point + * + * @param args + * String array containing arguments + */ + public static void main(String[] args) { + PositionTest positionTest = new PositionTest(); + positionTest.execute(args); + System.exit(0); + } + + /** + * Minute implementation of GLUT:
    COPYRIGHT: + * + * The OpenGL Utility Toolkit distribution for Win32 (Windows NT & Windows + * 95) contains source code modified from the original source code for GLUT + * version 3.3 which was developed by Mark J. Kilgard. The original source + * code for GLUT is Copyright 1997 by Mark J. Kilgard. GLUT for Win32 is + * Copyright 1997 by Nate Robins and is not in the public domain, but it is + * freely distributable without licensing fees. It is provided without + * guarantee or warrantee expressed or implied. It was ported with the + * permission of Mark J. Kilgard by Nate Robins. + * + * THIS SOURCE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OR MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + */ + class GLUT { + + float n[][] = new float[][] { { -1.0f, 0.0f, 0.0f }, { + 0.0f, 1.0f, 0.0f }, { + 1.0f, 0.0f, 0.0f }, { + 0.0f, -1.0f, 0.0f }, { + 0.0f, 0.0f, 1.0f }, { + 0.0f, 0.0f, -1.0f } + }; + + int faces[][] = new int[][] { { 0, 1, 2, 3 }, { + 3, 2, 6, 7 }, { + 7, 6, 5, 4 }, { + 4, 5, 1, 0 }, { + 5, 6, 2, 1 }, { + 7, 4, 0, 3 } + }; + float v[][] = new float[8][3]; + + public void glutWireCube(float size) { + drawBox(size, GL11.GL_LINE_LOOP); + } + + public void glutSolidCube(float size) { + drawBox(size, GL11.GL_QUADS); + } + + private void drawBox(float size, int type) { + + v[0][0] = v[1][0] = v[2][0] = v[3][0] = -size / 2; + v[4][0] = v[5][0] = v[6][0] = v[7][0] = size / 2; + v[0][1] = v[1][1] = v[4][1] = v[5][1] = -size / 2; + v[2][1] = v[3][1] = v[6][1] = v[7][1] = size / 2; + v[0][2] = v[3][2] = v[4][2] = v[7][2] = -size / 2; + v[1][2] = v[2][2] = v[5][2] = v[6][2] = size / 2; + + for (int i = 5; i >= 0; i--) { + GL11.glBegin(type); + GL11.glNormal3f(n[i][0], n[i][1], n[i][2]); + GL11.glVertex3f(v[faces[i][0]][0], v[faces[i][0]][1], v[faces[i][0]][2]); + GL11.glVertex3f(v[faces[i][1]][0], v[faces[i][1]][1], v[faces[i][1]][2]); + GL11.glVertex3f(v[faces[i][2]][0], v[faces[i][2]][1], v[faces[i][2]][2]); + GL11.glVertex3f(v[faces[i][3]][0], v[faces[i][3]][1], v[faces[i][3]][2]); + GL11.glEnd(); + } + + } + } +} diff --git a/src/java/org/lwjgl/test/openal/SourceLimitTest.java b/src/java/org/lwjgl/test/openal/SourceLimitTest.java new file mode 100644 index 0000000..98e7a1b --- /dev/null +++ b/src/java/org/lwjgl/test/openal/SourceLimitTest.java @@ -0,0 +1,165 @@ +/* + * 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.test.openal; + +import java.nio.IntBuffer; + +import org.lwjgl.BufferUtils; +import org.lwjgl.openal.AL10; +import org.lwjgl.openal.OpenALException; + +/** + * + * Simple test for testing the number of available sources + * + * @author Brian Matzon + * @version $Revision: 2983 $ + * $Id: SourceLimitTest.java 2983 2008-04-07 18:36:09Z matzon $ + */ +public class SourceLimitTest extends BasicTest { + + /** Sources to create */ + protected int sourcesToCreate = 64; + + /** + * Creates an instance of SourceLimitTest + */ + public SourceLimitTest() { + super(); + } + + /** + * Runs the actual test, using supplied arguments + */ + protected void execute(String[] args) { + //parse 1st arg to sourcecount + if (args.length > 0) { + try { + sourcesToCreate = Integer.parseInt(args[0]); + } catch (NumberFormatException nfe) { + System.out.println( + "Unable to parse parameter to integer. Defaulting to 64 sources."); + } + } + + System.out.print("Creating " + sourcesToCreate + " in one go..."); + try { + CreateAllSources(); + } catch(OpenALException oale) { + oale.printStackTrace(); + } + + + System.out.print("Creating " + sourcesToCreate + " one at a time..."); + try { + CreateSourcesStep(); + } catch(Exception e) { + e.printStackTrace(); + } + //shutdown + alExit(); + } + + /** + * Tests the creation of n sources in on go + */ + protected void CreateAllSources() { + int lastError; + + //make bytbuffer that can hold sourcesToCreate sources + IntBuffer sources = BufferUtils.createIntBuffer(sourcesToCreate); + + //Create sourcesToCreate sources in one fell swoop + try { + sources.position(0).limit(sourcesToCreate); + AL10.alGenSources(sources); + + //delete sources + sources.position(0).limit(sourcesToCreate); + AL10.alDeleteSources(sources); + + System.out.println("created " + sourcesToCreate + " sources successfully!"); + } catch (OpenALException oale) { + System.out.println("Unable to create " + sourcesToCreate + " sources"); + } + } + + /** + * Tests if n sources can be created one at a time + */ + protected void CreateSourcesStep() { + int lastError; + int sourcesCreated = 0; + + //make bytbuffer that can hold sourcesToCreate sources + IntBuffer[] sources = new IntBuffer[sourcesToCreate]; + + //create the sources + try { + for (int i = 0; i < sourcesToCreate; i++) { + sources[i] = BufferUtils.createIntBuffer(1); + sources[i].position(0).limit(1); + AL10.alGenSources(sources[i]); + if ((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) { + break; + } + sourcesCreated++; + } + } catch (OpenALException oale) { + System.out.println("failed to create source: " + (sourcesCreated + 1)); + } + + //delete allocated sources + for (int i = 0; i < sourcesCreated; i++) { + //delete buffers and sources + sources[i].position(0).limit(1); + AL10.alDeleteSources(sources[i]); + } + + if(sourcesCreated != sourcesToCreate) { + System.out.println("created " + sourcesCreated + " sources before failing"); + } else { + System.out.println("created " + sourcesCreated + " sources successfully!"); + } + } + + /** + * main entry point + * + * @param args String array containing arguments + */ + public static void main(String[] args) { + SourceLimitTest sourceLimitTest = new SourceLimitTest(); + sourceLimitTest.execute(args); + System.exit(0); + } +} diff --git a/src/java/org/lwjgl/test/openal/StressTest.java b/src/java/org/lwjgl/test/openal/StressTest.java new file mode 100644 index 0000000..f67b7d8 --- /dev/null +++ b/src/java/org/lwjgl/test/openal/StressTest.java @@ -0,0 +1,223 @@ +/* + * 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.test.openal; + +import java.nio.IntBuffer; + +import org.lwjgl.BufferUtils; +import org.lwjgl.openal.AL10; +import org.lwjgl.util.WaveData; + +/** + * + * Simple test for stresstesting OpenAL playing random samples ad nausea + * + * @author Brian Matzon + * @version $Revision: 2983 $ + * $Id: StressTest.java 2983 2008-04-07 18:36:09Z matzon $ + */ +public class StressTest extends BasicTest { + + /** Buffer containing sources */ + private IntBuffer sources; + + /** Buffer containing buffers */ + private IntBuffer buffers; + + /** + * Creates an instance of StressTest + */ + public StressTest() { + super(); + } + + /** + * Runs the actual test, using supplied arguments + */ + protected void execute(String[] args) { + + createSources(); + + createBuffers(); + + try { + loadSamples(); + runTest(); + } catch (Exception e) { + e.printStackTrace(); + } + + + alExit(); + } + + private void createSources() { + sources = BufferUtils.createIntBuffer(4); + sources.position(0).limit(4); + AL10.alGenSources(sources); + if (AL10.alGetError() != AL10.AL_NO_ERROR) { + System.out.println("Unable to create 4 sources"); + alExit(); + } + } + + private void createBuffers() { + buffers = BufferUtils.createIntBuffer(10); + buffers.position(0).limit(10); + AL10.alGenBuffers(buffers); + if (AL10.alGetError() != AL10.AL_NO_ERROR) { + System.out.println("Unable to create 10 buffers"); + sources.position(0).limit(4); + AL10.alDeleteSources(sources); + alExit(); + } + } + + private void loadSamples() throws Exception { + AL10.alGetError(); + WaveData data = WaveData.create("ding.wav"); + for (int i = 1; i <= 10; i++) { + AL10.alBufferData( + buffers.get(i - 1), + data.format, + data.data, + data.samplerate); + + if (AL10.alGetError() != AL10.AL_NO_ERROR) { + System.out.println("Failed to load " + i + ".wav into buffer"); + sources.position(0).limit(4); + AL10.alDeleteSources(sources); + buffers.position(0).limit(10); + AL10.alDeleteBuffers(buffers); + + alExit(); + } + } + data.dispose(); + } + + public void runTest() { + int iterations = 0; + int randomBuffer; + int startSlot = 1; + int nextSlot = startSlot; + long startTime = System.currentTimeMillis(); + + //mark background source as looping + AL10.alSourcei(sources.get(0), AL10.AL_LOOPING, AL10.AL_TRUE); + + //play background + AL10.alSourcei(sources.get(0), AL10.AL_BUFFER, buffers.get(0)); + AL10.alSourcePlay(sources.get(0)); + + while (System.currentTimeMillis() - startTime < (2000)) { + + randomBuffer = getRandomBuffer(); + System.out.println("random:" + randomBuffer); + + //stop source at slot + AL10.alSourceStop(sources.get(nextSlot)); + if (AL10.alGetError() != AL10.AL_NO_ERROR) { + System.out.println("Error stopping source."); + } + System.out.println("Stopped source: " + nextSlot); + + //link source<->buffer + AL10.alSourcei(sources.get(nextSlot), AL10.AL_BUFFER, buffers.get(randomBuffer)); + if (AL10.alGetError() != AL10.AL_NO_ERROR) { + System.out.println("Error linking buffer and source."); + } + System.out.println("linked source " + nextSlot + " with buffer " + randomBuffer); + + //start playing + System.out.println("playing source " + nextSlot); + AL10.alSourcePlay(sources.get(nextSlot++)); + if (nextSlot == 4) { + nextSlot = startSlot; + } + + //pause + try { + Thread.sleep(500); + } catch (InterruptedException inte) { + } + + //debug info + if ((++iterations % 10) == 0) { + System.out.println("========================"); + System.out.println("MaxMemory: " + Runtime.getRuntime().maxMemory() / 1024); + System.out.println("FreeMemory: " + Runtime.getRuntime().freeMemory() / 1024); + System.out.println("TotalMemory: " + Runtime.getRuntime().totalMemory() / 1024); + System.out.println("========================"); + } + } + + //stop all sources + for (int i = 0; i < 4; i++) { + AL10.alSourceStop(sources.get(i)); + System.out.println("Stopping source " + (i+1)); + } + + //test done - ask for user input + try { + System.out.println("Test completed"); + System.out.println("========================"); + System.out.println("MaxMemory: " + Runtime.getRuntime().maxMemory() / 1024); + System.out.println("FreeMemory: " + Runtime.getRuntime().freeMemory() / 1024); + System.out.println("TotalMemory: " + Runtime.getRuntime().totalMemory() / 1024); + System.out.println("========================"); + System.out.println("Push any key to exit..."); + System.in.read(); + } catch (Exception e) { + } + + sources.position(0).limit(4); + AL10.alDeleteSources(sources); + buffers.position(0).limit(10); + AL10.alDeleteBuffers(buffers); + } + + private int getRandomBuffer() { + return (int) (Math.random() * 10.0); + } + + /** + * main entry point + * + * @param args String array containing arguments + */ + public static void main(String[] args) { + StressTest stressTest = new StressTest(); + stressTest.execute(args); + System.exit(0); + } +} diff --git a/src/java/org/lwjgl/test/opengl/FullScreenWindowedTest.java b/src/java/org/lwjgl/test/opengl/FullScreenWindowedTest.java new file mode 100644 index 0000000..d749c8a --- /dev/null +++ b/src/java/org/lwjgl/test/opengl/FullScreenWindowedTest.java @@ -0,0 +1,279 @@ +/* + * 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.test.opengl; + +import org.lwjgl.LWJGLException; +import org.lwjgl.input.Keyboard; +import org.lwjgl.opengl.Display; +import org.lwjgl.opengl.DisplayMode; +import org.lwjgl.opengl.GL11; +import org.lwjgl.util.glu.GLU; +import org.lwjgl.util.vector.Vector2f; + +/** + * + * Tests switching between windowed and fullscreen + * + * @author Brian Matzon + * @version $Revision: 3172 $ + * $Id: FullScreenWindowedTest.java 3172 2008-12-28 19:30:43Z elias_naur $ + */ +public class FullScreenWindowedTest { + /** Intended deiplay mode */ + private DisplayMode mode; + /** our quad moving around */ + private Vector2f quadPosition; + /** our quadVelocity */ + private Vector2f quadVelocity; + /** angle of quad */ + private float angle; + /** degrees to rotate per frame */ + private float angleRotation = 1.0f; + /** Max speed of all changable attributes */ + private static final float MAX_SPEED = 20.0f; + + /** + * Creates a FullScreenWindowedTest + */ + public FullScreenWindowedTest() { + } + /** + * Executes the test + */ + public void execute() { + initialize(); + mainLoop(); + cleanup(); + } + + private void switchMode() throws LWJGLException { + mode = findDisplayMode(800, 600, Display.getDisplayMode().getBitsPerPixel()); + Display.setDisplayModeAndFullscreen(mode); + } + + /** + * Initializes the test + */ + private void initialize() { + try { + //find displaymode + switchMode(); + // start of in windowed mode + Display.create(); + glInit(); + quadPosition = new Vector2f(100f, 100f); + quadVelocity = new Vector2f(1.0f, 1.0f); + } catch (Exception e) { + e.printStackTrace(); + } + } + /** + * Runs the main loop of the "test" + */ + private void mainLoop() { + while (!Keyboard.isKeyDown(Keyboard.KEY_ESCAPE) && !Display.isCloseRequested()) { + if (Display.isVisible()) { + // check keyboard input + processKeyboard(); + // do "game" logic, and render it + logic(); + render(); + } else { + // no need to render/paint if nothing has changed (ie. window + // dragged over) + if (Display.isDirty()) { + render(); + } + // don't waste cpu time, sleep more + try { + Thread.sleep(100); + } catch (InterruptedException inte) { + } + } + // Update window + Display.update(); + } + } + /** + * Performs the logic + */ + private void logic() { + angle += angleRotation; + if (angle > 90.0f) { + angle = 0.0f; + } + quadPosition.x += quadVelocity.x; + quadPosition.y += quadVelocity.y; + //check colision with vertical border border + if (quadPosition.x + 50 >= mode.getWidth() || quadPosition.x - 50 <= 0) { + quadVelocity.x *= -1; + } + //check collision with horizontal border + if (quadPosition.y + 50 >= mode.getHeight() || quadPosition.y - 50 <= 0) { + quadVelocity.y *= -1; + } + } + private void render() { + //clear background + GL11.glClear(GL11.GL_COLOR_BUFFER_BIT); + // draw white quad + GL11.glPushMatrix(); + { + GL11.glTranslatef(quadPosition.x, quadPosition.y, 0); + GL11.glRotatef(angle, 0.0f, 0.0f, 1.0f); + GL11.glColor3f(1.0f, 1.0f, 1.0f); + GL11.glBegin(GL11.GL_QUADS); + { + GL11.glVertex2i(-50, -50); + GL11.glVertex2i(50, -50); + GL11.glVertex2i(50, 50); + GL11.glVertex2i(-50, 50); + } + GL11.glEnd(); + } + GL11.glPopMatrix(); + } + /** + * Processes keyboard input + */ + private void processKeyboard() { + //check for fullscreen key + if (Keyboard.isKeyDown(Keyboard.KEY_F)) { + try { + switchMode(); + } catch (Exception e) { + e.printStackTrace(); + } + } + //check for window key + if (Keyboard.isKeyDown(Keyboard.KEY_W)) { + try { + mode = new DisplayMode(640, 480); + Display.setDisplayModeAndFullscreen(mode); + glInit(); + } catch (Exception e) { + e.printStackTrace(); + } + } + //check for speed changes + if (Keyboard.isKeyDown(Keyboard.KEY_UP)) { + quadVelocity.y += 0.1f; + } + if (Keyboard.isKeyDown(Keyboard.KEY_DOWN)) { + quadVelocity.y -= 0.1f; + } + if (Keyboard.isKeyDown(Keyboard.KEY_RIGHT)) { + quadVelocity.x += 0.1f; + } + if (Keyboard.isKeyDown(Keyboard.KEY_LEFT)) { + quadVelocity.x -= 0.1f; + } + if (Keyboard.isKeyDown(Keyboard.KEY_ADD)) { + angleRotation += 0.1f; + } + if (Keyboard.isKeyDown(Keyboard.KEY_SUBTRACT)) { + angleRotation -= 0.1f; + } + //throttle + if (quadVelocity.x < -MAX_SPEED) { + quadVelocity.x = -MAX_SPEED; + } + if (quadVelocity.x > MAX_SPEED) { + quadVelocity.x = MAX_SPEED; + } + if (quadVelocity.y < -MAX_SPEED) { + quadVelocity.y = -MAX_SPEED; + } + if (quadVelocity.y > MAX_SPEED) { + quadVelocity.y = MAX_SPEED; + } + if (angleRotation < 0.0f) { + angleRotation = 0.0f; + } + if (angleRotation > MAX_SPEED) { + angleRotation = MAX_SPEED; + } + } + /** + * Cleans up the test + */ + private void cleanup() { + Display.destroy(); + } + + /** + * Retrieves a displaymode, if one such is available + * + * @param width + * Required width + * @param height + * Required height + * @param bpp + * Minimum required bits per pixel + * @return + */ + private DisplayMode findDisplayMode(int width, int height, int bpp) throws LWJGLException { + DisplayMode[] modes = Display.getAvailableDisplayModes(); + for (int i = 0; i < modes.length; i++) { + if (modes[i].getWidth() == width && modes[i].getHeight() == height && modes[i].getBitsPerPixel() >= bpp && modes[i].getFrequency() <= 60) { + return modes[i]; + } + } + return Display.getDesktopDisplayMode(); + } + /** + * Initializes OGL + */ + private void glInit() { + // Go into orthographic projection mode. + GL11.glMatrixMode(GL11.GL_PROJECTION); + GL11.glLoadIdentity(); + GLU.gluOrtho2D(0, mode.getWidth(), 0, mode.getHeight()); + GL11.glMatrixMode(GL11.GL_MODELVIEW); + GL11.glLoadIdentity(); + GL11.glViewport(0, 0, mode.getWidth(), mode.getHeight()); + //set clear color to black + GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); + //sync frame (only works on windows) + Display.setVSyncEnabled(true); + } + /** + * Test entry point + */ + public static void main(String[] args) { + System.out.println("Change between fullscreen and windowed mode, by pressing F and W respectively"); + System.out.println("Move quad using arrowkeys, and change rotation using +/-"); + FullScreenWindowedTest fswTest = new FullScreenWindowedTest(); + fswTest.execute(); + System.exit(0); + } +} diff --git a/src/java/org/lwjgl/test/opengl/Gears.java b/src/java/org/lwjgl/test/opengl/Gears.java new file mode 100644 index 0000000..8ce8672 --- /dev/null +++ b/src/java/org/lwjgl/test/opengl/Gears.java @@ -0,0 +1,339 @@ +/* + * 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. + */ + +/* + * 3-D gear wheels. Originally by Brian Paul + */ +package org.lwjgl.test.opengl; + +import java.nio.FloatBuffer; + +import org.lwjgl.BufferUtils; +import org.lwjgl.LWJGLException; +import org.lwjgl.opengl.ARBTransposeMatrix; +import org.lwjgl.opengl.Display; +import org.lwjgl.opengl.DisplayMode; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GLContext; + +/** + *

    + * This is the OpenGL "standard" Gears demo, originally by Brian Paul + *

    + * @author Brian Matzon + * @version $Revision: 3276 $ + * $Id: Gears.java 3276 2010-02-21 21:18:17Z matzon $ + */ +public class Gears { + + private float view_rotx = 20.0f; + + private float view_roty = 30.0f; + + private float view_rotz = 0.0f; + + private int gear1; + + private int gear2; + + private int gear3; + + private float angle = 0.0f; + + public static void main(String[] args) { + new Gears().execute(); + System.exit(0); + } + + /** + * + */ + private void execute() { + try { + init(); + } catch (LWJGLException le) { + le.printStackTrace(); + System.out.println("Failed to initialize Gears."); + return; + } + + loop(); + + destroy(); + } + + /** + * + */ + private void destroy() { + Display.destroy(); + } + + /** + * + */ + private void loop() { + long startTime = System.currentTimeMillis() + 5000; + long fps = 0; + + while (!Display.isCloseRequested()) { + angle += 2.0f; + + GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); + + GL11.glPushMatrix(); + GL11.glRotatef(view_rotx, 1.0f, 0.0f, 0.0f); + GL11.glRotatef(view_roty, 0.0f, 1.0f, 0.0f); + GL11.glRotatef(view_rotz, 0.0f, 0.0f, 1.0f); + + GL11.glPushMatrix(); + GL11.glTranslatef(-3.0f, -2.0f, 0.0f); + GL11.glRotatef(angle, 0.0f, 0.0f, 1.0f); + GL11.glCallList(gear1); + GL11.glPopMatrix(); + + GL11.glPushMatrix(); + GL11.glTranslatef(3.1f, -2.0f, 0.0f); + GL11.glRotatef(-2.0f * angle - 9.0f, 0.0f, 0.0f, 1.0f); + GL11.glCallList(gear2); + GL11.glPopMatrix(); + + GL11.glPushMatrix(); + GL11.glTranslatef(-3.1f, 4.2f, 0.0f); + GL11.glRotatef(-2.0f * angle - 25.0f, 0.0f, 0.0f, 1.0f); + GL11.glCallList(gear3); + GL11.glPopMatrix(); + + GL11.glPopMatrix(); + + Display.update(); + if (startTime > System.currentTimeMillis()) { + fps++; + } else { + long timeUsed = 5000 + (startTime - System.currentTimeMillis()); + startTime = System.currentTimeMillis() + 5000; + System.out.println(fps + " frames in " + (float) (timeUsed / 1000f) + " seconds = " + + (fps / (timeUsed / 1000f))); + fps = 0; + } + } + } + + /** + * + */ + private void init() throws LWJGLException { + // create Window of size 300x300 + Display.setLocation((Display.getDisplayMode().getWidth() - 300) / 2, + (Display.getDisplayMode().getHeight() - 300) / 2); + Display.setDisplayMode(new DisplayMode(300, 300)); + Display.setTitle("Gears"); + Display.create(); + + // setup ogl + FloatBuffer pos = BufferUtils.createFloatBuffer(4).put(new float[] { 5.0f, 5.0f, 10.0f, 0.0f}); + FloatBuffer red = BufferUtils.createFloatBuffer(4).put(new float[] { 0.8f, 0.1f, 0.0f, 1.0f}); + FloatBuffer green = BufferUtils.createFloatBuffer(4).put(new float[] { 0.0f, 0.8f, 0.2f, 1.0f}); + FloatBuffer blue = BufferUtils.createFloatBuffer(4).put(new float[] { 0.2f, 0.2f, 1.0f, 1.0f}); + + pos.flip(); + red.flip(); + green.flip(); + blue.flip(); + + GL11.glLight(GL11.GL_LIGHT0, GL11.GL_POSITION, pos); + GL11.glEnable(GL11.GL_CULL_FACE); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_LIGHT0); + GL11.glEnable(GL11.GL_DEPTH_TEST); + + /* make the gears */ + gear1 = GL11.glGenLists(1); + GL11.glNewList(gear1, GL11.GL_COMPILE); + GL11.glMaterial(GL11.GL_FRONT, GL11.GL_AMBIENT_AND_DIFFUSE, red); + gear(1.0f, 4.0f, 1.0f, 20, 0.7f); + GL11.glEndList(); + + gear2 = GL11.glGenLists(1); + GL11.glNewList(gear2, GL11.GL_COMPILE); + GL11.glMaterial(GL11.GL_FRONT, GL11.GL_AMBIENT_AND_DIFFUSE, green); + gear(0.5f, 2.0f, 2.0f, 10, 0.7f); + GL11.glEndList(); + + gear3 = GL11.glGenLists(1); + GL11.glNewList(gear3, GL11.GL_COMPILE); + GL11.glMaterial(GL11.GL_FRONT, GL11.GL_AMBIENT_AND_DIFFUSE, blue); + gear(1.3f, 2.0f, 0.5f, 10, 0.7f); + GL11.glEndList(); + + GL11.glEnable(GL11.GL_NORMALIZE); + + GL11.glMatrixMode(GL11.GL_PROJECTION); + + System.err.println("GL_VENDOR: " + GL11.glGetString(GL11.GL_VENDOR)); + System.err.println("GL_RENDERER: " + GL11.glGetString(GL11.GL_RENDERER)); + System.err.println("GL_VERSION: " + GL11.glGetString(GL11.GL_VERSION)); + System.err.println(); + System.err.println("glLoadTransposeMatrixfARB() supported: " + GLContext.getCapabilities().GL_ARB_transpose_matrix); + if (!GLContext.getCapabilities().GL_ARB_transpose_matrix) { + // --- not using extensions + GL11.glLoadIdentity(); + } else { + // --- using extensions + final FloatBuffer identityTranspose = BufferUtils.createFloatBuffer(16).put( + new float[] { 1, 0, 0, 0, 0, 1, 0, 0, + 0, 0, 1, 0, 0, 0, 0, 1}); + identityTranspose.flip(); + ARBTransposeMatrix.glLoadTransposeMatrixARB(identityTranspose); + } + + float h = (float) 300 / (float) 300; + GL11.glFrustum(-1.0f, 1.0f, -h, h, 5.0f, 60.0f); + GL11.glMatrixMode(GL11.GL_MODELVIEW); + GL11.glLoadIdentity(); + GL11.glTranslatef(0.0f, 0.0f, -40.0f); + } + + /** + * Draw a gear wheel. You'll probably want to call this function when + * building a display list since we do a lot of trig here. + * + * @param inner_radius radius of hole at center + * @param outer_radius radius at center of teeth + * @param width width of gear + * @param teeth number of teeth + * @param tooth_depth depth of tooth + */ + private void gear(float inner_radius, float outer_radius, float width, int teeth, float tooth_depth) { + int i; + float r0, r1, r2; + float angle, da; + float u, v, len; + + r0 = inner_radius; + r1 = outer_radius - tooth_depth / 2.0f; + r2 = outer_radius + tooth_depth / 2.0f; + + da = 2.0f * (float) Math.PI / teeth / 4.0f; + + GL11.glShadeModel(GL11.GL_FLAT); + + GL11.glNormal3f(0.0f, 0.0f, 1.0f); + + /* draw front face */ + GL11.glBegin(GL11.GL_QUAD_STRIP); + for (i = 0; i <= teeth; i++) { + angle = i * 2.0f * (float) Math.PI / teeth; + GL11.glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), width * 0.5f); + GL11.glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), width * 0.5f); + if (i < teeth) { + GL11.glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), width * 0.5f); + GL11.glVertex3f(r1 * (float) Math.cos(angle + 3.0f * da), r1 * (float) Math.sin(angle + 3.0f * da), + width * 0.5f); + } + } + GL11.glEnd(); + + /* draw front sides of teeth */ + GL11.glBegin(GL11.GL_QUADS); + for (i = 0; i < teeth; i++) { + angle = i * 2.0f * (float) Math.PI / teeth; + GL11.glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), width * 0.5f); + GL11.glVertex3f(r2 * (float) Math.cos(angle + da), r2 * (float) Math.sin(angle + da), width * 0.5f); + GL11.glVertex3f(r2 * (float) Math.cos(angle + 2.0f * da), r2 * (float) Math.sin(angle + 2.0f * da), width * 0.5f); + GL11.glVertex3f(r1 * (float) Math.cos(angle + 3.0f * da), r1 * (float) Math.sin(angle + 3.0f * da), width * 0.5f); + } + GL11.glEnd(); + + /* draw back face */ + GL11.glBegin(GL11.GL_QUAD_STRIP); + for (i = 0; i <= teeth; i++) { + angle = i * 2.0f * (float) Math.PI / teeth; + GL11.glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), -width * 0.5f); + GL11.glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), -width * 0.5f); + GL11.glVertex3f(r1 * (float) Math.cos(angle + 3 * da), r1 * (float) Math.sin(angle + 3 * da), -width * 0.5f); + GL11.glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), -width * 0.5f); + } + GL11.glEnd(); + + /* draw back sides of teeth */ + GL11.glBegin(GL11.GL_QUADS); + for (i = 0; i < teeth; i++) { + angle = i * 2.0f * (float) Math.PI / teeth; + GL11.glVertex3f(r1 * (float) Math.cos(angle + 3 * da), r1 * (float) Math.sin(angle + 3 * da), -width * 0.5f); + GL11.glVertex3f(r2 * (float) Math.cos(angle + 2 * da), r2 * (float) Math.sin(angle + 2 * da), -width * 0.5f); + GL11.glVertex3f(r2 * (float) Math.cos(angle + da), r2 * (float) Math.sin(angle + da), -width * 0.5f); + GL11.glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), -width * 0.5f); + } + GL11.glEnd(); + + /* draw outward faces of teeth */ + GL11.glBegin(GL11.GL_QUAD_STRIP); + for (i = 0; i < teeth; i++) { + angle = i * 2.0f * (float) Math.PI / teeth; + GL11.glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), width * 0.5f); + GL11.glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), -width * 0.5f); + u = r2 * (float) Math.cos(angle + da) - r1 * (float) Math.cos(angle); + v = r2 * (float) Math.sin(angle + da) - r1 * (float) Math.sin(angle); + len = (float) Math.sqrt(u * u + v * v); + u /= len; + v /= len; + GL11.glNormal3f(v, -u, 0.0f); + GL11.glVertex3f(r2 * (float) Math.cos(angle + da), r2 * (float) Math.sin(angle + da), width * 0.5f); + GL11.glVertex3f(r2 * (float) Math.cos(angle + da), r2 * (float) Math.sin(angle + da), -width * 0.5f); + GL11.glNormal3f((float) Math.cos(angle), (float) Math.sin(angle), 0.0f); + GL11.glVertex3f(r2 * (float) Math.cos(angle + 2 * da), r2 * (float) Math.sin(angle + 2 * da), width * 0.5f); + GL11.glVertex3f(r2 * (float) Math.cos(angle + 2 * da), r2 * (float) Math.sin(angle + 2 * da), -width * 0.5f); + u = r1 * (float) Math.cos(angle + 3 * da) - r2 * (float) Math.cos(angle + 2 * da); + v = r1 * (float) Math.sin(angle + 3 * da) - r2 * (float) Math.sin(angle + 2 * da); + GL11.glNormal3f(v, -u, 0.0f); + GL11.glVertex3f(r1 * (float) Math.cos(angle + 3 * da), r1 * (float) Math.sin(angle + 3 * da), width * 0.5f); + GL11.glVertex3f(r1 * (float) Math.cos(angle + 3 * da), r1 * (float) Math.sin(angle + 3 * da), -width * 0.5f); + GL11.glNormal3f((float) Math.cos(angle), (float) Math.sin(angle), 0.0f); + } + GL11.glVertex3f(r1 * (float) Math.cos(0), r1 * (float) Math.sin(0), width * 0.5f); + GL11.glVertex3f(r1 * (float) Math.cos(0), r1 * (float) Math.sin(0), -width * 0.5f); + GL11.glEnd(); + + GL11.glShadeModel(GL11.GL_SMOOTH); + + /* draw inside radius cylinder */ + GL11.glBegin(GL11.GL_QUAD_STRIP); + for (i = 0; i <= teeth; i++) { + angle = i * 2.0f * (float) Math.PI / teeth; + GL11.glNormal3f(-(float) Math.cos(angle), -(float) Math.sin(angle), 0.0f); + GL11.glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), -width * 0.5f); + GL11.glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), width * 0.5f); + } + GL11.glEnd(); + } +} diff --git a/src/java/org/lwjgl/test/opengl/PbufferTest.java b/src/java/org/lwjgl/test/opengl/PbufferTest.java new file mode 100644 index 0000000..eac8e8c --- /dev/null +++ b/src/java/org/lwjgl/test/opengl/PbufferTest.java @@ -0,0 +1,400 @@ +/* + * 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.test.opengl; + +import java.nio.ByteBuffer; +import java.nio.ByteOrder; +import java.nio.IntBuffer; + +import org.lwjgl.LWJGLException; +import org.lwjgl.input.Keyboard; +import org.lwjgl.opengl.Display; +import org.lwjgl.opengl.DisplayMode; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.Pbuffer; +import org.lwjgl.opengl.PixelFormat; +import org.lwjgl.util.glu.GLU; +import org.lwjgl.util.vector.Vector2f; + +/** + * + * Tests Pbuffers + * + * @author elias_naur + * @version $Revision: 2983 $ + * $Id: PbufferTest.java 2983 2008-04-07 18:36:09Z matzon $ + */ +public class PbufferTest { + + /** Intended deiplay mode */ + private DisplayMode mode; + + /** our quad moving around */ + private Vector2f quadPosition; + + /** our quadVelocity */ + private Vector2f quadVelocity; + + /** angle of quad */ + private float angle; + + /** degrees to rotate per frame */ + private float angleRotation = 1.0f; + + /** Max speed of all changable attributes */ + private static final float MAX_SPEED = 20.0f; + + /** Pbuffer instance */ + private static Pbuffer pbuffer; + + /** The shared texture */ + private static int tex_handle; + + /** + * Executes the test + */ + public void execute() { + initialize(); + + mainLoop(); + + cleanup(); + } + + /** + * Initializes the test + */ + private void initialize() { + try { + //find displaymode + pbuffer = new Pbuffer(512, 512, new PixelFormat(), null, null); + mode = findDisplayMode(800, 600, 16); + Display.setDisplayMode(mode); + // start of in windowed mode + Display.create(); +// gl = new GLWindow("Test", 50, 50, mode.width, mode.height, mode.bpp, 0, 0, 0); + if ((Pbuffer.getCapabilities() & Pbuffer.PBUFFER_SUPPORTED) == 0) { + System.out.println("No Pbuffer support!"); + System.exit(1); + } + System.out.println("Pbuffer support detected"); + + glInit(); + initPbuffer(); + + Keyboard.create(); + + quadPosition = new Vector2f(100f, 100f); + quadVelocity = new Vector2f(1.0f, 1.0f); + } catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * Runs the main loop of the "test" + */ + private void mainLoop() { + while (!Keyboard.isKeyDown(Keyboard.KEY_ESCAPE) && !Display.isCloseRequested()) { + if (Display.isVisible()) { + // check keyboard input + processKeyboard(); + // do "game" logic, and render it + logic(); + render(); + } else { + // no need to render/paint if nothing has changed (ie. window + // dragged over) + if (Display.isDirty()) { + render(); + } + // don't waste cpu time, sleep more + try { + Thread.sleep(100); + } catch (InterruptedException inte) { + } + } + // Update window + Display.update(); + } + } + + /** + * Performs the logic + */ + private void logic() { + angle += angleRotation; + if (angle > 90.0f) { + angle = 0.0f; + } + + quadPosition.x += quadVelocity.x; + quadPosition.y += quadVelocity.y; + + //check colision with vertical border border + if (quadPosition.x + 50 >= mode.getWidth() || quadPosition.x - 50 <= 0) { + quadVelocity.x *= -1; + } + + //check collision with horizontal border + if (quadPosition.y + 50 >= mode.getHeight() || quadPosition.y - 50 <= 0) { + quadVelocity.y *= -1; + } + } + + private void render() { + if (pbuffer.isBufferLost()) { + System.out.println("Buffer contents lost - will recreate the buffer"); + pbuffer.destroy(); + try { + pbuffer = new Pbuffer(512, 512, new PixelFormat(), null, null); + initPbuffer(); + } catch (LWJGLException e) { + e.printStackTrace(); + } + } + try { + pbuffer.makeCurrent(); + } catch (LWJGLException e) { + throw new RuntimeException(e); + } + // Pbuffer rendering + //clear background + GL11.glClear(GL11.GL_COLOR_BUFFER_BIT); + + // draw white quad + GL11.glPushMatrix(); + { + GL11.glTranslatef(quadPosition.x, quadPosition.y, 0); + GL11.glRotatef(angle, 0.0f, 0.0f, 1.0f); + GL11.glColor3f(1.0f, 1.0f, 1.0f); + GL11.glBegin(GL11.GL_QUADS); + { + GL11.glVertex2i(-50, -50); + GL11.glVertex2i(50, -50); + GL11.glVertex2i(50, 50); + GL11.glVertex2i(-50, 50); + } + GL11.glEnd(); + } + GL11.glPopMatrix(); + GL11.glCopyTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGB, 0, 0, 512, 512, 0); + try { + Display.makeCurrent(); + } catch (LWJGLException e) { + throw new RuntimeException(e); + } + + // OpenGL window rendering + GL11.glClear(GL11.GL_COLOR_BUFFER_BIT); + // draw white quad + GL11.glPushMatrix(); + { + GL11.glTranslatef(quadPosition.x, quadPosition.y, 0); + GL11.glRotatef(angle, 0.0f, 0.0f, 1.0f); + GL11.glColor3f(1.0f, 1.0f, 0.0f); + GL11.glBegin(GL11.GL_QUADS); + { + GL11.glTexCoord2f(0f, 0f); + GL11.glVertex2i(-50, -50); + GL11.glTexCoord2f(1f, 0f); + GL11.glVertex2i(50, -50); + GL11.glTexCoord2f(1f, 1f); + GL11.glVertex2i(50, 50); + GL11.glTexCoord2f(0f, 1f); + GL11.glVertex2i(-50, 50); + } + GL11.glEnd(); + } + GL11.glPopMatrix(); + } + + private void initPbuffer() { + try { + pbuffer.makeCurrent(); + initGLState(256, 256, 0.5f); + GL11.glBindTexture(GL11.GL_TEXTURE_2D, tex_handle); + Display.makeCurrent(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * Processes keyboard input + */ + private void processKeyboard() { + Keyboard.poll(); + + //check for fullscreen key + if (Keyboard.isKeyDown(Keyboard.KEY_F)) { + + try { + Display.setDisplayMode(mode); + Display.setFullscreen(true); + } catch (Exception e) { + e.printStackTrace(); + } + } + + //check for window key + if (Keyboard.isKeyDown(Keyboard.KEY_W)) { + try { + Display.setFullscreen(false); + } catch (Exception e) { + e.printStackTrace(); + } + } + + //check for speed changes + if (Keyboard.isKeyDown(Keyboard.KEY_UP)) { + quadVelocity.y += 0.1f; + } + if (Keyboard.isKeyDown(Keyboard.KEY_DOWN)) { + quadVelocity.y -= 0.1f; + } + if (Keyboard.isKeyDown(Keyboard.KEY_RIGHT)) { + quadVelocity.x += 0.1f; + } + if (Keyboard.isKeyDown(Keyboard.KEY_LEFT)) { + quadVelocity.x -= 0.1f; + } + + if (Keyboard.isKeyDown(Keyboard.KEY_ADD)) { + angleRotation += 0.1f; + } + if (Keyboard.isKeyDown(Keyboard.KEY_SUBTRACT)) { + angleRotation -= 0.1f; + } + + //throttle + if (quadVelocity.x < -MAX_SPEED) { + quadVelocity.x = -MAX_SPEED; + } + if (quadVelocity.x > MAX_SPEED) { + quadVelocity.x = MAX_SPEED; + } + if (quadVelocity.y < -MAX_SPEED) { + quadVelocity.y = -MAX_SPEED; + } + if (quadVelocity.y > MAX_SPEED) { + quadVelocity.y = MAX_SPEED; + } + + if (angleRotation < 0.0f) { + angleRotation = 0.0f; + } + if (angleRotation > MAX_SPEED) { + angleRotation = MAX_SPEED; + } + } + + private void destroyTexture() { + IntBuffer buffer = ByteBuffer.allocateDirect(4).order(ByteOrder.nativeOrder()).asIntBuffer(); + buffer.put(0, tex_handle); + GL11.glDeleteTextures(buffer); + } + + /** + * Cleans up the test + */ + private void cleanup() { + destroyTexture(); + pbuffer.destroy(); + Display.destroy(); + } + + /** + * Retrieves a displaymode, if one such is available + * + * @param width Required width + * @param height Required height + * @param bpp Minimum required bits per pixel + * @return + */ + private DisplayMode findDisplayMode(int width, int height, int bpp) throws LWJGLException { + DisplayMode[] modes = Display.getAvailableDisplayModes(); + for (int i = 0; i < modes.length; i++) { + if (modes[i].getWidth() == width + && modes[i].getHeight() == height + && modes[i].getBitsPerPixel() >= bpp) { + return modes[i]; + } + } + return null; + } + + private void initGLState(int width, int height, float color) { + GL11.glMatrixMode(GL11.GL_PROJECTION); + GL11.glLoadIdentity(); + GLU.gluOrtho2D(0, mode.getWidth(), 0, mode.getHeight()); + GL11.glMatrixMode(GL11.GL_MODELVIEW); + GL11.glLoadIdentity(); + GL11.glViewport(0, 0, width, height); + + //set clear color to black + GL11.glClearColor(color, color, color, 0.0f); + } + + /** + * Initializes OGL + */ + private void glInit() { + //sync frame (only works on windows) + Display.setVSyncEnabled(true); + + GL11.glTexEnvf(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_REPLACE); + GL11.glEnable(GL11.GL_TEXTURE_2D); + // Create shared texture + IntBuffer buffer = ByteBuffer.allocateDirect(4).order(ByteOrder.nativeOrder()).asIntBuffer(); + GL11.glGenTextures(buffer); + tex_handle = buffer.get(0); + GL11.glBindTexture(GL11.GL_TEXTURE_2D, tex_handle); + GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_CLAMP); + GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_CLAMP); + GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR); + GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR); + initGLState(mode.getWidth(), mode.getHeight(), 0f); + } + + /** + * Test entry point + */ + public static void main(String[] args) { + System.out.println( + "Change between fullscreen and windowed mode, by pressing F and W respectively"); + System.out.println("Move quad using arrowkeys, and change rotation using +/-"); + PbufferTest fswTest = new PbufferTest(); + fswTest.execute(); + System.exit(0); + } +} diff --git a/src/java/org/lwjgl/test/opengl/SyncTest.java b/src/java/org/lwjgl/test/opengl/SyncTest.java new file mode 100644 index 0000000..cc8cd87 --- /dev/null +++ b/src/java/org/lwjgl/test/opengl/SyncTest.java @@ -0,0 +1,178 @@ +/* + * 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.test.opengl; + +import org.lwjgl.LWJGLException; +import org.lwjgl.Sys; +import org.lwjgl.opengl.*; + +import java.util.Random; + +/** @author spasi */ +public final class SyncTest { + + private SyncTest() { + } + + public static void main(String[] args) { + runTest(args); + cleanup(); + System.exit(0); + } + + private static void runTest(String[] args) { + if ( args.length < 2 ) + argsError("Insufficient number of arguments."); + + int clears = 1; + int timeout = 0; + + try { + clears = Integer.parseInt(args[0]); + timeout = Integer.parseInt(args[1]); + } catch (NumberFormatException e) { + argsError("Invalid number format."); + } + + ContextAttribs ca = new ContextAttribs(); + + try { + DisplayMode[] modes = Display.getAvailableDisplayModes(); + + DisplayMode displayMode = chooseMode(modes, 1024, 768); + if ( displayMode == null ) + displayMode = chooseMode(modes, 800, 600); + if ( displayMode == null ) + displayMode = chooseMode(modes, 640, 480); + if ( displayMode == null ) + kill("Failed to set an appropriate display mode."); + + System.out.println("Setting display mode to: " + displayMode); + Display.setDisplayMode(displayMode); + Display.create(new PixelFormat(8, 24, 0), ca); + } catch (LWJGLException e) { + kill(e.getMessage()); + } + + System.out.println("\n---------\n"); + + final String version = GL11.glGetString(GL11.GL_VERSION); + + System.out.println("GL Version: " + version); + System.out.println("ARB_sync: " + GLContext.getCapabilities().GL_ARB_sync); + + if ( !GLContext.getCapabilities().OpenGL32 && !GLContext.getCapabilities().GL_ARB_sync ) + kill("OpenGL3.2 or ARB_sync support is required for this test."); + + System.out.println("\n---------\n"); + + System.out.println("Clearing the framebuffer a gazillion times..."); + + Random rand = new Random(System.currentTimeMillis()); + for ( int i = 0; i < clears; i++ ) { + GL11.glClearColor(rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), 1.0f); + GL11.glClear(GL11.GL_COLOR_BUFFER_BIT); + } + + GLSync sync = GL32.glFenceSync(GL32.GL_SYNC_GPU_COMMANDS_COMPLETE, 0); + + System.out.println("\nWaiting on fence..."); + long time = Sys.getTime(); + int status = GL32.glClientWaitSync(sync, 0, timeout < 0 ? GL32.GL_TIMEOUT_IGNORED : timeout * 1000 * 1000); + System.out.println("\nFence sync complete after: " + ((Sys.getTime() - time) / (double)Sys.getTimerResolution()) + " seconds."); + System.out.print("\nWait Status: "); + switch ( status ) { + case GL32.GL_ALREADY_SIGNALED: + System.out.println("ALREADY_SIGNALED"); + break; + case GL32.GL_CONDITION_SATISFIED: + System.out.println("CONDITION_SATISFIED"); + break; + case GL32.GL_TIMEOUT_EXPIRED: + System.out.println("TIMEOUT_EXPIRED"); + break; + case GL32.GL_WAIT_FAILED: + System.out.println("WAIT_FAILED"); + break; + default: + System.out.println("Unexpected wait status: 0x" + Integer.toHexString(status)); + } + + System.out.println("Sync Status: " + (GL32.glGetSync(sync, GL32.GL_SYNC_STATUS) == GL32.GL_UNSIGNALED ? "UNSIGNALED" : "SIGNALED")); + + GL32.glDeleteSync(sync); + + int error = GL11.glGetError(); + if ( error != 0 ) + System.out.println("\nTest failed with OpenGL error: " + error); + else + System.out.println("\nTest completed successfully."); + } + + private static DisplayMode chooseMode(DisplayMode[] modes, int width, int height) { + DisplayMode bestMode = null; + + for ( int i = 0; i < modes.length; i++ ) { + DisplayMode mode = modes[i]; + if ( mode.getWidth() == width && mode.getHeight() == height && mode.getFrequency() <= 85 ) { + if ( bestMode == null || (mode.getBitsPerPixel() >= bestMode.getBitsPerPixel() && mode.getFrequency() > bestMode.getFrequency()) ) + bestMode = mode; + } + } + + return bestMode; + } + + private static void cleanup() { + if ( Display.isCreated() ) + Display.destroy(); + } + + private static void argsError(final String msg) { + System.out.println("\nInvalid arguments error: " + msg); + System.out.println("\nUsage: SyncTest :\n"); + System.out.println("clears\t- Number of times to clear the framebuffer."); + System.out.println("timeout\t- WaitSync timeout in milliseconds."); + + cleanup(); + System.exit(-1); + } + + static void kill(String reason) { + System.out.println("The SyncTest program was terminated because an error occured.\n"); + System.out.println("Reason: " + (reason == null ? "Unknown" : reason)); + + cleanup(); + System.exit(-1); + } + +} \ No newline at end of file diff --git a/src/java/org/lwjgl/test/opengl/VBOIndexTest.java b/src/java/org/lwjgl/test/opengl/VBOIndexTest.java new file mode 100644 index 0000000..21e68cd --- /dev/null +++ b/src/java/org/lwjgl/test/opengl/VBOIndexTest.java @@ -0,0 +1,242 @@ +/* + * 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. + */ + +/** + * $Id: VBOIndexTest.java 2983 2008-04-07 18:36:09Z matzon $ + * + * Simple java test program. + * + * @author elias_naur + * @version $Revision: 2983 $ + */ + +package org.lwjgl.test.opengl; + +import java.nio.ByteBuffer; +import java.nio.ByteOrder; +import java.nio.FloatBuffer; +import java.nio.IntBuffer; + +import org.lwjgl.Sys; +import org.lwjgl.input.Keyboard; +import org.lwjgl.input.Mouse; +import org.lwjgl.opengl.ARBBufferObject; +import org.lwjgl.opengl.ARBVertexBufferObject; +import org.lwjgl.opengl.Display; +import org.lwjgl.opengl.DisplayMode; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GLContext; +import org.lwjgl.util.glu.GLU; + +public final class VBOIndexTest { + + static { + try { + //find first display mode that allows us 640*480*16 + int mode = -1; + DisplayMode[] modes = Display.getAvailableDisplayModes(); + for ( int i = 0; i < modes.length; i++ ) { + if ( modes[i].getWidth() == 640 + && modes[i].getHeight() == 480 + && modes[i].getBitsPerPixel() >= 16 ) { + mode = i; + break; + } + } + if ( mode != -1 ) { + //select above found displaymode + System.out.println("Setting display mode to " + modes[mode]); + Display.setDisplayMode(modes[mode]); + System.out.println("Created display."); + } + } catch (Exception e) { + System.err.println("Failed to create display due to " + e); + } + } + + static { + try { + Display.create(); + System.out.println("Created OpenGL."); + } catch (Exception e) { + System.err.println("Failed to create OpenGL due to " + e); + System.exit(1); + } + } + + /** + * Is the game finished? + */ + private static boolean finished; + + /** + * A rotating square! + */ + private static float angle; + private static int buffer_id; + private static int indices_buffer_id; + private static FloatBuffer vertices; + private static ByteBuffer mapped_buffer = null; + private static FloatBuffer mapped_float_buffer = null; + private static IntBuffer indices; + private static ByteBuffer mapped_indices_buffer = null; + private static IntBuffer mapped_indices_int_buffer = null; + + public static void main(String[] arguments) { + try { + init(); + while ( !finished ) { + Display.update(); + + if ( !Display.isVisible() ) + Thread.sleep(200); + else if ( Display.isCloseRequested() ) + System.exit(0); + + mainLoop(); + render(); + } + } catch (Throwable t) { + t.printStackTrace(); + } finally { + cleanup(); + } + System.exit(0); + } + + /** + * All calculations are done in here + */ + private static void mainLoop() { + angle += 1f; + if ( angle > 360.0f ) + angle = 0.0f; + + if ( Mouse.getDX() != 0 || Mouse.getDY() != 0 || Mouse.getDWheel() != 0 ) + System.out.println("Mouse moved " + Mouse.getDX() + " " + Mouse.getDY() + " " + Mouse.getDWheel()); + for ( int i = 0; i < Mouse.getButtonCount(); i++ ) + if ( Mouse.isButtonDown(i) ) + System.out.println("Button " + i + " down"); + if ( Keyboard.isKeyDown(Keyboard.KEY_ESCAPE) ) + finished = true; + for ( int i = 0; i < Keyboard.getNumKeyboardEvents(); i++ ) { + Keyboard.next(); + if ( Keyboard.getEventKey() == Keyboard.KEY_ESCAPE && Keyboard.getEventKeyState() ) + finished = true; + if ( Keyboard.getEventKey() == Keyboard.KEY_T && Keyboard.getEventKeyState() ) + System.out.println("Current time: " + Sys.getTime()); + } + } + + /** + * All rendering is done in here + */ + private static void render() { + GL11.glClear(GL11.GL_COLOR_BUFFER_BIT); + GL11.glPushMatrix(); + GL11.glTranslatef(Display.getDisplayMode().getWidth() / 2, Display.getDisplayMode().getHeight() / 2, 0.0f); + GL11.glRotatef(angle, 0, 0, 1.0f); + + + ByteBuffer new_mapped_buffer = ARBBufferObject.glMapBufferARB(ARBVertexBufferObject.GL_ARRAY_BUFFER_ARB, + ARBBufferObject.GL_WRITE_ONLY_ARB, + mapped_buffer); + if ( new_mapped_buffer != mapped_buffer ) + mapped_float_buffer = new_mapped_buffer.order(ByteOrder.nativeOrder()).asFloatBuffer(); + mapped_buffer = new_mapped_buffer; + + new_mapped_buffer = ARBBufferObject.glMapBufferARB(ARBVertexBufferObject.GL_ELEMENT_ARRAY_BUFFER_ARB, + ARBBufferObject.GL_WRITE_ONLY_ARB, + mapped_indices_buffer); + if ( new_mapped_buffer != mapped_indices_buffer ) + mapped_indices_int_buffer = new_mapped_buffer.order(ByteOrder.nativeOrder()).asIntBuffer(); + + mapped_float_buffer.rewind(); + vertices.rewind(); + mapped_float_buffer.put(vertices); + + mapped_indices_int_buffer.rewind(); + indices.rewind(); + mapped_indices_int_buffer.put(indices); + if ( ARBBufferObject.glUnmapBufferARB(ARBVertexBufferObject.GL_ARRAY_BUFFER_ARB) && + ARBBufferObject.glUnmapBufferARB(ARBVertexBufferObject.GL_ELEMENT_ARRAY_BUFFER_ARB) ) { + GL11.glDrawElements(GL11.GL_QUADS, 4, GL11.GL_UNSIGNED_INT, 0); + } + GL11.glPopMatrix(); + } + + /** + * Initialize + */ + private static void init() throws Exception { + + System.out.println("Timer resolution: " + Sys.getTimerResolution()); + // Go into orthographic projection mode. + GL11.glMatrixMode(GL11.GL_PROJECTION); + GL11.glLoadIdentity(); + GLU.gluOrtho2D(0, Display.getDisplayMode().getWidth(), 0, Display.getDisplayMode().getHeight()); + GL11.glMatrixMode(GL11.GL_MODELVIEW); + GL11.glLoadIdentity(); + GL11.glViewport(0, 0, Display.getDisplayMode().getWidth(), Display.getDisplayMode().getHeight()); + if ( !GLContext.getCapabilities().GL_ARB_vertex_buffer_object ) { + System.out.println("ARB VBO not supported!"); + System.exit(1); + } + IntBuffer int_buffer = ByteBuffer.allocateDirect(8).order(ByteOrder.nativeOrder()).asIntBuffer(); + ARBBufferObject.glGenBuffersARB(int_buffer); + buffer_id = int_buffer.get(0); + indices_buffer_id = int_buffer.get(1); + ARBBufferObject.glBindBufferARB(ARBVertexBufferObject.GL_ARRAY_BUFFER_ARB, buffer_id); + ARBBufferObject.glBindBufferARB(ARBVertexBufferObject.GL_ELEMENT_ARRAY_BUFFER_ARB, indices_buffer_id); + vertices = ByteBuffer.allocateDirect(2 * 4 * 4).order(ByteOrder.nativeOrder()).asFloatBuffer(); + vertices.put(-50).put(-50).put(50).put(-50).put(50).put(50).put(-50).put(50); + vertices.rewind(); + indices = ByteBuffer.allocateDirect(4 * 4).order(ByteOrder.nativeOrder()).asIntBuffer(); + indices.put(0).put(1).put(2).put(3); + indices.rewind(); + ARBBufferObject.glBufferDataARB(ARBVertexBufferObject.GL_ARRAY_BUFFER_ARB, 2 * 4 * 4, ARBBufferObject.GL_STREAM_DRAW_ARB); + ARBBufferObject.glBufferDataARB(ARBVertexBufferObject.GL_ELEMENT_ARRAY_BUFFER_ARB, 4 * 4, ARBBufferObject.GL_STREAM_DRAW_ARB); + GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY); + GL11.glVertexPointer(2, GL11.GL_FLOAT, 0, 0); + } + + /** + * Cleanup + */ + private static void cleanup() { + IntBuffer int_buffer = ByteBuffer.allocateDirect(8).order(ByteOrder.nativeOrder()).asIntBuffer(); + int_buffer.put(0, buffer_id); + int_buffer.put(1, indices_buffer_id); + ARBBufferObject.glDeleteBuffersARB(int_buffer); + Display.destroy(); + } +} diff --git a/src/java/org/lwjgl/test/opengl/VBOTest.java b/src/java/org/lwjgl/test/opengl/VBOTest.java new file mode 100644 index 0000000..7bdf9ea --- /dev/null +++ b/src/java/org/lwjgl/test/opengl/VBOTest.java @@ -0,0 +1,209 @@ +/* + * 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. + */ + +/** + * $Id: VBOTest.java 3287 2010-03-14 23:24:40Z spasi $ + * + * Simple java test program. + * + * @author elias_naur + * @version $Revision: 3287 $ + */ + +package org.lwjgl.test.opengl; + +import java.nio.ByteBuffer; +import java.nio.ByteOrder; +import java.nio.FloatBuffer; + +import org.lwjgl.Sys; +import org.lwjgl.input.Keyboard; +import org.lwjgl.input.Mouse; +import org.lwjgl.opengl.ARBBufferObject; +import org.lwjgl.opengl.ARBVertexBufferObject; +import org.lwjgl.opengl.Display; +import org.lwjgl.opengl.DisplayMode; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GLContext; +import org.lwjgl.util.glu.GLU; + +public final class VBOTest { + + static { + try { + //find first display mode that allows us 640*480*16 + int mode = -1; + DisplayMode[] modes = Display.getAvailableDisplayModes(); + for ( int i = 0; i < modes.length; i++ ) { + if ( modes[i].getWidth() == 640 + && modes[i].getHeight() == 480 + && modes[i].getBitsPerPixel() >= 16 ) { + mode = i; + break; + } + } + if ( mode != -1 ) { + //select above found displaymode + System.out.println("Setting display mode to " + modes[mode]); + Display.setDisplayMode(modes[mode]); + System.out.println("Created display."); + } + } catch (Exception e) { + System.err.println("Failed to create display due to " + e); + } + } + + static { + try { + Display.create(); + System.out.println("Created OpenGL."); + } catch (Exception e) { + System.err.println("Failed to create OpenGL due to " + e); + System.exit(1); + } + } + + /** + * Is the game finished? + */ + private static boolean finished; + + /** + * A rotating square! + */ + private static float angle; + private static int buffer_id; + private static FloatBuffer vertices; + private static ByteBuffer mapped_buffer = null; + private static FloatBuffer mapped_float_buffer = null; + + public static void main(String[] arguments) { + try { + init(); + while ( !finished ) { + Display.update(); + + if ( !Display.isVisible() ) + Thread.sleep(200); + else if ( Display.isCloseRequested() ) + System.exit(0); + + mainLoop(); + render(); + } + } catch (Throwable t) { + t.printStackTrace(); + } finally { + cleanup(); + } + System.exit(0); + } + + /** + * All calculations are done in here + */ + private static void mainLoop() { + angle += 1f; + if ( angle > 360.0f ) + angle = 0.0f; + + if ( Mouse.getDX() != 0 || Mouse.getDY() != 0 || Mouse.getDWheel() != 0 ) + System.out.println("Mouse moved " + Mouse.getDX() + " " + Mouse.getDY() + " " + Mouse.getDWheel()); + for ( int i = 0; i < Mouse.getButtonCount(); i++ ) + if ( Mouse.isButtonDown(i) ) + System.out.println("Button " + i + " down"); + if ( Keyboard.isKeyDown(Keyboard.KEY_ESCAPE) ) + finished = true; + for ( int i = 0; i < Keyboard.getNumKeyboardEvents(); i++ ) { + Keyboard.next(); + if ( Keyboard.getEventKey() == Keyboard.KEY_ESCAPE && Keyboard.getEventKeyState() ) + finished = true; + if ( Keyboard.getEventKey() == Keyboard.KEY_T && Keyboard.getEventKeyState() ) + System.out.println("Current time: " + Sys.getTime()); + } + } + + /** + * All rendering is done in here + */ + private static void render() { + GL11.glClear(GL11.GL_COLOR_BUFFER_BIT); + GL11.glPushMatrix(); + GL11.glTranslatef(Display.getDisplayMode().getWidth() / 2, Display.getDisplayMode().getHeight() / 2, 0.0f); + GL11.glRotatef(angle, 0, 0, 1.0f); + ByteBuffer new_mapped_buffer = ARBBufferObject.glMapBufferARB(ARBVertexBufferObject.GL_ARRAY_BUFFER_ARB, + ARBBufferObject.GL_WRITE_ONLY_ARB, + mapped_buffer); + if ( new_mapped_buffer != mapped_buffer ) + mapped_float_buffer = new_mapped_buffer.order(ByteOrder.nativeOrder()).asFloatBuffer(); + mapped_buffer = new_mapped_buffer; + mapped_float_buffer.rewind(); + vertices.rewind(); + mapped_float_buffer.put(vertices); + if ( ARBBufferObject.glUnmapBufferARB(ARBVertexBufferObject.GL_ARRAY_BUFFER_ARB) ) + GL11.glDrawArrays(GL11.GL_QUADS, 0, 4); + GL11.glPopMatrix(); + } + + /** + * Initialize + */ + private static void init() throws Exception { + System.out.println("Timer resolution: " + Sys.getTimerResolution()); + // Go into orthographic projection mode. + GL11.glMatrixMode(GL11.GL_PROJECTION); + GL11.glLoadIdentity(); + GLU.gluOrtho2D(0, Display.getDisplayMode().getWidth(), 0, Display.getDisplayMode().getHeight()); + GL11.glMatrixMode(GL11.GL_MODELVIEW); + GL11.glLoadIdentity(); + GL11.glViewport(0, 0, Display.getDisplayMode().getWidth(), Display.getDisplayMode().getHeight()); + if ( !GLContext.getCapabilities().GL_ARB_vertex_buffer_object ) { + System.out.println("ARB VBO not supported!"); + System.exit(1); + } + buffer_id = ARBBufferObject.glGenBuffersARB(); + ARBBufferObject.glBindBufferARB(ARBVertexBufferObject.GL_ARRAY_BUFFER_ARB, buffer_id); + vertices = ByteBuffer.allocateDirect(2 * 4 * 4).order(ByteOrder.nativeOrder()).asFloatBuffer(); + vertices.put(-50).put(-50).put(50).put(-50).put(50).put(50).put(-50).put(50); + ARBBufferObject.glBufferDataARB(ARBVertexBufferObject.GL_ARRAY_BUFFER_ARB, 2 * 4 * 4, ARBBufferObject.GL_STREAM_DRAW_ARB); + GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY); + GL11.glVertexPointer(2, GL11.GL_FLOAT, 0, 0); + } + + /** + * Cleanup + */ + private static void cleanup() { + ARBBufferObject.glDeleteBuffersARB(buffer_id); + Display.destroy(); + } +} diff --git a/src/java/org/lwjgl/test/opengl/VersionTest.java b/src/java/org/lwjgl/test/opengl/VersionTest.java new file mode 100644 index 0000000..f85ea07 --- /dev/null +++ b/src/java/org/lwjgl/test/opengl/VersionTest.java @@ -0,0 +1,196 @@ +/* + * 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. + */ +/* + * Created by LWJGL. + * User: spasi + * Date: 2009-04-04 + * Time: 21:20:24 pm + */ + +package org.lwjgl.test.opengl; + +import org.lwjgl.LWJGLException; +import org.lwjgl.opengl.*; + +import java.util.StringTokenizer; +import java.util.regex.Pattern; + +public final class VersionTest { + + private VersionTest() { + } + + public static void main(String[] args) { + initialize(args); + cleanup(); + System.exit(0); + } + + private static void initialize(String[] args) { + if ( args.length < 2 ) + argsError("Insufficient number of arguments"); + + int majorInput = 1; + int minorInput = 0; + + try { + majorInput = Integer.parseInt(args[0]); + minorInput = Integer.parseInt(args[1]); + } catch (NumberFormatException e) { + argsError("Invalid number format"); + } + + ContextAttribs ca = new ContextAttribs(majorInput, minorInput); + + if ( 2 < args.length ) { + for ( int i = 2; i < args.length; i++ ) { + if ( Pattern.matches("[0-9]+", args[i]) ) + ca = ca.withLayer(Integer.parseInt(args[i])); + else if ( "debug".equalsIgnoreCase(args[i]) ) + ca = ca.withDebug(true); + else if ( "fc".equalsIgnoreCase(args[i]) ) + ca = ca.withForwardCompatible(true); + else if ( "core".equalsIgnoreCase(args[i]) ) + ca = ca.withProfileCore(true); + else if ( "compatibility".equalsIgnoreCase(args[i]) ) + ca = ca.withProfileCompatibility(true); + else + argsError("Unknown argument: \'" + args[i] + "\'"); + } + } + + try { + DisplayMode[] modes = Display.getAvailableDisplayModes(); + + DisplayMode displayMode; + + displayMode = chooseMode(modes, 1024, 768); + if ( displayMode == null ) + displayMode = chooseMode(modes, 800, 600); + if ( displayMode == null ) + displayMode = chooseMode(modes, 640, 480); + if ( displayMode == null ) + kill("Failed to set an appropriate display mode."); + + System.out.println("Setting display mode to: " + displayMode); + Display.setDisplayMode(displayMode); + Display.create(new PixelFormat(8, 24, 0), ca); + } catch (LWJGLException e) { + kill(e.getMessage()); + } + + System.out.println("\n---------\n"); + + final String version = GL11.glGetString(GL11.GL_VERSION); + + System.out.print("GL Version requested: " + majorInput + '.' + minorInput); + if ( ca.isProfileCore() ) + System.out.print(" - Core Profile"); + else if ( ca.isProfileCompatibility() ) + System.out.print(" - Compatibility Profile"); + System.out.println("\nGL Version returned : " + version); + + final StringTokenizer version_tokenizer = new StringTokenizer(version, ". "); + + int majorVersion = Integer.parseInt(version_tokenizer.nextToken()); + int minorVersion = Integer.parseInt(version_tokenizer.nextToken()); + + if ( majorVersion != majorInput || minorVersion != minorInput ) { + if ( majorInput == 1 && minorInput == 0 ) + System.out.println("\tThe maximum supported version has been returned. The driver is well-behaved. :)"); + else if ( majorInput < 3 && majorVersion < 3 ) + System.out.println("\tThe maximum supported version pre-3.0 has been returned. The driver is well-behaved. :)"); + else + System.out.println("\tThe requested version was not returned. The driver is buggy! :("); + } else + System.out.println("\tThe requested version was returned. :)"); + + if ( ca.isProfileCompatibility() && !GLContext.getCapabilities().GL_ARB_compatibility ) + System.out.println("\tThe driver does not support the Compatibility Profile."); + + System.out.println("\n---------\n"); + + System.out.println("Debug mode: " + ca.isDebug()); + System.out.println("Forward compatible mode: " + ca.isForwardCompatible()); + System.out.println("ARB_compatibility: " + GLContext.getCapabilities().GL_ARB_compatibility); + try { + GL11.glVertex3f(0.0f, 0.0f, 0.0f); + System.out.println("Deprecated functionality present: " + true); + } catch (Throwable t) { + System.out.println("Deprecated functionality present: " + false); + if ( GLContext.getCapabilities().GL_ARB_compatibility ) { + System.out.println("\tARB_compatibility is present, but LWJGL has enabled pseudo-forward compatible mode."); + } + } + } + + private static DisplayMode chooseMode(DisplayMode[] modes, int width, int height) { + DisplayMode bestMode = null; + + for ( int i = 0; i < modes.length; i++ ) { + DisplayMode mode = modes[i]; + if ( mode.getWidth() == width && mode.getHeight() == height && mode.getFrequency() <= 85 ) { + if ( bestMode == null || (mode.getBitsPerPixel() >= bestMode.getBitsPerPixel() && mode.getFrequency() > bestMode.getFrequency()) ) + bestMode = mode; + } + } + + return bestMode; + } + + private static void cleanup() { + if ( Display.isCreated() ) + Display.destroy(); + } + + private static void argsError(final String msg) { + System.out.println("\nInvalid arguments error: " + msg); + System.out.println("\nUsage: VersionTest {, 'debug', 'fc'}:\n"); + System.out.println("majorVersion\t- Major OpenGL version."); + System.out.println("majorVersion\t- Minor OpenGL version."); + System.out.println("layer\t- Layer plane (optional)."); + System.out.println("debug\t- Enables debug mode (optional)."); + System.out.println("fc\t- Enables forward compatibility mode (optional)."); + + cleanup(); + System.exit(-1); + } + + static void kill(String reason) { + System.out.println("The VersionTest program was terminated because an error occured.\n"); + System.out.println("Reason: " + (reason == null ? "Unknown" : reason)); + + cleanup(); + System.exit(-1); + } + +} \ No newline at end of file diff --git a/src/java/org/lwjgl/test/opengl/awt/AWTGears.java b/src/java/org/lwjgl/test/opengl/awt/AWTGears.java new file mode 100644 index 0000000..8c7fd62 --- /dev/null +++ b/src/java/org/lwjgl/test/opengl/awt/AWTGears.java @@ -0,0 +1,275 @@ +/* + * 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.test.opengl.awt; + +import java.awt.Frame; +import java.awt.Color; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.nio.FloatBuffer; + +import org.lwjgl.BufferUtils; +import org.lwjgl.LWJGLException; +import org.lwjgl.opengl.ARBTransposeMatrix; +import org.lwjgl.opengl.AWTGLCanvas; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GLContext; + +/** + *

    + * AWT version of the gears demo + *

    + * @version $Revision$ + * @author Brian Matzon + * $Id$ + */ +public class AWTGears extends Frame { + + /** AWT GL canvas */ + private AWTGLCanvas canvas0; + + private float view_rotx = 20.0f; + + private float view_roty = 30.0f; + + private float view_rotz = 0.0f; + + private int gear1; + + private int gear2; + + private int gear3; + + private float angle = 0.0f; + + /** + * C'tor + */ + public AWTGears() throws LWJGLException { + setTitle("Gears"); + setBackground(Color.BLACK); + AWTGearsCanvas canvas = new AWTGearsCanvas(); + canvas.setSize(300, 300); + add(canvas); + addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent e) { + dispose(); + System.exit(0); + } + }); + setResizable(true); + pack(); + setVisible(true); + } + + private void setup() { + // setup ogl + FloatBuffer pos = BufferUtils.createFloatBuffer(4).put(new float[] { 5.0f, 5.0f, 10.0f, 0.0f}); + FloatBuffer red = BufferUtils.createFloatBuffer(4).put(new float[] { 0.8f, 0.1f, 0.0f, 1.0f}); + FloatBuffer green = BufferUtils.createFloatBuffer(4).put(new float[] { 0.0f, 0.8f, 0.2f, 1.0f}); + FloatBuffer blue = BufferUtils.createFloatBuffer(4).put(new float[] { 0.2f, 0.2f, 1.0f, 1.0f}); + pos.flip(); + red.flip(); + green.flip(); + blue.flip(); + + GL11.glLight(GL11.GL_LIGHT0, GL11.GL_POSITION, pos); + GL11.glEnable(GL11.GL_CULL_FACE); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_LIGHT0); + GL11.glEnable(GL11.GL_DEPTH_TEST); + + /* make the gears */ + gear1 = GL11.glGenLists(1); + GL11.glNewList(gear1, GL11.GL_COMPILE); + GL11.glMaterial(GL11.GL_FRONT, GL11.GL_AMBIENT_AND_DIFFUSE, red); + gear(1.0f, 4.0f, 1.0f, 20, 0.7f); + GL11.glEndList(); + + gear2 = GL11.glGenLists(1); + GL11.glNewList(gear2, GL11.GL_COMPILE); + GL11.glMaterial(GL11.GL_FRONT, GL11.GL_AMBIENT_AND_DIFFUSE, green); + gear(0.5f, 2.0f, 2.0f, 10, 0.7f); + GL11.glEndList(); + + gear3 = GL11.glGenLists(1); + GL11.glNewList(gear3, GL11.GL_COMPILE); + GL11.glMaterial(GL11.GL_FRONT, GL11.GL_AMBIENT_AND_DIFFUSE, blue); + gear(1.3f, 2.0f, 0.5f, 10, 0.7f); + GL11.glEndList(); + + GL11.glEnable(GL11.GL_NORMALIZE); + + GL11.glMatrixMode(GL11.GL_PROJECTION); + + System.err.println("GL_VENDOR: " + GL11.glGetString(GL11.GL_VENDOR)); + System.err.println("GL_RENDERER: " + GL11.glGetString(GL11.GL_RENDERER)); + System.err.println("GL_VERSION: " + GL11.glGetString(GL11.GL_VERSION)); + System.err.println(); + System.err.println("glLoadTransposeMatrixfARB() supported: " + GLContext.getCapabilities().GL_ARB_transpose_matrix); + if (!GLContext.getCapabilities().GL_ARB_transpose_matrix) { + // --- not using extensions + GL11.glLoadIdentity(); + } else { + // --- using extensions + final FloatBuffer identityTranspose = BufferUtils.createFloatBuffer(16).put( + new float[] { 1, 0, 0, 0, 0, 1, 0, 0, + 0, 0, 1, 0, 0, 0, 0, 1}); + identityTranspose.flip(); + ARBTransposeMatrix.glLoadTransposeMatrixARB(identityTranspose); + } + + float h = (float) 300 / (float) 300; + GL11.glFrustum(-1.0f, 1.0f, -h, h, 5.0f, 60.0f); + GL11.glMatrixMode(GL11.GL_MODELVIEW); + GL11.glLoadIdentity(); + GL11.glTranslatef(0.0f, 0.0f, -40.0f); + } + + /** + * Draw a gear wheel. You'll probably want to call this function when + * building a display list since we do a lot of trig here. + * + * @param inner_radius radius of hole at center + * @param outer_radius radius at center of teeth + * @param width width of gear + * @param teeth number of teeth + * @param tooth_depth depth of tooth + */ + private void gear(float inner_radius, float outer_radius, float width, int teeth, float tooth_depth) { + int i; + float r0, r1, r2; + float angle, da; + float u, v, len; + + r0 = inner_radius; + r1 = outer_radius - tooth_depth / 2.0f; + r2 = outer_radius + tooth_depth / 2.0f; + + da = 2.0f * (float) Math.PI / teeth / 4.0f; + + GL11.glShadeModel(GL11.GL_FLAT); + + GL11.glNormal3f(0.0f, 0.0f, 1.0f); + + /* draw front face */ + GL11.glBegin(GL11.GL_QUAD_STRIP); + for (i = 0; i <= teeth; i++) { + angle = i * 2.0f * (float) Math.PI / teeth; + GL11.glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), width * 0.5f); + GL11.glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), width * 0.5f); + if (i < teeth) { + GL11.glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), width * 0.5f); + GL11.glVertex3f(r1 * (float) Math.cos(angle + 3.0f * da), r1 * (float) Math.sin(angle + 3.0f * da), + width * 0.5f); + } + } + GL11.glEnd(); + + /* draw front sides of teeth */ + GL11.glBegin(GL11.GL_QUADS); + for (i = 0; i < teeth; i++) { + angle = i * 2.0f * (float) Math.PI / teeth; + GL11.glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), width * 0.5f); + GL11.glVertex3f(r2 * (float) Math.cos(angle + da), r2 * (float) Math.sin(angle + da), width * 0.5f); + GL11.glVertex3f(r2 * (float) Math.cos(angle + 2.0f * da), r2 * (float) Math.sin(angle + 2.0f * da), width * 0.5f); + GL11.glVertex3f(r1 * (float) Math.cos(angle + 3.0f * da), r1 * (float) Math.sin(angle + 3.0f * da), width * 0.5f); + } + GL11.glEnd(); + + /* draw back face */ + GL11.glBegin(GL11.GL_QUAD_STRIP); + for (i = 0; i <= teeth; i++) { + angle = i * 2.0f * (float) Math.PI / teeth; + GL11.glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), -width * 0.5f); + GL11.glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), -width * 0.5f); + GL11.glVertex3f(r1 * (float) Math.cos(angle + 3 * da), r1 * (float) Math.sin(angle + 3 * da), -width * 0.5f); + GL11.glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), -width * 0.5f); + } + GL11.glEnd(); + + /* draw back sides of teeth */ + GL11.glBegin(GL11.GL_QUADS); + for (i = 0; i < teeth; i++) { + angle = i * 2.0f * (float) Math.PI / teeth; + GL11.glVertex3f(r1 * (float) Math.cos(angle + 3 * da), r1 * (float) Math.sin(angle + 3 * da), -width * 0.5f); + GL11.glVertex3f(r2 * (float) Math.cos(angle + 2 * da), r2 * (float) Math.sin(angle + 2 * da), -width * 0.5f); + GL11.glVertex3f(r2 * (float) Math.cos(angle + da), r2 * (float) Math.sin(angle + da), -width * 0.5f); + GL11.glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), -width * 0.5f); + } + GL11.glEnd(); + + /* draw outward faces of teeth */ + GL11.glBegin(GL11.GL_QUAD_STRIP); + for (i = 0; i < teeth; i++) { + angle = i * 2.0f * (float) Math.PI / teeth; + GL11.glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), width * 0.5f); + GL11.glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), -width * 0.5f); + u = r2 * (float) Math.cos(angle + da) - r1 * (float) Math.cos(angle); + v = r2 * (float) Math.sin(angle + da) - r1 * (float) Math.sin(angle); + len = (float) Math.sqrt(u * u + v * v); + u /= len; + v /= len; + GL11.glNormal3f(v, -u, 0.0f); + GL11.glVertex3f(r2 * (float) Math.cos(angle + da), r2 * (float) Math.sin(angle + da), width * 0.5f); + GL11.glVertex3f(r2 * (float) Math.cos(angle + da), r2 * (float) Math.sin(angle + da), -width * 0.5f); + GL11.glNormal3f((float) Math.cos(angle), (float) Math.sin(angle), 0.0f); + GL11.glVertex3f(r2 * (float) Math.cos(angle + 2 * da), r2 * (float) Math.sin(angle + 2 * da), width * 0.5f); + GL11.glVertex3f(r2 * (float) Math.cos(angle + 2 * da), r2 * (float) Math.sin(angle + 2 * da), -width * 0.5f); + u = r1 * (float) Math.cos(angle + 3 * da) - r2 * (float) Math.cos(angle + 2 * da); + v = r1 * (float) Math.sin(angle + 3 * da) - r2 * (float) Math.sin(angle + 2 * da); + GL11.glNormal3f(v, -u, 0.0f); + GL11.glVertex3f(r1 * (float) Math.cos(angle + 3 * da), r1 * (float) Math.sin(angle + 3 * da), width * 0.5f); + GL11.glVertex3f(r1 * (float) Math.cos(angle + 3 * da), r1 * (float) Math.sin(angle + 3 * da), -width * 0.5f); + GL11.glNormal3f((float) Math.cos(angle), (float) Math.sin(angle), 0.0f); + } + GL11.glVertex3f(r1 * (float) Math.cos(0), r1 * (float) Math.sin(0), width * 0.5f); + GL11.glVertex3f(r1 * (float) Math.cos(0), r1 * (float) Math.sin(0), -width * 0.5f); + GL11.glEnd(); + + GL11.glShadeModel(GL11.GL_SMOOTH); + + /* draw inside radius cylinder */ + GL11.glBegin(GL11.GL_QUAD_STRIP); + for (i = 0; i <= teeth; i++) { + angle = i * 2.0f * (float) Math.PI / teeth; + GL11.glNormal3f(-(float) Math.cos(angle), -(float) Math.sin(angle), 0.0f); + GL11.glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), -width * 0.5f); + GL11.glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), width * 0.5f); + } + GL11.glEnd(); + } + + public static void main(String[] args) throws LWJGLException { + new AWTGears(); + } +} diff --git a/src/java/org/lwjgl/test/opengl/awt/AWTGearsCanvas.java b/src/java/org/lwjgl/test/opengl/awt/AWTGearsCanvas.java new file mode 100644 index 0000000..c6dbb9a --- /dev/null +++ b/src/java/org/lwjgl/test/opengl/awt/AWTGearsCanvas.java @@ -0,0 +1,325 @@ +/* + * 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.test.opengl.awt; + +import java.nio.FloatBuffer; + +import org.lwjgl.BufferUtils; +import org.lwjgl.LWJGLException; +import org.lwjgl.opengl.ARBTransposeMatrix; +import org.lwjgl.opengl.AWTGLCanvas; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GLContext; +import org.lwjgl.test.applet.Test; + +/** + *

    + * AWT version of the gears demo + *

    + * @version $Revision$ + * @author Brian Matzon + * $Id$ + */ +public class AWTGearsCanvas extends AWTGLCanvas implements Test { + + private float view_rotx = 20.0f; + + private float view_roty = 30.0f; + + private float view_rotz = 0.0f; + + private int gear1; + + private int gear2; + + private int gear3; + + private float angle = 0.0f; + + long startTime = 0; + long fps = 0; + int current_width; + int current_height; + + /** + * C'tor + */ + public AWTGearsCanvas() throws LWJGLException { + super(); + } + + public void paintGL() { + + if(startTime == 0) { + setup(); + startTime = System.currentTimeMillis() + 5000; + } + + try { + angle += 2.0f; + if (getWidth() != current_width || getHeight() != current_height) { + current_width = getWidth(); + current_height = getHeight(); + GL11.glViewport(0, 0, current_width, current_height); + } + GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); + + GL11.glPushMatrix(); + GL11.glRotatef(view_rotx, 1.0f, 0.0f, 0.0f); + GL11.glRotatef(view_roty, 0.0f, 1.0f, 0.0f); + GL11.glRotatef(view_rotz, 0.0f, 0.0f, 1.0f); + + GL11.glPushMatrix(); + GL11.glTranslatef(-3.0f, -2.0f, 0.0f); + GL11.glRotatef(angle, 0.0f, 0.0f, 1.0f); + GL11.glCallList(gear1); + GL11.glPopMatrix(); + + GL11.glPushMatrix(); + GL11.glTranslatef(3.1f, -2.0f, 0.0f); + GL11.glRotatef(-2.0f * angle - 9.0f, 0.0f, 0.0f, 1.0f); + GL11.glCallList(gear2); + GL11.glPopMatrix(); + + GL11.glPushMatrix(); + GL11.glTranslatef(-3.1f, 4.2f, 0.0f); + GL11.glRotatef(-2.0f * angle - 25.0f, 0.0f, 0.0f, 1.0f); + GL11.glCallList(gear3); + GL11.glPopMatrix(); + + GL11.glPopMatrix(); + swapBuffers(); + repaint(); + } catch (LWJGLException e) { + throw new RuntimeException(e); + } + if (startTime > System.currentTimeMillis()) { + fps++; + } else { + long timeUsed = 5000 + (startTime - System.currentTimeMillis()); + startTime = System.currentTimeMillis() + 5000; + System.out.println(fps + " frames in " + (float) (timeUsed / 1000f) + " seconds = " + + (fps / (timeUsed / 1000f))); + fps = 0; + } + } + + private void setup() { + // setup ogl + FloatBuffer pos = BufferUtils.createFloatBuffer(4).put(new float[] { 5.0f, 5.0f, 10.0f, 0.0f}); + FloatBuffer red = BufferUtils.createFloatBuffer(4).put(new float[] { 0.8f, 0.1f, 0.0f, 1.0f}); + FloatBuffer green = BufferUtils.createFloatBuffer(4).put(new float[] { 0.0f, 0.8f, 0.2f, 1.0f}); + FloatBuffer blue = BufferUtils.createFloatBuffer(4).put(new float[] { 0.2f, 0.2f, 1.0f, 1.0f}); + pos.flip(); + red.flip(); + green.flip(); + blue.flip(); + + GL11.glLight(GL11.GL_LIGHT0, GL11.GL_POSITION, pos); + GL11.glEnable(GL11.GL_CULL_FACE); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_LIGHT0); + GL11.glEnable(GL11.GL_DEPTH_TEST); + + /* make the gears */ + gear1 = GL11.glGenLists(1); + GL11.glNewList(gear1, GL11.GL_COMPILE); + GL11.glMaterial(GL11.GL_FRONT, GL11.GL_AMBIENT_AND_DIFFUSE, red); + gear(1.0f, 4.0f, 1.0f, 20, 0.7f); + GL11.glEndList(); + + gear2 = GL11.glGenLists(1); + GL11.glNewList(gear2, GL11.GL_COMPILE); + GL11.glMaterial(GL11.GL_FRONT, GL11.GL_AMBIENT_AND_DIFFUSE, green); + gear(0.5f, 2.0f, 2.0f, 10, 0.7f); + GL11.glEndList(); + + gear3 = GL11.glGenLists(1); + GL11.glNewList(gear3, GL11.GL_COMPILE); + GL11.glMaterial(GL11.GL_FRONT, GL11.GL_AMBIENT_AND_DIFFUSE, blue); + gear(1.3f, 2.0f, 0.5f, 10, 0.7f); + GL11.glEndList(); + + GL11.glEnable(GL11.GL_NORMALIZE); + + GL11.glMatrixMode(GL11.GL_PROJECTION); + + System.err.println("GL_VENDOR: " + GL11.glGetString(GL11.GL_VENDOR)); + System.err.println("GL_RENDERER: " + GL11.glGetString(GL11.GL_RENDERER)); + System.err.println("GL_VERSION: " + GL11.glGetString(GL11.GL_VERSION)); + System.err.println(); + System.err.println("glLoadTransposeMatrixfARB() supported: " + GLContext.getCapabilities().GL_ARB_transpose_matrix); + if (!GLContext.getCapabilities().GL_ARB_transpose_matrix) { + // --- not using extensions + GL11.glLoadIdentity(); + } else { + // --- using extensions + final FloatBuffer identityTranspose = BufferUtils.createFloatBuffer(16).put( + new float[] { 1, 0, 0, 0, 0, 1, 0, 0, + 0, 0, 1, 0, 0, 0, 0, 1}); + identityTranspose.flip(); + ARBTransposeMatrix.glLoadTransposeMatrixARB(identityTranspose); + } + + float h = (float) 300 / (float) 300; + GL11.glFrustum(-1.0f, 1.0f, -h, h, 5.0f, 60.0f); + GL11.glMatrixMode(GL11.GL_MODELVIEW); + GL11.glLoadIdentity(); + GL11.glTranslatef(0.0f, 0.0f, -40.0f); + } + + /** + * Draw a gear wheel. You'll probably want to call this function when + * building a display list since we do a lot of trig here. + * + * @param inner_radius radius of hole at center + * @param outer_radius radius at center of teeth + * @param width width of gear + * @param teeth number of teeth + * @param tooth_depth depth of tooth + */ + private void gear(float inner_radius, float outer_radius, float width, int teeth, float tooth_depth) { + int i; + float r0, r1, r2; + float angle, da; + float u, v, len; + + r0 = inner_radius; + r1 = outer_radius - tooth_depth / 2.0f; + r2 = outer_radius + tooth_depth / 2.0f; + + da = 2.0f * (float) Math.PI / teeth / 4.0f; + + GL11.glShadeModel(GL11.GL_FLAT); + + GL11.glNormal3f(0.0f, 0.0f, 1.0f); + + /* draw front face */ + GL11.glBegin(GL11.GL_QUAD_STRIP); + for (i = 0; i <= teeth; i++) { + angle = i * 2.0f * (float) Math.PI / teeth; + GL11.glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), width * 0.5f); + GL11.glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), width * 0.5f); + if (i < teeth) { + GL11.glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), width * 0.5f); + GL11.glVertex3f(r1 * (float) Math.cos(angle + 3.0f * da), r1 * (float) Math.sin(angle + 3.0f * da), + width * 0.5f); + } + } + GL11.glEnd(); + + /* draw front sides of teeth */ + GL11.glBegin(GL11.GL_QUADS); + for (i = 0; i < teeth; i++) { + angle = i * 2.0f * (float) Math.PI / teeth; + GL11.glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), width * 0.5f); + GL11.glVertex3f(r2 * (float) Math.cos(angle + da), r2 * (float) Math.sin(angle + da), width * 0.5f); + GL11.glVertex3f(r2 * (float) Math.cos(angle + 2.0f * da), r2 * (float) Math.sin(angle + 2.0f * da), width * 0.5f); + GL11.glVertex3f(r1 * (float) Math.cos(angle + 3.0f * da), r1 * (float) Math.sin(angle + 3.0f * da), width * 0.5f); + } + GL11.glEnd(); + + /* draw back face */ + GL11.glBegin(GL11.GL_QUAD_STRIP); + for (i = 0; i <= teeth; i++) { + angle = i * 2.0f * (float) Math.PI / teeth; + GL11.glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), -width * 0.5f); + GL11.glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), -width * 0.5f); + GL11.glVertex3f(r1 * (float) Math.cos(angle + 3 * da), r1 * (float) Math.sin(angle + 3 * da), -width * 0.5f); + GL11.glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), -width * 0.5f); + } + GL11.glEnd(); + + /* draw back sides of teeth */ + GL11.glBegin(GL11.GL_QUADS); + for (i = 0; i < teeth; i++) { + angle = i * 2.0f * (float) Math.PI / teeth; + GL11.glVertex3f(r1 * (float) Math.cos(angle + 3 * da), r1 * (float) Math.sin(angle + 3 * da), -width * 0.5f); + GL11.glVertex3f(r2 * (float) Math.cos(angle + 2 * da), r2 * (float) Math.sin(angle + 2 * da), -width * 0.5f); + GL11.glVertex3f(r2 * (float) Math.cos(angle + da), r2 * (float) Math.sin(angle + da), -width * 0.5f); + GL11.glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), -width * 0.5f); + } + GL11.glEnd(); + + /* draw outward faces of teeth */ + GL11.glBegin(GL11.GL_QUAD_STRIP); + for (i = 0; i < teeth; i++) { + angle = i * 2.0f * (float) Math.PI / teeth; + GL11.glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), width * 0.5f); + GL11.glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), -width * 0.5f); + u = r2 * (float) Math.cos(angle + da) - r1 * (float) Math.cos(angle); + v = r2 * (float) Math.sin(angle + da) - r1 * (float) Math.sin(angle); + len = (float) Math.sqrt(u * u + v * v); + u /= len; + v /= len; + GL11.glNormal3f(v, -u, 0.0f); + GL11.glVertex3f(r2 * (float) Math.cos(angle + da), r2 * (float) Math.sin(angle + da), width * 0.5f); + GL11.glVertex3f(r2 * (float) Math.cos(angle + da), r2 * (float) Math.sin(angle + da), -width * 0.5f); + GL11.glNormal3f((float) Math.cos(angle), (float) Math.sin(angle), 0.0f); + GL11.glVertex3f(r2 * (float) Math.cos(angle + 2 * da), r2 * (float) Math.sin(angle + 2 * da), width * 0.5f); + GL11.glVertex3f(r2 * (float) Math.cos(angle + 2 * da), r2 * (float) Math.sin(angle + 2 * da), -width * 0.5f); + u = r1 * (float) Math.cos(angle + 3 * da) - r2 * (float) Math.cos(angle + 2 * da); + v = r1 * (float) Math.sin(angle + 3 * da) - r2 * (float) Math.sin(angle + 2 * da); + GL11.glNormal3f(v, -u, 0.0f); + GL11.glVertex3f(r1 * (float) Math.cos(angle + 3 * da), r1 * (float) Math.sin(angle + 3 * da), width * 0.5f); + GL11.glVertex3f(r1 * (float) Math.cos(angle + 3 * da), r1 * (float) Math.sin(angle + 3 * da), -width * 0.5f); + GL11.glNormal3f((float) Math.cos(angle), (float) Math.sin(angle), 0.0f); + } + GL11.glVertex3f(r1 * (float) Math.cos(0), r1 * (float) Math.sin(0), width * 0.5f); + GL11.glVertex3f(r1 * (float) Math.cos(0), r1 * (float) Math.sin(0), -width * 0.5f); + GL11.glEnd(); + + GL11.glShadeModel(GL11.GL_SMOOTH); + + /* draw inside radius cylinder */ + GL11.glBegin(GL11.GL_QUAD_STRIP); + for (i = 0; i <= teeth; i++) { + angle = i * 2.0f * (float) Math.PI / teeth; + GL11.glNormal3f(-(float) Math.cos(angle), -(float) Math.sin(angle), 0.0f); + GL11.glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), -width * 0.5f); + GL11.glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), width * 0.5f); + } + GL11.glEnd(); + } + + /* + * @see org.lwjgl.test.applet.Test#start() + */ + public void start() { + } + + /* + * @see org.lwjgl.test.applet.Test#stop() + */ + public void stop() { + } +} \ No newline at end of file diff --git a/src/java/org/lwjgl/test/opengl/awt/AWTTest.java b/src/java/org/lwjgl/test/opengl/awt/AWTTest.java new file mode 100644 index 0000000..80e8af7 --- /dev/null +++ b/src/java/org/lwjgl/test/opengl/awt/AWTTest.java @@ -0,0 +1,139 @@ +/* + * 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.test.opengl.awt; + +import java.awt.Frame; +import java.awt.GridLayout; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; + +import org.lwjgl.LWJGLException; +import org.lwjgl.opengl.AWTGLCanvas; +import org.lwjgl.opengl.GL11; +import org.lwjgl.util.glu.GLU; + +/** + *

    + * Tests AWTGLCanvas functionality + *

    + * @version $Revision: 2983 $ + * @author $Author: matzon $ + * $Id: AWTTest.java 2983 2008-04-07 18:36:09Z matzon $ + */ +public class AWTTest extends Frame { + + /** AWT GL canvas */ + private AWTGLCanvas canvas0, canvas1; + + private volatile float angle; + + /** + * C'tor + */ + public AWTTest() throws LWJGLException { + setTitle("LWJGL AWT Canvas Test"); + setSize(640, 320); + setLayout(new GridLayout(1, 2)); + add(canvas0 = new AWTGLCanvas() { + int current_height; + int current_width; + public void paintGL() { + try { + if (getWidth() != current_width || getHeight() != current_height) { + current_width = getWidth(); + current_height = getHeight(); + GL11.glViewport(0, 0, current_width, current_height); + } + GL11.glViewport(0, 0, getWidth(), getHeight()); + GL11.glClearColor(1.0f, 0.0f, 0.0f, 1.0f); + GL11.glClear(GL11.GL_COLOR_BUFFER_BIT); + GL11.glMatrixMode(GL11.GL_PROJECTION); + GL11.glLoadIdentity(); + GLU.gluOrtho2D(0.0f, (float) getWidth(), 0.0f, (float) getHeight()); + GL11.glMatrixMode(GL11.GL_MODELVIEW); + GL11.glPushMatrix(); + GL11.glColor3f(1f, 1f, 0f); + GL11.glTranslatef(getWidth() / 2.0f, getHeight() / 2.0f, 0.0f); + GL11.glRotatef(angle, 0f, 0f, 1.0f); + GL11.glRectf(-50.0f, -50.0f, 50.0f, 50.0f); + GL11.glPopMatrix(); + swapBuffers(); + repaint(); + } catch (LWJGLException e) { + throw new RuntimeException(e); + } + } + }); + add(canvas1 = new AWTGLCanvas() { + int current_height; + int current_width; + public void paintGL() { + try { + angle += 1.0f; + if (getWidth() != current_width || getHeight() != current_height) { + current_width = getWidth(); + current_height = getHeight(); + GL11.glViewport(0, 0, current_width, current_height); + } + GL11.glViewport(0, 0, getWidth(), getHeight()); + GL11.glClearColor(0.0f, 1.0f, 0.0f, 1.0f); + GL11.glClear(GL11.GL_COLOR_BUFFER_BIT); + GL11.glMatrixMode(GL11.GL_PROJECTION); + GL11.glLoadIdentity(); + GLU.gluOrtho2D(0.0f, (float) getWidth(), 0.0f, (float) getHeight()); + GL11.glMatrixMode(GL11.GL_MODELVIEW); + GL11.glPushMatrix(); + GL11.glTranslatef(getWidth() / 2.0f, getHeight() / 2.0f, 0.0f); + GL11.glRotatef(2*angle, 0f, 0f, -1.0f); + GL11.glRectf(-50.0f, -50.0f, 50.0f, 50.0f); + GL11.glPopMatrix(); + swapBuffers(); + repaint(); + } catch (LWJGLException e) { + throw new RuntimeException(e); + } + } + }); + addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent e) { + dispose(); + System.exit(0); + } + }); + setResizable(true); + setVisible(true); + } + + public static void main(String[] args) throws LWJGLException { + new AWTTest(); + } +} diff --git a/src/java/org/lwjgl/test/opengl/awt/DemoBox.java b/src/java/org/lwjgl/test/opengl/awt/DemoBox.java new file mode 100644 index 0000000..9e4be2d --- /dev/null +++ b/src/java/org/lwjgl/test/opengl/awt/DemoBox.java @@ -0,0 +1,638 @@ +/* + * 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.test.opengl.awt; + +import java.awt.BorderLayout; +import java.awt.Button; +import java.awt.Frame; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Label; +import java.awt.List; +import java.awt.Panel; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.nio.FloatBuffer; +import java.util.Enumeration; +import java.util.Hashtable; + +import org.lwjgl.BufferUtils; +import org.lwjgl.LWJGLException; +import org.lwjgl.opengl.ARBTransposeMatrix; +import org.lwjgl.opengl.AWTGLCanvas; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GLContext; + +/** + *

    + *

    + * @version $Revision$ + * @author Brian Matzon + * $Id$ + */ +public class DemoBox extends Frame { + + /** GL canvas */ + private DemoBoxGLCanvas demoCanvas; + + /** Demo selection panel */ + private Panel selectionPanel; + + /** Hashtable of demos */ + private Hashtable selectableDemos; + + /** + * Creates a new demo box instance + */ + public DemoBox() { + selectableDemos = new Hashtable(); + selectableDemos.put("default", new NullDemoBox()); + selectableDemos.put("clear_color", new ClearColorDemoBox()); + selectableDemos.put("gears", new GearsDemoBox()); + } + + /** + * @return + */ + public boolean initialize() { + setTitle("LWJGL - Demo Box"); + setSize(640, 480); + setLayout(new GridBagLayout()); + + // Setup selection panel + // ================================= + selectionPanel = new Panel(); + selectionPanel.setLayout(new BorderLayout()); + selectionPanel.add(new Label("Demo", Label.CENTER), BorderLayout.NORTH); + + Button fullScreen = new Button("Fullscreen"); + fullScreen.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent event) { + toggleFullscreen(); + } + }); + selectionPanel.add(fullScreen, BorderLayout.SOUTH); + + final List demos = new List(); + for (Enumeration e = selectableDemos.keys(); e.hasMoreElements();) { + demos.add(e.nextElement().toString()); + } + selectionPanel.add(demos, BorderLayout.CENTER); + + demos.addItemListener(new ItemListener() { + + public void itemStateChanged(ItemEvent event) { + demoSelected(event.getItemSelectable().getSelectedObjects()[0].toString()); + } + }); + + GridBagConstraints gbc = new GridBagConstraints(); + gbc.gridx = 0; + gbc.gridy = 0; + gbc.fill = java.awt.GridBagConstraints.BOTH; + gbc.weightx = 0.05; + gbc.weighty = 1.0; + add(selectionPanel, gbc); + // --------------------------------- + + // setup demo canvas + // ================================= + try { + demoCanvas = new DemoBoxGLCanvas(this); + + gbc = new GridBagConstraints(); + gbc.gridx = 1; + gbc.gridy = 0; + gbc.fill = java.awt.GridBagConstraints.BOTH; + gbc.weightx = 0.95; + gbc.weighty = 1.0; + add(demoCanvas, gbc); + } catch (LWJGLException le) { + le.printStackTrace(); + return false; + } + // --------------------------------- + + addWindowListener(new WindowAdapter() { + + public void windowClosing(WindowEvent e) { + demoCanvas.destroy(); + dispose(); + System.exit(0); + } + }); + + //demos.select(0); + //demoSelected(demos.getSelectedItem()); + return true; + } + + public void updateFPS(float fps) { + if(fps != -1) { + setTitle("LWJGL - Demo Box (FPS: " + fps + ")"); + } else { + setTitle("LWJGL - Demo Box"); + } + } + + /** + * Enter fullscreen mode for this demo + */ + protected void toggleFullscreen() { + System.out.println("Toggle Fullscreen"); + } + + /** + * Selected a demo + * @param demo Name of demo that was selected + */ + protected void demoSelected(String demo) { + System.out.println("Selecting demo: " + demo); + demoCanvas.setActiveDemo((Demo) selectableDemos.get(demo)); + } + + /** + * @param args + * @throws LWJGLException + */ + public static void main(String[] args) throws LWJGLException { + DemoBox demo = new DemoBox(); + demo.initialize(); + demo.setVisible(true); + } + + /** + * Interface for a demo + */ + public interface Demo { + public boolean isInitialized(); + public boolean initialize(); + public void render(); + public void destroy(); + } + + /** + * + */ + private class DemoBoxGLCanvas extends AWTGLCanvas implements Runnable { + + /** Parent demo box */ + DemoBox parent; + + /** Currently active demo */ + Demo activeDemo; + + /** last active demo */ + Demo lastActiveDemo; + + /** Render thread */ + private Thread renderThread; + + public DemoBoxGLCanvas(DemoBox parent) throws LWJGLException { + super(); + this.parent = parent; + } + + // FPS + long startTime = 0; + long fps = 0; + + protected void paintGL() { + synchronized (this) { + if (lastActiveDemo != null && lastActiveDemo != activeDemo) { + lastActiveDemo.destroy(); + lastActiveDemo = null; + if (activeDemo != null) { + activeDemo.initialize(); + startTime = System.currentTimeMillis() + 5000; + } else { + parent.updateFPS(-1); + } + } + + if (activeDemo != null) { + + if(!activeDemo.isInitialized()) { + activeDemo.initialize(); + } + + activeDemo.render(); + try { + swapBuffers(); + } catch (LWJGLException le) { + le.printStackTrace(); + } + + if (startTime > System.currentTimeMillis()) { + fps++; + } else { + long timeUsed = 5000 + (startTime - System.currentTimeMillis()); + startTime = System.currentTimeMillis() + 5000; + parent.updateFPS((fps / (timeUsed / 1000f))); + fps = 0; + } + } + } + } + + public void destroy() { + setActiveDemo(null); + renderThread = null; + } + + public void setActiveDemo(Demo activeDemo) { + synchronized (this) { + // setting no current demo + if (activeDemo == null) { + lastActiveDemo = this.activeDemo; + this.activeDemo = null; + return; + } + + // setting to new demo + lastActiveDemo = this.activeDemo; + this.activeDemo = activeDemo; + } + + if (renderThread == null) { + renderThread = new Thread(this); + renderThread.setName("DemoBox-Renderer"); + renderThread.start(); + } + } + + public DemoBoxGLCanvas() throws LWJGLException { + super(); + } + + public void run() { + long sleep_time = 1000; + while (renderThread != null) { + + // check for change of demo + synchronized (this) { + // if no demo set, just sleep + if (activeDemo == null) { + sleep_time = 1000; + } else { + // we have a demo! + sleep_time = 16; + repaint(); + } + } + sleep(sleep_time); + } + System.out.println("dead"); + } + + private void sleep(long time) { + try { + Thread.sleep(time); + } catch (InterruptedException inte) { + } + } + } + + // Demo box demo + // ======================================================== + public class ClearColorDemoBox implements Demo { + + private boolean initialized; + + int direction = 1; + + float color; + + public boolean isInitialized() { + return initialized; + } + + public boolean initialize() { + return initialized = true; + } + + public void render() { + GL11.glClearColor(color, color, color, 1f); + GL11.glClear(GL11.GL_COLOR_BUFFER_BIT); + + color += direction * .05f; + + if (color > 1f) { + color = 1f; + direction = -1 * direction; + } else if (color < 0f) { + direction = -1 * direction; + color = 0f; + } + } + + public void destroy() { + initialized = false; + } + } + + // -------------------------------------------------------- + + // Demo box demo + // ======================================================== + public class NullDemoBox implements Demo { + + private boolean initialized; + + public boolean isInitialized() { + return initialized; + } + + public boolean initialize() { + GL11.glClearColor(0, 0, 0, 1f); + return true; + } + + public void render() { + GL11.glClear(GL11.GL_COLOR_BUFFER_BIT); + } + + public void destroy() { + initialized = false; + } + } + // -------------------------------------------------------- + + // Demo box demo + // ======================================================== + public class GearsDemoBox implements Demo { + + private boolean initialized; + + private float view_rotx = 20.0f; + + private float view_roty = 30.0f; + + private float view_rotz = 0.0f; + + private int gear1; + + private int gear2; + + private int gear3; + + private float angle = 0.0f; + + public boolean isInitialized() { + return initialized; + } + + public boolean initialize() { + // setup ogl + FloatBuffer pos = BufferUtils.createFloatBuffer(4).put(new float[] { 5.0f, 5.0f, 10.0f, 0.0f}); + FloatBuffer red = BufferUtils.createFloatBuffer(4).put(new float[] { 0.8f, 0.1f, 0.0f, 1.0f}); + FloatBuffer green = BufferUtils.createFloatBuffer(4).put(new float[] { 0.0f, 0.8f, 0.2f, 1.0f}); + FloatBuffer blue = BufferUtils.createFloatBuffer(4).put(new float[] { 0.2f, 0.2f, 1.0f, 1.0f}); + pos.flip(); + red.flip(); + green.flip(); + blue.flip(); + + GL11.glClearColor(0, 0, 0, 1f); + + GL11.glLight(GL11.GL_LIGHT0, GL11.GL_POSITION, pos); + GL11.glEnable(GL11.GL_CULL_FACE); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_LIGHT0); + GL11.glEnable(GL11.GL_DEPTH_TEST); + + /* make the gears */ + gear1 = GL11.glGenLists(1); + GL11.glNewList(gear1, GL11.GL_COMPILE); + GL11.glMaterial(GL11.GL_FRONT, GL11.GL_AMBIENT_AND_DIFFUSE, red); + gear(1.0f, 4.0f, 1.0f, 20, 0.7f); + GL11.glEndList(); + + gear2 = GL11.glGenLists(1); + GL11.glNewList(gear2, GL11.GL_COMPILE); + GL11.glMaterial(GL11.GL_FRONT, GL11.GL_AMBIENT_AND_DIFFUSE, green); + gear(0.5f, 2.0f, 2.0f, 10, 0.7f); + GL11.glEndList(); + + gear3 = GL11.glGenLists(1); + GL11.glNewList(gear3, GL11.GL_COMPILE); + GL11.glMaterial(GL11.GL_FRONT, GL11.GL_AMBIENT_AND_DIFFUSE, blue); + gear(1.3f, 2.0f, 0.5f, 10, 0.7f); + GL11.glEndList(); + + GL11.glEnable(GL11.GL_NORMALIZE); + + GL11.glMatrixMode(GL11.GL_PROJECTION); + + System.err.println("GL_VENDOR: " + GL11.glGetString(GL11.GL_VENDOR)); + System.err.println("GL_RENDERER: " + GL11.glGetString(GL11.GL_RENDERER)); + System.err.println("GL_VERSION: " + GL11.glGetString(GL11.GL_VERSION)); + System.err.println(); + System.err.println("glLoadTransposeMatrixfARB() supported: " + GLContext.getCapabilities().GL_ARB_transpose_matrix); + if (!GLContext.getCapabilities().GL_ARB_transpose_matrix) { + // --- not using extensions + GL11.glLoadIdentity(); + } else { + // --- using extensions + final FloatBuffer identityTranspose = BufferUtils.createFloatBuffer(16).put( + new float[] { 1, 0, 0, 0, 0, 1, 0, 0, + 0, 0, 1, 0, 0, 0, 0, 1}); + identityTranspose.flip(); + ARBTransposeMatrix.glLoadTransposeMatrixARB(identityTranspose); + } + + float h = (float) 300 / (float) 300; + GL11.glFrustum(-1.0f, 1.0f, -h, h, 5.0f, 60.0f); + GL11.glMatrixMode(GL11.GL_MODELVIEW); + GL11.glLoadIdentity(); + GL11.glTranslatef(0.0f, 0.0f, -40.0f); + return initialized = true; + } + + public void render() { + angle += 2.0f; + GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); + + GL11.glPushMatrix(); + GL11.glRotatef(view_rotx, 1.0f, 0.0f, 0.0f); + GL11.glRotatef(view_roty, 0.0f, 1.0f, 0.0f); + GL11.glRotatef(view_rotz, 0.0f, 0.0f, 1.0f); + + GL11.glPushMatrix(); + GL11.glTranslatef(-3.0f, -2.0f, 0.0f); + GL11.glRotatef(angle, 0.0f, 0.0f, 1.0f); + GL11.glCallList(gear1); + GL11.glPopMatrix(); + + GL11.glPushMatrix(); + GL11.glTranslatef(3.1f, -2.0f, 0.0f); + GL11.glRotatef(-2.0f * angle - 9.0f, 0.0f, 0.0f, 1.0f); + GL11.glCallList(gear2); + GL11.glPopMatrix(); + + GL11.glPushMatrix(); + GL11.glTranslatef(-3.1f, 4.2f, 0.0f); + GL11.glRotatef(-2.0f * angle - 25.0f, 0.0f, 0.0f, 1.0f); + GL11.glCallList(gear3); + GL11.glPopMatrix(); + + GL11.glPopMatrix(); + } + + /** + * Draw a gear wheel. You'll probably want to call this function when + * building a display list since we do a lot of trig here. + * + * @param inner_radius radius of hole at center + * @param outer_radius radius at center of teeth + * @param width width of gear + * @param teeth number of teeth + * @param tooth_depth depth of tooth + */ + private void gear(float inner_radius, float outer_radius, float width, int teeth, float tooth_depth) { + int i; + float r0, r1, r2; + float angle, da; + float u, v, len; + + r0 = inner_radius; + r1 = outer_radius - tooth_depth / 2.0f; + r2 = outer_radius + tooth_depth / 2.0f; + + da = 2.0f * (float) Math.PI / teeth / 4.0f; + + GL11.glShadeModel(GL11.GL_FLAT); + + GL11.glNormal3f(0.0f, 0.0f, 1.0f); + + /* draw front face */ + GL11.glBegin(GL11.GL_QUAD_STRIP); + for (i = 0; i <= teeth; i++) { + angle = i * 2.0f * (float) Math.PI / teeth; + GL11.glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), width * 0.5f); + GL11.glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), width * 0.5f); + if (i < teeth) { + GL11.glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), width * 0.5f); + GL11.glVertex3f(r1 * (float) Math.cos(angle + 3.0f * da), r1 * (float) Math.sin(angle + 3.0f * da), + width * 0.5f); + } + } + GL11.glEnd(); + + /* draw front sides of teeth */ + GL11.glBegin(GL11.GL_QUADS); + for (i = 0; i < teeth; i++) { + angle = i * 2.0f * (float) Math.PI / teeth; + GL11.glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), width * 0.5f); + GL11.glVertex3f(r2 * (float) Math.cos(angle + da), r2 * (float) Math.sin(angle + da), width * 0.5f); + GL11.glVertex3f(r2 * (float) Math.cos(angle + 2.0f * da), r2 * (float) Math.sin(angle + 2.0f * da), width * 0.5f); + GL11.glVertex3f(r1 * (float) Math.cos(angle + 3.0f * da), r1 * (float) Math.sin(angle + 3.0f * da), width * 0.5f); + } + GL11.glEnd(); + + /* draw back face */ + GL11.glBegin(GL11.GL_QUAD_STRIP); + for (i = 0; i <= teeth; i++) { + angle = i * 2.0f * (float) Math.PI / teeth; + GL11.glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), -width * 0.5f); + GL11.glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), -width * 0.5f); + GL11.glVertex3f(r1 * (float) Math.cos(angle + 3 * da), r1 * (float) Math.sin(angle + 3 * da), -width * 0.5f); + GL11.glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), -width * 0.5f); + } + GL11.glEnd(); + + /* draw back sides of teeth */ + GL11.glBegin(GL11.GL_QUADS); + for (i = 0; i < teeth; i++) { + angle = i * 2.0f * (float) Math.PI / teeth; + GL11.glVertex3f(r1 * (float) Math.cos(angle + 3 * da), r1 * (float) Math.sin(angle + 3 * da), -width * 0.5f); + GL11.glVertex3f(r2 * (float) Math.cos(angle + 2 * da), r2 * (float) Math.sin(angle + 2 * da), -width * 0.5f); + GL11.glVertex3f(r2 * (float) Math.cos(angle + da), r2 * (float) Math.sin(angle + da), -width * 0.5f); + GL11.glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), -width * 0.5f); + } + GL11.glEnd(); + + /* draw outward faces of teeth */ + GL11.glBegin(GL11.GL_QUAD_STRIP); + for (i = 0; i < teeth; i++) { + angle = i * 2.0f * (float) Math.PI / teeth; + GL11.glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), width * 0.5f); + GL11.glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), -width * 0.5f); + u = r2 * (float) Math.cos(angle + da) - r1 * (float) Math.cos(angle); + v = r2 * (float) Math.sin(angle + da) - r1 * (float) Math.sin(angle); + len = (float) Math.sqrt(u * u + v * v); + u /= len; + v /= len; + GL11.glNormal3f(v, -u, 0.0f); + GL11.glVertex3f(r2 * (float) Math.cos(angle + da), r2 * (float) Math.sin(angle + da), width * 0.5f); + GL11.glVertex3f(r2 * (float) Math.cos(angle + da), r2 * (float) Math.sin(angle + da), -width * 0.5f); + GL11.glNormal3f((float) Math.cos(angle), (float) Math.sin(angle), 0.0f); + GL11.glVertex3f(r2 * (float) Math.cos(angle + 2 * da), r2 * (float) Math.sin(angle + 2 * da), width * 0.5f); + GL11.glVertex3f(r2 * (float) Math.cos(angle + 2 * da), r2 * (float) Math.sin(angle + 2 * da), -width * 0.5f); + u = r1 * (float) Math.cos(angle + 3 * da) - r2 * (float) Math.cos(angle + 2 * da); + v = r1 * (float) Math.sin(angle + 3 * da) - r2 * (float) Math.sin(angle + 2 * da); + GL11.glNormal3f(v, -u, 0.0f); + GL11.glVertex3f(r1 * (float) Math.cos(angle + 3 * da), r1 * (float) Math.sin(angle + 3 * da), width * 0.5f); + GL11.glVertex3f(r1 * (float) Math.cos(angle + 3 * da), r1 * (float) Math.sin(angle + 3 * da), -width * 0.5f); + GL11.glNormal3f((float) Math.cos(angle), (float) Math.sin(angle), 0.0f); + } + GL11.glVertex3f(r1 * (float) Math.cos(0), r1 * (float) Math.sin(0), width * 0.5f); + GL11.glVertex3f(r1 * (float) Math.cos(0), r1 * (float) Math.sin(0), -width * 0.5f); + GL11.glEnd(); + + GL11.glShadeModel(GL11.GL_SMOOTH); + + /* draw inside radius cylinder */ + GL11.glBegin(GL11.GL_QUAD_STRIP); + for (i = 0; i <= teeth; i++) { + angle = i * 2.0f * (float) Math.PI / teeth; + GL11.glNormal3f(-(float) Math.cos(angle), -(float) Math.sin(angle), 0.0f); + GL11.glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), -width * 0.5f); + GL11.glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), width * 0.5f); + } + GL11.glEnd(); + } + + public void destroy() { + GL11.glDeleteLists(gear1, 1); + GL11.glDeleteLists(gear2, 1); + GL11.glDeleteLists(gear3, 1); + initialized = false; + } + } + // -------------------------------------------------------- +} diff --git a/src/java/org/lwjgl/test/opengl/awt/DisplayParentTest.java b/src/java/org/lwjgl/test/opengl/awt/DisplayParentTest.java new file mode 100644 index 0000000..e5848db --- /dev/null +++ b/src/java/org/lwjgl/test/opengl/awt/DisplayParentTest.java @@ -0,0 +1,132 @@ +/* + * 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.test.opengl.awt; + +import java.awt.Canvas; +import java.awt.Frame; +import java.awt.GridLayout; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; + +import org.lwjgl.LWJGLException; +import org.lwjgl.input.Keyboard; +import org.lwjgl.input.Mouse; +import org.lwjgl.opengl.Display; +import org.lwjgl.opengl.GL11; +import org.lwjgl.util.glu.GLU; + +/** + *

    + * Tests Display.setParent() + *

    + * @version $Revision: 3102 $ + * @author $Author: matzon $ + * $Id: DisplayParentTest.java 3102 2008-06-08 09:30:24Z matzon $ + */ +public class DisplayParentTest extends Frame { + boolean killswitch = false; + public DisplayParentTest() throws LWJGLException { + setTitle("LWJGL Display Parent Test"); + setSize(640, 320); + setLayout(new GridLayout(1, 2)); + final Canvas display_parent = new Canvas(); + display_parent.setFocusable(true); + display_parent.setIgnoreRepaint(true); + add(display_parent); + addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent e) { + killswitch = true; + } + }); + setResizable(true); + setVisible(true); + Display.setParent(display_parent); + Display.setVSyncEnabled(true); + Display.create(); + float angle = 0f; + + while (isVisible() && !killswitch) { + angle += 1.0f; + int width; + int height; + if (!Display.isFullscreen()) { + width = display_parent.getWidth(); + height = display_parent.getHeight(); + } else { + width = Display.getDisplayMode().getWidth(); + height = Display.getDisplayMode().getHeight(); + } + + if(width < 1 || height < 1) { + continue; + } + + GL11.glViewport(0, 0, width, height); + GL11.glClearColor(0.0f, 1.0f, 0.0f, 1.0f); + GL11.glClear(GL11.GL_COLOR_BUFFER_BIT); + GL11.glMatrixMode(GL11.GL_PROJECTION); + GL11.glLoadIdentity(); + GLU.gluOrtho2D(0.0f, (float) width, 0.0f, (float) height); + GL11.glMatrixMode(GL11.GL_MODELVIEW); + GL11.glPushMatrix(); + GL11.glTranslatef(width / 2.0f, height / 2.0f, 0.0f); + GL11.glRotatef(2*angle, 0f, 0f, -1.0f); + GL11.glRectf(-50.0f, -50.0f, 50.0f, 50.0f); + GL11.glPopMatrix(); + Display.update(); + while(Keyboard.next()) { + // closing on ESCAPE + if(Keyboard.getEventKey() == Keyboard.KEY_ESCAPE && Keyboard.getEventKeyState()) { + Display.destroy(); + dispose(); + break; + } + + if(Keyboard.getEventKey() == Keyboard.KEY_SPACE && Keyboard.getEventKeyState()) { + Mouse.setGrabbed(!Mouse.isGrabbed()); + } + if(Keyboard.getEventKey() == Keyboard.KEY_F && Keyboard.getEventKeyState()) { + Display.setFullscreen(!Display.isFullscreen()); + } + } +/* while (Mouse.next()) { +System.out.println(" Mouse.getEventX() = " + Mouse.getEventX() + " | Mouse.getEventY() = " + Mouse.getEventY()); + }*/ + } + Display.destroy(); + dispose(); + } + + public static void main(String[] args) throws LWJGLException { + new DisplayParentTest(); + } +} diff --git a/src/java/org/lwjgl/test/opengl/pbuffers/PbufferTest.java b/src/java/org/lwjgl/test/opengl/pbuffers/PbufferTest.java new file mode 100644 index 0000000..4f822ca --- /dev/null +++ b/src/java/org/lwjgl/test/opengl/pbuffers/PbufferTest.java @@ -0,0 +1,438 @@ +/* + * 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.test.opengl.pbuffers; + +import java.nio.IntBuffer; + +import org.lwjgl.BufferUtils; +import org.lwjgl.LWJGLException; +import org.lwjgl.input.Keyboard; +import org.lwjgl.opengl.Display; +import org.lwjgl.opengl.DisplayMode; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.Pbuffer; +import org.lwjgl.opengl.PixelFormat; +import org.lwjgl.util.glu.GLU; +import org.lwjgl.util.vector.Vector2f; + +/** + *

    + * Tests Pbuffers + * + * @author elias_naur + * @version $Revision: 2983 $ + * $Id: PbufferTest.java 2983 2008-04-07 18:36:09Z matzon $ + */ +public final class PbufferTest { + + /** + * Texture and pbuffer size + */ + private static final int TEXTURE_SIZE = 512; + + /** + * Size of the animated quad + */ + private static final int QUAD_SIZE = 64; + + /** + * The renderer to use when rendering to texture. + */ + private TextureRenderer texRenderer; + + /** + * Intended deiplay mode + */ + private DisplayMode mode; + + /** + * our quad moving around + */ + private Vector2f quadPosition; + + /** + * For positioning our quad in the texture + */ + private float texScaleX, texScaleY; + + /** + * our quadVelocity + */ + private Vector2f quadVelocity; + + /** + * angle of quad + */ + private float angle; + + /** + * degrees to rotate per frame + */ + private float angleRotation = 1.0f; + + /** + * Max speed of all changable attributes + */ + private static final float MAX_SPEED = 20.0f; + + /** + * The shared texture + */ + private static int texID; + + public PbufferTest(final int renderMode) { + try { + //find displaymode + mode = findDisplayMode(800, 600, 16); + Display.setDisplayMode(mode); + Display.create(new PixelFormat(16, 0, 0, 0, 0)); + + glInit(); + + if ( (Pbuffer.getCapabilities() & Pbuffer.PBUFFER_SUPPORTED) == 0 ) { + System.out.println("No Pbuffer support!"); + System.exit(-1); + } + System.out.println("Pbuffer support detected. Initializing...\n"); + + switch ( renderMode ) { + case 1: + System.out.print("Creating pbuffer with unique context..."); + texRenderer = new UniqueRenderer(TEXTURE_SIZE, TEXTURE_SIZE, texID); + break; + case 2: + System.out.print("Creating render-to-texture pbuffer with unique context..."); + texRenderer = new UniqueRendererRTT(TEXTURE_SIZE, TEXTURE_SIZE, texID); + break; + } + + System.out.println("OK"); + + quadPosition = new Vector2f(100f, 100f); + quadVelocity = new Vector2f(1.0f, 1.0f); + + texScaleX = TEXTURE_SIZE / (float)mode.getWidth(); + texScaleY = TEXTURE_SIZE / (float)mode.getHeight(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * Executes the test + */ + public void execute() { + mainLoop(); + cleanup(); + } + + /** + * Runs the main loop of the "test" + */ + private void mainLoop() { + while ( !Keyboard.isKeyDown(Keyboard.KEY_ESCAPE) && !Display.isCloseRequested() ) { + if ( Display.isVisible() ) { + // check keyboard input + processKeyboard(); + + // do "game" logic, and render it + logic(); + + render(); + } else { + // no need to render/paint if nothing has changed (ie. window dragged over) + if ( Display.isDirty() ) + render(); + + + // don't waste cpu time, sleep more + try { + Thread.sleep(100); + } catch (InterruptedException inte) { + } + } + // Update window + Display.update(); + // Sync + Display.sync(100); + } + } + + /** + * Performs the logic + */ + private void logic() { + angle += angleRotation; + if ( angle > 360.0f ) + angle -= 360.0f; + + quadPosition.x += quadVelocity.x; + quadPosition.y += quadVelocity.y; + + // check colision with vertical border border + if ( quadPosition.x + QUAD_SIZE >= mode.getWidth() || quadPosition.x - QUAD_SIZE <= 0 ) + quadVelocity.x *= -1; + + // check collision with horizontal border + if ( quadPosition.y + QUAD_SIZE >= mode.getHeight() || quadPosition.y - QUAD_SIZE <= 0 ) + quadVelocity.y *= -1; + } + + private void render() { + // ----------------------------------------------------------- + // -------------------- Pbuffer rendering -------------------- + // ----------------------------------------------------------- + // Tell the pbuffer to get ready for rendering + texRenderer.enable(); + + // Clear the background + GL11.glClear(GL11.GL_COLOR_BUFFER_BIT); + + // Draw quad with gradient + GL11.glPushMatrix(); + { + GL11.glTranslatef(quadPosition.x * texScaleX, quadPosition.y * texScaleY, 0); + GL11.glRotatef(angle, 0.0f, 0.0f, 1.0f); + GL11.glBegin(GL11.GL_QUADS); + { + GL11.glColor3f(1.0f, 0.0f, 0.0f); + GL11.glVertex2i(-QUAD_SIZE, -QUAD_SIZE); + GL11.glVertex2i(QUAD_SIZE, -QUAD_SIZE); + GL11.glColor3f(0.0f, 0.0f, 1.0f); + GL11.glVertex2i(QUAD_SIZE, QUAD_SIZE); + GL11.glVertex2i(-QUAD_SIZE, QUAD_SIZE); + } + GL11.glEnd(); + } + GL11.glPopMatrix(); + + // Refresh the texture + texRenderer.updateTexture(); + + // ----------------------------------------------------------- + // -------------------- Display rendering -------------------- + // ----------------------------------------------------------- + try { + Display.makeCurrent(); + } catch (LWJGLException e) { + throw new RuntimeException(e); + } + + GL11.glClear(GL11.GL_COLOR_BUFFER_BIT); + + // draw white quad + GL11.glPushMatrix(); + { + GL11.glTranslatef(quadPosition.x, quadPosition.y, 0); + GL11.glRotatef(angle, 0.0f, 0.0f, 1.0f); + GL11.glColor3f(1.0f, 1.0f, 1.0f); + GL11.glBegin(GL11.GL_QUADS); + { + GL11.glTexCoord2f(0f, 0f); + GL11.glVertex2i(-QUAD_SIZE, -QUAD_SIZE); + GL11.glTexCoord2f(1f, 0f); + GL11.glVertex2i(QUAD_SIZE, -QUAD_SIZE); + GL11.glTexCoord2f(1f, 1f); + GL11.glVertex2i(QUAD_SIZE, QUAD_SIZE); + GL11.glTexCoord2f(0f, 1f); + GL11.glVertex2i(-QUAD_SIZE, QUAD_SIZE); + } + GL11.glEnd(); + } + GL11.glPopMatrix(); + } + + /** + * Processes keyboard input + */ + private void processKeyboard() { + Keyboard.poll(); + + //check for fullscreen key + if ( Keyboard.isKeyDown(Keyboard.KEY_F) ) { + try { + Display.setDisplayMode(mode); + Display.setFullscreen(true); + } catch (Exception e) { + e.printStackTrace(); + } + } + + //check for window key + if ( Keyboard.isKeyDown(Keyboard.KEY_W) ) { + try { + Display.setFullscreen(false); + } catch (Exception e) { + e.printStackTrace(); + } + } + + //check for speed changes + if ( Keyboard.isKeyDown(Keyboard.KEY_UP) ) + quadVelocity.y += 0.1f; + if ( Keyboard.isKeyDown(Keyboard.KEY_DOWN) ) + quadVelocity.y -= 0.1f; + if ( Keyboard.isKeyDown(Keyboard.KEY_RIGHT) ) + quadVelocity.x += 0.1f; + if ( Keyboard.isKeyDown(Keyboard.KEY_LEFT) ) + quadVelocity.x -= 0.1f; + + if ( Keyboard.isKeyDown(Keyboard.KEY_ADD) ) + angleRotation += 0.1f; + if ( Keyboard.isKeyDown(Keyboard.KEY_SUBTRACT) ) + angleRotation -= 0.1f; + + //throttle + if ( quadVelocity.x < -MAX_SPEED ) + quadVelocity.x = -MAX_SPEED; + if ( quadVelocity.x > MAX_SPEED ) + quadVelocity.x = MAX_SPEED; + if ( quadVelocity.y < -MAX_SPEED ) + quadVelocity.y = -MAX_SPEED; + if ( quadVelocity.y > MAX_SPEED ) + quadVelocity.y = MAX_SPEED; + + if ( angleRotation < 0.0f ) + angleRotation = 0.0f; + if ( angleRotation > MAX_SPEED ) + angleRotation = MAX_SPEED; + } + + /** + * Cleans up the test + */ + private void cleanup() { + // Destroy texture + IntBuffer buffer = BufferUtils.createIntBuffer(1); + buffer.put(0, texID); + GL11.glDeleteTextures(buffer); + + texRenderer.destroy(); + Display.destroy(); + } + + /** + * Retrieves a displaymode, if one such is available + * + * @param width Required width + * @param height Required height + * @param bpp Minimum required bits per pixel + * + * @return + */ + private DisplayMode findDisplayMode(int width, int height, int bpp) throws LWJGLException { + DisplayMode[] modes = Display.getAvailableDisplayModes(); + for ( int i = 0; i < modes.length; i++ ) { + if ( modes[i].getWidth() == width + && modes[i].getHeight() == height + && modes[i].getBitsPerPixel() >= bpp ) { + return modes[i]; + } + } + return null; + } + + static void initGLState(int width, int height, float color) { + GL11.glMatrixMode(GL11.GL_PROJECTION); + GL11.glLoadIdentity(); + GLU.gluOrtho2D(0, width, 0, height); + + GL11.glMatrixMode(GL11.GL_MODELVIEW); + GL11.glLoadIdentity(); + GL11.glViewport(0, 0, width, height); + + //set clear color + GL11.glClearColor(color, color, color, 0.0f); + } + + /** + * Initializes OGL + */ + private void glInit() { + // Sync frame (only works on windows) + Display.setVSyncEnabled(true); + + // Create shared texture + IntBuffer buffer = BufferUtils.createIntBuffer(1); + GL11.glGenTextures(buffer); + texID = buffer.get(0); + + GL11.glTexEnvf(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_MODULATE); + GL11.glEnable(GL11.GL_TEXTURE_2D); + + GL11.glBindTexture(GL11.GL_TEXTURE_2D, texID); + + GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_CLAMP); + GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_CLAMP); + GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR); + GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR); + + initGLState(mode.getWidth(), mode.getHeight(), 0.0f); + } + + /** + * Test entry point + */ + public static void main(String[] args) { + if ( args.length != 1 ) + kill("Invalid arguments length."); + + int mode = -1; + try { + mode = Integer.parseInt(args[0]); + } catch (NumberFormatException e) { + kill("Invalid mode."); + } + + if ( mode != 1 && mode != 2 ) + kill("Invalid mode."); + + System.out.println("Change between fullscreen and windowed mode, by pressing F and W respectively"); + System.out.println("Move quad using arrowkeys, and change rotation using +/-"); + + PbufferTest test = new PbufferTest(mode); + + test.execute(); + System.exit(0); + } + + private static void kill(final String msg) { + System.out.println(msg); + System.out.println("-------"); + System.out.println("Usage: java org.lwjgl.test.opengl.pbuffer.PbufferTest "); + System.out.println("\n."); + System.out.println("\t1: no render-to-texture"); + System.out.println("\t2: with render-to-texture"); + + System.exit(-1); + } +} diff --git a/src/java/org/lwjgl/test/opengl/pbuffers/TextureRenderer.java b/src/java/org/lwjgl/test/opengl/pbuffers/TextureRenderer.java new file mode 100644 index 0000000..a8a2f77 --- /dev/null +++ b/src/java/org/lwjgl/test/opengl/pbuffers/TextureRenderer.java @@ -0,0 +1,101 @@ +/* + * 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.test.opengl.pbuffers; + +import org.lwjgl.LWJGLException; +import org.lwjgl.opengl.Pbuffer; + +/** + * Implementations of this class should create a pbuffer and implement "render-to-texture" accordingly. + */ +abstract class TextureRenderer { + + protected final int width; + protected final int height; + private final int texID; + + protected Pbuffer pbuffer; + + protected TextureRenderer(final int width, final int height, final int texID) { + this.width = width; + this.height = height; + this.texID = texID; + + try { + pbuffer = init(width, height, texID); + } catch (LWJGLException e) { + e.printStackTrace(); + System.exit(-1); + } + } + + /** + * Create and initialize the pbuffer. + * + * @param width + * @param height + * @param texID + * @return + * @throws LWJGLException + */ + protected abstract Pbuffer init(int width, int height, int texID) throws LWJGLException; + + /** + * This will be called before rendering to the renderer. Implementations should setup the pbuffer context as necessary. + */ + void enable() { + try { + if ( pbuffer.isBufferLost() ) { + System.out.println("Buffer contents lost - recreating the pbuffer"); + pbuffer.destroy(); + pbuffer = init(width, height, texID); + } + + pbuffer.makeCurrent(); + } catch (LWJGLException e) { + throw new RuntimeException(e); + } + } + + /** + * Implementations should update the texture contents here. + */ + abstract void updateTexture(); + + /** + * Clean-up resources held by the renderer + */ + final void destroy() { + pbuffer.destroy(); + } + +} \ No newline at end of file diff --git a/src/java/org/lwjgl/test/opengl/pbuffers/UniqueRenderer.java b/src/java/org/lwjgl/test/opengl/pbuffers/UniqueRenderer.java new file mode 100644 index 0000000..fd3cf9e --- /dev/null +++ b/src/java/org/lwjgl/test/opengl/pbuffers/UniqueRenderer.java @@ -0,0 +1,72 @@ +/* + * 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.test.opengl.pbuffers; + +import org.lwjgl.LWJGLException; +import org.lwjgl.opengl.Display; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.Pbuffer; +import org.lwjgl.opengl.PixelFormat; + +final class UniqueRenderer extends TextureRenderer { + + UniqueRenderer(final int width, final int height, final int texID) { + super(width, height, texID); + } + + protected Pbuffer init(final int width, final int height, final int texID) { + Pbuffer pbuffer = null; + + try { + pbuffer = new Pbuffer(width, height, new PixelFormat(16, 0, 0, 0, 0), null, null); + + // Initialise state of the pbuffer context. + pbuffer.makeCurrent(); + + PbufferTest.initGLState(width, height, 0.5f); + GL11.glBindTexture(GL11.GL_TEXTURE_2D, texID); + + Display.makeCurrent(); + } catch (LWJGLException e) { + e.printStackTrace(); + System.exit(-1); + } + + return pbuffer; + } + + public void updateTexture() { + // Copy the pbuffer contents to the texture. + GL11.glCopyTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGB, 0, 0, width, height, 0); + } + +} diff --git a/src/java/org/lwjgl/test/opengl/pbuffers/UniqueRendererRTT.java b/src/java/org/lwjgl/test/opengl/pbuffers/UniqueRendererRTT.java new file mode 100644 index 0000000..c726bff --- /dev/null +++ b/src/java/org/lwjgl/test/opengl/pbuffers/UniqueRendererRTT.java @@ -0,0 +1,82 @@ +/* + * 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.test.opengl.pbuffers; + +import org.lwjgl.LWJGLException; +import org.lwjgl.opengl.Display; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.Pbuffer; +import org.lwjgl.opengl.PixelFormat; +import org.lwjgl.opengl.RenderTexture; + +final class UniqueRendererRTT extends TextureRenderer { + + UniqueRendererRTT(final int width, final int height, final int texID) { + super(width, height, texID); + } + + // Initialize texture renderer + protected Pbuffer init(final int width, final int height, final int texID) { + Pbuffer pbuffer = null; + + try { + final RenderTexture rt = new RenderTexture(true, false, false, false, RenderTexture.RENDER_TEXTURE_2D, 0); + pbuffer = new Pbuffer(width, height, new PixelFormat(16, 0, 0, 0, 0), rt, null); + + // Initialise state of the pbuffer context. + pbuffer.makeCurrent(); + + PbufferTest.initGLState(width, height, 0.5f); + GL11.glBindTexture(GL11.GL_TEXTURE_2D, texID); + + Display.makeCurrent(); + } catch (LWJGLException e) { + e.printStackTrace(); + System.exit(-1); + } + + return pbuffer; + } + + void enable() { + super.enable(); + + // Put the renderer contents to the texture + pbuffer.releaseTexImage(Pbuffer.FRONT_LEFT_BUFFER); + } + + void updateTexture() { + // Bind the texture after rendering. + pbuffer.bindTexImage(Pbuffer.FRONT_LEFT_BUFFER); + } + +} diff --git a/src/java/org/lwjgl/test/opengl/shaders/Shader.java b/src/java/org/lwjgl/test/opengl/shaders/Shader.java new file mode 100644 index 0000000..1117851 --- /dev/null +++ b/src/java/org/lwjgl/test/opengl/shaders/Shader.java @@ -0,0 +1,148 @@ +/* + * 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. + */ +/* + * Created by LWJGL. + * User: spasi + * Date: 2004-03-30 + * Time: 8:41:42 pm + */ +package org.lwjgl.test.opengl.shaders; + +import org.lwjgl.BufferUtils; +import org.lwjgl.opengl.ARBProgram; +import org.lwjgl.opengl.ARBShaderObjects; +import org.lwjgl.opengl.GL11; + +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.nio.ByteBuffer; + +abstract class Shader { + + protected static ByteBuffer fileBuffer = BufferUtils.createByteBuffer(1024 * 10); + + protected Shader() { + } + + abstract void render(); + + abstract void cleanup(); + + protected static String getShaderText(String file) { + String shader = null; + + try { + ClassLoader loader = ShadersTest.class.getClassLoader(); + InputStream inputStream = loader.getResourceAsStream("org/lwjgl/test/opengl/shaders/" + file); + + if ( inputStream == null ) + ShadersTest.kill("A shader source file could not be found: " + file); + + BufferedInputStream stream = new BufferedInputStream(inputStream); + + byte character; + while ( (character = (byte)stream.read()) != -1 ) + fileBuffer.put(character); + + stream.close(); + + fileBuffer.flip(); + + byte[] array = new byte[fileBuffer.remaining()]; + fileBuffer.get(array); + shader = new String(array); + + fileBuffer.clear(); + } catch (IOException e) { + ShadersTest.kill("Failed to read the shader source file: " + file, e); + } + + return shader; + } + + protected static void checkProgramError(String programFile, String programSource) { + if ( GL11.glGetError() == GL11.GL_INVALID_OPERATION ) { + final int errorPos = GL11.glGetInteger(ARBProgram.GL_PROGRAM_ERROR_POSITION_ARB); + int lineStart = 0; + int lineEnd = -1; + for ( int i = 0; i < programSource.length(); i++ ) { + if ( programSource.charAt(i) == '\n' ) { + if ( i <= errorPos ) { + lineStart = i + 1; + } else { + lineEnd = i; + break; + } + } + } + + if ( lineEnd == -1 ) + lineEnd = programSource.length(); + + ShadersTest.kill("Low-level program error in file: " + programFile + + "\n\tError line: " + programSource.substring(lineStart, lineEnd) + + "\n\tError message: " + GL11.glGetString(ARBProgram.GL_PROGRAM_ERROR_STRING_ARB)); + } + } + + protected static int getUniformLocation(int ID, String name) { + final int location = ARBShaderObjects.glGetUniformLocationARB(ID, name); + + if ( location == -1 ) + throw new IllegalArgumentException("The uniform \"" + name + "\" does not exist in the Shader Program."); + + return location; + } + + protected static void printShaderObjectInfoLog(String file, int ID) { + final int logLength = ARBShaderObjects.glGetObjectParameteriARB(ID, ARBShaderObjects.GL_OBJECT_INFO_LOG_LENGTH_ARB); + if ( logLength <= 1 ) + return; + + System.out.println("\nInfo Log of Shader Object: " + file); + System.out.println("--------------------------"); + System.out.println(ARBShaderObjects.glGetInfoLogARB(ID, logLength)); + + } + + protected static void printShaderProgramInfoLog(int ID) { + final int logLength = ARBShaderObjects.glGetObjectParameteriARB(ID, ARBShaderObjects.GL_OBJECT_INFO_LOG_LENGTH_ARB); + if ( logLength <= 1 ) + return; + + System.out.println("\nShader Program Info Log: "); + System.out.println("--------------------------"); + System.out.println(ARBShaderObjects.glGetInfoLogARB(ID, logLength)); + } + +} diff --git a/src/java/org/lwjgl/test/opengl/shaders/ShaderFP.java b/src/java/org/lwjgl/test/opengl/shaders/ShaderFP.java new file mode 100644 index 0000000..e68d8ff --- /dev/null +++ b/src/java/org/lwjgl/test/opengl/shaders/ShaderFP.java @@ -0,0 +1,107 @@ +/* + * 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. + */ +/* + * Created by LWJGL. + * User: spasi + * Date: 2004-03-30 + * Time: 9:55:38 pm + */ + +package org.lwjgl.test.opengl.shaders; + +import org.lwjgl.opengl.ARBFragmentProgram; +import org.lwjgl.opengl.ARBProgram; +import org.lwjgl.opengl.ARBVertexProgram; +import org.lwjgl.opengl.GL11; + +final class ShaderFP extends Shader { + + final String vpFile; + final String vpSource; + + final int vpID; + + final String fpFile; + final String fpSource; + + final int fpID; + + ShaderFP(final String vpShaderFile, final String fpShaderFile) { + // Initialize the vertex program. + vpFile = vpShaderFile; + vpSource = getShaderText(vpShaderFile); + + vpID = ARBProgram.glGenProgramsARB(); + + ARBProgram.glBindProgramARB(ARBVertexProgram.GL_VERTEX_PROGRAM_ARB, vpID); + ARBProgram.glProgramStringARB(ARBVertexProgram.GL_VERTEX_PROGRAM_ARB, ARBProgram.GL_PROGRAM_FORMAT_ASCII_ARB, vpSource); + + checkProgramError(vpFile, vpSource); + + // Initialize the fragment program. + fpFile = fpShaderFile; + fpSource = getShaderText(fpShaderFile); + + fpID = ARBProgram.glGenProgramsARB(); + + ARBProgram.glBindProgramARB(ARBFragmentProgram.GL_FRAGMENT_PROGRAM_ARB, fpID); + ARBProgram.glProgramStringARB(ARBFragmentProgram.GL_FRAGMENT_PROGRAM_ARB, ARBProgram.GL_PROGRAM_FORMAT_ASCII_ARB, fpSource); + + checkProgramError(fpFile, fpSource); + } + + void render() { + GL11.glEnable(ARBVertexProgram.GL_VERTEX_PROGRAM_ARB); + ARBProgram.glBindProgramARB(ARBVertexProgram.GL_VERTEX_PROGRAM_ARB, vpID); + + GL11.glEnable(ARBFragmentProgram.GL_FRAGMENT_PROGRAM_ARB); + ARBProgram.glBindProgramARB(ARBFragmentProgram.GL_FRAGMENT_PROGRAM_ARB, fpID); + + ARBProgram.glProgramLocalParameter4fARB(ARBVertexProgram.GL_VERTEX_PROGRAM_ARB, 0, + ShadersTest.getSin(), ShadersTest.getSpecularity() * 8.0f, 0.0f, 0.0f); + + ARBProgram.glProgramLocalParameter4fARB(ARBFragmentProgram.GL_FRAGMENT_PROGRAM_ARB, 0, + ShadersTest.getSin(), ShadersTest.getSpecularity() * 8.0f, + -ShadersTest.getDisplayWidth() * 0.5f, -ShadersTest.getDisplayHeight() * 0.5f); + + ShadersTest.renderObject(); + + GL11.glDisable(ARBVertexProgram.GL_VERTEX_PROGRAM_ARB); + GL11.glDisable(ARBFragmentProgram.GL_FRAGMENT_PROGRAM_ARB); + } + + void cleanup() { + ARBProgram.glDeleteProgramsARB(vpID); + ARBProgram.glDeleteProgramsARB(fpID); + } + +} \ No newline at end of file diff --git a/src/java/org/lwjgl/test/opengl/shaders/ShaderFSH.java b/src/java/org/lwjgl/test/opengl/shaders/ShaderFSH.java new file mode 100644 index 0000000..a69f48f --- /dev/null +++ b/src/java/org/lwjgl/test/opengl/shaders/ShaderFSH.java @@ -0,0 +1,127 @@ +/* + * 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. + */ +/* + * Created by LWJGL. + * User: spasi + * Date: 2004-03-30 + * Time: 9:55:38 pm + */ + +package org.lwjgl.test.opengl.shaders; + +import org.lwjgl.opengl.ARBFragmentShader; +import org.lwjgl.opengl.ARBShaderObjects; +import org.lwjgl.opengl.ARBVertexShader; +import org.lwjgl.opengl.GL11; + +final class ShaderFSH extends Shader { + + final String vshFile; + final String vshSource; + + final int vshID; + + final String fshFile; + final String fshSource; + + final int fshID; + + final int programID; + + final int uniformLocation; + + ShaderFSH(final String vshFile, final String fshFile) { + // Initialize the vertex shader. + this.vshFile = vshFile; + vshSource = getShaderText(vshFile); + + vshID = ARBShaderObjects.glCreateShaderObjectARB(ARBVertexShader.GL_VERTEX_SHADER_ARB); + ARBShaderObjects.glShaderSourceARB(vshID, vshSource); + ARBShaderObjects.glCompileShaderARB(vshID); + + printShaderObjectInfoLog(this.vshFile, vshID); + + if ( ARBShaderObjects.glGetObjectParameteriARB(vshID, ARBShaderObjects.GL_OBJECT_COMPILE_STATUS_ARB) == GL11.GL_FALSE ) + ShadersTest.kill("A compilation error occured in a vertex shader."); + + // Initialize the fragment shader. + this.fshFile = fshFile; + fshSource = getShaderText(fshFile); + + fshID = ARBShaderObjects.glCreateShaderObjectARB(ARBFragmentShader.GL_FRAGMENT_SHADER_ARB); + ARBShaderObjects.glShaderSourceARB(fshID, fshSource); + ARBShaderObjects.glCompileShaderARB(fshID); + + printShaderObjectInfoLog(this.fshFile, fshID); + + if ( ARBShaderObjects.glGetObjectParameteriARB(fshID, ARBShaderObjects.GL_OBJECT_COMPILE_STATUS_ARB) == GL11.GL_FALSE ) + ShadersTest.kill("A compilation error occured in a fragment shader."); + + // Initialize the shader program. + programID = ARBShaderObjects.glCreateProgramObjectARB(); + + ARBShaderObjects.glAttachObjectARB(programID, vshID); + ARBShaderObjects.glAttachObjectARB(programID, fshID); + + ARBShaderObjects.glLinkProgramARB(programID); + + printShaderProgramInfoLog(programID); + + if ( ARBShaderObjects.glGetObjectParameteriARB(programID, ARBShaderObjects.GL_OBJECT_LINK_STATUS_ARB) == GL11.GL_FALSE ) + ShadersTest.kill("A linking error occured in a shader program."); + + uniformLocation = getUniformLocation(programID, "UNIFORMS"); + } + + void render() { + ARBShaderObjects.glUseProgramObjectARB(programID); + + ARBShaderObjects.glUniform4fARB(uniformLocation, + ShadersTest.getSin(), ShadersTest.getSpecularity() * 8.0f, + -ShadersTest.getDisplayWidth() * 0.5f, -ShadersTest.getDisplayHeight() * 0.5f); + + ShadersTest.renderObject(); + + ARBShaderObjects.glUseProgramObjectARB(0); + } + + void cleanup() { + ARBShaderObjects.glDetachObjectARB(programID, vshID); + ARBShaderObjects.glDetachObjectARB(programID, fshID); + + ARBShaderObjects.glDeleteObjectARB(vshID); + ARBShaderObjects.glDeleteObjectARB(fshID); + + ARBShaderObjects.glDeleteObjectARB(programID); + } + +} \ No newline at end of file diff --git a/src/java/org/lwjgl/test/opengl/shaders/ShaderUNI.java b/src/java/org/lwjgl/test/opengl/shaders/ShaderUNI.java new file mode 100644 index 0000000..a50278c --- /dev/null +++ b/src/java/org/lwjgl/test/opengl/shaders/ShaderUNI.java @@ -0,0 +1,164 @@ +/* + * 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. + */ +/* + * Created by LWJGL. + * User: spasi + * Date: 2009-12-04 + */ + +package org.lwjgl.test.opengl.shaders; + +import org.lwjgl.BufferUtils; +import org.lwjgl.opengl.*; + +import java.nio.FloatBuffer; +import java.nio.IntBuffer; + +final class ShaderUNI extends Shader { + + final String file; + final String source; + + final int shaderID; + final int programID; + + final int bufferID; + final FloatBuffer buffer; + + final int uniformA_index; + final int uniformA_offset; + + final int uniformB_index; + final int uniformB_offset; + + ShaderUNI(final String shaderFile) { + file = shaderFile; + source = getShaderText(shaderFile); + + shaderID = GL20.glCreateShader(GL20.GL_VERTEX_SHADER); + GL20.glShaderSource(shaderID, source); + GL20.glCompileShader(shaderID); + + printShaderObjectInfoLog(file, shaderID); + + if ( GL20.glGetShader(shaderID, GL20.GL_COMPILE_STATUS) == GL11.GL_FALSE ) + ShadersTest.kill("A compilation error occured in a vertex shader."); + + programID = GL20.glCreateProgram(); + + GL20.glAttachShader(programID, shaderID); + GL20.glLinkProgram(programID); + + printShaderProgramInfoLog(programID); + + if ( GL20.glGetProgram(programID, GL20.GL_LINK_STATUS) == GL11.GL_FALSE ) + ShadersTest.kill("A linking error occured in a shader program."); + + final String[] uniformNames = { "uniformA", "uniformB" }; + + // Get uniform block index and data size + final int blockIndex = ARBUniformBufferObject.glGetUniformBlockIndex(programID, "test"); + final int blockSize = ARBUniformBufferObject.glGetActiveUniformBlock(programID, blockIndex, ARBUniformBufferObject.GL_UNIFORM_BLOCK_DATA_SIZE); + + System.out.println("blockSize = " + blockSize); + + // Create uniform buffer object and allocate a ByteBuffer + bufferID = GL15.glGenBuffers(); + GL15.glBindBuffer(ARBUniformBufferObject.GL_UNIFORM_BUFFER, bufferID); + GL15.glBufferData(ARBUniformBufferObject.GL_UNIFORM_BUFFER, blockSize, GL15.GL_DYNAMIC_DRAW); + buffer = BufferUtils.createFloatBuffer(blockSize); + + // Attach UBO and associate uniform block to binding point 0 + ARBUniformBufferObject.glBindBufferBase(ARBUniformBufferObject.GL_UNIFORM_BUFFER, 0, bufferID); + ARBUniformBufferObject.glUniformBlockBinding(programID, blockIndex, 0); + + // Get uniform information + IntBuffer indexes = BufferUtils.createIntBuffer(uniformNames.length); + IntBuffer params = BufferUtils.createIntBuffer(uniformNames.length); + + ARBUniformBufferObject.glGetUniformIndices(programID, uniformNames, indexes); + uniformA_index = indexes.get(0); + uniformB_index = indexes.get(1); + + ARBUniformBufferObject.glGetActiveUniforms(programID, indexes, ARBUniformBufferObject.GL_UNIFORM_OFFSET, params); + uniformA_offset = params.get(0); + uniformB_offset = params.get(1); + + System.out.println("\nuniformA index = " + uniformA_index); + System.out.println("uniformB index = " + uniformB_index); + + System.out.println("\nuniformA offset = " + uniformA_offset + " - should be 0 for std140"); + System.out.println("uniformB offset = " + uniformB_offset + " - should be 16 for std140"); + + Util.checkGLError(); + } + + void render() { + GL20.glUseProgram(programID); + + //* -- std140 layout + // Uniform A + buffer.put(0, ShadersTest.getSin()).put(1, ShadersTest.getSpecularity() * 8.0f); + // Uniform B - str140 alignment at 16 bytes + buffer.put(4, 0.0f).put(5, 0.7f).put(6, 0.0f); + + GL15.glBindBuffer(ARBUniformBufferObject.GL_UNIFORM_BUFFER, bufferID); + GL15.glBufferData(ARBUniformBufferObject.GL_UNIFORM_BUFFER, buffer, GL15.GL_DYNAMIC_DRAW); + //*/ + + /* -- non-std140 layout + // Uniform A + buffer.put(ShadersTest.getSin()).put(ShadersTest.getSpecularity() * 8.0f); + buffer.flip(); + GL15.glBufferSubData(ARBUniformBufferObject.GL_UNIFORM_BUFFER, uniformA_offset, buffer); + // Uniform B + buffer.clear(); + buffer.put(0.0f).put(0.7f).put(0.0f); + buffer.flip(); + GL15.glBufferSubData(ARBUniformBufferObject.GL_UNIFORM_BUFFER, uniformB_offset, buffer); + //*/ + + ShadersTest.renderObject(); + + GL20.glUseProgram(0); + } + + void cleanup() { + GL15.glDeleteBuffers(bufferID); + + GL20.glDetachShader(programID, shaderID); + + GL20.glDeleteShader(shaderID); + GL20.glDeleteProgram(programID); + } + +} \ No newline at end of file diff --git a/src/java/org/lwjgl/test/opengl/shaders/ShaderVP.java b/src/java/org/lwjgl/test/opengl/shaders/ShaderVP.java new file mode 100644 index 0000000..72876be --- /dev/null +++ b/src/java/org/lwjgl/test/opengl/shaders/ShaderVP.java @@ -0,0 +1,80 @@ +/* + * 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. + */ +/* + * Created by LWJGL. + * User: spasi + * Date: 2004-03-30 + * Time: 9:55:38 pm + */ + +package org.lwjgl.test.opengl.shaders; + +import org.lwjgl.opengl.ARBProgram; +import org.lwjgl.opengl.ARBVertexProgram; +import org.lwjgl.opengl.GL11; + +final class ShaderVP extends Shader { + + final String file; + final String source; + + final int ID; + + ShaderVP(final String shaderFile) { + file = shaderFile; + source = getShaderText(shaderFile); + + ID = ARBProgram.glGenProgramsARB(); + + ARBProgram.glBindProgramARB(ARBVertexProgram.GL_VERTEX_PROGRAM_ARB, ID); + ARBProgram.glProgramStringARB(ARBVertexProgram.GL_VERTEX_PROGRAM_ARB, ARBProgram.GL_PROGRAM_FORMAT_ASCII_ARB, source); + + checkProgramError(file, source); + } + + void render() { + GL11.glEnable(ARBVertexProgram.GL_VERTEX_PROGRAM_ARB); + ARBProgram.glBindProgramARB(ARBVertexProgram.GL_VERTEX_PROGRAM_ARB, ID); + + ARBProgram.glProgramLocalParameter4fARB(ARBVertexProgram.GL_VERTEX_PROGRAM_ARB, 0, + ShadersTest.getSin(), ShadersTest.getSpecularity() * 8.0f, 0.0f, 0.0f); + + ShadersTest.renderObject(); + + GL11.glDisable(ARBVertexProgram.GL_VERTEX_PROGRAM_ARB); + } + + void cleanup() { + ARBProgram.glDeleteProgramsARB(ID); + } + +} \ No newline at end of file diff --git a/src/java/org/lwjgl/test/opengl/shaders/ShaderVSH.java b/src/java/org/lwjgl/test/opengl/shaders/ShaderVSH.java new file mode 100644 index 0000000..53fc35e --- /dev/null +++ b/src/java/org/lwjgl/test/opengl/shaders/ShaderVSH.java @@ -0,0 +1,98 @@ +/* + * 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. + */ +/* + * Created by LWJGL. + * User: spasi + * Date: 2004-03-30 + * Time: 9:55:38 pm + */ + +package org.lwjgl.test.opengl.shaders; + +import org.lwjgl.opengl.ARBShaderObjects; +import org.lwjgl.opengl.ARBVertexShader; +import org.lwjgl.opengl.GL11; + +final class ShaderVSH extends Shader { + + final String file; + final String source; + + final int shaderID; + final int programID; + + final int uniformLocation; + + ShaderVSH(final String shaderFile) { + file = shaderFile; + source = getShaderText(shaderFile); + + shaderID = ARBShaderObjects.glCreateShaderObjectARB(ARBVertexShader.GL_VERTEX_SHADER_ARB); + ARBShaderObjects.glShaderSourceARB(shaderID, source); + ARBShaderObjects.glCompileShaderARB(shaderID); + + printShaderObjectInfoLog(file, shaderID); + + if ( ARBShaderObjects.glGetObjectParameteriARB(shaderID, ARBShaderObjects.GL_OBJECT_COMPILE_STATUS_ARB) == GL11.GL_FALSE ) + ShadersTest.kill("A compilation error occured in a vertex shader."); + + programID = ARBShaderObjects.glCreateProgramObjectARB(); + + ARBShaderObjects.glAttachObjectARB(programID, shaderID); + ARBShaderObjects.glLinkProgramARB(programID); + + printShaderProgramInfoLog(programID); + + if ( ARBShaderObjects.glGetObjectParameteriARB(programID, ARBShaderObjects.GL_OBJECT_LINK_STATUS_ARB) == GL11.GL_FALSE ) + ShadersTest.kill("A linking error occured in a shader program."); + + uniformLocation = getUniformLocation(programID, "UNIFORMS"); + } + + void render() { + ARBShaderObjects.glUseProgramObjectARB(programID); + + ARBShaderObjects.glUniform2fARB(uniformLocation, ShadersTest.getSin(), ShadersTest.getSpecularity() * 8.0f); + + ShadersTest.renderObject(); + + ARBShaderObjects.glUseProgramObjectARB(0); + } + + void cleanup() { + ARBShaderObjects.glDetachObjectARB(programID, shaderID); + + ARBShaderObjects.glDeleteObjectARB(shaderID); + ARBShaderObjects.glDeleteObjectARB(programID); + } + +} \ No newline at end of file diff --git a/src/java/org/lwjgl/test/opengl/shaders/ShadersTest.java b/src/java/org/lwjgl/test/opengl/shaders/ShadersTest.java new file mode 100644 index 0000000..4cdb311 --- /dev/null +++ b/src/java/org/lwjgl/test/opengl/shaders/ShadersTest.java @@ -0,0 +1,345 @@ +/* + * 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. + */ +/* + * Created by LWJGL. + * User: spasi + * Date: 2004-03-30 + * Time: 8:41:42 pm + */ + +package org.lwjgl.test.opengl.shaders; + +import java.nio.FloatBuffer; + +import org.lwjgl.BufferUtils; +import org.lwjgl.LWJGLException; +import org.lwjgl.Sys; +import org.lwjgl.input.Keyboard; +import org.lwjgl.input.Mouse; +import org.lwjgl.opengl.*; +import org.lwjgl.util.glu.GLU; +import org.lwjgl.util.glu.Sphere; + +public final class ShadersTest { + + private static DisplayMode displayMode; + + private static boolean run = true; + + private static final FloatBuffer vectorBuffer = BufferUtils.createFloatBuffer(4); + + private static Sphere sphere; + + private static Shader shader; + + private static float frameTime; + + private static float angle; + private static float sin; + private static int specularity = 4; + + private ShadersTest() { + } + + public static void main(String[] args) { + initialize(args); + + long frameStart; + long lastFrameTime = 0; + + while ( run ) { + if (!Display.isVisible() ) + Thread.yield(); + else { + // This is the current frame time. + frameStart = Sys.getTime(); + + // How many seconds passed since last frame. + frameTime = (float)((frameStart - lastFrameTime) / (double)Sys.getTimerResolution()); + + lastFrameTime = frameStart; + + //angle += frameTime * 90.0f; + angle += 0.1f; + sin = (float)Math.sin(Math.toRadians(angle)); + + handleIO(); + + GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); + + if ( shader != null ) + shader.render(); + else + renderObject(); + + // Restore camera position. + GL11.glPopMatrix(); + GL11.glPushMatrix(); + } + + Display.update(); + + if ( Display.isCloseRequested() ) + break; + } + + cleanup(); + System.exit(0); + } + + private static void initialize(String[] args) { + if ( args.length != 1 ) + argsError(); + + try { + DisplayMode[] modes = Display.getAvailableDisplayModes(); + + DisplayMode displayMode; + + displayMode = chooseMode(modes, 1024, 768); + if ( displayMode == null ) + displayMode = chooseMode(modes, 800, 600); + if ( displayMode == null ) + displayMode = chooseMode(modes, 640, 480); + if ( displayMode == null ) + kill("Failed to set an appropriate display mode."); + + System.out.println("Setting display mode to: " + displayMode); + Display.setDisplayMode(displayMode); + Display.create(new PixelFormat(8, 24, 0), "UNI".equalsIgnoreCase(args[0]) ? new ContextAttribs(3, 1) : null); + ShadersTest.displayMode = displayMode; + } catch (LWJGLException e) { + kill(e.getMessage()); + } + + final ContextCapabilities caps = GLContext.getCapabilities(); + + if ( "NONE".equalsIgnoreCase(args[0]) ) { + shader = null; + } else if ( "VP".equalsIgnoreCase(args[0]) ) { + if ( !caps.GL_ARB_vertex_program ) + kill("The ARB_vertex_program extension is not supported."); + + shader = new ShaderVP("shaderVP.vp"); + } else if ( "FP".equalsIgnoreCase(args[0]) ) { + if ( !caps.GL_ARB_vertex_program ) + kill("The ARB_vertex_program extension is not supported."); + if ( !caps.GL_ARB_fragment_program ) + kill("The ARB_fragment_program extension is not supported."); + + shader = new ShaderFP("shaderFP.vp", "shaderFP.fp"); + } else if ( "VSH".equalsIgnoreCase(args[0]) ) { + if ( !caps.GL_ARB_vertex_shader ) + kill("The ARB_vertex_shader extension is not supported."); + + shader = new ShaderVSH("shaderVSH.vsh"); + } else if ( "FSH".equalsIgnoreCase(args[0]) ) { + if ( !caps.GL_ARB_vertex_shader ) + kill("The ARB_vertex_shader extension is not supported."); + if ( !caps.GL_ARB_fragment_shader ) + kill("The ARB_fragment_shader extension is not supported."); + + shader = new ShaderFSH("shaderFSH.vsh", "shaderFSH.fsh"); + } else if ("UNI".equalsIgnoreCase(args[0]) ) { + if ( !(caps.OpenGL31 || caps.GL_ARB_uniform_buffer_object) ) + kill("Neither OpenGL version 3.1 nor ARB_uniform_buffer_object are supported."); + + shader = new ShaderUNI("shaderUNI.vsh"); + } else { + argsError(); + } + + GL11.glViewport(0, 0, displayMode.getWidth(), displayMode.getHeight()); + + GL11.glMatrixMode(GL11.GL_PROJECTION); + GL11.glLoadIdentity(); + GLU.gluPerspective(45, displayMode.getWidth() / (float)displayMode.getHeight(), 1.0f, 10.0f); + + GL11.glMatrixMode(GL11.GL_MODELVIEW); + GL11.glLoadIdentity(); + + // Setup camera position. + GL11.glTranslatef(0.0f, 0.0f, -4.0f); + GL11.glRotatef(15.0f, 1.0f, 0.0f, 0.0f); + GL11.glPushMatrix(); + + GL11.glClearDepth(1.0f); + GL11.glDepthFunc(GL11.GL_LEQUAL); + + GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_NICEST); + + GL11.glFrontFace(GL11.GL_CCW); + GL11.glPolygonMode(GL11.GL_FRONT, GL11.GL_FILL); + + GL11.glCullFace(GL11.GL_BACK); + GL11.glEnable(GL11.GL_CULL_FACE); + + GL11.glAlphaFunc(GL11.GL_NOTEQUAL, 0.0f); + GL11.glEnable(GL11.GL_ALPHA_TEST); + + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glEnable(GL11.GL_BLEND); + + // Setup lighting for when we have fixed function fragment rendering. + GL11.glShadeModel(GL11.GL_SMOOTH); + + if ( shader == null ) { + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_LIGHT0); + } + + vectorBuffer.clear(); + vectorBuffer.put(1.0f).put(1.0f).put(1.0f).put(1.0f); + vectorBuffer.clear(); + GL11.glLight(GL11.GL_LIGHT0, GL11.GL_DIFFUSE, vectorBuffer); + + vectorBuffer.put(1.0f).put(1.0f).put(1.0f).put(1.0f); + vectorBuffer.clear(); + GL11.glLight(GL11.GL_LIGHT0, GL11.GL_AMBIENT, vectorBuffer); + + vectorBuffer.put(1.0f).put(1.0f).put(0.5f).put(1.0f); + vectorBuffer.clear(); + GL11.glLight(GL11.GL_LIGHT0, GL11.GL_SPECULAR, vectorBuffer); + + vectorBuffer.put(-1.0f / 3.0f).put(1.0f / 3.0f).put(1.0f / 3.0f).put(0.0f); // Infinite + vectorBuffer.clear(); + GL11.glLight(GL11.GL_LIGHT0, GL11.GL_POSITION, vectorBuffer); + + vectorBuffer.put(0.2f).put(0.2f).put(0.2f).put(1.0f); + vectorBuffer.clear(); + GL11.glLightModel(GL11.GL_LIGHT_MODEL_AMBIENT, vectorBuffer); + + sphere = new Sphere(); + } + + private static void handleIO() { + if ( Keyboard.getNumKeyboardEvents() != 0 ) { + while ( Keyboard.next() ) { + if ( Keyboard.getEventKeyState() ) + continue; + + switch ( Keyboard.getEventKey() ) { + case Keyboard.KEY_EQUALS: + if ( specularity < 8 ) + specularity++; + break; + case Keyboard.KEY_MINUS: + if ( specularity > 1 ) + specularity--; + break; + case Keyboard.KEY_ESCAPE: + run = false; + break; + } + } + } + + while ( Mouse.next() ) ; + } + + static int getDisplayWidth() { + return displayMode.getWidth(); + } + + static int getDisplayHeight() { + return displayMode.getHeight(); + } + + static float getSin() { + return sin; + } + + static int getSpecularity() { + return specularity; + } + + static void renderObject() { + GL11.glColor3b((byte)255, (byte)255, (byte)255); + sphere.draw(1.0f, 32, 32); + } + + private static DisplayMode chooseMode(DisplayMode[] modes, int width, int height) { + DisplayMode bestMode = null; + + for ( int i = 0; i < modes.length; i++ ) { + DisplayMode mode = modes[i]; + if ( mode.getWidth() == width && mode.getHeight() == height && mode.getFrequency() <= 85 ) { + if ( bestMode == null || (mode.getBitsPerPixel() >= bestMode.getBitsPerPixel() && mode.getFrequency() > bestMode.getFrequency()) ) + bestMode = mode; + } + } + + return bestMode; + } + + private static void cleanup() { + // This is not necessary, just showing how to properly delete a program/shader. + if ( shader != null ) + shader.cleanup(); + + if ( Display.isCreated() ) + Display.destroy(); + } + + private static void argsError() { + System.out.println("\nInvalid program arguments."); + System.out.println("\nUsage: ShadersTest , where argument can be one of the following:\n"); + System.out.println("none\t- Use fixed function rendering."); + System.out.println("vp\t- Use ARB_vertex_program (low-level) only."); + System.out.println("vsh\t- Use ARB_vertex_shader (GLSL) only."); + System.out.println("fp\t- Use ARB_vertex_program + ARB_fragment_program (low-level)."); + System.out.println("fsh\t- Use ARB_vertex_shader + ARB_fragment_shader (GLSL)."); + System.out.println("uni\t- Use ARB_uniform_buffer_object to update shader uniforms (GLSL)."); + + cleanup(); + System.exit(-1); + } + + static void kill(String reason) { + System.out.println("The ShaderTest program was terminated because an error occured.\n"); + System.out.println("Reason: " + (reason == null ? "Unknown" : reason)); + + cleanup(); + System.exit(-1); + } + + static void kill(String reason, Throwable t) { + System.out.println("The ShaderTest program was terminated because an exception occured.\n"); + System.out.println("Reason: " + reason == null ? "Unknown" : reason); + + System.out.println("Exception message: " + t.getMessage()); + + cleanup(); + System.exit(-1); + } + +} diff --git a/src/java/org/lwjgl/test/opengl/shaders/shaderFP.fp b/src/java/org/lwjgl/test/opengl/shaders/shaderFP.fp new file mode 100644 index 0000000..bf11274 --- /dev/null +++ b/src/java/org/lwjgl/test/opengl/shaders/shaderFP.fp @@ -0,0 +1,40 @@ +!!ARBfp1.0 +OPTION ARB_precision_hint_fastest; + +ATTRIB winPos = fragment.position; +ATTRIB iDots = fragment.texcoord[0]; + +PARAM ambience = state.lightmodel.ambient; + +PARAM specularColor = state.light[0].specular; + +PARAM UNIFORMS = program.local[0]; + +TEMP temp; + +OUTPUT oColor = result.color; + +# Offset window-space fragment position. +ADD temp.xyz, winPos, UNIFORMS.zwxx; +# Normalize position. +DP3 temp.w, temp, temp; +RSQ temp.w, temp.w; +MUL temp.xy, temp, temp.w; + +# Multiply with current sin. +MUL temp.xy, temp, UNIFORMS.x; +# {-1..1} => {0..1} +MAD temp.xy, temp, 0.5, 0.5; +# Intensify colors. +MUL temp.xy, temp, 2.0; +MOV temp.z, 1.0; + +# Accumulate color contributions. +MAD temp.xyz, iDots.x, temp, ambience; +# Calculate ^ +POW temp.w, iDots.y, UNIFORMS.y; +MAD oColor.xyz, temp.w, specularColor, temp; + +MOV oColor.w, 1.0; + +END \ No newline at end of file diff --git a/src/java/org/lwjgl/test/opengl/shaders/shaderFP.vp b/src/java/org/lwjgl/test/opengl/shaders/shaderFP.vp new file mode 100644 index 0000000..8b14a96 --- /dev/null +++ b/src/java/org/lwjgl/test/opengl/shaders/shaderFP.vp @@ -0,0 +1,37 @@ +!!ARBvp1.0 + +ATTRIB iPos = vertex.position; +ATTRIB iNormal = vertex.normal; + +PARAM mvp[4] = { state.matrix.mvp }; +PARAM mvIT[4] = { state.matrix.modelview.invtrans }; + +PARAM lightDir = state.light[0].position; +PARAM halfDir = state.light[0].half; + +PARAM UNIFORMS = program.local[0]; + +TEMP normal, dots; + +OUTPUT oPos = result.position; +OUTPUT oDots = result.texcoord[0]; + +# Transform the vertex to clip coordinates. +DP4 oPos.x, mvp[0], iPos; +DP4 oPos.y, mvp[1], iPos; +DP4 oPos.z, mvp[2], iPos; +DP4 oPos.w, mvp[3], iPos; + +# Transform the normal to eye coordinates. +DP3 normal.x, mvIT[0], iNormal; +DP3 normal.y, mvIT[1], iNormal; +DP3 normal.z, mvIT[2], iNormal; + +# Compute diffuse and specular dot products and clamp them. +DP3 dots.x, normal, lightDir; +MAX oDots.x, dots.x, 0.0; + +DP3 dots.y, normal, halfDir; +MAX oDots.y, dots.y, 0.0; + +END \ No newline at end of file diff --git a/src/java/org/lwjgl/test/opengl/shaders/shaderFSH.fsh b/src/java/org/lwjgl/test/opengl/shaders/shaderFSH.fsh new file mode 100644 index 0000000..99567c2 --- /dev/null +++ b/src/java/org/lwjgl/test/opengl/shaders/shaderFSH.fsh @@ -0,0 +1,21 @@ +uniform vec4 UNIFORMS; + +varying vec2 dots; + +void main(void) { + // Offset window-space fragment position. + vec3 color2D = vec3(gl_FragCoord + UNIFORMS.zwxx); + + // Normalize position. + // Multiply with current sin. + color2D.xy = normalize(color2D).xy * UNIFORMS.x; + // {-1..1} => {0..1} & Intensify colors. + color2D.xy = (vec2(color2D) * 0.5 + 0.5) * 2.0; + color2D.z = 1.0; + + // Accumulate color contributions. + // Hardcoded ambience and specular color, due to buggy drivers. + color2D = dots.x * color2D + vec3(0.2, 0.2, 0.2); + gl_FragColor.rgb = pow(dots.y, UNIFORMS.y) * vec3(1.0, 1.0, 0.5) + color2D; + gl_FragColor.a = 1.0; +} \ No newline at end of file diff --git a/src/java/org/lwjgl/test/opengl/shaders/shaderFSH.vsh b/src/java/org/lwjgl/test/opengl/shaders/shaderFSH.vsh new file mode 100644 index 0000000..4fc5db3 --- /dev/null +++ b/src/java/org/lwjgl/test/opengl/shaders/shaderFSH.vsh @@ -0,0 +1,13 @@ +uniform vec4 UNIFORMS; + +varying vec2 dots; + +void main(void) { + gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; + + vec3 normal = gl_NormalMatrix * gl_Normal; + + // Pass the dot products to the fragment shader. + dots.x = max(dot(normal, vec3(gl_LightSource[0].position)), 0.0); + dots.y = max(dot(normal, vec3(gl_LightSource[0].halfVector)), 0.0); +} \ No newline at end of file diff --git a/src/java/org/lwjgl/test/opengl/shaders/shaderUNI.vsh b/src/java/org/lwjgl/test/opengl/shaders/shaderUNI.vsh new file mode 100644 index 0000000..d1fbd74 --- /dev/null +++ b/src/java/org/lwjgl/test/opengl/shaders/shaderUNI.vsh @@ -0,0 +1,28 @@ +#version 140 +#extension GL_ARB_uniform_buffer_object : enable + +layout(std140) uniform test { + vec2 uniformA; + vec3 uniformB; +}; + +void main(void) { + gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; + + vec3 normal = gl_NormalMatrix * gl_Normal; + + float diffuseDot = max(dot(normal, vec3(gl_LightSource[0].position)), 0.0); + float specularDot = max(dot(normal, vec3(gl_LightSource[0].halfVector)), 0.0); + specularDot = pow(specularDot, uniformA.y); + + // Normalize position, to get a {-1..1} value for each vertex. + // Multiply with current sin. + vec3 color3D = normalize(vec3(gl_Vertex)) * uniformA.x; + // {-1..1} => {0..1} & Intensify colors. + color3D = (color3D * 0.5 + 0.5) * 2.0; + + // Accumulate color contributions. + color3D = diffuseDot * (uniformB + color3D) + vec3(gl_LightModel.ambient); + gl_FrontColor.rgb = specularDot * vec3(gl_LightSource[0].specular) + color3D; + gl_FrontColor.a = 1.0; +} \ No newline at end of file diff --git a/src/java/org/lwjgl/test/opengl/shaders/shaderVP.vp b/src/java/org/lwjgl/test/opengl/shaders/shaderVP.vp new file mode 100644 index 0000000..a410222 --- /dev/null +++ b/src/java/org/lwjgl/test/opengl/shaders/shaderVP.vp @@ -0,0 +1,59 @@ +!!ARBvp1.0 + +ATTRIB iPos = vertex.position; +ATTRIB iNormal = vertex.normal; + +PARAM mvp[4] = { state.matrix.mvp }; +PARAM mvIT[4] = { state.matrix.modelview.invtrans }; + +PARAM ambience = state.lightmodel.ambient; + +PARAM lightDir = state.light[0].position; +PARAM halfDir = state.light[0].half; +PARAM diffuseColor = state.light[0].diffuse; +PARAM specularColor = state.light[0].specular; + +PARAM UNIFORMS = program.local[0]; + +TEMP temp, temp2, normal, dots; + +OUTPUT oPos = result.position; +OUTPUT oColor = result.color; + +# Transform the vertex to clip coordinates. +DP4 oPos.x, mvp[0], iPos; +DP4 oPos.y, mvp[1], iPos; +DP4 oPos.z, mvp[2], iPos; +DP4 oPos.w, mvp[3], iPos; + +# Transform the normal to eye coordinates. +DP3 normal.x, mvIT[0], iNormal; +DP3 normal.y, mvIT[1], iNormal; +DP3 normal.z, mvIT[2], iNormal; + +# Compute diffuse and specular dot products and use LIT to compute +# lighting coefficients. +DP3 dots.x, normal, lightDir; +DP3 dots.y, normal, halfDir; +MOV dots.w, UNIFORMS.y; +LIT dots, dots; + +# Normalize position, to get a {-1..1} value for each vertex. +DP3 temp.w, iPos, iPos; +RSQ temp.w, temp.w; +MUL temp.xyz, iPos, temp.w; + +# Multiply with current sin. +MUL temp.xyz, temp, UNIFORMS.x; +# {-1..1} => {0..1} +MAD temp.xyz, temp, 0.5, 0.5; +# Intensify colors. +MUL temp.xyz, temp, 2.0; + +# Accumulate color contributions. +MAD temp.xyz, dots.y, temp, ambience; +MAD oColor.xyz, dots.z, specularColor, temp; +MOV oColor.w, 1.0; + + +END \ No newline at end of file diff --git a/src/java/org/lwjgl/test/opengl/shaders/shaderVSH.vsh b/src/java/org/lwjgl/test/opengl/shaders/shaderVSH.vsh new file mode 100644 index 0000000..c34ae1b --- /dev/null +++ b/src/java/org/lwjgl/test/opengl/shaders/shaderVSH.vsh @@ -0,0 +1,22 @@ +uniform vec2 UNIFORMS; + +void main(void) { + gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; + + vec3 normal = gl_NormalMatrix * gl_Normal; + + float diffuseDot = max(dot(normal, vec3(gl_LightSource[0].position)), 0.0); + float specularDot = max(dot(normal, vec3(gl_LightSource[0].halfVector)), 0.0); + specularDot = pow(specularDot, UNIFORMS.y); + + // Normalize position, to get a {-1..1} value for each vertex. + // Multiply with current sin. + vec3 color3D = normalize(vec3(gl_Vertex)) * UNIFORMS.x; + // {-1..1} => {0..1} & Intensify colors. + color3D = (color3D * 0.5 + 0.5) * 2.0; + + // Accumulate color contributions. + color3D = diffuseDot * color3D + vec3(gl_LightModel.ambient); + gl_FrontColor.rgb = specularDot * vec3(gl_LightSource[0].specular) + color3D; + gl_FrontColor.a = 1.0; +} \ No newline at end of file diff --git a/src/java/org/lwjgl/util/Color.java b/src/java/org/lwjgl/util/Color.java new file mode 100644 index 0000000..87e5ab0 --- /dev/null +++ b/src/java/org/lwjgl/util/Color.java @@ -0,0 +1,494 @@ +/* + * 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; +import java.io.Serializable; +import java.nio.ByteBuffer; + +/** + * A mutable Color class + * @author $Author: matzon $ + * @version $Revision: 2983 $ + * $Id: Color.java 2983 2008-04-07 18:36:09Z matzon $ + */ +public final class Color implements ReadableColor, Serializable, WritableColor { + + static final long serialVersionUID = 1L; + + /** Color components, publicly accessible */ + private byte red, green, blue, alpha; + + /** + * Constructor for Color. + */ + public Color() { + this(0, 0, 0, 255); + } + + /** + * Constructor for Color. Alpha defaults to 255. + */ + public Color(int r, int g, int b) { + this(r, g, b, 255); + } + + /** + * Constructor for Color. Alpha defaults to 255. + */ + public Color(byte r, byte g, byte b) { + this(r, g, b, (byte) 255); + } + + /** + * Constructor for Color. + */ + public Color(int r, int g, int b, int a) { + set(r, g, b, a); + } + + /** + * Constructor for Color. + */ + public Color(byte r, byte g, byte b, byte a) { + set(r, g, b, a); + } + + /** + * Constructor for Color + */ + public Color(ReadableColor c) { + setColor(c); + } + + /** + * Set a color + */ + public void set(int r, int g, int b, int a) { + red = (byte) r; + green = (byte) g; + blue = (byte) b; + alpha = (byte) a; + } + + /** + * Set a color + */ + public void set(byte r, byte g, byte b, byte a) { + this.red = r; + this.green = g; + this.blue = b; + this.alpha = a; + } + + /** + * Set a color + */ + public void set(int r, int g, int b) { + set(r, g, b, 255); + } + + /** + * Set a color + */ + public void set(byte r, byte g, byte b) { + set(r, g, b, (byte) 255); + } + + /** + * Accessor + */ + public int getRed() { + return red & 0xFF; + } + + /** + * Accessor + */ + public int getGreen() { + return green & 0xFF; + } + + /** + * Accessor + */ + public int getBlue() { + return blue & 0xFF; + } + + /** + * Accessor + */ + public int getAlpha() { + return alpha & 0xFF; + } + + /** + * Set the Red component + */ + public void setRed(int red) { + this.red = (byte) red; + } + + /** + * Set the Green component + */ + public void setGreen(int green) { + this.green = (byte) green; + } + + /** + * Set the Blue component + */ + public void setBlue(int blue) { + this.blue = (byte) blue; + } + + /** + * Set the Alpha component + */ + public void setAlpha(int alpha) { + this.alpha = (byte) alpha; + } + + /** + * Set the Red component + */ + public void setRed(byte red) { + this.red = red; + } + + /** + * Set the Green component + */ + public void setGreen(byte green) { + this.green = green; + } + + /** + * Set the Blue component + */ + public void setBlue(byte blue) { + this.blue = blue; + } + + /** + * Set the Alpha component + */ + public void setAlpha(byte alpha) { + this.alpha = alpha; + } + + /** + * Stringify + */ + public String toString() { + return "Color [" + getRed() + ", " + getGreen() + ", " + getBlue() + ", " + getAlpha() + "]"; + } + + /** + * Equals + */ + public boolean equals(Object o) { + return (o != null) + && (o instanceof ReadableColor) + && (((ReadableColor) o).getRed() == this.getRed()) + && (((ReadableColor) o).getGreen() == this.getGreen()) + && (((ReadableColor) o).getBlue() == this.getBlue()) + && (((ReadableColor) o).getAlpha() == this.getAlpha()); + } + + /** + * Hashcode + */ + public int hashCode() { + return (red << 24) | (green << 16) | (blue << 8) | alpha; + } + + /* (Overrides) + * @see com.shavenpuppy.jglib.ReadableColor#getAlphaByte() + */ + public byte getAlphaByte() { + return alpha; + } + + /* (Overrides) + * @see com.shavenpuppy.jglib.ReadableColor#getBlueByte() + */ + public byte getBlueByte() { + return blue; + } + + /* (Overrides) + * @see com.shavenpuppy.jglib.ReadableColor#getGreenByte() + */ + public byte getGreenByte() { + return green; + } + + /* (Overrides) + * @see com.shavenpuppy.jglib.ReadableColor#getRedByte() + */ + public byte getRedByte() { + return red; + } + + /* (Overrides) + * @see com.shavenpuppy.jglib.ReadableColor#writeRGBA(java.nio.ByteBuffer) + */ + public void writeRGBA(ByteBuffer dest) { + dest.put(red); + dest.put(green); + dest.put(blue); + dest.put(alpha); + } + + /* (Overrides) + * @see com.shavenpuppy.jglib.ReadableColor#writeRGB(java.nio.ByteBuffer) + */ + public void writeRGB(ByteBuffer dest) { + dest.put(red); + dest.put(green); + dest.put(blue); + } + + /* (Overrides) + * @see com.shavenpuppy.jglib.ReadableColor#writeABGR(java.nio.ByteBuffer) + */ + public void writeABGR(ByteBuffer dest) { + dest.put(alpha); + dest.put(blue); + dest.put(green); + dest.put(red); + } + + /* (Overrides) + * @see com.shavenpuppy.jglib.ReadableColor#writeARGB(java.nio.ByteBuffer) + */ + public void writeARGB(ByteBuffer dest) { + dest.put(alpha); + dest.put(red); + dest.put(green); + dest.put(blue); + } + + /* (Overrides) + * @see com.shavenpuppy.jglib.ReadableColor#writeBGR(java.nio.ByteBuffer) + */ + public void writeBGR(ByteBuffer dest) { + dest.put(blue); + dest.put(green); + dest.put(red); + } + + /* (Overrides) + * @see com.shavenpuppy.jglib.ReadableColor#writeBGRA(java.nio.ByteBuffer) + */ + public void writeBGRA(ByteBuffer dest) { + dest.put(blue); + dest.put(green); + dest.put(red); + dest.put(alpha); + } + + /** + * Read a color from a byte buffer + * @param src The source buffer + */ + public void readRGBA(ByteBuffer src) { + red = src.get(); + green = src.get(); + blue = src.get(); + alpha = src.get(); + } + + /** + * Read a color from a byte buffer + * @param src The source buffer + */ + public void readRGB(ByteBuffer src) { + red = src.get(); + green = src.get(); + blue = src.get(); + } + + /** + * Read a color from a byte buffer + * @param src The source buffer + */ + public void readARGB(ByteBuffer src) { + alpha = src.get(); + red = src.get(); + green = src.get(); + blue = src.get(); + } + + /** + * Read a color from a byte buffer + * @param src The source buffer + */ + public void readBGRA(ByteBuffer src) { + blue = src.get(); + green = src.get(); + red = src.get(); + alpha = src.get(); + } + + /** + * Read a color from a byte buffer + * @param src The source buffer + */ + public void readBGR(ByteBuffer src) { + blue = src.get(); + green = src.get(); + red = src.get(); + } + + /** + * Read a color from a byte buffer + * @param src The source buffer + */ + public void readABGR(ByteBuffer src) { + alpha = src.get(); + blue = src.get(); + green = src.get(); + red = src.get(); + } + + /** + * Set this color's color by copying another color + * @param src The source color + */ + public void setColor(ReadableColor src) { + red = src.getRedByte(); + green = src.getGreenByte(); + blue = src.getBlueByte(); + alpha = src.getAlphaByte(); + } + + /** + * HSB to RGB conversion, pinched from java.awt.Color. + * @param hue (0..1.0f) + * @param saturation (0..1.0f) + * @param brightness (0..1.0f) + */ + public void fromHSB(float hue, float saturation, float brightness) { + if (saturation == 0.0F) { + red = green = blue = (byte) (brightness * 255F + 0.5F); + } else { + float f3 = (hue - (float) Math.floor(hue)) * 6F; + float f4 = f3 - (float) Math.floor(f3); + float f5 = brightness * (1.0F - saturation); + float f6 = brightness * (1.0F - saturation * f4); + float f7 = brightness * (1.0F - saturation * (1.0F - f4)); + switch ((int) f3) { + case 0 : + red = (byte) (brightness * 255F + 0.5F); + green = (byte) (f7 * 255F + 0.5F); + blue = (byte) (f5 * 255F + 0.5F); + break; + case 1 : + red = (byte) (f6 * 255F + 0.5F); + green = (byte) (brightness * 255F + 0.5F); + blue = (byte) (f5 * 255F + 0.5F); + break; + case 2 : + red = (byte) (f5 * 255F + 0.5F); + green = (byte) (brightness * 255F + 0.5F); + blue = (byte) (f7 * 255F + 0.5F); + break; + case 3 : + red = (byte) (f5 * 255F + 0.5F); + green = (byte) (f6 * 255F + 0.5F); + blue = (byte) (brightness * 255F + 0.5F); + break; + case 4 : + red = (byte) (f7 * 255F + 0.5F); + green = (byte) (f5 * 255F + 0.5F); + blue = (byte) (brightness * 255F + 0.5F); + break; + case 5 : + red = (byte) (brightness * 255F + 0.5F); + green = (byte) (f5 * 255F + 0.5F); + blue = (byte) (f6 * 255F + 0.5F); + break; + } + } + } + + /** + * RGB to HSB conversion, pinched from java.awt.Color. + * The HSB value is returned in dest[] if dest[] is supplied. + * Values range from 0..1 + * @param dest Destination floats, or null + * @return dest, or a new float array + */ + public float[] toHSB(float dest[]) { + int r = getRed(); + int g = getGreen(); + int b = getBlue(); + if (dest == null) + dest = new float[3]; + int l = r <= g ? g : r; + if (b > l) + l = b; + int i1 = r >= g ? g : r; + if (b < i1) + i1 = b; + float brightness = l / 255F; + float saturation; + if (l != 0) + saturation = (float) (l - i1) / (float) l; + else + saturation = 0.0F; + float hue; + if (saturation == 0.0F) { + hue = 0.0F; + } else { + float f3 = (float) (l - r) / (float) (l - i1); + float f4 = (float) (l - g) / (float) (l - i1); + float f5 = (float) (l - b) / (float) (l - i1); + if (r == l) + hue = f5 - f4; + else if (g == l) + hue = (2.0F + f3) - f5; + else + hue = (4F + f4) - f3; + hue /= 6F; + if (hue < 0.0F) + hue++; + } + dest[0] = hue; + dest[1] = saturation; + dest[2] = brightness; + return dest; + } + +} diff --git a/src/java/org/lwjgl/util/Dimension.java b/src/java/org/lwjgl/util/Dimension.java new file mode 100644 index 0000000..a77b253 --- /dev/null +++ b/src/java/org/lwjgl/util/Dimension.java @@ -0,0 +1,156 @@ +/* + * 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; + +import java.io.Serializable; + +/** + * A 2D integer Dimension class, which looks remarkably like an AWT one. + * @author $Author: matzon $ + * @version $Revision: 2983 $ + * $Id: Dimension.java 2983 2008-04-07 18:36:09Z matzon $ + */ +public final class Dimension implements Serializable, ReadableDimension, WritableDimension { + + static final long serialVersionUID = 1L; + + /** The dimensions! */ + private int width, height; + + /** + * Constructor for Dimension. + */ + public Dimension() { + super(); + } + + /** + * Constructor for Dimension. + */ + public Dimension(int w, int h) { + this.width = w; + this.height = h; + } + + /** + * Constructor for Dimension. + */ + public Dimension(ReadableDimension d) { + setSize(d); + } + + public void setSize(int w, int h) { + this.width = w; + this.height = h; + } + + public void setSize(ReadableDimension d) { + this.width = d.getWidth(); + this.height = d.getHeight(); + } + + /* (Overrides) + * @see com.shavenpuppy.jglib.ReadableDimension#getSize(com.shavenpuppy.jglib.Dimension) + */ + public void getSize(WritableDimension dest) { + dest.setSize(this); + } + + /** + * Checks whether two dimension objects have equal values. + */ + public boolean equals(Object obj) { + if (obj instanceof ReadableDimension) { + ReadableDimension d = (ReadableDimension) obj; + return (width == d.getWidth()) && (height == d.getHeight()); + } + return false; + } + + /** + * Returns the hash code for this Dimension. + * + * @return a hash code for this Dimension + */ + public int hashCode() { + int sum = width + height; + return sum * (sum + 1) / 2 + width; + } + + /** + * Returns a string representation of the values of this + * Dimension object's height and + * width fields. This method is intended to be used only + * for debugging purposes, and the content and format of the returned + * string may vary between implementations. The returned string may be + * empty but may not be null. + * + * @return a string representation of this Dimension + * object + */ + public String toString() { + return getClass().getName() + "[width=" + width + ",height=" + height + "]"; + } + + /** + * Gets the height. + * @return Returns a int + */ + public int getHeight() { + return height; + } + + /** + * Sets the height. + * @param height The height to set + */ + public void setHeight(int height) { + this.height = height; + } + + /** + * Gets the width. + * @return Returns a int + */ + public int getWidth() { + return width; + } + + /** + * Sets the width. + * @param width The width to set + */ + public void setWidth(int width) { + this.width = width; + } + +} diff --git a/src/java/org/lwjgl/util/Display.java b/src/java/org/lwjgl/util/Display.java new file mode 100644 index 0000000..a340639 --- /dev/null +++ b/src/java/org/lwjgl/util/Display.java @@ -0,0 +1,246 @@ +/* + * 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; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Comparator; + +import org.lwjgl.LWJGLException; +import org.lwjgl.LWJGLUtil; +import org.lwjgl.opengl.DisplayMode; + +/** + * Display initialization utility, that can be used to find display modes and pick + * one for you based on your criteria. + * @author $Author: matzon $ + * @version $Revision: 2983 $ + * $Id: Display.java 2983 2008-04-07 18:36:09Z matzon $ + */ +public final class Display { + + private static final boolean DEBUG = false; + + /** + * Determine the available display modes that match the specified minimum and maximum criteria. + * If any given criterium is specified as -1 then it is ignored. + * + * @param minWidth the minimum display resolution in pixels + * @param minHeight the minimum display resolution in pixels + * @param maxWidth the maximum display resolution in pixels + * @param maxHeight the maximum display resolution in pixels + * @param minBPP the minimum bit depth per pixel + * @param maxBPP the maximum bit depth per pixel + * @param minFreq the minimum display frequency in Hz + * @param maxFreq the maximum display frequency in Hz + * @return an array of matching display modes + */ + public static DisplayMode[] getAvailableDisplayModes(int minWidth, int minHeight, int maxWidth, int maxHeight, int minBPP, int maxBPP, + int minFreq, int maxFreq) throws LWJGLException + { + // First get the available display modes + DisplayMode[] modes = org.lwjgl.opengl.Display.getAvailableDisplayModes(); + + if (LWJGLUtil.DEBUG || DEBUG) { + System.out.println("Available screen modes:"); + for (int i = 0; i < modes.length; i ++) { + System.out.println(modes[i]); + } + } + + ArrayList matches = new ArrayList(modes.length); + + for (int i = 0; i < modes.length; i ++) { + assert modes[i] != null : ""+i+" "+modes.length; + if (minWidth != -1 && modes[i].getWidth() < minWidth) + continue; + if (maxWidth != -1 && modes[i].getWidth() > maxWidth) + continue; + if (minHeight != -1 && modes[i].getHeight() < minHeight) + continue; + if (maxHeight != -1 && modes[i].getHeight() > maxHeight) + continue; + if (minBPP != -1 && modes[i].getBitsPerPixel() < minBPP) + continue; + if (maxBPP != -1 && modes[i].getBitsPerPixel() > maxBPP) + continue; + //if (modes[i].bpp == 24) + // continue; + if (modes[i].getFrequency() != 0) { + if (minFreq != -1 && modes[i].getFrequency() < minFreq) + continue; + if (maxFreq != -1 && modes[i].getFrequency() > maxFreq) + continue; + } + matches.add(modes[i]); + } + + DisplayMode[] ret = new DisplayMode[matches.size()]; + matches.toArray(ret); + if (LWJGLUtil.DEBUG && DEBUG) { + System.out.println("Filtered screen modes:"); + for (int i = 0; i < ret.length; i ++) { + System.out.println(ret[i]); + } + } + + return ret; + } + + /** + * Create the display by choosing from a list of display modes based on an order of preference. + * You must supply a list of allowable display modes, probably by calling getAvailableDisplayModes(), + * and an array with the order in which you would like them sorted in descending order. + * This method attempts to create the topmost display mode; if that fails, it will try the next one, + * and so on, until there are no modes left. If no mode is set at the end, an exception is thrown. + * @param dm a list of display modes to choose from + * @param param the names of the DisplayMode fields in the order in which you would like them sorted. + * @return the chosen display mode + * @throws NoSuchFieldException if one of the params is not a field in DisplayMode + * @throws Exception if no display mode could be set + * @see org.lwjgl.opengl.DisplayMode + */ + public static DisplayMode setDisplayMode(DisplayMode[] dm, final String[] param) throws Exception { + + class FieldAccessor { + final String fieldName; + final int order; + final int preferred; + final boolean usePreferred; + FieldAccessor(String fieldName, int order, int preferred, boolean usePreferred) { + this.fieldName = fieldName; + this.order = order; + this.preferred = preferred; + this.usePreferred = usePreferred; + } + int getInt(DisplayMode mode) { + if ("width".equals(fieldName)) { + return mode.getWidth(); + } + if ("height".equals(fieldName)) { + return mode.getHeight(); + } + if ("freq".equals(fieldName)) { + return mode.getFrequency(); + } + if ("bpp".equals(fieldName)) { + return mode.getBitsPerPixel(); + } + throw new IllegalArgumentException("Unknown field "+fieldName); + } + } + + class Sorter implements Comparator { + + final FieldAccessor[] field; + + Sorter() { + field = new FieldAccessor[param.length]; + for (int i = 0; i < field.length; i ++) { + int idx = param[i].indexOf('='); + if (idx > 0) { + field[i] = new FieldAccessor(param[i].substring(0, idx), 0, Integer.parseInt(param[i].substring(idx + 1, param[i].length())), true); + } else if (param[i].charAt(0) == '-') { + field[i] = new FieldAccessor(param[i].substring(1), -1, 0, false); + } else { + field[i] = new FieldAccessor(param[i], 1, 0, false); + } + } + } + + /** + * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object) + */ + public int compare(Object o1, Object o2) { + DisplayMode dm1 = (DisplayMode) o1; + DisplayMode dm2 = (DisplayMode) o2; + + for (int i = 0; i < field.length; i ++) { + int f1 = field[i].getInt(dm1); + int f2 = field[i].getInt(dm2); + + if (field[i].usePreferred && f1 != f2) { + if (f1 == field[i].preferred) + return -1; + else if (f2 == field[i].preferred) + return 1; + else { + // Score according to the difference between the values + int absf1 = Math.abs(f1 - field[i].preferred); + int absf2 = Math.abs(f2 - field[i].preferred); + if (absf1 < absf2) + return -1; + else if (absf1 > absf2) + return 1; + else + continue; + } + } else if (f1 < f2) + return field[i].order; + else if (f1 == f2) + continue; + else + return -field[i].order; + } + + return 0; + } + } + + // Sort the display modes + Arrays.sort(dm, new Sorter()); + + // Try them out in the appropriate order + if (LWJGLUtil.DEBUG || DEBUG) { + System.out.println("Sorted display modes:"); + for (int i = 0; i < dm.length; i ++) { + System.out.println(dm[i]); + } + } + for (int i = 0; i < dm.length; i ++) { + try { + if (LWJGLUtil.DEBUG || DEBUG) + System.out.println("Attempting to set displaymode: "+dm[i]); + org.lwjgl.opengl.Display.setDisplayMode(dm[i]); + return dm[i]; + } catch (Exception e) { + if (LWJGLUtil.DEBUG || DEBUG) { + System.out.println("Failed to set display mode to "+dm[i]); + e.printStackTrace(); + } + } + } + + throw new Exception("Failed to set display mode."); + } + +} diff --git a/src/java/org/lwjgl/util/Point.java b/src/java/org/lwjgl/util/Point.java new file mode 100644 index 0000000..c9ccb8e --- /dev/null +++ b/src/java/org/lwjgl/util/Point.java @@ -0,0 +1,170 @@ +/* + * 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; + +import java.io.Serializable; + +/** + * A 2D integer point class, which looks remarkably like an AWT one. + * @author $Author: matzon $ + * @version $Revision: 2983 $ + * $Id: Point.java 2983 2008-04-07 18:36:09Z matzon $ + */ +public final class Point implements ReadablePoint, WritablePoint, Serializable { + + static final long serialVersionUID = 1L; + + /** The location */ + private int x, y; + + /** + * Constructor for Point. + */ + public Point() { + super(); + } + + /** + * Constructor for Point. + */ + public Point(int x, int y) { + setLocation(x, y); + } + + /** + * Constructor for Point. + */ + public Point(ReadablePoint p) { + setLocation(p); + } + + public void setLocation(int x, int y) { + this.x = x; + this.y = y; + } + + public void setLocation(ReadablePoint p) { + this.x = p.getX(); + this.y = p.getY(); + } + + public void setX(int x) { + this.x = x; + } + + public void setY(int y) { + this.y = y; + } + + /** + * Translate a point. + * @param dx The translation to apply + * @param dy The translation to apply + */ + public void translate(int dx, int dy) { + this.x += dx; + this.y += dy; + } + + /** + * Translate a point. + * @param p The translation to apply + */ + public void translate(ReadablePoint p) { + this.x += p.getX(); + this.y += p.getY(); + } + + /** + * Un-translate a point. + * @param p The translation to apply + */ + public void untranslate(ReadablePoint p) { + this.x -= p.getX(); + this.y -= p.getY(); + } + + /** + * Determines whether an instance of Point2D is equal + * to this point. Two instances of Point2D are equal if + * the values of their x and y member + * fields, representing their position in the coordinate space, are + * the same. + * @param obj an object to be compared with this point + * @return true if the object to be compared is + * an instance of Point and has + * the same values; false otherwise + */ + public boolean equals(Object obj) { + if (obj instanceof Point) { + Point pt = (Point) obj; + return (x == pt.x) && (y == pt.y); + } + return super.equals(obj); + } + + /** + * Returns a string representation of this point and its location + * in the (xy) coordinate space. This method is + * intended to be used only for debugging purposes, and the content + * and format of the returned string may vary between implementations. + * The returned string may be empty but may not be null. + * + * @return a string representation of this point + */ + public String toString() { + return getClass().getName() + "[x=" + x + ",y=" + y + "]"; + } + + /** + * Returns the hash code for this Point. + * + * @return a hash code for this Point + */ + public int hashCode() { + int sum = x + y; + return sum * (sum + 1) / 2 + x; + } + + public int getX() { + return x; + } + + public int getY() { + return y; + } + + public void getLocation(WritablePoint dest) { + dest.setLocation(x, y); + } + +} diff --git a/src/java/org/lwjgl/util/ReadableColor.java b/src/java/org/lwjgl/util/ReadableColor.java new file mode 100644 index 0000000..8127d45 --- /dev/null +++ b/src/java/org/lwjgl/util/ReadableColor.java @@ -0,0 +1,146 @@ +/* + * 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; + +import java.nio.ByteBuffer; + +/** + * Readonly interface for Colors + * @author $Author: matzon $ + * @version $Revision: 2983 $ + * $Id: ReadableColor.java 2983 2008-04-07 18:36:09Z matzon $ + */ +public interface ReadableColor { + + /** + * Return the red component (0..255) + * @return int + */ + public int getRed(); + + /** + * Return the red component (0..255) + * @return int + */ + public int getGreen(); + + /** + * Return the red component (0..255) + * @return int + */ + public int getBlue(); + + /** + * Return the red component (0..255) + * @return int + */ + public int getAlpha(); + + /** + * Return the red component + * @return int + */ + public byte getRedByte(); + + /** + * Return the red component + * @return int + */ + public byte getGreenByte(); + + /** + * Return the red component + * @return int + */ + public byte getBlueByte(); + + /** + * Return the red component + * @return int + */ + public byte getAlphaByte(); + + /** + * Write the RGBA color directly out to a ByteBuffer + * @param dest the buffer to write to + */ + public void writeRGBA(ByteBuffer dest); + + /** + * Write the RGB color directly out to a ByteBuffer + * @param dest the buffer to write to + */ + public void writeRGB(ByteBuffer dest); + + /** + * Write the ABGR color directly out to a ByteBuffer + * @param dest the buffer to write to + */ + public void writeABGR(ByteBuffer dest); + + /** + * Write the BGR color directly out to a ByteBuffer + * @param dest the buffer to write to + */ + public void writeBGR(ByteBuffer dest); + + /** + * Write the BGRA color directly out to a ByteBuffer + * @param dest the buffer to write to + */ + public void writeBGRA(ByteBuffer dest); + + /** + * Write the ARGB color directly out to a ByteBuffer + * @param dest the buffer to write to + */ + public void writeARGB(ByteBuffer dest); + + /* + * Some standard colors + */ + public static final ReadableColor RED = new Color(255, 0, 0); + public static final ReadableColor ORANGE = new Color(255, 128, 0); + public static final ReadableColor YELLOW = new Color(255, 255, 0); + public static final ReadableColor GREEN = new Color(0, 255, 0); + public static final ReadableColor CYAN = new Color(0, 255, 255); + public static final ReadableColor BLUE = new Color(0, 0, 255); + public static final ReadableColor PURPLE = new Color(255, 0, 255); + public static final ReadableColor WHITE = new Color(255, 255, 255); + public static final ReadableColor BLACK = new Color(0, 0, 0); + public static final ReadableColor LTGREY = new Color(192, 192, 192); + public static final ReadableColor DKGREY = new Color(64, 64, 64); + public static final ReadableColor GREY = new Color(128, 128, 128); + + + +} diff --git a/src/java/org/lwjgl/util/ReadableDimension.java b/src/java/org/lwjgl/util/ReadableDimension.java new file mode 100644 index 0000000..251be8c --- /dev/null +++ b/src/java/org/lwjgl/util/ReadableDimension.java @@ -0,0 +1,60 @@ +/* + * 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; + +/** + * Readonly interface for Dimensions + * @author $Author: matzon $ + * @version $Revision: 2983 $ + * $Id: ReadableDimension.java 2983 2008-04-07 18:36:09Z matzon $ + */ +public interface ReadableDimension { + + /** + * Get the width + * @return int + */ + public int getWidth(); + + /** + * Get the height + * @return int + */ + public int getHeight(); + + /** + * Copy this ReadableDimension into a destination Dimension + * @param dest The destination + */ + public void getSize(WritableDimension dest); + +} diff --git a/src/java/org/lwjgl/util/ReadablePoint.java b/src/java/org/lwjgl/util/ReadablePoint.java new file mode 100644 index 0000000..4dea341 --- /dev/null +++ b/src/java/org/lwjgl/util/ReadablePoint.java @@ -0,0 +1,57 @@ +/* + * 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; + +/** + * Readonly interface for Points + * @author $Author: matzon $ + * @version $Revision: 2983 $ + * $Id: ReadablePoint.java 2983 2008-04-07 18:36:09Z matzon $ + */ +public interface ReadablePoint { + + /** + * @return int + */ + public int getX(); + + /** + * @return int + */ + public int getY(); + + /** + * Copy this ReadablePoint into a destination Point + * @param dest The destination Point, or null, to create a new Point + */ + public void getLocation(WritablePoint dest); +} diff --git a/src/java/org/lwjgl/util/ReadableRectangle.java b/src/java/org/lwjgl/util/ReadableRectangle.java new file mode 100644 index 0000000..6e8fb32 --- /dev/null +++ b/src/java/org/lwjgl/util/ReadableRectangle.java @@ -0,0 +1,48 @@ +/* + * 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; + +/** + * Readonly interface for Rectangles + * @author $Author: matzon $ + * @version $Revision: 2983 $ + * $Id: ReadableRectangle.java 2983 2008-04-07 18:36:09Z matzon $ + */ +public interface ReadableRectangle extends ReadableDimension, ReadablePoint { + + /** + * Copy this readable rectangle's bounds into a destination Rectangle + * @param dest The destination Rectangle, or null, to create a new Rectangle + */ + public void getBounds(WritableRectangle dest); + +} diff --git a/src/java/org/lwjgl/util/Rectangle.java b/src/java/org/lwjgl/util/Rectangle.java new file mode 100644 index 0000000..357fbf6 --- /dev/null +++ b/src/java/org/lwjgl/util/Rectangle.java @@ -0,0 +1,581 @@ +/* + * 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; + +import java.io.Serializable; + +/** + * A 2D integer Rectangle class which looks remarkably like an AWT one. + * @author $Author: matzon $ + * @version $Revision: 2983 $ + * $Id: Rectangle.java 2983 2008-04-07 18:36:09Z matzon $ + */ +public final class Rectangle implements ReadableRectangle, WritableRectangle, Serializable { + + static final long serialVersionUID = 1L; + + /** Rectangle's bounds */ + private int x, y, width, height; + + /** + * Constructor for Rectangle. + */ + public Rectangle() { + super(); + } + /** + * Constructor for Rectangle. + */ + public Rectangle(int x, int y, int w, int h) { + this.x = x; + this.y = y; + this.width = w; + this.height = h; + } + /** + * Constructor for Rectangle. + */ + public Rectangle(ReadablePoint p, ReadableDimension d) { + x = p.getX(); + y = p.getY(); + width = d.getWidth(); + height = d.getHeight(); + } + /** + * Constructor for Rectangle. + */ + public Rectangle(ReadableRectangle r) { + x = r.getX(); + y = r.getY(); + width = r.getWidth(); + height = r.getHeight(); + } + + public void setLocation(int x, int y) { + this.x = x; + this.y = y; + } + + public void setLocation(ReadablePoint p) { + this.x = p.getX(); + this.y = p.getY(); + } + + public void setSize(int w, int h) { + this.width = w; + this.height = h; + } + + public void setSize(ReadableDimension d) { + this.width = d.getWidth(); + this.height = d.getHeight(); + } + + public void setBounds(int x, int y, int w, int h) { + this.x = x; + this.y = y; + this.width = w; + this.height = h; + } + + public void setBounds(ReadablePoint p, ReadableDimension d) { + x = p.getX(); + y = p.getY(); + width = d.getWidth(); + height = d.getHeight(); + } + + public void setBounds(ReadableRectangle r) { + x = r.getX(); + y = r.getY(); + width = r.getWidth(); + height = r.getHeight(); + } + + /* (Overrides) + * @see com.shavenpuppy.jglib.ReadableRectangle#getBounds(com.shavenpuppy.jglib.Rectangle) + */ + public void getBounds(WritableRectangle dest) { + dest.setBounds(x, y, width, height); + } + + /* (Overrides) + * @see com.shavenpuppy.jglib.ReadablePoint#getLocation(com.shavenpuppy.jglib.Point) + */ + public void getLocation(WritablePoint dest) { + dest.setLocation(x, y); + } + + /* (Overrides) + * @see com.shavenpuppy.jglib.ReadableDimension#getSize(com.shavenpuppy.jglib.Dimension) + */ + public void getSize(WritableDimension dest) { + dest.setSize(width, height); + } + + /** + * Translate the rectangle by an amount. + * @param x The translation amount on the x axis + * @param y The translation amount on the y axis + */ + public void translate(int x, int y) { + this.x += x; + this.y += y; + } + + /** + * Translate the rectangle by an amount. + * @param point The translation amount + */ + public void translate(ReadablePoint point) { + this.x += point.getX(); + this.y += point.getY(); + } + + /** + * Un-translate the rectangle by an amount. + * @param point The translation amount + */ + public void untranslate(ReadablePoint point) { + this.x -= point.getX(); + this.y -= point.getY(); + } + + /** + * Checks whether or not this Rectangle contains the + * specified Point. + * @param p the Point to test + * @return true if the Point + * (xy) is inside this + * Rectangle; + * false otherwise. + */ + public boolean contains(ReadablePoint p) { + return contains(p.getX(), p.getY()); + } + + /** + * Checks whether or not this Rectangle contains the + * point at the specified location + * (xy). + * @param X the specified x coordinate + * @param Y the specified y coordinate + * @return true if the point + * (xy) is inside this + * Rectangle; + * false otherwise. + */ + public boolean contains(int X, int Y) { + int w = this.width; + int h = this.height; + if ((w | h) < 0) { + // At least one of the dimensions is negative... + return false; + } + // Note: if either dimension is zero, tests below must return false... + int x = this.x; + int y = this.y; + if (X < x || Y < y) { + return false; + } + w += x; + h += y; + // overflow || intersect + return ((w < x || w > X) && (h < y || h > Y)); + } + + /** + * Checks whether or not this Rectangle entirely contains + * the specified Rectangle. + * @param r the specified Rectangle + * @return true if the Rectangle + * is contained entirely inside this Rectangle; + * false otherwise. + */ + public boolean contains(ReadableRectangle r) { + return contains(r.getX(), r.getY(), r.getWidth(), r.getHeight()); + } + + /** + * Checks whether this Rectangle entirely contains + * the Rectangle + * at the specified location (XY) with the + * specified dimensions (WH). + * @param X the specified x coordinate + * @param Y the specified y coordinate + * @param W the width of the Rectangle + * @param H the height of the Rectangle + * @return true if the Rectangle specified by + * (XYWH) + * is entirely enclosed inside this Rectangle; + * false otherwise. + */ + public boolean contains(int X, int Y, int W, int H) { + int w = this.width; + int h = this.height; + if ((w | h | W | H) < 0) { + // At least one of the dimensions is negative... + return false; + } + // Note: if any dimension is zero, tests below must return false... + int x = this.x; + int y = this.y; + if (X < x || Y < y) { + return false; + } + w += x; + W += X; + if (W <= X) { + // X+W overflowed or W was zero, return false if... + // either original w or W was zero or + // x+w did not overflow or + // the overflowed x+w is smaller than the overflowed X+W + if (w >= x || W > w) + return false; + } else { + // X+W did not overflow and W was not zero, return false if... + // original w was zero or + // x+w did not overflow and x+w is smaller than X+W + if (w >= x && W > w) + return false; + } + h += y; + H += Y; + if (H <= Y) { + if (h >= y || H > h) + return false; + } else { + if (h >= y && H > h) + return false; + } + return true; + } + + /** + * Determines whether or not this Rectangle and the specified + * Rectangle intersect. Two rectangles intersect if + * their intersection is nonempty. + * + * @param r the specified Rectangle + * @return true if the specified Rectangle + * and this Rectangle intersect; + * false otherwise. + */ + public boolean intersects(ReadableRectangle r) { + int tw = this.width; + int th = this.height; + int rw = r.getWidth(); + int rh = r.getHeight(); + if (rw <= 0 || rh <= 0 || tw <= 0 || th <= 0) { + return false; + } + int tx = this.x; + int ty = this.y; + int rx = r.getX(); + int ry = r.getY(); + rw += rx; + rh += ry; + tw += tx; + th += ty; + // overflow || intersect + return ((rw < rx || rw > tx) && (rh < ry || rh > ty) && (tw < tx || tw > rx) && (th < ty || th > ry)); + } + + /** + * Computes the intersection of this Rectangle with the + * specified Rectangle. Returns a new Rectangle + * that represents the intersection of the two rectangles. + * If the two rectangles do not intersect, the result will be + * an empty rectangle. + * + * @param r the specified Rectangle + * @return the largest Rectangle contained in both the + * specified Rectangle and in + * this Rectangle; or if the rectangles + * do not intersect, an empty rectangle. + */ + public Rectangle intersection(ReadableRectangle r, Rectangle dest) { + int tx1 = this.x; + int ty1 = this.y; + int rx1 = r.getX(); + int ry1 = r.getY(); + long tx2 = tx1; + tx2 += this.width; + long ty2 = ty1; + ty2 += this.height; + long rx2 = rx1; + rx2 += r.getWidth(); + long ry2 = ry1; + ry2 += r.getHeight(); + if (tx1 < rx1) + tx1 = rx1; + if (ty1 < ry1) + ty1 = ry1; + if (tx2 > rx2) + tx2 = rx2; + if (ty2 > ry2) + ty2 = ry2; + tx2 -= tx1; + ty2 -= ty1; + // tx2,ty2 will never overflow (they will never be + // larger than the smallest of the two source w,h) + // they might underflow, though... + if (tx2 < Integer.MIN_VALUE) + tx2 = Integer.MIN_VALUE; + if (ty2 < Integer.MIN_VALUE) + ty2 = Integer.MIN_VALUE; + if (dest == null) + dest = new Rectangle(tx1, ty1, (int) tx2, (int) ty2); + else + dest.setBounds(tx1, ty1, (int) tx2, (int) ty2); + return dest; + + } + + /** + * Computes the union of this Rectangle with the + * specified Rectangle. Returns a new + * Rectangle that + * represents the union of the two rectangles + * @param r the specified Rectangle + * @return the smallest Rectangle containing both + * the specified Rectangle and this + * Rectangle. + */ + public WritableRectangle union(ReadableRectangle r, WritableRectangle dest) { + int x1 = Math.min(x, r.getX()); + int x2 = Math.max(x + width, r.getX() + r.getWidth()); + int y1 = Math.min(y, r.getY()); + int y2 = Math.max(y + height, r.getY() + r.getHeight()); + dest.setBounds(x1, y1, x2 - x1, y2 - y1); + return dest; + } + + /** + * Adds a point, specified by the integer arguments newx + * and newy, to this Rectangle. The + * resulting Rectangle is + * the smallest Rectangle that contains both the + * original Rectangle and the specified point. + *

    + * After adding a point, a call to contains with the + * added point as an argument does not necessarily return + * true. The contains method does not + * return true for points on the right or bottom + * edges of a Rectangle. Therefore, if the added point + * falls on the right or bottom edge of the enlarged + * Rectangle, contains returns + * false for that point. + * @param newx the x coordinates of the new point + * @param newy the y coordinates of the new point + */ + public void add(int newx, int newy) { + int x1 = Math.min(x, newx); + int x2 = Math.max(x + width, newx); + int y1 = Math.min(y, newy); + int y2 = Math.max(y + height, newy); + x = x1; + y = y1; + width = x2 - x1; + height = y2 - y1; + } + + /** + * Adds the specified Point to this + * Rectangle. The resulting Rectangle + * is the smallest Rectangle that contains both the + * original Rectangle and the specified + * Point. + *

    + * After adding a Point, a call to contains + * with the added Point as an argument does not + * necessarily return true. The contains + * method does not return true for points on the right + * or bottom edges of a Rectangle. Therefore if the added + * Point falls on the right or bottom edge of the + * enlarged Rectangle, contains returns + * false for that Point. + * @param pt the new Point to add to this + * Rectangle + */ + public void add(ReadablePoint pt) { + add(pt.getX(), pt.getY()); + } + + /** + * Adds a Rectangle to this Rectangle. + * The resulting Rectangle is the union of the two + * rectangles. + * @param r the specified Rectangle + */ + public void add(ReadableRectangle r) { + int x1 = Math.min(x, r.getX()); + int x2 = Math.max(x + width, r.getX() + r.getWidth()); + int y1 = Math.min(y, r.getY()); + int y2 = Math.max(y + height, r.getY() + r.getHeight()); + x = x1; + y = y1; + width = x2 - x1; + height = y2 - y1; + } + + /** + * Resizes the Rectangle both horizontally and vertically. + *

    + * This method modifies the Rectangle so that it is + * h units larger on both the left and right side, + * and v units larger at both the top and bottom. + *

    + * The new Rectangle has (x - h, + * y - v) as its top-left corner, a + * width of + * width + 2h, + * and a height of + * height + 2v. + *

    + * If negative values are supplied for h and + * v, the size of the Rectangle + * decreases accordingly. + * The grow method does not check whether the resulting + * values of width and height are + * non-negative. + * @param h the horizontal expansion + * @param v the vertical expansion + */ + public void grow(int h, int v) { + x -= h; + y -= v; + width += h * 2; + height += v * 2; + } + + /** + * Determines whether or not this Rectangle is empty. A + * Rectangle is empty if its width or its height is less + * than or equal to zero. + * @return true if this Rectangle is empty; + * false otherwise. + */ + public boolean isEmpty() { + return (width <= 0) || (height <= 0); + } + /** + * Checks whether two rectangles are equal. + *

    + * The result is true if and only if the argument is not + * null and is a Rectangle object that has the + * same top-left corner, width, and height as this Rectangle. + * @param obj the Object to compare with + * this Rectangle + * @return true if the objects are equal; + * false otherwise. + */ + public boolean equals(Object obj) { + if (obj instanceof Rectangle) { + Rectangle r = (Rectangle) obj; + return ((x == r.x) && (y == r.y) && (width == r.width) && (height == r.height)); + } + return super.equals(obj); + } + + /** + * Debugging + * @return a String + */ + public String toString() { + return getClass().getName() + "[x=" + x + ",y=" + y + ",width=" + width + ",height=" + height + "]"; + } + /** + * Gets the height. + * @return Returns a int + */ + public int getHeight() { + return height; + } + + /** + * Sets the height. + * @param height The height to set + */ + public void setHeight(int height) { + this.height = height; + } + + /** + * Gets the width. + * @return Returns a int + */ + public int getWidth() { + return width; + } + + /** + * Sets the width. + * @param width The width to set + */ + public void setWidth(int width) { + this.width = width; + } + + /** + * Gets the x. + * @return Returns a int + */ + public int getX() { + return x; + } + + /** + * Sets the x. + * @param x The x to set + */ + public void setX(int x) { + this.x = x; + } + + /** + * Gets the y. + * @return Returns a int + */ + public int getY() { + return y; + } + + /** + * Sets the y. + * @param y The y to set + */ + public void setY(int y) { + this.y = y; + } + +} diff --git a/src/java/org/lwjgl/util/Renderable.java b/src/java/org/lwjgl/util/Renderable.java new file mode 100644 index 0000000..61d3df7 --- /dev/null +++ b/src/java/org/lwjgl/util/Renderable.java @@ -0,0 +1,49 @@ +/* + * 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; + +/** + * + * Simple interface to things that can be Rendered. + * + * @author $Author: matzon $ + * @version $Revision: 2983 $ + * $Id: Renderable.java 2983 2008-04-07 18:36:09Z matzon $ + */ +public interface Renderable { + + /** + * "Render" this thing. This will involve calls to the GL. + */ + public void render(); + +} diff --git a/src/java/org/lwjgl/util/Timer.java b/src/java/org/lwjgl/util/Timer.java new file mode 100644 index 0000000..9a4d25a --- /dev/null +++ b/src/java/org/lwjgl/util/Timer.java @@ -0,0 +1,156 @@ +/* + * 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; + +import org.lwjgl.Sys; + +/** + * + * A hires timer. This measures time in seconds as floating point values. + * All Timers created are updated simultaneously by calling the static method + * tick(). This ensures that within a single iteration of a game loop that + * all timers are updated consistently with each other. + * + * @author cix_foo + * @version $Revision: 2983 $ + * $Id: Timer.java 2983 2008-04-07 18:36:09Z matzon $ + */ +public class Timer { + + // Record the timer resolution on classload + private static long resolution = Sys.getTimerResolution(); + + // Every so often we will re-query the timer resolution + private static final int QUERY_INTERVAL = 50; // in calls to tick() + private static int queryCount = 0; + + // Globally keeps track of time for all instances of Timer + private static long currentTime; + + // When the timer was started + private long startTime; + + // The last time recorded by getTime() + private long lastTime; + + // Whether the timer is paused + private boolean paused; + + static { + tick(); + } + + /** + * Constructs a timer. The timer will be reset to 0.0 and resumed immediately. + */ + public Timer() { + reset(); + resume(); + } + + /** + * @return the time in seconds, as a float + */ + public float getTime() { + if (!paused) { + lastTime = currentTime - startTime; + } + + return (float) ((double) lastTime / (double) resolution); + } + /** + * @return whether this timer is paused + */ + public boolean isPaused() { + return paused; + } + + /** + * Pause the timer. Whilst paused the time will not change for this timer + * when tick() is called. + * + * @see #resume() + */ + public void pause() { + paused = true; + } + + /** + * Reset the timer. Equivalent to set(0.0f); + * @see #set(float) + */ + public void reset() { + set(0.0f); + } + + /** + * Resume the timer. + * @see #pause() + */ + public void resume() { + paused = false; + startTime = currentTime - lastTime; + } + + /** + * Set the time of this timer + * @param newTime the new time, in seconds + */ + public void set(float newTime) { + long newTimeInTicks = (long) ((double) newTime * (double) resolution); + startTime = currentTime - newTimeInTicks; + lastTime = newTimeInTicks; + } + + /** + * Get the next time update from the system's hires timer. This method should + * be called once per main loop iteration; all timers are updated simultaneously + * from it. + */ + public static void tick() { + currentTime = Sys.getTime(); + + // Periodically refresh the timer resolution: + queryCount ++; + if (queryCount > QUERY_INTERVAL) { + queryCount = 0; + resolution = Sys.getTimerResolution(); + } + } + + /** + * Debug output. + */ + public String toString() { + return "Timer[Time=" + getTime() + ", Paused=" + paused + "]"; + } +} \ No newline at end of file diff --git a/src/java/org/lwjgl/util/WaveData.java b/src/java/org/lwjgl/util/WaveData.java new file mode 100644 index 0000000..1f2dec4 --- /dev/null +++ b/src/java/org/lwjgl/util/WaveData.java @@ -0,0 +1,253 @@ +/* + * 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; + +import java.io.BufferedInputStream; +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; +import java.nio.ByteBuffer; +import java.nio.ByteOrder; +import java.nio.ShortBuffer; + +import javax.sound.sampled.AudioFormat; +import javax.sound.sampled.AudioInputStream; +import javax.sound.sampled.AudioSystem; + +import org.lwjgl.openal.AL10; + +/** + * + * Utitlity class for loading wavefiles. + * + * @author Brian Matzon + * @version $Revision: 3274 $ + * $Id: WaveData.java 3274 2010-02-20 10:43:22Z matzon $ + */ +public class WaveData { + /** actual wave data */ + public final ByteBuffer data; + + /** format type of data */ + public final int format; + + /** sample rate of data */ + public final int samplerate; + + /** + * Creates a new WaveData + * + * @param data actual wavedata + * @param format format of wave data + * @param samplerate sample rate of data + */ + private WaveData(ByteBuffer data, int format, int samplerate) { + this.data = data; + this.format = format; + this.samplerate = samplerate; + } + + /** + * Disposes the wavedata + */ + public void dispose() { + data.clear(); + } + + /** + * Creates a WaveData container from the specified url + * + * @param path URL to file + * @return WaveData containing data, or null if a failure occured + */ + public static WaveData create(URL path) { + try { + return create( + AudioSystem.getAudioInputStream( + new BufferedInputStream(path.openStream()))); + } catch (Exception e) { + org.lwjgl.LWJGLUtil.log("Unable to create from: " + path + ", " + e.getMessage()); + return null; + } + } + + /** + * Creates a WaveData container from the specified in the classpath + * + * @param path path to file (relative, and in classpath) + * @return WaveData containing data, or null if a failure occured + */ + public static WaveData create(String path) { + return create(WaveData.class.getClassLoader().getResource(path)); + } + + /** + * Creates a WaveData container from the specified inputstream + * + * @param is InputStream to read from + * @return WaveData containing data, or null if a failure occured + */ + public static WaveData create(InputStream is) { + try { + return create( + AudioSystem.getAudioInputStream(is)); + } catch (Exception e) { + org.lwjgl.LWJGLUtil.log("Unable to create from inputstream, " + e.getMessage()); + return null; + } + } + + /** + * Creates a WaveData container from the specified bytes + * + * @param buffer array of bytes containing the complete wave file + * @return WaveData containing data, or null if a failure occured + */ + public static WaveData create(byte[] buffer) { + try { + return create( + AudioSystem.getAudioInputStream( + new BufferedInputStream(new ByteArrayInputStream(buffer)))); + } catch (Exception e) { + org.lwjgl.LWJGLUtil.log("Unable to create from byte array, " + e.getMessage()); + return null; + } + } + + /** + * Creates a WaveData container from the specified ByetBuffer. + * If the buffer is backed by an array, it will be used directly, + * else the contents of the buffer will be copied using get(byte[]). + * + * @param buffer ByteBuffer containing sound file + * @return WaveData containing data, or null if a failure occured + */ + public static WaveData create(ByteBuffer buffer) { + try { + byte[] bytes = null; + + if(buffer.hasArray()) { + bytes = buffer.array(); + } else { + bytes = new byte[buffer.capacity()]; + buffer.get(bytes); + } + return create(bytes); + } catch (Exception e) { + org.lwjgl.LWJGLUtil.log("Unable to create from ByteBuffer, " + e.getMessage()); + return null; + } + } + + /** + * Creates a WaveData container from the specified stream + * + * @param ais AudioInputStream to read from + * @return WaveData containing data, or null if a failure occured + */ + public static WaveData create(AudioInputStream ais) { + //get format of data + AudioFormat audioformat = ais.getFormat(); + + // get channels + int channels = 0; + if (audioformat.getChannels() == 1) { + if (audioformat.getSampleSizeInBits() == 8) { + channels = AL10.AL_FORMAT_MONO8; + } else if (audioformat.getSampleSizeInBits() == 16) { + channels = AL10.AL_FORMAT_MONO16; + } else { + assert false : "Illegal sample size"; + } + } else if (audioformat.getChannels() == 2) { + if (audioformat.getSampleSizeInBits() == 8) { + channels = AL10.AL_FORMAT_STEREO8; + } else if (audioformat.getSampleSizeInBits() == 16) { + channels = AL10.AL_FORMAT_STEREO16; + } else { + assert false : "Illegal sample size"; + } + } else { + assert false : "Only mono or stereo is supported"; + } + + //read data into buffer + ByteBuffer buffer = null; + try { + int available = ais.available(); + if(available <= 0) { + available = ais.getFormat().getChannels() * (int) ais.getFrameLength() * ais.getFormat().getSampleSizeInBits() / 8; + } + byte[] buf = new byte[ais.available()]; + int read = 0, total = 0; + while ((read = ais.read(buf, total, buf.length - total)) != -1 + && total < buf.length) { + total += read; + } + buffer = convertAudioBytes(buf, audioformat.getSampleSizeInBits() == 16); + } catch (IOException ioe) { + return null; + } + + + //create our result + WaveData wavedata = + new WaveData(buffer, channels, (int) audioformat.getSampleRate()); + + //close stream + try { + ais.close(); + } catch (IOException ioe) { + } + + return wavedata; + } + + private static ByteBuffer convertAudioBytes(byte[] audio_bytes, boolean two_bytes_data) { + ByteBuffer dest = ByteBuffer.allocateDirect(audio_bytes.length); + dest.order(ByteOrder.nativeOrder()); + ByteBuffer src = ByteBuffer.wrap(audio_bytes); + src.order(ByteOrder.LITTLE_ENDIAN); + if (two_bytes_data) { + ShortBuffer dest_short = dest.asShortBuffer(); + ShortBuffer src_short = src.asShortBuffer(); + while (src_short.hasRemaining()) + dest_short.put(src_short.get()); + } else { + while (src.hasRemaining()) + dest.put(src.get()); + } + dest.rewind(); + return dest; + } +} diff --git a/src/java/org/lwjgl/util/WritableColor.java b/src/java/org/lwjgl/util/WritableColor.java new file mode 100644 index 0000000..d70983a --- /dev/null +++ b/src/java/org/lwjgl/util/WritableColor.java @@ -0,0 +1,126 @@ +/* + * 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; + +import java.nio.ByteBuffer; + +/** + * Write interface for Colors + * @author $Author: matzon $ + * @version $Revision: 2983 $ + * $Id: WritableColor.java 2983 2008-04-07 18:36:09Z matzon $ + */ +public interface WritableColor { + /** + * Set a color + */ + public void set(int r, int g, int b, int a); + /** + * Set a color + */ + public void set(byte r, byte g, byte b, byte a); + /** + * Set a color + */ + public void set(int r, int g, int b); + /** + * Set a color + */ + public void set(byte r, byte g, byte b); + /** + * Set the Red component + */ + public void setRed(int red); + /** + * Set the Green component + */ + public void setGreen(int green); + /** + * Set the Blue component + */ + public void setBlue(int blue); + /** + * Set the Alpha component + */ + public void setAlpha(int alpha); + /** + * Set the Red component + */ + public void setRed(byte red); + /** + * Set the Green component + */ + public void setGreen(byte green); + /** + * Set the Blue component + */ + public void setBlue(byte blue); + /** + * Set the Alpha component + */ + public void setAlpha(byte alpha); + /** + * Read a color from a byte buffer + * @param src The source buffer + */ + public void readRGBA(ByteBuffer src); + /** + * Read a color from a byte buffer + * @param src The source buffer + */ + public void readRGB(ByteBuffer src); + /** + * Read a color from a byte buffer + * @param src The source buffer + */ + public void readARGB(ByteBuffer src); + /** + * Read a color from a byte buffer + * @param src The source buffer + */ + public void readBGRA(ByteBuffer src); + /** + * Read a color from a byte buffer + * @param src The source buffer + */ + public void readBGR(ByteBuffer src); + /** + * Read a color from a byte buffer + * @param src The source buffer + */ + public void readABGR(ByteBuffer src); + /** + * Set this color's color by copying another color + * @param src The source color + */ + public void setColor(ReadableColor src); +} \ No newline at end of file diff --git a/src/java/org/lwjgl/util/WritableDimension.java b/src/java/org/lwjgl/util/WritableDimension.java new file mode 100644 index 0000000..6852012 --- /dev/null +++ b/src/java/org/lwjgl/util/WritableDimension.java @@ -0,0 +1,54 @@ +/* + * 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; + +/** + * Write interface for Dimensions + * @author $Author: matzon $ + * @version $Revision: 2983 $ + * $Id: WritableDimension.java 2983 2008-04-07 18:36:09Z matzon $ + + */ +public interface WritableDimension { + public void setSize(int w, int h); + public void setSize(ReadableDimension d); + /** + * Sets the height. + * @param height The height to set + */ + public void setHeight(int height); + /** + * Sets the width. + * @param width The width to set + */ + public void setWidth(int width); +} \ No newline at end of file diff --git a/src/java/org/lwjgl/util/WritablePoint.java b/src/java/org/lwjgl/util/WritablePoint.java new file mode 100644 index 0000000..4b6c60a --- /dev/null +++ b/src/java/org/lwjgl/util/WritablePoint.java @@ -0,0 +1,45 @@ +/* + * 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; + +/** + * Write interface for Points + * @author $Author: matzon $ + * @version $Revision: 2983 $ + * $Id: WritablePoint.java 2983 2008-04-07 18:36:09Z matzon $ + */ +public interface WritablePoint { + public void setLocation(int x, int y); + public void setLocation(ReadablePoint p); + public void setX(int x); + public void setY(int y); +} \ No newline at end of file diff --git a/src/java/org/lwjgl/util/WritableRectangle.java b/src/java/org/lwjgl/util/WritableRectangle.java new file mode 100644 index 0000000..bc31371 --- /dev/null +++ b/src/java/org/lwjgl/util/WritableRectangle.java @@ -0,0 +1,63 @@ +/* + * 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; + +/** + * Write interface for Rectangles + * @author $Author: matzon $ + * @version $Revision: 2983 $ + * $Id: WritableRectangle.java 2983 2008-04-07 18:36:09Z matzon $ + */ +public interface WritableRectangle extends WritablePoint, WritableDimension { + + /** + * Sets the bounds of the rectangle + * @param x Position of rectangle on x axis + * @param y Position of rectangle on y axis + * @param width Width of rectangle + * @param height Height of rectangle + */ + public void setBounds(int x, int y, int width, int height); + + /** + * Sets the bounds of the rectangle + * @param location + * @param size + */ + public void setBounds(ReadablePoint location, ReadableDimension size); + + /** + * Sets the bounds of the rectangle + * @param src + */ + public void setBounds(ReadableRectangle src); +} diff --git a/src/java/org/lwjgl/util/XPMFile.java b/src/java/org/lwjgl/util/XPMFile.java new file mode 100644 index 0000000..eefc685 --- /dev/null +++ b/src/java/org/lwjgl/util/XPMFile.java @@ -0,0 +1,302 @@ +/* + * 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; + +import java.io.BufferedOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.LineNumberReader; +import java.util.HashMap; +import java.util.StringTokenizer; + +/** + *

    + * NOTE: This simple XPM reader does not support extensions nor hotspots + *

    + * + * @author Brian Matzon + * @author Jos Hirth + * @version $Revision$ + * $Id$ + */ + +public class XPMFile { + + /** Array of bytes (RGBA) */ + private byte bytes[] = null; + + private final static int WIDTH = 0; + + private final static int HEIGHT = 1; + + private final static int NUMBER_OF_COLORS = 2; + + private final static int CHARACTERS_PER_PIXEL = 3; + + private static int[] format = new int[4]; + + /* + * Private constructor, use load(String filename) + */ + private XPMFile() { + } + + /** + * Loads the XPM file + * + * @param file + * path to file + * @return XPMFile loaded, or exception + * @throws IOException + * If any IO exceptions occurs while reading file + */ + public static XPMFile load(String file) throws IOException { + return load(new FileInputStream(new File(file))); + } + + /** + * Loads the XPM file + * + * @param is + * InputStream to read file from + * @return XPMFile loaded, or exception + */ + public static XPMFile load(InputStream is) { + XPMFile xFile = new XPMFile(); + xFile.readImage(is); + return xFile; + } + + /** + * @return the height of the image. + */ + public int getHeight() { + return format[HEIGHT]; + } + + /** + * @return the width of the image. + */ + public int getWidth() { + return format[WIDTH]; + } + + /** + * @return The data of the image. + */ + public byte[] getBytes() { + return bytes; + } + + /** + * Read the image from the specified file. + */ + private void readImage(InputStream is) { + try { + LineNumberReader reader = new LineNumberReader( + new InputStreamReader(is)); + HashMap colors = new HashMap(); + + format = parseFormat(nextLineOfInterest(reader)); + + // setup color mapping + for (int i = 0; i < format[NUMBER_OF_COLORS]; i++) { + Object[] colorDefinition = parseColor(nextLineOfInterest(reader)); + colors.put(colorDefinition[0], colorDefinition[1]); + } + + // read actual image (convert to RGBA) + bytes = new byte[format[WIDTH] * format[HEIGHT] * 4]; + for (int i = 0; i < format[HEIGHT]; i++) { + parseImageLine(nextLineOfInterest(reader), format, colors, i); + } + } catch (Exception e) { + e.printStackTrace(); + throw new IllegalArgumentException("Unable to parse XPM File"); + } + } + + /** + * Finds the next interesting line of text. + * + * @param reader + * The LineNumberReader to read from + * @return The next interesting String (with stripped quotes) + * @throws IOException + * If any IO exceptions occurs while reading file + */ + private String nextLineOfInterest(LineNumberReader reader) + throws IOException { + String ret; + do { + ret = reader.readLine(); + } while (!ret.startsWith("\"")); + // lacks sanity check + return ret.substring(1, ret.lastIndexOf('\"')); + } + + /** + * Parses the format of the xpm file given a format string + * + * @param format + * String to parse + * @return Array specifying width, height, colors, characters per pixel + */ + private int[] parseFormat(String format) { + // format should look like this: + // 16 16 122 2 + + // tokenize it + StringTokenizer st = new StringTokenizer(format); + + return new int[] { Integer.parseInt(st.nextToken()), /* width */ + Integer.parseInt(st.nextToken()), /* height */ + Integer.parseInt(st.nextToken()), /* colors */ + Integer.parseInt(st.nextToken()) /* chars per pixel */ + }; + } + + /** + * Given a line defining a color/pixel, parses this into an array containing + * a key and a color + * + * @param line + * Line to parse + * @return Array containing a key (String) and a color (Integer) + */ + private Object[] parseColor(String line) { + // line should look like this: + // # c #0A0A0A + + // NOTE: will break if the color is something like "black" or "gray50" + // etc (instead of #rrggbb). + + String key = line.substring(0, format[CHARACTERS_PER_PIXEL]); + // since we always assume color as type we dont need to read it + // String type = line.substring(format[CHARACTERS_PER_PIXEL] + 1, + // format[CHARACTERS_PER_PIXEL] + 2); + String color = line.substring(format[CHARACTERS_PER_PIXEL] + 4); + + // we always assume type is color, and supplied as # + return new Object[] { key, new Integer(Integer.parseInt(color, 16)) }; + } + + /** + * Parses an Image line into its byte values + * + * @param line + * Line of chars to parse + * @param format + * Format to expext it in + * @param colors + * Colors to lookup + * @param index + * current index into lines, we've reached + */ + private void parseImageLine(String line, int[] format, HashMap colors, + int index) { + // offset for next line + int offset = index * 4 * format[WIDTH]; + + // read characters times, + // each iteration equals one pixel + for (int i = 0; i < format[WIDTH]; i++) { + String key = line + .substring( + i * format[CHARACTERS_PER_PIXEL], + (i * format[CHARACTERS_PER_PIXEL] + format[CHARACTERS_PER_PIXEL])); + Integer color = (Integer) colors.get(key); + bytes[offset + (i * 4)] = (byte) ((color.intValue() & 0x00ff0000) >> 16); + bytes[offset + ((i * 4) + 1)] = (byte) ((color.intValue() & 0x0000ff00) >> 8); + bytes[offset + ((i * 4) + 2)] = (byte) ((color.intValue() & 0x000000ff) >> 0); // looks + // better + // :) + bytes[offset + ((i * 4) + 3)] = (byte) 0xff; // always 0xff alpha + } + } + + /** + * @param args + */ + public static void main(String[] args) { + if (args.length != 1) { + System.out.println("usage:\nXPMFile "); + } + + try { + String out = args[0].substring(0, args[0].indexOf(".")) + ".raw"; + XPMFile file = XPMFile.load(args[0]); + BufferedOutputStream bos = new BufferedOutputStream( + new FileOutputStream(new File(out))); + bos.write(file.getBytes()); + bos.close(); + + // showResult(file.getBytes()); + } catch (Exception e) { + e.printStackTrace(); + } + } + /* + private static void showResult(byte[] bytes) { + final BufferedImage i = new BufferedImage(16, 16, BufferedImage.TYPE_INT_ARGB); + int c = 0; + for (int y = 0; y < 16; y++) { + for (int x = 0; x < 16; x++) { + i.setRGB(x, y, (bytes[c] << 16) + (bytes[c + 1] << 8) + (bytes[c + 2] << 0) + (bytes[c + 3] << 24));//+(128<<24));// + c += 4; + } + } + + final Frame frame = new Frame("XPM Result"); + frame.add(new Canvas() { + + public void paint(Graphics g) { + g.drawImage(i, 0, 0, frame); + } + }); + + frame.addWindowListener(new WindowAdapter() { + + public void windowClosing(WindowEvent e) { + frame.dispose(); + } + + }); + + frame.setSize(100, 100); + frame.setVisible(true); + }*/ +} \ No newline at end of file diff --git a/src/java/org/lwjgl/util/applet/AppletLoader.java b/src/java/org/lwjgl/util/applet/AppletLoader.java new file mode 100644 index 0000000..d9778b8 --- /dev/null +++ b/src/java/org/lwjgl/util/applet/AppletLoader.java @@ -0,0 +1,1357 @@ +/* + * 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.applet; + +import java.applet.Applet; +import java.applet.AppletStub; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.FontMetrics; +import java.awt.Graphics; +import java.awt.Image; +import java.awt.MediaTracker; +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.FilePermission; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.io.Writer; +import java.lang.reflect.Constructor; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.net.HttpURLConnection; +import java.net.JarURLConnection; +import java.net.SocketPermission; +import java.net.URL; +import java.net.URLClassLoader; +import java.net.URLConnection; +import java.security.AccessControlException; +import java.security.AccessController; +import java.security.CodeSource; +import java.security.PermissionCollection; +import java.security.PrivilegedExceptionAction; +import java.security.SecureClassLoader; +import java.security.cert.Certificate; +import java.util.Enumeration; +import java.util.StringTokenizer; +import java.util.Vector; +import java.util.jar.JarEntry; +import java.util.jar.JarFile; +import java.util.jar.JarOutputStream; +import java.util.jar.Pack200; + +import sun.security.util.SecurityConstants; + +/** + *

    + * The AppletLoader enables deployment of LWJGL to applets in an easy + * and polished way. The loader will display a configurable logo and progressbar + * while the relevant jars (generic and native) are downloaded from a specified source. + *

    + *

    + * The downloaded jars are extracted to the users temporary directory - and if enabled, cached for + * faster loading in future uses. + *

    + *

    + * The following applet parameters are required: + *

      + *
    • al_main - [String] Full package and class the applet to instantiate and display when loaded.
    • + *
    • al_logo - [String Path of of the logo resource to paint while loading.
    • + *
    • al_progressbar - [String] Path of the progressbar resource to paint on top of the logo, width clipped by percentage.
    • + *
    • al_jars - [String] Comma seperated list of jars to download.
    • + *
    • al_windows - [String] Jar containing native files for windows.
    • + *
    • al_linux - [String] Jar containing native files for linux.
    • + *
    • al_mac - [String] Jar containing native files for mac.
    • + *
    • al_solaris - [String] Jar containing native files for solaris.
    • + *
    • al_freebsd - [String] Jar containing native files for freebsd.
    • + *
    + *

    + *

    + * Additionally the following parameters can be supplied to tweak the behaviour of the AppletLoader. + *

      + *
    • al_version - [int or float] Version of deployment. If this is specified, the jars will be cached and + * reused if the version matches. If version doesn't match all of the files are reloaded.
    • + *
    • al_bgcolor - [String] Hex formated color to use as background. Default: ffffff.
    • + *
    • al_fgcolor - [String] Hex formated color to use as foreground. Default: 000000.
    • + *
    • al_errorcolor - [String] Hex formated color to use as foreground color on error. Default: ff0000.
    • + *
    • al_debug - [boolean] Whether to enable debug mode. Default: false.
    • + *
    • al_prepend_host - [boolean] Whether to limit caching to this domain, disable if your applet is hosted on multple domains and needs to share the cache. Default: true.
    • + *
    + *

    + * @author kappaOne + * @author Brian Matzon + * @version $Revision$ + * $Id$ + */ +public class AppletLoader extends Applet implements Runnable, AppletStub { + + /** initializing */ + public static final int STATE_INIT = 1; + + /** determining which packages that are required */ + public static final int STATE_DETERMINING_PACKAGES = 2; + + /** checking for already downloaded files */ + public static final int STATE_CHECKING_CACHE = 3; + + /** downloading packages */ + public static final int STATE_DOWNLOADING = 4; + + /** extracting packages */ + public static final int STATE_EXTRACTING_PACKAGES = 5; + + /** updating the classpath */ + public static final int STATE_UPDATING_CLASSPATH = 6; + + /** switching to real applet */ + public static final int STATE_SWITCHING_APPLET = 7; + + /** initializing real applet */ + public static final int STATE_INITIALIZE_REAL_APPLET = 8; + + /** stating real applet */ + public static final int STATE_START_REAL_APPLET = 9; + + /** done */ + public static final int STATE_DONE = 10; + + /** used to calculate length of progress bar */ + protected int percentage; + + /** current size of download in bytes */ + protected int currentSizeDownload; + + /** total size of download in bytes */ + protected int totalSizeDownload; + + /** current size of extracted in bytes */ + protected int currentSizeExtract; + + /** total size of extracted in bytes */ + protected int totalSizeExtract; + + /** logo to be shown while loading */ + protected Image logo; + + /** progressbar to render while loading */ + protected Image progressbar; + + /** offscreen image used */ + protected Image offscreen; + + /** background color of applet */ + protected Color bgColor = Color.white; + + /** Color to write errors in */ + protected Color errorColor = Color.red; + + /** color to write foreground in */ + protected Color fgColor = Color.black; + + /** urls of the jars to download */ + protected URL[] urlList; + + /** classLoader used to add downloaded jars to the classpath */ + protected ClassLoader classLoader; + + /** actual thread that does the loading */ + protected Thread loaderThread; + + /** animation thread that renders our load screen while loading */ + protected Thread animationThread; + + /** applet to load after all downloads are complete */ + protected Applet lwjglApplet; + + /** whether a fatal error occured */ + protected boolean fatalError; + + /** fatal error that occured */ + protected String fatalErrorDescription; + + /** whether we're running in debug mode */ + protected boolean debugMode; + + /** whether to prepend host to cache path */ + protected boolean prependHost; + + /** String to display as a subtask */ + protected String subtaskMessage = ""; + + /** state of applet loader */ + protected int state = STATE_INIT; + + /** whether lzma is supported */ + protected boolean lzmaSupported = false; + + /** whether pack200 is supported */ + protected boolean pack200Supported = false; + + /** generic error message to display on error */ + protected String[] genericErrorMessage = { "An error occured while loading the applet.", + "Please contact support to resolve this issue.", + ""}; + + /** whether a certificate refused error occured */ + protected boolean certificateRefused; + + /** error message to display if user refuses to accept certicate*/ + protected String[] certificateRefusedMessage = { "Permissions for Applet Refused.", + "Please accept the permissions dialog to allow", + "the applet to continue the loading process."}; + + /** have natives been loaded by another instance of this applet */ + static protected boolean natives_loaded = false; + + /* + * @see java.applet.Applet#init() + */ + public void init() { + state = STATE_INIT; + + // sanity check + String[] requiredArgs = {"al_main", "al_logo", "al_progressbar", "al_jars"}; + for(int i=0; i 0) { + messageX = (getWidth() - fm.stringWidth(subtaskMessage)) / 2; + og.drawString(subtaskMessage, messageX, messageY+20); + } + + // draw loading bar, clipping it depending on percentage done + int barSize = (progressbar.getWidth(this) * percentage) / 100; + og.clipRect(0, 0, x + barSize, getHeight()); + og.drawImage(progressbar, x, y, null); + } + + og.dispose(); + + // finally draw it all + g.drawImage(offscreen, 0, 0, null); + } + + /** + * @return string describing the state of the loader + */ + protected String getDescriptionForState() { + switch (state) { + case STATE_INIT: + return "Initializing loader"; + case STATE_DETERMINING_PACKAGES: + return "Determining packages to load"; + case STATE_CHECKING_CACHE: + return "Checking cache for existing files"; + case STATE_DOWNLOADING: + return "Downloading packages"; + case STATE_EXTRACTING_PACKAGES: + return "Extracting downloaded packages"; + case STATE_UPDATING_CLASSPATH: + return "Updating classpath"; + case STATE_SWITCHING_APPLET: + return "Switching applet"; + case STATE_INITIALIZE_REAL_APPLET: + return "Initializing real applet"; + case STATE_START_REAL_APPLET: + return "Starting real applet"; + case STATE_DONE: + return "Done loading"; + default: + return "unknown state"; + } + } + + /** + * Trims the passed file string based on the available capabilities + * @param file string of files to be trimmed + * @return trimmed string based on capabilities of client + */ + protected String trimExtensionByCapabilities(String file) { + if (!pack200Supported) { + file = file.replaceAll(".pack", ""); + } + + if (!lzmaSupported) { + file = file.replaceAll(".lzma", ""); + } + return file; + } + + /** + * Reads list of jars to download and adds the urls to urlList + * also finds out which OS you are on and adds appropriate native + * jar to the urlList + */ + protected void loadJarURLs() throws Exception { + state = STATE_DETERMINING_PACKAGES; + + // jars to load + String jarList = getParameter("al_jars"); + + jarList = trimExtensionByCapabilities(jarList); + + StringTokenizer jar = new StringTokenizer(jarList, ", "); + + int jarCount = jar.countTokens() + 1; + + urlList = new URL[jarCount]; + + URL path = getCodeBase(); + + // set jars urls + for (int i = 0; i < jarCount - 1; i++) { + urlList[i] = new URL(path, jar.nextToken()); + } + + // native jar url + String osName = System.getProperty("os.name"); + String nativeJar = null; + + if (osName.startsWith("Win")) { + nativeJar = getParameter("al_windows"); + } else if (osName.startsWith("Linux")) { + nativeJar = getParameter("al_linux"); + } else if (osName.startsWith("Mac")) { + nativeJar = getParameter("al_mac"); + } else if (osName.startsWith("Solaris") || osName.startsWith("SunOS")) { + nativeJar = getParameter("al_solaris"); + } else if (osName.startsWith("FreeBSD")) { + nativeJar = getParameter("al_freebsd"); + } else { + fatalErrorOccured("OS (" + osName + ") not supported", null); + } + + if (nativeJar == null) { + fatalErrorOccured("no lwjgl natives files found", null); + } else { + nativeJar = trimExtensionByCapabilities(nativeJar); + urlList[jarCount - 1] = new URL(path, nativeJar); + } + } + + /** + * 4 steps + * + * 1) check version of applet and decide whether to download jars + * 2) download the jars + * 3) extract natives + * 4) add to jars to class path + * 5) switch applets + */ + public void run() { + state = STATE_CHECKING_CACHE; + + percentage = 5; + + try { + debug_sleep(2000); + + // parse the urls for the jars into the url list + loadJarURLs(); + + // get path where applet will be stored + String path = (String) AccessController.doPrivileged(new PrivilegedExceptionAction() { + public Object run() throws Exception { + + // we append the code base to avoid naming collisions with al_title + String codebase = ""; + if(prependHost) { + codebase = getCodeBase().getHost(); + if(codebase == null || codebase.length() == 0) { + codebase = "localhost"; + } + codebase += File.separator; + } + return System.getProperty("java.io.tmpdir") + File.separator + codebase + getParameter("al_title") + File.separator; + } + }); + + File dir = new File(path); + + // create directory + if (!dir.exists()) { + dir.mkdirs(); + } + dir = new File(dir, "version"); + + // if applet already available don't download anything + boolean cacheAvailable = false; + + // version of applet + String version = getParameter("al_version"); + float latestVersion = 0; + + // if applet version specifed, check if you have latest version of applet + if (version != null) { + + latestVersion = Float.parseFloat(version); + + // if version file exists + if (dir.exists()) { + // compare to new version + if (latestVersion <= readVersionFile(dir)) { + cacheAvailable = true; + percentage = 90; + + if(debugMode) { + System.out.println("Loading Cached Applet Version " + latestVersion); + } + debug_sleep(2000); + } + } + } + + // if jars not available or need updating download them + if (!cacheAvailable) { + // downloads jars from the server + downloadJars(path); // 10-55% + + // Extract Pack and LZMA files + extractJars(path); // 55-65% + + // Extracts Native Files + extractNatives(path); // 65-85% + + // add version information once jars downloaded successfully + if (version != null) { + percentage = 90; + writeVersionFile(dir, latestVersion); + } + } + + // add the downloaded jars and natives to classpath + updateClassPath(path); + + // switch to LWJGL Applet + switchApplet(); + + state = STATE_DONE; + } catch (AccessControlException ace) { + fatalErrorOccured(ace.getMessage(), ace); + certificateRefused = true; + } catch (Exception e) { + fatalErrorOccured(e.getMessage(), e); + } finally { + loaderThread = null; + } + } + + /** + * read the current version file + * + * @param file the file to read + * @return the version value of saved file + * @throws Exception if it fails to read value + */ + protected float readVersionFile(File file) throws Exception { + DataInputStream dis = new DataInputStream(new FileInputStream(file)); + float version = dis.readFloat(); + dis.close(); + return version; + } + + /** + * write out version file of applet + * + * @param file the file to write out to + * @param version the version of the applet as a float + * @throws Exception if it fails to write file + */ + protected void writeVersionFile(File file, float version) throws Exception { + DataOutputStream dos = new DataOutputStream(new FileOutputStream(file)); + dos.writeFloat(version); + dos.close(); + } + + /** + * Edits the ClassPath at runtime to include the jars + * that have just been downloaded and then adds the + * lwjgl natives folder property. + * + * @param path location where applet is stored + * @throws Exception if it fails to add classpath + */ + protected void updateClassPath(String path) throws Exception { + + state = STATE_UPDATING_CLASSPATH; + + percentage = 95; + + URL[] urls = new URL[urlList.length]; + + for (int i = 0; i < urlList.length; i++) { + urls[i] = new URL("file:" + path + getJarName(urlList[i])); + } + + // add downloaded jars to the classpath with required permissions + classLoader = new URLClassLoader(urls) { + protected PermissionCollection getPermissions (CodeSource codesource) { + PermissionCollection perms = null; + + try { + // getPermissions from original classloader is important as it checks for signed jars and shows any security dialogs needed + Method method = SecureClassLoader.class.getDeclaredMethod("getPermissions", new Class[] { CodeSource.class }); + method.setAccessible(true); + perms = (PermissionCollection)method.invoke(getClass().getClassLoader(), new Object[] {codesource}); + + String host = getCodeBase().getHost(); + + if (host != null && (host.length() > 0)) { + // add permission for downloaded jars to access host they were from + perms.add(new SocketPermission(host, SecurityConstants.SOCKET_CONNECT_ACCEPT_ACTION)); + } + else if (codesource.getLocation().getProtocol().equals("file")) { + // if running locally add file permission + String path = codesource.getLocation().getFile().replace('/', File.separatorChar); + perms.add(new FilePermission(path, SecurityConstants.FILE_READ_ACTION)); + } + + } catch (Exception e) { + e.printStackTrace(); + } + + return perms; + } + }; + + debug_sleep(2000); + + // unload natives loaded by a previous instance of this lwjgl applet + unloadNatives(path); + + // add natives files path to native class path + System.setProperty("org.lwjgl.librarypath", path + "natives"); + + // Make sure jinput knows about the new path too + System.setProperty("net.java.games.input.librarypath", path + "natives"); + + // mark natives as loaded + natives_loaded = true; + } + + /** + * Unload natives loaded by a different classloader. + * + * Due to limitations of the jvm, native files can only + * be loaded once and only be used by the classloader + * they were loaded from. + * + * Due to the way applets on plugin1 work, one jvm must + * be used for all applets. We need to use multiple + * classloaders in the same jvm due to LWJGL's static + * nature. I order to solver this we simply remove the + * natives from a previous classloader allowing a new + * classloader to use those natives in the same jvm. + * + * This method will only attempt to unload natives from a + * previous classloader if it detects that the natives have + * been loaded in the same jvm. + * + * @param nativePath directory where natives are stored + */ + private void unloadNatives(String nativePath) { + + // check whether natives have been loaded into this jvm + if (!natives_loaded) { + return; + } + + try { + Field field = ClassLoader.class.getDeclaredField("loadedLibraryNames"); + field.setAccessible(true); + Vector libs = (Vector) field.get(getClass().getClassLoader()); + + String path = new File(nativePath).getCanonicalPath(); + + for (int i = 0; i < libs.size(); i++) { + String s = (String) libs.get(i); + + // if a native from the nativePath directory is loaded, unload it + if (s.startsWith(path)) { + libs.remove(i); + i--; + } + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * replace the current applet with the lwjgl applet + * using AppletStub and initialise and start it + */ + protected void switchApplet() throws Exception { + + state = STATE_SWITCHING_APPLET; + percentage = 100; + + debug_sleep(2000); + + Class appletClass = classLoader.loadClass(getParameter("al_main")); + lwjglApplet = (Applet) appletClass.newInstance(); + + lwjglApplet.setStub(this); + lwjglApplet.setSize(getWidth(), getHeight()); + + setLayout(new BorderLayout()); + add(lwjglApplet); + validate(); + + state = STATE_INITIALIZE_REAL_APPLET; + lwjglApplet.init(); + + state = STATE_START_REAL_APPLET; + lwjglApplet.start(); + } + + /** + * Will download the jars from the server using the list of urls + * in urlList, while at the same time updating progress bar + * + * @param path location of the directory to save to + * @throws Exception if download fails + */ + protected void downloadJars(String path) throws Exception { + + state = STATE_DOWNLOADING; + + URLConnection urlconnection; + + // store file sizes, used for download verification + int[] fileSizes = new int[urlList.length]; + + // calculate total size of jars to download + for (int i = 0; i < urlList.length; i++) { + urlconnection = urlList[i].openConnection(); + urlconnection.setDefaultUseCaches(false); + if (urlconnection instanceof HttpURLConnection) { + ((HttpURLConnection) urlconnection).setRequestMethod("HEAD"); + } + fileSizes[i] = urlconnection.getContentLength(); + totalSizeDownload += fileSizes[i]; + } + + int initialPercentage = percentage = 10; + + // download each jar + byte buffer[] = new byte[65536]; + for (int i = 0; i < urlList.length; i++) { + + int unsuccessfulAttempts = 0; + int maxUnsuccessfulAttempts = 3; + boolean downloadFile = true; + + // download the jar a max of 3 times + while(downloadFile) { + downloadFile = false; + + debug_sleep(2000); + + urlconnection = urlList[i].openConnection(); + + if (urlconnection instanceof HttpURLConnection) { + urlconnection.setRequestProperty("Cache-Control", "no-cache"); + urlconnection.connect(); + } + + String currentFile = getFileName(urlList[i]); + InputStream inputstream = getJarInputStream(currentFile, urlconnection); + FileOutputStream fos = new FileOutputStream(path + currentFile); + + + int bufferSize; + long downloadStartTime = System.currentTimeMillis(); + int downloadedAmount = 0; + int fileSize = 0; + String downloadSpeedMessage = ""; + + while ((bufferSize = inputstream.read(buffer, 0, buffer.length)) != -1) { + debug_sleep(10); + fos.write(buffer, 0, bufferSize); + currentSizeDownload += bufferSize; + fileSize += bufferSize; + percentage = initialPercentage + ((currentSizeDownload * 45) / totalSizeDownload); + subtaskMessage = "Retrieving: " + currentFile + " " + ((currentSizeDownload * 100) / totalSizeDownload) + "%"; + + downloadedAmount += bufferSize; + long timeLapse = System.currentTimeMillis() - downloadStartTime; + // update only if a second or more has passed + if (timeLapse >= 1000) { + // get kb/s, nice that bytes/millis is same as kilobytes/seconds + float downloadSpeed = (float) downloadedAmount / timeLapse; + // round to two decimal places + downloadSpeed = ((int)(downloadSpeed*100))/100f; + // set current speed message + downloadSpeedMessage = " @ " + downloadSpeed + " KB/sec"; + // reset downloaded amount + downloadedAmount = 0; + // reset start time + downloadStartTime = System.currentTimeMillis(); + } + + subtaskMessage += downloadSpeedMessage; + } + + inputstream.close(); + fos.close(); + + // download complete, verify if it was successful + if (urlconnection instanceof HttpURLConnection) { + if (fileSize == fileSizes[i]) { + // successful download + } + else if (fileSizes[i] <= 0) { + // If contentLength for fileSizes[i] <= 0, we don't know if the download + // is complete. We're going to guess the download is complete. + } + else { + unsuccessfulAttempts++; + // download failed try again + if (unsuccessfulAttempts < maxUnsuccessfulAttempts) { + downloadFile = true; + currentSizeDownload -= fileSize; // reset progress bar + } + else { + // retry attempts exhasted, download failed + throw new Exception("failed to download " + currentFile); + } + } + } + } + } + subtaskMessage = ""; + } + + /** + * Retrieves a jar files input stream. This method exists primarily to fix an Opera hang in getInputStream + * @param urlconnection connection to get input stream from + * @return InputStream or null if not possible + */ + protected InputStream getJarInputStream(final String currentFile, final URLConnection urlconnection) throws Exception { + final InputStream[] is = new InputStream[1]; + + // try to get the input stream 3 times. + // Wait at most 5 seconds before interrupting the thread + for (int j = 0; j < 3 && is[0] == null; j++) { + Thread t = new Thread() { + public void run() { + try { + is[0] = urlconnection.getInputStream(); + } catch (IOException e) { + /* ignored */ + } + } + }; + t.setName("JarInputStreamThread"); + t.start(); + + int iterationCount = 0; + while(is[0] == null && iterationCount++ < 5) { + try { + t.join(1000); + } catch (InterruptedException inte) { + /* ignored */ + } + } + + if(is[0] == null) { + try { + t.interrupt(); + t.join(); + } catch (InterruptedException inte) { + /* ignored */ + } + } + } + + if(is[0] == null) { + throw new Exception("Unable to get input stream for " + currentFile); + } + + + return is[0]; + } + + /** + * Extract LZMA File + * @param in Input path to pack file + * @param out output path to resulting file + * @throws exception if any errors occur + */ + protected void extractLZMA(String in, String out) throws Exception { + + File f = new File(in); + FileInputStream fileInputHandle = new FileInputStream(f); + + // use reflection to avoid hard dependency + Class clazz = Class.forName( "LZMA.LzmaInputStream" ); + Constructor constructor = clazz.getDeclaredConstructor( new Class[] {InputStream.class} ); + InputStream inputHandle = (InputStream) constructor.newInstance( new Object[] {fileInputHandle} ); + + OutputStream outputHandle; + outputHandle = new FileOutputStream(out); + + byte [] buffer = new byte [1<<14]; + + int ret = inputHandle.read(buffer); + while (ret >= 1) { + outputHandle.write(buffer,0,ret); + ret = inputHandle.read(buffer); + } + + inputHandle.close(); + outputHandle.close(); + + outputHandle = null; + inputHandle = null; + + // delete LZMA file, as it is no longer needed + f.delete(); + } + + /** + * Extract Pack File + * @param in Input path to pack file + * @param out output path to resulting file + * @throws exception if any errors occur + */ + protected void extractPack(String in, String out) throws Exception { + File f = new File(in); + FileOutputStream fostream = new FileOutputStream(out); + JarOutputStream jostream = new JarOutputStream(fostream); + + Pack200.Unpacker unpacker = Pack200.newUnpacker(); + unpacker.unpack(f, jostream); + jostream.close(); + + // delete pack file as its no longer needed + f.delete(); + } + + /** + * Extract all jars from any lzma/pack files + * + * @param path output path + * @throws exception if any errors occur + */ + protected void extractJars(String path) throws Exception { + state = STATE_EXTRACTING_PACKAGES; + + float increment = (float) 10.0 / urlList.length; + // extract all lzma and pack.lzma files + for (int i = 0; i < urlList.length; i++) { + percentage = 55 + (int) (increment * (i+1)); + String filename = getFileName(urlList[i]); + + if (filename.endsWith(".pack.lzma")) { + subtaskMessage = "Extracting: " + filename + " to " + filename.replaceAll(".lzma", ""); + debug_sleep(1000); + extractLZMA(path + filename, path + filename.replaceAll(".lzma", "")); + + subtaskMessage = "Extracting: " + filename.replaceAll(".lzma", "") + " to " + filename.replaceAll(".pack.lzma", ""); + debug_sleep(1000); + extractPack(path + filename.replaceAll(".lzma", ""), path + filename.replaceAll(".pack.lzma", "")); + } + else if (filename.endsWith(".pack")) { + subtaskMessage = "Extracting: " + filename + " to " + filename.replace(".pack", ""); + debug_sleep(1000); + extractPack(path + filename, path + filename.replace(".pack", "")); + } + else if (filename.endsWith(".lzma")) { + subtaskMessage = "Extracting: " + filename + " to " + filename.replace(".lzma", ""); + debug_sleep(1000); + extractLZMA(path + filename, path + filename.replace(".lzma", "")); + } + } + } + + /** + * This method will extract all file from the native jar and extract them + * to the subdirectory called "natives" in the local path, will also check + * to see if the native jar files is signed properly + * + * @param path base folder containing all downloaded jars + * @throws Exception if it fails to extract files + */ + protected void extractNatives(String path) throws Exception { + + state = STATE_EXTRACTING_PACKAGES; + + int initialPercentage = percentage; + + // get name of jar file with natives from urlList, it will be the last url + String nativeJar = getJarName(urlList[urlList.length - 1]); + + // get the current certificate to compare against native files + Certificate[] certificate = AppletLoader.class.getProtectionDomain().getCodeSource().getCertificates(); + + // workaround for bug where cached applet loader does not have certificates!? + if (certificate == null) { + URL location = AppletLoader.class.getProtectionDomain().getCodeSource().getLocation(); + + // manually load the certificate + JarURLConnection jurl = (JarURLConnection) (new URL("jar:" + location.toString() + "!/org/lwjgl/util/applet/AppletLoader.class").openConnection()); + jurl.setDefaultUseCaches(true); + certificate = jurl.getCertificates(); + } + + // create native folder + File nativeFolder = new File(path + "natives"); + if (!nativeFolder.exists()) { + nativeFolder.mkdir(); + } + + // open jar file + JarFile jarFile = new JarFile(path + nativeJar, true); + + // get list of files in jar + Enumeration entities = jarFile.entries(); + + totalSizeExtract = 0; + + // calculate the size of the files to extract for progress bar + while (entities.hasMoreElements()) { + JarEntry entry = (JarEntry) entities.nextElement(); + + // skip directories and anything in directories + // conveniently ignores the manifest + if (entry.isDirectory() || entry.getName().indexOf('/') != -1) { + continue; + } + totalSizeExtract += entry.getSize(); + } + + currentSizeExtract = 0; + + // reset point to begining by getting list of file again + entities = jarFile.entries(); + + // extract all files from the jar + while (entities.hasMoreElements()) { + JarEntry entry = (JarEntry) entities.nextElement(); + + // skip directories and anything in directories + // conveniently ignores the manifest + if (entry.isDirectory() || entry.getName().indexOf('/') != -1) { + continue; + } + + // check if native file already exists if so delete it to make room for new one + // useful when using the reload button on the browser + File f = new File(path + "natives" + File.separator + entry.getName()); + if (f.exists()) { + if (!f.delete()) { + continue; // unable to delete file, it is in use, skip extracting it + } + } + + debug_sleep(1000); + + InputStream in = jarFile.getInputStream(jarFile.getEntry(entry.getName())); + OutputStream out = new FileOutputStream(path + "natives" + File.separator + entry.getName()); + + int bufferSize; + byte buffer[] = new byte[65536]; + + while ((bufferSize = in.read(buffer, 0, buffer.length)) != -1) { + debug_sleep(10); + out.write(buffer, 0, bufferSize); + currentSizeExtract += bufferSize; + + // update progress bar + percentage = initialPercentage + ((currentSizeExtract * 20) / totalSizeExtract); + subtaskMessage = "Extracting: " + entry.getName() + " " + ((currentSizeExtract * 100) / totalSizeExtract) + "%"; + } + + // validate if the certificate for native file is correct + validateCertificateChain(certificate, entry.getCertificates()); + + in.close(); + out.close(); + } + subtaskMessage = ""; + + jarFile.close(); + + // delete native jar as it is no longer needed + File f = new File(path + nativeJar); + f.delete(); + } + + /** + * Validates the certificate chain for a single file + * + * @param ownCerts Chain of certificates to check against + * @param native_certs Chain of certificates to check + */ + protected static void validateCertificateChain(Certificate[] ownCerts, Certificate[] native_certs) throws Exception { + if (native_certs == null) + throw new Exception("Unable to validate certificate chain. Native entry did not have a certificate chain at all"); + + if (ownCerts.length != native_certs.length) + throw new Exception("Unable to validate certificate chain. Chain differs in length [" + ownCerts.length + " vs " + native_certs.length + "]"); + + for (int i = 0; i < ownCerts.length; i++) { + if (!ownCerts[i].equals(native_certs[i])) { + throw new Exception("Certificate mismatch: " + ownCerts[i] + " != " + native_certs[i]); + } + } + } + + /** + * Get Image from path provided + * + * @param s location of the image + * @return the Image file + */ + protected Image getImage(String s) { + try { + URL url = AppletLoader.class.getResource("/"+s); + + // if image not found in jar, look outside it + if (url == null) { + url = new URL(getCodeBase(), s); + } + + Image image = super.getImage(url); + + // wait for image to load + MediaTracker tracker = new MediaTracker(this); + tracker.addImage(image, 0); + tracker.waitForAll(); + + return image; + } catch (Exception e) { + /* */ + } + return null; + } + + + /** + * Get jar name from URL. + * + * @param url Get jar file name from this url + * @return file name as string + */ + protected String getJarName(URL url) { + String fileName = url.getFile(); + + if (fileName.endsWith(".pack.lzma")) { + fileName = fileName.replaceAll(".pack.lzma", ""); + } else if (fileName.endsWith(".pack")) { + fileName = fileName.replaceAll(".pack", ""); + } else if (fileName.endsWith(".lzma")) { + fileName = fileName.replaceAll(".lzma", ""); + } + + return fileName.substring(fileName.lastIndexOf('/') + 1); + } + + /** + * Get file name portion of URL. + * + * @param url Get file name from this url + * @return file name as string + */ + protected String getFileName(URL url) { + String fileName = url.getFile(); + return fileName.substring(fileName.lastIndexOf('/') + 1); + } + + /** + * Retrieves the color + * + * @param color Color to load + * @param defaultColor Default color to use if no color to load + * @return Color to use + */ + protected Color getColor(String color, Color defaultColor) { + String param_color = getParameter(color); + if (param_color != null) { + return new Color(Integer.parseInt(param_color, 16)); + } + return defaultColor; + } + + /** + * Retrieves the boolean value for the applet + * @param name Name of parameter + * @param defaultValue default value to return if no such parameter + * @return value of parameter or defaultValue + */ + protected boolean getBooleanParameter(String name, boolean defaultValue) { + String parameter = getParameter(name); + if(parameter != null) { + return Boolean.parseBoolean(parameter); + } + return defaultValue; + } + + /** + * Sets the state of the loaded and prints some debug information + * + * @param error Error message to print + */ + protected void fatalErrorOccured(String error, Exception e) { + fatalError = true; + fatalErrorDescription = "Fatal error occured (" + state + "): " + error; + System.out.println(fatalErrorDescription); + if(e != null) { + System.out.println(generateStacktrace(e)); + } + repaint(); + } + + /** + * Utility method for sleeping + * Will only really sleep if debug has been enabled + * @param ms milliseconds to sleep + */ + protected void debug_sleep(long ms) { + if(debugMode) { + sleep(ms); + } + } + + /** + * Utility method for sleeping + * @param ms milliseconds to sleep + */ + protected void sleep(long ms) { + try { + Thread.sleep(ms); + } catch (Exception e) { + /* ignored */ + } + } + + +} \ No newline at end of file diff --git a/src/java/org/lwjgl/util/generator/ALTypeMap.java b/src/java/org/lwjgl/util/generator/ALTypeMap.java new file mode 100644 index 0000000..c64cbf9 --- /dev/null +++ b/src/java/org/lwjgl/util/generator/ALTypeMap.java @@ -0,0 +1,218 @@ +/* + * 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; + +/** + * + * The OpenAL specific generator behaviour + * + * @author elias_naur + * @version $Revision: 2983 $ + * $Id: ALTypeMap.java 2983 2008-04-07 18:36:09Z matzon $ + */ + +import com.sun.mirror.declaration.*; +import com.sun.mirror.type.*; + +import java.io.*; +import java.util.*; +import java.nio.*; + +public class ALTypeMap implements TypeMap { + private static final Map native_types_to_primitive; + + static { + native_types_to_primitive = new HashMap(); + native_types_to_primitive.put(ALboolean.class, PrimitiveType.Kind.BOOLEAN); + native_types_to_primitive.put(ALbyte.class, PrimitiveType.Kind.BYTE); + native_types_to_primitive.put(ALenum.class, PrimitiveType.Kind.INT); + native_types_to_primitive.put(ALfloat.class, PrimitiveType.Kind.FLOAT); + native_types_to_primitive.put(ALdouble.class, PrimitiveType.Kind.DOUBLE); + native_types_to_primitive.put(ALint.class, PrimitiveType.Kind.INT); + native_types_to_primitive.put(ALshort.class, PrimitiveType.Kind.SHORT); + native_types_to_primitive.put(ALsizei.class, PrimitiveType.Kind.INT); + native_types_to_primitive.put(ALubyte.class, PrimitiveType.Kind.BYTE); + native_types_to_primitive.put(ALuint.class, PrimitiveType.Kind.INT); + native_types_to_primitive.put(ALvoid.class, PrimitiveType.Kind.BYTE); + } + + public PrimitiveType.Kind getPrimitiveTypeFromNativeType(Class native_type) { + PrimitiveType.Kind kind = native_types_to_primitive.get(native_type); + if (kind == null) + throw new RuntimeException("Unsupported type " + native_type); + return kind; + } + + public Signedness getSignednessFromType(Class type) { + if (ALuint.class.equals(type)) + return Signedness.UNSIGNED; + else if (ALint.class.equals(type)) + return Signedness.SIGNED; + else if (ALshort.class.equals(type)) + return Signedness.SIGNED; + else if (ALbyte.class.equals(type)) + return Signedness.SIGNED; + else + return Signedness.NONE; + } + + public String translateAnnotation(Class annotation_type) { + if (annotation_type.equals(ALuint.class)) + return "i"; + else if (annotation_type.equals(ALint.class)) + return "i"; + else if (annotation_type.equals(ALshort.class)) + return "s"; + else if (annotation_type.equals(ALbyte.class)) + return "b"; + else if (annotation_type.equals(ALfloat.class)) + return "f"; + else if (annotation_type.equals(ALdouble.class)) + return "d"; + else if (annotation_type.equals(ALboolean.class) || annotation_type.equals(ALvoid.class)) + return ""; + else + throw new RuntimeException(annotation_type + " is not allowed"); + } + + public Class getNativeTypeFromPrimitiveType(PrimitiveType.Kind kind) { + Class type; + switch (kind) { + case INT: + type = ALint.class; + break; + case FLOAT: + type = ALfloat.class; + break; + case DOUBLE: + type = ALdouble.class; + break; + case SHORT: + type = ALshort.class; + break; + case BYTE: + type = ALbyte.class; + break; + case BOOLEAN: + type = ALboolean.class; + break; + default: + throw new RuntimeException(kind + " is not allowed"); + } + return type; + } + + private static Class[] getValidBufferTypes(Class type) { + if (type.equals(IntBuffer.class)) + return new Class[]{ALenum.class, ALint.class, ALsizei.class, ALuint.class}; + else if (type.equals(FloatBuffer.class)) + return new Class[]{ALfloat.class}; + else if (type.equals(ByteBuffer.class)) + return new Class[]{ALboolean.class, ALbyte.class, ALvoid.class}; + else if (type.equals(ShortBuffer.class)) + return new Class[]{ALshort.class}; + else if (type.equals(DoubleBuffer.class)) + return new Class[]{ALdouble.class}; + else + return new Class[]{}; + } + + private static Class[] getValidPrimitiveTypes(Class type) { + if (type.equals(int.class)) + return new Class[]{ALenum.class, ALint.class, ALsizei.class, ALuint.class}; + else if (type.equals(double.class)) + return new Class[]{ALdouble.class}; + else if (type.equals(float.class)) + return new Class[]{ALfloat.class}; + else if (type.equals(short.class)) + return new Class[]{ALshort.class}; + else if (type.equals(byte.class)) + return new Class[]{ALbyte.class}; + else if (type.equals(boolean.class)) + return new Class[]{ALboolean.class}; + else if (type.equals(void.class)) + return new Class[]{ALvoid.class}; + else + return new Class[]{}; + } + + public String getErrorCheckMethodName() { + return "Util.checkALError()"; + } + + public String getRegisterNativesFunctionName() { + return "extal_InitializeClass"; + } + + public String getTypedefPrefix() { + return "ALAPIENTRY"; + } + + public void printNativeIncludes(PrintWriter writer) { + writer.println("#include \"extal.h\""); + } + + public Class getStringElementType() { + return ALubyte.class; + } + + public Class[] getValidAnnotationTypes(Class type) { + Class[] valid_types; + if (Buffer.class.isAssignableFrom(type)) + valid_types = getValidBufferTypes(type); + else if (type.isPrimitive()) + valid_types = getValidPrimitiveTypes(type); + else if (type.equals(String.class)) + valid_types = new Class[]{ALubyte.class}; + else + valid_types = new Class[]{}; + return valid_types; + } + + public Class getVoidType() { + return ALvoid.class; + } + + public Class getInverseType(Class type) { + if (ALuint.class.equals(type)) + return ALint.class; + else if (ALint.class.equals(type)) + return ALuint.class; + else + return null; + } + + public String getAutoTypeFromAnnotation(AnnotationMirror annotation) { + return null; + } +} diff --git a/src/java/org/lwjgl/util/generator/ALboolean.java b/src/java/org/lwjgl/util/generator/ALboolean.java new file mode 100644 index 0000000..6c828b3 --- /dev/null +++ b/src/java/org/lwjgl/util/generator/ALboolean.java @@ -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; + +/** + * + * @author elias_naur + * @version $Revision: 2983 $ + * $Id: ALboolean.java 2983 2008-04-07 18:36:09Z matzon $ + */ + +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +@NativeType +@Target({ElementType.PARAMETER, ElementType.METHOD}) +public @interface ALboolean { +} diff --git a/src/java/org/lwjgl/util/generator/ALbyte.java b/src/java/org/lwjgl/util/generator/ALbyte.java new file mode 100644 index 0000000..9a632e7 --- /dev/null +++ b/src/java/org/lwjgl/util/generator/ALbyte.java @@ -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; + +/** + * + * @author elias_naur + * @version $Revision: 2983 $ + * $Id: ALbyte.java 2983 2008-04-07 18:36:09Z matzon $ + */ + +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +@NativeType +@Target({ElementType.PARAMETER, ElementType.METHOD}) +public @interface ALbyte { +} diff --git a/src/java/org/lwjgl/util/generator/ALdouble.java b/src/java/org/lwjgl/util/generator/ALdouble.java new file mode 100644 index 0000000..9aa4f3c --- /dev/null +++ b/src/java/org/lwjgl/util/generator/ALdouble.java @@ -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; + +/** + * + * @author elias_naur + * @version $Revision: 2983 $ + * $Id: ALdouble.java 2983 2008-04-07 18:36:09Z matzon $ + */ + +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +@NativeType +@Target({ElementType.PARAMETER, ElementType.METHOD}) +public @interface ALdouble { +} diff --git a/src/java/org/lwjgl/util/generator/ALenum.java b/src/java/org/lwjgl/util/generator/ALenum.java new file mode 100644 index 0000000..a12a633 --- /dev/null +++ b/src/java/org/lwjgl/util/generator/ALenum.java @@ -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; + +/** + * + * @author elias_naur + * @version $Revision: 2983 $ + * $Id: ALenum.java 2983 2008-04-07 18:36:09Z matzon $ + */ + +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +@NativeType +@Target({ElementType.PARAMETER, ElementType.METHOD}) +public @interface ALenum { +} diff --git a/src/java/org/lwjgl/util/generator/ALfloat.java b/src/java/org/lwjgl/util/generator/ALfloat.java new file mode 100644 index 0000000..2777b66 --- /dev/null +++ b/src/java/org/lwjgl/util/generator/ALfloat.java @@ -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; + +/** + * + * @author elias_naur + * @version $Revision: 2983 $ + * $Id: ALfloat.java 2983 2008-04-07 18:36:09Z matzon $ + */ + +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +@NativeType +@Target({ElementType.PARAMETER, ElementType.METHOD}) +public @interface ALfloat { +} diff --git a/src/java/org/lwjgl/util/generator/ALint.java b/src/java/org/lwjgl/util/generator/ALint.java new file mode 100644 index 0000000..db5db7c --- /dev/null +++ b/src/java/org/lwjgl/util/generator/ALint.java @@ -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; + +/** + * + * @author elias_naur + * @version $Revision: 2983 $ + * $Id: ALint.java 2983 2008-04-07 18:36:09Z matzon $ + */ + +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +@NativeType +@Target({ElementType.PARAMETER, ElementType.METHOD}) +public @interface ALint { +} diff --git a/src/java/org/lwjgl/util/generator/ALshort.java b/src/java/org/lwjgl/util/generator/ALshort.java new file mode 100644 index 0000000..b10c6fd --- /dev/null +++ b/src/java/org/lwjgl/util/generator/ALshort.java @@ -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; + +/** + * + * @author elias_naur + * @version $Revision: 2983 $ + * $Id: ALshort.java 2983 2008-04-07 18:36:09Z matzon $ + */ + +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +@NativeType +@Target({ElementType.PARAMETER, ElementType.METHOD}) +public @interface ALshort { +} diff --git a/src/java/org/lwjgl/util/generator/ALsizei.java b/src/java/org/lwjgl/util/generator/ALsizei.java new file mode 100644 index 0000000..8b33f37 --- /dev/null +++ b/src/java/org/lwjgl/util/generator/ALsizei.java @@ -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; + +/** + * + * @author elias_naur + * @version $Revision: 2983 $ + * $Id: ALsizei.java 2983 2008-04-07 18:36:09Z matzon $ + */ + +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +@NativeType +@Target({ElementType.PARAMETER, ElementType.METHOD}) +public @interface ALsizei { +} diff --git a/src/java/org/lwjgl/util/generator/ALubyte.java b/src/java/org/lwjgl/util/generator/ALubyte.java new file mode 100644 index 0000000..12767c5 --- /dev/null +++ b/src/java/org/lwjgl/util/generator/ALubyte.java @@ -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; + +/** + * + * @author elias_naur + * @version $Revision: 2983 $ + * $Id: ALubyte.java 2983 2008-04-07 18:36:09Z matzon $ + */ + +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +@NativeType +@Target({ElementType.PARAMETER, ElementType.METHOD}) +public @interface ALubyte { +} diff --git a/src/java/org/lwjgl/util/generator/ALuint.java b/src/java/org/lwjgl/util/generator/ALuint.java new file mode 100644 index 0000000..c242a9e --- /dev/null +++ b/src/java/org/lwjgl/util/generator/ALuint.java @@ -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; + +/** + * + * @author elias_naur + * @version $Revision: 2983 $ + * $Id: ALuint.java 2983 2008-04-07 18:36:09Z matzon $ + */ + +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +@NativeType +@Target({ElementType.PARAMETER, ElementType.METHOD}) +public @interface ALuint { +} diff --git a/src/java/org/lwjgl/util/generator/ALvoid.java b/src/java/org/lwjgl/util/generator/ALvoid.java new file mode 100644 index 0000000..d1f7465 --- /dev/null +++ b/src/java/org/lwjgl/util/generator/ALvoid.java @@ -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; + +/** + * + * @author elias_naur + * @version $Revision: 2983 $ + * $Id: ALvoid.java 2983 2008-04-07 18:36:09Z matzon $ + */ + +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +@NativeType +@Target({ElementType.PARAMETER, ElementType.METHOD}) +public @interface ALvoid { +} diff --git a/src/java/org/lwjgl/util/generator/Alternate.java b/src/java/org/lwjgl/util/generator/Alternate.java new file mode 100644 index 0000000..67fe518 --- /dev/null +++ b/src/java/org/lwjgl/util/generator/Alternate.java @@ -0,0 +1,54 @@ +/* + * 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 + */ +@Target({ ElementType.METHOD }) +public @interface Alternate { + + /** This must match an existing GL method name. */ + String value(); + + /** If true, an alternate Java->native call will be created. Useful when the alternate implementation uses different types. */ + boolean nativeAlt() default false; + + /** If true, the alternate method's name will be used for the Java call. */ + boolean javaAlt() default false; +} \ No newline at end of file diff --git a/src/java/org/lwjgl/util/generator/Auto.java b/src/java/org/lwjgl/util/generator/Auto.java new file mode 100644 index 0000000..e53a64f --- /dev/null +++ b/src/java/org/lwjgl/util/generator/Auto.java @@ -0,0 +1,48 @@ +/* + * 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; + +/** + * + * AutoType and AutoSize is annotated with @Auto. + * + * @author elias_naur + * @version $Revision: 2983 $ + * $Id: Auto.java 2983 2008-04-07 18:36:09Z matzon $ + */ + +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +@Target(ElementType.ANNOTATION_TYPE) +public @interface Auto { +} diff --git a/src/java/org/lwjgl/util/generator/AutoResultSize.java b/src/java/org/lwjgl/util/generator/AutoResultSize.java new file mode 100644 index 0000000..4e3145f --- /dev/null +++ b/src/java/org/lwjgl/util/generator/AutoResultSize.java @@ -0,0 +1,50 @@ +/* + * 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; + +/** + * + * AutoResultSize specifies the size of a returned Buffer + * as an expression. + * + * @author elias_naur + * @version $Revision: 2983 $ + * $Id: AutoResultSize.java 2983 2008-04-07 18:36:09Z matzon $ + */ + +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +@Target(ElementType.METHOD) +public @interface AutoResultSize { + String value(); // The size as a java expression +} diff --git a/src/java/org/lwjgl/util/generator/AutoSize.java b/src/java/org/lwjgl/util/generator/AutoSize.java new file mode 100644 index 0000000..621a48a --- /dev/null +++ b/src/java/org/lwjgl/util/generator/AutoSize.java @@ -0,0 +1,52 @@ +/* + * 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; + +/** + * + * AutoSize specifies that a parameter should be pre-computed + * according to the remaining() of a Buffer parameter. + * + * @author elias_naur + * @version $Revision: 2983 $ + * $Id: AutoSize.java 2983 2008-04-07 18:36:09Z matzon $ + */ + +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +@Auto +@Target(ElementType.PARAMETER) +public @interface AutoSize { + String value(); // The name of the Buffer parameter + String expression() default ""; // This value is added after the argument +} diff --git a/src/java/org/lwjgl/util/generator/AutoType.java b/src/java/org/lwjgl/util/generator/AutoType.java new file mode 100644 index 0000000..93d094c --- /dev/null +++ b/src/java/org/lwjgl/util/generator/AutoType.java @@ -0,0 +1,51 @@ +/* + * 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; + +/** + * + * Indicates that a parameter should be pre-computed according + * to the type of a Buffer parameter. + * + * @author elias_naur + * @version $Revision: 2983 $ + * $Id: AutoType.java 2983 2008-04-07 18:36:09Z matzon $ + */ + +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +@Auto +@Target(ElementType.PARAMETER) +public @interface AutoType { + String value(); // The parameter to get the type from +} diff --git a/src/java/org/lwjgl/util/generator/BufferKind.java b/src/java/org/lwjgl/util/generator/BufferKind.java new file mode 100644 index 0000000..42c2c1a --- /dev/null +++ b/src/java/org/lwjgl/util/generator/BufferKind.java @@ -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; + +/** + * + * @author elias_naur + * @version $Revision: 3279 $ + * $Id: BufferKind.java 3279 2010-03-11 21:06:49Z spasi $ + */ + +public enum BufferKind { + UnpackPBO, + PackPBO, + ElementVBO, + ArrayVBO, + IndirectBO +} diff --git a/src/java/org/lwjgl/util/generator/BufferObject.java b/src/java/org/lwjgl/util/generator/BufferObject.java new file mode 100644 index 0000000..b886aff --- /dev/null +++ b/src/java/org/lwjgl/util/generator/BufferObject.java @@ -0,0 +1,50 @@ +/* + * 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; + +/** + * + * This annotation implies that a Buffer parameter can be an + * integer VBO/PBO offset. + * + * @author elias_naur + * @version $Revision: 2983 $ + * $Id: BufferObject.java 2983 2008-04-07 18:36:09Z matzon $ + */ + +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +@Target(ElementType.PARAMETER) +public @interface BufferObject { + BufferKind value(); +} diff --git a/src/java/org/lwjgl/util/generator/CachedReference.java b/src/java/org/lwjgl/util/generator/CachedReference.java new file mode 100644 index 0000000..ee7b910 --- /dev/null +++ b/src/java/org/lwjgl/util/generator/CachedReference.java @@ -0,0 +1,54 @@ +/* + * 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; + +/** + * + * This annotation indicates that a buffer parameter is cached by + * OpenGL. + * + * @author elias_naur + * @version $Revision: 2983 $ + * $Id: CachedReference.java 2983 2008-04-07 18:36:09Z matzon $ + */ + +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +@Target(ElementType.PARAMETER) +public @interface CachedReference { + /** If set then this will be used as array index for accessing the stored reference. */ + String index() default ""; + + /** If set then this name will be used for the reference and the reference field will not be auto generated in References. */ + String name() default ""; +} diff --git a/src/java/org/lwjgl/util/generator/CachedResult.java b/src/java/org/lwjgl/util/generator/CachedResult.java new file mode 100644 index 0000000..7de1f77 --- /dev/null +++ b/src/java/org/lwjgl/util/generator/CachedResult.java @@ -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; + +/** + * + * @author elias_naur + * @version $Revision: 3262 $ + * $Id: CachedResult.java 3262 2010-01-04 18:47:49Z spasi $ + */ + +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +@Target(ElementType.METHOD) +public @interface CachedResult { + boolean isRange() default false; +} diff --git a/src/java/org/lwjgl/util/generator/Check.java b/src/java/org/lwjgl/util/generator/Check.java new file mode 100644 index 0000000..1c177e3 --- /dev/null +++ b/src/java/org/lwjgl/util/generator/Check.java @@ -0,0 +1,48 @@ +/* + * 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; + +/** + * + * @author elias_naur + * @version $Revision: 2983 $ + * $Id: Check.java 2983 2008-04-07 18:36:09Z matzon $ + */ + +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +@Target(ElementType.PARAMETER) +public @interface Check { + String value() default ""; + boolean canBeNull() default false; +} diff --git a/src/java/org/lwjgl/util/generator/Code.java b/src/java/org/lwjgl/util/generator/Code.java new file mode 100644 index 0000000..8e9e878 --- /dev/null +++ b/src/java/org/lwjgl/util/generator/Code.java @@ -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; + +/** + * + * @author elias_naur + * @version $Revision: 2983 $ + * $Id: Code.java 2983 2008-04-07 18:36:09Z matzon $ + */ + +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +@Target(ElementType.METHOD) +public @interface Code { + String value(); +} diff --git a/src/java/org/lwjgl/util/generator/Const.java b/src/java/org/lwjgl/util/generator/Const.java new file mode 100644 index 0000000..c8193d6 --- /dev/null +++ b/src/java/org/lwjgl/util/generator/Const.java @@ -0,0 +1,46 @@ +/* + * 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; + +/** + * + * @author elias_naur + * @version $Revision: 2983 $ + * $Id: Const.java 2983 2008-04-07 18:36:09Z matzon $ + */ + +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +@Target({ElementType.PARAMETER, ElementType.METHOD}) +public @interface Const { +} diff --git a/src/java/org/lwjgl/util/generator/Constant.java b/src/java/org/lwjgl/util/generator/Constant.java new file mode 100644 index 0000000..07d0afa --- /dev/null +++ b/src/java/org/lwjgl/util/generator/Constant.java @@ -0,0 +1,49 @@ +/* + * 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; + +/** + * + * @author elias_naur + * @version $Revision: 3287 $ + * $Id: Constant.java 3287 2010-03-14 23:24:40Z spasi $ + */ + +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +@Target(ElementType.PARAMETER) +public @interface Constant { + String value(); + /** If true, the original parameter will not be removed from the method. */ + boolean keepParam() default false; +} diff --git a/src/java/org/lwjgl/util/generator/ContextCapabilitiesGenerator.java b/src/java/org/lwjgl/util/generator/ContextCapabilitiesGenerator.java new file mode 100644 index 0000000..36232ca --- /dev/null +++ b/src/java/org/lwjgl/util/generator/ContextCapabilitiesGenerator.java @@ -0,0 +1,293 @@ +/* + * 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.io.PrintWriter; +import java.util.Arrays; +import java.util.Collection; +import java.util.EnumSet; +import java.util.Iterator; + +import com.sun.mirror.declaration.InterfaceDeclaration; +import com.sun.mirror.declaration.MethodDeclaration; +import com.sun.mirror.type.InterfaceType; + +/** + * Generator visitor for the context capabilities generator tool + * + * @author elias_naur + * @version $Revision: 3316 $ + * $Id: ContextCapabilitiesGenerator.java 3316 2010-04-09 23:57:40Z spasi $ + */ +public class ContextCapabilitiesGenerator { + + private final static String STUBS_LOADED_NAME = "loaded_stubs"; + private final static String ALL_INIT_METHOD_NAME = "initAllStubs"; + private final static String POINTER_INITIALIZER_POSTFIX = "_initNativeFunctionAddresses"; + private final static String CACHED_EXTS_VAR_NAME = "supported_extensions"; + private final static String PROFILE_MASK_VAR_NAME = "profileMask"; + private final static String EXTENSION_PREFIX = "GL_"; + private final static String CORE_PREFIX = "Open"; + + public static void generateClassPrologue(PrintWriter writer, boolean context_specific, boolean generate_error_checks) { + writer.println("public class " + Utils.CONTEXT_CAPS_CLASS_NAME + " {"); + writer.println("\tstatic final boolean DEBUG = " + Boolean.toString(generate_error_checks) + ";"); + writer.println("\tfinal StateTracker tracker = new StateTracker();"); + writer.println("\tfinal IntBuffer scratch_int_buffer = BufferUtils.createIntBuffer(16);"); + writer.println(); + if ( !context_specific ) { + writer.println("\tprivate static boolean " + STUBS_LOADED_NAME + " = false;"); + } + } + + public static void generateInitializerPrologue(PrintWriter writer) { + writer.println("\t" + Utils.CONTEXT_CAPS_CLASS_NAME + "(boolean forwardCompatible) throws LWJGLException {"); + writer.println("\t\tSet " + CACHED_EXTS_VAR_NAME + " = " + ALL_INIT_METHOD_NAME + "(forwardCompatible);"); + } + + private static String translateFieldName(String interface_name) { + if ( interface_name.startsWith("GL") ) + return CORE_PREFIX + interface_name; + else + return EXTENSION_PREFIX + interface_name; + } + + public static void generateSuperClassAdds(PrintWriter writer, InterfaceDeclaration d) { + Collection super_interfaces = d.getSuperinterfaces(); + if ( super_interfaces.size() > 1 ) + throw new RuntimeException(d + " extends more than one other interface"); + if ( super_interfaces.size() == 1 ) { + InterfaceType super_interface = super_interfaces.iterator().next(); + writer.print("\t\tif (" + CACHED_EXTS_VAR_NAME + ".contains(\""); + writer.println(translateFieldName(d.getSimpleName()) + "\"))"); + writer.print("\t\t\t"); + generateAddExtension(writer, super_interface.getDeclaration()); + } + } + + public static void generateInitializer(PrintWriter writer, InterfaceDeclaration d) { + String translated_field_name = translateFieldName(d.getSimpleName()); + writer.print("\t\tthis." + translated_field_name + " = "); + writer.print(CACHED_EXTS_VAR_NAME + ".contains(\""); + writer.print(translated_field_name + "\")"); + Collection super_interfaces = d.getSuperinterfaces(); + if ( super_interfaces.size() > 1 ) + throw new RuntimeException(d + " extends more than one other interface"); + if ( super_interfaces.size() == 1 ) { + InterfaceType super_interface = super_interfaces.iterator().next(); + writer.println(); + writer.print("\t\t\t&& " + CACHED_EXTS_VAR_NAME + ".contains(\""); + writer.print(translateFieldName(super_interface.getDeclaration().getSimpleName()) + "\")"); + } + writer.println(";"); + } + + private static String getAddressesInitializerName(String class_name) { + return class_name + POINTER_INITIALIZER_POSTFIX; + } + + public static void generateInitStubsPrologue(PrintWriter writer, boolean context_specific) { + writer.println("\tprivate Set " + ALL_INIT_METHOD_NAME + "(boolean forwardCompatible) throws LWJGLException {"); + + // Load the basic pointers we need to detect OpenGL version and supported extensions. + writer.println("\t\tGL11_glGetError_pointer = GLContext.getFunctionAddress(\"glGetError\");"); + writer.println("\t\tGL11_glGetString_pointer = GLContext.getFunctionAddress(\"glGetString\");"); + + // Initialize GL11.glGetIntegerv and GL30.glGetStringi here, in case we have created an OpenGL 3.0 context. + // (they will be used in GLContext.getSupportedExtensions) + writer.println("\t\tGL11_glGetIntegerv_pointer = GLContext.getFunctionAddress(\"glGetIntegerv\");"); + writer.println("\t\tGL30_glGetStringi_pointer = GLContext.getFunctionAddress(\"glGetStringi\");"); + + // Get the supported extensions set. + writer.println("\t\tGLContext.setCapabilities(this);"); + writer.println("\t\tSet " + CACHED_EXTS_VAR_NAME + " = new HashSet(256);"); + writer.println("\t\tint " + PROFILE_MASK_VAR_NAME + " = GLContext.getSupportedExtensions(" + CACHED_EXTS_VAR_NAME + ");"); + + // Force forward compatible mode when OpenGL version is 3.1 or higher and ARB_compatibility is not available. + writer.println("\t\tif ( supported_extensions.contains(\"OpenGL31\") && !(supported_extensions.contains(\"GL_ARB_compatibility\") || (profileMask & GL32.GL_CONTEXT_COMPATIBILITY_PROFILE_BIT) != 0) )"); + writer.println("\t\t\tforwardCompatible = true;"); + + if ( !context_specific ) { + writer.println("\t\tif (" + STUBS_LOADED_NAME + ")"); + writer.println("\t\t\treturn GLContext.getSupportedExtensions();"); + writer.println("\t\torg.lwjgl.opengl.GL11." + Utils.STUB_INITIALIZER_NAME + "();"); + } else { + writer.println("\t\tif (!" + getAddressesInitializerName("GL11") + "(forwardCompatible))"); + writer.println("\t\t\tthrow new LWJGLException(\"GL11 not supported\");"); + } + } + + public static void generateInitStubsEpilogue(PrintWriter writer, boolean context_specific) { + if ( !context_specific ) { + writer.println("\t\t" + STUBS_LOADED_NAME + " = true;"); + } + writer.println("\t\treturn " + CACHED_EXTS_VAR_NAME + ";"); + writer.println("\t}"); + } + + public static void generateUnloadStubs(PrintWriter writer, InterfaceDeclaration d) { + if ( d.getMethods().size() > 0 ) { + writer.print("\t\tGLContext.resetNativeStubs(" + Utils.getSimpleClassName(d)); + writer.println(".class);"); + } + } + + public static void generateInitStubs(PrintWriter writer, InterfaceDeclaration d, boolean context_specific) { + if ( d.getMethods().size() > 0 ) { + if ( context_specific ) { + if ( d.getAnnotation(ForceInit.class) != null ) + writer.println("\t\t" + CACHED_EXTS_VAR_NAME + ".add(\"" + translateFieldName(d.getSimpleName()) + "\");"); + writer.print("\t\tif (" + CACHED_EXTS_VAR_NAME + ".contains(\""); + writer.print(translateFieldName(d.getSimpleName()) + "\")"); + writer.print(" && !" + getAddressesInitializerName(d.getSimpleName()) + "("); + if ( d.getAnnotation(DeprecatedGL.class) != null ) + writer.print("forwardCompatible"); + if ( d.getAnnotation(Dependent.class) != null ) { + if ( d.getAnnotation(DeprecatedGL.class) != null ) + writer.print(","); + writer.print("supported_extensions"); + } + writer.println("))"); + //writer.print("\t\t\t" + CACHED_EXTS_VAR_NAME + ".remove(\""); + writer.print("\t\t\tremove(" + CACHED_EXTS_VAR_NAME + ", \""); + writer.println(translateFieldName(d.getSimpleName()) + "\");"); + } else { + writer.print("\t\tGLContext." + Utils.STUB_INITIALIZER_NAME + "(" + Utils.getSimpleClassName(d)); + writer.println(".class, " + CACHED_EXTS_VAR_NAME + ", \"" + translateFieldName(d.getSimpleName()) + "\");"); + } + } + } + + private static void generateAddExtension(PrintWriter writer, InterfaceDeclaration d) { + writer.print(CACHED_EXTS_VAR_NAME + ".add(\""); + writer.println(translateFieldName(d.getSimpleName()) + "\");"); + } + + public static void generateAddressesInitializers(PrintWriter writer, InterfaceDeclaration d) { + Iterator methods = d.getMethods().iterator(); + if ( !methods.hasNext() ) + return; + + writer.print("\tprivate boolean " + getAddressesInitializerName(d.getSimpleName()) + "("); + + boolean optional; + boolean deprecated = d.getAnnotation(DeprecatedGL.class) != null; + Dependent dependent = d.getAnnotation(Dependent.class); + if ( deprecated ) + writer.print("boolean forwardCompatible"); + if ( dependent != null ) { + if ( deprecated ) + writer.print(","); + writer.print("Set supported_extensions"); + } + + writer.println(") {"); + writer.println("\t\treturn "); + + boolean first = true; + while ( methods.hasNext() ) { + MethodDeclaration method = methods.next(); + if ( method.getAnnotation(Alternate.class) != null ) + continue; + + if ( !first ) + writer.println(" &"); + else + first = false; + + optional = method.getAnnotation(Optional.class) != null; + deprecated = method.getAnnotation(DeprecatedGL.class) != null; + dependent = method.getAnnotation(Dependent.class); + + writer.print("\t\t\t("); + if ( optional ) + writer.print('('); + if ( deprecated ) + writer.print("forwardCompatible || "); + if ( dependent != null ) { + if ( dependent.value().indexOf(',') == -1 ) + writer.print("!supported_extensions.contains(\"" + dependent.value() + "\") || "); + else { + writer.print("!(false"); + for ( String extension : dependent.value().split(",") ) + writer.print(" || supported_extensions.contains(\"" + extension + "\")"); + writer.print(") || "); + } + } + if ( deprecated || dependent != null ) + writer.print('('); + writer.print(Utils.getFunctionAddressName(d, method) + " = "); + PlatformDependent platform_dependent = method.getAnnotation(PlatformDependent.class); + if ( platform_dependent != null ) { + EnumSet platform_set = EnumSet.copyOf(Arrays.asList(platform_dependent.value())); + writer.print("GLContext.getPlatformSpecificFunctionAddress(\""); + writer.print(Platform.ALL.getPrefix() + "\", "); + writer.print("new String[]{"); + Iterator platforms = platform_set.iterator(); + while ( platforms.hasNext() ) { + writer.print("\"" + platforms.next().getOSPrefix() + "\""); + if ( platforms.hasNext() ) + writer.print(", "); + } + writer.print("}, new String[]{"); + platforms = platform_set.iterator(); + while ( platforms.hasNext() ) { + writer.print("\"" + platforms.next().getPrefix() + "\""); + if ( platforms.hasNext() ) + writer.print(", "); + } + writer.print("}, "); + } else + writer.print("GLContext.getFunctionAddress("); + writer.print("\"" + method.getSimpleName() + "\")) != 0"); + if ( deprecated || dependent != null ) + writer.print(')'); + if ( optional ) + writer.print(" || true)"); + } + writer.println(";"); + writer.println("\t}"); + writer.println(); + } + + public static void generateSymbolAddresses(PrintWriter writer, InterfaceDeclaration d) { + for ( MethodDeclaration method : d.getMethods() ) { + if ( method.getAnnotation(Alternate.class) == null ) + writer.println("\tlong " + Utils.getFunctionAddressName(d, method) + ";"); + } + } + + public static void generateField(PrintWriter writer, InterfaceDeclaration d) { + writer.println("\tpublic final boolean " + translateFieldName(d.getSimpleName()) + ";"); + } +} \ No newline at end of file diff --git a/src/java/org/lwjgl/util/generator/ContextGeneratorProcessorFactory.java b/src/java/org/lwjgl/util/generator/ContextGeneratorProcessorFactory.java new file mode 100644 index 0000000..88813b9 --- /dev/null +++ b/src/java/org/lwjgl/util/generator/ContextGeneratorProcessorFactory.java @@ -0,0 +1,189 @@ +/* + * 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 static java.util.Collections.unmodifiableCollection; + +import java.io.File; +import java.io.IOException; +import java.io.PrintWriter; +import java.util.Arrays; +import java.util.Collection; +import java.util.Map; +import java.util.Set; + +import com.sun.mirror.apt.AnnotationProcessor; +import com.sun.mirror.apt.AnnotationProcessorEnvironment; +import com.sun.mirror.apt.AnnotationProcessorFactory; +import com.sun.mirror.apt.AnnotationProcessors; +import com.sun.mirror.apt.Filer; +import com.sun.mirror.apt.RoundCompleteEvent; +import com.sun.mirror.apt.RoundCompleteListener; +import com.sun.mirror.declaration.AnnotationTypeDeclaration; +import com.sun.mirror.declaration.InterfaceDeclaration; +import com.sun.mirror.declaration.TypeDeclaration; +import com.sun.mirror.util.DeclarationFilter; + +/** + * + * Generator tool for creating the ContexCapabilities class + * + * @author elias_naur + * @version $Revision: 3316 $ + * $Id: ContextGeneratorProcessorFactory.java 3316 2010-04-09 23:57:40Z spasi $ + */ +public class ContextGeneratorProcessorFactory implements AnnotationProcessorFactory, RoundCompleteListener { + private static boolean first_round = true; + + // Process any set of annotations + private static final Collection supportedAnnotations = + unmodifiableCollection(Arrays.asList("*")); + + public Collection supportedAnnotationTypes() { + return supportedAnnotations; + } + + public Collection supportedOptions() { + return unmodifiableCollection(Arrays.asList("-Acontextspecific", "-Ageneratechecks")); + } + + public void roundComplete(RoundCompleteEvent event) { + first_round = false; + } + + public AnnotationProcessor getProcessorFor(Set atds, AnnotationProcessorEnvironment env) { + // Only process the initial types, not the generated ones + if (first_round) { + env.addListener(this); + return new GeneratorProcessor(env); + } else + return AnnotationProcessors.NO_OP; + } + + private static class GeneratorProcessor implements AnnotationProcessor { + private final AnnotationProcessorEnvironment env; + + GeneratorProcessor(AnnotationProcessorEnvironment env) { + this.env = env; + } + + public void process() { + Map options = env.getOptions(); + boolean generate_error_checks = options.containsKey("-Ageneratechecks"); + boolean context_specific = options.containsKey("-Acontextspecific"); + try { + generateContextCapabilitiesSource(context_specific, generate_error_checks); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + private void generateContextCapabilitiesSource(boolean context_specific, boolean generate_error_checks) throws IOException { + PrintWriter writer = env.getFiler().createTextFile(Filer.Location.SOURCE_TREE, "org.lwjgl.opengl", new File(Utils.CONTEXT_CAPS_CLASS_NAME + ".java"), null); + writer.println("/* MACHINE GENERATED FILE, DO NOT EDIT */"); + writer.println(); + writer.println("package org.lwjgl.opengl;"); + writer.println(); + writer.println("import org.lwjgl.LWJGLException;"); + writer.println("import org.lwjgl.LWJGLUtil;"); + writer.println("import org.lwjgl.BufferUtils;"); + writer.println("import java.util.Set;"); + writer.println("import java.util.HashSet;"); + writer.println("import java.nio.IntBuffer;"); + writer.println(); + ContextCapabilitiesGenerator.generateClassPrologue(writer, context_specific, generate_error_checks); + DeclarationFilter filter = DeclarationFilter.getFilter(InterfaceDeclaration.class); + Collection interface_decls = filter.filter(env.getSpecifiedTypeDeclarations()); + for (TypeDeclaration typedecl : interface_decls) { + InterfaceDeclaration interface_decl = (InterfaceDeclaration)typedecl; + if (Utils.isFinal(interface_decl)) + ContextCapabilitiesGenerator.generateField(writer, interface_decl); + } + writer.println(); + for (TypeDeclaration typedecl : interface_decls) { + InterfaceDeclaration interface_decl = (InterfaceDeclaration)typedecl; + ContextCapabilitiesGenerator.generateSymbolAddresses(writer, interface_decl); + } + writer.println(); + if (context_specific) { + for (TypeDeclaration typedecl : interface_decls) { + InterfaceDeclaration interface_decl = (InterfaceDeclaration)typedecl; + ContextCapabilitiesGenerator.generateAddressesInitializers(writer, interface_decl); + } + writer.println(); + } + + writer.println("\tprivate static void remove(Set supported_extensions, String extension) {"); + writer.println("\t\tLWJGLUtil.log(extension + \" was reported as available but an entry point is missing\");"); + writer.println("\t\tsupported_extensions.remove(extension);"); + writer.println("\t}\n"); + + ContextCapabilitiesGenerator.generateInitStubsPrologue(writer, context_specific); + for (TypeDeclaration typedecl : interface_decls) { + InterfaceDeclaration interface_decl = (InterfaceDeclaration)typedecl; + ContextCapabilitiesGenerator.generateSuperClassAdds(writer, interface_decl); + } + for (TypeDeclaration typedecl : interface_decls) { + InterfaceDeclaration interface_decl = (InterfaceDeclaration)typedecl; + String simple_name = interface_decl.getSimpleName(); + if (simple_name.equals("GL11")) + continue; + ContextCapabilitiesGenerator.generateInitStubs(writer, interface_decl, context_specific); + } + ContextCapabilitiesGenerator.generateInitStubsEpilogue(writer, context_specific); + writer.println(); + writer.println("\tstatic void unloadAllStubs() {"); + if (!context_specific) { + writer.println("\t\tif (!loaded_stubs)"); + writer.println("\t\t\treturn;"); + for (TypeDeclaration typedecl : interface_decls) { + InterfaceDeclaration interface_decl = (InterfaceDeclaration)typedecl; + ContextCapabilitiesGenerator.generateUnloadStubs(writer, interface_decl); + } + writer.println("\t\tloaded_stubs = false;"); + } + writer.println("\t}"); + writer.println(); + ContextCapabilitiesGenerator.generateInitializerPrologue(writer); + for (TypeDeclaration typedecl : interface_decls) { + InterfaceDeclaration interface_decl = (InterfaceDeclaration)typedecl; + if (Utils.isFinal(interface_decl)) + ContextCapabilitiesGenerator.generateInitializer(writer, interface_decl); + } + writer.println("\t\ttracker.init();"); + writer.println("\t}"); + writer.println("}"); + writer.close(); + } + } +} diff --git a/src/java/org/lwjgl/util/generator/Dependent.java b/src/java/org/lwjgl/util/generator/Dependent.java new file mode 100644 index 0000000..1741823 --- /dev/null +++ b/src/java/org/lwjgl/util/generator/Dependent.java @@ -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; + +/** + * Use this annotation on extensions with functionality that depends on the presence of other extensions. + * Functions in such extensions marked with this annotation will only be loaded if the specified extension is present. + * + * @author spasi + */ + +import java.lang.annotation.ElementType; +import java.lang.annotation.Target; + +@Target({ ElementType.TYPE, ElementType.METHOD }) +public @interface Dependent { + String value() default ""; +} \ No newline at end of file diff --git a/src/java/org/lwjgl/util/generator/DeprecatedGL.java b/src/java/org/lwjgl/util/generator/DeprecatedGL.java new file mode 100644 index 0000000..4789d98 --- /dev/null +++ b/src/java/org/lwjgl/util/generator/DeprecatedGL.java @@ -0,0 +1,46 @@ +/* + * 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; + +/** + * Use this annotation on extensions with deprecated functionality. + * Functions in such extensions marked with this annotation will not be loaded in a forward compatible context. + * + * @author spasi + */ + +import java.lang.annotation.ElementType; +import java.lang.annotation.Target; + +@Target({ ElementType.TYPE, ElementType.METHOD }) +public @interface DeprecatedGL { +} \ No newline at end of file diff --git a/src/java/org/lwjgl/util/generator/Extension.java b/src/java/org/lwjgl/util/generator/Extension.java new file mode 100644 index 0000000..2b9e5fa --- /dev/null +++ b/src/java/org/lwjgl/util/generator/Extension.java @@ -0,0 +1,49 @@ +/* + * 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; + +/** + * + * @author elias_naur + * @version $Revision: 2983 $ + * $Id: Extension.java 2983 2008-04-07 18:36:09Z matzon $ + */ + +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +@Target(ElementType.TYPE) +public @interface Extension { + String className() default ""; + boolean isFinal() default true; + String postfix(); +} diff --git a/src/java/org/lwjgl/util/generator/FieldsGenerator.java b/src/java/org/lwjgl/util/generator/FieldsGenerator.java new file mode 100644 index 0000000..42649f8 --- /dev/null +++ b/src/java/org/lwjgl/util/generator/FieldsGenerator.java @@ -0,0 +1,78 @@ +/* + * 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 com.sun.mirror.declaration.*; +import com.sun.mirror.type.*; + +import java.io.*; +import java.util.*; + +public class FieldsGenerator { + private static void validateField(FieldDeclaration field) { + Collection modifiers = field.getModifiers(); + if (modifiers.size() != 3 || !modifiers.contains(Modifier.PUBLIC) || !modifiers.contains(Modifier.STATIC) || + !modifiers.contains(Modifier.FINAL)) + throw new RuntimeException("Field " + field.getSimpleName() + " is not declared public static final"); + TypeMirror field_type = field.getType(); + if (!(field_type instanceof PrimitiveType)) + throw new RuntimeException("Field " + field.getSimpleName() + " is not a primitive type"); + PrimitiveType field_type_prim = (PrimitiveType)field_type; + if (field_type_prim.getKind() != PrimitiveType.Kind.INT && field_type_prim.getKind() != PrimitiveType.Kind.LONG) + throw new RuntimeException("Field " + field.getSimpleName() + " is not of type 'int' or 'long'"); + Object field_value = field.getConstantValue(); + if (field_value == null) + throw new RuntimeException("Field " + field.getSimpleName() + " has no initial value"); + } + + private static void generateField(PrintWriter writer, FieldDeclaration field) { + validateField(field); + + Object value = field.getConstantValue(); + String field_value_string; + if ( value.getClass().equals(Integer.class) ) + field_value_string = Integer.toHexString((Integer)field.getConstantValue()); + else + field_value_string = Long.toHexString((Long)field.getConstantValue()) + 'l'; + + Utils.printDocComment(writer, field); + // Print field declaration + writer.println("\tpublic static final " + field.getType().toString() + " " + field.getSimpleName() + " = 0x" + field_value_string + ";"); + } + + public static void generateFields(PrintWriter writer, Collection fields) { + for (FieldDeclaration field : fields) + generateField(writer, field); + } + +} diff --git a/src/java/org/lwjgl/util/generator/ForceInit.java b/src/java/org/lwjgl/util/generator/ForceInit.java new file mode 100644 index 0000000..7173f6e --- /dev/null +++ b/src/java/org/lwjgl/util/generator/ForceInit.java @@ -0,0 +1,45 @@ +/* + * 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; + +/** + * Extensions marked with ForceInit will be initialized by LWJGL even if not exposed in the GL_EXTENSIONS string. + * + * @author spasi + */ + +import java.lang.annotation.ElementType; +import java.lang.annotation.Target; + +@Target({ ElementType.TYPE }) +public @interface ForceInit { +} \ No newline at end of file diff --git a/src/java/org/lwjgl/util/generator/GLTypeMap.java b/src/java/org/lwjgl/util/generator/GLTypeMap.java new file mode 100644 index 0000000..0a61351 --- /dev/null +++ b/src/java/org/lwjgl/util/generator/GLTypeMap.java @@ -0,0 +1,299 @@ +/* + * 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; + +/** + * + * OpenGL sepcific generator behaviour + * + * @author elias_naur + * @version $Revision: 3287 $ + * $Id: GLTypeMap.java 3287 2010-03-14 23:24:40Z spasi $ + */ + +import org.lwjgl.opengl.PointerWrapper; + +import java.io.PrintWriter; +import java.nio.*; +import java.util.HashMap; +import java.util.Map; + +import com.sun.mirror.declaration.AnnotationMirror; +import com.sun.mirror.type.PrimitiveType; + +public class GLTypeMap implements TypeMap { + + private static final Map native_types_to_primitive; + + static { + native_types_to_primitive = new HashMap(); + native_types_to_primitive.put(GLbitfield.class, PrimitiveType.Kind.INT); + native_types_to_primitive.put(GLcharARB.class, PrimitiveType.Kind.BYTE); + native_types_to_primitive.put(GLclampf.class, PrimitiveType.Kind.FLOAT); + native_types_to_primitive.put(GLfloat.class, PrimitiveType.Kind.FLOAT); + native_types_to_primitive.put(GLint.class, PrimitiveType.Kind.INT); + native_types_to_primitive.put(GLshort.class, PrimitiveType.Kind.SHORT); + native_types_to_primitive.put(GLsizeiptr.class, PrimitiveType.Kind.LONG); + native_types_to_primitive.put(GLuint.class, PrimitiveType.Kind.INT); + native_types_to_primitive.put(GLboolean.class, PrimitiveType.Kind.BOOLEAN); + native_types_to_primitive.put(GLchar.class, PrimitiveType.Kind.BYTE); + native_types_to_primitive.put(GLdouble.class, PrimitiveType.Kind.DOUBLE); + native_types_to_primitive.put(GLhalf.class, PrimitiveType.Kind.SHORT); + native_types_to_primitive.put(GLintptrARB.class, PrimitiveType.Kind.LONG); + native_types_to_primitive.put(GLsizei.class, PrimitiveType.Kind.INT); + native_types_to_primitive.put(GLushort.class, PrimitiveType.Kind.SHORT); + native_types_to_primitive.put(GLbyte.class, PrimitiveType.Kind.BYTE); + native_types_to_primitive.put(GLclampd.class, PrimitiveType.Kind.DOUBLE); + native_types_to_primitive.put(GLenum.class, PrimitiveType.Kind.INT); + native_types_to_primitive.put(GLhandleARB.class, PrimitiveType.Kind.INT); + native_types_to_primitive.put(GLintptr.class, PrimitiveType.Kind.LONG); + 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); + native_types_to_primitive.put(GLint64.class, PrimitiveType.Kind.LONG); + native_types_to_primitive.put(GLuint64.class, PrimitiveType.Kind.LONG); + } + + public PrimitiveType.Kind getPrimitiveTypeFromNativeType(Class native_type) { + PrimitiveType.Kind kind = native_types_to_primitive.get(native_type); + if ( kind == null ) + throw new RuntimeException("Unsupported type " + native_type); + return kind; + } + + public String getErrorCheckMethodName() { + return "Util.checkGLError()"; + } + + public String getRegisterNativesFunctionName() { + return "extgl_InitializeClass"; + } + + public Signedness getSignednessFromType(Class type) { + if ( GLuint.class.equals(type) ) + return Signedness.UNSIGNED; + else if ( GLint.class.equals(type) ) + return Signedness.SIGNED; + else if ( GLushort.class.equals(type) ) + return Signedness.UNSIGNED; + else if ( GLshort.class.equals(type) ) + return Signedness.SIGNED; + else if ( GLubyte.class.equals(type) ) + 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 if ( GLuint64.class.equals(type) ) + return Signedness.UNSIGNED; + else if ( GLint64.class.equals(type) ) + return Signedness.SIGNED; + else + return Signedness.NONE; + } + + public String translateAnnotation(Class annotation_type) { + if ( annotation_type.equals(GLuint.class) || annotation_type.equals(GLint.class) ) + return "i"; + else if ( annotation_type.equals(GLushort.class) || annotation_type.equals(GLshort.class) ) + return "s"; + else if ( annotation_type.equals(GLubyte.class) || annotation_type.equals(GLbyte.class) ) + return "b"; + else if ( annotation_type.equals(GLfloat.class) ) + return "f"; + else if ( annotation_type.equals(GLdouble.class) ) + return "d"; + else if ( annotation_type.equals(GLhalf.class) ) + return "h"; + else if ( annotation_type.equals(GLuint64EXT.class) || annotation_type.equals(GLint64EXT.class) || annotation_type.equals(GLuint64.class) || annotation_type.equals(GLint64.class) ) + return "i64"; + else if ( annotation_type.equals(GLboolean.class) || annotation_type.equals(GLvoid.class) ) + return ""; + else + throw new RuntimeException(annotation_type + " is not allowed"); + } + + public Class getNativeTypeFromPrimitiveType(PrimitiveType.Kind kind) { + Class type; + switch ( kind ) { + case INT: + type = GLint.class; + break; + case DOUBLE: + type = GLdouble.class; + break; + case FLOAT: + type = GLfloat.class; + break; + case SHORT: + type = GLshort.class; + break; + case BYTE: + type = GLbyte.class; + break; + case LONG: + type = GLint64EXT.class; + break; + case BOOLEAN: + type = GLboolean.class; + break; + default: + throw new RuntimeException(kind + " is not allowed"); + } + return type; + } + + public Class getVoidType() { + return GLvoid.class; + } + + public Class getStringElementType() { + return GLubyte.class; + } + + 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, GLvoid.class }; + else if ( type.equals(FloatBuffer.class) ) + return new Class[] { GLclampf.class, GLfloat.class }; + else if ( type.equals(ByteBuffer.class) ) + return new Class[] { GLboolean.class, GLbyte.class, GLcharARB.class, GLchar.class, GLubyte.class, GLvoid.class }; + else if ( type.equals(ShortBuffer.class) ) + 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, GLint64.class, GLuint64.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, GLint64EXT.class, GLuint64EXT.class, GLint64.class, GLuint64.class }; + else if ( type.equals(int.class) ) + return new Class[] { GLbitfield.class, GLenum.class, GLhandleARB.class, GLint.class, GLuint.class, + GLsizei.class }; + else if ( type.equals(double.class) ) + return new Class[] { GLclampd.class, GLdouble.class }; + else if ( type.equals(float.class) ) + return new Class[] { GLclampf.class, GLfloat.class }; + else if ( type.equals(short.class) ) + return new Class[] { GLhalf.class, GLshort.class, GLushort.class }; + else if ( type.equals(byte.class) ) + return new Class[] { GLbyte.class, GLcharARB.class, GLchar.class, GLubyte.class }; + else if ( type.equals(boolean.class) ) + return new Class[] { GLboolean.class }; + else if ( type.equals(void.class) ) + return new Class[] { GLvoid.class, GLreturn.class }; + else + return new Class[] { }; + } + + public String getTypedefPrefix() { + return "APIENTRY"; + } + + public void printNativeIncludes(PrintWriter writer) { + writer.println("#include \"extgl.h\""); + } + + public Class[] getValidAnnotationTypes(Class type) { + Class[] valid_types; + if ( Buffer.class.isAssignableFrom(type) ) + valid_types = getValidBufferTypes(type); + else if ( type.isPrimitive() ) + valid_types = getValidPrimitiveTypes(type); + else if ( String.class.equals(type) ) + valid_types = new Class[] { GLubyte.class }; + else if ( PointerWrapper.class.isAssignableFrom(type) ) + valid_types = new Class[] { GLpointer.class }; + else if (void.class.equals(type) ) + valid_types = new Class[] { GLreturn.class }; + else + valid_types = new Class[] { }; + return valid_types; + } + + public Class getInverseType(Class type) { + if ( GLuint.class.equals(type) ) + return GLint.class; + else if ( GLint.class.equals(type) ) + return GLuint.class; + else if ( GLushort.class.equals(type) ) + return GLshort.class; + else if ( GLshort.class.equals(type) ) + return GLushort.class; + else if ( GLubyte.class.equals(type) ) + 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 if ( GLuint64.class.equals(type) ) + return GLint64.class; + else if ( GLint64.class.equals(type) ) + return GLuint64.class; + else + return null; + } + + public String getAutoTypeFromAnnotation(AnnotationMirror annotation) { + Class annotation_class = NativeTypeTranslator.getClassFromType(annotation.getAnnotationType()); + if ( annotation_class.equals(GLint.class) ) + return "GL11.GL_INT"; + else if ( annotation_class.equals(GLbyte.class) ) + return "GL11.GL_BYTE"; + else if ( annotation_class.equals(GLshort.class) ) + return "GL11.GL_SHORT"; + if ( annotation_class.equals(GLuint.class) ) + return "GL11.GL_UNSIGNED_INT"; + else if ( annotation_class.equals(GLubyte.class) ) + return "GL11.GL_UNSIGNED_BYTE"; + else if ( annotation_class.equals(GLushort.class) ) + return "GL11.GL_UNSIGNED_SHORT"; + else if ( annotation_class.equals(GLfloat.class) ) + return "GL11.GL_FLOAT"; + else if ( annotation_class.equals(GLdouble.class) ) + return "GL11.GL_DOUBLE"; + else + return null; + } +} diff --git a/src/java/org/lwjgl/util/generator/GLbitfield.java b/src/java/org/lwjgl/util/generator/GLbitfield.java new file mode 100644 index 0000000..4522a5e --- /dev/null +++ b/src/java/org/lwjgl/util/generator/GLbitfield.java @@ -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; + +/** + * + * @author elias_naur + * @version $Revision: 2983 $ + * $Id: GLbitfield.java 2983 2008-04-07 18:36:09Z matzon $ + */ + +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +@NativeType +@Target({ElementType.PARAMETER, ElementType.METHOD}) +public @interface GLbitfield { +} diff --git a/src/java/org/lwjgl/util/generator/GLboolean.java b/src/java/org/lwjgl/util/generator/GLboolean.java new file mode 100644 index 0000000..b685412 --- /dev/null +++ b/src/java/org/lwjgl/util/generator/GLboolean.java @@ -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; + +/** + * + * @author elias_naur + * @version $Revision: 2983 $ + * $Id: GLboolean.java 2983 2008-04-07 18:36:09Z matzon $ + */ + +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +@NativeType +@Target({ElementType.PARAMETER, ElementType.METHOD}) +public @interface GLboolean { +} diff --git a/src/java/org/lwjgl/util/generator/GLbyte.java b/src/java/org/lwjgl/util/generator/GLbyte.java new file mode 100644 index 0000000..ab3c473 --- /dev/null +++ b/src/java/org/lwjgl/util/generator/GLbyte.java @@ -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; + +/** + * + * @author elias_naur + * @version $Revision: 2983 $ + * $Id: GLbyte.java 2983 2008-04-07 18:36:09Z matzon $ + */ + +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +@NativeType +@Target({ElementType.PARAMETER, ElementType.METHOD}) +public @interface GLbyte { +} diff --git a/src/java/org/lwjgl/util/generator/GLchar.java b/src/java/org/lwjgl/util/generator/GLchar.java new file mode 100644 index 0000000..9263c83 --- /dev/null +++ b/src/java/org/lwjgl/util/generator/GLchar.java @@ -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; + +/** + * + * @author elias_naur + * @version $Revision: 2983 $ + * $Id: GLchar.java 2983 2008-04-07 18:36:09Z matzon $ + */ + +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +@NativeType +@Target({ElementType.PARAMETER, ElementType.METHOD}) +public @interface GLchar { +} diff --git a/src/java/org/lwjgl/util/generator/GLcharARB.java b/src/java/org/lwjgl/util/generator/GLcharARB.java new file mode 100644 index 0000000..285e5d6 --- /dev/null +++ b/src/java/org/lwjgl/util/generator/GLcharARB.java @@ -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; + +/** + * + * @author elias_naur + * @version $Revision: 2983 $ + * $Id: GLcharARB.java 2983 2008-04-07 18:36:09Z matzon $ + */ + +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +@NativeType +@Target({ElementType.PARAMETER, ElementType.METHOD}) +public @interface GLcharARB { +} diff --git a/src/java/org/lwjgl/util/generator/GLclampd.java b/src/java/org/lwjgl/util/generator/GLclampd.java new file mode 100644 index 0000000..429b49f --- /dev/null +++ b/src/java/org/lwjgl/util/generator/GLclampd.java @@ -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; + +/** + * + * @author elias_naur + * @version $Revision: 2983 $ + * $Id: GLclampd.java 2983 2008-04-07 18:36:09Z matzon $ + */ + +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +@NativeType +@Target({ElementType.PARAMETER, ElementType.METHOD}) +public @interface GLclampd { +} diff --git a/src/java/org/lwjgl/util/generator/GLclampf.java b/src/java/org/lwjgl/util/generator/GLclampf.java new file mode 100644 index 0000000..356cea8 --- /dev/null +++ b/src/java/org/lwjgl/util/generator/GLclampf.java @@ -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; + +/** + * + * @author elias_naur + * @version $Revision: 2983 $ + * $Id: GLclampf.java 2983 2008-04-07 18:36:09Z matzon $ + */ + +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +@NativeType +@Target({ElementType.PARAMETER, ElementType.METHOD}) +public @interface GLclampf { +} diff --git a/src/java/org/lwjgl/util/generator/GLdouble.java b/src/java/org/lwjgl/util/generator/GLdouble.java new file mode 100644 index 0000000..b3622ec --- /dev/null +++ b/src/java/org/lwjgl/util/generator/GLdouble.java @@ -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; + +/** + * + * @author elias_naur + * @version $Revision: 2983 $ + * $Id: GLdouble.java 2983 2008-04-07 18:36:09Z matzon $ + */ + +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +@NativeType +@Target({ElementType.PARAMETER, ElementType.METHOD}) +public @interface GLdouble { +} diff --git a/src/java/org/lwjgl/util/generator/GLenum.java b/src/java/org/lwjgl/util/generator/GLenum.java new file mode 100644 index 0000000..f7f68d8 --- /dev/null +++ b/src/java/org/lwjgl/util/generator/GLenum.java @@ -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; + +/** + * + * @author elias_naur + * @version $Revision: 2983 $ + * $Id: GLenum.java 2983 2008-04-07 18:36:09Z matzon $ + */ + +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +@NativeType +@Target({ElementType.PARAMETER, ElementType.METHOD}) +public @interface GLenum { +} diff --git a/src/java/org/lwjgl/util/generator/GLfloat.java b/src/java/org/lwjgl/util/generator/GLfloat.java new file mode 100644 index 0000000..fe351a9 --- /dev/null +++ b/src/java/org/lwjgl/util/generator/GLfloat.java @@ -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; + +/** + * + * @author elias_naur + * @version $Revision: 2983 $ + * $Id: GLfloat.java 2983 2008-04-07 18:36:09Z matzon $ + */ + +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +@NativeType +@Target({ElementType.PARAMETER, ElementType.METHOD}) +public @interface GLfloat { +} diff --git a/src/java/org/lwjgl/util/generator/GLhalf.java b/src/java/org/lwjgl/util/generator/GLhalf.java new file mode 100644 index 0000000..bf54627 --- /dev/null +++ b/src/java/org/lwjgl/util/generator/GLhalf.java @@ -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; + +/** + * + * @author elias_naur + * @version $Revision: 2983 $ + * $Id: GLhalf.java 2983 2008-04-07 18:36:09Z matzon $ + */ + +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +@NativeType +@Target({ElementType.PARAMETER, ElementType.METHOD}) +public @interface GLhalf { +} diff --git a/src/java/org/lwjgl/util/generator/GLhandleARB.java b/src/java/org/lwjgl/util/generator/GLhandleARB.java new file mode 100644 index 0000000..e4c388d --- /dev/null +++ b/src/java/org/lwjgl/util/generator/GLhandleARB.java @@ -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; + +/** + * + * @author elias_naur + * @version $Revision: 2983 $ + * $Id: GLhandleARB.java 2983 2008-04-07 18:36:09Z matzon $ + */ + +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +@NativeType +@Target({ElementType.PARAMETER, ElementType.METHOD}) +public @interface GLhandleARB { +} diff --git a/src/java/org/lwjgl/util/generator/GLint.java b/src/java/org/lwjgl/util/generator/GLint.java new file mode 100644 index 0000000..8321875 --- /dev/null +++ b/src/java/org/lwjgl/util/generator/GLint.java @@ -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; + +/** + * + * @author elias_naur + * @version $Revision: 2983 $ + * $Id: GLint.java 2983 2008-04-07 18:36:09Z matzon $ + */ + +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +@NativeType +@Target({ElementType.PARAMETER, ElementType.METHOD}) +public @interface GLint { +} diff --git a/src/java/org/lwjgl/util/generator/GLint64.java b/src/java/org/lwjgl/util/generator/GLint64.java new file mode 100644 index 0000000..75fc705 --- /dev/null +++ b/src/java/org/lwjgl/util/generator/GLint64.java @@ -0,0 +1,40 @@ +/* + * 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.Target; +import java.lang.annotation.ElementType; + +@NativeType +@Target({ElementType.PARAMETER, ElementType.METHOD}) +public @interface GLint64 { +} \ No newline at end of file diff --git a/src/java/org/lwjgl/util/generator/GLint64EXT.java b/src/java/org/lwjgl/util/generator/GLint64EXT.java new file mode 100644 index 0000000..7c96212 --- /dev/null +++ b/src/java/org/lwjgl/util/generator/GLint64EXT.java @@ -0,0 +1,40 @@ +/* + * 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.Target; +import java.lang.annotation.ElementType; + +@NativeType +@Target({ElementType.PARAMETER, ElementType.METHOD}) +public @interface GLint64EXT { +} \ No newline at end of file diff --git a/src/java/org/lwjgl/util/generator/GLintptr.java b/src/java/org/lwjgl/util/generator/GLintptr.java new file mode 100644 index 0000000..fa8afe1 --- /dev/null +++ b/src/java/org/lwjgl/util/generator/GLintptr.java @@ -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; + +/** + * + * @author elias_naur + * @version $Revision: 2983 $ + * $Id: GLintptr.java 2983 2008-04-07 18:36:09Z matzon $ + */ + +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +@NativeType +@Target({ElementType.PARAMETER, ElementType.METHOD}) +public @interface GLintptr { +} diff --git a/src/java/org/lwjgl/util/generator/GLintptrARB.java b/src/java/org/lwjgl/util/generator/GLintptrARB.java new file mode 100644 index 0000000..f88a54a --- /dev/null +++ b/src/java/org/lwjgl/util/generator/GLintptrARB.java @@ -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; + +/** + * + * @author elias_naur + * @version $Revision: 2983 $ + * $Id: GLintptrARB.java 2983 2008-04-07 18:36:09Z matzon $ + */ + +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +@NativeType +@Target({ElementType.PARAMETER, ElementType.METHOD}) +public @interface GLintptrARB { +} diff --git a/src/java/org/lwjgl/util/generator/GLpointer.java b/src/java/org/lwjgl/util/generator/GLpointer.java new file mode 100644 index 0000000..d42f590 --- /dev/null +++ b/src/java/org/lwjgl/util/generator/GLpointer.java @@ -0,0 +1,43 @@ +/* + * 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; + +/** + * @author spasi + */ +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +@Target({ElementType.PARAMETER, ElementType.METHOD}) +public @interface GLpointer { + String value(); // The native pointer type. +} \ No newline at end of file diff --git a/src/java/org/lwjgl/util/generator/GLreturn.java b/src/java/org/lwjgl/util/generator/GLreturn.java new file mode 100644 index 0000000..51fd9e8 --- /dev/null +++ b/src/java/org/lwjgl/util/generator/GLreturn.java @@ -0,0 +1,55 @@ +/* + * 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; + +/** + * When a method is annonated with @GLreturn, the specified output Buffer parameter + * will be used to return a single value. The primitive type will match the Buffer type. + * String will be returned if the Buffer is a ByteBuffer annotated with @GLchar. + * + * @author spasi + */ +import java.lang.annotation.ElementType; +import java.lang.annotation.Target; + +@NativeType +@Target({ ElementType.METHOD }) +public @interface GLreturn { + /** The Buffer parameter to use as the method result. */ + String value(); + /** The argument that specifies the maximum number of bytes that may be read (String results only). */ + String maxLength() default ""; + /** If true, the maxLength value is going to be used when creating the String. */ + boolean forceMaxLength() default false; + ///** If we use the byte buffer for another parameter, an offset must be used. */ + //String offset() default ""; +} \ No newline at end of file diff --git a/src/java/org/lwjgl/util/generator/GLshort.java b/src/java/org/lwjgl/util/generator/GLshort.java new file mode 100644 index 0000000..099f6e4 --- /dev/null +++ b/src/java/org/lwjgl/util/generator/GLshort.java @@ -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; + +/** + * + * @author elias_naur + * @version $Revision: 2983 $ + * $Id: GLshort.java 2983 2008-04-07 18:36:09Z matzon $ + */ + +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +@NativeType +@Target({ElementType.PARAMETER, ElementType.METHOD}) +public @interface GLshort { +} diff --git a/src/java/org/lwjgl/util/generator/GLsizei.java b/src/java/org/lwjgl/util/generator/GLsizei.java new file mode 100644 index 0000000..8831151 --- /dev/null +++ b/src/java/org/lwjgl/util/generator/GLsizei.java @@ -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; + +/** + * + * @author elias_naur + * @version $Revision: 2983 $ + * $Id: GLsizei.java 2983 2008-04-07 18:36:09Z matzon $ + */ + +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +@NativeType +@Target({ElementType.PARAMETER, ElementType.METHOD}) +public @interface GLsizei { +} diff --git a/src/java/org/lwjgl/util/generator/GLsizeiptr.java b/src/java/org/lwjgl/util/generator/GLsizeiptr.java new file mode 100644 index 0000000..b5169a3 --- /dev/null +++ b/src/java/org/lwjgl/util/generator/GLsizeiptr.java @@ -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; + +/** + * + * @author elias_naur + * @version $Revision: 2983 $ + * $Id: GLsizeiptr.java 2983 2008-04-07 18:36:09Z matzon $ + */ + +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +@NativeType +@Target({ElementType.PARAMETER, ElementType.METHOD}) +public @interface GLsizeiptr { +} diff --git a/src/java/org/lwjgl/util/generator/GLsizeiptrARB.java b/src/java/org/lwjgl/util/generator/GLsizeiptrARB.java new file mode 100644 index 0000000..9a24cf0 --- /dev/null +++ b/src/java/org/lwjgl/util/generator/GLsizeiptrARB.java @@ -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; + +/** + * + * @author elias_naur + * @version $Revision: 2983 $ + * $Id: GLsizeiptrARB.java 2983 2008-04-07 18:36:09Z matzon $ + */ + +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +@NativeType +@Target({ElementType.PARAMETER, ElementType.METHOD}) +public @interface GLsizeiptrARB { +} diff --git a/src/java/org/lwjgl/util/generator/GLtime.java b/src/java/org/lwjgl/util/generator/GLtime.java new file mode 100644 index 0000000..81506f1 --- /dev/null +++ b/src/java/org/lwjgl/util/generator/GLtime.java @@ -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; + +/** + * Unsigned binary representing an absolute absolute or relative time interval. + * Precision is nanoseconds but accuracy is implementation-dependent. + * + * @author spasi + */ + +import java.lang.annotation.ElementType; +import java.lang.annotation.Target; + +@NativeType +@Target({ElementType.PARAMETER, ElementType.METHOD}) +public @interface GLtime { +} \ No newline at end of file diff --git a/src/java/org/lwjgl/util/generator/GLubyte.java b/src/java/org/lwjgl/util/generator/GLubyte.java new file mode 100644 index 0000000..b093b91 --- /dev/null +++ b/src/java/org/lwjgl/util/generator/GLubyte.java @@ -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; + +/** + * + * @author elias_naur + * @version $Revision: 2983 $ + * $Id: GLubyte.java 2983 2008-04-07 18:36:09Z matzon $ + */ + +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +@NativeType +@Target({ElementType.PARAMETER, ElementType.METHOD}) +public @interface GLubyte { +} diff --git a/src/java/org/lwjgl/util/generator/GLuint.java b/src/java/org/lwjgl/util/generator/GLuint.java new file mode 100644 index 0000000..5a6adcc --- /dev/null +++ b/src/java/org/lwjgl/util/generator/GLuint.java @@ -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; + +/** + * + * @author elias_naur + * @version $Revision: 2983 $ + * $Id: GLuint.java 2983 2008-04-07 18:36:09Z matzon $ + */ + +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +@NativeType +@Target({ElementType.PARAMETER, ElementType.METHOD}) +public @interface GLuint { +} diff --git a/src/java/org/lwjgl/util/generator/GLuint64.java b/src/java/org/lwjgl/util/generator/GLuint64.java new file mode 100644 index 0000000..0cd089c --- /dev/null +++ b/src/java/org/lwjgl/util/generator/GLuint64.java @@ -0,0 +1,40 @@ +/* + * 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.Target; +import java.lang.annotation.ElementType; + +@NativeType +@Target({ElementType.PARAMETER, ElementType.METHOD}) +public @interface GLuint64 { +} \ No newline at end of file diff --git a/src/java/org/lwjgl/util/generator/GLuint64EXT.java b/src/java/org/lwjgl/util/generator/GLuint64EXT.java new file mode 100644 index 0000000..0eae8e6 --- /dev/null +++ b/src/java/org/lwjgl/util/generator/GLuint64EXT.java @@ -0,0 +1,40 @@ +/* + * 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.Target; +import java.lang.annotation.ElementType; + +@NativeType +@Target({ElementType.PARAMETER, ElementType.METHOD}) +public @interface GLuint64EXT { +} \ No newline at end of file diff --git a/src/java/org/lwjgl/util/generator/GLushort.java b/src/java/org/lwjgl/util/generator/GLushort.java new file mode 100644 index 0000000..171f0ff --- /dev/null +++ b/src/java/org/lwjgl/util/generator/GLushort.java @@ -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; + +/** + * + * @author elias_naur + * @version $Revision: 2983 $ + * $Id: GLushort.java 2983 2008-04-07 18:36:09Z matzon $ + */ + +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +@NativeType +@Target({ElementType.PARAMETER, ElementType.METHOD}) +public @interface GLushort { +} diff --git a/src/java/org/lwjgl/util/generator/GLvoid.java b/src/java/org/lwjgl/util/generator/GLvoid.java new file mode 100644 index 0000000..d5c3113 --- /dev/null +++ b/src/java/org/lwjgl/util/generator/GLvoid.java @@ -0,0 +1,50 @@ +/* + * 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; + +/** + * + * @author elias_naur + * @version $Revision: 3279 $ + * $Id: GLvoid.java 3279 2010-03-11 21:06:49Z spasi $ + */ + +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; +} diff --git a/src/java/org/lwjgl/util/generator/GenerateAutos.java b/src/java/org/lwjgl/util/generator/GenerateAutos.java new file mode 100644 index 0000000..de22669 --- /dev/null +++ b/src/java/org/lwjgl/util/generator/GenerateAutos.java @@ -0,0 +1,46 @@ +/* + * 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; + +/** + * + * @author elias_naur + * @version $Revision: 2983 $ + * $Id: GenerateAutos.java 2983 2008-04-07 18:36:09Z matzon $ + */ + +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +@Target(ElementType.METHOD) +public @interface GenerateAutos { +} diff --git a/src/java/org/lwjgl/util/generator/GeneratorProcessorFactory.java b/src/java/org/lwjgl/util/generator/GeneratorProcessorFactory.java new file mode 100644 index 0000000..a57a208 --- /dev/null +++ b/src/java/org/lwjgl/util/generator/GeneratorProcessorFactory.java @@ -0,0 +1,157 @@ +/* + * 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 com.sun.mirror.apt.*; +import com.sun.mirror.declaration.*; + +import java.io.File; +import java.io.FileFilter; +import java.util.Collection; +import java.util.Set; +import java.util.Map; +import java.util.Arrays; + +import static java.util.Collections.*; +import static com.sun.mirror.util.DeclarationVisitors.*; + +/** + * + * Generator tool for creating the java classes and native code + * from an annotated template java interface. + * + * @author elias_naur + * @version $Revision: 3289 $ + * $Id: GeneratorProcessorFactory.java 3289 2010-03-16 19:05:19Z spasi $ + */ +public class GeneratorProcessorFactory implements AnnotationProcessorFactory, RoundCompleteListener { + private static boolean first_round = true; + + // Process any set of annotations + private static final Collection supportedAnnotations = + unmodifiableCollection(Arrays.asList("*")); + + private static final Collection supportedOptions = + unmodifiableCollection(Arrays.asList("-Atypemap", "-Ageneratechecks", "-Acontextspecific")); + + public Collection supportedAnnotationTypes() { + return supportedAnnotations; + } + + public Collection supportedOptions() { + return supportedOptions; + } + + public void roundComplete(RoundCompleteEvent event) { + first_round = false; + } + + public AnnotationProcessor getProcessorFor(Set atds, AnnotationProcessorEnvironment env) { + // Only process the initial types, not the generated ones + if (first_round) { + env.addListener(this); + return new GeneratorProcessor(env); + } else + return AnnotationProcessors.NO_OP; + } + + private static class GeneratorProcessor implements AnnotationProcessor { + private final AnnotationProcessorEnvironment env; + + GeneratorProcessor(AnnotationProcessorEnvironment env) { + this.env = env; + } + + public void process() { + Map options = env.getOptions(); + String typemap_classname = null; + boolean generate_error_checks = options.containsKey("-Ageneratechecks"); + boolean context_specific = options.containsKey("-Acontextspecific"); + for (String k : options.keySet()) { + int delimiter = k.indexOf('='); + if (delimiter != -1) { + if (k.startsWith("-Atypemap")) { + typemap_classname = k.substring(delimiter + 1); + } + } + } + if (typemap_classname == null) + throw new RuntimeException("No TypeMap class name specified with -Atypemap="); + + TypeDeclaration lastFile = null; + try { + long generatorLM = getGeneratorLastModified(); + TypeMap type_map = (TypeMap)(Class.forName(typemap_classname).newInstance()); + for (TypeDeclaration typedecl : env.getSpecifiedTypeDeclarations()) { + lastFile = typedecl; + typedecl.accept(getDeclarationScanner(new GeneratorVisitor(env, type_map, generate_error_checks, context_specific, generatorLM), NO_OP)); + } + } catch (Exception e) { + if ( lastFile == null ) + throw new RuntimeException(e); + else + throw new RuntimeException("\n-- Failed to process template: " + lastFile.getQualifiedName() + " --", e); + } + } + + /** + * Gets the time of the latest change on the Generator classes. + * + * @return time of the latest change + */ + private static long getGeneratorLastModified() { + final File pck = new File(System.getProperty("user.dir") + "/bin/org/lwjgl/util/generator"); + if ( !pck.exists() || !pck.isDirectory() ) + return Long.MAX_VALUE; + + final File[] classes = pck.listFiles(new FileFilter() { + public boolean accept(final File pathname) { + return pathname.isFile() && pathname.getName().endsWith(".class"); + } + }); + + if ( classes == null || classes.length == 0 ) + return Long.MAX_VALUE; + + long lastModified = 0; + + for ( File clazz : classes ) { + long lm = clazz.lastModified(); + if ( lastModified < lm ) + lastModified = lm; + } + + return lastModified; + } + } +} \ No newline at end of file diff --git a/src/java/org/lwjgl/util/generator/GeneratorVisitor.java b/src/java/org/lwjgl/util/generator/GeneratorVisitor.java new file mode 100644 index 0000000..93f6b31 --- /dev/null +++ b/src/java/org/lwjgl/util/generator/GeneratorVisitor.java @@ -0,0 +1,278 @@ +/* + * 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 com.sun.mirror.apt.*; +import com.sun.mirror.declaration.*; +import com.sun.mirror.type.*; +import com.sun.mirror.util.*; + +import java.util.*; + +import java.io.PrintWriter; +import java.io.IOException; +import java.io.File; + +import java.nio.*; + +/** + * + * Generator visitor for the generator tool + * + * @author elias_naur + * @version $Revision: 3299 $ + * $Id: GeneratorVisitor.java 3299 2010-03-31 15:46:16Z spasi $ + */ +public class GeneratorVisitor extends SimpleDeclarationVisitor { + private final AnnotationProcessorEnvironment env; + private final TypeMap type_map; + private final boolean generate_error_checks; + private final boolean context_specific; + private final long generatorLM; + + public GeneratorVisitor(AnnotationProcessorEnvironment env, TypeMap type_map, boolean generate_error_checks, boolean context_specific, long generatorLM) { + this.env = env; + this.type_map = type_map; + this.generate_error_checks = generate_error_checks; + this.context_specific = context_specific; + this.generatorLM = generatorLM; + } + + private void validateMethods(InterfaceDeclaration d) { + for (MethodDeclaration method : d.getMethods()) + validateMethod(method); + } + + private void validateMethod(MethodDeclaration method) { + if (method.isVarArgs()) + throw new RuntimeException("Method " + method.getSimpleName() + " is variadic"); + Collection modifiers = method.getModifiers(); + if (!modifiers.contains(Modifier.PUBLIC)) + throw new RuntimeException("Method " + method.getSimpleName() + " is not public"); + if (method.getThrownTypes().size() > 0) + throw new RuntimeException("Method " + method.getSimpleName() + " throws checked exceptions"); + validateParameters(method); + StripPostfix strip_annotation = method.getAnnotation(StripPostfix.class); + if (strip_annotation != null && method.getAnnotation(Alternate.class) == null) { + String postfix_param_name = strip_annotation.value(); + ParameterDeclaration postfix_param = Utils.findParameter(method, postfix_param_name); + if (Utils.isParameterMultiTyped(postfix_param)) + throw new RuntimeException("Postfix parameter can't be the same as a multityped parameter in method " + method); + if (Utils.getNIOBufferType(postfix_param.getType()) == null) + throw new RuntimeException("Postfix parameter type must be a nio Buffer"); + } + if (Utils.getResultParameter(method) != null && !method.getReturnType().equals(env.getTypeUtils().getVoidType())) + throw new RuntimeException(method + " return type is not void but a parameter is annotated with Result"); + if (method.getAnnotation(CachedResult.class) != null) { + if (Utils.getNIOBufferType(Utils.getMethodReturnType(method)) == null) + throw new RuntimeException(method + " return type is not a Buffer, but is annotated with CachedResult"); + if (method.getAnnotation(AutoResultSize.class) == null) + throw new RuntimeException(method + " is annotated with CachedResult but misses an AutoResultSize annotation"); + } + validateTypes(method, method.getAnnotationMirrors(), method.getReturnType()); + } + + private void validateType(MethodDeclaration method, Class annotation_type, Class type) { + Class[] valid_types = type_map.getValidAnnotationTypes(type); + for (int i = 0; i < valid_types.length; i++) + if (valid_types[i].equals(annotation_type)) + return; + throw new RuntimeException(type + " is annotated with invalid native type " + annotation_type + + " in method " + method); + } + + private void validateTypes(MethodDeclaration method, Collection annotations, TypeMirror type_mirror) { + for (AnnotationMirror annotation : annotations) { + NativeType native_type_annotation = NativeTypeTranslator.getAnnotation(annotation, NativeType.class); + if (native_type_annotation != null) { + Class annotation_type = NativeTypeTranslator.getClassFromType(annotation.getAnnotationType()); + Class type = Utils.getJavaType(type_mirror); + if (Buffer.class.equals(type)) + continue; + validateType(method, annotation_type, type); + } + } + } + + private void validateParameters(MethodDeclaration method) { + for (ParameterDeclaration param : method.getParameters()) { + validateTypes(method, param.getAnnotationMirrors(), param.getType()); + Class param_type = Utils.getJavaType(param.getType()); + if (Utils.getNIOBufferType(param.getType()) != null && param_type != CharSequence.class && param_type != CharSequence[].class) { + Check parameter_check_annotation = param.getAnnotation(Check.class); + NullTerminated null_terminated_annotation = param.getAnnotation(NullTerminated.class); + if (parameter_check_annotation == null && null_terminated_annotation == null) { + boolean found_auto_size_param = false; + for (ParameterDeclaration inner_param : method.getParameters()) { + AutoSize auto_size_annotation = inner_param.getAnnotation(AutoSize.class); + if (auto_size_annotation != null && + auto_size_annotation.value().equals(param.getSimpleName())) { + found_auto_size_param = true; + break; + } + } + if (!found_auto_size_param + && param.getAnnotation(Result.class) == null + && param.getAnnotation(Constant.class) == null + && !Utils.isReturnParameter(method, param) + ) + throw new RuntimeException(param + " has no Check, Result nor Constant annotation, is not the return parameter and no other parameter has" + + " an @AutoSize annotation on it in method " + method); + } + if (param.getAnnotation(CachedReference.class) != null && param.getAnnotation(Result.class) != null) + 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"); + } else { + if (param.getAnnotation(BufferObject.class) != null) + throw new RuntimeException(param + " type is not a buffer, but annotated as a BufferObject"); + if (param.getAnnotation(CachedReference.class) != null) + throw new RuntimeException(param + " type is not a buffer, but annotated as a CachedReference"); + } + } + } + + private static void generateMethodsNativePointers(PrintWriter writer, Collection methods) { + for (MethodDeclaration method : methods) { + if ( method.getAnnotation(Alternate.class) == null ) + generateMethodNativePointers(writer, method); + } + } + + private static void generateMethodNativePointers(PrintWriter writer, MethodDeclaration method) { + writer.println("static " + Utils.getTypedefName(method) + " " + method.getSimpleName() + ";"); + } + + private void generateJavaSource(InterfaceDeclaration d, PrintWriter java_writer) throws IOException { + java_writer.println("/* MACHINE GENERATED FILE, DO NOT EDIT */"); + java_writer.println(); + java_writer.println("package " + d.getPackage().getQualifiedName() + ";"); + java_writer.println(); + java_writer.println("import org.lwjgl.LWJGLException;"); + java_writer.println("import org.lwjgl.BufferChecks;"); + // DISABLED: indirect buffer support + //java_writer.println("import org.lwjgl.NondirectBufferWrapper;"); + java_writer.println("import java.nio.*;"); + java_writer.println(); + Utils.printDocComment(java_writer, d); + java_writer.print("public "); + boolean is_final = Utils.isFinal(d); + if (is_final) + java_writer.write("final "); + java_writer.print("class " + Utils.getSimpleClassName(d)); + Collection super_interfaces = d.getSuperinterfaces(); + if (super_interfaces.size() > 1) + throw new RuntimeException(d + " extends more than one interface"); + if (super_interfaces.size() == 1) { + InterfaceDeclaration super_interface = super_interfaces.iterator().next().getDeclaration(); + java_writer.print(" extends " + Utils.getSimpleClassName(super_interface)); + } + java_writer.println(" {"); + FieldsGenerator.generateFields(java_writer, d.getFields()); + java_writer.println(); + if (is_final) { + // Write private constructor to avoid instantiation + java_writer.println("\tprivate " + Utils.getSimpleClassName(d) + "() {"); + java_writer.println("\t}"); + java_writer.println(); + } + if (d.getMethods().size() > 0 && !context_specific) + java_writer.println("\tstatic native void " + Utils.STUB_INITIALIZER_NAME + "() throws LWJGLException;"); + JavaMethodsGenerator.generateMethodsJava(env, type_map, java_writer, d, generate_error_checks, context_specific); + java_writer.println("}"); + java_writer.close(); + String qualified_interface_name = Utils.getQualifiedClassName(d); + env.getMessager().printNotice("Generated class " + qualified_interface_name); + } + + private void generateNativeSource(InterfaceDeclaration d) throws IOException { + String qualified_interface_name = Utils.getQualifiedClassName(d); + String qualified_native_name = Utils.getNativeQualifiedName(qualified_interface_name)+ ".c"; + PrintWriter native_writer = env.getFiler().createTextFile(Filer.Location.CLASS_TREE, "", new File(qualified_native_name), "UTF-8"); + native_writer.println("/* MACHINE GENERATED FILE, DO NOT EDIT */"); + native_writer.println(); + native_writer.println("#include "); + type_map.printNativeIncludes(native_writer); + native_writer.println(); + TypedefsGenerator.generateNativeTypedefs(type_map, native_writer, d.getMethods()); + native_writer.println(); + if (!context_specific) { + generateMethodsNativePointers(native_writer, d.getMethods()); + native_writer.println(); + } + NativeMethodStubsGenerator.generateNativeMethodStubs(env, type_map, native_writer, d, generate_error_checks, context_specific); + if (!context_specific) { + native_writer.print("JNIEXPORT void JNICALL " + Utils.getQualifiedNativeMethodName(qualified_interface_name, Utils.STUB_INITIALIZER_NAME)); + native_writer.println("(JNIEnv *env, jclass clazz) {"); + native_writer.println("\tJavaMethodAndExtFunction functions[] = {"); + RegisterStubsGenerator.generateMethodsNativeStubBind(native_writer, d, generate_error_checks, context_specific); + native_writer.println("\t};"); + native_writer.println("\tint num_functions = NUMFUNCTIONS(functions);"); + native_writer.print("\t"); + native_writer.print(type_map.getRegisterNativesFunctionName()); + native_writer.println("(env, clazz, num_functions, functions);"); + native_writer.println("}"); + } + native_writer.close(); + env.getMessager().printNotice("Generated C source " + qualified_interface_name); + } + + public void visitInterfaceDeclaration(InterfaceDeclaration d) { + File input = d.getPosition().file(); + File output = new File(env.getOptions().get("-s") + '/' + d.getPackage().getQualifiedName().replace('.', '/'), Utils.getSimpleClassName(d) + ".java"); + + PrintWriter java_writer = null; + + try { + // Skip this class if the output exists and the input has not been modified. + if ( output.exists() && Math.max(input.lastModified(), generatorLM) < output.lastModified() ) + return; + + if (d.getMethods().size() > 0 || d.getFields().size() > 0) { + validateMethods(d); + java_writer = env.getFiler().createTextFile(Filer.Location.SOURCE_TREE, d.getPackage().getQualifiedName(), new File(Utils.getSimpleClassName(d) + ".java"), null); + generateJavaSource(d, java_writer); + } + if (d.getMethods().size() > 0) + generateNativeSource(d); + } catch (Exception e) { + // If anything goes wrong mid-gen, delete output to allow regen next time we run. + if ( java_writer != null ) java_writer.close(); + if ( output.exists() ) output.delete(); + + throw new RuntimeException(e); + } + } +} diff --git a/src/java/org/lwjgl/util/generator/Indirect.java b/src/java/org/lwjgl/util/generator/Indirect.java new file mode 100644 index 0000000..4bbbc01 --- /dev/null +++ b/src/java/org/lwjgl/util/generator/Indirect.java @@ -0,0 +1,49 @@ +/* + * 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; + +/** + * + * Implies that a parameter is indirect, and forces the native + * stub to use the indirection operator '&' on it. + * + * @author elias_naur + * @version $Revision: 2983 $ + * $Id: Indirect.java 2983 2008-04-07 18:36:09Z matzon $ + */ + +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +@Target(ElementType.PARAMETER) +public @interface Indirect { +} diff --git a/src/java/org/lwjgl/util/generator/JNITypeTranslator.java b/src/java/org/lwjgl/util/generator/JNITypeTranslator.java new file mode 100644 index 0000000..c5d72bb --- /dev/null +++ b/src/java/org/lwjgl/util/generator/JNITypeTranslator.java @@ -0,0 +1,130 @@ +/* + * 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 com.sun.mirror.type.*; +import com.sun.mirror.util.*; + +/** + * + * A TypeVisitor that translates TypeMirrors to JNI + * type strings. + * + * @author elias_naur + * @version $Revision: 3281 $ + * $Id: JNITypeTranslator.java 3281 2010-03-12 21:55:13Z spasi $ + */ +public class JNITypeTranslator implements TypeVisitor { + private final StringBuilder signature = new StringBuilder(); + + public String getSignature() { + return signature.toString(); + } + + public void visitAnnotationType(AnnotationType t) { + throw new RuntimeException(t + " is not allowed"); + } + + public void visitArrayType(ArrayType t) { + if ( "java.lang.CharSequence".equals(t.getComponentType().toString()) ) + signature.append("jobject"); + else + throw new RuntimeException(t + " is not allowed"); + } + + public void visitClassType(ClassType t) { + signature.append("jobject"); + } + + public void visitDeclaredType(DeclaredType t) { + throw new RuntimeException(t + " is not allowed"); + } + + public void visitEnumType(EnumType t) { + throw new RuntimeException(t + " is not allowed"); + } + + public void visitInterfaceType(InterfaceType t) { + throw new RuntimeException(t + " is not allowed"); + } + + public void visitPrimitiveType(PrimitiveType t) { + String type; + switch (t.getKind()) { + case LONG: + type = "jlong"; + break; + case INT: + type = "jint"; + break; + case FLOAT: + type = "jfloat"; + break; + case SHORT: + type = "jshort"; + break; + case BYTE: + type = "jbyte"; + break; + case DOUBLE: + type = "jdouble"; + break; + case BOOLEAN: + type = "jboolean"; + break; + default: + throw new RuntimeException(t + " is not allowed"); + } + signature.append(type); + } + + public void visitReferenceType(ReferenceType t) { + throw new RuntimeException(t + " is not allowed"); + } + + public void visitTypeMirror(TypeMirror t) { + throw new RuntimeException(t + " is not allowed"); + } + + public void visitTypeVariable(TypeVariable t) { + throw new RuntimeException(t + " is not allowed"); + } + + public void visitVoidType(VoidType t) { + signature.append(t.toString()); + } + + public void visitWildcardType(WildcardType t) { + throw new RuntimeException(t + " is not allowed"); + } +} diff --git a/src/java/org/lwjgl/util/generator/JavaMethodsGenerator.java b/src/java/org/lwjgl/util/generator/JavaMethodsGenerator.java new file mode 100644 index 0000000..5f86429 --- /dev/null +++ b/src/java/org/lwjgl/util/generator/JavaMethodsGenerator.java @@ -0,0 +1,593 @@ +/* + * 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; + +/** + * + * This class generates the methods in the generated java source files. + * + * @author elias_naur + * @version $Revision: 3293 $ + * $Id: JavaMethodsGenerator.java 3293 2010-03-23 12:43:44Z spasi $ + */ + +import com.sun.mirror.apt.*; +import com.sun.mirror.declaration.*; +import com.sun.mirror.type.*; + +import java.io.*; +import java.util.*; +import java.nio.*; + +public class JavaMethodsGenerator { + private final static String SAVED_PARAMETER_POSTFIX = "_saved"; + + public static void generateMethodsJava(AnnotationProcessorEnvironment env, TypeMap type_map, PrintWriter writer, InterfaceDeclaration interface_decl, boolean generate_error_checks, boolean context_specific) { + for (MethodDeclaration method : interface_decl.getMethods()) + generateMethodJava(env, type_map, writer, interface_decl, method, generate_error_checks, context_specific); + } + + private static void generateMethodJava(AnnotationProcessorEnvironment env, TypeMap type_map, PrintWriter writer, InterfaceDeclaration interface_decl, MethodDeclaration method, boolean generate_error_checks, boolean context_specific) { + writer.println(); + if (Utils.isMethodIndirect(generate_error_checks, context_specific, method)) { + if (method.getAnnotation(GenerateAutos.class) != null) { + printMethodWithMultiType(env, type_map, writer, interface_decl, method, TypeInfo.getDefaultTypeInfoMap(method), Mode.AUTOS, generate_error_checks, context_specific); + } + Collection> cross_product = TypeInfo.getTypeInfoCrossProduct(type_map, method); + for (Map typeinfos_instance : cross_product) { + printMethodWithMultiType(env, type_map, writer, interface_decl, method, typeinfos_instance, Mode.NORMAL, generate_error_checks, context_specific); + } + } + 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); + } + Alternate alt_annotation = method.getAnnotation(Alternate.class); + if ( alt_annotation == null || alt_annotation.nativeAlt() ) { + if ( alt_annotation != null && method.getSimpleName().equals(alt_annotation.value()) ) + throw new RuntimeException("An alternate function with native code should have a different name than the main function."); + 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); + } + } + } + + private static void printJavaNativeStub(PrintWriter writer, MethodDeclaration method, Mode mode, boolean generate_error_checks, boolean context_specific) { + if (Utils.isMethodIndirect(generate_error_checks, context_specific, method)) { + writer.print("\tprivate static native "); + } else { + Utils.printDocComment(writer, method); + writer.print("\tpublic static native "); + } + printResultType(writer, method, true); + writer.print(" " + Utils.getSimpleNativeMethodName(method, generate_error_checks, context_specific)); + if (mode == Mode.BUFFEROBJECT) + writer.print(Utils.BUFFER_OBJECT_METHOD_POSTFIX); + writer.print("("); + boolean first_parameter = generateParametersJava(writer, method, TypeInfo.getDefaultTypeInfoMap(method), true, mode); + if (context_specific) { + if (!first_parameter) + writer.print(", "); + writer.print("long " + Utils.FUNCTION_POINTER_VAR_NAME); + } + writer.println(");"); + } + + private static boolean generateParametersJava(PrintWriter writer, MethodDeclaration method, Map typeinfos_instance, + boolean native_stub, Mode mode) { + boolean first_parameter = true; + for (ParameterDeclaration param : method.getParameters()) { + AnnotationMirror auto_annotation_mirror = Utils.getParameterAutoAnnotation(param); + boolean hide_auto_parameter = mode == Mode.NORMAL && !native_stub && auto_annotation_mirror != null; + if (hide_auto_parameter) { + AutoType auto_type_annotation = param.getAnnotation(AutoType.class); + if (auto_type_annotation != null) { + ParameterDeclaration auto_parameter = Utils.findParameter(method, auto_type_annotation.value()); + TypeInfo auto_param_type_info = typeinfos_instance.get(auto_parameter); + if (auto_param_type_info.getSignedness() == Signedness.BOTH) { + if (!first_parameter) + writer.print(", "); + first_parameter = false; + writer.print("boolean " + TypeInfo.UNSIGNED_PARAMETER_NAME); + } + } + } else if ( + param.getAnnotation(Result.class) == null + && (native_stub || ((param.getAnnotation(Constant.class) == null || param.getAnnotation(Constant.class).keepParam()) && !Utils.isReturnParameter(method, param))) + && (getAutoTypeParameter(method, param) == null || mode != Mode.AUTOS) + ) + { + TypeInfo type_info = typeinfos_instance.get(param); + first_parameter = generateParameterJava(writer, param, type_info, native_stub, first_parameter, mode); + } + } + CachedResult cached_result_annotation = method.getAnnotation(CachedResult.class); + TypeMirror result_type = Utils.getMethodReturnType(method); + if ((native_stub && Utils.getNIOBufferType(result_type) != null) || Utils.needResultSize(method)) { + if (cached_result_annotation == null || !cached_result_annotation.isRange()) { + if (!first_parameter) + writer.print(", "); + first_parameter = false; + writer.print("long " + Utils.RESULT_SIZE_NAME); + } + } + if (cached_result_annotation != null) { + if (!first_parameter) + writer.print(", "); + + if ( mode == Mode.CACHEDRESULT ) + writer.print("long " + Utils.CACHED_BUFFER_LENGTH_NAME + ", "); + + first_parameter = false; + printResultType(writer, method, native_stub); + writer.print(" " + Utils.CACHED_BUFFER_NAME); + } + return first_parameter; + } + + private static boolean generateParameterJava(PrintWriter writer, ParameterDeclaration param, TypeInfo type_info, boolean native_stub, boolean first_parameter, Mode mode) { + Class buffer_type = Utils.getNIOBufferType(param.getType()); + if (!first_parameter) + writer.print(", "); + BufferObject bo_annotation = param.getAnnotation(BufferObject.class); + if (bo_annotation != null && mode == Mode.BUFFEROBJECT) { + if (buffer_type == null) + throw new RuntimeException("type of " + param + " is not a nio Buffer parameter but is annotated as buffer object"); + writer.print("long " + param.getSimpleName() + Utils.BUFFER_OBJECT_PARAMETER_POSTFIX); + } else { + if ( native_stub && param.getAnnotation(GLpointer.class) != null ) + writer.print("long"); + else { + Class type = type_info.getType(); + if ( native_stub && (type == CharSequence.class || type == CharSequence[].class) ) + writer.print("ByteBuffer"); + else + writer.print(type_info.getType().getSimpleName()); + } + writer.print(" " + param.getSimpleName()); + if ( native_stub && buffer_type != null ) + writer.print(", int " + param.getSimpleName() + NativeMethodStubsGenerator.BUFFER_POSITION_POSTFIX); + } + return false; + } + + private static void printBufferObjectCheck(PrintWriter writer, BufferKind kind, Mode mode) { + String bo_check_method_name = kind.toString(); + writer.print("\t\t" + Utils.CHECKS_CLASS_NAME + ".ensure" + bo_check_method_name); + if (mode == Mode.BUFFEROBJECT) + writer.print("enabled"); + else + writer.print("disabled"); + writer.println("(caps);"); + } + + private static void printBufferObjectChecks(PrintWriter writer, MethodDeclaration method, Mode mode) { + EnumSet check_set = EnumSet.noneOf(BufferKind.class); + for (ParameterDeclaration param : method.getParameters()) { + BufferObject bo_annotation = param.getAnnotation(BufferObject.class); + if (bo_annotation != null) + check_set.add(bo_annotation.value()); + } + for (BufferKind kind : check_set) + printBufferObjectCheck(writer, kind, mode); + } + + private static void printMethodWithMultiType(AnnotationProcessorEnvironment env, TypeMap type_map, PrintWriter writer, InterfaceDeclaration interface_decl, MethodDeclaration method, Map typeinfos_instance, Mode mode, boolean generate_error_checks, boolean context_specific) { + Utils.printDocComment(writer, method); + writer.print("\tpublic static "); + printResultType(writer, method, false); + StripPostfix strip_annotation = method.getAnnotation(StripPostfix.class); + String method_name; + Alternate alt_annotation = method.getAnnotation(Alternate.class); + method_name = alt_annotation == null || alt_annotation.javaAlt() ? method.getSimpleName() : alt_annotation.value(); + if (strip_annotation != null && mode == Mode.NORMAL) + method_name = getPostfixStrippedName(type_map, interface_decl, method); + writer.print(" " + method_name + "("); + generateParametersJava(writer, method, typeinfos_instance, false, mode); + TypeMirror result_type = Utils.getMethodReturnType(method); + writer.println(") {"); + if (context_specific) { + writer.println("\t\tContextCapabilities caps = GLContext.getCapabilities();"); + writer.print("\t\tlong " + Utils.FUNCTION_POINTER_VAR_NAME + " = caps."); + writer.println(Utils.getFunctionAddressName(interface_decl, method, true) + ";"); + writer.print("\t\tBufferChecks.checkFunctionAddress("); + writer.println(Utils.FUNCTION_POINTER_VAR_NAME + ");"); + } + Code code_annotation = method.getAnnotation(Code.class); + if (code_annotation != null) + writer.println(code_annotation.value()); + printBufferObjectChecks(writer, method, mode); + printParameterChecks(writer, method, typeinfos_instance, mode); + printParameterCaching(writer, interface_decl, method, mode); + writer.print("\t\t"); + boolean has_result = !result_type.equals(env.getTypeUtils().getVoidType()); + if (has_result) { + printResultType(writer, method, false); + writer.print(" " + Utils.RESULT_VAR_NAME + " = "); + + if ( method.getAnnotation(GLpointer.class) != null ) + writer.print("new " + method.getReturnType() + "("); + } + if ( method.getAnnotation(GLreturn.class) != null ) { + has_result = true; + Utils.printGLReturnPre(writer, method, method.getAnnotation(GLreturn.class)); + } + writer.print(Utils.getSimpleNativeMethodName(method, generate_error_checks, context_specific)); + if (mode == Mode.BUFFEROBJECT) + writer.print(Utils.BUFFER_OBJECT_METHOD_POSTFIX); + writer.print("("); + boolean first_parameter = printMethodCallArguments(writer, method, typeinfos_instance, mode); + if (context_specific) { + if (!first_parameter) + writer.print(", "); + writer.print(Utils.FUNCTION_POINTER_VAR_NAME); + } + if ( has_result && method.getAnnotation(GLpointer.class) != null ) + writer.print(")"); + writer.println(");"); + if (generate_error_checks && method.getAnnotation(NoErrorCheck.class) == null) + writer.println("\t\t" + type_map.getErrorCheckMethodName() + ";"); + // DISABLED: indirect buffer support + //printNondirectParameterCopies(writer, method, mode); + if (has_result) { + if ( method.getAnnotation(GLreturn.class) == null ) + writer.println("\t\treturn " + Utils.RESULT_VAR_NAME + ";"); + else + Utils.printGLReturnPost(writer, method, method.getAnnotation(GLreturn.class)); + } + writer.println("\t}"); + } + + private static String getExtensionPostfix(InterfaceDeclaration interface_decl) { + String interface_simple_name = interface_decl.getSimpleName(); + Extension extension_annotation = interface_decl.getAnnotation(Extension.class); + if (extension_annotation == null) { + int underscore_index = interface_simple_name.indexOf("_"); + if (underscore_index != -1) + return interface_simple_name.substring(0, underscore_index); + else + return ""; + } else + return extension_annotation.postfix(); + } + + private static ParameterDeclaration getAutoTypeParameter(MethodDeclaration method, ParameterDeclaration target_parameter) { + for (ParameterDeclaration param : method.getParameters()) { + AnnotationMirror auto_annotation = Utils.getParameterAutoAnnotation(param); + if (auto_annotation != null) { + Class annotation_type = NativeTypeTranslator.getClassFromType(auto_annotation.getAnnotationType()); + String parameter_name; + if (annotation_type.equals(AutoType.class)) + parameter_name = param.getAnnotation(AutoType.class).value(); + else if (annotation_type.equals(AutoSize.class)) + parameter_name = param.getAnnotation(AutoSize.class).value(); + else + throw new RuntimeException("Unkown annotation type " + annotation_type); + if (target_parameter.getSimpleName().equals(parameter_name)) + return param; + } + } + return null; + } + + private static boolean hasAnyParameterAutoTypeAnnotation(MethodDeclaration method, ParameterDeclaration target_param) { + for (ParameterDeclaration param : method.getParameters()) { + AutoType auto_type_annotation = param.getAnnotation(AutoType.class); + if (auto_type_annotation != null) { + ParameterDeclaration type_target_param = Utils.findParameter(method, auto_type_annotation.value()); + if (target_param.equals(type_target_param)) + return true; + } + } + return false; + } + + private static String getPostfixStrippedName(TypeMap type_map, InterfaceDeclaration interface_decl, MethodDeclaration method) { + StripPostfix strip_annotation = method.getAnnotation(StripPostfix.class); + ParameterDeclaration postfix_parameter = Utils.findParameter(method, strip_annotation.value()); + String postfix = strip_annotation.postfix(); + if ( "NULL".equals(postfix) ) { + PostfixTranslator translator = new PostfixTranslator(type_map, postfix_parameter); + postfix_parameter.getType().accept(translator); + postfix = translator.getSignature(); + } + String method_name; + Alternate alt_annotation = method.getAnnotation(Alternate.class); + method_name = alt_annotation == null || alt_annotation.javaAlt() ? method.getSimpleName() : alt_annotation.value(); + + String extension_postfix = "NULL".equals(strip_annotation.extension()) ? getExtensionPostfix(interface_decl) : strip_annotation.extension(); + String result; + + if ( strip_annotation.hasPostfix() && method_name.endsWith(postfix + "v" + extension_postfix)) + result = method_name.substring(0, method_name.length() - (postfix.length() + 1 + extension_postfix.length())); + else if ( strip_annotation.hasPostfix() && method_name.endsWith(postfix + extension_postfix)) + result = method_name.substring(0, method_name.length() - (postfix.length() + extension_postfix.length())); + else if ( strip_annotation.hasPostfix() && method_name.endsWith(postfix + "i_v" + extension_postfix) ) + result = method_name.substring(0, method_name.length() - (postfix.length() + 3 + extension_postfix.length())); + else if ( method_name.endsWith("i_v" + extension_postfix) ) + result = method_name.substring(0, method_name.length() - (3 + extension_postfix.length())); + else if (method_name.endsWith("v" + extension_postfix)) + result = method_name.substring(0, method_name.length() - (1 + extension_postfix.length())); + else + throw new RuntimeException(method + " is specified as being postfix stripped on parameter " + postfix_parameter + ", but it's postfix is not '" + postfix + "' nor 'v'"); + + return result + extension_postfix; + } + + private static int getBufferElementSizeExponent(Class c) { + if (IntBuffer.class.equals(c)) + return 2; + else if (LongBuffer.class.equals(c)) + return 3; + else if (DoubleBuffer.class.equals(c)) + return 3; + else if (ShortBuffer.class.equals(c)) + return 1; + else if (ByteBuffer.class.equals(c)) + return 0; + else if (FloatBuffer.class.equals(c)) + return 2; + else + throw new RuntimeException(c + " is not allowed"); + } + + private static boolean printMethodCallArgument(PrintWriter writer, MethodDeclaration method, ParameterDeclaration param, Map typeinfos_instance, Mode mode, boolean first_parameter) { + if (!first_parameter) + writer.print(", "); + AnnotationMirror auto_annotation = Utils.getParameterAutoAnnotation(param); + Constant constant_annotation = param.getAnnotation(Constant.class); + if (constant_annotation != null) { + writer.print(constant_annotation.value()); + } else if (auto_annotation != null && mode == Mode.NORMAL) { + Class param_type = NativeTypeTranslator.getClassFromType(auto_annotation.getAnnotationType()); + if (AutoType.class.equals(param_type)) { + AutoType auto_type_annotation = param.getAnnotation(AutoType.class); + String auto_parameter_name = auto_type_annotation.value(); + ParameterDeclaration auto_parameter = Utils.findParameter(method, auto_parameter_name); + String auto_type = typeinfos_instance.get(auto_parameter).getAutoType(); + if (auto_type == null) + throw new RuntimeException("No auto type for parameter " + param.getSimpleName() + " in method " + method); + writer.print(auto_type); + } else if (AutoSize.class.equals(param_type)) { + AutoSize auto_type_annotation = param.getAnnotation(AutoSize.class); + String auto_parameter_name = auto_type_annotation.value(); + ParameterDeclaration auto_target_param = Utils.findParameter(method, auto_parameter_name); + TypeInfo auto_target_type_info = typeinfos_instance.get(auto_target_param); + writer.print("(" + auto_parameter_name + ".remaining()"); + // Shift the remaining if the target parameter is multityped and there's no AutoType to track type + boolean shift_remaining = !hasAnyParameterAutoTypeAnnotation(method, auto_target_param) && Utils.isParameterMultiTyped(auto_target_param); + if (shift_remaining) { + int shifting = getBufferElementSizeExponent(auto_target_type_info.getType()); + if (shifting > 0) + writer.print(" << " + shifting); + } + writer.print(")"); + writer.print(auto_type_annotation.expression()); + } else + throw new RuntimeException("Unknown auto annotation " + param_type); + } else { + if (mode == Mode.BUFFEROBJECT && param.getAnnotation(BufferObject.class) != null) { + writer.print(param.getSimpleName() + Utils.BUFFER_OBJECT_PARAMETER_POSTFIX); + } else { + Class type = typeinfos_instance.get(param).getType(); + boolean hide_buffer = mode == Mode.AUTOS && getAutoTypeParameter(method, param) != null; + if (hide_buffer) + writer.print("null"); + else { + if ( type == CharSequence.class || type == CharSequence[].class ) { + final String offset = Utils.getStringOffset(method, param); + + writer.print("APIUtils.getBuffer"); + if ( param.getAnnotation(NullTerminated.class) != null ) + writer.print("NT"); + writer.print("(" + param.getSimpleName()); + if ( offset != null ) + writer.print(", " + offset); + writer.print(")"); + hide_buffer = true; + } else + writer.print(param.getSimpleName()); + } + Class buffer_type = Utils.getNIOBufferType(param.getType()); + if (buffer_type != null) { + writer.print(", "); + if (!hide_buffer) { + TypeInfo type_info = typeinfos_instance.get(param); + Check check_annotation = param.getAnnotation(Check.class); + int shifting; + if (Utils.getNIOBufferType(param.getType()).equals(Buffer.class)) + shifting = getBufferElementSizeExponent(type_info.getType()); + else + shifting = 0; + writer.print(param.getSimpleName()); + if (check_annotation != null && check_annotation.canBeNull()) + writer.print(" != null ? " + param.getSimpleName()); + writer.print(".position()"); + if (shifting > 0) + writer.print(" << " + shifting); + if (check_annotation != null && check_annotation.canBeNull()) + writer.print(" : 0"); + } else if ( type == CharSequence.class || type == CharSequence[].class ) { + final String offset = Utils.getStringOffset(method, param); + writer.print(offset == null ? "0" : offset); + } else + writer.print("0"); + } else if ( param.getAnnotation(GLpointer.class) != null ) { + writer.print(".getPointer()"); + } + } + } + return false; + } + + private static boolean printMethodCallArguments(PrintWriter writer, MethodDeclaration method, Map typeinfos_instance, Mode mode) { + boolean first_parameter = true; + for (ParameterDeclaration param : method.getParameters()) + if (param.getAnnotation(Result.class) == null) { + first_parameter = printMethodCallArgument(writer, method, param, typeinfos_instance, mode, first_parameter); + } + if (Utils.getNIOBufferType(Utils.getMethodReturnType(method)) != null) { + if (method.getAnnotation(CachedResult.class) != null && method.getAnnotation(CachedResult.class).isRange()) { + first_parameter = false; + Utils.printExtraCallArguments(writer, method, ""); + } else { + if (!first_parameter) + writer.print(", "); + first_parameter = false; + + String result_size_expression; + if ( mode == Mode.CACHEDRESULT ) + result_size_expression = Utils.CACHED_BUFFER_LENGTH_NAME; + else { + AutoResultSize auto_result_size_annotation = method.getAnnotation(AutoResultSize.class); + if (auto_result_size_annotation == null) + result_size_expression = Utils.RESULT_SIZE_NAME; + else + result_size_expression = auto_result_size_annotation.value(); + } + Utils.printExtraCallArguments(writer, method, result_size_expression); + } + } + return first_parameter; + } + + private static void printParameterCaching(PrintWriter writer, InterfaceDeclaration interface_decl, MethodDeclaration method, Mode mode) { + for (ParameterDeclaration param : method.getParameters()) { + Class java_type = Utils.getJavaType(param.getType()); + CachedReference cachedReference = param.getAnnotation(CachedReference.class); + if (Buffer.class.isAssignableFrom(java_type) && + cachedReference != null && + (mode != Mode.BUFFEROBJECT || param.getAnnotation(BufferObject.class) == null) && + param.getAnnotation(Result.class) == null) { + writer.print("\t\t" + Utils.CHECKS_CLASS_NAME + ".getReferences(caps)."); + if(cachedReference.name().length() > 0) { + writer.print(cachedReference.name()); + } else { + writer.print(Utils.getReferenceName(interface_decl, method, param)); + } + if(cachedReference.index().length() > 0) { + writer.print("[" + cachedReference.index() + "]"); + } + writer.println(" = " + param.getSimpleName() + ";"); + } + } + } + + private static void printNondirectParameterCopies(PrintWriter writer, MethodDeclaration method, Mode mode) { + for (ParameterDeclaration param : method.getParameters()) { + Class java_type = Utils.getJavaType(param.getType()); + if (Utils.isAddressableType(java_type) && + (mode != Mode.BUFFEROBJECT || param.getAnnotation(BufferObject.class) == null) && + (mode != Mode.AUTOS || getAutoTypeParameter(method, param) == null) && + param.getAnnotation(Result.class) == null) { + if (Buffer.class.isAssignableFrom(java_type)) { + boolean out_parameter = param.getAnnotation(OutParameter.class) != null; + if (out_parameter) + writer.println("\t\tNondirectBufferWrapper.copy(" + param.getSimpleName() + ", " + param.getSimpleName() + SAVED_PARAMETER_POSTFIX + ");"); + } + } + } + } + + private static void printParameterChecks(PrintWriter writer, MethodDeclaration method, Map typeinfos, Mode mode) { + for (ParameterDeclaration param : method.getParameters()) { + Class java_type = Utils.getJavaType(param.getType()); + if (Utils.isAddressableType(java_type) && + (mode != Mode.BUFFEROBJECT || param.getAnnotation(BufferObject.class) == null) && + (mode != Mode.AUTOS || getAutoTypeParameter(method, param) == null) && + param.getAnnotation(Result.class) == null && + !Utils.isReturnParameter(method, param) ) { + String check_value = null; + boolean can_be_null = false; + Check check_annotation = param.getAnnotation(Check.class); + if (check_annotation != null) { + check_value = check_annotation.value(); + can_be_null = check_annotation.canBeNull(); + } + NullTerminated null_terminated = param.getAnnotation(NullTerminated.class); + 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); + printParameterCheck(writer, param.getSimpleName(), typeinfo.getType().getSimpleName(), check_value, can_be_null, null_terminated, indirect_buffer_allowed, out_parameter); + } else if ( String.class.equals(java_type)) { + if (!can_be_null) + writer.println("\t\tBufferChecks.checkNotNull(" + param.getSimpleName() + ");"); + } + } + } + if (method.getAnnotation(CachedResult.class) != null) + printParameterCheck(writer, Utils.CACHED_BUFFER_NAME, null, null, true, null, false, false); + } + + private static void printParameterCheck(PrintWriter writer, String name, String type, String check_value, boolean can_be_null, NullTerminated null_terminated, boolean indirect_buffer_allowed, boolean out_parameter) { + if (indirect_buffer_allowed && out_parameter) { + writer.println("\t\t" + type + " " + name + SAVED_PARAMETER_POSTFIX + " = " + name + ";"); + } + if (can_be_null) { + writer.println("\t\tif (" + name + " != null)"); + writer.print("\t"); + } + if (indirect_buffer_allowed) { + writer.print("\t\t" + name + " = NondirectBufferWrapper.wrap"); + if (out_parameter) + writer.print("NoCopy"); + } else + writer.print("\t\tBufferChecks.check"); + if (check_value != null && !"".equals(check_value) ) { + writer.print("Buffer(" + name + ", " + check_value); + } else { + writer.print("Direct(" + name); + } + writer.println(");"); + if (null_terminated != null) { + writer.print("\t\tBufferChecks.checkNullTerminated("); + writer.print(name); + if ( null_terminated.value().length() > 0 ) { + writer.print(", "); + writer.print(null_terminated.value()); + } + writer.println(");"); + } + } + + private static void printResultType(PrintWriter writer, MethodDeclaration method, boolean native_stub) { + if ( native_stub && method.getAnnotation(GLpointer.class) != null ) + writer.print("long"); + else if ( !native_stub && method.getAnnotation(GLreturn.class) != null ) + writer.print(Utils.getMethodReturnType(method, method.getAnnotation(GLreturn.class), false)); + else + writer.print(Utils.getMethodReturnType(method).toString()); + } +} diff --git a/src/java/org/lwjgl/util/generator/JavaTypeTranslator.java b/src/java/org/lwjgl/util/generator/JavaTypeTranslator.java new file mode 100644 index 0000000..9d11a72 --- /dev/null +++ b/src/java/org/lwjgl/util/generator/JavaTypeTranslator.java @@ -0,0 +1,125 @@ +/* + * 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 com.sun.mirror.type.*; +import com.sun.mirror.util.*; + +/** + * + * A TypeVisitor that translates (annotated) TypeMirrors to + * java types (represented by a Class) + * + * @author elias_naur + * @version $Revision: 3287 $ + * $Id: JavaTypeTranslator.java 3287 2010-03-14 23:24:40Z spasi $ + */ +public class JavaTypeTranslator implements TypeVisitor { + private Class type; + + public Class getType() { + return type; + } + + public void visitAnnotationType(AnnotationType t) { + throw new RuntimeException(t + " is not allowed"); + } + + public void visitArrayType(ArrayType t) { + if ( "java.lang.CharSequence".equals(t.getComponentType().toString()) ) + type = CharSequence[].class; + else + throw new RuntimeException(t + " is not allowed"); + } + + public static Class getPrimitiveClassFromKind(PrimitiveType.Kind kind) { + switch ( kind ) { + case LONG: + return long.class; + case INT: + return int.class; + case DOUBLE: + return double.class; + case FLOAT: + return float.class; + case SHORT: + return short.class; + case BYTE: + return byte.class; + case BOOLEAN: + return boolean.class; + default: + throw new RuntimeException(kind + " is not allowed"); + } + } + + public void visitPrimitiveType(PrimitiveType t) { + type = getPrimitiveClassFromKind(t.getKind()); + } + + public void visitDeclaredType(DeclaredType t) { + throw new RuntimeException(t + " is not allowed"); + } + + public void visitEnumType(EnumType t) { + throw new RuntimeException(t + " is not allowed"); + } + + public void visitClassType(ClassType t) { + type = NativeTypeTranslator.getClassFromType(t); + } + + public void visitInterfaceType(InterfaceType t) { + type = NativeTypeTranslator.getClassFromType(t); + } + + public void visitReferenceType(ReferenceType t) { + throw new RuntimeException(t + " is not allowed"); + } + + public void visitTypeMirror(TypeMirror t) { + throw new RuntimeException(t + " is not allowed"); + } + + public void visitTypeVariable(TypeVariable t) { + throw new RuntimeException(t + " is not allowed"); + } + + public void visitVoidType(VoidType t) { + type = void.class; + } + + public void visitWildcardType(WildcardType t) { + throw new RuntimeException(t + " is not allowed"); + } +} diff --git a/src/java/org/lwjgl/util/generator/Mode.java b/src/java/org/lwjgl/util/generator/Mode.java new file mode 100644 index 0000000..ffb6aa9 --- /dev/null +++ b/src/java/org/lwjgl/util/generator/Mode.java @@ -0,0 +1,39 @@ +/* + * 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; + +public enum Mode { + BUFFEROBJECT, + AUTOS, + CACHEDRESULT, // Used for generating a CachedResult method with an explicit length argument. + NORMAL +} diff --git a/src/java/org/lwjgl/util/generator/NativeMethodStubsGenerator.java b/src/java/org/lwjgl/util/generator/NativeMethodStubsGenerator.java new file mode 100644 index 0000000..10aa467 --- /dev/null +++ b/src/java/org/lwjgl/util/generator/NativeMethodStubsGenerator.java @@ -0,0 +1,314 @@ +/* + * 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; + +/** + * + * This class generates the functions in the native source files. + * + * @author elias_naur + * @version $Revision: 3289 $ + * $Id: NativeMethodStubsGenerator.java 3289 2010-03-16 19:05:19Z spasi $ + */ + +import com.sun.mirror.apt.*; +import com.sun.mirror.declaration.*; +import com.sun.mirror.type.*; + +import java.io.*; +import java.util.*; +import java.nio.*; + +public class NativeMethodStubsGenerator { + private static final String BUFFER_ADDRESS_POSTFIX = "_address"; + public static final String BUFFER_POSITION_POSTFIX = "_position"; + private static final String STRING_LIST_POSTFIX = "_str"; + + public static void generateNativeMethodStubs(AnnotationProcessorEnvironment env, TypeMap type_map, PrintWriter writer, InterfaceDeclaration d, boolean generate_error_checks, boolean context_specific) { + for (MethodDeclaration method : d.getMethods()) { + Alternate alt_annotation = method.getAnnotation(Alternate.class); + if ( alt_annotation != null && !alt_annotation.nativeAlt() ) + continue; + generateMethodStub(env, type_map, writer, Utils.getQualifiedClassName(d), method, Mode.NORMAL, generate_error_checks, context_specific); + if (Utils.hasMethodBufferObjectParameter(method)) + generateMethodStub(env, type_map, writer, Utils.getQualifiedClassName(d), method, Mode.BUFFEROBJECT, generate_error_checks, context_specific); + } + } + + private static void generateParameters(PrintWriter writer, Collection params, Mode mode) { + for (ParameterDeclaration param : params) + if (param.getAnnotation(Result.class) == null) + generateParameter(writer, param, mode); + } + + private static void generateParameter(PrintWriter writer, ParameterDeclaration param, Mode mode) { + writer.print(", "); + if (mode == Mode.BUFFEROBJECT && param.getAnnotation(BufferObject.class) != null) { + writer.print("jlong " + param.getSimpleName() + Utils.BUFFER_OBJECT_PARAMETER_POSTFIX); + } else if ( param.getAnnotation(GLpointer.class) != null ) { + writer.print("jlong " + param.getSimpleName()); + } else { + JNITypeTranslator translator = new JNITypeTranslator(); + param.getType().accept(translator); + writer.print(translator.getSignature() + " " + param.getSimpleName()); + if (Utils.getNIOBufferType(param.getType()) != null) + writer.print(", jint " + param.getSimpleName() + BUFFER_POSITION_POSTFIX); + } + } + + private static void generateMethodStub(AnnotationProcessorEnvironment env, TypeMap type_map, PrintWriter writer, String interface_name, MethodDeclaration method, Mode mode, boolean generate_error_checks, boolean context_specific) { + if ( !context_specific && method.getAnnotation(Alternate.class) == null ) + writer.print("static "); + else + writer.print("JNIEXPORT "); + + TypeMirror result_type = Utils.getMethodReturnType(method); + + if ( method.getAnnotation(GLpointer.class) != null ) { + writer.print("jlong"); + } else { + JNITypeTranslator translator = new JNITypeTranslator(); + result_type.accept(translator); + writer.print(translator.getSignature()); + } + writer.print(" JNICALL "); + + writer.print(Utils.getQualifiedNativeMethodName(interface_name, method, generate_error_checks, context_specific)); + if (mode == Mode.BUFFEROBJECT) + writer.print(Utils.BUFFER_OBJECT_METHOD_POSTFIX); + writer.print("(JNIEnv *env, jclass clazz"); + generateParameters(writer, method.getParameters(), mode); + if (Utils.getNIOBufferType(result_type) != null) { + CachedResult cached_result_annotation = method.getAnnotation(CachedResult.class); + if (cached_result_annotation == null || !cached_result_annotation.isRange()) + writer.print(", jlong " + Utils.RESULT_SIZE_NAME); + if (cached_result_annotation != null) + writer.print(", jobject " + Utils.CACHED_BUFFER_NAME); + } + if (context_specific) { + writer.print(", jlong " + Utils.FUNCTION_POINTER_VAR_NAME); + } + writer.println(") {"); + generateBufferParameterAddresses(type_map, writer, method, mode); + Alternate alt_annotation = method.getAnnotation(Alternate.class); + if (context_specific) { + String typedef_name = Utils.getTypedefName(method); + writer.print("\t" + typedef_name + " " + (alt_annotation == null ? method.getSimpleName() : alt_annotation.value())); + writer.print(" = (" + typedef_name + ")((intptr_t)"); + writer.println(Utils.FUNCTION_POINTER_VAR_NAME + ");"); + } + generateStringListInits(writer, method.getParameters()); + writer.print("\t"); + if (!result_type.equals(env.getTypeUtils().getVoidType())) { + Declaration return_declaration; + ParameterDeclaration result_param = Utils.getResultParameter(method); + if (result_param != null) + return_declaration = result_param; + else + return_declaration = method; + NativeTypeTranslator native_translator = new NativeTypeTranslator(type_map, return_declaration); + result_type.accept(native_translator); + writer.print(native_translator.getSignature() + " " + Utils.RESULT_VAR_NAME); + if (result_param != null) { + writer.println(";"); + writer.print("\t"); + } else + writer.print(" = "); + } + writer.print((alt_annotation == null ? method.getSimpleName() : alt_annotation.value()) + "("); + generateCallParameters(writer, type_map, method.getParameters()); + writer.print(")"); + writer.println(";"); + generateStringDeallocations(writer, method.getParameters()); + if (!result_type.equals(env.getTypeUtils().getVoidType())) { + writer.print("\treturn "); + Class java_result_type = Utils.getJavaType(result_type); + if (Buffer.class.isAssignableFrom(java_result_type)) { + if (method.getAnnotation(CachedResult.class) != null) + writer.print("safeNewBufferCached(env, "); + else + writer.print("safeNewBuffer(env, "); + } else if (String.class.equals(java_result_type)) { + writer.print("NewStringNativeUnsigned(env, "); + } else if ( method.getAnnotation(GLpointer.class) != null ) { + writer.print("(intptr_t)"); + } + writer.print(Utils.RESULT_VAR_NAME); + if (Buffer.class.isAssignableFrom(java_result_type)) { + writer.print(", "); + if (method.getAnnotation(CachedResult.class) != null && method.getAnnotation(CachedResult.class).isRange()) + Utils.printExtraCallArguments(writer, method, method.getAnnotation(AutoResultSize.class).value()); + else + Utils.printExtraCallArguments(writer, method, Utils.RESULT_SIZE_NAME); + } + if (Buffer.class.isAssignableFrom(java_result_type) || + String.class.equals(java_result_type)) + writer.print(")"); + writer.println(";"); + } + writer.println("}"); + writer.println(); + } + + private static void generateCallParameters(PrintWriter writer, TypeMap type_map, Collection params) { + if (params.size() > 0) { + Iterator it = params.iterator(); + generateCallParameter(writer, type_map, it.next()); + while (it.hasNext()) { + writer.print(", "); + generateCallParameter(writer, type_map, it.next()); + } + } + } + + private static void generateCallParameter(PrintWriter writer, TypeMap type_map, ParameterDeclaration param) { + boolean is_indirect = param.getAnnotation(Indirect.class) != null; + if (is_indirect || param.getAnnotation(StringList.class) != null) { + writer.print("("); + NativeTypeTranslator translator = new NativeTypeTranslator(type_map, param); + param.getType().accept(translator); + writer.print(translator.getSignature()); + writer.print("*)"); + } + if ( param.getAnnotation(GLpointer.class) != null ) + writer.print("(" + param.getAnnotation(GLpointer.class).value() + ")(intptr_t)"); + if (param.getAnnotation(Result.class) != null || is_indirect) + writer.print("&"); + if (param.getAnnotation(Result.class) != null) { + writer.print(Utils.RESULT_VAR_NAME); + } else { + writer.print(param.getSimpleName()); + if ( param.getAnnotation(StringList.class) != null ) + writer.print(STRING_LIST_POSTFIX); + else if (Utils.isAddressableType(param.getType())) + writer.print(BUFFER_ADDRESS_POSTFIX); + } + } + + private static void generateStringDeallocations(PrintWriter writer, Collection params) { + for (ParameterDeclaration param : params) { + if (Utils.getJavaType(param.getType()).equals(String.class) && + param.getAnnotation(Result.class) == null) + writer.println("\tfree(" + param.getSimpleName() + BUFFER_ADDRESS_POSTFIX + ");"); + else if (param.getAnnotation(StringList.class) != null ) // Free the string array mem + writer.println("\tfree(" + param.getSimpleName() + STRING_LIST_POSTFIX + ");"); + } + } + + private static void generateBufferParameterAddresses(TypeMap type_map, PrintWriter writer, MethodDeclaration method, Mode mode) { + boolean loopDeclared = false; + for (ParameterDeclaration param : method.getParameters()) + if (Utils.isAddressableType(param.getType()) && param.getAnnotation(Result.class) == null) + loopDeclared = generateBufferParameterAddress(type_map, writer, method, param, mode, loopDeclared); + } + + private static boolean generateBufferParameterAddress(TypeMap type_map, PrintWriter writer, MethodDeclaration method, ParameterDeclaration param, Mode mode, boolean loopDeclared) { + NativeTypeTranslator translator = new NativeTypeTranslator(type_map, param); + param.getType().accept(translator); + writer.print("\t" + translator.getSignature() + param.getSimpleName()); + writer.print(BUFFER_ADDRESS_POSTFIX + " = (("); + writer.print(translator.getSignature()); + Check check_annotation = param.getAnnotation(Check.class); + writer.print(")"); + if (mode == Mode.BUFFEROBJECT && param.getAnnotation(BufferObject.class) != null) { + writer.print("offsetToPointer(" + param.getSimpleName() + Utils.BUFFER_OBJECT_PARAMETER_POSTFIX + "))"); + } else { + Class java_type = Utils.getJavaType(param.getType()); + if (Buffer.class.isAssignableFrom(java_type) || java_type.equals(CharSequence.class) || java_type.equals(CharSequence[].class)) { + boolean explicitly_byte_sized = java_type.equals(Buffer.class) || + translator.getAnnotationType().equals(type_map.getVoidType()); + if (explicitly_byte_sized) + writer.print("(((char *)"); + if (method.getAnnotation(GenerateAutos.class) != null || (check_annotation != null && check_annotation.canBeNull())) { + writer.print("safeGetBufferAddress(env, " + param.getSimpleName()); + } else { + writer.print("(*env)->GetDirectBufferAddress(env, " + param.getSimpleName()); + } + writer.print("))"); + writer.print(" + " + param.getSimpleName() + BUFFER_POSITION_POSTFIX); + if (explicitly_byte_sized) + writer.print("))"); + } else if (java_type.equals(String.class)) { + writer.print("GetStringNativeChars(env, " + param.getSimpleName() + "))"); + } else + throw new RuntimeException("Illegal type " + java_type); + } + writer.println(";"); + + if ( param.getAnnotation(StringList.class) != null ) { + if ( Utils.getJavaType(param.getType()) != CharSequence[].class && ( + param.getAnnotation(GLchar.class) == null || + param.getAnnotation(NullTerminated.class) == null || + param.getAnnotation(NullTerminated.class).value().length() == 0 + ) + ) + throw new RuntimeException("StringList annotation can only be applied on null-terminated GLchar buffers."); + + if ( "_str".equals(param.getSimpleName()) ) + throw new RuntimeException("The name '_str' is not valid for arguments annotated with StringList"); + + // Declare loop counters and allocate string array + if ( !loopDeclared ) { + writer.println("\tunsigned int _str_i;"); + writer.println("\tGLchar *_str_address;"); + loopDeclared = true; + } + writer.println("\tGLchar **" + param.getSimpleName() + STRING_LIST_POSTFIX + " = (GLchar **) malloc(" + param.getAnnotation(StringList.class).value() + "*sizeof(GLchar*));"); + } + return loopDeclared; + } + + private static void generateStringListInits(PrintWriter writer, Collection params) { + for ( ParameterDeclaration param : params ) { + StringList stringList_annotation = param.getAnnotation(StringList.class); + if ( stringList_annotation != null ) { + String lengths = stringList_annotation.lengths(); + + // Init vars + writer.println("\t_str_i = 0;"); + writer.println("\t_str_address = (GLchar *)" + param.getSimpleName() + BUFFER_ADDRESS_POSTFIX + ";"); + // Fill string array with the string pointers + writer.println("\twhile ( _str_i < " + stringList_annotation.value() + " ) {"); + if ( lengths.length() == 0 ) { + writer.println("\t\t" + param.getSimpleName() + STRING_LIST_POSTFIX + "[_str_i++] = _str_address;"); + writer.println("\t\t_str_address += strlen(_str_address) + 1;"); + } else { + writer.println("\t\t" + param.getSimpleName() + STRING_LIST_POSTFIX + "[_str_i] = _str_address;"); + writer.println("\t\t_str_address += " + lengths + BUFFER_ADDRESS_POSTFIX + "[_str_i++];"); + } + writer.println("\t}"); + } + } + } + +} diff --git a/src/java/org/lwjgl/util/generator/NativeType.java b/src/java/org/lwjgl/util/generator/NativeType.java new file mode 100644 index 0000000..f9a8207 --- /dev/null +++ b/src/java/org/lwjgl/util/generator/NativeType.java @@ -0,0 +1,49 @@ +/* + * 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; + +/** + * + * This annotation indicates that another annotation is + * a native type. + * + * @author elias_naur + * @version $Revision: 2983 $ + * $Id: NativeType.java 2983 2008-04-07 18:36:09Z matzon $ + */ + +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +@Target(ElementType.ANNOTATION_TYPE) +public @interface NativeType { +} diff --git a/src/java/org/lwjgl/util/generator/NativeTypeTranslator.java b/src/java/org/lwjgl/util/generator/NativeTypeTranslator.java new file mode 100644 index 0000000..941cfb4 --- /dev/null +++ b/src/java/org/lwjgl/util/generator/NativeTypeTranslator.java @@ -0,0 +1,229 @@ +/* + * 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; + +/** + * + * A TypeVisitor that translates types (and optional native type + * annotations) to the native type string. + * + * @author elias_naur + * @version $Revision: 3281 $ + * $Id: NativeTypeTranslator.java 3281 2010-03-12 21:55:13Z spasi $ + */ + +import org.lwjgl.opengl.PointerWrapper; + +import com.sun.mirror.declaration.*; +import com.sun.mirror.type.*; +import com.sun.mirror.util.*; + +import java.util.Collection; +import java.util.ArrayList; + +import java.nio.*; + +import java.lang.annotation.Annotation; + +/** + * $Id: NativeTypeTranslator.java 3281 2010-03-12 21:55:13Z spasi $ + * + * A TypeVisitor that translates (annotated) TypeMirrors to + * native types + * + * @author elias_naur + * @version $Revision: 3281 $ + */ +public class NativeTypeTranslator implements TypeVisitor { + private Collection native_types; + private boolean is_indirect; + private final Declaration declaration; + private final TypeMap type_map; + + public NativeTypeTranslator(TypeMap type_map, Declaration declaration) { + this.declaration = declaration; + this.type_map = type_map; + } + + public String getSignature() { + StringBuilder signature = new StringBuilder(); + if (declaration.getAnnotation(Const.class) != null) + signature.append("const "); + + if ( declaration.getAnnotation(GLpointer.class) != null ) { + signature.append(declaration.getAnnotation(GLpointer.class).value()); + } else { + // Use the name of the native type annotation as the C type name + signature.append(getAnnotationType().getSimpleName()); + } + + if (is_indirect) + signature.append(" *"); + return signature.toString(); + } + + public Class getAnnotationType() { + if (native_types.size() != 1) + throw new RuntimeException("Expected only one native type for declaration " + declaration + + ", but got " + native_types.size()); + return native_types.iterator().next(); + } + + public void visitAnnotationType(AnnotationType t) { + throw new RuntimeException(t + " is not allowed"); + } + + public void visitArrayType(ArrayType t) { + if ( "java.lang.CharSequence".equals(t.getComponentType().toString()) ) { + is_indirect = true; + native_types = new ArrayList(); + native_types.add(GLchar.class); + } else + throw new RuntimeException(t + " is not allowed"); + } + + public static PrimitiveType.Kind getPrimitiveKindFromBufferClass(Class c) { + if (IntBuffer.class.equals(c)) + return PrimitiveType.Kind.INT; + else if (DoubleBuffer.class.equals(c)) + return PrimitiveType.Kind.DOUBLE; + else if (ShortBuffer.class.equals(c)) + return PrimitiveType.Kind.SHORT; + else if (ByteBuffer.class.equals(c)) + 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"); + } + + public static Class getClassFromType(DeclaredType t) { + try { + return Class.forName(t.getDeclaration().getQualifiedName()); + } catch (ClassNotFoundException e) { + throw new RuntimeException(e); + } + } + + private void getNativeTypeFromAnnotatedPrimitiveType(PrimitiveType.Kind kind) { + native_types = translateAnnotations(); + if (native_types.size() == 0) + native_types.add(type_map.getNativeTypeFromPrimitiveType(kind)); + } + + public void visitClassType(ClassType t) { + is_indirect = true; + + Class c = getClassFromType(t); + if (String.class.equals(c)) { + native_types = new ArrayList(); + native_types.add(type_map.getStringElementType()); + } else if (Buffer.class.equals(c)) { + native_types = new ArrayList(); + native_types.add(type_map.getVoidType()); + } else if (Buffer.class.isAssignableFrom(c)) { + PrimitiveType.Kind kind = getPrimitiveKindFromBufferClass(c); + getNativeTypeFromAnnotatedPrimitiveType(kind); + } else if ( PointerWrapper.class.isAssignableFrom(c) ) { + native_types = new ArrayList(); + native_types.add(GLpointer.class); + + is_indirect = false; + } else + throw new RuntimeException(t + " is not allowed"); + } + + public void visitPrimitiveType(PrimitiveType t) { + getNativeTypeFromAnnotatedPrimitiveType(t.getKind()); + } + + public void visitDeclaredType(DeclaredType t) { + throw new RuntimeException(t + " is not allowed"); + } + + public void visitEnumType(EnumType t) { + throw new RuntimeException(t + " is not allowed"); + } + + public void visitInterfaceType(InterfaceType t) { + throw new RuntimeException(t + " is not allowed"); + } + + // Check if the annotation is itself annotated with a certain annotation type + public static T getAnnotation(AnnotationMirror annotation, Class type) { + return annotation.getAnnotationType().getDeclaration().getAnnotation(type); + } + + private static Class translateAnnotation(AnnotationMirror annotation) { + NativeType native_type = getAnnotation(annotation, NativeType.class); + if (native_type != null) { + return getClassFromType(annotation.getAnnotationType()); + } else + return null; + } + + private Collection translateAnnotations() { + Collection result = new ArrayList(); + for (AnnotationMirror annotation : Utils.getSortedAnnotations(declaration.getAnnotationMirrors())) { + Class translated_result = translateAnnotation(annotation); + if (translated_result != null) { + result.add(translated_result); + } + } + return result; + } + + public void visitReferenceType(ReferenceType t) { + throw new RuntimeException(t + " is not allowed"); + } + + public void visitTypeMirror(TypeMirror t) { + throw new RuntimeException(t + " is not allowed"); + } + + public void visitTypeVariable(TypeVariable t) { + throw new RuntimeException(t + " is not allowed"); + } + + public void visitVoidType(VoidType t) { + native_types = translateAnnotations(); + if (native_types.size() == 0) + native_types.add(void.class); + } + + public void visitWildcardType(WildcardType t) { + throw new RuntimeException(t + " is not allowed"); + } +} diff --git a/src/java/org/lwjgl/util/generator/NoErrorCheck.java b/src/java/org/lwjgl/util/generator/NoErrorCheck.java new file mode 100644 index 0000000..7e10c7f --- /dev/null +++ b/src/java/org/lwjgl/util/generator/NoErrorCheck.java @@ -0,0 +1,49 @@ +/* + * 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; + +/** + * + * This annotation implies that a method should not include + * error checking even if it is enabled. + * + * @author elias_naur + * @version $Revision: 2983 $ + * $Id: NoErrorCheck.java 2983 2008-04-07 18:36:09Z matzon $ + */ + +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +@Target(ElementType.METHOD) +public @interface NoErrorCheck { +} diff --git a/src/java/org/lwjgl/util/generator/NullTerminated.java b/src/java/org/lwjgl/util/generator/NullTerminated.java new file mode 100644 index 0000000..ff0a2dd --- /dev/null +++ b/src/java/org/lwjgl/util/generator/NullTerminated.java @@ -0,0 +1,50 @@ +/* + * 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; + +/** + * + * This annotation implies that a Buffer argument should be + * checked for a trailing '\0' + * + * @author elias_naur + * @version $Revision: 3260 $ + * $Id: NullTerminated.java 3260 2009-12-04 04:49:19Z spasi $ + */ + +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +@Target(ElementType.PARAMETER) +public @interface NullTerminated { + String value() default ""; +} diff --git a/src/java/org/lwjgl/util/generator/Optional.java b/src/java/org/lwjgl/util/generator/Optional.java new file mode 100644 index 0000000..60f1063 --- /dev/null +++ b/src/java/org/lwjgl/util/generator/Optional.java @@ -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; + +/** + * A function annotated with @Optional will allow the extension to be available even if the driver does not expose that function. + * This is useful when certain buggy drivers miss some functionality. + * + * @author spasi + */ + +import java.lang.annotation.ElementType; +import java.lang.annotation.Target; + +@Target(ElementType.METHOD) +public @interface Optional { + String reason(); // No default value to force documentation +} \ No newline at end of file diff --git a/src/java/org/lwjgl/util/generator/OutParameter.java b/src/java/org/lwjgl/util/generator/OutParameter.java new file mode 100644 index 0000000..c23c6ee --- /dev/null +++ b/src/java/org/lwjgl/util/generator/OutParameter.java @@ -0,0 +1,48 @@ +/* + * 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; + +/** + * This annotation indicates that a parameter is written, + * not read. + * + * @author elias_naur + * @version $Revision: 2286 $ + * $Id: Check.java 2286 2006-03-23 19:32:21Z matzon $ + */ + +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +@Target(ElementType.PARAMETER) +public @interface OutParameter { +} diff --git a/src/java/org/lwjgl/util/generator/Platform.java b/src/java/org/lwjgl/util/generator/Platform.java new file mode 100644 index 0000000..106a1c4 --- /dev/null +++ b/src/java/org/lwjgl/util/generator/Platform.java @@ -0,0 +1,93 @@ +/* + * 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; + +/** + * + * @author elias_naur + * @version $Revision: 2983 $ + * $Id: Platform.java 2983 2008-04-07 18:36:09Z matzon $ + */ + +import java.io.PrintWriter; + +public enum Platform { + WGL, + GLX, + ALL; + + public void printPrologue(PrintWriter writer) { + if (this == ALL) + return; + writer.print("#ifdef "); + switch (this) { + case WGL: + writer.println("_WIN32"); + break; + case GLX: + writer.println("_X11"); + break; + default: + throw new RuntimeException(this + " is not supported"); + } + } + + public void printEpilogue(PrintWriter writer) { + if (this == ALL) + return; + writer.println("#endif"); + } + + public String getOSPrefix() { + switch (this) { + case WGL: + return "Windows"; + case GLX: + return "Linux"; + default: + throw new RuntimeException(this + " has no OS specific prefix"); + } + } + + public String getPrefix() { + switch (this) { + case WGL: + return "wgl"; + case GLX: + return "glX"; + case ALL: + return "gl"; + default: + throw new RuntimeException(this + " is not supported"); + } + } +} diff --git a/src/java/org/lwjgl/util/generator/PlatformDependent.java b/src/java/org/lwjgl/util/generator/PlatformDependent.java new file mode 100644 index 0000000..f6fe1ab --- /dev/null +++ b/src/java/org/lwjgl/util/generator/PlatformDependent.java @@ -0,0 +1,51 @@ +/* + * 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; + +/** + * + * This annotation implies that the corresponding native + * function symbol is named after the platform specific + * window system (glX, wgl, ...) + * + * @author elias_naur + * @version $Revision: 2983 $ + * $Id: PlatformDependent.java 2983 2008-04-07 18:36:09Z matzon $ + */ + +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +@Target(ElementType.METHOD) +public @interface PlatformDependent { + Platform[] value(); +} diff --git a/src/java/org/lwjgl/util/generator/PostfixTranslator.java b/src/java/org/lwjgl/util/generator/PostfixTranslator.java new file mode 100644 index 0000000..0a4a08a --- /dev/null +++ b/src/java/org/lwjgl/util/generator/PostfixTranslator.java @@ -0,0 +1,182 @@ +/* + * 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; + +/** + * + * A TypeVisitor that translates (annotated) TypeMirrors to + * postfixes. + * + * @author elias_naur + * @version $Revision: 3287 $ + * $Id: PostfixTranslator.java 3287 2010-03-14 23:24:40Z spasi $ + */ + +import com.sun.mirror.declaration.*; +import com.sun.mirror.type.*; +import com.sun.mirror.util.*; + +import java.nio.*; + +public class PostfixTranslator implements TypeVisitor { + private final StringBuilder signature = new StringBuilder(); + private final Declaration declaration; + private final TypeMap type_map; + + public PostfixTranslator(TypeMap type_map, Declaration declaration) { + this.declaration = declaration; + this.type_map = type_map; + } + + public String getSignature() { + return signature.toString(); + } + + public void visitAnnotationType(AnnotationType t) { + throw new RuntimeException(t + " is not allowed"); + } + + public void visitArrayType(ArrayType t) { + throw new RuntimeException(t + " is not allowed"); + } + + private static PrimitiveType.Kind getPrimitiveKindFromBufferClass(Class c) { + if (IntBuffer.class.equals(c) || int.class.equals(c) ) + return PrimitiveType.Kind.INT; + else if (DoubleBuffer.class.equals(c) || double.class.equals(c) ) + return PrimitiveType.Kind.DOUBLE; + else if (ShortBuffer.class.equals(c) || short.class.equals(c) ) + return PrimitiveType.Kind.SHORT; + else if (ByteBuffer.class.equals(c) || byte.class.equals(c) ) + return PrimitiveType.Kind.BYTE; + else if (FloatBuffer.class.equals(c) || float.class.equals(c)) + return PrimitiveType.Kind.FLOAT; + else if (LongBuffer.class.equals(c) || long.class.equals(c) ) + return PrimitiveType.Kind.LONG; + else + throw new RuntimeException(c + " is not allowed"); + } + + public void visitClassType(ClassType t) { + Class c = NativeTypeTranslator.getClassFromType(t); + PrimitiveType.Kind kind = getPrimitiveKindFromBufferClass(c); + visitPrimitiveTypeKind(kind); + } + + public void visitDeclaredType(DeclaredType t) { + throw new RuntimeException(t + " is not allowed"); + } + + public void visitEnumType(EnumType t) { + throw new RuntimeException(t + " is not allowed"); + } + + public void visitInterfaceType(InterfaceType t) { + throw new RuntimeException(t + " is not allowed"); + } + + private boolean translateAnnotation(AnnotationMirror annotation) { + NativeType native_type = NativeTypeTranslator.getAnnotation(annotation, NativeType.class); + if (native_type != null) { + Class annotation_class = NativeTypeTranslator.getClassFromType(annotation.getAnnotationType()); + signature.append(type_map.translateAnnotation(annotation_class)); + return true; + } else + return false; + } + + private boolean translateAnnotations() { + boolean result = false; + for (AnnotationMirror annotation : Utils.getSortedAnnotations(declaration.getAnnotationMirrors())) + if (translateAnnotation(annotation)) { + if (result) + throw new RuntimeException("Multiple native types"); + result = true; + } + return result; + } + + public void visitPrimitiveType(PrimitiveType t) { + visitPrimitiveTypeKind(t.getKind()); + } + + private void visitPrimitiveTypeKind(PrimitiveType.Kind kind) { + boolean annotated_translation = translateAnnotations(); + if (annotated_translation) + return; + // No annotation type was specified, fall back to default + String type; + switch (kind) { + case INT: + type = "i"; + break; + case DOUBLE: + type = "d"; + break; + case FLOAT: + type = "f"; + break; + case SHORT: + type = "s"; + break; + case BYTE: + type = "b"; + break; + case LONG: + type = "i64"; + break; + default: + throw new RuntimeException(kind + " is not allowed"); + } + signature.append(type); + } + + public void visitReferenceType(ReferenceType t) { + throw new RuntimeException(t + " is not allowed"); + } + + public void visitTypeMirror(TypeMirror t) { + throw new RuntimeException(t + " is not allowed"); + } + + public void visitTypeVariable(TypeVariable t) { + throw new RuntimeException(t + " is not allowed"); + } + + public void visitVoidType(VoidType t) { + } + + public void visitWildcardType(WildcardType t) { + throw new RuntimeException(t + " is not allowed"); + } +} \ No newline at end of file diff --git a/src/java/org/lwjgl/util/generator/ReferencesGeneratorProcessorFactory.java b/src/java/org/lwjgl/util/generator/ReferencesGeneratorProcessorFactory.java new file mode 100644 index 0000000..b3c50ff --- /dev/null +++ b/src/java/org/lwjgl/util/generator/ReferencesGeneratorProcessorFactory.java @@ -0,0 +1,205 @@ +/* + * 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 static java.util.Collections.emptyList; +import static java.util.Collections.unmodifiableCollection; + +import java.io.File; +import java.io.IOException; +import java.io.PrintWriter; +import java.util.Arrays; +import java.util.Collection; +import java.util.Set; + +import com.sun.mirror.apt.AnnotationProcessor; +import com.sun.mirror.apt.AnnotationProcessorEnvironment; +import com.sun.mirror.apt.AnnotationProcessorFactory; +import com.sun.mirror.apt.AnnotationProcessors; +import com.sun.mirror.apt.Filer; +import com.sun.mirror.apt.RoundCompleteEvent; +import com.sun.mirror.apt.RoundCompleteListener; +import com.sun.mirror.declaration.AnnotationTypeDeclaration; +import com.sun.mirror.declaration.InterfaceDeclaration; +import com.sun.mirror.declaration.MethodDeclaration; +import com.sun.mirror.declaration.ParameterDeclaration; +import com.sun.mirror.declaration.TypeDeclaration; +import com.sun.mirror.util.DeclarationFilter; + +/** + * + * Generator tool for creating the References class + * + * @author elias_naur + * @version $Revision: 3237 $ + * $Id: ReferencesGeneratorProcessorFactory.java 3237 2009-09-08 15:07:15Z spasi $ + */ +public class ReferencesGeneratorProcessorFactory implements AnnotationProcessorFactory, RoundCompleteListener { + private final static String REFERENCES_CLASS_NAME = "References"; + private final static String REFERENCES_PARAMETER_NAME = "references"; + + private static boolean first_round = true; + + // Process any set of annotations + private static final Collection supportedAnnotations = + unmodifiableCollection(Arrays.asList("*")); + + public Collection supportedAnnotationTypes() { + return supportedAnnotations; + } + + public Collection supportedOptions() { + return emptyList(); + } + + public void roundComplete(RoundCompleteEvent event) { + first_round = false; + } + + public AnnotationProcessor getProcessorFor(Set atds, AnnotationProcessorEnvironment env) { + // Only process the initial types, not the generated ones + if (first_round) { + env.addListener(this); + return new GeneratorProcessor(env); + } else + return AnnotationProcessors.NO_OP; + } + + private static class GeneratorProcessor implements AnnotationProcessor { + private final AnnotationProcessorEnvironment env; + + GeneratorProcessor(AnnotationProcessorEnvironment env) { + this.env = env; + } + + public void process() { + try { + generateReferencesSource(); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + private static void generateClearsFromParameters(PrintWriter writer, InterfaceDeclaration interface_decl, MethodDeclaration method) { + for (ParameterDeclaration param : method.getParameters()) { + CachedReference cached_reference_annotation = param.getAnnotation(CachedReference.class); + if (cached_reference_annotation != null && cached_reference_annotation.name().length() == 0) { + Class nio_type = Utils.getNIOBufferType(param.getType()); + String reference_name = Utils.getReferenceName(interface_decl, method, param); + writer.println("\t\tthis." + reference_name + " = null;"); + } + } + } + + private static void generateCopiesFromParameters(PrintWriter writer, InterfaceDeclaration interface_decl, MethodDeclaration method) { + for (ParameterDeclaration param : method.getParameters()) { + CachedReference cached_reference_annotation = param.getAnnotation(CachedReference.class); + if (cached_reference_annotation != null && cached_reference_annotation.name().length() == 0) { + Class nio_type = Utils.getNIOBufferType(param.getType()); + String reference_name = Utils.getReferenceName(interface_decl, method, param); + writer.print("\t\t\tthis." + reference_name + " = "); + writer.println(REFERENCES_PARAMETER_NAME + "." + reference_name + ";"); + } + } + } + + private static void generateClearsFromMethods(PrintWriter writer, InterfaceDeclaration interface_decl) { + for (MethodDeclaration method : interface_decl.getMethods()) { + generateClearsFromParameters(writer, interface_decl, method); + } + } + + private static void generateCopiesFromMethods(PrintWriter writer, InterfaceDeclaration interface_decl) { + for (MethodDeclaration method : interface_decl.getMethods()) { + generateCopiesFromParameters(writer, interface_decl, method); + } + } + + private static void generateReferencesFromParameters(PrintWriter writer, InterfaceDeclaration interface_decl, MethodDeclaration method) { + for (ParameterDeclaration param : method.getParameters()) { + CachedReference cached_reference_annotation = param.getAnnotation(CachedReference.class); + if (cached_reference_annotation != null && cached_reference_annotation.name().length() == 0) { + Class nio_type = Utils.getNIOBufferType(param.getType()); + if (nio_type == null) + throw new RuntimeException(param + " in method " + method + " in " + interface_decl + " is annotated with " + + cached_reference_annotation.annotationType().getSimpleName() + " but the parameter is not a NIO buffer"); + writer.print("\t" + nio_type.getName() + " " + Utils.getReferenceName(interface_decl, method, param)); + writer.println(";"); + } + } + } + + private static void generateReferencesFromMethods(PrintWriter writer, InterfaceDeclaration interface_decl) { + for (MethodDeclaration method : interface_decl.getMethods()) { + generateReferencesFromParameters(writer, interface_decl, method); + } + } + + private void generateReferencesSource() throws IOException { + PrintWriter writer = env.getFiler().createTextFile(Filer.Location.SOURCE_TREE, "org.lwjgl.opengl", new File(REFERENCES_CLASS_NAME + ".java"), null); + writer.println("/* MACHINE GENERATED FILE, DO NOT EDIT */"); + writer.println(); + writer.println("package org.lwjgl.opengl;"); + writer.println(); + writer.println("class " + REFERENCES_CLASS_NAME + " extends BaseReferences {"); + writer.println("\t" + REFERENCES_CLASS_NAME + "(ContextCapabilities caps) {"); + writer.println("\t\tsuper(caps);"); + writer.println("\t}"); + DeclarationFilter filter = DeclarationFilter.getFilter(InterfaceDeclaration.class); + Collection interface_decls = filter.filter(env.getSpecifiedTypeDeclarations()); + for (TypeDeclaration typedecl : interface_decls) { + InterfaceDeclaration interface_decl = (InterfaceDeclaration)typedecl; + generateReferencesFromMethods(writer, interface_decl); + } + writer.println(); + writer.println("\tvoid copy(" + REFERENCES_CLASS_NAME + " " + REFERENCES_PARAMETER_NAME + ", int mask) {"); + writer.println("\t\tsuper.copy(" + REFERENCES_PARAMETER_NAME + ", mask);"); + writer.println("\t\tif ( (mask & GL11.GL_CLIENT_VERTEX_ARRAY_BIT) != 0 ) {"); + for (TypeDeclaration typedecl : interface_decls) { + InterfaceDeclaration interface_decl = (InterfaceDeclaration)typedecl; + generateCopiesFromMethods(writer, interface_decl); + } + writer.println("\t\t}"); + writer.println("\t}"); + writer.println("\tvoid clear() {"); + writer.println("\t\tsuper.clear();"); + for (TypeDeclaration typedecl : interface_decls) { + InterfaceDeclaration interface_decl = (InterfaceDeclaration)typedecl; + generateClearsFromMethods(writer, interface_decl); + } + writer.println("\t}"); + writer.println("}"); + writer.close(); + } + } +} diff --git a/src/java/org/lwjgl/util/generator/RegisterStubsGenerator.java b/src/java/org/lwjgl/util/generator/RegisterStubsGenerator.java new file mode 100644 index 0000000..7aea345 --- /dev/null +++ b/src/java/org/lwjgl/util/generator/RegisterStubsGenerator.java @@ -0,0 +1,119 @@ +/* + * 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; + +/** + * + * This class generates the initNatives native function. + * + * @author elias_naur + * @version $Revision: 3288 $ + * $Id: RegisterStubsGenerator.java 3288 2010-03-16 17:58:48Z spasi $ + */ + +import com.sun.mirror.declaration.*; +import com.sun.mirror.type.*; + +import java.io.*; +import java.util.*; + +public class RegisterStubsGenerator { + public static void generateMethodsNativeStubBind(PrintWriter writer, InterfaceDeclaration d, boolean generate_error_checks, boolean context_specific) { + Iterator it = d.getMethods().iterator(); + while (it.hasNext()) { + MethodDeclaration method = it.next(); + if ( method.getAnnotation(Alternate.class) != null ) + continue; + EnumSet platforms; + PlatformDependent platform_annotation = method.getAnnotation(PlatformDependent.class); + if (platform_annotation != null) + platforms = EnumSet.copyOf(Arrays.asList(platform_annotation.value())); + else + platforms = EnumSet.of(Platform.ALL); + for (Platform platform : platforms) { + platform.printPrologue(writer); + boolean has_buffer_parameter = Utils.hasMethodBufferObjectParameter(method); + printMethodNativeStubBind(writer, d, method, platform, Mode.NORMAL, it.hasNext() || has_buffer_parameter, generate_error_checks, context_specific); + if (has_buffer_parameter) { + printMethodNativeStubBind(writer, d, method, platform, Mode.BUFFEROBJECT, it.hasNext(), generate_error_checks, context_specific); + } + platform.printEpilogue(writer); + } + } + writer.println(); + } + + private static String getTypeSignature(TypeMirror type, boolean add_position_signature) { + SignatureTranslator v = new SignatureTranslator(add_position_signature); + type.accept(v); + return v.getSignature(); + } + + private static String getMethodSignature(MethodDeclaration method, Mode mode) { + Collection params = method.getParameters(); + String signature = "("; + for (ParameterDeclaration param : params) { + if (param.getAnnotation(Result.class) != null) + continue; + if (mode == Mode.BUFFEROBJECT && param.getAnnotation(BufferObject.class) != null) { + signature += "I"; + } else { + signature += getTypeSignature(param.getType(), true); + } + } + TypeMirror result_type = Utils.getMethodReturnType(method); + if (Utils.getNIOBufferType(result_type) != null) + signature += "I"; + String result_type_signature = getTypeSignature(result_type, false); + if (method.getAnnotation(CachedResult.class) != null) + signature += result_type_signature; + signature += ")"; + signature += result_type_signature; + return signature; + } + + private static void printMethodNativeStubBind(PrintWriter writer, InterfaceDeclaration d, MethodDeclaration method, Platform platform, Mode mode, boolean has_more, boolean generate_error_checks, boolean context_specific) { + writer.print("\t\t{\"" + Utils.getSimpleNativeMethodName(method, generate_error_checks, context_specific)); + if (mode == Mode.BUFFEROBJECT) + writer.print(Utils.BUFFER_OBJECT_METHOD_POSTFIX); + writer.print("\", \"" + getMethodSignature(method, mode) + "\", (void *)&"); + writer.print(Utils.getQualifiedNativeMethodName(Utils.getQualifiedClassName(d), method, generate_error_checks, context_specific)); + if (mode == Mode.BUFFEROBJECT) + writer.print(Utils.BUFFER_OBJECT_METHOD_POSTFIX); + String opengl_handle_name = method.getSimpleName().replaceFirst("gl", platform.getPrefix()); + writer.print(", \"" + opengl_handle_name + "\", (void *)&" + method.getSimpleName() + "}"); + if (has_more) + writer.println(","); + } + +} diff --git a/src/java/org/lwjgl/util/generator/Result.java b/src/java/org/lwjgl/util/generator/Result.java new file mode 100644 index 0000000..ca20b34 --- /dev/null +++ b/src/java/org/lwjgl/util/generator/Result.java @@ -0,0 +1,49 @@ +/* + * 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; + +/** + * + * This annotation indicates that the method result is in the + * specified parameter. + * + * @author elias_naur + * @version $Revision: 2983 $ + * $Id: Result.java 2983 2008-04-07 18:36:09Z matzon $ + */ + +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +@Target(ElementType.PARAMETER) +public @interface Result { +} diff --git a/src/java/org/lwjgl/util/generator/SignatureTranslator.java b/src/java/org/lwjgl/util/generator/SignatureTranslator.java new file mode 100644 index 0000000..289fc11 --- /dev/null +++ b/src/java/org/lwjgl/util/generator/SignatureTranslator.java @@ -0,0 +1,142 @@ +/* + * 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; + +/** + * + * A TypeVisitor that translates types to JNI signatures. + * + * @author elias_naur + * @version $Revision: 2983 $ + * $Id: SignatureTranslator.java 2983 2008-04-07 18:36:09Z matzon $ + */ + +import com.sun.mirror.type.*; +import com.sun.mirror.util.*; + +import java.nio.*; + +class SignatureTranslator implements TypeVisitor { + private final boolean add_position_signature; + private final StringBuilder signature = new StringBuilder(); + + SignatureTranslator(boolean add_position_signature) { + this.add_position_signature = add_position_signature; + } + + private static String getNativeNameFromClassName(String class_name) { + return class_name.replaceAll("\\.", "/"); + } + + public String getSignature() { + return signature.toString(); + } + + public void visitAnnotationType(AnnotationType t) { + throw new RuntimeException(t + " is not allowed"); + } + + public void visitArrayType(ArrayType t) { + throw new RuntimeException(t + " is not allowed"); + } + + public void visitClassType(ClassType t) { + String type_name = getNativeNameFromClassName(t.getDeclaration().getQualifiedName()); + signature.append("L"); + signature.append(type_name); + signature.append(";"); + if (add_position_signature && Buffer.class.isAssignableFrom(NativeTypeTranslator.getClassFromType(t))) { + signature.append("I"); + } + } + + public void visitDeclaredType(DeclaredType t) { + throw new RuntimeException(t + " is not allowed"); + } + + public void visitEnumType(EnumType t) { + throw new RuntimeException(t + " is not allowed"); + } + + public void visitInterfaceType(InterfaceType t) { + throw new RuntimeException(t + " is not allowed"); + } + + public void visitPrimitiveType(PrimitiveType t) { + switch (t.getKind()) { + case BOOLEAN: + signature.append("Z"); + break; + case INT: + signature.append("I"); + break; + case FLOAT: + signature.append("F"); + break; + case SHORT: + signature.append("S"); + break; + case DOUBLE: + signature.append("D"); + break; + case BYTE: + signature.append("B"); + break; + case LONG: + signature.append("J"); + break; + default: + throw new RuntimeException("Unsupported type " + t); + } + } + + public void visitReferenceType(ReferenceType t) { + throw new RuntimeException(t + " is not allowed"); + } + + public void visitTypeMirror(TypeMirror t) { + throw new RuntimeException(t + " is not allowed"); + } + + public void visitTypeVariable(TypeVariable t) { + throw new RuntimeException(t + " is not allowed"); + } + + public void visitVoidType(VoidType t) { + signature.append("V"); + } + + public void visitWildcardType(WildcardType t) { + throw new RuntimeException(t + " is not allowed"); + } +} diff --git a/src/java/org/lwjgl/util/generator/Signedness.java b/src/java/org/lwjgl/util/generator/Signedness.java new file mode 100644 index 0000000..3f8ca1b --- /dev/null +++ b/src/java/org/lwjgl/util/generator/Signedness.java @@ -0,0 +1,46 @@ +/* + * 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; + +/** + * + * @author elias_naur + * @version $Revision: 2983 $ + * $Id: Signedness.java 2983 2008-04-07 18:36:09Z matzon $ + */ + +public enum Signedness { + SIGNED, + UNSIGNED, + NONE, + BOTH +} diff --git a/src/java/org/lwjgl/util/generator/StringList.java b/src/java/org/lwjgl/util/generator/StringList.java new file mode 100644 index 0000000..0d9e20d --- /dev/null +++ b/src/java/org/lwjgl/util/generator/StringList.java @@ -0,0 +1,48 @@ +/* + * 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; + +/** + * + * @author spasi + */ + +import java.lang.annotation.ElementType; +import java.lang.annotation.Target; + +@Target({ElementType.PARAMETER, ElementType.METHOD}) +public @interface StringList { + /** Number of values in the string list (name of native-side parameter) */ + String value(); + /** List of string lengths (name of native-side parameter) */ + String lengths() default ""; +} \ No newline at end of file diff --git a/src/java/org/lwjgl/util/generator/StripPostfix.java b/src/java/org/lwjgl/util/generator/StripPostfix.java new file mode 100644 index 0000000..8f63d42 --- /dev/null +++ b/src/java/org/lwjgl/util/generator/StripPostfix.java @@ -0,0 +1,53 @@ +/* + * 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; + +/** + * + * This annotation implies that a method have its postfix stripped + * according to a specified Buffer parameter. + * + * @author elias_naur + * @version $Revision: 3256 $ + * $Id: StripPostfix.java 3256 2009-12-01 03:37:27Z spasi $ + */ + +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +@Target(ElementType.METHOD) +public @interface StripPostfix { + String value(); // The parameter to deduce the postfix from + String extension() default "NULL"; + boolean hasPostfix() default true; + String postfix() default "NULL"; +} diff --git a/src/java/org/lwjgl/util/generator/TypeInfo.java b/src/java/org/lwjgl/util/generator/TypeInfo.java new file mode 100644 index 0000000..63a3b37 --- /dev/null +++ b/src/java/org/lwjgl/util/generator/TypeInfo.java @@ -0,0 +1,229 @@ +/* + * 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; + +/** + * + * This class represent a parameter configuration. There are multiple + * TypeInfos in case of multityped parameters. + * + * @author elias_naur + * @version $Revision: 3279 $ + * $Id: TypeInfo.java 3279 2010-03-11 21:06:49Z spasi $ + */ + +import com.sun.mirror.declaration.*; +import com.sun.mirror.type.*; + +import java.util.*; +import java.nio.*; + +public class TypeInfo { + public static final String UNSIGNED_PARAMETER_NAME = "unsigned"; + + private final Signedness signedness; + private final Class type; + private final String auto_type; + + private TypeInfo(Class type, Signedness signedness, String auto_type) { + this.type = type; + this.signedness = signedness; + this.auto_type = auto_type; + } + + public Class getType() { + return type; + } + + public Signedness getSignedness() { + return signedness; + } + + public String getAutoType() { + if (auto_type == null) + throw new RuntimeException("No auto type assigned"); + return auto_type; + } + + private static Class getTypeFromPrimitiveKind(PrimitiveType.Kind kind) { + Class type; + switch (kind) { + case LONG: + type = long.class; + break; + case INT: + type = int.class; + break; + case FLOAT: + type = float.class; + break; + case DOUBLE: + type = double.class; + break; + case SHORT: + type = short.class; + break; + case BYTE: + type = byte.class; + break; + default: + throw new RuntimeException(kind + " is not allowed"); + } + return type; + } + + private static Class getBufferTypeFromPrimitiveKind(PrimitiveType.Kind kind) { + Class type; + switch (kind) { + case INT: + type = IntBuffer.class; + break; + case FLOAT: + type = FloatBuffer.class; + break; + case DOUBLE: + type = DoubleBuffer.class; + break; + case SHORT: + type = ShortBuffer.class; + break; + case LONG: + type = LongBuffer.class; + break; + case BYTE: /* fall through */ + case BOOLEAN: + type = ByteBuffer.class; + break; + default: + throw new RuntimeException(kind + " is not allowed"); + } + return type; + } + + private static TypeInfo getDefaultTypeInfo(TypeMirror t) { + Class java_type = Utils.getJavaType(t); + return new TypeInfo(java_type, Signedness.NONE, null); + } + + public static Map getDefaultTypeInfoMap(MethodDeclaration method) { + Map map = new HashMap(); + for (ParameterDeclaration param : method.getParameters()) { + TypeInfo type_info = getDefaultTypeInfo(param.getType()); + map.put(param, type_info); + } + return map; + } + + private static Collection getTypeInfos(TypeMap type_map, Declaration param, TypeMirror decl_type) { + Collection annotations = Utils.getSortedAnnotations(param.getAnnotationMirrors()); + Map types = new HashMap(); + Collection multityped_result = new ArrayList(); + boolean add_default_type = true; + for (AnnotationMirror annotation : annotations) { + NativeType native_type_annotation = NativeTypeTranslator.getAnnotation(annotation, NativeType.class); + if (native_type_annotation != null) { + Class annotation_type = NativeTypeTranslator.getClassFromType(annotation.getAnnotationType()); + Signedness signedness = type_map.getSignednessFromType(annotation_type); + Class inverse_type = type_map.getInverseType(annotation_type); + String auto_type = type_map.getAutoTypeFromAnnotation(annotation); + if (inverse_type != null) { + if (types.containsKey(inverse_type)) { + TypeInfo inverse_type_info = types.get(inverse_type); + String inverse_auto_type = inverse_type_info.getAutoType(); + auto_type = signedness == Signedness.UNSIGNED ? auto_type + " : " + inverse_auto_type : + inverse_auto_type + " : " + auto_type; + auto_type = UNSIGNED_PARAMETER_NAME + " ? " + auto_type; + signedness = Signedness.BOTH; + types.remove(inverse_type); + multityped_result.remove(inverse_type_info); + } + } + Class 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 + type = getTypeFromPrimitiveKind(kind); + TypeInfo type_info = new TypeInfo(type, signedness, auto_type); + types.put(annotation_type, type_info); + multityped_result.add(type_info); + add_default_type = false; + } + } + if (add_default_type) { + TypeInfo default_type_info = getDefaultTypeInfo(decl_type); + Collection result = new ArrayList(); + result.add(default_type_info); + return result; + } else + return multityped_result; + } + + private static Map> getTypeInfoMap(TypeMap type_map, MethodDeclaration method) { + Map> map = new HashMap>(); + for (ParameterDeclaration param : method.getParameters()) { + Collection types = getTypeInfos(type_map, param, param.getType()); + map.put(param, types); + } + return map; + } + + public static Collection> getTypeInfoCrossProduct(TypeMap type_map, MethodDeclaration method) { + Collection parameter_collection = method.getParameters(); + ParameterDeclaration[] parameters = new ParameterDeclaration[parameter_collection.size()]; + parameter_collection.toArray(parameters); + Collection> cross_product = new ArrayList>(); + getCrossProductRecursive(0, parameters, getTypeInfoMap(type_map, method), + new HashMap(), cross_product); + return cross_product; + } + + private static void getCrossProductRecursive(int index, ParameterDeclaration[] parameters, Map> typeinfos_map, Map current_instance, + Collection> cross_product) { + if (index == parameters.length) { + cross_product.add(current_instance); + return; + } + ParameterDeclaration param = parameters[index]; + Collection typeinfos = typeinfos_map.get(param); + if (typeinfos != null) { + for (TypeInfo typeinfo : typeinfos) { + Map instance = new HashMap(current_instance); + instance.put(param, typeinfo); + getCrossProductRecursive(index + 1, parameters, typeinfos_map, instance, cross_product); + } + } + } +} diff --git a/src/java/org/lwjgl/util/generator/TypeMap.java b/src/java/org/lwjgl/util/generator/TypeMap.java new file mode 100644 index 0000000..76a4a49 --- /dev/null +++ b/src/java/org/lwjgl/util/generator/TypeMap.java @@ -0,0 +1,63 @@ +/* + * 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; + +/** + * + * The interface to the OpenAL/OpenGL specific generator behaviour + * + * @author elias_naur + * @version $Revision: 2983 $ + * $Id: TypeMap.java 2983 2008-04-07 18:36:09Z matzon $ + */ + +import com.sun.mirror.declaration.*; +import com.sun.mirror.type.*; + +import java.io.*; + +public interface TypeMap { + String getErrorCheckMethodName(); + String getRegisterNativesFunctionName(); + PrimitiveType.Kind getPrimitiveTypeFromNativeType(Class native_type); + String getTypedefPrefix(); + void printNativeIncludes(PrintWriter writer); + Class getStringElementType(); + Class[] getValidAnnotationTypes(Class type); + Class getVoidType(); + String translateAnnotation(Class annotation_type); + Class getNativeTypeFromPrimitiveType(PrimitiveType.Kind kind); + String getAutoTypeFromAnnotation(AnnotationMirror annotation); + Class getInverseType(Class type); + Signedness getSignednessFromType(Class type); +} diff --git a/src/java/org/lwjgl/util/generator/TypedefsGenerator.java b/src/java/org/lwjgl/util/generator/TypedefsGenerator.java new file mode 100644 index 0000000..fe6863a --- /dev/null +++ b/src/java/org/lwjgl/util/generator/TypedefsGenerator.java @@ -0,0 +1,91 @@ +/* + * 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; + +/** + * + * A TypeVisitor that generates the native typedefs. + * + * @author elias_naur + * @version $Revision: 3281 $ + * $Id: TypedefsGenerator.java 3281 2010-03-12 21:55:13Z spasi $ + */ + +import com.sun.mirror.declaration.*; +import com.sun.mirror.type.*; + +import java.io.*; +import java.util.*; + +public class TypedefsGenerator { + private static void generateNativeTypedefs(TypeMap type_map, PrintWriter writer, MethodDeclaration method) { + TypeMirror return_type = method.getReturnType(); + writer.print("typedef "); + NativeTypeTranslator translator = new NativeTypeTranslator(type_map, method); + return_type.accept(translator); + writer.print(translator.getSignature()); + writer.print(" ("); + writer.print(type_map.getTypedefPrefix()); + writer.print(" *" + Utils.getTypedefName(method) + ") ("); + generateNativeTypedefsParameters(type_map, writer, method.getParameters()); + writer.println(");"); + } + + private static void generateNativeTypedefsParameters(TypeMap type_map, PrintWriter writer, Collection params) { + if (params.size() > 0) { + Iterator it = params.iterator(); + generateNativeTypedefsParameter(type_map, writer, it.next()); + while (it.hasNext()) { + writer.print(", "); + generateNativeTypedefsParameter(type_map, writer, it.next()); + } + } + } + + private static void generateNativeTypedefsParameter(TypeMap type_map, PrintWriter writer, ParameterDeclaration param) { + NativeTypeTranslator translator = new NativeTypeTranslator(type_map, param); + param.getType().accept(translator); + writer.print(translator.getSignature()); + if (param.getAnnotation(Result.class) != null || param.getAnnotation(Indirect.class) != null || param.getAnnotation(StringList.class) != null) + writer.print("*"); + writer.print(" " + param.getSimpleName()); + } + + public static void generateNativeTypedefs(TypeMap type_map, PrintWriter writer, Collection methods) { + for (MethodDeclaration method : methods) { + if ( method.getAnnotation(Alternate.class) == null ) + generateNativeTypedefs(type_map, writer, method); + } + } + +} diff --git a/src/java/org/lwjgl/util/generator/Utils.java b/src/java/org/lwjgl/util/generator/Utils.java new file mode 100644 index 0000000..c9f1b94 --- /dev/null +++ b/src/java/org/lwjgl/util/generator/Utils.java @@ -0,0 +1,397 @@ +/* + * 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; + +/** + * + * Various utility methods to the generator. + * + * @author elias_naur + * @version $Revision: 3299 $ + * $Id: Utils.java 3299 2010-03-31 15:46:16Z spasi $ + */ + +import java.io.PrintWriter; +import java.nio.Buffer; +import java.nio.ByteBuffer; +import java.util.*; + +import com.sun.mirror.declaration.*; +import com.sun.mirror.type.PrimitiveType; +import com.sun.mirror.type.TypeMirror; + +public class Utils { + + public static final String TYPEDEF_POSTFIX = "PROC"; + public static final String FUNCTION_POINTER_VAR_NAME = "function_pointer"; + public static final String FUNCTION_POINTER_POSTFIX = "_pointer"; + public static final String CHECKS_CLASS_NAME = "GLChecks"; + public static final String CONTEXT_CAPS_CLASS_NAME = "ContextCapabilities"; + public static final String STUB_INITIALIZER_NAME = "initNativeStubs"; + public static final String BUFFER_OBJECT_METHOD_POSTFIX = "BO"; + public static final String BUFFER_OBJECT_PARAMETER_POSTFIX = "_buffer_offset"; + public static final String RESULT_SIZE_NAME = "result_size"; + public static final String RESULT_VAR_NAME = "__result"; + public static final String CACHED_BUFFER_LENGTH_NAME = "length"; + public static final String CACHED_BUFFER_NAME = "old_buffer"; + private static final String OVERLOADED_METHOD_PREFIX = "n"; + + public static String getTypedefName(MethodDeclaration method) { + Alternate alt_annotation = method.getAnnotation(Alternate.class); + return (alt_annotation == null ? method.getSimpleName() : alt_annotation.value()) + TYPEDEF_POSTFIX; + } + + public static String getFunctionAddressName(InterfaceDeclaration interface_decl, MethodDeclaration method) { + return getFunctionAddressName(interface_decl, method, false); + } + + public static String getFunctionAddressName(InterfaceDeclaration interface_decl, MethodDeclaration method, boolean forceAlt) { + Alternate alt_annotation = method.getAnnotation(Alternate.class); + if ( alt_annotation == null || (alt_annotation.nativeAlt() && !forceAlt) ) + return interface_decl.getSimpleName() + "_" + method.getSimpleName() + FUNCTION_POINTER_POSTFIX; + else + return interface_decl.getSimpleName() + "_" + alt_annotation.value() + FUNCTION_POINTER_POSTFIX; + } + + public static boolean isFinal(InterfaceDeclaration d) { + Extension extension_annotation = d.getAnnotation(Extension.class); + return extension_annotation == null || extension_annotation.isFinal(); + } + + private static class AnnotationMirrorComparator implements Comparator { + public int compare(AnnotationMirror a1, AnnotationMirror a2) { + String n1 = a1.getAnnotationType().getDeclaration().getQualifiedName(); + String n2 = a2.getAnnotationType().getDeclaration().getQualifiedName(); + int result = n1.compareTo(n2); + return result; + } + + public boolean equals(AnnotationMirror a1, AnnotationMirror a2) { + return compare(a1, a2) == 0; + } + } + + public static Collection getSortedAnnotations(Collection annotations) { + List annotation_list = new ArrayList(annotations); + Collections.sort(annotation_list, new AnnotationMirrorComparator()); + return annotation_list; + } + + public static String getReferenceName(InterfaceDeclaration interface_decl, MethodDeclaration method, ParameterDeclaration param) { + return interface_decl.getSimpleName() + "_" + method.getSimpleName() + "_" + param.getSimpleName(); + } + + public static boolean isAddressableType(TypeMirror type) { + return isAddressableType(getJavaType(type)); + } + + public static boolean isAddressableType(Class type) { + return Buffer.class.isAssignableFrom(type) || String.class.equals(type) || CharSequence.class.equals(type) || CharSequence[].class.equals(type); + } + + public static Class getJavaType(TypeMirror type_mirror) { + JavaTypeTranslator translator = new JavaTypeTranslator(); + type_mirror.accept(translator); + return translator.getType(); + } + + private static boolean hasParameterMultipleTypes(ParameterDeclaration param) { + int num_native_annotations = 0; + for (AnnotationMirror annotation : param.getAnnotationMirrors()) + if (NativeTypeTranslator.getAnnotation(annotation, NativeType.class) != null) + num_native_annotations++; + return num_native_annotations > 1; + } + + public static boolean isParameterMultiTyped(ParameterDeclaration param) { + boolean result = Buffer.class.equals(Utils.getJavaType(param.getType())); + if (!result && hasParameterMultipleTypes(param)) + throw new RuntimeException(param + " not defined as java.nio.Buffer but has multiple types"); + return result; + } + + public static ParameterDeclaration findParameter(MethodDeclaration method, String name) { + for (ParameterDeclaration param : method.getParameters()) + if (param.getSimpleName().equals(name)) + return param; + throw new RuntimeException("Parameter " + name + " not found"); + } + + public static void printDocComment(PrintWriter writer, Declaration decl) { + String doc_comment = decl.getDocComment(); + if (doc_comment != null) { + String tab = decl instanceof InterfaceDeclaration ? "" : "\t"; + writer.println(tab + "/**"); + StringTokenizer doc_lines = new StringTokenizer(doc_comment, "\n"); + while (doc_lines.hasMoreTokens()) + writer.println(tab + " * " + doc_lines.nextToken()); + writer.println(tab + " */"); + } else if ( (decl instanceof MethodDeclaration) && decl.getAnnotation(Alternate.class) != null ) + writer.println("\t/** Overloads " + decl.getAnnotation(Alternate.class).value() + " */"); + } + + public static AnnotationMirror getParameterAutoAnnotation(ParameterDeclaration param) { + for (AnnotationMirror annotation : param.getAnnotationMirrors()) + if (NativeTypeTranslator.getAnnotation(annotation, Auto.class) != null) + return annotation; + return null; + } + + public static boolean isMethodIndirect(boolean generate_error_checks, boolean context_specific, MethodDeclaration method) { + for (ParameterDeclaration param : method.getParameters()) { + if (isAddressableType(param.getType()) || getParameterAutoAnnotation(param) != null || + param.getAnnotation(Constant.class) != null) + return true; + } + return hasMethodBufferObjectParameter(method) || method.getAnnotation(Code.class) != null || + method.getAnnotation(CachedResult.class) != null || + (generate_error_checks && method.getAnnotation(NoErrorCheck.class) == null) || + context_specific; + } + + public static String getNativeQualifiedName(String qualified_name) { + return qualified_name.replaceAll("\\.", "_"); + } + + public static String getQualifiedNativeMethodName(String qualified_class_name, String method_name) { + return "Java_" + getNativeQualifiedName(qualified_class_name) + "_" + method_name; + } + + public static String getQualifiedNativeMethodName(String qualified_class_name, MethodDeclaration method, boolean generate_error_checks, boolean context_specific) { + String method_name = getSimpleNativeMethodName(method, generate_error_checks, context_specific); + return getQualifiedNativeMethodName(qualified_class_name, method_name); + } + + public static ParameterDeclaration getResultParameter(MethodDeclaration method) { + ParameterDeclaration result_param = null; + for (ParameterDeclaration param : method.getParameters()) { + if (param.getAnnotation(Result.class) != null) { + if (result_param != null) + throw new RuntimeException("Multiple parameters annotated with Result in method " + method); + result_param = param; + } + } + return result_param; + } + + public static TypeMirror getMethodReturnType(MethodDeclaration method) { + TypeMirror result_type; + ParameterDeclaration result_param = getResultParameter(method); + if (result_param != null) { + result_type = result_param.getType(); + } else + result_type = method.getReturnType(); + return result_type; + } + + public static String getMethodReturnType(MethodDeclaration method, GLreturn return_annotation, boolean buffer) { + ParameterDeclaration return_param = null; + for ( ParameterDeclaration param : method.getParameters() ) { + if ( param.getSimpleName().equals(return_annotation.value()) ) { + return_param = param; + break; + } + } + if ( return_param == null ) + throw new RuntimeException("The @GLreturn parameter \"" + return_annotation.value() + "\" could not be found in method: " + method); + + PrimitiveType.Kind kind = NativeTypeTranslator.getPrimitiveKindFromBufferClass(Utils.getJavaType(return_param.getType())); + if ( return_param.getAnnotation(GLboolean.class) != null ) + kind = PrimitiveType.Kind.BOOLEAN; + + if ( kind == PrimitiveType.Kind.BYTE && (return_param.getAnnotation(GLchar.class) != null || return_param.getAnnotation(GLcharARB.class) != null) ) + return "String"; + else { + final String type = JavaTypeTranslator.getPrimitiveClassFromKind(kind).getName(); + return buffer ? Character.toUpperCase(type.charAt(0)) + type.substring(1) : type; + } + } + + public static boolean needResultSize(MethodDeclaration method) { + return getNIOBufferType(getMethodReturnType(method)) != null && method.getAnnotation(AutoResultSize.class) == null; + } + + public static void printExtraCallArguments(PrintWriter writer, MethodDeclaration method, String size_parameter_name) { + writer.print(size_parameter_name); + if (method.getAnnotation(CachedResult.class) != null) { + writer.print(", " + CACHED_BUFFER_NAME); + } + } + + private static String getClassName(InterfaceDeclaration interface_decl, String opengl_name) { + Extension extension_annotation = interface_decl.getAnnotation(Extension.class); + if (extension_annotation != null && !"".equals(extension_annotation.className())) { + return extension_annotation.className(); + } + StringBuilder result = new StringBuilder(); + for (int i = 0; i < opengl_name.length(); i++) { + int ch = opengl_name.codePointAt(i); + if (ch == '_') { + i++; + result.appendCodePoint(Character.toUpperCase(opengl_name.codePointAt(i))); + } else + result.appendCodePoint(ch); + } + return result.toString(); + } + + public static boolean hasMethodBufferObjectParameter(MethodDeclaration method) { + for (ParameterDeclaration param : method.getParameters()) { + if (param.getAnnotation(BufferObject.class) != null) { + return true; + } + } + return false; + } + + public static String getQualifiedClassName(InterfaceDeclaration interface_decl) { + return interface_decl.getPackage().getQualifiedName() + "." + getSimpleClassName(interface_decl); + } + + public static String getSimpleClassName(InterfaceDeclaration interface_decl) { + return getClassName(interface_decl, interface_decl.getSimpleName()); + } + + public static Class getNIOBufferType(TypeMirror t) { + Class param_type = getJavaType(t); + if (Buffer.class.isAssignableFrom(param_type)) + return param_type; + else if ( param_type == CharSequence.class || param_type == CharSequence[].class ) + return ByteBuffer.class; + else + return null; + } + + public static String getSimpleNativeMethodName(MethodDeclaration method, boolean generate_error_checks, boolean context_specific) { + String method_name; + Alternate alt_annotation = method.getAnnotation(Alternate.class); + method_name = alt_annotation == null || alt_annotation.nativeAlt() ? method.getSimpleName() : alt_annotation.value(); + if (isMethodIndirect(generate_error_checks, context_specific, method)) + method_name = OVERLOADED_METHOD_PREFIX + method_name; + return method_name; + } + + static boolean isReturnParameter(MethodDeclaration method, ParameterDeclaration param) { + GLreturn string_annotation = method.getAnnotation(GLreturn.class); + if ( string_annotation == null || !string_annotation.value().equals(param.getSimpleName()) ) + return false; + + if ( param.getAnnotation(OutParameter.class) == null ) + throw new RuntimeException("The parameter specified in @GLreturn is not annotated with @OutParameter in method: " + method); + + if ( param.getAnnotation(Check.class) != null ) + throw new RuntimeException("The parameter specified in @GLreturn is annotated with @Check in method: " + method); + + if ( param.getAnnotation(GLchar.class) != null && Utils.getJavaType(param.getType()).equals(ByteBuffer.class) && string_annotation.maxLength().length() == 0 ) + throw new RuntimeException("The @GLreturn annotation is missing a maxLength parameter in method: " + method); + + return true; + } + + static String getStringOffset(MethodDeclaration method, ParameterDeclaration param) { + String offset = null; + for ( ParameterDeclaration p : method.getParameters() ) { + if ( param != null && p.getSimpleName().equals(param.getSimpleName()) ) + break; + + final Class type = Utils.getJavaType(p.getType()); + if ( type.equals(CharSequence.class) ) { + if ( offset == null ) + offset = p.getSimpleName() + ".length()"; + else + offset += " + " + p.getSimpleName() + ".length()"; + if ( p.getAnnotation(NullTerminated.class) != null ) offset += " + 1"; + + } else if ( type.equals(CharSequence[].class) ) { + if ( offset == null ) + offset = "APIUtils.getTotalLength(" + p.getSimpleName() + ")"; + else + offset += " + APIUtils.getTotalLength(" + p.getSimpleName() + ")"; + if ( p.getAnnotation(NullTerminated.class) != null ) offset += " + " + p.getSimpleName() + ".length"; + } + + } + return offset; + } + + static void printGLReturnPre(PrintWriter writer, MethodDeclaration method, GLreturn return_annotation) { + final String return_type = getMethodReturnType(method, return_annotation, true); + + if ( "String".equals(return_type) ) { + if ( !return_annotation.forceMaxLength() ) { + writer.println("IntBuffer " + return_annotation.value() + "_length = APIUtils.getLengths();"); + writer.print("\t\t"); + } + writer.print("ByteBuffer " + return_annotation.value() + " = APIUtils.getBufferByte(" + return_annotation.maxLength()); + /* + Params that use the return buffer will advance its position while filling it. When we return, the position will be + at the right spot for grabbing the returned string bytes. We only have to make sure that the original buffer was + large enough to hold everything, so that no re-allocations happen while filling. + */ + final String offset = getStringOffset(method, null); + if ( offset != null ) + writer.print(" + " + offset); + writer.println(");"); + } else { + final String buffer_type = "Boolean".equals(return_type) ? "Byte" : return_type; + writer.print(buffer_type + "Buffer " + return_annotation.value() + " = APIUtils.getBuffer" + buffer_type + "("); + if ( "Byte".equals(buffer_type) ) + writer.print('1'); + writer.println(");"); + } + + writer.print("\t\t"); + } + + static void printGLReturnPost(PrintWriter writer, MethodDeclaration method, GLreturn return_annotation) { + final String return_type = getMethodReturnType(method, return_annotation, true); + + if ( "String".equals(return_type) ) { + writer.print("\t\t" + return_annotation.value() + ".limit("); + final String offset = getStringOffset(method, null); + if ( offset != null) + writer.print(offset + " + "); + if ( return_annotation.forceMaxLength() ) + writer.print(return_annotation.maxLength()); + else + writer.print(return_annotation.value() + "_length.get(0)"); + writer.println(");"); + writer.println("\t\treturn APIUtils.getString(" + return_annotation.value() + ");"); + } else { + writer.print("\t\treturn " + return_annotation.value() + ".get(0)"); + if ( "Boolean".equals(return_type) ) + writer.print(" == 1"); + writer.println(";"); + } + } + +} diff --git a/src/java/org/lwjgl/util/glu/Cylinder.java b/src/java/org/lwjgl/util/glu/Cylinder.java new file mode 100644 index 0000000..4792f83 --- /dev/null +++ b/src/java/org/lwjgl/util/glu/Cylinder.java @@ -0,0 +1,200 @@ +/* + * 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.glu; + +import org.lwjgl.opengl.GL11; + +/** + * Cylinder.java + * + * + * Created 23-dec-2003 + * @author Erik Duijs + */ +public class Cylinder extends Quadric { + + /** + * Constructor for Cylinder. + */ + public Cylinder() { + super(); + } + + /** + * draws a cylinder oriented along the z axis. The base of the + * cylinder is placed at z = 0, and the top at z=height. Like a sphere, a + * cylinder is subdivided around the z axis into slices, and along the z axis + * into stacks. + * + * Note that if topRadius is set to zero, then this routine will generate a + * cone. + * + * If the orientation is set to GLU.OUTSIDE (with glu.quadricOrientation), then + * any generated normals point away from the z axis. Otherwise, they point + * toward the z axis. + * + * If texturing is turned on (with glu.quadricTexture), then texture + * coordinates are generated so that t ranges linearly from 0.0 at z = 0 to + * 1.0 at z = height, and s ranges from 0.0 at the +y axis, to 0.25 at the +x + * axis, to 0.5 at the -y axis, to 0.75 at the -x axis, and back to 1.0 at the + * +y axis. + * + * @param baseRadius Specifies the radius of the cylinder at z = 0. + * @param topRadius Specifies the radius of the cylinder at z = height. + * @param height Specifies the height of the cylinder. + * @param slices Specifies the number of subdivisions around the z axis. + * @param stacks Specifies the number of subdivisions along the z axis. + */ + public void draw(float baseRadius, float topRadius, float height, int slices, int stacks) { + + float da, r, dr, dz; + float x, y, z, nz, nsign; + int i, j; + + if (super.orientation == GLU.GLU_INSIDE) { + nsign = -1.0f; + } else { + nsign = 1.0f; + } + + da = 2.0f * GLU.PI / slices; + dr = (topRadius - baseRadius) / stacks; + dz = height / stacks; + nz = (baseRadius - topRadius) / height; + // Z component of normal vectors + + if (super.drawStyle == GLU.GLU_POINT) { + GL11.glBegin(GL11.GL_POINTS); + for (i = 0; i < slices; i++) { + x = cos((i * da)); + y = sin((i * da)); + normal3f(x * nsign, y * nsign, nz * nsign); + + z = 0.0f; + r = baseRadius; + for (j = 0; j <= stacks; j++) { + GL11.glVertex3f((x * r), (y * r), z); + z += dz; + r += dr; + } + } + GL11.glEnd(); + } else if (super.drawStyle == GLU.GLU_LINE || super.drawStyle == GLU.GLU_SILHOUETTE) { + // Draw rings + if (super.drawStyle == GLU.GLU_LINE) { + z = 0.0f; + r = baseRadius; + for (j = 0; j <= stacks; j++) { + GL11.glBegin(GL11.GL_LINE_LOOP); + for (i = 0; i < slices; i++) { + x = cos((i * da)); + y = sin((i * da)); + normal3f(x * nsign, y * nsign, nz * nsign); + GL11.glVertex3f((x * r), (y * r), z); + } + GL11.glEnd(); + z += dz; + r += dr; + } + } else { + // draw one ring at each end + if (baseRadius != 0.0) { + GL11.glBegin(GL11.GL_LINE_LOOP); + for (i = 0; i < slices; i++) { + x = cos((i * da)); + y = sin((i * da)); + normal3f(x * nsign, y * nsign, nz * nsign); + GL11.glVertex3f((x * baseRadius), (y * baseRadius), 0.0f); + } + GL11.glEnd(); + GL11.glBegin(GL11.GL_LINE_LOOP); + for (i = 0; i < slices; i++) { + x = cos((i * da)); + y = sin((i * da)); + normal3f(x * nsign, y * nsign, nz * nsign); + GL11.glVertex3f((x * topRadius), (y * topRadius), height); + } + GL11.glEnd(); + } + } + // draw length lines + GL11.glBegin(GL11.GL_LINES); + for (i = 0; i < slices; i++) { + x = cos((i * da)); + y = sin((i * da)); + normal3f(x * nsign, y * nsign, nz * nsign); + GL11.glVertex3f((x * baseRadius), (y * baseRadius), 0.0f); + GL11.glVertex3f((x * topRadius), (y * topRadius), (height)); + } + GL11.glEnd(); + } else if (super.drawStyle == GLU.GLU_FILL) { + float ds = 1.0f / slices; + float dt = 1.0f / stacks; + float t = 0.0f; + z = 0.0f; + r = baseRadius; + for (j = 0; j < stacks; j++) { + float s = 0.0f; + GL11.glBegin(GL11.GL_QUAD_STRIP); + for (i = 0; i <= slices; i++) { + if (i == slices) { + x = sin(0.0f); + y = cos(0.0f); + } else { + x = sin((i * da)); + y = cos((i * da)); + } + if (nsign == 1.0f) { + normal3f((x * nsign), (y * nsign), (nz * nsign)); + TXTR_COORD(s, t); + GL11.glVertex3f((x * r), (y * r), z); + normal3f((x * nsign), (y * nsign), (nz * nsign)); + TXTR_COORD(s, t + dt); + GL11.glVertex3f((x * (r + dr)), (y * (r + dr)), (z + dz)); + } else { + normal3f(x * nsign, y * nsign, nz * nsign); + TXTR_COORD(s, t); + GL11.glVertex3f((x * r), (y * r), z); + normal3f(x * nsign, y * nsign, nz * nsign); + TXTR_COORD(s, t + dt); + GL11.glVertex3f((x * (r + dr)), (y * (r + dr)), (z + dz)); + } + s += ds; + } // for slices + GL11.glEnd(); + r += dr; + t += dt; + z += dz; + } // for stacks + } + } +} diff --git a/src/java/org/lwjgl/util/glu/Disk.java b/src/java/org/lwjgl/util/glu/Disk.java new file mode 100644 index 0000000..0f5cf28 --- /dev/null +++ b/src/java/org/lwjgl/util/glu/Disk.java @@ -0,0 +1,213 @@ +/* + * 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.glu; + +import org.lwjgl.opengl.GL11; + +/** + * Disk.java + * + * + * Created 23-dec-2003 + * @author Erik Duijs + */ +public class Disk extends Quadric { + + /** + * Constructor for Disk. + */ + public Disk() { + super(); + } + + /** + * renders a disk on the z = 0 plane. The disk has a radius of + * outerRadius, and contains a concentric circular hole with a radius of + * innerRadius. If innerRadius is 0, then no hole is generated. The disk is + * subdivided around the z axis into slices (like pizza slices), and also + * about the z axis into rings (as specified by slices and loops, + * respectively). + * + * With respect to orientation, the +z side of the disk is considered to be + * "outside" (see glu.quadricOrientation). This means that if the orientation + * is set to GLU.OUTSIDE, then any normals generated point along the +z axis. + * Otherwise, they point along the -z axis. + * + * If texturing is turned on (with glu.quadricTexture), texture coordinates are + * generated linearly such that where r=outerRadius, the value at (r, 0, 0) is + * (1, 0.5), at (0, r, 0) it is (0.5, 1), at (-r, 0, 0) it is (0, 0.5), and at + * (0, -r, 0) it is (0.5, 0). + */ + public void draw(float innerRadius, float outerRadius, int slices, int loops) + { + float da, dr; + + /* Normal vectors */ + if (super.normals != GLU.GLU_NONE) { + if (super.orientation == GLU.GLU_OUTSIDE) { + GL11.glNormal3f(0.0f, 0.0f, +1.0f); + } + else { + GL11.glNormal3f(0.0f, 0.0f, -1.0f); + } + } + + da = 2.0f * GLU.PI / slices; + dr = (outerRadius - innerRadius) / loops; + + switch (super.drawStyle) { + case GLU.GLU_FILL: + { + /* texture of a gluDisk is a cut out of the texture unit square + * x, y in [-outerRadius, +outerRadius]; s, t in [0, 1] + * (linear mapping) + */ + float dtc = 2.0f * outerRadius; + float sa, ca; + float r1 = innerRadius; + int l; + for (l = 0; l < loops; l++) { + float r2 = r1 + dr; + if (super.orientation == GLU.GLU_OUTSIDE) { + int s; + GL11.glBegin(GL11.GL_QUAD_STRIP); + for (s = 0; s <= slices; s++) { + float a; + if (s == slices) + a = 0.0f; + else + a = s * da; + sa = sin(a); + ca = cos(a); + TXTR_COORD(0.5f + sa * r2 / dtc, 0.5f + ca * r2 / dtc); + GL11.glVertex2f(r2 * sa, r2 * ca); + TXTR_COORD(0.5f + sa * r1 / dtc, 0.5f + ca * r1 / dtc); + GL11.glVertex2f(r1 * sa, r1 * ca); + } + GL11.glEnd(); + } + else { + int s; + GL11.glBegin(GL11.GL_QUAD_STRIP); + for (s = slices; s >= 0; s--) { + float a; + if (s == slices) + a = 0.0f; + else + a = s * da; + sa = sin(a); + ca = cos(a); + TXTR_COORD(0.5f - sa * r2 / dtc, 0.5f + ca * r2 / dtc); + GL11.glVertex2f(r2 * sa, r2 * ca); + TXTR_COORD(0.5f - sa * r1 / dtc, 0.5f + ca * r1 / dtc); + GL11.glVertex2f(r1 * sa, r1 * ca); + } + GL11.glEnd(); + } + r1 = r2; + } + break; + } + case GLU.GLU_LINE: + { + int l, s; + /* draw loops */ + for (l = 0; l <= loops; l++) { + float r = innerRadius + l * dr; + GL11.glBegin(GL11.GL_LINE_LOOP); + for (s = 0; s < slices; s++) { + float a = s * da; + GL11.glVertex2f(r * sin(a), r * cos(a)); + } + GL11.glEnd(); + } + /* draw spokes */ + for (s = 0; s < slices; s++) { + float a = s * da; + float x = sin(a); + float y = cos(a); + GL11.glBegin(GL11.GL_LINE_STRIP); + for (l = 0; l <= loops; l++) { + float r = innerRadius + l * dr; + GL11.glVertex2f(r * x, r * y); + } + GL11.glEnd(); + } + break; + } + case GLU.GLU_POINT: + { + int s; + GL11.glBegin(GL11.GL_POINTS); + for (s = 0; s < slices; s++) { + float a = s * da; + float x = sin(a); + float y = cos(a); + int l; + for (l = 0; l <= loops; l++) { + float r = innerRadius * l * dr; + GL11.glVertex2f(r * x, r * y); + } + } + GL11.glEnd(); + break; + } + case GLU.GLU_SILHOUETTE: + { + if (innerRadius != 0.0) { + float a; + GL11.glBegin(GL11.GL_LINE_LOOP); + for (a = 0.0f; a < 2.0 * GLU.PI; a += da) { + float x = innerRadius * sin(a); + float y = innerRadius * cos(a); + GL11.glVertex2f(x, y); + } + GL11.glEnd(); + } + { + float a; + GL11.glBegin(GL11.GL_LINE_LOOP); + for (a = 0; a < 2.0f * GLU.PI; a += da) { + float x = outerRadius * sin(a); + float y = outerRadius * cos(a); + GL11.glVertex2f(x, y); + } + GL11.glEnd(); + } + break; + } + default: + return; + } + } + +} diff --git a/src/java/org/lwjgl/util/glu/GLU.java b/src/java/org/lwjgl/util/glu/GLU.java new file mode 100644 index 0000000..210ddac --- /dev/null +++ b/src/java/org/lwjgl/util/glu/GLU.java @@ -0,0 +1,429 @@ +/* + * 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.glu; + +import java.nio.ByteBuffer; +import java.nio.FloatBuffer; +import java.nio.IntBuffer; + +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.Util; +import org.lwjgl.util.glu.tessellation.GLUtessellatorImpl; + +/** + * GLU.java + * + * + * Created 23-dec-2003 + * @author Erik Duijs + */ +public class GLU { + static final float PI = (float)Math.PI; + + /* Errors: (return value 0 = no error) */ + public static final int GLU_INVALID_ENUM = 100900; + public static final int GLU_INVALID_VALUE = 100901; + public static final int GLU_OUT_OF_MEMORY = 100902; + public static final int GLU_INCOMPATIBLE_GL_VERSION = 100903; + + /* StringName */ + public static final int GLU_VERSION = 100800; + public static final int GLU_EXTENSIONS = 100801; + + /* Boolean */ + public static final boolean GLU_TRUE = true; + public static final boolean GLU_FALSE = false; + + + /**** Quadric constants ****/ + + /* QuadricNormal */ + public static final int GLU_SMOOTH = 100000; + public static final int GLU_FLAT = 100001; + public static final int GLU_NONE = 100002; + + /* QuadricDrawStyle */ + public static final int GLU_POINT = 100010; + public static final int GLU_LINE = 100011; + public static final int GLU_FILL = 100012; + public static final int GLU_SILHOUETTE = 100013; + + /* QuadricOrientation */ + public static final int GLU_OUTSIDE = 100020; + public static final int GLU_INSIDE = 100021; + + /* Callback types: */ + /* ERROR = 100103 */ + + + /**** Tesselation constants ****/ + + public static final double GLU_TESS_MAX_COORD = 1.0e150; + public static final double TESS_MAX_COORD = 1.0e150; + + /* TessProperty */ + public static final int GLU_TESS_WINDING_RULE = 100140; + public static final int GLU_TESS_BOUNDARY_ONLY = 100141; + public static final int GLU_TESS_TOLERANCE = 100142; + + /* TessWinding */ + public static final int GLU_TESS_WINDING_ODD = 100130; + public static final int GLU_TESS_WINDING_NONZERO = 100131; + public static final int GLU_TESS_WINDING_POSITIVE = 100132; + public static final int GLU_TESS_WINDING_NEGATIVE = 100133; + public static final int GLU_TESS_WINDING_ABS_GEQ_TWO = 100134; + + /* TessCallback */ + public static final int GLU_TESS_BEGIN = 100100; /* void (CALLBACK*)(GLenum type) */ + public static final int GLU_TESS_VERTEX = 100101; /* void (CALLBACK*)(void *data) */ + public static final int GLU_TESS_END = 100102; /* void (CALLBACK*)(void) */ + public static final int GLU_TESS_ERROR = 100103; /* void (CALLBACK*)(GLenum errno) */ + public static final int GLU_TESS_EDGE_FLAG = 100104; /* void (CALLBACK*)(GLboolean boundaryEdge) */ + public static final int GLU_TESS_COMBINE = 100105; /* void (CALLBACK*)(GLdouble coords[3], + void *data[4], + GLfloat weight[4], + void **dataOut) */ + public static final int GLU_TESS_BEGIN_DATA = 100106; /* void (CALLBACK*)(GLenum type, + void *polygon_data) */ + public static final int GLU_TESS_VERTEX_DATA = 100107; /* void (CALLBACK*)(void *data, + void *polygon_data) */ + public static final int GLU_TESS_END_DATA = 100108; /* void (CALLBACK*)(void *polygon_data) */ + public static final int GLU_TESS_ERROR_DATA = 100109; /* void (CALLBACK*)(GLenum errno, + void *polygon_data) */ + public static final int GLU_TESS_EDGE_FLAG_DATA = 100110; /* void (CALLBACK*)(GLboolean boundaryEdge, + void *polygon_data) */ + public static final int GLU_TESS_COMBINE_DATA = 100111; /* void (CALLBACK*)(GLdouble coords[3], + void *data[4], + GLfloat weight[4], + void **dataOut, + void *polygon_data) */ + + /* TessError */ + public static final int GLU_TESS_ERROR1 = 100151; + public static final int GLU_TESS_ERROR2 = 100152; + public static final int GLU_TESS_ERROR3 = 100153; + public static final int GLU_TESS_ERROR4 = 100154; + public static final int GLU_TESS_ERROR5 = 100155; + public static final int GLU_TESS_ERROR6 = 100156; + public static final int GLU_TESS_ERROR7 = 100157; + public static final int GLU_TESS_ERROR8 = 100158; + + public static final int GLU_TESS_MISSING_BEGIN_POLYGON = GLU_TESS_ERROR1; + public static final int GLU_TESS_MISSING_BEGIN_CONTOUR = GLU_TESS_ERROR2; + public static final int GLU_TESS_MISSING_END_POLYGON = GLU_TESS_ERROR3; + public static final int GLU_TESS_MISSING_END_CONTOUR = GLU_TESS_ERROR4; + public static final int GLU_TESS_COORD_TOO_LARGE = GLU_TESS_ERROR5; + public static final int GLU_TESS_NEED_COMBINE_CALLBACK = GLU_TESS_ERROR6; + + /**** NURBS constants ****/ + + /* NurbsProperty */ + public static final int GLU_AUTO_LOAD_MATRIX = 100200; + public static final int GLU_CULLING = 100201; + public static final int GLU_SAMPLING_TOLERANCE = 100203; + public static final int GLU_DISPLAY_MODE = 100204; + public static final int GLU_PARAMETRIC_TOLERANCE = 100202; + public static final int GLU_SAMPLING_METHOD = 100205; + public static final int GLU_U_STEP = 100206; + public static final int GLU_V_STEP = 100207; + + /* NurbsSampling */ + public static final int GLU_PATH_LENGTH = 100215; + public static final int GLU_PARAMETRIC_ERROR = 100216; + public static final int GLU_DOMAIN_DISTANCE = 100217; + + + /* NurbsTrim */ + public static final int GLU_MAP1_TRIM_2 = 100210; + public static final int GLU_MAP1_TRIM_3 = 100211; + + /* NurbsDisplay */ + /* FILL = 100012 */ + public static final int GLU_OUTLINE_POLYGON = 100240; + public static final int GLU_OUTLINE_PATCH = 100241; + + /* NurbsCallback */ + /* ERROR = 100103 */ + + /* NurbsErrors */ + public static final int GLU_NURBS_ERROR1 = 100251; + public static final int GLU_NURBS_ERROR2 = 100252; + public static final int GLU_NURBS_ERROR3 = 100253; + public static final int GLU_NURBS_ERROR4 = 100254; + public static final int GLU_NURBS_ERROR5 = 100255; + public static final int GLU_NURBS_ERROR6 = 100256; + public static final int GLU_NURBS_ERROR7 = 100257; + public static final int GLU_NURBS_ERROR8 = 100258; + public static final int GLU_NURBS_ERROR9 = 100259; + public static final int GLU_NURBS_ERROR10 = 100260; + public static final int GLU_NURBS_ERROR11 = 100261; + public static final int GLU_NURBS_ERROR12 = 100262; + public static final int GLU_NURBS_ERROR13 = 100263; + public static final int GLU_NURBS_ERROR14 = 100264; + public static final int GLU_NURBS_ERROR15 = 100265; + public static final int GLU_NURBS_ERROR16 = 100266; + public static final int GLU_NURBS_ERROR17 = 100267; + public static final int GLU_NURBS_ERROR18 = 100268; + public static final int GLU_NURBS_ERROR19 = 100269; + public static final int GLU_NURBS_ERROR20 = 100270; + public static final int GLU_NURBS_ERROR21 = 100271; + public static final int GLU_NURBS_ERROR22 = 100272; + public static final int GLU_NURBS_ERROR23 = 100273; + public static final int GLU_NURBS_ERROR24 = 100274; + public static final int GLU_NURBS_ERROR25 = 100275; + public static final int GLU_NURBS_ERROR26 = 100276; + public static final int GLU_NURBS_ERROR27 = 100277; + public static final int GLU_NURBS_ERROR28 = 100278; + public static final int GLU_NURBS_ERROR29 = 100279; + public static final int GLU_NURBS_ERROR30 = 100280; + public static final int GLU_NURBS_ERROR31 = 100281; + public static final int GLU_NURBS_ERROR32 = 100282; + public static final int GLU_NURBS_ERROR33 = 100283; + public static final int GLU_NURBS_ERROR34 = 100284; + public static final int GLU_NURBS_ERROR35 = 100285; + public static final int GLU_NURBS_ERROR36 = 100286; + public static final int GLU_NURBS_ERROR37 = 100287; + + /* Contours types -- obsolete! */ + public static final int GLU_CW = 100120; + public static final int GLU_CCW = 100121; + public static final int GLU_INTERIOR = 100122; + public static final int GLU_EXTERIOR = 100123; + public static final int GLU_UNKNOWN = 100124; + + /* Names without "TESS_" prefix */ + public static final int GLU_BEGIN = GLU_TESS_BEGIN; + public static final int GLU_VERTEX = GLU_TESS_VERTEX; + public static final int GLU_END = GLU_TESS_END; + public static final int GLU_ERROR = GLU_TESS_ERROR; + public static final int GLU_EDGE_FLAG = GLU_TESS_EDGE_FLAG; + + /** + * Method gluLookAt + * @param eyex + * @param eyey + * @param eyez + * @param centerx + * @param centery + * @param centerz + * @param upx + * @param upy + * @param upz + */ + public static void gluLookAt( + float eyex, + float eyey, + float eyez, + float centerx, + float centery, + float centerz, + float upx, + float upy, + float upz) { + + Project.gluLookAt(eyex, eyey, eyez, centerx, centery, centerz, upx, upy, upz); + } + + /** + * Method gluOrtho2D + * @param left + * @param right + * @param bottom + * @param top + */ + public static void gluOrtho2D( + float left, + float right, + float bottom, + float top) { + + GL11.glOrtho(left, right, bottom, top, -1.0, 1.0); + } + + /** + * Method gluPerspective + * @param fovy + * @param aspect + * @param zNear + * @param zFar + */ + public static void gluPerspective( + float fovy, + float aspect, + float zNear, + float zFar) { + + Project.gluPerspective(fovy, aspect, zNear, zFar); + } + + /** + * Method gluProject + * @param objx + * @param objy + * @param objz + * @param modelMatrix + * @param projMatrix + * @param viewport + * @param win_pos + */ + public static boolean gluProject(float objx, float objy, float objz, + FloatBuffer modelMatrix, + FloatBuffer projMatrix, + IntBuffer viewport, + FloatBuffer win_pos) + { + return Project.gluProject(objx, objy, objz, modelMatrix, projMatrix, viewport, win_pos); + } + + /** + * Method gluUnproject + * @param winx + * @param winy + * @param winz + * @param modelMatrix + * @param projMatrix + * @param viewport + * @param obj_pos + */ + public static boolean gluUnProject(float winx, float winy, float winz, + FloatBuffer modelMatrix, + FloatBuffer projMatrix, + IntBuffer viewport, + FloatBuffer obj_pos) + { + return Project.gluUnProject(winx, winy, winz, modelMatrix, projMatrix, viewport, obj_pos); + } + + /** + * Method gluPickMatrix + * @param x + * @param y + * @param width + * @param height + * @param viewport + */ + public static void gluPickMatrix( + float x, + float y, + float width, + float height, + IntBuffer viewport) { + + Project.gluPickMatrix(x, y, width, height, viewport); + } + + /** + * Method gluGetString. + * @param name + * @return String + */ + public static String gluGetString(int name) { + return Registry.gluGetString(name); + } + + /** + * Method gluCheckExtension. + * @param extName + * @param extString + * @return boolean + */ + public static boolean gluCheckExtension(String extName, String extString) { + return Registry.gluCheckExtension(extName, extString); + } + + /** + * Method gluBuild2DMipmaps + * @param target + * @param components + * @param width + * @param height + * @param format + * @param type + * @param data + * @return int + */ + public static int gluBuild2DMipmaps( + int target, + int components, + int width, + int height, + int format, + int type, + ByteBuffer data) { + + return MipMap.gluBuild2DMipmaps(target, components, width, height, format, type, data); + } + + /** + * Method gluScaleImage. + * @param format + * @param widthIn + * @param heightIn + * @param typeIn + * @param dataIn + * @param widthOut + * @param heightOut + * @param typeOut + * @param dataOut + * @return int + */ + public static int gluScaleImage( + int format, + int widthIn, + int heightIn, + int typeIn, + ByteBuffer dataIn, + int widthOut, + int heightOut, + int typeOut, + ByteBuffer dataOut) { + + return MipMap.gluScaleImage(format, widthIn, heightIn, typeIn, dataIn, widthOut, heightOut, typeOut, dataOut); + } + + public static String gluErrorString(int error_code) { + switch (error_code) { + case GLU.GLU_INVALID_ENUM: + return "Invalid enum (glu)"; + case GLU.GLU_INVALID_VALUE: + return "Invalid value (glu)"; + case GLU.GLU_OUT_OF_MEMORY: + return "Out of memory (glu)"; + default: + return Util.translateGLErrorString(error_code); + } + } + + public static GLUtessellator gluNewTess() { + return new GLUtessellatorImpl(); + } +} diff --git a/src/java/org/lwjgl/util/glu/GLUtessellator.java b/src/java/org/lwjgl/util/glu/GLUtessellator.java new file mode 100644 index 0000000..c07c6e4 --- /dev/null +++ b/src/java/org/lwjgl/util/glu/GLUtessellator.java @@ -0,0 +1,72 @@ +/* + * 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.glu; + +public interface GLUtessellator { + + public abstract void gluDeleteTess(); + + public abstract void gluTessProperty(int which, double value); + + /* Returns tessellator property */ + public abstract void gluGetTessProperty(int which, double[] value, + int value_offset); /* gluGetTessProperty() */ + + public abstract void gluTessNormal(double x, double y, double z); + + public abstract void gluTessCallback(int which, + GLUtessellatorCallback aCallback); + + public abstract void gluTessVertex(double[] coords, int coords_offset, + Object vertexData); + + public abstract void gluTessBeginPolygon(Object data); + + public abstract void gluTessBeginContour(); + + public abstract void gluTessEndContour(); + + public abstract void gluTessEndPolygon(); + + /*******************************************************/ + + /* Obsolete calls -- for backward compatibility */ + + public abstract void gluBeginPolygon(); + + /*ARGSUSED*/ + public abstract void gluNextContour(int type); + + public abstract void gluEndPolygon(); + +} \ No newline at end of file diff --git a/src/java/org/lwjgl/util/glu/GLUtessellatorCallback.java b/src/java/org/lwjgl/util/glu/GLUtessellatorCallback.java new file mode 100644 index 0000000..3f3413f --- /dev/null +++ b/src/java/org/lwjgl/util/glu/GLUtessellatorCallback.java @@ -0,0 +1,388 @@ +/* + * 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. + */ + +/* +* Portions Copyright (C) 2003-2006 Sun Microsystems, Inc. +* All rights reserved. +*/ + +/* +** License Applicability. Except to the extent portions of this file are +** made subject to an alternative license as permitted in the SGI Free +** Software License B, Version 1.1 (the "License"), the contents of this +** file are subject only to the provisions of the License. You may not use +** this file except in compliance with the License. You may obtain a copy +** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 +** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: +** +** http://oss.sgi.com/projects/FreeB +** +** Note that, as provided in the License, the Software is distributed on an +** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS +** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND +** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A +** PARTICULAR PURPOSE, AND NON-INFRINGEMENT. +** +** NOTE: The Original Code (as defined below) has been licensed to Sun +** Microsystems, Inc. ("Sun") under the SGI Free Software License B +** (Version 1.1), shown above ("SGI License"). Pursuant to Section +** 3.2(3) of the SGI License, Sun is distributing the Covered Code to +** you under an alternative license ("Alternative License"). This +** Alternative License includes all of the provisions of the SGI License +** except that Section 2.2 and 11 are omitted. Any differences between +** the Alternative License and the SGI License are offered solely by Sun +** and not by SGI. +** +** Original Code. The Original Code is: OpenGL Sample Implementation, +** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics, +** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc. +** Copyright in any portions created by third parties is as indicated +** elsewhere herein. All Rights Reserved. +** +** Additional Notice Provisions: The application programming interfaces +** established by SGI in conjunction with the Original Code are The +** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released +** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version +** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X +** Window System(R) (Version 1.3), released October 19, 1998. This software +** was created using the OpenGL(R) version 1.2.1 Sample Implementation +** published by SGI, but has not been independently verified as being +** compliant with the OpenGL(R) version 1.2.1 Specification. +** +** Author: Eric Veach, July 1994 +** Java Port: Pepijn Van Eeckhoudt, July 2003 +** Java Port: Nathan Parker Burg, August 2003 +*/ +package org.lwjgl.util.glu; + +/** + * GLUtessellatorCallback interface provides methods that the user will + * override to define the callbacks for a tessellation object. + * + * @author Eric Veach, July 1994 + * @author Java Port: Pepijn Van Eeckhoudt, July 2003 + * @author Java Port: Nathan Parker Burg, August 2003 + */ +public interface GLUtessellatorCallback { + /** + * The begin callback method is invoked like + * {@link javax.media.opengl.GL#glBegin glBegin} to indicate the start of a + * (triangle) primitive. The method takes a single argument of type int. If + * the GLU_TESS_BOUNDARY_ONLY property is set to GL_FALSE, then + * the argument is set to either GL_TRIANGLE_FAN, + * GL_TRIANGLE_STRIP, or GL_TRIANGLES. If the + * GLU_TESS_BOUNDARY_ONLY property is set to GL_TRUE, then the + * argument will be set to GL_LINE_LOOP. + * + * @param type + * Specifics the type of begin/end pair being defined. The following + * values are valid: GL_TRIANGLE_FAN, GL_TRIANGLE_STRIP, + * GL_TRIANGLES or GL_LINE_LOOP. + * + * @see GLU#gluTessCallback gluTessCallback + * @see #end end + * @see #begin begin + */ + public void begin(int type); + + /** + * The same as the {@link #begin begin} callback method except that + * it takes an additional reference argument. This reference is + * identical to the opaque reference provided when {@link + * GLU#gluTessBeginPolygon gluTessBeginPolygon} was called. + * + * @param type + * Specifics the type of begin/end pair being defined. The following + * values are valid: GL_TRIANGLE_FAN, GL_TRIANGLE_STRIP, + * GL_TRIANGLES or GL_LINE_LOOP. + * @param polygonData + * Specifics a reference to user-defined data. + * + * @see GLU#gluTessCallback gluTessCallback + * @see #endData endData + * @see #begin begin + */ + public void beginData(int type, Object polygonData); + + + /** + * The edgeFlag callback method is similar to + * {@link javax.media.opengl.GL#glEdgeFlag glEdgeFlag}. The method takes + * a single boolean boundaryEdge that indicates which edges lie on the + * polygon boundary. If the boundaryEdge is GL_TRUE, then each vertex + * that follows begins an edge that lies on the polygon boundary, that is, + * an edge that separates an interior region from an exterior one. If the + * boundaryEdge is GL_FALSE, then each vertex that follows begins an + * edge that lies in the polygon interior. The edge flag callback (if + * defined) is invoked before the first vertex callback.

    + * + * Since triangle fans and triangle strips do not support edge flags, the + * begin callback is not called with GL_TRIANGLE_FAN or + * GL_TRIANGLE_STRIP if a non-null edge flag callback is provided. + * (If the callback is initialized to null, there is no impact on + * performance). Instead, the fans and strips are converted to independent + * triangles. + * + * @param boundaryEdge + * Specifics which edges lie on the polygon boundary. + * + * @see GLU#gluTessCallback gluTessCallback + * @see #edgeFlagData edgeFlagData + */ + public void edgeFlag(boolean boundaryEdge); + + + /** + * The same as the {@link #edgeFlag edgeFlage} callback method + * except that it takes an additional reference argument. This + * reference is identical to the opaque reference provided when + * {@link GLU#gluTessBeginPolygon gluTessBeginPolygon} was called. + * + * @param boundaryEdge + * Specifics which edges lie on the polygon boundary. + * @param polygonData + * Specifics a reference to user-defined data. + * + * @see GLU#gluTessCallback gluTessCallback + * @see #edgeFlag edgeFlag + */ + public void edgeFlagData(boolean boundaryEdge, Object polygonData); + + + /** + * The vertex callback method is invoked between the {@link + * #begin begin} and {@link #end end} callback methods. It is + * similar to {@link javax.media.opengl.GL#glVertex3f glVertex3f}, + * and it defines the vertices of the triangles created by the + * tessellation process. The method takes a reference as its only + * argument. This reference is identical to the opaque reference + * provided by the user when the vertex was described (see {@link + * GLU#gluTessVertex gluTessVertex}). + * + * @param vertexData + * Specifics a reference to the vertices of the triangles created + * byt the tessellatin process. + * + * @see GLU#gluTessCallback gluTessCallback + * @see #vertexData vertexData + */ + public void vertex(Object vertexData); + + + /** + * The same as the {@link #vertex vertex} callback method except + * that it takes an additional reference argument. This reference is + * identical to the opaque reference provided when {@link + * GLU#gluTessBeginPolygon gluTessBeginPolygon} was called. + * + * @param vertexData + * Specifics a reference to the vertices of the triangles created + * byt the tessellatin process. + * @param polygonData + * Specifics a reference to user-defined data. + * + * @see GLU#gluTessCallback gluTessCallback + * @see #vertex vertex + */ + public void vertexData(Object vertexData, Object polygonData); + + + /** + * The end callback serves the same purpose as + * {@link javax.media.opengl.GL#glEnd glEnd}. It indicates the end of a + * primitive and it takes no arguments. + * + * @see GLU#gluTessCallback gluTessCallback + * @see #begin begin + * @see #endData endData + */ + public void end(); + + + /** + * The same as the {@link #end end} callback method except that it + * takes an additional reference argument. This reference is + * identical to the opaque reference provided when {@link + * GLU#gluTessBeginPolygon gluTessBeginPolygon} was called. + * + * @param polygonData + * Specifics a reference to user-defined data. + * + * @see GLU#gluTessCallback gluTessCallback + * @see #beginData beginData + * @see #end end + */ + public void endData(Object polygonData); + + + /** + * The combine callback method is called to create a new vertex when + * the tessellation detects an intersection, or wishes to merge features. The + * method takes four arguments: an array of three elements each of type + * double, an array of four references, an array of four elements each of + * type float, and a reference to a reference.

    + * + * The vertex is defined as a linear combination of up to four existing + * vertices, stored in data. The coefficients of the linear combination + * are given by weight; these weights always add up to 1. All vertex + * pointers are valid even when some of the weights are 0. coords gives + * the location of the new vertex.

    + * + * The user must allocate another vertex, interpolate parameters using + * data and weight, and return the new vertex pointer in + * outData. This handle is supplied during rendering callbacks. The + * user is responsible for freeing the memory some time after + * {@link GLU#gluTessEndPolygon gluTessEndPolygon} is + * called.

    + * + * For example, if the polygon lies in an arbitrary plane in 3-space, and a + * color is associated with each vertex, the GLU_TESS_COMBINE + * callback might look like this: + * + *

    +   *         void myCombine(double[] coords, Object[] data,
    +   *                        float[] weight, Object[] outData)
    +   *         {
    +   *            MyVertex newVertex = new MyVertex();
    +   *
    +   *            newVertex.x = coords[0];
    +   *            newVertex.y = coords[1];
    +   *            newVertex.z = coords[2];
    +   *            newVertex.r = weight[0]*data[0].r +
    +   *                          weight[1]*data[1].r +
    +   *                          weight[2]*data[2].r +
    +   *                          weight[3]*data[3].r;
    +   *            newVertex.g = weight[0]*data[0].g +
    +   *                          weight[1]*data[1].g +
    +   *                          weight[2]*data[2].g +
    +   *                          weight[3]*data[3].g;
    +   *            newVertex.b = weight[0]*data[0].b +
    +   *                          weight[1]*data[1].b +
    +   *                          weight[2]*data[2].b +
    +   *                          weight[3]*data[3].b;
    +   *            newVertex.a = weight[0]*data[0].a +
    +   *                          weight[1]*data[1].a +
    +   *                          weight[2]*data[2].a +
    +   *                          weight[3]*data[3].a;
    +   *            outData = newVertex;
    +   *         }
    + * + * @param coords + * Specifics the location of the new vertex. + * @param data + * Specifics the vertices used to create the new vertex. + * @param weight + * Specifics the weights used to create the new vertex. + * @param outData + * Reference user the put the coodinates of the new vertex. + * + * @see GLU#gluTessCallback gluTessCallback + * @see #combineData combineData + */ + public void combine(double[] coords, Object[] data, + float[] weight, Object[] outData); + + + /** + * The same as the {@link #combine combine} callback method except + * that it takes an additional reference argument. This reference is + * identical to the opaque reference provided when {@link + * GLU#gluTessBeginPolygon gluTessBeginPolygon} was called. + * + * @param coords + * Specifics the location of the new vertex. + * @param data + * Specifics the vertices used to create the new vertex. + * @param weight + * Specifics the weights used to create the new vertex. + * @param outData + * Reference user the put the coodinates of the new vertex. + * @param polygonData + * Specifics a reference to user-defined data. + * + * @see GLU#gluTessCallback gluTessCallback + * @see #combine combine + */ + public void combineData(double[] coords, Object[] data, + float[] weight, Object[] outData, + Object polygonData); + + + /** + * The error callback method is called when an error is encountered. + * The one argument is of type int; it indicates the specific error that + * occurred and will be set to one of GLU_TESS_MISSING_BEGIN_POLYGON, + * GLU_TESS_MISSING_END_POLYGON, GLU_TESS_MISSING_BEGIN_CONTOUR, + * GLU_TESS_MISSING_END_CONTOUR, GLU_TESS_COORD_TOO_LARGE, + * GLU_TESS_NEED_COMBINE_CALLBACK or GLU_OUT_OF_MEMORY. + * Character strings describing these errors can be retrieved with the + * {@link GLU#gluErrorString gluErrorString} call.

    + * + * The GLU library will recover from the first four errors by inserting the + * missing call(s). GLU_TESS_COORD_TOO_LARGE indicates that some + * vertex coordinate exceeded the predefined constant + * GLU_TESS_MAX_COORD in absolute value, and that the value has been + * clamped. (Coordinate values must be small enough so that two can be + * multiplied together without overflow.) + * GLU_TESS_NEED_COMBINE_CALLBACK indicates that the tessellation + * detected an intersection between two edges in the input data, and the + * GLU_TESS_COMBINE or GLU_TESS_COMBINE_DATA callback was not + * provided. No output is generated. GLU_OUT_OF_MEMORY indicates that + * there is not enough memory so no output is generated. + * + * @param errnum + * Specifics the error number code. + * + * @see GLU#gluTessCallback gluTessCallback + * @see #errorData errorData + */ + public void error(int errnum); + + + /** + * The same as the {@link #error error} callback method except that + * it takes an additional reference argument. This reference is + * identical to the opaque reference provided when {@link + * GLU#gluTessBeginPolygon gluTessBeginPolygon} was called. + * + * @param errnum + * Specifics the error number code. + * @param polygonData + * Specifics a reference to user-defined data. + * + * @see GLU#gluTessCallback gluTessCallback + * @see #error error + */ + public void errorData(int errnum, Object polygonData); + + //void mesh(com.sun.opengl.impl.tessellator.GLUmesh mesh); +} diff --git a/src/java/org/lwjgl/util/glu/GLUtessellatorCallbackAdapter.java b/src/java/org/lwjgl/util/glu/GLUtessellatorCallbackAdapter.java new file mode 100644 index 0000000..742529b --- /dev/null +++ b/src/java/org/lwjgl/util/glu/GLUtessellatorCallbackAdapter.java @@ -0,0 +1,116 @@ +/* + * 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. + */ + +/* +* Portions Copyright (C) 2003-2006 Sun Microsystems, Inc. +* All rights reserved. +*/ + +/* +** License Applicability. Except to the extent portions of this file are +** made subject to an alternative license as permitted in the SGI Free +** Software License B, Version 1.1 (the "License"), the contents of this +** file are subject only to the provisions of the License. You may not use +** this file except in compliance with the License. You may obtain a copy +** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 +** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: +** +** http://oss.sgi.com/projects/FreeB +** +** Note that, as provided in the License, the Software is distributed on an +** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS +** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND +** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A +** PARTICULAR PURPOSE, AND NON-INFRINGEMENT. +** +** NOTE: The Original Code (as defined below) has been licensed to Sun +** Microsystems, Inc. ("Sun") under the SGI Free Software License B +** (Version 1.1), shown above ("SGI License"). Pursuant to Section +** 3.2(3) of the SGI License, Sun is distributing the Covered Code to +** you under an alternative license ("Alternative License"). This +** Alternative License includes all of the provisions of the SGI License +** except that Section 2.2 and 11 are omitted. Any differences between +** the Alternative License and the SGI License are offered solely by Sun +** and not by SGI. +** +** Original Code. The Original Code is: OpenGL Sample Implementation, +** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics, +** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc. +** Copyright in any portions created by third parties is as indicated +** elsewhere herein. All Rights Reserved. +** +** Additional Notice Provisions: The application programming interfaces +** established by SGI in conjunction with the Original Code are The +** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released +** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version +** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X +** Window System(R) (Version 1.3), released October 19, 1998. This software +** was created using the OpenGL(R) version 1.2.1 Sample Implementation +** published by SGI, but has not been independently verified as being +** compliant with the OpenGL(R) version 1.2.1 Specification. +** +** Author: Eric Veach, July 1994 +** Java Port: Pepijn Van Eeckhoudt, July 2003 +** Java Port: Nathan Parker Burg, August 2003 +*/ +package org.lwjgl.util.glu; + +/** + * The GLUtessellatorCallbackAdapter provides a default implementation of + * {@link GLUtessellatorCallback GLUtessellatorCallback} + * with empty callback methods. This class can be extended to provide user + * defined callback methods. + * + * @author Eric Veach, July 1994 + * @author Java Port: Pepijn Van Eechhoudt, July 2003 + * @author Java Port: Nathan Parker Burg, August 2003 + */ + +public class GLUtessellatorCallbackAdapter implements GLUtessellatorCallback { + public void begin(int type) {} + public void edgeFlag(boolean boundaryEdge) {} + public void vertex(Object vertexData) {} + public void end() {} +// public void mesh(com.sun.opengl.impl.tessellator.GLUmesh mesh) {} + public void error(int errnum) {} + public void combine(double[] coords, Object[] data, + float[] weight, Object[] outData) {} + public void beginData(int type, Object polygonData) {} + public void edgeFlagData(boolean boundaryEdge, + Object polygonData) {} + public void vertexData(Object vertexData, Object polygonData) {} + public void endData(Object polygonData) {} + public void errorData(int errnum, Object polygonData) {} + public void combineData(double[] coords, Object[] data, + float[] weight, Object[] outData, + Object polygonData) {} +} diff --git a/src/java/org/lwjgl/util/glu/MipMap.java b/src/java/org/lwjgl/util/glu/MipMap.java new file mode 100644 index 0000000..229f52f --- /dev/null +++ b/src/java/org/lwjgl/util/glu/MipMap.java @@ -0,0 +1,351 @@ +/* + * 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.glu; + +import java.nio.ByteBuffer; + +import org.lwjgl.BufferUtils; +import org.lwjgl.opengl.GL11; + +/** + * MipMap.java + * + * + * Created 11-jan-2004 + * @author Erik Duijs + */ +public class MipMap extends Util { + + /** + * Method gluBuild2DMipmaps + * + * @param target + * @param components + * @param width + * @param height + * @param format + * @param type + * @param data + * @return int + */ + public static int gluBuild2DMipmaps(final int target, + final int components, final int width, final int height, + final int format, final int type, final ByteBuffer data) { + if ( width < 1 || height < 1 ) return GLU.GLU_INVALID_VALUE; + + final int bpp = bytesPerPixel(format, type); + if ( bpp == 0 ) + return GLU.GLU_INVALID_ENUM; + + final int maxSize = glGetIntegerv(GL11.GL_MAX_TEXTURE_SIZE); + + int w = nearestPower(width); + if ( w > maxSize ) + w = maxSize; + + int h = nearestPower(height); + if ( h > maxSize ) + h = maxSize; + + // Get current glPixelStore state + PixelStoreState pss = new PixelStoreState(); + + // set pixel packing + GL11.glPixelStorei(GL11.GL_PACK_ROW_LENGTH, 0); + GL11.glPixelStorei(GL11.GL_PACK_ALIGNMENT, 1); + GL11.glPixelStorei(GL11.GL_PACK_SKIP_ROWS, 0); + GL11.glPixelStorei(GL11.GL_PACK_SKIP_PIXELS, 0); + + ByteBuffer image; + int retVal = 0; + boolean done = false; + + if ( w != width || h != height ) { + // must rescale image to get "top" mipmap texture image + image = BufferUtils.createByteBuffer((w + 4) * h * bpp); + int error = gluScaleImage(format, width, height, type, data, w, h, type, image); + if ( error != 0 ) { + retVal = error; + done = true; + } + + /* set pixel unpacking */ + GL11.glPixelStorei(GL11.GL_UNPACK_ROW_LENGTH, 0); + GL11.glPixelStorei(GL11.GL_UNPACK_ALIGNMENT, 1); + GL11.glPixelStorei(GL11.GL_UNPACK_SKIP_ROWS, 0); + GL11.glPixelStorei(GL11.GL_UNPACK_SKIP_PIXELS, 0); + } else { + image = data; + } + + ByteBuffer bufferA = null; + ByteBuffer bufferB = null; + + int level = 0; + while ( !done ) { + if (image != data) { + /* set pixel unpacking */ + GL11.glPixelStorei(GL11.GL_UNPACK_ROW_LENGTH, 0); + GL11.glPixelStorei(GL11.GL_UNPACK_ALIGNMENT, 1); + GL11.glPixelStorei(GL11.GL_UNPACK_SKIP_ROWS, 0); + GL11.glPixelStorei(GL11.GL_UNPACK_SKIP_PIXELS, 0); + } + + GL11.glTexImage2D(target, level, components, w, h, 0, format, type, image); + + if ( w == 1 && h == 1 ) + break; + + final int newW = (w < 2) ? 1 : w >> 1; + final int newH = (h < 2) ? 1 : h >> 1; + + final ByteBuffer newImage; + + if ( bufferA == null ) + newImage = (bufferA = BufferUtils.createByteBuffer((newW + 4) * newH * bpp)); + else if ( bufferB == null ) + newImage = (bufferB = BufferUtils.createByteBuffer((newW + 4) * newH * bpp)); + else + newImage = bufferB; + + int error = gluScaleImage(format, w, h, type, image, newW, newH, type, newImage); + if ( error != 0 ) { + retVal = error; + done = true; + } + + image = newImage; + if ( bufferB != null ) + bufferB = bufferA; + + w = newW; + h = newH; + level++; + } + + // Restore original glPixelStore state + pss.save(); + + return retVal; + } + + /** + * Method gluScaleImage. + * @param format + * @param widthIn + * @param heightIn + * @param typein + * @param dataIn + * @param widthOut + * @param heightOut + * @param typeOut + * @param dataOut + * @return int + */ + public static int gluScaleImage(int format, + int widthIn, int heightIn, int typein, ByteBuffer dataIn, + int widthOut, int heightOut, int typeOut, ByteBuffer dataOut) { + + final int components = compPerPix(format); + if ( components == -1 ) + return GLU.GLU_INVALID_ENUM; + + int i, j, k; + float[] tempIn, tempOut; + float sx, sy; + int sizein, sizeout; + int rowstride, rowlen; + + // temp image data + tempIn = new float[widthIn * heightIn * components]; + tempOut = new float[widthOut * heightOut * components]; + + // Determine bytes per input type + switch ( typein ) { + case GL11.GL_UNSIGNED_BYTE: + sizein = 1; + break; + case GL11.GL_FLOAT: + sizein = 4; + break; + default: + return GL11.GL_INVALID_ENUM; + } + + // Determine bytes per output type + switch ( typeOut ) { + case GL11.GL_UNSIGNED_BYTE: + sizeout = 1; + break; + case GL11.GL_FLOAT: + sizeout = 4; + break; + default: + return GL11.GL_INVALID_ENUM; + } + + // Get glPixelStore state + PixelStoreState pss = new PixelStoreState(); + + //Unpack the pixel data and convert to floating point + if ( pss.unpackRowLength > 0 ) + rowlen = pss.unpackRowLength; + else + rowlen = widthIn; + + if ( sizein >= pss.unpackAlignment ) + rowstride = components * rowlen; + else + rowstride = pss.unpackAlignment / sizein * ceil(components * rowlen * sizein, pss.unpackAlignment); + + switch ( typein ) { + case GL11.GL_UNSIGNED_BYTE: + k = 0; + dataIn.rewind(); + for ( i = 0; i < heightIn; i++ ) { + int ubptr = i * rowstride + pss.unpackSkipRows * rowstride + pss.unpackSkipPixels * components; + for ( j = 0; j < widthIn * components; j++ ) { + tempIn[k++] = dataIn.get(ubptr++) & 0xff; + } + } + break; + case GL11.GL_FLOAT: + k = 0; + dataIn.rewind(); + for ( i = 0; i < heightIn; i++ ) + { + int fptr = 4 * (i * rowstride + pss.unpackSkipRows * rowstride + pss.unpackSkipPixels * components); + for ( j = 0; j < widthIn * components; j++ ) + { + tempIn[k++] = dataIn.getFloat(fptr); + fptr += 4; + } + } + break; + default: + return GLU.GLU_INVALID_ENUM; + } + + // Do scaling + sx = (float)widthIn / (float)widthOut; + sy = (float)heightIn / (float)heightOut; + + float[] c = new float[components]; + int src, dst; + + for ( int iy = 0; iy < heightOut; iy++ ) { + for ( int ix = 0; ix < widthOut; ix++ ) { + int x0 = (int)(ix * sx); + int x1 = (int)((ix + 1) * sx); + int y0 = (int)(iy * sy); + int y1 = (int)((iy + 1) * sy); + + int readPix = 0; + + // reset weighted pixel + for ( int ic = 0; ic < components; ic++ ) { + c[ic] = 0; + } + + // create weighted pixel + for ( int ix0 = x0; ix0 < x1; ix0++ ) { + for ( int iy0 = y0; iy0 < y1; iy0++ ) { + + src = (iy0 * widthIn + ix0) * components; + + for ( int ic = 0; ic < components; ic++ ) { + c[ic] += tempIn[src + ic]; + } + + readPix++; + } + } + + // store weighted pixel + dst = (iy * widthOut + ix) * components; + + if ( readPix == 0 ) { + // Image is sized up, caused by non power of two texture as input + src = (y0 * widthIn + x0) * components; + for ( int ic = 0; ic < components; ic++ ) { + tempOut[dst++] = tempIn[src + ic]; + } + } else { + // sized down + for ( k = 0; k < components; k++ ) { + tempOut[dst++] = c[k] / readPix; + } + } + } + } + + + // Convert temp output + if ( pss.packRowLength > 0 ) + rowlen = pss.packRowLength; + else + rowlen = widthOut; + + if ( sizeout >= pss.packAlignment ) + rowstride = components * rowlen; + else + rowstride = pss.packAlignment / sizeout * ceil(components * rowlen * sizeout, pss.packAlignment); + + switch ( typeOut ) { + case GL11.GL_UNSIGNED_BYTE: + k = 0; + for ( i = 0; i < heightOut; i++ ) { + int ubptr = i * rowstride + pss.packSkipRows * rowstride + pss.packSkipPixels * components; + + for ( j = 0; j < widthOut * components; j++ ) { + dataOut.put(ubptr++, (byte)tempOut[k++]); + } + } + break; + case GL11.GL_FLOAT: + k = 0; + for ( i = 0; i < heightOut; i++ ) { + int fptr = 4 * (i * rowstride + pss.unpackSkipRows * rowstride + pss.unpackSkipPixels * components); + + for ( j = 0; j < widthOut * components; j++ ) { + dataOut.putFloat(fptr, tempOut[k++]); + fptr += 4; + } + } + break; + default: + return GLU.GLU_INVALID_ENUM; + } + + return 0; + } +} diff --git a/src/java/org/lwjgl/util/glu/PartialDisk.java b/src/java/org/lwjgl/util/glu/PartialDisk.java new file mode 100644 index 0000000..269b5b0 --- /dev/null +++ b/src/java/org/lwjgl/util/glu/PartialDisk.java @@ -0,0 +1,357 @@ +/* + * 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.glu; + +import org.lwjgl.opengl.GL11; + +/** + * PartialDisk.java + * + * + * Created 23-dec-2003 + * + * @author Erik Duijs + */ +public class PartialDisk extends Quadric { + + private static final int CACHE_SIZE = 240; + + /** + * Constructor for PartialDisk. + */ + public PartialDisk() { + super(); + } + + /** + * renders a partial disk on the z=0 plane. A partial disk is similar to a + * full disk, except that only the subset of the disk from startAngle + * through startAngle + sweepAngle is included (where 0 degrees is along + * the +y axis, 90 degrees along the +x axis, 180 along the -y axis, and + * 270 along the -x axis). + * + * The partial disk has a radius of outerRadius, and contains a concentric + * circular hole with a radius of innerRadius. If innerRadius is zero, then + * no hole is generated. The partial disk is subdivided around the z axis + * into slices (like pizza slices), and also about the z axis into rings + * (as specified by slices and loops, respectively). + * + * With respect to orientation, the +z side of the partial disk is + * considered to be outside (see gluQuadricOrientation). This means that if + * the orientation is set to GLU.GLU_OUTSIDE, then any normals generated point + * along the +z axis. Otherwise, they point along the -z axis. + * + * If texturing is turned on (with gluQuadricTexture), texture coordinates + * are generated linearly such that where r=outerRadius, the value at (r, 0, 0) + * is (1, 0.5), at (0, r, 0) it is (0.5, 1), at (-r, 0, 0) it is (0, 0.5), + * and at (0, -r, 0) it is (0.5, 0). + */ + public void draw( + float innerRadius, + float outerRadius, + int slices, + int loops, + float startAngle, + float sweepAngle) { + + int i, j; + float[] sinCache = new float[CACHE_SIZE]; + float[] cosCache = new float[CACHE_SIZE]; + float angle; + float sintemp, costemp; + float deltaRadius; + float radiusLow, radiusHigh; + float texLow = 0, texHigh = 0; + float angleOffset; + int slices2; + int finish; + + if (slices >= CACHE_SIZE) + slices = CACHE_SIZE - 1; + if (slices < 2 + || loops < 1 + || outerRadius <= 0.0f + || innerRadius < 0.0f + || innerRadius > outerRadius) { + //gluQuadricError(qobj, GLU.GLU_INVALID_VALUE); + System.err.println("PartialDisk: GLU_INVALID_VALUE"); + return; + } + + if (sweepAngle < -360.0f) + sweepAngle = 360.0f; + if (sweepAngle > 360.0f) + sweepAngle = 360.0f; + if (sweepAngle < 0) { + startAngle += sweepAngle; + sweepAngle = -sweepAngle; + } + + if (sweepAngle == 360.0f) { + slices2 = slices; + } else { + slices2 = slices + 1; + } + + /* Compute length (needed for normal calculations) */ + deltaRadius = outerRadius - innerRadius; + + /* Cache is the vertex locations cache */ + + angleOffset = startAngle / 180.0f * GLU.PI; + for (i = 0; i <= slices; i++) { + angle = angleOffset + ((GLU.PI * sweepAngle) / 180.0f) * i / slices; + sinCache[i] = sin(angle); + cosCache[i] = cos(angle); + } + + if (sweepAngle == 360.0f) { + sinCache[slices] = sinCache[0]; + cosCache[slices] = cosCache[0]; + } + + switch (super.normals) { + case GLU.GLU_FLAT : + case GLU.GLU_SMOOTH : + if (super.orientation == GLU.GLU_OUTSIDE) { + GL11.glNormal3f(0.0f, 0.0f, 1.0f); + } else { + GL11.glNormal3f(0.0f, 0.0f, -1.0f); + } + break; + default : + case GLU.GLU_NONE : + break; + } + + switch (super.drawStyle) { + case GLU.GLU_FILL : + if (innerRadius == .0f) { + finish = loops - 1; + /* Triangle strip for inner polygons */ + GL11.glBegin(GL11.GL_TRIANGLE_FAN); + if (super.textureFlag) { + GL11.glTexCoord2f(0.5f, 0.5f); + } + GL11.glVertex3f(0.0f, 0.0f, 0.0f); + radiusLow = outerRadius - deltaRadius * ((float) (loops - 1) / loops); + if (super.textureFlag) { + texLow = radiusLow / outerRadius / 2; + } + + if (super.orientation == GLU.GLU_OUTSIDE) { + for (i = slices; i >= 0; i--) { + if (super.textureFlag) { + GL11.glTexCoord2f( + texLow * sinCache[i] + 0.5f, + texLow * cosCache[i] + 0.5f); + } + GL11.glVertex3f(radiusLow * sinCache[i], radiusLow * cosCache[i], 0.0f); + } + } else { + for (i = 0; i <= slices; i++) { + if (super.textureFlag) { + GL11.glTexCoord2f( + texLow * sinCache[i] + 0.5f, + texLow * cosCache[i] + 0.5f); + } + GL11.glVertex3f(radiusLow * sinCache[i], radiusLow * cosCache[i], 0.0f); + } + } + GL11.glEnd(); + } else { + finish = loops; + } + for (j = 0; j < finish; j++) { + radiusLow = outerRadius - deltaRadius * ((float) j / loops); + radiusHigh = outerRadius - deltaRadius * ((float) (j + 1) / loops); + if (super.textureFlag) { + texLow = radiusLow / outerRadius / 2; + texHigh = radiusHigh / outerRadius / 2; + } + + GL11.glBegin(GL11.GL_QUAD_STRIP); + for (i = 0; i <= slices; i++) { + if (super.orientation == GLU.GLU_OUTSIDE) { + if (super.textureFlag) { + GL11.glTexCoord2f( + texLow * sinCache[i] + 0.5f, + texLow * cosCache[i] + 0.5f); + } + GL11.glVertex3f(radiusLow * sinCache[i], radiusLow * cosCache[i], 0.0f); + + if (super.textureFlag) { + GL11.glTexCoord2f( + texHigh * sinCache[i] + 0.5f, + texHigh * cosCache[i] + 0.5f); + } + GL11.glVertex3f( + radiusHigh * sinCache[i], + radiusHigh * cosCache[i], + 0.0f); + } else { + if (super.textureFlag) { + GL11.glTexCoord2f( + texHigh * sinCache[i] + 0.5f, + texHigh * cosCache[i] + 0.5f); + } + GL11.glVertex3f( + radiusHigh * sinCache[i], + radiusHigh * cosCache[i], + 0.0f); + + if (super.textureFlag) { + GL11.glTexCoord2f( + texLow * sinCache[i] + 0.5f, + texLow * cosCache[i] + 0.5f); + } + GL11.glVertex3f(radiusLow * sinCache[i], radiusLow * cosCache[i], 0.0f); + } + } + GL11.glEnd(); + } + break; + case GLU.GLU_POINT : + GL11.glBegin(GL11.GL_POINTS); + for (i = 0; i < slices2; i++) { + sintemp = sinCache[i]; + costemp = cosCache[i]; + for (j = 0; j <= loops; j++) { + radiusLow = outerRadius - deltaRadius * ((float) j / loops); + + if (super.textureFlag) { + texLow = radiusLow / outerRadius / 2; + + GL11.glTexCoord2f( + texLow * sinCache[i] + 0.5f, + texLow * cosCache[i] + 0.5f); + } + GL11.glVertex3f(radiusLow * sintemp, radiusLow * costemp, 0.0f); + } + } + GL11.glEnd(); + break; + case GLU.GLU_LINE : + if (innerRadius == outerRadius) { + GL11.glBegin(GL11.GL_LINE_STRIP); + + for (i = 0; i <= slices; i++) { + if (super.textureFlag) { + GL11.glTexCoord2f(sinCache[i] / 2 + 0.5f, cosCache[i] / 2 + 0.5f); + } + GL11.glVertex3f(innerRadius * sinCache[i], innerRadius * cosCache[i], 0.0f); + } + GL11.glEnd(); + break; + } + for (j = 0; j <= loops; j++) { + radiusLow = outerRadius - deltaRadius * ((float) j / loops); + if (super.textureFlag) { + texLow = radiusLow / outerRadius / 2; + } + + GL11.glBegin(GL11.GL_LINE_STRIP); + for (i = 0; i <= slices; i++) { + if (super.textureFlag) { + GL11.glTexCoord2f( + texLow * sinCache[i] + 0.5f, + texLow * cosCache[i] + 0.5f); + } + GL11.glVertex3f(radiusLow * sinCache[i], radiusLow * cosCache[i], 0.0f); + } + GL11.glEnd(); + } + for (i = 0; i < slices2; i++) { + sintemp = sinCache[i]; + costemp = cosCache[i]; + GL11.glBegin(GL11.GL_LINE_STRIP); + for (j = 0; j <= loops; j++) { + radiusLow = outerRadius - deltaRadius * ((float) j / loops); + if (super.textureFlag) { + texLow = radiusLow / outerRadius / 2; + } + + if (super.textureFlag) { + GL11.glTexCoord2f( + texLow * sinCache[i] + 0.5f, + texLow * cosCache[i] + 0.5f); + } + GL11.glVertex3f(radiusLow * sintemp, radiusLow * costemp, 0.0f); + } + GL11.glEnd(); + } + break; + case GLU.GLU_SILHOUETTE : + if (sweepAngle < 360.0f) { + for (i = 0; i <= slices; i += slices) { + sintemp = sinCache[i]; + costemp = cosCache[i]; + GL11.glBegin(GL11.GL_LINE_STRIP); + for (j = 0; j <= loops; j++) { + radiusLow = outerRadius - deltaRadius * ((float) j / loops); + + if (super.textureFlag) { + texLow = radiusLow / outerRadius / 2; + GL11.glTexCoord2f( + texLow * sinCache[i] + 0.5f, + texLow * cosCache[i] + 0.5f); + } + GL11.glVertex3f(radiusLow * sintemp, radiusLow * costemp, 0.0f); + } + GL11.glEnd(); + } + } + for (j = 0; j <= loops; j += loops) { + radiusLow = outerRadius - deltaRadius * ((float) j / loops); + if (super.textureFlag) { + texLow = radiusLow / outerRadius / 2; + } + + GL11.glBegin(GL11.GL_LINE_STRIP); + for (i = 0; i <= slices; i++) { + if (super.textureFlag) { + GL11.glTexCoord2f( + texLow * sinCache[i] + 0.5f, + texLow * cosCache[i] + 0.5f); + } + GL11.glVertex3f(radiusLow * sinCache[i], radiusLow * cosCache[i], 0.0f); + } + GL11.glEnd(); + if (innerRadius == outerRadius) + break; + } + break; + default : + break; + } + } +} diff --git a/src/java/org/lwjgl/util/glu/PixelStoreState.java b/src/java/org/lwjgl/util/glu/PixelStoreState.java new file mode 100644 index 0000000..c93686f --- /dev/null +++ b/src/java/org/lwjgl/util/glu/PixelStoreState.java @@ -0,0 +1,84 @@ +/* + * 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.glu; + +import org.lwjgl.opengl.GL11; + +/** + * PixelStoreState.java + * + * + * Created 11-jan-2004 + * @author Erik Duijs + */ +class PixelStoreState extends Util { + + public int unpackRowLength; + public int unpackAlignment; + public int unpackSkipRows; + public int unpackSkipPixels; + public int packRowLength; + public int packAlignment; + public int packSkipRows; + public int packSkipPixels; + + /** + * Constructor for PixelStoreState. + */ + PixelStoreState() { + super(); + load(); + } + + public void load() { + unpackRowLength = glGetIntegerv(GL11.GL_UNPACK_ROW_LENGTH); + unpackAlignment = glGetIntegerv(GL11.GL_UNPACK_ALIGNMENT); + unpackSkipRows = glGetIntegerv(GL11.GL_UNPACK_SKIP_ROWS); + unpackSkipPixels = glGetIntegerv(GL11.GL_UNPACK_SKIP_PIXELS); + packRowLength = glGetIntegerv(GL11.GL_PACK_ROW_LENGTH); + packAlignment = glGetIntegerv(GL11.GL_PACK_ALIGNMENT); + packSkipRows = glGetIntegerv(GL11.GL_PACK_SKIP_ROWS); + packSkipPixels = glGetIntegerv(GL11.GL_PACK_SKIP_PIXELS); + } + + public void save() { + GL11.glPixelStorei(GL11.GL_UNPACK_ROW_LENGTH, unpackRowLength); + GL11.glPixelStorei(GL11.GL_UNPACK_ALIGNMENT, unpackAlignment); + GL11.glPixelStorei(GL11.GL_UNPACK_SKIP_ROWS, unpackSkipRows); + GL11.glPixelStorei(GL11.GL_UNPACK_SKIP_PIXELS, unpackSkipPixels); + GL11.glPixelStorei(GL11.GL_PACK_ROW_LENGTH, packRowLength); + GL11.glPixelStorei(GL11.GL_PACK_ALIGNMENT, packAlignment); + GL11.glPixelStorei(GL11.GL_PACK_SKIP_ROWS, packSkipRows); + GL11.glPixelStorei(GL11.GL_PACK_SKIP_PIXELS, packSkipPixels); + } + +} diff --git a/src/java/org/lwjgl/util/glu/Project.java b/src/java/org/lwjgl/util/glu/Project.java new file mode 100644 index 0000000..552a2a6 --- /dev/null +++ b/src/java/org/lwjgl/util/glu/Project.java @@ -0,0 +1,410 @@ +/* + * 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.glu; + +import java.nio.FloatBuffer; +import java.nio.IntBuffer; + +import org.lwjgl.BufferUtils; +import org.lwjgl.opengl.GL11; + +/** + * Project.java + *

    + *

    + * Created 11-jan-2004 + * + * @author Erik Duijs + */ +public class Project extends Util { + + private static final float[] IDENTITY_MATRIX = + new float[] { + 1.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 1.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 1.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 1.0f }; + + private static final FloatBuffer matrix = BufferUtils.createFloatBuffer(16); + private static final FloatBuffer finalMatrix = BufferUtils.createFloatBuffer(16); + + private static final FloatBuffer tempMatrix = BufferUtils.createFloatBuffer(16); + private static final float[] in = new float[4]; + private static final float[] out = new float[4]; + + private static final float[] forward = new float[3]; + private static final float[] side = new float[3]; + private static final float[] up = new float[3]; + + /** + * Make matrix an identity matrix + */ + private static void __gluMakeIdentityf(FloatBuffer m) { + int oldPos = m.position(); + m.put(IDENTITY_MATRIX); + m.position(oldPos); + } + + /** + * Method __gluMultMatrixVecf + * + * @param finalMatrix + * @param in + * @param out + */ + private static void __gluMultMatrixVecf(FloatBuffer m, float[] in, float[] out) { + for (int i = 0; i < 4; i++) { + out[i] = + in[0] * m.get(m.position() + 0*4 + i) + + in[1] * m.get(m.position() + 1*4 + i) + + in[2] * m.get(m.position() + 2*4 + i) + + in[3] * m.get(m.position() + 3*4 + i); + + } + } + + /** + * @param src + * @param inverse + * + * @return + */ + private static boolean __gluInvertMatrixf(FloatBuffer src, FloatBuffer inverse) { + int i, j, k, swap; + float t; + FloatBuffer temp = Project.tempMatrix; + + + for (i = 0; i < 16; i++) { + temp.put(i, src.get(i + src.position())); + } + __gluMakeIdentityf(inverse); + + for (i = 0; i < 4; i++) { + /* + * * Look for largest element in column + */ + swap = i; + for (j = i + 1; j < 4; j++) { + /* + * if (fabs(temp[j][i]) > fabs(temp[i][i])) { swap = j; + */ + if (Math.abs(temp.get(j*4 + i)) > Math.abs(temp.get(i* 4 + i))) { + swap = j; + } + } + + if (swap != i) { + /* + * * Swap rows. + */ + for (k = 0; k < 4; k++) { + t = temp.get(i*4 + k); + temp.put(i*4 + k, temp.get(swap*4 + k)); + temp.put(swap*4 + k, t); + + t = inverse.get(i*4 + k); + inverse.put(i*4 + k, inverse.get(swap*4 + k)); + //inverse.put((i << 2) + k, inverse.get((swap << 2) + k)); + inverse.put(swap*4 + k, t); + //inverse.put((swap << 2) + k, t); + } + } + + if (temp.get(i*4 + i) == 0) { + /* + * * No non-zero pivot. The matrix is singular, which shouldn't * + * happen. This means the user gave us a bad matrix. + */ + return false; + } + + t = temp.get(i*4 + i); + for (k = 0; k < 4; k++) { + temp.put(i*4 + k, temp.get(i*4 + k)/t); + inverse.put(i*4 + k, inverse.get(i*4 + k)/t); + } + for (j = 0; j < 4; j++) { + if (j != i) { + t = temp.get(j*4 + i); + for (k = 0; k < 4; k++) { + temp.put(j*4 + k, temp.get(j*4 + k) - temp.get(i*4 + k) * t); + inverse.put(j*4 + k, inverse.get(j*4 + k) - inverse.get(i*4 + k) * t); + /*inverse.put( + (j << 2) + k, + inverse.get((j << 2) + k) - inverse.get((i << 2) + k) * t);*/ + } + } + } + } + return true; + } + + /** + * @param a + * @param b + * @param r + */ + private static void __gluMultMatricesf(FloatBuffer a, FloatBuffer b, FloatBuffer r) { + for (int i = 0; i < 4; i++) { + for (int j = 0; j < 4; j++) { + r.put(r.position() + i*4 + j, + a.get(a.position() + i*4 + 0) * b.get(b.position() + 0*4 + j) + a.get(a.position() + i*4 + 1) * b.get(b.position() + 1*4 + j) + a.get(a.position() + i*4 + 2) * b.get(b.position() + 2*4 + j) + a.get(a.position() + i*4 + 3) * b.get(b.position() + 3*4 + j)); + } + } + } + + /** + * Method gluPerspective. + * + * @param fovy + * @param aspect + * @param zNear + * @param zFar + */ + public static void gluPerspective(float fovy, float aspect, float zNear, float zFar) { + float sine, cotangent, deltaZ; + float radians = fovy / 2 * GLU.PI / 180; + + deltaZ = zFar - zNear; + sine = (float) Math.sin(radians); + + if ((deltaZ == 0) || (sine == 0) || (aspect == 0)) { + return; + } + + cotangent = (float) Math.cos(radians) / sine; + + __gluMakeIdentityf(matrix); + + matrix.put(0 * 4 + 0, cotangent / aspect); + matrix.put(1 * 4 + 1, cotangent); + matrix.put(2 * 4 + 2, - (zFar + zNear) / deltaZ); + matrix.put(2 * 4 + 3, -1); + matrix.put(3 * 4 + 2, -2 * zNear * zFar / deltaZ); + matrix.put(3 * 4 + 3, 0); + + GL11.glMultMatrix(matrix); + } + + /** + * Method gluLookAt + * + * @param eyex + * @param eyey + * @param eyez + * @param centerx + * @param centery + * @param centerz + * @param upx + * @param upy + * @param upz + */ + public static void gluLookAt( + float eyex, + float eyey, + float eyez, + float centerx, + float centery, + float centerz, + float upx, + float upy, + float upz) { + float[] forward = Project.forward; + float[] side = Project.side; + float[] up = Project.up; + + forward[0] = centerx - eyex; + forward[1] = centery - eyey; + forward[2] = centerz - eyez; + + up[0] = upx; + up[1] = upy; + up[2] = upz; + + normalize(forward); + + /* Side = forward x up */ + cross(forward, up, side); + normalize(side); + + /* Recompute up as: up = side x forward */ + cross(side, forward, up); + + __gluMakeIdentityf(matrix); + matrix.put(0 * 4 + 0, side[0]); + matrix.put(1 * 4 + 0, side[1]); + matrix.put(2 * 4 + 0, side[2]); + + matrix.put(0 * 4 + 1, up[0]); + matrix.put(1 * 4 + 1, up[1]); + matrix.put(2 * 4 + 1, up[2]); + + matrix.put(0 * 4 + 2, -forward[0]); + matrix.put(1 * 4 + 2, -forward[1]); + matrix.put(2 * 4 + 2, -forward[2]); + + GL11.glMultMatrix(matrix); + GL11.glTranslatef(-eyex, -eyey, -eyez); + } + + /** + * Method gluProject + * + * @param objx + * @param objy + * @param objz + * @param modelMatrix + * @param projMatrix + * @param viewport + * @param win_pos + */ + public static boolean gluProject( + float objx, + float objy, + float objz, + FloatBuffer modelMatrix, + FloatBuffer projMatrix, + IntBuffer viewport, + FloatBuffer win_pos) { + + float[] in = Project.in; + float[] out = Project.out; + + in[0] = objx; + in[1] = objy; + in[2] = objz; + in[3] = 1.0f; + + __gluMultMatrixVecf(modelMatrix, in, out); + __gluMultMatrixVecf(projMatrix, out, in); + + if (in[3] == 0.0) + return false; + + in[3] = (1.0f / in[3]) * 0.5f; + + // Map x, y and z to range 0-1 + in[0] = in[0] * in[3] + 0.5f; + in[1] = in[1] * in[3] + 0.5f; + in[2] = in[2] * in[3] + 0.5f; + + // Map x,y to viewport + win_pos.put(0, in[0] * viewport.get(viewport.position() + 2) + viewport.get(viewport.position() + 0)); + win_pos.put(1, in[1] * viewport.get(viewport.position() + 3) + viewport.get(viewport.position() + 1)); + win_pos.put(2, in[2]); + + return true; + } + + /** + * Method gluUnproject + * + * @param winx + * @param winy + * @param winz + * @param modelMatrix + * @param projMatrix + * @param viewport + * @param obj_pos + */ + public static boolean gluUnProject( + float winx, + float winy, + float winz, + FloatBuffer modelMatrix, + FloatBuffer projMatrix, + IntBuffer viewport, + FloatBuffer obj_pos) { + float[] in = Project.in; + float[] out = Project.out; + + __gluMultMatricesf(modelMatrix, projMatrix, finalMatrix); + + if (!__gluInvertMatrixf(finalMatrix, finalMatrix)) + return false; + + in[0] = winx; + in[1] = winy; + in[2] = winz; + in[3] = 1.0f; + + // Map x and y from window coordinates + in[0] = (in[0] - viewport.get(viewport.position() + 0)) / viewport.get(viewport.position() + 2); + in[1] = (in[1] - viewport.get(viewport.position() + 1)) / viewport.get(viewport.position() + 3); + + // Map to range -1 to 1 + in[0] = in[0] * 2 - 1; + in[1] = in[1] * 2 - 1; + in[2] = in[2] * 2 - 1; + + __gluMultMatrixVecf(finalMatrix, in, out); + + if (out[3] == 0.0) + return false; + + out[3] = 1.0f / out[3]; + + obj_pos.put(obj_pos.position() + 0, out[0] * out[3]); + obj_pos.put(obj_pos.position() + 1, out[1] * out[3]); + obj_pos.put(obj_pos.position() + 2, out[2] * out[3]); + + return true; + } + + /** + * Method gluPickMatrix + * + * @param x + * @param y + * @param deltaX + * @param deltaY + * @param viewport + */ + public static void gluPickMatrix( + float x, + float y, + float deltaX, + float deltaY, + IntBuffer viewport) { + if (deltaX <= 0 || deltaY <= 0) { + return; + } + + /* Translate and scale the picked region to the entire window */ + GL11.glTranslatef( + (viewport.get(viewport.position() + 2) - 2 * (x - viewport.get(viewport.position() + 0))) / deltaX, + (viewport.get(viewport.position() + 3) - 2 * (y - viewport.get(viewport.position() + 1))) / deltaY, + 0); + GL11.glScalef(viewport.get(viewport.position() + 2) / deltaX, viewport.get(viewport.position() + 3) / deltaY, 1.0f); + } +} diff --git a/src/java/org/lwjgl/util/glu/Quadric.java b/src/java/org/lwjgl/util/glu/Quadric.java new file mode 100644 index 0000000..9a86c73 --- /dev/null +++ b/src/java/org/lwjgl/util/glu/Quadric.java @@ -0,0 +1,198 @@ +/* + * 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.glu; + +import org.lwjgl.opengl.GL11; + +/** + * Quadric.java + * + * + * Created 22-dec-2003 + * @author Erik Duijs + */ +public class Quadric { + + protected int drawStyle; + protected int orientation; + protected boolean textureFlag; + protected int normals; + + /** + * Constructor for Quadric. + */ + public Quadric() { + super(); + + drawStyle = GLU.GLU_FILL; + orientation = GLU.GLU_OUTSIDE; + textureFlag = false; + normals = GLU.GLU_SMOOTH; + } + + /** + * Call glNormal3f after scaling normal to unit length. + * + * @param x + * @param y + * @param z + */ + protected void normal3f(float x, float y, float z) { + float mag; + + mag = (float)Math.sqrt(x * x + y * y + z * z); + if (mag > 0.00001F) { + x /= mag; + y /= mag; + z /= mag; + } + GL11.glNormal3f(x, y, z); + } + + /** + * specifies the draw style for quadrics. + * + * The legal values are as follows: + * + * GLU.FILL: Quadrics are rendered with polygon primitives. The polygons + * are drawn in a counterclockwise fashion with respect to + * their normals (as defined with glu.quadricOrientation). + * + * GLU.LINE: Quadrics are rendered as a set of lines. + * + * GLU.SILHOUETTE: Quadrics are rendered as a set of lines, except that edges + * separating coplanar faces will not be drawn. + * + * GLU.POINT: Quadrics are rendered as a set of points. + * + * @param drawStyle The drawStyle to set + */ + public void setDrawStyle(int drawStyle) { + this.drawStyle = drawStyle; + } + + /** + * specifies what kind of normals are desired for quadrics. + * The legal values are as follows: + * + * GLU.NONE: No normals are generated. + * + * GLU.FLAT: One normal is generated for every facet of a quadric. + * + * GLU.SMOOTH: One normal is generated for every vertex of a quadric. This + * is the default. + * + * @param normals The normals to set + */ + public void setNormals(int normals) { + this.normals = normals; + } + + /** + * specifies what kind of orientation is desired for. + * The orientation values are as follows: + * + * GLU.OUTSIDE: Quadrics are drawn with normals pointing outward. + * + * GLU.INSIDE: Normals point inward. The default is GLU.OUTSIDE. + * + * Note that the interpretation of outward and inward depends on the quadric + * being drawn. + * + * @param orientation The orientation to set + */ + public void setOrientation(int orientation) { + this.orientation = orientation; + } + + /** + * specifies if texture coordinates should be generated for + * quadrics rendered with qobj. If the value of textureCoords is true, + * then texture coordinates are generated, and if textureCoords is false, + * they are not.. The default is false. + * + * The manner in which texture coordinates are generated depends upon the + * specific quadric rendered. + * + * @param textureFlag The textureFlag to set + */ + public void setTextureFlag(boolean textureFlag) { + this.textureFlag = textureFlag; + } + + + /** + * Returns the drawStyle. + * @return int + */ + public int getDrawStyle() { + return drawStyle; + } + + /** + * Returns the normals. + * @return int + */ + public int getNormals() { + return normals; + } + + /** + * Returns the orientation. + * @return int + */ + public int getOrientation() { + return orientation; + } + + /** + * Returns the textureFlag. + * @return boolean + */ + public boolean getTextureFlag() { + return textureFlag; + } + + protected void TXTR_COORD(float x, float y) { + if (textureFlag) GL11.glTexCoord2f(x,y); + } + + + protected float sin(float r) { + return (float)Math.sin(r); + } + + protected float cos(float r) { + return (float)Math.cos(r); + } + +} diff --git a/src/java/org/lwjgl/util/glu/Registry.java b/src/java/org/lwjgl/util/glu/Registry.java new file mode 100644 index 0000000..05abb5e --- /dev/null +++ b/src/java/org/lwjgl/util/glu/Registry.java @@ -0,0 +1,78 @@ +/* + * 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.glu; + +/** + * Registry.java + * + * + * Created 11-jan-2004 + * @author Erik Duijs + */ +public class Registry extends Util { + + private static final String versionString = "1.3"; + private static final String extensionString = + "GLU_EXT_nurbs_tessellator " + "GLU_EXT_object_space_tess "; + + /** + * Method gluGetString + * @param name + * @return String + */ + public static String gluGetString(int name) { + + if (name == GLU.GLU_VERSION) { + return versionString; + } else if (name == GLU.GLU_EXTENSIONS) { + return extensionString; + } + return null; + } + + /** + * Method gluCheckExtension + * + * @param extName is an extension name. + * @param extString is a string of extensions separated by blank(s). There may or + * may not be leading or trailing blank(s) in extString. + * This works in cases of extensions being prefixes of another like + * GL_EXT_texture and GL_EXT_texture3D. + * @return boolean true if extName is found otherwise it returns false. + */ + public static boolean gluCheckExtension(String extName, String extString) { + if (extString == null || extName == null) + return false; + + return extString.indexOf(extName) != -1; + } +} diff --git a/src/java/org/lwjgl/util/glu/Sphere.java b/src/java/org/lwjgl/util/glu/Sphere.java new file mode 100644 index 0000000..3f8e906 --- /dev/null +++ b/src/java/org/lwjgl/util/glu/Sphere.java @@ -0,0 +1,229 @@ +/* + * 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.glu; + + +import org.lwjgl.opengl.GL11; + +/** + * Sphere.java + * + * + * Created 23-dec-2003 + * @author Erik Duijs + */ +public class Sphere extends Quadric { + + /** + * Constructor + */ + public Sphere() { + super(); + } + + /** + * draws a sphere of the given radius centered around the origin. + * The sphere is subdivided around the z axis into slices and along the z axis + * into stacks (similar to lines of longitude and latitude). + * + * If the orientation is set to GLU.OUTSIDE (with glu.quadricOrientation), then + * any normals generated point away from the center of the sphere. Otherwise, + * they point toward the center of the sphere. + + * If texturing is turned on (with glu.quadricTexture), then texture + * coordinates are generated so that t ranges from 0.0 at z=-radius to 1.0 at + * z=radius (t increases linearly along longitudinal lines), and s ranges from + * 0.0 at the +y axis, to 0.25 at the +x axis, to 0.5 at the -y axis, to 0.75 + * at the -x axis, and back to 1.0 at the +y axis. + */ + public void draw(float radius, int slices, int stacks) { + // TODO + + float rho, drho, theta, dtheta; + float x, y, z; + float s, t, ds, dt; + int i, j, imin, imax; + boolean normals; + float nsign; + + normals = super.normals != GLU.GLU_NONE; + + if (super.orientation == GLU.GLU_INSIDE) { + nsign = -1.0f; + } else { + nsign = 1.0f; + } + + drho = GLU.PI / stacks; + dtheta = 2.0f * GLU.PI / slices; + + if (super.drawStyle == GLU.GLU_FILL) { + if (!super.textureFlag) { + // draw +Z end as a triangle fan + GL11.glBegin(GL11.GL_TRIANGLE_FAN); + GL11.glNormal3f(0.0f, 0.0f, 1.0f); + GL11.glVertex3f(0.0f, 0.0f, nsign * radius); + for (j = 0; j <= slices; j++) { + theta = (j == slices) ? 0.0f : j * dtheta; + x = -sin(theta) * sin(drho); + y = cos(theta) * sin(drho); + z = nsign * cos(drho); + if (normals) { + GL11.glNormal3f(x * nsign, y * nsign, z * nsign); + } + GL11.glVertex3f(x * radius, y * radius, z * radius); + } + GL11.glEnd(); + } + + ds = 1.0f / slices; + dt = 1.0f / stacks; + t = 1.0f; // because loop now runs from 0 + if (super.textureFlag) { + imin = 0; + imax = stacks; + } else { + imin = 1; + imax = stacks - 1; + } + + // draw intermediate stacks as quad strips + for (i = imin; i < imax; i++) { + rho = i * drho; + GL11.glBegin(GL11.GL_QUAD_STRIP); + s = 0.0f; + for (j = 0; j <= slices; j++) { + theta = (j == slices) ? 0.0f : j * dtheta; + x = -sin(theta) * sin(rho); + y = cos(theta) * sin(rho); + z = nsign * cos(rho); + if (normals) { + GL11.glNormal3f(x * nsign, y * nsign, z * nsign); + } + TXTR_COORD(s, t); + GL11.glVertex3f(x * radius, y * radius, z * radius); + x = -sin(theta) * sin(rho + drho); + y = cos(theta) * sin(rho + drho); + z = nsign * cos(rho + drho); + if (normals) { + GL11.glNormal3f(x * nsign, y * nsign, z * nsign); + } + TXTR_COORD(s, t - dt); + s += ds; + GL11.glVertex3f(x * radius, y * radius, z * radius); + } + GL11.glEnd(); + t -= dt; + } + + if (!super.textureFlag) { + // draw -Z end as a triangle fan + GL11.glBegin(GL11.GL_TRIANGLE_FAN); + GL11.glNormal3f(0.0f, 0.0f, -1.0f); + GL11.glVertex3f(0.0f, 0.0f, -radius * nsign); + rho = GLU.PI - drho; + s = 1.0f; + for (j = slices; j >= 0; j--) { + theta = (j == slices) ? 0.0f : j * dtheta; + x = -sin(theta) * sin(rho); + y = cos(theta) * sin(rho); + z = nsign * cos(rho); + if (normals) + GL11.glNormal3f(x * nsign, y * nsign, z * nsign); + s -= ds; + GL11.glVertex3f(x * radius, y * radius, z * radius); + } + GL11.glEnd(); + } + } else if ( + super.drawStyle == GLU.GLU_LINE + || super.drawStyle == GLU.GLU_SILHOUETTE) { + // draw stack lines + for (i = 1; + i < stacks; + i++) { // stack line at i==stacks-1 was missing here + rho = i * drho; + GL11.glBegin(GL11.GL_LINE_LOOP); + for (j = 0; j < slices; j++) { + theta = j * dtheta; + x = cos(theta) * sin(rho); + y = sin(theta) * sin(rho); + z = cos(rho); + if (normals) + GL11.glNormal3f(x * nsign, y * nsign, z * nsign); + GL11.glVertex3f(x * radius, y * radius, z * radius); + } + GL11.glEnd(); + } + // draw slice lines + for (j = 0; j < slices; j++) { + theta = j * dtheta; + GL11.glBegin(GL11.GL_LINE_STRIP); + for (i = 0; i <= stacks; i++) { + rho = i * drho; + x = cos(theta) * sin(rho); + y = sin(theta) * sin(rho); + z = cos(rho); + if (normals) + GL11.glNormal3f(x * nsign, y * nsign, z * nsign); + GL11.glVertex3f(x * radius, y * radius, z * radius); + } + GL11.glEnd(); + } + } else if (super.drawStyle == GLU.GLU_POINT) { + // top and bottom-most points + GL11.glBegin(GL11.GL_POINTS); + if (normals) + GL11.glNormal3f(0.0f, 0.0f, nsign); + GL11.glVertex3f(0.0f, 0.0f, radius); + if (normals) + GL11.glNormal3f(0.0f, 0.0f, -nsign); + GL11.glVertex3f(0.0f, 0.0f, -radius); + + // loop over stacks + for (i = 1; i < stacks - 1; i++) { + rho = i * drho; + for (j = 0; j < slices; j++) { + theta = j * dtheta; + x = cos(theta) * sin(rho); + y = sin(theta) * sin(rho); + z = cos(rho); + if (normals) + GL11.glNormal3f(x * nsign, y * nsign, z * nsign); + GL11.glVertex3f(x * radius, y * radius, z * radius); + } + } + GL11.glEnd(); + } + } + +} diff --git a/src/java/org/lwjgl/util/glu/Util.java b/src/java/org/lwjgl/util/glu/Util.java new file mode 100644 index 0000000..7ad9679 --- /dev/null +++ b/src/java/org/lwjgl/util/glu/Util.java @@ -0,0 +1,246 @@ +/* + * 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.glu; + +import java.nio.IntBuffer; + +import org.lwjgl.BufferUtils; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; + +/** + * Util.java + *

    + *

    + * Created 7-jan-2004 + * + * @author Erik Duijs + */ +public class Util { + + /** + * temp IntBuffer of one for getting an int from some GL functions + */ + private static IntBuffer scratch = BufferUtils.createIntBuffer(16); + + /** + * Return ceiling of integer division + * + * @param a + * @param b + * + * @return int + */ + protected static int ceil(int a, int b) { + return (a % b == 0 ? a / b : a / b + 1); + } + + /** + * Normalize vector + * + * @param v + * + * @return float[] + */ + protected static float[] normalize(float[] v) { + float r; + + r = (float)Math.sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]); + if ( r == 0.0 ) + return v; + + r = 1.0f / r; + + v[0] *= r; + v[1] *= r; + v[2] *= r; + + return v; + } + + /** + * Calculate cross-product + * + * @param v1 + * @param v2 + * @param result + */ + protected static void cross(float[] v1, float[] v2, float[] result) { + result[0] = v1[1] * v2[2] - v1[2] * v2[1]; + result[1] = v1[2] * v2[0] - v1[0] * v2[2]; + result[2] = v1[0] * v2[1] - v1[1] * v2[0]; + } + + /** + * Method compPerPix. + * + * @param format + * + * @return int + */ + protected static int compPerPix(int format) { + /* Determine number of components per pixel */ + switch ( format ) { + case GL11.GL_COLOR_INDEX: + case GL11.GL_STENCIL_INDEX: + case GL11.GL_DEPTH_COMPONENT: + case GL11.GL_RED: + case GL11.GL_GREEN: + case GL11.GL_BLUE: + case GL11.GL_ALPHA: + case GL11.GL_LUMINANCE: + return 1; + case GL11.GL_LUMINANCE_ALPHA: + return 2; + case GL11.GL_RGB: + case GL12.GL_BGR: + return 3; + case GL11.GL_RGBA: + case GL12.GL_BGRA: + return 4; + default : + return -1; + } + } + + /** + * Method nearestPower. + *

    + * Compute the nearest power of 2 number. This algorithm is a little strange, but it works quite well. + * + * @param value + * + * @return int + */ + protected static int nearestPower(int value) { + int i; + + i = 1; + + /* Error! */ + if ( value == 0 ) + return -1; + + for ( ; ; ) { + if ( value == 1 ) { + return i; + } else if ( value == 3 ) { + return i << 2; + } + value >>= 1; + i <<= 1; + } + } + + /** + * Method bytesPerPixel. + * + * @param format + * @param type + * + * @return int + */ + protected static int bytesPerPixel(int format, int type) { + int n, m; + + switch ( format ) { + case GL11.GL_COLOR_INDEX: + case GL11.GL_STENCIL_INDEX: + case GL11.GL_DEPTH_COMPONENT: + case GL11.GL_RED: + case GL11.GL_GREEN: + case GL11.GL_BLUE: + case GL11.GL_ALPHA: + case GL11.GL_LUMINANCE: + n = 1; + break; + case GL11.GL_LUMINANCE_ALPHA: + n = 2; + break; + case GL11.GL_RGB: + case GL12.GL_BGR: + n = 3; + break; + case GL11.GL_RGBA: + case GL12.GL_BGRA: + n = 4; + break; + default : + n = 0; + } + + switch ( type ) { + case GL11.GL_UNSIGNED_BYTE: + m = 1; + break; + case GL11.GL_BYTE: + m = 1; + break; + case GL11.GL_BITMAP: + m = 1; + break; + case GL11.GL_UNSIGNED_SHORT: + m = 2; + break; + case GL11.GL_SHORT: + m = 2; + break; + case GL11.GL_UNSIGNED_INT: + m = 4; + break; + case GL11.GL_INT: + m = 4; + break; + case GL11.GL_FLOAT: + m = 4; + break; + default : + m = 0; + } + + return n * m; + } + + /** + * Convenience method for returning an int, rather than getting it out of a buffer yourself. + * + * @param what + * + * @return int + */ + protected static int glGetIntegerv(int what) { + scratch.rewind(); + GL11.glGetInteger(what, scratch); + return scratch.get(); + } + +} diff --git a/src/java/org/lwjgl/util/glu/tessellation/ActiveRegion.java b/src/java/org/lwjgl/util/glu/tessellation/ActiveRegion.java new file mode 100644 index 0000000..7b566ec --- /dev/null +++ b/src/java/org/lwjgl/util/glu/tessellation/ActiveRegion.java @@ -0,0 +1,100 @@ +/* + * 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. + */ + +/* +* Portions Copyright (C) 2003-2006 Sun Microsystems, Inc. +* All rights reserved. +*/ + +/* +** License Applicability. Except to the extent portions of this file are +** made subject to an alternative license as permitted in the SGI Free +** Software License B, Version 1.1 (the "License"), the contents of this +** file are subject only to the provisions of the License. You may not use +** this file except in compliance with the License. You may obtain a copy +** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 +** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: +** +** http://oss.sgi.com/projects/FreeB +** +** Note that, as provided in the License, the Software is distributed on an +** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS +** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND +** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A +** PARTICULAR PURPOSE, AND NON-INFRINGEMENT. +** +** NOTE: The Original Code (as defined below) has been licensed to Sun +** Microsystems, Inc. ("Sun") under the SGI Free Software License B +** (Version 1.1), shown above ("SGI License"). Pursuant to Section +** 3.2(3) of the SGI License, Sun is distributing the Covered Code to +** you under an alternative license ("Alternative License"). This +** Alternative License includes all of the provisions of the SGI License +** except that Section 2.2 and 11 are omitted. Any differences between +** the Alternative License and the SGI License are offered solely by Sun +** and not by SGI. +** +** Original Code. The Original Code is: OpenGL Sample Implementation, +** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics, +** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc. +** Copyright in any portions created by third parties is as indicated +** elsewhere herein. All Rights Reserved. +** +** Additional Notice Provisions: The application programming interfaces +** established by SGI in conjunction with the Original Code are The +** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released +** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version +** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X +** Window System(R) (Version 1.3), released October 19, 1998. This software +** was created using the OpenGL(R) version 1.2.1 Sample Implementation +** published by SGI, but has not been independently verified as being +** compliant with the OpenGL(R) version 1.2.1 Specification. +** +** Author: Eric Veach, July 1994 +** Java Port: Pepijn Van Eeckhoudt, July 2003 +** Java Port: Nathan Parker Burg, August 2003 +*/ +package org.lwjgl.util.glu.tessellation; + +class ActiveRegion { + GLUhalfEdge eUp; /* upper edge, directed right to left */ + DictNode nodeUp; /* dictionary node corresponding to eUp */ + int windingNumber; /* used to determine which regions are + * inside the polygon */ + boolean inside; /* is this region inside the polygon? */ + boolean sentinel; /* marks fake edges at t = +/-infinity */ + boolean dirty; /* marks regions where the upper or lower + * edge has changed, but we haven't checked + * whether they intersect yet */ + boolean fixUpperEdge; /* marks temporary edges introduced when + * we process a "right vertex" (one without + * any edges leaving to the right) */ +} diff --git a/src/java/org/lwjgl/util/glu/tessellation/CachedVertex.java b/src/java/org/lwjgl/util/glu/tessellation/CachedVertex.java new file mode 100644 index 0000000..d695476 --- /dev/null +++ b/src/java/org/lwjgl/util/glu/tessellation/CachedVertex.java @@ -0,0 +1,90 @@ +/* + * 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. + */ + +/* +* Portions Copyright (C) 2003-2006 Sun Microsystems, Inc. +* All rights reserved. +*/ + +/* +** License Applicability. Except to the extent portions of this file are +** made subject to an alternative license as permitted in the SGI Free +** Software License B, Version 1.1 (the "License"), the contents of this +** file are subject only to the provisions of the License. You may not use +** this file except in compliance with the License. You may obtain a copy +** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 +** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: +** +** http://oss.sgi.com/projects/FreeB +** +** Note that, as provided in the License, the Software is distributed on an +** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS +** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND +** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A +** PARTICULAR PURPOSE, AND NON-INFRINGEMENT. +** +** NOTE: The Original Code (as defined below) has been licensed to Sun +** Microsystems, Inc. ("Sun") under the SGI Free Software License B +** (Version 1.1), shown above ("SGI License"). Pursuant to Section +** 3.2(3) of the SGI License, Sun is distributing the Covered Code to +** you under an alternative license ("Alternative License"). This +** Alternative License includes all of the provisions of the SGI License +** except that Section 2.2 and 11 are omitted. Any differences between +** the Alternative License and the SGI License are offered solely by Sun +** and not by SGI. +** +** Original Code. The Original Code is: OpenGL Sample Implementation, +** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics, +** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc. +** Copyright in any portions created by third parties is as indicated +** elsewhere herein. All Rights Reserved. +** +** Additional Notice Provisions: The application programming interfaces +** established by SGI in conjunction with the Original Code are The +** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released +** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version +** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X +** Window System(R) (Version 1.3), released October 19, 1998. This software +** was created using the OpenGL(R) version 1.2.1 Sample Implementation +** published by SGI, but has not been independently verified as being +** compliant with the OpenGL(R) version 1.2.1 Specification. +** +** Author: Eric Veach, July 1994 +** Java Port: Pepijn Van Eeckhoudt, July 2003 +** Java Port: Nathan Parker Burg, August 2003 +*/ +package org.lwjgl.util.glu.tessellation; + +class CachedVertex { + public double[] coords = new double[3]; + public Object data; +} diff --git a/src/java/org/lwjgl/util/glu/tessellation/Dict.java b/src/java/org/lwjgl/util/glu/tessellation/Dict.java new file mode 100644 index 0000000..55c3320 --- /dev/null +++ b/src/java/org/lwjgl/util/glu/tessellation/Dict.java @@ -0,0 +1,172 @@ +/* + * 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. + */ + +/* +* Portions Copyright (C) 2003-2006 Sun Microsystems, Inc. +* All rights reserved. +*/ + +/* +** License Applicability. Except to the extent portions of this file are +** made subject to an alternative license as permitted in the SGI Free +** Software License B, Version 1.1 (the "License"), the contents of this +** file are subject only to the provisions of the License. You may not use +** this file except in compliance with the License. You may obtain a copy +** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 +** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: +** +** http://oss.sgi.com/projects/FreeB +** +** Note that, as provided in the License, the Software is distributed on an +** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS +** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND +** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A +** PARTICULAR PURPOSE, AND NON-INFRINGEMENT. +** +** NOTE: The Original Code (as defined below) has been licensed to Sun +** Microsystems, Inc. ("Sun") under the SGI Free Software License B +** (Version 1.1), shown above ("SGI License"). Pursuant to Section +** 3.2(3) of the SGI License, Sun is distributing the Covered Code to +** you under an alternative license ("Alternative License"). This +** Alternative License includes all of the provisions of the SGI License +** except that Section 2.2 and 11 are omitted. Any differences between +** the Alternative License and the SGI License are offered solely by Sun +** and not by SGI. +** +** Original Code. The Original Code is: OpenGL Sample Implementation, +** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics, +** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc. +** Copyright in any portions created by third parties is as indicated +** elsewhere herein. All Rights Reserved. +** +** Additional Notice Provisions: The application programming interfaces +** established by SGI in conjunction with the Original Code are The +** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released +** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version +** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X +** Window System(R) (Version 1.3), released October 19, 1998. This software +** was created using the OpenGL(R) version 1.2.1 Sample Implementation +** published by SGI, but has not been independently verified as being +** compliant with the OpenGL(R) version 1.2.1 Specification. +** +** Author: Eric Veach, July 1994 +** Java Port: Pepijn Van Eeckhoudt, July 2003 +** Java Port: Nathan Parker Burg, August 2003 +*/ +package org.lwjgl.util.glu.tessellation; + +class Dict { + DictNode head; + Object frame; + DictLeq leq; + + private Dict() { + } + + static Dict dictNewDict(Object frame, DictLeq leq) { + Dict dict = new Dict(); + dict.head = new DictNode(); + + dict.head.key = null; + dict.head.next = dict.head; + dict.head.prev = dict.head; + + dict.frame = frame; + dict.leq = leq; + + return dict; + } + + static void dictDeleteDict(Dict dict) { + dict.head = null; + dict.frame = null; + dict.leq = null; + } + + static DictNode dictInsert(Dict dict, Object key) { + return dictInsertBefore(dict, dict.head, key); + } + + static DictNode dictInsertBefore(Dict dict, DictNode node, Object key) { + do { + node = node.prev; + } while (node.key != null && !dict.leq.leq(dict.frame, node.key, key)); + + DictNode newNode = new DictNode(); + newNode.key = key; + newNode.next = node.next; + node.next.prev = newNode; + newNode.prev = node; + node.next = newNode; + + return newNode; + } + + static Object dictKey(DictNode aNode) { + return aNode.key; + } + + static DictNode dictSucc(DictNode aNode) { + return aNode.next; + } + + static DictNode dictPred(DictNode aNode) { + return aNode.prev; + } + + static DictNode dictMin(Dict aDict) { + return aDict.head.next; + } + + static DictNode dictMax(Dict aDict) { + return aDict.head.prev; + } + + static void dictDelete(Dict dict, DictNode node) { + node.next.prev = node.prev; + node.prev.next = node.next; + } + + static DictNode dictSearch(Dict dict, Object key) { + DictNode node = dict.head; + + do { + node = node.next; + } while (node.key != null && !(dict.leq.leq(dict.frame, key, node.key))); + + return node; + } + + public interface DictLeq { + boolean leq(Object frame, Object key1, Object key2); + } +} diff --git a/src/java/org/lwjgl/util/glu/tessellation/DictNode.java b/src/java/org/lwjgl/util/glu/tessellation/DictNode.java new file mode 100644 index 0000000..ec93eb5 --- /dev/null +++ b/src/java/org/lwjgl/util/glu/tessellation/DictNode.java @@ -0,0 +1,91 @@ +/* + * 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. + */ + +/* +* Portions Copyright (C) 2003-2006 Sun Microsystems, Inc. +* All rights reserved. +*/ + +/* +** License Applicability. Except to the extent portions of this file are +** made subject to an alternative license as permitted in the SGI Free +** Software License B, Version 1.1 (the "License"), the contents of this +** file are subject only to the provisions of the License. You may not use +** this file except in compliance with the License. You may obtain a copy +** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 +** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: +** +** http://oss.sgi.com/projects/FreeB +** +** Note that, as provided in the License, the Software is distributed on an +** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS +** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND +** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A +** PARTICULAR PURPOSE, AND NON-INFRINGEMENT. +** +** NOTE: The Original Code (as defined below) has been licensed to Sun +** Microsystems, Inc. ("Sun") under the SGI Free Software License B +** (Version 1.1), shown above ("SGI License"). Pursuant to Section +** 3.2(3) of the SGI License, Sun is distributing the Covered Code to +** you under an alternative license ("Alternative License"). This +** Alternative License includes all of the provisions of the SGI License +** except that Section 2.2 and 11 are omitted. Any differences between +** the Alternative License and the SGI License are offered solely by Sun +** and not by SGI. +** +** Original Code. The Original Code is: OpenGL Sample Implementation, +** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics, +** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc. +** Copyright in any portions created by third parties is as indicated +** elsewhere herein. All Rights Reserved. +** +** Additional Notice Provisions: The application programming interfaces +** established by SGI in conjunction with the Original Code are The +** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released +** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version +** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X +** Window System(R) (Version 1.3), released October 19, 1998. This software +** was created using the OpenGL(R) version 1.2.1 Sample Implementation +** published by SGI, but has not been independently verified as being +** compliant with the OpenGL(R) version 1.2.1 Specification. +** +** Author: Eric Veach, July 1994 +** Java Port: Pepijn Van Eeckhoudt, July 2003 +** Java Port: Nathan Parker Burg, August 2003 +*/ +package org.lwjgl.util.glu.tessellation; + +class DictNode { + Object key; + DictNode next; + DictNode prev; +} diff --git a/src/java/org/lwjgl/util/glu/tessellation/GLUface.java b/src/java/org/lwjgl/util/glu/tessellation/GLUface.java new file mode 100644 index 0000000..40ba208 --- /dev/null +++ b/src/java/org/lwjgl/util/glu/tessellation/GLUface.java @@ -0,0 +1,97 @@ +/* + * 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. + */ + +/* +* Portions Copyright (C) 2003-2006 Sun Microsystems, Inc. +* All rights reserved. +*/ + +/* +** License Applicability. Except to the extent portions of this file are +** made subject to an alternative license as permitted in the SGI Free +** Software License B, Version 1.1 (the "License"), the contents of this +** file are subject only to the provisions of the License. You may not use +** this file except in compliance with the License. You may obtain a copy +** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 +** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: +** +** http://oss.sgi.com/projects/FreeB +** +** Note that, as provided in the License, the Software is distributed on an +** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS +** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND +** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A +** PARTICULAR PURPOSE, AND NON-INFRINGEMENT. +** +** NOTE: The Original Code (as defined below) has been licensed to Sun +** Microsystems, Inc. ("Sun") under the SGI Free Software License B +** (Version 1.1), shown above ("SGI License"). Pursuant to Section +** 3.2(3) of the SGI License, Sun is distributing the Covered Code to +** you under an alternative license ("Alternative License"). This +** Alternative License includes all of the provisions of the SGI License +** except that Section 2.2 and 11 are omitted. Any differences between +** the Alternative License and the SGI License are offered solely by Sun +** and not by SGI. +** +** Original Code. The Original Code is: OpenGL Sample Implementation, +** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics, +** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc. +** Copyright in any portions created by third parties is as indicated +** elsewhere herein. All Rights Reserved. +** +** Additional Notice Provisions: The application programming interfaces +** established by SGI in conjunction with the Original Code are The +** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released +** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version +** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X +** Window System(R) (Version 1.3), released October 19, 1998. This software +** was created using the OpenGL(R) version 1.2.1 Sample Implementation +** published by SGI, but has not been independently verified as being +** compliant with the OpenGL(R) version 1.2.1 Specification. +** +** Author: Eric Veach, July 1994 +** Java Port: Pepijn Van Eeckhoudt, July 2003 +** Java Port: Nathan Parker Burg, August 2003 +*/ +package org.lwjgl.util.glu.tessellation; + +class GLUface { + public GLUface next; /* next face (never NULL) */ + public GLUface prev; /* previous face (never NULL) */ + public GLUhalfEdge anEdge; /* a half edge with this left face */ + public Object data; /* room for client's data */ + + /* Internal data (keep hidden) */ + public GLUface trail; /* "stack" for conversion to strips */ + public boolean marked; /* flag for conversion to strips */ + public boolean inside; /* this face is in the polygon interior */ +} diff --git a/src/java/org/lwjgl/util/glu/tessellation/GLUhalfEdge.java b/src/java/org/lwjgl/util/glu/tessellation/GLUhalfEdge.java new file mode 100644 index 0000000..c329b18 --- /dev/null +++ b/src/java/org/lwjgl/util/glu/tessellation/GLUhalfEdge.java @@ -0,0 +1,105 @@ +/* + * 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. + */ + +/* +* Portions Copyright (C) 2003-2006 Sun Microsystems, Inc. +* All rights reserved. +*/ + +/* +** License Applicability. Except to the extent portions of this file are +** made subject to an alternative license as permitted in the SGI Free +** Software License B, Version 1.1 (the "License"), the contents of this +** file are subject only to the provisions of the License. You may not use +** this file except in compliance with the License. You may obtain a copy +** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 +** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: +** +** http://oss.sgi.com/projects/FreeB +** +** Note that, as provided in the License, the Software is distributed on an +** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS +** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND +** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A +** PARTICULAR PURPOSE, AND NON-INFRINGEMENT. +** +** NOTE: The Original Code (as defined below) has been licensed to Sun +** Microsystems, Inc. ("Sun") under the SGI Free Software License B +** (Version 1.1), shown above ("SGI License"). Pursuant to Section +** 3.2(3) of the SGI License, Sun is distributing the Covered Code to +** you under an alternative license ("Alternative License"). This +** Alternative License includes all of the provisions of the SGI License +** except that Section 2.2 and 11 are omitted. Any differences between +** the Alternative License and the SGI License are offered solely by Sun +** and not by SGI. +** +** Original Code. The Original Code is: OpenGL Sample Implementation, +** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics, +** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc. +** Copyright in any portions created by third parties is as indicated +** elsewhere herein. All Rights Reserved. +** +** Additional Notice Provisions: The application programming interfaces +** established by SGI in conjunction with the Original Code are The +** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released +** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version +** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X +** Window System(R) (Version 1.3), released October 19, 1998. This software +** was created using the OpenGL(R) version 1.2.1 Sample Implementation +** published by SGI, but has not been independently verified as being +** compliant with the OpenGL(R) version 1.2.1 Specification. +** +** Author: Eric Veach, July 1994 +** Java Port: Pepijn Van Eeckhoudt, July 2003 +** Java Port: Nathan Parker Burg, August 2003 +*/ +package org.lwjgl.util.glu.tessellation; + + + +class GLUhalfEdge { + public GLUhalfEdge next; /* doubly-linked list (prev==Sym->next) */ + public GLUhalfEdge Sym; /* same edge, opposite direction */ + public GLUhalfEdge Onext; /* next edge CCW around origin */ + public GLUhalfEdge Lnext; /* next edge CCW around left face */ + public GLUvertex Org; /* origin vertex (Overtex too long) */ + public GLUface Lface; /* left face */ + + /* Internal data (keep hidden) */ + public ActiveRegion activeRegion; /* a region with this upper edge (sweep.c) */ + public int winding; /* change in winding number when crossing */ + public boolean first; + + public GLUhalfEdge(boolean first) { + this.first = first; + } +} diff --git a/src/java/org/lwjgl/util/glu/tessellation/GLUmesh.java b/src/java/org/lwjgl/util/glu/tessellation/GLUmesh.java new file mode 100644 index 0000000..3aa41ed --- /dev/null +++ b/src/java/org/lwjgl/util/glu/tessellation/GLUmesh.java @@ -0,0 +1,94 @@ +/* + * 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. + */ + +/* +* Portions Copyright (C) 2003-2006 Sun Microsystems, Inc. +* All rights reserved. +*/ + +/* +** License Applicability. Except to the extent portions of this file are +** made subject to an alternative license as permitted in the SGI Free +** Software License B, Version 1.1 (the "License"), the contents of this +** file are subject only to the provisions of the License. You may not use +** this file except in compliance with the License. You may obtain a copy +** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 +** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: +** +** http://oss.sgi.com/projects/FreeB +** +** Note that, as provided in the License, the Software is distributed on an +** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS +** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND +** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A +** PARTICULAR PURPOSE, AND NON-INFRINGEMENT. +** +** NOTE: The Original Code (as defined below) has been licensed to Sun +** Microsystems, Inc. ("Sun") under the SGI Free Software License B +** (Version 1.1), shown above ("SGI License"). Pursuant to Section +** 3.2(3) of the SGI License, Sun is distributing the Covered Code to +** you under an alternative license ("Alternative License"). This +** Alternative License includes all of the provisions of the SGI License +** except that Section 2.2 and 11 are omitted. Any differences between +** the Alternative License and the SGI License are offered solely by Sun +** and not by SGI. +** +** Original Code. The Original Code is: OpenGL Sample Implementation, +** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics, +** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc. +** Copyright in any portions created by third parties is as indicated +** elsewhere herein. All Rights Reserved. +** +** Additional Notice Provisions: The application programming interfaces +** established by SGI in conjunction with the Original Code are The +** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released +** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version +** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X +** Window System(R) (Version 1.3), released October 19, 1998. This software +** was created using the OpenGL(R) version 1.2.1 Sample Implementation +** published by SGI, but has not been independently verified as being +** compliant with the OpenGL(R) version 1.2.1 Specification. +** +** Author: Eric Veach, July 1994 +** Java Port: Pepijn Van Eeckhoudt, July 2003 +** Java Port: Nathan Parker Burg, August 2003 +*/ +package org.lwjgl.util.glu.tessellation; + + + +class GLUmesh { + GLUvertex vHead = new GLUvertex(); /* dummy header for vertex list */ + GLUface fHead = new GLUface(); /* dummy header for face list */ + GLUhalfEdge eHead = new GLUhalfEdge(true); /* dummy header for edge list */ + GLUhalfEdge eHeadSym = new GLUhalfEdge(false); /* and its symmetric counterpart */ +} diff --git a/src/java/org/lwjgl/util/glu/tessellation/GLUtessellatorImpl.java b/src/java/org/lwjgl/util/glu/tessellation/GLUtessellatorImpl.java new file mode 100644 index 0000000..b08b044 --- /dev/null +++ b/src/java/org/lwjgl/util/glu/tessellation/GLUtessellatorImpl.java @@ -0,0 +1,668 @@ +/* + * 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. + */ + +/* +* Portions Copyright (C) 2003-2006 Sun Microsystems, Inc. +* All rights reserved. +*/ + +/* +** License Applicability. Except to the extent portions of this file are +** made subject to an alternative license as permitted in the SGI Free +** Software License B, Version 1.1 (the "License"), the contents of this +** file are subject only to the provisions of the License. You may not use +** this file except in compliance with the License. You may obtain a copy +** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 +** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: +** +** http://oss.sgi.com/projects/FreeB +** +** Note that, as provided in the License, the Software is distributed on an +** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS +** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND +** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A +** PARTICULAR PURPOSE, AND NON-INFRINGEMENT. +** +** NOTE: The Original Code (as defined below) has been licensed to Sun +** Microsystems, Inc. ("Sun") under the SGI Free Software License B +** (Version 1.1), shown above ("SGI License"). Pursuant to Section +** 3.2(3) of the SGI License, Sun is distributing the Covered Code to +** you under an alternative license ("Alternative License"). This +** Alternative License includes all of the provisions of the SGI License +** except that Section 2.2 and 11 are omitted. Any differences between +** the Alternative License and the SGI License are offered solely by Sun +** and not by SGI. +** +** Original Code. The Original Code is: OpenGL Sample Implementation, +** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics, +** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc. +** Copyright in any portions created by third parties is as indicated +** elsewhere herein. All Rights Reserved. +** +** Additional Notice Provisions: The application programming interfaces +** established by SGI in conjunction with the Original Code are The +** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released +** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version +** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X +** Window System(R) (Version 1.3), released October 19, 1998. This software +** was created using the OpenGL(R) version 1.2.1 Sample Implementation +** published by SGI, but has not been independently verified as being +** compliant with the OpenGL(R) version 1.2.1 Specification. +** +** Author: Eric Veach, July 1994 +** Java Port: Pepijn Van Eeckhoudt, July 2003 +** Java Port: Nathan Parker Burg, August 2003 +*/ +package org.lwjgl.util.glu.tessellation; + +import org.lwjgl.util.glu.GLU; +import org.lwjgl.util.glu.GLUtessellator; +import org.lwjgl.util.glu.GLUtessellatorCallback; +import org.lwjgl.util.glu.GLUtessellatorCallbackAdapter; + +public class GLUtessellatorImpl implements GLUtessellator { + public static final int TESS_MAX_CACHE = 100; + + private int state; /* what begin/end calls have we seen? */ + + private GLUhalfEdge lastEdge; /* lastEdge->Org is the most recent vertex */ + GLUmesh mesh; /* stores the input contours, and eventually + the tessellation itself */ + + /*** state needed for projecting onto the sweep plane ***/ + + double[] normal = new double[3]; /* user-specified normal (if provided) */ + double[] sUnit = new double[3]; /* unit vector in s-direction (debugging) */ + double[] tUnit = new double[3]; /* unit vector in t-direction (debugging) */ + + /*** state needed for the line sweep ***/ + + private double relTolerance; /* tolerance for merging features */ + int windingRule; /* rule for determining polygon interior */ + boolean fatalError; /* fatal error: needed combine callback */ + + Dict dict; /* edge dictionary for sweep line */ + PriorityQ pq; /* priority queue of vertex events */ + GLUvertex event; /* current sweep event being processed */ + + /*** state needed for rendering callbacks (see render.c) ***/ + + boolean flagBoundary; /* mark boundary edges (use EdgeFlag) */ + boolean boundaryOnly; /* Extract contours, not triangles */ + GLUface lonelyTriList; + /* list of triangles which could not be rendered as strips or fans */ + + + + /*** state needed to cache single-contour polygons for renderCache() */ + + private boolean flushCacheOnNextVertex; /* empty cache on next vertex() call */ + int cacheCount; /* number of cached vertices */ + CachedVertex[] cache = new CachedVertex[TESS_MAX_CACHE]; /* the vertex data */ + + /*** rendering callbacks that also pass polygon data ***/ + private Object polygonData; /* client data for current polygon */ + + private GLUtessellatorCallback callBegin; + private GLUtessellatorCallback callEdgeFlag; + private GLUtessellatorCallback callVertex; + private GLUtessellatorCallback callEnd; +// private GLUtessellatorCallback callMesh; + private GLUtessellatorCallback callError; + private GLUtessellatorCallback callCombine; + + private GLUtessellatorCallback callBeginData; + private GLUtessellatorCallback callEdgeFlagData; + private GLUtessellatorCallback callVertexData; + private GLUtessellatorCallback callEndData; +// private GLUtessellatorCallback callMeshData; + private GLUtessellatorCallback callErrorData; + private GLUtessellatorCallback callCombineData; + + private static final double GLU_TESS_DEFAULT_TOLERANCE = 0.0; +// private static final int GLU_TESS_MESH = 100112; /* void (*)(GLUmesh *mesh) */ + private static GLUtessellatorCallback NULL_CB = new GLUtessellatorCallbackAdapter(); + +// #define MAX_FAST_ALLOC (MAX(sizeof(EdgePair), \ +// MAX(sizeof(GLUvertex),sizeof(GLUface)))) + + public GLUtessellatorImpl() { + state = TessState.T_DORMANT; + + normal[0] = 0; + normal[1] = 0; + normal[2] = 0; + + relTolerance = GLU_TESS_DEFAULT_TOLERANCE; + windingRule = GLU.GLU_TESS_WINDING_ODD; + flagBoundary = false; + boundaryOnly = false; + + callBegin = NULL_CB; + callEdgeFlag = NULL_CB; + callVertex = NULL_CB; + callEnd = NULL_CB; + callError = NULL_CB; + callCombine = NULL_CB; +// callMesh = NULL_CB; + + callBeginData = NULL_CB; + callEdgeFlagData = NULL_CB; + callVertexData = NULL_CB; + callEndData = NULL_CB; + callErrorData = NULL_CB; + callCombineData = NULL_CB; + + polygonData = null; + + for (int i = 0; i < cache.length; i++) { + cache[i] = new CachedVertex(); + } + } + + static public GLUtessellator gluNewTess() + { + return new GLUtessellatorImpl(); + } + + + private void makeDormant() { + /* Return the tessellator to its original dormant state. */ + + if (mesh != null) { + Mesh.__gl_meshDeleteMesh(mesh); + } + state = TessState.T_DORMANT; + lastEdge = null; + mesh = null; + } + + private void requireState(int newState) { + if (state != newState) gotoState(newState); + } + + private void gotoState(int newState) { + while (state != newState) { + /* We change the current state one level at a time, to get to + * the desired state. + */ + if (state < newState) { + if (state == TessState.T_DORMANT) { + callErrorOrErrorData(GLU.GLU_TESS_MISSING_BEGIN_POLYGON); + gluTessBeginPolygon(null); + } else if (state == TessState.T_IN_POLYGON) { + callErrorOrErrorData(GLU.GLU_TESS_MISSING_BEGIN_CONTOUR); + gluTessBeginContour(); + } + } else { + if (state == TessState.T_IN_CONTOUR) { + callErrorOrErrorData(GLU.GLU_TESS_MISSING_END_CONTOUR); + gluTessEndContour(); + } else if (state == TessState.T_IN_POLYGON) { + callErrorOrErrorData(GLU.GLU_TESS_MISSING_END_POLYGON); + /* gluTessEndPolygon( tess ) is too much work! */ + makeDormant(); + } + } + } + } + + public void gluDeleteTess() { + requireState(TessState.T_DORMANT); + } + + public void gluTessProperty(int which, double value) { + switch (which) { + case GLU.GLU_TESS_TOLERANCE: + if (value < 0.0 || value > 1.0) break; + relTolerance = value; + return; + + case GLU.GLU_TESS_WINDING_RULE: + int windingRule = (int) value; + if (windingRule != value) break; /* not an integer */ + + switch (windingRule) { + case GLU.GLU_TESS_WINDING_ODD: + case GLU.GLU_TESS_WINDING_NONZERO: + case GLU.GLU_TESS_WINDING_POSITIVE: + case GLU.GLU_TESS_WINDING_NEGATIVE: + case GLU.GLU_TESS_WINDING_ABS_GEQ_TWO: + this.windingRule = windingRule; + return; + default: + break; + } + + case GLU.GLU_TESS_BOUNDARY_ONLY: + boundaryOnly = (value != 0); + return; + + default: + callErrorOrErrorData(GLU.GLU_INVALID_ENUM); + return; + } + callErrorOrErrorData(GLU.GLU_INVALID_VALUE); + } + +/* Returns tessellator property */ + public void gluGetTessProperty(int which, double[] value, int value_offset) { + switch (which) { + case GLU.GLU_TESS_TOLERANCE: +/* tolerance should be in range [0..1] */ + assert (0.0 <= relTolerance && relTolerance <= 1.0); + value[value_offset] = relTolerance; + break; + case GLU.GLU_TESS_WINDING_RULE: + assert (windingRule == GLU.GLU_TESS_WINDING_ODD || + windingRule == GLU.GLU_TESS_WINDING_NONZERO || + windingRule == GLU.GLU_TESS_WINDING_POSITIVE || + windingRule == GLU.GLU_TESS_WINDING_NEGATIVE || + windingRule == GLU.GLU_TESS_WINDING_ABS_GEQ_TWO); + value[value_offset] = windingRule; + break; + case GLU.GLU_TESS_BOUNDARY_ONLY: + assert (boundaryOnly == true || boundaryOnly == false); + value[value_offset] = boundaryOnly ? 1 : 0; + break; + default: + value[value_offset] = 0.0; + callErrorOrErrorData(GLU.GLU_INVALID_ENUM); + break; + } + } /* gluGetTessProperty() */ + + public void gluTessNormal(double x, double y, double z) { + normal[0] = x; + normal[1] = y; + normal[2] = z; + } + + public void gluTessCallback(int which, GLUtessellatorCallback aCallback) { + switch (which) { + case GLU.GLU_TESS_BEGIN: + callBegin = aCallback == null ? NULL_CB : aCallback; + return; + case GLU.GLU_TESS_BEGIN_DATA: + callBeginData = aCallback == null ? NULL_CB : aCallback; + return; + case GLU.GLU_TESS_EDGE_FLAG: + callEdgeFlag = aCallback == null ? NULL_CB : aCallback; +/* If the client wants boundary edges to be flagged, + * we render everything as separate triangles (no strips or fans). + */ + flagBoundary = aCallback != null; + return; + case GLU.GLU_TESS_EDGE_FLAG_DATA: + callEdgeFlagData = callBegin = aCallback == null ? NULL_CB : aCallback; +/* If the client wants boundary edges to be flagged, + * we render everything as separate triangles (no strips or fans). + */ + flagBoundary = (aCallback != null); + return; + case GLU.GLU_TESS_VERTEX: + callVertex = aCallback == null ? NULL_CB : aCallback; + return; + case GLU.GLU_TESS_VERTEX_DATA: + callVertexData = aCallback == null ? NULL_CB : aCallback; + return; + case GLU.GLU_TESS_END: + callEnd = aCallback == null ? NULL_CB : aCallback; + return; + case GLU.GLU_TESS_END_DATA: + callEndData = aCallback == null ? NULL_CB : aCallback; + return; + case GLU.GLU_TESS_ERROR: + callError = aCallback == null ? NULL_CB : aCallback; + return; + case GLU.GLU_TESS_ERROR_DATA: + callErrorData = aCallback == null ? NULL_CB : aCallback; + return; + case GLU.GLU_TESS_COMBINE: + callCombine = aCallback == null ? NULL_CB : aCallback; + return; + case GLU.GLU_TESS_COMBINE_DATA: + callCombineData = aCallback == null ? NULL_CB : aCallback; + return; +// case GLU_TESS_MESH: +// callMesh = aCallback == null ? NULL_CB : aCallback; +// return; + default: + callErrorOrErrorData(GLU.GLU_INVALID_ENUM); + return; + } + } + + private boolean addVertex(double[] coords, Object vertexData) { + GLUhalfEdge e; + + e = lastEdge; + if (e == null) { +/* Make a self-loop (one vertex, one edge). */ + + e = Mesh.__gl_meshMakeEdge(mesh); + if (e == null) return false; + if (!Mesh.__gl_meshSplice(e, e.Sym)) return false; + } else { +/* Create a new vertex and edge which immediately follow e + * in the ordering around the left face. + */ + if (Mesh.__gl_meshSplitEdge(e) == null) return false; + e = e.Lnext; + } + +/* The new vertex is now e.Org. */ + e.Org.data = vertexData; + e.Org.coords[0] = coords[0]; + e.Org.coords[1] = coords[1]; + e.Org.coords[2] = coords[2]; + +/* The winding of an edge says how the winding number changes as we + * cross from the edge''s right face to its left face. We add the + * vertices in such an order that a CCW contour will add +1 to + * the winding number of the region inside the contour. + */ + e.winding = 1; + e.Sym.winding = -1; + + lastEdge = e; + + return true; + } + + private void cacheVertex(double[] coords, Object vertexData) { + if (cache[cacheCount] == null) { + cache[cacheCount] = new CachedVertex(); + } + + CachedVertex v = cache[cacheCount]; + + v.data = vertexData; + v.coords[0] = coords[0]; + v.coords[1] = coords[1]; + v.coords[2] = coords[2]; + ++cacheCount; + } + + + private boolean flushCache() { + CachedVertex[] v = cache; + + mesh = Mesh.__gl_meshNewMesh(); + if (mesh == null) return false; + + for (int i = 0; i < cacheCount; i++) { + CachedVertex vertex = v[i]; + if (!addVertex(vertex.coords, vertex.data)) return false; + } + cacheCount = 0; + flushCacheOnNextVertex = false; + + return true; + } + + public void gluTessVertex(double[] coords, int coords_offset, Object vertexData) { + int i; + boolean tooLarge = false; + double x; + double[] clamped = new double[3]; + + requireState(TessState.T_IN_CONTOUR); + + if (flushCacheOnNextVertex) { + if (!flushCache()) { + callErrorOrErrorData(GLU.GLU_OUT_OF_MEMORY); + return; + } + lastEdge = null; + } + for (i = 0; i < 3; ++i) { + x = coords[i+coords_offset]; + if (x < -GLU.GLU_TESS_MAX_COORD) { + x = -GLU.GLU_TESS_MAX_COORD; + tooLarge = true; + } + if (x > GLU.GLU_TESS_MAX_COORD) { + x = GLU.GLU_TESS_MAX_COORD; + tooLarge = true; + } + clamped[i] = x; + } + if (tooLarge) { + callErrorOrErrorData(GLU.GLU_TESS_COORD_TOO_LARGE); + } + + if (mesh == null) { + if (cacheCount < TESS_MAX_CACHE) { + cacheVertex(clamped, vertexData); + return; + } + if (!flushCache()) { + callErrorOrErrorData(GLU.GLU_OUT_OF_MEMORY); + return; + } + } + + if (!addVertex(clamped, vertexData)) { + callErrorOrErrorData(GLU.GLU_OUT_OF_MEMORY); + } + } + + + public void gluTessBeginPolygon(Object data) { + requireState(TessState.T_DORMANT); + + state = TessState.T_IN_POLYGON; + cacheCount = 0; + flushCacheOnNextVertex = false; + mesh = null; + + polygonData = data; + } + + + public void gluTessBeginContour() { + requireState(TessState.T_IN_POLYGON); + + state = TessState.T_IN_CONTOUR; + lastEdge = null; + if (cacheCount > 0) { +/* Just set a flag so we don't get confused by empty contours + * -- these can be generated accidentally with the obsolete + * NextContour() interface. + */ + flushCacheOnNextVertex = true; + } + } + + + public void gluTessEndContour() { + requireState(TessState.T_IN_CONTOUR); + state = TessState.T_IN_POLYGON; + } + + public void gluTessEndPolygon() { + GLUmesh mesh; + + try { + requireState(TessState.T_IN_POLYGON); + state = TessState.T_DORMANT; + + if (this.mesh == null) { + if (!flagBoundary /*&& callMesh == NULL_CB*/) { + +/* Try some special code to make the easy cases go quickly + * (eg. convex polygons). This code does NOT handle multiple contours, + * intersections, edge flags, and of course it does not generate + * an explicit mesh either. + */ + if (Render.__gl_renderCache(this)) { + polygonData = null; + return; + } + } + if (!flushCache()) throw new RuntimeException(); /* could've used a label*/ + } + +/* Determine the polygon normal and project vertices onto the plane + * of the polygon. + */ + Normal.__gl_projectPolygon(this); + +/* __gl_computeInterior( tess ) computes the planar arrangement specified + * by the given contours, and further subdivides this arrangement + * into regions. Each region is marked "inside" if it belongs + * to the polygon, according to the rule given by windingRule. + * Each interior region is guaranteed be monotone. + */ + if (!Sweep.__gl_computeInterior(this)) { + throw new RuntimeException(); /* could've used a label */ + } + + mesh = this.mesh; + if (!fatalError) { + boolean rc = true; + +/* If the user wants only the boundary contours, we throw away all edges + * except those which separate the interior from the exterior. + * Otherwise we tessellate all the regions marked "inside". + */ + if (boundaryOnly) { + rc = TessMono.__gl_meshSetWindingNumber(mesh, 1, true); + } else { + rc = TessMono.__gl_meshTessellateInterior(mesh); + } + if (!rc) throw new RuntimeException(); /* could've used a label */ + + Mesh.__gl_meshCheckMesh(mesh); + + if (callBegin != NULL_CB || callEnd != NULL_CB + || callVertex != NULL_CB || callEdgeFlag != NULL_CB + || callBeginData != NULL_CB + || callEndData != NULL_CB + || callVertexData != NULL_CB + || callEdgeFlagData != NULL_CB) { + if (boundaryOnly) { + Render.__gl_renderBoundary(this, mesh); /* output boundary contours */ + } else { + Render.__gl_renderMesh(this, mesh); /* output strips and fans */ + } + } +// if (callMesh != NULL_CB) { +// +///* Throw away the exterior faces, so that all faces are interior. +// * This way the user doesn't have to check the "inside" flag, +// * and we don't need to even reveal its existence. It also leaves +// * the freedom for an implementation to not generate the exterior +// * faces in the first place. +// */ +// TessMono.__gl_meshDiscardExterior(mesh); +// callMesh.mesh(mesh); /* user wants the mesh itself */ +// mesh = null; +// polygonData = null; +// return; +// } + } + Mesh.__gl_meshDeleteMesh(mesh); + polygonData = null; + mesh = null; + } catch (Exception e) { + e.printStackTrace(); + callErrorOrErrorData(GLU.GLU_OUT_OF_MEMORY); + } + } + + /*******************************************************/ + +/* Obsolete calls -- for backward compatibility */ + + public void gluBeginPolygon() { + gluTessBeginPolygon(null); + gluTessBeginContour(); + } + + +/*ARGSUSED*/ + public void gluNextContour(int type) { + gluTessEndContour(); + gluTessBeginContour(); + } + + + public void gluEndPolygon() { + gluTessEndContour(); + gluTessEndPolygon(); + } + + void callBeginOrBeginData(int a) { + if (callBeginData != NULL_CB) + callBeginData.beginData(a, polygonData); + else + callBegin.begin(a); + } + + void callVertexOrVertexData(Object a) { + if (callVertexData != NULL_CB) + callVertexData.vertexData(a, polygonData); + else + callVertex.vertex(a); + } + + void callEdgeFlagOrEdgeFlagData(boolean a) { + if (callEdgeFlagData != NULL_CB) + callEdgeFlagData.edgeFlagData(a, polygonData); + else + callEdgeFlag.edgeFlag(a); + } + + void callEndOrEndData() { + if (callEndData != NULL_CB) + callEndData.endData(polygonData); + else + callEnd.end(); + } + + void callCombineOrCombineData(double[] coords, Object[] vertexData, float[] weights, Object[] outData) { + if (callCombineData != NULL_CB) + callCombineData.combineData(coords, vertexData, weights, outData, polygonData); + else + callCombine.combine(coords, vertexData, weights, outData); + } + + void callErrorOrErrorData(int a) { + if (callErrorData != NULL_CB) + callErrorData.errorData(a, polygonData); + else + callError.error(a); + } + +} diff --git a/src/java/org/lwjgl/util/glu/tessellation/GLUvertex.java b/src/java/org/lwjgl/util/glu/tessellation/GLUvertex.java new file mode 100644 index 0000000..374c968 --- /dev/null +++ b/src/java/org/lwjgl/util/glu/tessellation/GLUvertex.java @@ -0,0 +1,97 @@ +/* + * 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. + */ + +/* +* Portions Copyright (C) 2003-2006 Sun Microsystems, Inc. +* All rights reserved. +*/ + +/* +** License Applicability. Except to the extent portions of this file are +** made subject to an alternative license as permitted in the SGI Free +** Software License B, Version 1.1 (the "License"), the contents of this +** file are subject only to the provisions of the License. You may not use +** this file except in compliance with the License. You may obtain a copy +** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 +** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: +** +** http://oss.sgi.com/projects/FreeB +** +** Note that, as provided in the License, the Software is distributed on an +** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS +** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND +** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A +** PARTICULAR PURPOSE, AND NON-INFRINGEMENT. +** +** NOTE: The Original Code (as defined below) has been licensed to Sun +** Microsystems, Inc. ("Sun") under the SGI Free Software License B +** (Version 1.1), shown above ("SGI License"). Pursuant to Section +** 3.2(3) of the SGI License, Sun is distributing the Covered Code to +** you under an alternative license ("Alternative License"). This +** Alternative License includes all of the provisions of the SGI License +** except that Section 2.2 and 11 are omitted. Any differences between +** the Alternative License and the SGI License are offered solely by Sun +** and not by SGI. +** +** Original Code. The Original Code is: OpenGL Sample Implementation, +** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics, +** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc. +** Copyright in any portions created by third parties is as indicated +** elsewhere herein. All Rights Reserved. +** +** Additional Notice Provisions: The application programming interfaces +** established by SGI in conjunction with the Original Code are The +** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released +** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version +** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X +** Window System(R) (Version 1.3), released October 19, 1998. This software +** was created using the OpenGL(R) version 1.2.1 Sample Implementation +** published by SGI, but has not been independently verified as being +** compliant with the OpenGL(R) version 1.2.1 Specification. +** +** Author: Eric Veach, July 1994 +** Java Port: Pepijn Van Eeckhoudt, July 2003 +** Java Port: Nathan Parker Burg, August 2003 +*/ +package org.lwjgl.util.glu.tessellation; + +class GLUvertex { + public GLUvertex next; /* next vertex (never NULL) */ + public GLUvertex prev; /* previous vertex (never NULL) */ + public GLUhalfEdge anEdge; /* a half-edge with this origin */ + public Object data; /* client's data */ + + /* Internal data (keep hidden) */ + public double[] coords = new double[3]; /* vertex location in 3D */ + public double s, t; /* projection onto the sweep plane */ + public int pqHandle; /* to allow deletion from priority queue */ +} diff --git a/src/java/org/lwjgl/util/glu/tessellation/Geom.java b/src/java/org/lwjgl/util/glu/tessellation/Geom.java new file mode 100644 index 0000000..23fef1f --- /dev/null +++ b/src/java/org/lwjgl/util/glu/tessellation/Geom.java @@ -0,0 +1,350 @@ +/* + * 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. + */ + +/* +* Portions Copyright (C) 2003-2006 Sun Microsystems, Inc. +* All rights reserved. +*/ + +/* +** License Applicability. Except to the extent portions of this file are +** made subject to an alternative license as permitted in the SGI Free +** Software License B, Version 1.1 (the "License"), the contents of this +** file are subject only to the provisions of the License. You may not use +** this file except in compliance with the License. You may obtain a copy +** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 +** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: +** +** http://oss.sgi.com/projects/FreeB +** +** Note that, as provided in the License, the Software is distributed on an +** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS +** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND +** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A +** PARTICULAR PURPOSE, AND NON-INFRINGEMENT. +** +** NOTE: The Original Code (as defined below) has been licensed to Sun +** Microsystems, Inc. ("Sun") under the SGI Free Software License B +** (Version 1.1), shown above ("SGI License"). Pursuant to Section +** 3.2(3) of the SGI License, Sun is distributing the Covered Code to +** you under an alternative license ("Alternative License"). This +** Alternative License includes all of the provisions of the SGI License +** except that Section 2.2 and 11 are omitted. Any differences between +** the Alternative License and the SGI License are offered solely by Sun +** and not by SGI. +** +** Original Code. The Original Code is: OpenGL Sample Implementation, +** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics, +** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc. +** Copyright in any portions created by third parties is as indicated +** elsewhere herein. All Rights Reserved. +** +** Additional Notice Provisions: The application programming interfaces +** established by SGI in conjunction with the Original Code are The +** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released +** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version +** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X +** Window System(R) (Version 1.3), released October 19, 1998. This software +** was created using the OpenGL(R) version 1.2.1 Sample Implementation +** published by SGI, but has not been independently verified as being +** compliant with the OpenGL(R) version 1.2.1 Specification. +** +** Author: Eric Veach, July 1994 +** Java Port: Pepijn Van Eeckhoudt, July 2003 +** Java Port: Nathan Parker Burg, August 2003 +*/ +package org.lwjgl.util.glu.tessellation; + +class Geom { + private Geom() { + } + + /* Given three vertices u,v,w such that VertLeq(u,v) && VertLeq(v,w), + * evaluates the t-coord of the edge uw at the s-coord of the vertex v. + * Returns v->t - (uw)(v->s), ie. the signed distance from uw to v. + * If uw is vertical (and thus passes thru v), the result is zero. + * + * The calculation is extremely accurate and stable, even when v + * is very close to u or w. In particular if we set v->t = 0 and + * let r be the negated result (this evaluates (uw)(v->s)), then + * r is guaranteed to satisfy MIN(u->t,w->t) <= r <= MAX(u->t,w->t). + */ + static double EdgeEval(GLUvertex u, GLUvertex v, GLUvertex w) { + double gapL, gapR; + + assert (VertLeq(u, v) && VertLeq(v, w)); + + gapL = v.s - u.s; + gapR = w.s - v.s; + + if (gapL + gapR > 0) { + if (gapL < gapR) { + return (v.t - u.t) + (u.t - w.t) * (gapL / (gapL + gapR)); + } else { + return (v.t - w.t) + (w.t - u.t) * (gapR / (gapL + gapR)); + } + } + /* vertical line */ + return 0; + } + + static double EdgeSign(GLUvertex u, GLUvertex v, GLUvertex w) { + double gapL, gapR; + + assert (VertLeq(u, v) && VertLeq(v, w)); + + gapL = v.s - u.s; + gapR = w.s - v.s; + + if (gapL + gapR > 0) { + return (v.t - w.t) * gapL + (v.t - u.t) * gapR; + } + /* vertical line */ + return 0; + } + + + /*********************************************************************** + * Define versions of EdgeSign, EdgeEval with s and t transposed. + */ + + static double TransEval(GLUvertex u, GLUvertex v, GLUvertex w) { + /* Given three vertices u,v,w such that TransLeq(u,v) && TransLeq(v,w), + * evaluates the t-coord of the edge uw at the s-coord of the vertex v. + * Returns v->s - (uw)(v->t), ie. the signed distance from uw to v. + * If uw is vertical (and thus passes thru v), the result is zero. + * + * The calculation is extremely accurate and stable, even when v + * is very close to u or w. In particular if we set v->s = 0 and + * let r be the negated result (this evaluates (uw)(v->t)), then + * r is guaranteed to satisfy MIN(u->s,w->s) <= r <= MAX(u->s,w->s). + */ + double gapL, gapR; + + assert (TransLeq(u, v) && TransLeq(v, w)); + + gapL = v.t - u.t; + gapR = w.t - v.t; + + if (gapL + gapR > 0) { + if (gapL < gapR) { + return (v.s - u.s) + (u.s - w.s) * (gapL / (gapL + gapR)); + } else { + return (v.s - w.s) + (w.s - u.s) * (gapR / (gapL + gapR)); + } + } + /* vertical line */ + return 0; + } + + static double TransSign(GLUvertex u, GLUvertex v, GLUvertex w) { + /* Returns a number whose sign matches TransEval(u,v,w) but which + * is cheaper to evaluate. Returns > 0, == 0 , or < 0 + * as v is above, on, or below the edge uw. + */ + double gapL, gapR; + + assert (TransLeq(u, v) && TransLeq(v, w)); + + gapL = v.t - u.t; + gapR = w.t - v.t; + + if (gapL + gapR > 0) { + return (v.s - w.s) * gapL + (v.s - u.s) * gapR; + } + /* vertical line */ + return 0; + } + + + static boolean VertCCW(GLUvertex u, GLUvertex v, GLUvertex w) { + /* For almost-degenerate situations, the results are not reliable. + * Unless the floating-point arithmetic can be performed without + * rounding errors, *any* implementation will give incorrect results + * on some degenerate inputs, so the client must have some way to + * handle this situation. + */ + return (u.s * (v.t - w.t) + v.s * (w.t - u.t) + w.s * (u.t - v.t)) >= 0; + } + +/* Given parameters a,x,b,y returns the value (b*x+a*y)/(a+b), + * or (x+y)/2 if a==b==0. It requires that a,b >= 0, and enforces + * this in the rare case that one argument is slightly negative. + * The implementation is extremely stable numerically. + * In particular it guarantees that the result r satisfies + * MIN(x,y) <= r <= MAX(x,y), and the results are very accurate + * even when a and b differ greatly in magnitude. + */ + static double Interpolate(double a, double x, double b, double y) { + a = (a < 0) ? 0 : a; + b = (b < 0) ? 0 : b; + if (a <= b) { + if (b == 0) { + return (x + y) / 2.0; + } else { + return (x + (y - x) * (a / (a + b))); + } + } else { + return (y + (x - y) * (b / (a + b))); + } + } + + static void EdgeIntersect(GLUvertex o1, GLUvertex d1, + GLUvertex o2, GLUvertex d2, + GLUvertex v) +/* Given edges (o1,d1) and (o2,d2), compute their point of intersection. + * The computed point is guaranteed to lie in the intersection of the + * bounding rectangles defined by each edge. + */ { + double z1, z2; + + /* This is certainly not the most efficient way to find the intersection + * of two line segments, but it is very numerically stable. + * + * Strategy: find the two middle vertices in the VertLeq ordering, + * and interpolate the intersection s-value from these. Then repeat + * using the TransLeq ordering to find the intersection t-value. + */ + + if (!VertLeq(o1, d1)) { + GLUvertex temp = o1; + o1 = d1; + d1 = temp; + } + if (!VertLeq(o2, d2)) { + GLUvertex temp = o2; + o2 = d2; + d2 = temp; + } + if (!VertLeq(o1, o2)) { + GLUvertex temp = o1; + o1 = o2; + o2 = temp; + temp = d1; + d1 = d2; + d2 = temp; + } + + if (!VertLeq(o2, d1)) { + /* Technically, no intersection -- do our best */ + v.s = (o2.s + d1.s) / 2.0; + } else if (VertLeq(d1, d2)) { + /* Interpolate between o2 and d1 */ + z1 = EdgeEval(o1, o2, d1); + z2 = EdgeEval(o2, d1, d2); + if (z1 + z2 < 0) { + z1 = -z1; + z2 = -z2; + } + v.s = Interpolate(z1, o2.s, z2, d1.s); + } else { + /* Interpolate between o2 and d2 */ + z1 = EdgeSign(o1, o2, d1); + z2 = -EdgeSign(o1, d2, d1); + if (z1 + z2 < 0) { + z1 = -z1; + z2 = -z2; + } + v.s = Interpolate(z1, o2.s, z2, d2.s); + } + + /* Now repeat the process for t */ + + if (!TransLeq(o1, d1)) { + GLUvertex temp = o1; + o1 = d1; + d1 = temp; + } + if (!TransLeq(o2, d2)) { + GLUvertex temp = o2; + o2 = d2; + d2 = temp; + } + if (!TransLeq(o1, o2)) { + GLUvertex temp = o2; + o2 = o1; + o1 = temp; + temp = d2; + d2 = d1; + d1 = temp; + } + + if (!TransLeq(o2, d1)) { + /* Technically, no intersection -- do our best */ + v.t = (o2.t + d1.t) / 2.0; + } else if (TransLeq(d1, d2)) { + /* Interpolate between o2 and d1 */ + z1 = TransEval(o1, o2, d1); + z2 = TransEval(o2, d1, d2); + if (z1 + z2 < 0) { + z1 = -z1; + z2 = -z2; + } + v.t = Interpolate(z1, o2.t, z2, d1.t); + } else { + /* Interpolate between o2 and d2 */ + z1 = TransSign(o1, o2, d1); + z2 = -TransSign(o1, d2, d1); + if (z1 + z2 < 0) { + z1 = -z1; + z2 = -z2; + } + v.t = Interpolate(z1, o2.t, z2, d2.t); + } + } + + static boolean VertEq(GLUvertex u, GLUvertex v) { + return u.s == v.s && u.t == v.t; + } + + static boolean VertLeq(GLUvertex u, GLUvertex v) { + return u.s < v.s || (u.s == v.s && u.t <= v.t); + } + +/* Versions of VertLeq, EdgeSign, EdgeEval with s and t transposed. */ + + static boolean TransLeq(GLUvertex u, GLUvertex v) { + return u.t < v.t || (u.t == v.t && u.s <= v.s); + } + + static boolean EdgeGoesLeft(GLUhalfEdge e) { + return VertLeq(e.Sym.Org, e.Org); + } + + static boolean EdgeGoesRight(GLUhalfEdge e) { + return VertLeq(e.Org, e.Sym.Org); + } + + static double VertL1dist(GLUvertex u, GLUvertex v) { + return Math.abs(u.s - v.s) + Math.abs(u.t - v.t); + } +} diff --git a/src/java/org/lwjgl/util/glu/tessellation/Mesh.java b/src/java/org/lwjgl/util/glu/tessellation/Mesh.java new file mode 100644 index 0000000..11d10f4 --- /dev/null +++ b/src/java/org/lwjgl/util/glu/tessellation/Mesh.java @@ -0,0 +1,766 @@ +/* + * 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. + */ + +/* +* Portions Copyright (C) 2003-2006 Sun Microsystems, Inc. +* All rights reserved. +*/ + +/* +** License Applicability. Except to the extent portions of this file are +** made subject to an alternative license as permitted in the SGI Free +** Software License B, Version 1.1 (the "License"), the contents of this +** file are subject only to the provisions of the License. You may not use +** this file except in compliance with the License. You may obtain a copy +** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 +** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: +** +** http://oss.sgi.com/projects/FreeB +** +** Note that, as provided in the License, the Software is distributed on an +** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS +** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND +** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A +** PARTICULAR PURPOSE, AND NON-INFRINGEMENT. +** +** NOTE: The Original Code (as defined below) has been licensed to Sun +** Microsystems, Inc. ("Sun") under the SGI Free Software License B +** (Version 1.1), shown above ("SGI License"). Pursuant to Section +** 3.2(3) of the SGI License, Sun is distributing the Covered Code to +** you under an alternative license ("Alternative License"). This +** Alternative License includes all of the provisions of the SGI License +** except that Section 2.2 and 11 are omitted. Any differences between +** the Alternative License and the SGI License are offered solely by Sun +** and not by SGI. +** +** Original Code. The Original Code is: OpenGL Sample Implementation, +** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics, +** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc. +** Copyright in any portions created by third parties is as indicated +** elsewhere herein. All Rights Reserved. +** +** Additional Notice Provisions: The application programming interfaces +** established by SGI in conjunction with the Original Code are The +** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released +** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version +** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X +** Window System(R) (Version 1.3), released October 19, 1998. This software +** was created using the OpenGL(R) version 1.2.1 Sample Implementation +** published by SGI, but has not been independently verified as being +** compliant with the OpenGL(R) version 1.2.1 Specification. +** +** Author: Eric Veach, July 1994 +** Java Port: Pepijn Van Eeckhoudt, July 2003 +** Java Port: Nathan Parker Burg, August 2003 +*/ +package org.lwjgl.util.glu.tessellation; + +class Mesh { + private Mesh() { + } + + /************************ Utility Routines ************************/ +/* MakeEdge creates a new pair of half-edges which form their own loop. + * No vertex or face structures are allocated, but these must be assigned + * before the current edge operation is completed. + */ + static GLUhalfEdge MakeEdge(GLUhalfEdge eNext) { + GLUhalfEdge e; + GLUhalfEdge eSym; + GLUhalfEdge ePrev; + +// EdgePair * pair = (EdgePair *) +// memAlloc(sizeof(EdgePair)); +// if (pair == NULL) return NULL; +// +// e = &pair - > e; + e = new GLUhalfEdge(true); +// eSym = &pair - > eSym; + eSym = new GLUhalfEdge(false); + + + /* Make sure eNext points to the first edge of the edge pair */ + if (!eNext.first) { + eNext = eNext.Sym; + } + + /* Insert in circular doubly-linked list before eNext. + * Note that the prev pointer is stored in Sym->next. + */ + ePrev = eNext.Sym.next; + eSym.next = ePrev; + ePrev.Sym.next = e; + e.next = eNext; + eNext.Sym.next = eSym; + + e.Sym = eSym; + e.Onext = e; + e.Lnext = eSym; + e.Org = null; + e.Lface = null; + e.winding = 0; + e.activeRegion = null; + + eSym.Sym = e; + eSym.Onext = eSym; + eSym.Lnext = e; + eSym.Org = null; + eSym.Lface = null; + eSym.winding = 0; + eSym.activeRegion = null; + + return e; + } + +/* Splice( a, b ) is best described by the Guibas/Stolfi paper or the + * CS348a notes (see mesh.h). Basically it modifies the mesh so that + * a->Onext and b->Onext are exchanged. This can have various effects + * depending on whether a and b belong to different face or vertex rings. + * For more explanation see __gl_meshSplice() below. + */ + static void Splice(GLUhalfEdge a, GLUhalfEdge b) { + GLUhalfEdge aOnext = a.Onext; + GLUhalfEdge bOnext = b.Onext; + + aOnext.Sym.Lnext = b; + bOnext.Sym.Lnext = a; + a.Onext = bOnext; + b.Onext = aOnext; + } + +/* MakeVertex( newVertex, eOrig, vNext ) attaches a new vertex and makes it the + * origin of all edges in the vertex loop to which eOrig belongs. "vNext" gives + * a place to insert the new vertex in the global vertex list. We insert + * the new vertex *before* vNext so that algorithms which walk the vertex + * list will not see the newly created vertices. + */ + static void MakeVertex(GLUvertex newVertex, + GLUhalfEdge eOrig, GLUvertex vNext) { + GLUhalfEdge e; + GLUvertex vPrev; + GLUvertex vNew = newVertex; + + assert (vNew != null); + + /* insert in circular doubly-linked list before vNext */ + vPrev = vNext.prev; + vNew.prev = vPrev; + vPrev.next = vNew; + vNew.next = vNext; + vNext.prev = vNew; + + vNew.anEdge = eOrig; + vNew.data = null; + /* leave coords, s, t undefined */ + + /* fix other edges on this vertex loop */ + e = eOrig; + do { + e.Org = vNew; + e = e.Onext; + } while (e != eOrig); + } + +/* MakeFace( newFace, eOrig, fNext ) attaches a new face and makes it the left + * face of all edges in the face loop to which eOrig belongs. "fNext" gives + * a place to insert the new face in the global face list. We insert + * the new face *before* fNext so that algorithms which walk the face + * list will not see the newly created faces. + */ + static void MakeFace(GLUface newFace, GLUhalfEdge eOrig, GLUface fNext) { + GLUhalfEdge e; + GLUface fPrev; + GLUface fNew = newFace; + + assert (fNew != null); + + /* insert in circular doubly-linked list before fNext */ + fPrev = fNext.prev; + fNew.prev = fPrev; + fPrev.next = fNew; + fNew.next = fNext; + fNext.prev = fNew; + + fNew.anEdge = eOrig; + fNew.data = null; + fNew.trail = null; + fNew.marked = false; + + /* The new face is marked "inside" if the old one was. This is a + * convenience for the common case where a face has been split in two. + */ + fNew.inside = fNext.inside; + + /* fix other edges on this face loop */ + e = eOrig; + do { + e.Lface = fNew; + e = e.Lnext; + } while (e != eOrig); + } + +/* KillEdge( eDel ) destroys an edge (the half-edges eDel and eDel->Sym), + * and removes from the global edge list. + */ + static void KillEdge(GLUhalfEdge eDel) { + GLUhalfEdge ePrev, eNext; + + /* Half-edges are allocated in pairs, see EdgePair above */ + if (!eDel.first) { + eDel = eDel.Sym; + } + + /* delete from circular doubly-linked list */ + eNext = eDel.next; + ePrev = eDel.Sym.next; + eNext.Sym.next = ePrev; + ePrev.Sym.next = eNext; + } + + +/* KillVertex( vDel ) destroys a vertex and removes it from the global + * vertex list. It updates the vertex loop to point to a given new vertex. + */ + static void KillVertex(GLUvertex vDel, GLUvertex newOrg) { + GLUhalfEdge e, eStart = vDel.anEdge; + GLUvertex vPrev, vNext; + + /* change the origin of all affected edges */ + e = eStart; + do { + e.Org = newOrg; + e = e.Onext; + } while (e != eStart); + + /* delete from circular doubly-linked list */ + vPrev = vDel.prev; + vNext = vDel.next; + vNext.prev = vPrev; + vPrev.next = vNext; + } + +/* KillFace( fDel ) destroys a face and removes it from the global face + * list. It updates the face loop to point to a given new face. + */ + static void KillFace(GLUface fDel, GLUface newLface) { + GLUhalfEdge e, eStart = fDel.anEdge; + GLUface fPrev, fNext; + + /* change the left face of all affected edges */ + e = eStart; + do { + e.Lface = newLface; + e = e.Lnext; + } while (e != eStart); + + /* delete from circular doubly-linked list */ + fPrev = fDel.prev; + fNext = fDel.next; + fNext.prev = fPrev; + fPrev.next = fNext; + } + + + /****************** Basic Edge Operations **********************/ + +/* __gl_meshMakeEdge creates one edge, two vertices, and a loop (face). + * The loop consists of the two new half-edges. + */ + public static GLUhalfEdge __gl_meshMakeEdge(GLUmesh mesh) { + GLUvertex newVertex1 = new GLUvertex(); + GLUvertex newVertex2 = new GLUvertex(); + GLUface newFace = new GLUface(); + GLUhalfEdge e; + + e = MakeEdge(mesh.eHead); + if (e == null) return null; + + MakeVertex(newVertex1, e, mesh.vHead); + MakeVertex(newVertex2, e.Sym, mesh.vHead); + MakeFace(newFace, e, mesh.fHead); + return e; + } + + +/* __gl_meshSplice( eOrg, eDst ) is the basic operation for changing the + * mesh connectivity and topology. It changes the mesh so that + * eOrg->Onext <- OLD( eDst->Onext ) + * eDst->Onext <- OLD( eOrg->Onext ) + * where OLD(...) means the value before the meshSplice operation. + * + * This can have two effects on the vertex structure: + * - if eOrg->Org != eDst->Org, the two vertices are merged together + * - if eOrg->Org == eDst->Org, the origin is split into two vertices + * In both cases, eDst->Org is changed and eOrg->Org is untouched. + * + * Similarly (and independently) for the face structure, + * - if eOrg->Lface == eDst->Lface, one loop is split into two + * - if eOrg->Lface != eDst->Lface, two distinct loops are joined into one + * In both cases, eDst->Lface is changed and eOrg->Lface is unaffected. + * + * Some special cases: + * If eDst == eOrg, the operation has no effect. + * If eDst == eOrg->Lnext, the new face will have a single edge. + * If eDst == eOrg->Lprev, the old face will have a single edge. + * If eDst == eOrg->Onext, the new vertex will have a single edge. + * If eDst == eOrg->Oprev, the old vertex will have a single edge. + */ + public static boolean __gl_meshSplice(GLUhalfEdge eOrg, GLUhalfEdge eDst) { + boolean joiningLoops = false; + boolean joiningVertices = false; + + if (eOrg == eDst) return true; + + if (eDst.Org != eOrg.Org) { + /* We are merging two disjoint vertices -- destroy eDst->Org */ + joiningVertices = true; + KillVertex(eDst.Org, eOrg.Org); + } + if (eDst.Lface != eOrg.Lface) { + /* We are connecting two disjoint loops -- destroy eDst.Lface */ + joiningLoops = true; + KillFace(eDst.Lface, eOrg.Lface); + } + + /* Change the edge structure */ + Splice(eDst, eOrg); + + if (!joiningVertices) { + GLUvertex newVertex = new GLUvertex(); + + /* We split one vertex into two -- the new vertex is eDst.Org. + * Make sure the old vertex points to a valid half-edge. + */ + MakeVertex(newVertex, eDst, eOrg.Org); + eOrg.Org.anEdge = eOrg; + } + if (!joiningLoops) { + GLUface newFace = new GLUface(); + + /* We split one loop into two -- the new loop is eDst.Lface. + * Make sure the old face points to a valid half-edge. + */ + MakeFace(newFace, eDst, eOrg.Lface); + eOrg.Lface.anEdge = eOrg; + } + + return true; + } + + +/* __gl_meshDelete( eDel ) removes the edge eDel. There are several cases: + * if (eDel.Lface != eDel.Rface), we join two loops into one; the loop + * eDel.Lface is deleted. Otherwise, we are splitting one loop into two; + * the newly created loop will contain eDel.Dst. If the deletion of eDel + * would create isolated vertices, those are deleted as well. + * + * This function could be implemented as two calls to __gl_meshSplice + * plus a few calls to memFree, but this would allocate and delete + * unnecessary vertices and faces. + */ + static boolean __gl_meshDelete(GLUhalfEdge eDel) { + GLUhalfEdge eDelSym = eDel.Sym; + boolean joiningLoops = false; + + /* First step: disconnect the origin vertex eDel.Org. We make all + * changes to get a consistent mesh in this "intermediate" state. + */ + if (eDel.Lface != eDel.Sym.Lface) { + /* We are joining two loops into one -- remove the left face */ + joiningLoops = true; + KillFace(eDel.Lface, eDel.Sym.Lface); + } + + if (eDel.Onext == eDel) { + KillVertex(eDel.Org, null); + } else { + /* Make sure that eDel.Org and eDel.Sym.Lface point to valid half-edges */ + eDel.Sym.Lface.anEdge = eDel.Sym.Lnext; + eDel.Org.anEdge = eDel.Onext; + + Splice(eDel, eDel.Sym.Lnext); + if (!joiningLoops) { + GLUface newFace = new GLUface(); + + /* We are splitting one loop into two -- create a new loop for eDel. */ + MakeFace(newFace, eDel, eDel.Lface); + } + } + + /* Claim: the mesh is now in a consistent state, except that eDel.Org + * may have been deleted. Now we disconnect eDel.Dst. + */ + if (eDelSym.Onext == eDelSym) { + KillVertex(eDelSym.Org, null); + KillFace(eDelSym.Lface, null); + } else { + /* Make sure that eDel.Dst and eDel.Lface point to valid half-edges */ + eDel.Lface.anEdge = eDelSym.Sym.Lnext; + eDelSym.Org.anEdge = eDelSym.Onext; + Splice(eDelSym, eDelSym.Sym.Lnext); + } + + /* Any isolated vertices or faces have already been freed. */ + KillEdge(eDel); + + return true; + } + + + /******************** Other Edge Operations **********************/ + +/* All these routines can be implemented with the basic edge + * operations above. They are provided for convenience and efficiency. + */ + + +/* __gl_meshAddEdgeVertex( eOrg ) creates a new edge eNew such that + * eNew == eOrg.Lnext, and eNew.Dst is a newly created vertex. + * eOrg and eNew will have the same left face. + */ + static GLUhalfEdge __gl_meshAddEdgeVertex(GLUhalfEdge eOrg) { + GLUhalfEdge eNewSym; + GLUhalfEdge eNew = MakeEdge(eOrg); + + eNewSym = eNew.Sym; + + /* Connect the new edge appropriately */ + Splice(eNew, eOrg.Lnext); + + /* Set the vertex and face information */ + eNew.Org = eOrg.Sym.Org; + { + GLUvertex newVertex = new GLUvertex(); + + MakeVertex(newVertex, eNewSym, eNew.Org); + } + eNew.Lface = eNewSym.Lface = eOrg.Lface; + + return eNew; + } + + +/* __gl_meshSplitEdge( eOrg ) splits eOrg into two edges eOrg and eNew, + * such that eNew == eOrg.Lnext. The new vertex is eOrg.Sym.Org == eNew.Org. + * eOrg and eNew will have the same left face. + */ + public static GLUhalfEdge __gl_meshSplitEdge(GLUhalfEdge eOrg) { + GLUhalfEdge eNew; + GLUhalfEdge tempHalfEdge = __gl_meshAddEdgeVertex(eOrg); + + eNew = tempHalfEdge.Sym; + + /* Disconnect eOrg from eOrg.Sym.Org and connect it to eNew.Org */ + Splice(eOrg.Sym, eOrg.Sym.Sym.Lnext); + Splice(eOrg.Sym, eNew); + + /* Set the vertex and face information */ + eOrg.Sym.Org = eNew.Org; + eNew.Sym.Org.anEdge = eNew.Sym; /* may have pointed to eOrg.Sym */ + eNew.Sym.Lface = eOrg.Sym.Lface; + eNew.winding = eOrg.winding; /* copy old winding information */ + eNew.Sym.winding = eOrg.Sym.winding; + + return eNew; + } + + +/* __gl_meshConnect( eOrg, eDst ) creates a new edge from eOrg.Sym.Org + * to eDst.Org, and returns the corresponding half-edge eNew. + * If eOrg.Lface == eDst.Lface, this splits one loop into two, + * and the newly created loop is eNew.Lface. Otherwise, two disjoint + * loops are merged into one, and the loop eDst.Lface is destroyed. + * + * If (eOrg == eDst), the new face will have only two edges. + * If (eOrg.Lnext == eDst), the old face is reduced to a single edge. + * If (eOrg.Lnext.Lnext == eDst), the old face is reduced to two edges. + */ + static GLUhalfEdge __gl_meshConnect(GLUhalfEdge eOrg, GLUhalfEdge eDst) { + GLUhalfEdge eNewSym; + boolean joiningLoops = false; + GLUhalfEdge eNew = MakeEdge(eOrg); + + eNewSym = eNew.Sym; + + if (eDst.Lface != eOrg.Lface) { + /* We are connecting two disjoint loops -- destroy eDst.Lface */ + joiningLoops = true; + KillFace(eDst.Lface, eOrg.Lface); + } + + /* Connect the new edge appropriately */ + Splice(eNew, eOrg.Lnext); + Splice(eNewSym, eDst); + + /* Set the vertex and face information */ + eNew.Org = eOrg.Sym.Org; + eNewSym.Org = eDst.Org; + eNew.Lface = eNewSym.Lface = eOrg.Lface; + + /* Make sure the old face points to a valid half-edge */ + eOrg.Lface.anEdge = eNewSym; + + if (!joiningLoops) { + GLUface newFace = new GLUface(); + + /* We split one loop into two -- the new loop is eNew.Lface */ + MakeFace(newFace, eNew, eOrg.Lface); + } + return eNew; + } + + + /******************** Other Operations **********************/ + +/* __gl_meshZapFace( fZap ) destroys a face and removes it from the + * global face list. All edges of fZap will have a null pointer as their + * left face. Any edges which also have a null pointer as their right face + * are deleted entirely (along with any isolated vertices this produces). + * An entire mesh can be deleted by zapping its faces, one at a time, + * in any order. Zapped faces cannot be used in further mesh operations! + */ + static void __gl_meshZapFace(GLUface fZap) { + GLUhalfEdge eStart = fZap.anEdge; + GLUhalfEdge e, eNext, eSym; + GLUface fPrev, fNext; + + /* walk around face, deleting edges whose right face is also null */ + eNext = eStart.Lnext; + do { + e = eNext; + eNext = e.Lnext; + + e.Lface = null; + if (e.Sym.Lface == null) { + /* delete the edge -- see __gl_MeshDelete above */ + + if (e.Onext == e) { + KillVertex(e.Org, null); + } else { + /* Make sure that e.Org points to a valid half-edge */ + e.Org.anEdge = e.Onext; + Splice(e, e.Sym.Lnext); + } + eSym = e.Sym; + if (eSym.Onext == eSym) { + KillVertex(eSym.Org, null); + } else { + /* Make sure that eSym.Org points to a valid half-edge */ + eSym.Org.anEdge = eSym.Onext; + Splice(eSym, eSym.Sym.Lnext); + } + KillEdge(e); + } + } while (e != eStart); + + /* delete from circular doubly-linked list */ + fPrev = fZap.prev; + fNext = fZap.next; + fNext.prev = fPrev; + fPrev.next = fNext; + } + + +/* __gl_meshNewMesh() creates a new mesh with no edges, no vertices, + * and no loops (what we usually call a "face"). + */ + public static GLUmesh __gl_meshNewMesh() { + GLUvertex v; + GLUface f; + GLUhalfEdge e; + GLUhalfEdge eSym; + GLUmesh mesh = new GLUmesh(); + + v = mesh.vHead; + f = mesh.fHead; + e = mesh.eHead; + eSym = mesh.eHeadSym; + + v.next = v.prev = v; + v.anEdge = null; + v.data = null; + + f.next = f.prev = f; + f.anEdge = null; + f.data = null; + f.trail = null; + f.marked = false; + f.inside = false; + + e.next = e; + e.Sym = eSym; + e.Onext = null; + e.Lnext = null; + e.Org = null; + e.Lface = null; + e.winding = 0; + e.activeRegion = null; + + eSym.next = eSym; + eSym.Sym = e; + eSym.Onext = null; + eSym.Lnext = null; + eSym.Org = null; + eSym.Lface = null; + eSym.winding = 0; + eSym.activeRegion = null; + + return mesh; + } + + +/* __gl_meshUnion( mesh1, mesh2 ) forms the union of all structures in + * both meshes, and returns the new mesh (the old meshes are destroyed). + */ + static GLUmesh __gl_meshUnion(GLUmesh mesh1, GLUmesh mesh2) { + GLUface f1 = mesh1.fHead; + GLUvertex v1 = mesh1.vHead; + GLUhalfEdge e1 = mesh1.eHead; + GLUface f2 = mesh2.fHead; + GLUvertex v2 = mesh2.vHead; + GLUhalfEdge e2 = mesh2.eHead; + + /* Add the faces, vertices, and edges of mesh2 to those of mesh1 */ + if (f2.next != f2) { + f1.prev.next = f2.next; + f2.next.prev = f1.prev; + f2.prev.next = f1; + f1.prev = f2.prev; + } + + if (v2.next != v2) { + v1.prev.next = v2.next; + v2.next.prev = v1.prev; + v2.prev.next = v1; + v1.prev = v2.prev; + } + + if (e2.next != e2) { + e1.Sym.next.Sym.next = e2.next; + e2.next.Sym.next = e1.Sym.next; + e2.Sym.next.Sym.next = e1; + e1.Sym.next = e2.Sym.next; + } + + return mesh1; + } + + +/* __gl_meshDeleteMesh( mesh ) will free all storage for any valid mesh. + */ + static void __gl_meshDeleteMeshZap(GLUmesh mesh) { + GLUface fHead = mesh.fHead; + + while (fHead.next != fHead) { + __gl_meshZapFace(fHead.next); + } + assert (mesh.vHead.next == mesh.vHead); + } + +/* __gl_meshDeleteMesh( mesh ) will free all storage for any valid mesh. + */ + public static void __gl_meshDeleteMesh(GLUmesh mesh) { + GLUface f, fNext; + GLUvertex v, vNext; + GLUhalfEdge e, eNext; + + for (f = mesh.fHead.next; f != mesh.fHead; f = fNext) { + fNext = f.next; + } + + for (v = mesh.vHead.next; v != mesh.vHead; v = vNext) { + vNext = v.next; + } + + for (e = mesh.eHead.next; e != mesh.eHead; e = eNext) { + /* One call frees both e and e.Sym (see EdgePair above) */ + eNext = e.next; + } + } + +/* __gl_meshCheckMesh( mesh ) checks a mesh for self-consistency. + */ + public static void __gl_meshCheckMesh(GLUmesh mesh) { + GLUface fHead = mesh.fHead; + GLUvertex vHead = mesh.vHead; + GLUhalfEdge eHead = mesh.eHead; + GLUface f, fPrev; + GLUvertex v, vPrev; + GLUhalfEdge e, ePrev; + + fPrev = fHead; + for (fPrev = fHead; (f = fPrev.next) != fHead; fPrev = f) { + assert (f.prev == fPrev); + e = f.anEdge; + do { + assert (e.Sym != e); + assert (e.Sym.Sym == e); + assert (e.Lnext.Onext.Sym == e); + assert (e.Onext.Sym.Lnext == e); + assert (e.Lface == f); + e = e.Lnext; + } while (e != f.anEdge); + } + assert (f.prev == fPrev && f.anEdge == null && f.data == null); + + vPrev = vHead; + for (vPrev = vHead; (v = vPrev.next) != vHead; vPrev = v) { + assert (v.prev == vPrev); + e = v.anEdge; + do { + assert (e.Sym != e); + assert (e.Sym.Sym == e); + assert (e.Lnext.Onext.Sym == e); + assert (e.Onext.Sym.Lnext == e); + assert (e.Org == v); + e = e.Onext; + } while (e != v.anEdge); + } + assert (v.prev == vPrev && v.anEdge == null && v.data == null); + + ePrev = eHead; + for (ePrev = eHead; (e = ePrev.next) != eHead; ePrev = e) { + assert (e.Sym.next == ePrev.Sym); + assert (e.Sym != e); + assert (e.Sym.Sym == e); + assert (e.Org != null); + assert (e.Sym.Org != null); + assert (e.Lnext.Onext.Sym == e); + assert (e.Onext.Sym.Lnext == e); + } + assert (e.Sym.next == ePrev.Sym + && e.Sym == mesh.eHeadSym + && e.Sym.Sym == e + && e.Org == null && e.Sym.Org == null + && e.Lface == null && e.Sym.Lface == null); + } +} diff --git a/src/java/org/lwjgl/util/glu/tessellation/Normal.java b/src/java/org/lwjgl/util/glu/tessellation/Normal.java new file mode 100644 index 0000000..b207fc2 --- /dev/null +++ b/src/java/org/lwjgl/util/glu/tessellation/Normal.java @@ -0,0 +1,319 @@ +/* + * 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. + */ + +/* +* Portions Copyright (C) 2003-2006 Sun Microsystems, Inc. +* All rights reserved. +*/ + +/* +** License Applicability. Except to the extent portions of this file are +** made subject to an alternative license as permitted in the SGI Free +** Software License B, Version 1.1 (the "License"), the contents of this +** file are subject only to the provisions of the License. You may not use +** this file except in compliance with the License. You may obtain a copy +** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 +** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: +** +** http://oss.sgi.com/projects/FreeB +** +** Note that, as provided in the License, the Software is distributed on an +** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS +** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND +** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A +** PARTICULAR PURPOSE, AND NON-INFRINGEMENT. +** +** NOTE: The Original Code (as defined below) has been licensed to Sun +** Microsystems, Inc. ("Sun") under the SGI Free Software License B +** (Version 1.1), shown above ("SGI License"). Pursuant to Section +** 3.2(3) of the SGI License, Sun is distributing the Covered Code to +** you under an alternative license ("Alternative License"). This +** Alternative License includes all of the provisions of the SGI License +** except that Section 2.2 and 11 are omitted. Any differences between +** the Alternative License and the SGI License are offered solely by Sun +** and not by SGI. +** +** Original Code. The Original Code is: OpenGL Sample Implementation, +** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics, +** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc. +** Copyright in any portions created by third parties is as indicated +** elsewhere herein. All Rights Reserved. +** +** Additional Notice Provisions: The application programming interfaces +** established by SGI in conjunction with the Original Code are The +** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released +** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version +** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X +** Window System(R) (Version 1.3), released October 19, 1998. This software +** was created using the OpenGL(R) version 1.2.1 Sample Implementation +** published by SGI, but has not been independently verified as being +** compliant with the OpenGL(R) version 1.2.1 Specification. +** +** Author: Eric Veach, July 1994 +** Java Port: Pepijn Van Eeckhoudt, July 2003 +** Java Port: Nathan Parker Burg, August 2003 +*/ +package org.lwjgl.util.glu.tessellation; + +import org.lwjgl.util.glu.GLU; + +class Normal { + private Normal() { + } + + static boolean SLANTED_SWEEP = false; + static double S_UNIT_X; /* Pre-normalized */ + static double S_UNIT_Y; + private static final boolean TRUE_PROJECT = false; + + static { + if (SLANTED_SWEEP) { +/* The "feature merging" is not intended to be complete. There are + * special cases where edges are nearly parallel to the sweep line + * which are not implemented. The algorithm should still behave + * robustly (ie. produce a reasonable tesselation) in the presence + * of such edges, however it may miss features which could have been + * merged. We could minimize this effect by choosing the sweep line + * direction to be something unusual (ie. not parallel to one of the + * coordinate axes). + */ + S_UNIT_X = 0.50941539564955385; /* Pre-normalized */ + S_UNIT_Y = 0.86052074622010633; + } else { + S_UNIT_X = 1.0; + S_UNIT_Y = 0.0; + } + } + + private static double Dot(double[] u, double[] v) { + return (u[0] * v[0] + u[1] * v[1] + u[2] * v[2]); + } + + static void Normalize(double[] v) { + double len = v[0] * v[0] + v[1] * v[1] + v[2] * v[2]; + + assert (len > 0); + len = Math.sqrt(len); + v[0] /= len; + v[1] /= len; + v[2] /= len; + } + + static int LongAxis(double[] v) { + int i = 0; + + if (Math.abs(v[1]) > Math.abs(v[0])) { + i = 1; + } + if (Math.abs(v[2]) > Math.abs(v[i])) { + i = 2; + } + return i; + } + + static void ComputeNormal(GLUtessellatorImpl tess, double[] norm) { + GLUvertex v, v1, v2; + double c, tLen2, maxLen2; + double[] maxVal, minVal, d1, d2, tNorm; + GLUvertex[] maxVert, minVert; + GLUvertex vHead = tess.mesh.vHead; + int i; + + maxVal = new double[3]; + minVal = new double[3]; + minVert = new GLUvertex[3]; + maxVert = new GLUvertex[3]; + d1 = new double[3]; + d2 = new double[3]; + tNorm = new double[3]; + + maxVal[0] = maxVal[1] = maxVal[2] = -2 * GLU.TESS_MAX_COORD; + minVal[0] = minVal[1] = minVal[2] = 2 * GLU.TESS_MAX_COORD; + + for (v = vHead.next; v != vHead; v = v.next) { + for (i = 0; i < 3; ++i) { + c = v.coords[i]; + if (c < minVal[i]) { + minVal[i] = c; + minVert[i] = v; + } + if (c > maxVal[i]) { + maxVal[i] = c; + maxVert[i] = v; + } + } + } + +/* Find two vertices separated by at least 1/sqrt(3) of the maximum + * distance between any two vertices + */ + i = 0; + if (maxVal[1] - minVal[1] > maxVal[0] - minVal[0]) { + i = 1; + } + if (maxVal[2] - minVal[2] > maxVal[i] - minVal[i]) { + i = 2; + } + if (minVal[i] >= maxVal[i]) { +/* All vertices are the same -- normal doesn't matter */ + norm[0] = 0; + norm[1] = 0; + norm[2] = 1; + return; + } + +/* Look for a third vertex which forms the triangle with maximum area + * (Length of normal == twice the triangle area) + */ + maxLen2 = 0; + v1 = minVert[i]; + v2 = maxVert[i]; + d1[0] = v1.coords[0] - v2.coords[0]; + d1[1] = v1.coords[1] - v2.coords[1]; + d1[2] = v1.coords[2] - v2.coords[2]; + for (v = vHead.next; v != vHead; v = v.next) { + d2[0] = v.coords[0] - v2.coords[0]; + d2[1] = v.coords[1] - v2.coords[1]; + d2[2] = v.coords[2] - v2.coords[2]; + tNorm[0] = d1[1] * d2[2] - d1[2] * d2[1]; + tNorm[1] = d1[2] * d2[0] - d1[0] * d2[2]; + tNorm[2] = d1[0] * d2[1] - d1[1] * d2[0]; + tLen2 = tNorm[0] * tNorm[0] + tNorm[1] * tNorm[1] + tNorm[2] * tNorm[2]; + if (tLen2 > maxLen2) { + maxLen2 = tLen2; + norm[0] = tNorm[0]; + norm[1] = tNorm[1]; + norm[2] = tNorm[2]; + } + } + + if (maxLen2 <= 0) { +/* All points lie on a single line -- any decent normal will do */ + norm[0] = norm[1] = norm[2] = 0; + norm[LongAxis(d1)] = 1; + } + } + + static void CheckOrientation(GLUtessellatorImpl tess) { + double area; + GLUface f, fHead = tess.mesh.fHead; + GLUvertex v, vHead = tess.mesh.vHead; + GLUhalfEdge e; + +/* When we compute the normal automatically, we choose the orientation + * so that the the sum of the signed areas of all contours is non-negative. + */ + area = 0; + for (f = fHead.next; f != fHead; f = f.next) { + e = f.anEdge; + if (e.winding <= 0) continue; + do { + area += (e.Org.s - e.Sym.Org.s) * (e.Org.t + e.Sym.Org.t); + e = e.Lnext; + } while (e != f.anEdge); + } + if (area < 0) { +/* Reverse the orientation by flipping all the t-coordinates */ + for (v = vHead.next; v != vHead; v = v.next) { + v.t = -v.t; + } + tess.tUnit[0] = -tess.tUnit[0]; + tess.tUnit[1] = -tess.tUnit[1]; + tess.tUnit[2] = -tess.tUnit[2]; + } + } + +/* Determine the polygon normal and project vertices onto the plane + * of the polygon. + */ + public static void __gl_projectPolygon(GLUtessellatorImpl tess) { + GLUvertex v, vHead = tess.mesh.vHead; + double w; + double[] norm = new double[3]; + double[] sUnit, tUnit; + int i; + boolean computedNormal = false; + + norm[0] = tess.normal[0]; + norm[1] = tess.normal[1]; + norm[2] = tess.normal[2]; + if (norm[0] == 0 && norm[1] == 0 && norm[2] == 0) { + ComputeNormal(tess, norm); + computedNormal = true; + } + sUnit = tess.sUnit; + tUnit = tess.tUnit; + i = LongAxis(norm); + + if (TRUE_PROJECT) { +/* Choose the initial sUnit vector to be approximately perpendicular + * to the normal. + */ + Normalize(norm); + + sUnit[i] = 0; + sUnit[(i + 1) % 3] = S_UNIT_X; + sUnit[(i + 2) % 3] = S_UNIT_Y; + +/* Now make it exactly perpendicular */ + w = Dot(sUnit, norm); + sUnit[0] -= w * norm[0]; + sUnit[1] -= w * norm[1]; + sUnit[2] -= w * norm[2]; + Normalize(sUnit); + +/* Choose tUnit so that (sUnit,tUnit,norm) form a right-handed frame */ + tUnit[0] = norm[1] * sUnit[2] - norm[2] * sUnit[1]; + tUnit[1] = norm[2] * sUnit[0] - norm[0] * sUnit[2]; + tUnit[2] = norm[0] * sUnit[1] - norm[1] * sUnit[0]; + Normalize(tUnit); + } else { +/* Project perpendicular to a coordinate axis -- better numerically */ + sUnit[i] = 0; + sUnit[(i + 1) % 3] = S_UNIT_X; + sUnit[(i + 2) % 3] = S_UNIT_Y; + + tUnit[i] = 0; + tUnit[(i + 1) % 3] = (norm[i] > 0) ? -S_UNIT_Y : S_UNIT_Y; + tUnit[(i + 2) % 3] = (norm[i] > 0) ? S_UNIT_X : -S_UNIT_X; + } + +/* Project the vertices onto the sweep plane */ + for (v = vHead.next; v != vHead; v = v.next) { + v.s = Dot(v.coords, sUnit); + v.t = Dot(v.coords, tUnit); + } + if (computedNormal) { + CheckOrientation(tess); + } + } +} diff --git a/src/java/org/lwjgl/util/glu/tessellation/PriorityQ.java b/src/java/org/lwjgl/util/glu/tessellation/PriorityQ.java new file mode 100644 index 0000000..a93f283 --- /dev/null +++ b/src/java/org/lwjgl/util/glu/tessellation/PriorityQ.java @@ -0,0 +1,132 @@ +/* + * 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. + */ + +/* +* Portions Copyright (C) 2003-2006 Sun Microsystems, Inc. +* All rights reserved. +*/ + +/* +** License Applicability. Except to the extent portions of this file are +** made subject to an alternative license as permitted in the SGI Free +** Software License B, Version 1.1 (the "License"), the contents of this +** file are subject only to the provisions of the License. You may not use +** this file except in compliance with the License. You may obtain a copy +** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 +** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: +** +** http://oss.sgi.com/projects/FreeB +** +** Note that, as provided in the License, the Software is distributed on an +** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS +** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND +** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A +** PARTICULAR PURPOSE, AND NON-INFRINGEMENT. +** +** NOTE: The Original Code (as defined below) has been licensed to Sun +** Microsystems, Inc. ("Sun") under the SGI Free Software License B +** (Version 1.1), shown above ("SGI License"). Pursuant to Section +** 3.2(3) of the SGI License, Sun is distributing the Covered Code to +** you under an alternative license ("Alternative License"). This +** Alternative License includes all of the provisions of the SGI License +** except that Section 2.2 and 11 are omitted. Any differences between +** the Alternative License and the SGI License are offered solely by Sun +** and not by SGI. +** +** Original Code. The Original Code is: OpenGL Sample Implementation, +** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics, +** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc. +** Copyright in any portions created by third parties is as indicated +** elsewhere herein. All Rights Reserved. +** +** Additional Notice Provisions: The application programming interfaces +** established by SGI in conjunction with the Original Code are The +** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released +** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version +** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X +** Window System(R) (Version 1.3), released October 19, 1998. This software +** was created using the OpenGL(R) version 1.2.1 Sample Implementation +** published by SGI, but has not been independently verified as being +** compliant with the OpenGL(R) version 1.2.1 Specification. +** +** Author: Eric Veach, July 1994 +** Java Port: Pepijn Van Eeckhoudt, July 2003 +** Java Port: Nathan Parker Burg, August 2003 +*/ +package org.lwjgl.util.glu.tessellation; + +abstract class PriorityQ { + public static final int INIT_SIZE = 32; + + public static class PQnode { + int handle; + } + + public static class PQhandleElem { + Object key; + int node; + } + + public static interface Leq { + boolean leq(Object key1, Object key2); + } + + // #ifdef FOR_TRITE_TEST_PROGRAM +// private static boolean LEQ(PriorityQCommon.Leq leq, Object x,Object y) { +// return pq.leq.leq(x,y); +// } +// #else +/* Violates modularity, but a little faster */ +// #include "geom.h" + public static boolean LEQ(Leq leq, Object x, Object y) { + return Geom.VertLeq((GLUvertex) x, (GLUvertex) y); + } + + static PriorityQ pqNewPriorityQ(Leq leq) { + return new PriorityQSort(leq); + } + + abstract void pqDeletePriorityQ(); + + abstract boolean pqInit(); + + abstract int pqInsert(Object keyNew); + + abstract Object pqExtractMin(); + + abstract void pqDelete(int hCurr); + + abstract Object pqMinimum(); + + abstract boolean pqIsEmpty(); +// #endif +} diff --git a/src/java/org/lwjgl/util/glu/tessellation/PriorityQHeap.java b/src/java/org/lwjgl/util/glu/tessellation/PriorityQHeap.java new file mode 100644 index 0000000..550e86f --- /dev/null +++ b/src/java/org/lwjgl/util/glu/tessellation/PriorityQHeap.java @@ -0,0 +1,296 @@ +/* + * 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. + */ + +/* +* Portions Copyright (C) 2003-2006 Sun Microsystems, Inc. +* All rights reserved. +*/ + +/* +** License Applicability. Except to the extent portions of this file are +** made subject to an alternative license as permitted in the SGI Free +** Software License B, Version 1.1 (the "License"), the contents of this +** file are subject only to the provisions of the License. You may not use +** this file except in compliance with the License. You may obtain a copy +** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 +** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: +** +** http://oss.sgi.com/projects/FreeB +** +** Note that, as provided in the License, the Software is distributed on an +** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS +** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND +** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A +** PARTICULAR PURPOSE, AND NON-INFRINGEMENT. +** +** NOTE: The Original Code (as defined below) has been licensed to Sun +** Microsystems, Inc. ("Sun") under the SGI Free Software License B +** (Version 1.1), shown above ("SGI License"). Pursuant to Section +** 3.2(3) of the SGI License, Sun is distributing the Covered Code to +** you under an alternative license ("Alternative License"). This +** Alternative License includes all of the provisions of the SGI License +** except that Section 2.2 and 11 are omitted. Any differences between +** the Alternative License and the SGI License are offered solely by Sun +** and not by SGI. +** +** Original Code. The Original Code is: OpenGL Sample Implementation, +** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics, +** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc. +** Copyright in any portions created by third parties is as indicated +** elsewhere herein. All Rights Reserved. +** +** Additional Notice Provisions: The application programming interfaces +** established by SGI in conjunction with the Original Code are The +** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released +** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version +** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X +** Window System(R) (Version 1.3), released October 19, 1998. This software +** was created using the OpenGL(R) version 1.2.1 Sample Implementation +** published by SGI, but has not been independently verified as being +** compliant with the OpenGL(R) version 1.2.1 Specification. +** +** Author: Eric Veach, July 1994 +** Java Port: Pepijn Van Eeckhoudt, July 2003 +** Java Port: Nathan Parker Burg, August 2003 +*/ +package org.lwjgl.util.glu.tessellation; + + + +class PriorityQHeap extends PriorityQ { + PriorityQ.PQnode[] nodes; + PriorityQ.PQhandleElem[] handles; + int size, max; + int freeList; + boolean initialized; + PriorityQ.Leq leq; + +/* really __gl_pqHeapNewPriorityQ */ + public PriorityQHeap(PriorityQ.Leq leq) { + size = 0; + max = PriorityQ.INIT_SIZE; + nodes = new PriorityQ.PQnode[PriorityQ.INIT_SIZE + 1]; + for (int i = 0; i < nodes.length; i++) { + nodes[i] = new PQnode(); + } + handles = new PriorityQ.PQhandleElem[PriorityQ.INIT_SIZE + 1]; + for (int i = 0; i < handles.length; i++) { + handles[i] = new PQhandleElem(); + } + initialized = false; + freeList = 0; + this.leq = leq; + + nodes[1].handle = 1; /* so that Minimum() returns NULL */ + handles[1].key = null; + } + +/* really __gl_pqHeapDeletePriorityQ */ + void pqDeletePriorityQ() { + handles = null; + nodes = null; + } + + void FloatDown(int curr) { + PriorityQ.PQnode[] n = nodes; + PriorityQ.PQhandleElem[] h = handles; + int hCurr, hChild; + int child; + + hCurr = n[curr].handle; + for (; ;) { + child = curr << 1; + if (child < size && LEQ(leq, h[n[child + 1].handle].key, + h[n[child].handle].key)) { + ++child; + } + + assert (child <= max); + + hChild = n[child].handle; + if (child > size || LEQ(leq, h[hCurr].key, h[hChild].key)) { + n[curr].handle = hCurr; + h[hCurr].node = curr; + break; + } + n[curr].handle = hChild; + h[hChild].node = curr; + curr = child; + } + } + + + void FloatUp(int curr) { + PriorityQ.PQnode[] n = nodes; + PriorityQ.PQhandleElem[] h = handles; + int hCurr, hParent; + int parent; + + hCurr = n[curr].handle; + for (; ;) { + parent = curr >> 1; + hParent = n[parent].handle; + if (parent == 0 || LEQ(leq, h[hParent].key, h[hCurr].key)) { + n[curr].handle = hCurr; + h[hCurr].node = curr; + break; + } + n[curr].handle = hParent; + h[hParent].node = curr; + curr = parent; + } + } + +/* really __gl_pqHeapInit */ + boolean pqInit() { + int i; + + /* This method of building a heap is O(n), rather than O(n lg n). */ + + for (i = size; i >= 1; --i) { + FloatDown(i); + } + initialized = true; + + return true; + } + +/* really __gl_pqHeapInsert */ +/* returns LONG_MAX iff out of memory */ + int pqInsert(Object keyNew) { + int curr; + int free; + + curr = ++size; + if ((curr * 2) > max) { + PriorityQ.PQnode[] saveNodes = nodes; + PriorityQ.PQhandleElem[] saveHandles = handles; + + /* If the heap overflows, double its size. */ + max <<= 1; +// pq->nodes = (PQnode *)memRealloc( pq->nodes, (size_t) ((pq->max + 1) * sizeof( pq->nodes[0] ))); + PriorityQ.PQnode[] pqNodes = new PriorityQ.PQnode[max + 1]; + System.arraycopy( nodes, 0, pqNodes, 0, nodes.length ); + for (int i = nodes.length; i < pqNodes.length; i++) { + pqNodes[i] = new PQnode(); + } + nodes = pqNodes; + if (nodes == null) { + nodes = saveNodes; /* restore ptr to free upon return */ + return Integer.MAX_VALUE; + } + +// pq->handles = (PQhandleElem *)memRealloc( pq->handles,(size_t)((pq->max + 1) * sizeof( pq->handles[0] ))); + PriorityQ.PQhandleElem[] pqHandles = new PriorityQ.PQhandleElem[max + 1]; + System.arraycopy( handles, 0, pqHandles, 0, handles.length ); + for (int i = handles.length; i < pqHandles.length; i++) { + pqHandles[i] = new PQhandleElem(); + } + handles = pqHandles; + if (handles == null) { + handles = saveHandles; /* restore ptr to free upon return */ + return Integer.MAX_VALUE; + } + } + + if (freeList == 0) { + free = curr; + } else { + free = freeList; + freeList = handles[free].node; + } + + nodes[curr].handle = free; + handles[free].node = curr; + handles[free].key = keyNew; + + if (initialized) { + FloatUp(curr); + } + assert (free != Integer.MAX_VALUE); + return free; + } + +/* really __gl_pqHeapExtractMin */ + Object pqExtractMin() { + PriorityQ.PQnode[] n = nodes; + PriorityQ.PQhandleElem[] h = handles; + int hMin = n[1].handle; + Object min = h[hMin].key; + + if (size > 0) { + n[1].handle = n[size].handle; + h[n[1].handle].node = 1; + + h[hMin].key = null; + h[hMin].node = freeList; + freeList = hMin; + + if (--size > 0) { + FloatDown(1); + } + } + return min; + } + +/* really __gl_pqHeapDelete */ + void pqDelete(int hCurr) { + PriorityQ.PQnode[] n = nodes; + PriorityQ.PQhandleElem[] h = handles; + int curr; + + assert (hCurr >= 1 && hCurr <= max && h[hCurr].key != null); + + curr = h[hCurr].node; + n[curr].handle = n[size].handle; + h[n[curr].handle].node = curr; + + if (curr <= --size) { + if (curr <= 1 || LEQ(leq, h[n[curr >> 1].handle].key, h[n[curr].handle].key)) { + FloatDown(curr); + } else { + FloatUp(curr); + } + } + h[hCurr].key = null; + h[hCurr].node = freeList; + freeList = hCurr; + } + + Object pqMinimum() { + return handles[nodes[1].handle].key; + } + + boolean pqIsEmpty() { + return size == 0; + } +} diff --git a/src/java/org/lwjgl/util/glu/tessellation/PriorityQSort.java b/src/java/org/lwjgl/util/glu/tessellation/PriorityQSort.java new file mode 100644 index 0000000..b5f0834 --- /dev/null +++ b/src/java/org/lwjgl/util/glu/tessellation/PriorityQSort.java @@ -0,0 +1,312 @@ +/* + * 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. + */ + +/* +** License Applicability. Except to the extent portions of this file are +** made subject to an alternative license as permitted in the SGI Free +** Software License B, Version 1.1 (the "License"), the contents of this +** file are subject only to the provisions of the License. You may not use +** this file except in compliance with the License. You may obtain a copy +** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 +** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: +** +** http://oss.sgi.com/projects/FreeB +** +** Note that, as provided in the License, the Software is distributed on an +** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS +** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND +** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A +** PARTICULAR PURPOSE, AND NON-INFRINGEMENT. +** +** NOTE: The Original Code (as defined below) has been licensed to Sun +** Microsystems, Inc. ("Sun") under the SGI Free Software License B +** (Version 1.1), shown above ("SGI License"). Pursuant to Section +** 3.2(3) of the SGI License, Sun is distributing the Covered Code to +** you under an alternative license ("Alternative License"). This +** Alternative License includes all of the provisions of the SGI License +** except that Section 2.2 and 11 are omitted. Any differences between +** the Alternative License and the SGI License are offered solely by Sun +** and not by SGI. +** +** Original Code. The Original Code is: OpenGL Sample Implementation, +** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics, +** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc. +** Copyright in any portions created by third parties is as indicated +** elsewhere herein. All Rights Reserved. +** +** Additional Notice Provisions: The application programming interfaces +** established by SGI in conjunction with the Original Code are The +** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released +** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version +** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X +** Window System(R) (Version 1.3), released October 19, 1998. This software +** was created using the OpenGL(R) version 1.2.1 Sample Implementation +** published by SGI, but has not been independently verified as being +** compliant with the OpenGL(R) version 1.2.1 Specification. +** +** Author: Eric Veach, July 1994 +** Java Port: Pepijn Van Eeckhoudt, July 2003 +** Java Port: Nathan Parker Burg, August 2003 +*/ +package org.lwjgl.util.glu.tessellation; + + + +class PriorityQSort extends PriorityQ { + PriorityQHeap heap; + Object[] keys; + + // JAVA: 'order' contains indices into the keys array. + // This simulates the indirect pointers used in the original C code + // (from Frank Suykens, Luciad.com). + int[] order; + int size, max; + boolean initialized; + PriorityQ.Leq leq; + + public PriorityQSort(PriorityQ.Leq leq) { + heap = new PriorityQHeap(leq); + + keys = new Object[PriorityQ.INIT_SIZE]; + + size = 0; + max = PriorityQ.INIT_SIZE; + initialized = false; + this.leq = leq; + } + +/* really __gl_pqSortDeletePriorityQ */ + void pqDeletePriorityQ() { + if (heap != null) heap.pqDeletePriorityQ(); + order = null; + keys = null; + } + + private static boolean LT(PriorityQ.Leq leq, Object x, Object y) { + return (!PriorityQHeap.LEQ(leq, y, x)); + } + + private static boolean GT(PriorityQ.Leq leq, Object x, Object y) { + return (!PriorityQHeap.LEQ(leq, x, y)); + } + + private static void Swap(int[] array, int a, int b) { + if (true) { + int tmp = array[a]; + array[a] = array[b]; + array[b] = tmp; + } else { + + } + } + + private static class Stack { + int p, r; + } + +/* really __gl_pqSortInit */ + boolean pqInit() { + int p, r, i, j; + int piv; + Stack[] stack = new Stack[50]; + for (int k = 0; k < stack.length; k++) { + stack[k] = new Stack(); + } + int top = 0; + + int seed = 2016473283; + + /* Create an array of indirect pointers to the keys, so that we + * the handles we have returned are still valid. + */ + order = new int[size + 1]; +/* the previous line is a patch to compensate for the fact that IBM */ +/* machines return a null on a malloc of zero bytes (unlike SGI), */ +/* so we have to put in this defense to guard against a memory */ +/* fault four lines down. from fossum@austin.ibm.com. */ + p = 0; + r = size - 1; + for (piv = 0, i = p; i <= r; ++piv, ++i) { + // indirect pointers: keep an index into the keys array, not a direct pointer to its contents + order[i] = piv; + } + + /* Sort the indirect pointers in descending order, + * using randomized Quicksort + */ + stack[top].p = p; + stack[top].r = r; + ++top; + while (--top >= 0) { + p = stack[top].p; + r = stack[top].r; + while (r > p + 10) { + seed = Math.abs( seed * 1539415821 + 1 ); + i = p + seed % (r - p + 1); + piv = order[i]; + order[i] = order[p]; + order[p] = piv; + i = p - 1; + j = r + 1; + do { + do { + ++i; + } while (GT(leq, keys[order[i]], keys[piv])); + do { + --j; + } while (LT(leq, keys[order[j]], keys[piv])); + Swap(order, i, j); + } while (i < j); + Swap(order, i, j); /* Undo last swap */ + if (i - p < r - j) { + stack[top].p = j + 1; + stack[top].r = r; + ++top; + r = i - 1; + } else { + stack[top].p = p; + stack[top].r = i - 1; + ++top; + p = j + 1; + } + } + /* Insertion sort small lists */ + for (i = p + 1; i <= r; ++i) { + piv = order[i]; + for (j = i; j > p && LT(leq, keys[order[j - 1]], keys[piv]); --j) { + order[j] = order[j - 1]; + } + order[j] = piv; + } + } + max = size; + initialized = true; + heap.pqInit(); /* always succeeds */ + +/* #ifndef NDEBUG + p = order; + r = p + size - 1; + for (i = p; i < r; ++i) { + Assertion.doAssert(LEQ( * * (i + 1), **i )); + } + #endif*/ + + return true; + } + +/* really __gl_pqSortInsert */ +/* returns LONG_MAX iff out of memory */ + int pqInsert(Object keyNew) { + int curr; + + if (initialized) { + return heap.pqInsert(keyNew); + } + curr = size; + if (++size >= max) { + Object[] saveKey = keys; + + /* If the heap overflows, double its size. */ + max <<= 1; +// pq->keys = (PQHeapKey *)memRealloc( pq->keys,(size_t)(pq->max * sizeof( pq->keys[0] ))); + Object[] pqKeys = new Object[max]; + System.arraycopy( keys, 0, pqKeys, 0, keys.length ); + keys = pqKeys; + if (keys == null) { + keys = saveKey; /* restore ptr to free upon return */ + return Integer.MAX_VALUE; + } + } + assert curr != Integer.MAX_VALUE; + keys[curr] = keyNew; + + /* Negative handles index the sorted array. */ + return -(curr + 1); + } + +/* really __gl_pqSortExtractMin */ + Object pqExtractMin() { + Object sortMin, heapMin; + + if (size == 0) { + return heap.pqExtractMin(); + } + sortMin = keys[order[size - 1]]; + if (!heap.pqIsEmpty()) { + heapMin = heap.pqMinimum(); + if (LEQ(leq, heapMin, sortMin)) { + return heap.pqExtractMin(); + } + } + do { + --size; + } while (size > 0 && keys[order[size - 1]] == null); + return sortMin; + } + +/* really __gl_pqSortMinimum */ + Object pqMinimum() { + Object sortMin, heapMin; + + if (size == 0) { + return heap.pqMinimum(); + } + sortMin = keys[order[size - 1]]; + if (!heap.pqIsEmpty()) { + heapMin = heap.pqMinimum(); + if (PriorityQHeap.LEQ(leq, heapMin, sortMin)) { + return heapMin; + } + } + return sortMin; + } + +/* really __gl_pqSortIsEmpty */ + boolean pqIsEmpty() { + return (size == 0) && heap.pqIsEmpty(); + } + +/* really __gl_pqSortDelete */ + void pqDelete(int curr) { + if (curr >= 0) { + heap.pqDelete(curr); + return; + } + curr = -(curr + 1); + assert curr < max && keys[curr] != null; + + keys[curr] = null; + while (size > 0 && keys[order[size - 1]] == null) { + --size; + } + } +} diff --git a/src/java/org/lwjgl/util/glu/tessellation/Render.java b/src/java/org/lwjgl/util/glu/tessellation/Render.java new file mode 100644 index 0000000..aa9bec9 --- /dev/null +++ b/src/java/org/lwjgl/util/glu/tessellation/Render.java @@ -0,0 +1,589 @@ +/* + * 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. + */ + +/* +* Portions Copyright (C) 2003-2006 Sun Microsystems, Inc. +* All rights reserved. +*/ + +/* +** License Applicability. Except to the extent portions of this file are +** made subject to an alternative license as permitted in the SGI Free +** Software License B, Version 1.1 (the "License"), the contents of this +** file are subject only to the provisions of the License. You may not use +** this file except in compliance with the License. You may obtain a copy +** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 +** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: +** +** http://oss.sgi.com/projects/FreeB +** +** Note that, as provided in the License, the Software is distributed on an +** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS +** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND +** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A +** PARTICULAR PURPOSE, AND NON-INFRINGEMENT. +** +** NOTE: The Original Code (as defined below) has been licensed to Sun +** Microsystems, Inc. ("Sun") under the SGI Free Software License B +** (Version 1.1), shown above ("SGI License"). Pursuant to Section +** 3.2(3) of the SGI License, Sun is distributing the Covered Code to +** you under an alternative license ("Alternative License"). This +** Alternative License includes all of the provisions of the SGI License +** except that Section 2.2 and 11 are omitted. Any differences between +** the Alternative License and the SGI License are offered solely by Sun +** and not by SGI. +** +** Original Code. The Original Code is: OpenGL Sample Implementation, +** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics, +** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc. +** Copyright in any portions created by third parties is as indicated +** elsewhere herein. All Rights Reserved. +** +** Additional Notice Provisions: The application programming interfaces +** established by SGI in conjunction with the Original Code are The +** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released +** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version +** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X +** Window System(R) (Version 1.3), released October 19, 1998. This software +** was created using the OpenGL(R) version 1.2.1 Sample Implementation +** published by SGI, but has not been independently verified as being +** compliant with the OpenGL(R) version 1.2.1 Specification. +** +** Author: Eric Veach, July 1994 +** Java Port: Pepijn Van Eeckhoudt, July 2003 +** Java Port: Nathan Parker Burg, August 2003 +*/ +package org.lwjgl.util.glu.tessellation; + +import org.lwjgl.opengl.GL11; +import org.lwjgl.util.glu.GLU; + +class Render { + private static final boolean USE_OPTIMIZED_CODE_PATH = false; + + private Render() { + } + + private static final RenderFan renderFan = new RenderFan(); + private static final RenderStrip renderStrip = new RenderStrip(); + private static final RenderTriangle renderTriangle = new RenderTriangle(); + +/* This structure remembers the information we need about a primitive + * to be able to render it later, once we have determined which + * primitive is able to use the most triangles. + */ + private static class FaceCount { + public FaceCount() { + } + + public FaceCount(long size, GLUhalfEdge eStart, renderCallBack render) { + this.size = size; + this.eStart = eStart; + this.render = render; + } + + long size; /* number of triangles used */ + GLUhalfEdge eStart; /* edge where this primitive starts */ + renderCallBack render; + }; + + private static interface renderCallBack { + void render(GLUtessellatorImpl tess, GLUhalfEdge e, long size); + } + + /************************ Strips and Fans decomposition ******************/ + +/* __gl_renderMesh( tess, mesh ) takes a mesh and breaks it into triangle + * fans, strips, and separate triangles. A substantial effort is made + * to use as few rendering primitives as possible (ie. to make the fans + * and strips as large as possible). + * + * The rendering output is provided as callbacks (see the api). + */ + public static void __gl_renderMesh(GLUtessellatorImpl tess, GLUmesh mesh) { + GLUface f; + + /* Make a list of separate triangles so we can render them all at once */ + tess.lonelyTriList = null; + + for (f = mesh.fHead.next; f != mesh.fHead; f = f.next) { + f.marked = false; + } + for (f = mesh.fHead.next; f != mesh.fHead; f = f.next) { + + /* We examine all faces in an arbitrary order. Whenever we find + * an unprocessed face F, we output a group of faces including F + * whose size is maximum. + */ + if (f.inside && !f.marked) { + RenderMaximumFaceGroup(tess, f); + assert (f.marked); + } + } + if (tess.lonelyTriList != null) { + RenderLonelyTriangles(tess, tess.lonelyTriList); + tess.lonelyTriList = null; + } + } + + + static void RenderMaximumFaceGroup(GLUtessellatorImpl tess, GLUface fOrig) { + /* We want to find the largest triangle fan or strip of unmarked faces + * which includes the given face fOrig. There are 3 possible fans + * passing through fOrig (one centered at each vertex), and 3 possible + * strips (one for each CCW permutation of the vertices). Our strategy + * is to try all of these, and take the primitive which uses the most + * triangles (a greedy approach). + */ + GLUhalfEdge e = fOrig.anEdge; + FaceCount max = new FaceCount(); + FaceCount newFace = new FaceCount(); + + max.size = 1; + max.eStart = e; + max.render = renderTriangle; + + if (!tess.flagBoundary) { + newFace = MaximumFan(e); + if (newFace.size > max.size) { + max = newFace; + } + newFace = MaximumFan(e.Lnext); + if (newFace.size > max.size) { + max = newFace; + } + newFace = MaximumFan(e.Onext.Sym); + if (newFace.size > max.size) { + max = newFace; + } + + newFace = MaximumStrip(e); + if (newFace.size > max.size) { + max = newFace; + } + newFace = MaximumStrip(e.Lnext); + if (newFace.size > max.size) { + max = newFace; + } + newFace = MaximumStrip(e.Onext.Sym); + if (newFace.size > max.size) { + max = newFace; + } + } + max.render.render(tess, max.eStart, max.size); + } + + +/* Macros which keep track of faces we have marked temporarily, and allow + * us to backtrack when necessary. With triangle fans, this is not + * really necessary, since the only awkward case is a loop of triangles + * around a single origin vertex. However with strips the situation is + * more complicated, and we need a general tracking method like the + * one here. + */ + private static boolean Marked(GLUface f) { + return !f.inside || f.marked; + } + + private static GLUface AddToTrail(GLUface f, GLUface t) { + f.trail = t; + f.marked = true; + return f; + } + + private static void FreeTrail(GLUface t) { + if (true) { + while (t != null) { + t.marked = false; + t = t.trail; + } + } else { + /* absorb trailing semicolon */ + } + } + + static FaceCount MaximumFan(GLUhalfEdge eOrig) { + /* eOrig.Lface is the face we want to render. We want to find the size + * of a maximal fan around eOrig.Org. To do this we just walk around + * the origin vertex as far as possible in both directions. + */ + FaceCount newFace = new FaceCount(0, null, renderFan); + GLUface trail = null; + GLUhalfEdge e; + + for (e = eOrig; !Marked(e.Lface); e = e.Onext) { + trail = AddToTrail(e.Lface, trail); + ++newFace.size; + } + for (e = eOrig; !Marked(e.Sym.Lface); e = e.Sym.Lnext) { + trail = AddToTrail(e.Sym.Lface, trail); + ++newFace.size; + } + newFace.eStart = e; + /*LINTED*/ + FreeTrail(trail); + return newFace; + } + + + private static boolean IsEven(long n) { + return (n & 0x1L) == 0; + } + + static FaceCount MaximumStrip(GLUhalfEdge eOrig) { + /* Here we are looking for a maximal strip that contains the vertices + * eOrig.Org, eOrig.Dst, eOrig.Lnext.Dst (in that order or the + * reverse, such that all triangles are oriented CCW). + * + * Again we walk forward and backward as far as possible. However for + * strips there is a twist: to get CCW orientations, there must be + * an *even* number of triangles in the strip on one side of eOrig. + * We walk the strip starting on a side with an even number of triangles; + * if both side have an odd number, we are forced to shorten one side. + */ + FaceCount newFace = new FaceCount(0, null, renderStrip); + long headSize = 0, tailSize = 0; + GLUface trail = null; + GLUhalfEdge e, eTail, eHead; + + for (e = eOrig; !Marked(e.Lface); ++tailSize, e = e.Onext) { + trail = AddToTrail(e.Lface, trail); + ++tailSize; + e = e.Lnext.Sym; + if (Marked(e.Lface)) break; + trail = AddToTrail(e.Lface, trail); + } + eTail = e; + + for (e = eOrig; !Marked(e.Sym.Lface); ++headSize, e = e.Sym.Onext.Sym) { + trail = AddToTrail(e.Sym.Lface, trail); + ++headSize; + e = e.Sym.Lnext; + if (Marked(e.Sym.Lface)) break; + trail = AddToTrail(e.Sym.Lface, trail); + } + eHead = e; + + newFace.size = tailSize + headSize; + if (IsEven(tailSize)) { + newFace.eStart = eTail.Sym; + } else if (IsEven(headSize)) { + newFace.eStart = eHead; + } else { + /* Both sides have odd length, we must shorten one of them. In fact, + * we must start from eHead to guarantee inclusion of eOrig.Lface. + */ + --newFace.size; + newFace.eStart = eHead.Onext; + } + /*LINTED*/ + FreeTrail(trail); + return newFace; + } + + private static class RenderTriangle implements renderCallBack { + public void render(GLUtessellatorImpl tess, GLUhalfEdge e, long size) { + /* Just add the triangle to a triangle list, so we can render all + * the separate triangles at once. + */ + assert (size == 1); + tess.lonelyTriList = AddToTrail(e.Lface, tess.lonelyTriList); + } + } + + + static void RenderLonelyTriangles(GLUtessellatorImpl tess, GLUface f) { + /* Now we render all the separate triangles which could not be + * grouped into a triangle fan or strip. + */ + GLUhalfEdge e; + int newState; + int edgeState = -1; /* force edge state output for first vertex */ + + tess.callBeginOrBeginData(GL11.GL_TRIANGLES); + + for (; f != null; f = f.trail) { + /* Loop once for each edge (there will always be 3 edges) */ + + e = f.anEdge; + do { + if (tess.flagBoundary) { + /* Set the "edge state" to true just before we output the + * first vertex of each edge on the polygon boundary. + */ + newState = (!e.Sym.Lface.inside) ? 1 : 0; + if (edgeState != newState) { + edgeState = newState; + tess.callEdgeFlagOrEdgeFlagData( edgeState != 0); + } + } + tess.callVertexOrVertexData( e.Org.data); + + e = e.Lnext; + } while (e != f.anEdge); + } + tess.callEndOrEndData(); + } + + private static class RenderFan implements renderCallBack { + public void render(GLUtessellatorImpl tess, GLUhalfEdge e, long size) { + /* Render as many CCW triangles as possible in a fan starting from + * edge "e". The fan *should* contain exactly "size" triangles + * (otherwise we've goofed up somewhere). + */ + tess.callBeginOrBeginData(GL11.GL_TRIANGLE_FAN); + tess.callVertexOrVertexData( e.Org.data); + tess.callVertexOrVertexData( e.Sym.Org.data); + + while (!Marked(e.Lface)) { + e.Lface.marked = true; + --size; + e = e.Onext; + tess.callVertexOrVertexData( e.Sym.Org.data); + } + + assert (size == 0); + tess.callEndOrEndData(); + } + } + + private static class RenderStrip implements renderCallBack { + public void render(GLUtessellatorImpl tess, GLUhalfEdge e, long size) { + /* Render as many CCW triangles as possible in a strip starting from + * edge "e". The strip *should* contain exactly "size" triangles + * (otherwise we've goofed up somewhere). + */ + tess.callBeginOrBeginData(GL11.GL_TRIANGLE_STRIP); + tess.callVertexOrVertexData( e.Org.data); + tess.callVertexOrVertexData( e.Sym.Org.data); + + while (!Marked(e.Lface)) { + e.Lface.marked = true; + --size; + e = e.Lnext.Sym; + tess.callVertexOrVertexData( e.Org.data); + if (Marked(e.Lface)) break; + + e.Lface.marked = true; + --size; + e = e.Onext; + tess.callVertexOrVertexData( e.Sym.Org.data); + } + + assert (size == 0); + tess.callEndOrEndData(); + } + } + + /************************ Boundary contour decomposition ******************/ + +/* __gl_renderBoundary( tess, mesh ) takes a mesh, and outputs one + * contour for each face marked "inside". The rendering output is + * provided as callbacks (see the api). + */ + public static void __gl_renderBoundary(GLUtessellatorImpl tess, GLUmesh mesh) { + GLUface f; + GLUhalfEdge e; + + for (f = mesh.fHead.next; f != mesh.fHead; f = f.next) { + if (f.inside) { + tess.callBeginOrBeginData(GL11.GL_LINE_LOOP); + e = f.anEdge; + do { + tess.callVertexOrVertexData( e.Org.data); + e = e.Lnext; + } while (e != f.anEdge); + tess.callEndOrEndData(); + } + } + } + + + /************************ Quick-and-dirty decomposition ******************/ + + private static final int SIGN_INCONSISTENT = 2; + + static int ComputeNormal(GLUtessellatorImpl tess, double[] norm, boolean check) +/* + * If check==false, we compute the polygon normal and place it in norm[]. + * If check==true, we check that each triangle in the fan from v0 has a + * consistent orientation with respect to norm[]. If triangles are + * consistently oriented CCW, return 1; if CW, return -1; if all triangles + * are degenerate return 0; otherwise (no consistent orientation) return + * SIGN_INCONSISTENT. + */ { + CachedVertex[] v = tess.cache; +// CachedVertex vn = v0 + tess.cacheCount; + int vn = tess.cacheCount; +// CachedVertex vc; + int vc; + double dot, xc, yc, zc, xp, yp, zp; + double[] n = new double[3]; + int sign = 0; + + /* Find the polygon normal. It is important to get a reasonable + * normal even when the polygon is self-intersecting (eg. a bowtie). + * Otherwise, the computed normal could be very tiny, but perpendicular + * to the true plane of the polygon due to numerical noise. Then all + * the triangles would appear to be degenerate and we would incorrectly + * decompose the polygon as a fan (or simply not render it at all). + * + * We use a sum-of-triangles normal algorithm rather than the more + * efficient sum-of-trapezoids method (used in CheckOrientation() + * in normal.c). This lets us explicitly reverse the signed area + * of some triangles to get a reasonable normal in the self-intersecting + * case. + */ + if (!check) { + norm[0] = norm[1] = norm[2] = 0.0; + } + + vc = 1; + xc = v[vc].coords[0] - v[0].coords[0]; + yc = v[vc].coords[1] - v[0].coords[1]; + zc = v[vc].coords[2] - v[0].coords[2]; + while (++vc < vn) { + xp = xc; + yp = yc; + zp = zc; + xc = v[vc].coords[0] - v[0].coords[0]; + yc = v[vc].coords[1] - v[0].coords[1]; + zc = v[vc].coords[2] - v[0].coords[2]; + + /* Compute (vp - v0) cross (vc - v0) */ + n[0] = yp * zc - zp * yc; + n[1] = zp * xc - xp * zc; + n[2] = xp * yc - yp * xc; + + dot = n[0] * norm[0] + n[1] * norm[1] + n[2] * norm[2]; + if (!check) { + /* Reverse the contribution of back-facing triangles to get + * a reasonable normal for self-intersecting polygons (see above) + */ + if (dot >= 0) { + norm[0] += n[0]; + norm[1] += n[1]; + norm[2] += n[2]; + } else { + norm[0] -= n[0]; + norm[1] -= n[1]; + norm[2] -= n[2]; + } + } else if (dot != 0) { + /* Check the new orientation for consistency with previous triangles */ + if (dot > 0) { + if (sign < 0) return SIGN_INCONSISTENT; + sign = 1; + } else { + if (sign > 0) return SIGN_INCONSISTENT; + sign = -1; + } + } + } + return sign; + } + +/* __gl_renderCache( tess ) takes a single contour and tries to render it + * as a triangle fan. This handles convex polygons, as well as some + * non-convex polygons if we get lucky. + * + * Returns true if the polygon was successfully rendered. The rendering + * output is provided as callbacks (see the api). + */ + public static boolean __gl_renderCache(GLUtessellatorImpl tess) { + CachedVertex[] v = tess.cache; +// CachedVertex vn = v0 + tess.cacheCount; + int vn = tess.cacheCount; +// CachedVertex vc; + int vc; + double[] norm = new double[3]; + int sign; + + if (tess.cacheCount < 3) { + /* Degenerate contour -- no output */ + return true; + } + + norm[0] = tess.normal[0]; + norm[1] = tess.normal[1]; + norm[2] = tess.normal[2]; + if (norm[0] == 0 && norm[1] == 0 && norm[2] == 0) { + ComputeNormal( tess, norm, false); + } + + sign = ComputeNormal( tess, norm, true); + if (sign == SIGN_INCONSISTENT) { + /* Fan triangles did not have a consistent orientation */ + return false; + } + if (sign == 0) { + /* All triangles were degenerate */ + return true; + } + + if ( !USE_OPTIMIZED_CODE_PATH ) { + return false; + } else { + /* Make sure we do the right thing for each winding rule */ + switch (tess.windingRule) { + case GLU.GLU_TESS_WINDING_ODD: + case GLU.GLU_TESS_WINDING_NONZERO: + break; + case GLU.GLU_TESS_WINDING_POSITIVE: + if (sign < 0) return true; + break; + case GLU.GLU_TESS_WINDING_NEGATIVE: + if (sign > 0) return true; + break; + case GLU.GLU_TESS_WINDING_ABS_GEQ_TWO: + return true; + } + + tess.callBeginOrBeginData( tess.boundaryOnly ? GL11.GL_LINE_LOOP + : (tess.cacheCount > 3) ? GL11.GL_TRIANGLE_FAN + : GL11.GL_TRIANGLES); + + tess.callVertexOrVertexData( v[0].data); + if (sign > 0) { + for (vc = 1; vc < vn; ++vc) { + tess.callVertexOrVertexData( v[vc].data); + } + } else { + for (vc = vn - 1; vc > 0; --vc) { + tess.callVertexOrVertexData( v[vc].data); + } + } + tess.callEndOrEndData(); + return true; + } + } +} diff --git a/src/java/org/lwjgl/util/glu/tessellation/Sweep.java b/src/java/org/lwjgl/util/glu/tessellation/Sweep.java new file mode 100644 index 0000000..7d35ced --- /dev/null +++ b/src/java/org/lwjgl/util/glu/tessellation/Sweep.java @@ -0,0 +1,1384 @@ +/* + * 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. + */ + +/* +* Portions Copyright (C) 2003-2006 Sun Microsystems, Inc. +* All rights reserved. +*/ + +/* +** License Applicability. Except to the extent portions of this file are +** made subject to an alternative license as permitted in the SGI Free +** Software License B, Version 1.1 (the "License"), the contents of this +** file are subject only to the provisions of the License. You may not use +** this file except in compliance with the License. You may obtain a copy +** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 +** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: +** +** http://oss.sgi.com/projects/FreeB +** +** Note that, as provided in the License, the Software is distributed on an +** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS +** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND +** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A +** PARTICULAR PURPOSE, AND NON-INFRINGEMENT. +** +** NOTE: The Original Code (as defined below) has been licensed to Sun +** Microsystems, Inc. ("Sun") under the SGI Free Software License B +** (Version 1.1), shown above ("SGI License"). Pursuant to Section +** 3.2(3) of the SGI License, Sun is distributing the Covered Code to +** you under an alternative license ("Alternative License"). This +** Alternative License includes all of the provisions of the SGI License +** except that Section 2.2 and 11 are omitted. Any differences between +** the Alternative License and the SGI License are offered solely by Sun +** and not by SGI. +** +** Original Code. The Original Code is: OpenGL Sample Implementation, +** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics, +** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc. +** Copyright in any portions created by third parties is as indicated +** elsewhere herein. All Rights Reserved. +** +** Additional Notice Provisions: The application programming interfaces +** established by SGI in conjunction with the Original Code are The +** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released +** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version +** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X +** Window System(R) (Version 1.3), released October 19, 1998. This software +** was created using the OpenGL(R) version 1.2.1 Sample Implementation +** published by SGI, but has not been independently verified as being +** compliant with the OpenGL(R) version 1.2.1 Specification. +** +** Author: Eric Veach, July 1994 +** Java Port: Pepijn Van Eeckhoudt, July 2003 +** Java Port: Nathan Parker Burg, August 2003 +*/ +package org.lwjgl.util.glu.tessellation; + +import org.lwjgl.util.glu.GLU; + +class Sweep { + private Sweep() { + } + +// #ifdef FOR_TRITE_TEST_PROGRAM +// extern void DebugEvent( GLUtessellator *tess ); +// #else + private static void DebugEvent(GLUtessellatorImpl tess) { + + } +// #endif + +/* + * Invariants for the Edge Dictionary. + * - each pair of adjacent edges e2=Succ(e1) satisfies EdgeLeq(e1,e2) + * at any valid location of the sweep event + * - if EdgeLeq(e2,e1) as well (at any valid sweep event), then e1 and e2 + * share a common endpoint + * - for each e, e.Dst has been processed, but not e.Org + * - each edge e satisfies VertLeq(e.Dst,event) && VertLeq(event,e.Org) + * where "event" is the current sweep line event. + * - no edge e has zero length + * + * Invariants for the Mesh (the processed portion). + * - the portion of the mesh left of the sweep line is a planar graph, + * ie. there is *some* way to embed it in the plane + * - no processed edge has zero length + * - no two processed vertices have identical coordinates + * - each "inside" region is monotone, ie. can be broken into two chains + * of monotonically increasing vertices according to VertLeq(v1,v2) + * - a non-invariant: these chains may intersect (very slightly) + * + * Invariants for the Sweep. + * - if none of the edges incident to the event vertex have an activeRegion + * (ie. none of these edges are in the edge dictionary), then the vertex + * has only right-going edges. + * - if an edge is marked "fixUpperEdge" (it is a temporary edge introduced + * by ConnectRightVertex), then it is the only right-going edge from + * its associated vertex. (This says that these edges exist only + * when it is necessary.) + */ + +/* When we merge two edges into one, we need to compute the combined + * winding of the new edge. + */ + private static void AddWinding(GLUhalfEdge eDst, GLUhalfEdge eSrc) { + eDst.winding += eSrc.winding; + eDst.Sym.winding += eSrc.Sym.winding; + } + + + private static ActiveRegion RegionBelow(ActiveRegion r) { + return ((ActiveRegion) Dict.dictKey(Dict.dictPred(r.nodeUp))); + } + + private static ActiveRegion RegionAbove(ActiveRegion r) { + return ((ActiveRegion) Dict.dictKey(Dict.dictSucc(r.nodeUp))); + } + + static boolean EdgeLeq(GLUtessellatorImpl tess, ActiveRegion reg1, ActiveRegion reg2) +/* + * Both edges must be directed from right to left (this is the canonical + * direction for the upper edge of each region). + * + * The strategy is to evaluate a "t" value for each edge at the + * current sweep line position, given by tess.event. The calculations + * are designed to be very stable, but of course they are not perfect. + * + * Special case: if both edge destinations are at the sweep event, + * we sort the edges by slope (they would otherwise compare equally). + */ { + GLUvertex event = tess.event; + GLUhalfEdge e1, e2; + double t1, t2; + + e1 = reg1.eUp; + e2 = reg2.eUp; + + if (e1.Sym.Org == event) { + if (e2.Sym.Org == event) { + /* Two edges right of the sweep line which meet at the sweep event. + * Sort them by slope. + */ + if (Geom.VertLeq(e1.Org, e2.Org)) { + return Geom.EdgeSign(e2.Sym.Org, e1.Org, e2.Org) <= 0; + } + return Geom.EdgeSign(e1.Sym.Org, e2.Org, e1.Org) >= 0; + } + return Geom.EdgeSign(e2.Sym.Org, event, e2.Org) <= 0; + } + if (e2.Sym.Org == event) { + return Geom.EdgeSign(e1.Sym.Org, event, e1.Org) >= 0; + } + + /* General case - compute signed distance *from* e1, e2 to event */ + t1 = Geom.EdgeEval(e1.Sym.Org, event, e1.Org); + t2 = Geom.EdgeEval(e2.Sym.Org, event, e2.Org); + return (t1 >= t2); + } + + + static void DeleteRegion(GLUtessellatorImpl tess, ActiveRegion reg) { + if (reg.fixUpperEdge) { + /* It was created with zero winding number, so it better be + * deleted with zero winding number (ie. it better not get merged + * with a real edge). + */ + assert (reg.eUp.winding == 0); + } + reg.eUp.activeRegion = null; + Dict.dictDelete(tess.dict, reg.nodeUp); /* __gl_dictListDelete */ + } + + + static boolean FixUpperEdge(ActiveRegion reg, GLUhalfEdge newEdge) +/* + * Replace an upper edge which needs fixing (see ConnectRightVertex). + */ { + assert (reg.fixUpperEdge); + if (!Mesh.__gl_meshDelete(reg.eUp)) return false; + reg.fixUpperEdge = false; + reg.eUp = newEdge; + newEdge.activeRegion = reg; + + return true; + } + + static ActiveRegion TopLeftRegion(ActiveRegion reg) { + GLUvertex org = reg.eUp.Org; + GLUhalfEdge e; + + /* Find the region above the uppermost edge with the same origin */ + do { + reg = RegionAbove(reg); + } while (reg.eUp.Org == org); + + /* If the edge above was a temporary edge introduced by ConnectRightVertex, + * now is the time to fix it. + */ + if (reg.fixUpperEdge) { + e = Mesh.__gl_meshConnect(RegionBelow(reg).eUp.Sym, reg.eUp.Lnext); + if (e == null) return null; + if (!FixUpperEdge(reg, e)) return null; + reg = RegionAbove(reg); + } + return reg; + } + + static ActiveRegion TopRightRegion(ActiveRegion reg) { + GLUvertex dst = reg.eUp.Sym.Org; + + /* Find the region above the uppermost edge with the same destination */ + do { + reg = RegionAbove(reg); + } while (reg.eUp.Sym.Org == dst); + return reg; + } + + static ActiveRegion AddRegionBelow(GLUtessellatorImpl tess, + ActiveRegion regAbove, + GLUhalfEdge eNewUp) +/* + * Add a new active region to the sweep line, *somewhere* below "regAbove" + * (according to where the new edge belongs in the sweep-line dictionary). + * The upper edge of the new region will be "eNewUp". + * Winding number and "inside" flag are not updated. + */ { + ActiveRegion regNew = new ActiveRegion(); + if (regNew == null) throw new RuntimeException(); + + regNew.eUp = eNewUp; + /* __gl_dictListInsertBefore */ + regNew.nodeUp = Dict.dictInsertBefore(tess.dict, regAbove.nodeUp, regNew); + if (regNew.nodeUp == null) throw new RuntimeException(); + regNew.fixUpperEdge = false; + regNew.sentinel = false; + regNew.dirty = false; + + eNewUp.activeRegion = regNew; + return regNew; + } + + static boolean IsWindingInside(GLUtessellatorImpl tess, int n) { + switch (tess.windingRule) { + case GLU.GLU_TESS_WINDING_ODD: + return (n & 1) != 0; + case GLU.GLU_TESS_WINDING_NONZERO: + return (n != 0); + case GLU.GLU_TESS_WINDING_POSITIVE: + return (n > 0); + case GLU.GLU_TESS_WINDING_NEGATIVE: + return (n < 0); + case GLU.GLU_TESS_WINDING_ABS_GEQ_TWO: + return (n >= 2) || (n <= -2); + } + /*LINTED*/ +// assert (false); + throw new InternalError(); + /*NOTREACHED*/ + } + + + static void ComputeWinding(GLUtessellatorImpl tess, ActiveRegion reg) { + reg.windingNumber = RegionAbove(reg).windingNumber + reg.eUp.winding; + reg.inside = IsWindingInside(tess, reg.windingNumber); + } + + + static void FinishRegion(GLUtessellatorImpl tess, ActiveRegion reg) +/* + * Delete a region from the sweep line. This happens when the upper + * and lower chains of a region meet (at a vertex on the sweep line). + * The "inside" flag is copied to the appropriate mesh face (we could + * not do this before -- since the structure of the mesh is always + * changing, this face may not have even existed until now). + */ { + GLUhalfEdge e = reg.eUp; + GLUface f = e.Lface; + + f.inside = reg.inside; + f.anEdge = e; /* optimization for __gl_meshTessellateMonoRegion() */ + DeleteRegion(tess, reg); + } + + + static GLUhalfEdge FinishLeftRegions(GLUtessellatorImpl tess, + ActiveRegion regFirst, ActiveRegion regLast) +/* + * We are given a vertex with one or more left-going edges. All affected + * edges should be in the edge dictionary. Starting at regFirst.eUp, + * we walk down deleting all regions where both edges have the same + * origin vOrg. At the same time we copy the "inside" flag from the + * active region to the face, since at this point each face will belong + * to at most one region (this was not necessarily true until this point + * in the sweep). The walk stops at the region above regLast; if regLast + * is null we walk as far as possible. At the same time we relink the + * mesh if necessary, so that the ordering of edges around vOrg is the + * same as in the dictionary. + */ { + ActiveRegion reg, regPrev; + GLUhalfEdge e, ePrev; + + regPrev = regFirst; + ePrev = regFirst.eUp; + while (regPrev != regLast) { + regPrev.fixUpperEdge = false; /* placement was OK */ + reg = RegionBelow(regPrev); + e = reg.eUp; + if (e.Org != ePrev.Org) { + if (!reg.fixUpperEdge) { + /* Remove the last left-going edge. Even though there are no further + * edges in the dictionary with this origin, there may be further + * such edges in the mesh (if we are adding left edges to a vertex + * that has already been processed). Thus it is important to call + * FinishRegion rather than just DeleteRegion. + */ + FinishRegion(tess, regPrev); + break; + } + /* If the edge below was a temporary edge introduced by + * ConnectRightVertex, now is the time to fix it. + */ + e = Mesh.__gl_meshConnect(ePrev.Onext.Sym, e.Sym); + if (e == null) throw new RuntimeException(); + if (!FixUpperEdge(reg, e)) throw new RuntimeException(); + } + + /* Relink edges so that ePrev.Onext == e */ + if (ePrev.Onext != e) { + if (!Mesh.__gl_meshSplice(e.Sym.Lnext, e)) throw new RuntimeException(); + if (!Mesh.__gl_meshSplice(ePrev, e)) throw new RuntimeException(); + } + FinishRegion(tess, regPrev); /* may change reg.eUp */ + ePrev = reg.eUp; + regPrev = reg; + } + return ePrev; + } + + + static void AddRightEdges(GLUtessellatorImpl tess, ActiveRegion regUp, + GLUhalfEdge eFirst, GLUhalfEdge eLast, GLUhalfEdge eTopLeft, + boolean cleanUp) +/* + * Purpose: insert right-going edges into the edge dictionary, and update + * winding numbers and mesh connectivity appropriately. All right-going + * edges share a common origin vOrg. Edges are inserted CCW starting at + * eFirst; the last edge inserted is eLast.Sym.Lnext. If vOrg has any + * left-going edges already processed, then eTopLeft must be the edge + * such that an imaginary upward vertical segment from vOrg would be + * contained between eTopLeft.Sym.Lnext and eTopLeft; otherwise eTopLeft + * should be null. + */ { + ActiveRegion reg, regPrev; + GLUhalfEdge e, ePrev; + boolean firstTime = true; + + /* Insert the new right-going edges in the dictionary */ + e = eFirst; + do { + assert (Geom.VertLeq(e.Org, e.Sym.Org)); + AddRegionBelow(tess, regUp, e.Sym); + e = e.Onext; + } while (e != eLast); + + /* Walk *all* right-going edges from e.Org, in the dictionary order, + * updating the winding numbers of each region, and re-linking the mesh + * edges to match the dictionary ordering (if necessary). + */ + if (eTopLeft == null) { + eTopLeft = RegionBelow(regUp).eUp.Sym.Onext; + } + regPrev = regUp; + ePrev = eTopLeft; + for (; ;) { + reg = RegionBelow(regPrev); + e = reg.eUp.Sym; + if (e.Org != ePrev.Org) break; + + if (e.Onext != ePrev) { + /* Unlink e from its current position, and relink below ePrev */ + if (!Mesh.__gl_meshSplice(e.Sym.Lnext, e)) throw new RuntimeException(); + if (!Mesh.__gl_meshSplice(ePrev.Sym.Lnext, e)) throw new RuntimeException(); + } + /* Compute the winding number and "inside" flag for the new regions */ + reg.windingNumber = regPrev.windingNumber - e.winding; + reg.inside = IsWindingInside(tess, reg.windingNumber); + + /* Check for two outgoing edges with same slope -- process these + * before any intersection tests (see example in __gl_computeInterior). + */ + regPrev.dirty = true; + if (!firstTime && CheckForRightSplice(tess, regPrev)) { + AddWinding(e, ePrev); + DeleteRegion(tess, regPrev); + if (!Mesh.__gl_meshDelete(ePrev)) throw new RuntimeException(); + } + firstTime = false; + regPrev = reg; + ePrev = e; + } + regPrev.dirty = true; + assert (regPrev.windingNumber - e.winding == reg.windingNumber); + + if (cleanUp) { + /* Check for intersections between newly adjacent edges. */ + WalkDirtyRegions(tess, regPrev); + } + } + + + static void CallCombine(GLUtessellatorImpl tess, GLUvertex isect, + Object[] data, float[] weights, boolean needed) { + double[] coords = new double[3]; + + /* Copy coord data in case the callback changes it. */ + coords[0] = isect.coords[0]; + coords[1] = isect.coords[1]; + coords[2] = isect.coords[2]; + + Object[] outData = new Object[1]; + tess.callCombineOrCombineData(coords, data, weights, outData); + isect.data = outData[0]; + if (isect.data == null) { + if (!needed) { + isect.data = data[0]; + } else if (!tess.fatalError) { + /* The only way fatal error is when two edges are found to intersect, + * but the user has not provided the callback necessary to handle + * generated intersection points. + */ + tess.callErrorOrErrorData(GLU.GLU_TESS_NEED_COMBINE_CALLBACK); + tess.fatalError = true; + } + } + } + + static void SpliceMergeVertices(GLUtessellatorImpl tess, GLUhalfEdge e1, + GLUhalfEdge e2) +/* + * Two vertices with idential coordinates are combined into one. + * e1.Org is kept, while e2.Org is discarded. + */ { + Object[] data = new Object[4]; + float[] weights = new float[]{0.5f, 0.5f, 0.0f, 0.0f}; + + data[0] = e1.Org.data; + data[1] = e2.Org.data; + CallCombine(tess, e1.Org, data, weights, false); + if (!Mesh.__gl_meshSplice(e1, e2)) throw new RuntimeException(); + } + + static void VertexWeights(GLUvertex isect, GLUvertex org, GLUvertex dst, + float[] weights) +/* + * Find some weights which describe how the intersection vertex is + * a linear combination of "org" and "dest". Each of the two edges + * which generated "isect" is allocated 50% of the weight; each edge + * splits the weight between its org and dst according to the + * relative distance to "isect". + */ { + double t1 = Geom.VertL1dist(org, isect); + double t2 = Geom.VertL1dist(dst, isect); + + weights[0] = (float) (0.5 * t2 / (t1 + t2)); + weights[1] = (float) (0.5 * t1 / (t1 + t2)); + isect.coords[0] += weights[0] * org.coords[0] + weights[1] * dst.coords[0]; + isect.coords[1] += weights[0] * org.coords[1] + weights[1] * dst.coords[1]; + isect.coords[2] += weights[0] * org.coords[2] + weights[1] * dst.coords[2]; + } + + + static void GetIntersectData(GLUtessellatorImpl tess, GLUvertex isect, + GLUvertex orgUp, GLUvertex dstUp, + GLUvertex orgLo, GLUvertex dstLo) +/* + * We've computed a new intersection point, now we need a "data" pointer + * from the user so that we can refer to this new vertex in the + * rendering callbacks. + */ { + Object[] data = new Object[4]; + float[] weights = new float[4]; + float[] weights1 = new float[2]; + float[] weights2 = new float[2]; + + data[0] = orgUp.data; + data[1] = dstUp.data; + data[2] = orgLo.data; + data[3] = dstLo.data; + + isect.coords[0] = isect.coords[1] = isect.coords[2] = 0; + VertexWeights(isect, orgUp, dstUp, weights1); + VertexWeights(isect, orgLo, dstLo, weights2); + System.arraycopy(weights1, 0, weights, 0, 2); + System.arraycopy(weights2, 0, weights, 2, 2); + + CallCombine(tess, isect, data, weights, true); + } + + static boolean CheckForRightSplice(GLUtessellatorImpl tess, ActiveRegion regUp) +/* + * Check the upper and lower edge of "regUp", to make sure that the + * eUp.Org is above eLo, or eLo.Org is below eUp (depending on which + * origin is leftmost). + * + * The main purpose is to splice right-going edges with the same + * dest vertex and nearly identical slopes (ie. we can't distinguish + * the slopes numerically). However the splicing can also help us + * to recover from numerical errors. For example, suppose at one + * point we checked eUp and eLo, and decided that eUp.Org is barely + * above eLo. Then later, we split eLo into two edges (eg. from + * a splice operation like this one). This can change the result of + * our test so that now eUp.Org is incident to eLo, or barely below it. + * We must correct this condition to maintain the dictionary invariants. + * + * One possibility is to check these edges for intersection again + * (ie. CheckForIntersect). This is what we do if possible. However + * CheckForIntersect requires that tess.event lies between eUp and eLo, + * so that it has something to fall back on when the intersection + * calculation gives us an unusable answer. So, for those cases where + * we can't check for intersection, this routine fixes the problem + * by just splicing the offending vertex into the other edge. + * This is a guaranteed solution, no matter how degenerate things get. + * Basically this is a combinatorial solution to a numerical problem. + */ { + ActiveRegion regLo = RegionBelow(regUp); + GLUhalfEdge eUp = regUp.eUp; + GLUhalfEdge eLo = regLo.eUp; + + if (Geom.VertLeq(eUp.Org, eLo.Org)) { + if (Geom.EdgeSign(eLo.Sym.Org, eUp.Org, eLo.Org) > 0) return false; + + /* eUp.Org appears to be below eLo */ + if (!Geom.VertEq(eUp.Org, eLo.Org)) { + /* Splice eUp.Org into eLo */ + if (Mesh.__gl_meshSplitEdge(eLo.Sym) == null) throw new RuntimeException(); + if (!Mesh.__gl_meshSplice(eUp, eLo.Sym.Lnext)) throw new RuntimeException(); + regUp.dirty = regLo.dirty = true; + + } else if (eUp.Org != eLo.Org) { + /* merge the two vertices, discarding eUp.Org */ + tess.pq.pqDelete(eUp.Org.pqHandle); /* __gl_pqSortDelete */ + SpliceMergeVertices(tess, eLo.Sym.Lnext, eUp); + } + } else { + if (Geom.EdgeSign(eUp.Sym.Org, eLo.Org, eUp.Org) < 0) return false; + + /* eLo.Org appears to be above eUp, so splice eLo.Org into eUp */ + RegionAbove(regUp).dirty = regUp.dirty = true; + if (Mesh.__gl_meshSplitEdge(eUp.Sym) == null) throw new RuntimeException(); + if (!Mesh.__gl_meshSplice(eLo.Sym.Lnext, eUp)) throw new RuntimeException(); + } + return true; + } + + static boolean CheckForLeftSplice(GLUtessellatorImpl tess, ActiveRegion regUp) +/* + * Check the upper and lower edge of "regUp", to make sure that the + * eUp.Sym.Org is above eLo, or eLo.Sym.Org is below eUp (depending on which + * destination is rightmost). + * + * Theoretically, this should always be true. However, splitting an edge + * into two pieces can change the results of previous tests. For example, + * suppose at one point we checked eUp and eLo, and decided that eUp.Sym.Org + * is barely above eLo. Then later, we split eLo into two edges (eg. from + * a splice operation like this one). This can change the result of + * the test so that now eUp.Sym.Org is incident to eLo, or barely below it. + * We must correct this condition to maintain the dictionary invariants + * (otherwise new edges might get inserted in the wrong place in the + * dictionary, and bad stuff will happen). + * + * We fix the problem by just splicing the offending vertex into the + * other edge. + */ { + ActiveRegion regLo = RegionBelow(regUp); + GLUhalfEdge eUp = regUp.eUp; + GLUhalfEdge eLo = regLo.eUp; + GLUhalfEdge e; + + assert (!Geom.VertEq(eUp.Sym.Org, eLo.Sym.Org)); + + if (Geom.VertLeq(eUp.Sym.Org, eLo.Sym.Org)) { + if (Geom.EdgeSign(eUp.Sym.Org, eLo.Sym.Org, eUp.Org) < 0) return false; + + /* eLo.Sym.Org is above eUp, so splice eLo.Sym.Org into eUp */ + RegionAbove(regUp).dirty = regUp.dirty = true; + e = Mesh.__gl_meshSplitEdge(eUp); + if (e == null) throw new RuntimeException(); + if (!Mesh.__gl_meshSplice(eLo.Sym, e)) throw new RuntimeException(); + e.Lface.inside = regUp.inside; + } else { + if (Geom.EdgeSign(eLo.Sym.Org, eUp.Sym.Org, eLo.Org) > 0) return false; + + /* eUp.Sym.Org is below eLo, so splice eUp.Sym.Org into eLo */ + regUp.dirty = regLo.dirty = true; + e = Mesh.__gl_meshSplitEdge(eLo); + if (e == null) throw new RuntimeException(); + if (!Mesh.__gl_meshSplice(eUp.Lnext, eLo.Sym)) throw new RuntimeException(); + e.Sym.Lface.inside = regUp.inside; + } + return true; + } + + + static boolean CheckForIntersect(GLUtessellatorImpl tess, ActiveRegion regUp) +/* + * Check the upper and lower edges of the given region to see if + * they intersect. If so, create the intersection and add it + * to the data structures. + * + * Returns true if adding the new intersection resulted in a recursive + * call to AddRightEdges(); in this case all "dirty" regions have been + * checked for intersections, and possibly regUp has been deleted. + */ { + ActiveRegion regLo = RegionBelow(regUp); + GLUhalfEdge eUp = regUp.eUp; + GLUhalfEdge eLo = regLo.eUp; + GLUvertex orgUp = eUp.Org; + GLUvertex orgLo = eLo.Org; + GLUvertex dstUp = eUp.Sym.Org; + GLUvertex dstLo = eLo.Sym.Org; + double tMinUp, tMaxLo; + GLUvertex isect = new GLUvertex(); + GLUvertex orgMin; + GLUhalfEdge e; + + assert (!Geom.VertEq(dstLo, dstUp)); + assert (Geom.EdgeSign(dstUp, tess.event, orgUp) <= 0); + assert (Geom.EdgeSign(dstLo, tess.event, orgLo) >= 0); + assert (orgUp != tess.event && orgLo != tess.event); + assert (!regUp.fixUpperEdge && !regLo.fixUpperEdge); + + if (orgUp == orgLo) return false; /* right endpoints are the same */ + + tMinUp = Math.min(orgUp.t, dstUp.t); + tMaxLo = Math.max(orgLo.t, dstLo.t); + if (tMinUp > tMaxLo) return false; /* t ranges do not overlap */ + + if (Geom.VertLeq(orgUp, orgLo)) { + if (Geom.EdgeSign(dstLo, orgUp, orgLo) > 0) return false; + } else { + if (Geom.EdgeSign(dstUp, orgLo, orgUp) < 0) return false; + } + + /* At this point the edges intersect, at least marginally */ + DebugEvent(tess); + + Geom.EdgeIntersect(dstUp, orgUp, dstLo, orgLo, isect); + /* The following properties are guaranteed: */ + assert (Math.min(orgUp.t, dstUp.t) <= isect.t); + assert (isect.t <= Math.max(orgLo.t, dstLo.t)); + assert (Math.min(dstLo.s, dstUp.s) <= isect.s); + assert (isect.s <= Math.max(orgLo.s, orgUp.s)); + + if (Geom.VertLeq(isect, tess.event)) { + /* The intersection point lies slightly to the left of the sweep line, + * so move it until it''s slightly to the right of the sweep line. + * (If we had perfect numerical precision, this would never happen + * in the first place). The easiest and safest thing to do is + * replace the intersection by tess.event. + */ + isect.s = tess.event.s; + isect.t = tess.event.t; + } + /* Similarly, if the computed intersection lies to the right of the + * rightmost origin (which should rarely happen), it can cause + * unbelievable inefficiency on sufficiently degenerate inputs. + * (If you have the test program, try running test54.d with the + * "X zoom" option turned on). + */ + orgMin = Geom.VertLeq(orgUp, orgLo) ? orgUp : orgLo; + if (Geom.VertLeq(orgMin, isect)) { + isect.s = orgMin.s; + isect.t = orgMin.t; + } + + if (Geom.VertEq(isect, orgUp) || Geom.VertEq(isect, orgLo)) { + /* Easy case -- intersection at one of the right endpoints */ + CheckForRightSplice(tess, regUp); + return false; + } + + if ((!Geom.VertEq(dstUp, tess.event) + && Geom.EdgeSign(dstUp, tess.event, isect) >= 0) + || (!Geom.VertEq(dstLo, tess.event) + && Geom.EdgeSign(dstLo, tess.event, isect) <= 0)) { + /* Very unusual -- the new upper or lower edge would pass on the + * wrong side of the sweep event, or through it. This can happen + * due to very small numerical errors in the intersection calculation. + */ + if (dstLo == tess.event) { + /* Splice dstLo into eUp, and process the new region(s) */ + if (Mesh.__gl_meshSplitEdge(eUp.Sym) == null) throw new RuntimeException(); + if (!Mesh.__gl_meshSplice(eLo.Sym, eUp)) throw new RuntimeException(); + regUp = TopLeftRegion(regUp); + if (regUp == null) throw new RuntimeException(); + eUp = RegionBelow(regUp).eUp; + FinishLeftRegions(tess, RegionBelow(regUp), regLo); + AddRightEdges(tess, regUp, eUp.Sym.Lnext, eUp, eUp, true); + return true; + } + if (dstUp == tess.event) { + /* Splice dstUp into eLo, and process the new region(s) */ + if (Mesh.__gl_meshSplitEdge(eLo.Sym) == null) throw new RuntimeException(); + if (!Mesh.__gl_meshSplice(eUp.Lnext, eLo.Sym.Lnext)) throw new RuntimeException(); + regLo = regUp; + regUp = TopRightRegion(regUp); + e = RegionBelow(regUp).eUp.Sym.Onext; + regLo.eUp = eLo.Sym.Lnext; + eLo = FinishLeftRegions(tess, regLo, null); + AddRightEdges(tess, regUp, eLo.Onext, eUp.Sym.Onext, e, true); + return true; + } + /* Special case: called from ConnectRightVertex. If either + * edge passes on the wrong side of tess.event, split it + * (and wait for ConnectRightVertex to splice it appropriately). + */ + if (Geom.EdgeSign(dstUp, tess.event, isect) >= 0) { + RegionAbove(regUp).dirty = regUp.dirty = true; + if (Mesh.__gl_meshSplitEdge(eUp.Sym) == null) throw new RuntimeException(); + eUp.Org.s = tess.event.s; + eUp.Org.t = tess.event.t; + } + if (Geom.EdgeSign(dstLo, tess.event, isect) <= 0) { + regUp.dirty = regLo.dirty = true; + if (Mesh.__gl_meshSplitEdge(eLo.Sym) == null) throw new RuntimeException(); + eLo.Org.s = tess.event.s; + eLo.Org.t = tess.event.t; + } + /* leave the rest for ConnectRightVertex */ + return false; + } + + /* General case -- split both edges, splice into new vertex. + * When we do the splice operation, the order of the arguments is + * arbitrary as far as correctness goes. However, when the operation + * creates a new face, the work done is proportional to the size of + * the new face. We expect the faces in the processed part of + * the mesh (ie. eUp.Lface) to be smaller than the faces in the + * unprocessed original contours (which will be eLo.Sym.Lnext.Lface). + */ + if (Mesh.__gl_meshSplitEdge(eUp.Sym) == null) throw new RuntimeException(); + if (Mesh.__gl_meshSplitEdge(eLo.Sym) == null) throw new RuntimeException(); + if (!Mesh.__gl_meshSplice(eLo.Sym.Lnext, eUp)) throw new RuntimeException(); + eUp.Org.s = isect.s; + eUp.Org.t = isect.t; + eUp.Org.pqHandle = tess.pq.pqInsert(eUp.Org); /* __gl_pqSortInsert */ + if (eUp.Org.pqHandle == Long.MAX_VALUE) { + tess.pq.pqDeletePriorityQ(); /* __gl_pqSortDeletePriorityQ */ + tess.pq = null; + throw new RuntimeException(); + } + GetIntersectData(tess, eUp.Org, orgUp, dstUp, orgLo, dstLo); + RegionAbove(regUp).dirty = regUp.dirty = regLo.dirty = true; + return false; + } + + static void WalkDirtyRegions(GLUtessellatorImpl tess, ActiveRegion regUp) +/* + * When the upper or lower edge of any region changes, the region is + * marked "dirty". This routine walks through all the dirty regions + * and makes sure that the dictionary invariants are satisfied + * (see the comments at the beginning of this file). Of course + * new dirty regions can be created as we make changes to restore + * the invariants. + */ { + ActiveRegion regLo = RegionBelow(regUp); + GLUhalfEdge eUp, eLo; + + for (; ;) { + /* Find the lowest dirty region (we walk from the bottom up). */ + while (regLo.dirty) { + regUp = regLo; + regLo = RegionBelow(regLo); + } + if (!regUp.dirty) { + regLo = regUp; + regUp = RegionAbove(regUp); + if (regUp == null || !regUp.dirty) { + /* We've walked all the dirty regions */ + return; + } + } + regUp.dirty = false; + eUp = regUp.eUp; + eLo = regLo.eUp; + + if (eUp.Sym.Org != eLo.Sym.Org) { + /* Check that the edge ordering is obeyed at the Dst vertices. */ + if (CheckForLeftSplice(tess, regUp)) { + + /* If the upper or lower edge was marked fixUpperEdge, then + * we no longer need it (since these edges are needed only for + * vertices which otherwise have no right-going edges). + */ + if (regLo.fixUpperEdge) { + DeleteRegion(tess, regLo); + if (!Mesh.__gl_meshDelete(eLo)) throw new RuntimeException(); + regLo = RegionBelow(regUp); + eLo = regLo.eUp; + } else if (regUp.fixUpperEdge) { + DeleteRegion(tess, regUp); + if (!Mesh.__gl_meshDelete(eUp)) throw new RuntimeException(); + regUp = RegionAbove(regLo); + eUp = regUp.eUp; + } + } + } + if (eUp.Org != eLo.Org) { + if (eUp.Sym.Org != eLo.Sym.Org + && !regUp.fixUpperEdge && !regLo.fixUpperEdge + && (eUp.Sym.Org == tess.event || eLo.Sym.Org == tess.event)) { + /* When all else fails in CheckForIntersect(), it uses tess.event + * as the intersection location. To make this possible, it requires + * that tess.event lie between the upper and lower edges, and also + * that neither of these is marked fixUpperEdge (since in the worst + * case it might splice one of these edges into tess.event, and + * violate the invariant that fixable edges are the only right-going + * edge from their associated vertex). + */ + if (CheckForIntersect(tess, regUp)) { + /* WalkDirtyRegions() was called recursively; we're done */ + return; + } + } else { + /* Even though we can't use CheckForIntersect(), the Org vertices + * may violate the dictionary edge ordering. Check and correct this. + */ + CheckForRightSplice(tess, regUp); + } + } + if (eUp.Org == eLo.Org && eUp.Sym.Org == eLo.Sym.Org) { + /* A degenerate loop consisting of only two edges -- delete it. */ + AddWinding(eLo, eUp); + DeleteRegion(tess, regUp); + if (!Mesh.__gl_meshDelete(eUp)) throw new RuntimeException(); + regUp = RegionAbove(regLo); + } + } + } + + + static void ConnectRightVertex(GLUtessellatorImpl tess, ActiveRegion regUp, + GLUhalfEdge eBottomLeft) +/* + * Purpose: connect a "right" vertex vEvent (one where all edges go left) + * to the unprocessed portion of the mesh. Since there are no right-going + * edges, two regions (one above vEvent and one below) are being merged + * into one. "regUp" is the upper of these two regions. + * + * There are two reasons for doing this (adding a right-going edge): + * - if the two regions being merged are "inside", we must add an edge + * to keep them separated (the combined region would not be monotone). + * - in any case, we must leave some record of vEvent in the dictionary, + * so that we can merge vEvent with features that we have not seen yet. + * For example, maybe there is a vertical edge which passes just to + * the right of vEvent; we would like to splice vEvent into this edge. + * + * However, we don't want to connect vEvent to just any vertex. We don''t + * want the new edge to cross any other edges; otherwise we will create + * intersection vertices even when the input data had no self-intersections. + * (This is a bad thing; if the user's input data has no intersections, + * we don't want to generate any false intersections ourselves.) + * + * Our eventual goal is to connect vEvent to the leftmost unprocessed + * vertex of the combined region (the union of regUp and regLo). + * But because of unseen vertices with all right-going edges, and also + * new vertices which may be created by edge intersections, we don''t + * know where that leftmost unprocessed vertex is. In the meantime, we + * connect vEvent to the closest vertex of either chain, and mark the region + * as "fixUpperEdge". This flag says to delete and reconnect this edge + * to the next processed vertex on the boundary of the combined region. + * Quite possibly the vertex we connected to will turn out to be the + * closest one, in which case we won''t need to make any changes. + */ { + GLUhalfEdge eNew; + GLUhalfEdge eTopLeft = eBottomLeft.Onext; + ActiveRegion regLo = RegionBelow(regUp); + GLUhalfEdge eUp = regUp.eUp; + GLUhalfEdge eLo = regLo.eUp; + boolean degenerate = false; + + if (eUp.Sym.Org != eLo.Sym.Org) { + CheckForIntersect(tess, regUp); + } + + /* Possible new degeneracies: upper or lower edge of regUp may pass + * through vEvent, or may coincide with new intersection vertex + */ + if (Geom.VertEq(eUp.Org, tess.event)) { + if (!Mesh.__gl_meshSplice(eTopLeft.Sym.Lnext, eUp)) throw new RuntimeException(); + regUp = TopLeftRegion(regUp); + if (regUp == null) throw new RuntimeException(); + eTopLeft = RegionBelow(regUp).eUp; + FinishLeftRegions(tess, RegionBelow(regUp), regLo); + degenerate = true; + } + if (Geom.VertEq(eLo.Org, tess.event)) { + if (!Mesh.__gl_meshSplice(eBottomLeft, eLo.Sym.Lnext)) throw new RuntimeException(); + eBottomLeft = FinishLeftRegions(tess, regLo, null); + degenerate = true; + } + if (degenerate) { + AddRightEdges(tess, regUp, eBottomLeft.Onext, eTopLeft, eTopLeft, true); + return; + } + + /* Non-degenerate situation -- need to add a temporary, fixable edge. + * Connect to the closer of eLo.Org, eUp.Org. + */ + if (Geom.VertLeq(eLo.Org, eUp.Org)) { + eNew = eLo.Sym.Lnext; + } else { + eNew = eUp; + } + eNew = Mesh.__gl_meshConnect(eBottomLeft.Onext.Sym, eNew); + if (eNew == null) throw new RuntimeException(); + + /* Prevent cleanup, otherwise eNew might disappear before we've even + * had a chance to mark it as a temporary edge. + */ + AddRightEdges(tess, regUp, eNew, eNew.Onext, eNew.Onext, false); + eNew.Sym.activeRegion.fixUpperEdge = true; + WalkDirtyRegions(tess, regUp); + } + +/* Because vertices at exactly the same location are merged together + * before we process the sweep event, some degenerate cases can't occur. + * However if someone eventually makes the modifications required to + * merge features which are close together, the cases below marked + * TOLERANCE_NONZERO will be useful. They were debugged before the + * code to merge identical vertices in the main loop was added. + */ + private static final boolean TOLERANCE_NONZERO = false; + + static void ConnectLeftDegenerate(GLUtessellatorImpl tess, + ActiveRegion regUp, GLUvertex vEvent) +/* + * The event vertex lies exacty on an already-processed edge or vertex. + * Adding the new vertex involves splicing it into the already-processed + * part of the mesh. + */ { + GLUhalfEdge e, eTopLeft, eTopRight, eLast; + ActiveRegion reg; + + e = regUp.eUp; + if (Geom.VertEq(e.Org, vEvent)) { + /* e.Org is an unprocessed vertex - just combine them, and wait + * for e.Org to be pulled from the queue + */ + assert (TOLERANCE_NONZERO); + SpliceMergeVertices(tess, e, vEvent.anEdge); + return; + } + + if (!Geom.VertEq(e.Sym.Org, vEvent)) { + /* General case -- splice vEvent into edge e which passes through it */ + if (Mesh.__gl_meshSplitEdge(e.Sym) == null) throw new RuntimeException(); + if (regUp.fixUpperEdge) { + /* This edge was fixable -- delete unused portion of original edge */ + if (!Mesh.__gl_meshDelete(e.Onext)) throw new RuntimeException(); + regUp.fixUpperEdge = false; + } + if (!Mesh.__gl_meshSplice(vEvent.anEdge, e)) throw new RuntimeException(); + SweepEvent(tess, vEvent); /* recurse */ + return; + } + + /* vEvent coincides with e.Sym.Org, which has already been processed. + * Splice in the additional right-going edges. + */ + assert (TOLERANCE_NONZERO); + regUp = TopRightRegion(regUp); + reg = RegionBelow(regUp); + eTopRight = reg.eUp.Sym; + eTopLeft = eLast = eTopRight.Onext; + if (reg.fixUpperEdge) { + /* Here e.Sym.Org has only a single fixable edge going right. + * We can delete it since now we have some real right-going edges. + */ + assert (eTopLeft != eTopRight); /* there are some left edges too */ + DeleteRegion(tess, reg); + if (!Mesh.__gl_meshDelete(eTopRight)) throw new RuntimeException(); + eTopRight = eTopLeft.Sym.Lnext; + } + if (!Mesh.__gl_meshSplice(vEvent.anEdge, eTopRight)) throw new RuntimeException(); + if (!Geom.EdgeGoesLeft(eTopLeft)) { + /* e.Sym.Org had no left-going edges -- indicate this to AddRightEdges() */ + eTopLeft = null; + } + AddRightEdges(tess, regUp, eTopRight.Onext, eLast, eTopLeft, true); + } + + + static void ConnectLeftVertex(GLUtessellatorImpl tess, GLUvertex vEvent) +/* + * Purpose: connect a "left" vertex (one where both edges go right) + * to the processed portion of the mesh. Let R be the active region + * containing vEvent, and let U and L be the upper and lower edge + * chains of R. There are two possibilities: + * + * - the normal case: split R into two regions, by connecting vEvent to + * the rightmost vertex of U or L lying to the left of the sweep line + * + * - the degenerate case: if vEvent is close enough to U or L, we + * merge vEvent into that edge chain. The subcases are: + * - merging with the rightmost vertex of U or L + * - merging with the active edge of U or L + * - merging with an already-processed portion of U or L + */ { + ActiveRegion regUp, regLo, reg; + GLUhalfEdge eUp, eLo, eNew; + ActiveRegion tmp = new ActiveRegion(); + + /* assert ( vEvent.anEdge.Onext.Onext == vEvent.anEdge ); */ + + /* Get a pointer to the active region containing vEvent */ + tmp.eUp = vEvent.anEdge.Sym; + /* __GL_DICTLISTKEY */ /* __gl_dictListSearch */ + regUp = (ActiveRegion) Dict.dictKey(Dict.dictSearch(tess.dict, tmp)); + regLo = RegionBelow(regUp); + eUp = regUp.eUp; + eLo = regLo.eUp; + + /* Try merging with U or L first */ + if (Geom.EdgeSign(eUp.Sym.Org, vEvent, eUp.Org) == 0) { + ConnectLeftDegenerate(tess, regUp, vEvent); + return; + } + + /* Connect vEvent to rightmost processed vertex of either chain. + * e.Sym.Org is the vertex that we will connect to vEvent. + */ + reg = Geom.VertLeq(eLo.Sym.Org, eUp.Sym.Org) ? regUp : regLo; + + if (regUp.inside || reg.fixUpperEdge) { + if (reg == regUp) { + eNew = Mesh.__gl_meshConnect(vEvent.anEdge.Sym, eUp.Lnext); + if (eNew == null) throw new RuntimeException(); + } else { + GLUhalfEdge tempHalfEdge = Mesh.__gl_meshConnect(eLo.Sym.Onext.Sym, vEvent.anEdge); + if (tempHalfEdge == null) throw new RuntimeException(); + + eNew = tempHalfEdge.Sym; + } + if (reg.fixUpperEdge) { + if (!FixUpperEdge(reg, eNew)) throw new RuntimeException(); + } else { + ComputeWinding(tess, AddRegionBelow(tess, regUp, eNew)); + } + SweepEvent(tess, vEvent); + } else { + /* The new vertex is in a region which does not belong to the polygon. + * We don''t need to connect this vertex to the rest of the mesh. + */ + AddRightEdges(tess, regUp, vEvent.anEdge, vEvent.anEdge, null, true); + } + } + + + static void SweepEvent(GLUtessellatorImpl tess, GLUvertex vEvent) +/* + * Does everything necessary when the sweep line crosses a vertex. + * Updates the mesh and the edge dictionary. + */ { + ActiveRegion regUp, reg; + GLUhalfEdge e, eTopLeft, eBottomLeft; + + tess.event = vEvent; /* for access in EdgeLeq() */ + DebugEvent(tess); + + /* Check if this vertex is the right endpoint of an edge that is + * already in the dictionary. In this case we don't need to waste + * time searching for the location to insert new edges. + */ + e = vEvent.anEdge; + while (e.activeRegion == null) { + e = e.Onext; + if (e == vEvent.anEdge) { + /* All edges go right -- not incident to any processed edges */ + ConnectLeftVertex(tess, vEvent); + return; + } + } + + /* Processing consists of two phases: first we "finish" all the + * active regions where both the upper and lower edges terminate + * at vEvent (ie. vEvent is closing off these regions). + * We mark these faces "inside" or "outside" the polygon according + * to their winding number, and delete the edges from the dictionary. + * This takes care of all the left-going edges from vEvent. + */ + regUp = TopLeftRegion(e.activeRegion); + if (regUp == null) throw new RuntimeException(); + reg = RegionBelow(regUp); + eTopLeft = reg.eUp; + eBottomLeft = FinishLeftRegions(tess, reg, null); + + /* Next we process all the right-going edges from vEvent. This + * involves adding the edges to the dictionary, and creating the + * associated "active regions" which record information about the + * regions between adjacent dictionary edges. + */ + if (eBottomLeft.Onext == eTopLeft) { + /* No right-going edges -- add a temporary "fixable" edge */ + ConnectRightVertex(tess, regUp, eBottomLeft); + } else { + AddRightEdges(tess, regUp, eBottomLeft.Onext, eTopLeft, eTopLeft, true); + } + } + + +/* Make the sentinel coordinates big enough that they will never be + * merged with real input features. (Even with the largest possible + * input contour and the maximum tolerance of 1.0, no merging will be + * done with coordinates larger than 3 * GLU_TESS_MAX_COORD). + */ + private static final double SENTINEL_COORD = (4.0 * GLU.GLU_TESS_MAX_COORD); + + static void AddSentinel(GLUtessellatorImpl tess, double t) +/* + * We add two sentinel edges above and below all other edges, + * to avoid special cases at the top and bottom. + */ { + GLUhalfEdge e; + ActiveRegion reg = new ActiveRegion(); + if (reg == null) throw new RuntimeException(); + + e = Mesh.__gl_meshMakeEdge(tess.mesh); + if (e == null) throw new RuntimeException(); + + e.Org.s = SENTINEL_COORD; + e.Org.t = t; + e.Sym.Org.s = -SENTINEL_COORD; + e.Sym.Org.t = t; + tess.event = e.Sym.Org; /* initialize it */ + + reg.eUp = e; + reg.windingNumber = 0; + reg.inside = false; + reg.fixUpperEdge = false; + reg.sentinel = true; + reg.dirty = false; + reg.nodeUp = Dict.dictInsert(tess.dict, reg); /* __gl_dictListInsertBefore */ + if (reg.nodeUp == null) throw new RuntimeException(); + } + + + static void InitEdgeDict(final GLUtessellatorImpl tess) +/* + * We maintain an ordering of edge intersections with the sweep line. + * This order is maintained in a dynamic dictionary. + */ { + /* __gl_dictListNewDict */ + tess.dict = Dict.dictNewDict(tess, new Dict.DictLeq() { + public boolean leq(Object frame, Object key1, Object key2) { + return EdgeLeq(tess, (ActiveRegion) key1, (ActiveRegion) key2); + } + }); + if (tess.dict == null) throw new RuntimeException(); + + AddSentinel(tess, -SENTINEL_COORD); + AddSentinel(tess, SENTINEL_COORD); + } + + + static void DoneEdgeDict(GLUtessellatorImpl tess) { + ActiveRegion reg; + int fixedEdges = 0; + + /* __GL_DICTLISTKEY */ /* __GL_DICTLISTMIN */ + while ((reg = (ActiveRegion) Dict.dictKey(Dict.dictMin(tess.dict))) != null) { + /* + * At the end of all processing, the dictionary should contain + * only the two sentinel edges, plus at most one "fixable" edge + * created by ConnectRightVertex(). + */ + if (!reg.sentinel) { + assert (reg.fixUpperEdge); + assert (++fixedEdges == 1); + } + assert (reg.windingNumber == 0); + DeleteRegion(tess, reg); +/* __gl_meshDelete( reg.eUp );*/ + } + Dict.dictDeleteDict(tess.dict); /* __gl_dictListDeleteDict */ + } + + + static void RemoveDegenerateEdges(GLUtessellatorImpl tess) +/* + * Remove zero-length edges, and contours with fewer than 3 vertices. + */ { + GLUhalfEdge e, eNext, eLnext; + GLUhalfEdge eHead = tess.mesh.eHead; + + /*LINTED*/ + for (e = eHead.next; e != eHead; e = eNext) { + eNext = e.next; + eLnext = e.Lnext; + + if (Geom.VertEq(e.Org, e.Sym.Org) && e.Lnext.Lnext != e) { + /* Zero-length edge, contour has at least 3 edges */ + + SpliceMergeVertices(tess, eLnext, e); /* deletes e.Org */ + if (!Mesh.__gl_meshDelete(e)) throw new RuntimeException(); /* e is a self-loop */ + e = eLnext; + eLnext = e.Lnext; + } + if (eLnext.Lnext == e) { + /* Degenerate contour (one or two edges) */ + + if (eLnext != e) { + if (eLnext == eNext || eLnext == eNext.Sym) { + eNext = eNext.next; + } + if (!Mesh.__gl_meshDelete(eLnext)) throw new RuntimeException(); + } + if (e == eNext || e == eNext.Sym) { + eNext = eNext.next; + } + if (!Mesh.__gl_meshDelete(e)) throw new RuntimeException(); + } + } + } + + static boolean InitPriorityQ(GLUtessellatorImpl tess) +/* + * Insert all vertices into the priority queue which determines the + * order in which vertices cross the sweep line. + */ { + PriorityQ pq; + GLUvertex v, vHead; + + /* __gl_pqSortNewPriorityQ */ + pq = tess.pq = PriorityQ.pqNewPriorityQ(new PriorityQ.Leq() { + public boolean leq(Object key1, Object key2) { + return Geom.VertLeq(((GLUvertex) key1), (GLUvertex) key2); + } + }); + if (pq == null) return false; + + vHead = tess.mesh.vHead; + for (v = vHead.next; v != vHead; v = v.next) { + v.pqHandle = pq.pqInsert(v); /* __gl_pqSortInsert */ + if (v.pqHandle == Long.MAX_VALUE) break; + } + if (v != vHead || !pq.pqInit()) { /* __gl_pqSortInit */ + tess.pq.pqDeletePriorityQ(); /* __gl_pqSortDeletePriorityQ */ + tess.pq = null; + return false; + } + + return true; + } + + + static void DonePriorityQ(GLUtessellatorImpl tess) { + tess.pq.pqDeletePriorityQ(); /* __gl_pqSortDeletePriorityQ */ + } + + + static boolean RemoveDegenerateFaces(GLUmesh mesh) +/* + * Delete any degenerate faces with only two edges. WalkDirtyRegions() + * will catch almost all of these, but it won't catch degenerate faces + * produced by splice operations on already-processed edges. + * The two places this can happen are in FinishLeftRegions(), when + * we splice in a "temporary" edge produced by ConnectRightVertex(), + * and in CheckForLeftSplice(), where we splice already-processed + * edges to ensure that our dictionary invariants are not violated + * by numerical errors. + * + * In both these cases it is *very* dangerous to delete the offending + * edge at the time, since one of the routines further up the stack + * will sometimes be keeping a pointer to that edge. + */ { + GLUface f, fNext; + GLUhalfEdge e; + + /*LINTED*/ + for (f = mesh.fHead.next; f != mesh.fHead; f = fNext) { + fNext = f.next; + e = f.anEdge; + assert (e.Lnext != e); + + if (e.Lnext.Lnext == e) { + /* A face with only two edges */ + AddWinding(e.Onext, e); + if (!Mesh.__gl_meshDelete(e)) return false; + } + } + return true; + } + + public static boolean __gl_computeInterior(GLUtessellatorImpl tess) +/* + * __gl_computeInterior( tess ) computes the planar arrangement specified + * by the given contours, and further subdivides this arrangement + * into regions. Each region is marked "inside" if it belongs + * to the polygon, according to the rule given by tess.windingRule. + * Each interior region is guaranteed be monotone. + */ { + GLUvertex v, vNext; + + tess.fatalError = false; + + /* Each vertex defines an event for our sweep line. Start by inserting + * all the vertices in a priority queue. Events are processed in + * lexicographic order, ie. + * + * e1 < e2 iff e1.x < e2.x || (e1.x == e2.x && e1.y < e2.y) + */ + RemoveDegenerateEdges(tess); + if (!InitPriorityQ(tess)) return false; /* if error */ + InitEdgeDict(tess); + + /* __gl_pqSortExtractMin */ + while ((v = (GLUvertex) tess.pq.pqExtractMin()) != null) { + for (; ;) { + vNext = (GLUvertex) tess.pq.pqMinimum(); /* __gl_pqSortMinimum */ + if (vNext == null || !Geom.VertEq(vNext, v)) break; + + /* Merge together all vertices at exactly the same location. + * This is more efficient than processing them one at a time, + * simplifies the code (see ConnectLeftDegenerate), and is also + * important for correct handling of certain degenerate cases. + * For example, suppose there are two identical edges A and B + * that belong to different contours (so without this code they would + * be processed by separate sweep events). Suppose another edge C + * crosses A and B from above. When A is processed, we split it + * at its intersection point with C. However this also splits C, + * so when we insert B we may compute a slightly different + * intersection point. This might leave two edges with a small + * gap between them. This kind of error is especially obvious + * when using boundary extraction (GLU_TESS_BOUNDARY_ONLY). + */ + vNext = (GLUvertex) tess.pq.pqExtractMin(); /* __gl_pqSortExtractMin*/ + SpliceMergeVertices(tess, v.anEdge, vNext.anEdge); + } + SweepEvent(tess, v); + } + + /* Set tess.event for debugging purposes */ + /* __GL_DICTLISTKEY */ /* __GL_DICTLISTMIN */ + tess.event = ((ActiveRegion) Dict.dictKey(Dict.dictMin(tess.dict))).eUp.Org; + DebugEvent(tess); + DoneEdgeDict(tess); + DonePriorityQ(tess); + + if (!RemoveDegenerateFaces(tess.mesh)) return false; + Mesh.__gl_meshCheckMesh(tess.mesh); + + return true; + } +} diff --git a/src/java/org/lwjgl/util/glu/tessellation/TessMono.java b/src/java/org/lwjgl/util/glu/tessellation/TessMono.java new file mode 100644 index 0000000..10890e6 --- /dev/null +++ b/src/java/org/lwjgl/util/glu/tessellation/TessMono.java @@ -0,0 +1,241 @@ +/* + * 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. + */ + +/* +* Portions Copyright (C) 2003-2006 Sun Microsystems, Inc. +* All rights reserved. +*/ + +/* +** License Applicability. Except to the extent portions of this file are +** made subject to an alternative license as permitted in the SGI Free +** Software License B, Version 1.1 (the "License"), the contents of this +** file are subject only to the provisions of the License. You may not use +** this file except in compliance with the License. You may obtain a copy +** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 +** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: +** +** http://oss.sgi.com/projects/FreeB +** +** Note that, as provided in the License, the Software is distributed on an +** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS +** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND +** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A +** PARTICULAR PURPOSE, AND NON-INFRINGEMENT. +** +** NOTE: The Original Code (as defined below) has been licensed to Sun +** Microsystems, Inc. ("Sun") under the SGI Free Software License B +** (Version 1.1), shown above ("SGI License"). Pursuant to Section +** 3.2(3) of the SGI License, Sun is distributing the Covered Code to +** you under an alternative license ("Alternative License"). This +** Alternative License includes all of the provisions of the SGI License +** except that Section 2.2 and 11 are omitted. Any differences between +** the Alternative License and the SGI License are offered solely by Sun +** and not by SGI. +** +** Original Code. The Original Code is: OpenGL Sample Implementation, +** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics, +** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc. +** Copyright in any portions created by third parties is as indicated +** elsewhere herein. All Rights Reserved. +** +** Additional Notice Provisions: The application programming interfaces +** established by SGI in conjunction with the Original Code are The +** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released +** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version +** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X +** Window System(R) (Version 1.3), released October 19, 1998. This software +** was created using the OpenGL(R) version 1.2.1 Sample Implementation +** published by SGI, but has not been independently verified as being +** compliant with the OpenGL(R) version 1.2.1 Specification. +** +** Author: Eric Veach, July 1994 +** Java Port: Pepijn Van Eeckhoudt, July 2003 +** Java Port: Nathan Parker Burg, August 2003 +*/ +package org.lwjgl.util.glu.tessellation; + +class TessMono { +/* __gl_meshTessellateMonoRegion( face ) tessellates a monotone region + * (what else would it do??) The region must consist of a single + * loop of half-edges (see mesh.h) oriented CCW. "Monotone" in this + * case means that any vertical line intersects the interior of the + * region in a single interval. + * + * Tessellation consists of adding interior edges (actually pairs of + * half-edges), to split the region into non-overlapping triangles. + * + * The basic idea is explained in Preparata and Shamos (which I don''t + * have handy right now), although their implementation is more + * complicated than this one. The are two edge chains, an upper chain + * and a lower chain. We process all vertices from both chains in order, + * from right to left. + * + * The algorithm ensures that the following invariant holds after each + * vertex is processed: the untessellated region consists of two + * chains, where one chain (say the upper) is a single edge, and + * the other chain is concave. The left vertex of the single edge + * is always to the left of all vertices in the concave chain. + * + * Each step consists of adding the rightmost unprocessed vertex to one + * of the two chains, and forming a fan of triangles from the rightmost + * of two chain endpoints. Determining whether we can add each triangle + * to the fan is a simple orientation test. By making the fan as large + * as possible, we restore the invariant (check it yourself). + */ + static boolean __gl_meshTessellateMonoRegion(GLUface face) { + GLUhalfEdge up, lo; + + /* All edges are oriented CCW around the boundary of the region. + * First, find the half-edge whose origin vertex is rightmost. + * Since the sweep goes from left to right, face->anEdge should + * be close to the edge we want. + */ + up = face.anEdge; + assert (up.Lnext != up && up.Lnext.Lnext != up); + + for (; Geom.VertLeq(up.Sym.Org, up.Org); up = up.Onext.Sym) + ; + for (; Geom.VertLeq(up.Org, up.Sym.Org); up = up.Lnext) + ; + lo = up.Onext.Sym; + + while (up.Lnext != lo) { + if (Geom.VertLeq(up.Sym.Org, lo.Org)) { + /* up.Sym.Org is on the left. It is safe to form triangles from lo.Org. + * The EdgeGoesLeft test guarantees progress even when some triangles + * are CW, given that the upper and lower chains are truly monotone. + */ + while (lo.Lnext != up && (Geom.EdgeGoesLeft(lo.Lnext) + || Geom.EdgeSign(lo.Org, lo.Sym.Org, lo.Lnext.Sym.Org) <= 0)) { + GLUhalfEdge tempHalfEdge = Mesh.__gl_meshConnect(lo.Lnext, lo); + if (tempHalfEdge == null) return false; + lo = tempHalfEdge.Sym; + } + lo = lo.Onext.Sym; + } else { + /* lo.Org is on the left. We can make CCW triangles from up.Sym.Org. */ + while (lo.Lnext != up && (Geom.EdgeGoesRight(up.Onext.Sym) + || Geom.EdgeSign(up.Sym.Org, up.Org, up.Onext.Sym.Org) >= 0)) { + GLUhalfEdge tempHalfEdge = Mesh.__gl_meshConnect(up, up.Onext.Sym); + if (tempHalfEdge == null) return false; + up = tempHalfEdge.Sym; + } + up = up.Lnext; + } + } + + /* Now lo.Org == up.Sym.Org == the leftmost vertex. The remaining region + * can be tessellated in a fan from this leftmost vertex. + */ + assert (lo.Lnext != up); + while (lo.Lnext.Lnext != up) { + GLUhalfEdge tempHalfEdge = Mesh.__gl_meshConnect(lo.Lnext, lo); + if (tempHalfEdge == null) return false; + lo = tempHalfEdge.Sym; + } + + return true; + } + + +/* __gl_meshTessellateInterior( mesh ) tessellates each region of + * the mesh which is marked "inside" the polygon. Each such region + * must be monotone. + */ + public static boolean __gl_meshTessellateInterior(GLUmesh mesh) { + GLUface f, next; + + /*LINTED*/ + for (f = mesh.fHead.next; f != mesh.fHead; f = next) { + /* Make sure we don''t try to tessellate the new triangles. */ + next = f.next; + if (f.inside) { + if (!__gl_meshTessellateMonoRegion(f)) return false; + } + } + + return true; + } + + +/* __gl_meshDiscardExterior( mesh ) zaps (ie. sets to NULL) all faces + * which are not marked "inside" the polygon. Since further mesh operations + * on NULL faces are not allowed, the main purpose is to clean up the + * mesh so that exterior loops are not represented in the data structure. + */ + public static void __gl_meshDiscardExterior(GLUmesh mesh) { + GLUface f, next; + + /*LINTED*/ + for (f = mesh.fHead.next; f != mesh.fHead; f = next) { + /* Since f will be destroyed, save its next pointer. */ + next = f.next; + if (!f.inside) { + Mesh.__gl_meshZapFace(f); + } + } + } + +// private static final int MARKED_FOR_DELETION = 0x7fffffff; + +/* __gl_meshSetWindingNumber( mesh, value, keepOnlyBoundary ) resets the + * winding numbers on all edges so that regions marked "inside" the + * polygon have a winding number of "value", and regions outside + * have a winding number of 0. + * + * If keepOnlyBoundary is TRUE, it also deletes all edges which do not + * separate an interior region from an exterior one. + */ + public static boolean __gl_meshSetWindingNumber(GLUmesh mesh, int value, boolean keepOnlyBoundary) { + GLUhalfEdge e, eNext; + + for (e = mesh.eHead.next; e != mesh.eHead; e = eNext) { + eNext = e.next; + if (e.Sym.Lface.inside != e.Lface.inside) { + + /* This is a boundary edge (one side is interior, one is exterior). */ + e.winding = (e.Lface.inside) ? value : -value; + } else { + + /* Both regions are interior, or both are exterior. */ + if (!keepOnlyBoundary) { + e.winding = 0; + } else { + if (!Mesh.__gl_meshDelete(e)) return false; + } + } + } + return true; + } + +} diff --git a/src/java/org/lwjgl/util/glu/tessellation/TessState.java b/src/java/org/lwjgl/util/glu/tessellation/TessState.java new file mode 100644 index 0000000..1c5c396 --- /dev/null +++ b/src/java/org/lwjgl/util/glu/tessellation/TessState.java @@ -0,0 +1,91 @@ +/* + * 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. + */ + +/* +* Portions Copyright (C) 2003-2006 Sun Microsystems, Inc. +* All rights reserved. +*/ + +/* +** License Applicability. Except to the extent portions of this file are +** made subject to an alternative license as permitted in the SGI Free +** Software License B, Version 1.1 (the "License"), the contents of this +** file are subject only to the provisions of the License. You may not use +** this file except in compliance with the License. You may obtain a copy +** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 +** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: +** +** http://oss.sgi.com/projects/FreeB +** +** Note that, as provided in the License, the Software is distributed on an +** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS +** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND +** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A +** PARTICULAR PURPOSE, AND NON-INFRINGEMENT. +** +** NOTE: The Original Code (as defined below) has been licensed to Sun +** Microsystems, Inc. ("Sun") under the SGI Free Software License B +** (Version 1.1), shown above ("SGI License"). Pursuant to Section +** 3.2(3) of the SGI License, Sun is distributing the Covered Code to +** you under an alternative license ("Alternative License"). This +** Alternative License includes all of the provisions of the SGI License +** except that Section 2.2 and 11 are omitted. Any differences between +** the Alternative License and the SGI License are offered solely by Sun +** and not by SGI. +** +** Original Code. The Original Code is: OpenGL Sample Implementation, +** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics, +** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc. +** Copyright in any portions created by third parties is as indicated +** elsewhere herein. All Rights Reserved. +** +** Additional Notice Provisions: The application programming interfaces +** established by SGI in conjunction with the Original Code are The +** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released +** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version +** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X +** Window System(R) (Version 1.3), released October 19, 1998. This software +** was created using the OpenGL(R) version 1.2.1 Sample Implementation +** published by SGI, but has not been independently verified as being +** compliant with the OpenGL(R) version 1.2.1 Specification. +** +** Author: Eric Veach, July 1994 +** Java Port: Pepijn Van Eeckhoudt, July 2003 +** Java Port: Nathan Parker Burg, August 2003 +*/ +package org.lwjgl.util.glu.tessellation; + +class TessState { + public static final int T_DORMANT = 0; + public static final int T_IN_POLYGON = 1; + public static final int T_IN_CONTOUR = 2; +} diff --git a/src/java/org/lwjgl/util/input/ControllerAdapter.java b/src/java/org/lwjgl/util/input/ControllerAdapter.java new file mode 100644 index 0000000..541e506 --- /dev/null +++ b/src/java/org/lwjgl/util/input/ControllerAdapter.java @@ -0,0 +1,329 @@ +/* + * 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.input; + +import org.lwjgl.input.Controller; + +/** + * Adapter for the Controller interface. It can be used as placeholder + * Controller, which doesn't do anything (eg if Controllers.create() fails and + * you don't want to take care of that). + * + * @author Onyx, Aho and all the other aliases... + */ +public class ControllerAdapter implements Controller { + + /** + * Get the name assigned to this controller. + * + * @return The name assigned to this controller + */ + public String getName() { + return "Dummy Controller"; + } + + /** + * Get the index of this controller in the collection + * + * @return The index of this controller in the collection + */ + public int getIndex() { + return 0; //-1 maybe? + } + + /** + * Retrieve the number of buttons available on this controller + * + * @return The number of butotns available on this controller + */ + public int getButtonCount() { + return 0; + } + + /** + * 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 + */ + public String getButtonName(int index) { + return "button n/a"; + } + + /** + * Check if a button is currently pressed + * + * @param index The button to check + * @return True if the button is currently pressed + */ + public boolean isButtonPressed(int index) { + return false; + } + + /** + * Poll the controller for new data. This will also update events + */ + public void poll() { + } + + /** + * Get the X-Axis value of the POV on this controller + * + * @return The X-Axis value of the POV on this controller + */ + public float getPovX() { + return 0f; + } + + /** + * Get the Y-Axis value of the POV on this controller + * + * @return The Y-Axis value of the POV on this controller + */ + public float getPovY() { + return 0f; + } + + /** + * 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 + */ + public float getDeadZone(int index) { + return 0f; + } + + /** + * 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 + */ + public void setDeadZone(int index, float zone) { + } + + /** + * Retrieve the number of axes available on this controller. + * + * @return The number of axes available on this controller. + */ + public int getAxisCount() { + return 0; + } + + /** + * 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. + */ + public String getAxisName(int index) { + return "axis n/a"; + } + + /** + * 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. + */ + public float getAxisValue(int index) { + return 0f; + } + + /** + * 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 + */ + public float getXAxisValue() { + return 0f; + } + + /** + * Get the dead zone for the X axis. + * + * @return The dead zone for the X axis + */ + public float getXAxisDeadZone() { + return 0f; + } + + /** + * Set the dead zone for the X axis + * + * @param zone The dead zone to use for the X axis + */ + public 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 + */ + public float getYAxisValue() { + return 0f; + } + + /** + * Get the dead zone for the Y axis. + * + * @return The dead zone for the Y axis + */ + public float getYAxisDeadZone() { + return 0f; + } + + /** + * Set the dead zone for the Y axis + * + * @param zone The dead zone to use for the Y axis + */ + public 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 + */ + public float getZAxisValue() { + return 0f; + } + + /** + * Get the dead zone for the Z axis. + * + * @return The dead zone for the Z axis + */ + public float getZAxisDeadZone() { + return 0f; + } + + /** + * Set the dead zone for the Z axis + * + * @param zone The dead zone to use for the Z axis + */ + public 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 + */ + public float getRXAxisValue() { + return 0f; + } + + /** + * Get the dead zone for the RX axis. + * + * @return The dead zone for the RX axis + */ + public float getRXAxisDeadZone() { + return 0f; + } + + /** + * Set the dead zone for the RX axis + * + * @param zone The dead zone to use for the RX axis + */ + public 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 + */ + public float getRYAxisValue() { + return 0f; + } + + /** + * Get the dead zone for the RY axis. + * + * @return The dead zone for the RY axis + */ + public float getRYAxisDeadZone() { + return 0f; + } + + /** + * Set the dead zone for the RY axis + * + * @param zone The dead zone to use for the RY axis + */ + public 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 + */ + public float getRZAxisValue() { + return 0f; + } + + /** + * Get the dead zone for the RZ axis. + * + * @return The dead zone for the RZ axis + */ + public float getRZAxisDeadZone() { + return 0f; + } + + /** + * Set the dead zone for the RZ axis + * + * @param zone The dead zone to use for the RZ axis + */ + public void setRZAxisDeadZone(float zone) { + } +} \ No newline at end of file diff --git a/src/java/org/lwjgl/util/jinput/KeyMap.java b/src/java/org/lwjgl/util/jinput/KeyMap.java new file mode 100644 index 0000000..0bbf65f --- /dev/null +++ b/src/java/org/lwjgl/util/jinput/KeyMap.java @@ -0,0 +1,293 @@ +/* + * 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.jinput; + +import org.lwjgl.input.Keyboard; +import net.java.games.input.Component; + +/** + * @author elias + */ +final class KeyMap { + public final static Component.Identifier.Key map(int lwjgl_key_code) { + switch (lwjgl_key_code) { + case Keyboard.KEY_ESCAPE: + return Component.Identifier.Key.ESCAPE; + case Keyboard.KEY_1: + return Component.Identifier.Key._1; + case Keyboard.KEY_2: + return Component.Identifier.Key._2; + case Keyboard.KEY_3: + return Component.Identifier.Key._3; + case Keyboard.KEY_4: + return Component.Identifier.Key._4; + case Keyboard.KEY_5: + return Component.Identifier.Key._5; + case Keyboard.KEY_6: + return Component.Identifier.Key._6; + case Keyboard.KEY_7: + return Component.Identifier.Key._7; + case Keyboard.KEY_8: + return Component.Identifier.Key._8; + case Keyboard.KEY_9: + return Component.Identifier.Key._9; + case Keyboard.KEY_0: + return Component.Identifier.Key._0; + case Keyboard.KEY_MINUS: + return Component.Identifier.Key.MINUS; + case Keyboard.KEY_EQUALS: + return Component.Identifier.Key.EQUALS; + case Keyboard.KEY_BACK: + return Component.Identifier.Key.BACK; + case Keyboard.KEY_TAB: + return Component.Identifier.Key.TAB; + case Keyboard.KEY_Q: + return Component.Identifier.Key.Q; + case Keyboard.KEY_W: + return Component.Identifier.Key.W; + case Keyboard.KEY_E: + return Component.Identifier.Key.E; + case Keyboard.KEY_R: + return Component.Identifier.Key.R; + case Keyboard.KEY_T: + return Component.Identifier.Key.T; + case Keyboard.KEY_Y: + return Component.Identifier.Key.Y; + case Keyboard.KEY_U: + return Component.Identifier.Key.U; + case Keyboard.KEY_I: + return Component.Identifier.Key.I; + case Keyboard.KEY_O: + return Component.Identifier.Key.O; + case Keyboard.KEY_P: + return Component.Identifier.Key.P; + case Keyboard.KEY_LBRACKET: + return Component.Identifier.Key.LBRACKET; + case Keyboard.KEY_RBRACKET: + return Component.Identifier.Key.RBRACKET; + case Keyboard.KEY_RETURN: + return Component.Identifier.Key.RETURN; + case Keyboard.KEY_LCONTROL: + return Component.Identifier.Key.LCONTROL; + case Keyboard.KEY_A: + return Component.Identifier.Key.A; + case Keyboard.KEY_S: + return Component.Identifier.Key.S; + case Keyboard.KEY_D: + return Component.Identifier.Key.D; + case Keyboard.KEY_F: + return Component.Identifier.Key.F; + case Keyboard.KEY_G: + return Component.Identifier.Key.G; + case Keyboard.KEY_H: + return Component.Identifier.Key.H; + case Keyboard.KEY_J: + return Component.Identifier.Key.J; + case Keyboard.KEY_K: + return Component.Identifier.Key.K; + case Keyboard.KEY_L: + return Component.Identifier.Key.L; + case Keyboard.KEY_SEMICOLON: + return Component.Identifier.Key.SEMICOLON; + case Keyboard.KEY_APOSTROPHE: + return Component.Identifier.Key.APOSTROPHE; + case Keyboard.KEY_GRAVE: + return Component.Identifier.Key.GRAVE; + case Keyboard.KEY_LSHIFT: + return Component.Identifier.Key.LSHIFT; + case Keyboard.KEY_BACKSLASH: + return Component.Identifier.Key.BACKSLASH; + case Keyboard.KEY_Z: + return Component.Identifier.Key.Z; + case Keyboard.KEY_X: + return Component.Identifier.Key.X; + case Keyboard.KEY_C: + return Component.Identifier.Key.C; + case Keyboard.KEY_V: + return Component.Identifier.Key.V; + case Keyboard.KEY_B: + return Component.Identifier.Key.B; + case Keyboard.KEY_N: + return Component.Identifier.Key.N; + case Keyboard.KEY_M: + return Component.Identifier.Key.M; + case Keyboard.KEY_COMMA: + return Component.Identifier.Key.COMMA; + case Keyboard.KEY_PERIOD: + return Component.Identifier.Key.PERIOD; + case Keyboard.KEY_SLASH: + return Component.Identifier.Key.SLASH; + case Keyboard.KEY_RSHIFT: + return Component.Identifier.Key.RSHIFT; + case Keyboard.KEY_MULTIPLY: + return Component.Identifier.Key.MULTIPLY; + case Keyboard.KEY_LMENU: + return Component.Identifier.Key.LALT; + case Keyboard.KEY_SPACE: + return Component.Identifier.Key.SPACE; + case Keyboard.KEY_CAPITAL: + return Component.Identifier.Key.CAPITAL; + case Keyboard.KEY_F1: + return Component.Identifier.Key.F1; + case Keyboard.KEY_F2: + return Component.Identifier.Key.F2; + case Keyboard.KEY_F3: + return Component.Identifier.Key.F3; + case Keyboard.KEY_F4: + return Component.Identifier.Key.F4; + case Keyboard.KEY_F5: + return Component.Identifier.Key.F5; + case Keyboard.KEY_F6: + return Component.Identifier.Key.F6; + case Keyboard.KEY_F7: + return Component.Identifier.Key.F7; + case Keyboard.KEY_F8: + return Component.Identifier.Key.F8; + case Keyboard.KEY_F9: + return Component.Identifier.Key.F9; + case Keyboard.KEY_F10: + return Component.Identifier.Key.F10; + case Keyboard.KEY_NUMLOCK: + return Component.Identifier.Key.NUMLOCK; + case Keyboard.KEY_SCROLL: + return Component.Identifier.Key.SCROLL; + case Keyboard.KEY_NUMPAD7: + return Component.Identifier.Key.NUMPAD7; + case Keyboard.KEY_NUMPAD8: + return Component.Identifier.Key.NUMPAD8; + case Keyboard.KEY_NUMPAD9: + return Component.Identifier.Key.NUMPAD9; + case Keyboard.KEY_SUBTRACT: + return Component.Identifier.Key.SUBTRACT; + case Keyboard.KEY_NUMPAD4: + return Component.Identifier.Key.NUMPAD4; + case Keyboard.KEY_NUMPAD5: + return Component.Identifier.Key.NUMPAD5; + case Keyboard.KEY_NUMPAD6: + return Component.Identifier.Key.NUMPAD6; + case Keyboard.KEY_ADD: + return Component.Identifier.Key.ADD; + case Keyboard.KEY_NUMPAD1: + return Component.Identifier.Key.NUMPAD1; + case Keyboard.KEY_NUMPAD2: + return Component.Identifier.Key.NUMPAD2; + case Keyboard.KEY_NUMPAD3: + return Component.Identifier.Key.NUMPAD3; + case Keyboard.KEY_NUMPAD0: + return Component.Identifier.Key.NUMPAD0; + case Keyboard.KEY_DECIMAL: + return Component.Identifier.Key.DECIMAL; + case Keyboard.KEY_F11: + return Component.Identifier.Key.F11; + case Keyboard.KEY_F12: + return Component.Identifier.Key.F12; + case Keyboard.KEY_F13: + return Component.Identifier.Key.F13; + case Keyboard.KEY_F14: + return Component.Identifier.Key.F14; + case Keyboard.KEY_F15: + return Component.Identifier.Key.F15; + case Keyboard.KEY_KANA: + return Component.Identifier.Key.KANA; + case Keyboard.KEY_CONVERT: + return Component.Identifier.Key.CONVERT; + case Keyboard.KEY_NOCONVERT: + return Component.Identifier.Key.NOCONVERT; + case Keyboard.KEY_YEN: + return Component.Identifier.Key.YEN; + case Keyboard.KEY_NUMPADEQUALS: + return Component.Identifier.Key.NUMPADEQUAL; + case Keyboard.KEY_CIRCUMFLEX: + return Component.Identifier.Key.CIRCUMFLEX; + case Keyboard.KEY_AT: + return Component.Identifier.Key.AT; + case Keyboard.KEY_COLON: + return Component.Identifier.Key.COLON; + case Keyboard.KEY_UNDERLINE: + return Component.Identifier.Key.UNDERLINE; + case Keyboard.KEY_KANJI: + return Component.Identifier.Key.KANJI; + case Keyboard.KEY_STOP: + return Component.Identifier.Key.STOP; + case Keyboard.KEY_AX: + return Component.Identifier.Key.AX; + case Keyboard.KEY_UNLABELED: + return Component.Identifier.Key.UNLABELED; + case Keyboard.KEY_NUMPADENTER: + return Component.Identifier.Key.NUMPADENTER; + case Keyboard.KEY_RCONTROL: + return Component.Identifier.Key.RCONTROL; + case Keyboard.KEY_NUMPADCOMMA: + return Component.Identifier.Key.NUMPADCOMMA; + case Keyboard.KEY_DIVIDE: + return Component.Identifier.Key.DIVIDE; + case Keyboard.KEY_SYSRQ: + return Component.Identifier.Key.SYSRQ; + case Keyboard.KEY_RMENU: + return Component.Identifier.Key.RALT; + case Keyboard.KEY_PAUSE: + return Component.Identifier.Key.PAUSE; + case Keyboard.KEY_HOME: + return Component.Identifier.Key.HOME; + case Keyboard.KEY_UP: + return Component.Identifier.Key.UP; + case Keyboard.KEY_PRIOR: + return Component.Identifier.Key.PAGEUP; + case Keyboard.KEY_LEFT: + return Component.Identifier.Key.LEFT; + case Keyboard.KEY_RIGHT: + return Component.Identifier.Key.RIGHT; + case Keyboard.KEY_END: + return Component.Identifier.Key.END; + case Keyboard.KEY_DOWN: + return Component.Identifier.Key.DOWN; + case Keyboard.KEY_NEXT: + return Component.Identifier.Key.PAGEDOWN; + case Keyboard.KEY_INSERT: + return Component.Identifier.Key.INSERT; + case Keyboard.KEY_DELETE: + return Component.Identifier.Key.DELETE; + case Keyboard.KEY_LMETA: + return Component.Identifier.Key.LWIN; + case Keyboard.KEY_RMETA: + return Component.Identifier.Key.RWIN; + case Keyboard.KEY_APPS: + return Component.Identifier.Key.APPS; + case Keyboard.KEY_POWER: + return Component.Identifier.Key.POWER; + case Keyboard.KEY_SLEEP: + return Component.Identifier.Key.SLEEP; + default: + return Component.Identifier.Key.UNKNOWN; + } + } +} diff --git a/src/java/org/lwjgl/util/jinput/LWJGLEnvironmentPlugin.java b/src/java/org/lwjgl/util/jinput/LWJGLEnvironmentPlugin.java new file mode 100644 index 0000000..6f4b5f3 --- /dev/null +++ b/src/java/org/lwjgl/util/jinput/LWJGLEnvironmentPlugin.java @@ -0,0 +1,55 @@ +/* + * 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.jinput; + +import net.java.games.input.Controller; +import net.java.games.input.ControllerEnvironment; +import net.java.games.util.plugins.Plugin; + +/** + * @author elias + */ +public class LWJGLEnvironmentPlugin extends ControllerEnvironment implements Plugin { + private final Controller[] controllers; + + public LWJGLEnvironmentPlugin() { + this.controllers = new Controller[]{new LWJGLKeyboard(), new LWJGLMouse()}; + } + + public Controller[] getControllers() { + return controllers; + } + + public boolean isSupported() { + return true; + } +} diff --git a/src/java/org/lwjgl/util/jinput/LWJGLKeyboard.java b/src/java/org/lwjgl/util/jinput/LWJGLKeyboard.java new file mode 100644 index 0000000..303e2dd --- /dev/null +++ b/src/java/org/lwjgl/util/jinput/LWJGLKeyboard.java @@ -0,0 +1,132 @@ +/* + * 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.jinput; + +import net.java.games.input.AbstractComponent; +import net.java.games.input.Keyboard; +import net.java.games.input.Component; +import net.java.games.input.Controller; +import net.java.games.input.Rumbler; +import net.java.games.input.Event; +import java.util.List; +import java.util.ArrayList; + +import java.io.IOException; + +import java.lang.reflect.Field; +import java.lang.reflect.Modifier; + +/** + * @author elias + */ +final class LWJGLKeyboard extends Keyboard { + protected LWJGLKeyboard() { + super("LWJGLKeyboard", createComponents(), new Controller[]{}, new Rumbler[]{}); + } + + private final static Component[] createComponents() { + List components = new ArrayList(); + Field[] vkey_fields = org.lwjgl.input.Keyboard.class.getFields(); + for (int i = 0; i < vkey_fields.length; i++) { + Field vkey_field = vkey_fields[i]; + try { + if (Modifier.isStatic(vkey_field.getModifiers()) && vkey_field.getType() == int.class && + vkey_field.getName().startsWith("KEY_")) { + int vkey_code = vkey_field.getInt(null); + Component.Identifier.Key key_id = KeyMap.map(vkey_code); + if (key_id != Component.Identifier.Key.UNKNOWN) + components.add(new Key(key_id, vkey_code)); + } + } catch (IllegalAccessException e) { + throw new RuntimeException(e); + } + } + return (Component[])components.toArray(new Component[]{}); + } + + public final synchronized void pollDevice() throws IOException { + if (!org.lwjgl.input.Keyboard.isCreated()) + return; + org.lwjgl.input.Keyboard.poll(); + Component[] components = getComponents(); + for (int i = 0; i < components.length; i++) { + Key key = (Key)components[i]; + key.update(); + } + } + + protected final synchronized boolean getNextDeviceEvent(Event event) throws IOException { + if (!org.lwjgl.input.Keyboard.isCreated()) + return false; + if (!org.lwjgl.input.Keyboard.next()) + return false; + int lwjgl_key = org.lwjgl.input.Keyboard.getEventKey(); + if (lwjgl_key == org.lwjgl.input.Keyboard.KEY_NONE) + return false; + Component.Identifier.Key key_id = KeyMap.map(lwjgl_key); + if (key_id == null) + return false; + Component key = getComponent(key_id); + if (key == null) + return false; + float value = org.lwjgl.input.Keyboard.getEventKeyState() ? 1 : 0; + event.set(key, value, org.lwjgl.input.Keyboard.getEventNanoseconds()); + return true; + } + + + private final static class Key extends AbstractComponent { + private final int lwjgl_key; + private float value; + + public Key(Component.Identifier.Key key_id, int lwjgl_key) { + super(key_id.getName(), key_id); + this.lwjgl_key = lwjgl_key; + } + + public final void update() { + this.value = org.lwjgl.input.Keyboard.isKeyDown(lwjgl_key) ? 1 : 0; + } + + protected final float poll() { + return value; + } + + public final boolean isRelative() { + return false; + } + + public final boolean isAnalog() { + return false; + } + } +} diff --git a/src/java/org/lwjgl/util/jinput/LWJGLMouse.java b/src/java/org/lwjgl/util/jinput/LWJGLMouse.java new file mode 100644 index 0000000..3b37b9a --- /dev/null +++ b/src/java/org/lwjgl/util/jinput/LWJGLMouse.java @@ -0,0 +1,191 @@ +/* + * 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.jinput; + +import java.io.IOException; + +import net.java.games.input.AbstractComponent; +import net.java.games.input.Component; +import net.java.games.input.Controller; +import net.java.games.input.Event; +import net.java.games.input.Mouse; +import net.java.games.input.Rumbler; + +/** + * @author elias + */ +final class LWJGLMouse extends Mouse { + private final static int EVENT_X = 1; + private final static int EVENT_Y = 2; + private final static int EVENT_WHEEL = 3; + private final static int EVENT_BUTTON = 4; + private final static int EVENT_DONE = 5; + + private int event_state = EVENT_DONE; + + protected LWJGLMouse() { + super("LWJGLMouse", createComponents(), new Controller[]{}, new Rumbler[]{}); + } + + private final static Component[] createComponents() { + return new Component[]{new Axis(Component.Identifier.Axis.X), + new Axis(Component.Identifier.Axis.Y), + new Axis(Component.Identifier.Axis.Z), + new Button(Component.Identifier.Button.LEFT), + new Button(Component.Identifier.Button.MIDDLE), + new Button(Component.Identifier.Button.RIGHT)}; + } + + public final synchronized void pollDevice() throws IOException { + if (!org.lwjgl.input.Mouse.isCreated()) + return; + org.lwjgl.input.Mouse.poll(); + for (int i = 0; i < 3; i++) + setButtonState(i); + } + + private final Button map(int lwjgl_button) { + switch (lwjgl_button) { + case 0: + return (Button)getLeft(); + case 1: + return (Button)getRight(); + case 2: + return (Button)getMiddle(); + default: + return null; + } + } + + private final void setButtonState(int lwjgl_button) { + Button button = map(lwjgl_button); + if (button != null) + button.setValue(org.lwjgl.input.Mouse.isButtonDown(lwjgl_button) ? 1 : 0); + } + + protected final synchronized boolean getNextDeviceEvent(Event event) throws IOException { + if (!org.lwjgl.input.Mouse.isCreated()) + return false; + while (true) { + long nanos = org.lwjgl.input.Mouse.getEventNanoseconds(); + switch (event_state) { + case EVENT_X: + event_state = EVENT_Y; + int dx = org.lwjgl.input.Mouse.getEventDX(); + if (dx != 0) { + event.set(getX(), dx, nanos); + return true; + } + break; + case EVENT_Y: + event_state = EVENT_WHEEL; + /* We must negate the y coord since lwjgl uses the + * OpenGL coordinate system + */ + int dy = -org.lwjgl.input.Mouse.getEventDY(); + if (dy != 0) { + event.set(getY(), dy, nanos); + return true; + } + break; + case EVENT_WHEEL: + event_state = EVENT_BUTTON; + int dwheel = org.lwjgl.input.Mouse.getEventDWheel(); + if (dwheel != 0) { + event.set(getWheel(), dwheel, nanos); + return true; + } + break; + case EVENT_BUTTON: + event_state = EVENT_DONE; + int lwjgl_button = org.lwjgl.input.Mouse.getEventButton(); + if (lwjgl_button != -1) { + Button button = map(lwjgl_button); + if (button != null) { + event.set(button, org.lwjgl.input.Mouse.getEventButtonState() ? 1f : 0f, nanos); + return true; + } + } + break; + case EVENT_DONE: + if (!org.lwjgl.input.Mouse.next()) + return false; + event_state = EVENT_X; + break; + default: + break; + } + } + } + + final static class Axis extends AbstractComponent { + public Axis(Component.Identifier.Axis axis_id) { + super(axis_id.getName(), axis_id); + } + + public final boolean isRelative() { + return true; + } + + protected final float poll() throws IOException { + return 0; + } + + public final boolean isAnalog() { + return true; + } + } + + final static class Button extends AbstractComponent { + private float value; + + public Button(Component.Identifier.Button button_id) { + super(button_id.getName(), button_id); + } + + protected final void setValue(float value) { + this.value = value; + } + + protected final float poll() throws IOException { + return value; + } + + public final boolean isRelative() { + return false; + } + + public final boolean isAnalog() { + return false; + } + } +} diff --git a/src/java/org/lwjgl/util/vector/Matrix.java b/src/java/org/lwjgl/util/vector/Matrix.java new file mode 100644 index 0000000..efab6f6 --- /dev/null +++ b/src/java/org/lwjgl/util/vector/Matrix.java @@ -0,0 +1,134 @@ +/* + * 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.vector; + +import java.io.Serializable; +import java.nio.FloatBuffer; + +/** + * + * Base class for matrices. When a matrix is constructed it will be the identity + * matrix unless otherwise stated. + * + * @author cix_foo + * @version $Revision: 2983 $ + * $Id: Matrix.java 2983 2008-04-07 18:36:09Z matzon $ + */ +public abstract class Matrix implements Serializable { + + /** + * Constructor for Matrix. + */ + public Matrix() { + super(); + } + + /** + * Set this matrix to be the identity matrix. + * @return this + */ + public abstract Matrix setIdentity(); + + + /** + * Invert this matrix + * @return this + */ + public abstract Matrix invert(); + + + /** + * Load from a float buffer. The buffer stores the matrix in column major + * (OpenGL) order. + * + * @param buf A float buffer to read from + * @return this + */ + public abstract Matrix load(FloatBuffer buf); + + + /** + * Load from a float buffer. The buffer stores the matrix in row major + * (mathematical) order. + * + * @param buf A float buffer to read from + * @return this + */ + public abstract Matrix loadTranspose(FloatBuffer buf); + + + /** + * Negate this matrix + * @return this + */ + public abstract Matrix negate(); + + + /** + * Store this matrix in a float buffer. The matrix is stored in column + * major (openGL) order. + * @param buf The buffer to store this matrix in + * @return this + */ + public abstract Matrix store(FloatBuffer buf); + + + /** + * Store this matrix in a float buffer. The matrix is stored in row + * major (maths) order. + * @param buf The buffer to store this matrix in + * @return this + */ + public abstract Matrix storeTranspose(FloatBuffer buf); + + + /** + * Transpose this matrix + * @return this + */ + public abstract Matrix transpose(); + + + /** + * Set this matrix to 0. + * @return this + */ + public abstract Matrix setZero(); + + + /** + * @return the determinant of the matrix + */ + public abstract float determinant(); + + +} diff --git a/src/java/org/lwjgl/util/vector/Matrix2f.java b/src/java/org/lwjgl/util/vector/Matrix2f.java new file mode 100644 index 0000000..a802d90 --- /dev/null +++ b/src/java/org/lwjgl/util/vector/Matrix2f.java @@ -0,0 +1,400 @@ +/* + * 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.vector; + +import java.io.Serializable; +import java.nio.FloatBuffer; + +/** + * + * Holds a 2x2 matrix + * + * @author cix_foo + * @version $Revision: 2983 $ + * $Id: Matrix2f.java 2983 2008-04-07 18:36:09Z matzon $ + */ + +public class Matrix2f extends Matrix implements Serializable { + + private static final long serialVersionUID = 1L; + + public float m00, m01, m10, m11; + + /** + * Constructor for Matrix2f. The matrix is initialised to the identity. + */ + public Matrix2f() { + setIdentity(); + } + + /** + * Constructor + */ + public Matrix2f(Matrix2f src) { + load(src); + } + + /** + * Load from another matrix + * @param src The source matrix + * @return this + */ + public Matrix2f load(Matrix2f src) { + return load(src, this); + } + + /** + * Copy the source matrix to the destination matrix. + * @param src The source matrix + * @param dest The destination matrix, or null if a new one should be created. + * @return The copied matrix + */ + public static Matrix2f load(Matrix2f src, Matrix2f dest) { + if (dest == null) + dest = new Matrix2f(); + + dest.m00 = src.m00; + dest.m01 = src.m01; + dest.m10 = src.m10; + dest.m11 = src.m11; + + return dest; + } + + /** + * Load from a float buffer. The buffer stores the matrix in column major + * (OpenGL) order. + * + * @param buf A float buffer to read from + * @return this + */ + public Matrix load(FloatBuffer buf) { + + m00 = buf.get(); + m01 = buf.get(); + m10 = buf.get(); + m11 = buf.get(); + + return this; + } + + /** + * Load from a float buffer. The buffer stores the matrix in row major + * (mathematical) order. + * + * @param buf A float buffer to read from + * @return this + */ + public Matrix loadTranspose(FloatBuffer buf) { + + m00 = buf.get(); + m10 = buf.get(); + m01 = buf.get(); + m11 = buf.get(); + + return this; + } + + /** + * Store this matrix in a float buffer. The matrix is stored in column + * major (openGL) order. + * @param buf The buffer to store this matrix in + */ + public Matrix store(FloatBuffer buf) { + buf.put(m00); + buf.put(m01); + buf.put(m10); + buf.put(m11); + return this; + } + + /** + * Store this matrix in a float buffer. The matrix is stored in row + * major (maths) order. + * @param buf The buffer to store this matrix in + */ + public Matrix storeTranspose(FloatBuffer buf) { + buf.put(m00); + buf.put(m10); + buf.put(m01); + buf.put(m11); + return this; + } + + + + /** + * Add two matrices together and place the result in a third matrix. + * @param left The left source matrix + * @param right The right source matrix + * @param dest The destination matrix, or null if a new one is to be created + * @return the destination matrix + */ + public static Matrix2f add(Matrix2f left, Matrix2f right, Matrix2f dest) { + if (dest == null) + dest = new Matrix2f(); + + dest.m00 = left.m00 + right.m00; + dest.m01 = left.m01 + right.m01; + dest.m10 = left.m10 + right.m10; + dest.m11 = left.m11 + right.m11; + + return dest; + } + + /** + * Subtract the right matrix from the left and place the result in a third matrix. + * @param left The left source matrix + * @param right The right source matrix + * @param dest The destination matrix, or null if a new one is to be created + * @return the destination matrix + */ + public static Matrix2f sub(Matrix2f left, Matrix2f right, Matrix2f dest) { + if (dest == null) + dest = new Matrix2f(); + + dest.m00 = left.m00 - right.m00; + dest.m01 = left.m01 - right.m01; + dest.m10 = left.m10 - right.m10; + dest.m11 = left.m11 - right.m11; + + return dest; + } + + /** + * Multiply the right matrix by the left and place the result in a third matrix. + * @param left The left source matrix + * @param right The right source matrix + * @param dest The destination matrix, or null if a new one is to be created + * @return the destination matrix + */ + public static Matrix2f mul(Matrix2f left, Matrix2f right, Matrix2f dest) { + if (dest == null) + dest = new Matrix2f(); + + float m00 = left.m00 * right.m00 + left.m10 * right.m01; + float m01 = left.m01 * right.m00 + left.m11 * right.m01; + float m10 = left.m00 * right.m10 + left.m10 * right.m11; + float m11 = left.m01 * right.m10 + left.m11 * right.m11; + + dest.m00 = m00; + dest.m01 = m01; + dest.m10 = m10; + dest.m11 = m11; + + return dest; + } + + /** + * Transform a Vector by a matrix and return the result in a destination + * vector. + * @param left The left matrix + * @param right The right vector + * @param dest The destination vector, or null if a new one is to be created + * @return the destination vector + */ + public static Vector2f transform(Matrix2f left, Vector2f right, Vector2f dest) { + if (dest == null) + dest = new Vector2f(); + + float x = left.m00 * right.x + left.m10 * right.y; + float y = left.m01 * right.x + left.m11 * right.y; + + dest.x = x; + dest.y = y; + + return dest; + } + + /** + * Transpose this matrix + * @return this + */ + public Matrix transpose() { + return transpose(this); + } + + /** + * Transpose this matrix and place the result in another matrix. + * @param dest The destination matrix or null if a new matrix is to be created + * @return the transposed matrix + */ + public Matrix2f transpose(Matrix2f dest) { + return transpose(this, dest); + } + + /** + * Transpose the source matrix and place the result in the destination matrix. + * @param src The source matrix or null if a new matrix is to be created + * @param dest The destination matrix or null if a new matrix is to be created + * @return the transposed matrix + */ + public static Matrix2f transpose(Matrix2f src, Matrix2f dest) { + if (dest == null) + dest = new Matrix2f(); + + float m01 = src.m10; + float m10 = src.m01; + + dest.m01 = m01; + dest.m10 = m10; + + return dest; + } + + /** + * Invert this matrix + * @return this if successful, null otherwise + */ + public Matrix invert() { + return invert(this, this); + } + + /** + * Invert the source matrix and place the result in the destination matrix. + * @param src The source matrix to be inverted + * @param dest The destination matrix or null if a new matrix is to be created + * @return The inverted matrix, or null if source can't be reverted. + */ + public static Matrix2f invert(Matrix2f src, Matrix2f dest) { + /* + *inv(A) = 1/det(A) * adj(A); + */ + + float determinant = src.determinant(); + if (determinant != 0) { + if (dest == null) + dest = new Matrix2f(); + float determinant_inv = 1f/determinant; + float t00 = src.m11*determinant_inv; + float t01 = -src.m01*determinant_inv; + float t11 = src.m00*determinant_inv; + float t10 = -src.m10*determinant_inv; + + dest.m00 = t00; + dest.m01 = t01; + dest.m10 = t10; + dest.m11 = t11; + return dest; + } else + return null; + } + + /** + * Returns a string representation of this matrix + */ + public String toString() { + StringBuffer buf = new StringBuffer(); + buf.append(m00).append(' ').append(m10).append(' ').append('\n'); + buf.append(m01).append(' ').append(m11).append(' ').append('\n'); + return buf.toString(); + } + + /** + * Negate this matrix + * @return this + */ + public Matrix negate() { + return negate(this); + } + + /** + * Negate this matrix and stash the result in another matrix. + * @param dest The destination matrix, or null if a new matrix is to be created + * @return the negated matrix + */ + public Matrix2f negate(Matrix2f dest) { + return negate(this, this); + } + + /** + * Negate the source matrix and stash the result in the destination matrix. + * @param src The source matrix to be negated + * @param dest The destination matrix, or null if a new matrix is to be created + * @return the negated matrix + */ + public static Matrix2f negate(Matrix2f src, Matrix2f dest) { + if (dest == null) + dest = new Matrix2f(); + + dest.m00 = -src.m00; + dest.m01 = -src.m01; + dest.m10 = -src.m10; + dest.m11 = -src.m11; + + return dest; + } + + /** + * Set this matrix to be the identity matrix. + * @return this + */ + public Matrix setIdentity() { + return setIdentity(this); + } + + /** + * Set the source matrix to be the identity matrix. + * @param src The matrix to set to the identity. + * @return The source matrix + */ + public static Matrix2f setIdentity(Matrix2f src) { + src.m00 = 1.0f; + src.m01 = 0.0f; + src.m10 = 0.0f; + src.m11 = 1.0f; + return src; + } + + /** + * Set this matrix to 0. + * @return this + */ + public Matrix setZero() { + return setZero(this); + } + + public static Matrix2f setZero(Matrix2f src) { + src.m00 = 0.0f; + src.m01 = 0.0f; + src.m10 = 0.0f; + src.m11 = 0.0f; + return src; + } + + /* (non-Javadoc) + * @see org.lwjgl.vector.Matrix#determinant() + */ + public float determinant() { + return m00 * m11 - m01*m10; + } +} diff --git a/src/java/org/lwjgl/util/vector/Matrix3f.java b/src/java/org/lwjgl/util/vector/Matrix3f.java new file mode 100644 index 0000000..f766a95 --- /dev/null +++ b/src/java/org/lwjgl/util/vector/Matrix3f.java @@ -0,0 +1,510 @@ +/* + * 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.vector; + +import java.io.Serializable; +import java.nio.FloatBuffer; + +/** + * + * Holds a 3x3 matrix. + * + * @author cix_foo + * @version $Revision: 2983 $ + * $Id: Matrix3f.java 2983 2008-04-07 18:36:09Z matzon $ + */ + +public class Matrix3f extends Matrix implements Serializable { + + private static final long serialVersionUID = 1L; + + public float m00, + m01, + m02, + m10, + m11, + m12, + m20, + m21, + m22; + + /** + * Constructor for Matrix3f. Matrix is initialised to the identity. + */ + public Matrix3f() { + super(); + setIdentity(); + } + + /** + * Load from another matrix + * @param src The source matrix + * @return this + */ + public Matrix3f load(Matrix3f src) { + return load(src, this); + } + + /** + * Copy source matrix to destination matrix + * @param src The source matrix + * @param dest The destination matrix, or null of a new matrix is to be created + * @return The copied matrix + */ + public static Matrix3f load(Matrix3f src, Matrix3f dest) { + if (dest == null) + dest = new Matrix3f(); + + dest.m00 = src.m00; + dest.m10 = src.m10; + dest.m20 = src.m20; + dest.m01 = src.m01; + dest.m11 = src.m11; + dest.m21 = src.m21; + dest.m02 = src.m02; + dest.m12 = src.m12; + dest.m22 = src.m22; + + return dest; + } + + /** + * Load from a float buffer. The buffer stores the matrix in column major + * (OpenGL) order. + * + * @param buf A float buffer to read from + * @return this + */ + public Matrix load(FloatBuffer buf) { + + m00 = buf.get(); + m01 = buf.get(); + m02 = buf.get(); + m10 = buf.get(); + m11 = buf.get(); + m12 = buf.get(); + m20 = buf.get(); + m21 = buf.get(); + m22 = buf.get(); + + return this; + } + + /** + * Load from a float buffer. The buffer stores the matrix in row major + * (maths) order. + * + * @param buf A float buffer to read from + * @return this + */ + public Matrix loadTranspose(FloatBuffer buf) { + + m00 = buf.get(); + m10 = buf.get(); + m20 = buf.get(); + m01 = buf.get(); + m11 = buf.get(); + m21 = buf.get(); + m02 = buf.get(); + m12 = buf.get(); + m22 = buf.get(); + + return this; + } + + /** + * Store this matrix in a float buffer. The matrix is stored in column + * major (openGL) order. + * @param buf The buffer to store this matrix in + */ + public Matrix store(FloatBuffer buf) { + buf.put(m00); + buf.put(m01); + buf.put(m02); + buf.put(m10); + buf.put(m11); + buf.put(m12); + buf.put(m20); + buf.put(m21); + buf.put(m22); + return this; + } + + /** + * Store this matrix in a float buffer. The matrix is stored in row + * major (maths) order. + * @param buf The buffer to store this matrix in + */ + public Matrix storeTranspose(FloatBuffer buf) { + buf.put(m00); + buf.put(m10); + buf.put(m20); + buf.put(m01); + buf.put(m11); + buf.put(m21); + buf.put(m02); + buf.put(m12); + buf.put(m22); + return this; + } + + /** + * Add two matrices together and place the result in a third matrix. + * @param left The left source matrix + * @param right The right source matrix + * @param dest The destination matrix, or null if a new one is to be created + * @return the destination matrix + */ + public static Matrix3f add(Matrix3f left, Matrix3f right, Matrix3f dest) { + if (dest == null) + dest = new Matrix3f(); + + dest.m00 = left.m00 + right.m00; + dest.m01 = left.m01 + right.m01; + dest.m02 = left.m02 + right.m02; + dest.m10 = left.m10 + right.m10; + dest.m11 = left.m11 + right.m11; + dest.m12 = left.m12 + right.m12; + dest.m20 = left.m20 + right.m20; + dest.m21 = left.m21 + right.m21; + dest.m22 = left.m22 + right.m22; + + return dest; + } + + /** + * Subtract the right matrix from the left and place the result in a third matrix. + * @param left The left source matrix + * @param right The right source matrix + * @param dest The destination matrix, or null if a new one is to be created + * @return the destination matrix + */ + public static Matrix3f sub(Matrix3f left, Matrix3f right, Matrix3f dest) { + if (dest == null) + dest = new Matrix3f(); + + dest.m00 = left.m00 - right.m00; + dest.m01 = left.m01 - right.m01; + dest.m02 = left.m02 - right.m02; + dest.m10 = left.m10 - right.m10; + dest.m11 = left.m11 - right.m11; + dest.m12 = left.m12 - right.m12; + dest.m20 = left.m20 - right.m20; + dest.m21 = left.m21 - right.m21; + dest.m22 = left.m22 - right.m22; + + return dest; + } + + /** + * Multiply the right matrix by the left and place the result in a third matrix. + * @param left The left source matrix + * @param right The right source matrix + * @param dest The destination matrix, or null if a new one is to be created + * @return the destination matrix + */ + public static Matrix3f mul(Matrix3f left, Matrix3f right, Matrix3f dest) { + if (dest == null) + dest = new Matrix3f(); + + float m00 = + left.m00 * right.m00 + left.m10 * right.m01 + left.m20 * right.m02; + float m01 = + left.m01 * right.m00 + left.m11 * right.m01 + left.m21 * right.m02; + float m02 = + left.m02 * right.m00 + left.m12 * right.m01 + left.m22 * right.m02; + float m10 = + left.m00 * right.m10 + left.m10 * right.m11 + left.m20 * right.m12; + float m11 = + left.m01 * right.m10 + left.m11 * right.m11 + left.m21 * right.m12; + float m12 = + left.m02 * right.m10 + left.m12 * right.m11 + left.m22 * right.m12; + float m20 = + left.m00 * right.m20 + left.m10 * right.m21 + left.m20 * right.m22; + float m21 = + left.m01 * right.m20 + left.m11 * right.m21 + left.m21 * right.m22; + float m22 = + left.m02 * right.m20 + left.m12 * right.m21 + left.m22 * right.m22; + + dest.m00 = m00; + dest.m01 = m01; + dest.m02 = m02; + dest.m10 = m10; + dest.m11 = m11; + dest.m12 = m12; + dest.m20 = m20; + dest.m21 = m21; + dest.m22 = m22; + + return dest; + } + + /** + * Transform a Vector by a matrix and return the result in a destination + * vector. + * @param left The left matrix + * @param right The right vector + * @param dest The destination vector, or null if a new one is to be created + * @return the destination vector + */ + public static Vector3f transform(Matrix3f left, Vector3f right, Vector3f dest) { + if (dest == null) + dest = new Vector3f(); + + float x = left.m00 * right.x + left.m10 * right.y + left.m20 * right.z; + float y = left.m01 * right.x + left.m11 * right.y + left.m21 * right.z; + float z = left.m02 * right.x + left.m12 * right.y + left.m22 * right.z; + + dest.x = x; + dest.y = y; + dest.z = z; + + return dest; + } + + /** + * Transpose this matrix + * @return this + */ + public Matrix transpose() { + return transpose(this, this); + } + + /** + * Transpose this matrix and place the result in another matrix + * @param dest The destination matrix or null if a new matrix is to be created + * @return the transposed matrix + */ + public Matrix3f transpose(Matrix3f dest) { + return transpose(this, dest); + } + + /** + * Transpose the source matrix and place the result into the destination matrix + * @param src The source matrix to be transposed + * @param dest The destination matrix or null if a new matrix is to be created + * @return the transposed matrix + */ + public static Matrix3f transpose(Matrix3f src, Matrix3f dest) { + if (dest == null) + dest = new Matrix3f(); + float m00 = src.m00; + float m01 = src.m10; + float m02 = src.m20; + float m10 = src.m01; + float m11 = src.m11; + float m12 = src.m21; + float m20 = src.m02; + float m21 = src.m12; + float m22 = src.m22; + + dest.m00 = m00; + dest.m01 = m01; + dest.m02 = m02; + dest.m10 = m10; + dest.m11 = m11; + dest.m12 = m12; + dest.m20 = m20; + dest.m21 = m21; + dest.m22 = m22; + return dest; + } + + /** + * @return the determinant of the matrix + */ + public float determinant() { + float f = + m00 * (m11 * m22 - m12 * m21) + + m01 * (m12 * m20 - m10 * m22) + + m02 * (m10 * m21 - m11 * m20); + return f; + } + + /** + * Returns a string representation of this matrix + */ + public String toString() { + StringBuffer buf = new StringBuffer(); + buf.append(m00).append(' ').append(m10).append(' ').append(m20).append(' ').append('\n'); + buf.append(m01).append(' ').append(m11).append(' ').append(m21).append(' ').append('\n'); + buf.append(m02).append(' ').append(m12).append(' ').append(m22).append(' ').append('\n'); + return buf.toString(); + } + + /** + * Invert this matrix + * @return this if successful, null otherwise + */ + public Matrix invert() { + return invert(this, this); + } + + /** + * Invert the source matrix and put the result into the destination matrix + * @param src The source matrix to be inverted + * @param dest The destination matrix, or null if a new one is to be created + * @return The inverted matrix if successful, null otherwise + */ + public static Matrix3f invert(Matrix3f src, Matrix3f dest) { + float determinant = src.determinant(); + + if (determinant != 0) { + if (dest == null) + dest = new Matrix3f(); + /* do it the ordinary way + * + * inv(A) = 1/det(A) * adj(T), where adj(T) = transpose(Conjugate Matrix) + * + * m00 m01 m02 + * m10 m11 m12 + * m20 m21 m22 + */ + float determinant_inv = 1f/determinant; + + // get the conjugate matrix + float t00 = src.m11 * src.m22 - src.m12* src.m21; + float t01 = - src.m10 * src.m22 + src.m12 * src.m20; + float t02 = src.m10 * src.m21 - src.m11 * src.m20; + float t10 = - src.m01 * src.m22 + src.m02 * src.m21; + float t11 = src.m00 * src.m22 - src.m02 * src.m20; + float t12 = - src.m00 * src.m21 + src.m01 * src.m20; + float t20 = src.m01 * src.m12 - src.m02 * src.m11; + float t21 = -src.m00 * src.m12 + src.m02 * src.m10; + float t22 = src.m00 * src.m11 - src.m01 * src.m10; + + dest.m00 = t00*determinant_inv; + dest.m11 = t11*determinant_inv; + dest.m22 = t22*determinant_inv; + dest.m01 = t10*determinant_inv; + dest.m10 = t01*determinant_inv; + dest.m20 = t02*determinant_inv; + dest.m02 = t20*determinant_inv; + dest.m12 = t21*determinant_inv; + dest.m21 = t12*determinant_inv; + return dest; + } else + return null; + } + + + /** + * Negate this matrix + * @return this + */ + public Matrix negate() { + return negate(this); + } + + /** + * Negate this matrix and place the result in a destination matrix. + * @param dest The destination matrix, or null if a new matrix is to be created + * @return the negated matrix + */ + public Matrix3f negate(Matrix3f dest) { + return negate(this, this); + } + + /** + * Negate the source matrix and place the result in the destination matrix. + * @param src The source matrix + * @param dest The destination matrix, or null if a new matrix is to be created + * @return the negated matrix + */ + public static Matrix3f negate(Matrix3f src, Matrix3f dest) { + if (dest == null) + dest = new Matrix3f(); + + dest.m00 = -src.m00; + dest.m01 = -src.m02; + dest.m02 = -src.m01; + dest.m10 = -src.m10; + dest.m11 = -src.m12; + dest.m12 = -src.m11; + dest.m20 = -src.m20; + dest.m21 = -src.m22; + dest.m22 = -src.m21; + return dest; + } + + /** + * Set this matrix to be the identity matrix. + * @return this + */ + public Matrix setIdentity() { + return setIdentity(this); + } + + /** + * Set the matrix to be the identity matrix. + * @param m The matrix to be set to the identity + * @return m + */ + public static Matrix3f setIdentity(Matrix3f m) { + m.m00 = 1.0f; + m.m01 = 0.0f; + m.m02 = 0.0f; + m.m10 = 0.0f; + m.m11 = 1.0f; + m.m12 = 0.0f; + m.m20 = 0.0f; + m.m21 = 0.0f; + m.m22 = 1.0f; + return m; + } + + /** + * Set this matrix to 0. + * @return this + */ + public Matrix setZero() { + return setZero(this); + } + + /** + * Set the matrix matrix to 0. + * @param m The matrix to be set to 0 + * @return m + */ + public static Matrix3f setZero(Matrix3f m) { + m.m00 = 0.0f; + m.m01 = 0.0f; + m.m02 = 0.0f; + m.m10 = 0.0f; + m.m11 = 0.0f; + m.m12 = 0.0f; + m.m20 = 0.0f; + m.m21 = 0.0f; + m.m22 = 0.0f; + return m; + } +} diff --git a/src/java/org/lwjgl/util/vector/Matrix4f.java b/src/java/org/lwjgl/util/vector/Matrix4f.java new file mode 100644 index 0000000..254f3a8 --- /dev/null +++ b/src/java/org/lwjgl/util/vector/Matrix4f.java @@ -0,0 +1,827 @@ +/* + * 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.vector; + +import java.io.Serializable; +import java.nio.FloatBuffer; + +/** + * Holds a 4x4 float matrix. + * + * @author foo + */ +public class Matrix4f extends Matrix implements Serializable { + private static final long serialVersionUID = 1L; + + public float m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33; + + /** + * Construct a new matrix, initialized to the identity. + */ + public Matrix4f() { + super(); + setIdentity(); + } + + /** + * Returns a string representation of this matrix + */ + public String toString() { + StringBuffer buf = new StringBuffer(); + buf.append(m00).append(' ').append(m10).append(' ').append(m20).append(' ').append(m30).append('\n'); + buf.append(m01).append(' ').append(m11).append(' ').append(m21).append(' ').append(m31).append('\n'); + buf.append(m02).append(' ').append(m12).append(' ').append(m22).append(' ').append(m32).append('\n'); + buf.append(m03).append(' ').append(m13).append(' ').append(m23).append(' ').append(m33).append('\n'); + return buf.toString(); + } + + /** + * Set this matrix to be the identity matrix. + * @return this + */ + public Matrix setIdentity() { + return setIdentity(this); + } + + /** + * Set the given matrix to be the identity matrix. + * @param m The matrix to set to the identity + * @return m + */ + public static Matrix4f setIdentity(Matrix4f m) { + m.m00 = 1.0f; + m.m01 = 0.0f; + m.m02 = 0.0f; + m.m03 = 0.0f; + m.m10 = 0.0f; + m.m11 = 1.0f; + m.m12 = 0.0f; + m.m13 = 0.0f; + m.m20 = 0.0f; + m.m21 = 0.0f; + m.m22 = 1.0f; + m.m23 = 0.0f; + m.m30 = 0.0f; + m.m31 = 0.0f; + m.m32 = 0.0f; + m.m33 = 1.0f; + + return m; + } + + /** + * Set this matrix to 0. + * @return this + */ + public Matrix setZero() { + return setZero(this); + } + + /** + * Set the given matrix to 0. + * @param m The matrix to set to 0 + * @return m + */ + public static Matrix4f setZero(Matrix4f m) { + m.m00 = 0.0f; + m.m01 = 0.0f; + m.m02 = 0.0f; + m.m03 = 0.0f; + m.m10 = 0.0f; + m.m11 = 0.0f; + m.m12 = 0.0f; + m.m13 = 0.0f; + m.m20 = 0.0f; + m.m21 = 0.0f; + m.m22 = 0.0f; + m.m23 = 0.0f; + m.m30 = 0.0f; + m.m31 = 0.0f; + m.m32 = 0.0f; + m.m33 = 0.0f; + + return m; + } + + /** + * Load from another matrix4f + * @param src The source matrix + * @return this + */ + public Matrix4f load(Matrix4f src) { + return load(src, this); + } + + /** + * Copy the source matrix to the destination matrix + * @param src The source matrix + * @param dest The destination matrix, or null of a new one is to be created + * @return The copied matrix + */ + public static Matrix4f load(Matrix4f src, Matrix4f dest) { + if (dest == null) + dest = new Matrix4f(); + dest.m00 = src.m00; + dest.m01 = src.m01; + dest.m02 = src.m02; + dest.m03 = src.m03; + dest.m10 = src.m10; + dest.m11 = src.m11; + dest.m12 = src.m12; + dest.m13 = src.m13; + dest.m20 = src.m20; + dest.m21 = src.m21; + dest.m22 = src.m22; + dest.m23 = src.m23; + dest.m30 = src.m30; + dest.m31 = src.m31; + dest.m32 = src.m32; + dest.m33 = src.m33; + + return dest; + } + + /** + * Load from a float buffer. The buffer stores the matrix in column major + * (OpenGL) order. + * + * @param buf A float buffer to read from + * @return this + */ + public Matrix load(FloatBuffer buf) { + + m00 = buf.get(); + m01 = buf.get(); + m02 = buf.get(); + m03 = buf.get(); + m10 = buf.get(); + m11 = buf.get(); + m12 = buf.get(); + m13 = buf.get(); + m20 = buf.get(); + m21 = buf.get(); + m22 = buf.get(); + m23 = buf.get(); + m30 = buf.get(); + m31 = buf.get(); + m32 = buf.get(); + m33 = buf.get(); + + return this; + } + + /** + * Load from a float buffer. The buffer stores the matrix in row major + * (maths) order. + * + * @param buf A float buffer to read from + * @return this + */ + public Matrix loadTranspose(FloatBuffer buf) { + + m00 = buf.get(); + m10 = buf.get(); + m20 = buf.get(); + m30 = buf.get(); + m01 = buf.get(); + m11 = buf.get(); + m21 = buf.get(); + m31 = buf.get(); + m02 = buf.get(); + m12 = buf.get(); + m22 = buf.get(); + m32 = buf.get(); + m03 = buf.get(); + m13 = buf.get(); + m23 = buf.get(); + m33 = buf.get(); + + return this; + } + + /** + * Store this matrix in a float buffer. The matrix is stored in column + * major (openGL) order. + * @param buf The buffer to store this matrix in + */ + public Matrix store(FloatBuffer buf) { + buf.put(m00); + buf.put(m01); + buf.put(m02); + buf.put(m03); + buf.put(m10); + buf.put(m11); + buf.put(m12); + buf.put(m13); + buf.put(m20); + buf.put(m21); + buf.put(m22); + buf.put(m23); + buf.put(m30); + buf.put(m31); + buf.put(m32); + buf.put(m33); + return this; + } + + /** + * Store this matrix in a float buffer. The matrix is stored in row + * major (maths) order. + * @param buf The buffer to store this matrix in + */ + public Matrix storeTranspose(FloatBuffer buf) { + buf.put(m00); + buf.put(m10); + buf.put(m20); + buf.put(m30); + buf.put(m01); + buf.put(m11); + buf.put(m21); + buf.put(m31); + buf.put(m02); + buf.put(m12); + buf.put(m22); + buf.put(m32); + buf.put(m03); + buf.put(m13); + buf.put(m23); + buf.put(m33); + return this; + } + + + /** + * Add two matrices together and place the result in a third matrix. + * @param left The left source matrix + * @param right The right source matrix + * @param dest The destination matrix, or null if a new one is to be created + * @return the destination matrix + */ + public static Matrix4f add(Matrix4f left, Matrix4f right, Matrix4f dest) { + if (dest == null) + dest = new Matrix4f(); + + dest.m00 = left.m00 + right.m00; + dest.m01 = left.m01 + right.m01; + dest.m02 = left.m02 + right.m02; + dest.m03 = left.m03 + right.m03; + dest.m10 = left.m10 + right.m10; + dest.m11 = left.m11 + right.m11; + dest.m12 = left.m12 + right.m12; + dest.m13 = left.m13 + right.m13; + dest.m20 = left.m20 + right.m20; + dest.m21 = left.m21 + right.m21; + dest.m22 = left.m22 + right.m22; + dest.m23 = left.m23 + right.m23; + dest.m30 = left.m30 + right.m30; + dest.m31 = left.m31 + right.m31; + dest.m32 = left.m32 + right.m32; + dest.m33 = left.m33 + right.m33; + + return dest; + } + + /** + * Subtract the right matrix from the left and place the result in a third matrix. + * @param left The left source matrix + * @param right The right source matrix + * @param dest The destination matrix, or null if a new one is to be created + * @return the destination matrix + */ + public static Matrix4f sub(Matrix4f left, Matrix4f right, Matrix4f dest) { + if (dest == null) + dest = new Matrix4f(); + + dest.m00 = left.m00 - right.m00; + dest.m01 = left.m01 - right.m01; + dest.m02 = left.m02 - right.m02; + dest.m03 = left.m03 - right.m03; + dest.m10 = left.m10 - right.m10; + dest.m11 = left.m11 - right.m11; + dest.m12 = left.m12 - right.m12; + dest.m13 = left.m13 - right.m13; + dest.m20 = left.m20 - right.m20; + dest.m21 = left.m21 - right.m21; + dest.m22 = left.m22 - right.m22; + dest.m23 = left.m23 - right.m23; + dest.m30 = left.m30 - right.m30; + dest.m31 = left.m31 - right.m31; + dest.m32 = left.m32 - right.m32; + dest.m33 = left.m33 - right.m33; + + return dest; + } + + /** + * Multiply the right matrix by the left and place the result in a third matrix. + * @param left The left source matrix + * @param right The right source matrix + * @param dest The destination matrix, or null if a new one is to be created + * @return the destination matrix + */ + public static Matrix4f mul(Matrix4f left, Matrix4f right, Matrix4f dest) { + if (dest == null) + dest = new Matrix4f(); + + float m00 = left.m00 * right.m00 + left.m10 * right.m01 + left.m20 * right.m02 + left.m30 * right.m03; + float m01 = left.m01 * right.m00 + left.m11 * right.m01 + left.m21 * right.m02 + left.m31 * right.m03; + float m02 = left.m02 * right.m00 + left.m12 * right.m01 + left.m22 * right.m02 + left.m32 * right.m03; + float m03 = left.m03 * right.m00 + left.m13 * right.m01 + left.m23 * right.m02 + left.m33 * right.m03; + float m10 = left.m00 * right.m10 + left.m10 * right.m11 + left.m20 * right.m12 + left.m30 * right.m13; + float m11 = left.m01 * right.m10 + left.m11 * right.m11 + left.m21 * right.m12 + left.m31 * right.m13; + float m12 = left.m02 * right.m10 + left.m12 * right.m11 + left.m22 * right.m12 + left.m32 * right.m13; + float m13 = left.m03 * right.m10 + left.m13 * right.m11 + left.m23 * right.m12 + left.m33 * right.m13; + float m20 = left.m00 * right.m20 + left.m10 * right.m21 + left.m20 * right.m22 + left.m30 * right.m23; + float m21 = left.m01 * right.m20 + left.m11 * right.m21 + left.m21 * right.m22 + left.m31 * right.m23; + float m22 = left.m02 * right.m20 + left.m12 * right.m21 + left.m22 * right.m22 + left.m32 * right.m23; + float m23 = left.m03 * right.m20 + left.m13 * right.m21 + left.m23 * right.m22 + left.m33 * right.m23; + float m30 = left.m00 * right.m30 + left.m10 * right.m31 + left.m20 * right.m32 + left.m30 * right.m33; + float m31 = left.m01 * right.m30 + left.m11 * right.m31 + left.m21 * right.m32 + left.m31 * right.m33; + float m32 = left.m02 * right.m30 + left.m12 * right.m31 + left.m22 * right.m32 + left.m32 * right.m33; + float m33 = left.m03 * right.m30 + left.m13 * right.m31 + left.m23 * right.m32 + left.m33 * right.m33; + + dest.m00 = m00; + dest.m01 = m01; + dest.m02 = m02; + dest.m03 = m03; + dest.m10 = m10; + dest.m11 = m11; + dest.m12 = m12; + dest.m13 = m13; + dest.m20 = m20; + dest.m21 = m21; + dest.m22 = m22; + dest.m23 = m23; + dest.m30 = m30; + dest.m31 = m31; + dest.m32 = m32; + dest.m33 = m33; + + return dest; + } + + /** + * Transform a Vector by a matrix and return the result in a destination + * vector. + * @param left The left matrix + * @param right The right vector + * @param dest The destination vector, or null if a new one is to be created + * @return the destination vector + */ + public static Vector4f transform(Matrix4f left, Vector4f right, Vector4f dest) { + if (dest == null) + dest = new Vector4f(); + + float x = left.m00 * right.x + left.m10 * right.y + left.m20 * right.z + left.m30 * right.w; + float y = left.m01 * right.x + left.m11 * right.y + left.m21 * right.z + left.m31 * right.w; + float z = left.m02 * right.x + left.m12 * right.y + left.m22 * right.z + left.m32 * right.w; + float w = left.m03 * right.x + left.m13 * right.y + left.m23 * right.z + left.m33 * right.w; + + dest.x = x; + dest.y = y; + dest.z = z; + dest.w = w; + + return dest; + } + + /** + * Transpose this matrix + * @return this + */ + public Matrix transpose() { + return transpose(this); + } + + /** + * Translate this matrix + * @param vec The vector to translate by + * @return this + */ + public Matrix4f translate(Vector2f vec) { + return translate(vec, this); + } + + /** + * Translate this matrix + * @param vec The vector to translate by + * @return this + */ + public Matrix4f translate(Vector3f vec) { + return translate(vec, this); + } + + /** + * Scales this matrix + * @param vec The vector to scale by + * @return this + */ + public Matrix4f scale(Vector3f vec) { + return scale(vec, this, this); + } + + /** + * Scales the source matrix and put the result in the destination matrix + * @param vec The vector to scale by + * @param src The source matrix + * @param dest The destination matrix, or null if a new matrix is to be created + * @return The scaled matrix + */ + public static Matrix4f scale(Vector3f vec, Matrix4f src, Matrix4f dest) { + if (dest == null) + dest = new Matrix4f(); + dest.m00 = src.m00 * vec.x; + dest.m01 = src.m01 * vec.x; + dest.m02 = src.m02 * vec.x; + dest.m03 = src.m03 * vec.x; + dest.m10 = src.m10 * vec.y; + dest.m11 = src.m11 * vec.y; + dest.m12 = src.m12 * vec.y; + dest.m13 = src.m13 * vec.y; + dest.m20 = src.m20 * vec.z; + dest.m21 = src.m21 * vec.z; + dest.m22 = src.m22 * vec.z; + dest.m23 = src.m23 * vec.z; + return dest; + } + + /** + * Rotates the matrix around the given axis the specified angle + * @param angle the angle, in radians. + * @param axis The vector representing the rotation axis. Must be normalized. + * @return this + */ + public Matrix4f rotate(float angle, Vector3f axis) { + return rotate(angle, axis, this); + } + + /** + * Rotates the matrix around the given axis the specified angle + * @param angle the angle, in radians. + * @param axis The vector representing the rotation axis. Must be normalized. + * @param dest The matrix to put the result, or null if a new matrix is to be created + * @return The rotated matrix + */ + public Matrix4f rotate(float angle, Vector3f axis, Matrix4f dest) { + return rotate(angle, axis, this, dest); + } + + /** + * Rotates the source matrix around the given axis the specified angle and + * put the result in the destination matrix. + * @param angle the angle, in radians. + * @param axis The vector representing the rotation axis. Must be normalized. + * @param src The matrix to rotate + * @param dest The matrix to put the result, or null if a new matrix is to be created + * @return The rotated matrix + */ + public static Matrix4f rotate(float angle, Vector3f axis, Matrix4f src, Matrix4f dest) { + if (dest == null) + dest = new Matrix4f(); + float c = (float) Math.cos(angle); + float s = (float) Math.sin(angle); + float oneminusc = 1.0f - c; + float xy = axis.x*axis.y; + float yz = axis.y*axis.z; + float xz = axis.x*axis.z; + float xs = axis.x*s; + float ys = axis.y*s; + float zs = axis.z*s; + + float f00 = axis.x*axis.x*oneminusc+c; + float f01 = xy*oneminusc+zs; + float f02 = xz*oneminusc-ys; + // n[3] not used + float f10 = xy*oneminusc-zs; + float f11 = axis.y*axis.y*oneminusc+c; + float f12 = yz*oneminusc+xs; + // n[7] not used + float f20 = xz*oneminusc+ys; + float f21 = yz*oneminusc-xs; + float f22 = axis.z*axis.z*oneminusc+c; + + float t00 = src.m00 * f00 + src.m10 * f01 + src.m20 * f02; + float t01 = src.m01 * f00 + src.m11 * f01 + src.m21 * f02; + float t02 = src.m02 * f00 + src.m12 * f01 + src.m22 * f02; + float t03 = src.m03 * f00 + src.m13 * f01 + src.m23 * f02; + float t10 = src.m00 * f10 + src.m10 * f11 + src.m20 * f12; + float t11 = src.m01 * f10 + src.m11 * f11 + src.m21 * f12; + float t12 = src.m02 * f10 + src.m12 * f11 + src.m22 * f12; + float t13 = src.m03 * f10 + src.m13 * f11 + src.m23 * f12; + dest.m20 = src.m00 * f20 + src.m10 * f21 + src.m20 * f22; + dest.m21 = src.m01 * f20 + src.m11 * f21 + src.m21 * f22; + dest.m22 = src.m02 * f20 + src.m12 * f21 + src.m22 * f22; + dest.m23 = src.m03 * f20 + src.m13 * f21 + src.m23 * f22; + dest.m00 = t00; + dest.m01 = t01; + dest.m02 = t02; + dest.m03 = t03; + dest.m10 = t10; + dest.m11 = t11; + dest.m12 = t12; + dest.m13 = t13; + return dest; + } + + /** + * Translate this matrix and stash the result in another matrix + * @param vec The vector to translate by + * @param dest The destination matrix or null if a new matrix is to be created + * @return the translated matrix + */ + public Matrix4f translate(Vector3f vec, Matrix4f dest) { + return translate(vec, this, dest); + } + + /** + * Translate the source matrix and stash the result in the destination matrix + * @param vec The vector to translate by + * @param src The source matrix + * @param dest The destination matrix or null if a new matrix is to be created + * @return The translated matrix + */ + public static Matrix4f translate(Vector3f vec, Matrix4f src, Matrix4f dest) { + if (dest == null) + dest = new Matrix4f(); + + dest.m30 += src.m00 * vec.x + src.m10 * vec.y + src.m20 * vec.z; + dest.m31 += src.m01 * vec.x + src.m11 * vec.y + src.m21 * vec.z; + dest.m32 += src.m02 * vec.x + src.m12 * vec.y + src.m22 * vec.z; + dest.m33 += src.m03 * vec.x + src.m13 * vec.y + src.m23 * vec.z; + + return dest; + } + + /** + * Translate this matrix and stash the result in another matrix + * @param vec The vector to translate by + * @param dest The destination matrix or null if a new matrix is to be created + * @return the translated matrix + */ + public Matrix4f translate(Vector2f vec, Matrix4f dest) { + return translate(vec, this, dest); + } + + /** + * Translate the source matrix and stash the result in the destination matrix + * @param vec The vector to translate by + * @param src The source matrix + * @param dest The destination matrix or null if a new matrix is to be created + * @return The translated matrix + */ + public static Matrix4f translate(Vector2f vec, Matrix4f src, Matrix4f dest) { + if (dest == null) + dest = new Matrix4f(); + + dest.m30 += src.m00 * vec.x + src.m10 * vec.y; + dest.m31 += src.m01 * vec.x + src.m11 * vec.y; + dest.m32 += src.m02 * vec.x + src.m12 * vec.y; + dest.m33 += src.m03 * vec.x + src.m13 * vec.y; + + return dest; + } + + /** + * Transpose this matrix and place the result in another matrix + * @param dest The destination matrix or null if a new matrix is to be created + * @return the transposed matrix + */ + public Matrix4f transpose(Matrix4f dest) { + return transpose(this, dest); + } + + /** + * Transpose the source matrix and place the result in the destination matrix + * @param src The source matrix + * @param dest The destination matrix or null if a new matrix is to be created + * @return the transposed matrix + */ + public static Matrix4f transpose(Matrix4f src, Matrix4f dest) { + if (dest == null) + dest = new Matrix4f(); + float m00 = src.m00; + float m01 = src.m10; + float m02 = src.m20; + float m03 = src.m30; + float m10 = src.m01; + float m11 = src.m11; + float m12 = src.m21; + float m13 = src.m31; + float m20 = src.m02; + float m21 = src.m12; + float m22 = src.m22; + float m23 = src.m32; + float m30 = src.m03; + float m31 = src.m13; + float m32 = src.m23; + float m33 = src.m33; + + dest.m00 = m00; + dest.m01 = m01; + dest.m02 = m02; + dest.m03 = m03; + dest.m10 = m10; + dest.m11 = m11; + dest.m12 = m12; + dest.m13 = m13; + dest.m20 = m20; + dest.m21 = m21; + dest.m22 = m22; + dest.m23 = m23; + dest.m30 = m30; + dest.m31 = m31; + dest.m32 = m32; + dest.m33 = m33; + + return dest; + } + + /** + * @return the determinant of the matrix + */ + public float determinant() { + float f = + m00 + * ((m11 * m22 * m33 + m12 * m23 * m31 + m13 * m21 * m32) + - m13 * m22 * m31 + - m11 * m23 * m32 + - m12 * m21 * m33); + f -= m01 + * ((m10 * m22 * m33 + m12 * m23 * m30 + m13 * m20 * m32) + - m13 * m22 * m30 + - m10 * m23 * m32 + - m12 * m20 * m33); + f += m02 + * ((m10 * m21 * m33 + m11 * m23 * m30 + m13 * m20 * m31) + - m13 * m21 * m30 + - m10 * m23 * m31 + - m11 * m20 * m33); + f -= m03 + * ((m10 * m21 * m32 + m11 * m22 * m30 + m12 * m20 * m31) + - m12 * m21 * m30 + - m10 * m22 * m31 + - m11 * m20 * m32); + return f; + } + + /** + * Calculate the determinant of a 3x3 matrix + * @return result + */ + + private static float determinant3x3(float t00, float t01, float t02, + float t10, float t11, float t12, + float t20, float t21, float t22) + { + return t00 * (t11 * t22 - t12 * t21) + + t01 * (t12 * t20 - t10 * t22) + + t02 * (t10 * t21 - t11 * t20); + } + + /** + * Invert this matrix + * @return this if successful, null otherwise + */ + public Matrix invert() { + return invert(this, this); + } + + /** + * Invert the source matrix and put the result in the destination + * @param src The source matrix + * @param dest The destination matrix, or null if a new matrix is to be created + * @return The inverted matrix if successful, null otherwise + */ + public static Matrix4f invert(Matrix4f src, Matrix4f dest) { + float determinant = src.determinant(); + + if (determinant != 0) { + /* + * m00 m01 m02 m03 + * m10 m11 m12 m13 + * m20 m21 m22 m23 + * m30 m31 m32 m33 + */ + if (dest == null) + dest = new Matrix4f(); + float determinant_inv = 1f/determinant; + + // first row + float t00 = determinant3x3(src.m11, src.m12, src.m13, src.m21, src.m22, src.m23, src.m31, src.m32, src.m33); + float t01 = -determinant3x3(src.m10, src.m12, src.m13, src.m20, src.m22, src.m23, src.m30, src.m32, src.m33); + float t02 = determinant3x3(src.m10, src.m11, src.m13, src.m20, src.m21, src.m23, src.m30, src.m31, src.m33); + float t03 = -determinant3x3(src.m10, src.m11, src.m12, src.m20, src.m21, src.m22, src.m30, src.m31, src.m32); + // second row + float t10 = -determinant3x3(src.m01, src.m02, src.m03, src.m21, src.m22, src.m23, src.m31, src.m32, src.m33); + float t11 = determinant3x3(src.m00, src.m02, src.m03, src.m20, src.m22, src.m23, src.m30, src.m32, src.m33); + float t12 = -determinant3x3(src.m00, src.m01, src.m03, src.m20, src.m21, src.m23, src.m30, src.m31, src.m33); + float t13 = determinant3x3(src.m00, src.m01, src.m02, src.m20, src.m21, src.m22, src.m30, src.m31, src.m32); + // third row + float t20 = determinant3x3(src.m01, src.m02, src.m03, src.m11, src.m12, src.m13, src.m31, src.m32, src.m33); + float t21 = -determinant3x3(src.m00, src.m02, src.m03, src.m10, src.m12, src.m13, src.m30, src.m32, src.m33); + float t22 = determinant3x3(src.m00, src.m01, src.m03, src.m10, src.m11, src.m13, src.m30, src.m31, src.m33); + float t23 = -determinant3x3(src.m00, src.m01, src.m02, src.m10, src.m11, src.m12, src.m30, src.m31, src.m32); + // fourth row + float t30 = -determinant3x3(src.m01, src.m02, src.m03, src.m11, src.m12, src.m13, src.m21, src.m22, src.m23); + float t31 = determinant3x3(src.m00, src.m02, src.m03, src.m10, src.m12, src.m13, src.m20, src.m22, src.m23); + float t32 = -determinant3x3(src.m00, src.m01, src.m03, src.m10, src.m11, src.m13, src.m20, src.m21, src.m23); + float t33 = determinant3x3(src.m00, src.m01, src.m02, src.m10, src.m11, src.m12, src.m20, src.m21, src.m22); + + // transpose and divide by the determinant + dest.m00 = t00*determinant_inv; + dest.m11 = t11*determinant_inv; + dest.m22 = t22*determinant_inv; + dest.m33 = t33*determinant_inv; + dest.m01 = t10*determinant_inv; + dest.m10 = t01*determinant_inv; + dest.m20 = t02*determinant_inv; + dest.m02 = t20*determinant_inv; + dest.m12 = t21*determinant_inv; + dest.m21 = t12*determinant_inv; + dest.m03 = t30*determinant_inv; + dest.m30 = t03*determinant_inv; + dest.m13 = t31*determinant_inv; + dest.m31 = t13*determinant_inv; + dest.m32 = t23*determinant_inv; + dest.m23 = t32*determinant_inv; + return dest; + } else + return null; + } + + /** + * Negate this matrix + * @return this + */ + public Matrix negate() { + return negate(this); + } + + /** + * Negate this matrix and place the result in a destination matrix. + * @param dest The destination matrix, or null if a new matrix is to be created + * @return the negated matrix + */ + public Matrix4f negate(Matrix4f dest) { + return negate(this, this); + } + + /** + * Negate this matrix and place the result in a destination matrix. + * @param src The source matrix + * @param dest The destination matrix, or null if a new matrix is to be created + * @return The negated matrix + */ + public static Matrix4f negate(Matrix4f src, Matrix4f dest) { + if (dest == null) + dest = new Matrix4f(); + + dest.m00 = -src.m00; + dest.m01 = -src.m01; + dest.m02 = -src.m02; + dest.m03 = -src.m03; + dest.m10 = -src.m10; + dest.m11 = -src.m11; + dest.m12 = -src.m12; + dest.m13 = -src.m13; + dest.m20 = -src.m20; + dest.m21 = -src.m21; + dest.m22 = -src.m22; + dest.m23 = -src.m23; + dest.m30 = -src.m30; + dest.m31 = -src.m31; + dest.m32 = -src.m32; + dest.m33 = -src.m33; + + return dest; + } +} diff --git a/src/java/org/lwjgl/util/vector/Quaternion.java b/src/java/org/lwjgl/util/vector/Quaternion.java new file mode 100644 index 0000000..50cefdc --- /dev/null +++ b/src/java/org/lwjgl/util/vector/Quaternion.java @@ -0,0 +1,530 @@ +/* + * 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.vector; + +/** + * + * Quaternions for LWJGL! + * + * @author fbi + * @version $Revision: 2983 $ + * $Id: Quaternion.java 2983 2008-04-07 18:36:09Z matzon $ + */ + +import java.nio.FloatBuffer; + +public class Quaternion extends Vector implements ReadableVector4f { + private static final long serialVersionUID = 1L; + + public float x, y, z, w; + + /** + * C'tor. The quaternion will be initialized to the identity. + */ + public Quaternion() { + super(); + setIdentity(); + } + + /** + * C'tor + * + * @param src + */ + public Quaternion(ReadableVector4f src) { + set(src); + } + + /** + * C'tor + * + */ + public Quaternion(float x, float y, float z, float w) { + set(x, y, z, w); + } + + /* + * (non-Javadoc) + * + * @see org.lwjgl.util.vector.WritableVector2f#set(float, float) + */ + public void set(float x, float y) { + this.x = x; + this.y = y; + } + + /* + * (non-Javadoc) + * + * @see org.lwjgl.util.vector.WritableVector3f#set(float, float, float) + */ + public void set(float x, float y, float z) { + this.x = x; + this.y = y; + this.z = z; + } + + /* + * (non-Javadoc) + * + * @see org.lwjgl.util.vector.WritableVector4f#set(float, float, float, + * float) + */ + public void set(float x, float y, float z, float w) { + this.x = x; + this.y = y; + this.z = z; + this.w = w; + } + + /** + * Load from another Vector4f + * + * @param src + * The source vector + * @return this + */ + public Quaternion set(ReadableVector4f src) { + x = src.getX(); + y = src.getY(); + z = src.getZ(); + w = src.getW(); + return this; + } + + /** + * Set this quaternion to the multiplication identity. + * @return this + */ + public Quaternion setIdentity() { + return setIdentity(this); + } + + /** + * Set the given quaternion to the multiplication identity. + * @param q The quaternion + * @return q + */ + public static Quaternion setIdentity(Quaternion q) { + q.x = 0; + q.y = 0; + q.z = 0; + q.w = 1; + return q; + } + + /** + * @return the length squared of the quaternion + */ + public float lengthSquared() { + return x * x + y * y + z * z + w * w; + } + + /** + * Normalise the source quaternion and place the result in another quaternion. + * + * @param src + * The source quaternion + * @param dest + * The destination quaternion, or null if a new quaternion is to be + * created + * @return The normalised quaternion + */ + public static Quaternion normalise(Quaternion src, Quaternion dest) { + float inv_l = 1f/src.length(); + + if (dest == null) + dest = new Quaternion(); + + dest.set(src.x * inv_l, src.y * inv_l, src.z * inv_l, src.w * inv_l); + + return dest; + } + + /** + * Normalise this quaternion and place the result in another quaternion. + * + * @param dest + * The destination quaternion, or null if a new quaternion is to be + * created + * @return the normalised quaternion + */ + public Quaternion normalise(Quaternion dest) { + return normalise(this, dest); + } + + /** + * The dot product of two quaternions + * + * @param left + * The LHS quat + * @param right + * The RHS quat + * @return left dot right + */ + public static float dot(Quaternion left, Quaternion right) { + return left.x * right.x + left.y * right.y + left.z * right.z + left.w + * right.w; + } + + /** + * Calculate the conjugate of this quaternion and put it into the given one + * + * @param dest + * The quaternion which should be set to the conjugate of this + * quaternion + */ + public Quaternion negate(Quaternion dest) { + return negate(this, dest); + } + + /** + * Calculate the conjugate of this quaternion and put it into the given one + * + * @param src + * The source quaternion + * @param dest + * The quaternion which should be set to the conjugate of this + * quaternion + */ + public static Quaternion negate(Quaternion src, Quaternion dest) { + if (dest == null) + dest = new Quaternion(); + + dest.x = -src.x; + dest.y = -src.y; + dest.z = -src.z; + dest.w = src.w; + + return dest; + } + + /** + * Calculate the conjugate of this quaternion + */ + public Vector negate() { + return negate(this, this); + } + + /* (non-Javadoc) + * @see org.lwjgl.util.vector.Vector#load(java.nio.FloatBuffer) + */ + public Vector load(FloatBuffer buf) { + x = buf.get(); + y = buf.get(); + z = buf.get(); + w = buf.get(); + return this; + } + + /* + * (non-Javadoc) + * + * @see org.lwjgl.vector.Vector#scale(float) + */ + public Vector scale(float scale) { + return scale(scale, this, this); + } + + /** + * Scale the source quaternion by scale and put the result in the destination + * @param scale The amount to scale by + * @param src The source quaternion + * @param dest The destination quaternion, or null if a new quaternion is to be created + * @return The scaled quaternion + */ + public static Quaternion scale(float scale, Quaternion src, Quaternion dest) { + if (dest == null) + dest = new Quaternion(); + dest.x = src.x * scale; + dest.y = src.y * scale; + dest.z = src.z * scale; + dest.w = src.w * scale; + return dest; + } + + /* (non-Javadoc) + * @see org.lwjgl.util.vector.ReadableVector#store(java.nio.FloatBuffer) + */ + public Vector store(FloatBuffer buf) { + buf.put(x); + buf.put(y); + buf.put(z); + buf.put(w); + + return this; + } + + /** + * @return x + */ + public final float getX() { + return x; + } + + /** + * @return y + */ + public final float getY() { + return y; + } + + /** + * Set X + * + * @param x + */ + public final void setX(float x) { + this.x = x; + } + + /** + * Set Y + * + * @param y + */ + public final void setY(float y) { + this.y = y; + } + + /** + * Set Z + * + * @param z + */ + public void setZ(float z) { + this.z = z; + } + + /* + * (Overrides) + * + * @see org.lwjgl.vector.ReadableVector3f#getZ() + */ + public float getZ() { + return z; + } + + /** + * Set W + * + * @param w + */ + public void setW(float w) { + this.w = w; + } + + /* + * (Overrides) + * + * @see org.lwjgl.vector.ReadableVector3f#getW() + */ + public float getW() { + return w; + } + + public String toString() { + return "Quaternion: " + x + " " + y + " " + z + " " + w; + } + + /** + * Sets the value of this quaternion to the quaternion product of + * quaternions left and right (this = left * right). Note that this is safe + * for aliasing (e.g. this can be left or right). + * + * @param left + * the first quaternion + * @param right + * the second quaternion + */ + public static Quaternion mul(Quaternion left, Quaternion right, + Quaternion dest) { + if (dest == null) + dest = new Quaternion(); + dest.set(left.x * right.w + left.w * right.x + left.y * right.z + - left.z * right.y, left.y * right.w + left.w * right.y + + left.z * right.x - left.x * right.z, left.z * right.w + + left.w * right.z + left.x * right.y - left.y * right.x, + left.w * right.w - left.x * right.x - left.y * right.y + - left.z * right.z); + return dest; + } + + /** + * + * Multiplies quaternion left by the inverse of quaternion right and places + * the value into this quaternion. The value of both argument quaternions is + * preservered (this = left * right^-1). + * + * @param left + * the left quaternion + * @param right + * the right quaternion + */ + public static Quaternion mulInverse(Quaternion left, Quaternion right, + Quaternion dest) { + float n = right.lengthSquared(); + // zero-div may occur. + n = (n == 0.0 ? n : 1 / n); + // store on stack once for aliasing-safty + if (dest == null) + dest = new Quaternion(); + dest + .set((left.x * right.w - left.w * right.x - left.y + * right.z + left.z * right.y) + * n, (left.y * right.w - left.w * right.y - left.z + * right.x + left.x * right.z) + * n, (left.z * right.w - left.w * right.z - left.x + * right.y + left.y * right.x) + * n, (left.w * right.w + left.x * right.x + left.y + * right.y + left.z * right.z) + * n); + + return dest; + } + + /** + * Sets the value of this quaternion to the equivalent rotation of the + * Axis-Angle argument. + * + * @param a1 + * the axis-angle: (x,y,z) is the axis and w is the angle + */ + public final void setFromAxisAngle(Vector4f a1) { + x = a1.x; + y = a1.y; + z = a1.z; + float n = (float) Math.sqrt(x * x + y * y + z * z); + // zero-div may occur. + float s = (float) (Math.sin(0.5 * a1.w) / n); + x *= s; + y *= s; + z *= s; + w = (float) Math.cos(0.5 * a1.w); + } + + /** + * Sets the value of this quaternion using the rotational component of the + * passed matrix. + * + * @param m + * The matrix + * @return this + */ + public final Quaternion setFromMatrix(Matrix4f m) { + return setFromMatrix(m, this); + } + + /** + * Sets the value of the source quaternion using the rotational component of the + * passed matrix. + * + * @param m + * The source matrix + * @param q + * The destination quaternion, or null if a new quaternion is to be created + * @return q + */ + public final static Quaternion setFromMatrix(Matrix4f m, Quaternion q) { + return q.setFromMat(m.m00, m.m01, m.m02, m.m10, m.m11, m.m12, m.m20, + m.m21, m.m22); + } + + /** + * Sets the value of this quaternion using the rotational component of the + * passed matrix. + * + * @param m + * The source matrix + */ + public final Quaternion setFromMatrix(Matrix3f m) { + return setFromMatrix(m, this); + } + + /** + * Sets the value of the source quaternion using the rotational component of the + * passed matrix. + * + * @param m + * The source matrix + * @param q + * The destination quaternion, or null if a new quaternion is to be created + * @return q + */ + public static final Quaternion setFromMatrix(Matrix3f m, Quaternion q) { + return q.setFromMat(m.m00, m.m01, m.m02, m.m10, m.m11, m.m12, m.m20, + m.m21, m.m22); + } + + /** + * Private method to perform the matrix-to-quaternion conversion + */ + private Quaternion setFromMat(float m00, float m01, float m02, float m10, + float m11, float m12, float m20, float m21, float m22) { + + float s; + float tr = m00 + m11 + m22; + if (tr >= 0.0) { + s = (float) Math.sqrt(tr + 1.0); + w = s * 0.5f; + s = 0.5f / s; + x = (m21 - m12) * s; + y = (m02 - m20) * s; + z = (m10 - m01) * s; + } else { + float max = Math.max(Math.max(m00, m11), m22); + if (max == m00) { + s = (float) Math.sqrt(m00 - (m11 + m22) + 1.0); + x = s * 0.5f; + s = 0.5f / s; + y = (m01 + m10) * s; + z = (m20 + m02) * s; + w = (m21 - m12) * s; + } else if (max == m11) { + s = (float) Math.sqrt(m11 - (m22 + m00) + 1.0); + y = s * 0.5f; + s = 0.5f / s; + z = (m12 + m21) * s; + x = (m01 + m10) * s; + w = (m02 - m20) * s; + } else { + s = (float) Math.sqrt(m22 - (m00 + m11) + 1.0); + z = s * 0.5f; + s = 0.5f / s; + x = (m20 + m02) * s; + y = (m12 + m21) * s; + w = (m10 - m01) * s; + } + } + return this; + } +} diff --git a/src/java/org/lwjgl/util/vector/ReadableVector.java b/src/java/org/lwjgl/util/vector/ReadableVector.java new file mode 100644 index 0000000..20194af --- /dev/null +++ b/src/java/org/lwjgl/util/vector/ReadableVector.java @@ -0,0 +1,54 @@ +/* + * 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.vector; + +import java.nio.FloatBuffer; + +/** + * @author foo + */ +public interface ReadableVector { + /** + * @return the length of the vector + */ + public float length(); + /** + * @return the length squared of the vector + */ + public float lengthSquared(); + /** + * Store this vector in a FloatBuffer + * @param buf The buffer to store it in, at the current position + * @return this + */ + public Vector store(FloatBuffer buf); +} \ No newline at end of file diff --git a/src/java/org/lwjgl/util/vector/ReadableVector2f.java b/src/java/org/lwjgl/util/vector/ReadableVector2f.java new file mode 100644 index 0000000..f6e883a --- /dev/null +++ b/src/java/org/lwjgl/util/vector/ReadableVector2f.java @@ -0,0 +1,46 @@ +/* + * 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.vector; + +/** + * @author foo + */ +public interface ReadableVector2f extends ReadableVector { + /** + * @return x + */ + public float getX(); + /** + * @return y + */ + public float getY(); +} \ No newline at end of file diff --git a/src/java/org/lwjgl/util/vector/ReadableVector3f.java b/src/java/org/lwjgl/util/vector/ReadableVector3f.java new file mode 100644 index 0000000..c877bd1 --- /dev/null +++ b/src/java/org/lwjgl/util/vector/ReadableVector3f.java @@ -0,0 +1,42 @@ +/* + * 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.vector; + +/** + * @author foo + */ +public interface ReadableVector3f extends ReadableVector2f { + /** + * @return z + */ + public float getZ(); +} \ No newline at end of file diff --git a/src/java/org/lwjgl/util/vector/ReadableVector4f.java b/src/java/org/lwjgl/util/vector/ReadableVector4f.java new file mode 100644 index 0000000..3ca837c --- /dev/null +++ b/src/java/org/lwjgl/util/vector/ReadableVector4f.java @@ -0,0 +1,44 @@ +/* + * 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.vector; + +/** + * @author foo + */ +public interface ReadableVector4f extends ReadableVector3f { + + /** + * @return w + */ + public float getW(); + +} diff --git a/src/java/org/lwjgl/util/vector/Vector.java b/src/java/org/lwjgl/util/vector/Vector.java new file mode 100644 index 0000000..ea5b8d8 --- /dev/null +++ b/src/java/org/lwjgl/util/vector/Vector.java @@ -0,0 +1,112 @@ +/* + * 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.vector; + +import java.io.Serializable; +import java.nio.FloatBuffer; + +/** + * + * Base class for vectors. + * + * @author cix_foo + * @version $Revision: 2983 $ + * $Id: Vector.java 2983 2008-04-07 18:36:09Z matzon $ + */ +public abstract class Vector implements Serializable, ReadableVector { + + /** + * Constructor for Vector. + */ + public Vector() { + super(); + } + + /** + * @return the length of the vector + */ + public final float length() { + return (float) Math.sqrt(lengthSquared()); + } + + + /** + * @return the length squared of the vector + */ + public abstract float lengthSquared(); + + /** + * Load this vector from a FloatBuffer + * @param buf The buffer to load it from, at the current position + * @return this + */ + public abstract Vector load(FloatBuffer buf); + + /** + * Negate a vector + * @return this + */ + public abstract Vector negate(); + + + /** + * Normalise this vector + * @return this + */ + public final Vector normalise() { + float len = length(); + if (len != 0.0f) { + float l = 1.0f / len; + return scale(l); + } else + throw new IllegalStateException("Zero length vector"); + } + + + /** + * Store this vector in a FloatBuffer + * @param buf The buffer to store it in, at the current position + * @return this + */ + public abstract Vector store(FloatBuffer buf); + + + /** + * Scale this vector + * @param scale The scale factor + * @return this + */ + public abstract Vector scale(float scale); + + + +} diff --git a/src/java/org/lwjgl/util/vector/Vector2f.java b/src/java/org/lwjgl/util/vector/Vector2f.java new file mode 100644 index 0000000..59d5f13 --- /dev/null +++ b/src/java/org/lwjgl/util/vector/Vector2f.java @@ -0,0 +1,290 @@ +/* + * 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.vector; + +import java.io.Serializable; +import java.nio.FloatBuffer; + +/** + * + * Holds a 2-tuple vector. + * + * @author cix_foo + * @version $Revision: 2983 $ + * $Id: Vector2f.java 2983 2008-04-07 18:36:09Z matzon $ + */ + +public class Vector2f extends Vector implements Serializable, ReadableVector2f, WritableVector2f { + + private static final long serialVersionUID = 1L; + + public float x, y; + + /** + * Constructor for Vector3f. + */ + public Vector2f() { + super(); + } + + /** + * Constructor + */ + public Vector2f(ReadableVector2f src) { + set(src); + } + + /** + * Constructor + */ + public Vector2f(float x, float y) { + set(x, y); + } + + /* (non-Javadoc) + * @see org.lwjgl.util.vector.WritableVector2f#set(float, float) + */ + public void set(float x, float y) { + this.x = x; + this.y = y; + } + + /** + * Load from another Vector2f + * @param src The source vector + * @return this + */ + public Vector2f set(ReadableVector2f src) { + x = src.getX(); + y = src.getY(); + return this; + } + + /** + * @return the length squared of the vector + */ + public float lengthSquared() { + return x * x + y * y; + } + + /** + * Translate a vector + * @param x The translation in x + * @param y the translation in y + * @return this + */ + public Vector2f translate(float x, float y) { + this.x += x; + this.y += y; + return this; + } + + /** + * Negate a vector + * @return this + */ + public Vector negate() { + x = -x; + y = -y; + return this; + } + + /** + * Negate a vector and place the result in a destination vector. + * @param dest The destination vector or null if a new vector is to be created + * @return the negated vector + */ + public Vector2f negate(Vector2f dest) { + if (dest == null) + dest = new Vector2f(); + dest.x = -x; + dest.y = -y; + return dest; + } + + + /** + * Normalise this vector and place the result in another vector. + * @param dest The destination vector, or null if a new vector is to be created + * @return the normalised vector + */ + public Vector2f normalise(Vector2f dest) { + float l = length(); + + if (dest == null) + dest = new Vector2f(x / l, y / l); + else + dest.set(x / l, y / l); + + return dest; + } + + /** + * The dot product of two vectors is calculated as + * v1.x * v2.x + v1.y * v2.y + v1.z * v2.z + * @param left The LHS vector + * @param right The RHS vector + * @return left dot right + */ + public static float dot(Vector2f left, Vector2f right) { + return left.x * right.x + left.y * right.y; + } + + + + /** + * Calculate the angle between two vectors, in radians + * @param a A vector + * @param b The other vector + * @return the angle between the two vectors, in radians + */ + public static float angle(Vector2f a, Vector2f b) { + float dls = dot(a, b) / (a.length() * b.length()); + if (dls < -1f) + dls = -1f; + else if (dls > 1.0f) + dls = 1.0f; + return (float)Math.acos(dls); + } + + /** + * Add a vector to another vector and place the result in a destination + * vector. + * @param left The LHS vector + * @param right The RHS vector + * @param dest The destination vector, or null if a new vector is to be created + * @return the sum of left and right in dest + */ + public static Vector2f add(Vector2f left, Vector2f right, Vector2f dest) { + if (dest == null) + return new Vector2f(left.x + right.x, left.y + right.y); + else { + dest.set(left.x + right.x, left.y + right.y); + return dest; + } + } + + /** + * Subtract a vector from another vector and place the result in a destination + * vector. + * @param left The LHS vector + * @param right The RHS vector + * @param dest The destination vector, or null if a new vector is to be created + * @return left minus right in dest + */ + public static Vector2f sub(Vector2f left, Vector2f right, Vector2f dest) { + if (dest == null) + return new Vector2f(left.x - right.x, left.y - right.y); + else { + dest.set(left.x - right.x, left.y - right.y); + return dest; + } + } + + /** + * Store this vector in a FloatBuffer + * @param buf The buffer to store it in, at the current position + * @return this + */ + public Vector store(FloatBuffer buf) { + buf.put(x); + buf.put(y); + return this; + } + + /** + * Load this vector from a FloatBuffer + * @param buf The buffer to load it from, at the current position + * @return this + */ + public Vector load(FloatBuffer buf) { + x = buf.get(); + y = buf.get(); + return this; + } + + /* (non-Javadoc) + * @see org.lwjgl.vector.Vector#scale(float) + */ + public Vector scale(float scale) { + + x *= scale; + y *= scale; + + return this; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + public String toString() { + StringBuffer sb = new StringBuffer(64); + + sb.append("Vector2f["); + sb.append(x); + sb.append(", "); + sb.append(y); + sb.append(']'); + return sb.toString(); + } + + /** + * @return x + */ + public final float getX() { + return x; + } + + /** + * @return y + */ + public final float getY() { + return y; + } + + /** + * Set X + * @param x + */ + public final void setX(float x) { + this.x = x; + } + + /** + * Set Y + * @param y + */ + public final void setY(float y) { + this.y = y; + } + +} diff --git a/src/java/org/lwjgl/util/vector/Vector3f.java b/src/java/org/lwjgl/util/vector/Vector3f.java new file mode 100644 index 0000000..2396bbf --- /dev/null +++ b/src/java/org/lwjgl/util/vector/Vector3f.java @@ -0,0 +1,347 @@ +/* + * 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.vector; + +import java.io.Serializable; +import java.nio.FloatBuffer; + +/** + * + * Holds a 3-tuple vector. + * + * @author cix_foo + * @version $Revision: 2983 $ + * $Id: Vector3f.java 2983 2008-04-07 18:36:09Z matzon $ + */ + +public class Vector3f extends Vector implements Serializable, ReadableVector3f, WritableVector3f { + + private static final long serialVersionUID = 1L; + + public float x, y, z; + + /** + * Constructor for Vector3f. + */ + public Vector3f() { + super(); + } + + /** + * Constructor + */ + public Vector3f(ReadableVector3f src) { + set(src); + } + + /** + * Constructor + */ + public Vector3f(float x, float y, float z) { + set(x, y, z); + } + + /* (non-Javadoc) + * @see org.lwjgl.util.vector.WritableVector2f#set(float, float) + */ + public void set(float x, float y) { + this.x = x; + this.y = y; + } + + /* (non-Javadoc) + * @see org.lwjgl.util.vector.WritableVector3f#set(float, float, float) + */ + public void set(float x, float y, float z) { + this.x = x; + this.y = y; + this.z = z; + } + + /** + * Load from another Vector3f + * @param src The source vector + * @return this + */ + public Vector3f set(ReadableVector3f src) { + x = src.getX(); + y = src.getY(); + z = src.getZ(); + return this; + } + + /** + * @return the length squared of the vector + */ + public float lengthSquared() { + return x * x + y * y + z * z; + } + + /** + * Translate a vector + * @param x The translation in x + * @param y the translation in y + * @return this + */ + public Vector3f translate(float x, float y, float z) { + this.x += x; + this.y += y; + this.z += z; + return this; + } + + /** + * Add a vector to another vector and place the result in a destination + * vector. + * @param left The LHS vector + * @param right The RHS vector + * @param dest The destination vector, or null if a new vector is to be created + * @return the sum of left and right in dest + */ + public static Vector3f add(Vector3f left, Vector3f right, Vector3f dest) { + if (dest == null) + return new Vector3f(left.x + right.x, left.y + right.y, left.z + right.z); + else { + dest.set(left.x + right.x, left.y + right.y, left.z + right.z); + return dest; + } + } + + /** + * Subtract a vector from another vector and place the result in a destination + * vector. + * @param left The LHS vector + * @param right The RHS vector + * @param dest The destination vector, or null if a new vector is to be created + * @return left minus right in dest + */ + public static Vector3f sub(Vector3f left, Vector3f right, Vector3f dest) { + if (dest == null) + return new Vector3f(left.x - right.x, left.y - right.y, left.z - right.z); + else { + dest.set(left.x - right.x, left.y - right.y, left.z - right.z); + return dest; + } + } + + /** + * The cross product of two vectors. + * + * @param left The LHS vector + * @param right The RHS vector + * @param dest The destination result, or null if a new vector is to be created + * @return left cross right + */ + public static Vector3f cross( + Vector3f left, + Vector3f right, + Vector3f dest) + { + + if (dest == null) + dest = new Vector3f(); + + dest.set( + left.y * right.z - left.z * right.y, + right.x * left.z - right.z * left.x, + left.x * right.y - left.y * right.x + ); + + return dest; + } + + + + /** + * Negate a vector + * @return this + */ + public Vector negate() { + x = -x; + y = -y; + z = -z; + return this; + } + + /** + * Negate a vector and place the result in a destination vector. + * @param dest The destination vector or null if a new vector is to be created + * @return the negated vector + */ + public Vector3f negate(Vector3f dest) { + if (dest == null) + dest = new Vector3f(); + dest.x = -x; + dest.y = -y; + dest.z = -z; + return dest; + } + + + /** + * Normalise this vector and place the result in another vector. + * @param dest The destination vector, or null if a new vector is to be created + * @return the normalised vector + */ + public Vector3f normalise(Vector3f dest) { + float l = length(); + + if (dest == null) + dest = new Vector3f(x / l, y / l, z / l); + else + dest.set(x / l, y / l, z / l); + + return dest; + } + + /** + * The dot product of two vectors is calculated as + * v1.x * v2.x + v1.y * v2.y + v1.z * v2.z + * @param left The LHS vector + * @param right The RHS vector + * @return left dot right + */ + public static float dot(Vector3f left, Vector3f right) { + return left.x * right.x + left.y * right.y + left.z * right.z; + } + + /** + * Calculate the angle between two vectors, in radians + * @param a A vector + * @param b The other vector + * @return the angle between the two vectors, in radians + */ + public static float angle(Vector3f a, Vector3f b) { + float dls = dot(a, b) / (a.length() * b.length()); + if (dls < -1f) + dls = -1f; + else if (dls > 1.0f) + dls = 1.0f; + return (float)Math.acos(dls); + } + + /* (non-Javadoc) + * @see org.lwjgl.vector.Vector#load(FloatBuffer) + */ + public Vector load(FloatBuffer buf) { + x = buf.get(); + y = buf.get(); + z = buf.get(); + return this; + } + + /* (non-Javadoc) + * @see org.lwjgl.vector.Vector#scale(float) + */ + public Vector scale(float scale) { + + x *= scale; + y *= scale; + z *= scale; + + return this; + + } + + /* (non-Javadoc) + * @see org.lwjgl.vector.Vector#store(FloatBuffer) + */ + public Vector store(FloatBuffer buf) { + + buf.put(x); + buf.put(y); + buf.put(z); + + return this; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + public String toString() { + StringBuffer sb = new StringBuffer(64); + + sb.append("Vector3f["); + sb.append(x); + sb.append(", "); + sb.append(y); + sb.append(", "); + sb.append(z); + sb.append(']'); + return sb.toString(); + } + + /** + * @return x + */ + public final float getX() { + return x; + } + + /** + * @return y + */ + public final float getY() { + return y; + } + + /** + * Set X + * @param x + */ + public final void setX(float x) { + this.x = x; + } + + /** + * Set Y + * @param y + */ + public final void setY(float y) { + this.y = y; + } + + /** + * Set Z + * @param z + */ + public void setZ(float z) { + this.z = z; + } + + /* (Overrides) + * @see org.lwjgl.vector.ReadableVector3f#getZ() + */ + public float getZ() { + return z; + } +} diff --git a/src/java/org/lwjgl/util/vector/Vector4f.java b/src/java/org/lwjgl/util/vector/Vector4f.java new file mode 100644 index 0000000..3ab7db7 --- /dev/null +++ b/src/java/org/lwjgl/util/vector/Vector4f.java @@ -0,0 +1,340 @@ +/* + * 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.vector; + +import java.io.Serializable; +import java.nio.FloatBuffer; + +/** + * + * Holds a 4-tuple vector. + * + * @author cix_foo + * @version $Revision: 2983 $ + * $Id: Vector4f.java 2983 2008-04-07 18:36:09Z matzon $ + */ + +public class Vector4f extends Vector implements Serializable, ReadableVector4f, WritableVector4f { + + private static final long serialVersionUID = 1L; + + public float x, y, z, w; + + /** + * Constructor for Vector4f. + */ + public Vector4f() { + super(); + } + + /** + * Constructor + */ + public Vector4f(ReadableVector4f src) { + set(src); + } + + /** + * Constructor + */ + public Vector4f(float x, float y, float z, float w) { + set(x, y, z, w); + } + + /* (non-Javadoc) + * @see org.lwjgl.util.vector.WritableVector2f#set(float, float) + */ + public void set(float x, float y) { + this.x = x; + this.y = y; + } + + /* (non-Javadoc) + * @see org.lwjgl.util.vector.WritableVector3f#set(float, float, float) + */ + public void set(float x, float y, float z) { + this.x = x; + this.y = y; + this.z = z; + } + + /* (non-Javadoc) + * @see org.lwjgl.util.vector.WritableVector4f#set(float, float, float, float) + */ + public void set(float x, float y, float z, float w) { + this.x = x; + this.y = y; + this.z = z; + this.w = w; + } + + /** + * Load from another Vector4f + * @param src The source vector + * @return this + */ + public Vector4f set(ReadableVector4f src) { + x = src.getX(); + y = src.getY(); + z = src.getZ(); + w = src.getW(); + return this; + } + + /** + * @return the length squared of the vector + */ + public float lengthSquared() { + return x * x + y * y + z * z + w * w; + } + + /** + * Translate a vector + * @param x The translation in x + * @param y the translation in y + * @return this + */ + public Vector4f translate(float x, float y, float z, float w) { + this.x += x; + this.y += y; + this.z += z; + this.w += w; + return this; + } + + /** + * Add a vector to another vector and place the result in a destination + * vector. + * @param left The LHS vector + * @param right The RHS vector + * @param dest The destination vector, or null if a new vector is to be created + * @return the sum of left and right in dest + */ + public static Vector4f add(Vector4f left, Vector4f right, Vector4f dest) { + if (dest == null) + return new Vector4f(left.x + right.x, left.y + right.y, left.z + right.z, left.w + right.w); + else { + dest.set(left.x + right.x, left.y + right.y, left.z + right.z, left.w + right.w); + return dest; + } + } + + /** + * Subtract a vector from another vector and place the result in a destination + * vector. + * @param left The LHS vector + * @param right The RHS vector + * @param dest The destination vector, or null if a new vector is to be created + * @return left minus right in dest + */ + public static Vector4f sub(Vector4f left, Vector4f right, Vector4f dest) { + if (dest == null) + return new Vector4f(left.x - right.x, left.y - right.y, left.z - right.z, left.w - right.w); + else { + dest.set(left.x - right.x, left.y - right.y, left.z - right.z, left.w - right.w); + return dest; + } + } + + + /** + * Negate a vector + * @return this + */ + public Vector negate() { + x = -x; + y = -y; + z = -z; + w = -w; + return this; + } + + /** + * Negate a vector and place the result in a destination vector. + * @param dest The destination vector or null if a new vector is to be created + * @return the negated vector + */ + public Vector4f negate(Vector4f dest) { + if (dest == null) + dest = new Vector4f(); + dest.x = -x; + dest.y = -y; + dest.z = -z; + dest.w = -w; + return dest; + } + + + /** + * Normalise this vector and place the result in another vector. + * @param dest The destination vector, or null if a new vector is to be created + * @return the normalised vector + */ + public Vector4f normalise(Vector4f dest) { + float l = length(); + + if (dest == null) + dest = new Vector4f(x / l, y / l, z / l, w / l); + else + dest.set(x / l, y / l, z / l, w / l); + + return dest; + } + + /** + * The dot product of two vectors is calculated as + * v1.x * v2.x + v1.y * v2.y + v1.z * v2.z + v1.w * v2.w + * @param left The LHS vector + * @param right The RHS vector + * @return left dot right + */ + public static float dot(Vector4f left, Vector4f right) { + return left.x * right.x + left.y * right.y + left.z * right.z + left.w * right.w; + } + + /** + * Calculate the angle between two vectors, in radians + * @param a A vector + * @param b The other vector + * @return the angle between the two vectors, in radians + */ + public static float angle(Vector4f a, Vector4f b) { + float dls = dot(a, b) / (a.length() * b.length()); + if (dls < -1f) + dls = -1f; + else if (dls > 1.0f) + dls = 1.0f; + return (float)Math.acos(dls); + } + + /* (non-Javadoc) + * @see org.lwjgl.vector.Vector#load(FloatBuffer) + */ + public Vector load(FloatBuffer buf) { + x = buf.get(); + y = buf.get(); + z = buf.get(); + w = buf.get(); + return this; + } + + /* (non-Javadoc) + * @see org.lwjgl.vector.Vector#scale(float) + */ + public Vector scale(float scale) { + x *= scale; + y *= scale; + z *= scale; + w *= scale; + return this; + } + + /* (non-Javadoc) + * @see org.lwjgl.vector.Vector#store(FloatBuffer) + */ + public Vector store(FloatBuffer buf) { + + buf.put(x); + buf.put(y); + buf.put(z); + buf.put(w); + + return this; + } + + public String toString() { + return "Vector4f: " + x + " " + y + " " + z + " " + w; + } + + /** + * @return x + */ + public final float getX() { + return x; + } + + /** + * @return y + */ + public final float getY() { + return y; + } + + /** + * Set X + * @param x + */ + public final void setX(float x) { + this.x = x; + } + + /** + * Set Y + * @param y + */ + public final void setY(float y) { + this.y = y; + } + + /** + * Set Z + * @param z + */ + public void setZ(float z) { + this.z = z; + } + + + /* (Overrides) + * @see org.lwjgl.vector.ReadableVector3f#getZ() + */ + public float getZ() { + return z; + } + + /** + * Set W + * @param w + */ + public void setW(float w) { + this.w = w; + } + + /* (Overrides) + * @see org.lwjgl.vector.ReadableVector3f#getZ() + */ + public float getW() { + return w; + } + + +} diff --git a/src/java/org/lwjgl/util/vector/WritableVector2f.java b/src/java/org/lwjgl/util/vector/WritableVector2f.java new file mode 100644 index 0000000..23f23ca --- /dev/null +++ b/src/java/org/lwjgl/util/vector/WritableVector2f.java @@ -0,0 +1,61 @@ +/* + * 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.vector; + +/** + * Writable interface to Vector2fs + * @author $author$ + * @version $revision$ + * $Id: WritableVector2f.java 2983 2008-04-07 18:36:09Z matzon $ + */ +public interface WritableVector2f { + + /** + * Set the X value + * @param x + */ + public void setX(float x); + + /** + * Set the Y value + * @param y + */ + public void setY(float y); + + /** + * Set the X,Y values + * @param x + * @param y + */ + public void set(float x, float y); + +} \ No newline at end of file diff --git a/src/java/org/lwjgl/util/vector/WritableVector3f.java b/src/java/org/lwjgl/util/vector/WritableVector3f.java new file mode 100644 index 0000000..0f895bf --- /dev/null +++ b/src/java/org/lwjgl/util/vector/WritableVector3f.java @@ -0,0 +1,56 @@ +/* + * 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.vector; + +/** + * Writable interface to Vector3fs + * @author $author$ + * @version $revision$ + * $Id: WritableVector3f.java 2983 2008-04-07 18:36:09Z matzon $ + */ +public interface WritableVector3f extends WritableVector2f { + + /** + * Set the Z value + * @param z + */ + public void setZ(float z); + + /** + * Set the X,Y,Z values + * @param x + * @param y + * @param z + */ + public void set(float x, float y, float z); + +} \ No newline at end of file diff --git a/src/java/org/lwjgl/util/vector/WritableVector4f.java b/src/java/org/lwjgl/util/vector/WritableVector4f.java new file mode 100644 index 0000000..7ea492c --- /dev/null +++ b/src/java/org/lwjgl/util/vector/WritableVector4f.java @@ -0,0 +1,57 @@ +/* + * 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.vector; + +/** + * Writable interface to Vector4fs + * @author $author$ + * @version $revision$ + * $Id: WritableVector4f.java 2983 2008-04-07 18:36:09Z matzon $ + */ +public interface WritableVector4f extends WritableVector3f { + + /** + * Set the W value + * @param w + */ + public void setW(float w); + + /** + * Set the X,Y,Z,W values + * @param x + * @param y + * @param z + * @param w + */ + public void set(float x, float y, float z, float w); + +} \ No newline at end of file diff --git a/src/native/common/awt_tools.h b/src/native/common/awt_tools.h new file mode 100644 index 0000000..f8479e0 --- /dev/null +++ b/src/native/common/awt_tools.h @@ -0,0 +1,53 @@ +/* + * 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. + */ + +/** + * $Id: awt_tools.h 2985 2008-04-07 18:42:36Z matzon $ + * + * @author elias_naur + * @version $Revision: 2985 $ + */ + +#ifndef __LWJGL_AWT_TOOLS_H +#define __LWJGL_AWT_TOOLS_H + +#include +#include + +typedef struct { + JAWT awt; + JAWT_DrawingSurface* ds; + JAWT_DrawingSurfaceInfo *dsi; +} AWTSurfaceLock; + +#endif + diff --git a/src/native/common/common_tools.c b/src/native/common/common_tools.c new file mode 100644 index 0000000..e2ba2ac --- /dev/null +++ b/src/native/common/common_tools.c @@ -0,0 +1,356 @@ +/* + * 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. + */ + +/** + * $Id: common_tools.c 3167 2008-12-22 16:38:57Z elias_naur $ + * + * @author elias_naur + * @version $Revision: 3167 $ + */ + +#include +#include +#include "common_tools.h" +#include "org_lwjgl_DefaultSysImplementation.h" + +static bool debug = false; +static JavaVM *jvm; + +void initAttribList(attrib_list_t *list) { + list->current_index = 0; +} + +void putAttrib(attrib_list_t *list, int attrib) { + if (list->current_index == ATTRIB_LIST_SIZE) { + printfDebug("Ignoring attrib %d: attrib list size too small", attrib); + return; + } + list->attribs[list->current_index] = attrib; + list->current_index++; +} + +JNIEXPORT void JNICALL Java_org_lwjgl_DefaultSysImplementation_setDebug + (JNIEnv *env, jobject ignored, jboolean enable) { + debug = enable == JNI_TRUE ? true : false; +} + +bool isDebugEnabled(void) { + return debug; +} + +static int do_vsnprintf(char* buffer, size_t buffer_size, const char *format, va_list ap) { +#ifdef _MSC_VER + return vsnprintf_s(buffer, buffer_size, _TRUNCATE, format, ap); +#else + va_list cp_ap; + va_copy(cp_ap, ap); + int res = vsnprintf(buffer, buffer_size, format, cp_ap); + va_end(cp_ap); + return res; +#endif +} + +static jstring sprintfJavaString(JNIEnv *env, const char *format, va_list ap) { + int buffer_size = 2; + char *buffer; + jstring str; + int str_size; + buffer = (char *)malloc(sizeof(char)*buffer_size); + if (buffer == NULL) + return NULL; + str_size = do_vsnprintf(buffer, buffer_size, format, ap); + if (str_size > buffer_size) { + free(buffer); + buffer_size = str_size + 1; + buffer = (char *)malloc(sizeof(char)*buffer_size); + if (buffer == NULL) + return NULL; + do_vsnprintf(buffer, buffer_size, format, ap); + } + str = (*env)->NewStringUTF(env, buffer); + free(buffer); + return str; +} + +void printfDebugJava(JNIEnv *env, const char *format, ...) { + jstring str; + jclass org_lwjgl_LWJGLUtil_class; + jmethodID log_method; + va_list ap; + if (isDebugEnabled() && !(*env)->ExceptionOccurred(env)) { + va_start(ap, format); + str = sprintfJavaString(env, format, ap); + va_end(ap); + org_lwjgl_LWJGLUtil_class = (*env)->FindClass(env, "org/lwjgl/LWJGLUtil"); + if (org_lwjgl_LWJGLUtil_class == NULL) + return; + log_method = (*env)->GetStaticMethodID(env, org_lwjgl_LWJGLUtil_class, "log", "(Ljava/lang/String;)V"); + if (log_method == NULL) + return; + (*env)->CallStaticVoidMethod(env, org_lwjgl_LWJGLUtil_class, log_method, str); + } +} + +void printfDebug(const char *format, ...) { + va_list ap; + va_start(ap, format); + if (isDebugEnabled()) + vfprintf(stderr, format, ap); + va_end(ap); +} + +static void throwFormattedGeneralException(JNIEnv * env, const char *exception_name, const char *format, va_list ap) { + jclass cls; + jstring str; + jmethodID exception_constructor; + jobject exception; + + if ((*env)->ExceptionCheck(env) == JNI_TRUE) + return; // The JVM crashes if we try to throw two exceptions from one native call + str = sprintfJavaString(env, format, ap); + cls = (*env)->FindClass(env, exception_name); + exception_constructor = (*env)->GetMethodID(env, cls, "", "(Ljava/lang/String;)V"); + exception = (*env)->NewObject(env, cls, exception_constructor, str); + (*env)->Throw(env, exception); +} + +void throwGeneralException(JNIEnv * env, const char *exception_name, const char * err) { + jclass cls; + + if ((*env)->ExceptionCheck(env) == JNI_TRUE) + return; // The JVM crashes if we try to throw two exceptions from one native call + cls = (*env)->FindClass(env, exception_name); + (*env)->ThrowNew(env, cls, err); +} + +void throwFMODException(JNIEnv * env, const char * err) { + throwGeneralException(env, "org/lwjgl/fmod3/FMODException", err); +} + +void throwFormattedRuntimeException(JNIEnv * env, const char *format, ...) { + va_list ap; + va_start(ap, format); + throwFormattedGeneralException(env, "java/lang/RuntimeException", format, ap); + va_end(ap); +} + +void throwFormattedException(JNIEnv * env, const char *format, ...) { + va_list ap; + va_start(ap, format); + throwFormattedGeneralException(env, "org/lwjgl/LWJGLException", format, ap); + va_end(ap); +} + +void throwException(JNIEnv * env, const char * err) { + throwGeneralException(env, "org/lwjgl/LWJGLException", err); +} + +// retrieves the locale-specific C string +char * GetStringNativeChars(JNIEnv *env, jstring jstr) { + jbyteArray bytes = 0; + jthrowable exc; + char *result = 0; + jclass jcls_str; + jmethodID MID_String_getBytes; + + /* out of memory error? */ + if ((*env)->EnsureLocalCapacity(env, 2) < 0) { + return 0; + } + + // aquire getBytes method + jcls_str = (*env)->FindClass(env, "java/lang/String"); + MID_String_getBytes = (*env)->GetMethodID(env, jcls_str, "getBytes", "()[B"); + + // get the bytes + bytes = (jbyteArray) (*env)->CallObjectMethod(env, jstr, MID_String_getBytes); + exc = (*env)->ExceptionOccurred(env); + + // if no exception occured while getting bytes - continue + if (!exc) { + jint len = (*env)->GetArrayLength(env, bytes); + result = (char *) malloc(len + 1); + if (result == 0) { + throwGeneralException(env, "java/lang/OutOfMemoryError", NULL); + (*env)->DeleteLocalRef(env, bytes); + return 0; + } + (*env)->GetByteArrayRegion(env, bytes, 0, len, (jbyte *) result); + result[len] = 0; /* NULL-terminate */ + } else { + (*env)->DeleteLocalRef(env, exc); + } + (*env)->DeleteLocalRef(env, bytes); + return (char*) result; +} + +/* creates locale specific string, unsigned argument to + * match GLuchar and ALuchar types + */ +jstring NewStringNativeUnsigned(JNIEnv *env, const unsigned char *ustr) { + const char *str = (const char *)ustr; + if (str == NULL) + return NULL; + return NewStringNativeWithLength(env, str, strlen(str)); +} + +// creates locale specific string +jstring NewStringNativeWithLength(JNIEnv *env, const char *str, int length) { + jclass jcls_str; + jmethodID jmethod_str; + jstring result; + jbyteArray bytes; + if (str==NULL) { + return NULL; + } + + jcls_str = (*env)->FindClass(env,"java/lang/String"); + if (jcls_str == NULL) + return NULL; + jmethod_str = (*env)->GetMethodID(env,jcls_str, "", "([B)V"); + if (jmethod_str == NULL) + return NULL; + + bytes = 0; + + if ((*env)->EnsureLocalCapacity(env,2) < 0) { + return NULL; /* out of memory error */ + } + + bytes = (*env)->NewByteArray(env,length); + if (bytes != NULL) { + (*env)->SetByteArrayRegion(env,bytes, 0, length, (jbyte *)str); + result = (jstring)(*env)->NewObject(env,jcls_str, jmethod_str, bytes); + (*env)->DeleteLocalRef(env,bytes); + return result; + } /* else fall through */ + return NULL; +} + +bool ext_InitializeFunctions(ExtGetProcAddressPROC gpa, int num_functions, ExtFunction *functions) { + int i; + void **ext_function_pointer_pointer; + for (i = 0; i < num_functions; i++) { + ExtFunction *function = functions + i; + if (function->ext_function_name != NULL) { + void *ext_func_pointer = gpa(function->ext_function_name); + if (ext_func_pointer == NULL) + return false; + ext_function_pointer_pointer = function->ext_function_pointer; + *ext_function_pointer_pointer = ext_func_pointer; + } + } + return true; +} + +jobject newJavaManagedByteBuffer(JNIEnv *env, const int size) { + jclass bufferutils_class = (*env)->FindClass(env, "org/lwjgl/BufferUtils"); + jmethodID createByteBuffer = (*env)->GetStaticMethodID(env, bufferutils_class, "createByteBuffer", "(I)Ljava/nio/ByteBuffer;"); + jobject buffer = (*env)->CallStaticObjectMethod(env, bufferutils_class, createByteBuffer, size); + return buffer; +} + +void ext_InitializeClass(JNIEnv *env, jclass clazz, ExtGetProcAddressPROC gpa, int num_functions, JavaMethodAndExtFunction *functions) { + JNINativeMethod *methods; + JavaMethodAndExtFunction *function; + void *ext_func_pointer; + void **ext_function_pointer_pointer; + JNINativeMethod *method; + int i; + if (clazz == NULL) { + throwException(env, "Null class"); + return; + } + methods = (JNINativeMethod *)malloc(num_functions*sizeof(JNINativeMethod)); + for (i = 0; i < num_functions; i++) { + function = functions + i; + if (function->ext_function_name != NULL) { + ext_func_pointer = gpa(function->ext_function_name); + if (ext_func_pointer == NULL) { + free(methods); + throwException(env, "Missing driver symbols"); + return; + } + ext_function_pointer_pointer = function->ext_function_pointer; + *ext_function_pointer_pointer = ext_func_pointer; + } + method = methods + i; + method->name = function->method_name; + method->signature = function->signature; + method->fnPtr = function->method_pointer; + } + (*env)->RegisterNatives(env, clazz, methods, num_functions); + free(methods); +} + +bool getBooleanProperty(JNIEnv *env, const char* propertyName) { + jstring property = NewStringNativeWithLength(env, propertyName, strlen(propertyName)); + jclass org_lwjgl_LWJGLUtil_class; + jmethodID getBoolean; + if (property == NULL) + return false; + org_lwjgl_LWJGLUtil_class = (*env)->FindClass(env, "org/lwjgl/LWJGLUtil"); + if (org_lwjgl_LWJGLUtil_class == NULL) + return false; + getBoolean = (*env)->GetStaticMethodID(env, org_lwjgl_LWJGLUtil_class, "getPrivilegedBoolean", "(Ljava/lang/String;)Z"); + if (getBoolean == NULL) + return false; + return (*env)->CallStaticBooleanMethod(env, org_lwjgl_LWJGLUtil_class, getBoolean, property) ? true : false; +} + +JNIEnv *getThreadEnv() { + JNIEnv *env; + (*jvm)->GetEnv(jvm, (void *)&env, JNI_VERSION_1_4); + return env; +} + +JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) { + jvm = vm; + return JNI_VERSION_1_4; +} + +JNIEXPORT void JNICALL JNI_OnUnload(JavaVM *vm, void *reserved) { +} + +bool positionBuffer(JNIEnv *env, jobject buffer, jint position) { + jclass buffer_class; + jmethodID position_method; + + buffer_class = (*env)->GetObjectClass(env, buffer); + if (buffer_class == NULL) + return false; + position_method = (*env)->GetMethodID(env, buffer_class, "position", "(I)Ljava/nio/Buffer;"); + if (position_method == NULL) + return false; + (*env)->CallObjectMethod(env, buffer, position_method, position); + return true; +} diff --git a/src/native/common/common_tools.h b/src/native/common/common_tools.h new file mode 100644 index 0000000..c14f640 --- /dev/null +++ b/src/native/common/common_tools.h @@ -0,0 +1,154 @@ +/* + * 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. + */ + +/** + * $Id: common_tools.h 2988 2008-04-07 19:31:23Z elias_naur $ + * + * @author elias_naur + * @version $Revision: 2988 $ + */ + +#ifndef _COMMON_TOOLS_H +#define _COMMON_TOOLS_H + +#include +#include +#include + +#define ATTRIB_LIST_SIZE (256) + +typedef struct { + int current_index; + int attribs[ATTRIB_LIST_SIZE]; +} attrib_list_t; + +#ifndef __cplusplus +#ifndef bool +typedef enum {false, true} bool; +#endif +#endif + +#ifdef _MSC_VER +#define inline __inline +#include +#else +#include +#endif + +static inline void * safeGetBufferAddress(JNIEnv *env, jobject buffer) { + if (buffer != NULL) { +#ifdef __cplusplus + return (void *)((char *)env->GetDirectBufferAddress(buffer)); +#else + return (void *)((char *)(*env)->GetDirectBufferAddress(env, buffer)); +#endif + } else + return NULL; +} + +static inline jobject safeNewBuffer(JNIEnv *env, void *p, int size) { + if (p != NULL) { +#ifdef __cplusplus + return env->NewDirectByteBuffer(p, size); +#else + return (*env)->NewDirectByteBuffer(env, p, size); +#endif + } else + return NULL; +} + +static inline jobject safeNewBufferCached(JNIEnv *env, void *p, int size, jobject old_buffer) { + if (old_buffer != NULL) { + void *old_buffer_address = (*env)->GetDirectBufferAddress(env, old_buffer); + jlong capacity = (*env)->GetDirectBufferCapacity(env, old_buffer); + if (old_buffer_address == p && capacity == size) + return old_buffer; + } + return safeNewBuffer(env, p, size); + +} + +static inline void *offsetToPointer(jlong offset) { + return (char *)NULL + offset; +} + +typedef void *(* ExtGetProcAddressPROC) (const char *func_name); +typedef struct { + char *method_name; + char *signature; + void *method_pointer; + + char *ext_function_name; + void **ext_function_pointer; +} JavaMethodAndExtFunction; + +typedef struct { + char *ext_function_name; + void **ext_function_pointer; +} ExtFunction; + +#define NUMFUNCTIONS(x) (sizeof(x)/sizeof(JavaMethodAndExtFunction)); + +#ifdef __cplusplus +extern "C" { +#endif + +extern JNIEnv *getThreadEnv(); +extern void initAttribList(attrib_list_t *list); +extern void putAttrib(attrib_list_t *list, int attrib); + +extern bool isDebugEnabled(void); +extern jstring getVersionString(JNIEnv *env); +extern void throwGeneralException(JNIEnv * env, const char *exception_name, const char * err); +extern void throwFormattedRuntimeException(JNIEnv * env, const char *format, ...); +extern void throwException(JNIEnv *env, const char *msg); +extern void throwFormattedException(JNIEnv * env, const char *format, ...); +extern void throwFMODException(JNIEnv * env, const char * err); +extern void setDebugEnabled(bool enable); +extern void printfDebugJava(JNIEnv *env, const char *format, ...); +extern void printfDebug(const char *format, ...); +extern bool getBooleanProperty(JNIEnv *env, const char* propertyName); +extern char * GetStringNativeChars(JNIEnv *env, jstring jstr); +extern jstring NewStringNativeWithLength(JNIEnv *env, const char *str, int length); +extern jstring NewStringNativeUnsigned(JNIEnv *env, const unsigned char *str); +extern jobject newJavaManagedByteBuffer(JNIEnv *env, const int size); +extern bool positionBuffer(JNIEnv *env, jobject buffer, jint position); + +extern void ext_InitializeClass(JNIEnv *env, jclass clazz, ExtGetProcAddressPROC gpa, int num_functions, JavaMethodAndExtFunction *functions); +extern bool ext_InitializeFunctions(ExtGetProcAddressPROC gpa, int num_functions, ExtFunction *functions); + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/src/native/common/extal.c b/src/native/common/extal.c new file mode 100644 index 0000000..4e04c8b --- /dev/null +++ b/src/native/common/extal.c @@ -0,0 +1,78 @@ +/* + * 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. + */ + +#include +#include "extal.h" + +typedef ALvoid* (ALAPIENTRY *alGetProcAddressPROC)(const ALubyte* fname); +/* alGetProcAddress is commented out, since we don't use it anyway */ +//static alGetProcAddressPROC alGetProcAddress = NULL; + +/** + * Initializes OpenAL by loading the library + */ +/*void InitializeOpenAL(JNIEnv *env, jstring oalPath) { + //load our library + if (!tryLoadLibrary(env, oalPath)) { + throwException(env, "Could not load openal library."); + return; + } + alGetProcAddress = (alGetProcAddressPROC)NativeGetFunctionPointer("alGetProcAddress"); + if (alGetProcAddress == NULL) { + UnLoadOpenAL(); + throwException(env, "Could not load alGetProcAddress function pointer."); + return; + } +}*/ + +/** + * Retrieves a pointer to the named function + * + * @param function Name of function + * @return pointer to named function, or NULL if not found + */ +void* extal_GetProcAddress(const char* function) { + void *p; +/* p = alGetProcAddress((const ALubyte*)function); + if (p == NULL) {*/ + p = NativeGetFunctionPointer(function); + if (p == NULL) { + printfDebug("Could not locate symbol %s\n", function); + } +// } + return p; +} + +void extal_InitializeClass(JNIEnv *env, jclass clazz, int num_functions, JavaMethodAndExtFunction *functions) { + ext_InitializeClass(env, clazz, &extal_GetProcAddress, num_functions, functions); +} + diff --git a/src/native/common/extal.h b/src/native/common/extal.h new file mode 100644 index 0000000..d0b62f8 --- /dev/null +++ b/src/native/common/extal.h @@ -0,0 +1,172 @@ +/* + * 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. + */ + +#ifndef _AL_TEST_H +#define _AL_TEST_H + +#ifdef _WIN32 +#include +#endif + +#include +#include "common_tools.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(_WIN32) + #ifdef _OPENAL32LIB + #define ALCAPI __declspec(dllexport) + #else + #define ALCAPI __declspec(dllimport) + #endif + + #define ALCAPIENTRY __cdecl +#else + #define ALCAPI + #define ALCAPIENTRY + +#endif + +#ifdef _WIN32 + #ifdef _OPENAL32LIB + #define ALAPI __declspec(dllexport) + #else + #define ALAPI __declspec(dllimport) + #endif + #define ALAPIENTRY __cdecl + #define AL_CALLBACK +#else + #define ALAPI + #define ALAPIENTRY + #define AL_CALLBACK +#endif + +#define INITGUID +#define OPENAL + +// ALC typedefs +typedef struct ALCdevice_struct ALCdevice; +typedef struct ALCcontext_struct ALCcontext; +/** 8-bit boolean */ +typedef char ALCboolean; + +/** character */ +typedef char ALCchar; + +/** signed 8-bit 2's complement integer */ +typedef char ALCbyte; + +/** unsigned 8-bit integer */ +typedef unsigned char ALCubyte; + +/** signed 16-bit 2's complement integer */ +typedef short ALCshort; + +/** unsigned 16-bit integer */ +typedef unsigned short ALCushort; + +/** signed 32-bit 2's complement integer */ +typedef int ALCint; + +/** unsigned 32-bit integer */ +typedef unsigned int ALCuint; + +/** non-negative 32-bit binary integer size */ +typedef int ALCsizei; + +/** enumerated 32-bit value */ +typedef int ALCenum; + +/** 32-bit IEEE754 floating-point */ +typedef float ALCfloat; + +/** 64-bit IEEE754 floating-point */ +typedef double ALCdouble; + +/** void type (for opaque pointers only) */ +typedef void ALCvoid; + +// AL typedefs +/** 8-bit boolean */ +typedef char ALboolean; + +/** character */ +typedef char ALchar; + +/** signed 8-bit 2's complement integer */ +typedef char ALbyte; + +/** unsigned 8-bit integer */ +typedef unsigned char ALubyte; + +/** signed 16-bit 2's complement integer */ +typedef short ALshort; + +/** unsigned 16-bit integer */ +typedef unsigned short ALushort; + +/** signed 32-bit 2's complement integer */ +typedef int ALint; + +/** unsigned 32-bit integer */ +typedef unsigned int ALuint; + +/** non-negative 32-bit binary integer size */ +typedef int ALsizei; + +/** enumerated 32-bit value */ +typedef int ALenum; + +/** 32-bit IEEE754 floating-point */ +typedef float ALfloat; + +/** 64-bit IEEE754 floating-point */ +typedef double ALdouble; + +/** void type (for opaque pointers only) */ +typedef void ALvoid; + +void* extal_GetProcAddress(const char* function); +void extal_InitializeClass(JNIEnv *env, jclass clazz, int num_functions, JavaMethodAndExtFunction *functions); + +/* Platform dependent functions */ +void *NativeGetFunctionPointer(const char *function); +void tryLoadLibrary(JNIEnv *env, jstring path); +void UnLoadOpenAL(); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/native/common/extgl.c b/src/native/common/extgl.c new file mode 100644 index 0000000..c965ede --- /dev/null +++ b/src/native/common/extgl.c @@ -0,0 +1,83 @@ +/* ---------------------------------------------------------------------------- +Copyright (c) 2001-2002, Lev Povalahev +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. + * The name of the author 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. +------------------------------------------------------------------------------*/ +/* + Lev Povalahev + + levp@gmx.net + + http://www.uni-karlsruhe.de/~uli2/ + +*/ + +#include +#include +#include "extgl.h" +#include "common_tools.h" + +void extgl_InitializeClass(JNIEnv *env, jclass clazz, int num_functions, JavaMethodAndExtFunction *functions) { + ext_InitializeClass(env, clazz, &extgl_GetProcAddress, num_functions, functions); +} + +bool extgl_InitializeFunctions(int num_functions, ExtFunction *functions) { + return ext_InitializeFunctions(&extgl_GetProcAddress, num_functions, functions); +} + +bool extgl_QueryExtension(const GLubyte*extensions, const char *name) +{ + const GLubyte *start; + GLubyte *where, *terminator; + + if (extensions == NULL) { + printfDebug("NULL extension string\n"); + return false; + } + + /* Extension names should not have spaces. */ + where = (GLubyte *) strchr(name, ' '); + if (where || *name == '\0') + return false; + + /* It takes a bit of care to be fool-proof about parsing the + OpenGL extensions string. Don't be fooled by sub-strings, + etc. */ + start = extensions; + for (;;) + { + where = (GLubyte *) strstr((const char *) start, name); + if (!where) + break; + terminator = where + strlen(name); + if (where == start || *(where - 1) == ' ') + if (*terminator == ' ' || *terminator == '\0') { + return true; + } + start = terminator; + } + return false; + +} + diff --git a/src/native/common/extgl.h b/src/native/common/extgl.h new file mode 100644 index 0000000..de01b10 --- /dev/null +++ b/src/native/common/extgl.h @@ -0,0 +1,146 @@ +/* Small parts were taken from Mesa's glext.h and gl.h, here's the license: */ + +/* + * Mesa 3-D graphics library + * Version: 6.5.1 + * + * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +/* Some parts derived from files copyright (c) 2001-2002 Lev Povalahev under this license: */ + +/* ---------------------------------------------------------------------------- +Copyright (c) 2002, Lev Povalahev +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. + * The name of the author 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. +------------------------------------------------------------------------------*/ +/* + GL_draw_range_elements support added by Benjamin Karaban + + Lev Povalahev contact information: + + levp@gmx.net + + http://www.uni-karlsruhe.de/~uli2/ +*/ + +#ifndef __EXTGL_H__ +#define __EXTGL_H__ + +#include + +#include +#include + +#include "common_tools.h" + +#if defined(_WIN32) || defined(_WIN64) + #include // fix APIENTRY macro redefinition + # define int64_t __int64 + # define uint64_t unsigned __int64 +#endif + +#ifndef APIENTRY +#define APIENTRY +#endif + +#ifdef _MACOSX + typedef unsigned long GLenum; + typedef unsigned char GLboolean; + typedef unsigned long GLbitfield; + typedef signed char GLbyte; + typedef short GLshort; + typedef long GLint; + typedef long GLsizei; + typedef unsigned char GLubyte; + typedef unsigned short GLushort; + typedef unsigned long GLuint; + typedef float GLfloat; + typedef float GLclampf; + typedef double GLdouble; + typedef double GLclampd; + typedef void GLvoid; +#else + typedef unsigned int GLenum; + typedef unsigned char GLboolean; + typedef unsigned int GLbitfield; + typedef void GLvoid; + typedef signed char GLbyte; /* 1-byte signed */ + typedef short GLshort; /* 2-byte signed */ + typedef int GLint; /* 4-byte signed */ + typedef unsigned char GLubyte; /* 1-byte unsigned */ + typedef unsigned short GLushort; /* 2-byte unsigned */ + typedef unsigned int GLuint; /* 4-byte unsigned */ + typedef int GLsizei; /* 4-byte signed */ + typedef float GLfloat; /* single precision float */ + typedef float GLclampf; /* single precision float in [0,1] */ + typedef double GLdouble; /* double precision float */ + typedef double GLclampd; /* double precision float in [0,1] */ +#endif + +typedef char GLchar; /* native character */ + +typedef ptrdiff_t GLintptr; +typedef ptrdiff_t GLsizeiptr; +typedef ptrdiff_t GLintptrARB; +typedef ptrdiff_t GLsizeiptrARB; +typedef char GLcharARB; /* native character */ +typedef unsigned int GLhandleARB; /* shader object handle */ +typedef unsigned short GLhalfARB; +typedef unsigned short GLhalfNV; +typedef unsigned short GLhalf; +typedef int64_t GLint64EXT; +typedef uint64_t GLuint64EXT; +typedef int64_t GLint64; +typedef uint64_t GLuint64; +typedef struct __GLsync *GLsync; + +/* helper stuff */ + +/* initializes everything, call this right after the rc is created. the function returns true if successful */ +extern bool extgl_Open(JNIEnv *env); +extern void extgl_Close(void); +extern void extgl_InitializeClass(JNIEnv *env, jclass clazz, int num_functions, JavaMethodAndExtFunction *functions); +extern bool extgl_InitializeFunctions(int num_functions, ExtFunction *functions); +extern bool extgl_QueryExtension(const GLubyte*extensions, const char *name); +extern void *extgl_GetProcAddress(const char *name); + +#endif /* __EXTGL_H__ */ diff --git a/src/native/common/org_lwjgl_openal_AL.c b/src/native/common/org_lwjgl_openal_AL.c new file mode 100644 index 0000000..67fda88 --- /dev/null +++ b/src/native/common/org_lwjgl_openal_AL.c @@ -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. + */ + +#include +#include "org_lwjgl_openal_AL.h" +#include "extal.h" + +JNIEXPORT void JNICALL Java_org_lwjgl_openal_AL_nCreate(JNIEnv *env, jclass clazz, jstring oalPath) { + tryLoadLibrary(env, oalPath); +} + +JNIEXPORT void JNICALL Java_org_lwjgl_openal_AL_nDestroy(JNIEnv *env, jclass clazz) { + UnLoadOpenAL(); +} + +JNIEXPORT void JNICALL Java_org_lwjgl_openal_AL_resetNativeStubs(JNIEnv *env, jclass clazz, jclass al_class) { + (*env)->UnregisterNatives(env, al_class); +} diff --git a/src/native/common/org_lwjgl_openal_ALC10.c b/src/native/common/org_lwjgl_openal_ALC10.c new file mode 100644 index 0000000..cbf9db3 --- /dev/null +++ b/src/native/common/org_lwjgl_openal_ALC10.c @@ -0,0 +1,315 @@ +/* + * 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. + */ + +/** + * $Id: org_lwjgl_openal_ALC.c 2279 2006-02-23 19:22:00Z elias_naur $ + * + * This is the actual JNI implementation of the OpenAL context/device library. + * + * @author Brian Matzon + * @version $Revision: 2279 $ + */ + +/* OpenAL includes */ +#include "extal.h" + +//alc +typedef ALCubyte* (ALCAPIENTRY *alcGetStringPROC)(ALCdevice *device,ALCenum param); +typedef ALCvoid (ALCAPIENTRY *alcGetIntegervPROC)(ALCdevice *device,ALCenum param,ALCsizei size,ALCint *data); +typedef ALCdevice* (ALCAPIENTRY *alcOpenDevicePROC)(ALCubyte *deviceName); +typedef ALCboolean (ALCAPIENTRY *alcCloseDevicePROC)(ALCdevice *device); +typedef ALCcontext* (ALCAPIENTRY *alcCreateContextPROC)(ALCdevice *device,ALCint *attrList); +typedef ALCenum (ALCAPIENTRY *alcMakeContextCurrentPROC)(ALCcontext *context); +typedef ALCvoid (ALCAPIENTRY *alcProcessContextPROC)(ALCcontext *context); +typedef ALCdevice* (ALCAPIENTRY *alcGetContextsDevicePROC)(ALCcontext *context); +typedef ALCvoid (ALCAPIENTRY *alcSuspendContextPROC)(ALCcontext *context); +typedef ALCvoid (ALCAPIENTRY *alcDestroyContextPROC)(ALCcontext *context); +typedef ALCenum (ALCAPIENTRY *alcGetErrorPROC)(ALCdevice *device); +typedef ALCboolean (ALCAPIENTRY *alcIsExtensionPresentPROC)(ALCdevice *device,ALCubyte *extName); +//typedef ALCvoid* (ALCAPIENTRY *alcGetProcAddressPROC)(ALCdevice *device,ALCubyte *funcName); +typedef ALCenum (ALCAPIENTRY *alcGetEnumValuePROC)(ALCdevice *device,ALCubyte *enumName); +typedef ALCcontext* (ALCAPIENTRY *alcGetCurrentContextPROC)(ALCvoid); + +static alcGetCurrentContextPROC alcGetCurrentContext = NULL; +static alcGetStringPROC alcGetString; +static alcGetIntegervPROC alcGetIntegerv; +static alcOpenDevicePROC alcOpenDevice; +static alcCloseDevicePROC alcCloseDevice; +static alcCreateContextPROC alcCreateContext; +static alcMakeContextCurrentPROC alcMakeContextCurrent; +static alcProcessContextPROC alcProcessContext; +static alcGetContextsDevicePROC alcGetContextsDevice; +static alcSuspendContextPROC alcSuspendContext; +static alcDestroyContextPROC alcDestroyContext; +static alcGetErrorPROC alcGetError; +static alcIsExtensionPresentPROC alcIsExtensionPresent; +//static alcGetProcAddressPROC alcGetProcAddress; +static alcGetEnumValuePROC alcGetEnumValue; + +/** + * This function returns strings related to the context. + * + * C Specification: + * ALubyte * alcGetString(ALCdevice *device, ALenum token); + */ +static jstring JNICALL Java_org_lwjgl_openal_ALC10_nalcGetString (JNIEnv *env, jclass clazz, jlong deviceaddress, jint token) { + const char* alcString = (const char*) alcGetString((ALCdevice*)((intptr_t)deviceaddress), (ALenum) token); + int length; + int i=1; + + if(alcString == NULL) { + return NULL; + } + + // Special treatment of enumeration tokens + // These are encoded using \0 between elements and a finishing \0\0 + switch(token) { + case 0x1005: // ALC_DEVICE_SPECIFIER + case 0x310: // ALC_CAPTURE_DEVICE_SPECIFIER + case 0x1013: // ALC_ALL_DEVICES_SPECIFIER + while (alcString[i - 1] != '\0' || alcString[i] != '\0') { + i++; + } + length = i + 1; + break; + default: + length = strlen(alcString); + } + return NewStringNativeWithLength(env, alcString, length); +} + +/** + * This function returns integers related to the context. + * + * C Specification: + * ALvoid alcGetIntegerv(ALCdevice *device, ALenum token, ALsizei size, ALint *dest); + */ +static void JNICALL Java_org_lwjgl_openal_ALC10_nalcGetIntegerv (JNIEnv *env, jclass clazz, jlong deviceaddress, jint token, jint size, jobject dest, jint offset) { + ALint* address = NULL; + if (dest != NULL) { + address = offset + (ALint*) (*env)->GetDirectBufferAddress(env, dest); + } + alcGetIntegerv((ALCdevice*)((intptr_t)deviceaddress), (ALenum) token, (ALsizei) size, address); +} + +/** + * This function opens a device by name. + * + * C Specification: + * ALCdevice *alcOpenDevice( const ALubyte *tokstr ); + */ +static jlong JNICALL Java_org_lwjgl_openal_ALC10_nalcOpenDevice (JNIEnv *env, jclass clazz, jstring tokstr) { + char * tokenstring; + ALCdevice* device; + + if(tokstr != NULL) { + tokenstring = GetStringNativeChars(env, tokstr); + } else { + tokenstring = NULL; + } + + /* get device */ + device = alcOpenDevice((ALubyte *) tokenstring); + + if(tokenstring != NULL) { + free(tokenstring); + } + + return (jlong)((intptr_t)device); +} + +/** + * This function closes a device by name. + * + * C Specification: + * bool alcCloseDevice( ALCdevice *dev ); + */ +static jboolean JNICALL Java_org_lwjgl_openal_ALC10_nalcCloseDevice (JNIEnv *env, jclass clazz, jlong deviceaddress) { + return alcCloseDevice((ALCdevice*)((intptr_t)deviceaddress)); +} + +/** + * This function creates a context using a specified device. + * + * C Specification: + * ALCcontext* alcCreateContext( ALCdevice *dev, ALint* attrlist ); + */ +static jlong JNICALL Java_org_lwjgl_openal_ALC10_nalcCreateContext (JNIEnv *env, jclass clazz, jlong deviceaddress, jobject attrlist) { + ALint* address = NULL; + ALCcontext* context; + + if (attrlist != NULL) { + address = (ALint*) safeGetBufferAddress(env, attrlist); + } + context = alcCreateContext((ALCdevice*)((intptr_t)deviceaddress), address); + + return (jlong)((intptr_t)context); +} + +/** + * This function makes a specified context the current context. + * + * C Specification: + * ALCboolean alcMakeContextCurrent(ALCcontext *context); + */ +static jint JNICALL Java_org_lwjgl_openal_ALC10_nalcMakeContextCurrent (JNIEnv *env, jclass clazz, jlong contextaddress) { + ALCcontext* context = (ALCcontext*)((intptr_t)contextaddress); + return alcMakeContextCurrent(context); +} + +/** + * This function tells a context to begin processing. + * + * C Specification: + * void alcProcessContext(ALCcontext *context); + */ +static void JNICALL Java_org_lwjgl_openal_ALC10_nalcProcessContext (JNIEnv *env, jclass clazz, jlong contextaddress) { + alcProcessContext((ALCcontext*)((intptr_t)contextaddress)); +} + +/** + * This function retrieves the current context. + * + * C Specification: + * ALCcontext* alcGetCurrentContext( ALvoid ); + */ +static jlong JNICALL Java_org_lwjgl_openal_ALC10_nalcGetCurrentContext (JNIEnv *env, jclass clazz) { + ALCcontext* context = alcGetCurrentContext(); + return (jlong)((intptr_t)context); +} + +/** + * This function retrieves the specified contexts device + * + * C Specification: + * ALCdevice* alcGetContextsDevice(ALCcontext *context); + */ +static jlong JNICALL Java_org_lwjgl_openal_ALC10_nalcGetContextsDevice (JNIEnv *env, jclass clazz, jlong contextaddress) { + ALCdevice* device = alcGetContextsDevice((ALCcontext*)((intptr_t)contextaddress)); + return (jlong)((intptr_t)device); +} + +/** + * This function suspends processing on a specified context. + * + * C Specification: + * void alcSuspendContext(ALCcontext *context); + */ +static void JNICALL Java_org_lwjgl_openal_ALC10_nalcSuspendContext (JNIEnv *env, jclass clazz, jlong contextaddress) { + alcSuspendContext((ALCcontext*)((intptr_t)contextaddress)); +} + +/** + * This function destroys a context. + * + * C Specification: + * void alcDestroyContext(ALCcontext *context); + */ +static void JNICALL Java_org_lwjgl_openal_ALC10_nalcDestroyContext (JNIEnv *env, jclass clazz, jlong contextaddress) { + alcDestroyContext((ALCcontext*)((intptr_t)contextaddress)); +} + +/** + * This function retrieves the specified devices context error state. + * + * C Specification: + * ALCenum alcGetError(ALCdevice *device); + */ +static jint JNICALL Java_org_lwjgl_openal_ALC10_nalcGetError (JNIEnv *env, jclass clazz, jlong deviceaddress) { + return alcGetError((ALCdevice*)((intptr_t)deviceaddress)); +} + +/** + * This function queries if a specified context extension is available. + * + * C Specification: + * ALboolean alcIsExtensionPresent(ALCdevice *device, ALubyte *extName); + */ +static jboolean JNICALL Java_org_lwjgl_openal_ALC10_nalcIsExtensionPresent (JNIEnv *env, jclass clazz, jlong deviceaddress, jstring extName) { + /* get extension */ + ALubyte* functionname = (ALubyte*) GetStringNativeChars(env, extName); + + jboolean result = (jboolean) alcIsExtensionPresent((ALCdevice*)((intptr_t)deviceaddress), functionname); + + free(functionname); + + return result; +} + +/** + * This function retrieves the enum value for a specified enumeration name. + * + * C Specification: + * ALenum alcGetEnumValue(ALCdevice *device, ALubyte *enumName); + */ +static jint JNICALL Java_org_lwjgl_openal_ALC10_nalcGetEnumValue (JNIEnv *env, jclass clazz, jlong deviceaddress, jstring enumName) { + /* get extension */ + ALubyte* enumerationname = (ALubyte*) GetStringNativeChars(env, enumName); + + jint result = (jint) alcGetEnumValue((ALCdevice*)((intptr_t)deviceaddress), enumerationname); + + free(enumerationname); + + return result; +} + +/** + * Loads the context OpenAL functions + * + * @return true if all methods were loaded, false if one of the methods could not be loaded + */ +#ifdef __cplusplus +extern "C" { +#endif +JNIEXPORT void JNICALL Java_org_lwjgl_openal_ALC10_initNativeStubs(JNIEnv *env, jclass clazz) { + JavaMethodAndExtFunction functions[] = { + {"nalcGetString", "(JI)Ljava/lang/String;", (void*)&Java_org_lwjgl_openal_ALC10_nalcGetString, "alcGetString", (void*)&alcGetString}, + {"nalcGetIntegerv", "(JIILjava/nio/Buffer;I)V", (void*)&Java_org_lwjgl_openal_ALC10_nalcGetIntegerv, "alcGetIntegerv", (void*)&alcGetIntegerv}, + {"nalcOpenDevice", "(Ljava/lang/String;)J", (void*)&Java_org_lwjgl_openal_ALC10_nalcOpenDevice, "alcOpenDevice", (void*)&alcOpenDevice}, + {"nalcCloseDevice", "(J)Z", (void*)&Java_org_lwjgl_openal_ALC10_nalcCloseDevice, "alcCloseDevice", (void*)&alcCloseDevice}, + {"nalcCreateContext", "(JLjava/nio/IntBuffer;)J", (void*)&Java_org_lwjgl_openal_ALC10_nalcCreateContext, "alcCreateContext", (void*)&alcCreateContext}, + {"nalcMakeContextCurrent", "(J)I", (void*)&Java_org_lwjgl_openal_ALC10_nalcMakeContextCurrent, "alcMakeContextCurrent", (void*)&alcMakeContextCurrent}, + {"nalcProcessContext", "(J)V", (void*)&Java_org_lwjgl_openal_ALC10_nalcProcessContext, "alcProcessContext", (void*)&alcProcessContext}, + {"nalcGetCurrentContext", "()J", (void*)&Java_org_lwjgl_openal_ALC10_nalcGetCurrentContext, "alcGetCurrentContext", (void*)&alcGetCurrentContext}, + {"nalcGetContextsDevice", "(J)J", (void*)&Java_org_lwjgl_openal_ALC10_nalcGetContextsDevice, "alcGetContextsDevice", (void*)&alcGetContextsDevice}, + {"nalcSuspendContext", "(J)V", (void*)&Java_org_lwjgl_openal_ALC10_nalcSuspendContext, "alcSuspendContext", (void*)&alcSuspendContext}, + {"nalcDestroyContext", "(J)V", (void*)&Java_org_lwjgl_openal_ALC10_nalcDestroyContext, "alcDestroyContext", (void*)&alcDestroyContext}, + {"nalcGetError", "(J)I", (void*)&Java_org_lwjgl_openal_ALC10_nalcGetError, "alcGetError", (void*)&alcGetError}, + {"nalcIsExtensionPresent", "(JLjava/lang/String;)Z", (void*)&Java_org_lwjgl_openal_ALC10_nalcIsExtensionPresent, "alcIsExtensionPresent", (void*)&alcIsExtensionPresent}, + {"nalcGetEnumValue", "(JLjava/lang/String;)I", (void*)&Java_org_lwjgl_openal_ALC10_nalcGetEnumValue, "alcGetEnumValue", (void*)&alcGetEnumValue} + }; + int num_functions = NUMFUNCTIONS(functions); + extal_InitializeClass(env, clazz, num_functions, functions); +} +#ifdef __cplusplus +} +#endif diff --git a/src/native/common/org_lwjgl_openal_ALC11.c b/src/native/common/org_lwjgl_openal_ALC11.c new file mode 100644 index 0000000..a67396e --- /dev/null +++ b/src/native/common/org_lwjgl_openal_ALC11.c @@ -0,0 +1,135 @@ +/* + * 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. + */ + +/** + * $Id: org_lwjgl_openal_ALC.c 2279 2006-02-23 19:22:00Z elias_naur $ + * + * This is the actual JNI implementation of the OpenAL context/device library. + * + * @author Brian Matzon + * @version $Revision: 2279 $ + */ + +/* OpenAL includes */ +#include "extal.h" + +//alc +typedef ALCdevice * (ALCAPIENTRY *alcCaptureOpenDevicePROC)( const ALCchar *devicename, ALCuint frequency, ALCenum format, ALCsizei buffersize ); +typedef ALCboolean (ALCAPIENTRY *alcCaptureCloseDevicePROC)( ALCdevice *device ); +typedef void (ALCAPIENTRY *alcCaptureStartPROC)( ALCdevice *device ); +typedef void (ALCAPIENTRY *alcCaptureStopPROC)( ALCdevice *device ); +typedef void (ALCAPIENTRY *alcCaptureSamplesPROC)( ALCdevice *device, ALCvoid *buffer, ALCsizei samples ); + +static alcCaptureOpenDevicePROC alcCaptureOpenDevice; +static alcCaptureCloseDevicePROC alcCaptureCloseDevice; +static alcCaptureStartPROC alcCaptureStart; +static alcCaptureStopPROC alcCaptureStop; +static alcCaptureSamplesPROC alcCaptureSamples; + +/* + * Class: org_lwjgl_openal_ALC11 + * Method: nalcCaptureOpenDevice + * Signature: (Ljava/lang/String;III)J + */ +static jlong JNICALL Java_org_lwjgl_openal_ALC11_nalcCaptureOpenDevice(JNIEnv *env, jclass clazz, jstring devicename, jint frequency, jint format, jint buffersize) { + ALubyte* dev_name = NULL; + ALCdevice* device = NULL; + + if(devicename != NULL) { + dev_name = (ALubyte*) GetStringNativeChars(env, devicename); + } + + device = alcCaptureOpenDevice((const char *)dev_name, (unsigned int) frequency, format, buffersize); + + free(dev_name); + return (jlong) ((intptr_t)device); +} + +/* + * Class: org_lwjgl_openal_ALC11 + * Method: nalcCaptureCloseDevice + * Signature: (J)Z + */ +static jboolean JNICALL Java_org_lwjgl_openal_ALC11_nalcCaptureCloseDevice(JNIEnv *env, jclass clazz, jlong device) { + return (jboolean) alcCaptureCloseDevice((ALCdevice*) ((intptr_t)device)); +} + +/* + * Class: org_lwjgl_openal_ALC11 + * Method: nalcCaptureStart + * Signature: (J)V + */ +static void JNICALL Java_org_lwjgl_openal_ALC11_nalcCaptureStart(JNIEnv *env, jclass clazz, jlong device) { + alcCaptureStart((ALCdevice*) ((intptr_t)device)); +} + +/* + * Class: org_lwjgl_openal_ALC11 + * Method: nalcCaptureStop + * Signature: (J)V + */ +static void JNICALL Java_org_lwjgl_openal_ALC11_nalcCaptureStop(JNIEnv * env, jclass clazz, jlong device) { + alcCaptureStop((ALCdevice*) ((intptr_t)device)); +} + +/* + * Class: org_lwjgl_openal_ALC11 + * Method: nalcCaptureSamples + * Signature: (JLjava/nio/ByteBuffer;I)V + */ +static void JNICALL Java_org_lwjgl_openal_ALC11_nalcCaptureSamples(JNIEnv *env, jclass clazz, jlong device, jobject buffer, jint position, jint samples) { + ALvoid *buffer_address = ((ALbyte *)(((char*)(*env)->GetDirectBufferAddress(env, buffer)) + position)); + alcCaptureSamples((ALCdevice*) ((intptr_t)device), buffer_address, samples); +} + +/** + * Loads the context OpenAL functions + * + * @return true if all methods were loaded, false if one of the methods could not be loaded + */ +#ifdef __cplusplus +extern "C" { +#endif +JNIEXPORT void JNICALL Java_org_lwjgl_openal_ALC11_initNativeStubs(JNIEnv *env, jclass clazz) { + JavaMethodAndExtFunction functions[] = { + {"nalcCaptureOpenDevice", "(Ljava/lang/String;III)J", (void*)&Java_org_lwjgl_openal_ALC11_nalcCaptureOpenDevice, "alcCaptureOpenDevice", (void*)&alcCaptureOpenDevice}, + {"nalcCaptureCloseDevice", "(J)Z", (void*)&Java_org_lwjgl_openal_ALC11_nalcCaptureCloseDevice, "alcCaptureCloseDevice", (void*)&alcCaptureCloseDevice}, + {"nalcCaptureStart", "(J)V", (void*)&Java_org_lwjgl_openal_ALC11_nalcCaptureStart, "alcCaptureStart", (void*)&alcCaptureStart}, + {"nalcCaptureStop", "(J)V", (void*)&Java_org_lwjgl_openal_ALC11_nalcCaptureStop, "alcCaptureStop", (void*)&alcCaptureStop}, + {"nalcCaptureSamples", "(JLjava/nio/ByteBuffer;II)V", (void*)&Java_org_lwjgl_openal_ALC11_nalcCaptureSamples, "alcCaptureSamples", (void*)&alcCaptureSamples} + }; + int num_functions = NUMFUNCTIONS(functions); + extal_InitializeClass(env, clazz, num_functions, functions); +} +#ifdef __cplusplus +} +#endif diff --git a/src/native/common/org_lwjgl_opengl_AWTSurfaceLock.c b/src/native/common/org_lwjgl_opengl_AWTSurfaceLock.c new file mode 100644 index 0000000..83b945c --- /dev/null +++ b/src/native/common/org_lwjgl_opengl_AWTSurfaceLock.c @@ -0,0 +1,94 @@ +/* + * 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. + */ + +/** + * $Id: org_lwjgl_opengl_AWTSurfaceLock.c 2985 2008-04-07 18:42:36Z matzon $ + * + * @author elias_naur + * @version $Revision: 2985 $ + */ + +#include +#include +#include "org_lwjgl_opengl_AWTSurfaceLock.h" +#include "awt_tools.h" +#include "common_tools.h" + +JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_AWTSurfaceLock_createHandle + (JNIEnv *env, jclass clazz) { + return newJavaManagedByteBuffer(env, sizeof(AWTSurfaceLock)); +} + +JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_AWTSurfaceLock_lockAndInitHandle + (JNIEnv *env, jclass clazz, jobject lock_buffer_handle, jobject canvas) { + JAWT awt; + JAWT_DrawingSurface* ds; + JAWT_DrawingSurfaceInfo *dsi; + AWTSurfaceLock *awt_lock = (AWTSurfaceLock *)(*env)->GetDirectBufferAddress(env, lock_buffer_handle); + awt.version = JAWT_VERSION_1_4; + if (JAWT_GetAWT(env, &awt) == JNI_FALSE) { + throwException(env, "Could not get the JAWT interface"); + return JNI_FALSE; + } + + ds = awt.GetDrawingSurface(env, canvas); + if (ds == NULL) { + throwException(env, "Could not get the drawing surface"); + return JNI_FALSE; + } + + if((ds->Lock(ds) & JAWT_LOCK_ERROR) != 0) { + awt.FreeDrawingSurface(ds); + throwException(env, "Could not lock the drawing surface"); + return JNI_FALSE; + } + + dsi = ds->GetDrawingSurfaceInfo(ds); + if (dsi != NULL) { + awt_lock->awt = awt; + awt_lock->ds = ds; + awt_lock->dsi = dsi; + return JNI_TRUE; + } + ds->Unlock(ds); + awt.FreeDrawingSurface(ds); + return JNI_FALSE; +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_AWTSurfaceLock_nUnlock + (JNIEnv *env, jclass clazz, jobject lock_buffer_handle) { + AWTSurfaceLock *awt_lock = (AWTSurfaceLock *)(*env)->GetDirectBufferAddress(env, lock_buffer_handle); + awt_lock->ds->FreeDrawingSurfaceInfo(awt_lock->dsi); + awt_lock->ds->Unlock(awt_lock->ds); + awt_lock->awt.FreeDrawingSurface(awt_lock->ds); +} + diff --git a/src/native/common/org_lwjgl_opengl_GLContext.c b/src/native/common/org_lwjgl_opengl_GLContext.c new file mode 100644 index 0000000..2c9b178 --- /dev/null +++ b/src/native/common/org_lwjgl_opengl_GLContext.c @@ -0,0 +1,57 @@ +/* + * 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. + */ + +#include +#include "common_tools.h" +#include "org_lwjgl_opengl_GLContext.h" +#include "extgl.h" + +JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_GLContext_getFunctionAddress(JNIEnv *env, jclass clazz, jstring function_name) { + jlong address_jlong; + char *function_name_pointer = GetStringNativeChars(env, function_name); + void *address = extgl_GetProcAddress(function_name_pointer); + free(function_name_pointer); + address_jlong = (jlong)(intptr_t)address; + return address_jlong; +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_GLContext_nLoadOpenGLLibrary(JNIEnv * env, jclass clazz) { + extgl_Open(env); +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_GLContext_nUnloadOpenGLLibrary(JNIEnv * env, jclass clazz) { + extgl_Close(); +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_GLContext_resetNativeStubs(JNIEnv *env, jclass clazz, jclass gl_class) { + (*env)->UnregisterNatives(env, gl_class); +} diff --git a/src/native/linux/context.c b/src/native/linux/context.c new file mode 100644 index 0000000..727b706 --- /dev/null +++ b/src/native/linux/context.c @@ -0,0 +1,347 @@ +/* + * 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. + */ + +/** + * $Id: context.c 3116 2008-08-19 16:46:03Z spasi $ + * + * Include file to access public window features + * + * @author elias_naur + * @version $Revision: 3116 $ + */ + +#include +#include +#include +#include +#include "extgl_glx.h" +#include "context.h" + +XVisualInfo *getVisualInfoFromPeerInfo(JNIEnv *env, X11PeerInfo *peer_info) { + XVisualInfo *vis_info; + if (!peer_info->glx13) { + XVisualInfo template; + template.visualid = peer_info->config.glx_config.visualid; + template.depth = peer_info->config.glx_config.depth; + template.screen = peer_info->screen; + int num_infos; + vis_info = XGetVisualInfo(peer_info->display, VisualIDMask | VisualScreenMask | VisualDepthMask, &template, &num_infos); + if (vis_info == NULL) { + throwException(env, "Could not find VisualInfo from peer info"); + return NULL; + } + // Check the assumption from GLX 1.3 docs that a VisualInfo is uniquely identified by its + // {VisualID, screen, depth} tuple + if (num_infos != 1) { + XFree(vis_info); + throwException(env, "No unique VisualInfo matches peer info"); + return NULL; + } + } else { + GLXFBConfig *configs = getFBConfigFromPeerInfo(env, peer_info); + if (configs == NULL) + return NULL; + vis_info = lwjgl_glXGetVisualFromFBConfig(peer_info->display, configs[0]); + if (vis_info == NULL) + throwException(env, "Could not get VisualInfo from GLX 1.3 config"); + XFree(configs); + } + return vis_info; +} + +GLXFBConfig *getFBConfigFromPeerInfo(JNIEnv *env, X11PeerInfo *peer_info) { + int attribs[] = {GLX_FBCONFIG_ID, peer_info->config.glx13_config.config_id, None, None}; + int num_elements; + GLXFBConfig *configs = lwjgl_glXChooseFBConfig(peer_info->display, peer_info->screen, attribs, &num_elements); + if (configs == NULL) { + throwException(env, "Could not find GLX 1.3 config from peer info"); + return NULL; + } + // Check that only one FBConfig matches the config id + if (num_elements != 1) { + XFree(configs); + throwException(env, "No unique GLX 1.3 config matches peer info"); + return NULL; + } + return configs; +} + +static int convertToBPE(int bpp) { + int bpe; + switch (bpp) { + case 0: + bpe = 0; + break; + case 32: + case 24: + bpe = 8; + break; + case 16: /* Fall through */ + default: + bpe = 4; + break; + } + return bpe; +} + +static GLXFBConfig *chooseVisualGLX13FromBPP(JNIEnv *env, Display *disp, int screen, jobject pixel_format, int bpp, int drawable_type, bool double_buffer) { + jclass cls_pixel_format = (*env)->GetObjectClass(env, pixel_format); + int alpha = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "alpha", "I")); + int depth = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "depth", "I")); + int stencil = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "stencil", "I")); + int samples = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "samples", "I")); + int num_aux_buffers = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "num_aux_buffers", "I")); + int accum_bpp = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "accum_bpp", "I")); + int accum_alpha = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "accum_alpha", "I")); + + bool stereo = (bool)(*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "stereo", "Z")); + bool floating_point = (bool)(*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "floating_point", "Z")); + bool floating_point_packed = (bool)(*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "floating_point_packed", "Z")); + bool sRGB = (bool)(*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "sRGB", "Z")); + + int bpe = convertToBPE(bpp); + int accum_bpe = convertToBPE(accum_bpp); + attrib_list_t attrib_list; + initAttribList(&attrib_list); + int render_type; + + if ( floating_point ) + render_type = GLX_RGBA_FLOAT_BIT; + else if ( floating_point_packed ) + render_type = GLX_RGBA_UNSIGNED_FLOAT_BIT_EXT; + else + render_type = GLX_RGBA_BIT; + + putAttrib(&attrib_list, GLX_RENDER_TYPE); putAttrib(&attrib_list, render_type); + putAttrib(&attrib_list, GLX_DOUBLEBUFFER); putAttrib(&attrib_list, double_buffer ? True : False); + putAttrib(&attrib_list, GLX_DRAWABLE_TYPE); putAttrib(&attrib_list, drawable_type); + putAttrib(&attrib_list, GLX_DEPTH_SIZE); putAttrib(&attrib_list, depth); + putAttrib(&attrib_list, GLX_RED_SIZE); putAttrib(&attrib_list, bpe); + putAttrib(&attrib_list, GLX_GREEN_SIZE); putAttrib(&attrib_list, bpe); + putAttrib(&attrib_list, GLX_BLUE_SIZE); putAttrib(&attrib_list, bpe); + putAttrib(&attrib_list, GLX_ALPHA_SIZE); putAttrib(&attrib_list, alpha); + putAttrib(&attrib_list, GLX_STENCIL_SIZE); putAttrib(&attrib_list, stencil); + putAttrib(&attrib_list, GLX_AUX_BUFFERS); putAttrib(&attrib_list, num_aux_buffers); + putAttrib(&attrib_list, GLX_ACCUM_RED_SIZE); putAttrib(&attrib_list, accum_bpe); + putAttrib(&attrib_list, GLX_ACCUM_GREEN_SIZE); putAttrib(&attrib_list, accum_bpe); + putAttrib(&attrib_list, GLX_ACCUM_BLUE_SIZE); putAttrib(&attrib_list, accum_bpe); + putAttrib(&attrib_list, GLX_ACCUM_ALPHA_SIZE); putAttrib(&attrib_list, accum_alpha); + if (stereo) { + putAttrib(&attrib_list, GLX_STEREO); putAttrib(&attrib_list, True); + } + // Assume the caller has checked support for multisample + if (samples > 0) { + putAttrib(&attrib_list, GLX_SAMPLE_BUFFERS_ARB); putAttrib(&attrib_list, 1); + putAttrib(&attrib_list, GLX_SAMPLES_ARB); putAttrib(&attrib_list, samples); + } + if (sRGB) { + putAttrib(&attrib_list, GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB); putAttrib(&attrib_list, True); + } + putAttrib(&attrib_list, None); putAttrib(&attrib_list, None); + int num_formats = 0; + GLXFBConfig* configs = lwjgl_glXChooseFBConfig(disp, screen, attrib_list.attribs, &num_formats); + if (num_formats > 0) { + return configs; + } else { + if (configs != NULL) + XFree(configs); + return NULL; + } +} + +GLXFBConfig *chooseVisualGLX13(JNIEnv *env, Display *disp, int screen, jobject pixel_format, bool use_display_bpp, int drawable_type, bool double_buffer) { + jclass cls_pixel_format = (*env)->GetObjectClass(env, pixel_format); + int bpp; + if (use_display_bpp) { + bpp = XDefaultDepthOfScreen(XScreenOfDisplay(disp, screen)); + GLXFBConfig *configs = chooseVisualGLX13FromBPP(env, disp, screen, pixel_format, bpp, drawable_type, double_buffer); + if (configs != NULL) + return configs; + else + bpp = 16; + } else + bpp = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "bpp", "I")); + return chooseVisualGLX13FromBPP(env, disp, screen, pixel_format, bpp, drawable_type, double_buffer); +} + +static XVisualInfo *chooseVisualGLXFromBPP(JNIEnv *env, Display *disp, int screen, jobject pixel_format, int bpp, bool double_buffer) { + jclass cls_pixel_format = (*env)->GetObjectClass(env, pixel_format); + int alpha = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "alpha", "I")); + int depth = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "depth", "I")); + int stencil = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "stencil", "I")); + int samples = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "samples", "I")); + int num_aux_buffers = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "num_aux_buffers", "I")); + int accum_bpp = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "accum_bpp", "I")); + int accum_alpha = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "accum_alpha", "I")); + + bool stereo = (bool)(*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "stereo", "Z")); + bool sRGB = (bool)(*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "sRGB", "Z")); + + int bpe = convertToBPE(bpp); + int accum_bpe = convertToBPE(accum_bpp); + attrib_list_t attrib_list; + initAttribList(&attrib_list); + putAttrib(&attrib_list, GLX_RGBA); + putAttrib(&attrib_list, GLX_DOUBLEBUFFER); + putAttrib(&attrib_list, GLX_DEPTH_SIZE); putAttrib(&attrib_list, depth); + putAttrib(&attrib_list, GLX_RED_SIZE); putAttrib(&attrib_list, bpe); + putAttrib(&attrib_list, GLX_GREEN_SIZE); putAttrib(&attrib_list, bpe); + putAttrib(&attrib_list, GLX_BLUE_SIZE); putAttrib(&attrib_list, bpe); + putAttrib(&attrib_list, GLX_ALPHA_SIZE); putAttrib(&attrib_list, alpha); + putAttrib(&attrib_list, GLX_STENCIL_SIZE); putAttrib(&attrib_list, stencil); + putAttrib(&attrib_list, GLX_AUX_BUFFERS); putAttrib(&attrib_list, num_aux_buffers); + putAttrib(&attrib_list, GLX_ACCUM_RED_SIZE); putAttrib(&attrib_list, accum_bpe); + putAttrib(&attrib_list, GLX_ACCUM_GREEN_SIZE); putAttrib(&attrib_list, accum_bpe); + putAttrib(&attrib_list, GLX_ACCUM_BLUE_SIZE); putAttrib(&attrib_list, accum_bpe); + putAttrib(&attrib_list, GLX_ACCUM_ALPHA_SIZE); putAttrib(&attrib_list, accum_alpha); + if (stereo) + putAttrib(&attrib_list, GLX_STEREO); + // Assume the caller has checked support for multisample + if (samples > 0) { + putAttrib(&attrib_list, GLX_SAMPLE_BUFFERS_ARB); putAttrib(&attrib_list, 1); + putAttrib(&attrib_list, GLX_SAMPLES_ARB); putAttrib(&attrib_list, samples); + } + if (sRGB) + putAttrib(&attrib_list, GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB); + putAttrib(&attrib_list, None); + return lwjgl_glXChooseVisual(disp, screen, attrib_list.attribs); +} + +XVisualInfo *chooseVisualGLX(JNIEnv *env, Display *disp, int screen, jobject pixel_format, bool use_display_bpp, bool double_buffer) { + jclass cls_pixel_format = (*env)->GetObjectClass(env, pixel_format); + int bpp; + if (use_display_bpp) { + bpp = XDefaultDepthOfScreen(XScreenOfDisplay(disp, screen)); + XVisualInfo *vis_info = chooseVisualGLXFromBPP(env, disp, screen, pixel_format, bpp, double_buffer); + if (vis_info != NULL) + return vis_info; + else + bpp = 16; + } else + bpp = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "bpp", "I")); + return chooseVisualGLXFromBPP(env, disp, screen, pixel_format, bpp, double_buffer); +} + +static void dumpVisualInfo(JNIEnv *env, Display *display, GLXExtensions *extension_flags, XVisualInfo *vis_info) { + int alpha, depth, stencil, r, g, b; + int sample_buffers = 0; + int samples = 0; + lwjgl_glXGetConfig(display, vis_info, GLX_RED_SIZE, &r); + lwjgl_glXGetConfig(display, vis_info, GLX_GREEN_SIZE, &g); + lwjgl_glXGetConfig(display, vis_info, GLX_BLUE_SIZE, &b); + lwjgl_glXGetConfig(display, vis_info, GLX_ALPHA_SIZE, &alpha); + lwjgl_glXGetConfig(display, vis_info, GLX_DEPTH_SIZE, &depth); + lwjgl_glXGetConfig(display, vis_info, GLX_STENCIL_SIZE, &stencil); + if (extension_flags->GLX_ARB_multisample) { + lwjgl_glXGetConfig(display, vis_info, GLX_SAMPLE_BUFFERS_ARB, &sample_buffers); + lwjgl_glXGetConfig(display, vis_info, GLX_SAMPLES_ARB, &samples); + } + printfDebugJava(env, "Pixel format info: r = %d, g = %d, b = %d, a = %d, depth = %d, stencil = %d, sample buffers = %d, samples = %d", r, g, b, alpha, depth, stencil, sample_buffers, samples); +} + +bool initPeerInfo(JNIEnv *env, jobject peer_info_handle, Display *display, int screen, jobject pixel_format, bool use_display_bpp, int drawable_type, bool double_buffered, bool force_glx13) { + if ((*env)->GetDirectBufferCapacity(env, peer_info_handle) < sizeof(X11PeerInfo)) { + throwException(env, "Handle too small"); + return false; + } + X11PeerInfo *peer_info = (*env)->GetDirectBufferAddress(env, peer_info_handle); + GLXExtensions extension_flags; + if (!extgl_InitGLX(display, screen, &extension_flags)) { + throwException(env, "Could not init GLX"); + return false; + } + if (!extension_flags.GLX13 && force_glx13) { + throwException(env, "GLX13 is required, but is not available"); + return false; + } + jclass cls_pixel_format = (*env)->GetObjectClass(env, pixel_format); + int samples = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "samples", "I")); + if (samples > 0 && !extension_flags.GLX_ARB_multisample) { + throwException(env, "Samples > 0 specified but there's no support for GLX_ARB_multisample"); + return false; + } + bool floating_point = (bool)(*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "floating_point", "Z")); + if (floating_point && !(extension_flags.GLX13 && extension_flags.GLX_ARB_fbconfig_float)) { // We need GLX13 to support floating point + throwException(env, "Floating point specified but there's no support for GLX_ARB_fbconfig_float"); + return false; + } + bool floating_point_packed = (bool)(*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "floating_point_packed", "Z")); + if (floating_point_packed && !(extension_flags.GLX13 && extension_flags.GLX_EXT_fbconfig_packed_float)) { // We need GLX13 to support packed floating point + throwException(env, "Packed floating point specified but there's no support for GLX_EXT_fbconfig_packed_float"); + return false; + } + bool sRGB = (bool)(*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "sRGB", "Z")); + if (sRGB && !extension_flags.GLX_ARB_framebuffer_sRGB) { + throwException(env, "sRGB specified but there's no support for GLX_ARB_framebuffer_sRGB"); + return false; + } + + peer_info->glx13 = extension_flags.GLX13; + if (peer_info->glx13) { + GLXFBConfig *configs = chooseVisualGLX13(env, display, screen, pixel_format, use_display_bpp, drawable_type, double_buffered); + if (configs == NULL) { + throwException(env, "Could not choose GLX13 config"); + return false; + } + if (isDebugEnabled()) { + XVisualInfo *vis_info = lwjgl_glXGetVisualFromFBConfig(display, configs[0]); + if (vis_info != NULL) { + dumpVisualInfo(env, display, &extension_flags, vis_info); + XFree(vis_info); + } + } + int config_id; + int result = lwjgl_glXGetFBConfigAttrib(display, configs[0], GLX_FBCONFIG_ID, &config_id); + XFree(configs); + if (result != Success) { + throwException(env, "Could not get GLX_FBCONFIG_ID from GLXFBConfig"); + return false; + } + peer_info->config.glx13_config.config_id = config_id; + } else { + XVisualInfo *vis_info = chooseVisualGLX(env, display, screen, pixel_format, use_display_bpp, double_buffered); + if (vis_info == NULL) { + throwException(env, "Could not choose visual"); + return false; + } + peer_info->config.glx_config.visualid = vis_info->visualid; + peer_info->config.glx_config.depth = vis_info->depth; + peer_info->screen = vis_info->screen; + if (isDebugEnabled()) + dumpVisualInfo(env, display, &extension_flags, vis_info); + XFree(vis_info); + } + peer_info->display = display; + peer_info->screen = screen; + peer_info->drawable = None; + return true; +} diff --git a/src/native/linux/context.h b/src/native/linux/context.h new file mode 100644 index 0000000..476d904 --- /dev/null +++ b/src/native/linux/context.h @@ -0,0 +1,83 @@ +/* + * 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. + */ + +/** + * $Id: context.h 2985 2008-04-07 18:42:36Z matzon $ + * + * Include file to access public window features + * + * @author elias_naur + * @version $Revision: 2985 $ + */ + +#ifndef _LWJGL_CONTEXT_H_INCLUDED_ +#define _LWJGL_CONTEXT_H_INCLUDED_ + +#include +#include +#include +#include +#include "extgl_glx.h" + +typedef struct { + VisualID visualid; + int depth; +} GLXConfig; + +typedef struct { + GLXFBConfigID config_id; +} GLX13Config; + +typedef struct { + Display *display; + int screen; + GLXDrawable drawable; + // This flag determines the appropriate glx struct + bool glx13; + union { + GLXConfig glx_config; + GLX13Config glx13_config; + } config; +} X11PeerInfo; + +/* GLX 1.3 chooser */ +extern GLXFBConfig *chooseVisualGLX13(JNIEnv *env, Display *disp, int screen, jobject pixel_format, bool use_display_bpp, int drawable_type, bool double_buffer); + +/* Default GLX chooser*/ +extern XVisualInfo *chooseVisualGLX(JNIEnv *env, Display *disp, int screen, jobject pixel_format, bool use_display_bpp, bool double_buffer); + +extern XVisualInfo *getVisualInfoFromPeerInfo(JNIEnv *env, X11PeerInfo *peer_info); +extern GLXFBConfig *getFBConfigFromPeerInfo(JNIEnv *env, X11PeerInfo *peer_info); + +extern bool initPeerInfo(JNIEnv *env, jobject peer_info_handle, Display *display, int screen, jobject pixel_format, bool use_display_bpp, int drawable_type, bool double_buffered, bool force_glx13); + +#endif /* _LWJGL_CONTEXT_H_INCLUDED_ */ diff --git a/src/native/linux/display.c b/src/native/linux/display.c new file mode 100644 index 0000000..4f74682 --- /dev/null +++ b/src/native/linux/display.c @@ -0,0 +1,411 @@ +/* + * 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. + */ + +/** + * $Id: display.c 2985 2008-04-07 18:42:36Z matzon $ + * + * Linux specific library for display handling. + * + * @author elias_naur + * @version $Revision: 2985 $ + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include "common_tools.h" +#include "org_lwjgl_opengl_LinuxDisplay.h" + +#define NUM_XRANDR_RETRIES 5 + +typedef struct { + int width; + int height; + int freq; + union { + int size_index; // Data for Xrandr extension + XF86VidModeModeInfo xf86vm_modeinfo; // Data for XF86VidMode extension + } mode_data; +} mode_info; + +static bool getXF86VidModeVersion(JNIEnv *env, Display *disp, int *major, int *minor) { + int event_base, error_base; + + if (!XF86VidModeQueryExtension(disp, &event_base, &error_base)) { + printfDebugJava(env, "XF86VidMode extension not available"); + return false; + } + if (!XF86VidModeQueryVersion(disp, major, minor)) { + throwException(env, "Could not query XF86VidMode version"); + return false; + } + printfDebugJava(env, "XF86VidMode extension version %i.%i", *major, *minor); + return true; +} + +static bool getXrandrVersion(JNIEnv *env, Display *disp, int *major, int *minor) { + int event_base, error_base; + + if (!XRRQueryExtension(disp, &event_base, &error_base)) { + printfDebugJava(env, "Xrandr extension not available"); + return false; + } + if (!XRRQueryVersion(disp, major, minor)) { + throwException(env, "Could not query Xrandr version"); + return false; + } + printfDebugJava(env, "Xrandr extension version %i.%i", *major, *minor); + return true; +} + +static bool isXrandrSupported(JNIEnv *env, Display *disp) { + int major, minor; + if (!getXrandrVersion(env, disp, &major, &minor)) + return false; + return major >= 1; +} + +static bool isXF86VidModeSupported(JNIEnv *env, Display *disp) { + int minor_ver, major_ver; + if (!getXF86VidModeVersion(env, disp, &major_ver, &minor_ver)) + return false; + return major_ver >= 2; +} + +JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nIsXrandrSupported(JNIEnv *env, jclass unused, jlong display) { + Display *disp = (Display *)(intptr_t)display; + jboolean result = isXrandrSupported(env, disp) ? JNI_TRUE : JNI_FALSE; + return result; +} + +JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nIsXF86VidModeSupported(JNIEnv *env, jclass unused, jlong display) { + Display *disp = (Display *)(intptr_t)display; + jboolean result = isXF86VidModeSupported(env, disp) ? JNI_TRUE : JNI_FALSE; + return result; +} + +static mode_info *getXrandrDisplayModes(Display *disp, int screen, int *num_modes) { + int num_randr_sizes; + XRRScreenSize *sizes = XRRSizes(disp, screen, &num_randr_sizes); + mode_info *avail_modes = NULL; + int list_size = 0; + /* Count number of modes */ + int i; + int mode_index = 0; + for (i = 0; i < num_randr_sizes; i++) { + int num_randr_rates; + short *freqs = XRRRates(disp, screen, i, &num_randr_rates); + int j; + for (j = 0; j < num_randr_rates; j++) { + if (list_size <= mode_index) { + list_size += 1; + avail_modes = (mode_info *)realloc(avail_modes, sizeof(mode_info)*list_size); + if (avail_modes == NULL) + return NULL; + } + avail_modes[mode_index].width = sizes[i].width; + avail_modes[mode_index].height = sizes[i].height; + avail_modes[mode_index].freq = freqs[j]; + avail_modes[mode_index].mode_data.size_index = i; + mode_index++; + } + } + *num_modes = mode_index; + return avail_modes; +} + +static mode_info *getXF86VidModeDisplayModes(Display *disp, int screen, int *num_modes) { + int num_xf86vm_modes; + XF86VidModeModeInfo **avail_xf86vm_modes; + XF86VidModeGetAllModeLines(disp, screen, &num_xf86vm_modes, &avail_xf86vm_modes); + mode_info *avail_modes = (mode_info *)malloc(sizeof(mode_info)*num_xf86vm_modes); + if (avail_modes == NULL) { + XFree(avail_xf86vm_modes); + return NULL; + } + int i; + for (i = 0; i < num_xf86vm_modes; i++) { + avail_modes[i].width = avail_xf86vm_modes[i]->hdisplay; + avail_modes[i].height = avail_xf86vm_modes[i]->vdisplay; + avail_modes[i].freq = 0; // No frequency support in XF86VidMode + avail_modes[i].mode_data.xf86vm_modeinfo = *avail_xf86vm_modes[i]; + } + XFree(avail_xf86vm_modes); + *num_modes = num_xf86vm_modes; + return avail_modes; +} + +static mode_info *getDisplayModes(Display *disp, int screen, jint extension, int *num_modes) { + switch (extension) { + case org_lwjgl_opengl_LinuxDisplay_XF86VIDMODE: + return getXF86VidModeDisplayModes(disp, screen, num_modes); + case org_lwjgl_opengl_LinuxDisplay_XRANDR: + return getXrandrDisplayModes(disp, screen, num_modes); + case org_lwjgl_opengl_LinuxDisplay_NONE: + // fall through + default: + return NULL; + } +} + +static bool setXF86VidModeMode(Display *disp, int screen, mode_info *mode) { + return True == XF86VidModeSwitchToMode(disp, screen, &mode->mode_data.xf86vm_modeinfo); +} + +/* Try to set the mode specified through XRandR. + * Return value is the Status code of the mode switch + * The timestamp parameter is filled with the latest timestamp returned from XRRConfigTimes + */ +static Status trySetXrandrMode(Display *disp, int screen, mode_info *mode, Time *timestamp) { + Status status; + Drawable root_window = RootWindow(disp, screen); + XRRScreenConfiguration *screen_configuration = XRRGetScreenInfo(disp, root_window); + Time config_time; + *timestamp = XRRConfigTimes(screen_configuration, &config_time); + Rotation current_rotation; + XRRConfigCurrentConfiguration(screen_configuration, ¤t_rotation); + status = XRRSetScreenConfigAndRate(disp, screen_configuration, root_window, mode->mode_data.size_index, current_rotation, mode->freq, *timestamp); + XRRFreeScreenConfigInfo(screen_configuration); + return status; +} + +static bool setXrandrMode(Display *disp, int screen, mode_info *mode) { + int iteration; + Time timestamp; + Status status = trySetXrandrMode(disp, screen, mode, ×tamp); + if (status == 0) + return true; // Success + Time new_timestamp; + for (iteration = 0; iteration < NUM_XRANDR_RETRIES; iteration++) { + status = trySetXrandrMode(disp, screen, mode, &new_timestamp); + if (status == 0) + return true; // Success + if (new_timestamp == timestamp) { + return false; // Failure, and the stamps are equal meaning that the failure is not merely transient + } + timestamp = new_timestamp; + } + return false; +} + +static bool setMode(JNIEnv *env, Display *disp, int screen, jint extension, int width, int height, int freq) { + int num_modes, i; + mode_info *avail_modes = getDisplayModes(disp, screen, extension, &num_modes); + if (avail_modes == NULL) { + printfDebugJava(env, "Could not get display modes"); + return false; + } + bool result = false; + for (i = 0; i < num_modes; ++i) { + printfDebugJava(env, "Mode %d: %dx%d @%d", i, avail_modes[i].width, avail_modes[i].height, avail_modes[i].freq); + if (avail_modes[i].width == width && avail_modes[i].height == height && avail_modes[i].freq == freq) { + switch (extension) { + case org_lwjgl_opengl_LinuxDisplay_XF86VIDMODE: + if (!setXF86VidModeMode(disp, screen, &avail_modes[i])) { + printfDebugJava(env, "Could not switch mode"); + continue; + } + break; + case org_lwjgl_opengl_LinuxDisplay_XRANDR: + if (!setXrandrMode(disp, screen, &avail_modes[i])) { + printfDebugJava(env, "Could not switch mode"); + continue; + } + break; + case org_lwjgl_opengl_LinuxDisplay_NONE: // Should never happen, since NONE imply no available display modes + default: // Should never happen + continue; + } + result = true; + break; + } + } + free(avail_modes); + XFlush(disp); + return result; +} + +static int getGammaRampLengthOfDisplay(JNIEnv *env, Display *disp, int screen) { + int ramp_size; + if (XF86VidModeGetGammaRampSize(disp, screen, &ramp_size) == False) { + throwException(env, "XF86VidModeGetGammaRampSize call failed"); + return 0; + } + return ramp_size; +} + +JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nConvertToNativeRamp(JNIEnv *env, jclass unused, jobject ramp_buffer, jint buffer_offset, jint length) { + const jfloat *ramp_ptr = (const jfloat *)(*env)->GetDirectBufferAddress(env, ramp_buffer) + buffer_offset; + jobject native_ramp = newJavaManagedByteBuffer(env, length*3*sizeof(unsigned short)); + if (native_ramp == NULL) { + throwException(env, "Failed to allocate gamma ramp buffer"); + return NULL; + } + unsigned short *native_ramp_ptr = (unsigned short *)(*env)->GetDirectBufferAddress(env, native_ramp); + int i; + for (i = 0; i < length; i++) { + float scaled_gamma = ramp_ptr[i]*0xffff; + short scaled_gamma_short = (unsigned short)roundf(scaled_gamma); + native_ramp_ptr[i] = scaled_gamma_short; + native_ramp_ptr[i + length] = scaled_gamma_short; + native_ramp_ptr[i + length*2] = scaled_gamma_short; + } + return native_ramp; +} + +JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetCurrentGammaRamp(JNIEnv *env, jclass unused, jlong display, jint screen) { + Display *disp = (Display *)(intptr_t)display; + int ramp_size = getGammaRampLengthOfDisplay(env, disp, screen); + jobject ramp_buffer = newJavaManagedByteBuffer(env, sizeof(unsigned short)*3*ramp_size); + if (ramp_buffer == NULL) { + throwException(env, "Could not allocate gamma ramp buffer"); + return NULL; + } + unsigned short *ramp = (unsigned short *)(*env)->GetDirectBufferAddress(env, ramp_buffer); + if (!XF86VidModeGetGammaRamp(disp, screen, ramp_size, ramp, + ramp + ramp_size, ramp + ramp_size*2)) { + throwException(env, "Could not get the current gamma ramp"); + return NULL; + } + return ramp_buffer; +} + +static void setGamma(JNIEnv *env, Display *disp, int screen, jobject ramp_buffer) { + if (ramp_buffer == NULL) + return; + unsigned short *ramp_ptr = (unsigned short *)(*env)->GetDirectBufferAddress(env, ramp_buffer); + jlong capacity = (*env)->GetDirectBufferCapacity(env, ramp_buffer); + int size = capacity/(sizeof(unsigned short)*3); + if (size == 0) + return; + if (XF86VidModeSetGammaRamp(disp, screen, size, ramp_ptr, ramp_ptr + size, ramp_ptr + size*2) == False) { + throwException(env, "Could not set gamma ramp."); + } +} + +static bool switchDisplayMode(JNIEnv * env, Display *disp, int screen, jint extension, jobject mode) { + if (mode == NULL) { + throwException(env, "mode must be non-null"); + return false; + } + jclass cls_displayMode = (*env)->GetObjectClass(env, mode); + jfieldID fid_width = (*env)->GetFieldID(env, cls_displayMode, "width", "I"); + jfieldID fid_height = (*env)->GetFieldID(env, cls_displayMode, "height", "I"); + jfieldID fid_freq = (*env)->GetFieldID(env, cls_displayMode, "freq", "I"); + int width = (*env)->GetIntField(env, mode, fid_width); + int height = (*env)->GetIntField(env, mode, fid_height); + int freq = (*env)->GetIntField(env, mode, fid_freq); + if (!setMode(env, disp, screen, extension, width, height, freq)) { + throwException(env, "Could not switch mode."); + return false; + } + return true; +} + +static jobjectArray getAvailableDisplayModes(JNIEnv * env, Display *disp, int screen, jint extension) { + int num_modes, i; + mode_info *avail_modes; + int bpp = XDefaultDepth(disp, screen); + avail_modes = getDisplayModes(disp, screen, extension, &num_modes); + if (avail_modes == NULL) { + printfDebugJava(env, "Could not get display modes"); + return NULL; + } + // Allocate an array of DisplayModes big enough + jclass displayModeClass = (*env)->FindClass(env, "org/lwjgl/opengl/DisplayMode"); + jobjectArray ret = (*env)->NewObjectArray(env, num_modes, displayModeClass, NULL); + jmethodID displayModeConstructor = (*env)->GetMethodID(env, displayModeClass, "", "(IIII)V"); + + for (i = 0; i < num_modes; i++) { + jobject displayMode = (*env)->NewObject(env, displayModeClass, displayModeConstructor, avail_modes[i].width, avail_modes[i].height, bpp, avail_modes[i].freq); + (*env)->SetObjectArrayElement(env, ret, i, displayMode); + } + free(avail_modes); + return ret; +} + +static jobject getCurrentXRandrMode(JNIEnv * env, Display *disp, int screen) { + Drawable root_window = RootWindow(disp, screen); + XRRScreenConfiguration *config = XRRGetScreenInfo(disp, root_window); + if (config == NULL) { + throwException(env, "Could not get current screen configuration."); + return NULL; + } + short rate = XRRConfigCurrentRate(config); + Rotation current_rotation; + SizeID size_index = XRRConfigCurrentConfiguration(config, ¤t_rotation); + int n_sizes; + XRRScreenSize *sizes = XRRConfigSizes(config, &n_sizes); + if (size_index >= n_sizes) { + throwFormattedException(env, "Xrandr current index (%d) is larger than or equals to the number of sizes (%d).", size_index, n_sizes); + XRRFreeScreenConfigInfo(config); + return NULL; + } + XRRScreenSize current_size = sizes[size_index]; + XRRFreeScreenConfigInfo(config); + int bpp = XDefaultDepth(disp, screen); + jclass displayModeClass = (*env)->FindClass(env, "org/lwjgl/opengl/DisplayMode"); + jmethodID displayModeConstructor = (*env)->GetMethodID(env, displayModeClass, "", "(IIII)V"); + jobject displayMode = (*env)->NewObject(env, displayModeClass, displayModeConstructor, current_size.width, current_size.height, bpp, rate); + return displayMode; +} + +JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetCurrentXRandrMode(JNIEnv *env, jclass unused, jlong display, jint screen) { + Display *disp = (Display *)(intptr_t)display; + return getCurrentXRandrMode(env, disp, screen); +} + +JNIEXPORT jobjectArray JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetAvailableDisplayModes(JNIEnv *env, jclass clazz, jlong display, jint screen, jint extension) { + Display *disp = (Display *)(intptr_t)display; + return getAvailableDisplayModes(env, disp, screen, extension); +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nSwitchDisplayMode(JNIEnv *env, jclass clazz, jlong display, jint screen, jint extension, jobject mode) { + Display *disp = (Display *)(intptr_t)display; + switchDisplayMode(env, disp, screen, extension, mode); +} + +JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetGammaRampLength(JNIEnv *env, jclass clazz, jlong display_ptr, jint screen) { + Display *disp = (Display *)(intptr_t)display_ptr; + return (jint)getGammaRampLengthOfDisplay(env, disp, screen); +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nSetGammaRamp(JNIEnv *env, jclass clazz, jlong display, jint screen, jobject gamma_buffer) { + Display *disp = (Display *)(intptr_t)display; + setGamma(env, disp, screen, gamma_buffer); +} + diff --git a/src/native/linux/extgl_glx.c b/src/native/linux/extgl_glx.c new file mode 100644 index 0000000..1603063 --- /dev/null +++ b/src/native/linux/extgl_glx.c @@ -0,0 +1,231 @@ +/* + * 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. + */ +#include +#include "extgl_glx.h" + +glXGetFBConfigsPROC lwjgl_glXGetFBConfigs = NULL; +glXChooseFBConfigPROC lwjgl_glXChooseFBConfig = NULL; +glXGetFBConfigAttribPROC lwjgl_glXGetFBConfigAttrib = NULL; +glXGetVisualFromFBConfigPROC lwjgl_glXGetVisualFromFBConfig = NULL; +glXCreateWindowPROC lwjgl_glXCreateWindow = NULL; +glXDestroyWindowPROC lwjgl_glXDestroyWindow = NULL; +glXCreatePixmapPROC lwjgl_glXCreatePixmap = NULL; +glXDestroyPixmapPROC lwjgl_glXDestroyPixmap = NULL; +glXCreatePbufferPROC lwjgl_glXCreatePbuffer = NULL; +glXDestroyPbufferPROC lwjgl_glXDestroyPbuffer = NULL; +glXQueryDrawablePROC lwjgl_glXQueryDrawable = NULL; +glXCreateNewContextPROC lwjgl_glXCreateNewContext = NULL; +glXMakeContextCurrentPROC lwjgl_glXMakeContextCurrent = NULL; +glXGetCurrentReadDrawablePROC lwjgl_glXGetCurrentReadDrawable = NULL; +glXGetCurrentDisplayPROC lwjgl_glXGetCurrentDisplay = NULL; +glXQueryContextPROC lwjgl_glXQueryContext = NULL; +glXSelectEventPROC lwjgl_glXSelectEvent = NULL; +glXGetSelectedEventPROC lwjgl_glXGetSelectedEvent = NULL; +glXChooseVisualPROC lwjgl_glXChooseVisual = NULL; +glXCopyContextPROC lwjgl_glXCopyContext = NULL; +glXCreateContextPROC lwjgl_glXCreateContext = NULL; +glXCreateGLXPixmapPROC lwjgl_glXCreateGLXPixmap = NULL; +glXDestroyContextPROC lwjgl_glXDestroyContext = NULL; +glXDestroyGLXPixmapPROC lwjgl_glXDestroyGLXPixmap = NULL; +glXGetConfigPROC lwjgl_glXGetConfig = NULL; +glXGetCurrentContextPROC lwjgl_glXGetCurrentContext = NULL; +glXGetCurrentDrawablePROC lwjgl_glXGetCurrentDrawable = NULL; +glXIsDirectPROC lwjgl_glXIsDirect = NULL; +glXMakeCurrentPROC lwjgl_glXMakeCurrent = NULL; +glXQueryExtensionPROC lwjgl_glXQueryExtension = NULL; +glXQueryVersionPROC lwjgl_glXQueryVersion = NULL; +glXSwapBuffersPROC lwjgl_glXSwapBuffers = NULL; +glXUseXFontPROC lwjgl_glXUseXFont = NULL; +glXWaitGLPROC lwjgl_glXWaitGL = NULL; +glXWaitXPROC lwjgl_glXWaitX = NULL; +glXGetClientStringPROC lwjgl_glXGetClientString = NULL; +glXQueryServerStringPROC lwjgl_glXQueryServerString = NULL; +glXQueryExtensionsStringPROC lwjgl_glXQueryExtensionsString = NULL; + +/* GLX_SGI_swap_control */ +glXSwapIntervalSGIPROC lwjgl_glXSwapIntervalSGI = NULL; + +/* GLX_ARB_create_context */ +glXCreateContextAttribsARBPROC lwjgl_glXCreateContextAttribsARB = NULL; + +static void * lib_gl_handle = NULL; + +typedef void * (APIENTRY * glXGetProcAddressARBPROC) (const GLubyte *procName); + +static glXGetProcAddressARBPROC lwjgl_glXGetProcAddressARB; + +static GLXExtensions symbols_flags; + +/** returns true if the extention is available */ +static bool GLXQueryExtension(Display *disp, int screen, const char *name) { + const GLubyte *exts = (const GLubyte *)lwjgl_glXQueryExtensionsString(disp, screen); + return extgl_QueryExtension(exts, name); +} + +static void extgl_InitGLX13() { + ExtFunction functions[] = { + {"glXGetFBConfigs", (void*)&lwjgl_glXGetFBConfigs}, + {"glXChooseFBConfig", (void*)&lwjgl_glXChooseFBConfig}, + {"glXGetFBConfigAttrib", (void*)&lwjgl_glXGetFBConfigAttrib}, + {"glXGetVisualFromFBConfig", (void*)&lwjgl_glXGetVisualFromFBConfig}, + {"glXCreateWindow", (void*)&lwjgl_glXCreateWindow}, + {"glXDestroyWindow", (void*)&lwjgl_glXDestroyWindow}, + {"glXCreatePixmap", (void*)&lwjgl_glXCreatePixmap}, + {"glXDestroyPixmap", (void*)&lwjgl_glXDestroyPixmap}, + {"glXCreatePbuffer", (void*)&lwjgl_glXCreatePbuffer}, + {"glXDestroyPbuffer", (void*)&lwjgl_glXDestroyPbuffer}, + {"glXQueryDrawable", (void*)&lwjgl_glXQueryDrawable}, + {"glXCreateNewContext", (void*)&lwjgl_glXCreateNewContext}, + {"glXMakeContextCurrent", (void*)&lwjgl_glXMakeContextCurrent}, + {"glXGetCurrentReadDrawable", (void*)&lwjgl_glXGetCurrentReadDrawable}, + {"glXGetCurrentDisplay", (void*)&lwjgl_glXGetCurrentDisplay}, + {"glXQueryContext", (void*)&lwjgl_glXQueryContext}, + {"glXSelectEvent", (void*)&lwjgl_glXSelectEvent}, + {"glXGetSelectedEvent", (void*)&lwjgl_glXGetSelectedEvent}}; + symbols_flags.GLX13 = extgl_InitializeFunctions(sizeof(functions)/sizeof(ExtFunction), functions); +} + +static void extgl_InitGLX12(void) { + ExtFunction functions[] = { + {"glXChooseVisual", (void*)&lwjgl_glXChooseVisual}, + {"glXCopyContext", (void*)&lwjgl_glXCopyContext}, + {"glXCreateContext", (void*)&lwjgl_glXCreateContext}, + {"glXCreateGLXPixmap", (void*)&lwjgl_glXCreateGLXPixmap}, + {"glXDestroyContext", (void*)&lwjgl_glXDestroyContext}, + {"glXDestroyGLXPixmap", (void*)&lwjgl_glXDestroyGLXPixmap}, + {"glXGetConfig", (void*)&lwjgl_glXGetConfig}, + {"glXGetCurrentContext", (void*)&lwjgl_glXGetCurrentContext}, + {"glXGetCurrentDrawable", (void*)&lwjgl_glXGetCurrentDrawable}, + {"glXIsDirect", (void*)&lwjgl_glXIsDirect}, + {"glXMakeCurrent", (void*)&lwjgl_glXMakeCurrent}, + {"glXQueryExtension", (void*)&lwjgl_glXQueryExtension}, + {"glXQueryVersion", (void*)&lwjgl_glXQueryVersion}, + {"glXSwapBuffers", (void*)&lwjgl_glXSwapBuffers}, + {"glXUseXFont", (void*)&lwjgl_glXUseXFont}, + {"glXWaitGL", (void*)&lwjgl_glXWaitGL}, + {"glXWaitX", (void*)&lwjgl_glXWaitX}, + {"glXGetClientString", (void*)&lwjgl_glXGetClientString}, + {"glXQueryServerString", (void*)&lwjgl_glXQueryServerString}, + {"glXQueryExtensionsString", (void*)&lwjgl_glXQueryExtensionsString}}; + symbols_flags.GLX12 = extgl_InitializeFunctions(sizeof(functions)/sizeof(ExtFunction), functions); +} + +static void extgl_InitGLXSGISwapControl() { + ExtFunction functions[] = { + {"glXSwapIntervalSGI", (void*)&lwjgl_glXSwapIntervalSGI}}; + symbols_flags.GLX_SGI_swap_control = extgl_InitializeFunctions(sizeof(functions)/sizeof(ExtFunction), functions); +} + +static void extgl_InitGLXARBCreateContext() { + ExtFunction functions[] = { + {"glXCreateContextAttribsARB", (void*)&lwjgl_glXCreateContextAttribsARB}}; + symbols_flags.GLX_ARB_create_context = extgl_InitializeFunctions(sizeof(functions)/sizeof(ExtFunction), functions); +} + +static void extgl_InitGLXSupportedExtensions(Display *disp, int screen, GLXExtensions *extension_flags) { +/* extension_flags.GLX_EXT_visual_info = GLXQueryExtension(disp, screen, "GLX_EXT_visual_info"); + extension_flags.GLX_EXT_visual_rating = GLXQueryExtension(disp, screen, "GLX_EXT_visual_rating");*/ + extension_flags->GLX_SGI_swap_control = symbols_flags.GLX_SGI_swap_control && GLXQueryExtension(disp, screen, "GLX_SGI_swap_control"); + extension_flags->GLX_ARB_multisample = GLXQueryExtension(disp, screen, "GLX_ARB_multisample"); + extension_flags->GLX_ARB_fbconfig_float = GLXQueryExtension(disp, screen, "GLX_ARB_fbconfig_float"); + extension_flags->GLX_EXT_fbconfig_packed_float = GLXQueryExtension(disp, screen, "GLX_EXT_fbconfig_packed_float"); + extension_flags->GLX_ARB_framebuffer_sRGB = GLXQueryExtension(disp, screen, "GLX_ARB_framebuffer_sRGB") || GLXQueryExtension(disp, screen, "GLX_EXT_framebuffer_sRGB"); + extension_flags->GLX_ARB_create_context = GLXQueryExtension(disp, screen, "GLX_ARB_create_context"); +} + +bool extgl_Open(JNIEnv *env) { + if (lib_gl_handle != NULL) + return true; + /* + * Actually we don't need the RTLD_GLOBAL flag, since the symbols + * we load should be private to us. However, according to the + * documentation at + * + * http://dri.sourceforge.net/doc/DRIuserguide.html + * + * DRI drivers need this flag to work properly + */ + lib_gl_handle = dlopen("libGL.so.1", RTLD_LAZY | RTLD_GLOBAL); + if (lib_gl_handle == NULL) { + throwFormattedException(env, "Error loading libGL.so.1: %s", dlerror()); + return false; + } + lwjgl_glXGetProcAddressARB = (glXGetProcAddressARBPROC)dlsym(lib_gl_handle, "glXGetProcAddressARB"); + if (lwjgl_glXGetProcAddressARB == NULL) { + extgl_Close(); + throwException(env, "Could not get address of glXGetProcAddressARB"); + return false; + } + /* Unlike Windows, GLX function addresses are context-independent + * so we only have to initialize the addresses once at load + */ + extgl_InitGLX12(); + extgl_InitGLX13(); + extgl_InitGLXSGISwapControl(); + extgl_InitGLXARBCreateContext(); + return true; +} + +void *extgl_GetProcAddress(const char *name) { + void *t = (void*)lwjgl_glXGetProcAddressARB((const GLubyte*)name); + if (t == NULL) { + t = dlsym(lib_gl_handle, name); + if (t == NULL) { + printfDebug("Could not locate symbol %s\n", name); + } + } + return t; +} + +void extgl_Close(void) { + dlclose(lib_gl_handle); + lib_gl_handle = NULL; +} + +bool extgl_InitGLX(Display *disp, int screen, GLXExtensions *extension_flags) { + int major, minor; + /* Assume glx ver >= 1.2 */ + // Check GLX 1.2 symbols available + if (!symbols_flags.GLX12) + return false; + if (lwjgl_glXQueryVersion(disp, &major, &minor) != True) + return false; + bool glx12 = major > 1 || (major == 1 && minor >= 2); + // Check GLX 1.2 version + if (!glx12) + return false; + extension_flags->GLX12 = glx12; + extension_flags->GLX13 = major > 1 || (major == 1 && minor >= 3); + extension_flags->GLX14 = major > 1 || (major == 1 && minor >= 4); + extgl_InitGLXSupportedExtensions(disp, screen, extension_flags); + return true; +} diff --git a/src/native/linux/extgl_glx.h b/src/native/linux/extgl_glx.h new file mode 100644 index 0000000..fba7d0a --- /dev/null +++ b/src/native/linux/extgl_glx.h @@ -0,0 +1,398 @@ +/* + * 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. + */ + +#ifndef EXTGL_GLX_H +#define EXTGL_GLX_H + +#include +#include "extgl.h" + +/* + * Names for attributes to lwjgl_glXGetConfig. + */ +#define GLX_USE_GL 1 /* support GLX rendering */ +#define GLX_BUFFER_SIZE 2 /* depth of the color buffer */ +#define GLX_LEVEL 3 /* level in plane stacking */ +#define GLX_RGBA 4 /* true if RGBA mode */ +#define GLX_DOUBLEBUFFER 5 /* double buffering supported */ +#define GLX_STEREO 6 /* stereo buffering supported */ +#define GLX_AUX_BUFFERS 7 /* number of aux buffers */ +#define GLX_RED_SIZE 8 /* number of red component bits */ +#define GLX_GREEN_SIZE 9 /* number of green component bits */ +#define GLX_BLUE_SIZE 10 /* number of blue component bits */ +#define GLX_ALPHA_SIZE 11 /* number of alpha component bits */ +#define GLX_DEPTH_SIZE 12 /* number of depth bits */ +#define GLX_STENCIL_SIZE 13 /* number of stencil bits */ +#define GLX_ACCUM_RED_SIZE 14 /* number of red accum bits */ +#define GLX_ACCUM_GREEN_SIZE 15 /* number of green accum bits */ +#define GLX_ACCUM_BLUE_SIZE 16 /* number of blue accum bits */ +#define GLX_ACCUM_ALPHA_SIZE 17 /* number of alpha accum bits */ + +#define GLX_SAMPLE_BUFFERS_ARB 100000 /* number of multisample buffers */ +#define GLX_SAMPLES_ARB 100001 /* number of multisample samples */ + +/* + * FBConfig-specific attributes + */ +#define GLX_X_VISUAL_TYPE 0x22 +#define GLX_CONFIG_CAVEAT 0x20 /* Like visual_info VISUAL_CAVEAT */ +#define GLX_TRANSPARENT_TYPE 0x23 +#define GLX_TRANSPARENT_INDEX_VALUE 0x24 +#define GLX_TRANSPARENT_RED_VALUE 0x25 +#define GLX_TRANSPARENT_GREEN_VALUE 0x26 +#define GLX_TRANSPARENT_BLUE_VALUE 0x27 +#define GLX_TRANSPARENT_ALPHA_VALUE 0x28 +#define GLX_DRAWABLE_TYPE 0x8010 +#define GLX_RENDER_TYPE 0x8011 +#define GLX_X_RENDERABLE 0x8012 +#define GLX_FBCONFIG_ID 0x8013 +#define GLX_MAX_PBUFFER_WIDTH 0x8016 +#define GLX_MAX_PBUFFER_HEIGHT 0x8017 +#define GLX_MAX_PBUFFER_PIXELS 0x8018 +#define GLX_VISUAL_ID 0x800B + +#define GLX_DRAWABLE_TYPE_SGIX GLX_DRAWABLE_TYPE +#define GLX_RENDER_TYPE_SGIX GLX_RENDER_TYPE +#define GLX_X_RENDERABLE_SGIX GLX_X_RENDERABLE +#define GLX_FBCONFIG_ID_SGIX GLX_FBCONFIG_ID +#define GLX_MAX_PBUFFER_WIDTH_SGIX GLX_MAX_PBUFFER_WIDTH +#define GLX_MAX_PBUFFER_HEIGHT_SGIX GLX_MAX_PBUFFER_HEIGHT +#define GLX_MAX_PBUFFER_PIXELS_SGIX GLX_MAX_PBUFFER_PIXELS +#define GLX_OPTIMAL_PBUFFER_WIDTH_SGIX 0x8019 +#define GLX_OPTIMAL_PBUFFER_HEIGHT_SGIX 0x801A + +/* + * Error return values from lwjgl_glXGetConfig. Success is indicated by + * a value of 0. + */ +#define GLX_BAD_SCREEN 1 /* screen # is bad */ +#define GLX_BAD_ATTRIBUTE 2 /* attribute to get is bad */ +#define GLX_NO_EXTENSION 3 /* no glx extension on server */ +#define GLX_BAD_VISUAL 4 /* visual # not known by GLX */ +#define GLX_BAD_CONTEXT 5 +#define GLX_BAD_VALUE 6 +#define GLX_BAD_ENUM 7 + + +/* FBConfig attribute values */ + +/* + * Generic "don't care" value for lwjgl_glX ChooseFBConfig attributes (except + * GLX_LEVEL). + */ +#define GLX_DONT_CARE 0xFFFFFFFF + +/* GLX_RENDER_TYPE bits */ +#define GLX_RGBA_BIT 0x00000001 +#define GLX_COLOR_INDEX_BIT 0x00000002 +#define GLX_RGBA_BIT_SGIX GLX_RGBA_BIT +#define GLX_COLOR_INDEX_BIT_SGIX GLX_COLOR_INDEX_BIT + +/* GLX_DRAWABLE_TYPE bits */ +#define GLX_WINDOW_BIT 0x00000001 +#define GLX_PIXMAP_BIT 0x00000002 +#define GLX_PBUFFER_BIT 0x00000004 +#define GLX_WINDOW_BIT_SGIX GLX_WINDOW_BIT +#define GLX_PIXMAP_BIT_SGIX GLX_PIXMAP_BIT +#define GLX_PBUFFER_BIT_SGIX GLX_PBUFFER_BIT + +/* GLX_CONFIG_CAVEAT attribute values */ +#define GLX_NONE 0x8000 +#define GLX_SLOW_CONFIG 0x8001 +#define GLX_NON_CONFORMANT_CONFIG 0x800D + +/* GLX_X_VISUAL_TYPE attribute values */ +#define GLX_TRUE_COLOR 0x8002 +#define GLX_DIRECT_COLOR 0x8003 +#define GLX_PSEUDO_COLOR 0x8004 +#define GLX_STATIC_COLOR 0x8005 +#define GLX_GRAY_SCALE 0x8006 +#define GLX_STATIC_GRAY 0x8007 + +/* GLX_TRANSPARENT_TYPE attribute values */ +/* #define GLX_NONE 0x8000 */ +#define GLX_TRANSPARENT_RGB 0x8008 +#define GLX_TRANSPARENT_INDEX 0x8009 + +/* lwjgl_glXCreateGLXPbuffer attributes */ +#define GLX_PRESERVED_CONTENTS 0x801B +#define GLX_LARGEST_PBUFFER 0x801C +#define GLX_PBUFFER_HEIGHT 0x8040 /* New for GLX 1.3 */ +#define GLX_PBUFFER_WIDTH 0x8041 /* New for GLX 1.3 */ +#define GLX_PRESERVED_CONTENTS_SGIX GLX_PRESERVED_CONTENTS +#define GLX_LARGEST_PBUFFER_SGIX GLX_LARGEST_PBUFFER + +/* lwjgl_glXQueryGLXPBuffer attributes */ +#define GLX_WIDTH 0x801D +#define GLX_HEIGHT 0x801E +#define GLX_EVENT_MASK 0x801F +#define GLX_WIDTH_SGIX GLX_WIDTH +#define GLX_HEIGHT_SGIX GLX_HEIGHT +#define GLX_EVENT_MASK_SGIX GLX_EVENT_MASK + +/* lwjgl_glXCreateNewContext render_type attribute values */ +#define GLX_RGBA_TYPE 0x8014 +#define GLX_COLOR_INDEX_TYPE 0x8015 +#define GLX_RGBA_TYPE_SGIX GLX_RGBA_TYPE +#define GLX_COLOR_INDEX_TYPE_SGIX GLX_COLOR_INDEX_TYPE + +/* lwjgl_glXQueryContext attributes */ +/* #define GLX_FBCONFIG_ID 0x8013 */ +/* #define GLX_RENDER_TYPE 0x8011 */ +#define GLX_SCREEN 0x800C + +/* lwjgl_glXSelectEvent event mask bits */ +#define GLX_PBUFFER_CLOBBER_MASK 0x08000000 +#define GLX_PBUFFER_CLOBBER_MASK_SGIX GLX_PBUFFER_CLOBBER_MASK + +/* GLXPbufferClobberEvent event_type values */ +#define GLX_DAMAGED 0x8020 +#define GLX_SAVED 0x8021 +#define GLX_DAMAGED_SGIX GLX_DAMAGED +#define GLX_SAVED_SGIX GLX_SAVED + +/* GLXPbufferClobberEvent draw_type values */ +#define GLX_WINDOW 0x8022 +#define GLX_PBUFFER 0x8023 +#define GLX_WINDOW_SGIX GLX_WINDOW +#define GLX_PBUFFER_SGIX GLX_PBUFFER + +/* GLXPbufferClobberEvent buffer_mask bits */ +#define GLX_FRONT_LEFT_BUFFER_BIT 0x00000001 +#define GLX_FRONT_RIGHT_BUFFER_BIT 0x00000002 +#define GLX_BACK_LEFT_BUFFER_BIT 0x00000004 +#define GLX_BACK_RIGHT_BUFFER_BIT 0x00000008 +#define GLX_AUX_BUFFERS_BIT 0x00000010 +#define GLX_DEPTH_BUFFER_BIT 0x00000020 +#define GLX_STENCIL_BUFFER_BIT 0x00000040 +#define GLX_ACCUM_BUFFER_BIT 0x00000080 +#define GLX_FRONT_LEFT_BUFFER_BIT_SGIX GLX_FRONT_LEFT_BUFFER_BIT +#define GLX_FRONT_RIGHT_BUFFER_BIT_SGIX GLX_FRONT_RIGHT_BUFFER_BIT +#define GLX_BACK_LEFT_BUFFER_BIT_SGIX GLX_BACK_LEFT_BUFFER_BIT +#define GLX_BACK_RIGHT_BUFFER_BIT_SGIX GLX_BACK_RIGHT_BUFFER_BIT +#define GLX_AUX_BUFFERS_BIT_SGIX GLX_AUX_BUFFERS_BIT +#define GLX_DEPTH_BUFFER_BIT_SGIX GLX_DEPTH_BUFFER_BIT +#define GLX_STENCIL_BUFFER_BIT_SGIX GLX_STENCIL_BUFFER_BIT +#define GLX_ACCUM_BUFFER_BIT_SGIX GLX_ACCUM_BUFFER_BIT + +/* + * Extension return values from lwjgl_glXGetConfig. These are also + * accepted as parameter values for lwjgl_glXChooseVisual. + */ + +#define GLX_X_VISUAL_TYPE_EXT 0x22 /* visual_info extension type */ +#define GLX_TRANSPARENT_TYPE_EXT 0x23 /* visual_info extension */ +#define GLX_TRANSPARENT_INDEX_VALUE_EXT 0x24 /* visual_info extension */ +#define GLX_TRANSPARENT_RED_VALUE_EXT 0x25 /* visual_info extension */ +#define GLX_TRANSPARENT_GREEN_VALUE_EXT 0x26 /* visual_info extension */ +#define GLX_TRANSPARENT_BLUE_VALUE_EXT 0x27 /* visual_info extension */ +#define GLX_TRANSPARENT_ALPHA_VALUE_EXT 0x28 /* visual_info extension */ + +/* Property values for visual_type */ +#define GLX_TRUE_COLOR_EXT 0x8002 +#define GLX_DIRECT_COLOR_EXT 0x8003 +#define GLX_PSEUDO_COLOR_EXT 0x8004 +#define GLX_STATIC_COLOR_EXT 0x8005 +#define GLX_GRAY_SCALE_EXT 0x8006 +#define GLX_STATIC_GRAY_EXT 0x8007 + +/* Property values for transparent pixel */ +#define GLX_NONE_EXT 0x8000 +#define GLX_TRANSPARENT_RGB_EXT 0x8008 +#define GLX_TRANSPARENT_INDEX_EXT 0x8009 + +/* Property values for visual_rating */ +#define GLX_VISUAL_CAVEAT_EXT 0x20 /* visual_rating extension type */ +#define GLX_SLOW_VISUAL_EXT 0x8001 +#define GLX_NON_CONFORMANT_VISUAL_EXT 0x800D + +/* + * Names for attributes to lwjgl_glXGetClientString. + */ +#define GLX_VENDOR 0x1 +#define GLX_VERSION 0x2 +#define GLX_EXTENSIONS 0x3 + +/* + * Names for attributes to lwjgl_glXQueryContextInfoEXT. + */ +#define GLX_SHARE_CONTEXT_EXT 0x800A /* id of share context */ +#define GLX_VISUAL_ID_EXT 0x800B /* id of context's visual */ +#define GLX_SCREEN_EXT 0x800C /* screen number */ + +/* NV_float_buffer */ +#define GLX_FLOAT_COMPONENTS_NV 0x20B0 + +/* GLX_ARB_fbconfig_float */ +#define GLX_RGBA_FLOAT_TYPE 0x20B9 +#define GLX_RGBA_FLOAT_BIT 0x0004 + +/* GLX_ARB_fbconfig_float */ +#define GLX_RGBA_UNSIGNED_FLOAT_TYPE_EXT 0x20B1 +#define GLX_RGBA_UNSIGNED_FLOAT_BIT_EXT 0x00000008 + +/* GLX_ARB_framebuffer_sRGB */ +#define GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20B2 + +/* GLX_ARB_create_context */ +#define GLX_CONTEXT_MAJOR_VERSION_ARB 0x2091 +#define GLX_CONTEXT_MINOR_VERSION_ARB 0x2092 +#define GLX_CONTEXT_FLAGS_ARB 0x2094 + +#define GLX_CONTEXT_DEBUG_BIT_ARB 0x0001 +#define GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x0002 + +typedef XID GLXContextID; +typedef XID GLXPixmap; +typedef XID GLXDrawable; +typedef XID GLXPbuffer; +typedef XID GLXWindow; +typedef XID GLXFBConfigID; + +typedef struct __GLXcontextRec *GLXContext; + +typedef struct __GLXFBConfigRec *GLXFBConfig; + +typedef GLXFBConfig * (APIENTRY * glXGetFBConfigsPROC) (Display *dpy, int screen, int *nelements); +typedef GLXFBConfig * (APIENTRY * glXChooseFBConfigPROC) (Display *dpy, int screen, const int *attrib_list, int *nelements); +typedef int (APIENTRY * glXGetFBConfigAttribPROC) (Display *dpy, GLXFBConfig config, int attribute, int *value); +typedef XVisualInfo * (APIENTRY * glXGetVisualFromFBConfigPROC) (Display *dpy, GLXFBConfig config); +typedef GLXWindow (APIENTRY * glXCreateWindowPROC) (Display *dpy, GLXFBConfig config, Window win, const int *attrib_list); +typedef void (APIENTRY * glXDestroyWindowPROC) (Display *dpy, GLXWindow win); +typedef GLXPixmap (APIENTRY * glXCreatePixmapPROC) (Display *dpy, GLXFBConfig config, Pixmap pixmap, const int *attrib_list); +typedef void (APIENTRY * glXDestroyPixmapPROC) (Display *dpy, GLXPixmap pixmap); +typedef GLXPbuffer (APIENTRY * glXCreatePbufferPROC) (Display *dpy, GLXFBConfig config, const int *attrib_list); +typedef void (APIENTRY * glXDestroyPbufferPROC) (Display *dpy, GLXPbuffer pbuf); +typedef void (APIENTRY * glXQueryDrawablePROC) (Display *dpy, GLXDrawable draw, int attribute, unsigned int *value); +typedef GLXContext (APIENTRY * glXCreateNewContextPROC) (Display *dpy, GLXFBConfig config, int render_type, GLXContext share_list, Bool direct); +typedef Bool (APIENTRY * glXMakeContextCurrentPROC) (Display *display, GLXDrawable draw, GLXDrawable read, GLXContext ctx); +typedef GLXDrawable (APIENTRY * glXGetCurrentReadDrawablePROC) (void); +typedef Display * (APIENTRY * glXGetCurrentDisplayPROC) (void); +typedef int (APIENTRY * glXQueryContextPROC) (Display *dpy, GLXContext ctx, int attribute, int *value); +typedef void (APIENTRY * glXSelectEventPROC) (Display *dpy, GLXDrawable draw, unsigned long event_mask); +typedef void (APIENTRY * glXGetSelectedEventPROC) (Display *dpy, GLXDrawable draw, unsigned long *event_mask); + +typedef GLXContextID (APIENTRY * glXGetContextIDEXTPROC) (const GLXContext ctx); +typedef GLXDrawable (APIENTRY * glXGetCurrentDrawableEXTPROC) (void); +typedef GLXContext (APIENTRY * glXImportContextEXTPROC) (Display *dpy, GLXContextID contextID); +typedef void (APIENTRY * glXFreeContextEXTPROC) (Display *dpy, GLXContext ctx); +typedef int (APIENTRY * glXQueryContextInfoEXTPROC) (Display *dpy, GLXContext ctx, int attribute, int *value); + +typedef XVisualInfo* (APIENTRY * glXChooseVisualPROC) (Display *dpy, int screen, int *attribList); +typedef void (APIENTRY * glXCopyContextPROC) (Display *dpy, GLXContext src, GLXContext dst, unsigned long mask); +typedef GLXContext (APIENTRY * glXCreateContextPROC) (Display *dpy, XVisualInfo *vis, GLXContext shareList, Bool direct); +typedef GLXPixmap (APIENTRY * glXCreateGLXPixmapPROC) (Display *dpy, XVisualInfo *vis, Pixmap pixmap); +typedef void (APIENTRY * glXDestroyContextPROC) (Display *dpy, GLXContext ctx); +typedef void (APIENTRY * glXDestroyGLXPixmapPROC) (Display *dpy, GLXPixmap pix); +typedef int (APIENTRY * glXGetConfigPROC) (Display *dpy, XVisualInfo *vis, int attrib, int *value); +typedef GLXContext (APIENTRY * glXGetCurrentContextPROC) (void); +typedef GLXDrawable (APIENTRY * glXGetCurrentDrawablePROC) (void); +typedef Bool (APIENTRY * glXIsDirectPROC) (Display *dpy, GLXContext ctx); +typedef Bool (APIENTRY * glXMakeCurrentPROC) (Display *dpy, GLXDrawable drawable, GLXContext ctx); +typedef Bool (APIENTRY * glXQueryExtensionPROC) (Display *dpy, int *errorBase, int *eventBase); +typedef Bool (APIENTRY * glXQueryVersionPROC) (Display *dpy, int *major, int *minor); +typedef void (APIENTRY * glXSwapBuffersPROC) (Display *dpy, GLXDrawable drawable); +typedef void (APIENTRY * glXUseXFontPROC) (Font font, int first, int count, int listBase); +typedef void (APIENTRY * glXWaitGLPROC) (void); +typedef void (APIENTRY * glXWaitXPROC) (void); +typedef const char * (APIENTRY * glXGetClientStringPROC) (Display *dpy, int name ); +typedef const char * (APIENTRY * glXQueryServerStringPROC) (Display *dpy, int screen, int name ); +typedef const char * (APIENTRY * glXQueryExtensionsStringPROC) (Display *dpy, int screen ); + +/* GLX_SGI_swap_control */ +typedef void (APIENTRY * glXSwapIntervalSGIPROC)(int interval); + +/* GLX_ARB_create_context */ +typedef GLXContext (APIENTRY * glXCreateContextAttribsARBPROC) (Display *dpy, GLXFBConfig config, GLXContext share_context, Bool direct, const int *attrib_list); + +typedef struct { + bool GLX12; + bool GLX13; + bool GLX14; +/* bool GLX_EXT_visual_info; + bool GLX_EXT_visual_rating;*/ + bool GLX_SGI_swap_control; + bool GLX_ARB_multisample; + bool GLX_ARB_fbconfig_float; + bool GLX_EXT_fbconfig_packed_float; + bool GLX_ARB_framebuffer_sRGB; + bool GLX_ARB_create_context; +} GLXExtensions; + +/* Add _ to global symbols to avoid symbol clash with the OpenGL library */ +extern glXGetFBConfigsPROC lwjgl_glXGetFBConfigs; +extern glXChooseFBConfigPROC lwjgl_glXChooseFBConfig; +extern glXGetFBConfigAttribPROC lwjgl_glXGetFBConfigAttrib; +extern glXGetVisualFromFBConfigPROC lwjgl_glXGetVisualFromFBConfig; +extern glXCreateWindowPROC lwjgl_glXCreateWindow; +extern glXDestroyWindowPROC lwjgl_glXDestroyWindow; +extern glXCreatePixmapPROC lwjgl_glXCreatePixmap; +extern glXDestroyPixmapPROC lwjgl_glXDestroyPixmap; +extern glXCreatePbufferPROC lwjgl_glXCreatePbuffer; +extern glXDestroyPbufferPROC lwjgl_glXDestroyPbuffer; +extern glXQueryDrawablePROC lwjgl_glXQueryDrawable; +extern glXCreateNewContextPROC lwjgl_glXCreateNewContext; +extern glXMakeContextCurrentPROC lwjgl_glXMakeContextCurrent; +extern glXGetCurrentReadDrawablePROC lwjgl_glXGetCurrentReadDrawable; +extern glXGetCurrentDisplayPROC lwjgl_glXGetCurrentDisplay; +extern glXQueryContextPROC lwjgl_glXQueryContext; +extern glXSelectEventPROC lwjgl_glXSelectEvent; +extern glXGetSelectedEventPROC lwjgl_glXGetSelectedEvent; + +extern glXChooseVisualPROC lwjgl_glXChooseVisual; +extern glXCopyContextPROC lwjgl_glXCopyContext; +extern glXCreateContextPROC lwjgl_glXCreateContext; +extern glXCreateGLXPixmapPROC lwjgl_glXCreateGLXPixmap; +extern glXDestroyContextPROC lwjgl_glXDestroyContext; +extern glXDestroyGLXPixmapPROC lwjgl_glXDestroyGLXPixmap; +extern glXGetConfigPROC lwjgl_glXGetConfig; +extern glXGetCurrentContextPROC lwjgl_glXGetCurrentContext; +extern glXGetCurrentDrawablePROC lwjgl_glXGetCurrentDrawable; +extern glXIsDirectPROC lwjgl_glXIsDirect; +extern glXMakeCurrentPROC lwjgl_glXMakeCurrent; +extern glXQueryExtensionPROC lwjgl_glXQueryExtension; +extern glXQueryVersionPROC lwjgl_glXQueryVersion; +extern glXSwapBuffersPROC lwjgl_glXSwapBuffers; +extern glXUseXFontPROC lwjgl_glXUseXFont; +extern glXWaitGLPROC lwjgl_glXWaitGL; +extern glXWaitXPROC lwjgl_glXWaitX; +extern glXGetClientStringPROC lwjgl_glXGetClientString; +extern glXQueryServerStringPROC lwjgl_glXQueryServerString; +extern glXQueryExtensionsStringPROC lwjgl_glXQueryExtensionsString; + +extern glXSwapIntervalSGIPROC lwjgl_glXSwapIntervalSGI; + +extern glXCreateContextAttribsARBPROC lwjgl_glXCreateContextAttribsARB; + +extern bool extgl_InitGLX(Display *disp, int screen, GLXExtensions *extension_flags); + +#endif diff --git a/src/native/linux/linux_al.c b/src/native/linux/linux_al.c new file mode 100644 index 0000000..207dea2 --- /dev/null +++ b/src/native/linux/linux_al.c @@ -0,0 +1,65 @@ +/* + * 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. + */ + +#include +#include +#include +#include "org_lwjgl_openal_AL.h" +#include "extal.h" +#include "common_tools.h" + +#include + +static void* handleOAL; + +void *NativeGetFunctionPointer(const char *function) { + return dlsym(handleOAL, function); +} + +void tryLoadLibrary(JNIEnv *env, jstring path) { + char *path_str = GetStringNativeChars(env, path); + printfDebugJava(env, "Testing '%s'", path_str); + handleOAL = dlopen(path_str, RTLD_LAZY); + if (handleOAL != NULL) { + printfDebugJava(env, "Found OpenAL at '%s'", path_str); + } else { + throwException(env, "Could not load OpenAL library"); + } + free(path_str); +} + +void UnLoadOpenAL() { + if (handleOAL != NULL) { + dlclose(handleOAL); + handleOAL = NULL; + } +} diff --git a/src/native/linux/lwjgl.map b/src/native/linux/lwjgl.map new file mode 100644 index 0000000..939db7b --- /dev/null +++ b/src/native/linux/lwjgl.map @@ -0,0 +1,7 @@ +{ + global: + Java_*; + JNI_OnLoad; + JNI_OnUnload; + local: *; +}; diff --git a/src/native/linux/org_lwjgl_input_Cursor.c b/src/native/linux/org_lwjgl_input_Cursor.c new file mode 100644 index 0000000..a974d8d --- /dev/null +++ b/src/native/linux/org_lwjgl_input_Cursor.c @@ -0,0 +1,120 @@ +/* + * 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. + */ + +/** + * $Id: org_lwjgl_input_Cursor.c 2985 2008-04-07 18:42:36Z matzon $ + * + * Linux cursor handling. + * + * @author elias_naur + * @version $Revision: 2985 $ + */ + +#include +#include +#include +#include "org_lwjgl_input_Cursor.h" +#include "org_lwjgl_opengl_LinuxDisplay.h" +#include "common_tools.h" + +JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetNativeCursorCapabilities + (JNIEnv *env, jclass clazz, jlong display) { + Display *disp = (Display *)(intptr_t)display; + int caps = 0; + XcursorBool argb_supported = XcursorSupportsARGB(disp); + XcursorBool anim_supported = XcursorSupportsAnim(disp); + if (argb_supported) + caps |= org_lwjgl_input_Cursor_CURSOR_8_BIT_ALPHA | org_lwjgl_input_Cursor_CURSOR_ONE_BIT_TRANSPARENCY; + if (anim_supported) + caps |= org_lwjgl_input_Cursor_CURSOR_ANIMATION; + return caps; +} + +JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetMinCursorSize + (JNIEnv *env, jclass clazz, jlong display, jlong window_ptr) +{ + Display *disp = (Display *)(intptr_t)display; + Window window = (Window)window_ptr; + unsigned int width_return = 0; + unsigned int height_return = 0; + XQueryBestCursor(disp, window, 1, 1, &width_return, &height_return); + return width_return > height_return ? width_return : height_return; +} + +JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetMaxCursorSize + (JNIEnv *env, jclass clazz, jlong display, jlong window_ptr) +{ + Display *disp = (Display *)(intptr_t)display; + Window window = (Window)window_ptr; + unsigned int width_return = 0; + unsigned int height_return = 0; + XQueryBestCursor(disp, window, 0xffffffff, 0xffffffff, &width_return, &height_return); + return width_return > height_return ? height_return : width_return; +} + +JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nCreateCursor + (JNIEnv *env, jclass clazz, jlong display, jint width, jint height, jint x_hotspot, jint y_hotspot, jint num_images, jobject image_buffer, jint images_offset, jobject delay_buffer, jint delays_offset) +{ + Display *disp = (Display *)(intptr_t)display; + const int *delays = NULL; + if (delay_buffer != NULL) + delays = (const int *)(*env)->GetDirectBufferAddress(env, delay_buffer) + delays_offset; + XcursorPixel *pixels = (XcursorPixel *)(*env)->GetDirectBufferAddress(env, image_buffer) + images_offset; + int stride = width*height; + XcursorImages *cursor_images = XcursorImagesCreate(num_images); + if (cursor_images == NULL) { + throwException(env, "Could not allocate cursor."); + return None; + } + cursor_images->nimage = num_images; + int i; + for (i = 0; i < num_images; i++) { + XcursorImage *cursor_image = XcursorImageCreate(width, height); + cursor_image->xhot = x_hotspot; + cursor_image->yhot = y_hotspot; + cursor_image->pixels = &(pixels[stride*i]); + if (num_images > 1) + cursor_image->delay = delays[i]; + cursor_images->images[i] = cursor_image; + } + Cursor cursor = XcursorImagesLoadCursor(disp, cursor_images); + XcursorImagesDestroy(cursor_images); + return cursor; +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nDestroyCursor + (JNIEnv *env, jclass clazz, jlong display, jlong cursor_ptr) +{ + Display *disp = (Display *)(intptr_t)display; + Cursor cursor = (Cursor)cursor_ptr; + XFreeCursor(disp, cursor); +} diff --git a/src/native/linux/org_lwjgl_opengl_Display.c b/src/native/linux/org_lwjgl_opengl_Display.c new file mode 100644 index 0000000..3e5d565 --- /dev/null +++ b/src/native/linux/org_lwjgl_opengl_Display.c @@ -0,0 +1,589 @@ +/* + * 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. + */ + +/** + * $Id: org_lwjgl_opengl_Display.c 3188 2009-03-19 21:50:30Z elias_naur $ + * + * Linux specific display functions. + * + * @author elias_naur + * @version $Revision: 3188 $ + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "common_tools.h" +#include "extgl.h" +#include "extgl_glx.h" +#include "context.h" +#include "org_lwjgl_opengl_LinuxDisplay.h" +#include "org_lwjgl_opengl_LinuxDisplayPeerInfo.h" +#include "org_lwjgl_LinuxSysImplementation.h" + +#define ERR_MSG_SIZE 1024 + +typedef struct { + unsigned long flags; + unsigned long functions; + unsigned long decorations; + long input_mode; + unsigned long status; +} MotifWmHints; + +#define MWM_HINTS_DECORATIONS (1L << 1) + +static GLXWindow glx_window = None; + +static Colormap cmap; +static int current_depth; +static Pixmap current_icon_pixmap; +static Pixmap current_icon_mask_pixmap; + +static Visual *current_visual; + +static bool checkXError(JNIEnv *env, Display *disp) { + XSync(disp, False); + return (*env)->ExceptionCheck(env) == JNI_FALSE; +} + +static int global_error_handler(Display *disp, XErrorEvent *error) { + JNIEnv *env = getThreadEnv(); + if (env != NULL) { + jclass org_lwjgl_LinuxDisplay_class = (*env)->FindClass(env, "org/lwjgl/opengl/LinuxDisplay"); + if (org_lwjgl_LinuxDisplay_class == NULL) { + // Don't propagate error + (*env)->ExceptionClear(env); + return 0; + } + jmethodID handler_method = (*env)->GetStaticMethodID(env, org_lwjgl_LinuxDisplay_class, "globalErrorHandler", "(JJJJJJJ)I"); + if (handler_method == NULL) + return 0; + return (*env)->CallStaticIntMethod(env, org_lwjgl_LinuxDisplay_class, handler_method, (jlong)(intptr_t)disp, (jlong)(intptr_t)error, + (jlong)(intptr_t)error->display, (jlong)error->serial, (jlong)error->error_code, (jlong)error->request_code, (jlong)error->minor_code); + } else + return 0; +} + +static jlong openDisplay(JNIEnv *env) { + Display *display_connection = XOpenDisplay(NULL); + if (display_connection == NULL) { + throwException(env, "Could not open X display connection"); + return (intptr_t)NULL; + } + return (intptr_t)display_connection; +} + +JNIEXPORT jint JNICALL Java_org_lwjgl_DefaultSysImplementation_getJNIVersion + (JNIEnv *env, jobject ignored) { + return org_lwjgl_LinuxSysImplementation_JNI_VERSION; +} + +JNIEXPORT jstring JNICALL Java_org_lwjgl_opengl_LinuxDisplay_getErrorText(JNIEnv *env, jclass unused, jlong display_ptr, jlong error_code) { + Display *disp = (Display *)(intptr_t)display_ptr; + char err_msg_buffer[ERR_MSG_SIZE]; + XGetErrorText(disp, error_code, err_msg_buffer, ERR_MSG_SIZE); + err_msg_buffer[ERR_MSG_SIZE - 1] = '\0'; + return NewStringNativeWithLength(env, err_msg_buffer, strlen(err_msg_buffer)); +} + +JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_callErrorHandler(JNIEnv *env, jclass unused, jlong handler_ptr, jlong display_ptr, jlong event_ptr) { + XErrorHandler handler = (XErrorHandler)(intptr_t)handler_ptr; + Display *disp = (Display *)(intptr_t)display_ptr; + XErrorEvent *event = (XErrorEvent *)(intptr_t)event_ptr; + return (jint)handler(disp, event); +} + +JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxDisplay_setErrorHandler(JNIEnv *env, jclass unused) { + return (intptr_t)XSetErrorHandler(global_error_handler); +} + +JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxDisplay_resetErrorHandler(JNIEnv *env, jclass unused, jlong handler_ptr) { + XErrorHandler handler = (XErrorHandler)(intptr_t)handler_ptr; + return (intptr_t)XSetErrorHandler(handler); +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_sync(JNIEnv *env, jclass unused, jlong display_ptr, jboolean throw_away_events) { + Display *disp = (Display *)(intptr_t)display_ptr; + XSync(disp, throw_away_events ? True : False); +} + +JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetDefaultScreen(JNIEnv *env, jclass unused, jlong display_ptr) { + Display *disp = (Display *)(intptr_t)display_ptr; + return XDefaultScreen(disp); +} + +JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nInternAtom(JNIEnv *env, jclass unused, jlong display_ptr, jstring atom_name_obj, jboolean only_if_exists) { + Display *disp = (Display *)(intptr_t)display_ptr; + char *atom_name = GetStringNativeChars(env, atom_name_obj); + if (atom_name == NULL) + return 0; + Atom atom = XInternAtom(disp, atom_name, only_if_exists ? True : False); + free(atom_name); + return atom; +} + +static void setDecorations(Display *disp, Window window, int dec) { + Atom motif_hints_atom = XInternAtom(disp, "_MOTIF_WM_HINTS", False); + MotifWmHints motif_hints; + motif_hints.flags = MWM_HINTS_DECORATIONS; + motif_hints.decorations = dec; + XChangeProperty(disp, window, motif_hints_atom, motif_hints_atom, 32, PropModeReplace, (unsigned char *)&motif_hints, sizeof(MotifWmHints)/sizeof(long)); +} + +static bool isLegacyFullscreen(jint window_mode) { + return window_mode == org_lwjgl_opengl_LinuxDisplay_FULLSCREEN_LEGACY; +} + +static void setWindowTitle(Display *disp, Window window, const char *title) { + XStoreName(disp, window, title); +} + +JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxDisplay_openDisplay(JNIEnv *env, jclass clazz) { + return openDisplay(env); +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_closeDisplay(JNIEnv *env, jclass clazz, jlong display) { + Display *disp = (Display *)(intptr_t)display; + XCloseDisplay(disp); +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplayPeerInfo_initDrawable(JNIEnv *env, jclass clazz, jlong window, jobject peer_info_handle) { + X11PeerInfo *peer_info = (*env)->GetDirectBufferAddress(env, peer_info_handle); + if (peer_info->glx13) + peer_info->drawable = glx_window; + else + peer_info->drawable = window; +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplayPeerInfo_initDefaultPeerInfo(JNIEnv *env, jclass clazz, jlong display, jint screen, jobject peer_info_handle, jobject pixel_format) { + Display *disp = (Display *)(intptr_t)display; + initPeerInfo(env, peer_info_handle, disp, screen, pixel_format, true, GLX_WINDOW_BIT, true, false); +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nSetTitle(JNIEnv * env, jclass clazz, jlong display, jlong window_ptr, jstring title_obj) { + Display *disp = (Display *)(intptr_t)display; + Window window = (Window)window_ptr; + char * title = GetStringNativeChars(env, title_obj); + setWindowTitle(disp, window, title); + free(title); +} + +static void freeIconPixmap(Display *disp) { + if (current_icon_mask_pixmap != 0) { + XFreePixmap(disp, current_icon_mask_pixmap); + current_icon_mask_pixmap = 0; + } + if (current_icon_pixmap != 0) { + XFreePixmap(disp, current_icon_pixmap); + current_icon_pixmap = 0; + } +} + +static void destroyWindow(JNIEnv *env, Display *disp, Window window) { + if (glx_window != None) { + lwjgl_glXDestroyWindow(disp, glx_window); + glx_window = None; + } + XDestroyWindow(disp, window); + XFreeColormap(disp, cmap); + freeIconPixmap(disp); +} + +static bool isNetWMFullscreenSupported(JNIEnv *env, Display *disp, int screen) { + unsigned long nitems; + Atom actual_type; + int actual_format; + unsigned long bytes_after; + Atom *supported_list; + Atom netwm_supported_atom = XInternAtom(disp, "_NET_SUPPORTED", False); + int result = XGetWindowProperty(disp, RootWindow(disp, screen), netwm_supported_atom, 0, 10000, False, AnyPropertyType, &actual_type, &actual_format, &nitems, &bytes_after, (void *)&supported_list); + if (result != Success) { + throwException(env, "Unable to query _NET_SUPPORTED window property"); + return false; + } + Atom fullscreen_atom = XInternAtom(disp, "_NET_WM_STATE_FULLSCREEN", False); + bool supported = false; + unsigned long i; + for (i = 0; i < nitems; i++) { + if (fullscreen_atom == supported_list[i]) { + supported = true; + break; + } + } + XFree(supported_list); + return supported; +} + +JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nIsNetWMFullscreenSupported(JNIEnv *env, jclass unused, jlong display, jint screen) { + Display *disp = (Display *)(intptr_t)display; + return isNetWMFullscreenSupported(env, disp, screen) ? JNI_TRUE : JNI_FALSE; +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nReshape(JNIEnv *env, jclass clazz, jlong display, jlong window_ptr, jint x, jint y, jint width, jint height) { + Display *disp = (Display *)(intptr_t)display; + Window window = (Window)window_ptr; + XMoveWindow(disp, window, x, y); + XResizeWindow(disp, window, width, height); +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_synchronize(JNIEnv *env, jclass clazz, jlong display, jboolean synchronize) { + Display *disp = (Display *)(intptr_t)display; + XSynchronize(disp, synchronize ? True : False); +} + +JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxDisplay_getRootWindow(JNIEnv *env, jclass clazz, jlong display, jint screen) { + Display *disp = (Display *)(intptr_t)display; + return RootWindow(disp, screen); +} + +static void updateWindowHints(JNIEnv *env, Display *disp, Window window) { + XWMHints* win_hints = XAllocWMHints(); + if (win_hints == NULL) { + throwException(env, "XAllocWMHints failed"); + return; + } + + win_hints->flags = InputHint; + win_hints->input = True; + if (current_icon_pixmap != 0) { + win_hints->flags |= IconPixmapHint; + win_hints->icon_pixmap = current_icon_pixmap; + } + if (current_icon_mask_pixmap != 0) { + win_hints->flags |= IconMaskHint; + win_hints->icon_mask = current_icon_mask_pixmap; + } + + XSetWMHints(disp, window, win_hints); + XFree(win_hints); + XFlush(disp); +} + +static Window createWindow(JNIEnv* env, Display *disp, int screen, jint window_mode, X11PeerInfo *peer_info, int x, int y, int width, int height, jboolean undecorated, long parent_handle) { + Window parent = (Window)parent_handle; + Window win; + XSetWindowAttributes attribs; + int attribmask; + + XVisualInfo *vis_info = getVisualInfoFromPeerInfo(env, peer_info); + if (vis_info == NULL) + return false; + cmap = XCreateColormap(disp, parent, vis_info->visual, AllocNone); + attribs.colormap = cmap; + attribs.border_pixel = 0; + attribs.event_mask = ExposureMask | FocusChangeMask | VisibilityChangeMask | StructureNotifyMask | KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | PointerMotionMask; + attribmask = CWColormap | CWEventMask | CWBorderPixel; + if (isLegacyFullscreen(window_mode)) { + attribmask |= CWOverrideRedirect; + attribs.override_redirect = True; + } + win = XCreateWindow(disp, parent, x, y, width, height, 0, vis_info->depth, InputOutput, vis_info->visual, attribmask, &attribs); + + current_depth = vis_info->depth; + current_visual = vis_info->visual; + + XFree(vis_info); + if (!checkXError(env, disp)) { + XFreeColormap(disp, cmap); + return false; + } +// printfDebugJava(env, "Created window"); + if (undecorated) { + // Use Motif decoration hint property and hope the window manager respects them + setDecorations(disp, win, 0); + } + XSizeHints * size_hints = XAllocSizeHints(); + size_hints->flags = PMinSize | PMaxSize; + size_hints->min_width = width; + size_hints->max_width = width; + size_hints->min_height = height; + size_hints->max_height = height; + XSetWMNormalHints(disp, win, size_hints); + updateWindowHints(env, disp, win); + XFree(size_hints); +#define NUM_ATOMS 1 + Atom protocol_atoms[NUM_ATOMS] = {XInternAtom(disp, "WM_DELETE_WINDOW", False)/*, XInternAtom(disp, "WM_TAKE_FOCUS", False)*/}; + XSetWMProtocols(disp, win, protocol_atoms, NUM_ATOMS); + if (window_mode == org_lwjgl_opengl_LinuxDisplay_FULLSCREEN_NETWM) { + Atom fullscreen_atom = XInternAtom(disp, "_NET_WM_STATE_FULLSCREEN", False); + XChangeProperty(disp, win, XInternAtom(disp, "_NET_WM_STATE", False), + XInternAtom(disp, "ATOM", False), 32, PropModeReplace, (const unsigned char*)&fullscreen_atom, 1); + } + if (!checkXError(env, disp)) { + destroyWindow(env, disp, win); + return 0; + } + return win; +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_reparentWindow(JNIEnv *env, jclass unused, jlong display, jlong window_ptr, jlong parent_ptr, jint x, jint y) { + Display *disp = (Display *)(intptr_t)display; + Window window = (Window)window_ptr; + Window parent = (Window)parent_ptr; + XReparentWindow(disp, window, parent, x, y); +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_mapRaised(JNIEnv *env, jclass unused, jlong display, jlong window_ptr) { + Display *disp = (Display *)(intptr_t)display; + Window window = (Window)window_ptr; + XMapRaised(disp, window); +} + +JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxDisplay_getParentWindow(JNIEnv *env, jclass unused, jlong display, jlong window_ptr) { + Display *disp = (Display *)(intptr_t)display; + Window window = (Window)window_ptr; + Window root, parent; + Window *children; + unsigned int nchildren; + if (XQueryTree(disp, window, &root, &parent, &children, &nchildren) == 0) { + throwException(env, "XQueryTree failed"); + return None; + } + if (children != NULL) + XFree(children); + return parent; +} + +JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_LinuxDisplay_hasProperty(JNIEnv *env, jclass unusued, jlong display, jlong window_ptr, jlong property_ptr) { + Display *disp = (Display *)(intptr_t)display; + Window window = (Window)window_ptr; + Atom property = (Atom)property_ptr; + int num_props; + Atom *properties = XListProperties(disp, window, &num_props); + if (properties == NULL) + return JNI_FALSE; + jboolean result = JNI_FALSE; + for (int i = 0; i < num_props; i++) { + if (properties[i] == property) { + result = JNI_TRUE; + break; + } + } + XFree(properties); + return result; +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_setInputFocus(JNIEnv *env, jclass clazz, jlong display, jlong window_ptr, jlong time) { + Display *disp = (Display *)(intptr_t)display; + Window window = (Window)window_ptr; + XSetInputFocus(disp, window, RevertToParent, time); +} + +JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nCreateWindow(JNIEnv *env, jclass clazz, jlong display, jint screen, jobject peer_info_handle, jobject mode, jint window_mode, jint x, jint y, jboolean undecorated, jlong parent_handle) { + Display *disp = (Display *)(intptr_t)display; + X11PeerInfo *peer_info = (*env)->GetDirectBufferAddress(env, peer_info_handle); + GLXFBConfig *fb_config = NULL; + if (peer_info->glx13) { + fb_config = getFBConfigFromPeerInfo(env, peer_info); + if (fb_config == NULL) + return 0; + } + jclass cls_displayMode = (*env)->GetObjectClass(env, mode); + jfieldID fid_width = (*env)->GetFieldID(env, cls_displayMode, "width", "I"); + jfieldID fid_height = (*env)->GetFieldID(env, cls_displayMode, "height", "I"); + int width = (*env)->GetIntField(env, mode, fid_width); + int height = (*env)->GetIntField(env, mode, fid_height); + Window win = createWindow(env, disp, screen, window_mode, peer_info, x, y, width, height, undecorated, parent_handle); + if ((*env)->ExceptionOccurred(env)) { + return 0; + } + if (peer_info->glx13) { + glx_window = lwjgl_glXCreateWindow(disp, *fb_config, win, NULL); + XFree(fb_config); + } + if (!checkXError(env, disp)) { + lwjgl_glXDestroyWindow(disp, glx_window); + destroyWindow(env, disp, win); + } + return win; +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nDestroyWindow(JNIEnv *env, jclass clazz, jlong display, jlong window_ptr) { + Display *disp = (Display *)(intptr_t)display; + Window window = (Window)window_ptr; + destroyWindow(env, disp, window); +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nLockAWT(JNIEnv *env, jclass clazz) { + JAWT jawt; + jawt.version = JAWT_VERSION_1_4; + if (JAWT_GetAWT(env, &jawt) != JNI_TRUE) { + throwException(env, "GetAWT failed"); + return; + } + jawt.Lock(env); +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nUnlockAWT(JNIEnv *env, jclass clazz) { + JAWT jawt; + jawt.version = JAWT_VERSION_1_4; + if (JAWT_GetAWT(env, &jawt) != JNI_TRUE) { + throwException(env, "GetAWT failed"); + return; + } + jawt.Unlock(env); +} + +static Pixmap createPixmapFromBuffer(JNIEnv *env, Display *disp, Window window, char *data, int data_size, int width, int height, int format, int depth) { + Pixmap pixmap = XCreatePixmap(disp, window, width, height, depth); + /* We need to copy the image data since XDestroyImage will also free its data buffer, which can't be allowed + * since the data buffer is managed by the jvm (it's the storage for the direct ByteBuffer) + */ + char *icon_copy = (char *)malloc(sizeof(*icon_copy)*data_size); + + if (icon_copy == NULL) { + XFreePixmap(disp, pixmap); + throwException(env, "malloc failed"); + return None; + } + memcpy(icon_copy, data, data_size); + XImage *image = XCreateImage(disp, current_visual, depth, format, 0, icon_copy, width, height, 32, 0); + if (image == NULL) { + XFreePixmap(disp, pixmap); + free(icon_copy); + throwException(env, "XCreateImage failed"); + return None; + } + + GC gc = XCreateGC(disp, pixmap, 0, NULL); + XPutImage(disp, pixmap, gc, image, 0, 0, 0, 0, width, height); + XFreeGC(disp, gc); + XDestroyImage(image); + // We won't free icon_copy because it is freed by XDestroyImage + return pixmap; +} + +static void setIcon(JNIEnv *env, Display *disp, Window window, char *rgb_data, int rgb_size, char *mask_data, int mask_size, int width, int height) { + freeIconPixmap(disp); + current_icon_pixmap = createPixmapFromBuffer(env, disp, window, rgb_data, rgb_size, width, height, ZPixmap, current_depth); + if ((*env)->ExceptionCheck(env)) + return; + current_icon_mask_pixmap = createPixmapFromBuffer(env, disp, window, mask_data, mask_size, width, height, XYPixmap, 1); + if ((*env)->ExceptionCheck(env)) { + freeIconPixmap(disp); + return; + } + + updateWindowHints(env, disp, window); +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nSetWindowIcon + (JNIEnv *env, jclass clazz, jlong display, jlong window_ptr, jobject icon_rgb_buffer, jint rgb_size, jobject icon_mask_buffer, jint mask_size, jint width, jint height) +{ + Display *disp = (Display *)(intptr_t)display; + Window window = (Window)window_ptr; + char *rgb_data= (char *)(*env)->GetDirectBufferAddress(env, icon_rgb_buffer); + char *mask_data= (char *)(*env)->GetDirectBufferAddress(env, icon_mask_buffer); + + setIcon(env, disp, window, rgb_data, rgb_size, mask_data, mask_size, width, height); +} + +JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nUngrabKeyboard(JNIEnv *env, jclass unused, jlong display_ptr) { + Display *disp = (Display *)(intptr_t)display_ptr; + return XUngrabKeyboard(disp, CurrentTime); +} + +JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGrabKeyboard(JNIEnv *env, jclass unused, jlong display_ptr, jlong window_ptr) { + Display *disp = (Display *)(intptr_t)display_ptr; + Window win = (Window)window_ptr; + return XGrabKeyboard(disp, win, False, GrabModeAsync, GrabModeAsync, CurrentTime); +} + +JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGrabPointer(JNIEnv *env, jclass unused, jlong display_ptr, jlong window_ptr, jlong cursor_ptr) { + Display *disp = (Display *)(intptr_t)display_ptr; + Window win = (Window)window_ptr; + Cursor cursor = (Cursor)cursor_ptr; + int grab_mask = PointerMotionMask | ButtonPressMask | ButtonReleaseMask; + return XGrabPointer(disp, win, False, grab_mask, GrabModeAsync, GrabModeAsync, win, cursor, CurrentTime); +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nSetViewPort(JNIEnv *env, jclass unused, jlong display_ptr, jlong window_ptr, jint screen) { + Display *disp = (Display *)(intptr_t)display_ptr; + Window win = (Window)window_ptr; + XWindowAttributes win_attribs; + + XGetWindowAttributes(disp, win, &win_attribs); + XF86VidModeSetViewPort(disp, screen, win_attribs.x, win_attribs.y); +} + +JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nUngrabPointer(JNIEnv *env, jclass unused, jlong display_ptr) { + Display *disp = (Display *)(intptr_t)display_ptr; + return XUngrabPointer(disp, CurrentTime); +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nDefineCursor(JNIEnv *env, jclass unused, jlong display_ptr, jlong window_ptr, jlong cursor_ptr) { + Display *disp = (Display *)(intptr_t)display_ptr; + Window win = (Window)window_ptr; + Cursor cursor = (Cursor)cursor_ptr; + XDefineCursor(disp, win, cursor); +} + +JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nCreateBlankCursor(JNIEnv *env, jclass unused, jlong display_ptr, jlong window_ptr) { + Display *disp = (Display *)(intptr_t)display_ptr; + Window win = (Window)window_ptr; + unsigned int best_width, best_height; + if (XQueryBestCursor(disp, win, 1, 1, &best_width, &best_height) == 0) { + throwException(env, "Could not query best cursor size"); + return false; + } + Pixmap mask = XCreatePixmap(disp, win, best_width, best_height, 1); + XGCValues gc_values; + gc_values.foreground = 0; + GC gc = XCreateGC(disp, mask, GCForeground, &gc_values); + XFillRectangle(disp, mask, gc, 0, 0, best_width, best_height); + XFreeGC(disp, gc); + XColor dummy_color; + Cursor cursor = XCreatePixmapCursor(disp, mask, mask, &dummy_color, &dummy_color, 0, 0); + XFreePixmap(disp, mask); + return cursor; +} + +JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetInputFocus(JNIEnv *env, jclass unused, jlong display_ptr) { + Display *disp = (Display *)(intptr_t)display_ptr; + int revert_mode; + Window win; + XGetInputFocus(disp, &win, &revert_mode); + return win; +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nIconifyWindow(JNIEnv *env, jclass unused, jlong display_ptr, jlong window_ptr, jint screen) { + Display *disp = (Display *)(intptr_t)display_ptr; + Window win = (Window)window_ptr; + XIconifyWindow(disp, win, screen); +} diff --git a/src/native/linux/org_lwjgl_opengl_LinuxAWTGLCanvasPeerInfo.c b/src/native/linux/org_lwjgl_opengl_LinuxAWTGLCanvasPeerInfo.c new file mode 100644 index 0000000..84797ee --- /dev/null +++ b/src/native/linux/org_lwjgl_opengl_LinuxAWTGLCanvasPeerInfo.c @@ -0,0 +1,82 @@ +/* + * 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. + */ + +/** + * $Id: org_lwjgl_opengl_LinuxAWTGLCanvasPeerInfo.c 2985 2008-04-07 18:42:36Z matzon $ + * + * @author elias_naur + * @version $Revision: 2985 $ + */ + +#include +#include +#include +#include +#include +#include "awt_tools.h" +#include "org_lwjgl_opengl_LinuxAWTGLCanvasPeerInfo.h" +#include "context.h" + +JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxAWTGLCanvasPeerInfo_getScreenFromSurfaceInfo + (JNIEnv *env, jclass clazz, jobject lock_buffer_handle) { + const AWTSurfaceLock *awt_lock = (AWTSurfaceLock *)(*env)->GetDirectBufferAddress(env, lock_buffer_handle); + // Get the platform-specific drawing info + JAWT_X11DrawingSurfaceInfo *dsi_x11 = (JAWT_X11DrawingSurfaceInfo*)awt_lock->dsi->platformInfo; + + XVisualInfo template; + int num_infos; + template.visualid = dsi_x11->visualID; + template.depth = dsi_x11->depth; + XVisualInfo *vis_info = XGetVisualInfo(dsi_x11->display, VisualIDMask | VisualDepthMask, &template, &num_infos); + if (vis_info == NULL) { + throwException(env, "Could not determine screen"); + return -1; + } + int screen = vis_info[0].screen; + XFree(vis_info); + return screen; +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxAWTGLCanvasPeerInfo_nInitHandle + (JNIEnv *env, jclass clazz, int screen, jobject lock_buffer_handle, jobject peer_info_handle) { + const AWTSurfaceLock *awt_lock = (AWTSurfaceLock *)(*env)->GetDirectBufferAddress(env, lock_buffer_handle); + X11PeerInfo *peer_info = (X11PeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle); + // Get the platform-specific drawing info + JAWT_X11DrawingSurfaceInfo *dsi_x11 = (JAWT_X11DrawingSurfaceInfo*)awt_lock->dsi->platformInfo; + + peer_info->display = dsi_x11->display; + peer_info->screen = screen; + peer_info->drawable = dsi_x11->drawable; + peer_info->glx13 = false; + peer_info->config.glx_config.visualid = dsi_x11->visualID; + peer_info->config.glx_config.depth = dsi_x11->depth; +} diff --git a/src/native/linux/org_lwjgl_opengl_LinuxCanvasImplementation.c b/src/native/linux/org_lwjgl_opengl_LinuxCanvasImplementation.c new file mode 100644 index 0000000..a27efea --- /dev/null +++ b/src/native/linux/org_lwjgl_opengl_LinuxCanvasImplementation.c @@ -0,0 +1,65 @@ +/* + * 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. + */ + +/** + * $Id: org_lwjgl_opengl_LinuxCanvasImplementation.c 2985 2008-04-07 18:42:36Z matzon $ + * + * @author elias_naur + * @version $Revision: 2985 $ + */ + +#include +#include +#include +#include +#include "org_lwjgl_opengl_LinuxCanvasImplementation.h" +#include "extgl_glx.h" +#include "context.h" + +JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxCanvasImplementation_nFindVisualIDFromFormat + (JNIEnv *env, jclass clazz, jlong display, jint screen, jobject pixel_format) { + Display *disp = (Display *)(intptr_t)display; + GLXExtensions extension_flags; + if (!extgl_InitGLX(disp, screen, &extension_flags)) { + throwException(env, "Could not initialize GLX"); + return -1; + } + XVisualInfo *vis_info = chooseVisualGLX(env, disp, screen, pixel_format, true, true); + if (vis_info == NULL) { + throwException(env, "Could not choose a VisualInfo"); + return -1; + } + + VisualID vis_id = vis_info->visualid; + XFree(vis_info); + return vis_id; +} diff --git a/src/native/linux/org_lwjgl_opengl_LinuxContextImplementation.c b/src/native/linux/org_lwjgl_opengl_LinuxContextImplementation.c new file mode 100644 index 0000000..f810b70 --- /dev/null +++ b/src/native/linux/org_lwjgl_opengl_LinuxContextImplementation.c @@ -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. + */ + +/** + * $Id: org_lwjgl_opengl_LinuxContextImplementation.c 3203 2009-04-24 20:35:33Z elias_naur $ + * + * @author elias_naur + * @version $Revision: 3203 $ + */ + +#include +#include +#include +#include +#include "org_lwjgl_opengl_LinuxContextImplementation.h" +#include "extgl_glx.h" +#include "context.h" +#include "common_tools.h" + +typedef struct { + GLXExtensions extension_flags; + GLXContext context; +} X11Context; + +static bool checkContext(JNIEnv *env, Display *display, GLXContext context) { + if (context == NULL) { + throwException(env, "Could not create GLX context"); + return false; + } + /* + * Ditched the requirement that contexts have to be direct. It was + * never true that all accelerated contexts are direct, but it + * was a reasonable test until the appearance of Xgl and AIGLX. + * Now the test is at best useless, and at worst wrong, + * in case the current X server accelerates indirect rendering. + */ +/* jboolean allow_software_acceleration = getBooleanProperty(env, "org.lwjgl.opengl.Display.allowSoftwareOpenGL"); + if (!allow_software_acceleration && lwjgl_glXIsDirect(display, context) == False) { + lwjgl_glXDestroyContext(display, context); + throwException(env, "Could not create a direct GLX context"); + return false; + }*/ + return true; +} + +static void createContextGLX13(JNIEnv *env, X11PeerInfo *peer_info, X11Context *context_info, jobject attribs, GLXContext shared_context) { + GLXFBConfig *config = getFBConfigFromPeerInfo(env, peer_info); + if (config == NULL) + return; + GLXContext context; + if (attribs) { + const int *attrib_list = (const int *)(*env)->GetDirectBufferAddress(env, attribs); + context = lwjgl_glXCreateContextAttribsARB(peer_info->display, *config, shared_context, True, attrib_list); + } else { + int render_type; + if (lwjgl_glXGetFBConfigAttrib(peer_info->display, *config, GLX_RENDER_TYPE, &render_type) != 0) { + throwException(env, "Could not get GLX_RENDER_TYPE attribute"); + return; + } + int context_render_type = (render_type & GLX_RGBA_FLOAT_BIT) != 0 ? GLX_RGBA_FLOAT_TYPE : GLX_RGBA_TYPE; + context = lwjgl_glXCreateNewContext(peer_info->display, *config, context_render_type, shared_context, True); + } + XFree(config); + if (!checkContext(env, peer_info->display, context)) + return; + context_info->context = context; +} + +static void createContextGLX(JNIEnv *env, X11PeerInfo *peer_info, X11Context *context_info, GLXContext shared_context) { + XVisualInfo *vis_info = getVisualInfoFromPeerInfo(env, peer_info); + if (vis_info == NULL) + return; + GLXContext context = lwjgl_glXCreateContext(peer_info->display, vis_info, shared_context, True); + XFree(vis_info); + if (!checkContext(env, peer_info->display, context)) + return; + context_info->context = context; +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxContextImplementation_nSetSwapInterval + (JNIEnv *env, jclass clazz, jobject context_handle, jint value) +{ + X11Context *context_info = (*env)->GetDirectBufferAddress(env, context_handle); + if (context_info->extension_flags.GLX_SGI_swap_control) { + lwjgl_glXSwapIntervalSGI(value); + } +} + +JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_LinuxContextImplementation_nCreate + (JNIEnv *env , jclass clazz, jobject peer_handle, jobject attribs, jobject shared_context_handle) { + jobject context_handle = newJavaManagedByteBuffer(env, sizeof(X11Context)); + if (context_handle == NULL) { + throwException(env, "Could not allocate handle buffer"); + return NULL; + } + X11PeerInfo *peer_info = (*env)->GetDirectBufferAddress(env, peer_handle); + X11Context *context_info = (*env)->GetDirectBufferAddress(env, context_handle); + GLXExtensions extension_flags; + if (!extgl_InitGLX(peer_info->display, peer_info->screen, &extension_flags)) { + throwException(env, "Could not initialize GLX"); + return NULL; + } + GLXContext shared_context = NULL; + if (shared_context_handle != NULL) { + X11Context *shared_context_info = (*env)->GetDirectBufferAddress(env, shared_context_handle); + shared_context = shared_context_info->context; + } + if (peer_info->glx13) { + createContextGLX13(env, peer_info, context_info, extension_flags.GLX_ARB_create_context ? attribs : NULL, shared_context); + } else { + createContextGLX(env, peer_info, context_info, shared_context); + } + context_info->extension_flags = extension_flags; + return context_handle; +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxContextImplementation_nDestroy + (JNIEnv *env, jclass clazz, jobject peer_handle, jobject context_handle) { + X11PeerInfo *peer_info = (*env)->GetDirectBufferAddress(env, peer_handle); + X11Context *context_info = (*env)->GetDirectBufferAddress(env, context_handle); + lwjgl_glXDestroyContext(peer_info->display, context_info->context); +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxContextImplementation_nReleaseCurrentContext + (JNIEnv *env , jclass clazz, jobject peer_info_handle) { + X11PeerInfo *peer_info = (*env)->GetDirectBufferAddress(env, peer_info_handle); + Bool result; + if (peer_info->glx13) { + result = lwjgl_glXMakeContextCurrent(peer_info->display, None, None, NULL); + } else { + result = lwjgl_glXMakeCurrent(peer_info->display, None, NULL); + } + if (!result) + throwException(env, "Could not release current context"); +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxContextImplementation_nMakeCurrent + (JNIEnv *env, jclass clazz, jobject peer_info_handle, jobject context_handle) { + X11PeerInfo *peer_info = (*env)->GetDirectBufferAddress(env, peer_info_handle); + X11Context *context_info = (*env)->GetDirectBufferAddress(env, context_handle); + Bool result; + if (peer_info->glx13) { + result = lwjgl_glXMakeContextCurrent(peer_info->display, peer_info->drawable, peer_info->drawable, context_info->context); + } else { + result = lwjgl_glXMakeCurrent(peer_info->display, peer_info->drawable, context_info->context); + } + if (!result) + throwException(env, "Could not make context current"); +} + +JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_LinuxContextImplementation_nIsCurrent + (JNIEnv *env, jclass clazz, jobject context_handle) { + X11Context *context_info = (*env)->GetDirectBufferAddress(env, context_handle); + return context_info->context == lwjgl_glXGetCurrentContext(); +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxContextImplementation_nSwapBuffers + (JNIEnv *env, jclass clazz, jobject peer_info_handle) { + X11PeerInfo *peer_info = (*env)->GetDirectBufferAddress(env, peer_info_handle); + lwjgl_glXSwapBuffers(peer_info->display, peer_info->drawable); +} diff --git a/src/native/linux/org_lwjgl_opengl_LinuxEvent.c b/src/native/linux/org_lwjgl_opengl_LinuxEvent.c new file mode 100644 index 0000000..41ac284 --- /dev/null +++ b/src/native/linux/org_lwjgl_opengl_LinuxEvent.c @@ -0,0 +1,185 @@ +/* + * 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. + */ + +/** + * $Id: org_lwjgl_opengl_LinuxEvent.c 2598 2006-10-24 08:33:09Z elias_naur $ + * + * @author elias_naur + * @version $Revision: 2598 $ + */ + +#include +#include +#include +#include +#include "common_tools.h" +#include "org_lwjgl_opengl_LinuxEvent.h" + +JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_LinuxEvent_createEventBuffer(JNIEnv *env, jclass unused) { + return newJavaManagedByteBuffer(env, sizeof(XEvent)); +} + +JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxEvent_getPending(JNIEnv *env, jclass unused, jlong display_ptr) { + Display *disp = (Display *)(intptr_t)display_ptr; + return XPending(disp); +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxEvent_nSetWindow(JNIEnv *env, jclass unused, jobject event_buffer, jlong window_ptr) { + XEvent *event = (XEvent *)(*env)->GetDirectBufferAddress(env, event_buffer); + Window window = (Window)window_ptr; + event->xany.window = window; +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxEvent_nSendEvent(JNIEnv *env, jclass unused, jobject event_buffer, jlong display_ptr, jlong window_ptr, jboolean propagate, jlong eventmask) { + XEvent *event = (XEvent *)(*env)->GetDirectBufferAddress(env, event_buffer); + Display *disp = (Display *)(intptr_t)display_ptr; + Window window = (Window)window_ptr; + XSendEvent(disp, window, propagate == JNI_TRUE ? True : False, eventmask, event); +} + +JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetFocusDetail(JNIEnv *env, jclass unused, jobject event_buffer) { + XEvent *event = (XEvent *)(*env)->GetDirectBufferAddress(env, event_buffer); + return event->xfocus.detail; +} + +JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetFocusMode(JNIEnv *env, jclass unused, jobject event_buffer) { + XEvent *event = (XEvent *)(*env)->GetDirectBufferAddress(env, event_buffer); + return event->xfocus.mode; +} + +JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_LinuxEvent_nFilterEvent(JNIEnv *env, jclass unused, jobject event_buffer, jlong window_ptr) { + XEvent *event = (XEvent *)(*env)->GetDirectBufferAddress(env, event_buffer); + Window window = (Window)window_ptr; + return XFilterEvent(event, window) == True ? JNI_TRUE : JNI_FALSE; +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxEvent_nNextEvent(JNIEnv *env, jclass unused, jlong display_ptr, jobject event_buffer) { + XEvent *event = (XEvent *)(*env)->GetDirectBufferAddress(env, event_buffer); + Display *disp = (Display *)(intptr_t)display_ptr; + XNextEvent(disp, event); +} + +JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetType(JNIEnv *env, jclass unused, jobject event_buffer) { + XEvent *event = (XEvent *)(*env)->GetDirectBufferAddress(env, event_buffer); + return event->type; +} + +JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetWindow(JNIEnv *env, jclass unused, jobject event_buffer) { + XEvent *event = (XEvent *)(*env)->GetDirectBufferAddress(env, event_buffer); + return event->xany.window; +} + +JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetClientMessageType(JNIEnv *env, jclass unused, jobject event_buffer) { + XEvent *event = (XEvent *)(*env)->GetDirectBufferAddress(env, event_buffer); + return event->xclient.message_type; +} + +JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetClientData(JNIEnv *env, jclass unused, jobject event_buffer, jint index) { + XEvent *event = (XEvent *)(*env)->GetDirectBufferAddress(env, event_buffer); + return event->xclient.data.l[index]; +} + +JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetClientFormat(JNIEnv *env, jclass unused, jobject event_buffer) { + XEvent *event = (XEvent *)(*env)->GetDirectBufferAddress(env, event_buffer); + return event->xclient.format; +} + +JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetButtonTime(JNIEnv *env, jclass unused, jobject event_buffer) { + XEvent *event = (XEvent *)(*env)->GetDirectBufferAddress(env, event_buffer); + return event->xbutton.time; +} + +JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetButtonState(JNIEnv *env, jclass unused, jobject event_buffer) { + XEvent *event = (XEvent *)(*env)->GetDirectBufferAddress(env, event_buffer); + return event->xbutton.state; +} + +JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetButtonType(JNIEnv *env, jclass unused, jobject event_buffer) { + XEvent *event = (XEvent *)(*env)->GetDirectBufferAddress(env, event_buffer); + return event->xbutton.type; +} + +JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetButtonButton(JNIEnv *env, jclass unused, jobject event_buffer) { + XEvent *event = (XEvent *)(*env)->GetDirectBufferAddress(env, event_buffer); + return event->xbutton.button; +} + +JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetButtonRoot(JNIEnv *env, jclass unused, jobject event_buffer) { + XEvent *event = (XEvent *)(*env)->GetDirectBufferAddress(env, event_buffer); + return event->xbutton.root; +} + +JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetButtonXRoot(JNIEnv *env, jclass unused, jobject event_buffer) { + XEvent *event = (XEvent *)(*env)->GetDirectBufferAddress(env, event_buffer); + return event->xbutton.x_root; +} + +JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetButtonYRoot(JNIEnv *env, jclass unused, jobject event_buffer) { + XEvent *event = (XEvent *)(*env)->GetDirectBufferAddress(env, event_buffer); + return event->xbutton.y_root; +} + +JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetButtonX(JNIEnv *env, jclass unused, jobject event_buffer) { + XEvent *event = (XEvent *)(*env)->GetDirectBufferAddress(env, event_buffer); + return event->xbutton.x; +} + +JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetButtonY(JNIEnv *env, jclass unused, jobject event_buffer) { + XEvent *event = (XEvent *)(*env)->GetDirectBufferAddress(env, event_buffer); + return event->xbutton.y; +} + +JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetKeyAddress(JNIEnv *env, jclass unused, jobject event_buffer) { + XEvent *event = (XEvent *)(*env)->GetDirectBufferAddress(env, event_buffer); + XKeyEvent *key_event = &(event->xkey); + return (jlong)(intptr_t)key_event; +} + +JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetKeyTime(JNIEnv *env, jclass unused, jobject event_buffer) { + XEvent *event = (XEvent *)(*env)->GetDirectBufferAddress(env, event_buffer); + return event->xkey.time; +} + +JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetKeyType(JNIEnv *env, jclass unused, jobject event_buffer) { + XEvent *event = (XEvent *)(*env)->GetDirectBufferAddress(env, event_buffer); + return event->xkey.type; +} + +JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetKeyKeyCode(JNIEnv *env, jclass unused, jobject event_buffer) { + XEvent *event = (XEvent *)(*env)->GetDirectBufferAddress(env, event_buffer); + return event->xkey.keycode; +} + +JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetKeyState(JNIEnv *env, jclass unused, jobject event_buffer) { + XEvent *event = (XEvent *)(*env)->GetDirectBufferAddress(env, event_buffer); + return event->xkey.state; +} diff --git a/src/native/linux/org_lwjgl_opengl_LinuxKeyboard.c b/src/native/linux/org_lwjgl_opengl_LinuxKeyboard.c new file mode 100644 index 0000000..85a04f7 --- /dev/null +++ b/src/native/linux/org_lwjgl_opengl_LinuxKeyboard.c @@ -0,0 +1,152 @@ +/* + * 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. + */ + +/** + * $Id: org_lwjgl_input_Keyboard.c 2399 2006-06-30 19:28:00Z elias_naur $ + * + * Linux keyboard handling. + * + * @author elias_naur + * @version $Revision: 2399 $ + */ + +#include +#include +#include +#include +#include +#include "common_tools.h" +#include "org_lwjgl_opengl_LinuxKeyboard.h" + +JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxKeyboard_getModifierMapping(JNIEnv *env, jclass unused, jlong display_ptr) { + Display *disp = (Display *)(intptr_t)display_ptr; + XModifierKeymap *modifier_map = XGetModifierMapping(disp); + return (intptr_t)modifier_map; +} + +JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_LinuxKeyboard_nSetDetectableKeyRepeat(JNIEnv *env, jclass unused, jlong display_ptr, jboolean set_enabled) { + Display *disp = (Display *)(intptr_t)display_ptr; + Bool enabled = set_enabled == JNI_TRUE ? True : False; + Bool result = XkbSetDetectableAutoRepeat(disp, enabled, NULL); + return result == enabled ? JNI_TRUE : JNI_FALSE; +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxKeyboard_freeModifierMapping(JNIEnv *env, jclass unused, jlong mapping_ptr) { + XModifierKeymap *modifier_map = (XModifierKeymap *)(intptr_t)mapping_ptr; + XFreeModifiermap(modifier_map); +} + +JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxKeyboard_getMaxKeyPerMod(JNIEnv *env, jclass unsused, jlong mapping_ptr) { + XModifierKeymap *modifier_map = (XModifierKeymap *)(intptr_t)mapping_ptr; + return modifier_map->max_keypermod; +} + +JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxKeyboard_lookupModifierMap(JNIEnv *env, jclass unused, jlong mapping_ptr, jint index) { + XModifierKeymap *modifier_map = (XModifierKeymap *)(intptr_t)mapping_ptr; + KeyCode key_code = modifier_map->modifiermap[index]; + return key_code; +} + +JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxKeyboard_keycodeToKeySym(JNIEnv *env, jclass unused, jlong display_ptr, jint key_code) { + Display *disp = (Display *)(intptr_t)display_ptr; + KeySym key_sym = XKeycodeToKeysym(disp, key_code, 0); + return key_sym; +} + +JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxKeyboard_openIM(JNIEnv *env, jclass unused, jlong display_ptr) { + Display *disp = (Display *)(intptr_t)display_ptr; + XIM xim = XOpenIM(disp, NULL, NULL, NULL); + return (intptr_t)xim; +} + +JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxKeyboard_createIC(JNIEnv *env, jclass unused, jlong xim_ptr, jlong window_ptr) { + Window win = (Window)window_ptr; + XIM xim = (XIM)(intptr_t)xim_ptr; + XIC xic = XCreateIC(xim, XNClientWindow, win, XNFocusWindow, win, XNInputStyle, XIMPreeditNothing | XIMStatusNothing, NULL); + return (intptr_t)xic; +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxKeyboard_setupIMEventMask(JNIEnv *env, jclass unused, jlong display_ptr, jlong window_ptr, jlong xic_ptr) { + Display *disp = (Display *)(intptr_t)display_ptr; + Window win = (Window)window_ptr; + XIC xic = (XIC)(intptr_t)xic_ptr; + long im_event_mask; + XWindowAttributes win_attributes; + + XGetWindowAttributes(disp, win, &win_attributes); + XGetICValues(xic, XNFilterEvents, &im_event_mask, NULL); + XSelectInput(disp, win, win_attributes.your_event_mask | im_event_mask); + XSetICFocus(xic); +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxKeyboard_destroyIC(JNIEnv *env, jclass unused, jlong xic_ptr) { + XIC xic = (XIC)(intptr_t)xic_ptr; + XDestroyIC(xic); +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxKeyboard_closeIM(JNIEnv *env, jclass unused, jlong xim_ptr) { + XIM xim = (XIM)(intptr_t)xim_ptr; + XCloseIM(xim); +} + +JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxKeyboard_lookupKeysym(JNIEnv *env, jclass unused, jlong event_ptr, jint index) { + XKeyEvent *event = (XKeyEvent *)(intptr_t)event_ptr; + return XLookupKeysym(event, index); +} + +JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxKeyboard_toUpper(JNIEnv *env, jclass unused, jlong keysym) { + KeySym lower_case, upper_case; + XConvertCase(keysym, &lower_case, &upper_case); + return upper_case; +} + +JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxKeyboard_lookupString(JNIEnv *env, jclass unused, jlong event_ptr, jobject buffer_obj, jobject compose_status_obj) { + XKeyEvent *event = (XKeyEvent *)(intptr_t)event_ptr; + char *buffer = (char *)(*env)->GetDirectBufferAddress(env, buffer_obj); + int capacity = (*env)->GetDirectBufferCapacity(env, buffer_obj); + XComposeStatus *status = (XComposeStatus *)(*env)->GetDirectBufferAddress(env, compose_status_obj); + return XLookupString(event, buffer, capacity, NULL, status); +} + +JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_LinuxKeyboard_allocateComposeStatus(JNIEnv *env, jclass unused) { + return newJavaManagedByteBuffer(env, sizeof(XComposeStatus)); +} + +JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxKeyboard_utf8LookupString(JNIEnv *env, jclass unused, jlong xic_ptr, jlong event_ptr, jobject buffer_obj, jint buffer_position, jint buffer_size) { + XIC xic = (XIC)(intptr_t)xic_ptr; + XKeyEvent *event = (XKeyEvent *)(intptr_t)event_ptr; + char *buffer = buffer_position + (char *)(*env)->GetDirectBufferAddress(env, buffer_obj); + Status status; + size_t num_bytes = Xutf8LookupString(xic, event, buffer, buffer_size, NULL, &status); + positionBuffer(env, buffer_obj, num_bytes); + return status; +} diff --git a/src/native/linux/org_lwjgl_opengl_LinuxMouse.c b/src/native/linux/org_lwjgl_opengl_LinuxMouse.c new file mode 100644 index 0000000..bdc775c --- /dev/null +++ b/src/native/linux/org_lwjgl_opengl_LinuxMouse.c @@ -0,0 +1,105 @@ +/* + * 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. + */ + +/** + * $Id: org_lwjgl_input_Keyboard.c 2399 2006-06-30 19:28:00Z elias_naur $ + * + * Linux mouse handling. + * + * @author elias_naur + * @version $Revision: 2399 $ + */ + +#include +#include +#include +#include "common_tools.h" +#include "org_lwjgl_opengl_LinuxMouse.h" + +static void getWindowAttributes(jlong display_ptr, jlong window_ptr, XWindowAttributes *attr) { + Display *disp = (Display *)(intptr_t)display_ptr; + Window win = (Window)window_ptr; + XGetWindowAttributes(disp, win, attr); +} + +JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxMouse_nGetWindowHeight(JNIEnv *env, jclass unused, jlong display_ptr, jlong window_ptr) { + XWindowAttributes window_attributes; + getWindowAttributes(display_ptr, window_ptr, &window_attributes); + return window_attributes.height; +} + +JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxMouse_nGetWindowWidth(JNIEnv *env, jclass unused, jlong display_ptr, jlong window_ptr) { + XWindowAttributes window_attributes; + getWindowAttributes(display_ptr, window_ptr, &window_attributes); + return window_attributes.width; +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxMouse_nWarpCursor(JNIEnv *env, jclass unused, jlong display_ptr, jlong window_ptr, jint x, jint y) { + Display *disp = (Display *)(intptr_t)display_ptr; + Window win = (Window)window_ptr; + XWarpPointer(disp, None, win, 0, 0, 0, 0, x, y); +} + +JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxMouse_nQueryPointer(JNIEnv *env, jclass unused, jlong display_ptr, jlong window_ptr, jobject result_buffer) { + Display *disp = (Display *)(intptr_t)display_ptr; + Window win = (Window)window_ptr; + Window root_return, child_return; + int root_x, root_y, win_x, win_y; + unsigned int mask_return; + jint *result = (jint *)(*env)->GetDirectBufferAddress(env, result_buffer); + int result_size = (*env)->GetDirectBufferCapacity(env, result_buffer); + if (result_size < 4) { + throwFormattedException(env, "Not enough space in result buffer (%d)", result_size); + return (intptr_t)NULL; + } + + XQueryPointer(disp, win, &root_return, &child_return, &root_x, &root_y, &win_x, &win_y, &mask_return); + result[0] = root_x; + result[1] = root_y; + result[2] = win_x; + result[3] = win_y; + return root_return; +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxMouse_nSendWarpEvent(JNIEnv *env, jclass unusued, jlong display_ptr, jlong window_ptr, jlong warp_atom_ptr, jint x, jint y) { + Atom warp_atom = (Atom)warp_atom_ptr; + Display *disp = (Display *)(intptr_t)display_ptr; + Window win = (Window)window_ptr; + XEvent warp_event; + warp_event.type = ClientMessage; + warp_event.xclient.window = win; + warp_event.xclient.message_type = warp_atom; + warp_event.xclient.format = 32; + warp_event.xclient.data.l[0] = x; + warp_event.xclient.data.l[1] = y; + XSendEvent(disp, win, False, 0, &warp_event); +} diff --git a/src/native/linux/org_lwjgl_opengl_LinuxPeerInfo.c b/src/native/linux/org_lwjgl_opengl_LinuxPeerInfo.c new file mode 100644 index 0000000..db6323c --- /dev/null +++ b/src/native/linux/org_lwjgl_opengl_LinuxPeerInfo.c @@ -0,0 +1,58 @@ +/* + * 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. + */ + +/** + * $Id: org_lwjgl_opengl_LinuxPeerInfo.c 2985 2008-04-07 18:42:36Z matzon $ + * + * @author elias_naur + * @version $Revision: 2985 $ + */ + +#include +#include "org_lwjgl_opengl_LinuxPeerInfo.h" +#include "context.h" +#include "common_tools.h" + +JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_LinuxPeerInfo_createHandle + (JNIEnv *env, jclass clazz) { + return newJavaManagedByteBuffer(env, sizeof(X11PeerInfo)); +} + +JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxPeerInfo_nGetDisplay(JNIEnv *env, jclass unused, jobject handle) { + X11PeerInfo *peer_info = (*env)->GetDirectBufferAddress(env, handle); + return (jlong)(intptr_t)peer_info->display; +} + +JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxPeerInfo_nGetDrawable(JNIEnv *env, jclass unused, jobject handle) { + X11PeerInfo *peer_info = (*env)->GetDirectBufferAddress(env, handle); + return peer_info->drawable; +} diff --git a/src/native/linux/org_lwjgl_opengl_Pbuffer.c b/src/native/linux/org_lwjgl_opengl_Pbuffer.c new file mode 100644 index 0000000..a0eac74 --- /dev/null +++ b/src/native/linux/org_lwjgl_opengl_Pbuffer.c @@ -0,0 +1,90 @@ +/* + * 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. + */ + +/** + * $Id: org_lwjgl_opengl_Pbuffer.c 2985 2008-04-07 18:42:36Z matzon $ + * + * Linux Pbuffer. + * + * @author elias_naur + * @version $Revision: 2985 $ + */ + +#include +#include "org_lwjgl_opengl_LinuxPbufferPeerInfo.h" +#include "org_lwjgl_opengl_Pbuffer.h" +#include "extgl.h" +#include "context.h" +#include "common_tools.h" + +JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetPbufferCapabilities + (JNIEnv *env, jclass clazz, jlong display, jint screen) +{ + Display *disp = (Display *)(intptr_t)display; + GLXExtensions extension_flags; + if (!extgl_InitGLX(disp, screen, &extension_flags)) + return 0; + // Only support the GLX 1.3 Pbuffers and ignore the GLX_SGIX_pbuffer extension + return extension_flags.GLX13 ? org_lwjgl_opengl_Pbuffer_PBUFFER_SUPPORTED : 0; +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxPbufferPeerInfo_nInitHandle + (JNIEnv *env, jclass clazz, jlong display, jint screen, jobject peer_info_handle, jint width, jint height, jobject pixel_format) { + Display *disp = (Display *)(intptr_t)display; + GLXExtensions extension_flags; + if (!extgl_InitGLX(disp, screen, &extension_flags) || !extension_flags.GLX13) { + throwException(env, "No Pbuffer support"); + return; + } + bool result = initPeerInfo(env, peer_info_handle, disp, screen, pixel_format, false, GLX_PBUFFER_BIT, false, true); + if (!result) + return; + const int buffer_attribs[] = {GLX_PBUFFER_WIDTH, width, + GLX_PBUFFER_HEIGHT, height, + GLX_PRESERVED_CONTENTS, True, + GLX_LARGEST_PBUFFER, False, + None, None}; + + X11PeerInfo *peer_info = (X11PeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle); + GLXFBConfig *config = getFBConfigFromPeerInfo(env, peer_info); + if (config != NULL) { + GLXPbuffer buffer = lwjgl_glXCreatePbuffer(peer_info->display, *config, buffer_attribs); + XFree(config); + peer_info->drawable = buffer; + } +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxPbufferPeerInfo_nDestroy + (JNIEnv *env, jclass clazz, jobject peer_info_handle) { + X11PeerInfo *peer_info = (X11PeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle); + lwjgl_glXDestroyPbuffer(peer_info->display, peer_info->drawable); +} diff --git a/src/native/macosx/context.h b/src/native/macosx/context.h new file mode 100644 index 0000000..4c5b4f6 --- /dev/null +++ b/src/native/macosx/context.h @@ -0,0 +1,60 @@ +/* + * 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. + */ + +/** + * $Id: context.h 2985 2008-04-07 18:42:36Z matzon $ + * + * Base Win32 display + * + * @author cix_foo + * @version $Revision: 2985 $ + */ + +#ifndef __LWJGL_CONTEXT_H +#define __LWJGL_CONTEXT_H + +#include +#include +#include +#include "common_tools.h" + +typedef struct { + NSOpenGLPixelFormat *pixel_format; + bool window; + union { + NSView *nsview; + NSOpenGLPixelBuffer *pbuffer; + }; +} MacOSXPeerInfo; + +NSOpenGLPixelFormat *choosePixelFormat(JNIEnv *env, jobject pixel_format, bool use_display_bpp, bool support_window, bool support_pbuffer, bool double_buffered); +#endif diff --git a/src/native/macosx/context.m b/src/native/macosx/context.m new file mode 100644 index 0000000..a5dc84b --- /dev/null +++ b/src/native/macosx/context.m @@ -0,0 +1,144 @@ +/* + * 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. + */ + +/** + * $Id: context.m 3116 2008-08-19 16:46:03Z spasi $ + * + * @author elias_naur + * @version $Revision: 3116 $ + */ + +#import +#import "context.h" + +static CFBundleRef opengl_bundle = NULL; + +void *extgl_GetProcAddress(const char *name) { + CFStringRef cf_name = CFStringCreateWithCString(NULL, name, kCFStringEncodingUTF8); + void *address = CFBundleGetFunctionPointerForName(opengl_bundle, cf_name); + CFRelease(cf_name); + if (address == NULL) + printfDebug("Could not locate symbol %s\n", name); + return address; +} + +static CFBundleRef loadFramework(JNIEnv *env) { + CFStringRef framework_path = CFSTR("/System/Library/Frameworks/OpenGL.framework"); + if (framework_path == NULL) { + printfDebugJava(env, "Failed to allocate string"); + return NULL; + } + CFURLRef url = CFURLCreateWithFileSystemPath(NULL, framework_path, kCFURLPOSIXPathStyle, TRUE); + if (url == NULL) { + printfDebugJava(env, "Failed to allocate URL"); + return NULL; + } + CFBundleRef opengl_bundle = CFBundleCreate(NULL, url); + CFRelease(url); + return opengl_bundle; +} + +bool extgl_Open(JNIEnv *env) { + if (opengl_bundle != NULL) + return true; + opengl_bundle = loadFramework(env); + if (opengl_bundle != NULL) { + return true; + } else { + throwException(env, "Could not load OpenGL library"); + return false; + } +} + +void extgl_Close(void) +{ + if (opengl_bundle != NULL) { + CFRelease(opengl_bundle); + opengl_bundle = NULL; + } +} + +NSOpenGLPixelFormat *choosePixelFormat(JNIEnv *env, jobject pixel_format, bool use_display_bpp, bool support_window, bool support_pbuffer, bool double_buffered) { + int bpp; + jclass cls_pixel_format = (*env)->GetObjectClass(env, pixel_format); + if (use_display_bpp) + bpp = CGDisplayBitsPerPixel(kCGDirectMainDisplay); + else + bpp = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "bpp", "I")); + + int alpha = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "alpha", "I")); + int depth = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "depth", "I")); + int stencil = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "stencil", "I")); + int samples = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "samples", "I")); + int num_aux_buffers = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "num_aux_buffers", "I")); + int accum_bpp = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "accum_bpp", "I")); + int accum_alpha = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "accum_alpha", "I")); + bool stereo = (bool)(*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "stereo", "Z")); + bool floating_point = (bool)(*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "floating_point", "Z")); + // TODO: Add floating_point_packed attribute below + bool floating_point_packed = (bool)(*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "floating_point_packed", "Z")); + // TODO: Add sRGB attribute below + bool sRGB = (bool)(*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "sRGB", "Z")); + + attrib_list_t attribs; + jboolean allow_software_acceleration = getBooleanProperty(env, "org.lwjgl.opengl.Display.allowSoftwareOpenGL"); + initAttribList(&attribs); + if (!allow_software_acceleration) + putAttrib(&attribs, NSOpenGLPFAAccelerated); + if (double_buffered) + putAttrib(&attribs, NSOpenGLPFADoubleBuffer); + putAttrib(&attribs, NSOpenGLPFAMinimumPolicy); + putAttrib(&attribs, NSOpenGLPFAColorSize); putAttrib(&attribs, bpp); + putAttrib(&attribs, NSOpenGLPFAAlphaSize); putAttrib(&attribs, alpha); + putAttrib(&attribs, NSOpenGLPFADepthSize); putAttrib(&attribs, depth); + putAttrib(&attribs, NSOpenGLPFAStencilSize); putAttrib(&attribs, stencil); + putAttrib(&attribs, NSOpenGLPFAAccumSize); putAttrib(&attribs, accum_bpp + accum_alpha); + putAttrib(&attribs, NSOpenGLPFASampleBuffers); putAttrib(&attribs, samples > 0 ? 1 : 0); + putAttrib(&attribs, NSOpenGLPFASamples); putAttrib(&attribs, samples); + putAttrib(&attribs, NSOpenGLPFAAuxBuffers); putAttrib(&attribs, num_aux_buffers); + if (support_window) + putAttrib(&attribs, NSOpenGLPFAWindow); + if (support_pbuffer) + putAttrib(&attribs, NSOpenGLPFAPixelBuffer); + if (stereo) + putAttrib(&attribs, NSOpenGLPFAStereo); + if (floating_point) + putAttrib(&attribs, NSOpenGLPFAColorFloat); + putAttrib(&attribs, 0); + NSOpenGLPixelFormat* fmt = [[NSOpenGLPixelFormat alloc] initWithAttributes:(NSOpenGLPixelFormatAttribute *)attribs.attribs]; + + if (fmt == nil) { + throwException(env, "Could not create pixel format"); + return NULL; + } + return fmt; +} diff --git a/src/native/macosx/macosx_al.c b/src/native/macosx/macosx_al.c new file mode 100644 index 0000000..1e2e9a0 --- /dev/null +++ b/src/native/macosx/macosx_al.c @@ -0,0 +1,120 @@ +/* + * 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. + */ + +#include +#include +#include +#include +#include +#include +#include +#include "extal.h" +#include "common_tools.h" + +/** + * $Id: macosx_al.c 2985 2008-04-07 18:42:36Z matzon $ + * + * This file contains the AL extension assigning mechanism + * + * @author Brian Matzon + * @version $Revision: 2985 $ + */ + +static const struct mach_header* handleOAL = NULL; +static CFBundleRef openal_bundle = NULL; + +void *NativeGetFunctionPointer(const char *function) { + void *address = NULL; + if (handleOAL != NULL) { + char *mac_symbol_name = (char *)malloc((strlen(function) + 2)*sizeof(char)); + if (mac_symbol_name == NULL) + return NULL; + mac_symbol_name[0] = '_'; + strcpy(&(mac_symbol_name[1]), function); + NSSymbol symbol = NSLookupSymbolInImage(handleOAL, mac_symbol_name, NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR); + free(mac_symbol_name); + if (symbol != NULL) { + address = NSAddressOfSymbol(symbol); + } + } else if (openal_bundle != NULL) { + CFStringRef cf_function = CFStringCreateWithCString(NULL, function, kCFStringEncodingUTF8); + address = CFBundleGetFunctionPointerForName(openal_bundle, cf_function); + CFRelease(cf_function); + } + return address; +} + +static CFBundleRef tryLoadFramework(JNIEnv *env) { + CFStringRef framework_path = CFSTR("/System/Library/Frameworks/OpenAL.framework"); + if (framework_path == NULL) { + printfDebugJava(env, "Failed to allocate string"); + return NULL; + } + CFURLRef url = CFURLCreateWithFileSystemPath(NULL, framework_path, kCFURLPOSIXPathStyle, TRUE); + if (url == NULL) { + printfDebugJava(env, "Failed to allocate URL"); + return NULL; + } + CFBundleRef openal_bundle = CFBundleCreate(NULL, url); + CFRelease(url); + return openal_bundle; +} + +void tryLoadLibrary(JNIEnv *env, jstring path) { + const char *path_str = (*env)->GetStringUTFChars(env, path, NULL); + printfDebugJava(env, "Testing '%s'", path_str); + handleOAL = NSAddImage(path_str, NSADDIMAGE_OPTION_RETURN_ON_ERROR); + if (handleOAL != NULL) { + printfDebugJava(env, "Found OpenAL at '%s'", path_str); + } else { + throwException(env, "Could not load OpenAL library"); + } + (*env)->ReleaseStringUTFChars(env, path, path_str); +} + +/** + * Unloads the OpenAL Library + */ +void UnLoadOpenAL() { + if (openal_bundle != NULL) { + CFRelease(openal_bundle); + openal_bundle = NULL; + } +} + +JNIEXPORT void JNICALL Java_org_lwjgl_openal_AL_nCreateDefault(JNIEnv *env, jclass clazz) { + openal_bundle = tryLoadFramework(env); + if (openal_bundle != NULL) + printfDebugJava(env, "Found OpenAL Bundle"); + else + throwException(env, "Could not load OpenAL framework"); +} diff --git a/src/native/macosx/org_lwjgl_input_Mouse.c b/src/native/macosx/org_lwjgl_input_Mouse.c new file mode 100644 index 0000000..21eea37 --- /dev/null +++ b/src/native/macosx/org_lwjgl_input_Mouse.c @@ -0,0 +1,73 @@ +/* + * 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. + */ + +/** + * $Id: org_lwjgl_input_Mouse.c 2985 2008-04-07 18:42:36Z matzon $ + * + * Mac OS X mouse handling. + * + * @author elias_naur + * @version $Revision: 2985 $ + */ + +#include +#include +#include "org_lwjgl_opengl_MacOSXMouseEventQueue.h" +#include "common_tools.h" + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXMouseEventQueue_nGrabMouse(JNIEnv *env, jclass unused, jboolean grab) { + CGAssociateMouseAndMouseCursorPosition(grab == JNI_TRUE ? FALSE : TRUE); + if (grab) + CGDisplayHideCursor(kCGDirectMainDisplay); + else + CGDisplayShowCursor(kCGDirectMainDisplay); +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXMouseEventQueue_nWarpCursor(JNIEnv *env, jclass unused, jint x, jint y) { + CGPoint p; + p.x = x; + p.y = y; + CGWarpMouseCursorPosition(p); +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXMouseEventQueue_getMouseDeltas(JNIEnv *env, jclass unused, jobject delta_buffer) { + CGMouseDelta dx, dy; + CGGetLastMouseDelta(&dx, &dy); + int buffer_length = (*env)->GetDirectBufferCapacity(env, delta_buffer); + if (buffer_length != 2) { + printfDebugJava(env, "Delta buffer not large enough!"); + return; + } + jint *buffer = (*env)->GetDirectBufferAddress(env, delta_buffer); + buffer[0] = dx; + buffer[1] = dy; +} diff --git a/src/native/macosx/org_lwjgl_opengl_Display.m b/src/native/macosx/org_lwjgl_opengl_Display.m new file mode 100644 index 0000000..cfd9e2f --- /dev/null +++ b/src/native/macosx/org_lwjgl_opengl_Display.m @@ -0,0 +1,78 @@ +/* + * 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. + */ + +/** + * $Id: org_lwjgl_opengl_Display.m 3055 2008-04-30 14:58:47Z elias_naur $ + * + * Mac OS X specific display functions. + * + * @author elias_naur + * @version $Revision: 3055 $ + */ + +#import +#import +#import +#import +#import +//#import "display.h" +#import "common_tools.h" +#import "org_lwjgl_opengl_MacOSXDisplay.h" +#import "org_lwjgl_MacOSXSysImplementation.h" + +#define WAIT_DELAY 100 + +JNIEXPORT jint JNICALL Java_org_lwjgl_DefaultSysImplementation_getJNIVersion + (JNIEnv *env, jobject ignored) { + return org_lwjgl_MacOSXSysImplementation_JNI_VERSION; +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXDisplay_restoreGamma(JNIEnv *env, jobject this) { + CGDisplayRestoreColorSyncSettings(); +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXDisplay_setGammaRamp(JNIEnv *env, jobject this, jobject gamma_buffer) { + const CGGammaValue *values = (*env)->GetDirectBufferAddress(env, gamma_buffer); + CGTableCount table_size = (*env)->GetDirectBufferCapacity(env, gamma_buffer); + CGDisplayErr err = CGSetDisplayTransferByTable(kCGDirectMainDisplay, table_size, values, values, values); + if (err != CGDisplayNoErr) { + throwException(env, "Could not set display gamma"); + } +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXDisplay_nHideUI(JNIEnv *env, jobject this, jboolean hide) { + if (hide == JNI_TRUE) { + SetSystemUIMode(kUIModeContentSuppressed, 0); + } else { + SetSystemUIMode(kUIModeNormal, 0); + } +} diff --git a/src/native/macosx/org_lwjgl_opengl_MacOSXCanvasPeerInfo.m b/src/native/macosx/org_lwjgl_opengl_MacOSXCanvasPeerInfo.m new file mode 100644 index 0000000..4903124 --- /dev/null +++ b/src/native/macosx/org_lwjgl_opengl_MacOSXCanvasPeerInfo.m @@ -0,0 +1,56 @@ +/* + * 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. + */ + +/** + * $Id: org_lwjgl_opengl_MacOSXCanvasPeerInfo.m 2985 2008-04-07 18:42:36Z matzon $ + * + * @author elias_naur + * @version $Revision: 2985 $ + */ + +#include +#include +#include "awt_tools.h" +#include "org_lwjgl_opengl_MacOSXCanvasPeerInfo.h" +#include "context.h" +#include "common_tools.h" + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXCanvasPeerInfo_nInitHandle + (JNIEnv *env, jclass clazz, jobject lock_buffer_handle, jobject peer_info_handle) { + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + MacOSXPeerInfo *peer_info = (MacOSXPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle); + AWTSurfaceLock *surface = (AWTSurfaceLock *)(*env)->GetDirectBufferAddress(env, lock_buffer_handle); + JAWT_MacOSXDrawingSurfaceInfo *macosx_dsi = (JAWT_MacOSXDrawingSurfaceInfo *)surface->dsi->platformInfo; + peer_info->nsview = macosx_dsi->cocoaViewRef; + peer_info->window = true; + [pool release]; +} diff --git a/src/native/macosx/org_lwjgl_opengl_MacOSXContextImplementation.m b/src/native/macosx/org_lwjgl_opengl_MacOSXContextImplementation.m new file mode 100644 index 0000000..7f13e1c --- /dev/null +++ b/src/native/macosx/org_lwjgl_opengl_MacOSXContextImplementation.m @@ -0,0 +1,157 @@ +/* + * 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. + */ + +/** + * $Id: org_lwjgl_opengl_MacOSXContextImplementation.m 3116 2008-08-19 16:46:03Z spasi $ + * + * @author elias_naur + * @version $Revision: 3116 $ + */ + +#import +#import +#import "org_lwjgl_opengl_MacOSXContextImplementation.h" +#import "context.h" +#import "common_tools.h" + +typedef struct { + NSOpenGLContext *context; +} MacOSXContext; + +JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_MacOSXContextImplementation_nCreate + (JNIEnv *env, jclass clazz, jobject peer_info_handle, jobject attribs, jobject shared_context_handle) { + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + MacOSXPeerInfo *peer_info; + MacOSXContext *shared_context_info; + MacOSXContext *context_info; + NSOpenGLContext *context; + NSOpenGLContext *shared_context = NULL; + jobject context_handle = newJavaManagedByteBuffer(env, sizeof(MacOSXContext)); + if (context_handle == NULL) { + throwException(env, "Could not create handle buffer"); + return NULL; + } + peer_info = (MacOSXPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle); + if (shared_context_handle != NULL) { + shared_context_info = (MacOSXContext *)(*env)->GetDirectBufferAddress(env, shared_context_handle); + shared_context = shared_context_info->context; + } + context = [[NSOpenGLContext alloc] initWithFormat:peer_info->pixel_format shareContext:shared_context]; + if (context == NULL) { + throwException(env, "Could not create context"); + return NULL; + } + context_info = (MacOSXContext *)(*env)->GetDirectBufferAddress(env, context_handle); + context_info->context = context; + [pool release]; + return context_handle; +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXContextImplementation_nSwapBuffers + (JNIEnv *env, jclass clazz, jobject context_handle) { + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + MacOSXContext *peer_info = (MacOSXContext *)(*env)->GetDirectBufferAddress(env, context_handle); + [peer_info->context flushBuffer]; + [pool release]; +} + + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXContextImplementation_nUpdate + (JNIEnv *env, jclass clazz, jobject context_handle) { + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + MacOSXContext *context_info = (MacOSXContext *)(*env)->GetDirectBufferAddress(env, context_handle); + [context_info->context update]; + [pool release]; +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXContextImplementation_clearDrawable + (JNIEnv *env, jclass clazz, jobject context_handle) { + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + MacOSXContext *context_info = (MacOSXContext *)(*env)->GetDirectBufferAddress(env, context_handle); + [context_info->context clearDrawable]; + [pool release]; +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXContextImplementation_nReleaseCurrentContext + (JNIEnv *env, jclass clazz) { + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + [NSOpenGLContext clearCurrentContext]; + [pool release]; +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXContextImplementation_setView + (JNIEnv *env, jclass clazz, jobject peer_info_handle, jobject context_handle) { + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + MacOSXContext *context_info = (MacOSXContext *)(*env)->GetDirectBufferAddress(env, context_handle); + MacOSXPeerInfo *peer_info = (MacOSXPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle); + if (peer_info->window) { + [context_info->context setView: peer_info->nsview]; + } else { + [context_info->context setPixelBuffer:peer_info->pbuffer cubeMapFace:0 mipMapLevel:0 currentVirtualScreen:0]; + } + [pool release]; +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXContextImplementation_nMakeCurrent + (JNIEnv *env, jclass clazz, jobject context_handle) { + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + MacOSXContext *context_info = (MacOSXContext *)(*env)->GetDirectBufferAddress(env, context_handle); + [context_info->context makeCurrentContext]; + [pool release]; +} + +JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_MacOSXContextImplementation_nIsCurrent + (JNIEnv *env, jclass clazz, jobject context_handle) { + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + MacOSXContext *context_info = (MacOSXContext *)(*env)->GetDirectBufferAddress(env, context_handle); + bool result = context_info->context == [NSOpenGLContext currentContext]; + [pool release]; + return result ? JNI_TRUE : JNI_FALSE; +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXContextImplementation_nSetSwapInterval + (JNIEnv *env, jclass clazz, jobject context_handle, jint int_value) { + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + MacOSXContext *context_info = (MacOSXContext *)(*env)->GetDirectBufferAddress(env, context_handle); + GLint value = int_value; + [context_info->context setValues:&value forParameter:NSOpenGLCPSwapInterval]; + [pool release]; +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXContextImplementation_nDestroy + (JNIEnv *env, jclass clazz, jobject context_handle) { + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + MacOSXContext *context_info = (MacOSXContext *)(*env)->GetDirectBufferAddress(env, context_handle); + [context_info->context clearDrawable]; + [context_info->context release]; + [pool release]; +} diff --git a/src/native/macosx/org_lwjgl_opengl_MacOSXPbufferPeerInfo.m b/src/native/macosx/org_lwjgl_opengl_MacOSXPbufferPeerInfo.m new file mode 100644 index 0000000..affd641 --- /dev/null +++ b/src/native/macosx/org_lwjgl_opengl_MacOSXPbufferPeerInfo.m @@ -0,0 +1,78 @@ +/* + * 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. + */ + +/** + * $Id: org_lwjgl_opengl_MacOSXPbufferPeerInfo.m 2985 2008-04-07 18:42:36Z matzon $ + * + * @author elias_naur + * @version $Revision: 2985 $ + */ + +#import +#import +#import "org_lwjgl_opengl_MacOSXPbufferPeerInfo.h" +#import "context.h" +#import "common_tools.h" + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXPbufferPeerInfo_nCreate(JNIEnv *env, jclass clazz, jobject peer_info_handle, jint width, jint height) { + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + NSOpenGLPixelBuffer *pbuffer = nil; + // check if the texture is power of 2 + if ( (( width > 0 ) && ( width & ( width-1)) == 0) || (( height > 0 ) && ( height & ( height-1)) == 0) ) + { + pbuffer = [[NSOpenGLPixelBuffer alloc] initWithTextureTarget:GL_TEXTURE_2D + textureInternalFormat:GL_RGBA + textureMaxMipMapLevel:0 + pixelsWide:width + pixelsHigh:height]; + } + else + { + pbuffer = [[NSOpenGLPixelBuffer alloc] initWithTextureTarget:GL_TEXTURE_RECTANGLE_EXT + textureInternalFormat:GL_RGBA + textureMaxMipMapLevel:0 + pixelsWide:width + pixelsHigh:height]; + } + MacOSXPeerInfo *peer_info = (MacOSXPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle); + peer_info->pbuffer = pbuffer; + peer_info->window = false; + [pool release]; +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXPbufferPeerInfo_nDestroy + (JNIEnv *env, jclass clazz, jobject peer_info_handle) { + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + MacOSXPeerInfo *peer_info = (MacOSXPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle); + [peer_info->pbuffer release]; + [pool release]; +} diff --git a/src/native/macosx/org_lwjgl_opengl_MacOSXPeerInfo.m b/src/native/macosx/org_lwjgl_opengl_MacOSXPeerInfo.m new file mode 100644 index 0000000..6ccd2c9 --- /dev/null +++ b/src/native/macosx/org_lwjgl_opengl_MacOSXPeerInfo.m @@ -0,0 +1,73 @@ +/* + * 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. + */ + +/** + * $Id: org_lwjgl_opengl_MacOSXPeerInfo.m 2985 2008-04-07 18:42:36Z matzon $ + * + * @author elias_naur + * @version $Revision: 2985 $ + */ + +#import +#import +#import "org_lwjgl_opengl_MacOSXPeerInfo.h" +#import "context.h" +#import "common_tools.h" + +JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_MacOSXPeerInfo_createHandle + (JNIEnv *env, jclass clazz) { + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + jobject handle = newJavaManagedByteBuffer(env, sizeof(MacOSXPeerInfo)); + [pool release]; + return handle; +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXPeerInfo_nChoosePixelFormat + (JNIEnv *env, jclass clazz, jobject peer_info_handle, jobject pixel_format, jboolean use_display_bpp, jboolean support_window, jboolean support_pbuffer, jboolean double_buffered) { + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + MacOSXPeerInfo *peer_info = (MacOSXPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle); + NSOpenGLPixelFormat *macosx_pixel_format = choosePixelFormat(env, pixel_format, use_display_bpp, support_window, support_pbuffer, double_buffered); + if (pixel_format == nil) { + throwException(env, "Could not find pixel format"); + return; + } + peer_info->pixel_format = macosx_pixel_format; + [pool release]; +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXPeerInfo_nDestroy + (JNIEnv *env, jclass clazz, jobject peer_info_handle) { + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + MacOSXPeerInfo *peer_info = (MacOSXPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle); + [peer_info->pixel_format release]; + [pool release]; +} diff --git a/src/native/windows/LWJGL.c b/src/native/windows/LWJGL.c new file mode 100644 index 0000000..9999f1b --- /dev/null +++ b/src/native/windows/LWJGL.c @@ -0,0 +1,65 @@ +/* + * 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. + */ + +/** + * $Id: LWJGL.c 2985 2008-04-07 18:42:36Z matzon $ + * + * Basic DLL stub. + * + * @author cix_foo + * @version $Revision: 2985 $ + */ + +#define WIN32_LEAN_AND_MEAN +#include +#include +#include +#include "org_lwjgl_opengl_WindowsDisplay.h" + +HINSTANCE dll_handle; + +/* + * DLL entry point for Windows. Called when Java loads the .dll + */ +BOOL WINAPI DllMain( + HINSTANCE hinstDLL, // handle to DLL module + DWORD fdwReason, // reason for calling function + LPVOID lpvReserved // reserved + ) +{ + dll_handle = hinstDLL; + return TRUE; // Success +} + +JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WindowsDisplay_getDllInstance(JNIEnv *env, jclass unused) { + return (LONG_PTR)dll_handle; +} diff --git a/src/native/windows/Window.h b/src/native/windows/Window.h new file mode 100644 index 0000000..cdcabc5 --- /dev/null +++ b/src/native/windows/Window.h @@ -0,0 +1,65 @@ +/* + * 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. + */ + +/** + * $Id: Window.h 3227 2009-07-07 19:47:55Z matzon $ + * + * Include file to access public window features + * + * @author cix_foo + * @version $Revision: 3227 $ + */ +#ifndef _LWJGL_WINDOW_H_INCLUDED_ + #define _LWJGL_WINDOW_H_INCLUDED_ + + #define WIN32_LEAN_AND_MEAN + #ifndef _WIN32_WINDOWS + #define _WIN32_WINDOWS 0x0500 + #endif + #ifndef WINVER + #define WINVER 0x0500 + #endif + #ifndef _WIN32_WINNT + #define _WIN32_WINNT 0x0400 + #endif + + #include + #include + #include "common_tools.h" + + #ifdef _PRIVATE_WINDOW_H_ + #define WINDOW_H_API + #else + #define WINDOW_H_API extern + #endif /* _PRIVATE_WINDOW_H_ */ + +#endif /* _LWJGL_WINDOW_H_INCLUDED_ */ diff --git a/src/native/windows/context.c b/src/native/windows/context.c new file mode 100644 index 0000000..e7c65c7 --- /dev/null +++ b/src/native/windows/context.c @@ -0,0 +1,489 @@ +/* + * 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. + */ + +/** + * $Id: context.c 3139 2008-10-28 09:53:16Z elias_naur $ + * + * @author elias_naue + * @version $Revision: 3139 $ + */ + +#include +#include +#include "common_tools.h" +#include "extgl.h" +#include "extgl_wgl.h" +#include "context.h" + +extern HINSTANCE dll_handle; // Handle to the LWJGL dll + +#define _CONTEXT_PRIVATE_CLASS_NAME "__lwjgl_context_class_name" + +/* + * Register the LWJGL window class. + * Returns true for success, or false for failure + */ +bool registerWindow(WNDPROC win_proc, LPCTSTR class_name) +{ + WNDCLASS windowClass; + memset(&windowClass, 0, sizeof(windowClass)); + windowClass.style = CS_OWNDC; + windowClass.lpfnWndProc = win_proc; + windowClass.cbClsExtra = 0; + windowClass.cbWndExtra = 0; + windowClass.hInstance = dll_handle; + windowClass.hIcon = LoadIcon(NULL, IDI_APPLICATION); + windowClass.hCursor = LoadCursor(NULL, IDC_ARROW); + windowClass.hbrBackground = NULL; + windowClass.lpszMenuName = NULL; + windowClass.lpszClassName = class_name; + + if (RegisterClass(&windowClass) == 0) { + printfDebug("Failed to register window class\n"); + return false; + } + return true; +} + +static LRESULT CALLBACK dummyWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { + return DefWindowProc(hwnd, msg, wParam, lParam); +} + +bool applyPixelFormat(JNIEnv *env, HDC hdc, int iPixelFormat) { + PIXELFORMATDESCRIPTOR desc; + if (DescribePixelFormat(hdc, iPixelFormat, sizeof(PIXELFORMATDESCRIPTOR), &desc) == 0) { + throwFormattedException(env, "DescribePixelFormat failed (%d)", GetLastError()); + return false; + } + + // make that the pixel format of the device context + if (SetPixelFormat(hdc, iPixelFormat, &desc) == FALSE) { + throwFormattedException(env, "SetPixelFormat failed (%d)", GetLastError()); + return false; + } + return true; +} + +/* + * Close the window + */ +void closeWindow(HWND *hwnd, HDC *hdc) +{ + // Release device context + if (*hdc != NULL && *hwnd != NULL) { + ReleaseDC(*hwnd, *hdc); + *hdc = NULL; + } + + // Close the window + if (*hwnd != NULL) { + ShowWindow(*hwnd, SW_HIDE); + DestroyWindow(*hwnd); + *hwnd = NULL; + } +} + +void getWindowFlags(DWORD *windowflags_return, DWORD *exstyle_return, bool undecorated, bool child_window) { + DWORD exstyle, windowflags; + if (undecorated) { + exstyle = WS_EX_APPWINDOW; + windowflags = WS_POPUP; + } else if (child_window) { + exstyle = 0; + windowflags = WS_CHILDWINDOW; + } else { + exstyle = WS_EX_APPWINDOW; + windowflags = WS_OVERLAPPED | WS_BORDER | WS_CAPTION | WS_MINIMIZEBOX | WS_SYSMENU; + } + windowflags = windowflags | WS_CLIPCHILDREN | WS_CLIPSIBLINGS; + *windowflags_return = windowflags; + *exstyle_return = exstyle; +} + +HWND createWindow(LPCTSTR window_class_name, int x, int y, int width, int height, bool undecorated, bool child_window, HWND parent) +{ + RECT clientSize; + DWORD exstyle, windowflags; + HWND new_hwnd; + + getWindowFlags(&windowflags, &exstyle, undecorated, child_window); + + clientSize.bottom = height; + clientSize.left = 0; + clientSize.right = width; + clientSize.top = 0; + + AdjustWindowRectEx( + &clientSize, // client-rectangle structure + windowflags, // window styles + FALSE, // menu-present option + exstyle // extended window style + ); + // Create the window now, using that class: + new_hwnd = CreateWindowEx ( + exstyle, + window_class_name, + "", + windowflags, + x, y, clientSize.right - clientSize.left, clientSize.bottom - clientSize.top, + parent, + NULL, + dll_handle, + NULL); + + return new_hwnd; +} + +static int convertToBPE(int bpp) { + int bpe; + switch (bpp) { + case 0: + bpe = 0; + break; + case 32: + case 24: + bpe = 8; + break; + case 16: /* Fall through */ + default: + bpe = 4; + break; + } + return bpe; +} + +static int findPixelFormatARBFromBPP(JNIEnv *env, HDC hdc, WGLExtensions *extensions, jobject pixel_format, jobject pixelFormatCaps, int bpp, bool window, bool pbuffer, bool double_buffer) { + jclass cls_pixel_format = (*env)->GetObjectClass(env, pixel_format); + int alpha = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "alpha", "I")); + int depth = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "depth", "I")); + int stencil = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "stencil", "I")); + int samples = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "samples", "I")); + int num_aux_buffers = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "num_aux_buffers", "I")); + int accum_bpp = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "accum_bpp", "I")); + int accum_alpha = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "accum_alpha", "I")); + + jboolean stereo = (*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "stereo", "Z")); + jboolean floating_point = (*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "floating_point", "Z")); + jboolean floating_point_packed = (*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "floating_point_packed", "Z")); + jboolean sRGB = (*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "sRGB", "Z")); + + int pixel_type; + int iPixelFormat; + unsigned int num_formats_returned; + attrib_list_t attrib_list; + GLuint *pixelFormatCaps_ptr; + jlong pixelFormatCapsSize; + BOOL result; + jlong i; + int bpe = convertToBPE(bpp); + + if ( floating_point ) + pixel_type = WGL_TYPE_RGBA_FLOAT_ARB; + else if ( floating_point_packed ) + pixel_type = WGL_TYPE_RGBA_UNSIGNED_FLOAT_EXT; + else + pixel_type = WGL_TYPE_RGBA_ARB; + + initAttribList(&attrib_list); + if (window) { + putAttrib(&attrib_list, WGL_DRAW_TO_WINDOW_ARB); putAttrib(&attrib_list, TRUE); + } + if (pbuffer) { + putAttrib(&attrib_list, WGL_DRAW_TO_PBUFFER_ARB); putAttrib(&attrib_list, TRUE); + } + if (!getBooleanProperty(env, "org.lwjgl.opengl.Display.allowSoftwareOpenGL")) + putAttrib(&attrib_list, WGL_ACCELERATION_ARB); putAttrib(&attrib_list, WGL_FULL_ACCELERATION_ARB); + putAttrib(&attrib_list, WGL_PIXEL_TYPE_ARB); putAttrib(&attrib_list, pixel_type); + putAttrib(&attrib_list, WGL_DOUBLE_BUFFER_ARB); putAttrib(&attrib_list, double_buffer ? TRUE : FALSE); + putAttrib(&attrib_list, WGL_SUPPORT_OPENGL_ARB); putAttrib(&attrib_list, TRUE); + putAttrib(&attrib_list, WGL_RED_BITS_ARB); putAttrib(&attrib_list, bpe); + putAttrib(&attrib_list, WGL_GREEN_BITS_ARB); putAttrib(&attrib_list, bpe); + putAttrib(&attrib_list, WGL_BLUE_BITS_ARB); putAttrib(&attrib_list, bpe); + putAttrib(&attrib_list, WGL_ALPHA_BITS_ARB); putAttrib(&attrib_list, alpha); + putAttrib(&attrib_list, WGL_DEPTH_BITS_ARB); putAttrib(&attrib_list, depth); + putAttrib(&attrib_list, WGL_STENCIL_BITS_ARB); putAttrib(&attrib_list, stencil); + // Assume caller checked extension availability + if (samples > 0) { + putAttrib(&attrib_list, WGL_SAMPLE_BUFFERS_ARB); putAttrib(&attrib_list, 1); + putAttrib(&attrib_list, WGL_SAMPLES_ARB); putAttrib(&attrib_list, samples); + } + putAttrib(&attrib_list, WGL_ACCUM_BITS_ARB); putAttrib(&attrib_list, accum_bpp); + putAttrib(&attrib_list, WGL_ACCUM_ALPHA_BITS_ARB); putAttrib(&attrib_list, accum_alpha); + putAttrib(&attrib_list, WGL_STEREO_ARB); putAttrib(&attrib_list, stereo ? TRUE : FALSE); + putAttrib(&attrib_list, WGL_AUX_BUFFERS_ARB); putAttrib(&attrib_list, num_aux_buffers); + if (sRGB) { + putAttrib(&attrib_list, WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB); putAttrib(&attrib_list, TRUE); + } + + // Assume caller checked extension availability + if (pixelFormatCaps != NULL) { + pixelFormatCaps_ptr = (GLuint *)(*env)->GetDirectBufferAddress(env, pixelFormatCaps); + pixelFormatCapsSize = (*env)->GetDirectBufferCapacity(env, pixelFormatCaps); + + for (i = 0; i < pixelFormatCapsSize; i++) + putAttrib(&attrib_list, pixelFormatCaps_ptr[i]); + } + putAttrib(&attrib_list, 0); putAttrib(&attrib_list, 0); + result = extensions->wglChoosePixelFormatARB(hdc, attrib_list.attribs, NULL, 1, &iPixelFormat, &num_formats_returned); + + if (result == FALSE || num_formats_returned < 1) { + throwFormattedException(env, "Failed to find ARB pixel format %d %d\n", result, num_formats_returned); + return -1; + } + return iPixelFormat; +} + +static int findPixelFormatARB(JNIEnv *env, HDC hdc, WGLExtensions *extensions, jobject pixel_format, jobject pixelFormatCaps, bool use_hdc_bpp, bool window, bool pbuffer, bool double_buffer) { + int bpp; + int iPixelFormat; + int fallback_bpp = 16; + jclass cls_pixel_format = (*env)->GetObjectClass(env, pixel_format); + if (use_hdc_bpp) { + bpp = GetDeviceCaps(hdc, BITSPIXEL); + iPixelFormat = findPixelFormatARBFromBPP(env, hdc, extensions, pixel_format, pixelFormatCaps, bpp, window, pbuffer, double_buffer); + if ((*env)->ExceptionOccurred(env)) { + (*env)->ExceptionClear(env); + printfDebugJava(env, "Failed to find ARB pixel format with HDC depth %d, falling back to %d\n", bpp, fallback_bpp); + bpp = fallback_bpp; + } else + return iPixelFormat; + } else + bpp = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "bpp", "I")); + return findPixelFormatARBFromBPP(env, hdc, extensions, pixel_format, pixelFormatCaps, bpp, window, pbuffer, double_buffer); +} + +/* + * Find an appropriate pixel format + */ +static int findPixelFormatFromBPP(JNIEnv *env, HDC hdc, jobject pixel_format, int bpp, bool double_buffer) +{ + jclass cls_pixel_format = (*env)->GetObjectClass(env, pixel_format); + int alpha = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "alpha", "I")); + int depth = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "depth", "I")); + int stencil = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "stencil", "I")); + int num_aux_buffers = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "num_aux_buffers", "I")); + int accum_bpp = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "accum_bpp", "I")); + int accum_alpha = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "accum_alpha", "I")); + jboolean stereo = (*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "stereo", "Z")); + unsigned int flags = PFD_DRAW_TO_WINDOW | // support window + PFD_SUPPORT_OPENGL | + (double_buffer ? PFD_DOUBLEBUFFER : 0) | + (stereo ? PFD_STEREO : 0); + PIXELFORMATDESCRIPTOR desc; + int iPixelFormat; + PIXELFORMATDESCRIPTOR pfd = { + sizeof(PIXELFORMATDESCRIPTOR), // size of this pfd + 1, // version number + flags, // RGBA type + PFD_TYPE_RGBA, + (BYTE)bpp, + 0, 0, 0, 0, 0, 0, // color bits ignored + (BYTE)alpha, + 0, // shift bit ignored + accum_bpp + accum_alpha, // no accumulation buffer + 0, 0, 0, 0, // accum bits ignored + (BYTE)depth, + (BYTE)stencil, + num_aux_buffers, + PFD_MAIN_PLANE, // main layer + 0, // reserved + 0, 0, 0 // layer masks ignored + }; + // get the best available match of pixel format for the device context + iPixelFormat = ChoosePixelFormat(hdc, &pfd); + if (iPixelFormat == 0) { + throwException(env, "Failed to choose pixel format"); + return -1; + } + + if (DescribePixelFormat(hdc, iPixelFormat, sizeof(PIXELFORMATDESCRIPTOR), &desc) == 0) { + throwException(env, "Could not describe pixel format"); + return -1; + } + + if (desc.cColorBits < bpp) { + throwException(env, "Insufficient color precision"); + return -1; + } + + if (desc.cAlphaBits < alpha) { + throwException(env, "Insufficient alpha precision"); + return -1; + } + + if (desc.cStencilBits < stencil) { + throwException(env, "Insufficient stencil precision"); + return -1; + } + + if (desc.cDepthBits < depth) { + throwException(env, "Insufficient depth buffer precision"); + return -1; + } + + if ((desc.dwFlags & PFD_GENERIC_FORMAT) != 0) { + jboolean allowSoftwareOpenGL = getBooleanProperty(env, "org.lwjgl.opengl.Display.allowSoftwareOpenGL"); + // secondary check for software override + if(!allowSoftwareOpenGL) { + throwException(env, "Pixel format not accelerated"); + return -1; + } + } + + if ((desc.dwFlags & flags) != flags) { + throwException(env, "Capabilities not supported"); + return -1; + } + return iPixelFormat; +} + +static int findPixelFormatDefault(JNIEnv *env, HDC hdc, jobject pixel_format, bool use_hdc_bpp, bool double_buffer) { + int bpp; + int iPixelFormat; + int fallback_bpp = 16; + jclass cls_pixel_format = (*env)->GetObjectClass(env, pixel_format); + if (use_hdc_bpp) { + bpp = GetDeviceCaps(hdc, BITSPIXEL); + iPixelFormat = findPixelFormatFromBPP(env, hdc, pixel_format, bpp, double_buffer); + if ((*env)->ExceptionOccurred(env)) { + (*env)->ExceptionClear(env); + printfDebugJava(env, "Failed to find pixel format with HDC depth %d, falling back to %d\n", bpp, fallback_bpp); + bpp = fallback_bpp; + } else + return iPixelFormat; + } else + bpp = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "bpp", "I")); + return findPixelFormatFromBPP(env, hdc, pixel_format, bpp, double_buffer); +} + +static bool validateAndGetExtensions(JNIEnv *env, WGLExtensions *extensions, HDC dummy_hdc, HGLRC dummy_hglrc, int samples, bool floating_point, bool floating_point_packed, bool sRGB, jobject pixelFormatCaps) { + if (!wglMakeCurrent(dummy_hdc, dummy_hglrc)) { + throwException(env, "Could not bind context to dummy window"); + return false; + } + extgl_InitWGL(extensions); + + if (!extensions->WGL_ARB_pixel_format) { + throwException(env, "No support for WGL_ARB_pixel_format"); + return false; + } + if (samples > 0 && !extensions->WGL_ARB_multisample) { + throwException(env, "No support for WGL_ARB_multisample"); + return false; + } + /* + * Apparently, some drivers don't report WGL_ARB_pixel_format_float + * even though GL_ARB_color_buffer_float and WGL_ATI_color_format_float + * is supported. + */ + if (floating_point && !(extensions->WGL_ARB_pixel_format_float || extensions->WGL_ATI_pixel_format_float)) { + throwException(env, "No support for WGL_ARB_pixel_format_float nor WGL_ATI_pixel_format_float"); + return false; + } + if (floating_point_packed && !(extensions->WGL_EXT_pixel_format_packed_float)) { + throwException(env, "No support for WGL_EXT_pixel_format_packed_float"); + return false; + } + if (sRGB && !(extensions->WGL_ARB_framebuffer_sRGB)) { + throwException(env, "No support for WGL_ARB_framebuffer_sRGB"); + return false; + } + if (pixelFormatCaps != NULL && !extensions->WGL_ARB_render_texture) { + throwException(env, "No support for WGL_ARB_render_texture"); + return false; + } + return true; +} + +int findPixelFormatOnDC(JNIEnv *env, HDC hdc, int origin_x, int origin_y, jobject pixel_format, jobject pixelFormatCaps, bool use_hdc_bpp, bool window, bool pbuffer, bool double_buffer) { + HGLRC dummy_hglrc; + HDC saved_current_hdc; + HGLRC saved_current_hglrc; + WGLExtensions extensions; + HWND dummy_hwnd; + HDC dummy_hdc; + int pixel_format_id; + jclass cls_pixel_format = (*env)->GetObjectClass(env, pixel_format); + + int samples = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "samples", "I")); + bool floating_point = (bool)(*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "floating_point", "Z")); + bool floating_point_packed = (bool)(*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "floating_point_packed", "Z")); + bool sRGB = (bool)(*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "sRGB", "Z")); + bool use_arb_selection = samples > 0 || floating_point || floating_point_packed || sRGB || pbuffer || pixelFormatCaps != NULL; + + pixel_format_id = findPixelFormatDefault(env, hdc, pixel_format, use_hdc_bpp, double_buffer); + if (!(*env)->ExceptionOccurred(env) && use_arb_selection) { + dummy_hwnd = createDummyWindow(origin_x, origin_y); + if (dummy_hwnd == NULL) { + throwException(env, "Could not create dummy window"); + return -1; + } + dummy_hdc = GetDC(dummy_hwnd); + if (!applyPixelFormat(env, dummy_hdc, pixel_format_id)) { + closeWindow(&dummy_hwnd, &dummy_hdc); + return -1; + } + dummy_hglrc = wglCreateContext(dummy_hdc); + if (dummy_hglrc == NULL) { + closeWindow(&dummy_hwnd, &dummy_hdc); + throwException(env, "Failed to create OpenGL rendering context"); + return -1; + } + // Save the current HDC and HGLRC to avoid disruption + saved_current_hdc = wglGetCurrentDC(); + saved_current_hglrc = wglGetCurrentContext(); + if (validateAndGetExtensions(env, &extensions, dummy_hdc, dummy_hglrc, samples, floating_point, floating_point_packed, sRGB, pixelFormatCaps)) { + pixel_format_id = findPixelFormatARB(env, hdc, &extensions, pixel_format, pixelFormatCaps, use_hdc_bpp, window, pbuffer, double_buffer); + } + wglMakeCurrent(saved_current_hdc, saved_current_hglrc); + wglDeleteContext(dummy_hglrc); + closeWindow(&dummy_hwnd, &dummy_hdc); + } + return pixel_format_id; +} + +static bool registerDummyWindow() { + static bool window_registered = false; + if (!window_registered) { + if (!registerWindow(dummyWindowProc, _CONTEXT_PRIVATE_CLASS_NAME)) { + return false; + } + window_registered = true; + } + return true; +} + +HWND createDummyWindow(int origin_x, int origin_y) { + if (!registerDummyWindow()) + return NULL; + return createWindow(_CONTEXT_PRIVATE_CLASS_NAME, origin_x, origin_y, 1, 1, false, false, NULL); +} diff --git a/src/native/windows/context.h b/src/native/windows/context.h new file mode 100644 index 0000000..8f513c1 --- /dev/null +++ b/src/native/windows/context.h @@ -0,0 +1,96 @@ +/* + * 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. + */ + +/** + * $Id: context.h 3139 2008-10-28 09:53:16Z elias_naur $ + * + * @author elias_naur + * @version $Revision: 3139 $ + */ + +#ifndef __LWJGL_CONTEXT_H +#define __LWJGL_CONTEXT_H + +#include +#include +#include "common_tools.h" +#include "extgl.h" +#include "extgl_wgl.h" + +typedef struct { + union { + HWND hwnd; + struct { + HPBUFFERARB pbuffer; + // Contains the function pointers that + // created the pbuffer + WGLExtensions extensions; + } pbuffer; + } u; + HDC drawable_hdc; +} WindowsPeerInfo; + +/* + * Register the LWJGL window class. + * Returns true for success, or false for failure + */ +extern bool registerWindow(); + +extern bool applyPixelFormat(JNIEnv *env, HDC hdc, int iPixelFormat); + +/* + * Close the window + */ +extern void closeWindow(HWND *hwnd, HDC *hdc); + +/** + * Create a dummy window suitable to create contexts from + */ +extern HWND createDummyWindow(int x, int y); + +/** + * Return appropriate window and extended style flags from the given fullscreen and undecorated property + */ +extern void getWindowFlags(DWORD *windowflags_return, DWORD *exstyle_return, bool undecorated, bool child_window); + +/* + * Create a window with the specified position, size, and + * fullscreen attribute. The window will have DirectInput associated + * with it. + * + * Returns true for success, or false for failure + */ +extern HWND createWindow(LPCTSTR window_class_name, int x, int y, int width, int height, bool undecorated, bool child_window, HWND parent); + +extern int findPixelFormatOnDC(JNIEnv *env, HDC hdc, int origin_x, int origin_y, jobject pixel_format, jobject pixelFormatCaps, bool use_hdc_bpp, bool window, bool pbuffer, bool double_buffer); + +#endif diff --git a/src/native/windows/display.c b/src/native/windows/display.c new file mode 100644 index 0000000..a858745 --- /dev/null +++ b/src/native/windows/display.c @@ -0,0 +1,277 @@ +/* + * 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. + */ + +/** + * $Id: display.c 2985 2008-04-07 18:42:36Z matzon $ + * + * Windows specific library for display handling. + * + * @author cix_foo + * @version $Revision: 2985 $ + */ + +#include +#include +#include "org_lwjgl_opengl_WindowsDisplay.h" +#include "display.h" +#include "common_tools.h" + +static jobject createDisplayMode(JNIEnv *env, DEVMODE *devmode) { + jclass displayModeClass; + + jmethodID displayModeConstructor; + + displayModeClass = (*env)->FindClass(env, "org/lwjgl/opengl/DisplayMode"); + if (displayModeClass == NULL) + return NULL; + displayModeConstructor = (*env)->GetMethodID(env, displayModeClass, "", "(IIII)V"); + if (displayModeConstructor == NULL) + return NULL; + + return (*env)->NewObject(env, displayModeClass, displayModeConstructor, + devmode->dmPelsWidth, devmode->dmPelsHeight, + devmode->dmBitsPerPel, devmode->dmDisplayFrequency); +} + +/** + * Choose displaymodes using extended codepath (multiple displaydevices) + */ +jobjectArray getAvailableDisplayModes(JNIEnv * env) { + + int i = 0, j = 0, n = 0; + +// DISPLAY_DEVICE DisplayDevice; + DEVMODE DevMode; + jobject *display_mode_objects = NULL; + int list_size = 0; + + jclass displayModeClass; + jobjectArray ret; + displayModeClass = (*env)->FindClass(env, "org/lwjgl/opengl/DisplayMode"); + + ZeroMemory(&DevMode, sizeof(DEVMODE)); +// ZeroMemory(&DisplayDevice, sizeof(DISPLAY_DEVICE)); + + DevMode.dmSize = sizeof(DEVMODE); +// DisplayDevice.cb = sizeof(DISPLAY_DEVICE); + + /* Multi-monitor stuff commented out since we're only really interested in the primary monitor */ +/* while(EnumDisplayDevices(NULL, i++, &DisplayDevice, 0) != 0) { + // continue if mirroring device + if((DisplayDevice.StateFlags & DISPLAY_DEVICE_MIRRORING_DRIVER) != 0) { + continue; + } + + j = 0; + while(EnumDisplaySettings((const char *) DisplayDevice.DeviceName, j++, &DevMode) != 0) {*/ + while(EnumDisplaySettings(NULL, j++, &DevMode) != 0) { + // Filter out indexed modes + if (DevMode.dmBitsPerPel > 8 && ChangeDisplaySettings(&DevMode, CDS_FULLSCREEN | CDS_TEST) == DISP_CHANGE_SUCCESSFUL) { + jobject displayMode; + if (list_size <= n) { + list_size += 1; + display_mode_objects = (jobject *)realloc(display_mode_objects, sizeof(jobject)*list_size); + if (display_mode_objects == NULL) + return NULL; + } + displayMode = createDisplayMode(env, &DevMode); + display_mode_objects[n++] = displayMode; + } + } +// } + printfDebugJava(env, "Found %d displaymodes", n); + + ret = (*env)->NewObjectArray(env, n, displayModeClass, NULL); + for (i = 0; i < n; i++) { + (*env)->SetObjectArrayElement(env, ret, i, display_mode_objects[i]); + } + free(display_mode_objects); + return ret; +} + +void switchDisplayMode(JNIEnv * env, jobject mode) { + DEVMODE devmode; + + jclass cls_displayMode = (*env)->GetObjectClass(env, mode); + jfieldID fid_width = (*env)->GetFieldID(env, cls_displayMode, "width", "I"); + jfieldID fid_height = (*env)->GetFieldID(env, cls_displayMode, "height", "I"); + jfieldID fid_bpp = (*env)->GetFieldID(env, cls_displayMode, "bpp", "I"); + jfieldID fid_freq = (*env)->GetFieldID(env, cls_displayMode, "freq", "I"); + + int width = (*env)->GetIntField(env, mode, fid_width); + int height = (*env)->GetIntField(env, mode, fid_height); + int bpp = (*env)->GetIntField(env, mode, fid_bpp); + int freq = (*env)->GetIntField(env, mode, fid_freq); + LONG cdsret; + + ZeroMemory(&devmode, sizeof(DEVMODE)); + devmode.dmSize = sizeof(DEVMODE); + devmode.dmBitsPerPel = bpp; + devmode.dmPelsWidth = width; + devmode.dmPelsHeight = height; + devmode.dmDisplayFrequency = freq; + devmode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT; + if (freq != 0) + devmode.dmFields |= DM_DISPLAYFREQUENCY; + cdsret = ChangeDisplaySettings(&devmode, CDS_FULLSCREEN); + + if (cdsret != DISP_CHANGE_SUCCESSFUL) { + /* What's the proper way to do this multiply with 2 thing, if at all necessary? */ +/* // Failed: so let's check to see if it's a wierd dual screen display + printfDebugJava(env, "Failed to set display mode (%ld) ... assuming dual monitors", cdsret); + devmode.dmPelsWidth = width * 2; + cdsret = ChangeDisplaySettings(&devmode, CDS_FULLSCREEN); + + if (cdsret != DISP_CHANGE_SUCCESSFUL) { + printfDebugJava(env, "Failed to set display mode using dual monitors (%ld)", cdsret);*/ + throwFormattedException(env, "Failed to set display mode (%ld).", cdsret); + return; +// } + } +} + +static jobject createNativeGammaBuffer(JNIEnv *env) { + return newJavaManagedByteBuffer(env, sizeof(WORD)*3*org_lwjgl_opengl_WindowsDisplay_GAMMA_LENGTH); +} + +jobject getCurrentGammaRamp(JNIEnv *env) { + jobject gamma_buffer; + WORD *gamma; + HDC screenDC; + + gamma_buffer = createNativeGammaBuffer(env); + if (gamma_buffer == NULL) + return NULL; + gamma = (WORD *)(*env)->GetDirectBufferAddress(env, gamma_buffer); + + // Get the screen + screenDC = GetDC(NULL); + if (screenDC == NULL) { + throwException(env, "Couldn't get screen DC!"); + return NULL; + } + // Get the default gamma ramp + if (GetDeviceGammaRamp(screenDC, gamma) == FALSE) { + printfDebugJava(env, "Failed to get initial device gamma"); + } + ReleaseDC(NULL, screenDC); + return gamma_buffer; +} + +void setGammaRamp(JNIEnv * env, jobject gammaRampBuffer) { + HDC screenDC; + WORD *gammaRamp = (WORD *)(*env)->GetDirectBufferAddress(env, gammaRampBuffer); + + screenDC = GetDC(NULL); + if (SetDeviceGammaRamp(screenDC, gammaRamp) == FALSE) { + throwException(env, "Failed to set device gamma."); + } + ReleaseDC(NULL, screenDC); +} + +jobject convertToNativeRamp(JNIEnv *env, jobject float_gamma_obj) { + int i; + float scaledRampEntry; + WORD rampEntry; + const float *gammaRamp = (const float *)(*env)->GetDirectBufferAddress(env, float_gamma_obj); + jint gamma_ramp_length = (*env)->GetDirectBufferCapacity(env, float_gamma_obj); + jobject native_ramp; + WORD *native_ramp_buffer; + + native_ramp = createNativeGammaBuffer(env); + if (native_ramp == NULL) + return NULL; + native_ramp_buffer = (WORD *)(*env)->GetDirectBufferAddress(env, native_ramp); + // Turn array of floats into array of RGB WORDs + + for (i = 0; i < gamma_ramp_length; i++) { + scaledRampEntry = gammaRamp[i]*0xffff; + rampEntry = (WORD)scaledRampEntry; + native_ramp_buffer[i] = rampEntry; + native_ramp_buffer[i + org_lwjgl_opengl_WindowsDisplay_GAMMA_LENGTH] = rampEntry; + native_ramp_buffer[i + 2*org_lwjgl_opengl_WindowsDisplay_GAMMA_LENGTH] = rampEntry; + } + return native_ramp; +} + +jobject getCurrentDisplayMode(JNIEnv * env) { + DEVMODE devmode; + if (!EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &devmode)) { + throwFormattedException(env, "Couldn't get current display settings (%ld)", GetLastError()); + return NULL; + } + return createDisplayMode(env, &devmode); +} + +void resetDisplayMode(JNIEnv * env) { + // Under Windows, all we have to do is: + ChangeDisplaySettings(NULL, 0); +} + +jobject getVersion(JNIEnv * env, char *driver) +{ + DWORD var = 0; + DWORD dwInfoSize; + LPVOID lpInfoBuff; + BOOL bRetval; + jclass version_class; + jmethodID version_cons; + jobject ret = NULL; + + version_class = (*env)->FindClass(env, "org/lwjgl/opengl/WindowsFileVersion"); + if (version_class == NULL) + return NULL; + version_cons = (*env)->GetMethodID(env, version_class, "", "(II)V"); + if (version_cons == NULL) + return NULL; + + dwInfoSize = GetFileVersionInfoSize(driver, &var); + lpInfoBuff = malloc(dwInfoSize); + if (lpInfoBuff == NULL) { + throwException(env, "Failed to allocate lpInfoBuff"); + return NULL; + } + bRetval = GetFileVersionInfo(driver, 0, dwInfoSize, lpInfoBuff); + if (bRetval != 0) { + VS_FIXEDFILEINFO * fxdFileInfo; + + UINT uiLen = 0; + bRetval = VerQueryValue(lpInfoBuff, TEXT("\\"), (void *)&fxdFileInfo, &uiLen); + if (bRetval != 0) + ret = (*env)->NewObject(env, version_class, version_cons, fxdFileInfo->dwProductVersionMS, fxdFileInfo->dwProductVersionLS); + } + + free(lpInfoBuff); + + return ret; +} + diff --git a/src/native/windows/display.h b/src/native/windows/display.h new file mode 100644 index 0000000..ba0a510 --- /dev/null +++ b/src/native/windows/display.h @@ -0,0 +1,57 @@ +/* + * 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. + */ + +/** + * $Id: display.h 2985 2008-04-07 18:42:36Z matzon $ + * + * Windows specific library for display handling. + * + * @author cix_foo + * @version $Revision: 2985 $ + */ + +#ifndef _DISPLAY_H +#define _DISPLAY_H + +#include + +extern jobjectArray getAvailableDisplayModes(JNIEnv *env); +extern void switchDisplayMode(JNIEnv * env, jobject mode); +extern void resetDisplayMode(JNIEnv * env); +extern void restoreDisplayMode(void); +extern void setGammaRamp(JNIEnv * env, jobject gammaRampBuffer); +extern jobject getCurrentGammaRamp(JNIEnv *env); +extern jobject getCurrentDisplayMode(JNIEnv * env); +extern jobject getVersion(JNIEnv * env, char *driver); +extern jobject convertToNativeRamp(JNIEnv *env, jobject float_gamma_obj); + +#endif diff --git a/src/native/windows/extgl_wgl.c b/src/native/windows/extgl_wgl.c new file mode 100644 index 0000000..5c88289 --- /dev/null +++ b/src/native/windows/extgl_wgl.c @@ -0,0 +1,183 @@ +/* ---------------------------------------------------------------------------- +Copyright (c) 2001-2002, Lev Povalahev +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. + * The name of the author 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. +------------------------------------------------------------------------------*/ +/* + Lev Povalahev + + levp@gmx.net + + http://www.uni-karlsruhe.de/~uli2/ + +*/ + +#include +#include +#include "extgl_wgl.h" +#include "extgl.h" + +static HMODULE lib_gl_handle = NULL; + +void *extgl_GetProcAddress(const char *name) { + void *t = wglGetProcAddress(name); + if (t == NULL) + { + t = GetProcAddress(lib_gl_handle, name); + if (t == NULL) + { + printfDebug("Could not locate symbol %s\n", name); + } + } + return t; +} + +bool extgl_Open(JNIEnv *env) { + if (lib_gl_handle != NULL) + return true; + // load the dynamic libraries for OpenGL + lib_gl_handle = LoadLibrary("opengl32.dll"); + if (lib_gl_handle == NULL) { + throwException(env, "Could not load OpenGL library"); + return false; + } + return true; +} + +void extgl_Close(void) { + FreeLibrary(lib_gl_handle); + lib_gl_handle = NULL; +} + +/** returns true if the extension is available */ +static bool WGLQueryExtension(WGLExtensions *extensions, const char *name) { + const GLubyte *extension_string; + + if (!extensions->WGL_ARB_extensions_string) + if (!extensions->WGL_EXT_extensions_string) + return false; + else + extension_string = (GLubyte*)extensions->wglGetExtensionsStringEXT(); + else + extension_string = (GLubyte*)extensions->wglGetExtensionsStringARB(wglGetCurrentDC()); + return extgl_QueryExtension(extension_string, name); +} + +static void extgl_InitWGLARBPbuffer(WGLExtensions *extensions) { + ExtFunction functions[] = { + {"wglCreatePbufferARB", (void *)&extensions->wglCreatePbufferARB}, + {"wglGetPbufferDCARB", (void *)&extensions->wglGetPbufferDCARB}, + {"wglReleasePbufferDCARB", (void *)&extensions->wglReleasePbufferDCARB}, + {"wglDestroyPbufferARB", (void *)&extensions->wglDestroyPbufferARB}, + {"wglQueryPbufferARB", (void *)&extensions->wglQueryPbufferARB}}; + if (extensions->WGL_ARB_pbuffer) + extensions->WGL_ARB_pbuffer = extgl_InitializeFunctions(sizeof(functions)/sizeof(ExtFunction), functions); +} + +static void extgl_InitWGLARBPixelFormat(WGLExtensions *extensions) { + ExtFunction functions[] = { + {"wglGetPixelFormatAttribivARB", (void *)&extensions->wglGetPixelFormatAttribivARB}, + {"wglGetPixelFormatAttribfvARB", (void *)&extensions->wglGetPixelFormatAttribfvARB}, + {"wglChoosePixelFormatARB", (void *)&extensions->wglChoosePixelFormatARB}}; + if (extensions->WGL_ARB_pixel_format) + extensions->WGL_ARB_pixel_format = extgl_InitializeFunctions(sizeof(functions)/sizeof(ExtFunction), functions); +} + +static void extgl_InitWGLARBRenderTexture(WGLExtensions *extensions) { + ExtFunction functions[] = { + {"wglBindTexImageARB", (void *)&extensions->wglBindTexImageARB}, + {"wglReleaseTexImageARB", (void *)&extensions->wglReleaseTexImageARB}, + {"wglSetPbufferAttribARB", (void *)&extensions->wglSetPbufferAttribARB}}; + if (extensions->WGL_ARB_render_texture) + extensions->WGL_ARB_render_texture = extgl_InitializeFunctions(sizeof(functions)/sizeof(ExtFunction), functions); +} + +static void extgl_InitWGLEXTSwapControl(WGLExtensions *extensions) { + ExtFunction functions[] = { + {"wglSwapIntervalEXT", (void *)&extensions->wglSwapIntervalEXT}, + {"wglGetSwapIntervalEXT", (void *)&extensions->wglGetSwapIntervalEXT}}; + if (extensions->WGL_EXT_swap_control) + extensions->WGL_EXT_swap_control = extgl_InitializeFunctions(sizeof(functions)/sizeof(ExtFunction), functions); +} + +static void extgl_InitWGLARBMakeCurrentRead(WGLExtensions *extensions) { + ExtFunction functions[] = { + {"wglMakeContextCurrentARB", (void *)&extensions->wglMakeContextCurrentARB}, + {"wglGetCurrentReadDCARB", (void *)&extensions->wglGetCurrentReadDCARB}}; + if (extensions->WGL_ARB_make_current_read) + extensions->WGL_ARB_make_current_read = extgl_InitializeFunctions(sizeof(functions)/sizeof(ExtFunction), functions); +} + +static void extgl_InitWGLARBCreateContext(WGLExtensions *extensions) { + ExtFunction functions[] = { + {"wglCreateContextAttribsARB", (void *)&extensions->wglCreateContextAttribsARB} + }; + if (extensions->WGL_ARB_create_context) + extensions->WGL_ARB_create_context = extgl_InitializeFunctions(sizeof(functions)/sizeof(ExtFunction), functions); +} + +static void extgl_InitSupportedWGLExtensions(WGLExtensions *extensions) { + extensions->WGL_ARB_buffer_region = WGLQueryExtension(extensions, "WGL_ARB_buffer_region"); + extensions->WGL_ARB_make_current_read = WGLQueryExtension(extensions, "WGL_ARB_make_current_read"); + extensions->WGL_ARB_multisample = WGLQueryExtension(extensions, "WGL_ARB_multisample"); + extensions->WGL_ARB_pixel_format_float = WGLQueryExtension(extensions, "WGL_ARB_pixel_format_float"); + extensions->WGL_ATI_pixel_format_float = WGLQueryExtension(extensions, "WGL_ATI_pixel_format_float"); + extensions->WGL_ARB_pbuffer = WGLQueryExtension(extensions, "WGL_ARB_pbuffer"); + extensions->WGL_ARB_pixel_format = WGLQueryExtension(extensions, "WGL_ARB_pixel_format"); + extensions->WGL_ARB_render_texture = WGLQueryExtension(extensions, "WGL_ARB_render_texture"); + extensions->WGL_EXT_swap_control = WGLQueryExtension(extensions, "WGL_EXT_swap_control"); + extensions->WGL_NV_render_depth_texture = WGLQueryExtension(extensions, "WGL_NV_render_depth_texture"); + extensions->WGL_NV_render_texture_rectangle = WGLQueryExtension(extensions, "WGL_NV_render_texture_rectangle"); + extensions->WGL_ARB_framebuffer_sRGB = WGLQueryExtension(extensions, "WGL_ARB_framebuffer_sRGB") || WGLQueryExtension(extensions, "WGL_EXT_framebuffer_sRGB"); + extensions->WGL_EXT_pixel_format_packed_float = WGLQueryExtension(extensions, "WGL_EXT_pixel_format_packed_float"); + extensions->WGL_ARB_create_context = WGLQueryExtension(extensions, "WGL_ARB_create_context"); +} + +static void extgl_InitWGLEXTExtensionsString(WGLExtensions *extensions) { + ExtFunction functions[] = { + {"wglGetExtensionsStringEXT", (void *)&extensions->wglGetExtensionsStringEXT} + }; + extensions->WGL_EXT_extensions_string = extgl_InitializeFunctions(sizeof(functions)/sizeof(ExtFunction), functions); +} + +static void extgl_InitWGLARBExtensionsString(WGLExtensions *extensions) { + ExtFunction functions[] = { + {"wglGetExtensionsStringARB", (void *)&extensions->wglGetExtensionsStringARB} + }; + extensions->WGL_ARB_extensions_string = extgl_InitializeFunctions(sizeof(functions)/sizeof(ExtFunction), functions); +} + +void extgl_InitWGL(WGLExtensions *extensions) { + extgl_InitWGLARBExtensionsString(extensions); + extgl_InitWGLEXTExtensionsString(extensions); + + extgl_InitSupportedWGLExtensions(extensions); + + extgl_InitWGLARBMakeCurrentRead(extensions); + extgl_InitWGLEXTSwapControl(extensions); + extgl_InitWGLARBRenderTexture(extensions); + extgl_InitWGLARBPixelFormat(extensions); + extgl_InitWGLARBPbuffer(extensions); + extgl_InitWGLARBCreateContext(extensions); +} diff --git a/src/native/windows/extgl_wgl.h b/src/native/windows/extgl_wgl.h new file mode 100644 index 0000000..a6ead0f --- /dev/null +++ b/src/native/windows/extgl_wgl.h @@ -0,0 +1,251 @@ +/* ---------------------------------------------------------------------------- +Copyright (c) 2001-2002, Lev Povalahev +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. + * The name of the author 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. +------------------------------------------------------------------------------*/ +/* + Lev Povalahev + + levp@gmx.net + + http://www.uni-karlsruhe.de/~uli2/ + +*/ + +#ifndef _EXTGL_WGL_H +#define _EXTGL_WGL_H + +#include +#include "extgl.h" +#include "common_tools.h" + +/*-------------------------------------------------------------------*/ +/*------------WGL_EXT_EXTENSION_STRING-------------------------------*/ +/*-------------------------------------------------------------------*/ + +typedef const char* (APIENTRY * wglGetExtensionsStringEXTPROC) (); + +/*-------------------------------------------------------------------*/ +/*------------WGL_ARB_EXTENSION_STRING-------------------------------*/ +/*-------------------------------------------------------------------*/ + +typedef const char* (APIENTRY * wglGetExtensionsStringARBPROC) (HDC hdc); + +/*-------------------------------------------------------------------*/ +/*------------WGL_ARB_PBUFFER----------------------------------------*/ +/*-------------------------------------------------------------------*/ + +#define WGL_DRAW_TO_PBUFFER_ARB 0x202D +#define WGL_DRAW_TO_PBUFFER_ARB 0x202D +#define WGL_MAX_PBUFFER_PIXELS_ARB 0x202E +#define WGL_MAX_PBUFFER_WIDTH_ARB 0x202F +#define WGL_MAX_PBUFFER_HEIGHT_ARB 0x2030 +#define WGL_PBUFFER_LARGEST_ARB 0x2033 +#define WGL_PBUFFER_WIDTH_ARB 0x2034 +#define WGL_PBUFFER_HEIGHT_ARB 0x2035 +#define WGL_PBUFFER_LOST_ARB 0x2036 + +DECLARE_HANDLE(HPBUFFERARB); + +typedef HPBUFFERARB (APIENTRY * wglCreatePbufferARBPROC) (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList); +typedef HDC (APIENTRY * wglGetPbufferDCARBPROC) (HPBUFFERARB hPbuffer); +typedef int (APIENTRY * wglReleasePbufferDCARBPROC) (HPBUFFERARB hPbuffer, HDC hDC); +typedef BOOL (APIENTRY * wglDestroyPbufferARBPROC) (HPBUFFERARB hPbuffer); +typedef BOOL (APIENTRY * wglQueryPbufferARBPROC) (HPBUFFERARB hPbuffer, int iAttribute, int *piValue); + +/*-------------------------------------------------------------------*/ +/*------------WGL_ARB_PIXEL_FORMAT-----------------------------------*/ +/*-------------------------------------------------------------------*/ + +#define WGL_NUMBER_PIXEL_FORMATS_ARB 0x2000 +#define WGL_DRAW_TO_WINDOW_ARB 0x2001 +#define WGL_DRAW_TO_BITMAP_ARB 0x2002 +#define WGL_ACCELERATION_ARB 0x2003 +#define WGL_NEED_PALETTE_ARB 0x2004 +#define WGL_NEED_SYSTEM_PALETTE_ARB 0x2005 +#define WGL_SWAP_LAYER_BUFFERS_ARB 0x2006 +#define WGL_SWAP_METHOD_ARB 0x2007 +#define WGL_NUMBER_OVERLAYS_ARB 0x2008 +#define WGL_NUMBER_UNDERLAYS_ARB 0x2009 +#define WGL_TRANSPARENT_ARB 0x200A +#define WGL_TRANSPARENT_RED_VALUE_ARB 0x2037 +#define WGL_TRANSPARENT_GREEN_VALUE_ARB 0x2038 +#define WGL_TRANSPARENT_BLUE_VALUE_ARB 0x2039 +#define WGL_TRANSPARENT_ALPHA_VALUE_ARB 0x203A +#define WGL_TRANSPARENT_INDEX_VALUE_ARB 0x203B +#define WGL_SHARE_DEPTH_ARB 0x200C +#define WGL_SHARE_STENCIL_ARB 0x200D +#define WGL_SHARE_ACCUM_ARB 0x200E +#define WGL_SUPPORT_GDI_ARB 0x200F +#define WGL_SUPPORT_OPENGL_ARB 0x2010 +#define WGL_DOUBLE_BUFFER_ARB 0x2011 +#define WGL_STEREO_ARB 0x2012 +#define WGL_PIXEL_TYPE_ARB 0x2013 +#define WGL_COLOR_BITS_ARB 0x2014 +#define WGL_RED_BITS_ARB 0x2015 +#define WGL_RED_SHIFT_ARB 0x2016 +#define WGL_GREEN_BITS_ARB 0x2017 +#define WGL_GREEN_SHIFT_ARB 0x2018 +#define WGL_BLUE_BITS_ARB 0x2019 +#define WGL_BLUE_SHIFT_ARB 0x201A +#define WGL_ALPHA_BITS_ARB 0x201B +#define WGL_ALPHA_SHIFT_ARB 0x201C +#define WGL_ACCUM_BITS_ARB 0x201D +#define WGL_ACCUM_RED_BITS_ARB 0x201E +#define WGL_ACCUM_GREEN_BITS_ARB 0x201F +#define WGL_ACCUM_BLUE_BITS_ARB 0x2020 +#define WGL_ACCUM_ALPHA_BITS_ARB 0x2021 +#define WGL_DEPTH_BITS_ARB 0x2022 +#define WGL_STENCIL_BITS_ARB 0x2023 +#define WGL_AUX_BUFFERS_ARB 0x2024 +#define WGL_NO_ACCELERATION_ARB 0x2025 +#define WGL_GENERIC_ACCELERATION_ARB 0x2026 +#define WGL_FULL_ACCELERATION_ARB 0x2027 +#define WGL_SWAP_EXCHANGE_ARB 0x2028 +#define WGL_SWAP_COPY_ARB 0x2029 +#define WGL_SWAP_UNDEFINED_ARB 0x202A +#define WGL_TYPE_RGBA_ARB 0x202B +#define WGL_TYPE_COLORINDEX_ARB 0x202C + +typedef BOOL (APIENTRY * wglGetPixelFormatAttribivARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, int *piValues); +typedef BOOL (APIENTRY * wglGetPixelFormatAttribfvARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, FLOAT *pfValues); +typedef BOOL (APIENTRY * wglChoosePixelFormatARBPROC) (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); + +typedef BOOL (APIENTRY * wglBindTexImageARBPROC) (HPBUFFERARB hPbuffer, int iBuffer); +typedef BOOL (APIENTRY * wglReleaseTexImageARBPROC) (HPBUFFERARB hPbuffer, int iBuffer); +typedef BOOL (APIENTRY * wglSetPbufferAttribARBPROC) (HPBUFFERARB hPbuffer, const int *piAttribList); + +/*-------------------------------------------------------------------*/ +/*------------WGL_EXT_SWAP_CONTROL-----------------------------------*/ +/*-------------------------------------------------------------------*/ + +typedef BOOL (APIENTRY * wglSwapIntervalEXTPROC) (int interval); +typedef int (APIENTRY * wglGetSwapIntervalEXTPROC) (void); + +/*-------------------------------------------------------------------*/ +/*------------WGL_ARB_MAKE_CURRENT_READ------------------------------*/ +/*-------------------------------------------------------------------*/ + +#define ERROR_INVALID_PIXEL_TYPE_ARB 0x2043 +#define ERROR_INCOMPATIBLE_DEVICE_CONTEXTS_ARB 0x2054 + +typedef BOOL (APIENTRY * wglMakeContextCurrentARBPROC) (HDC hDrawDC, HDC hReadDC, HGLRC hglrc); +typedef HDC (APIENTRY * wglGetCurrentReadDCARBPROC) (void); + +/*-------------------------------------------------------------------*/ +/*------------WGL_ARB_MULTISAMPLE------------------------------------*/ +/*-------------------------------------------------------------------*/ + +#define WGL_SAMPLE_BUFFERS_ARB 0x2041 +#define WGL_SAMPLES_ARB 0x2042 + +/*-------------------------------------------------------------------*/ +/*------------WGL_ARB_pixel_format_float ----------------------------*/ +/*-------------------------------------------------------------------*/ + +#define WGL_TYPE_RGBA_FLOAT_ARB 0x21A0 + +/*-------------------------------------------------------------------*/ +/*------------WGL_ATI_pixel_format_float ----------------------------*/ +/*-------------------------------------------------------------------*/ + +#define WGL_TYPE_RGBA_FLOAT_ATI 0x21A0 + +/*------------------------------------------------------------------*/ +/*------------ WGL_ARB_framebuffer_sRGB ----------------------------*/ +/*------------------------------------------------------------------*/ + +#define WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20A9 + +/*---------------------------------------------------------------------------*/ +/*------------ WGL_EXT_pixel_format_packed_float ----------------------------*/ +/*---------------------------------------------------------------------------*/ + +#define WGL_TYPE_RGBA_UNSIGNED_FLOAT_EXT 0x20A8 + +/*----------------------------------------------------------------*/ +/*------------ WGL_ARB_create_context ----------------------------*/ +/*----------------------------------------------------------------*/ + +#define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091 +#define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092 +#define WGL_CONTEXT_LAYER_PLANE_ARB 0x2093 +#define WGL_CONTEXT_FLAGS_ARB 0x2094 + +#define WGL_CONTEXT_DEBUG_BIT_ARB 0x0001 +#define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x0002 + +#define ERROR_INVALID_VERSION_ARB 0x2095 + +typedef HGLRC (APIENTRY * wglCreateContextAttribsARBPROC) (HDC hDC, HGLRC hShareContext, const int *attribList); + +typedef struct { + bool WGL_ARB_buffer_region; + bool WGL_ARB_extensions_string; + bool WGL_ARB_make_current_read; + bool WGL_ARB_multisample; + bool WGL_ARB_pbuffer; + bool WGL_ARB_pixel_format; + bool WGL_ARB_render_texture; + bool WGL_EXT_extensions_string; + bool WGL_EXT_swap_control; + bool WGL_NV_render_depth_texture; + bool WGL_NV_render_texture_rectangle; + bool WGL_ARB_pixel_format_float; + bool WGL_ATI_pixel_format_float; + bool WGL_ARB_framebuffer_sRGB; + bool WGL_EXT_pixel_format_packed_float; + bool WGL_ARB_create_context; + + wglGetExtensionsStringEXTPROC wglGetExtensionsStringEXT; + + wglGetExtensionsStringARBPROC wglGetExtensionsStringARB; + + wglCreatePbufferARBPROC wglCreatePbufferARB; + wglGetPbufferDCARBPROC wglGetPbufferDCARB; + wglReleasePbufferDCARBPROC wglReleasePbufferDCARB; + wglDestroyPbufferARBPROC wglDestroyPbufferARB; + wglQueryPbufferARBPROC wglQueryPbufferARB; + + wglGetPixelFormatAttribivARBPROC wglGetPixelFormatAttribivARB; + wglGetPixelFormatAttribfvARBPROC wglGetPixelFormatAttribfvARB; + wglChoosePixelFormatARBPROC wglChoosePixelFormatARB; + + wglBindTexImageARBPROC wglBindTexImageARB; + wglReleaseTexImageARBPROC wglReleaseTexImageARB; + wglSetPbufferAttribARBPROC wglSetPbufferAttribARB; + + wglSwapIntervalEXTPROC wglSwapIntervalEXT; + wglGetSwapIntervalEXTPROC wglGetSwapIntervalEXT; + + wglMakeContextCurrentARBPROC wglMakeContextCurrentARB; + wglGetCurrentReadDCARBPROC wglGetCurrentReadDCARB; + + wglCreateContextAttribsARBPROC wglCreateContextAttribsARB; +} WGLExtensions; + +extern void extgl_InitWGL(WGLExtensions *extensions); + + +#endif diff --git a/src/native/windows/org_lwjgl_Sys.c b/src/native/windows/org_lwjgl_Sys.c new file mode 100644 index 0000000..390d218 --- /dev/null +++ b/src/native/windows/org_lwjgl_Sys.c @@ -0,0 +1,121 @@ +/* + * 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. + */ + +/** + * $Id: org_lwjgl_Sys.c 3259 2009-12-02 23:11:14Z matzon $ + * + * Windows system library. + * + * @author cix_foo + * @version $Revision: 3259 $ + */ + +#include "Window.h" +#include "mmsystem.h" +#include "org_lwjgl_WindowsSysImplementation.h" +#include "common_tools.h" +#include +#include + +JNIEXPORT jlong JNICALL Java_org_lwjgl_WindowsSysImplementation_nGetTime(JNIEnv * env, jclass unused) { + DWORD time; + + timeBeginPeriod(1); + time = timeGetTime(); + timeEndPeriod(1); + + return time; +} + +JNIEXPORT void JNICALL Java_org_lwjgl_WindowsSysImplementation_nAlert(JNIEnv * env, jclass unused, jlong hwnd_ptr, jstring title, jstring message) { + HWND hwnd = (HWND)(INT_PTR)hwnd_ptr; + char * eMessageText = GetStringNativeChars(env, message); + char * cTitleBarText = GetStringNativeChars(env, title); + MessageBox(hwnd, eMessageText, cTitleBarText, MB_OK | MB_TOPMOST); + + printfDebugJava(env, "*** Alert ***%s\n%s\n", cTitleBarText, eMessageText); + + free(eMessageText); + free(cTitleBarText); +} + +JNIEXPORT void JNICALL Java_org_lwjgl_WindowsSysImplementation_initCommonControls(JNIEnv * env, jclass unused) { + InitCommonControls(); +} + +JNIEXPORT jstring JNICALL Java_org_lwjgl_WindowsSysImplementation_nGetClipboard + (JNIEnv * env, jclass unused) +{ + // Check to see if there's text available in the clipboard + BOOL textAvailable = IsClipboardFormatAvailable(CF_TEXT); + BOOL unicodeAvailable = IsClipboardFormatAvailable(CF_UNICODETEXT); + void *clipboard_data; + jstring ret; + HANDLE hglb; + const wchar_t * str; + + if (unicodeAvailable) { + if (!OpenClipboard(NULL)) + return NULL; + hglb = GetClipboardData(CF_UNICODETEXT); + if (hglb == NULL) { + CloseClipboard(); + return NULL; + } + clipboard_data = GlobalLock(hglb); + if (clipboard_data == NULL) { + CloseClipboard(); + return NULL; + } + str = (const wchar_t *)clipboard_data; + ret = (*env)->NewString(env, str, wcslen(str)); + } else if (textAvailable) { + if (!OpenClipboard(NULL)) + return NULL; + hglb = GetClipboardData(CF_TEXT); + if (hglb == NULL) { + CloseClipboard(); + return NULL; + } + clipboard_data = GlobalLock(hglb); + if (clipboard_data == NULL) { + CloseClipboard(); + return NULL; + } + ret = NewStringNativeWithLength(env, (const char *) clipboard_data, strlen(clipboard_data)); + } else { + return NULL; + } + GlobalUnlock(hglb); + CloseClipboard(); + return ret; +} diff --git a/src/native/windows/org_lwjgl_input_Cursor.c b/src/native/windows/org_lwjgl_input_Cursor.c new file mode 100644 index 0000000..be93262 --- /dev/null +++ b/src/native/windows/org_lwjgl_input_Cursor.c @@ -0,0 +1,167 @@ +/* + * 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. + */ + +/** + * $Id: org_lwjgl_input_Cursor.c 3263 2010-01-10 22:46:41Z matzon $ + * + * win32 mouse handling. + * + * @author elias_naur + * @version $Revision: 3263 $ + */ + +#include "Window.h" +#include "org_lwjgl_input_Cursor.h" +#include "org_lwjgl_opengl_WindowsDisplay.h" +#include "common_tools.h" + +JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nCreateCursor +(JNIEnv *env, jclass unused, jint width, jint height, jint x_hotspot, jint y_hotspot, jint num_images, jobject image_buffer, jint images_offset, jobject delay_buffer, jint delays_offset) +{ + unsigned char col0, col1, col2, col3, col4, col5, col6, col7; + unsigned char mask; + BITMAPINFO bitmapInfo; + + HBITMAP cursorMask; + HCURSOR *cursor_handle; + + HCURSOR cursor = NULL; + ICONINFO iconInfo; + char *ptrCursorImage; + HBITMAP colorDIB; + int *srcPtr; + char *dstPtr; + int bitWidth; + int scanlinePad; + int imageSize; // Size in bits + unsigned char *maskPixels; + int pixelCount = 0; + int maskCount = 0; + HBITMAP colorBitmap; + int x, y; + HDC hDC; + jobject handle_buffer = newJavaManagedByteBuffer(env, sizeof(HCURSOR)); + + int *pixels; + if (handle_buffer == NULL) { + throwException(env, "Could not allocate handle"); + return NULL; + } + pixels = (int *)(*env)->GetDirectBufferAddress(env, image_buffer) + images_offset; + + memset(&bitmapInfo, 0, sizeof(BITMAPINFO)); + bitmapInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); + bitmapInfo.bmiHeader.biWidth = width; + bitmapInfo.bmiHeader.biHeight = -height; + bitmapInfo.bmiHeader.biPlanes = 1; + + bitmapInfo.bmiHeader.biBitCount = 24; + bitmapInfo.bmiHeader.biCompression = BI_RGB; + + hDC = GetDC(NULL); + + colorDIB = CreateDIBSection(hDC, (BITMAPINFO*)&(bitmapInfo), + DIB_RGB_COLORS, + (void*)&(ptrCursorImage), + NULL, 0); + srcPtr = pixels; + dstPtr = ptrCursorImage; + if (!dstPtr) { + throwException(env, "Could not allocate DIB section."); + ReleaseDC(NULL, hDC); + return NULL; + } + for (y = 0; y < height; y++ ) { + for (x = 0; x < width; x++ ) { + dstPtr[2] = (*srcPtr >> 0x10) & 0xFF; + dstPtr[1] = (*srcPtr >> 0x08) & 0xFF; + dstPtr[0] = *srcPtr & 0xFF; + + srcPtr++; + dstPtr += 3; + } + } + + colorBitmap = CreateDIBitmap(hDC, + (BITMAPINFOHEADER*)&bitmapInfo.bmiHeader, + CBM_INIT, + (void *)ptrCursorImage, + (BITMAPINFO*)&bitmapInfo, + DIB_RGB_COLORS); + + DeleteObject(colorDIB); + + // Convert alpha map to pixel packed mask + bitWidth = width >> 3; + scanlinePad = bitWidth & (sizeof(WORD) - 1); + imageSize = (bitWidth + scanlinePad)*height; // Size in bits + maskPixels = (unsigned char*)malloc(sizeof(unsigned char)*imageSize); + memset(maskPixels, 0, imageSize); + for (y = 0; y < height; y++) + for (x = 0; x < bitWidth; x++) { + col0 = (pixels[pixelCount++] & 0x01000000) >> 17; + col1 = (pixels[pixelCount++] & 0x01000000) >> 18; + col2 = (pixels[pixelCount++] & 0x01000000) >> 19; + col3 = (pixels[pixelCount++] & 0x01000000) >> 20; + col4 = (pixels[pixelCount++] & 0x01000000) >> 21; + col5 = (pixels[pixelCount++] & 0x01000000) >> 22; + col6 = (pixels[pixelCount++] & 0x01000000) >> 23; + col7 = (pixels[pixelCount++] & 0x01000000) >> 24; + mask = col0 | col1 | col2 | col3 | col4 | col5 | col6 | col7; + maskPixels[maskCount++] = ~mask; // 1 is tranparant, 0 opaque + } + + cursorMask = CreateBitmap(width, height, 1, 1, maskPixels); + + memset(&iconInfo, 0, sizeof(ICONINFO)); + iconInfo.hbmMask = cursorMask; + iconInfo.hbmColor = colorBitmap; + iconInfo.fIcon = FALSE; + iconInfo.xHotspot = x_hotspot; + iconInfo.yHotspot = y_hotspot; + cursor = CreateIconIndirect(&iconInfo); + DeleteObject(colorBitmap); + DeleteObject(cursorMask); + free(maskPixels); + ReleaseDC(NULL, hDC); + + cursor_handle = (HCURSOR *)(*env)->GetDirectBufferAddress(env, handle_buffer); + *cursor_handle = cursor; + return handle_buffer; +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_doDestroyCursor +(JNIEnv *env, jclass unused, jobject handle_buffer) +{ + HCURSOR *cursor_handle = (HCURSOR *)(*env)->GetDirectBufferAddress(env, handle_buffer); + DestroyCursor(*cursor_handle); +} diff --git a/src/native/windows/org_lwjgl_opengl_Display.c b/src/native/windows/org_lwjgl_opengl_Display.c new file mode 100644 index 0000000..c24a135 --- /dev/null +++ b/src/native/windows/org_lwjgl_opengl_Display.c @@ -0,0 +1,481 @@ +/* + * 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. + */ + +/** + * $Id: org_lwjgl_opengl_Display.c 3302 2010-03-31 23:56:24Z spasi $ + * + * Base Windows display + * + * @author cix_foo + * @version $Revision: 3302 $ + */ + +#define _PRIVATE_WINDOW_H_ +#include +#include +#include "Window.h" +#include "extgl_wgl.h" +#include "common_tools.h" +#include "display.h" +#include "org_lwjgl_opengl_WindowsDisplay.h" +#include "org_lwjgl_WindowsSysImplementation.h" +#include "context.h" +#include + +#define WINDOWCLASSNAME "LWJGL" + +/* + * WindowProc for the GL window. + */ +static LRESULT CALLBACK lwjglWindowProc(HWND hWnd, + UINT msg, + WPARAM wParam, + LPARAM lParam) +{ + jclass display_class; + jclass display_class_global; + jmethodID handleMessage_method; + LONG message_time; + JNIEnv *env = getThreadEnv(); + if (env != NULL && !(*env)->ExceptionOccurred(env)) { + /* + * We'll cache a global reference to the WindowsDisplay class in the window's user data. + * This is not so much to avoid lookup overhead as it is to avoid problems + * with AWT. Specifically, awt code can indirectly call this message handler + * when it does a SendMessage on the main thread to the currently focused window, + * which could be a LWJGL window. The FindClass will then fail because the calling + * internal awt class is using the system class loader, not the application loader + * where lwjgl is found. + * + * The very first message sent to this handler is sent when + * a window is created, where we are sure that the calling class' classloader has + * LWJGL classes in it. + */ + display_class_global = (jclass)(LONG_PTR)GetWindowLongPtr(hWnd, GWLP_USERDATA); + if (display_class_global == NULL) { + display_class = (*env)->FindClass(env, "org/lwjgl/opengl/WindowsDisplay"); + if (display_class != NULL) { + display_class_global = (*env)->NewGlobalRef(env, display_class); + if (display_class_global != NULL) + SetWindowLongPtr(hWnd, GWLP_USERDATA, (LONG_PTR)display_class_global); + } + } + if (display_class_global != NULL) { + message_time = GetMessageTime(); + handleMessage_method = (*env)->GetStaticMethodID(env, display_class_global, "handleMessage", "(JIJJJ)I"); + if (handleMessage_method != NULL) + return (*env)->CallStaticIntMethod(env, display_class_global, handleMessage_method, (jlong)(intptr_t)hWnd, (jint)msg, (jlong)wParam, (jlong)lParam, (jlong)message_time); + } + } + return DefWindowProc(hWnd, msg, wParam, lParam); +} + +JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_WindowsDisplay_defWindowProc(JNIEnv *env, jclass unused, jlong hWnd, jint msg, jlong wParam, jlong lParam) { + return DefWindowProc((HWND)(INT_PTR)hWnd, msg, wParam, lParam); +} + +/* + * Handle native Windows messages + */ +static void handleMessages(JNIEnv *env) { + /* + * Now's our chance to deal with Windows messages that are + * otherwise just piling up and causing everything not to + * work properly + */ + MSG msg; + while (!(*env)->ExceptionOccurred(env) && PeekMessage( + &msg, // message information + NULL, // handle to window + 0, // first message + 0, // last message + PM_REMOVE // removal options + )) + { + if (msg.message == WM_QUIT) + break; + TranslateMessage(&msg); + DispatchMessage(&msg); + } +} + +JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WindowsDisplay_getDC(JNIEnv *env, jclass unused, jlong hwnd_ptr) { + HWND hwnd = (HWND)(INT_PTR)hwnd_ptr; + return (INT_PTR)GetDC(hwnd); +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nSetTitle + (JNIEnv * env, jclass unused, jlong hwnd_ptr, jstring title_obj) { + HWND hwnd = (HWND)(INT_PTR)hwnd_ptr; + char * title = GetStringNativeChars(env, title_obj); + SetWindowText(hwnd, title); + free(title); +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nUpdate(JNIEnv * env, jclass class) { + handleMessages(env); +} + +JNIEXPORT jobjectArray JNICALL Java_org_lwjgl_opengl_WindowsDisplay_getAvailableDisplayModes(JNIEnv *env, jobject self) { + return getAvailableDisplayModes(env); +} + +JNIEXPORT jint JNICALL Java_org_lwjgl_DefaultSysImplementation_getJNIVersion + (JNIEnv *env, jobject ignored) { + return org_lwjgl_WindowsSysImplementation_JNI_VERSION; +} + +JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nCreateWindow(JNIEnv *env, jclass unused, jint x, jint y, jint width, jint height, jboolean undecorated, jboolean child_window, jlong parent_hwnd) { + HWND hwnd; + static bool oneShotInitialised = false; + if (!oneShotInitialised) { + if (!registerWindow(lwjglWindowProc, WINDOWCLASSNAME)) { + throwException(env, "Could not register window class"); + return 0; + } + oneShotInitialised = true; + } + + hwnd = createWindow(WINDOWCLASSNAME, x, y, width, height, undecorated, child_window, (HWND)(INT_PTR)parent_hwnd); + return (INT_PTR)hwnd; +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nReleaseDC(JNIEnv *env, jclass clazz, jlong hwnd_ptr, jlong hdc_ptr) { + HWND hwnd = (HWND)(INT_PTR)hwnd_ptr; + HDC hdc = (HDC)(INT_PTR)hdc_ptr; + ReleaseDC(hwnd, hdc); +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nDestroyWindow(JNIEnv *env, jclass clazz, jlong hwnd_ptr) { + jclass display_class_global; + HWND hwnd = (HWND)(INT_PTR)hwnd_ptr; + display_class_global = (jclass)(LONG_PTR)GetWindowLongPtr(hwnd, GWLP_USERDATA); + ShowWindow(hwnd, SW_HIDE); + DestroyWindow(hwnd); + if (display_class_global != NULL) + (*env)->DeleteGlobalRef(env, display_class_global); +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_clientToScreen(JNIEnv *env, jclass unused, jlong hwnd_int, jobject buffer_handle) { + HWND hwnd = (HWND)(INT_PTR)hwnd_int; + POINT point; + jint *buffer = (jint *)(*env)->GetDirectBufferAddress(env, buffer_handle); + jlong size = (*env)->GetDirectBufferCapacity(env, buffer_handle); + if (size < 2) { + throwFormattedRuntimeException(env, "Buffer size < 2", size); + return; + } + point.x = buffer[0]; + point.y = buffer[1]; + ClientToScreen(hwnd, &point); + buffer[0] = point.x; + buffer[1] = point.y; +} + +JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WindowsDisplay_getForegroundWindow(JNIEnv *env, jclass unused) { + return (INT_PTR)GetForegroundWindow(); +} + +JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WindowsDisplay_getDesktopWindow(JNIEnv *env, jclass unused) { + return (INT_PTR)GetDesktopWindow(); +} + +static void copyBufferToRect(JNIEnv *env, jobject buffer_handle, RECT *rect) { + jint *buffer = (jint *)(*env)->GetDirectBufferAddress(env, buffer_handle); + jlong size = (*env)->GetDirectBufferCapacity(env, buffer_handle); + if (size < 4) { + throwFormattedRuntimeException(env, "Buffer size < 4", size); + return; + } + rect->top = buffer[0]; + rect->bottom = buffer[1]; + rect->left = buffer[2]; + rect->right = buffer[3]; +} + +static void copyRectToBuffer(JNIEnv *env, RECT *rect, jobject buffer_handle) { + jint *buffer = (jint *)(*env)->GetDirectBufferAddress(env, buffer_handle); + jlong size = (*env)->GetDirectBufferCapacity(env, buffer_handle); + if (size < 4) { + throwFormattedRuntimeException(env, "Buffer size < 4", size); + return; + } + buffer[0] = rect->top; + buffer[1] = rect->bottom; + buffer[2] = rect->left; + buffer[3] = rect->right; +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_clipCursor(JNIEnv *env, jclass unused, jobject handle_buffer) { + RECT clip_rect; + LPRECT clip_rect_ptr; + if (handle_buffer != NULL) { + copyBufferToRect(env, handle_buffer, &clip_rect); + clip_rect_ptr = &clip_rect; + } else + clip_rect_ptr = NULL; + if (ClipCursor(clip_rect_ptr) == 0) + throwFormattedException(env, "ClipCursor failed (%d)", GetLastError()); +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nSwitchDisplayMode(JNIEnv *env, jobject self, jobject mode) { + switchDisplayMode(env, mode); +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nResetDisplayMode(JNIEnv *env, jobject self) { + resetDisplayMode(env); +} + +JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_WindowsDisplay_getCurrentDisplayMode(JNIEnv *env, jclass unused) { + return getCurrentDisplayMode(env); +} + +JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_WindowsDisplay_convertToNativeRamp(JNIEnv *env, jclass unused, jobject float_ramp) { + return convertToNativeRamp(env, float_ramp); +} + +JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_WindowsDisplay_getCurrentGammaRamp(JNIEnv *env, jclass unused) { + return getCurrentGammaRamp(env); +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nSetGammaRamp(JNIEnv *env, jclass unused, jobject gamma_buffer) { + setGammaRamp(env, gamma_buffer); +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_showWindow(JNIEnv *env, jclass unused, jlong hwnd_ptr, jint mode) { + HWND hwnd = (HWND)(INT_PTR)hwnd_ptr; + ShowWindow(hwnd, mode); +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_setForegroundWindow(JNIEnv *env, jclass unused, jlong hwnd_ptr) { + HWND hwnd = (HWND)(INT_PTR)hwnd_ptr; + SetForegroundWindow(hwnd); +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_setFocus(JNIEnv *env, jclass unused, jlong hwnd_ptr) { + HWND hwnd = (HWND)(INT_PTR)hwnd_ptr; + SetFocus(hwnd); +} + +JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nGetVersion(JNIEnv *env, jobject self, jstring driver) { + char *driver_str; + jstring result; + driver_str = GetStringNativeChars(env, driver); + if (driver_str == NULL) + return NULL; + result = getVersion(env, driver_str); + free(driver_str); + return result; +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nReshape(JNIEnv *env, jclass unused, jlong hwnd_ptr, jint x, jint y, jint width, jint height, jboolean undecorated, jboolean child) { + HWND hwnd = (HWND)(INT_PTR)hwnd_ptr; + DWORD exstyle, windowflags; + RECT clientSize; + + getWindowFlags(&windowflags, &exstyle, undecorated, child); + + // If we're not a fullscreen window, adjust the height to account for the + // height of the title bar: + clientSize.bottom = height; + clientSize.left = 0; + clientSize.right = width; + clientSize.top = 0; + + AdjustWindowRectEx( + &clientSize, // client-rectangle structure + windowflags, // window styles + FALSE, // menu-present option + exstyle // extended window style + ); + + SetWindowPos(hwnd, HWND_TOP, x, y, clientSize.right - clientSize.left, clientSize.bottom - clientSize.top, SWP_NOZORDER); +} + +static HICON createWindowIcon(JNIEnv *env, jint *pixels, jint width, jint height) { + unsigned char col; + unsigned char mask; + BITMAPV5HEADER bitmapInfo; + HBITMAP cursorMask; + HBITMAP colorBitmap; + ICONINFO iconInfo; + HICON icon; + char *ptrCursorImage; + int x, y; + char *dstPtr; + int imageSize; + unsigned char *maskPixels; + int widthInBytes; + int leftShift; + int maskPixelsOff; + int scanlineWidth; + HBITMAP colorDIB; + + memset(&bitmapInfo, 0, sizeof(BITMAPV5HEADER)); + bitmapInfo.bV5Size = sizeof(BITMAPV5HEADER); + bitmapInfo.bV5Width = width; + bitmapInfo.bV5Height = -height; + bitmapInfo.bV5Planes = 1; + bitmapInfo.bV5BitCount = 32; + bitmapInfo.bV5Compression = BI_BITFIELDS; + bitmapInfo.bV5RedMask = 0x00FF0000; + bitmapInfo.bV5GreenMask = 0x0000FF00; + bitmapInfo.bV5BlueMask = 0x000000FF; + bitmapInfo.bV5AlphaMask = 0xFF000000; + + colorDIB = CreateDIBSection(GetDC(NULL), (BITMAPINFO*)&(bitmapInfo), + DIB_RGB_COLORS, (void*)&(ptrCursorImage), NULL, 0); + if (!ptrCursorImage) { + throwException(env, "Could not allocate DIB section."); + } + + for (y = 0; y < height; y++ ) { + dstPtr = ptrCursorImage + width*4*y;; + for (x = 0; x < width; x++ ) { + dstPtr[0] = (pixels[y*width+x] >> 0x10) & 0xFF; + dstPtr[1] = (pixels[y*width+x] >> 0x08) & 0xFF; + dstPtr[2] = pixels[y*width+x] & 0xFF; + dstPtr[3] = (pixels[y*width+x] >> 0x18) & 0xFF; + dstPtr += 4; + } + } + + + colorBitmap = CreateDIBitmap(GetDC(NULL), + (BITMAPINFOHEADER*)&bitmapInfo, + CBM_INIT, + (void *)ptrCursorImage, + (BITMAPINFO*)&bitmapInfo, + DIB_RGB_COLORS); + + DeleteObject(colorDIB); + + // Convert alpha map to pixel packed mask + + // number of bytes it takes to fit a bit packed scan line. + widthInBytes = (width & 0x7) != 0 ? (width >> 3) + 1 : (width >> 3); + + // number of bytes it takes to fit WORD padded scan line. + scanlineWidth = widthInBytes; + if (scanlineWidth % sizeof(WORD) != 0) { + scanlineWidth = (scanlineWidth / sizeof(WORD)) * sizeof(WORD) + sizeof(WORD); + } + imageSize = scanlineWidth*height; + maskPixels = (unsigned char*)malloc(sizeof(unsigned char)*imageSize); + memset(maskPixels, 0xFF, sizeof(unsigned char)*imageSize); + + cursorMask = CreateBitmap(width, height, 1, 1, maskPixels); + + memset(&iconInfo, 0, sizeof(ICONINFO)); + iconInfo.hbmMask = cursorMask; + iconInfo.hbmColor = colorBitmap; + iconInfo.fIcon = TRUE; + iconInfo.xHotspot = 0; + iconInfo.yHotspot = 0; + icon = CreateIconIndirect(&iconInfo); + DeleteObject(colorBitmap); + DeleteObject(cursorMask); + free(maskPixels); + + return icon; +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_destroyIcon + (JNIEnv *env, jclass clazz, jlong handle) { + HICON icon = (HICON)(INT_PTR)handle; + DestroyIcon(icon); +} + +JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WindowsDisplay_createIcon + (JNIEnv *env, jclass clazz, jint width, jint height, jobject iconBuffer) { + jint *imgData = (jint *)(*env)->GetDirectBufferAddress(env, iconBuffer); + return (INT_PTR)createWindowIcon(env, imgData, width, height); +} + +JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WindowsDisplay_sendMessage + (JNIEnv *env, jclass clazz, jlong hwnd_ptr, jlong msg, jlong wparam, jlong lparam) { + HWND hwnd = (HWND)(INT_PTR)hwnd_ptr; + return SendMessage(hwnd, (UINT)msg, (WPARAM)wparam, (LPARAM)lparam); +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nSetCursorPosition +(JNIEnv * env, jclass unused, jint x, jint y) { + if (!SetCursorPos(x, y)) + printfDebugJava(env, "SetCursorPos failed"); +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_getClientRect + (JNIEnv *env, jclass unused, jlong hwnd_int, jobject rect_buffer) { + HWND hwnd = (HWND)(INT_PTR)hwnd_int; + RECT clientRect; + GetClientRect(hwnd, &clientRect); + copyRectToBuffer(env, &clientRect, rect_buffer); +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nSetNativeCursor + (JNIEnv *env, jclass unused, jlong hwnd_int, jobject handle_buffer) +{ + HWND hwnd = (HWND)(INT_PTR)hwnd_int; + HCURSOR *cursor_handle; + HCURSOR cursor; + if (handle_buffer != NULL) { + cursor_handle = (HCURSOR *)(*env)->GetDirectBufferAddress(env, handle_buffer); + cursor = *cursor_handle; + SetClassLongPtr(hwnd, GCLP_HCURSOR, (LONG_PTR)cursor); + SetCursor(cursor); + } else { + SetClassLongPtr(hwnd, GCLP_HCURSOR, (LONG_PTR)NULL); + SetCursor(LoadCursor(NULL, IDC_ARROW)); + } +} + +JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_WindowsDisplay_getSystemMetrics(JNIEnv *env, jclass unused, jint index) { + return GetSystemMetrics(index); +} + +JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nSetCapture(JNIEnv *env, jclass unused, jlong hwnd_int) { + HWND hwnd = (HWND)(INT_PTR)hwnd_int; + return (INT_PTR) SetCapture(hwnd); +} + +JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nReleaseCapture(JNIEnv *env, jclass unused) { + return ReleaseCapture(); +} + +JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nTrackMouseEvent(JNIEnv *env, jclass clazz, jlong hwnd_ptr) { + HWND hwnd = (HWND)(INT_PTR)hwnd_ptr; + TRACKMOUSEEVENT tme; + tme.cbSize = sizeof(TRACKMOUSEEVENT); + tme.dwFlags = TME_LEAVE; + tme.hwndTrack = hwnd; + return TrackMouseEvent(&tme); +} \ No newline at end of file diff --git a/src/native/windows/org_lwjgl_opengl_Pbuffer.c b/src/native/windows/org_lwjgl_opengl_Pbuffer.c new file mode 100644 index 0000000..76afce9 --- /dev/null +++ b/src/native/windows/org_lwjgl_opengl_Pbuffer.c @@ -0,0 +1,212 @@ +/* + * 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. + */ + +/** + * $Id: org_lwjgl_opengl_Pbuffer.c 3149 2008-11-22 14:54:15Z elias_naur $ + * + * Windows Pbuffer. + * + * @author elias_naur + * @version $Revision: 3149 $ + */ + +#include +#include "org_lwjgl_opengl_WindowsDisplay.h" +#include "org_lwjgl_opengl_Pbuffer.h" +#include "context.h" + +#include "extgl.h" +#include "extgl_wgl.h" + +#include "common_tools.h" + +static bool isPbufferSupported(WGLExtensions *extensions) { + return extensions->WGL_ARB_pixel_format && extensions->WGL_ARB_pbuffer; +} + +static bool getExtensions(JNIEnv *env, WGLExtensions *extensions, jobject pixel_format, jobject pixelFormatCaps) { + int origin_x = 0; int origin_y = 0; + HWND dummy_hwnd; + HDC dummy_hdc; + HGLRC dummy_context; + HDC saved_hdc; + HGLRC saved_context; + int pixel_format_id; + + dummy_hwnd = createDummyWindow(origin_x, origin_y); + if (dummy_hwnd == NULL) { + throwException(env, "Could not create dummy window"); + return false; + } + dummy_hdc = GetDC(dummy_hwnd); + pixel_format_id = findPixelFormatOnDC(env, dummy_hdc, origin_x, origin_y, pixel_format, pixelFormatCaps, false, true, false, false); + if (pixel_format_id == -1) { + closeWindow(&dummy_hwnd, &dummy_hdc); + return false; + } + if (!applyPixelFormat(env, dummy_hdc, pixel_format_id)) { + closeWindow(&dummy_hwnd, &dummy_hdc); + return false; + } + dummy_context = wglCreateContext(dummy_hdc); + if (dummy_context == NULL) { + closeWindow(&dummy_hwnd, &dummy_hdc); + throwException(env, "Could not create dummy context"); + return false; + } + saved_hdc = wglGetCurrentDC(); + saved_context = wglGetCurrentContext(); + if (!wglMakeCurrent(dummy_hdc, dummy_context)) { + wglMakeCurrent(saved_hdc, saved_context); + closeWindow(&dummy_hwnd, &dummy_hdc); + wglDeleteContext(dummy_context); + throwException(env, "Could not make dummy context current"); + return false; + } + extgl_InitWGL(extensions); + if (!wglMakeCurrent(saved_hdc, saved_context)) + printfDebugJava(env, "ERROR: Could not restore current context"); + closeWindow(&dummy_hwnd, &dummy_hdc); + wglDeleteContext(dummy_context); + return true; +} + +JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nGetPbufferCapabilities + (JNIEnv *env, jobject self, jobject pixel_format) +{ + int caps = 0; + WGLExtensions extensions; + if (!getExtensions(env, &extensions, pixel_format, NULL)) + return 0; + if (isPbufferSupported(&extensions)) + caps |= org_lwjgl_opengl_Pbuffer_PBUFFER_SUPPORTED; + + if (extensions.WGL_ARB_render_texture) + caps |= org_lwjgl_opengl_Pbuffer_RENDER_TEXTURE_SUPPORTED; + + if (extensions.WGL_NV_render_texture_rectangle) + caps |= org_lwjgl_opengl_Pbuffer_RENDER_TEXTURE_RECTANGLE_SUPPORTED; + + if (extensions.WGL_NV_render_depth_texture) + caps |= org_lwjgl_opengl_Pbuffer_RENDER_DEPTH_TEXTURE_SUPPORTED; + + return caps; +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsPbufferPeerInfo_nCreate + (JNIEnv *env, jobject self, jobject peer_info_handle, + jint width, jint height, jobject pixel_format, + jobject pixelFormatCaps, jobject pBufferAttribs) +{ + int origin_x = 0; int origin_y = 0; + HWND dummy_hwnd; + HDC dummy_hdc; + HPBUFFERARB Pbuffer; + HDC Pbuffer_dc; + WGLExtensions extensions; + const int *pBufferAttribs_ptr; + WindowsPeerInfo *peer_info = (WindowsPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle); + int pixel_format_id; + + if ( pBufferAttribs != NULL ) { + pBufferAttribs_ptr = (const int *)(*env)->GetDirectBufferAddress(env, pBufferAttribs); + } else { + pBufferAttribs_ptr = NULL; + } + if (!getExtensions(env, &extensions, pixel_format, pixelFormatCaps)) + return; + dummy_hwnd = createDummyWindow(origin_x, origin_y); + if (dummy_hwnd == NULL) { + throwException(env, "Could not create dummy window"); + return; + } + dummy_hdc = GetDC(dummy_hwnd); + pixel_format_id = findPixelFormatOnDC(env, dummy_hdc, origin_x, origin_y, pixel_format, pixelFormatCaps, false, false, true, false); + if (pixel_format_id == -1) { + closeWindow(&dummy_hwnd, &dummy_hdc); + return; + } + Pbuffer = extensions.wglCreatePbufferARB(dummy_hdc, pixel_format_id, width, height, pBufferAttribs_ptr); + closeWindow(&dummy_hwnd, &dummy_hdc); + if (Pbuffer == NULL) { + throwException(env, "Could not create Pbuffer"); + return; + } + Pbuffer_dc = extensions.wglGetPbufferDCARB(Pbuffer); + if (Pbuffer_dc == NULL) { + extensions.wglDestroyPbufferARB(Pbuffer); + throwException(env, "Could not get Pbuffer DC"); + return; + } + peer_info->u.pbuffer.extensions = extensions; + peer_info->u.pbuffer.pbuffer = Pbuffer; + peer_info->drawable_hdc = Pbuffer_dc; +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsPbufferPeerInfo_nDestroy + (JNIEnv *env, jclass clazz, jobject peer_info_handle) { + WindowsPeerInfo *peer_info = (WindowsPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle); + peer_info->u.pbuffer.extensions.wglReleasePbufferDCARB(peer_info->u.pbuffer.pbuffer, peer_info->drawable_hdc); + peer_info->u.pbuffer.extensions.wglDestroyPbufferARB(peer_info->u.pbuffer.pbuffer); +} + +JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_WindowsPbufferPeerInfo_nIsBufferLost + (JNIEnv *env, jclass clazz, jobject peer_info_handle) { + WindowsPeerInfo *peer_info = (WindowsPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle); + BOOL buffer_lost; + peer_info->u.pbuffer.extensions.wglQueryPbufferARB(peer_info->u.pbuffer.pbuffer, WGL_PBUFFER_LOST_ARB, &buffer_lost); + return buffer_lost ? JNI_TRUE : JNI_FALSE; +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsPbufferPeerInfo_nSetPbufferAttrib + (JNIEnv *env, jclass clazz, jobject peer_info_handle, jint attrib, jint value) { + WindowsPeerInfo *peer_info = (WindowsPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle); + int attribs[3]; + + attribs[0] = attrib; + attribs[1] = value; + attribs[2] = 0; + + peer_info->u.pbuffer.extensions.wglSetPbufferAttribARB(peer_info->u.pbuffer.pbuffer, attribs); +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsPbufferPeerInfo_nBindTexImageToPbuffer + (JNIEnv *env, jclass clazz, jobject peer_info_handle, jint buffer) { + WindowsPeerInfo *peer_info = (WindowsPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle); + peer_info->u.pbuffer.extensions.wglBindTexImageARB(peer_info->u.pbuffer.pbuffer, buffer); +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsPbufferPeerInfo_nReleaseTexImageFromPbuffer + (JNIEnv *env, jclass clazz, jobject peer_info_handle, jint buffer) { + WindowsPeerInfo *peer_info = (WindowsPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle); + peer_info->u.pbuffer.extensions.wglReleaseTexImageARB(peer_info->u.pbuffer.pbuffer, buffer); +} diff --git a/src/native/windows/org_lwjgl_opengl_WindowsAWTGLCanvasPeerInfo.c b/src/native/windows/org_lwjgl_opengl_WindowsAWTGLCanvasPeerInfo.c new file mode 100644 index 0000000..d3d340a --- /dev/null +++ b/src/native/windows/org_lwjgl_opengl_WindowsAWTGLCanvasPeerInfo.c @@ -0,0 +1,54 @@ +/* + * 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. + */ + +/** + * $Id: org_lwjgl_opengl_WindowsAWTGLCanvasPeerInfo.c 2985 2008-04-07 18:42:36Z matzon $ + * + * @author elias_naur + * @version $Revision: 2985 $ + */ + +#include +#include +#include "awt_tools.h" +#include "org_lwjgl_opengl_WindowsAWTGLCanvasPeerInfo.h" +#include "context.h" +#include "common_tools.h" + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsAWTGLCanvasPeerInfo_nInitHandle + (JNIEnv *env, jclass clazz, jobject lock_buffer_handle, jobject peer_info_handle) { + WindowsPeerInfo *peer_info = (WindowsPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle); + AWTSurfaceLock *surface = (AWTSurfaceLock *)(*env)->GetDirectBufferAddress(env, lock_buffer_handle); + JAWT_Win32DrawingSurfaceInfo *win32_dsi = (JAWT_Win32DrawingSurfaceInfo *)surface->dsi->platformInfo; + peer_info->drawable_hdc = win32_dsi->hdc; + peer_info->u.hwnd = win32_dsi->hwnd; +} diff --git a/src/native/windows/org_lwjgl_opengl_WindowsContextImplementation.c b/src/native/windows/org_lwjgl_opengl_WindowsContextImplementation.c new file mode 100644 index 0000000..e494eec --- /dev/null +++ b/src/native/windows/org_lwjgl_opengl_WindowsContextImplementation.c @@ -0,0 +1,162 @@ +/* + * 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. + */ + +/** + * $Id: org_lwjgl_opengl_WindowsContextImplementation.c 3116 2008-08-19 16:46:03Z spasi $ + * + * @author elias_naur + * @version $Revision: 3116 $ + */ + +#include +#include "org_lwjgl_opengl_WindowsContextImplementation.h" +#include "context.h" +#include "extgl_wgl.h" +#include "common_tools.h" + +typedef struct { + HGLRC context; +} WindowsContext; + +JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_WindowsContextImplementation_nCreate + (JNIEnv *env, jclass clazz, jobject peer_info_handle, jobject attribs, jobject shared_context_handle) { + WindowsPeerInfo *peer_info; + WindowsContext *shared_context_info; + WindowsContext *context_info; + HGLRC context; + HGLRC shared_context = NULL; + + // -- We need to create a temporary context to detect the presence of WGL_ARB_create_context + HDC saved_current_hdc; + HGLRC saved_current_hglrc; + WGLExtensions extensions; + const int *attribList = attribs == NULL ? NULL : ((const int *)(*env)->GetDirectBufferAddress(env, attribs)); + + jobject context_handle = newJavaManagedByteBuffer(env, sizeof(WindowsContext)); + if (context_handle == NULL) { + throwException(env, "Could not create handle buffer"); + return NULL; + } + + peer_info = (WindowsPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle); + if (shared_context_handle != NULL) { + shared_context_info = (WindowsContext *)(*env)->GetDirectBufferAddress(env, shared_context_handle); + shared_context = shared_context_info->context; + } + + // Create the context + context = wglCreateContext(peer_info->drawable_hdc); + if (context == NULL) { + throwException(env, "Could not create context"); + return NULL; + } + + // Save the current HDC and HGLRC to avoid disruption + saved_current_hdc = wglGetCurrentDC(); + saved_current_hglrc = wglGetCurrentContext(); + + // Make context current and detect extensions + if (!wglMakeCurrent(peer_info->drawable_hdc, context)) { + throwException(env, "Could not bind dummy context"); + return NULL; + } + extgl_InitWGL(&extensions); + + // Restore previous context + wglMakeCurrent(saved_current_hdc, saved_current_hglrc); + + // + if ( extensions.WGL_ARB_create_context ) { // We support WGL_ARB_create_context, use the new context creation routine + // If we have no context to share and no special attributes, we don't have to recreate the context - wglCreateContext is equivalent to wglCreateContextAttribs(hdc,0,NULL). + if ( shared_context != NULL || attribList != NULL ) { + // Delete the oldschool context + wglDeleteContext(context); + // Create a new context using WGL_ARB_create_context + context = (HGLRC)extensions.wglCreateContextAttribsARB(peer_info->drawable_hdc, shared_context, attribList); + if (context == NULL) { + throwException(env, "Could not create context (WGL_ARB_create_context)"); + return NULL; + } + } + } else { // We don't support WGL_ARB_create_context, use the old context creation routine + if (shared_context != NULL && !wglShareLists(shared_context, context)) { // Use wglShareLists to share context data + wglDeleteContext(context); + throwException(env, "Could not share contexts"); + return NULL; + } + } + + context_info = (WindowsContext *)(*env)->GetDirectBufferAddress(env, context_handle); + context_info->context = context; + return context_handle; +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsContextImplementation_nSwapBuffers + (JNIEnv *env, jclass clazz, jobject peer_info_handle) { + WindowsPeerInfo *peer_info = (WindowsPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle); + SwapBuffers(peer_info->drawable_hdc); +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsContextImplementation_nReleaseCurrentContext + (JNIEnv *env, jclass clazz) { + wglMakeCurrent(NULL, NULL); +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsContextImplementation_nMakeCurrent + (JNIEnv *env, jclass clazz, jobject peer_info_handle, jobject context_handle) { + WindowsContext *context_info = (WindowsContext *)(*env)->GetDirectBufferAddress(env, context_handle); + WindowsPeerInfo *peer_info = (WindowsPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle); + if (!wglMakeCurrent(peer_info->drawable_hdc, context_info->context)) + throwException(env, "Could not make context current"); +} + +JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_WindowsContextImplementation_nIsCurrent + (JNIEnv *env, jclass clazz, jobject context_handle) { + WindowsContext *context_info = (WindowsContext *)(*env)->GetDirectBufferAddress(env, context_handle); + return wglGetCurrentContext() == context_info->context; +} + +JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_WindowsContextImplementation_nSetSwapInterval + (JNIEnv *env, jclass clazz, jint value) { + WGLExtensions extensions; + extgl_InitWGL(&extensions); + if (extensions.WGL_EXT_swap_control) { + return extensions.wglSwapIntervalEXT(value) ? JNI_TRUE : JNI_FALSE; + } else + return JNI_FALSE; +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsContextImplementation_nDestroy + (JNIEnv *env, jclass clazz, jobject context_handle) { + WindowsContext *context_info = (WindowsContext *)(*env)->GetDirectBufferAddress(env, context_handle); + wglDeleteContext(context_info->context); +} diff --git a/src/native/windows/org_lwjgl_opengl_WindowsDisplayPeerInfo.c b/src/native/windows/org_lwjgl_opengl_WindowsDisplayPeerInfo.c new file mode 100644 index 0000000..66e8548 --- /dev/null +++ b/src/native/windows/org_lwjgl_opengl_WindowsDisplayPeerInfo.c @@ -0,0 +1,53 @@ +/* + * 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. + */ + +/** + * $Id: org_lwjgl_opengl_WindowsDisplayPeerInfo.c 3057 2008-04-30 16:01:25Z elias_naur $ + * + * @author elias_naur + * @version $Revision: 3057 $ + */ + +#include +#include "Window.h" +#include "org_lwjgl_opengl_WindowsDisplayPeerInfo.h" +#include "context.h" +#include "common_tools.h" + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplayPeerInfo_nInitDC + (JNIEnv *env, jclass clazz, jobject peer_info_handle, jlong hwnd_ptr, jlong hdc_ptr) { + HWND hwnd = (HWND)(INT_PTR)hwnd_ptr; + HDC hdc = (HDC)(INT_PTR)hdc_ptr; + WindowsPeerInfo *peer_info = (WindowsPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle); + peer_info->drawable_hdc = hdc; + peer_info->u.hwnd = hwnd; +} diff --git a/src/native/windows/org_lwjgl_opengl_WindowsKeyboard.c b/src/native/windows/org_lwjgl_opengl_WindowsKeyboard.c new file mode 100644 index 0000000..b3176fa --- /dev/null +++ b/src/native/windows/org_lwjgl_opengl_WindowsKeyboard.c @@ -0,0 +1,75 @@ +/* + * 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. + */ + +/** + * $Id: org_lwjgl_input_Keyboard.c 2385 2006-06-23 16:45:21Z elias_naur $ + * + * @author elias_naue + * @version $Revision: 2385 $ + */ + +#include "Window.h" +#include +#include "org_lwjgl_opengl_WindowsKeyboard.h" + +JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_WindowsKeyboard_GetKeyState(JNIEnv *env, jclass unused, jint virt_key) { + return GetKeyState(virt_key); +} + +JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_WindowsKeyboard_MapVirtualKey(JNIEnv *env, jclass unused, jint uCode, jint uMapType) { + return MapVirtualKey(uCode, uMapType); +} + +JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_WindowsKeyboard_isWindowsNT(JNIEnv *env, jclass unused) { + OSVERSIONINFO osvi; + + osvi.dwOSVersionInfoSize = sizeof(osvi); + GetVersionEx(&osvi); + return osvi.dwPlatformId == VER_PLATFORM_WIN32_NT ? JNI_TRUE : JNI_FALSE; +} + +JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_WindowsKeyboard_ToUnicode(JNIEnv *env, jclass unused, jint wVirtKey, jint wScanCode, jobject lpKeyState_obj, jobject pwszBuff_obj, jint cchBuff, jint flags) { + const PBYTE lpKeyState = (*env)->GetDirectBufferAddress(env, lpKeyState_obj); + LPWSTR pwszBuff = (*env)->GetDirectBufferAddress(env, pwszBuff_obj); + return ToUnicode(wVirtKey, wScanCode, lpKeyState, pwszBuff, cchBuff, flags); +} + +JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_WindowsKeyboard_ToAscii(JNIEnv *env, jclass unused, jint wVirtKey, jint wScanCode, jobject lpKeyState_obj, jobject lpChar_obj, jint flags) { + const PBYTE lpKeyState = (*env)->GetDirectBufferAddress(env, lpKeyState_obj); + LPWORD lpChar = (*env)->GetDirectBufferAddress(env, lpChar_obj); + return ToAscii(wVirtKey, wScanCode, lpKeyState, lpChar, flags); +} + +JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_WindowsKeyboard_GetKeyboardState(JNIEnv *env, jclass unused, jobject lpKeyState_obj) { + PBYTE lpKeyState = (*env)->GetDirectBufferAddress(env, lpKeyState_obj); + return GetKeyboardState(lpKeyState); +} diff --git a/src/native/windows/org_lwjgl_opengl_WindowsPeerInfo.c b/src/native/windows/org_lwjgl_opengl_WindowsPeerInfo.c new file mode 100644 index 0000000..5806e9d --- /dev/null +++ b/src/native/windows/org_lwjgl_opengl_WindowsPeerInfo.c @@ -0,0 +1,70 @@ +/* + * 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. + */ + +/** + * $Id: org_lwjgl_opengl_WindowsPeerInfo.c 3148 2008-11-22 14:51:36Z elias_naur $ + * + * @author elias_naur + * @version $Revision: 3148 $ + */ + +#include +#include "org_lwjgl_opengl_WindowsPeerInfo.h" +#include "context.h" +#include "common_tools.h" + +JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_WindowsPeerInfo_createHandle + (JNIEnv *env, jclass clazz) { + return newJavaManagedByteBuffer(env, sizeof(WindowsPeerInfo)); +} + +JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_WindowsPeerInfo_nChoosePixelFormat + (JNIEnv *env, jclass clazz, jlong hdc_ptr, jint origin_x, jint origin_y, jobject pixel_format, jobject pixel_format_caps, jboolean use_hdc_bpp, jboolean window, jboolean pbuffer, jboolean double_buffer) { + HDC hdc = (HDC)(INT_PTR)hdc_ptr; + return findPixelFormatOnDC(env, hdc, origin_x, origin_y, pixel_format, pixel_format_caps, use_hdc_bpp, window, pbuffer, double_buffer); +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsPeerInfo_setPixelFormat + (JNIEnv *env, jclass clazz, jlong hdc_ptr, jint pixel_format) { + HDC hdc = (HDC)(INT_PTR)hdc_ptr; + applyPixelFormat(env, hdc, pixel_format); +} + +JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WindowsPeerInfo_nGetHdc(JNIEnv *env, jclass unused, jobject peer_info_handle) { + WindowsPeerInfo *peer_info = (WindowsPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle); + return (intptr_t)peer_info->drawable_hdc; +} + +JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WindowsPeerInfo_nGetHwnd(JNIEnv *env, jclass unused, jobject peer_info_handle) { + WindowsPeerInfo *peer_info = (WindowsPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle); + return (intptr_t)peer_info->u.hwnd; +} diff --git a/src/native/windows/org_lwjgl_opengl_WindowsRegistry.c b/src/native/windows/org_lwjgl_opengl_WindowsRegistry.c new file mode 100644 index 0000000..9059048 --- /dev/null +++ b/src/native/windows/org_lwjgl_opengl_WindowsRegistry.c @@ -0,0 +1,145 @@ +/* + * 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. + */ + +/** + * $Id: org_lwjgl_opengl_WindowsRegistry.c 2985 2008-04-07 18:42:36Z matzon $ + * + * @author elias_naur + * @version $Revision: 2985 $ + */ + +#include +#include +#include "org_lwjgl_opengl_WindowsRegistry.h" +#include "common_tools.h" + +/* + * Return a string containing the queried value, or NULL of the method fails. + * In that case, a java exception is thrown. + */ +static jstring queryRegistrationKey(JNIEnv *env, HKEY root_key, LPCTSTR subkey, LPCTSTR value) { + DWORD buf_size = 1; + char *result; + HKEY hKey; + LONG lRet; + jstring java_result; + + + if(RegOpenKeyEx(root_key, + TEXT(subkey), + 0, + KEY_QUERY_VALUE, + &hKey) != ERROR_SUCCESS) { + throwException(env, "Failed to open registry key"); + return NULL; + } + + result = (char *)malloc(buf_size); + if (result == NULL) { + RegCloseKey(hKey); + throwException(env, "Failed to allocate buffer"); + return NULL; + } + + while (1) { + lRet = RegQueryValueEx(hKey, + TEXT(value), + NULL, + NULL, + (LPBYTE)result, + &buf_size); + if (lRet != ERROR_SUCCESS && lRet != ERROR_MORE_DATA) { + RegCloseKey(hKey); + free(result); + throwException(env, "Failed query key value"); + return NULL; + } + if (lRet == ERROR_SUCCESS) { + RegCloseKey(hKey); + // make sure the result has a terminating null + buf_size += 1; + result = (char *)realloc(result, buf_size); + if (result == NULL) { + throwException(env, "Failed to resize buffer"); + return NULL; + } + result[buf_size - 1] = '\0'; + java_result = NewStringNativeWithLength(env, result, strlen(result)); + free(result); + return java_result; + } + result = (char *)realloc(result, buf_size); + if (result == NULL) { + RegCloseKey(hKey); + throwException(env, "Failed to resize buffer"); + return NULL; + } + } +} + +static HKEY enumToRootKey(jint root_key_enum) { + switch (root_key_enum) { + case org_lwjgl_opengl_WindowsRegistry_HKEY_CLASSES_ROOT: + return HKEY_CLASSES_ROOT; + case org_lwjgl_opengl_WindowsRegistry_HKEY_CURRENT_USER: + return HKEY_CURRENT_USER; + case org_lwjgl_opengl_WindowsRegistry_HKEY_LOCAL_MACHINE: + return HKEY_LOCAL_MACHINE; + case org_lwjgl_opengl_WindowsRegistry_HKEY_USERS: + return HKEY_USERS; + default: + return 0; + } +} + +JNIEXPORT jstring JNICALL Java_org_lwjgl_opengl_WindowsRegistry_nQueryRegistrationKey (JNIEnv *env, jclass unused, jint root_key, jstring subkey, jstring value) { + HKEY root = enumToRootKey(root_key); + char *subkey_native; + char *value_native; + jstring result; + + subkey_native = GetStringNativeChars(env, subkey); + if (subkey_native == NULL) { + throwException(env, "Failed to fetch the native string"); + return NULL; + } + value_native = GetStringNativeChars(env, value); + if (value_native == NULL) { + free(subkey_native); + throwException(env, "Failed to fetch the native string"); + return NULL; + } + result = queryRegistrationKey(env, root, subkey_native, value_native); + free(subkey_native); + free(value_native); + return result; +} diff --git a/src/native/windows/windows_al.c b/src/native/windows/windows_al.c new file mode 100644 index 0000000..ea5eab7 --- /dev/null +++ b/src/native/windows/windows_al.c @@ -0,0 +1,71 @@ +/* + * 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. + */ + +#include +#include +#include +#include "extal.h" +#include "common_tools.h" + +/** + * $Id: windows_al.c 2985 2008-04-07 18:42:36Z matzon $ + * + * This file contains the AL extension assigning mechanism + * + * @author Brian Matzon + * @version $Revision: 2985 $ + */ +/* Handle to OpenAL Library */ +static HMODULE handleOAL; + +void *NativeGetFunctionPointer(const char *function) { + return GetProcAddress(handleOAL, function); +} + +void tryLoadLibrary(JNIEnv *env, jstring path) { + char *path_str = GetStringNativeChars(env, path); + printfDebugJava(env, "Testing '%s'", path_str); + handleOAL = LoadLibrary(path_str); + if (handleOAL != NULL) { + printfDebugJava(env, "Found OpenAL at '%s'", path_str); + } else { + throwFormattedException(env, "Could not load OpenAL library (%d)", GetLastError()); + } + free(path_str); +} + +/** + * Unloads the OpenAL Library + */ +void UnLoadOpenAL() { + FreeLibrary(handleOAL); +} diff --git a/src/templates/org/lwjgl/openal/AL10.java b/src/templates/org/lwjgl/openal/AL10.java new file mode 100644 index 0000000..4bf327b --- /dev/null +++ b/src/templates/org/lwjgl/openal/AL10.java @@ -0,0 +1,1262 @@ +/* + * 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.openal; + +import java.nio.Buffer; +import java.nio.IntBuffer; +import java.nio.FloatBuffer; +import java.nio.DoubleBuffer; + +import org.lwjgl.util.generator.*; + +/** + *
    + * This is the core OpenAL class. This class implements + * AL.h version 1.0 + * + * @author Brian Matzon + * @version $Revision: 3288 $ + * $Id: AL10.java 3288 2010-03-16 17:58:48Z spasi $ + */ +public interface AL10 { + /** Bad value */ + int AL_INVALID = -1; + + /** Disable value */ + int AL_NONE = 0; + + /** Boolean False */ + int AL_FALSE = 0; + + /** Boolean True */ + int AL_TRUE = 1; + + /** + * Indicate the type of SOURCE. + * Sources can be spatialized + */ + int AL_SOURCE_TYPE = 0x1027; + + /** Indicate source has absolute coordinates */ + int AL_SOURCE_ABSOLUTE = 0x201; + + /** Indicate Source has listener relative coordinates */ + int AL_SOURCE_RELATIVE = 0x202; + + /** + * Directional source, inner cone angle, in degrees + * Range: [0-360] + * Default: 360 + */ + int AL_CONE_INNER_ANGLE = 0x1001; + + /** + * Directional source, outer cone angle, in degrees. + * Range: [0-360] + * Default: 360 + */ + int AL_CONE_OUTER_ANGLE = 0x1002; + + /** + * Specify the pitch to be applied, either at source, + * or on mixer results, at listener. + * Range: [0.5-2.0] + * Default: 1.0 + */ + int AL_PITCH = 0x1003; + + /** + * Specify the current location in three dimensional space. + * OpenAL, like OpenGL, uses a right handed coordinate system, + * where in a frontal default view X (thumb) points right, + * Y points up (index finger), and Z points towards the + * viewer/camera (middle finger). + * To switch from a left handed coordinate system, flip the + * sign on the Z coordinate. + * Listener position is always in the world coordinate system. + */ + int AL_POSITION = 0x1004; + + /** Specify the current direction as forward vector. */ + int AL_DIRECTION = 0x1005; + + /** Specify the current velocity in three dimensional space. */ + int AL_VELOCITY = 0x1006; + + /** + * Indicate whether source has to loop infinite. + * Type: ALboolean + * Range: [TRUE, FALSE] + * Default: FALSE + */ + int AL_LOOPING = 0x1007; + + /** + * Indicate the buffer to provide sound samples. + * Type: ALuint. + * Range: any valid Buffer id. + */ + int AL_BUFFER = 0x1009; + + /** + * Indicate the gain (volume amplification) applied. + * Type: ALfloat. + * Range: ]0.0- ] + * A value of 1.0 means un-attenuated/unchanged. + * Each division by 2 equals an attenuation of -6dB. + * Each multiplicaton with 2 equals an amplification of +6dB. + * A value of 0.0 is meaningless with respect to a logarithmic + * scale; it is interpreted as zero volume - the channel + * is effectively disabled. + */ + int AL_GAIN = 0x100A; + + /** + * Indicate minimum source attenuation. + * Type: ALfloat + * Range: [0.0 - 1.0] + */ + int AL_MIN_GAIN = 0x100D; + + /** + * Indicate maximum source attenuation. + * Type: ALfloat + * Range: [0.0 - 1.0] + */ + int AL_MAX_GAIN = 0x100E; + + /** + * Specify the current orientation. + * Type: ALfv6 (at/up) + * Range: N/A + */ + int AL_ORIENTATION = 0x100F; + + /* byte offset into source (in canon format). -1 if source + * is not playing. Don't set this, get this. + * + * Type: ALfloat + * Range: [0.0 - ] + * Default: 1.0 + */ + int AL_REFERENCE_DISTANCE = 0x1020; + + /** + * Indicate the rolloff factor for the source. + * Type: ALfloat + * Range: [0.0 - ] + * Default: 1.0 + */ + int AL_ROLLOFF_FACTOR = 0x1021; + + /** + * Indicate the gain (volume amplification) applied. + * Type: ALfloat. + * Range: ]0.0- ] + * A value of 1.0 means un-attenuated/unchanged. + * Each division by 2 equals an attenuation of -6dB. + * Each multiplicaton with 2 equals an amplification of +6dB. + * A value of 0.0 is meaningless with respect to a logarithmic + * scale; it is interpreted as zero volume - the channel + * is effectively disabled. + */ + int AL_CONE_OUTER_GAIN = 0x1022; + + /** + * Specify the maximum distance. + * Type: ALfloat + * Range: [0.0 - ] + */ + int AL_MAX_DISTANCE = 0x1023; + + /** + * Specify the channel mask. (Creative) + * Type: ALuint + * Range: [0 - 255] + */ + int AL_CHANNEL_MASK = 0x3000; + + /** Source state information */ + int AL_SOURCE_STATE = 0x1010; + + /** Source state information */ + int AL_INITIAL = 0x1011; + + /** Source state information */ + int AL_PLAYING = 0x1012; + + /** Source state information */ + int AL_PAUSED = 0x1013; + + /** Source state information */ + int AL_STOPPED = 0x1014; + + /** Buffer Queue params */ + int AL_BUFFERS_QUEUED = 0x1015; + + /** Buffer Queue params */ + int AL_BUFFERS_PROCESSED = 0x1016; + + /** Sound buffers: format specifier. */ + int AL_FORMAT_MONO8 = 0x1100; + + /** Sound buffers: format specifier. */ + int AL_FORMAT_MONO16 = 0x1101; + + /** Sound buffers: format specifier. */ + int AL_FORMAT_STEREO8 = 0x1102; + + /** Sound buffers: format specifier. */ + int AL_FORMAT_STEREO16 = 0x1103; + + /** Ogg Vorbis format specifier. */ + int AL_FORMAT_VORBIS_EXT = 0x10003; + + /** + * Sound buffers: frequency, in units of Hertz [Hz]. + * This is the number of samples per second. Half of the + * sample frequency marks the maximum significant + * frequency component. + */ + int AL_FREQUENCY = 0x2001; + + /** + * Sound buffers: frequency, in units of Hertz [Hz]. + * This is the number of samples per second. Half of the + * sample frequency marks the maximum significant + * frequency component. + */ + int AL_BITS = 0x2002; + + /** + * Sound buffers: frequency, in units of Hertz [Hz]. + * This is the number of samples per second. Half of the + * sample frequency marks the maximum significant + * frequency component. + */ + int AL_CHANNELS = 0x2003; + + /** + * Sound buffers: frequency, in units of Hertz [Hz]. + * This is the number of samples per second. Half of the + * sample frequency marks the maximum significant + * frequency component. + */ + int AL_SIZE = 0x2004; + + /** + * Sound buffers: frequency, in units of Hertz [Hz]. + * This is the number of samples per second. Half of the + * sample frequency marks the maximum significant + * frequency component. + */ + int AL_DATA = 0x2005; + + /** + * Buffer state. + * + * Not supported for public use (yet). + */ + int AL_UNUSED = 0x2010; + + /** + * Buffer state. + * + * Not supported for public use (yet). + */ + int AL_PENDING = 0x2011; + + /** + * Buffer state. + * + * Not supported for public use (yet). + */ + int AL_PROCESSED = 0x2012; + + /** Errors: No Error. */ + int AL_NO_ERROR = AL_FALSE; + + /** Illegal name passed as an argument to an AL call. */ + int AL_INVALID_NAME = 0xA001; + + /** Illegal enum passed as an argument to an AL call. */ + int AL_INVALID_ENUM = 0xA002; + + /** + * Illegal value passed as an argument to an AL call. + * Applies to parameter values, but not to enumerations. + */ + int AL_INVALID_VALUE = 0xA003; + + /** + * A function was called at inappropriate time, + * or in an inappropriate way, causing an illegal state. + * This can be an incompatible ALenum, object ID, + * and/or function. + */ + int AL_INVALID_OPERATION = 0xA004; + + /** + * A function could not be completed, + * because there is not enough memory available. + */ + int AL_OUT_OF_MEMORY = 0xA005; + + /** Context strings: Vendor */ + int AL_VENDOR = 0xB001; + + /** Context strings: Version */ + int AL_VERSION = 0xB002; + + /** Context strings: Renderer */ + int AL_RENDERER = 0xB003; + + /** Context strings: Extensions */ + int AL_EXTENSIONS = 0xB004; + + /** Doppler scale. Default 1.0 */ + int AL_DOPPLER_FACTOR = 0xC000; + + /** Doppler velocity. Default 1.0 */ + int AL_DOPPLER_VELOCITY = 0xC001; + + /** Distance model. Default INVERSE_DISTANCE_CLAMPED */ + int AL_DISTANCE_MODEL = 0xD000; + + /** Distance model */ + int AL_INVERSE_DISTANCE = 0xD001; + + /** Distance model */ + int AL_INVERSE_DISTANCE_CLAMPED = 0xD002; + + /** + * The application can temporarily disable certain AL capabilities on a per Context + * basis. This allows the driver implementation to optimize for certain subsets of + * operations. Enabling and disabling capabilities is handled using a function pair. + * + * @param capability name of a capability to enable + */ + @ALvoid + void alEnable(int capability); + + /** + * The application can temporarily disable certain AL capabilities on a per Context + * basis. This allows the driver implementation to optimize for certain subsets of + * operations. Enabling and disabling capabilities is handled using a function pair. + * + * @param capability name of a capability to disable + */ + @ALvoid + void alDisable(@ALenum int capability); + + /** + * The application can also query whether a given capability is currently enabled or + * not. + *

    + * If the token used to specify target is not legal, an AL_INVALID_ENUM error will be + * generated. + *

    + *

    + * At this time, this mechanism is not used. There are no valid targets. + *

    + * + * @param capability name of a capability to check + * @return true if named feature is enabled + */ + boolean alIsEnabled(@ALenum int capability); + + /** + * Hinting for implementation + * NOTE: This method is a NOP, but is provided for completeness. + * + * @param target The target to hint + * @param mode Mode to hint + */ +// @ALvoid +// void alHint(@ALenum int target, @ALenum int mode); + + /** + * Like OpenGL, AL uses a simplified interface for querying global state. + * + * Legal values are e.g. AL_DOPPLER_FACTOR, AL_DOPPLER_VELOCITY, + * AL_DISTANCE_MODEL. + *

    + * null destinations are quietly ignored. AL_INVALID_ENUM is the response to errors + * in specifying pName. The amount of memory required in the destination + * depends on the actual state requested. + *

    + * + * @return boolean state described by pname will be returned. + */ + boolean alGetBoolean(@ALenum int pname); + + /** + * Like OpenGL, AL uses a simplified interface for querying global state. + * + * Legal values are e.g. AL_DOPPLER_FACTOR, AL_DOPPLER_VELOCITY, + * AL_DISTANCE_MODEL. + *

    + * null destinations are quietly ignored. AL_INVALID_ENUM is the response to errors + * in specifying pName. The amount of memory required in the destination + * depends on the actual state requested. + *

    + * + * @return int state described by pname will be returned. + */ + int alGetInteger(@ALenum int pname); + + /** + * Like OpenGL, AL uses a simplified interface for querying global state. + * + * Legal values are e.g. AL_DOPPLER_FACTOR, AL_DOPPLER_VELOCITY, + * AL_DISTANCE_MODEL. + *

    + * null destinations are quietly ignored. AL_INVALID_ENUM is the response to errors + * in specifying pName. The amount of memory required in the destination + * depends on the actual state requested. + *

    + * + * @return float state described by pname will be returned. + */ + float alGetFloat(@ALenum int pname); + + /** + * Like OpenGL, AL uses a simplified interface for querying global state. + * + * Legal values are e.g. AL_DOPPLER_FACTOR, AL_DOPPLER_VELOCITY, + * AL_DISTANCE_MODEL. + *

    + * null destinations are quietly ignored. AL_INVALID_ENUM is the response to errors + * in specifying pName. The amount of memory required in the destination + * depends on the actual state requested. + *

    + * + * @return double state described by pname will be returned. + */ + double alGetDouble(@ALenum int pname); + + /** + * Like OpenGL, AL uses a simplified interface for querying global state. + * + * Legal values are e.g. AL_DOPPLER_FACTOR, AL_DOPPLER_VELOCITY, + * AL_DISTANCE_MODEL. + *

    + * null destinations are quietly ignored. AL_INVALID_ENUM is the response to errors + * in specifying pName. The amount of memory required in the destination + * depends on the actual state requested. + *

    + * + * @param pname state to be queried + * @param data Buffer to place the integers in + */ + @StripPostfix("data") + @ALvoid + void alGetIntegerv(@ALenum int pname, @OutParameter @Check("1") IntBuffer data); + + /** + * Like OpenGL, AL uses a simplified interface for querying global state. + * + * Legal values are e.g. AL_DOPPLER_FACTOR, AL_DOPPLER_VELOCITY, + * AL_DISTANCE_MODEL. + *

    + * null destinations are quietly ignored. AL_INVALID_ENUM is the response to errors + * in specifying pName. The amount of memory required in the destination + * depends on the actual state requested. + *

    + * + * @param pname state to be queried + * @param data Buffer to place the floats in + */ + @StripPostfix("data") + @ALvoid + void alGetFloatv(@ALenum int pname, @OutParameter @Check("1") FloatBuffer data); + + /** + * Like OpenGL, AL uses a simplified interface for querying global state. + * + * Legal values are e.g. AL_DOPPLER_FACTOR, AL_DOPPLER_VELOCITY, + * AL_DISTANCE_MODEL. + *

    + * null destinations are quietly ignored. AL_INVALID_ENUM is the response to errors + * in specifying pName. The amount of memory required in the destination + * depends on the actual state requested. + *

    + * + * @param pname state to be queried + * @param data Buffer to place the doubles in + */ + @StripPostfix("data") + @ALvoid + void alGetDoublev(@ALenum int pname, @OutParameter @Check("1") DoubleBuffer data); + + /** + * The application can retrieve state information global to the current AL Context. + * GetString will return a pointer to a constant string. Valid values for param are + * VERSION, RENDERER, VENDOR, and EXTENSIONS, as well as the error codes + * defined by AL. The application can use GetString to retrieve a string for an error + * code. + * + * @param pname The property to be returned + * @return OpenAL String property + */ + @NoErrorCheck + String alGetString(@ALenum int pname); + + /** + * The AL detects only a subset of those conditions that could be considered errors. + * This is because in many cases error checking would adversely impact the + * performance of an error-free program. + *

    + * Each detectable error is assigned a numeric + * code. When an error is detected by AL, a flag is set and the error code is recorded. + * Further errors, if they occur, do not affect this recorded code. When GetError is + * called, the code is returned and the flag is cleared, so that a further error will again + * record its code. If a call to GetError returns AL_NO_ERROR then there has been no + * detectable error since the last call to GetError (or since the AL was initialized). + *

    + *

    + * Error codes can be mapped to strings. The GetString function returns a pointer to a + * constant (literal) string that is identical to the identifier used for the enumeration + * value, as defined in the specification. + *

    + *

    + * AL_NO_ERROR - "No Error" token.
    + * AL_INVALID_NAME - Invalid Name parameter.
    + * AL_INVALID_ENUM - Invalid parameter.
    + * AL_INVALID_VALUE - Invalid enum parameter value.
    + * AL_INVALID_OPERATION - Illegal call.
    + * AL_OUT_OF_MEMORY - Unable to allocate memory.
    + *

    + *

    + * The table summarizes the AL errors. Currently, when an error flag is set, results of + * AL operations are undefined only if AL_OUT_OF_MEMORY has occured. In other + * cases, the command generating the error is ignored so that it has no effect on AL + * state or output buffer contents. If the error generating command returns a value, it + * returns zero. If the generating command modifies values through a pointer + * argument, no change is made to these values. These error semantics apply only to + * AL errors, not to system errors such as memory access errors. + *

    + *

    + * Several error generation conditions are implicit in the description of the various AL + * commands. First, if a command that requires an enumerated value is passed a value + * that is not one of those specified as allowable for that command, the error + * AL_INVALID_ENUM results. This is the case even if the argument is a pointer to a + * symbolic constant if that value is not allowable for the given command. This will + * occur whether the value is allowable for other functions, or an invalid integer value. + *

    + *

    + * Integer parameters that are used as names for AL objects such as Buffers and + * Sources are checked for validity. If an invalid name parameter is specified in an AL + * command, an AL_INVALID_NAME error will be generated, and the command is + * ignored. + *

    + *

    + * If a negative integer is provided where an argument of type sizei is specified, the + * error AL_INVALID_VALUE results. The same error will result from attempts to set + * integral and floating point values for attributes exceeding the legal range for these. + * The specification does not guarantee that the implementation emits + * AL_INVALID_VALUE if a NaN or Infinity value is passed in for a float or double + * argument (as the specification does not enforce possibly expensive testing of + * floating point values). + *

    + *

    + * Commands can be invalid. For example, certain commands might not be applicable + * to a given object. There are also illegal combinations of tokens and values as + * arguments to a command. AL responds to any such illegal command with an + * AL_INVALID_OPERATION error. + *

    + *

    + * If memory is exhausted as a side effect of the execution of an AL command, either + * on system level or by exhausting the allocated resources at AL's internal disposal, + * the error AL_OUT_OF_MEMORY may be generated. This can also happen independent + * of recent commands if AL has to request memory for an internal task and fails to + * allocate the required memory from the operating system. + *

    + *

    + * Otherwise errors are generated only for conditions that are explicitely described in + * this specification. + *

    + * + * @return current error state + */ + @NoErrorCheck + @ALenum int alGetError(); + + /** + * To verify that a given extension is available for the current context and the device it + * is associated with, use this method. + *

    + * A null name argument returns AL_FALSE, as do invalid and unsupported string + * tokens. A null deviceHandle will result in an INVALID_DEVICE error. + *

    + * + * @param fname String describing the desired extension + * @return true if extension is available, false if not + */ + boolean alIsExtensionPresent(String fname); + + /** + *

    + * To obtain enumeration values for extensions, the application has to use + * GetEnumValue of an extension token. Enumeration values are defined within the + * AL namespace and allocated according to specification of the core API and the + * extensions, thus they are context-independent. + *

    + *

    + * Returns 0 if the enumeration can not be found. The presence of an enum value does + * not guarantee the applicability of an extension to the current context. A non-zero + * return indicates merely that the implementation is aware of the existence of this + * extension. Implementations should not attempt to return 0 to indicate that the + * extensions is not supported for the current context. + *

    + * + * @param ename String describing an OpenAL enum + * @return Actual int for the described enumeration name + */ + @ALenum int alGetEnumValue(String ename); + + /** + * Listener attributes are changed using the Listener group of commands. + * + * @param pname name of the attribute to be set + * @param value value to set the attribute to + */ + @ALvoid + void alListeneri(@ALenum int pname, int value); + + /** + * Listener attributes are changed using the Listener group of commands. + * + * @param pname name of the attribute to be set + * @param value floating point value to set the attribute to + */ + @ALvoid + void alListenerf(@ALenum int pname, float value); + + /** + * Listener attributes are changed using the Listener group of commands. + * + * @param pname name of the attribute to be set + * @param value FloatBuffer containing value to set the attribute to + */ + @StripPostfix("value") + @ALvoid + void alListenerfv(@ALenum int pname, @Check("1") @Const FloatBuffer value); + + /** + * Listener attributes are changed using the Listener group of commands. + * + * @param pname name of the attribute to be set + * @param v1 value value 1 + * @param v2 value value 2 + * @param v3 float value 3 + */ + @ALvoid + void alListener3f(@ALenum int pname, float v1, float v2, float v3); + + /** + * Listener state is maintained inside the AL implementation and can be queried in + * full. + * + * @param pname name of the attribute to be retrieved + * @return int + */ + void alGetListeneri(@ALenum int pname, @Result @ALint int value); + + /** + * Listener state is maintained inside the AL implementation and can be queried in + * full. + * + * @param pname name of the attribute to be retrieved + * @return float + */ + void alGetListenerf(@ALenum int pname, @Result float value); + + /** + * Listener state is maintained inside the AL implementation and can be queried in + * full. + * + * @param pname name of the attribute to be retrieved + * @param floatdata Buffer to write floats to + */ + // TODO: What's the real minimum number of elements? + @StripPostfix("floatdata") + @ALvoid + void alGetListenerfv(@ALenum int pname, @OutParameter @Check("1") FloatBuffer floatdata); + + /** + * The application requests a number of Sources using GenSources. + * + * @param sources array holding sources + */ + @ALvoid + void alGenSources(@AutoSize("sources") @ALsizei int n, @OutParameter @ALuint IntBuffer sources); + + @Alternate(value = "alGenSources", nativeAlt = true) + @ALvoid + void alGenSources2(@Constant("1") @ALsizei int n, @Result @ALuint int source); + + /** + * The application requests deletion of a number of Sources by DeleteSources. + * + * @param sources Source array to delete from + */ + @ALvoid + void alDeleteSources(@AutoSize("sources") @ALsizei int n, @ALuint IntBuffer sources); + + @Alternate(value = "alDeleteSources", nativeAlt = true) + @ALvoid + void alDeleteSources2(@Constant("1") @ALsizei int n, @Indirect @ALuint int source); + + /** + * The application can verify whether a source name is valid using the IsSource query. + * + * @param id id of source to be testes for validity + * @return true if id is valid, false if not + */ + boolean alIsSource(@ALuint int id); + + /** + * Specifies the position and other properties as taken into account during + * sound processing. + * + * @param source Source to det property on + * @param pname property to set + * @param value value of property + */ + @ALvoid + void alSourcei(@ALuint int source, @ALenum int pname, int value); + + /** + * Specifies the position and other properties as taken into account during + * sound processing. + * + * @param source Source to det property on + * @param pname property to set + * @param value value of property + */ + @ALvoid + void alSourcef(@ALuint int source, @ALenum int pname, float value); + + /** + * Specifies the position and other properties as taken into account during + * sound processing. + * + * @param source Source to set property on + * @param pname property to set + * @param value FloatBuffer containing value of property + */ + // TODO: What's the correct minimum value? + @StripPostfix("value") + @ALvoid + void alSourcefv(@ALuint int source, @ALenum int pname, @Check("1") @Const FloatBuffer value); + + /** + * Specifies the position and other properties as taken into account during + * sound processing. + * + * @param source Source to set property on + * @param pname property to set + * @param v1 value 1 of property + * @param v2 value 2 of property + * @param v3 value 3 of property + */ + @ALvoid + void alSource3f( + @ALuint int source, + @ALenum int pname, + float v1, + float v2, + float v3); + + + /** + * Source state is maintained inside the AL implementation, and the current attributes + * can be queried. The performance of such queries is implementation dependent, no + * performance guarantees are made. + * + * @param source source to get property from + * @param pname name of property + * @return int + */ + @ALvoid + void alGetSourcei(@ALuint int source, @ALenum int pname, @Result int value); + + /** + * Source state is maintained inside the AL implementation, and the current attributes + * can be queried. The performance of such queries is implementation dependent, no + * performance guarantees are made. + * + * @param source source to get property from + * @param pname name of property + * @return float + */ + @ALvoid + void alGetSourcef(@ALuint int source, @ALenum int pname, @Result float value); + + /** + * Source state is maintained inside the AL implementation, and the current attributes + * can be queried. The performance of such queries is implementation dependent, no + * performance guarantees are made. + * + * @param source Source to get property from + * @param pname property to get + * @param floatdata Buffer to write floats to + */ + // TODO: What's the correct minimum value? + @StripPostfix("floatdata") + @ALvoid + void alGetSourcefv(@ALuint int source, @ALenum int pname, @OutParameter @Check("1") FloatBuffer floatdata); + + /** + * Play() applied to an AL_INITIAL Source will promote the Source to AL_PLAYING, thus + * the data found in the Buffer will be fed into the processing, starting at the + * beginning. Play() applied to a AL_PLAYING Source will restart the Source from the + * beginning. It will not affect the configuration, and will leave the Source in + * AL_PLAYING state, but reset the sampling offset to the beginning. Play() applied to a + * AL_PAUSED Source will resume processing using the Source state as preserved at the + * Pause() operation. Play() applied to a AL_STOPPED Source will propagate it to + * AL_INITIAL then to AL_PLAYING immediately. + * + * @param sources array of sources to play + */ + @StripPostfix("sources") + @ALvoid + void alSourcePlayv(@AutoSize("sources") @ALsizei int n, @ALuint IntBuffer sources); + + /** + * Pause() applied to an AL_INITIAL Source is a legal NOP. Pause() applied to a + * AL_PLAYING Source will change its state to AL_PAUSED. The Source is exempt from + * processing, its current state is preserved. Pause() applied to a AL_PAUSED Source is a + * legal NOP. Pause() applied to a AL_STOPPED Source is a legal NOP. + * + * @param sources array of sources to pause + */ + @StripPostfix("sources") + @ALvoid + void alSourcePausev(@AutoSize("sources") @ALsizei int n, @ALuint IntBuffer sources); + + /** + * Stop() applied to an AL_INITIAL Source is a legal NOP. Stop() applied to a AL_PLAYING + * Source will change its state to AL_STOPPED. The Source is exempt from processing, + * its current state is preserved. Stop() applied to a AL_PAUSED Source will change its + * state to AL_STOPPED, with the same consequences as on a AL_PLAYING Source. Stop() + * applied to a AL_STOPPED Source is a legal NOP. + * + * @param sources array of sources to stop + */ + @StripPostfix("sources") + @ALvoid + void alSourceStopv(@AutoSize("sources") @ALsizei int n, @ALuint IntBuffer sources); + + /** + * Rewind() applied to an AL_INITIAL Source is a legal NOP. Rewind() applied to a + * AL_PLAYING Source will change its state to AL_STOPPED then AL_INITIAL. The Source is + * exempt from processing, its current state is preserved, with the exception of the + * sampling offset which is reset to the beginning. Rewind() applied to a AL_PAUSED + * Source will change its state to AL_INITIAL, with the same consequences as on a + * AL_PLAYING Source. Rewind() applied to a AL_STOPPED Source promotes the Source to + * AL_INITIAL, resetting the sampling offset to the beginning. + * + * @param sources array of sources to rewind + */ + @StripPostfix("sources") + @ALvoid + void alSourceRewindv(@AutoSize("sources") @ALsizei int n, @ALuint IntBuffer sources); + + /** + * Play() applied to an AL_INITIAL Source will promote the Source to AL_PLAYING, thus + * the data found in the Buffer will be fed into the processing, starting at the + * beginning. Play() applied to a AL_PLAYING Source will restart the Source from the + * beginning. It will not affect the configuration, and will leave the Source in + * AL_PLAYING state, but reset the sampling offset to the beginning. Play() applied to a + * AL_PAUSED Source will resume processing using the Source state as preserved at the + * Pause() operation. Play() applied to a AL_STOPPED Source will propagate it to + * AL_INITIAL then to AL_PLAYING immediately. + * + * @param source Source to play + */ + @ALvoid + void alSourcePlay(@ALuint int source); + + /** + * Pause() applied to an AL_INITIAL Source is a legal NOP. Pause() applied to a + * AL_PLAYING Source will change its state to AL_PAUSED. The Source is exempt from + * processing, its current state is preserved. Pause() applied to a AL_PAUSED Source is a + * legal NOP. Pause() applied to a AL_STOPPED Source is a legal NOP. + * + * @param source Source to pause + */ + @ALvoid + void alSourcePause(@ALuint int source); + + /** + * Stop() applied to an AL_INITIAL Source is a legal NOP. Stop() applied to a AL_PLAYING + * Source will change its state to AL_STOPPED. The Source is exempt from processing, + * its current state is preserved. Stop() applied to a AL_PAUSED Source will change its + * state to AL_STOPPED, with the same consequences as on a AL_PLAYING Source. Stop() + * applied to a AL_STOPPED Source is a legal NOP. + * + * @param source Source to stop + */ + @ALvoid + void alSourceStop(@ALuint int source); + + /** + * Rewind() applied to an AL_INITIAL Source is a legal NOP. Rewind() applied to a + * AL_PLAYING Source will change its state to AL_STOPPED then AL_INITIAL. The Source is + * exempt from processing, its current state is preserved, with the exception of the + * sampling offset which is reset to the beginning. Rewind() applied to a AL_PAUSED + * Source will change its state to AL_INITIAL, with the same consequences as on a + * AL_PLAYING Source. Rewind() applied to a AL_STOPPED Source promotes the Source to + * AL_INITIAL, resetting the sampling offset to the beginning. + * + * @param source Source to rewind + */ + @ALvoid + void alSourceRewind(@ALuint int source); + + /** + * The application requests a number of Buffers using GenBuffers. + * + * @param buffers holding buffers + */ + @ALvoid + void alGenBuffers(@AutoSize("buffers") @ALsizei int n, @OutParameter @ALuint IntBuffer buffers); + + @Alternate(value = "alGenBuffers", nativeAlt = true) + @ALvoid + void alGenBuffers2(@Constant("1") @ALsizei int n, @Result @ALuint int buffer); + + /** + *

    + * The application requests deletion of a number of Buffers by calling DeleteBuffers. + *

    + *

    + * Once deleted, Names are no longer valid for use with AL function calls. Any such + * use will cause an AL_INVALID_NAME error. The implementation is free to defer actual + * release of resources. + *

    + *

    + * IsBuffer(bname) can be used to verify deletion of a buffer. Deleting bufferName 0 is + * a legal NOP in both scalar and vector forms of the command. The same is true for + * unused buffer names, e.g. such as not allocated yet, or as released already. + * + * @param buffers Buffer to delete from + */ + @ALvoid + void alDeleteBuffers(@AutoSize("buffers") @ALsizei int n, @ALuint IntBuffer buffers); + + @Alternate(value = "alDeleteBuffers", nativeAlt = true) + @ALvoid + void alDeleteBuffers2(@Constant("1") @ALsizei int n, @Indirect @ALuint int buffer); + + /** + * The application can verify whether a buffer Name is valid using the IsBuffer query. + * + * @param buffer buffer to be tested for validity + * @return true if supplied buffer is valid, false if not + */ + boolean alIsBuffer(@ALuint int buffer); + + /** + *

    + * A special case of Buffer state is the actual sound sample data stored in asociation + * with the Buffer. Applications can specify sample data using BufferData. + *

    + *

    + * The data specified is copied to an internal software, or if possible, hardware buffer. + * The implementation is free to apply decompression, conversion, resampling, and + * filtering as needed. The internal format of the Buffer is not exposed to the + * application, and not accessible. Valid formats are AL_FORMAT_MONO8, + * AL_FORMAT_MONO16, AL_FORMAT_STEREO8, and AL_FORMAT_STEREO16. An + * implementation may expose other formats, see the chapter on Extensions for + * information on determining if additional formats are supported. + *

    + *

    + * Applications should always check for an error condition after attempting to specify + * buffer data in case an implementation has to generate an AL_OUT_OF_MEMORY or + * conversion related AL_INVALID_VALUE error. The application is free to reuse the + * memory specified by the data pointer once the call to BufferData returns. The + * implementation has to dereference, e.g. copy, the data during BufferData execution. + *

    + * + * @param buffer Buffer to fill + * @param format format sound data is in + * @param data location of data + * @param freq frequency of data + */ + @ALvoid + void alBufferData( + @ALuint int buffer, + @ALenum int format, + @ALbyte + @ALshort + @ALint + Buffer data, + @AutoSize("data") + @ALsizei int size, + @ALsizei int freq); + + /** + * Buffer state is maintained inside the AL implementation and can be queried in full.
    + * ALC_FREQUENCY - specified in samples per second, i.e. units of Hertz [Hz].
    + * ALC_SIZE - Size in bytes of the buffer data.
    + * + * @param buffer buffer to get property from + * @param pname name of property to retrieve + */ + @ALvoid + void alGetBufferi(@ALuint int buffer, @ALenum int pname, @Result int value); + + /** + * Buffer state is maintained inside the AL implementation and can be queried in full.
    + * ALC_FREQUENCY - specified in samples per second, i.e. units of Hertz [Hz].
    + * ALC_SIZE - Size in bytes of the buffer data.
    + * + * @param buffer buffer to get property from + * @param pname name of property to retrieve + * @return float + */ + @ALvoid + void alGetBufferf(@ALuint int buffer, @ALenum int pname, @Result float value); + + /** + *

    + * The application can queue up one or multiple buffer names using + * SourceQueueBuffers. The buffers will be queued in the sequence in which they + * appear in the array. + *

    + *

    + * This command is legal on a Source in any state (to allow for streaming, queueing + * has to be possible on a AL_PLAYING Source). Queues are read-only with exception of + * the unqueue operation. The Buffer Name AL_NONE (i.e. 0) can be queued. + *

    + * + * @param source source to queue buffers onto + * @param buffers buffers to be queued + */ + @ALvoid + void alSourceQueueBuffers(@ALuint int source, @AutoSize("buffers") @ALsizei int n, @ALuint IntBuffer buffers); + + @Alternate(value = "alSourceQueueBuffers", nativeAlt = true) + @ALvoid + void alSourceQueueBuffers2(@ALuint int source, @Constant("1") @ALsizei int n, @Indirect @ALuint int buffer); + + /** + *

    + * Once a queue entry for a buffer has been appended to a queue and is pending + * processing, it should not be changed. Removal of a given queue entry is not possible + * unless either the Source is AL_STOPPED (in which case then entire queue is considered + * processed), or if the queue entry has already been processed (AL_PLAYING or AL_PAUSED + * Source). + *

    + *

    + * The Unqueue command removes a number of buffers entries that have finished + * processing, in the order of appearance, from the queue. The operation will fail if + * more buffers are requested than available, leaving the destination arguments + * unchanged. An AL_INVALID_VALUE error will be thrown. If no error, the destination + * argument will have been updated accordingly. + *

    + * + * @param source source to unqueue buffers from + * @param buffers IntBuffer containing list of names that were unqueued + */ + @ALvoid + void alSourceUnqueueBuffers(@ALuint int source, @AutoSize("buffers") @ALsizei int n, @OutParameter @ALuint IntBuffer buffers); + + @Alternate(value = "alSourceUnqueueBuffers", nativeAlt = true) + @ALvoid + void alSourceUnqueueBuffers2(@ALuint int source, @Constant("1") @ALsizei int n, @Result @ALuint int buffer); + + /** + *

    + * Samples usually use the entire dynamic range of the chosen format/encoding, + * independent of their real world intensity. In other words, a jet engine and a + * clockwork both will have samples with full amplitude. The application will then + * have to adjust Source AL_GAIN accordingly to account for relative differences. + *

    + *

    + * Source AL_GAIN is then attenuated by distance. The effective attenuation of a Source + * depends on many factors, among which distance attenuation and source and + * Listener AL_GAIN are only some of the contributing factors. Even if the source and + * Listener AL_GAIN exceed 1.0 (amplification beyond the guaranteed dynamic range), + * distance and other attenuation might ultimately limit the overall AL_GAIN to a value + * below 1.0. + *

    + *

    + * AL currently supports three modes of operation with respect to distance + * attenuation. It supports two distance-dependent attenuation models, one which is + * similar to the IASIG I3DL2 (and DS3D) model. The application choses one of these + * two models (or can chose to disable distance-dependent attenuation effects model) + * on a per-context basis. + *

    + *

    + * Legal arguments are AL_NONE, AL_INVERSE_DISTANCE, and + * AL_INVERSE_DISTANCE_CLAMPED. + *
    + *
    + * AL_NONE bypasses all distance attenuation + * calculation for all Sources. The implementation is expected to optimize this + * situation. + *
    + *
    + * AL_INVERSE_DISTANCE_CLAMPED is the DS3D model, with + * AL_REFERENCE_DISTANCE indicating both the reference distance and the distance + * below which gain will be clamped. + *
    + *
    + * AL_INVERSE_DISTANCE is equivalent to the DS3D + * model with the exception that AL_REFERENCE_DISTANCE does not imply any + * clamping. + *
    + *
    + * The AL implementation is still free to apply any range clamping as + * necessary. The current distance model chosen can be queried using GetIntegerv and + * AL_DISTANCE_MODEL. + *

    + * + * @param value distance model to be set + */ + @ALvoid + void alDistanceModel(@ALenum int value); + + /** + * The Doppler Effect depends on the velocities of Source and Listener relative to the + * medium, and the propagation speed of sound in that medium. The application + * might want to emphasize or de-emphasize the Doppler Effect as physically accurate + * calculation might not give the desired results. The amount of frequency shift (pitch + * change) is proportional to the speed of listener and source along their line of sight. + * The application can increase or decrease that frequency shift by specifying the + * scaling factor AL should apply to the result of the calculation. + *
    + *
    + * The Doppler Effect as implemented by AL is described by the formula below. Effects + * of the medium (air, water) moving with respect to listener and source are ignored. + * AL_DOPPLER_VELOCITY is the propagation speed relative to which the Source + * velocities are interpreted. + * + *

    + *

    +	 *	 VD: AL_DOPPLER_VELOCITY
    +	 *	 DF: AL_DOPPLER_FACTOR
    +	 *	 vl: Listener velocity (scalar, projected on source-listener vector)
    +	 *	 vs: Source verlocity (scalar, projected on source-listener vector)
    +	 *	 f: Frequency in sample
    +	 *	 f': effective Doppler shifted frequency
    +	 *
    +	 *	 f' = DF * f * (VD-vl)/(VD+vs)
    +	 *
    +	 *	 vl<0, vs>0 : source and listener approaching each other
    +	 *	 vl>0, vs<0 : source and listener moving away from each other
    +	 * 
    + *

    + *

    + * The implementation has to clamp the projected Listener velocity vl, if abs(vl) is + * greater or equal VD. It similarly has to clamp the projected Source velocity vs if + * abs(vs) is greater or equal VD. + *

    + *

    + * There are two API calls global to the current context that provide control of the two + * related parameters. + *

    + *

    + * AL_DOPPLER_FACTOR is a simple scaling to exaggerate or + * deemphasize the Doppler (pitch) shift resulting from the calculation. + *

    + *

    + * A negative value will result in an AL_INVALID_VALUE error, the command is then + * ignored. The default value is 1. The current setting can be queried using GetFloatv + * and AL_DOPPLER_FACTOR. The implementation is free to optimize the case of + * AL_DOPPLER_FACTOR being set to zero, as this effectively disables the effect. + *

    + * + * @param value Doppler scale value to set + */ + @ALvoid + void alDopplerFactor(float value); + + /** + * The Doppler Effect depends on the velocities of Source and Listener relative to the + * medium, and the propagation speed of sound in that medium. The application + * might want to emphasize or de-emphasize the Doppler Effect as physically accurate + * calculation might not give the desired results. The amount of frequency shift (pitch + * change) is proportional to the speed of listener and source along their line of sight. + * The application can increase or decrease that frequency shift by specifying the + * scaling factor AL should apply to the result of the calculation. + *
    + *
    + * The Doppler Effect as implemented by AL is described by the formula below. Effects + * of the medium (air, water) moving with respect to listener and source are ignored. + * AL_DOPPLER_VELOCITY is the propagation speed relative to which the Source + * velocities are interpreted. + * + *

    + *

    +	 *	 VD: AL_DOPPLER_VELOCITY
    +	 *	 DF: AL_DOPPLER_FACTOR
    +	 *	 vl: Listener velocity (scalar, projected on source-listener vector)
    +	 *	 vs: Source verlocity (scalar, projected on source-listener vector)
    +	 *	 f: Frequency in sample
    +	 *	 f': effective Doppler shifted frequency
    +	 *
    +	 *	 f' = DF * f * (VD-vl)/(VD+vs)
    +	 *
    +	 *	 vl<0, vs>0 : source and listener approaching each other
    +	 *	 vl>0, vs<0 : source and listener moving away from each other
    +	 * 
    + *

    + *

    + * The implementation has to clamp the projected Listener velocity vl, if abs(vl) is + * greater or equal VD. It similarly has to clamp the projected Source velocity vs if + * abs(vs) is greater or equal VD. + *

    + *

    + * There are two API calls global to the current context that provide control of the two + * related parameters. + *

    + *

    + * AL_DOPPLER_VELOCITY allows the application to change the reference (propagation) + * velocity used in the Doppler Effect calculation. This permits the application to use a + * velocity scale appropriate to its purposes. + *

    + *

    + * A negative or zero value will result in an AL_INVALID_VALUE error, the command is + * then ignored. The default value is 1. The current setting can be queried using + * GetFloatv and AL_DOPPLER_VELOCITY. + *

    + * + * @param value Doppler velocity value to set + */ + @ALvoid + void alDopplerVelocity(float value); +} diff --git a/src/templates/org/lwjgl/openal/AL11.java b/src/templates/org/lwjgl/openal/AL11.java new file mode 100644 index 0000000..f484849 --- /dev/null +++ b/src/templates/org/lwjgl/openal/AL11.java @@ -0,0 +1,278 @@ +/* + * 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.openal; + +import java.nio.Buffer; +import java.nio.IntBuffer; +import java.nio.FloatBuffer; +import java.nio.DoubleBuffer; + +import org.lwjgl.openal.AL10; +import org.lwjgl.util.generator.*; + +/** + *
    + * This is the core OpenAL class. This class implements + * AL.h version 1.1 + * + * @author Brian Matzon + * @version $Revision: 2286 $ + * $Id: AL10.java 2286 2006-03-23 19:32:21Z matzon $ + */ +public interface AL11 { + + /** Source buffer position information in seconds */ + public static final int AL_SEC_OFFSET = 0x1024; + + /** Source buffer position information in samples */ + public static final int AL_SAMPLE_OFFSET = 0x1025; + + /** Source buffer position information in bytes */ + public static final int AL_BYTE_OFFSET = 0x1026; + + /** Type of source: Buffer has been attached using AL_BUFFER */ + public static final int AL_STATIC = 0x1028; + + /** Type of source: if one or more Buffers have been attached using alSourceQueueBuffers */ + public static final int AL_STREAMING = 0x1029; + + /** Type of source: when it has the NULL buffer attached */ + public static final int AL_UNDETERMINED = 0x1030; + + /** @see AL10#AL_INVALID_OPERATION */ + public static final int AL_ILLEGAL_COMMAND = 0xA004; + + /** Speed of Sound in units per second */ + public static final int AL_SPEED_OF_SOUND = 0xC003; + + public static final int AL_LINEAR_DISTANCE = 0xD003; + public static final int AL_LINEAR_DISTANCE_CLAMPED = 0xD004; + public static final int AL_EXPONENT_DISTANCE = 0xD005; + public static final int AL_EXPONENT_DISTANCE_CLAMPED = 0xD006; + + /** + * Listener attributes are changed using the Listener group of commands. + * + * @param pname name of the attribute to be set + * @param v1 value value 1 + * @param v2 value value 2 + * @param v3 value value 3 + */ + @ALvoid + void alListener3i(@ALenum int pname, int v1, int v2, int v3); + + /** + * Listener state is maintained inside the AL implementation and can be queried in + * full. + * + * @param pname name of the attribute to be retrieved + * @param intdata Buffer to write ints to + */ + // TODO: What's the real minimum number of elements? + @StripPostfix("intdata") + @ALvoid + void alGetListeneriv(@ALenum int pname, @OutParameter @Check("1") FloatBuffer intdata); + + /** + * Specifies the position and other properties as taken into account during + * sound processing. + * + * @param source Source to set property on + * @param pname property to set + * @param v1 value 1 of property + * @param v2 value 2 of property + * @param v3 value 3 of property + */ + @ALvoid + void alSource3i(@ALuint int source, @ALenum int pname, int v1, int v2, int v3); + + /** + * Specifies the position and other properties as taken into account during + * sound processing. + * + * @param source Source to set property on + * @param pname property to set + * @param value IntBuffer containing value of property + */ + // TODO: What's the correct minimum value? + @StripPostfix("value") + @ALvoid + void alSourceiv(@ALuint int source, @ALenum int pname, @Check("1") @Const IntBuffer value); + + /** + * This function sets a floating point property of a buffer. + * note: There are no relevant buffer properties defined in OpenAL 1.1 which can be affected by + * this call, but this function may be used by OpenAL extensions. + * + * @param buffer Buffer to set property on + * @param pname property to set + * @param value value of property + */ + @ALvoid + void alBufferf(@ALuint int buffer, @ALenum int pname, float value); + + /** + * This function sets a floating point property of a buffer. + * note: There are no relevant buffer properties defined in OpenAL 1.1 which can be affected by + * this call, but this function may be used by OpenAL extensions. + * + * @param buffer Buffer to set property on + * @param pname property to set + * @param v1 value of property + * @param v2 value of property + * @param v3 value of property + */ + @ALvoid + void alBuffer3f(@ALuint int buffer, @ALenum int pname, float v1, float v2, float v3); + + /** + * This function sets a floating point property of a buffer. + * note: There are no relevant buffer properties defined in OpenAL 1.1 which can be affected by + * this call, but this function may be used by OpenAL extensions. + * + * @param buffer Buffer to set property on + * @param pname property to set + * @param value FloatBuffer containing value of property + */ + // TODO: What's the correct minimum value? + @StripPostfix("value") + @ALvoid + void alBufferfv(@ALuint int buffer, @ALenum int pname, @Check("1") @Const FloatBuffer value); + + /** + * This function sets an integer property of a buffer. + * note: There are no relevant buffer properties defined in OpenAL 1.1 which can be affected by + * this call, but this function may be used by OpenAL extensions. + * + * @param buffer Buffer to set property on + * @param pname property to set + * @param value value of property + */ + @ALvoid + void alBufferi(@ALuint int buffer, @ALenum int pname, int value); + + /** + * This function sets an integer property of a buffer. + * note: There are no relevant buffer properties defined in OpenAL 1.1 which can be affected by + * this call, but this function may be used by OpenAL extensions. + * + * @param buffer Buffer to set property on + * @param pname property to set + * @param v1 value of property + * @param v2 value of property + * @param v3 value of property + */ + @ALvoid + void alBuffer3i(@ALuint int buffer, @ALenum int pname, int v1, int v2, int v3); + + /** + * This function sets an integer property of a buffer. + * note: There are no relevant buffer properties defined in OpenAL 1.1 which can be affected by + * this call, but this function may be used by OpenAL extensions. + * + * @param buffer Buffer to set property on + * @param pname property to set + * @param value IntBuffer containing value of property + */ + // TODO: What's the correct minimum value? + @StripPostfix("value") + @ALvoid + void alBufferiv(@ALuint int buffer, @ALenum int pname, @Check("1") @Const IntBuffer value); + + /** + * This function retrieves an integer property of a buffer. + * note: There are no relevant buffer properties defined in OpenAL 1.1 which can be affected by + * this call, but this function may be used by OpenAL extensions. + * + * @param buffer Buffer to get property from + * @param pname name of property + * @return int + */ + @ALvoid + void alGetBufferi(@ALuint int buffer, @ALenum int pname, @Result int value); + + /** + * This function retrieves an integer property of a buffer. + * + * @param buffer Buffer to get property from + * @param pname name of property + */ + // TODO: What's the correct minimum value? + @StripPostfix("values") + @ALvoid + void alGetBufferiv(@ALuint int buffer, @ALenum int pname, @OutParameter @Check("1") IntBuffer values); + + /** + * This function retrieves a floating point property of a buffer. + * note: There are no relevant buffer properties defined in OpenAL 1.1 which can be affected by + * this call, but this function may be used by OpenAL extensions. + * + * @param buffer Buffer to get property from + * @param pname name of property + * @return floating point property + */ + @ALvoid + void alGetBufferf(@ALuint int buffer, @ALenum int pname, @Result float value); + + /** + * This function retrieves a floating point property of a buffer. + * note: There are no relevant buffer properties defined in OpenAL 1.1 which can be affected by + * this call, but this function may be used by OpenAL extensions. + * + * @param buffer Buffer to get property from + * @param pname name of property + */ + // TODO: What's the correct minimum value? + @StripPostfix("values") + @ALvoid + void alGetBufferfv(@ALuint int buffer, @ALenum int pname, @OutParameter @Check("1") FloatBuffer values); + + /** + *

    + * AL_SPEED_OF_SOUND allows the application to change the reference (propagation) + * speed used in the Doppler calculation. The source and listener velocities should be + * expressed in the same units as the speed of sound. + *

    + *

    + * A negative or zero value will result in an AL_INVALID_VALUE error, and the + * command is ignored. The default value is 343.3 (appropriate for velocity units of meters + * and air as the propagation medium). The current setting can be queried using + * alGetFloat{v} and AL_SPEED_OF_SOUND. + * Distance and velocity units are completely independent of one another (so you could use + * different units for each if desired). + *

    + * + * @param value distance model to be set + */ + @ALvoid + void alSpeedOfSound(float value); +} diff --git a/src/templates/org/lwjgl/opengl/AMD_conservative_depth.java b/src/templates/org/lwjgl/opengl/AMD_conservative_depth.java new file mode 100644 index 0000000..940799a --- /dev/null +++ b/src/templates/org/lwjgl/opengl/AMD_conservative_depth.java @@ -0,0 +1,35 @@ +/* + * 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; + +public interface AMD_conservative_depth { +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/AMD_draw_buffers_blend.java b/src/templates/org/lwjgl/opengl/AMD_draw_buffers_blend.java new file mode 100644 index 0000000..9786cfa --- /dev/null +++ b/src/templates/org/lwjgl/opengl/AMD_draw_buffers_blend.java @@ -0,0 +1,49 @@ +/* + * 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; + +import org.lwjgl.util.generator.GLenum; +import org.lwjgl.util.generator.GLuint; + +public interface AMD_draw_buffers_blend { + + void glBlendFuncIndexedAMD(@GLuint int buf, @GLenum int src, @GLenum int dst); + + void glBlendFuncSeparateIndexedAMD(@GLuint int buf, @GLenum int srcRGB, @GLenum int dstRGB, + @GLenum int srcAlpha, @GLenum int dstAlpha); + + void glBlendEquationIndexedAMD(@GLuint int buf, @GLenum int mode); + + void glBlendEquationSeparateIndexedAMD(@GLuint int buf, @GLenum int modeRGB, + @GLenum int modeAlpha); + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/AMD_performance_monitor.java b/src/templates/org/lwjgl/opengl/AMD_performance_monitor.java new file mode 100644 index 0000000..3f18a04 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/AMD_performance_monitor.java @@ -0,0 +1,122 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +import java.nio.ByteBuffer; +import java.nio.IntBuffer; + +public interface AMD_performance_monitor { + + /** Accepted by the <pame> parameter of GetPerfMonitorCounterInfoAMD */ + int GL_COUNTER_TYPE_AMD = 0x8BC0; + int GL_COUNTER_RANGE_AMD = 0x8BC1; + + /** + * Returned as a valid value in <data> parameter of + * GetPerfMonitorCounterInfoAMD if <pname> = COUNTER_TYPE_AMD + */ + int GL_UNSIGNED_INT = 0x1405; + int GL_FLOAT = 0x1406; + int GL_UNSIGNED_INT64_AMD = 0x8BC2; + int GL_PERCENTAGE_AMD = 0x8BC3; + + /** Accepted by the <pname> parameter of GetPerfMonitorCounterDataAMD */ + + int GL_PERFMON_RESULT_AVAILABLE_AMD = 0x8BC4; + int GL_PERFMON_RESULT_SIZE_AMD = 0x8BC5; + int GL_PERFMON_RESULT_AMD = 0x8BC6; + + void glGetPerfMonitorGroupsAMD(@OutParameter @Check(value = "1", canBeNull = true) @GLint IntBuffer numGroups, + @AutoSize("groups") @GLsizei int groupsSize, @GLuint IntBuffer groups); + + void glGetPerfMonitorCountersAMD(@GLuint int group, + @OutParameter @Check(value = "1") @GLint IntBuffer numCounters, + @OutParameter @Check(value = "1") @GLint IntBuffer maxActiveCounters, + @AutoSize("counters") @GLsizei int countersSize, + @GLuint IntBuffer counters); + + void glGetPerfMonitorGroupStringAMD(@GLuint int group, + @AutoSize("groupString") @GLsizei int bufSize, + @OutParameter @GLsizei @Check(value = "1", canBeNull = true) IntBuffer length, + @OutParameter @GLchar ByteBuffer groupString); + + @Alternate("glGetPerfMonitorGroupStringAMD") + @GLreturn(value = "groupString", maxLength = "bufSize") + void glGetPerfMonitorGroupStringAMD2(@GLuint int group, @GLsizei int bufSize, + @OutParameter @GLsizei @Constant("groupString_length, 0") IntBuffer length, + @OutParameter @GLchar ByteBuffer groupString); + + void glGetPerfMonitorCounterStringAMD(@GLuint int group, @GLuint int counter, @AutoSize("counterString") @GLsizei int bufSize, + @OutParameter @GLsizei @Check(value = "1", canBeNull = true) IntBuffer length, + @OutParameter @GLchar ByteBuffer counterString); + + @Alternate("glGetPerfMonitorCounterStringAMD") + @GLreturn(value = "counterString", maxLength = "bufSize") + void glGetPerfMonitorCounterStringAMD2(@GLuint int group, @GLuint int counter, @GLsizei int bufSize, + @OutParameter @GLsizei @Constant("counterString_length, 0") IntBuffer length, + @OutParameter @GLchar ByteBuffer counterString); + + void glGetPerfMonitorCounterInfoAMD(@GLuint int group, @GLuint int counter, @GLenum int pname, @Check(value = "16") @GLvoid ByteBuffer data); + + void glGenPerfMonitorsAMD(@AutoSize("monitors") @GLsizei int n, @OutParameter @GLuint IntBuffer monitors); + + @Alternate("glGenPerfMonitorsAMD") + @GLreturn("monitors") + void glGenPerfMonitorsAMD2(@Constant("1") @GLsizei int n, @OutParameter @GLuint IntBuffer monitors); + + void glDeletePerfMonitorsAMD(@AutoSize("monitors") @GLsizei int n, @GLuint IntBuffer monitors); + + @Alternate("glDeletePerfMonitorsAMD") + void glDeletePerfMonitorsAMD(@Constant("1") @GLsizei int n, @Constant(value = "APIUtils.getBufferInt().put(0, monitor), 0", keepParam = true) int monitor); + + void glSelectPerfMonitorCountersAMD(@GLuint int monitor, boolean enable, @GLuint int group, @AutoSize("counterList") int numCounters, @GLuint IntBuffer counterList); + + @Alternate("glSelectPerfMonitorCountersAMD") + void glSelectPerfMonitorCountersAMD(@GLuint int monitor, boolean enable, @GLuint int group, @Constant("1") int numCounters, @Constant(value = "APIUtils.getBufferInt().put(0, counter), 0", keepParam = true) int counter); + + void glBeginPerfMonitorAMD(@GLuint int monitor); + + void glEndPerfMonitorAMD(@GLuint int monitor); + + void glGetPerfMonitorCounterDataAMD(@GLuint int monitor, @GLenum int pname, @AutoSize("data") @GLsizei int dataSize, + @OutParameter @GLuint IntBuffer data, + @OutParameter @GLint @Check(value = "1", canBeNull = true) IntBuffer bytesWritten); + + @Alternate("glGetPerfMonitorCounterDataAMD") + @GLreturn("data") + void glGetPerfMonitorCounterDataAMD2(@GLuint int monitor, @GLenum int pname, @Constant("4") @GLsizei int dataSize, + @OutParameter @GLuint IntBuffer data, + @OutParameter @GLint @Constant("null, 0") IntBuffer bytesWritten); + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/AMD_seamless_cubemap_per_texture.java b/src/templates/org/lwjgl/opengl/AMD_seamless_cubemap_per_texture.java new file mode 100644 index 0000000..f0ce360 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/AMD_seamless_cubemap_per_texture.java @@ -0,0 +1,42 @@ +/* + * 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; + +public interface AMD_seamless_cubemap_per_texture { + + /** + * Accepted by the <pname> parameter of TexParameterf, TexParameteri, + * TexParameterfv, TexParameteriv, GetTexParameterfv, and GetTexParameteriv: + */ + int GL_TEXTURE_CUBE_MAP_SEAMLESS = ARB_seamless_cube_map.GL_TEXTURE_CUBE_MAP_SEAMLESS; + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/AMD_shader_stencil_export.java b/src/templates/org/lwjgl/opengl/AMD_shader_stencil_export.java new file mode 100644 index 0000000..c7824fa --- /dev/null +++ b/src/templates/org/lwjgl/opengl/AMD_shader_stencil_export.java @@ -0,0 +1,35 @@ +/* + * 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; + +public interface AMD_shader_stencil_export { +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/AMD_texture_texture4.java b/src/templates/org/lwjgl/opengl/AMD_texture_texture4.java new file mode 100644 index 0000000..5958ace --- /dev/null +++ b/src/templates/org/lwjgl/opengl/AMD_texture_texture4.java @@ -0,0 +1,35 @@ +/* + * 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; + +public interface AMD_texture_texture4 { +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/AMD_vertex_shader_tessellator.java b/src/templates/org/lwjgl/opengl/AMD_vertex_shader_tessellator.java new file mode 100644 index 0000000..5a596db --- /dev/null +++ b/src/templates/org/lwjgl/opengl/AMD_vertex_shader_tessellator.java @@ -0,0 +1,57 @@ +/* + * 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; + +import org.lwjgl.util.generator.GLenum; + +public interface AMD_vertex_shader_tessellator { + + /** Returned by the <type> parameter of GetActiveUniform: */ + int GL_SAMPLER_BUFFER_AMD = 0x9001; + int GL_INT_SAMPLER_BUFFER_AMD = 0x9002; + int GL_UNSIGNED_INT_SAMPLER_BUFFER_AMD = 0x9003; + + /** Accepted by TessellationModeAMD */ + int GL_DISCRETE_AMD = 0x9006; + int GL_CONTINUOUS_AMD = 0x9007; + + /** Accepted by GetIntegerv */ + int GL_TESSELLATION_MODE_AMD = 0x9004; + + /** Accepted by GetFloatv */ + int GL_TESSELLATION_FACTOR_AMD = 0x9005; + + void glTessellationFactorAMD(float factor); + + void glTessellationModeAMD(@GLenum int mode); + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/APPLE_aux_depth_stencil.java b/src/templates/org/lwjgl/opengl/APPLE_aux_depth_stencil.java new file mode 100644 index 0000000..0231fcd --- /dev/null +++ b/src/templates/org/lwjgl/opengl/APPLE_aux_depth_stencil.java @@ -0,0 +1,39 @@ +/* + * 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; + +public interface APPLE_aux_depth_stencil { + + /** Accepted by the <pname> parameter of GetIntegerv. */ + int GL_AUX_DEPTH_STENCIL_APPLE = 0x8A14; + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/APPLE_client_storage.java b/src/templates/org/lwjgl/opengl/APPLE_client_storage.java new file mode 100644 index 0000000..a8cee09 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/APPLE_client_storage.java @@ -0,0 +1,39 @@ +/* + * 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; + +public interface APPLE_client_storage { + + /** Accepted by the <pname> parameters of PixelStore: */ + int GL_UNPACK_CLIENT_STORAGE_APPLE = 0x85B2; + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/APPLE_element_array.java b/src/templates/org/lwjgl/opengl/APPLE_element_array.java new file mode 100644 index 0000000..8d09178 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/APPLE_element_array.java @@ -0,0 +1,77 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +import java.nio.Buffer; +import java.nio.IntBuffer; + +public interface APPLE_element_array { + + /** + * Accepted by the <array> parameter of EnableClientState and + * DisableClientState and the <value> parameter of IsEnabled: + */ + int GL_ELEMENT_ARRAY_APPLE = 0x8768; + + /** + * Accepted by the <value> parameter of GetBooleanv, GetIntegerv, + * GetFloatv, and GetDoublev: + */ + int GL_ELEMENT_ARRAY_TYPE_APPLE = 0x8769; + + /** Accepted by the <pname> parameter of GetPointerv: */ + int GL_ELEMENT_ARRAY_POINTER_APPLE = 0x876A; + + void glElementPointerAPPLE(@AutoType("pointer") @GLenum int type, + @Check + @Const + @GLubyte + @GLushort + @GLuint Buffer pointer); + + void glDrawElementArrayAPPLE(@GLenum int mode, int first, @GLsizei int count); + + void glDrawRangeElementArrayAPPLE(@GLenum int mode, @GLuint int start, @GLuint int end, int first, @GLsizei int count); + + void glMultiDrawElementArrayAPPLE(@GLenum int mode, + @Const IntBuffer first, + @Const @Check("first.remaining()") @GLsizei IntBuffer count, + @AutoSize("first") @GLsizei int primcount); + + void glMultiDrawRangeElementArrayAPPLE(@GLenum int mode, @GLuint int start, @GLuint int end, + @Const IntBuffer first, + @Const @Check("first.remaining()") @GLsizei IntBuffer count, + @AutoSize("first") @GLsizei int primcount); + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/APPLE_fence.java b/src/templates/org/lwjgl/opengl/APPLE_fence.java new file mode 100644 index 0000000..073bff7 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/APPLE_fence.java @@ -0,0 +1,67 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +import java.nio.IntBuffer; + +public interface APPLE_fence { + + /** Accepted by the <object> parameter of TestObjectAPPLE and FinishObjectAPPLE: */ + int GL_DRAW_PIXELS_APPLE = 0x8A0A; + int GL_FENCE_APPLE = 0x8A0B; + + void glGenFencesAPPLE(@AutoSize("fences") @GLsizei int n, @OutParameter @GLuint IntBuffer fences); + + @Alternate("glGenFencesAPPLE") + @GLreturn("fences") + void glGenFencesAPPLE2(@Constant("1") @GLsizei int n, @OutParameter @GLuint IntBuffer fences); + + void glDeleteFencesAPPLE(@AutoSize("fences") @GLsizei int n, @Const @GLuint IntBuffer fences); + + @Alternate("glDeleteFencesAPPLE") + void glDeleteFencesAPPLE(@Constant("1") @GLsizei int n, @Const @GLuint @Constant(value = "APIUtils.getBufferInt().put(0, fence), 0", keepParam = true) int fence); + + void glSetFenceAPPLE(@GLuint int fence); + + boolean glIsFenceAPPLE(@GLuint int fence); + + boolean glTestFenceAPPLE(@GLuint int fence); + + void glFinishFenceAPPLE(@GLuint int fence); + + boolean glTestObjectAPPLE(@GLenum int object, @GLuint int name); + + void glFinishObjectAPPLE(@GLenum int object, int name); + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/APPLE_float_pixels.java b/src/templates/org/lwjgl/opengl/APPLE_float_pixels.java new file mode 100644 index 0000000..e4f4f1c --- /dev/null +++ b/src/templates/org/lwjgl/opengl/APPLE_float_pixels.java @@ -0,0 +1,63 @@ +/* + * 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; + +public interface APPLE_float_pixels { + + /** + * Accepted by the parameters of DrawPixels, ReadPixels, TexImage1D, + * TexImage2D, TexImage3D, TexSubImage1D, TexSubImage2D, TexSubImage3D, and + * GetTexImage: + */ + int GL_HALF_APPLE = 0x140B; + + /** Accepted by the GetBooleanv: */ + int GL_COLOR_FLOAT_APPLE = 0x8A0F; + + /** + * Accepted by the parameter of TexImage1D, + * TexImage2D, and TexImage3D: + */ + int GL_RGBA_FLOAT32_APPLE = 0x8814; + int GL_RGB_FLOAT32_APPLE = 0x8815; + int GL_ALPHA_FLOAT32_APPLE = 0x8816; + int GL_INTENSITY_FLOAT32_APPLE = 0x8817; + int GL_LUMINANCE_FLOAT32_APPLE = 0x8818; + int GL_LUMINANCE_ALPHA_FLOAT32_APPLE = 0x8819; + int GL_RGBA_FLOAT16_APPLE = 0x881A; + int GL_RGB_FLOAT16_APPLE = 0x881B; + int GL_ALPHA_FLOAT16_APPLE = 0x881C; + int GL_INTENSITY_FLOAT16_APPLE = 0x881D; + int GL_LUMINANCE_FLOAT16_APPLE = 0x881E; + int GL_LUMINANCE_ALPHA_FLOAT16_APPLE = 0x881F; + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/APPLE_flush_buffer_range.java b/src/templates/org/lwjgl/opengl/APPLE_flush_buffer_range.java new file mode 100644 index 0000000..342c7dd --- /dev/null +++ b/src/templates/org/lwjgl/opengl/APPLE_flush_buffer_range.java @@ -0,0 +1,51 @@ +/* + * 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; + +import org.lwjgl.util.generator.GLenum; +import org.lwjgl.util.generator.GLintptr; +import org.lwjgl.util.generator.GLsizeiptr; + +public interface APPLE_flush_buffer_range { + + /** + * Accepted by the <pname> parameter of BufferParameteriAPPLE and + * GetBufferParameteriv: + */ + int GL_BUFFER_SERIALIZED_MODIFY_APPLE = 0x8A12; + int GL_BUFFER_FLUSHING_UNMAP_APPLE = 0x8A13; + + void glBufferParameteriAPPLE(@GLenum int target, @GLenum int pname, int param); + + void glFlushMappedBufferRangeAPPLE(@GLenum int target, @GLintptr long offset, @GLsizeiptr long size); + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/APPLE_object_purgeable.java b/src/templates/org/lwjgl/opengl/APPLE_object_purgeable.java new file mode 100644 index 0000000..87c3847 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/APPLE_object_purgeable.java @@ -0,0 +1,77 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +import java.nio.IntBuffer; + +public interface APPLE_object_purgeable { + + /** + * Accepted by the <option> parameter of ObjectPurgeable, and returned + * by ObjectPurgeable: + */ + int GL_RELEASED_APPLE = 0x8A19; + int GL_VOLATILE_APPLE = 0x8A1A; + + /** + * Accepted by the <option> parameters of ObjectUnpurgeable, and + * returned by ObjectUnpurgeable: + */ + int GL_RETAINED_APPLE = 0x8A1B; + int GL_UNDEFINED_APPLE = 0x8A1C; + + /** Accepted by the <pname> parameters of GetObjectParameteriv: */ + int GL_PURGEABLE_APPLE = 0x8A1D; + + /** + * Accepted by the <objectType> parameters of ObjectPurgeableAPPLE, + * ObjectUnpurgeableAPPLE and GetObjectParameteriv: + */ + int GL_BUFFER_OBJECT_APPLE = 0x85B3; + + @GLenum + int glObjectPurgeableAPPLE(@GLenum int objectType, @GLuint int name, @GLenum int option); + + @GLenum + int glObjectUnpurgeableAPPLE(@GLenum int objectType, @GLuint int name, @GLenum int option); + + @StripPostfix("params") + void glGetObjectParameterivAPPLE(@GLenum int objectType, @GLuint int name, @GLenum int pname, @OutParameter @Check("1") IntBuffer params); + + @Alternate("glGetObjectParameterivAPPLE") + @GLreturn("params") + @StripPostfix("params") + void glGetObjectParameterivAPPLE2(@GLenum int objectType, @GLuint int name, @GLenum int pname, @OutParameter IntBuffer params); + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/APPLE_packed_pixels.java b/src/templates/org/lwjgl/opengl/APPLE_packed_pixels.java new file mode 100644 index 0000000..6543ba1 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/APPLE_packed_pixels.java @@ -0,0 +1,58 @@ +/* + * 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; + +public interface APPLE_packed_pixels { + + /** + * Accepted by the <type> parameter of DrawPixels, ReadPixels, TexImage1D, + * TexImage2D, GetTexImage, TexImage3D, TexSubImage1D, + * TexSubImage2D, TexSubImage3D, GetHistogram, GetMinmax, + * ConvolutionFilter1D, ConvolutionFilter2D, ConvolutionFilter3D, + * GetConvolutionFilter, SeparableFilter2D, SeparableFilter3D, + * GetSeparableFilter, ColorTable, GetColorTable, TexImage4DSGIS, + * and TexSubImage4DSGIS: + */ + int GL_UNSIGNED_BYTE_3_3_2 = 0x8032; + int GL_UNSIGNED_BYTE_2_3_3_REV = 0x8362; + int GL_UNSIGNED_SHORT_5_6_5 = 0x8363; + int GL_UNSIGNED_SHORT_5_6_5_REV = 0x8364; + int GL_UNSIGNED_SHORT_4_4_4_4 = 0x8033; + int GL_UNSIGNED_SHORT_4_4_4_4_REV = 0x8365; + int GL_UNSIGNED_SHORT_5_5_5_1 = 0x8034; + int GL_UNSIGNED_SHORT_1_5_5_5_REV = 0x8366; + int GL_UNSIGNED_INT_8_8_8_8 = 0x8035; + int GL_UNSIGNED_INT_8_8_8_8_REV = 0x8367; + int GL_UNSIGNED_INT_10_10_10_2 = 0x8036; + int GL_UNSIGNED_INT_2_10_10_10_REV = 0x8368; + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/APPLE_rgb_422.java b/src/templates/org/lwjgl/opengl/APPLE_rgb_422.java new file mode 100644 index 0000000..27e4c2d --- /dev/null +++ b/src/templates/org/lwjgl/opengl/APPLE_rgb_422.java @@ -0,0 +1,55 @@ +/* + * 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; + +public interface APPLE_rgb_422 { + + /** + * Accepted by the <format> parameter of DrawPixels, ReadPixels, TexImage1D, + * TexImage2D, GetTexImage, TexImage3D, TexSubImage1D, TexSubImage2D, + * TexSubImage3D, GetHistogram, GetMinmax, ConvolutionFilter1D, + * ConvolutionFilter2D, GetConvolutionFilter, SeparableFilter2D, + * GetSeparableFilter, ColorTable, GetColorTable: + */ + int GL_RGB_422_APPLE = 0x8A1F; + + /** + * Accepted by the <type> parameter of DrawPixels, ReadPixels, TexImage1D, + * TexImage2D, GetTexImage, TexImage3D, TexSubImage1D, TexSubImage2D, + * TexSubImage3D, GetHistogram, GetMinmax, ConvolutionFilter1D, + * ConvolutionFilter2D, GetConvolutionFilter, SeparableFilter2D, + * GetSeparableFilter, ColorTable, GetColorTable: + */ + int GL_UNSIGNED_SHORT_8_8_APPLE = 0x85BA; + int GL_UNSIGNED_SHORT_8_8_REV_APPLE = 0x85BB; + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/APPLE_row_bytes.java b/src/templates/org/lwjgl/opengl/APPLE_row_bytes.java new file mode 100644 index 0000000..4d65fc3 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/APPLE_row_bytes.java @@ -0,0 +1,43 @@ +/* + * 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; + +public interface APPLE_row_bytes { + + /** + * Accepted by the <pname> parameter of PixelStorei and the <pname> + * parameter of GetIntegerv: + */ + int GL_PACK_ROW_BYTES_APPLE = 0x8A15; + int GL_UNPACK_ROW_BYTES_APPLE = 0x8A16; + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/APPLE_texture_range.java b/src/templates/org/lwjgl/opengl/APPLE_texture_range.java new file mode 100644 index 0000000..b4dd4ca --- /dev/null +++ b/src/templates/org/lwjgl/opengl/APPLE_texture_range.java @@ -0,0 +1,69 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +import java.nio.Buffer; +import java.nio.ByteBuffer; + +public interface APPLE_texture_range { + + /** + * Accepted by the parameters of TexParameteri, TexParameterf, + * TexParameteriv, TexParameterfv, GetTexParameteriv, and + * GetTexParameterfv: + */ + int GL_TEXTURE_STORAGE_HINT_APPLE = 0x85BC; + + /** + * Accepted by the parameters of TexParameteri, TexParameterf, + * TexParameteriv, and TexParameterfv: + */ + int GL_STORAGE_PRIVATE_APPLE = 0x85BD; + int GL_STORAGE_CACHED_APPLE = 0x85BE; + int GL_STORAGE_SHARED_APPLE = 0x85BF; + + /** + * Accepted by the parameters of GetTexParameteriv and + * GetTexParameterfv: + */ + int GL_TEXTURE_RANGE_LENGTH_APPLE = 0x85B7; + + /** Accepted by the parameters of GetTexParameterPointerv: */ + int GL_TEXTURE_RANGE_POINTER_APPLE = 0x85B8; + + void glTextureRangeAPPLE(@GLenum int target, @AutoSize("pointer") @GLsizei int length, @GLvoid ByteBuffer pointer); + + void glGetTexParameterPointervAPPLE(@GLenum int target, @GLenum int pname, @Result @GLvoid Buffer params); + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/APPLE_vertex_array_object.java b/src/templates/org/lwjgl/opengl/APPLE_vertex_array_object.java new file mode 100644 index 0000000..ea98f2a --- /dev/null +++ b/src/templates/org/lwjgl/opengl/APPLE_vertex_array_object.java @@ -0,0 +1,61 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +import java.nio.IntBuffer; + +public interface APPLE_vertex_array_object { + + /** + * Accepted by the <pname> parameter of GetBooleanv, GetIntegerv, GetFloatv, + * and GetDoublev: + */ + int GL_VERTEX_ARRAY_BINDING_APPLE = 0x85B5; + + void glBindVertexArrayAPPLE(@GLuint int array); + + void glDeleteVertexArraysAPPLE(@AutoSize("arrays") @GLsizei int n, @Const @GLuint IntBuffer arrays); + + @Alternate("glDeleteVertexArraysAPPLE") + void glDeleteVertexArraysAPPLE(@Constant("1") @GLsizei int n, @Const @GLuint @Constant(value = "APIUtils.getBufferInt().put(0, array), 0", keepParam = true) int array); + + void glGenVertexArraysAPPLE(@AutoSize("arrays") @GLsizei int n, @OutParameter @GLuint IntBuffer arrays); + + @Alternate("glGenVertexArraysAPPLE") + @GLreturn("arrays") + void glGenVertexArraysAPPLE2(@Constant("1") @GLsizei int n, @OutParameter @GLuint IntBuffer arrays); + + boolean glIsVertexArrayAPPLE(@GLuint int array); + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/APPLE_vertex_array_range.java b/src/templates/org/lwjgl/opengl/APPLE_vertex_array_range.java new file mode 100644 index 0000000..2eca457 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/APPLE_vertex_array_range.java @@ -0,0 +1,83 @@ +/* + * 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; + +import org.lwjgl.util.generator.AutoSize; +import org.lwjgl.util.generator.GLenum; +import org.lwjgl.util.generator.GLsizei; +import org.lwjgl.util.generator.GLvoid; + +import java.nio.ByteBuffer; + +public interface APPLE_vertex_array_range { + + /** + * Accepted by the <cap> parameter of EnableClientState, DisableClientState, + * and IsEnabled: + */ + int GL_VERTEX_ARRAY_RANGE_APPLE = 0x851D; + + /** + * Accepted by the <pname> parameter of GetBooleanv, GetIntegerv, GetFloatv, + * and GetDoublev: + */ + + int GL_VERTEX_ARRAY_RANGE_LENGTH_APPLE = 0x851E; + int GL_MAX_VERTEX_ARRAY_RANGE_ELEMENT_APPLE = 0x8520; + + /** Accepted by the <pname> parameter of GetPointerv: */ + + int GL_VERTEX_ARRAY_RANGE_POINTER_APPLE = 0x8521; + + /** + * Accepted by the <pname> parameter of VertexArrayParameteriAPPLE, + * GetBooleanv, GetIntegerv, GetFloatv, and GetDoublev: + */ + + int GL_VERTEX_ARRAY_STORAGE_HINT_APPLE = 0x851F; + + /** Accepted by the <param> parameter of VertexArrayParameteriAPPLE: */ + + int GL_STORAGE_CACHED_APPLE = 0x85BE; + int GL_STORAGE_SHARED_APPLE = 0x85BF; + + /** Accepted by the <object> parameter of TestObjectAPPLE and FinishObjectAPPLE: */ + int GL_DRAW_PIXELS_APPLE = 0x8A0A; + int GL_FENCE_APPLE = 0x8A0B; + + void glVertexArrayRangeAPPLE(@AutoSize("pointer") @GLsizei int length, @GLvoid ByteBuffer pointer); + + void glFlushVertexArrayRangeAPPLE(@AutoSize("pointer") @GLsizei int length, @GLvoid ByteBuffer pointer); + + void glVertexArrayParameteriAPPLE(@GLenum int pname, int param); + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/APPLE_vertex_program_evaluators.java b/src/templates/org/lwjgl/opengl/APPLE_vertex_program_evaluators.java new file mode 100644 index 0000000..77f625d --- /dev/null +++ b/src/templates/org/lwjgl/opengl/APPLE_vertex_program_evaluators.java @@ -0,0 +1,84 @@ +/* + * 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; + +import org.lwjgl.util.generator.Check; +import org.lwjgl.util.generator.Const; +import org.lwjgl.util.generator.GLenum; +import org.lwjgl.util.generator.GLuint; + +import java.nio.DoubleBuffer; +import java.nio.FloatBuffer; + +public interface APPLE_vertex_program_evaluators { + + /** + * Accepted by the <pname> parameter of EnableVertexAttribAPPLE, + * DisableVertexAttribAPPLE, and IsVertexAttribEnabledAPPLE. + */ + int GL_VERTEX_ATTRIB_MAP1_APPLE = 0x8A00; + int GL_VERTEX_ATTRIB_MAP2_APPLE = 0x8A01; + + /** + * Accepted by the <pname> parameter of GetVertexAttribdvARB, + * GetVertexAttribfvARB, and GetVertexAttribivARB. + */ + int GL_VERTEX_ATTRIB_MAP1_SIZE_APPLE = 0x8A02; + int GL_VERTEX_ATTRIB_MAP1_COEFF_APPLE = 0x8A03; + int GL_VERTEX_ATTRIB_MAP1_ORDER_APPLE = 0x8A04; + int GL_VERTEX_ATTRIB_MAP1_DOMAIN_APPLE = 0x8A05; + int GL_VERTEX_ATTRIB_MAP2_SIZE_APPLE = 0x8A06; + int GL_VERTEX_ATTRIB_MAP2_COEFF_APPLE = 0x8A07; + int GL_VERTEX_ATTRIB_MAP2_ORDER_APPLE = 0x8A08; + int GL_VERTEX_ATTRIB_MAP2_DOMAIN_APPLE = 0x8A09; + + void glEnableVertexAttribAPPLE(@GLuint int index, @GLenum int pname); + + void glDisableVertexAttribAPPLE(@GLuint int index, @GLenum int pname); + + boolean glIsVertexAttribEnabledAPPLE(@GLuint int index, @GLenum int pname); + + void glMapVertexAttrib1dAPPLE(@GLuint int index, @GLuint int size, double u1, double u2, + int stride, int order, @Check @Const DoubleBuffer points); + + void glMapVertexAttrib1fAPPLE(@GLuint int index, @GLuint int size, float u1, float u2, + int stride, int order, @Check @Const FloatBuffer points); + + void glMapVertexAttrib2dAPPLE(@GLuint int index, @GLuint int size, double u1, double u2, + int ustride, int uorder, double v1, double v2, int vstride, int vorder, + @Check @Const DoubleBuffer points); + + void glMapVertexAttrib2fAPPLE(@GLuint int index, @GLuint int size, float u1, float u2, + int ustride, int uorder, float v1, float v2, int vstride, int vorder, + @Check @Const FloatBuffer points); + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/APPLE_ycbcr_422.java b/src/templates/org/lwjgl/opengl/APPLE_ycbcr_422.java new file mode 100644 index 0000000..a871cc9 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/APPLE_ycbcr_422.java @@ -0,0 +1,57 @@ +/* + * 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; + +public interface APPLE_ycbcr_422 { + + /** + * Accepted by the <format> parameter of DrawPixels, ReadPixels, TexImage1D, + * TexImage2D, GetTexImage, TexImage3D, TexSubImage1D, TexSubImage2D, + * TexSubImage3D, GetHistogram, GetMinmax, ConvolutionFilter1D, + * ConvolutionFilter2D, ConvolutionFilter3D, GetConvolutionFilter, + * SeparableFilter2D, SeparableFilter3D, GetSeparableFilter, ColorTable, + * GetColorTable: + */ + int GL_YCBCR_422_APPLE = 0x85B9; + + /** + * Accepted by the <type> parameter of DrawPixels, ReadPixels, TexImage1D, + * TexImage2D, GetTexImage, TexImage3D, TexSubImage1D, TexSubImage2D, + * TexSubImage3D, GetHistogram, GetMinmax, ConvolutionFilter1D, + * ConvolutionFilter2D, ConvolutionFilter3D, GetConvolutionFilter, + * SeparableFilter2D, SeparableFilter3D, GetSeparableFilter, ColorTable, + * GetColorTable: + */ + int GL_UNSIGNED_SHORT_8_8_APPLE = 0x85BA; + int GL_UNSIGNED_SHORT_8_8_REV_APPLE = 0x85BB; + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/ARB_blend_func_extended.java b/src/templates/org/lwjgl/opengl/ARB_blend_func_extended.java new file mode 100644 index 0000000..ab6b007 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/ARB_blend_func_extended.java @@ -0,0 +1,66 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +import java.nio.ByteBuffer; + +public interface ARB_blend_func_extended { + + /** + * Accepted by the <src> and <dst> parameters of BlendFunc and + * BlendFunci, and by the <srcRGB>, <dstRGB>, <srcAlpha> and <dstAlpha> + * parameters of BlendFuncSeparate and BlendFuncSeparatei: + */ + int GL_SRC1_COLOR = 0x88F9; + int GL_SRC1_ALPHA = GL15.GL_SRC1_ALPHA; + int GL_ONE_MINUS_SRC1_COLOR = 0x88FA; + int GL_ONE_MINUS_SRC1_ALPHA = 0x88FB; + + /** + * Accepted by the <pname> parameter of GetBooleanv, GetIntegerv, GetFloatv + * and GetDoublev: + */ + int GL_MAX_DUAL_SOURCE_DRAW_BUFFERS = 0x88FC; + + void glBindFragDataLocationIndexed(@GLuint int program, @GLuint int colorNumber, @GLuint int index, @NullTerminated @Const @GLchar ByteBuffer name); + + @Alternate("glBindFragDataLocationIndexed") + void glBindFragDataLocationIndexed(@GLuint int program, @GLuint int colorNumber, @GLuint int index, @NullTerminated CharSequence name); + + int glGetFragDataIndex(@GLuint int program, @NullTerminated @Const @GLchar ByteBuffer name); + + @Alternate("glGetFragDataIndex") + int glGetFragDataIndex(@GLuint int program, @NullTerminated CharSequence name); + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/ARB_buffer_object.java b/src/templates/org/lwjgl/opengl/ARB_buffer_object.java new file mode 100644 index 0000000..fcf301e --- /dev/null +++ b/src/templates/org/lwjgl/opengl/ARB_buffer_object.java @@ -0,0 +1,150 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +import java.nio.Buffer; +import java.nio.ByteBuffer; +import java.nio.IntBuffer; + +@Extension(postfix = "ARB", isFinal = false) +public interface ARB_buffer_object { + + /** Accepted by the <usage> parameter of BufferDataARB: */ + int GL_STREAM_DRAW_ARB = 0x88E0; + int GL_STREAM_READ_ARB = 0x88E1; + int GL_STREAM_COPY_ARB = 0x88E2; + int GL_STATIC_DRAW_ARB = 0x88E4; + int GL_STATIC_READ_ARB = 0x88E5; + int GL_STATIC_COPY_ARB = 0x88E6; + int GL_DYNAMIC_DRAW_ARB = 0x88E8; + int GL_DYNAMIC_READ_ARB = 0x88E9; + int GL_DYNAMIC_COPY_ARB = 0x88EA; + + /** Accepted by the <access> parameter of MapBufferARB: */ + int GL_READ_ONLY_ARB = 0x88B8; + int GL_WRITE_ONLY_ARB = 0x88B9; + int GL_READ_WRITE_ARB = 0x88BA; + + /** Accepted by the <pname> parameter of GetBufferParameterivARB: */ + int GL_BUFFER_SIZE_ARB = 0x8764; + int GL_BUFFER_USAGE_ARB = 0x8765; + int GL_BUFFER_ACCESS_ARB = 0x88BB; + int GL_BUFFER_MAPPED_ARB = 0x88BC; + int GL_BUFFER_MAP_POINTER_ARB = 0x88BD; + + @Code(" StateTracker.bindBuffer(caps, target, buffer);") + void glBindBufferARB(@GLenum int target, @GLuint int buffer); + + void glDeleteBuffersARB(@AutoSize("buffers") @GLsizei int n, @Const @GLuint IntBuffer buffers); + + @Alternate("glDeleteBuffersARB") + void glDeleteBuffersARB(@Constant("1") @GLsizei int n, @Constant(value = "APIUtils.getBufferInt().put(0, buffer), 0", keepParam = true) int buffer); + + void glGenBuffersARB(@AutoSize("buffers") @GLsizei int n, @OutParameter @GLuint IntBuffer buffers); + + @Alternate("glGenBuffersARB") + @GLreturn("buffers") + void glGenBuffersARB2(@Constant("1") @GLsizei int n, @OutParameter @GLuint IntBuffer buffers); + + boolean glIsBufferARB(@GLuint int buffer); + + @GenerateAutos + void glBufferDataARB(@GLenum int target, @AutoSize("data") @GLsizeiptrARB long size, + @Const + @GLbyte + @GLshort + @GLint + @GLfloat + @GLdouble Buffer data, @GLenum int usage); + + void glBufferSubDataARB(@GLenum int target, @GLintptrARB long offset, @AutoSize("data") @GLsizeiptrARB long size, + @Check + @Const + @GLbyte + @GLshort + @GLint + @GLfloat + @GLdouble Buffer data); + + void glGetBufferSubDataARB(@GLenum int target, @GLintptrARB long offset, @AutoSize("data") @GLsizeiptrARB long size, + @OutParameter + @Check + @GLbyte + @GLshort + @GLint + @GLfloat + @GLdouble Buffer data); + + /** + * glMapBufferARB maps a GL buffer object to a ByteBuffer. The old_buffer argument can be null, + * in which case a new ByteBuffer will be created, pointing to the returned memory. If old_buffer is non-null, + * it will be returned if it points to the same mapped memory and has the same capacity as the buffer object, + * otherwise a new ByteBuffer is created. That way, an application will normally use glMapBufferARB like this: + *

    + * ByteBuffer mapped_buffer; mapped_buffer = glMapBufferARB(..., ..., null); ... // Another map on the same buffer mapped_buffer = glMapBufferARB(..., ..., mapped_buffer); + *

    + * Only ByteBuffers returned from this method are to be passed as the old_buffer argument. User-created ByteBuffers cannot be reused. + *

    + * The version of this method without an explicit length argument calls glGetBufferParameterARB internally to + * retrieve the current buffer object size, which may cause a pipeline flush and reduce application performance. + *

    + * The version of this method with an explicit length argument is a fast alternative to the one without. No GL call + * is made to retrieve the buffer object size, so the user is responsible for tracking and using the appropriate length.
    + * Security warning: The length argument should match the buffer object size. Reading from or writing to outside + * the memory region that corresponds to the mapped buffer object will cause native crashes. + * + * @param length the length of the mapped memory in bytes. + * @param old_buffer A ByteBuffer. If this argument points to the same address and has the same capacity as the new mapping, it will be returned and no new buffer will be created. + * + * @return A ByteBuffer representing the mapped buffer memory. + */ + @CachedResult + @GLvoid + @AutoResultSize("GLChecks.getBufferObjectSizeARB(caps, target)") + ByteBuffer glMapBufferARB(@GLenum int target, @GLenum int access); + + boolean glUnmapBufferARB(@GLenum int target); + + @StripPostfix("params") + void glGetBufferParameterivARB(@GLenum int target, @GLenum int pname, @OutParameter @Check("4") IntBuffer params); + + @Alternate("glGetBufferParameterivARB") + @GLreturn("params") + @StripPostfix("params") + void glGetBufferParameterivARB2(@GLenum int target, @GLenum int pname, @OutParameter IntBuffer params); + + @StripPostfix("pointer") + @AutoResultSize("GLChecks.getBufferObjectSizeARB(caps, target)") + void glGetBufferPointervARB(@GLenum int target, @GLenum int pname, @Result @GLvoid ByteBuffer pointer); +} diff --git a/src/templates/org/lwjgl/opengl/ARB_color_buffer_float.java b/src/templates/org/lwjgl/opengl/ARB_color_buffer_float.java new file mode 100644 index 0000000..a58e75b --- /dev/null +++ b/src/templates/org/lwjgl/opengl/ARB_color_buffer_float.java @@ -0,0 +1,74 @@ +/* + * 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; + +import org.lwjgl.util.generator.GLenum; + +public interface ARB_color_buffer_float { + + /** + * Accepted by the <pname> parameters of GetBooleanv, GetIntegerv, + * GetFloatv, and GetDoublev: + */ + int GL_RGBA_FLOAT_MODE_ARB = 0x8820; + + /** + * Accepted by the <target> parameter of ClampColorARB and the <pname> + * parameter of GetBooleanv, GetIntegerv, GetFloatv, and GetDoublev. + */ + int GL_CLAMP_VERTEX_COLOR_ARB = 0x891A; + int GL_CLAMP_FRAGMENT_COLOR_ARB = 0x891B; + int GL_CLAMP_READ_COLOR_ARB = 0x891C; + + /** Accepted by the <clamp> parameter of ClampColorARB. */ + int GL_FIXED_ONLY_ARB = 0x891D; + + /** + * Accepted as a value in the <piAttribIList> and <pfAttribFList> + * parameter arrays of wglChoosePixelFormatARB, and returned in the + * <piValues> parameter array of wglGetPixelFormatAttribivARB, and the + * <pfValues> parameter array of wglGetPixelFormatAttribfvARB: + */ + int WGL_TYPE_RGBA_FLOAT_ARB = 0x21A0; + + /** + * Accepted as values of the <render_type> arguments in the + * glXCreateNewContext and glXCreateContext functions + */ + int GLX_RGBA_FLOAT_TYPE = 0x20B9; + + /** Accepted as a bit set in the GLX_RENDER_TYPE variable */ + int GLX_RGBA_FLOAT_BIT = 0x00000004; + + void glClampColorARB(@GLenum int target, @GLenum int clamp); + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/ARB_compatibility.java b/src/templates/org/lwjgl/opengl/ARB_compatibility.java new file mode 100644 index 0000000..5d053e8 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/ARB_compatibility.java @@ -0,0 +1,35 @@ +/* + * 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; + +public interface ARB_compatibility { +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/ARB_copy_buffer.java b/src/templates/org/lwjgl/opengl/ARB_copy_buffer.java new file mode 100644 index 0000000..859f908 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/ARB_copy_buffer.java @@ -0,0 +1,54 @@ +/* + * 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; + +import org.lwjgl.util.generator.GLenum; +import org.lwjgl.util.generator.GLintptr; +import org.lwjgl.util.generator.GLsizeiptr; + +public interface ARB_copy_buffer { + + /** + * Accepted by the target parameters of BindBuffer, BufferData, + * BufferSubData, MapBuffer, UnmapBuffer, GetBufferSubData, + * GetBufferPointerv, MapBufferRange, FlushMappedBufferRange, + * GetBufferParameteriv, BindBufferRange, BindBufferBase, + * and CopyBufferSubData: + */ + int GL_COPY_READ_BUFFER = 0x8F36; + int GL_COPY_WRITE_BUFFER = 0x8F37; + + void glCopyBufferSubData(@GLenum int readTarget, @GLenum int writeTarget, + @GLintptr long readOffset, @GLintptr long writeOffset, + @GLsizeiptr long size); + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/ARB_depth_buffer_float.java b/src/templates/org/lwjgl/opengl/ARB_depth_buffer_float.java new file mode 100644 index 0000000..7e4c372 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/ARB_depth_buffer_float.java @@ -0,0 +1,52 @@ +/* + * 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; + +public interface ARB_depth_buffer_float { + + /** + * Accepted by the <internalformat> parameter of TexImage1D, TexImage2D, + * TexImage3D, CopyTexImage1D, CopyTexImage2D, and RenderbufferStorageEXT, + * and returned in the <data> parameter of GetTexLevelParameter and + * GetRenderbufferParameterivEXT: + */ + int GL_DEPTH_COMPONENT32F = 0x8CAC; + int GL_DEPTH32F_STENCIL8 = 0x8CAD; + + /** + * Accepted by the <type> parameter of DrawPixels, ReadPixels, TexImage1D, + * TexImage2D, TexImage3D, TexSubImage1D, TexSubImage2D, TexSubImage3D, and + * GetTexImage: + */ + int GL_FLOAT_32_UNSIGNED_INT_24_8_REV = 0x8DAD; + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/ARB_depth_clamp.java b/src/templates/org/lwjgl/opengl/ARB_depth_clamp.java new file mode 100644 index 0000000..c81bf96 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/ARB_depth_clamp.java @@ -0,0 +1,43 @@ +/* + * 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; + +public interface ARB_depth_clamp { + + /** + * Accepted by the <cap> parameter of Enable, Disable, and IsEnabled, + * and by the <pname> parameter of GetBooleanv, GetIntegerv, + * GetFloatv, and GetDoublev: + */ + int GL_DEPTH_CLAMP = 0x864F; + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/ARB_depth_texture.java b/src/templates/org/lwjgl/opengl/ARB_depth_texture.java new file mode 100644 index 0000000..4998f08 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/ARB_depth_texture.java @@ -0,0 +1,55 @@ +/* + * 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; + +public interface ARB_depth_texture { + + /** + * Accepted by the <internalFormat> parameter of TexImage1D, TexImage2D, + * CopyTexImage1D and CopyTexImage2D: + */ + int GL_DEPTH_COMPONENT16_ARB = 0x81A5; + int GL_DEPTH_COMPONENT24_ARB = 0x81A6; + int GL_DEPTH_COMPONENT32_ARB = 0x81A7; + + /** + * Accepted by the <pname> parameter of GetTexLevelParameterfv and + * GetTexLevelParameteriv: + */ + int GL_TEXTURE_DEPTH_SIZE_ARB = 0x884A; + + /** + * Accepted by the <pname> parameter of TexParameterf, TexParameteri, + * TexParameterfv, TexParameteriv, GetTexParameterfv, and GetTexParameteriv: + */ + int GL_DEPTH_TEXTURE_MODE_ARB = 0x884B; +} diff --git a/src/templates/org/lwjgl/opengl/ARB_draw_buffers.java b/src/templates/org/lwjgl/opengl/ARB_draw_buffers.java new file mode 100644 index 0000000..d209a31 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/ARB_draw_buffers.java @@ -0,0 +1,66 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +import java.nio.*; + +public interface ARB_draw_buffers { + + /** + * Accepted by the <pname> parameters of GetIntegerv, GetFloatv, + * and GetDoublev: + */ + int GL_MAX_DRAW_BUFFERS_ARB = 0x8824; + int GL_DRAW_BUFFER0_ARB = 0x8825; + int GL_DRAW_BUFFER1_ARB = 0x8826; + int GL_DRAW_BUFFER2_ARB = 0x8827; + int GL_DRAW_BUFFER3_ARB = 0x8828; + int GL_DRAW_BUFFER4_ARB = 0x8829; + int GL_DRAW_BUFFER5_ARB = 0x882A; + int GL_DRAW_BUFFER6_ARB = 0x882B; + int GL_DRAW_BUFFER7_ARB = 0x882C; + int GL_DRAW_BUFFER8_ARB = 0x882D; + int GL_DRAW_BUFFER9_ARB = 0x882E; + int GL_DRAW_BUFFER10_ARB = 0x882F; + int GL_DRAW_BUFFER11_ARB = 0x8830; + int GL_DRAW_BUFFER12_ARB = 0x8831; + int GL_DRAW_BUFFER13_ARB = 0x8832; + int GL_DRAW_BUFFER14_ARB = 0x8833; + int GL_DRAW_BUFFER15_ARB = 0x8834; + + void glDrawBuffersARB(@AutoSize("buffers") @GLsizei int size, @Const @GLenum IntBuffer buffers); + + @Alternate("glDrawBuffersARB") + void glDrawBuffersARB(@Constant("1") @GLsizei int size, @Constant(value = "APIUtils.getBufferInt().put(0, buffer), 0", keepParam = true) int buffer); +} diff --git a/src/templates/org/lwjgl/opengl/ARB_draw_buffers_blend.java b/src/templates/org/lwjgl/opengl/ARB_draw_buffers_blend.java new file mode 100644 index 0000000..d45400c --- /dev/null +++ b/src/templates/org/lwjgl/opengl/ARB_draw_buffers_blend.java @@ -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.opengl; + +import org.lwjgl.util.generator.GLenum; +import org.lwjgl.util.generator.GLuint; + +public interface ARB_draw_buffers_blend { + + void glBlendEquationiARB(@GLuint int buf, @GLenum int mode); + + void glBlendEquationSeparateiARB(@GLuint int buf, @GLenum int modeRGB, @GLenum int modeAlpha); + + void glBlendFunciARB(@GLuint int buf, @GLenum int src, @GLenum int dst); + + void glBlendFuncSeparateiARB(@GLuint int buf, @GLenum int srcRGB, @GLenum int dstRGB, @GLenum int srcAlpha, @GLenum int dstAlpha); + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/ARB_draw_elements_base_vertex.java b/src/templates/org/lwjgl/opengl/ARB_draw_elements_base_vertex.java new file mode 100644 index 0000000..0024d95 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/ARB_draw_elements_base_vertex.java @@ -0,0 +1,63 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +import java.nio.Buffer; + +public interface ARB_draw_elements_base_vertex { + + void glDrawElementsBaseVertex(@GLenum int mode, @AutoSize("indices") @GLsizei int count, @AutoType("indices") @GLenum int type, + @BufferObject(BufferKind.ElementVBO) + @Const + @GLubyte + @GLushort + @GLuint Buffer indices, int basevertex); + + void glDrawRangeElementsBaseVertex(@GLenum int mode, @GLuint int start, @GLuint int end, @AutoSize("indices") @GLsizei int count, @AutoType("indices") @GLenum int type, + @BufferObject(BufferKind.ElementVBO) + @Const + @GLubyte + @GLushort + @GLuint Buffer indices, int basevertex); + + void glDrawElementsInstancedBaseVertex(@GLenum int mode, @AutoSize("indices") @GLsizei int count, @AutoType("indices") @GLenum int type, + @BufferObject(BufferKind.ElementVBO) + @Const + @GLubyte + @GLushort + @GLuint Buffer indices, @GLsizei int primcount, int basevertex); + + //void glMultiDrawElementsBaseVertex(@GLenum int mode, @GLsizei*count, @GLenum int type, void**indices, @GLsizei int primcount, int*basevertex) + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/ARB_draw_indirect.java b/src/templates/org/lwjgl/opengl/ARB_draw_indirect.java new file mode 100644 index 0000000..86cd3db --- /dev/null +++ b/src/templates/org/lwjgl/opengl/ARB_draw_indirect.java @@ -0,0 +1,61 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +import java.nio.IntBuffer; + +import com.sun.mirror.type.PrimitiveType; + +public interface ARB_draw_indirect { + + /** + * Accepted by the <target> parameters of BindBuffer, BufferData, + * BufferSubData, MapBuffer, UnmapBuffer, GetBufferSubData, + * GetBufferPointerv, MapBufferRange, FlushMappedBufferRange, + * GetBufferParameteriv, BindBufferRange, BindBufferBase, and + * CopyBufferSubData: + */ + int GL_DRAW_INDIRECT_BUFFER = 0x8F3F; + + /** + * Accepted by the <value> parameter of GetIntegerv, GetBooleanv, GetFloatv, + * and GetDoublev: + */ + int GL_DRAW_INDIRECT_BUFFER_BINDING = 0x8F43; + + void glDrawArraysIndirect(@GLenum int mode, @BufferObject(BufferKind.IndirectBO) @Check("4") @NullTerminated @Const @GLvoid(PrimitiveType.Kind.INT) IntBuffer indirect); + + void glDrawElementsIndirect(@GLenum int mode, @GLenum int type, @BufferObject(BufferKind.IndirectBO) @Check("5") @NullTerminated @Const @GLvoid(PrimitiveType.Kind.INT) IntBuffer indirect); + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/ARB_draw_instanced.java b/src/templates/org/lwjgl/opengl/ARB_draw_instanced.java new file mode 100644 index 0000000..6fba717 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/ARB_draw_instanced.java @@ -0,0 +1,49 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +import java.nio.Buffer; + +public interface ARB_draw_instanced { + + void glDrawArraysInstancedARB(@GLenum int mode, int first, @GLsizei int count, @GLsizei int primcount); + + void glDrawElementsInstancedARB(@GLenum int mode, @AutoSize("indices") @GLsizei int count, @AutoType("indices") @GLenum int type, + @BufferObject(BufferKind.ElementVBO) + @Const + @GLubyte + @GLushort + @GLuint Buffer indices, @GLsizei int primcount); + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/ARB_explicit_attrib_location.java b/src/templates/org/lwjgl/opengl/ARB_explicit_attrib_location.java new file mode 100644 index 0000000..07617df --- /dev/null +++ b/src/templates/org/lwjgl/opengl/ARB_explicit_attrib_location.java @@ -0,0 +1,35 @@ +/* + * 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; + +public interface ARB_explicit_attrib_location { +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/ARB_fragment_coord_conventions.java b/src/templates/org/lwjgl/opengl/ARB_fragment_coord_conventions.java new file mode 100644 index 0000000..d4eedab --- /dev/null +++ b/src/templates/org/lwjgl/opengl/ARB_fragment_coord_conventions.java @@ -0,0 +1,35 @@ +/* + * 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; + +public interface ARB_fragment_coord_conventions { +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/ARB_fragment_program.java b/src/templates/org/lwjgl/opengl/ARB_fragment_program.java new file mode 100644 index 0000000..cc767c9 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/ARB_fragment_program.java @@ -0,0 +1,69 @@ +/* + * 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; + +public interface ARB_fragment_program extends ARB_program { + + /** + * Accepted by the <cap> parameter of Disable, Enable, and IsEnabled, by the + * <pname> parameter of GetBooleanv, GetIntegerv, GetFloatv, and GetDoublev, + * and by the <target> parameter of ProgramStringARB, BindProgramARB, + * ProgramEnvParameter4[df][v]ARB, ProgramLocalParameter4[df][v]ARB, + * GetProgramEnvParameter[df]vARB, GetProgramLocalParameter[df]vARB, + * GetProgramivARB and GetProgramStringARB. + */ + int GL_FRAGMENT_PROGRAM_ARB = 0x8804; + + /** + * Accepted by the <pname> parameter of GetProgramivARB: + */ + int GL_PROGRAM_ALU_INSTRUCTIONS_ARB = 0x8805; + int GL_PROGRAM_TEX_INSTRUCTIONS_ARB = 0x8806; + int GL_PROGRAM_TEX_INDIRECTIONS_ARB = 0x8807; + int GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB = 0x8808; + int GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB = 0x8809; + int GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB = 0x880A; + int GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB = 0x880B; + int GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB = 0x880C; + int GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB = 0x880D; + int GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB = 0x880E; + int GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB = 0x880F; + int GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB = 0x8810; + + /** + * Accepted by the <pname> parameter of GetBooleanv, GetIntegerv, GetFloatv, + * and GetDoublev: + */ + int GL_MAX_TEXTURE_COORDS_ARB = 0x8871; + int GL_MAX_TEXTURE_IMAGE_UNITS_ARB = 0x8872; +} + diff --git a/src/templates/org/lwjgl/opengl/ARB_fragment_program_shadow.java b/src/templates/org/lwjgl/opengl/ARB_fragment_program_shadow.java new file mode 100644 index 0000000..1900de0 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/ARB_fragment_program_shadow.java @@ -0,0 +1,36 @@ +/* + * 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; + +public interface ARB_fragment_program_shadow { + +} diff --git a/src/templates/org/lwjgl/opengl/ARB_fragment_shader.java b/src/templates/org/lwjgl/opengl/ARB_fragment_shader.java new file mode 100644 index 0000000..85fb0c2 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/ARB_fragment_shader.java @@ -0,0 +1,55 @@ +/* + * 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; + +public interface ARB_fragment_shader { + + /** + * Accepted by the <shaderType> argument of CreateShaderObjectARB and + * returned by the <params> parameter of GetObjectParameter{fi}vARB: + */ + int GL_FRAGMENT_SHADER_ARB = 0x8B30; + + /** + * Accepted by the <pname> parameter of GetBooleanv, GetIntegerv, + * GetFloatv, and GetDoublev: + */ + int GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB = 0x8B49; + int GL_MAX_TEXTURE_COORDS_ARB = 0x8871; + int GL_MAX_TEXTURE_IMAGE_UNITS_ARB = 0x8872; + + /** + * Accepted by the <target> parameter of Hint and the <pname> parameter of + * GetBooleanv, GetIntegerv, GetFloatv, and GetDoublev: + */ + int GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB = 0x8B8B; +} diff --git a/src/templates/org/lwjgl/opengl/ARB_framebuffer_object.java b/src/templates/org/lwjgl/opengl/ARB_framebuffer_object.java new file mode 100644 index 0000000..51a34f1 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/ARB_framebuffer_object.java @@ -0,0 +1,267 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +import java.nio.IntBuffer; + +@Extension(postfix = "") +public interface ARB_framebuffer_object { + + /** + * Accepted by the <target> parameter of BindFramebuffer, + * CheckFramebufferStatus, FramebufferTexture{1D|2D|3D}, + * FramebufferRenderbuffer, and + * GetFramebufferAttachmentParameteriv: + */ + int GL_FRAMEBUFFER = 0x8D40; + int GL_READ_FRAMEBUFFER = 0x8CA8; + int GL_DRAW_FRAMEBUFFER = 0x8CA9; + + /** + * Accepted by the <target> parameter of BindRenderbuffer, + * RenderbufferStorage, and GetRenderbufferParameteriv, and + * returned by GetFramebufferAttachmentParameteriv: + */ + int GL_RENDERBUFFER = 0x8D41; + + /** + * Accepted by the <internalformat> parameter of + * RenderbufferStorage: + */ + int GL_STENCIL_INDEX1 = 0x8D46; + int GL_STENCIL_INDEX4 = 0x8D47; + int GL_STENCIL_INDEX8 = 0x8D48; + int GL_STENCIL_INDEX16 = 0x8D49; + + /** Accepted by the <pname> parameter of GetRenderbufferParameteriv: */ + int GL_RENDERBUFFER_WIDTH = 0x8D42; + int GL_RENDERBUFFER_HEIGHT = 0x8D43; + int GL_RENDERBUFFER_INTERNAL_FORMAT = 0x8D44; + int GL_RENDERBUFFER_RED_SIZE = 0x8D50; + int GL_RENDERBUFFER_GREEN_SIZE = 0x8D51; + int GL_RENDERBUFFER_BLUE_SIZE = 0x8D52; + int GL_RENDERBUFFER_ALPHA_SIZE = 0x8D53; + int GL_RENDERBUFFER_DEPTH_SIZE = 0x8D54; + int GL_RENDERBUFFER_STENCIL_SIZE = 0x8D55; + int GL_RENDERBUFFER_SAMPLES = 0x8CAB; + + /** + * Accepted by the <pname> parameter of + * GetFramebufferAttachmentParameteriv: + */ + int GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE = 0x8CD0; + int GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME = 0x8CD1; + int GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL = 0x8CD2; + int GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE = 0x8CD3; + int GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER = 0x8CD4; + int GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING = 0x8210; + int GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE = 0x8211; + int GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE = 0x8212; + int GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE = 0x8213; + int GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE = 0x8214; + int GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE = 0x8215; + int GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE = 0x8216; + int GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE = 0x8217; + + /** Returned in <params> by GetFramebufferAttachmentParameteriv: */ + int GL_SRGB = 0x8C40; + int GL_UNSIGNED_NORMALIZED = 0x8C17; + int GL_FRAMEBUFFER_DEFAULT = 0x8218; + int GL_INDEX = 0x8222; + + /** + * Accepted by the <attachment> parameter of + * FramebufferTexture{1D|2D|3D}, FramebufferRenderbuffer, and + * GetFramebufferAttachmentParameteriv + */ + int GL_COLOR_ATTACHMENT0 = 0x8CE0; + int GL_COLOR_ATTACHMENT1 = 0x8CE1; + int GL_COLOR_ATTACHMENT2 = 0x8CE2; + int GL_COLOR_ATTACHMENT3 = 0x8CE3; + int GL_COLOR_ATTACHMENT4 = 0x8CE4; + int GL_COLOR_ATTACHMENT5 = 0x8CE5; + int GL_COLOR_ATTACHMENT6 = 0x8CE6; + int GL_COLOR_ATTACHMENT7 = 0x8CE7; + int GL_COLOR_ATTACHMENT8 = 0x8CE8; + int GL_COLOR_ATTACHMENT9 = 0x8CE9; + int GL_COLOR_ATTACHMENT10 = 0x8CEA; + int GL_COLOR_ATTACHMENT11 = 0x8CEB; + int GL_COLOR_ATTACHMENT12 = 0x8CEC; + int GL_COLOR_ATTACHMENT13 = 0x8CED; + int GL_COLOR_ATTACHMENT14 = 0x8CEE; + int GL_COLOR_ATTACHMENT15 = 0x8CEF; + int GL_DEPTH_ATTACHMENT = 0x8D00; + int GL_STENCIL_ATTACHMENT = 0x8D20; + int GL_DEPTH_STENCIL_ATTACHMENT = 0x821A; + + /** + * Accepted by the <pname> parameter of GetBooleanv, GetIntegerv, + * GetFloatv, and GetDoublev: + */ + int GL_MAX_SAMPLES = 0x8D57; + + /** Returned by CheckFramebufferStatus(): */ + int GL_FRAMEBUFFER_COMPLETE = 0x8CD5; + int GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT = 0x8CD6; + int GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT = 0x8CD7; + int GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER = 0x8CDB; + int GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER = 0x8CDC; + int GL_FRAMEBUFFER_UNSUPPORTED = 0x8CDD; + int GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE = 0x8D56; + int GL_FRAMEBUFFER_UNDEFINED = 0x8219; + + /** + * Accepted by the <pname> parameters of GetIntegerv, GetFloatv, + * and GetDoublev: + */ + int GL_FRAMEBUFFER_BINDING = 0x8CA6; // alias DRAW_FRAMEBUFFER_BINDING + int GL_DRAW_FRAMEBUFFER_BINDING = 0x8CA6; + int GL_READ_FRAMEBUFFER_BINDING = 0x8CAA; + int GL_RENDERBUFFER_BINDING = 0x8CA7; + int GL_MAX_COLOR_ATTACHMENTS = 0x8CDF; + int GL_MAX_RENDERBUFFER_SIZE = 0x84E8; + + /** Returned by GetError(): */ + int GL_INVALID_FRAMEBUFFER_OPERATION = 0x0506; + + /** + * Accepted by the <format> parameter of DrawPixels, ReadPixels, + * TexImage1D, TexImage2D, TexImage3D, TexSubImage1D, TexSubImage2D, + * TexSubImage3D, and GetTexImage, by the <type> parameter of + * CopyPixels, by the <internalformat> parameter of TexImage1D, + * TexImage2D, TexImage3D, CopyTexImage1D, CopyTexImage2D, and + * RenderbufferStorage, and returned in the <data> parameter of + * GetTexLevelParameter and GetRenderbufferParameteriv: + */ + int GL_DEPTH_STENCIL = 0x84F9; + + /** + * Accepted by the <type> parameter of DrawPixels, ReadPixels, + * TexImage1D, TexImage2D, TexImage3D, TexSubImage1D, TexSubImage2D, + * TexSubImage3D, and GetTexImage: + */ + int GL_UNSIGNED_INT_24_8 = 0x84FA; + + /** + * Accepted by the <internalformat> parameter of TexImage1D, + * TexImage2D, TexImage3D, CopyTexImage1D, CopyTexImage2D, and + * RenderbufferStorage, and returned in the <data> parameter of + * GetTexLevelParameter and GetRenderbufferParameteriv: + */ + int GL_DEPTH24_STENCIL8 = 0x88F0; + + /** Accepted by the <value> parameter of GetTexLevelParameter: */ + int GL_TEXTURE_STENCIL_SIZE = 0x88F1; + + boolean glIsRenderbuffer(@GLuint int renderbuffer); + + void glBindRenderbuffer(@GLenum int target, @GLuint int renderbuffer); + + void glDeleteRenderbuffers(@AutoSize("renderbuffers") @GLsizei int n, @Const @GLuint IntBuffer renderbuffers); + + @Alternate("glDeleteRenderbuffers") + void glDeleteRenderbuffers(@Constant("1") @GLsizei int n, @Constant(value = "APIUtils.getBufferInt().put(0, renderbuffer), 0", keepParam = true) int renderbuffer); + + void glGenRenderbuffers(@AutoSize("renderbuffers") @GLsizei int n, @OutParameter @GLuint IntBuffer renderbuffers); + + @Alternate("glGenRenderbuffers") + @GLreturn("renderbuffers") + void glGenRenderbuffers2(@Constant("1") @GLsizei int n, @OutParameter @GLuint IntBuffer renderbuffers); + + void glRenderbufferStorage(@GLenum int target, @GLenum int internalformat, + @GLsizei int width, @GLsizei int height); + + void glRenderbufferStorageMultisample(@GLenum int target, @GLsizei int samples, + @GLenum int internalformat, + @GLsizei int width, @GLsizei int height); + + @StripPostfix("params") + void glGetRenderbufferParameteriv(@GLenum int target, @GLenum int pname, @Check("4") @OutParameter IntBuffer params); + + @Alternate("glGetRenderbufferParameteriv") + @GLreturn("params") + @StripPostfix("params") + void glGetRenderbufferParameteriv2(@GLenum int target, @GLenum int pname, @OutParameter IntBuffer params); + + boolean glIsFramebuffer(@GLuint int framebuffer); + + void glBindFramebuffer(@GLenum int target, @GLuint int framebuffer); + + void glDeleteFramebuffers(@AutoSize("framebuffers") @GLsizei int n, @Const @GLuint IntBuffer framebuffers); + + @Alternate("glDeleteFramebuffers") + void glDeleteFramebuffers(@Constant("1") @GLsizei int n, @Constant(value = "APIUtils.getBufferInt().put(0, framebuffer), 0", keepParam = true) int framebuffer); + + void glGenFramebuffers(@AutoSize("framebuffers") @GLsizei int n, @OutParameter @GLuint IntBuffer framebuffers); + + @Alternate("glGenFramebuffers") + @GLreturn("framebuffers") + void glGenFramebuffers2(@Constant("1") @GLsizei int n, @OutParameter @GLuint IntBuffer framebuffers); + + @GLenum + int glCheckFramebufferStatus(@GLenum int target); + + void glFramebufferTexture1D(@GLenum int target, @GLenum int attachment, + @GLenum int textarget, @GLuint int texture, int level); + + void glFramebufferTexture2D(@GLenum int target, @GLenum int attachment, + @GLenum int textarget, @GLuint int texture, int level); + + void glFramebufferTexture3D(@GLenum int target, @GLenum int attachment, + @GLenum int textarget, @GLuint int texture, + int level, int layer); + + void glFramebufferTextureLayer(@GLenum int target, @GLenum int attachment, + @GLuint int texture, int level, int layer); + + void glFramebufferRenderbuffer(@GLenum int target, @GLenum int attachment, + @GLenum int renderbuffertarget, @GLuint int renderbuffer); + + @StripPostfix("params") + void glGetFramebufferAttachmentParameteriv(@GLenum int target, @GLenum int attachment, + @GLenum int pname, @Check("4") @OutParameter IntBuffer params); + + @Alternate("glGetFramebufferAttachmentParameteriv") + @GLreturn("params") + @StripPostfix("params") + void glGetFramebufferAttachmentParameteriv2(@GLenum int target, @GLenum int attachment, + @GLenum int pname, @OutParameter IntBuffer params); + + void glBlitFramebuffer(int srcX0, int srcY0, int srcX1, int srcY1, + int dstX0, int dstY0, int dstX1, int dstY1, + @GLbitfield int mask, @GLenum int filter); + + void glGenerateMipmap(@GLenum int target); + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/ARB_framebuffer_sRGB.java b/src/templates/org/lwjgl/opengl/ARB_framebuffer_sRGB.java new file mode 100644 index 0000000..7fa659c --- /dev/null +++ b/src/templates/org/lwjgl/opengl/ARB_framebuffer_sRGB.java @@ -0,0 +1,62 @@ +/* + * 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; + +public interface ARB_framebuffer_sRGB { + + /** + * Accepted by the <attribList> parameter of glXChooseVisual, and by + * the <attrib> parameter of glXGetConfig: + */ + int GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB = 0x20B2; + + /** + * Accepted by the <piAttributes> parameter of + * wglGetPixelFormatAttribivEXT, wglGetPixelFormatAttribfvEXT, and + * the <piAttribIList> and <pfAttribIList> of wglChoosePixelFormatEXT: + */ + int WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB = 0x20A9; + + /** + * Accepted by the <cap> parameter of Enable, Disable, and IsEnabled, + * and by the <pname> parameter of GetBooleanv, GetIntegerv, GetFloatv, + * and GetDoublev: + */ + int GL_FRAMEBUFFER_SRGB_ARB = 0x8DB9; + + /** + * Accepted by the <pname> parameter of GetBooleanv, GetIntegerv, + * GetFloatv, and GetDoublev: + */ + int GL_FRAMEBUFFER_SRGB_CAPABLE_ARB = 0x8DBA; + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/ARB_geometry_shader4.java b/src/templates/org/lwjgl/opengl/ARB_geometry_shader4.java new file mode 100644 index 0000000..286439f --- /dev/null +++ b/src/templates/org/lwjgl/opengl/ARB_geometry_shader4.java @@ -0,0 +1,101 @@ +/* + * 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; + +import org.lwjgl.util.generator.GLenum; +import org.lwjgl.util.generator.GLuint; + +public interface ARB_geometry_shader4 { + + /** + * Accepted by the <type> parameter of CreateShader and returned by the + * <params> parameter of GetShaderiv: + */ + int GL_GEOMETRY_SHADER_ARB = 0x8DD9; + + /** + * Accepted by the <pname> parameter of ProgramParameteriEXT and + * GetProgramiv: + */ + int GL_GEOMETRY_VERTICES_OUT_ARB = 0x8DDA; + int GL_GEOMETRY_INPUT_TYPE_ARB = 0x8DDB; + int GL_GEOMETRY_OUTPUT_TYPE_ARB = 0x8DDC; + + /** + * Accepted by the <pname> parameter of GetBooleanv, GetIntegerv, + * GetFloatv, and GetDoublev: + */ + int GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_ARB = 0x8C29; + int GL_MAX_GEOMETRY_VARYING_COMPONENTS_ARB = 0x8DDD; + int GL_MAX_VERTEX_VARYING_COMPONENTS_ARB = 0x8DDE; + int GL_MAX_VARYING_COMPONENTS_ARB = 0x8B4B; + int GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_ARB = 0x8DDF; + int GL_MAX_GEOMETRY_OUTPUT_VERTICES_ARB = 0x8DE0; + int GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_ARB = 0x8DE1; + + /** + * Accepted by the <mode> parameter of Begin, DrawArrays, + * MultiDrawArrays, DrawElements, MultiDrawElements, and + * DrawRangeElements: + */ + int GL_LINES_ADJACENCY_ARB = 0xA; + int GL_LINE_STRIP_ADJACENCY_ARB = 0xB; + int GL_TRIANGLES_ADJACENCY_ARB = 0xC; + int GL_TRIANGLE_STRIP_ADJACENCY_ARB = 0xD; + + /** Returned by CheckFramebufferStatusEXT: */ + int GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_ARB = 0x8DA8; + int GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_ARB = 0x8DA9; + + /** + * Accepted by the <pname> parameter of GetFramebufferAttachment- + * ParameterivEXT: + */ + int GL_FRAMEBUFFER_ATTACHMENT_LAYERED_ARB = 0x8DA7; + int GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_ARB = 0x8CD4; + + /** + * Accepted by the <cap> parameter of Enable, Disable, and IsEnabled, + * and by the <pname> parameter of GetIntegerv, GetFloatv, GetDoublev, + * and GetBooleanv: + */ + int GL_PROGRAM_POINT_SIZE_ARB = 0x8642; + + void glProgramParameteriARB(@GLuint int program, @GLenum int pname, int value); + + void glFramebufferTextureARB(@GLenum int target, @GLenum int attachment, @GLuint int texture, int level); + + void glFramebufferTextureLayerARB(@GLenum int target, @GLenum int attachment, @GLuint int texture, int level, int layer); + + void glFramebufferTextureFaceARB(@GLenum int target, @GLenum int attachment, @GLuint int texture, int level, @GLenum int face); + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/ARB_gpu_shader5.java b/src/templates/org/lwjgl/opengl/ARB_gpu_shader5.java new file mode 100644 index 0000000..7f2a031 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/ARB_gpu_shader5.java @@ -0,0 +1,49 @@ +/* + * 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; + +public interface ARB_gpu_shader5 { + + /** Accepted by the <pname> parameter of GetProgramiv: */ + int GL_GEOMETRY_SHADER_INVOCATIONS = 0x887F; + + /** + * Accepted by the <pname> parameter of GetBooleanv, GetIntegerv, GetFloatv, + * GetDoublev, and GetInteger64v: + */ + int GL_MAX_GEOMETRY_SHADER_INVOCATIONS = 0x8E5A; + int GL_MIN_FRAGMENT_INTERPOLATION_OFFSET = 0x8E5B; + int GL_MAX_FRAGMENT_INTERPOLATION_OFFSET = 0x8E5C; + int GL_FRAGMENT_INTERPOLATION_OFFSET_BITS = 0x8E5D; + int GL_MAX_VERTEX_STREAMS = 0x8E71; + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/ARB_gpu_shader_fp64.java b/src/templates/org/lwjgl/opengl/ARB_gpu_shader_fp64.java new file mode 100644 index 0000000..10557d4 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/ARB_gpu_shader_fp64.java @@ -0,0 +1,176 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +import java.nio.*; + +@Dependent +@Extension(postfix = "") +public interface ARB_gpu_shader_fp64 { + + /** + * Returned in the <type> parameter of GetActiveUniform, and + * GetTransformFeedbackVarying: + */ + int GL_DOUBLE = GL11.GL_DOUBLE; + int GL_DOUBLE_VEC2 = 0x8FFC; + int GL_DOUBLE_VEC3 = 0x8FFD; + int GL_DOUBLE_VEC4 = 0x8FFE; + int GL_DOUBLE_MAT2 = 0x8F46; + int GL_DOUBLE_MAT3 = 0x8F47; + int GL_DOUBLE_MAT4 = 0x8F48; + int GL_DOUBLE_MAT2x3 = 0x8F49; + int GL_DOUBLE_MAT2x4 = 0x8F4A; + int GL_DOUBLE_MAT3x2 = 0x8F4B; + int GL_DOUBLE_MAT3x4 = 0x8F4C; + int GL_DOUBLE_MAT4x2 = 0x8F4D; + int GL_DOUBLE_MAT4x3 = 0x8F4E; + + void glUniform1d(int location, double x); + + void glUniform2d(int location, double x, double y); + + void glUniform3d(int location, double x, double y, double z); + + void glUniform4d(int location, double x, double y, double z, double w); + + @StripPostfix("value") + void glUniform1dv(int location, @AutoSize("value") @GLsizei int count, @Const DoubleBuffer value); + + @StripPostfix("value") + void glUniform2dv(int location, @AutoSize(value = "value", expression = " >> 1") @GLsizei int count, @Const DoubleBuffer value); + + @StripPostfix("value") + void glUniform3dv(int location, @AutoSize(value = "value", expression = " / 3") @GLsizei int count, @Const DoubleBuffer value); + + @StripPostfix("value") + void glUniform4dv(int location, @AutoSize(value = "value", expression = " >> 2") @GLsizei int count, @Const DoubleBuffer value); + + @StripPostfix("value") + void glUniformMatrix2dv(int location, @AutoSize(value = "value", expression = " >> 2") @GLsizei int count, boolean transpose, @Const DoubleBuffer value); + + @StripPostfix("value") + void glUniformMatrix3dv(int location, @AutoSize(value = "value", expression = " / (3 * 3)") @GLsizei int count, boolean transpose, @Const DoubleBuffer value); + + @StripPostfix("value") + void glUniformMatrix4dv(int location, @AutoSize(value = "value", expression = " >> 4") @GLsizei int count, boolean transpose, @Const DoubleBuffer value); + + @StripPostfix("value") + void glUniformMatrix2x3dv(int location, @AutoSize(value = "value", expression = " / (2 * 3)") @GLsizei int count, boolean transpose, @Const DoubleBuffer value); + + @StripPostfix("value") + void glUniformMatrix2x4dv(int location, @AutoSize(value = "value", expression = " >> 3") @GLsizei int count, boolean transpose, @Const DoubleBuffer value); + + @StripPostfix("value") + void glUniformMatrix3x2dv(int location, @AutoSize(value = "value", expression = " / (3 * 2)") @GLsizei int count, boolean transpose, @Const DoubleBuffer value); + + @StripPostfix("value") + void glUniformMatrix3x4dv(int location, @AutoSize(value = "value", expression = " / (3 * 4)") @GLsizei int count, boolean transpose, @Const DoubleBuffer value); + + @StripPostfix("value") + void glUniformMatrix4x2dv(int location, @AutoSize(value = "value", expression = " >> 3") @GLsizei int count, boolean transpose, @Const DoubleBuffer value); + + @StripPostfix("value") + void glUniformMatrix4x3dv(int location, @AutoSize(value = "value", expression = " / (4 * 3)") @GLsizei int count, boolean transpose, @Const DoubleBuffer value); + + @StripPostfix("params") + void glGetUniformdv(@GLuint int program, int location, @OutParameter @Check DoubleBuffer params); + + // ---- + + @Dependent("GL_EXT_direct_state_access") + void glProgramUniform1dEXT(@GLuint int program, int location, double x); + + @Dependent("GL_EXT_direct_state_access") + void glProgramUniform2dEXT(@GLuint int program, int location, double x, double y); + + @Dependent("GL_EXT_direct_state_access") + void glProgramUniform3dEXT(@GLuint int program, int location, double x, double y, double z); + + @Dependent("GL_EXT_direct_state_access") + void glProgramUniform4dEXT(@GLuint int program, int location, double x, double y, double z, double w); + + @Dependent("GL_EXT_direct_state_access") + @StripPostfix(value="value", extension="EXT") + void glProgramUniform1dvEXT(@GLuint int program, int location, @AutoSize(value = "value") @GLsizei int count, @Const DoubleBuffer value); + + @Dependent("GL_EXT_direct_state_access") + @StripPostfix(value = "value", extension = "EXT") + void glProgramUniform2dvEXT(@GLuint int program, int location, @AutoSize(value = "value", expression = " >> 1") @GLsizei int count, @Const DoubleBuffer value); + + @Dependent("GL_EXT_direct_state_access") + @StripPostfix(value = "value", extension = "EXT") + void glProgramUniform3dvEXT(@GLuint int program, int location, @AutoSize(value = "value", expression = " / 3") @GLsizei int count, @Const DoubleBuffer value); + + @Dependent("GL_EXT_direct_state_access") + @StripPostfix(value = "value", extension = "EXT") + void glProgramUniform4dvEXT(@GLuint int program, int location, @AutoSize(value = "value", expression = " >> 2") @GLsizei int count, @Const DoubleBuffer value); + + @Dependent("GL_EXT_direct_state_access") + @StripPostfix(value = "value", extension = "EXT") + void glProgramUniformMatrix2dvEXT(@GLuint int program, int location, @AutoSize(value = "value", expression = " >> 2") @GLsizei int count, boolean transpose, @Const DoubleBuffer value); + + @Dependent("GL_EXT_direct_state_access") + @StripPostfix(value = "value", extension = "EXT") + void glProgramUniformMatrix3dvEXT(@GLuint int program, int location, @AutoSize(value = "value", expression = " / (3 * 3)") @GLsizei int count, boolean transpose, @Const DoubleBuffer value); + + @Dependent("GL_EXT_direct_state_access") + @StripPostfix(value = "value", extension = "EXT") + void glProgramUniformMatrix4dvEXT(@GLuint int program, int location, @AutoSize(value = "value", expression = " >> 4") @GLsizei int count, boolean transpose, @Const DoubleBuffer value); + + @Dependent("GL_EXT_direct_state_access") + @StripPostfix(value = "value", extension = "EXT") + void glProgramUniformMatrix2x3dvEXT(@GLuint int program, int location, @AutoSize(value = "value", expression = " / (2 * 3)") @GLsizei int count, boolean transpose, @Const DoubleBuffer value); + + @Dependent("GL_EXT_direct_state_access") + @StripPostfix(value = "value", extension = "EXT") + void glProgramUniformMatrix2x4dvEXT(@GLuint int program, int location, @AutoSize(value = "value", expression = " >> 3") @GLsizei int count, boolean transpose, @Const DoubleBuffer value); + + @Dependent("GL_EXT_direct_state_access") + @StripPostfix(value = "value", extension = "EXT") + void glProgramUniformMatrix3x2dvEXT(@GLuint int program, int location, @AutoSize(value = "value", expression = " / (3 * 2)") @GLsizei int count, boolean transpose, @Const DoubleBuffer value); + + @Dependent("GL_EXT_direct_state_access") + @StripPostfix(value = "value", extension = "EXT") + void glProgramUniformMatrix3x4dvEXT(@GLuint int program, int location, @AutoSize(value = "value", expression = " / (3 * 4)") @GLsizei int count, boolean transpose, @Const DoubleBuffer value); + + @Dependent("GL_EXT_direct_state_access") + @StripPostfix(value = "value", extension = "EXT") + void glProgramUniformMatrix4x2dvEXT(@GLuint int program, int location, @AutoSize(value = "value", expression = " >> 3") @GLsizei int count, boolean transpose, @Const DoubleBuffer value); + + @Dependent("GL_EXT_direct_state_access") + @StripPostfix(value = "value", extension = "EXT") + void glProgramUniformMatrix4x3dvEXT(@GLuint int program, int location, @AutoSize(value = "value", expression = " / (4 * 3)") @GLsizei int count, boolean transpose, @Const DoubleBuffer value); + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/ARB_half_float_pixel.java b/src/templates/org/lwjgl/opengl/ARB_half_float_pixel.java new file mode 100644 index 0000000..8aaca95 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/ARB_half_float_pixel.java @@ -0,0 +1,45 @@ +/* + * 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; + +public interface ARB_half_float_pixel { + + /** + * Accepted by the <type> parameter of DrawPixels, ReadPixels, + * TexImage1D, TexImage2D, TexImage3D, GetTexImage, TexSubImage1D, + * TexSubImage2D, TexSubImage3D, GetHistogram, GetMinmax, + * ConvolutionFilter1D, ConvolutionFilter2D, GetConvolutionFilter, + * SeparableFilter2D, GetSeparableFilter, ColorTable, ColorSubTable, + * and GetColorTable: + */ + int GL_HALF_FLOAT_ARB = 0x140B; +} diff --git a/src/templates/org/lwjgl/opengl/ARB_half_float_vertex.java b/src/templates/org/lwjgl/opengl/ARB_half_float_vertex.java new file mode 100644 index 0000000..9838535 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/ARB_half_float_vertex.java @@ -0,0 +1,43 @@ +/* + * 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; + +public interface ARB_half_float_vertex { + + /** + * Accepted by the <type> argument of VertexPointer, NormalPointer, + * ColorPointer, SecondaryColorPointer, FogCoordPointer, TexCoordPointer, + * and VertexAttribPointer: + */ + int GL_HALF_FLOAT = 0x140B; + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/ARB_imaging.java b/src/templates/org/lwjgl/opengl/ARB_imaging.java new file mode 100644 index 0000000..1f0a3e8 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/ARB_imaging.java @@ -0,0 +1,333 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +import java.nio.*; + +/** + *

    + * The GL12 imaging subset extension. + * + * @author cix_foo + * @version $Revision: 3116 $ + * $Id: ARB_imaging.java 3116 2008-08-19 16:46:03Z spasi $ + */ + +@Extension(postfix = "") +@DeprecatedGL +public interface ARB_imaging { + + int GL_CONSTANT_COLOR = 0x8001; + int GL_ONE_MINUS_CONSTANT_COLOR = 0x8002; + int GL_CONSTANT_ALPHA = 0x8003; + int GL_ONE_MINUS_CONSTANT_ALPHA = 0x8004; + int GL_BLEND_COLOR = 0x8005; + int GL_FUNC_ADD = 0x8006; + int GL_MIN = 0x8007; + int GL_MAX = 0x8008; + int GL_BLEND_EQUATION = 0x8009; + int GL_FUNC_SUBTRACT = 0x800A; + int GL_FUNC_REVERSE_SUBTRACT = 0x800B; + int GL_COLOR_MATRIX = 0x80B1; + int GL_COLOR_MATRIX_STACK_DEPTH = 0x80B2; + int GL_MAX_COLOR_MATRIX_STACK_DEPTH = 0x80B3; + int GL_POST_COLOR_MATRIX_RED_SCALE = 0x80B4; + int GL_POST_COLOR_MATRIX_GREEN_SCALE = 0x80B5; + int GL_POST_COLOR_MATRIX_BLUE_SCALE = 0x80B6; + int GL_POST_COLOR_MATRIX_ALPHA_SCALE = 0x80B7; + int GL_POST_COLOR_MATRIX_RED_BIAS = 0x80B8; + int GL_POST_COLOR_MATRIX_GREEN_BIAS = 0x80B9; + int GL_POST_COLOR_MATRIX_BLUE_BIAS = 0x80BA; + int GL_POST_COLOR_MATRIX_ALPHA_BIAS = 0x80BB; + int GL_COLOR_TABLE = 0x80D0; + int GL_POST_CONVOLUTION_COLOR_TABLE = 0x80D1; + int GL_POST_COLOR_MATRIX_COLOR_TABLE = 0x80D2; + int GL_PROXY_COLOR_TABLE = 0x80D3; + int GL_PROXY_POST_CONVOLUTION_COLOR_TABLE = 0x80D4; + int GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE = 0x80D5; + int GL_COLOR_TABLE_SCALE = 0x80D6; + int GL_COLOR_TABLE_BIAS = 0x80D7; + int GL_COLOR_TABLE_FORMAT = 0x80D8; + int GL_COLOR_TABLE_WIDTH = 0x80D9; + int GL_COLOR_TABLE_RED_SIZE = 0x80DA; + int GL_COLOR_TABLE_GREEN_SIZE = 0x80DB; + int GL_COLOR_TABLE_BLUE_SIZE = 0x80DC; + int GL_COLOR_TABLE_ALPHA_SIZE = 0x80DD; + int GL_COLOR_TABLE_LUMINANCE_SIZE = 0x80DE; + int GL_COLOR_TABLE_INTENSITY_SIZE = 0x80DF; + int GL_CONVOLUTION_1D = 0x8010; + int GL_CONVOLUTION_2D = 0x8011; + int GL_SEPARABLE_2D = 0x8012; + int GL_CONVOLUTION_BORDER_MODE = 0x8013; + int GL_CONVOLUTION_FILTER_SCALE = 0x8014; + int GL_CONVOLUTION_FILTER_BIAS = 0x8015; + int GL_REDUCE = 0x8016; + int GL_CONVOLUTION_FORMAT = 0x8017; + int GL_CONVOLUTION_WIDTH = 0x8018; + int GL_CONVOLUTION_HEIGHT = 0x8019; + int GL_MAX_CONVOLUTION_WIDTH = 0x801A; + int GL_MAX_CONVOLUTION_HEIGHT = 0x801B; + int GL_POST_CONVOLUTION_RED_SCALE = 0x801C; + int GL_POST_CONVOLUTION_GREEN_SCALE = 0x801D; + int GL_POST_CONVOLUTION_BLUE_SCALE = 0x801E; + int GL_POST_CONVOLUTION_ALPHA_SCALE = 0x801F; + int GL_POST_CONVOLUTION_RED_BIAS = 0x8020; + int GL_POST_CONVOLUTION_GREEN_BIAS = 0x8021; + int GL_POST_CONVOLUTION_BLUE_BIAS = 0x8022; + int GL_POST_CONVOLUTION_ALPHA_BIAS = 0x8023; + int GL_IGNORE_BORDER = 0x8150; + int GL_CONSTANT_BORDER = 0x8151; + int GL_REPLICATE_BORDER = 0x8153; + int GL_CONVOLUTION_BORDER_COLOR = 0x8154; + int GL_HISTOGRAM = 0x8024; + int GL_PROXY_HISTOGRAM = 0x8025; + int GL_HISTOGRAM_WIDTH = 0x8026; + int GL_HISTOGRAM_FORMAT = 0x8027; + int GL_HISTOGRAM_RED_SIZE = 0x8028; + int GL_HISTOGRAM_GREEN_SIZE = 0x8029; + int GL_HISTOGRAM_BLUE_SIZE = 0x802A; + int GL_HISTOGRAM_ALPHA_SIZE = 0x802B; + int GL_HISTOGRAM_LUMINANCE_SIZE = 0x802C; + int GL_HISTOGRAM_SINK = 0x802D; + int GL_MINMAX = 0x802E; + int GL_MINMAX_FORMAT = 0x802F; + int GL_MINMAX_SINK = 0x8030; + int GL_TABLE_TOO_LARGE = 0x8031; + + @DeprecatedGL + void glColorTable(@GLenum int target, @GLenum int internalFormat, @GLsizei int width, @GLenum int format, @GLenum int type, + @BufferObject(BufferKind.UnpackPBO) + @Check("256") + @Const + @GLbyte + @GLfloat + @GLdouble Buffer data); + + @DeprecatedGL + void glColorSubTable(@GLenum int target, @GLsizei int start, @GLsizei int count, @GLenum int format, @GLenum int type, + @BufferObject(BufferKind.UnpackPBO) + @Check("256") + @Const + @GLbyte + @GLfloat + @GLdouble Buffer data); + + @StripPostfix("params") + @DeprecatedGL + void glColorTableParameteriv(@GLenum int target, @GLenum int pname, @Check("4") @Const IntBuffer params); + + @StripPostfix("params") + @DeprecatedGL + void glColorTableParameterfv(@GLenum int target, @GLenum int pname, @Check("4") @Const FloatBuffer params); + + @DeprecatedGL + void glCopyColorSubTable(@GLenum int target, @GLsizei int start, int x, int y, @GLsizei int width); + + @DeprecatedGL + void glCopyColorTable(@GLenum int target, @GLenum int internalformat, int x, int y, @GLsizei int width); + + @DeprecatedGL + void glGetColorTable(@GLenum int target, @GLenum int format, @GLenum int type, + @OutParameter + @Check("256") + @GLbyte + @GLfloat + @GLdouble Buffer data); + + @StripPostfix("params") + @DeprecatedGL + void glGetColorTableParameteriv(@GLenum int target, @GLenum int pname, @Check("4") IntBuffer params); + + @StripPostfix("params") + @DeprecatedGL + void glGetColorTableParameterfv(@GLenum int target, @GLenum int pname, @Check("4") FloatBuffer params); + + void glBlendEquation(@GLenum int mode); + + void glBlendColor(@GLclampf float red, @GLclampf float green, @GLclampf float blue, @GLclampf float alpha); + + @DeprecatedGL + void glHistogram(@GLenum int target, @GLsizei int width, @GLenum int internalformat, boolean sink); + + @DeprecatedGL + void glResetHistogram(@GLenum int target); + + @DeprecatedGL + void glGetHistogram(@GLenum int target, boolean reset, @GLenum int format, @GLenum int type, + @OutParameter + @BufferObject(BufferKind.PackPBO) + @Check("256") + @GLbyte + @GLshort + @GLint + @GLfloat + @GLdouble Buffer values); + + @StripPostfix("params") + @DeprecatedGL + void glGetHistogramParameterfv(@GLenum int target, @GLenum int pname, @OutParameter @Check("256") FloatBuffer params); + + @StripPostfix("params") + @DeprecatedGL + void glGetHistogramParameteriv(@GLenum int target, @GLenum int pname, @OutParameter @Check("256") IntBuffer params); + + @DeprecatedGL + void glMinmax(@GLenum int target, @GLenum int internalformat, boolean sink); + + @DeprecatedGL + void glResetMinmax(@GLenum int target); + + @DeprecatedGL + void glGetMinmax(@GLenum int target, boolean reset, @GLenum int format, @GLenum int types, + @OutParameter + @BufferObject(BufferKind.PackPBO) + @Check("4") + @GLbyte + @GLshort + @GLint + @GLfloat + @GLdouble Buffer values); + + @StripPostfix("params") + @DeprecatedGL + void glGetMinmaxParameterfv(@GLenum int target, @GLenum int pname, @OutParameter @Check("4") FloatBuffer params); + + @StripPostfix("params") + @DeprecatedGL + void glGetMinmaxParameteriv(@GLenum int target, @GLenum int pname, @OutParameter @Check("4") IntBuffer params); + + @DeprecatedGL + void glConvolutionFilter1D(@GLenum int target, @GLenum int internalformat, @GLsizei int width, @GLenum int format, @GLenum int type, + @BufferObject(BufferKind.UnpackPBO) + @Check("GLChecks.calculateImageStorage(image, format, type, width, 1, 1)") + @Const + @GLbyte + @GLshort + @GLint + @GLfloat + @GLdouble Buffer image); + + @DeprecatedGL + void glConvolutionFilter2D(@GLenum int target, @GLenum int internalformat, @GLsizei int width, @GLsizei int height, @GLenum int format, @GLenum int type, + @BufferObject(BufferKind.UnpackPBO) + @Check("GLChecks.calculateImageStorage(image, format, type, width, height, 1)") + @Const + @GLbyte + @GLshort + @GLint Buffer image); + + @DeprecatedGL + void glConvolutionParameterf(@GLenum int target, @GLenum int pname, float params); + + @StripPostfix("params") + @DeprecatedGL + void glConvolutionParameterfv(@GLenum int target, @GLenum int pname, @Check("4") @Const FloatBuffer params); + + @DeprecatedGL + void glConvolutionParameteri(@GLenum int target, @GLenum int pname, int params); + + @StripPostfix("params") + @DeprecatedGL + void glConvolutionParameteriv(@GLenum int target, @GLenum int pname, @Check("4") @Const IntBuffer params); + + @DeprecatedGL + void glCopyConvolutionFilter1D(@GLenum int target, @GLenum int internalformat, int x, int y, @GLsizei int width); + + @DeprecatedGL + void glCopyConvolutionFilter2D(@GLenum int target, @GLenum int internalformat, int x, int y, @GLsizei int width, @GLsizei int height); + + // TODO: check buffer size valid + @DeprecatedGL + void glGetConvolutionFilter(@GLenum int target, @GLenum int format, @GLenum int type, + @OutParameter + @BufferObject(BufferKind.PackPBO) + @Check + @GLbyte + @GLshort + @GLint + @GLfloat + @GLdouble Buffer image); + + @StripPostfix("params") + @DeprecatedGL + void glGetConvolutionParameterfv(@GLenum int target, @GLenum int pname, @OutParameter @Check("4") FloatBuffer params); + + @StripPostfix("params") + @DeprecatedGL + void glGetConvolutionParameteriv(@GLenum int target, @GLenum int pname, @OutParameter @Check("4") IntBuffer params); + + // TODO: check buffer size valid + @DeprecatedGL + void glSeparableFilter2D(@GLenum int target, @GLenum int internalformat, @GLsizei int width, @GLsizei int height, @GLenum int format, @GLenum int type, + @BufferObject(BufferKind.UnpackPBO) + @Check + @Const + @GLbyte + @GLshort + @GLint + @GLfloat + @GLdouble Buffer row, + @BufferObject(BufferKind.UnpackPBO) + @Check + @Const + @GLbyte + @GLshort + @GLint + @GLfloat + @GLdouble Buffer column); + + // TODO: check buffer size valid + @DeprecatedGL + void glGetSeparableFilter(@GLenum int target, @GLenum int format, @GLenum int type, + @OutParameter + @BufferObject(BufferKind.PackPBO) + @Check + @GLbyte + @GLshort + @GLint + @GLfloat + @GLdouble Buffer row, + @BufferObject(BufferKind.PackPBO) + @Check + @GLbyte + @GLshort + @GLint + @GLdouble Buffer column, + @BufferObject(BufferKind.PackPBO) + @Check + @GLbyte + @GLshort + @GLint + @GLdouble Buffer span); +} diff --git a/src/templates/org/lwjgl/opengl/ARB_instanced_arrays.java b/src/templates/org/lwjgl/opengl/ARB_instanced_arrays.java new file mode 100644 index 0000000..24912c6 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/ARB_instanced_arrays.java @@ -0,0 +1,46 @@ +/* + * 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; + +import org.lwjgl.util.generator.GLuint; + +public interface ARB_instanced_arrays { + + /** + * Accepted by the <pname> parameters of GetVertexAttribdv, + * GetVertexAttribfv, and GetVertexAttribiv: + */ + int GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ARB = 0x88FE; + + void glVertexAttribDivisorARB(@GLuint int index, @GLuint int divisor); + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/ARB_map_buffer_range.java b/src/templates/org/lwjgl/opengl/ARB_map_buffer_range.java new file mode 100644 index 0000000..f99b4be --- /dev/null +++ b/src/templates/org/lwjgl/opengl/ARB_map_buffer_range.java @@ -0,0 +1,69 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +import java.nio.ByteBuffer; + +public interface ARB_map_buffer_range { + + /** Accepted by the <access> parameter of MapBufferRange: */ + int GL_MAP_READ_BIT = 0x0001; + int GL_MAP_WRITE_BIT = 0x0002; + int GL_MAP_INVALIDATE_RANGE_BIT = 0x0004; + int GL_MAP_INVALIDATE_BUFFER_BIT = 0x0008; + int GL_MAP_FLUSH_EXPLICIT_BIT = 0x0010; + int GL_MAP_UNSYNCHRONIZED_BIT = 0x0020; + + /** + * glMapBufferRange maps a GL buffer object range to a ByteBuffer. The old_buffer argument can be null, + * in which case a new ByteBuffer will be created, pointing to the returned memory. If old_buffer is non-null, + * it will be returned if it points to the same mapped memory and has the same capacity as the buffer object, + * otherwise a new ByteBuffer is created. That way, an application will normally use glMapBufferRange like this: + *

    + * ByteBuffer mapped_buffer; mapped_buffer = glMapBufferRange(..., ..., ..., ..., null); ... // Another map on the same buffer mapped_buffer = glMapBufferRange(..., ..., ..., ..., mapped_buffer); + *

    + * Only ByteBuffers returned from this method are to be passed as the old_buffer argument. User-created ByteBuffers cannot be reused. + * + * @param old_buffer A ByteBuffer. If this argument points to the same address and has the same capacity as the new mapping, it will be returned and no new buffer will be created. + * + * @return A ByteBuffer representing the mapped buffer memory. + */ + @CachedResult(isRange = true) + @GLvoid + @AutoResultSize("length") + ByteBuffer glMapBufferRange(@GLenum int target, @GLintptr long offset, @GLsizeiptr long length, @GLbitfield int access); + + void glFlushMappedBufferRange(@GLenum int target, @GLintptr long offset, @GLsizeiptr long length); + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/ARB_matrix_palette.java b/src/templates/org/lwjgl/opengl/ARB_matrix_palette.java new file mode 100644 index 0000000..8e76906 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/ARB_matrix_palette.java @@ -0,0 +1,70 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +import java.nio.*; + +public interface ARB_matrix_palette { + + int GL_MATRIX_PALETTE_ARB = 0x8840; + int GL_MAX_MATRIX_PALETTE_STACK_DEPTH_ARB = 0x8841; + int GL_MAX_PALETTE_MATRICES_ARB = 0x8842; + int GL_CURRENT_PALETTE_MATRIX_ARB = 0x8843; + int GL_MATRIX_INDEX_ARRAY_ARB = 0x8844; + int GL_CURRENT_MATRIX_INDEX_ARB = 0x8845; + int GL_MATRIX_INDEX_ARRAY_SIZE_ARB = 0x8846; + int GL_MATRIX_INDEX_ARRAY_TYPE_ARB = 0x8847; + int GL_MATRIX_INDEX_ARRAY_STRIDE_ARB = 0x8848; + int GL_MATRIX_INDEX_ARRAY_POINTER_ARB = 0x8849; + + void glCurrentPaletteMatrixARB(int index); + + void glMatrixIndexPointerARB(int size, @AutoType("pPointer") @GLenum int type, @GLsizei int stride, + @CachedReference + @BufferObject(BufferKind.ArrayVBO) + @Check + @Const + @GLubyte + @GLushort + @GLuint Buffer pPointer); + + @StripPostfix("pIndices") + void glMatrixIndexubvARB(@AutoSize("pIndices") int size, @GLubyte ByteBuffer pIndices); + + @StripPostfix("pIndices") + void glMatrixIndexusvARB(@AutoSize("pIndices") int size, @GLushort ShortBuffer pIndices); + + @StripPostfix("pIndices") + void glMatrixIndexuivARB(@AutoSize("pIndices") int size, @GLuint IntBuffer pIndices); +} diff --git a/src/templates/org/lwjgl/opengl/ARB_multisample.java b/src/templates/org/lwjgl/opengl/ARB_multisample.java new file mode 100644 index 0000000..12cfeb2 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/ARB_multisample.java @@ -0,0 +1,49 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +public interface ARB_multisample { + + int GL_MULTISAMPLE_ARB = 0x809D; + int GL_SAMPLE_ALPHA_TO_COVERAGE_ARB = 0x809E; + int GL_SAMPLE_ALPHA_TO_ONE_ARB = 0x809F; + int GL_SAMPLE_COVERAGE_ARB = 0x80A0; + int GL_SAMPLE_BUFFERS_ARB = 0x80A8; + int GL_SAMPLES_ARB = 0x80A9; + int GL_SAMPLE_COVERAGE_VALUE_ARB = 0x80AA; + int GL_SAMPLE_COVERAGE_INVERT_ARB = 0x80AB; + int GL_MULTISAMPLE_BIT_ARB = 0x20000000; + + void glSampleCoverageARB(@GLclampf float value, boolean invert); +} diff --git a/src/templates/org/lwjgl/opengl/ARB_multitexture.java b/src/templates/org/lwjgl/opengl/ARB_multitexture.java new file mode 100644 index 0000000..4aefdef --- /dev/null +++ b/src/templates/org/lwjgl/opengl/ARB_multitexture.java @@ -0,0 +1,125 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +public interface ARB_multitexture { + + int GL_TEXTURE0_ARB = 0x84C0; + int GL_TEXTURE1_ARB = 0x84C1; + int GL_TEXTURE2_ARB = 0x84C2; + int GL_TEXTURE3_ARB = 0x84C3; + int GL_TEXTURE4_ARB = 0x84C4; + int GL_TEXTURE5_ARB = 0x84C5; + int GL_TEXTURE6_ARB = 0x84C6; + int GL_TEXTURE7_ARB = 0x84C7; + int GL_TEXTURE8_ARB = 0x84C8; + int GL_TEXTURE9_ARB = 0x84C9; + int GL_TEXTURE10_ARB = 0x84CA; + int GL_TEXTURE11_ARB = 0x84CB; + int GL_TEXTURE12_ARB = 0x84CC; + int GL_TEXTURE13_ARB = 0x84CD; + int GL_TEXTURE14_ARB = 0x84CE; + int GL_TEXTURE15_ARB = 0x84CF; + int GL_TEXTURE16_ARB = 0x84D0; + int GL_TEXTURE17_ARB = 0x84D1; + int GL_TEXTURE18_ARB = 0x84D2; + int GL_TEXTURE19_ARB = 0x84D3; + int GL_TEXTURE20_ARB = 0x84D4; + int GL_TEXTURE21_ARB = 0x84D5; + int GL_TEXTURE22_ARB = 0x84D6; + int GL_TEXTURE23_ARB = 0x84D7; + int GL_TEXTURE24_ARB = 0x84D8; + int GL_TEXTURE25_ARB = 0x84D9; + int GL_TEXTURE26_ARB = 0x84DA; + int GL_TEXTURE27_ARB = 0x84DB; + int GL_TEXTURE28_ARB = 0x84DC; + int GL_TEXTURE29_ARB = 0x84DD; + int GL_TEXTURE30_ARB = 0x84DE; + int GL_TEXTURE31_ARB = 0x84DF; + int GL_ACTIVE_TEXTURE_ARB = 0x84E0; + int GL_CLIENT_ACTIVE_TEXTURE_ARB = 0x84E1; + int GL_MAX_TEXTURE_UNITS_ARB = 0x84E2; + + void glClientActiveTextureARB(@GLenum int texture); + + void glActiveTextureARB(@GLenum int texture); + + @NoErrorCheck + void glMultiTexCoord1fARB(@GLenum int target, float s); + + @NoErrorCheck + void glMultiTexCoord1dARB(@GLenum int target, double s); + + @NoErrorCheck + void glMultiTexCoord1iARB(@GLenum int target, int s); + + @NoErrorCheck + void glMultiTexCoord1sARB(@GLenum int target, short s); + + @NoErrorCheck + void glMultiTexCoord2fARB(@GLenum int target, float s, float t); + + @NoErrorCheck + void glMultiTexCoord2dARB(@GLenum int target, double s, double t); + + @NoErrorCheck + void glMultiTexCoord2iARB(@GLenum int target, int s, int t); + + @NoErrorCheck + void glMultiTexCoord2sARB(@GLenum int target, short s, short t); + + @NoErrorCheck + void glMultiTexCoord3fARB(@GLenum int target, float s, float t, float r); + + @NoErrorCheck + void glMultiTexCoord3dARB(@GLenum int target, double s, double t, double r); + + @NoErrorCheck + void glMultiTexCoord3iARB(@GLenum int target, int s, int t, int r); + + @NoErrorCheck + void glMultiTexCoord3sARB(@GLenum int target, short s, short t, short r); + + @NoErrorCheck + void glMultiTexCoord4fARB(@GLenum int target, float s, float t, float r, float q); + + @NoErrorCheck + void glMultiTexCoord4dARB(@GLenum int target, double s, double t, double r, double q); + + @NoErrorCheck + void glMultiTexCoord4iARB(@GLenum int target, int s, int t, int r, int q); + + @NoErrorCheck + void glMultiTexCoord4sARB(@GLenum int target, short s, short t, short r, short q); +} diff --git a/src/templates/org/lwjgl/opengl/ARB_occlusion_query.java b/src/templates/org/lwjgl/opengl/ARB_occlusion_query.java new file mode 100644 index 0000000..711ca2f --- /dev/null +++ b/src/templates/org/lwjgl/opengl/ARB_occlusion_query.java @@ -0,0 +1,97 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +import java.nio.IntBuffer; + +public interface ARB_occlusion_query { + + /** + * Accepted by the <target> parameter of BeginQueryARB, EndQueryARB, + * and GetQueryivARB: + */ + int GL_SAMPLES_PASSED_ARB = 0x8914; + + /** Accepted by the <pname> parameter of GetQueryivARB: */ + int GL_QUERY_COUNTER_BITS_ARB = 0x8864; + int GL_CURRENT_QUERY_ARB = 0x8865; + + /** + * Accepted by the <pname> parameter of GetQueryObjectivARB and + * GetQueryObjectuivARB: + */ + int GL_QUERY_RESULT_ARB = 0x8866; + int GL_QUERY_RESULT_AVAILABLE_ARB = 0x8867; + + void glGenQueriesARB(@AutoSize("ids") @GLsizei int n, @OutParameter @GLuint IntBuffer ids); + + @Alternate("glGenQueriesARB") + @GLreturn("ids") + void glGenQueriesARB2(@Constant("1") @GLsizei int n, @OutParameter @GLuint IntBuffer ids); + + void glDeleteQueriesARB(@AutoSize("ids") @GLsizei int n, @GLuint IntBuffer ids); + + @Alternate("glDeleteQueriesARB") + void glDeleteQueriesARB(@Constant("1") @GLsizei int n, @Constant(value = "APIUtils.getBufferInt().put(0, id), 0", keepParam = true) int id); + + boolean glIsQueryARB(@GLuint int id); + + void glBeginQueryARB(@GLenum int target, @GLuint int id); + + void glEndQueryARB(@GLenum int target); + + @StripPostfix("params") + void glGetQueryivARB(@GLenum int target, @GLenum int pname, @OutParameter @Check("1") IntBuffer params); + + @Alternate("glGetQueryivARB") + @GLreturn("params") + @StripPostfix("params") + void glGetQueryivARB2(@GLenum int target, @GLenum int pname, @OutParameter IntBuffer params); + + @StripPostfix("params") + void glGetQueryObjectivARB(@GLuint int id, @GLenum int pname, @OutParameter @Check("1") IntBuffer params); + + @Alternate("glGetQueryObjectivARB") + @GLreturn("params") + @StripPostfix(value = "params", postfix = "v") + void glGetQueryObjectivARB2(@GLuint int id, @GLenum int pname, @OutParameter IntBuffer params); + + @StripPostfix("params") + void glGetQueryObjectuivARB(@GLuint int id, @GLenum int pname, @OutParameter @Check("1") IntBuffer params); + + @Alternate("glGetQueryObjectuivARB") + @GLreturn("params") + @StripPostfix(value = "params", postfix = "v") + void glGetQueryObjectuivARB2(@GLuint int id, @GLenum int pname, @OutParameter IntBuffer params); +} diff --git a/src/templates/org/lwjgl/opengl/ARB_occlusion_query2.java b/src/templates/org/lwjgl/opengl/ARB_occlusion_query2.java new file mode 100644 index 0000000..fb53b5c --- /dev/null +++ b/src/templates/org/lwjgl/opengl/ARB_occlusion_query2.java @@ -0,0 +1,42 @@ +/* + * 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; + +public interface ARB_occlusion_query2 { + + /** + * Accepted by the <target> parameter of BeginQuery, EndQuery, + * and GetQueryiv: + */ + int GL_ANY_SAMPLES_PASSED = 0x8C2F; + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/ARB_pixel_buffer_object.java b/src/templates/org/lwjgl/opengl/ARB_pixel_buffer_object.java new file mode 100644 index 0000000..06d4596 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/ARB_pixel_buffer_object.java @@ -0,0 +1,50 @@ +/* + * 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; + +public interface ARB_pixel_buffer_object extends ARB_buffer_object { + + /** + * Accepted by the <target> parameters of BindBuffer, BufferData, + * BufferSubData, MapBuffer, UnmapBuffer, GetBufferSubData, + * GetBufferParameteriv, and GetBufferPointerv: + */ + int GL_PIXEL_PACK_BUFFER_ARB = 0x88EB; + int GL_PIXEL_UNPACK_BUFFER_ARB = 0x88EC; + + /** + * Accepted by the <pname> parameter of GetBooleanv, GetIntegerv, + * GetFloatv, and GetDoublev: + */ + int GL_PIXEL_PACK_BUFFER_BINDING_ARB = 0x88ED; + int GL_PIXEL_UNPACK_BUFFER_BINDING_ARB = 0x88EF; +} diff --git a/src/templates/org/lwjgl/opengl/ARB_point_parameters.java b/src/templates/org/lwjgl/opengl/ARB_point_parameters.java new file mode 100644 index 0000000..40d5155 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/ARB_point_parameters.java @@ -0,0 +1,50 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +import java.nio.*; + +public interface ARB_point_parameters { + + int GL_POINT_SIZE_MIN_ARB = 0x8126; + int GL_POINT_SIZE_MAX_ARB = 0x8127; + int GL_POINT_FADE_THRESHOLD_SIZE_ARB = 0x8128; + int GL_POINT_DISTANCE_ATTENUATION_ARB = 0x8129; + + void glPointParameterfARB(@GLenum int pname, float param); + + @StripPostfix("pfParams") + void glPointParameterfvARB(@GLenum int pname, @Check("4") @Const FloatBuffer pfParams); + +} diff --git a/src/templates/org/lwjgl/opengl/ARB_point_sprite.java b/src/templates/org/lwjgl/opengl/ARB_point_sprite.java new file mode 100644 index 0000000..3abb52f --- /dev/null +++ b/src/templates/org/lwjgl/opengl/ARB_point_sprite.java @@ -0,0 +1,50 @@ +/* + * 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; + +public interface ARB_point_sprite { + + /** + * Accepted by the <cap> parameter of Enable, Disable, and IsEnabled, by + * the <pname> parameter of GetBooleanv, GetIntegerv, GetFloatv, and + * GetDoublev, and by the <target> parameter of TexEnvi, TexEnviv, + * TexEnvf, TexEnvfv, GetTexEnviv, and GetTexEnvfv: + */ + int GL_POINT_SPRITE_ARB = 0x8861; + + /** + * When the <target> parameter of TexEnvf, TexEnvfv, TexEnvi, TexEnviv, + * GetTexEnvfv, or GetTexEnviv is POINT_SPRITE_ARB, then the value of + * <pname> may be: + */ + int GL_COORD_REPLACE_ARB = 0x8862; +} diff --git a/src/templates/org/lwjgl/opengl/ARB_program.java b/src/templates/org/lwjgl/opengl/ARB_program.java new file mode 100644 index 0000000..8cc89a4 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/ARB_program.java @@ -0,0 +1,185 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +import java.nio.*; + +@Extension(postfix = "ARB", isFinal = false) +public interface ARB_program { + + /** Accepted by the <format> parameter of ProgramStringARB: */ + int GL_PROGRAM_FORMAT_ASCII_ARB = 0x8875; + + /** Accepted by the <pname> parameter of GetProgramivARB: */ + int GL_PROGRAM_LENGTH_ARB = 0x8627; + int GL_PROGRAM_FORMAT_ARB = 0x8876; + int GL_PROGRAM_BINDING_ARB = 0x8677; + int GL_PROGRAM_INSTRUCTIONS_ARB = 0x88A0; + int GL_MAX_PROGRAM_INSTRUCTIONS_ARB = 0x88A1; + int GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB = 0x88A2; + int GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB = 0x88A3; + int GL_PROGRAM_TEMPORARIES_ARB = 0x88A4; + int GL_MAX_PROGRAM_TEMPORARIES_ARB = 0x88A5; + int GL_PROGRAM_NATIVE_TEMPORARIES_ARB = 0x88A6; + int GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB = 0x88A7; + int GL_PROGRAM_PARAMETERS_ARB = 0x88A8; + int GL_MAX_PROGRAM_PARAMETERS_ARB = 0x88A9; + int GL_PROGRAM_NATIVE_PARAMETERS_ARB = 0x88AA; + int GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB = 0x88AB; + int GL_PROGRAM_ATTRIBS_ARB = 0x88AC; + int GL_MAX_PROGRAM_ATTRIBS_ARB = 0x88AD; + int GL_PROGRAM_NATIVE_ATTRIBS_ARB = 0x88AE; + int GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB = 0x88AF; + int GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB = 0x88B4; + int GL_MAX_PROGRAM_ENV_PARAMETERS_ARB = 0x88B5; + int GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB = 0x88B6; + + /** Accepted by the <pname> parameter of GetProgramStringARB: */ + int GL_PROGRAM_STRING_ARB = 0x8628; + + /** + * Accepted by the <pname> parameter of GetBooleanv, GetIntegerv, + * GetFloatv, and GetDoublev: + */ + int GL_PROGRAM_ERROR_POSITION_ARB = 0x864B; + int GL_CURRENT_MATRIX_ARB = 0x8641; + int GL_TRANSPOSE_CURRENT_MATRIX_ARB = 0x88B7; + int GL_CURRENT_MATRIX_STACK_DEPTH_ARB = 0x8640; + int GL_MAX_PROGRAM_MATRICES_ARB = 0x862F; + int GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB = 0x862E; + + /** Accepted by the <name> parameter of GetString: */ + int GL_PROGRAM_ERROR_STRING_ARB = 0x8874; + + /** Accepted by the <mode> parameter of MatrixMode: */ + int GL_MATRIX0_ARB = 0x88C0; + int GL_MATRIX1_ARB = 0x88C1; + int GL_MATRIX2_ARB = 0x88C2; + int GL_MATRIX3_ARB = 0x88C3; + int GL_MATRIX4_ARB = 0x88C4; + int GL_MATRIX5_ARB = 0x88C5; + int GL_MATRIX6_ARB = 0x88C6; + int GL_MATRIX7_ARB = 0x88C7; + int GL_MATRIX8_ARB = 0x88C8; + int GL_MATRIX9_ARB = 0x88C9; + int GL_MATRIX10_ARB = 0x88CA; + int GL_MATRIX11_ARB = 0x88CB; + int GL_MATRIX12_ARB = 0x88CC; + int GL_MATRIX13_ARB = 0x88CD; + int GL_MATRIX14_ARB = 0x88CE; + int GL_MATRIX15_ARB = 0x88CF; + int GL_MATRIX16_ARB = 0x88D0; + int GL_MATRIX17_ARB = 0x88D1; + int GL_MATRIX18_ARB = 0x88D2; + int GL_MATRIX19_ARB = 0x88D3; + int GL_MATRIX20_ARB = 0x88D4; + int GL_MATRIX21_ARB = 0x88D5; + int GL_MATRIX22_ARB = 0x88D6; + int GL_MATRIX23_ARB = 0x88D7; + int GL_MATRIX24_ARB = 0x88D8; + int GL_MATRIX25_ARB = 0x88D9; + int GL_MATRIX26_ARB = 0x88DA; + int GL_MATRIX27_ARB = 0x88DB; + int GL_MATRIX28_ARB = 0x88DC; + int GL_MATRIX29_ARB = 0x88DD; + int GL_MATRIX30_ARB = 0x88DE; + int GL_MATRIX31_ARB = 0x88DF; + + void glProgramStringARB(@GLenum int target, @GLenum int format, @AutoSize("string") @GLsizei int length, @Const @GLbyte Buffer string); + + @Alternate("glProgramStringARB") + void glProgramStringARB(@GLenum int target, @GLenum int format, @Constant("string.length()") @GLsizei int length, CharSequence string); + + void glBindProgramARB(@GLenum int target, @GLuint int program); + + void glDeleteProgramsARB(@AutoSize("programs") @GLsizei int n, @Const @GLuint IntBuffer programs); + + @Alternate("glDeleteProgramsARB") + void glDeleteProgramsARB(@Constant("1") @GLsizei int n, @Constant(value = "APIUtils.getBufferInt().put(0, program), 0", keepParam = true) int program); + + void glGenProgramsARB(@AutoSize("programs") @GLsizei int n, @OutParameter @GLuint IntBuffer programs); + + @Alternate("glGenProgramsARB") + @GLreturn("programs") + void glGenProgramsARB2(@Constant("1") @GLsizei int n, @OutParameter @GLuint IntBuffer programs); + + void glProgramEnvParameter4fARB(int target, int index, float x, float y, float z, float w); + + void glProgramEnvParameter4dARB(int target, int index, double x, double y, double z, double w); + + @StripPostfix("params") + void glProgramEnvParameter4fvARB(@GLenum int target, @GLuint int index, @Check("4") @Const FloatBuffer params); + + @StripPostfix("params") + void glProgramEnvParameter4dvARB(@GLenum int target, @GLuint int index, @Check("4") @Const DoubleBuffer params); + + void glProgramLocalParameter4fARB(@GLenum int target, @GLuint int index, float x, float y, float z, float w); + + void glProgramLocalParameter4dARB(@GLenum int target, @GLuint int index, double x, double y, double z, double w); + + @StripPostfix("params") + void glProgramLocalParameter4fvARB(@GLenum int target, @GLuint int index, @Check("4") @Const FloatBuffer params); + + @StripPostfix("params") + void glProgramLocalParameter4dvARB(@GLenum int target, @GLuint int index, @Check("4") @Const DoubleBuffer params); + + @StripPostfix("params") + void glGetProgramEnvParameterfvARB(@GLenum int target, @GLuint int index, @OutParameter @Check("4") FloatBuffer params); + + @StripPostfix("params") + void glGetProgramEnvParameterdvARB(@GLenum int target, @GLuint int index, @OutParameter @Check("4") DoubleBuffer params); + + @StripPostfix("params") + void glGetProgramLocalParameterfvARB(@GLenum int target, @GLuint int index, @OutParameter @Check("4") FloatBuffer params); + + @StripPostfix("params") + void glGetProgramLocalParameterdvARB(@GLenum int target, @GLuint int index, @OutParameter @Check("4") DoubleBuffer params); + + @StripPostfix("params") + void glGetProgramivARB(@GLenum int target, @GLenum int parameterName, @OutParameter @Check("4") IntBuffer params); + + @Alternate("glGetProgramivARB") + @GLreturn("params") + @StripPostfix("params") + void glGetProgramivARB2(@GLenum int target, @GLenum int parameterName, @OutParameter IntBuffer params); + + void glGetProgramStringARB(@GLenum int target, @GLenum int parameterName, @OutParameter @Check @GLbyte Buffer paramString); + + @Alternate("glGetProgramStringARB") + @Code("\t\tint programLength = glGetProgramARB(target, GL_PROGRAM_LENGTH_ARB);") + @GLreturn(value="paramString", maxLength = "programLength", forceMaxLength = true) + void glGetProgramStringARB2(@GLenum int target, @GLenum int parameterName, @OutParameter @GLchar ByteBuffer paramString); + + boolean glIsProgramARB(@GLuint int program); +} diff --git a/src/templates/org/lwjgl/opengl/ARB_provoking_vertex.java b/src/templates/org/lwjgl/opengl/ARB_provoking_vertex.java new file mode 100644 index 0000000..0bf26e7 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/ARB_provoking_vertex.java @@ -0,0 +1,51 @@ +/* + * 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; + +import org.lwjgl.util.generator.GLenum; + +public interface ARB_provoking_vertex { + + /** Accepted by the <mode> parameter of ProvokingVertex: */ + int GL_FIRST_VERTEX_CONVENTION = 0x8E4D; + int GL_LAST_VERTEX_CONVENTION = 0x8E4E; + + /** + * Accepted by the <pname> parameter of GetBooleanv, GetIntegerv, + * GetFloatv, and GetDoublev: + */ + int GL_PROVOKING_VERTEX = 0x8E4F; + int GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION = 0x8E4C; + + void glProvokingVertex(@GLenum int mode); + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/ARB_sample_shading.java b/src/templates/org/lwjgl/opengl/ARB_sample_shading.java new file mode 100644 index 0000000..543ef6c --- /dev/null +++ b/src/templates/org/lwjgl/opengl/ARB_sample_shading.java @@ -0,0 +1,53 @@ +/* + * 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; + +import org.lwjgl.util.generator.GLclampf; + +public interface ARB_sample_shading { + + /** + * Accepted by the <cap> parameter of Enable, Disable, and IsEnabled, + * and by the <pname> parameter of GetBooleanv, GetIntegerv, GetFloatv, + * and GetDoublev: + */ + int GL_SAMPLE_SHADING_ARB = 0x8C36; + + /** + * Accepted by the <pname> parameter of GetBooleanv, GetDoublev, + * GetIntegerv, and GetFloatv: + */ + int GL_MIN_SAMPLE_SHADING_VALUE_ARB = 0x8C37; + + void glMinSampleShadingARB(@GLclampf float value); + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/ARB_sampler_objects.java b/src/templates/org/lwjgl/opengl/ARB_sampler_objects.java new file mode 100644 index 0000000..2ca468c --- /dev/null +++ b/src/templates/org/lwjgl/opengl/ARB_sampler_objects.java @@ -0,0 +1,111 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +import java.nio.FloatBuffer; +import java.nio.IntBuffer; + +@Extension(postfix = "") +public interface ARB_sampler_objects { + + /** + * Accepted by the <value> parameter of the GetBooleanv, GetIntegerv, + * GetInteger64v, GetFloatv and GetDoublev functions: + */ + int GL_SAMPLER_BINDING = 0x8919; + + void glGenSamplers(@AutoSize("samplers") @GLsizei int count, @OutParameter @GLuint IntBuffer samplers); + + @Alternate("glGenSamplers") + @GLreturn("samplers") + void glGenSamplers2(@Constant("1") @GLsizei int count, @OutParameter @GLuint IntBuffer samplers); + + void glDeleteSamplers(@AutoSize("samplers") @GLsizei int count, @Const @GLuint IntBuffer samplers); + + @Alternate("glDeleteSamplers") + void glDeleteSamplers(@Constant("1") @GLsizei int count, @Constant(value = "APIUtils.getBufferInt().put(0, sampler), 0", keepParam = true) int sampler); + + boolean glIsSampler(@GLuint int sampler); + + void glBindSampler(@GLenum int unit, @GLuint int sampler); + + void glSamplerParameteri(@GLuint int sampler, @GLenum int pname, int param); + + void glSamplerParameterf(@GLuint int sampler, @GLenum int pname, float param); + + @StripPostfix("params") + void glSamplerParameteriv(@GLuint int sampler, @GLenum int pname, @Check("4") @Const IntBuffer params); + + @StripPostfix("params") + void glSamplerParameterfv(@GLuint int sampler, @GLenum int pname, @Check("4") @Const FloatBuffer params); + + @StripPostfix("params") + void glSamplerParameterIiv(@GLuint int sampler, @GLenum int pname, @Check("4") @Const IntBuffer params); + + @StripPostfix("params") + void glSamplerParameterIuiv(@GLuint int sampler, @GLenum int pname, @Check("4") @Const @GLuint IntBuffer params); + + @StripPostfix("params") + void glGetSamplerParameteriv(@GLuint int sampler, @GLenum int pname, @Check("4") @OutParameter IntBuffer params); + + @Alternate("glGetSamplerParameteriv") + @GLreturn("params") + @StripPostfix(value = "params", postfix = "v") + void glGetSamplerParameteriv2(@GLuint int sampler, @GLenum int pname, @OutParameter IntBuffer params); + + @StripPostfix("params") + void glGetSamplerParameterfv(@GLuint int sampler, @GLenum int pname, @Check("4") @OutParameter FloatBuffer params); + + @Alternate("glGetSamplerParameterfv") + @GLreturn("params") + @StripPostfix(value = "params", postfix = "v") + void glGetSamplerParameterfv2(@GLuint int sampler, @GLenum int pname, @OutParameter FloatBuffer params); + + @StripPostfix("params") + void glGetSamplerParameterIiv(@GLuint int sampler, @GLenum int pname, @Check("4") @OutParameter IntBuffer params); + + @Alternate("glGetSamplerParameterIiv") + @GLreturn("params") + @StripPostfix(value = "params", postfix = "v") + void glGetSamplerParameterIiv2(@GLuint int sampler, @GLenum int pname, @OutParameter IntBuffer params); + + @StripPostfix("params") + void glGetSamplerParameterIuiv(@GLuint int sampler, @GLenum int pname, @Check("4") @OutParameter IntBuffer params); + + @Alternate("glGetSamplerParameterIuiv") + @GLreturn("params") + @StripPostfix(value = "params", postfix = "v") + void glGetSamplerParameterIuiv2(@GLuint int sampler, @GLenum int pname, @OutParameter IntBuffer params); + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/ARB_seamless_cube_map.java b/src/templates/org/lwjgl/opengl/ARB_seamless_cube_map.java new file mode 100644 index 0000000..0a58ffb --- /dev/null +++ b/src/templates/org/lwjgl/opengl/ARB_seamless_cube_map.java @@ -0,0 +1,43 @@ +/* + * 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; + +public interface ARB_seamless_cube_map { + + /** + * Accepted by the <cap> parameter of Enable, Disable and IsEnabled, + * and by the <pname> parameter of GetBooleanv, GetIntegerv, GetFloatv + * and GetDoublev: + */ + int GL_TEXTURE_CUBE_MAP_SEAMLESS = 0x884F; + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/ARB_shader_bit_encoding.java b/src/templates/org/lwjgl/opengl/ARB_shader_bit_encoding.java new file mode 100644 index 0000000..0c7a561 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/ARB_shader_bit_encoding.java @@ -0,0 +1,35 @@ +/* + * 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; + +public interface ARB_shader_bit_encoding { +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/ARB_shader_objects.java b/src/templates/org/lwjgl/opengl/ARB_shader_objects.java new file mode 100644 index 0000000..d58a8b2 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/ARB_shader_objects.java @@ -0,0 +1,272 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +import java.nio.ByteBuffer; +import java.nio.FloatBuffer; +import java.nio.IntBuffer; + +public interface ARB_shader_objects { + + /** Accepted by the <pname> argument of GetHandleARB: */ + int GL_PROGRAM_OBJECT_ARB = 0x8B40; + + /** Accepted by the <pname> parameter of GetObjectParameter{fi}vARB: */ + int GL_OBJECT_TYPE_ARB = 0x8B4E; + int GL_OBJECT_SUBTYPE_ARB = 0x8B4F; + int GL_OBJECT_DELETE_STATUS_ARB = 0x8B80; + int GL_OBJECT_COMPILE_STATUS_ARB = 0x8B81; + int GL_OBJECT_LINK_STATUS_ARB = 0x8B82; + int GL_OBJECT_VALIDATE_STATUS_ARB = 0x8B83; + int GL_OBJECT_INFO_LOG_LENGTH_ARB = 0x8B84; + int GL_OBJECT_ATTACHED_OBJECTS_ARB = 0x8B85; + int GL_OBJECT_ACTIVE_UNIFORMS_ARB = 0x8B86; + int GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB = 0x8B87; + int GL_OBJECT_SHADER_SOURCE_LENGTH_ARB = 0x8B88; + + /** Returned by the <params> parameter of GetObjectParameter{fi}vARB: */ + int GL_SHADER_OBJECT_ARB = 0x8B48; + + /** Returned by the <type> parameter of GetActiveUniformARB: */ + int GL_FLOAT = 0x1406; + int GL_FLOAT_VEC2_ARB = 0x8B50; + int GL_FLOAT_VEC3_ARB = 0x8B51; + int GL_FLOAT_VEC4_ARB = 0x8B52; + int GL_INT = 0x1404; + int GL_INT_VEC2_ARB = 0x8B53; + int GL_INT_VEC3_ARB = 0x8B54; + int GL_INT_VEC4_ARB = 0x8B55; + int GL_BOOL_ARB = 0x8B56; + int GL_BOOL_VEC2_ARB = 0x8B57; + int GL_BOOL_VEC3_ARB = 0x8B58; + int GL_BOOL_VEC4_ARB = 0x8B59; + int GL_FLOAT_MAT2_ARB = 0x8B5A; + int GL_FLOAT_MAT3_ARB = 0x8B5B; + int GL_FLOAT_MAT4_ARB = 0x8B5C; + int GL_SAMPLER_1D_ARB = 0x8B5D; + int GL_SAMPLER_2D_ARB = 0x8B5E; + int GL_SAMPLER_3D_ARB = 0x8B5F; + int GL_SAMPLER_CUBE_ARB = 0x8B60; + int GL_SAMPLER_1D_SHADOW_ARB = 0x8B61; + int GL_SAMPLER_2D_SHADOW_ARB = 0x8B62; + int GL_SAMPLER_2D_RECT_ARB = 0x8B63; + int GL_SAMPLER_2D_RECT_SHADOW_ARB = 0x8B64; + + void glDeleteObjectARB(@GLhandleARB int obj); + + @GLhandleARB + int glGetHandleARB(@GLenum int pname); + + void glDetachObjectARB(@GLhandleARB int containerObj, @GLhandleARB int attachedObj); + + @GLhandleARB + int glCreateShaderObjectARB(@GLenum int shaderType); + + /** + * The ARB_shader_objects extension allows multiple, optionally null-terminated, source strings to define a shader program. + *

    + * This method uses just a single string, that should NOT be null-terminated. + */ + void glShaderSourceARB(@GLhandleARB int shader, @Constant("1") @GLsizei int count, + @Indirect @Const @GLcharARB @Check ByteBuffer string, + @AutoSize("string") @Indirect @Const @GLint int length); + + @Alternate("glShaderSourceARB") + void glShaderSourceARB2(@GLhandleARB int shader, @Constant("1") @GLsizei int count, CharSequence string, @Constant("string.length()") @Indirect @Const int length); + + @Alternate(value = "glShaderSourceARB", nativeAlt = true) + void glShaderSourceARB3(@GLhandleARB int shader, @Constant("strings.length") @GLsizei int count, + @Const @StringList(value = "count", lengths = "length") CharSequence[] strings, + @Constant("APIUtils.getLengths(strings), 0") @Const IntBuffer length); + + void glCompileShaderARB(@GLhandleARB int shaderObj); + + @GLhandleARB + int glCreateProgramObjectARB(); + + void glAttachObjectARB(@GLhandleARB int containerObj, @GLhandleARB int obj); + + void glLinkProgramARB(@GLhandleARB int programObj); + + void glUseProgramObjectARB(@GLhandleARB int programObj); + + void glValidateProgramARB(@GLhandleARB int programObj); + + void glUniform1fARB(int location, float v0); + + void glUniform2fARB(int location, float v0, float v1); + + void glUniform3fARB(int location, float v0, float v1, float v2); + + void glUniform4fARB(int location, float v0, float v1, float v2, float v3); + + void glUniform1iARB(int location, int v0); + + void glUniform2iARB(int location, int v0, int v1); + + void glUniform3iARB(int location, int v0, int v1, int v2); + + void glUniform4iARB(int location, int v0, int v1, int v2, int v3); + + @StripPostfix("values") + void glUniform1fvARB(int location, @AutoSize("values") @GLsizei int count, @Const FloatBuffer values); + + @StripPostfix("values") + void glUniform2fvARB(int location, @AutoSize(value = "values", expression = " >> 1") @GLsizei int count, @Const FloatBuffer values); + + @StripPostfix("values") + void glUniform3fvARB(int location, @AutoSize(value = "values", expression = " / 3") @GLsizei int count, @Const FloatBuffer values); + + @StripPostfix("values") + void glUniform4fvARB(int location, @AutoSize(value = "values", expression = " >> 2") @GLsizei int count, @Const FloatBuffer values); + + @StripPostfix("values") + void glUniform1ivARB(int location, @AutoSize(value = "values") @GLsizei int count, @Const IntBuffer values); + + @StripPostfix("values") + void glUniform2ivARB(int location, @AutoSize(value = "values", expression = " >> 1") @GLsizei int count, @Const IntBuffer values); + + @StripPostfix("values") + void glUniform3ivARB(int location, @AutoSize(value = "values", expression = " / 3") @GLsizei int count, @Const IntBuffer values); + + @StripPostfix("values") + void glUniform4ivARB(int location, @AutoSize(value = "values", expression = " >> 2") @GLsizei int count, @Const IntBuffer values); + + @StripPostfix("matrices") + void glUniformMatrix2fvARB(int location, @AutoSize(value = "matrices", expression = " >> 2") @GLsizei int count, boolean transpose, @Const FloatBuffer matrices); + + @StripPostfix("matrices") + void glUniformMatrix3fvARB(int location, @AutoSize(value = "matrices", expression = " / (3 * 3)") @GLsizei int count, boolean transpose, @Const FloatBuffer matrices); + + @StripPostfix("matrices") + void glUniformMatrix4fvARB(int location, @AutoSize(value = "matrices", expression = " >> 4") @GLsizei int count, boolean transpose, @Const FloatBuffer matrices); + + @StripPostfix("params") + void glGetObjectParameterfvARB(@GLhandleARB int obj, @GLenum int pname, @OutParameter @Check FloatBuffer params); + + @Alternate("glGetObjectParameterfvARB") + @GLreturn("params") + @StripPostfix(value = "params", postfix = "v") + void glGetObjectParameterfvARB2(@GLhandleARB int obj, @GLenum int pname, @OutParameter FloatBuffer params); + + @StripPostfix("params") + void glGetObjectParameterivARB(@GLhandleARB int obj, @GLenum int pname, @OutParameter @Check IntBuffer params); + + @Alternate("glGetObjectParameterivARB") + @GLreturn("params") + @StripPostfix(value = "params", postfix = "v") + void glGetObjectParameterivARB2(@GLhandleARB int obj, @GLenum int pname, @OutParameter IntBuffer params); + + void glGetInfoLogARB(@GLhandleARB int obj, @AutoSize("infoLog") @GLsizei int maxLength, + @OutParameter @GLsizei @Check(value = "1", canBeNull = true) IntBuffer length, + @OutParameter @GLcharARB ByteBuffer infoLog); + + @Alternate("glGetInfoLogARB") + @GLreturn(value = "infoLog", maxLength = "maxLength") + void glGetInfoLogARB2(@GLhandleARB int obj, @GLsizei int maxLength, + @OutParameter @GLsizei @Constant("infoLog_length, 0") IntBuffer length, + @OutParameter @GLcharARB ByteBuffer infoLog); + + void glGetAttachedObjectsARB(@GLhandleARB int containerObj, @AutoSize("obj") @GLsizei int maxCount, + @OutParameter @GLsizei @Check(value = "1", canBeNull = true) IntBuffer count, + @OutParameter @GLhandleARB IntBuffer obj); + + /** + * Returns the location of the uniform with the specified name. The ByteBuffer should contain the uniform name as a null-terminated string. + * + * @param programObj + * @param name + */ + int glGetUniformLocationARB(@GLhandleARB int programObj, @NullTerminated @Const @GLcharARB ByteBuffer name); + + @Alternate("glGetUniformLocationARB") + int glGetUniformLocationARB(@GLhandleARB int programObj, @NullTerminated CharSequence name); + + void glGetActiveUniformARB(@GLhandleARB int programObj, @GLuint int index, @AutoSize("name") @GLsizei int maxLength, + @OutParameter @GLsizei @Check(value = "1", canBeNull = true) IntBuffer length, + @OutParameter @Check("1") IntBuffer size, + @OutParameter @GLenum @Check("1") IntBuffer type, + @OutParameter @GLcharARB ByteBuffer name); + + /** Overloads glGetActiveUniformARB. This version returns both size and type in the sizeType buffer (at .position() and .position() + 1). */ + @Alternate("glGetActiveUniformARB") + @GLreturn(value = "name", maxLength = "maxLength") + void glGetActiveUniformARB2(@GLhandleARB int programObj, @GLuint int index, @GLsizei int maxLength, + @OutParameter @GLsizei @Constant("name_length, 0") IntBuffer length, + @OutParameter @Check("2") IntBuffer sizeType, + @OutParameter @GLenum @Constant("sizeType, sizeType.position() + 1") IntBuffer type, + @OutParameter @GLcharARB ByteBuffer name); + + /** Overloads glGetActiveUniformARB. This version returns only the uniform name. */ + @Alternate(value = "glGetActiveUniformARB", javaAlt = true) + @GLreturn(value = "name", maxLength = "maxLength") + void glGetActiveUniformARB(@GLhandleARB int programObj, @GLuint int index, @GLsizei int maxLength, + @OutParameter @GLsizei @Constant("name_length, 0, APIUtils.getBufferInt(), 0, APIUtils.getBufferInt(), 1") IntBuffer length, + @OutParameter @GLcharARB ByteBuffer name); + + /** Overloads glGetActiveUniformARB. This version returns only the uniform size. */ + @Alternate(value = "glGetActiveUniformARB", javaAlt = true) + @GLreturn(value = "size") + void glGetActiveUniformSizeARB(@GLhandleARB int programObj, @GLuint int index, @Constant("0") @GLsizei int maxLength, + @OutParameter @GLsizei @Constant("null, 0") IntBuffer length, + @OutParameter IntBuffer size, + @OutParameter @GLenum @Constant("size, 1") IntBuffer type, // Reuse size buffer and ignore + @OutParameter @GLcharARB @Constant("APIUtils.getBufferByte(0), 0") ByteBuffer name); + + /** Overloads glGetActiveUniformARB. This version returns only the uniform type. */ + @Alternate(value = "glGetActiveUniformARB", javaAlt = true) + @GLreturn(value = "type") + void glGetActiveUniformTypeARB(@GLhandleARB int programObj, @GLuint int index, @Constant("0") @GLsizei int maxLength, + @OutParameter @GLsizei @Constant("null, 0") IntBuffer length, + @OutParameter @Constant("type, 1") IntBuffer size, // Reuse type buffer and ignore + @OutParameter @GLenum IntBuffer type, + @OutParameter @GLcharARB @Constant("APIUtils.getBufferByte(0), 0") ByteBuffer name); + + @StripPostfix("params") + void glGetUniformfvARB(@GLhandleARB int programObj, int location, @OutParameter @Check FloatBuffer params); + + @StripPostfix("params") + void glGetUniformivARB(@GLhandleARB int programObj, int location, @OutParameter @Check IntBuffer params); + + void glGetShaderSourceARB(@GLhandleARB int obj, @AutoSize("source") @GLsizei int maxLength, + @OutParameter @GLsizei @Check(value = "1", canBeNull = true) IntBuffer length, + @OutParameter @GLcharARB ByteBuffer source); + + @Alternate("glGetShaderSourceARB") + @GLreturn(value = "source", maxLength = "maxLength") + void glGetShaderSourceARB2(@GLhandleARB int obj, @GLsizei int maxLength, + @OutParameter @GLsizei @Constant("source_length, 0") IntBuffer length, + @OutParameter @GLcharARB ByteBuffer source); + +} diff --git a/src/templates/org/lwjgl/opengl/ARB_shader_subroutine.java b/src/templates/org/lwjgl/opengl/ARB_shader_subroutine.java new file mode 100644 index 0000000..51d1b6b --- /dev/null +++ b/src/templates/org/lwjgl/opengl/ARB_shader_subroutine.java @@ -0,0 +1,116 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +import java.nio.ByteBuffer; +import java.nio.IntBuffer; + +@Extension(postfix = "") +public interface ARB_shader_subroutine { + + /** Accepted by the <pname> parameter of GetProgramStageiv: */ + int GL_ACTIVE_SUBROUTINES = 0x8DE5; + int GL_ACTIVE_SUBROUTINE_UNIFORMS = 0x8DE6; + int GL_ACTIVE_SUBROUTINE_UNIFORM_LOCATIONS = 0x8E47; + int GL_ACTIVE_SUBROUTINE_MAX_LENGTH = 0x8E48; + int GL_ACTIVE_SUBROUTINE_UNIFORM_MAX_LENGTH = 0x8E49; + + /** + * Accepted by the <pname> parameter of GetBooleanv, GetIntegerv, + * GetFloatv, GetDoublev, and GetInteger64v: + */ + int GL_MAX_SUBROUTINES = 0x8DE7; + int GL_MAX_SUBROUTINE_UNIFORM_LOCATIONS = 0x8DE8; + + /** Accepted by the <pname> parameter of GetActiveSubroutineUniformiv: */ + int GL_NUM_COMPATIBLE_SUBROUTINES = 0x8E4A; + int GL_COMPATIBLE_SUBROUTINES = 0x8E4B; + int GL_UNIFORM_SIZE = GL31.GL_UNIFORM_SIZE; + int GL_UNIFORM_NAME_LENGTH = GL31.GL_UNIFORM_NAME_LENGTH; + + int glGetSubroutineUniformLocation(@GLuint int program, @GLenum int shadertype, @Const @NullTerminated ByteBuffer name); + + @GLuint + int glGetSubroutineIndex(@GLuint int program, @GLenum int shadertype, @Const @NullTerminated ByteBuffer name); + + @StripPostfix("values") + void glGetActiveSubroutineUniformiv(@GLuint int program, @GLenum int shadertype, @GLuint int index, @GLenum int pname, + @Check("1") @OutParameter IntBuffer values); + + @Alternate("glGetActiveSubroutineUniformiv") + @GLreturn("values") + @StripPostfix("values") + void glGetActiveSubroutineUniformiv2(@GLuint int program, @GLenum int shadertype, @GLuint int index, @GLenum int pname, + @OutParameter IntBuffer values); + + void glGetActiveSubroutineUniformName(@GLuint int program, @GLenum int shadertype, @GLuint int index, @AutoSize("name") @GLsizei int bufsize, + @OutParameter @Check(value = "1", canBeNull = true) @GLsizei IntBuffer length, + @OutParameter ByteBuffer name); + + @Alternate("glGetActiveSubroutineUniformName") + @GLreturn(value = "name", maxLength = "bufsize") + void glGetActiveSubroutineUniformName2(@GLuint int program, @GLenum int shadertype, @GLuint int index, @GLsizei int bufsize, + @OutParameter @Constant("name_length, 0") @GLsizei IntBuffer length, + @OutParameter @GLchar ByteBuffer name); + + void glGetActiveSubroutineName(@GLuint int program, @GLenum int shadertype, @GLuint int index, @AutoSize("name") @GLsizei int bufsize, + @OutParameter @Check(value = "1", canBeNull = true) @GLsizei IntBuffer length, + @OutParameter ByteBuffer name); + + @Alternate("glGetActiveSubroutineName") + @GLreturn(value = "name", maxLength = "bufsize") + void glGetActiveSubroutineName2(@GLuint int program, @GLenum int shadertype, @GLuint int index, @GLsizei int bufsize, + @OutParameter @Constant("name_length, 0") @GLsizei IntBuffer length, + @OutParameter @GLchar ByteBuffer name); + + @StripPostfix("indices") + void glUniformSubroutinesuiv(@GLenum int shadertype, @AutoSize("indices") @GLsizei int count, @Const @GLuint IntBuffer indices); + + @StripPostfix("params") + void glGetUniformSubroutineuiv(@GLenum int shadertype, int location, @Check("1") @OutParameter @GLuint IntBuffer params); + + @Alternate("glGetUniformSubroutineuiv") + @GLreturn("params") + @StripPostfix("params") + void glGetUniformSubroutineuiv2(@GLenum int shadertype, int location, @OutParameter @GLuint IntBuffer params); + + @StripPostfix("values") + void glGetProgramStageiv(@GLuint int program, @GLenum int shadertype, @GLenum int pname, @Check("1") @OutParameter IntBuffer values); + + @Alternate("glGetProgramStageiv") + @GLreturn("values") + @StripPostfix("values") + void glGetProgramStageiv2(@GLuint int program, @GLenum int shadertype, @GLenum int pname, @OutParameter IntBuffer values); + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/ARB_shader_texture_lod.java b/src/templates/org/lwjgl/opengl/ARB_shader_texture_lod.java new file mode 100644 index 0000000..e646dea --- /dev/null +++ b/src/templates/org/lwjgl/opengl/ARB_shader_texture_lod.java @@ -0,0 +1,35 @@ +/* + * 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; + +public interface ARB_shader_texture_lod { +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/ARB_shading_language_100.java b/src/templates/org/lwjgl/opengl/ARB_shading_language_100.java new file mode 100644 index 0000000..a9b9865 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/ARB_shading_language_100.java @@ -0,0 +1,40 @@ +/* + * 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; + +public interface ARB_shading_language_100 { + + /** + * Accepted by the <name> parameter of GetString: + */ + int GL_SHADING_LANGUAGE_VERSION_ARB = 0x8B8C; +} diff --git a/src/templates/org/lwjgl/opengl/ARB_shading_language_include.java b/src/templates/org/lwjgl/opengl/ARB_shading_language_include.java new file mode 100644 index 0000000..482411a --- /dev/null +++ b/src/templates/org/lwjgl/opengl/ARB_shading_language_include.java @@ -0,0 +1,106 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +import java.nio.ByteBuffer; +import java.nio.IntBuffer; + +public interface ARB_shading_language_include { + + /** Accepted by the <type> parameter of NamedStringARB: */ + int GL_SHADER_INCLUDE_ARB = 0x8DAE; + + /** Accepted by the <pname> parameter of GetNamedStringivARB: */ + int GL_NAMED_STRING_LENGTH_ARB = 0x8DE9; + int GL_NAMED_STRING_TYPE_ARB = 0x8DEA; + + void glNamedStringARB(@GLenum int type, + @AutoSize("name") int namelen, @Const @GLchar ByteBuffer name, + @AutoSize("string") int stringlen, @Const @GLchar ByteBuffer string); + + @Alternate("glNamedStringARB") + void glNamedStringARB(@GLenum int type, + @Constant("name.length()") int namelen, CharSequence name, + @Constant("string.length()") int stringlen, CharSequence string); + + void glDeleteNamedStringARB(@AutoSize("name") int namelen, @Const @GLchar ByteBuffer name); + + @Alternate("glDeleteNamedStringARB") + void glDeleteNamedStringARB(@Constant("name.length()") int namelen, CharSequence name); + + void glCompileShaderIncludeARB(@GLuint int shader, @GLsizei int count, + @Const @NullTerminated("count") @StringList("count") @GLchar ByteBuffer path, + @Constant("null, 0") @Const IntBuffer length); + + @Alternate(value = "glCompileShaderIncludeARB", nativeAlt = true) + void glCompileShaderIncludeARB2(@GLuint int shader, @Constant("path.length") @GLsizei int count, + @Const @StringList(value = "count", lengths = "length") CharSequence[] path, + @Constant("APIUtils.getLengths(path), 0") @Const IntBuffer length); + + boolean glIsNamedStringARB(@AutoSize("name") int namelen, @Const @GLchar ByteBuffer name); + + @Alternate("glIsNamedStringARB") + boolean glIsNamedStringARB(@Constant("name.length()") int namelen, CharSequence name); + + void glGetNamedStringARB(@AutoSize("name") int namelen, @Const @GLchar ByteBuffer name, + @AutoSize("string") @GLsizei int bufSize, + @OutParameter @Check(value = "1", canBeNull = true) IntBuffer stringlen, + @OutParameter @GLchar ByteBuffer string); + + @Alternate("glGetNamedStringARB") + void glGetNamedStringARB(@Constant("name.length()") int namelen, CharSequence name, + @AutoSize("string") @GLsizei int bufSize, + @OutParameter @Check(value = "1", canBeNull = true) IntBuffer stringlen, + @OutParameter @GLchar ByteBuffer string); + + @Alternate("glGetNamedStringARB") + @GLreturn(value = "string", maxLength = "bufSize") + void glGetNamedStringARB2(@Constant("name.length()") int namelen, CharSequence name, + @GLsizei int bufSize, + @OutParameter @Constant("string_length, 0") IntBuffer stringlen, + @OutParameter @GLchar ByteBuffer string); + + @StripPostfix("params") + void glGetNamedStringivARB(@AutoSize("name") int namelen, @Const @GLchar ByteBuffer name, @GLenum int pname, @OutParameter @Check("1") IntBuffer params); + + @Alternate("glGetNamedStringivARB") + @StripPostfix(value = "params", postfix = "v") + void glGetNamedStringivARB(@Constant("name.length()") int namelen, CharSequence name, @GLenum int pname, @OutParameter @Check("1") IntBuffer params); + + @Alternate("glGetNamedStringivARB") + @GLreturn("params") + @StripPostfix(value = "params", postfix = "v") + void glGetNamedStringivARB2(@Constant("name.length()") int namelen, CharSequence name, @GLenum int pname, @OutParameter IntBuffer params); + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/ARB_shadow.java b/src/templates/org/lwjgl/opengl/ARB_shadow.java new file mode 100644 index 0000000..c3d9c36 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/ARB_shadow.java @@ -0,0 +1,38 @@ +/* + * 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; + +public interface ARB_shadow { + int GL_TEXTURE_COMPARE_MODE_ARB = 0x884C; + int GL_TEXTURE_COMPARE_FUNC_ARB = 0x884D; + int GL_COMPARE_R_TO_TEXTURE_ARB = 0x884E; +} diff --git a/src/templates/org/lwjgl/opengl/ARB_shadow_ambient.java b/src/templates/org/lwjgl/opengl/ARB_shadow_ambient.java new file mode 100644 index 0000000..e2cea05 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/ARB_shadow_ambient.java @@ -0,0 +1,36 @@ +/* + * 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; + +public interface ARB_shadow_ambient { + int GL_TEXTURE_COMPARE_FAIL_VALUE_ARB = 0x80BF; +} diff --git a/src/templates/org/lwjgl/opengl/ARB_sync.java b/src/templates/org/lwjgl/opengl/ARB_sync.java new file mode 100644 index 0000000..eb78879 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/ARB_sync.java @@ -0,0 +1,104 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +import java.nio.IntBuffer; +import java.nio.LongBuffer; + +@Extension(postfix = "") +public interface ARB_sync { + + /** Accepted as the <pname> parameter of GetInteger64v: */ + int GL_MAX_SERVER_WAIT_TIMEOUT = 0x9111; + + /** Accepted as the <pname> parameter of GetSynciv: */ + int GL_OBJECT_TYPE = 0x9112; + int GL_SYNC_CONDITION = 0x9113; + int GL_SYNC_STATUS = 0x9114; + int GL_SYNC_FLAGS = 0x9115; + + /** Returned in <values> for GetSynciv <pname> OBJECT_TYPE: */ + int GL_SYNC_FENCE = 0x9116; + + /** Returned in <values> for GetSynciv <pname> SYNC_CONDITION: */ + int GL_SYNC_GPU_COMMANDS_COMPLETE = 0x9117; + + /** Returned in <values> for GetSynciv <pname> SYNC_STATUS: */ + int GL_UNSIGNALED = 0x9118; + int GL_SIGNALED = 0x9119; + + /** Accepted in the <flags> parameter of ClientWaitSync: */ + int GL_SYNC_FLUSH_COMMANDS_BIT = 0x00000001; + + /** Accepted in the <timeout> parameter of WaitSync: */ + long GL_TIMEOUT_IGNORED = 0xFFFFFFFFFFFFFFFFl; + + /** Returned by ClientWaitSync: */ + int GL_ALREADY_SIGNALED = 0x911A; + int GL_TIMEOUT_EXPIRED = 0x911B; + int GL_CONDITION_SATISFIED = 0x911C; + int GL_WAIT_FAILED = 0x911D; + + @GLpointer("GLsync") + GLSync glFenceSync(@GLenum int condition, @GLbitfield int flags); + + boolean glIsSync(@GLpointer("GLsync") GLSync sync); + + void glDeleteSync(@GLpointer("GLsync") GLSync sync); + + @GLenum + int glClientWaitSync(@GLpointer("GLsync") GLSync sync, @GLbitfield int flags, @GLuint64 long timeout); + + void glWaitSync(@GLpointer("GLsync") GLSync sync, @GLbitfield int flags, @GLuint64 long timeout); + + @StripPostfix(value = "params", postfix = "64") + void glGetInteger64v(@GLenum int pname, @OutParameter @Check("1") @GLint64 LongBuffer params); + + @Alternate("glGetInteger64v") + @GLreturn("params") + @StripPostfix(value = "params", postfix = "64") + void glGetInteger64v2(@GLenum int pname, @OutParameter @GLint64 LongBuffer params); + + @StripPostfix("values") + void glGetSynciv(@GLpointer("GLsync") GLSync sync, @GLenum int pname, @AutoSize("values") @GLsizei int bufSize, + @OutParameter @GLsizei @Check(value = "1", canBeNull = true) IntBuffer length, + @OutParameter IntBuffer values); + + @Alternate("glGetSynciv") + @GLreturn("values") + @StripPostfix("values") + void glGetSynciv2(@GLpointer("GLsync") GLSync sync, @GLenum int pname, @Constant("1") @GLsizei int bufSize, + @OutParameter @GLsizei @Constant("null, 0") IntBuffer length, + @OutParameter IntBuffer values); +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/ARB_tessellation_shader.java b/src/templates/org/lwjgl/opengl/ARB_tessellation_shader.java new file mode 100644 index 0000000..c599c2b --- /dev/null +++ b/src/templates/org/lwjgl/opengl/ARB_tessellation_shader.java @@ -0,0 +1,122 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +import java.nio.FloatBuffer; + +@Extension(postfix = "") +public interface ARB_tessellation_shader { + + /** + * Accepted by the <mode> parameter of Begin and all vertex array functions + * that implicitly call Begin: + */ + int GL_PATCHES = 0xE; + + /** + * Accepted by the <pname> parameter of PatchParameteri, GetBooleanv, + * GetDoublev, GetFloatv, GetIntegerv, and GetInteger64v: + */ + int GL_PATCH_VERTICES = 0x8E72; + + /** + * Accepted by the <pname> parameter of PatchParameterfv, GetBooleanv, + * GetDoublev, GetFloatv, and GetIntegerv, and GetInteger64v: + */ + int GL_PATCH_DEFAULT_INNER_LEVEL = 0x8E73; + int GL_PATCH_DEFAULT_OUTER_LEVEL = 0x8E74; + + /** Accepted by the <pname> parameter of GetProgramiv: */ + int GL_TESS_CONTROL_OUTPUT_VERTICES = 0x8E75; + int GL_TESS_GEN_MODE = 0x8E76; + int GL_TESS_GEN_SPACING = 0x8E77; + int GL_TESS_GEN_VERTEX_ORDER = 0x8E78; + int GL_TESS_GEN_POINT_MODE = 0x8E79; + + /** Returned by GetProgramiv when <pname> is TESS_GEN_MODE: */ + int GL_TRIANGLES = GL11.GL_TRIANGLES; + int GL_QUADS = GL11.GL_QUADS; + int GL_ISOLINES = 0x8E7A; + + /** Returned by GetProgramiv when <pname> is TESS_GEN_SPACING: */ + int GL_EQUAL = GL11.GL_EQUAL; + int GL_FRACTIONAL_ODD = 0x8E7B; + int GL_FRACTIONAL_EVEN = 0x8E7C; + + /** Returned by GetProgramiv when <pname> is TESS_GEN_VERTEX_ORDER: */ + int GL_CCW = GL11.GL_CCW; + int GL_CW = GL11.GL_CW; + + /** Returned by GetProgramiv when <pname> is TESS_GEN_POINT_MODE: */ + int GL_FALSE = GL11.GL_FALSE; + int GL_TRUE = GL11.GL_TRUE; + + /** + * Accepted by the <pname> parameter of GetBooleanv, GetDoublev, GetFloatv, + * GetIntegerv, and GetInteger64v: + */ + int GL_MAX_PATCH_VERTICES = 0x8E7D; + int GL_MAX_TESS_GEN_LEVEL = 0x8E7E; + int GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS = 0x8E7F; + int GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS = 0x8E80; + int GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS = 0x8E81; + int GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS = 0x8E82; + int GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS = 0x8E83; + int GL_MAX_TESS_PATCH_COMPONENTS = 0x8E84; + int GL_MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS = 0x8E85; + int GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS = 0x8E86; + int GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS = 0x8E89; + int GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS = 0x8E8A; + int GL_MAX_TESS_CONTROL_INPUT_COMPONENTS = 0x886C; + int GL_MAX_TESS_EVALUATION_INPUT_COMPONENTS = 0x886D; + int GL_MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS = 0x8E1E; + int GL_MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS = 0x8E1F; + + /** Accepted by the <pname> parameter of GetActiveUniformBlockiv: */ + int GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_CONTROL_SHADER = 0x84F0; + int GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_EVALUATION_SHADER = 0x84F1; + + /** + * Accepted by the <type> parameter of CreateShader and returned by the + * <params> parameter of GetShaderiv: + */ + int GL_TESS_EVALUATION_SHADER = 0x8E87; + int GL_TESS_CONTROL_SHADER = 0x8E88; + + void glPatchParameteri(@GLenum int pname, int value); + + @StripPostfix("values") + void glPatchParameterfv(@GLenum int pname, @Check("4") @Const FloatBuffer values); + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/ARB_texture_border_clamp.java b/src/templates/org/lwjgl/opengl/ARB_texture_border_clamp.java new file mode 100644 index 0000000..3530b1f --- /dev/null +++ b/src/templates/org/lwjgl/opengl/ARB_texture_border_clamp.java @@ -0,0 +1,36 @@ +/* + * 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; + +public interface ARB_texture_border_clamp { + int GL_CLAMP_TO_BORDER_ARB = 0x812D; +} diff --git a/src/templates/org/lwjgl/opengl/ARB_texture_buffer_object.java b/src/templates/org/lwjgl/opengl/ARB_texture_buffer_object.java new file mode 100644 index 0000000..3949912 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/ARB_texture_buffer_object.java @@ -0,0 +1,58 @@ +/* + * 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; + +import org.lwjgl.util.generator.GLenum; +import org.lwjgl.util.generator.GLuint; + +public interface ARB_texture_buffer_object { + + /** + * Accepted by the <target> parameter of BindBuffer, BufferData, + * BufferSubData, MapBuffer, MapBufferRangeARB, BindTexture, UnmapBuffer, + * GetBufferSubData, GetBufferParameteriv, GetBufferPointerv, and TexBufferARB, + * and the parameter of GetBooleanv, GetDoublev, GetFloatv, and + * GetIntegerv: + */ + int GL_TEXTURE_BUFFER_ARB = 0x8C2A; + + /** + * Accepted by the <pname> parameters of GetBooleanv, GetDoublev, + * GetFloatv, and GetIntegerv: + */ + int GL_MAX_TEXTURE_BUFFER_SIZE_ARB = 0x8C2B; + int GL_TEXTURE_BINDING_BUFFER_ARB = 0x8C2C; + int GL_TEXTURE_BUFFER_DATA_STORE_BINDING_ARB = 0x8C2D; + int GL_TEXTURE_BUFFER_FORMAT_ARB = 0x8C2E; + + void glTexBufferARB(@GLenum int target, @GLenum int internalformat, @GLuint int buffer); +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/ARB_texture_buffer_object_rgb32.java b/src/templates/org/lwjgl/opengl/ARB_texture_buffer_object_rgb32.java new file mode 100644 index 0000000..45ed2f3 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/ARB_texture_buffer_object_rgb32.java @@ -0,0 +1,35 @@ +/* + * 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; + +public interface ARB_texture_buffer_object_rgb32 { +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/ARB_texture_compression.java b/src/templates/org/lwjgl/opengl/ARB_texture_compression.java new file mode 100644 index 0000000..7aef7e7 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/ARB_texture_compression.java @@ -0,0 +1,99 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +import java.nio.*; + +public interface ARB_texture_compression { + int GL_COMPRESSED_ALPHA_ARB = 0x84E9; + int GL_COMPRESSED_LUMINANCE_ARB = 0x84EA; + int GL_COMPRESSED_LUMINANCE_ALPHA_ARB = 0x84EB; + int GL_COMPRESSED_INTENSITY_ARB = 0x84EC; + int GL_COMPRESSED_RGB_ARB = 0x84ED; + int GL_COMPRESSED_RGBA_ARB = 0x84EE; + int GL_TEXTURE_COMPRESSION_HINT_ARB = 0x84EF; + int GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB = 0x86A0; + int GL_TEXTURE_COMPRESSED_ARB = 0x86A1; + int GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB = 0x86A2; + int GL_COMPRESSED_TEXTURE_FORMATS_ARB = 0x86A3; + + void glCompressedTexImage1DARB(@GLenum int target, int level, @GLenum int internalformat, @GLsizei int width, int border, @AutoSize("pData") @GLsizei int imageSize, + @BufferObject(BufferKind.UnpackPBO) + @Check + @Const + @GLvoid + ByteBuffer pData); + + void glCompressedTexImage2DARB(@GLenum int target, int level, @GLenum int internalformat, @GLsizei int width, @GLsizei int height, int border, @AutoSize("pData") @GLsizei int imageSize, + @BufferObject(BufferKind.UnpackPBO) + @Check + @Const + @GLvoid + ByteBuffer pData); + + void glCompressedTexImage3DARB(@GLenum int target, int level, @GLenum int internalformat, @GLsizei int width, @GLsizei int height, @GLsizei int depth, int border, @AutoSize("pData") @GLsizei int imageSize, + @BufferObject(BufferKind.UnpackPBO) + @Check + @Const + @GLvoid + ByteBuffer pData); + + void glCompressedTexSubImage1DARB(@GLenum int target, int level, int xoffset, @GLsizei int width, @GLenum int format, @AutoSize("pData") @GLsizei int imageSize, + @BufferObject(BufferKind.UnpackPBO) + @Check + @Const + @GLvoid + ByteBuffer pData); + + void glCompressedTexSubImage2DARB(@GLenum int target, int level, int xoffset, int yoffset, @GLsizei int width, @GLsizei int height, @GLenum int format, @AutoSize("pData") @GLsizei int imageSize, + @BufferObject(BufferKind.UnpackPBO) + @Check + @Const + @GLvoid + ByteBuffer pData); + + void glCompressedTexSubImage3DARB(@GLenum int target, int level, int xoffset, int yoffset, int zoffset, @GLsizei int width, @GLsizei int height, @GLsizei int depth, @GLenum int format, @AutoSize("pData") @GLsizei int imageSize, + @BufferObject(BufferKind.UnpackPBO) + @Check + @Const + @GLvoid + ByteBuffer pData); + + void glGetCompressedTexImageARB(@GLenum int target, int lod, + @OutParameter + @BufferObject(BufferKind.PackPBO) + @Check + @GLvoid + ByteBuffer pImg); +} diff --git a/src/templates/org/lwjgl/opengl/ARB_texture_compression_bptc.java b/src/templates/org/lwjgl/opengl/ARB_texture_compression_bptc.java new file mode 100644 index 0000000..9ea5ab7 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/ARB_texture_compression_bptc.java @@ -0,0 +1,50 @@ +/* + * 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; + +import org.lwjgl.util.generator.Extension; + +@Extension(postfix = "ARB", className = "ARBTextureCompressionBPTC") +public interface ARB_texture_compression_bptc { + + /** + * Accepted by the <internalformat> parameter of TexImage2D, TexImage3D, + * CopyTexImage2D, CopyTexImage3D, CompressedTexImage2DARB, and + * CompressedTexImage3DARB and the <format> parameter of + * CompressedTexSubImage2DARB and CompressedTexSubImage3DARB: + */ + int GL_COMPRESSED_RGBA_BPTC_UNORM_ARB = 0x8E8C; + int GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB = 0x8E8D; + int GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB = 0x8E8E; + int GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB = 0x8E8F; + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/ARB_texture_compression_rgtc.java b/src/templates/org/lwjgl/opengl/ARB_texture_compression_rgtc.java new file mode 100644 index 0000000..a6ada35 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/ARB_texture_compression_rgtc.java @@ -0,0 +1,49 @@ +/* + * 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; + +import org.lwjgl.util.generator.Extension; + +@Extension(postfix = "ARB", className = "ARBTextureCompressionRGTC") +public interface ARB_texture_compression_rgtc { + + /** + * Accepted by the <internalformat> parameter of TexImage2D, + * CopyTexImage2D, and CompressedTexImage2D and the <format> parameter + * of CompressedTexSubImage2D: + */ + int GL_COMPRESSED_RED_RGTC1 = 0x8DBB; + int GL_COMPRESSED_SIGNED_RED_RGTC1 = 0x8DBC; + int GL_COMPRESSED_RED_GREEN_RGTC2 = 0x8DBD; + int GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2 = 0x8DBE; + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/ARB_texture_cube_map.java b/src/templates/org/lwjgl/opengl/ARB_texture_cube_map.java new file mode 100644 index 0000000..eb41182 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/ARB_texture_cube_map.java @@ -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.opengl; + +public interface ARB_texture_cube_map { + int GL_NORMAL_MAP_ARB = 0x8511; + int GL_REFLECTION_MAP_ARB = 0x8512; + int GL_TEXTURE_CUBE_MAP_ARB = 0x8513; + int GL_TEXTURE_BINDING_CUBE_MAP_ARB = 0x8514; + int GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB = 0x8515; + int GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB = 0x8516; + int GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB = 0x8517; + int GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB = 0x8518; + int GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB = 0x8519; + int GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB = 0x851A; + int GL_PROXY_TEXTURE_CUBE_MAP_ARB = 0x851B; + int GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB = 0x851C; +} diff --git a/src/templates/org/lwjgl/opengl/ARB_texture_cube_map_array.java b/src/templates/org/lwjgl/opengl/ARB_texture_cube_map_array.java new file mode 100644 index 0000000..dd5d95e --- /dev/null +++ b/src/templates/org/lwjgl/opengl/ARB_texture_cube_map_array.java @@ -0,0 +1,65 @@ +/* + * 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; + +public interface ARB_texture_cube_map_array { + + /** + * Accepted by the <target> parameter of TexParameteri, TexParameteriv, + * TexParameterf, TexParameterfv, BindTexture, and GenerateMipmap: + *

    + * Accepted by the <target> parameter of TexImage3D, TexSubImage3D, + * CompressedTeximage3D, CompressedTexSubImage3D and CopyTexSubImage3D: + *

    + * Accepted by the <tex> parameter of GetTexImage: + */ + int GL_TEXTURE_CUBE_MAP_ARRAY_ARB = 0x9009; + + /** + * Accepted by the <pname> parameter of GetBooleanv, GetDoublev, + * GetIntegerv and GetFloatv: + */ + int GL_TEXTURE_BINDING_CUBE_MAP_ARRAY_ARB = 0x900A; + + /** + * Accepted by the <target> parameter of TexImage3D, TexSubImage3D, + * CompressedTeximage3D, CompressedTexSubImage3D and CopyTexSubImage3D: + */ + int GL_PROXY_TEXTURE_CUBE_MAP_ARRAY_ARB = 0x900B; + + /** Returned by the <type> parameter of GetActiveUniform: */ + int GL_SAMPLER_CUBE_MAP_ARRAY_ARB = 0x900C; + int GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW_ARB = 0x900D; + int GL_INT_SAMPLER_CUBE_MAP_ARRAY_ARB = 0x900E; + int GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY_ARB = 0x900F; + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/ARB_texture_env_add.java b/src/templates/org/lwjgl/opengl/ARB_texture_env_add.java new file mode 100644 index 0000000..5b3f0e6 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/ARB_texture_env_add.java @@ -0,0 +1,35 @@ +/* + * 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; + +public interface ARB_texture_env_add { +} diff --git a/src/templates/org/lwjgl/opengl/ARB_texture_env_combine.java b/src/templates/org/lwjgl/opengl/ARB_texture_env_combine.java new file mode 100644 index 0000000..c733fcc --- /dev/null +++ b/src/templates/org/lwjgl/opengl/ARB_texture_env_combine.java @@ -0,0 +1,63 @@ +/* + * 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; + +public interface ARB_texture_env_combine { + int GL_COMBINE_ARB = 0x8570; + + int GL_COMBINE_RGB_ARB = 0x8571; + int GL_COMBINE_ALPHA_ARB = 0x8572; + + int GL_SOURCE0_RGB_ARB = 0x8580; + int GL_SOURCE1_RGB_ARB = 0x8581; + int GL_SOURCE2_RGB_ARB = 0x8582; + int GL_SOURCE0_ALPHA_ARB = 0x8588; + int GL_SOURCE1_ALPHA_ARB = 0x8589; + int GL_SOURCE2_ALPHA_ARB = 0x858A; + + int GL_OPERAND0_RGB_ARB = 0x8590; + int GL_OPERAND1_RGB_ARB = 0x8591; + int GL_OPERAND2_RGB_ARB = 0x8592; + int GL_OPERAND0_ALPHA_ARB = 0x8598; + int GL_OPERAND1_ALPHA_ARB = 0x8599; + int GL_OPERAND2_ALPHA_ARB = 0x859A; + + int GL_RGB_SCALE_ARB = 0x8573; + + int GL_ADD_SIGNED_ARB = 0x8574; + int GL_INTERPOLATE_ARB = 0x8575; + int GL_SUBTRACT_ARB = 0x84E7; + + int GL_CONSTANT_ARB = 0x8576; + int GL_PRIMARY_COLOR_ARB = 0x8577; + int GL_PREVIOUS_ARB = 0x8578; +} diff --git a/src/templates/org/lwjgl/opengl/ARB_texture_env_crossbar.java b/src/templates/org/lwjgl/opengl/ARB_texture_env_crossbar.java new file mode 100644 index 0000000..da2e481 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/ARB_texture_env_crossbar.java @@ -0,0 +1,35 @@ +/* + * 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; + +public interface ARB_texture_env_crossbar { +} diff --git a/src/templates/org/lwjgl/opengl/ARB_texture_env_dot3.java b/src/templates/org/lwjgl/opengl/ARB_texture_env_dot3.java new file mode 100644 index 0000000..7bcf541 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/ARB_texture_env_dot3.java @@ -0,0 +1,37 @@ +/* + * 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; + +public interface ARB_texture_env_dot3 { + int GL_DOT3_RGB_ARB = 0x86AE; + int GL_DOT3_RGBA_ARB = 0x86AF; +} diff --git a/src/templates/org/lwjgl/opengl/ARB_texture_float.java b/src/templates/org/lwjgl/opengl/ARB_texture_float.java new file mode 100644 index 0000000..652eb9d --- /dev/null +++ b/src/templates/org/lwjgl/opengl/ARB_texture_float.java @@ -0,0 +1,68 @@ +/* + * 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; + +public interface ARB_texture_float { + + /** + * Accepted by the <value> parameter of GetTexLevelParameter: + */ + int GL_TEXTURE_RED_TYPE_ARB = 0x8C10; + int GL_TEXTURE_GREEN_TYPE_ARB = 0x8C11; + int GL_TEXTURE_BLUE_TYPE_ARB = 0x8C12; + int GL_TEXTURE_ALPHA_TYPE_ARB = 0x8C13; + int GL_TEXTURE_LUMINANCE_TYPE_ARB = 0x8C14; + int GL_TEXTURE_INTENSITY_TYPE_ARB = 0x8C15; + int GL_TEXTURE_DEPTH_TYPE_ARB = 0x8C16; + + /** + * Returned by the <params> parameter of GetTexLevelParameter: + */ + int GL_UNSIGNED_NORMALIZED_ARB = 0x8C17; + + /** + * Accepted by the <internalFormat> parameter of TexImage1D, + * TexImage2D, and TexImage3D: + */ + int GL_RGBA32F_ARB = 0x8814; + int GL_RGB32F_ARB = 0x8815; + int GL_ALPHA32F_ARB = 0x8816; + int GL_INTENSITY32F_ARB = 0x8817; + int GL_LUMINANCE32F_ARB = 0x8818; + int GL_LUMINANCE_ALPHA32F_ARB = 0x8819; + int GL_RGBA16F_ARB = 0x881A; + int GL_RGB16F_ARB = 0x881B; + int GL_ALPHA16F_ARB = 0x881C; + int GL_INTENSITY16F_ARB = 0x881D; + int GL_LUMINANCE16F_ARB = 0x881E; + int GL_LUMINANCE_ALPHA16F_ARB = 0x881F; +} diff --git a/src/templates/org/lwjgl/opengl/ARB_texture_gather.java b/src/templates/org/lwjgl/opengl/ARB_texture_gather.java new file mode 100644 index 0000000..bc1af49 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/ARB_texture_gather.java @@ -0,0 +1,44 @@ +/* + * 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; + +public interface ARB_texture_gather { + + /** + * Accepted by the <pname> parameter of GetBooleanv, GetIntegerv, + * GetFloatv, and GetDoublev: + */ + int GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET_ARB = 0x8E5E; + int GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET_ARB = 0x8E5F; + int GL_MAX_PROGRAM_TEXTURE_GATHER_COMPONENTS_ARB = 0x8F9F; + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/ARB_texture_mirrored_repeat.java b/src/templates/org/lwjgl/opengl/ARB_texture_mirrored_repeat.java new file mode 100644 index 0000000..e952210 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/ARB_texture_mirrored_repeat.java @@ -0,0 +1,36 @@ +/* + * 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; + +public interface ARB_texture_mirrored_repeat { + int GL_MIRRORED_REPEAT_ARB = 0x8370; +} diff --git a/src/templates/org/lwjgl/opengl/ARB_texture_multisample.java b/src/templates/org/lwjgl/opengl/ARB_texture_multisample.java new file mode 100644 index 0000000..fe586bf --- /dev/null +++ b/src/templates/org/lwjgl/opengl/ARB_texture_multisample.java @@ -0,0 +1,111 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +import java.nio.FloatBuffer; + +@Extension(postfix = "") +public interface ARB_texture_multisample { + + /** Accepted by the <pname> parameter of GetMultisamplefv: */ + int GL_SAMPLE_POSITION = 0x8E50; + + /** + * Accepted by the <cap> parameter of Enable, Disable, and IsEnabled, and by + * the <pname> parameter of GetBooleanv, GetIntegerv, GetFloatv, and + * GetDoublev: + */ + int GL_SAMPLE_MASK = 0x8E51; + + /** + * Accepted by the <target> parameter of GetBooleani_v and + * GetIntegeri_v: + */ + int GL_SAMPLE_MASK_VALUE = 0x8E52; + + /** + * Accepted by the <target> parameter of BindTexture and + * TexImage2DMultisample: + */ + int GL_TEXTURE_2D_MULTISAMPLE = 0x9100; + + /** Accepted by the <target> parameter of TexImage2DMultisample: */ + int GL_PROXY_TEXTURE_2D_MULTISAMPLE = 0x9101; + + /** + * Accepted by the <target> parameter of BindTexture and + * TexImage3DMultisample: + */ + int GL_TEXTURE_2D_MULTISAMPLE_ARRAY = 0x9102; + + /** Accepted by the <target> parameter of TexImage3DMultisample: */ + int GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY = 0x9103; + + /** + * Accepted by the <pname> parameter of GetBooleanv, GetDoublev, GetIntegerv, + * and GetFloatv: + */ + int GL_MAX_SAMPLE_MASK_WORDS = 0x8E59; + int GL_MAX_COLOR_TEXTURE_SAMPLES = 0x910E; + int GL_MAX_DEPTH_TEXTURE_SAMPLES = 0x910F; + int GL_MAX_INTEGER_SAMPLES = 0x9110; + int GL_TEXTURE_BINDING_2D_MULTISAMPLE = 0x9104; + int GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY = 0x9105; + + /** Accepted by the <pname> parameter of GetTexLevelParameter */ + int GL_TEXTURE_SAMPLES = 0x9106; + int GL_TEXTURE_FIXED_SAMPLE_LOCATIONS = 0x9107; + + /** Returned by the <type> parameter of GetActiveUniform: */ + int GL_SAMPLER_2D_MULTISAMPLE = 0x9108; + int GL_INT_SAMPLER_2D_MULTISAMPLE = 0x9109; + int GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE = 0x910A; + int GL_SAMPLER_2D_MULTISAMPLE_ARRAY = 0x910B; + int GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY = 0x910C; + int GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY = 0x910D; + + void glTexImage2DMultisample(@GLenum int target, @GLsizei int samples, int internalformat, + @GLsizei int width, @GLsizei int height, + boolean fixedsamplelocations); + + void glTexImage3DMultisample(@GLenum int target, @GLsizei int samples, int internalformat, + @GLsizei int width, @GLsizei int height, @GLsizei int depth, + boolean fixedsamplelocations); + + @StripPostfix("val") + void glGetMultisamplefv(@GLenum int pname, @GLuint int index, @OutParameter @Check("2") FloatBuffer val); + + void glSampleMaski(@GLuint int index, @GLbitfield int mask); + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/ARB_texture_non_power_of_two.java b/src/templates/org/lwjgl/opengl/ARB_texture_non_power_of_two.java new file mode 100644 index 0000000..ece2a36 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/ARB_texture_non_power_of_two.java @@ -0,0 +1,35 @@ +/* + * 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; + +public interface ARB_texture_non_power_of_two { +} diff --git a/src/templates/org/lwjgl/opengl/ARB_texture_query_lod.java b/src/templates/org/lwjgl/opengl/ARB_texture_query_lod.java new file mode 100644 index 0000000..d54023a --- /dev/null +++ b/src/templates/org/lwjgl/opengl/ARB_texture_query_lod.java @@ -0,0 +1,35 @@ +/* + * 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; + +public interface ARB_texture_query_lod { +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/ARB_texture_rectangle.java b/src/templates/org/lwjgl/opengl/ARB_texture_rectangle.java new file mode 100644 index 0000000..87e1d48 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/ARB_texture_rectangle.java @@ -0,0 +1,78 @@ +/* + * 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; + +public interface ARB_texture_rectangle { + + /** + Accepted by the <cap> parameter of Enable, Disable and IsEnabled; + by the <pname> parameter of GetBooleanv, GetIntegerv, GetFloatv + and GetDoublev; and by the <target> parameter of BindTexture, + GetTexParameterfv, GetTexParameteriv, TexParameterf, TexParameteri, + TexParameterfv and TexParameteriv: + Accepted by the <target> parameter of GetTexImage, + GetTexLevelParameteriv, GetTexLevelParameterfv, TexImage2D, + CopyTexImage2D, TexSubImage2D and CopySubTexImage2D: + */ + int GL_TEXTURE_RECTANGLE_ARB = 0x84F5; + + /** + Accepted by the <pname> parameter of GetBooleanv, GetIntegerv, + GetFloatv and GetDoublev: + */ + int GL_TEXTURE_BINDING_RECTANGLE_ARB = 0x84F6; + + /** + Accepted by the <target> parameter of GetTexLevelParameteriv, + GetTexLevelParameterfv, GetTexParameteriv and TexImage2D: + */ + int GL_PROXY_TEXTURE_RECTANGLE_ARB = 0x84F7; + + /** + Accepted by the <pname> parameter of GetBooleanv, GetDoublev, + GetIntegerv and GetFloatv: + */ + int GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB = 0x84F8; + + /** + Returned by <type> parameter of GetActiveUniform when the location + <index> for program object <program> is of type sampler2DRect: + */ + int GL_SAMPLER_2D_RECT_ARB = 0x8B63; + + /** + Returned by <type> parameter of GetActiveUniform when the location + <index> for program object <program> is of type sampler2DRectShadow: + */ + int GL_SAMPLER_2D_RECT_SHADOW_ARB = 0x8B64; + +} diff --git a/src/templates/org/lwjgl/opengl/ARB_texture_rg.java b/src/templates/org/lwjgl/opengl/ARB_texture_rg.java new file mode 100644 index 0000000..1c6eb0b --- /dev/null +++ b/src/templates/org/lwjgl/opengl/ARB_texture_rg.java @@ -0,0 +1,80 @@ +/* + * 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; + +public interface ARB_texture_rg { + + /** + * Accepted by the <internalFormat> parameter of TexImage1D, TexImage2D, + * TexImage3D, CopyTexImage1D, and CopyTexImage2D: + */ + int GL_R8 = 0x8229; + int GL_R16 = 0x822A; + + int GL_RG8 = 0x822B; + int GL_RG16 = 0x822C; + + int GL_R16F = 0x822D; + int GL_R32F = 0x822E; + + int GL_RG16F = 0x822F; + int GL_RG32F = 0x8230; + + int GL_R8I = 0x8231; + int GL_R8UI = 0x8232; + int GL_R16I = 0x8233; + int GL_R16UI = 0x8234; + int GL_R32I = 0x8235; + int GL_R32UI = 0x8236; + + int GL_RG8I = 0x8237; + int GL_RG8UI = 0x8238; + int GL_RG16I = 0x8239; + int GL_RG16UI = 0x823A; + int GL_RG32I = 0x823B; + int GL_RG32UI = 0x823C; + + /** + * Accepted by the <format> parameter of TexImage3D, TexImage2D, + * TexImage3D, TexSubImage1D, TexSubImage2D, TexSubImage3D, + * DrawPixels and ReadPixels: + */ + int GL_RG = 0x8227; + int GL_RG_INTEGER = 0x8228; + + /** + * Accepted by the <param> parameter of the TexParameter{if}* + * functions when <pname> is DEPTH_TEXTURE_MODE: + */ + int GL_RED = 0x1903; + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/ARB_texture_rgb10_a2ui.java b/src/templates/org/lwjgl/opengl/ARB_texture_rgb10_a2ui.java new file mode 100644 index 0000000..abea10e --- /dev/null +++ b/src/templates/org/lwjgl/opengl/ARB_texture_rgb10_a2ui.java @@ -0,0 +1,46 @@ +/* + * 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; + +import org.lwjgl.util.generator.Extension; + +@Extension(postfix = "ARB", className = "ARBTextureRGB10_A2UI") +public interface ARB_texture_rgb10_a2ui { + + /** + * Accepted by the <internalFormat> parameter of TexImage1D, TexImage2D, + * TexImage3D, CopyTexImage1D, CopyTexImage2D, RenderbufferStorage and + * RenderbufferStorageMultisample: + */ + int GL_RGB10_A2UI = 0x906F; + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/ARB_texture_swizzle.java b/src/templates/org/lwjgl/opengl/ARB_texture_swizzle.java new file mode 100644 index 0000000..7cf6530 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/ARB_texture_swizzle.java @@ -0,0 +1,52 @@ +/* + * 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; + +public interface ARB_texture_swizzle { + + /** + * Accepted by the <pname> parameters of TexParameteri, + * TexParameterf, TexParameteriv, TexParameterfv, + * GetTexParameterfv, and GetTexParameteriv: + */ + int GL_TEXTURE_SWIZZLE_R = 0x8E42; + int GL_TEXTURE_SWIZZLE_G = 0x8E43; + int GL_TEXTURE_SWIZZLE_B = 0x8E44; + int GL_TEXTURE_SWIZZLE_A = 0x8E45; + + /** + * Accepted by the <pname> parameters of TexParameteriv, + * TexParameterfv, GetTexParameterfv, and GetTexParameteriv: + */ + int GL_TEXTURE_SWIZZLE_RGBA = 0x8E46; + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/ARB_timer_query.java b/src/templates/org/lwjgl/opengl/ARB_timer_query.java new file mode 100644 index 0000000..52ded87 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/ARB_timer_query.java @@ -0,0 +1,72 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +import java.nio.LongBuffer; + +@Extension(postfix = "") +public interface ARB_timer_query { + + /** + * Accepted by the <target> parameter of BeginQuery, EndQuery, and + * GetQueryiv: + */ + int GL_TIME_ELAPSED = 0x88BF; + + /** + * Accepted by the <target> parameter of GetQueryiv and QueryCounter. + * Accepted by the <value> parameter of GetBooleanv, GetIntegerv, + * GetInteger64v, GetFloatv, and GetDoublev: + */ + int GL_TIMESTAMP = 0x8E28; + + void glQueryCounter(@GLuint int id, @GLenum int target); + + @StripPostfix("params") + void glGetQueryObjecti64v(@GLuint int id, @GLenum int pname, @OutParameter @Check("1") @GLint64 LongBuffer params); + + @Alternate("glGetQueryObjecti64v") + @GLreturn("params") + @StripPostfix("params") + void glGetQueryObjecti64v2(@GLuint int id, @GLenum int pname, @OutParameter @GLint64 LongBuffer params); + + @StripPostfix("params") + void glGetQueryObjectui64v(@GLuint int id, @GLenum int pname, @OutParameter @Check("1") @GLuint64 LongBuffer params); + + @Alternate("glGetQueryObjectui64v") + @GLreturn("params") + @StripPostfix("params") + void glGetQueryObjectui64v2(@GLuint int id, @GLenum int pname, @OutParameter @GLuint64 LongBuffer params); + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/ARB_transform_feedback2.java b/src/templates/org/lwjgl/opengl/ARB_transform_feedback2.java new file mode 100644 index 0000000..49afd6a --- /dev/null +++ b/src/templates/org/lwjgl/opengl/ARB_transform_feedback2.java @@ -0,0 +1,72 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +import java.nio.IntBuffer; + +public interface ARB_transform_feedback2 { + + /** Accepted by the <target> parameter of BindTransformFeedback: */ + int GL_TRANSFORM_FEEDBACK = 0x8E22; + + /** + * Accepted by the <pname> parameter of GetBooleanv, GetDoublev, GetIntegerv, + * and GetFloatv: + */ + int GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED = 0x8E23; + int GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE = 0x8E24; + int GL_TRANSFORM_FEEDBACK_BINDING = 0x8E25; + + void glBindTransformFeedback(@GLenum int target, @GLuint int id); + + void glDeleteTransformFeedbacks(@AutoSize("ids") @GLsizei int n, @Const @GLuint IntBuffer ids); + + @Alternate("glDeleteTransformFeedbacks") + void glDeleteTransformFeedbacks(@Constant("1") @GLsizei int n, @Constant(value = "APIUtils.getBufferInt().put(0, id), 0", keepParam = true) int id); + + void glGenTransformFeedbacks(@AutoSize("ids") @GLsizei int n, @OutParameter @GLuint IntBuffer ids); + + @Alternate("glGenTransformFeedbacks") + @GLreturn("ids") + void glGenTransformFeedbacks2(@Constant("1") @GLsizei int n, @OutParameter @GLuint IntBuffer ids); + + boolean glIsTransformFeedback(@GLuint int id); + + void glPauseTransformFeedback(); + + void glResumeTransformFeedback(); + + void glDrawTransformFeedback(@GLenum int mode, @GLuint int id); + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/ARB_transform_feedback3.java b/src/templates/org/lwjgl/opengl/ARB_transform_feedback3.java new file mode 100644 index 0000000..da2e9cb --- /dev/null +++ b/src/templates/org/lwjgl/opengl/ARB_transform_feedback3.java @@ -0,0 +1,62 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +import java.nio.IntBuffer; + +@Extension(postfix = "") +public interface ARB_transform_feedback3 { + + /** + * Accepted by the <pname> parameter of GetBooleanv, GetDoublev, GetIntegerv, + * and GetFloatv: + */ + int GL_MAX_TRANSFORM_FEEDBACK_BUFFERS = 0x8E70; + int GL_MAX_VERTEX_STREAMS = 0x8E71; + + void glDrawTransformFeedbackStream(@GLenum int mode, @GLuint int id, @GLuint int stream); + + void glBeginQueryIndexed(@GLenum int target, @GLuint int index, @GLuint int id); + + void glEndQueryIndexed(@GLenum int target, @GLuint int index); + + @StripPostfix("params") + void glGetQueryIndexediv(@GLenum int target, @GLuint int index, @GLenum int pname, @OutParameter @Check("1") IntBuffer params); + + @Alternate("glGetQueryIndexediv") + @GLreturn("params") + @StripPostfix("params") + void glGetQueryIndexediv2(@GLenum int target, @GLuint int index, @GLenum int pname, @OutParameter IntBuffer params); + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/ARB_transpose_matrix.java b/src/templates/org/lwjgl/opengl/ARB_transpose_matrix.java new file mode 100644 index 0000000..e160b51 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/ARB_transpose_matrix.java @@ -0,0 +1,49 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +import java.nio.*; + +public interface ARB_transpose_matrix { + int GL_TRANSPOSE_MODELVIEW_MATRIX_ARB = 0x84E3; + int GL_TRANSPOSE_PROJECTION_MATRIX_ARB = 0x84E4; + int GL_TRANSPOSE_TEXTURE_MATRIX_ARB = 0x84E5; + int GL_TRANSPOSE_COLOR_MATRIX_ARB = 0x84E6; + + @StripPostfix("pfMtx") + void glLoadTransposeMatrixfARB(@Check("16") @Const FloatBuffer pfMtx); + + @StripPostfix("pfMtx") + void glMultTransposeMatrixfARB(@Check("16") @Const FloatBuffer pfMtx); +} diff --git a/src/templates/org/lwjgl/opengl/ARB_uniform_buffer_object.java b/src/templates/org/lwjgl/opengl/ARB_uniform_buffer_object.java new file mode 100644 index 0000000..9ee11c9 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/ARB_uniform_buffer_object.java @@ -0,0 +1,175 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +import java.nio.ByteBuffer; +import java.nio.IntBuffer; + +@Extension(postfix = "") +public interface ARB_uniform_buffer_object { + + /** + * Accepted by the <target> parameters of BindBuffer, BufferData, + * BufferSubData, MapBuffer, UnmapBuffer, GetBufferSubData, and + * GetBufferPointerv: + */ + int GL_UNIFORM_BUFFER = 0x8A11; + + /** + * Accepted by the <pname> parameter of GetIntegeri_v, GetBooleanv, + * GetIntegerv, GetFloatv, and GetDoublev: + */ + int GL_UNIFORM_BUFFER_BINDING = 0x8A28; + + /** Accepted by the <pname> parameter of GetIntegeri_v: */ + int GL_UNIFORM_BUFFER_START = 0x8A29; + int GL_UNIFORM_BUFFER_SIZE = 0x8A2A; + + /** + * Accepted by the <pname> parameter of GetBooleanv, GetIntegerv, + * GetFloatv, and GetDoublev: + */ + int GL_MAX_VERTEX_UNIFORM_BLOCKS = 0x8A2B; + int GL_MAX_GEOMETRY_UNIFORM_BLOCKS = 0x8A2C; + int GL_MAX_FRAGMENT_UNIFORM_BLOCKS = 0x8A2D; + int GL_MAX_COMBINED_UNIFORM_BLOCKS = 0x8A2E; + int GL_MAX_UNIFORM_BUFFER_BINDINGS = 0x8A2F; + int GL_MAX_UNIFORM_BLOCK_SIZE = 0x8A30; + int GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS = 0x8A31; + int GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS = 0x8A32; + int GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS = 0x8A33; + int GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT = 0x8A34; + + /** Accepted by the <pname> parameter of GetProgramiv: */ + int GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH = 0x8A35; + int GL_ACTIVE_UNIFORM_BLOCKS = 0x8A36; + + /** Accepted by the <pname> parameter of GetActiveUniformsivARB: */ + int GL_UNIFORM_TYPE = 0x8A37; + int GL_UNIFORM_SIZE = 0x8A38; + int GL_UNIFORM_NAME_LENGTH = 0x8A39; + int GL_UNIFORM_BLOCK_INDEX = 0x8A3A; + int GL_UNIFORM_OFFSET = 0x8A3B; + int GL_UNIFORM_ARRAY_STRIDE = 0x8A3C; + int GL_UNIFORM_MATRIX_STRIDE = 0x8A3D; + int GL_UNIFORM_IS_ROW_MAJOR = 0x8A3E; + + /** Accepted by the <pname> parameter of GetActiveUniformBlockivARB: */ + int GL_UNIFORM_BLOCK_BINDING = 0x8A3F; + int GL_UNIFORM_BLOCK_DATA_SIZE = 0x8A40; + int GL_UNIFORM_BLOCK_NAME_LENGTH = 0x8A41; + int GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS = 0x8A42; + int GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES = 0x8A43; + int GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER = 0x8A44; + int GL_UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER = 0x8A45; + int GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER = 0x8A46; + + /** Returned by GetActiveUniformsivARB and GetUniformBlockIndexARB */ + int GL_INVALID_INDEX = 0xFFFFFFFF; + + void glGetUniformIndices(@GLuint int program, @AutoSize("uniformIndices") @GLsizei int uniformCount, + @Const @NullTerminated("uniformIndices.remaining()") @GLchar @StringList("uniformCount") ByteBuffer uniformNames, + @OutParameter @GLuint IntBuffer uniformIndices); + + @Alternate(value = "glGetUniformIndices") + void glGetUniformIndices(@GLuint int program, @Constant("uniformNames.length") @GLsizei int uniformCount, + @Const @NullTerminated @StringList("uniformCount") CharSequence[] uniformNames, + @OutParameter @Check("uniformNames.length") @GLuint IntBuffer uniformIndices); + + @StripPostfix("params") + void glGetActiveUniformsiv(@GLuint int program, @AutoSize("uniformIndices") @GLsizei int uniformCount, + @Const @GLuint IntBuffer uniformIndices, + @GLenum int pname, + @OutParameter @Check("uniformIndices.remaining()") @GLint IntBuffer params); + + @Alternate("glGetActiveUniformsiv") + @GLreturn("params") + @StripPostfix("params") + void glGetActiveUniformsiv(@GLuint int program, @Constant("1") @GLsizei int uniformCount, + @Constant(value = "params.put(1, uniformIndex), 1", keepParam = true) int uniformIndex, // Reuse params buffer + @GLenum int pname, + @OutParameter @GLint IntBuffer params); + + void glGetActiveUniformName(@GLuint int program, @GLuint int uniformIndex, @AutoSize("uniformName") @GLsizei int bufSize, + @OutParameter @GLsizei @Check(value = "1", canBeNull = true) IntBuffer length, + @OutParameter @GLchar ByteBuffer uniformName); + + @Alternate("glGetActiveUniformName") + @GLreturn(value = "uniformName", maxLength = "bufSize") + void glGetActiveUniformName2(@GLuint int program, @GLuint int uniformIndex, @GLsizei int bufSize, + @OutParameter @GLsizei @Constant("uniformName_length, 0") IntBuffer length, + @OutParameter @GLchar ByteBuffer uniformName); + + @GLuint + int glGetUniformBlockIndex(@GLuint int program, @Const @NullTerminated @GLchar ByteBuffer uniformBlockName); + + @Alternate("glGetUniformBlockIndex") + @GLuint + int glGetUniformBlockIndex(@GLuint int program, @NullTerminated CharSequence uniformBlockName); + + @StripPostfix("params") + void glGetActiveUniformBlockiv(@GLuint int program, @GLuint int uniformBlockIndex, @GLenum int pname, + @OutParameter @Check(value = "16") @GLint IntBuffer params); + + @Alternate("glGetActiveUniformBlockiv") + @GLreturn("params") + @StripPostfix("params") + void glGetActiveUniformBlockiv2(@GLuint int program, @GLuint int uniformBlockIndex, @GLenum int pname, + @OutParameter @GLint IntBuffer params); + + void glGetActiveUniformBlockName(@GLuint int program, @GLuint int uniformBlockIndex, @AutoSize("uniformBlockName") @GLsizei int bufSize, + @OutParameter @GLsizei @Check(value = "1", canBeNull = true) IntBuffer length, + @OutParameter @GLchar ByteBuffer uniformBlockName); + + @Alternate("glGetActiveUniformBlockName") + @GLreturn(value = "uniformBlockName", maxLength = "bufSize") + void glGetActiveUniformBlockName2(@GLuint int program, @GLuint int uniformBlockIndex, @GLsizei int bufSize, + @OutParameter @GLsizei @Constant("uniformBlockName_length, 0") IntBuffer length, + @OutParameter @GLchar ByteBuffer uniformBlockName); + + void glBindBufferRange(@GLenum int target, @GLuint int index, @GLuint int buffer, @GLintptr long offset, @GLsizeiptr long size); + + void glBindBufferBase(@GLenum int target, @GLuint int index, @GLuint int buffer); + + @StripPostfix(value = "data", extension = "") + void glGetIntegeri_v(@GLenum int value, @GLuint int index, @OutParameter @Check("4") IntBuffer data); + + @Alternate("glGetIntegeri_v") + @GLreturn("data") + @StripPostfix("data") + void glGetIntegeri_v2(@GLenum int value, @GLuint int index, @OutParameter IntBuffer data); + + void glUniformBlockBinding(@GLuint int program, @GLuint int uniformBlockIndex, @GLuint int uniformBlockBinding); + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/ARB_vertex_array_bgra.java b/src/templates/org/lwjgl/opengl/ARB_vertex_array_bgra.java new file mode 100644 index 0000000..fb6e7b8 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/ARB_vertex_array_bgra.java @@ -0,0 +1,42 @@ +/* + * 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; + +public interface ARB_vertex_array_bgra { + + /** + * Accepted by the <size> parameter of ColorPointer, + * SecondaryColorPointer, and VertexAttribPointer: + */ + int GL_BGRA = 0x80E1; + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/ARB_vertex_array_object.java b/src/templates/org/lwjgl/opengl/ARB_vertex_array_object.java new file mode 100644 index 0000000..4baa92b --- /dev/null +++ b/src/templates/org/lwjgl/opengl/ARB_vertex_array_object.java @@ -0,0 +1,61 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +import java.nio.IntBuffer; + +public interface ARB_vertex_array_object { + + /** + * Accepted by the <pname> parameter of GetBooleanv, GetIntegerv, + * GetFloatv, and GetDoublev: + */ + int GL_VERTEX_ARRAY_BINDING = 0x85B5; + + void glBindVertexArray(@GLuint int array); + + void glDeleteVertexArrays(@AutoSize("arrays") @GLsizei int n, @Const @GLuint IntBuffer arrays); + + @Alternate("glDeleteVertexArrays") + void glDeleteVertexArrays(@Constant("1") @GLsizei int n, @Constant(value = "APIUtils.getBufferInt().put(0, array), 0", keepParam = true) int array); + + void glGenVertexArrays(@AutoSize("arrays") @GLsizei int n, @OutParameter @GLuint IntBuffer arrays); + + @Alternate("glGenVertexArrays") + @GLreturn("arrays") + void glGenVertexArrays2(@Constant("1") @GLsizei int n, @OutParameter @GLuint IntBuffer arrays); + + boolean glIsVertexArray(@GLuint int array); + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/ARB_vertex_blend.java b/src/templates/org/lwjgl/opengl/ARB_vertex_blend.java new file mode 100644 index 0000000..80bcf1d --- /dev/null +++ b/src/templates/org/lwjgl/opengl/ARB_vertex_blend.java @@ -0,0 +1,122 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +import java.nio.*; + +public interface ARB_vertex_blend { + + int GL_MAX_VERTEX_UNITS_ARB = 0x86A4; + int GL_ACTIVE_VERTEX_UNITS_ARB = 0x86A5; + int GL_WEIGHT_SUM_UNITY_ARB = 0x86A6; + int GL_VERTEX_BLEND_ARB = 0x86A7; + int GL_CURRENT_WEIGHT_ARB = 0x86A8; + int GL_WEIGHT_ARRAY_TYPE_ARB = 0x86A9; + int GL_WEIGHT_ARRAY_STRIDE_ARB = 0x86AA; + int GL_WEIGHT_ARRAY_SIZE_ARB = 0x86AB; + int GL_WEIGHT_ARRAY_POINTER_ARB = 0x86AC; + int GL_WEIGHT_ARRAY_ARB = 0x86AD; + int GL_MODELVIEW0_ARB = 0x1700; + int GL_MODELVIEW1_ARB = 0x850a; + int GL_MODELVIEW2_ARB = 0x8722; + int GL_MODELVIEW3_ARB = 0x8723; + int GL_MODELVIEW4_ARB = 0x8724; + int GL_MODELVIEW5_ARB = 0x8725; + int GL_MODELVIEW6_ARB = 0x8726; + int GL_MODELVIEW7_ARB = 0x8727; + int GL_MODELVIEW8_ARB = 0x8728; + int GL_MODELVIEW9_ARB = 0x8729; + int GL_MODELVIEW10_ARB = 0x872A; + int GL_MODELVIEW11_ARB = 0x872B; + int GL_MODELVIEW12_ARB = 0x872C; + int GL_MODELVIEW13_ARB = 0x872D; + int GL_MODELVIEW14_ARB = 0x872E; + int GL_MODELVIEW15_ARB = 0x872F; + int GL_MODELVIEW16_ARB = 0x8730; + int GL_MODELVIEW17_ARB = 0x8731; + int GL_MODELVIEW18_ARB = 0x8732; + int GL_MODELVIEW19_ARB = 0x8733; + int GL_MODELVIEW20_ARB = 0x8734; + int GL_MODELVIEW21_ARB = 0x8735; + int GL_MODELVIEW22_ARB = 0x8736; + int GL_MODELVIEW23_ARB = 0x8737; + int GL_MODELVIEW24_ARB = 0x8738; + int GL_MODELVIEW25_ARB = 0x8739; + int GL_MODELVIEW26_ARB = 0x873A; + int GL_MODELVIEW27_ARB = 0x873B; + int GL_MODELVIEW28_ARB = 0x873C; + int GL_MODELVIEW29_ARB = 0x873D; + int GL_MODELVIEW30_ARB = 0x873E; + int GL_MODELVIEW31_ARB = 0x873F; + + @StripPostfix("pWeights") + void glWeightbvARB(@AutoSize("pWeights") int size, ByteBuffer pWeights); + + @StripPostfix("pWeights") + void glWeightsvARB(@AutoSize("pWeights") int size, ShortBuffer pWeights); + + @StripPostfix("pWeights") + void glWeightivARB(@AutoSize("pWeights") int size, IntBuffer pWeights); + + @StripPostfix("pWeights") + void glWeightfvARB(@AutoSize("pWeights") int size, FloatBuffer pWeights); + + @StripPostfix("pWeights") + void glWeightdvARB(@AutoSize("pWeights") int size, DoubleBuffer pWeights); + + @StripPostfix("pWeights") + void glWeightubvARB(@AutoSize("pWeights") int size, @GLubyte ByteBuffer pWeights); + + @StripPostfix("pWeights") + void glWeightusvARB(@AutoSize("pWeights") int size, @GLushort ShortBuffer pWeights); + + @StripPostfix("pWeights") + void glWeightuivARB(@AutoSize("pWeights") int size, @GLuint IntBuffer pWeights); + + void glWeightPointerARB(int size, @AutoType("pPointer") @GLenum int type, @GLsizei int stride, + @CachedReference + @BufferObject(BufferKind.ArrayVBO) + @Check + @Const + @GLbyte + @GLubyte + @GLshort + @GLushort + @GLint + @GLuint + @GLfloat + @GLdouble Buffer pPointer); + + void glVertexBlendARB(int count); +} diff --git a/src/templates/org/lwjgl/opengl/ARB_vertex_buffer_object.java b/src/templates/org/lwjgl/opengl/ARB_vertex_buffer_object.java new file mode 100644 index 0000000..913c8bd --- /dev/null +++ b/src/templates/org/lwjgl/opengl/ARB_vertex_buffer_object.java @@ -0,0 +1,65 @@ +/* + * 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; + +public interface ARB_vertex_buffer_object extends ARB_buffer_object { + + /** + * Accepted by the <target> parameters of BindBufferARB, BufferDataARB, + * BufferSubDataARB, MapBufferARB, UnmapBufferARB, + * GetBufferSubDataARB, GetBufferParameterivARB, and + * GetBufferPointervARB: + */ + int GL_ARRAY_BUFFER_ARB = 0x8892; + int GL_ELEMENT_ARRAY_BUFFER_ARB = 0x8893; + + /** + * Accepted by the <pname> parameter of GetBooleanv, GetIntegerv, + * GetFloatv, and GetDoublev: + */ + int GL_ARRAY_BUFFER_BINDING_ARB = 0x8894; + int GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB = 0x8895; + int GL_VERTEX_ARRAY_BUFFER_BINDING_ARB = 0x8896; + int GL_NORMAL_ARRAY_BUFFER_BINDING_ARB = 0x8897; + int GL_COLOR_ARRAY_BUFFER_BINDING_ARB = 0x8898; + int GL_INDEX_ARRAY_BUFFER_BINDING_ARB = 0x8899; + int GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB = 0x889A; + int GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB = 0x889B; + int GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB = 0x889C; + int GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB = 0x889D; + int GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB = 0x889E; + + /** + * Accepted by the <pname> parameter of GetVertexAttribivARB: + */ + int GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB = 0x889F; +} diff --git a/src/templates/org/lwjgl/opengl/ARB_vertex_program.java b/src/templates/org/lwjgl/opengl/ARB_vertex_program.java new file mode 100644 index 0000000..0e50fe5 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/ARB_vertex_program.java @@ -0,0 +1,150 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +import java.nio.*; + +public interface ARB_vertex_program extends ARB_program { + + /** + * Accepted by the <cap> parameter of Disable, Enable, and IsEnabled, by the + * <pname> parameter of GetBooleanv, GetIntegerv, GetFloatv, and GetDoublev, + * and by the <target> parameter of ProgramStringARB, BindProgramARB, + * ProgramEnvParameter4[df][v]ARB, ProgramLocalParameter4[df][v]ARB, + * GetProgramEnvParameter[df]vARB, GetProgramLocalParameter[df]vARB, + * GetProgramivARB, and GetProgramStringARB. + */ + int GL_VERTEX_PROGRAM_ARB = 0x8620; + + /** + * Accepted by the <cap> parameter of Disable, Enable, and IsEnabled, and by + * the <pname> parameter of GetBooleanv, GetIntegerv, GetFloatv, and + * GetDoublev: + */ + int GL_VERTEX_PROGRAM_POINT_SIZE_ARB = 0x8642; + int GL_VERTEX_PROGRAM_TWO_SIDE_ARB = 0x8643; + int GL_COLOR_SUM_ARB = 0x8458; + + /** Accepted by the <pname> parameter of GetVertexAttrib[dfi]vARB: */ + int GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB = 0x8622; + int GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB = 0x8623; + int GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB = 0x8624; + int GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB = 0x8625; + int GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB = 0x886A; + int GL_CURRENT_VERTEX_ATTRIB_ARB = 0x8626; + + /** Accepted by the <pname> parameter of GetVertexAttribPointervARB: */ + int GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB = 0x8645; + + /** Accepted by the <pname> parameter of GetProgramivARB: */ + int GL_PROGRAM_ADDRESS_REGISTERS_ARB = 0x88B0; + int GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB = 0x88B1; + int GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB = 0x88B2; + int GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB = 0x88B3; + + /** + * Accepted by the <pname> parameter of GetBooleanv, GetIntegerv, + * GetFloatv, and GetDoublev: + */ + int GL_MAX_VERTEX_ATTRIBS_ARB = 0x8869; + + @NoErrorCheck + void glVertexAttrib1sARB(@GLuint int index, short x); + + @NoErrorCheck + void glVertexAttrib1fARB(@GLuint int index, float x); + + @NoErrorCheck + void glVertexAttrib1dARB(@GLuint int index, double x); + + @NoErrorCheck + void glVertexAttrib2sARB(@GLuint int index, short x, short y); + + @NoErrorCheck + void glVertexAttrib2fARB(@GLuint int index, float x, float y); + + @NoErrorCheck + void glVertexAttrib2dARB(@GLuint int index, double x, double y); + + @NoErrorCheck + void glVertexAttrib3sARB(@GLuint int index, short x, short y, short z); + + @NoErrorCheck + void glVertexAttrib3fARB(@GLuint int index, float x, float y, float z); + + @NoErrorCheck + void glVertexAttrib3dARB(@GLuint int index, double x, double y, double z); + + @NoErrorCheck + void glVertexAttrib4sARB(@GLuint int index, short x, short y, short z, short w); + + @NoErrorCheck + void glVertexAttrib4fARB(@GLuint int index, float x, float y, float z, float w); + + @NoErrorCheck + void glVertexAttrib4dARB(@GLuint int index, double x, double y, double z, double w); + + @NoErrorCheck + void glVertexAttrib4NubARB(@GLuint int index, @GLubyte byte x, @GLubyte byte y, @GLubyte byte z, @GLubyte byte w); + + void glVertexAttribPointerARB(@GLuint int index, int size, @AutoType("buffer") @GLenum int type, boolean normalized, @GLsizei int stride, + @CachedReference(index = "index", name = "glVertexAttribPointer_buffer") + @BufferObject(BufferKind.ArrayVBO) + @Check + @Const + @GLbyte + @GLubyte + @GLshort + @GLushort + @GLint + @GLuint + @GLfloat + @GLdouble Buffer buffer); + + void glEnableVertexAttribArrayARB(@GLuint int index); + + void glDisableVertexAttribArrayARB(@GLuint int index); + + @StripPostfix("params") + void glGetVertexAttribfvARB(@GLuint int index, @GLenum int pname, @OutParameter @Check("4") FloatBuffer params); + + @StripPostfix("params") + void glGetVertexAttribdvARB(@GLuint int index, @GLenum int pname, @OutParameter @Check("4") DoubleBuffer params); + + @StripPostfix("params") + void glGetVertexAttribivARB(@GLuint int index, @GLenum int pname, @OutParameter @Check("4") IntBuffer params); + + @StripPostfix("result") + void glGetVertexAttribPointervARB(@GLuint int index, @GLenum int pname, @Result @GLvoid ByteBuffer result); +} diff --git a/src/templates/org/lwjgl/opengl/ARB_vertex_shader.java b/src/templates/org/lwjgl/opengl/ARB_vertex_shader.java new file mode 100644 index 0000000..d8b31ec --- /dev/null +++ b/src/templates/org/lwjgl/opengl/ARB_vertex_shader.java @@ -0,0 +1,209 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +import java.nio.*; + +public interface ARB_vertex_shader { + + /** + * Accepted by the <shaderType> argument of CreateShaderObjectARB and + * returned by the <params> parameter of GetObjectParameter{if}vARB: + */ + int GL_VERTEX_SHADER_ARB = 0x8B31; + + /** + * Accepted by the <pname> parameter of GetBooleanv, GetIntegerv, + * GetFloatv, and GetDoublev: + */ + int GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB = 0x8B4A; + int GL_MAX_VARYING_FLOATS_ARB = 0x8B4B; + int GL_MAX_VERTEX_ATTRIBS_ARB = 0x8869; + int GL_MAX_TEXTURE_IMAGE_UNITS_ARB = 0x8872; + int GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB = 0x8B4C; + int GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB = 0x8B4D; + int GL_MAX_TEXTURE_COORDS_ARB = 0x8871; + + /** + * Accepted by the <cap> parameter of Disable, Enable, and IsEnabled, and + * by the <pname> parameter of GetBooleanv, GetIntegerv, GetFloatv, and + * GetDoublev: + */ + int GL_VERTEX_PROGRAM_POINT_SIZE_ARB = 0x8642; + int GL_VERTEX_PROGRAM_TWO_SIDE_ARB = 0x8643; + + /** Accepted by the <pname> parameter GetObjectParameter{if}vARB: */ + int GL_OBJECT_ACTIVE_ATTRIBUTES_ARB = 0x8B89; + int GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB = 0x8B8A; + + /** Accepted by the <pname> parameter of GetVertexAttrib{dfi}vARB: */ + int GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB = 0x8622; + int GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB = 0x8623; + int GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB = 0x8624; + int GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB = 0x8625; + int GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB = 0x886A; + int GL_CURRENT_VERTEX_ATTRIB_ARB = 0x8626; + + /** Accepted by the <pname> parameter of GetVertexAttribPointervARB: */ + int GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB = 0x8645; + + /** Returned by the <type> parameter of GetActiveAttribARB: */ + int GL_FLOAT = 0x1406; + int GL_FLOAT_VEC2_ARB = 0x8B50; + int GL_FLOAT_VEC3_ARB = 0x8B51; + int GL_FLOAT_VEC4_ARB = 0x8B52; + int GL_FLOAT_MAT2_ARB = 0x8B5A; + int GL_FLOAT_MAT3_ARB = 0x8B5B; + int GL_FLOAT_MAT4_ARB = 0x8B5C; + + @NoErrorCheck + void glVertexAttrib1sARB(@GLuint int index, short v0); + + @NoErrorCheck + void glVertexAttrib1fARB(@GLuint int index, float v0); + + @NoErrorCheck + void glVertexAttrib1dARB(@GLuint int index, double v0); + + @NoErrorCheck + void glVertexAttrib2sARB(@GLuint int index, short v0, short v1); + + @NoErrorCheck + void glVertexAttrib2fARB(@GLuint int index, float v0, float v1); + + @NoErrorCheck + void glVertexAttrib2dARB(@GLuint int index, double v0, double v1); + + @NoErrorCheck + void glVertexAttrib3sARB(@GLuint int index, short v0, short v1, short v2); + + @NoErrorCheck + void glVertexAttrib3fARB(@GLuint int index, float v0, float v1, float v2); + + @NoErrorCheck + void glVertexAttrib3dARB(@GLuint int index, double v0, double v1, double v2); + + @NoErrorCheck + void glVertexAttrib4sARB(@GLuint int index, short v0, short v1, short v2, short v3); + + @NoErrorCheck + void glVertexAttrib4fARB(@GLuint int index, float v0, float v1, float v2, float v3); + + @NoErrorCheck + void glVertexAttrib4dARB(@GLuint int index, double v0, double v1, double v2, double v3); + + @NoErrorCheck + void glVertexAttrib4NubARB(@GLuint int index, @GLubyte byte x, @GLubyte byte y, @GLubyte byte z, @GLubyte byte w); + + void glVertexAttribPointerARB(@GLuint int index, int size, @AutoType("buffer") @GLenum int type, boolean normalized, @GLsizei int stride, + @CachedReference(index = "index", name = "glVertexAttribPointer_buffer") + @BufferObject(BufferKind.ArrayVBO) + @Check + @Const + @GLbyte + @GLubyte + @GLshort + @GLushort + @GLint + @GLuint + @GLfloat + @GLdouble Buffer buffer); + + void glEnableVertexAttribArrayARB(@GLuint int index); + + void glDisableVertexAttribArrayARB(@GLuint int index); + + void glBindAttribLocationARB(@GLhandleARB int programObj, @GLuint int index, @NullTerminated @Const @GLcharARB ByteBuffer name); + + @Alternate("glBindAttribLocationARB") + void glBindAttribLocationARB(@GLhandleARB int programObj, @GLuint int index, @NullTerminated CharSequence name); + + void glGetActiveAttribARB(@GLhandleARB int programObj, @GLuint int index, @AutoSize("name") @GLsizei int maxLength, + @OutParameter @GLsizei @Check(value = "1", canBeNull = true) IntBuffer length, + @OutParameter @Check("1") IntBuffer size, + @OutParameter @GLenum @Check("1") IntBuffer type, + @OutParameter @GLcharARB ByteBuffer name); + + /** Overloads glGetActiveAttribARB. This version returns both size and type in the sizeType buffer (at .position() and .position() + 1). */ + @Alternate("glGetActiveAttribARB") + @GLreturn(value = "name", maxLength = "maxLength") + void glGetActiveAttribARB2(@GLhandleARB int programObj, @GLuint int index, @GLsizei int maxLength, + @OutParameter @GLsizei @Constant("name_length, 0") IntBuffer length, + @OutParameter @Check("2") IntBuffer sizeType, + @OutParameter @GLenum @Constant("sizeType, sizeType.position() + 1") IntBuffer type, + @OutParameter @GLcharARB ByteBuffer name); + + /** Overloads glGetActiveAttribARB. This version returns only the attrib name. */ + @Alternate(value = "glGetActiveAttribARB", javaAlt = true) + @GLreturn(value = "name", maxLength = "maxLength") + void glGetActiveAttribARB(@GLhandleARB int programObj, @GLuint int index, @GLsizei int maxLength, + @OutParameter @GLsizei @Constant("name_length, 0, APIUtils.getBufferInt(), 0, APIUtils.getBufferInt(), 1") IntBuffer length, + @OutParameter @GLcharARB ByteBuffer name); + + /** Overloads glGetActiveAttribARB. This version returns only the attrib size. */ + @Alternate(value = "glGetActiveAttribARB", javaAlt = true) + @GLreturn(value = "size") + void glGetActiveAttribSizeARB(@GLhandleARB int programObj, @GLuint int index, @Constant("0") @GLsizei int maxLength, + @OutParameter @GLsizei @Constant("null, 0") IntBuffer length, + @OutParameter IntBuffer size, + @OutParameter @GLenum @Constant("size, 1") IntBuffer type, // Reuse size buffer and ignore + @OutParameter @GLcharARB @Constant("APIUtils.getBufferByte(0), 0") ByteBuffer name); + + /** Overloads glGetActiveAttribARB. This version returns only the attrib type. */ + @Alternate(value = "glGetActiveAttribARB", javaAlt = true) + @GLreturn(value = "type") + void glGetActiveAttribTypeARB(@GLhandleARB int programObj, @GLuint int index, @Constant("0") @GLsizei int maxLength, + @OutParameter @GLsizei @Constant("null, 0") IntBuffer length, + @OutParameter @Constant("type, 1") IntBuffer size, // Reuse type buffer and ignore + @OutParameter @GLenum IntBuffer type, + @OutParameter @GLcharARB @Constant("APIUtils.getBufferByte(0), 0") ByteBuffer name); + + int glGetAttribLocationARB(@GLhandleARB int programObj, @NullTerminated @Const @GLcharARB ByteBuffer name); + + @Alternate("glGetAttribLocationARB") + int glGetAttribLocationARB(@GLhandleARB int programObj, @NullTerminated CharSequence name); + + @StripPostfix("params") + void glGetVertexAttribfvARB(@GLuint int index, @GLenum int pname, @OutParameter @Check("4") FloatBuffer params); + + @StripPostfix("params") + void glGetVertexAttribdvARB(@GLuint int index, @GLenum int pname, @OutParameter @Check("4") DoubleBuffer params); + + @StripPostfix("params") + void glGetVertexAttribivARB(@GLuint int index, @GLenum int pname, @OutParameter @Check("4") IntBuffer params); + + @StripPostfix("result") + void glGetVertexAttribPointervARB(@GLuint int index, @GLenum int pname, @Result @GLvoid ByteBuffer result); + +} diff --git a/src/templates/org/lwjgl/opengl/ARB_vertex_type_2_10_10_10_rev.java b/src/templates/org/lwjgl/opengl/ARB_vertex_type_2_10_10_10_rev.java new file mode 100644 index 0000000..9912e8d --- /dev/null +++ b/src/templates/org/lwjgl/opengl/ARB_vertex_type_2_10_10_10_rev.java @@ -0,0 +1,183 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +import java.nio.IntBuffer; + +@Extension(postfix = "", className = "ARBVertexType2_10_10_10_REV") +public interface ARB_vertex_type_2_10_10_10_rev { + + /** + * Accepted by the <type> parameter of VertexAttribPointer, VertexPointer, + * NormalPointer, ColorPointer, SecondaryColorPointer, TexCoordPointer, + * VertexAttribP{1234}ui, VertexP*, TexCoordP*, MultiTexCoordP*, NormalP3ui, + * ColorP*, SecondaryColorP* and VertexAttribP* + */ + int GL_UNSIGNED_INT_2_10_10_10_REV = GL12.GL_UNSIGNED_INT_2_10_10_10_REV; + int GL_INT_2_10_10_10_REV = 0x8D9F; + + @NoErrorCheck + void glVertexP2ui(@GLenum int type, @GLuint int value); + + @NoErrorCheck + void glVertexP3ui(@GLenum int type, @GLuint int value); + + @NoErrorCheck + void glVertexP4ui(@GLenum int type, @GLuint int value); + + @NoErrorCheck + @StripPostfix("value") + void glVertexP2uiv(@GLenum int type, @Check("2") @Const @GLuint IntBuffer value); + + @NoErrorCheck + @StripPostfix("value") + void glVertexP3uiv(@GLenum int type, @Check("3") @Const @GLuint IntBuffer value); + + @NoErrorCheck + @StripPostfix("value") + void glVertexP4uiv(@GLenum int type, @Check("4") @Const @GLuint IntBuffer value); + + @NoErrorCheck + void glTexCoordP1ui(@GLenum int type, @GLuint int coords); + + @NoErrorCheck + void glTexCoordP2ui(@GLenum int type, @GLuint int coords); + + @NoErrorCheck + void glTexCoordP3ui(@GLenum int type, @GLuint int coords); + + @NoErrorCheck + void glTexCoordP4ui(@GLenum int type, @GLuint int coords); + + @NoErrorCheck + @StripPostfix("coords") + void glTexCoordP1uiv(@GLenum int type, @Check("1") @Const @GLuint IntBuffer coords); + + @NoErrorCheck + @StripPostfix("coords") + void glTexCoordP2uiv(@GLenum int type, @Check("2") @Const @GLuint IntBuffer coords); + + @NoErrorCheck + @StripPostfix("coords") + void glTexCoordP3uiv(@GLenum int type, @Check("3") @Const @GLuint IntBuffer coords); + + @NoErrorCheck + @StripPostfix("coords") + void glTexCoordP4uiv(@GLenum int type, @Check("4") @Const @GLuint IntBuffer coords); + + @NoErrorCheck + void glMultiTexCoordP1ui(@GLenum int texture, @GLenum int type, @GLuint int coords); + + @NoErrorCheck + void glMultiTexCoordP2ui(@GLenum int texture, @GLenum int type, @GLuint int coords); + + @NoErrorCheck + void glMultiTexCoordP3ui(@GLenum int texture, @GLenum int type, @GLuint int coords); + + @NoErrorCheck + void glMultiTexCoordP4ui(@GLenum int texture, @GLenum int type, @GLuint int coords); + + @NoErrorCheck + @StripPostfix("coords") + void glMultiTexCoordP1uiv(@GLenum int texture, @GLenum int type, @Check("1") @Const @GLuint IntBuffer coords); + + @NoErrorCheck + @StripPostfix("coords") + void glMultiTexCoordP2uiv(@GLenum int texture, @GLenum int type, @Check("2") @Const @GLuint IntBuffer coords); + + @NoErrorCheck + @StripPostfix("coords") + void glMultiTexCoordP3uiv(@GLenum int texture, @GLenum int type, @Check("3") @Const @GLuint IntBuffer coords); + + @NoErrorCheck + @StripPostfix("coords") + void glMultiTexCoordP4uiv(@GLenum int texture, @GLenum int type, @Check("4") @Const @GLuint IntBuffer coords); + + @NoErrorCheck + void glNormalP3ui(@GLenum int type, @GLuint int coords); + + @NoErrorCheck + @StripPostfix("coords") + void glNormalP3uiv(@GLenum int type, @Check("3") @Const @GLuint IntBuffer coords); + + @NoErrorCheck + void glColorP3ui(@GLenum int type, @GLuint int color); + + @NoErrorCheck + void glColorP4ui(@GLenum int type, @GLuint int color); + + @NoErrorCheck + @StripPostfix("color") + void glColorP3uiv(@GLenum int type, @Check("3") @Const @GLuint IntBuffer color); + + @NoErrorCheck + @StripPostfix("color") + void glColorP4uiv(@GLenum int type, @Check("4") @Const @GLuint IntBuffer color); + + @NoErrorCheck + void glSecondaryColorP3ui(@GLenum int type, @GLuint int color); + + @NoErrorCheck + @StripPostfix("color") + void glSecondaryColorP3uiv(@GLenum int type, @Check("3") @Const @GLuint IntBuffer color); + + @NoErrorCheck + void glVertexAttribP1ui(@GLuint int index, @GLenum int type, boolean normalized, @GLuint int value); + + @NoErrorCheck + void glVertexAttribP2ui(@GLuint int index, @GLenum int type, boolean normalized, @GLuint int value); + + @NoErrorCheck + void glVertexAttribP3ui(@GLuint int index, @GLenum int type, boolean normalized, @GLuint int value); + + @NoErrorCheck + void glVertexAttribP4ui(@GLuint int index, @GLenum int type, boolean normalized, @GLuint int value); + + @NoErrorCheck + @StripPostfix("value") + void glVertexAttribP1uiv(@GLuint int index, @GLenum int type, boolean normalized, @Check("1") @Const @GLuint IntBuffer value); + + @NoErrorCheck + @StripPostfix("value") + void glVertexAttribP2uiv(@GLuint int index, @GLenum int type, boolean normalized, @Check("2") @Const @GLuint IntBuffer value); + + @NoErrorCheck + @StripPostfix("value") + void glVertexAttribP3uiv(@GLuint int index, @GLenum int type, boolean normalized, @Check("3") @Const @GLuint IntBuffer value); + + @NoErrorCheck + @StripPostfix("value") + void glVertexAttribP4uiv(@GLuint int index, @GLenum int type, boolean normalized, @Check("4") @Const @GLuint IntBuffer value); + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/ARB_window_pos.java b/src/templates/org/lwjgl/opengl/ARB_window_pos.java new file mode 100644 index 0000000..e8cf8dd --- /dev/null +++ b/src/templates/org/lwjgl/opengl/ARB_window_pos.java @@ -0,0 +1,62 @@ +/* + * 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; + +import org.lwjgl.util.generator.DeprecatedGL; + +@DeprecatedGL +public interface ARB_window_pos { + + @DeprecatedGL + void glWindowPos2fARB(float x, float y); + + @DeprecatedGL + void glWindowPos2dARB(double x, double y); + + @DeprecatedGL + void glWindowPos2iARB(int x, int y); + + @DeprecatedGL + void glWindowPos2sARB(short x, short y); + + @DeprecatedGL + void glWindowPos3fARB(float x, float y, float z); + + @DeprecatedGL + void glWindowPos3dARB(double x, double y, double z); + + @DeprecatedGL + void glWindowPos3iARB(int x, int y, int z); + + @DeprecatedGL + void glWindowPos3sARB(short x, short y, short z); +} diff --git a/src/templates/org/lwjgl/opengl/ATI_draw_buffers.java b/src/templates/org/lwjgl/opengl/ATI_draw_buffers.java new file mode 100644 index 0000000..23495bf --- /dev/null +++ b/src/templates/org/lwjgl/opengl/ATI_draw_buffers.java @@ -0,0 +1,66 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +import java.nio.*; + +public interface ATI_draw_buffers { + + /** + * Accepted by the <pname> parameters of GetIntegerv, GetFloatv, + * and GetDoublev: + */ + int GL_MAX_DRAW_BUFFERS_ATI = 0x8824; + int GL_DRAW_BUFFER0_ATI = 0x8825; + int GL_DRAW_BUFFER1_ATI = 0x8826; + int GL_DRAW_BUFFER2_ATI = 0x8827; + int GL_DRAW_BUFFER3_ATI = 0x8828; + int GL_DRAW_BUFFER4_ATI = 0x8829; + int GL_DRAW_BUFFER5_ATI = 0x882A; + int GL_DRAW_BUFFER6_ATI = 0x882B; + int GL_DRAW_BUFFER7_ATI = 0x882C; + int GL_DRAW_BUFFER8_ATI = 0x882D; + int GL_DRAW_BUFFER9_ATI = 0x882E; + int GL_DRAW_BUFFER10_ATI = 0x882F; + int GL_DRAW_BUFFER11_ATI = 0x8830; + int GL_DRAW_BUFFER12_ATI = 0x8831; + int GL_DRAW_BUFFER13_ATI = 0x8832; + int GL_DRAW_BUFFER14_ATI = 0x8833; + int GL_DRAW_BUFFER15_ATI = 0x8834; + + void glDrawBuffersATI(@AutoSize("buffers") @GLsizei int size, @Const @GLenum IntBuffer buffers); + + @Alternate("glDrawBuffersATI") + void glDrawBuffersATI(@Constant("1") @GLsizei int size, @Constant(value = "APIUtils.getBufferInt().put(0, buffer), 0", keepParam = true) int buffer); +} diff --git a/src/templates/org/lwjgl/opengl/ATI_element_array.java b/src/templates/org/lwjgl/opengl/ATI_element_array.java new file mode 100644 index 0000000..e850d03 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/ATI_element_array.java @@ -0,0 +1,53 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +import java.nio.*; + +public interface ATI_element_array { + int GL_ELEMENT_ARRAY_ATI = 0x8768; + int GL_ELEMENT_ARRAY_TYPE_ATI = 0x8769; + int GL_ELEMENT_ARRAY_POINTER_ATI = 0x876A; + + void glElementPointerATI(@AutoType("pPointer") @GLenum int type, + @Check + @Const + @GLubyte + @GLushort + @GLuint Buffer pPointer); + + void glDrawElementArrayATI(@GLenum int mode, @GLsizei int count); + + void glDrawRangeElementArrayATI(@GLenum int mode, @GLuint int start, @GLuint int end, @GLsizei int count); +} diff --git a/src/templates/org/lwjgl/opengl/ATI_envmap_bumpmap.java b/src/templates/org/lwjgl/opengl/ATI_envmap_bumpmap.java new file mode 100644 index 0000000..1d5d523 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/ATI_envmap_bumpmap.java @@ -0,0 +1,59 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +import java.nio.*; + +public interface ATI_envmap_bumpmap { + int GL_BUMP_ROT_MATRIX_ATI = 0x8775; + int GL_BUMP_ROT_MATRIX_SIZE_ATI = 0x8776; + int GL_BUMP_NUM_TEX_UNITS_ATI = 0x8777; + int GL_BUMP_TEX_UNITS_ATI = 0x8778; + int GL_DUDV_ATI = 0x8779; + int GL_DU8DV8_ATI = 0x877A; + int GL_BUMP_ENVMAP_ATI = 0x877B; + int GL_BUMP_TARGET_ATI = 0x877C; + + @StripPostfix("param") + void glTexBumpParameterfvATI(@GLenum int pname, @Check("4") @Const FloatBuffer param); + + @StripPostfix("param") + void glTexBumpParameterivATI(@GLenum int pname, @Check("4") @Const IntBuffer param); + + @StripPostfix("param") + void glGetTexBumpParameterfvATI(@GLenum int pname, @OutParameter @Check("4") FloatBuffer param); + + @StripPostfix("param") + void glGetTexBumpParameterivATI(@GLenum int pname, @OutParameter @Check("4") IntBuffer param); +} diff --git a/src/templates/org/lwjgl/opengl/ATI_fragment_shader.java b/src/templates/org/lwjgl/opengl/ATI_fragment_shader.java new file mode 100644 index 0000000..b60f35a --- /dev/null +++ b/src/templates/org/lwjgl/opengl/ATI_fragment_shader.java @@ -0,0 +1,174 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +import java.nio.*; + +public interface ATI_fragment_shader { + + int GL_FRAGMENT_SHADER_ATI = 0x8920; + int GL_REG_0_ATI = 0x8921; + int GL_REG_1_ATI = 0x8922; + int GL_REG_2_ATI = 0x8923; + int GL_REG_3_ATI = 0x8924; + int GL_REG_4_ATI = 0x8925; + int GL_REG_5_ATI = 0x8926; + int GL_REG_6_ATI = 0x8927; + int GL_REG_7_ATI = 0x8928; + int GL_REG_8_ATI = 0x8929; + int GL_REG_9_ATI = 0x892A; + int GL_REG_10_ATI = 0x892B; + int GL_REG_11_ATI = 0x892C; + int GL_REG_12_ATI = 0x892D; + int GL_REG_13_ATI = 0x892E; + int GL_REG_14_ATI = 0x892F; + int GL_REG_15_ATI = 0x8930; + int GL_REG_16_ATI = 0x8931; + int GL_REG_17_ATI = 0x8932; + int GL_REG_18_ATI = 0x8933; + int GL_REG_19_ATI = 0x8934; + int GL_REG_20_ATI = 0x8935; + int GL_REG_21_ATI = 0x8936; + int GL_REG_22_ATI = 0x8937; + int GL_REG_23_ATI = 0x8938; + int GL_REG_24_ATI = 0x8939; + int GL_REG_25_ATI = 0x893A; + int GL_REG_26_ATI = 0x893B; + int GL_REG_27_ATI = 0x893C; + int GL_REG_28_ATI = 0x893D; + int GL_REG_29_ATI = 0x893E; + int GL_REG_30_ATI = 0x893F; + int GL_REG_31_ATI = 0x8940; + int GL_CON_0_ATI = 0x8941; + int GL_CON_1_ATI = 0x8942; + int GL_CON_2_ATI = 0x8943; + int GL_CON_3_ATI = 0x8944; + int GL_CON_4_ATI = 0x8945; + int GL_CON_5_ATI = 0x8946; + int GL_CON_6_ATI = 0x8947; + int GL_CON_7_ATI = 0x8948; + int GL_CON_8_ATI = 0x8949; + int GL_CON_9_ATI = 0x894A; + int GL_CON_10_ATI = 0x894B; + int GL_CON_11_ATI = 0x894C; + int GL_CON_12_ATI = 0x894D; + int GL_CON_13_ATI = 0x894E; + int GL_CON_14_ATI = 0x894F; + int GL_CON_15_ATI = 0x8950; + int GL_CON_16_ATI = 0x8951; + int GL_CON_17_ATI = 0x8952; + int GL_CON_18_ATI = 0x8953; + int GL_CON_19_ATI = 0x8954; + int GL_CON_20_ATI = 0x8955; + int GL_CON_21_ATI = 0x8956; + int GL_CON_22_ATI = 0x8957; + int GL_CON_23_ATI = 0x8958; + int GL_CON_24_ATI = 0x8959; + int GL_CON_25_ATI = 0x895A; + int GL_CON_26_ATI = 0x895B; + int GL_CON_27_ATI = 0x895C; + int GL_CON_28_ATI = 0x895D; + int GL_CON_29_ATI = 0x895E; + int GL_CON_30_ATI = 0x895F; + int GL_CON_31_ATI = 0x8960; + int GL_MOV_ATI = 0x8961; + int GL_ADD_ATI = 0x8963; + int GL_MUL_ATI = 0x8964; + int GL_SUB_ATI = 0x8965; + int GL_DOT3_ATI = 0x8966; + int GL_DOT4_ATI = 0x8967; + int GL_MAD_ATI = 0x8968; + int GL_LERP_ATI = 0x8969; + int GL_CND_ATI = 0x896A; + int GL_CND0_ATI = 0x896B; + int GL_DOT2_ADD_ATI = 0x896C; + int GL_SECONDARY_INTERPOLATOR_ATI = 0x896D; + int GL_NUM_FRAGMENT_REGISTERS_ATI = 0x896E; + int GL_NUM_FRAGMENT_CONSTANTS_ATI = 0x896F; + int GL_NUM_PASSES_ATI = 0x8970; + int GL_NUM_INSTRUCTIONS_PER_PASS_ATI = 0x8971; + int GL_NUM_INSTRUCTIONS_TOTAL_ATI = 0x8972; + int GL_NUM_INPUT_INTERPOLATOR_COMPONENTS_ATI = 0x8973; + int GL_NUM_LOOPBACK_COMPONENTS_ATI = 0x8974; + int GL_COLOR_ALPHA_PAIRING_ATI = 0x8975; + int GL_SWIZZLE_STR_ATI = 0x8976; + int GL_SWIZZLE_STQ_ATI = 0x8977; + int GL_SWIZZLE_STR_DR_ATI = 0x8978; + int GL_SWIZZLE_STQ_DQ_ATI = 0x8979; + int GL_SWIZZLE_STRQ_ATI = 0x897A; + int GL_SWIZZLE_STRQ_DQ_ATI = 0x897B; + int GL_RED_BIT_ATI = 0x00000001; + int GL_GREEN_BIT_ATI = 0x00000002; + int GL_BLUE_BIT_ATI = 0x00000004; + int GL_2X_BIT_ATI = 0x00000001; + int GL_4X_BIT_ATI = 0x00000002; + int GL_8X_BIT_ATI = 0x00000004; + int GL_HALF_BIT_ATI = 0x00000008; + int GL_QUARTER_BIT_ATI = 0x00000010; + int GL_EIGHTH_BIT_ATI = 0x00000020; + int GL_SATURATE_BIT_ATI = 0x00000040; + int GL_COMP_BIT_ATI = 0x00000002; + int GL_NEGATE_BIT_ATI = 0x00000004; + int GL_BIAS_BIT_ATI = 0x00000008; + + @GLuint + int glGenFragmentShadersATI(@GLuint int range); + + void glBindFragmentShaderATI(@GLuint int id); + + void glDeleteFragmentShaderATI(@GLuint int id); + + void glBeginFragmentShaderATI(); + + void glEndFragmentShaderATI(); + + void glPassTexCoordATI(@GLuint int dst, @GLuint int coord, @GLenum int swizzle); + + void glSampleMapATI(@GLuint int dst, @GLuint int interp, @GLenum int swizzle); + + void glColorFragmentOp1ATI(@GLenum int op, @GLuint int dst, @GLuint int dstMask, @GLuint int dstMod, @GLuint int arg1, @GLuint int arg1Rep, @GLuint int arg1Mod); + + void glColorFragmentOp2ATI(@GLenum int op, @GLuint int dst, @GLuint int dstMask, @GLuint int dstMod, @GLuint int arg1, @GLuint int arg1Rep, @GLuint int arg1Mod, @GLuint int arg2, @GLuint int arg2Rep, @GLuint int arg2Mod); + + void glColorFragmentOp3ATI(@GLenum int op, @GLuint int dst, @GLuint int dstMask, @GLuint int dstMod, @GLuint int arg1, @GLuint int arg1Rep, @GLuint int arg1Mod, @GLuint int arg2, @GLuint int arg2Rep, @GLuint int arg2Mod, @GLuint int arg3, @GLuint int arg3Rep, @GLuint int arg3Mod); + + void glAlphaFragmentOp1ATI(@GLenum int op, @GLuint int dst, @GLuint int dstMod, @GLuint int arg1, @GLuint int arg1Rep, @GLuint int arg1Mod); + + void glAlphaFragmentOp2ATI(@GLenum int op, @GLuint int dst, @GLuint int dstMod, @GLuint int arg1, @GLuint int arg1Rep, @GLuint int arg1Mod, @GLuint int arg2, @GLuint int arg2Rep, @GLuint int arg2Mod); + + void glAlphaFragmentOp3ATI(@GLenum int op, @GLuint int dst, @GLuint int dstMod, @GLuint int arg1, @GLuint int arg1Rep, @GLuint int arg1Mod, @GLuint int arg2, @GLuint int arg2Rep, @GLuint int arg2Mod, @GLuint int arg3, @GLuint int arg3Rep, @GLuint int arg3Mod); + + // TODO:is the @Check correct? + void glSetFragmentShaderConstantATI(@GLuint int dst, @Check("4") @Const FloatBuffer pfValue); +} diff --git a/src/templates/org/lwjgl/opengl/ATI_map_object_buffer.java b/src/templates/org/lwjgl/opengl/ATI_map_object_buffer.java new file mode 100644 index 0000000..2de7846 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/ATI_map_object_buffer.java @@ -0,0 +1,70 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +import java.nio.*; + +public interface ATI_map_object_buffer { + + /** + * glMapObjectBufferATI maps an ATI vertex array object to a ByteBuffer. The old_buffer argument can be null, + * in which case a new ByteBuffer will be created, pointing to the returned memory. If old_buffer is non-null, + * it will be returned if it points to the same mapped memory and has the same capacity as the vertex array object, + * otherwise a new ByteBuffer is created. That way, an application will normally use glMapObjectBufferATI like this: + *

    + * ByteBuffer mapped_buffer; mapped_buffer = glMapObjectBufferATI(..., null); ... // Another map on the same buffer mapped_buffer = glMapObjectBufferATI(..., mapped_buffer); + *

    + * Only ByteBuffers returned from this method are to be passed as the old_buffer argument. User-created ByteBuffers cannot be reused. + *

    + * The version of this method without an explicit length argument calls glGetObjectBufferATI internally to + * retrieve the current vertex array object size, which may cause a pipeline flush and reduce application performance. + *

    + * The version of this method with an explicit length argument is a fast alternative to the one without. No GL call + * is made to retrieve the vertex array object size, so the user is responsible for tracking and using the appropriate length.
    + * Security warning: The length argument should match the vertex array object size. Reading from or writing to outside + * the memory region that corresponds to the mapped vertex array object will cause native crashes. + * + * @param length the length of the mapped memory in bytes. + * @param old_buffer A ByteBuffer. If this argument points to the same address and has the same capacity as the new mapping, it will be returned and no new buffer will be created. + * + * @return A ByteBuffer representing the mapped buffer memory. + */ + @CachedResult + @GLvoid + @AutoResultSize("GLChecks.getBufferObjectSizeATI(caps, buffer)") + ByteBuffer glMapObjectBufferATI(@GLuint int buffer); + + void glUnmapObjectBufferATI(@GLuint int buffer); + +} diff --git a/src/templates/org/lwjgl/opengl/ATI_meminfo.java b/src/templates/org/lwjgl/opengl/ATI_meminfo.java new file mode 100644 index 0000000..27c8351 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/ATI_meminfo.java @@ -0,0 +1,41 @@ +/* + * 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; + +public interface ATI_meminfo { + + /** Accepted by the <value> parameter of GetIntegerv: */ + int GL_VBO_FREE_MEMORY_ATI = 0x87FB; + int GL_TEXTURE_FREE_MEMORY_ATI = 0x87FC; + int GL_RENDERBUFFER_FREE_MEMORY_ATI = 0x87FD; + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/ATI_pn_triangles.java b/src/templates/org/lwjgl/opengl/ATI_pn_triangles.java new file mode 100644 index 0000000..5d7dbc7 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/ATI_pn_triangles.java @@ -0,0 +1,50 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +public interface ATI_pn_triangles { + int GL_PN_TRIANGLES_ATI = 0x87F0; + int GL_MAX_PN_TRIANGLES_TESSELATION_LEVEL_ATI = 0x87F1; + int GL_PN_TRIANGLES_POINT_MODE_ATI = 0x87F2; + int GL_PN_TRIANGLES_NORMAL_MODE_ATI = 0x87F3; + int GL_PN_TRIANGLES_TESSELATION_LEVEL_ATI = 0x87F4; + int GL_PN_TRIANGLES_POINT_MODE_LINEAR_ATI = 0x87F5; + int GL_PN_TRIANGLES_POINT_MODE_CUBIC_ATI = 0x87F6; + int GL_PN_TRIANGLES_NORMAL_MODE_LINEAR_ATI = 0x87F7; + int GL_PN_TRIANGLES_NORMAL_MODE_QUADRATIC_ATI = 0x87F8; + + void glPNTrianglesfATI(@GLenum int pname, float param); + + void glPNTrianglesiATI(@GLenum int pname, int param); +} diff --git a/src/templates/org/lwjgl/opengl/ATI_separate_stencil.java b/src/templates/org/lwjgl/opengl/ATI_separate_stencil.java new file mode 100644 index 0000000..1079192 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/ATI_separate_stencil.java @@ -0,0 +1,45 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +public interface ATI_separate_stencil { + int GL_STENCIL_BACK_FUNC_ATI = 0x8800; + int GL_STENCIL_BACK_FAIL_ATI = 0x8801; + int GL_STENCIL_BACK_PASS_DEPTH_FAIL_ATI = 0x8802; + int GL_STENCIL_BACK_PASS_DEPTH_PASS_ATI = 0x8803; + + void glStencilOpSeparateATI(@GLenum int face, @GLenum int sfail, @GLenum int dpfail, @GLenum int dppass); + + void glStencilFuncSeparateATI(@GLenum int frontfunc, @GLenum int backfunc, int ref, @GLuint int mask); +} diff --git a/src/templates/org/lwjgl/opengl/ATI_shader_texture_lod.java b/src/templates/org/lwjgl/opengl/ATI_shader_texture_lod.java new file mode 100644 index 0000000..ee7ac0d --- /dev/null +++ b/src/templates/org/lwjgl/opengl/ATI_shader_texture_lod.java @@ -0,0 +1,35 @@ +/* + * 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; + +public interface ATI_shader_texture_lod { +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/ATI_text_fragment_shader.java b/src/templates/org/lwjgl/opengl/ATI_text_fragment_shader.java new file mode 100644 index 0000000..795cb3d --- /dev/null +++ b/src/templates/org/lwjgl/opengl/ATI_text_fragment_shader.java @@ -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.opengl; + +public interface ATI_text_fragment_shader { + + /** + * Accepted by the <cap> parameter of Disable, Enable, and IsEnabled, + * and by the <pname> parameter of GetBooleanv, GetIntegerv, GetFloatv, + * and GetDoublev, and by the <target> parameter of ProgramStringARB, + * BindProgramARB, ProgramEnvParameter4{d,dv,f,fv}ARB, + * ProgramLocalParameter4{d,dv,f,fv}ARB, + * GetProgramEnvParameter{dv,fv}ARB, GetProgramLocalParameter{dv,fv}ARB, + * GetProgramivARB, GetProgramfvATI, and GetProgramStringARB. + */ + int GL_TEXT_FRAGMENT_SHADER_ATI = 0x8200; + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/ATI_texture_compression_3dc.java b/src/templates/org/lwjgl/opengl/ATI_texture_compression_3dc.java new file mode 100644 index 0000000..1fe4a40 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/ATI_texture_compression_3dc.java @@ -0,0 +1,39 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +@Extension(postfix = "ATI", className = "ATITextureCompression3DC") +public interface ATI_texture_compression_3dc { + int GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI = 0x8837; +} diff --git a/src/templates/org/lwjgl/opengl/ATI_texture_env_combine3.java b/src/templates/org/lwjgl/opengl/ATI_texture_env_combine3.java new file mode 100644 index 0000000..7bf1121 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/ATI_texture_env_combine3.java @@ -0,0 +1,45 @@ +/* + * 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; + +public interface ATI_texture_env_combine3 { + + /** + * Accepted by the <params> parameter of TexEnvf, TexEnvi, TexEnvfv, + * and TexEnviv when the <pname> parameter value is COMBINE_RGB_ARB + * or COMBINE_ALPHA_ARB + */ + int GL_MODULATE_ADD_ATI = 0x8744; + int GL_MODULATE_SIGNED_ADD_ATI = 0x8745; + int GL_MODULATE_SUBTRACT_ATI = 0x8746; + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/ATI_texture_float.java b/src/templates/org/lwjgl/opengl/ATI_texture_float.java new file mode 100644 index 0000000..d8405fc --- /dev/null +++ b/src/templates/org/lwjgl/opengl/ATI_texture_float.java @@ -0,0 +1,52 @@ +/* + * 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; + +public interface ATI_texture_float { + + /** + * Accepted by the <internalFormat> parameter of TexImage1D, + * TexImage2D, and TexImage3D: + */ + int GL_RGBA_FLOAT32_ATI = 0x8814; + int GL_RGB_FLOAT32_ATI = 0x8815; + int GL_ALPHA_FLOAT32_ATI = 0x8816; + int GL_INTENSITY_FLOAT32_ATI = 0x8817; + int GL_LUMINANCE_FLOAT32_ATI = 0x8818; + int GL_LUMINANCE_ALPHA_FLOAT32_ATI = 0x8819; + int GL_RGBA_FLOAT16_ATI = 0x881A; + int GL_RGB_FLOAT16_ATI = 0x881B; + int GL_ALPHA_FLOAT16_ATI = 0x881C; + int GL_INTENSITY_FLOAT16_ATI = 0x881D; + int GL_LUMINANCE_FLOAT16_ATI = 0x881E; + int GL_LUMINANCE_ALPHA_FLOAT16_ATI = 0x881F; +} diff --git a/src/templates/org/lwjgl/opengl/ATI_texture_mirror_once.java b/src/templates/org/lwjgl/opengl/ATI_texture_mirror_once.java new file mode 100644 index 0000000..e6692df --- /dev/null +++ b/src/templates/org/lwjgl/opengl/ATI_texture_mirror_once.java @@ -0,0 +1,37 @@ +/* + * 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; + +public interface ATI_texture_mirror_once { + int GL_MIRROR_CLAMP_ATI = 0x8742; + int GL_MIRROR_CLAMP_TO_EDGE_ATI = 0x8743; +} diff --git a/src/templates/org/lwjgl/opengl/ATI_vertex_array_object.java b/src/templates/org/lwjgl/opengl/ATI_vertex_array_object.java new file mode 100644 index 0000000..016b613 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/ATI_vertex_array_object.java @@ -0,0 +1,91 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +import java.nio.*; + +public interface ATI_vertex_array_object { + int GL_STATIC_ATI = 0x8760; + int GL_DYNAMIC_ATI = 0x8761; + int GL_PRESERVE_ATI = 0x8762; + int GL_DISCARD_ATI = 0x8763; + int GL_OBJECT_BUFFER_SIZE_ATI = 0x8764; + int GL_OBJECT_BUFFER_USAGE_ATI = 0x8765; + int GL_ARRAY_OBJECT_BUFFER_ATI = 0x8766; + int GL_ARRAY_OBJECT_OFFSET_ATI = 0x8767; + + @GenerateAutos + @GLuint + int glNewObjectBufferATI(@AutoSize("pPointer") @GLsizei int size, + @Const + @GLbyte + @GLshort + @GLint + @GLfloat + @GLdouble Buffer pPointer, @GLenum int usage); + + boolean glIsObjectBufferATI(@GLuint int buffer); + + void glUpdateObjectBufferATI(@GLuint int buffer, @GLuint int offset, @AutoSize("pPointer") @GLsizei int size, + @Const + @GLbyte + @GLshort + @GLint + @GLfloat + @GLdouble Buffer pPointer, @GLenum int preserve); + + @StripPostfix("params") + void glGetObjectBufferfvATI(@GLuint int buffer, @GLenum int pname, @OutParameter @Check FloatBuffer params); + + @StripPostfix("params") + void glGetObjectBufferivATI(@GLuint int buffer, @GLenum int pname, @OutParameter @Check IntBuffer params); + + void glFreeObjectBufferATI(@GLuint int buffer); + + void glArrayObjectATI(@GLenum int array, int size, @GLenum int type, @GLsizei int stride, @GLuint int buffer, @GLuint int offset); + + @StripPostfix("params") + void glGetArrayObjectfvATI(@GLenum int array, @GLenum int pname, @OutParameter @Check("4") FloatBuffer params); + + @StripPostfix("params") + void glGetArrayObjectivATI(@GLenum int array, @GLenum int pname, @OutParameter @Check("4") IntBuffer params); + + void glVariantArrayObjectATI(@GLuint int id, @GLenum int type, @GLsizei int stride, @GLuint int buffer, @GLuint int offset); + + @StripPostfix("params") + void glGetVariantArrayObjectfvATI(@GLuint int id, @GLenum int pname, @OutParameter @Check("4") FloatBuffer params); + + @StripPostfix("params") + void glGetVariantArrayObjectivATI(@GLuint int id, @GLenum int pname, @OutParameter @Check("4") IntBuffer params); +} diff --git a/src/templates/org/lwjgl/opengl/ATI_vertex_attrib_array_object.java b/src/templates/org/lwjgl/opengl/ATI_vertex_attrib_array_object.java new file mode 100644 index 0000000..e515521 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/ATI_vertex_attrib_array_object.java @@ -0,0 +1,46 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +import java.nio.*; + +public interface ATI_vertex_attrib_array_object { + void glVertexAttribArrayObjectATI(@GLuint int index, int size, @GLenum int type, boolean normalized, @GLsizei int stride, @GLuint int buffer, @GLuint int offset); + + @StripPostfix("params") + void glGetVertexAttribArrayObjectfvATI(@GLuint int index, @GLenum int pname, @OutParameter @Check("4") FloatBuffer params); + + @StripPostfix("params") + void glGetVertexAttribArrayObjectivATI(@GLuint int index, @GLenum int pname, @OutParameter @Check("4") IntBuffer params); +} diff --git a/src/templates/org/lwjgl/opengl/ATI_vertex_streams.java b/src/templates/org/lwjgl/opengl/ATI_vertex_streams.java new file mode 100644 index 0000000..7242ee7 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/ATI_vertex_streams.java @@ -0,0 +1,104 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +public interface ATI_vertex_streams { + int GL_MAX_VERTEX_STREAMS_ATI = 0x876B; + int GL_VERTEX_SOURCE_ATI = 0x876C; + int GL_VERTEX_STREAM0_ATI = 0x876D; + int GL_VERTEX_STREAM1_ATI = 0x876E; + int GL_VERTEX_STREAM2_ATI = 0x876F; + int GL_VERTEX_STREAM3_ATI = 0x8770; + int GL_VERTEX_STREAM4_ATI = 0x8771; + int GL_VERTEX_STREAM5_ATI = 0x8772; + int GL_VERTEX_STREAM6_ATI = 0x8773; + int GL_VERTEX_STREAM7_ATI = 0x8774; + + @NoErrorCheck + void glVertexStream2fATI(@GLenum int stream, float x, float y); + + @NoErrorCheck + void glVertexStream2dATI(@GLenum int stream, double x, double y); + + @NoErrorCheck + void glVertexStream2iATI(@GLenum int stream, int x, int y); + + @NoErrorCheck + void glVertexStream2sATI(@GLenum int stream, short x, short y); + + @NoErrorCheck + void glVertexStream3fATI(@GLenum int stream, float x, float y, float z); + + @NoErrorCheck + void glVertexStream3dATI(@GLenum int stream, double x, double y, double z); + + @NoErrorCheck + void glVertexStream3iATI(@GLenum int stream, int x, int y, int z); + + @NoErrorCheck + void glVertexStream3sATI(@GLenum int stream, short x, short y, short z); + + @NoErrorCheck + void glVertexStream4fATI(@GLenum int stream, float x, float y, float z, float w); + + @NoErrorCheck + void glVertexStream4dATI(@GLenum int stream, double x, double y, double z, double w); + + @NoErrorCheck + void glVertexStream4iATI(@GLenum int stream, int x, int y, int z, int w); + + @NoErrorCheck + void glVertexStream4sATI(@GLenum int stream, short x, short y, short z, short w); + + @NoErrorCheck + void glNormalStream3bATI(@GLenum int stream, byte x, byte y, byte z); + + @NoErrorCheck + void glNormalStream3fATI(@GLenum int stream, float x, float y, float z); + + @NoErrorCheck + void glNormalStream3dATI(@GLenum int stream, double x, double y, double z); + + @NoErrorCheck + void glNormalStream3iATI(@GLenum int stream, int x, int y, int z); + + @NoErrorCheck + void glNormalStream3sATI(@GLenum int stream, short x, short y, short z); + + void glClientActiveVertexStreamATI(@GLenum int stream); + + void glVertexBlendEnvfATI(@GLenum int pname, float param); + + void glVertexBlendEnviATI(@GLenum int pname, int param); +} diff --git a/src/templates/org/lwjgl/opengl/EXT_abgr.java b/src/templates/org/lwjgl/opengl/EXT_abgr.java new file mode 100644 index 0000000..09c9615 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/EXT_abgr.java @@ -0,0 +1,36 @@ +/* + * 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; + +public interface EXT_abgr { + int GL_ABGR_EXT = 0x8000; +} diff --git a/src/templates/org/lwjgl/opengl/EXT_bgra.java b/src/templates/org/lwjgl/opengl/EXT_bgra.java new file mode 100644 index 0000000..36e9d65 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/EXT_bgra.java @@ -0,0 +1,37 @@ +/* + * 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; + +public interface EXT_bgra { + int GL_BGR_EXT = 0x80E0; + int GL_BGRA_EXT = 0x80E1; +} diff --git a/src/templates/org/lwjgl/opengl/EXT_bindable_uniform.java b/src/templates/org/lwjgl/opengl/EXT_bindable_uniform.java new file mode 100644 index 0000000..789e290 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/EXT_bindable_uniform.java @@ -0,0 +1,63 @@ +/* + * 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; + +import org.lwjgl.util.generator.GLintptr; +import org.lwjgl.util.generator.GLuint; + +public interface EXT_bindable_uniform { + + /** + * Accepted by the <pname> parameter of GetBooleanv, GetIntegerv, GetFloatv, + * and GetDoublev: + */ + int GL_MAX_VERTEX_BINDABLE_UNIFORMS_EXT = 0x8DE2; + int GL_MAX_FRAGMENT_BINDABLE_UNIFORMS_EXT = 0x8DE3; + int GL_MAX_GEOMETRY_BINDABLE_UNIFORMS_EXT = 0x8DE4; + int GL_MAX_BINDABLE_UNIFORM_SIZE_EXT = 0x8DED; + int GL_UNIFORM_BUFFER_BINDING_EXT = 0x8DEF; + + /** + * Accepted by the <target> parameters of BindBuffer, BufferData, + * BufferSubData, MapBuffer, UnmapBuffer, GetBufferSubData, and + * GetBufferPointerv: + */ + int GL_UNIFORM_BUFFER_EXT = 0x8DEE; + + void glUniformBufferEXT(@GLuint int program, int location, @GLuint int buffer); + + int glGetUniformBufferSizeEXT(@GLuint int program, int location); + + @GLintptr + long glGetUniformOffsetEXT(@GLuint int program, int location); + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/EXT_blend_color.java b/src/templates/org/lwjgl/opengl/EXT_blend_color.java new file mode 100644 index 0000000..926245c --- /dev/null +++ b/src/templates/org/lwjgl/opengl/EXT_blend_color.java @@ -0,0 +1,52 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +public interface EXT_blend_color { + + /** Accepted by the <sfactor> and <dfactor> parameters of BlendFunc. */ + int GL_CONSTANT_COLOR_EXT = 0x8001; + int GL_ONE_MINUS_CONSTANT_COLOR_EXT = 0x8002; + int GL_CONSTANT_ALPHA_EXT = 0x8003; + int GL_ONE_MINUS_CONSTANT_ALPHA_EXT = 0x8004; + + /** + * Accepted by the <pname> parameter of GetBooleanv, GetIntegerv, + * GetFloatv, and GetDoublev. + */ + int GL_BLEND_COLOR_EXT = 0x8005; + + void glBlendColorEXT(@GLclampf float red, @GLclampf float green, @GLclampf float blue, @GLclampf float alpha); + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/EXT_blend_equation_separate.java b/src/templates/org/lwjgl/opengl/EXT_blend_equation_separate.java new file mode 100644 index 0000000..f7ff6a6 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/EXT_blend_equation_separate.java @@ -0,0 +1,46 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +public interface EXT_blend_equation_separate { + + /** + * Accepted by the <pname> parameter of GetBooleanv, GetIntegerv, + * GetFloatv, and GetDoublev: + */ + int GL_BLEND_EQUATION_RGB_EXT = 0x8009; + int GL_BLEND_EQUATION_ALPHA_EXT = 0x883D; + + void glBlendEquationSeparateEXT(@GLenum int modeRGB, @GLenum int modeAlpha); +} diff --git a/src/templates/org/lwjgl/opengl/EXT_blend_func_separate.java b/src/templates/org/lwjgl/opengl/EXT_blend_func_separate.java new file mode 100644 index 0000000..9d0b54b --- /dev/null +++ b/src/templates/org/lwjgl/opengl/EXT_blend_func_separate.java @@ -0,0 +1,43 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +public interface EXT_blend_func_separate { + int GL_BLEND_DST_RGB_EXT = 0x80C8; + int GL_BLEND_SRC_RGB_EXT = 0x80C9; + int GL_BLEND_DST_ALPHA_EXT = 0x80CA; + int GL_BLEND_SRC_ALPHA_EXT = 0x80CB; + + void glBlendFuncSeparateEXT(@GLenum int sfactorRGB, @GLenum int dfactorRGB, @GLenum int sfactorAlpha, @GLenum int dfactorAlpha); +} diff --git a/src/templates/org/lwjgl/opengl/EXT_blend_minmax.java b/src/templates/org/lwjgl/opengl/EXT_blend_minmax.java new file mode 100644 index 0000000..058adcf --- /dev/null +++ b/src/templates/org/lwjgl/opengl/EXT_blend_minmax.java @@ -0,0 +1,51 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +public interface EXT_blend_minmax { + + /** Accepted by the <mode> parameter of BlendEquationEXT. */ + int GL_FUNC_ADD_EXT = 0x8006; + int GL_MIN_EXT = 0x8007; + int GL_MAX_EXT = 0x8008; + + /** + * Accepted by the <pname> parameter of GetBooleanv, GetIntegerv, + * GetFloatv, and GetDoublev. + */ + int GL_BLEND_EQUATION_EXT = 0x8009; + + void glBlendEquationEXT(@GLenum int mode); + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/EXT_blend_subtract.java b/src/templates/org/lwjgl/opengl/EXT_blend_subtract.java new file mode 100644 index 0000000..df164cf --- /dev/null +++ b/src/templates/org/lwjgl/opengl/EXT_blend_subtract.java @@ -0,0 +1,37 @@ +/* + * 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; + +public interface EXT_blend_subtract { + int GL_FUNC_SUBTRACT_EXT = 0x800A; + int GL_FUNC_REVERSE_SUBTRACT_EXT = 0x800B; +} diff --git a/src/templates/org/lwjgl/opengl/EXT_cg_shader.java b/src/templates/org/lwjgl/opengl/EXT_cg_shader.java new file mode 100644 index 0000000..d253c11 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/EXT_cg_shader.java @@ -0,0 +1,44 @@ +/* + * 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; + +public interface EXT_Cg_shader { + + /** + * You can pass GL_CG_VERTEX_SHADER_EXT to glCreateShaderARB instead of GL_VERTEX_SHADER_ARB to create a vertex shader object + * that will parse and compile its shader source with the Cg compiler front-end rather than the GLSL front-end. Likewise, you + * can pass GL_CG_FRAGMENT_SHADER_EXT to glCreateShaderARB instead of GL_FRAGMENT_SHADER_ARB to create a fragment shader object + * that will parse and compile its shader source with the Cg front-end rather than the GLSL front-end. + */ + int GL_CG_VERTEX_SHADER_EXT = 0x890E; + int GL_CG_FRAGMENT_SHADER_EXT = 0x890F; +} diff --git a/src/templates/org/lwjgl/opengl/EXT_compiled_vertex_array.java b/src/templates/org/lwjgl/opengl/EXT_compiled_vertex_array.java new file mode 100644 index 0000000..0d0ab27 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/EXT_compiled_vertex_array.java @@ -0,0 +1,43 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +public interface EXT_compiled_vertex_array { + int GL_ARRAY_ELEMENT_LOCK_FIRST_EXT = 0x81A8; + int GL_ARRAY_ELEMENT_LOCK_COUNT_EXT = 0x81A9; + + void glLockArraysEXT(int first, @GLsizei int count); + + void glUnlockArraysEXT(); +} diff --git a/src/templates/org/lwjgl/opengl/EXT_depth_bounds_test.java b/src/templates/org/lwjgl/opengl/EXT_depth_bounds_test.java new file mode 100644 index 0000000..923474a --- /dev/null +++ b/src/templates/org/lwjgl/opengl/EXT_depth_bounds_test.java @@ -0,0 +1,52 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +public interface EXT_depth_bounds_test { + + /** + Accepted by the <cap> parameter of Enable, Disable, and IsEnabled, + and by the <pname> parameter of GetBooleanv, GetIntegerv, + GetFloatv, and GetDoublev: + */ + int GL_DEPTH_BOUNDS_TEST_EXT = 0x8890; + + /** + Accepted by the <pname> parameter of GetBooleanv, GetIntegerv, + GetFloatv, and GetDoublev: + */ + int GL_DEPTH_BOUNDS_EXT = 0x8891; + + void glDepthBoundsEXT(@GLclampd double zmin, @GLclampd double zmax); +} diff --git a/src/templates/org/lwjgl/opengl/EXT_direct_state_access.java b/src/templates/org/lwjgl/opengl/EXT_direct_state_access.java new file mode 100644 index 0000000..676e298 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/EXT_direct_state_access.java @@ -0,0 +1,1514 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +import java.nio.*; + +@ForceInit +@Dependent +@DeprecatedGL +public interface EXT_direct_state_access { + + /** + * Accepted by the <pname> parameter of GetBooleanIndexedvEXT, + * GetIntegerIndexedvEXT, GetFloatIndexedvEXT, GetDoubleIndexedvEXT: + * GetBooleani_v, GetIntegeri_v, GetFloati_vEXT, GetDoublei_vEXT: + */ + int GL_PROGRAM_MATRIX_EXT = 0x8E2D; + int GL_TRANSPOSE_PROGRAM_MATRIX_EXT = 0x8E2E; + int GL_PROGRAM_MATRIX_STACK_DEPTH_EXT = 0x8E2F; + + /* + OpenGL 1.1: New client commands + */ + + @DeprecatedGL + void glClientAttribDefaultEXT(@GLbitfield int mask); + + @DeprecatedGL + void glPushClientAttribDefaultEXT(@GLbitfield int mask); + + /* + OpenGL 1.0: New matrix commands add "Matrix" prefix to name, + drops "Matrix" suffix from name, and add initial "enum matrixMode" + parameter + */ + + @StripPostfix("m") + @DeprecatedGL + void glMatrixLoadfEXT(@GLenum int matrixMode, @Check("16") @Const FloatBuffer m); + + @StripPostfix("m") + @DeprecatedGL + void glMatrixLoaddEXT(@GLenum int matrixMode, @Check("16") @Const DoubleBuffer m); + + @StripPostfix("m") + @DeprecatedGL + void glMatrixMultfEXT(@GLenum int matrixMode, @Check("16") @Const FloatBuffer m); + + @StripPostfix("m") + @DeprecatedGL + void glMatrixMultdEXT(@GLenum int matrixMode, @Check("16") @Const DoubleBuffer m); + + @DeprecatedGL + void glMatrixLoadIdentityEXT(@GLenum int matrixMode); + + @DeprecatedGL + void glMatrixRotatefEXT(@GLenum int matrixMode, float angle, float x, float y, float z); + + @DeprecatedGL + void glMatrixRotatedEXT(@GLenum int matrixMode, double angle, double x, double y, double z); + + @DeprecatedGL + void glMatrixScalefEXT(@GLenum int matrixMode, float x, float y, float z); + + @DeprecatedGL + void glMatrixScaledEXT(@GLenum int matrixMode, double x, double y, double z); + + @DeprecatedGL + void glMatrixTranslatefEXT(@GLenum int matrixMode, float x, float y, float z); + + @DeprecatedGL + void glMatrixTranslatedEXT(@GLenum int matrixMode, double x, double y, double z); + + @DeprecatedGL + void glMatrixOrthoEXT(@GLenum int matrixMode, double l, double r, double b, double t, double n, double f); + + @DeprecatedGL + void glMatrixFrustumEXT(@GLenum int matrixMode, double l, double r, double b, double t, double n, double f); + + @DeprecatedGL + void glMatrixPushEXT(@GLenum int matrixMode); + + @DeprecatedGL + void glMatrixPopEXT(@GLenum int matrixMode); + + /* + OpenGL 1.1: New texture object commands and queries replace "Tex" + in name with "Texture" and add initial "uint texture" parameter + */ + + void glTextureParameteriEXT(@GLuint int texture, @GLenum int target, @GLenum int pname, int param); + + @StripPostfix("param") + void glTextureParameterivEXT(@GLuint int texture, @GLenum int target, @GLenum int pname, @Check("4") @Const IntBuffer param); + + void glTextureParameterfEXT(@GLuint int texture, @GLenum int target, @GLenum int pname, float param); + + @StripPostfix("param") + void glTextureParameterfvEXT(@GLuint int texture, @GLenum int target, @GLenum int pname, @Check("4") @Const FloatBuffer param); + + void glTextureImage1DEXT(@GLuint int texture, @GLenum int target, int level, + int internalformat, @GLsizei int width, int border, @GLenum int format, @GLenum int type, + @BufferObject(BufferKind.UnpackPBO) + @Check(value = "GLChecks.calculateTexImage1DStorage(pixels, format, type, width)", canBeNull = true) + @Const + @GLbyte + @GLshort + @GLint + @GLfloat + @GLdouble Buffer pixels); + + void glTextureImage2DEXT(@GLuint int texture, @GLenum int target, int level, + int internalformat, @GLsizei int width, @GLsizei int height, int border, @GLenum int format, @GLenum int type, + @BufferObject(BufferKind.UnpackPBO) + @Check(value = "GLChecks.calculateTexImage2DStorage(pixels, format, type, width, height)", canBeNull = true) + @Const + @GLbyte + @GLshort + @GLint + @GLfloat + @GLdouble Buffer pixels); + + void glTextureSubImage1DEXT(@GLuint int texture, @GLenum int target, int level, + int xoffset, @GLsizei int width, @GLenum int format, @GLenum int type, + @BufferObject(BufferKind.UnpackPBO) + @Check("GLChecks.calculateImageStorage(pixels, format, type, width, 1, 1)") + @Const + @GLbyte + @GLshort + @GLint + @GLfloat + @GLdouble Buffer pixels); + + void glTextureSubImage2DEXT(@GLuint int texture, @GLenum int target, int level, + int xoffset, int yoffset, @GLsizei int width, @GLsizei int height, @GLenum int format, @GLenum int type, + @BufferObject(BufferKind.UnpackPBO) + @Check("GLChecks.calculateImageStorage(pixels, format, type, width, height, 1)") + @Const + @GLbyte + @GLshort + @GLint + @GLfloat + @GLdouble Buffer pixels); + + void glCopyTextureImage1DEXT(@GLuint int texture, @GLenum int target, int level, @GLenum int internalformat, int x, int y, @GLsizei int width, int border); + + void glCopyTextureImage2DEXT(@GLuint int texture, @GLenum int target, int level, @GLenum int internalformat, int x, int y, @GLsizei int width, @GLsizei int height, int border); + + void glCopyTextureSubImage1DEXT(@GLuint int texture, @GLenum int target, int level, int xoffset, int x, int y, @GLsizei int width); + + void glCopyTextureSubImage2DEXT(@GLuint int texture, @GLenum int target, int level, int xoffset, int yoffset, int x, int y, @GLsizei int width, @GLsizei int height); + + void glGetTextureImageEXT(@GLuint int texture, @GLenum int target, int level, + @GLenum int format, @GLenum int type, + @OutParameter + @BufferObject(BufferKind.PackPBO) + @Check("GLChecks.calculateImageStorage(pixels, format, type, 1, 1, 1)") + @GLbyte + @GLshort + @GLint + @GLfloat + @GLdouble Buffer pixels); + + @StripPostfix("params") + void glGetTextureParameterfvEXT(@GLuint int texture, @GLenum int target, @GLenum int pname, @OutParameter @Check("4") FloatBuffer params); + + @Alternate("glGetTextureParameterfvEXT") + @GLreturn("params") + @StripPostfix(value = "params", postfix = "v") + void glGetTextureParameterfvEXT2(@GLuint int texture, @GLenum int target, @GLenum int pname, @OutParameter FloatBuffer params); + + @StripPostfix("params") + void glGetTextureParameterivEXT(@GLuint int texture, @GLenum int target, @GLenum int pname, @OutParameter @Check("4") IntBuffer params); + + @Alternate("glGetTextureParameterivEXT") + @GLreturn("params") + @StripPostfix(value = "params", postfix = "v") + void glGetTextureParameterivEXT2(@GLuint int texture, @GLenum int target, @GLenum int pname, @OutParameter IntBuffer params); + + @StripPostfix("params") + void glGetTextureLevelParameterfvEXT(@GLuint int texture, @GLenum int target, int level, @GLenum int pname, @OutParameter @Check("4") FloatBuffer params); + + @Alternate("glGetTextureLevelParameterfvEXT") + @GLreturn("params") + @StripPostfix(value = "params", postfix = "v") + void glGetTextureLevelParameterfvEXT2(@GLuint int texture, @GLenum int target, int level, @GLenum int pname, @OutParameter FloatBuffer params); + + @StripPostfix("params") + void glGetTextureLevelParameterivEXT(@GLuint int texture, @GLenum int target, int level, @GLenum int pname, @OutParameter @Check("4") IntBuffer params); + + @Alternate("glGetTextureLevelParameterivEXT") + @GLreturn("params") + @StripPostfix(value = "params", postfix = "v") + void glGetTextureLevelParameterivEXT2(@GLuint int texture, @GLenum int target, int level, @GLenum int pname, @OutParameter IntBuffer params); + + /* + OpenGL 1.2: New 3D texture object commands replace "Tex" in name with + "Texture" and adds initial "uint texture" parameter + */ + + @Dependent("OpenGL12") + void glTextureImage3DEXT(@GLuint int texture, @GLenum int target, int level, + int internalformat, @GLsizei int width, @GLsizei int height, @GLsizei int depth, int border, @GLenum int format, @GLenum int type, + @BufferObject(BufferKind.UnpackPBO) + @Check(value = "GLChecks.calculateTexImage3DStorage(pixels, format, type, width, height, depth)", canBeNull = true) + @Const + @GLbyte + @GLshort + @GLint + @GLfloat + @GLdouble Buffer pixels); + + @Dependent("OpenGL12") + void glTextureSubImage3DEXT(@GLuint int texture, @GLenum int target, int level, + int xoffset, int yoffset, int zoffset, @GLsizei int width, @GLsizei int height, @GLsizei int depth, @GLenum int format, @GLenum int type, + @BufferObject(BufferKind.UnpackPBO) + @Check("GLChecks.calculateImageStorage(pixels, format, type, width, height, depth)") + @Const + @GLbyte + @GLshort + @GLint + @GLfloat + @GLdouble Buffer pixels); + + @Dependent("OpenGL12") + void glCopyTextureSubImage3DEXT(@GLuint int texture, @GLenum int target, int level, + int xoffset, int yoffset, int zoffset, int x, int y, @GLsizei int width, @GLsizei int height); + + /* + OpenGL 1.2.1: New multitexture commands and queries prefix "Multi" + before "Tex" and add an initial "enum texunit" parameter (to identify + the texture unit + */ + + @Dependent("OpenGL13") + void glBindMultiTextureEXT(@GLenum int texunit, @GLenum int target, @GLuint int texture); + + @Dependent("OpenGL13") + @DeprecatedGL + void glMultiTexCoordPointerEXT(@GLenum int texunit, int size, @AutoType("pointer") @GLenum int type, @GLsizei int stride, + @BufferObject(BufferKind.ArrayVBO) + @Check + @Const + @GLfloat + @GLdouble + Buffer pointer); + + @Dependent("OpenGL13") + @DeprecatedGL + void glMultiTexEnvfEXT(@GLenum int texunit, @GLenum int target, @GLenum int pname, float param); + + @Dependent("OpenGL13") + @StripPostfix("params") + @DeprecatedGL + void glMultiTexEnvfvEXT(@GLenum int texunit, @GLenum int target, @GLenum int pname, @Check("4") @Const FloatBuffer params); + + @Dependent("OpenGL13") + @DeprecatedGL + void glMultiTexEnviEXT(@GLenum int texunit, @GLenum int target, @GLenum int pname, int param); + + @Dependent("OpenGL13") + @StripPostfix("params") + @DeprecatedGL + void glMultiTexEnvivEXT(@GLenum int texunit, @GLenum int target, @GLenum int pname, @Check("4") @Const IntBuffer params); + + @Dependent("OpenGL13") + @DeprecatedGL + void glMultiTexGendEXT(@GLenum int texunit, @GLenum int coord, @GLenum int pname, double param); + + @Dependent("OpenGL13") + @StripPostfix("params") + @DeprecatedGL + void glMultiTexGendvEXT(@GLenum int texunit, @GLenum int coord, @GLenum int pname, @Check("4") @Const DoubleBuffer params); + + @Dependent("OpenGL13") + @DeprecatedGL + void glMultiTexGenfEXT(@GLenum int texunit, @GLenum int coord, @GLenum int pname, float param); + + @Dependent("OpenGL13") + @StripPostfix("params") + @DeprecatedGL + void glMultiTexGenfvEXT(@GLenum int texunit, @GLenum int coord, @GLenum int pname, @Check("4") @Const FloatBuffer params); + + @Dependent("OpenGL13") + @DeprecatedGL + void glMultiTexGeniEXT(@GLenum int texunit, @GLenum int coord, @GLenum int pname, int param); + + @Dependent("OpenGL13") + @StripPostfix("params") + @DeprecatedGL + void glMultiTexGenivEXT(@GLenum int texunit, @GLenum int coord, @GLenum int pname, @Check("4") @Const IntBuffer params); + + @Dependent("OpenGL13") + @StripPostfix("params") + @DeprecatedGL + void glGetMultiTexEnvfvEXT(@GLenum int texunit, @GLenum int target, @GLenum int pname, @Check("4") @OutParameter FloatBuffer params); + + @Dependent("OpenGL13") + @StripPostfix("params") + @DeprecatedGL + void glGetMultiTexEnvivEXT(@GLenum int texunit, @GLenum int target, @GLenum int pname, @Check("4") @OutParameter IntBuffer params); + + @Dependent("OpenGL13") + @StripPostfix("params") + @DeprecatedGL + void glGetMultiTexGendvEXT(@GLenum int texunit, @GLenum int coord, @GLenum int pname, @Check("4") @OutParameter DoubleBuffer params); + + @Dependent("OpenGL13") + @StripPostfix("params") + @DeprecatedGL + void glGetMultiTexGenfvEXT(@GLenum int texunit, @GLenum int coord, @GLenum int pname, @Check("4") @OutParameter FloatBuffer params); + + @Dependent("OpenGL13") + @StripPostfix("params") + @DeprecatedGL + void glGetMultiTexGenivEXT(@GLenum int texunit, @GLenum int coord, @GLenum int pname, @Check("4") @OutParameter IntBuffer params); + + @Dependent("OpenGL13") + void glMultiTexParameteriEXT(@GLenum int texunit, @GLenum int target, @GLenum int pname, int param); + + @Dependent("OpenGL13") + @StripPostfix("param") + void glMultiTexParameterivEXT(@GLenum int texunit, @GLenum int target, @GLenum int pname, @Check("4") @Const IntBuffer param); + + @Dependent("OpenGL13") + void glMultiTexParameterfEXT(@GLenum int texunit, @GLenum int target, @GLenum int pname, float param); + + @Dependent("OpenGL13") + @StripPostfix("param") + void glMultiTexParameterfvEXT(@GLenum int texunit, @GLenum int target, @GLenum int pname, @Check("4") @Const FloatBuffer param); + + @Dependent("OpenGL13") + void glMultiTexImage1DEXT(@GLenum int texunit, @GLenum int target, int level, + int internalformat, @GLsizei int width, int border, @GLenum int format, @GLenum int type, + @BufferObject(BufferKind.UnpackPBO) + @Check(value = "GLChecks.calculateTexImage1DStorage(pixels, format, type, width)", canBeNull = true) + @Const + @GLbyte + @GLshort + @GLint + @GLfloat + @GLdouble Buffer pixels); + + @Dependent("OpenGL13") + void glMultiTexImage2DEXT(@GLenum int texunit, @GLenum int target, int level, + int internalformat, @GLsizei int width, @GLsizei int height, int border, @GLenum int format, @GLenum int type, + @BufferObject(BufferKind.UnpackPBO) + @Check(value = "GLChecks.calculateTexImage2DStorage(pixels, format, type, width, height)", canBeNull = true) + @Const + @GLbyte + @GLshort + @GLint + @GLfloat + @GLdouble Buffer pixels); + + @Dependent("OpenGL13") + void glMultiTexSubImage1DEXT(@GLenum int texunit, @GLenum int target, int level, + int xoffset, @GLsizei int width, @GLenum int format, @GLenum int type, + @BufferObject(BufferKind.UnpackPBO) + @Check("GLChecks.calculateImageStorage(pixels, format, type, width, 1, 1)") + @Const + @GLbyte + @GLshort + @GLint + @GLfloat + @GLdouble Buffer pixels); + + @Dependent("OpenGL13") + void glMultiTexSubImage2DEXT(@GLenum int texunit, @GLenum int target, int level, + int xoffset, int yoffset, @GLsizei int width, @GLsizei int height, @GLenum int format, @GLenum int type, + @BufferObject(BufferKind.UnpackPBO) + @Check("GLChecks.calculateImageStorage(pixels, format, type, width, height, 1)") + @Const + @GLbyte + @GLshort + @GLint + @GLfloat + @GLdouble Buffer pixels); + + @Dependent("OpenGL13") + void glCopyMultiTexImage1DEXT(@GLenum int texunit, @GLenum int target, int level, @GLenum int internalformat, int x, int y, @GLsizei int width, int border); + + @Dependent("OpenGL13") + void glCopyMultiTexImage2DEXT(@GLenum int texunit, @GLenum int target, int level, @GLenum int internalformat, int x, int y, @GLsizei int width, @GLsizei int height, int border); + + @Dependent("OpenGL13") + void glCopyMultiTexSubImage1DEXT(@GLenum int texunit, @GLenum int target, int level, int xoffset, int x, int y, @GLsizei int width); + + @Dependent("OpenGL13") + void glCopyMultiTexSubImage2DEXT(@GLenum int texunit, @GLenum int target, int level, int xoffset, int yoffset, int x, int y, @GLsizei int width, @GLsizei int height); + + @Dependent("OpenGL13") + void glGetMultiTexImageEXT(@GLenum int texunit, @GLenum int target, int level, @GLenum int format, @GLenum int type, + @OutParameter + @BufferObject(BufferKind.PackPBO) + @Check("GLChecks.calculateImageStorage(pixels, format, type, 1, 1, 1)") + @GLbyte + @GLshort + @GLint + @GLfloat + @GLdouble Buffer pixels); + + @Dependent("OpenGL13") + @StripPostfix("params") + void glGetMultiTexParameterfvEXT(@GLenum int texunit, @GLenum int target, @GLenum int pname, @Check("4") @OutParameter FloatBuffer params); + + @Alternate("glGetMultiTexParameterfvEXT") + @GLreturn("params") + @StripPostfix(value = "params", postfix = "v") + void glGetMultiTexParameterfvEXT2(@GLenum int texunit, @GLenum int target, @GLenum int pname, @OutParameter FloatBuffer params); + + @Dependent("OpenGL13") + @StripPostfix("params") + void glGetMultiTexParameterivEXT(@GLenum int texunit, @GLenum int target, @GLenum int pname, @Check("4") @OutParameter IntBuffer params); + + @Alternate("glGetMultiTexParameterivEXT") + @GLreturn("params") + @Dependent("OpenGL13") + @StripPostfix(value = "params", postfix = "v") + void glGetMultiTexParameterivEXT2(@GLenum int texunit, @GLenum int target, @GLenum int pname, @OutParameter IntBuffer params); + + @Dependent("OpenGL13") + @StripPostfix("params") + void glGetMultiTexLevelParameterfvEXT(@GLenum int texunit, @GLenum int target, int level, @GLenum int pname, @Check("4") @OutParameter FloatBuffer params); + + @Alternate("glGetMultiTexLevelParameterfvEXT") + @GLreturn("params") + @Dependent("OpenGL13") + @StripPostfix(value = "params", postfix = "v") + void glGetMultiTexLevelParameterfvEXT2(@GLenum int texunit, @GLenum int target, int level, @GLenum int pname, @OutParameter FloatBuffer params); + + @Dependent("OpenGL13") + @StripPostfix("params") + void glGetMultiTexLevelParameterivEXT(@GLenum int texunit, @GLenum int target, int level, @GLenum int pname, @Check("4") @OutParameter IntBuffer params); + + @Alternate("glGetMultiTexLevelParameterivEXT") + @GLreturn("params") + @Dependent("OpenGL13") + @StripPostfix(value = "params", postfix = "v") + void glGetMultiTexLevelParameterivEXT2(@GLenum int texunit, @GLenum int target, int level, @GLenum int pname, @OutParameter IntBuffer params); + + @Dependent("OpenGL13") + void glMultiTexImage3DEXT(@GLenum int texunit, @GLenum int target, int level, + int internalformat, @GLsizei int width, @GLsizei int height, @GLsizei int depth, int border, @GLenum int format, @GLenum int type, + @BufferObject(BufferKind.UnpackPBO) + @Check(value = "GLChecks.calculateTexImage3DStorage(pixels, format, type, width, height, depth)", canBeNull = true) + @Const + @GLbyte + @GLshort + @GLint + @GLfloat + @GLdouble Buffer pixels); + + @Dependent("OpenGL13") + void glMultiTexSubImage3DEXT(@GLenum int texunit, @GLenum int target, int level, + int xoffset, int yoffset, int zoffset, @GLsizei int width, @GLsizei int height, @GLsizei int depth, @GLenum int format, @GLenum int type, + @BufferObject(BufferKind.UnpackPBO) + @Check("GLChecks.calculateImageStorage(pixels, format, type, width, height, depth)") + @Const + @GLbyte + @GLshort + @GLint + @GLfloat + @GLdouble Buffer pixels); + + @Dependent("OpenGL13") + void glCopyMultiTexSubImage3DEXT(@GLenum int texunit, @GLenum int target, int level, int xoffset, int yoffset, int zoffset, int x, int y, @GLsizei int width, @GLsizei int height); + + /* + OpenGL 1.2.1: New indexed texture commands and queries append + "Indexed" to name and add "uint index" parameter (to identify the + texture unit index) after state name parameters (if any) and before + state value parameters + */ + + @Dependent("OpenGL13") + @DeprecatedGL + void glEnableClientStateIndexedEXT(@GLenum int array, @GLuint int index); + + @Dependent("OpenGL13") + @DeprecatedGL + void glDisableClientStateIndexedEXT(@GLenum int array, @GLuint int index); + + /* + OpenGL 3.0: New indexed texture commands and queries append "i" + to name and add "uint index" parameter (to identify the texture + unit index) after state name parameters (if any) and before state + value parameters + */ + + @Optional(reason = "AMD does not expose this (last driver checked: 10.3)") + @Dependent("OpenGL30") + void glEnableClientStateiEXT(@GLenum int array, @GLuint int index); + + @Optional(reason = "AMD does not expose this (last driver checked: 10.3)") + @Dependent("OpenGL30") + void glDisableClientStateiEXT(@GLenum int array, @GLuint int index); + + /* + OpenGL 1.2.1: New indexed generic queries (added for indexed texture + state) append "Indexed" to name and add "uint index" parameter + (to identify the texture unit) after state name parameters (if any) + and before state value parameters + */ + + @Dependent("OpenGL13") + @StripPostfix("params") + void glGetFloatIndexedvEXT(@GLenum int pname, @GLuint int index, @OutParameter @Check("16") FloatBuffer params); + + @Alternate("glGetFloatIndexedvEXT") + @GLreturn("params") + @Dependent("OpenGL13") + @StripPostfix("params") + void glGetFloatIndexedvEXT2(@GLenum int pname, @GLuint int index, @OutParameter FloatBuffer params); + + @Dependent("OpenGL13") + @StripPostfix(value = "params", hasPostfix = false) + void glGetDoubleIndexedvEXT(@GLenum int pname, @GLuint int index, @OutParameter @Check("16") DoubleBuffer params); + + @Alternate("glGetDoubleIndexedvEXT") + @GLreturn("params") + @Dependent("OpenGL13") + @StripPostfix(value = "params", hasPostfix = false) + void glGetDoubleIndexedvEXT2(@GLenum int pname, @GLuint int index, @OutParameter DoubleBuffer params); + + @Dependent("OpenGL13") + @StripPostfix("params") + void glGetPointerIndexedvEXT(@GLenum int pname, @GLuint int index, @Result @GLvoid ByteBuffer params); + + /* + OpenGL 3.0: New indexed generic queries (added for indexed texture + state) replace "v" for "i_v" to name and add "uint index" parameter + (to identify the texture unit) after state name parameters (if any) + and before state value parameters + */ + + @Optional(reason = "AMD does not expose this (last driver checked: 10.3)") + @Dependent("OpenGL30") + @StripPostfix("params") + void glGetFloati_vEXT(@GLenum int pname, @GLuint int index, @OutParameter @Check("16") FloatBuffer params); + + @Alternate("glGetFloati_vEXT") + @GLreturn("params") + @Dependent("OpenGL30") + @StripPostfix("params") + void glGetFloati_vEXT2(@GLenum int pname, @GLuint int index, @OutParameter FloatBuffer params); + + @Optional(reason = "AMD does not expose this (last driver checked: 10.3)") + @Dependent("OpenGL30") + @StripPostfix("params") + void glGetDoublei_vEXT(@GLenum int pname, @GLuint int index, @OutParameter @Check("16") DoubleBuffer params); + + @Alternate("glGetDoublei_vEXT") + @GLreturn("params") + @Dependent("OpenGL30") + @StripPostfix("params") + void glGetDoublei_vEXT2(@GLenum int pname, @GLuint int index, @OutParameter DoubleBuffer params); + + @Optional(reason = "AMD does not expose this (last driver checked: 10.3)") + @Dependent("OpenGL30") + @StripPostfix(value = "params", hasPostfix = false) + void glGetPointeri_vEXT(@GLenum int pname, @GLuint int index, @Result @GLvoid ByteBuffer params); + + /* + OpenGL 1.2.1: Extend the functionality of these EXT_draw_buffers2 + commands and queries for multitexture + TODO: Why 1.2.1 and not EXT_draw_buffers2? + */ + + @Dependent("GL_EXT_draw_buffers2") + void glEnableIndexedEXT(@GLenum int cap, @GLuint int index); + + @Dependent("GL_EXT_draw_buffers2") + void glDisableIndexedEXT(@GLenum int cap, @GLuint int index); + + @Dependent("GL_EXT_draw_buffers2") + boolean glIsEnabledIndexedEXT(@GLenum int cap, @GLuint int index); + + @Dependent("GL_EXT_draw_buffers2") + @StripPostfix("params") + void glGetIntegerIndexedvEXT(@GLenum int pname, @GLuint int index, @OutParameter @Check("16") IntBuffer params); + + @Alternate("glGetIntegerIndexedvEXT") + @GLreturn("params") + @Dependent("GL_EXT_draw_buffers2") + @StripPostfix("params") + void glGetIntegerIndexedvEXT2(@GLenum int pname, @GLuint int index, @OutParameter IntBuffer params); + + @Dependent("GL_EXT_draw_buffers2") + @StripPostfix("params") + void glGetBooleanIndexedvEXT(@GLenum int pname, @GLuint int index, @OutParameter @Check("16") @GLboolean ByteBuffer params); + + @Alternate("glGetBooleanIndexedvEXT") + @GLreturn("params") + @Dependent("GL_EXT_draw_buffers2") + @StripPostfix("params") + void glGetBooleanIndexedvEXT2(@GLenum int pname, @GLuint int index, @OutParameter @GLboolean ByteBuffer params); + + /* + ARB_vertex_program: New program commands and queries add "Named" + prefix to name and adds initial "uint program" parameter + */ + + @Dependent("GL_ARB_vertex_program") + void glNamedProgramStringEXT(@GLuint int program, @GLenum int target, @GLenum int format, @AutoSize("string") @GLsizei int len, @Const @GLvoid Buffer string); + + @Alternate("glNamedProgramStringEXT") + @Dependent("GL_ARB_vertex_program") + void glNamedProgramStringEXT(@GLuint int program, @GLenum int target, @GLenum int format, @Constant("string.length()") @GLsizei int length, CharSequence string); + + @Dependent("GL_ARB_vertex_program") + void glNamedProgramLocalParameter4dEXT(@GLuint int program, @GLenum int target, @GLuint int index, double x, double y, double z, double w); + + @Dependent("GL_ARB_vertex_program") + @StripPostfix("params") + void glNamedProgramLocalParameter4dvEXT(@GLuint int program, @GLenum int target, @GLuint int index, @Const @Check("4") DoubleBuffer params); + + @Dependent("GL_ARB_vertex_program") + void glNamedProgramLocalParameter4fEXT(@GLuint int program, @GLenum int target, @GLuint int index, float x, float y, float z, float w); + + @Dependent("GL_ARB_vertex_program") + @StripPostfix("params") + void glNamedProgramLocalParameter4fvEXT(@GLuint int program, @GLenum int target, @GLuint int index, @Const @Check("4") FloatBuffer params); + + @Dependent("GL_ARB_vertex_program") + @StripPostfix("params") + void glGetNamedProgramLocalParameterdvEXT(@GLuint int program, @GLenum int target, @GLuint int index, @OutParameter @Check("4") DoubleBuffer params); + + @Dependent("GL_ARB_vertex_program") + @StripPostfix("params") + void glGetNamedProgramLocalParameterfvEXT(@GLuint int program, @GLenum int target, @GLuint int index, @OutParameter @Check("4") FloatBuffer params); + + @Dependent("GL_ARB_vertex_program") + @StripPostfix("params") + void glGetNamedProgramivEXT(@GLuint int program, @GLenum int target, @GLenum int pname, @OutParameter @Check("4") IntBuffer params); + + @Alternate("glGetNamedProgramivEXT") + @GLreturn("params") + @Dependent("GL_ARB_vertex_program") + @StripPostfix("params") + void glGetNamedProgramivEXT2(@GLuint int program, @GLenum int target, @GLenum int pname, @OutParameter IntBuffer params); + + @Dependent("GL_ARB_vertex_program") + void glGetNamedProgramStringEXT(@GLuint int program, @GLenum int target, @GLenum int pname, @OutParameter @Check @GLvoid ByteBuffer string); + + @Alternate("glGetNamedProgramStringEXT") + @Code("\t\tint programLength = glGetNamedProgramEXT(program, target, ARBProgram.GL_PROGRAM_LENGTH_ARB);") + @GLreturn(value = "paramString", maxLength = "programLength", forceMaxLength = true) + void glGetNamedProgramStringEXT2(@GLuint int program, @GLenum int target, @GLenum int pname, @OutParameter @GLchar ByteBuffer paramString); + + /* + OpenGL 1.3: New compressed texture object commands replace "Tex" + in name with "Texture" and add initial "uint texture" parameter + */ + + @Dependent("OpenGL13") + void glCompressedTextureImage3DEXT(@GLuint int texture, @GLenum int target, int level, + @GLenum int internalformat, @GLsizei int width, @GLsizei int height, @GLsizei int depth, int border, @AutoSize("data") @GLsizei int imageSize, + @BufferObject(BufferKind.UnpackPBO) + @Check + @Const + @GLvoid + ByteBuffer data); + + @Dependent("OpenGL13") + void glCompressedTextureImage2DEXT(@GLuint int texture, @GLenum int target, int level, + @GLenum int internalformat, @GLsizei int width, @GLsizei int height, int border, @AutoSize("data") @GLsizei int imageSize, + @BufferObject(BufferKind.UnpackPBO) + @Check + @Const + @GLvoid + ByteBuffer data); + + @Dependent("OpenGL13") + void glCompressedTextureImage1DEXT(@GLuint int texture, @GLenum int target, int level, + @GLenum int internalformat, @GLsizei int width, int border, @AutoSize("data") @GLsizei int imageSize, + @BufferObject(BufferKind.UnpackPBO) + @Check + @Const + @GLvoid + ByteBuffer data); + + @Dependent("OpenGL13") + void glCompressedTextureSubImage3DEXT(@GLuint int texture, @GLenum int target, int level, + int xoffset, int yoffset, int zoffset, @GLsizei int width, @GLsizei int height, @GLsizei int depth, + @GLenum int format, @AutoSize("data") @GLsizei int imageSize, + @BufferObject(BufferKind.UnpackPBO) + @Check + @Const + @GLvoid + ByteBuffer data); + + @Dependent("OpenGL13") + void glCompressedTextureSubImage2DEXT(@GLuint int texture, @GLenum int target, int level, + int xoffset, int yoffset, @GLsizei int width, @GLsizei int height, @GLenum int format, @AutoSize("data") @GLsizei int imageSize, + @BufferObject(BufferKind.UnpackPBO) + @Check + @Const + @GLvoid + ByteBuffer data); + + @Dependent("OpenGL13") + void glCompressedTextureSubImage1DEXT(@GLuint int texture, @GLenum int target, int level, + int xoffset, @GLsizei int width, @GLenum int format, @AutoSize("data") @GLsizei int imageSize, + @BufferObject(BufferKind.UnpackPBO) + @Check + @Const + @GLvoid + ByteBuffer data); + + @Dependent("OpenGL13") + void glGetCompressedTextureImageEXT(@GLuint int texture, @GLenum int target, int level, + @OutParameter + @BufferObject(BufferKind.PackPBO) + @Check + @GLbyte + @GLshort + @GLint Buffer img); + + /* + OpenGL 1.3: New multitexture compressed texture commands and queries + prefix "Multi" before "Tex" and add an initial "enum texunit" + parameter (to identify the texture unit) + */ + + @Dependent("OpenGL13") + void glCompressedMultiTexImage3DEXT(@GLenum int texunit, @GLenum int target, int level, + @GLenum int internalformat, @GLsizei int width, @GLsizei int height, @GLsizei int depth, int border, @AutoSize("data") @GLsizei int imageSize, + @BufferObject(BufferKind.UnpackPBO) + @Check + @Const + @GLvoid + ByteBuffer data); + + @Dependent("OpenGL13") + void glCompressedMultiTexImage2DEXT(@GLenum int texunit, @GLenum int target, int level, + @GLenum int internalformat, @GLsizei int width, @GLsizei int height, int border, @AutoSize("data") @GLsizei int imageSize, + @BufferObject(BufferKind.UnpackPBO) + @Check + @Const + @GLvoid + ByteBuffer data); + + @Dependent("OpenGL13") + void glCompressedMultiTexImage1DEXT(@GLenum int texunit, @GLenum int target, int level, + @GLenum int internalformat, @GLsizei int width, int border, @AutoSize("data") @GLsizei int imageSize, + @BufferObject(BufferKind.UnpackPBO) + @Check + @Const + @GLvoid + ByteBuffer data); + + @Dependent("OpenGL13") + void glCompressedMultiTexSubImage3DEXT(@GLenum int texunit, @GLenum int target, int level, + int xoffset, int yoffset, int zoffset, @GLsizei int width, @GLsizei int height, @GLsizei int depth, + @GLenum int format, @AutoSize("data") @GLsizei int imageSize, + @BufferObject(BufferKind.UnpackPBO) + @Check + @Const + @GLvoid + ByteBuffer data); + + @Dependent("OpenGL13") + void glCompressedMultiTexSubImage2DEXT(@GLenum int texunit, @GLenum int target, int level, + int xoffset, int yoffset, @GLsizei int width, @GLsizei int height, @GLenum int format, @AutoSize("data") @GLsizei int imageSize, + @BufferObject(BufferKind.UnpackPBO) + @Check + @Const + @GLvoid + ByteBuffer data); + + @Dependent("OpenGL13") + void glCompressedMultiTexSubImage1DEXT(@GLenum int texunit, @GLenum int target, int level, + int xoffset, @GLsizei int width, @GLenum int format, @AutoSize("data") @GLsizei int imageSize, + @BufferObject(BufferKind.UnpackPBO) + @Check + @Const + @GLvoid + ByteBuffer data); + + @Dependent("OpenGL13") + void glGetCompressedMultiTexImageEXT(@GLenum int texunit, @GLenum int target, int level, + @OutParameter + @BufferObject(BufferKind.PackPBO) + @Check + @GLbyte + @GLshort + @GLint Buffer img); + + @Dependent("OpenGL13") + void glGetCompressedTexImage(@GLenum int target, int lod, + @OutParameter + @BufferObject(BufferKind.PackPBO) + @Check + @GLbyte + @GLshort + @GLint Buffer img); + + /* + OpenGL 1.3: New transpose matrix commands add "Matrix" suffix + to name, drops "Matrix" suffix from name, and add initial "enum + matrixMode" parameter + */ + + @Dependent("OpenGL13") + @StripPostfix("m") + @DeprecatedGL + void glMatrixLoadTransposefEXT(@GLenum int matrixMode, @Check("16") @Const FloatBuffer m); + + @Dependent("OpenGL13") + @StripPostfix("m") + @DeprecatedGL + void glMatrixLoadTransposedEXT(@GLenum int matrixMode, @Check("16") @Const DoubleBuffer m); + + @Dependent("OpenGL13") + @StripPostfix("m") + @DeprecatedGL + void glMatrixMultTransposefEXT(@GLenum int matrixMode, @Check("16") @Const FloatBuffer m); + + @Dependent("OpenGL13") + @StripPostfix("m") + @DeprecatedGL + void glMatrixMultTransposedEXT(@GLenum int matrixMode, @Check("16") @Const DoubleBuffer m); + + /* + OpenGL 1.5: New buffer commands and queries replace "Buffer" with + "NamedBuffer" in name and replace "enum target" parameter with + "uint buffer" + */ + + @Dependent("OpenGL15") + @GenerateAutos + void glNamedBufferDataEXT(@GLuint int buffer, @AutoSize("data") @GLsizeiptr long size, + @Const + @GLbyte + @GLshort + @GLint + @GLfloat + @GLdouble Buffer data, @GLenum int usage); + + @Dependent("OpenGL15") + void glNamedBufferSubDataEXT(@GLuint int buffer, @GLintptr long offset, @AutoSize("data") @GLsizeiptr long size, + @Check + @Const + @GLbyte + @GLshort + @GLint + @GLfloat + @GLdouble Buffer data); + + /** + * glMapNamedBufferEXT maps a GL buffer object to a ByteBuffer. The old_buffer argument can be null, + * in which case a new ByteBuffer will be created, pointing to the returned memory. If old_buffer is non-null, + * it will be returned if it points to the same mapped memory and has the same capacity as the buffer object, + * otherwise a new ByteBuffer is created. That way, an application will normally use glMapNamedBufferEXT like this: + *

    + * ByteBuffer mapped_buffer; mapped_buffer = glMapNamedBufferEXT(..., ..., null); ... // Another map on the same buffer mapped_buffer = glMapNamedBufferEXT(..., ..., mapped_buffer); + *

    + * Only ByteBuffers returned from this method are to be passed as the old_buffer argument. User-created ByteBuffers cannot be reused. + *

    + * The version of this method without an explicit length argument calls glGetNamedBufferParameterEXT internally to + * retrieve the current buffer object size, which may cause a pipeline flush and reduce application performance. + *

    + * The version of this method with an explicit length argument is a fast alternative to the one without. No GL call + * is made to retrieve the buffer object size, so the user is responsible for tracking and using the appropriate length.
    + * Security warning: The length argument should match the buffer object size. Reading from or writing to outside + * the memory region that corresponds to the mapped buffer object will cause native crashes. + * + * @param length the length of the mapped memory in bytes. + * @param old_buffer A ByteBuffer. If this argument points to the same address and has the same capacity as the new mapping, it will be returned and no new buffer will be created. + * + * @return A ByteBuffer representing the mapped buffer memory. + */ + @Dependent("OpenGL15") + @CachedResult + @GLvoid + @AutoResultSize("GLChecks.getNamedBufferObjectSize(caps, buffer)") + ByteBuffer glMapNamedBufferEXT(@GLuint int buffer, @GLenum int access); + + @Dependent("OpenGL15") + boolean glUnmapNamedBufferEXT(@GLuint int buffer); + + @Dependent("OpenGL15") + @StripPostfix("params") + void glGetNamedBufferParameterivEXT(@GLuint int buffer, @GLenum int pname, @OutParameter @Check("4") IntBuffer params); + + @Alternate("glGetNamedBufferParameterivEXT") + @GLreturn("params") + @Dependent("OpenGL15") + @StripPostfix("params") + void glGetNamedBufferParameterivEXT2(@GLuint int buffer, @GLenum int pname, @OutParameter IntBuffer params); + + @Dependent("OpenGL15") + @StripPostfix("params") + @AutoResultSize("GLChecks.getNamedBufferObjectSize(caps, buffer)") + void glGetNamedBufferPointervEXT(@GLuint int buffer, @GLenum int pname, @OutParameter @Result @GLvoid ByteBuffer params); + + @Dependent("OpenGL15") + void glGetNamedBufferSubDataEXT(@GLuint int buffer, @GLintptr long offset, @AutoSize("data") @GLsizeiptr long size, + @OutParameter + @Check + @GLbyte + @GLshort + @GLint + @GLfloat + @GLdouble Buffer data); + + /* + OpenGL 2.0: New uniform commands add "Program" prefix to name and + add initial "uint program" parameter + */ + + @Dependent("OpenGL20") + void glProgramUniform1fEXT(@GLuint int program, int location, float v0); + + @Dependent("OpenGL20") + void glProgramUniform2fEXT(@GLuint int program, int location, float v0, float v1); + + @Dependent("OpenGL20") + void glProgramUniform3fEXT(@GLuint int program, int location, float v0, float v1, float v2); + + @Dependent("OpenGL20") + void glProgramUniform4fEXT(@GLuint int program, int location, float v0, float v1, float v2, float v3); + + @Dependent("OpenGL20") + void glProgramUniform1iEXT(@GLuint int program, int location, int v0); + + @Dependent("OpenGL20") + void glProgramUniform2iEXT(@GLuint int program, int location, int v0, int v1); + + @Dependent("OpenGL20") + void glProgramUniform3iEXT(@GLuint int program, int location, int v0, int v1, int v2); + + @Dependent("OpenGL20") + void glProgramUniform4iEXT(@GLuint int program, int location, int v0, int v1, int v2, int v3); + + @Dependent("OpenGL20") + @StripPostfix("value") + void glProgramUniform1fvEXT(@GLuint int program, int location, @AutoSize(value = "value") @GLsizei int count, @Const FloatBuffer value); + + @Dependent("OpenGL20") + @StripPostfix("value") + void glProgramUniform2fvEXT(@GLuint int program, int location, @AutoSize(value = "value", expression = " >> 1") @GLsizei int count, @Const FloatBuffer value); + + @Dependent("OpenGL20") + @StripPostfix("value") + void glProgramUniform3fvEXT(@GLuint int program, int location, @AutoSize(value = "value", expression = " / 3") @GLsizei int count, @Const FloatBuffer value); + + @Dependent("OpenGL20") + @StripPostfix("value") + void glProgramUniform4fvEXT(@GLuint int program, int location, @AutoSize(value = "value", expression = " >> 2") @GLsizei int count, @Const FloatBuffer value); + + @Dependent("OpenGL20") + @StripPostfix("value") + void glProgramUniform1ivEXT(@GLuint int program, int location, @AutoSize(value = "value") @GLsizei int count, @Const IntBuffer value); + + @Dependent("OpenGL20") + @StripPostfix("value") + void glProgramUniform2ivEXT(@GLuint int program, int location, @AutoSize(value = "value", expression = " >> 1") @GLsizei int count, @Const IntBuffer value); + + @Dependent("OpenGL20") + @StripPostfix("value") + void glProgramUniform3ivEXT(@GLuint int program, int location, @AutoSize(value = "value", expression = " / 3") @GLsizei int count, @Const IntBuffer value); + + @Dependent("OpenGL20") + @StripPostfix("value") + void glProgramUniform4ivEXT(@GLuint int program, int location, @AutoSize(value = "value", expression = " >> 2") @GLsizei int count, @Const IntBuffer value); + + @Dependent("OpenGL20") + @StripPostfix("value") + void glProgramUniformMatrix2fvEXT(@GLuint int program, int location, @AutoSize(value = "value", expression = " >> 2") @GLsizei int count, boolean transpose, @Const FloatBuffer value); + + @Dependent("OpenGL20") + @StripPostfix("value") + void glProgramUniformMatrix3fvEXT(@GLuint int program, int location, @AutoSize(value = "value", expression = " / (3 * 3)") @GLsizei int count, boolean transpose, @Const FloatBuffer value); + + @Dependent("OpenGL20") + @StripPostfix("value") + void glProgramUniformMatrix4fvEXT(@GLuint int program, int location, @AutoSize(value = "value", expression = " >> 4") @GLsizei int count, boolean transpose, @Const FloatBuffer value); + + /* + OpenGL 2.1: New uniform matrix commands add "Program" prefix to + name and add initial "uint program" parameter + */ + + @Dependent("OpenGL21") + @StripPostfix("value") + void glProgramUniformMatrix2x3fvEXT(@GLuint int program, int location, + @AutoSize(value = "value", expression = " / (2 * 3)") @GLsizei int count, boolean transpose, @Const FloatBuffer value); + + @Dependent("OpenGL21") + @StripPostfix("value") + void glProgramUniformMatrix3x2fvEXT(@GLuint int program, int location, + @AutoSize(value = "value", expression = " / (3 * 2)") @GLsizei int count, boolean transpose, @Const FloatBuffer value); + + @Dependent("OpenGL21") + @StripPostfix("value") + void glProgramUniformMatrix2x4fvEXT(@GLuint int program, int location, + @AutoSize(value = "value", expression = " >> 3") @GLsizei int count, boolean transpose, @Const FloatBuffer value); + + @Dependent("OpenGL21") + @StripPostfix("value") + void glProgramUniformMatrix4x2fvEXT(@GLuint int program, int location, + @AutoSize(value = "value", expression = " >> 3") @GLsizei int count, boolean transpose, @Const FloatBuffer value); + + @Dependent("OpenGL21") + @StripPostfix("value") + void glProgramUniformMatrix3x4fvEXT(@GLuint int program, int location, + @AutoSize(value = "value", expression = " / (3 * 4)") @GLsizei int count, boolean transpose, @Const FloatBuffer value); + + @Dependent("OpenGL21") + @StripPostfix("value") + void glProgramUniformMatrix4x3fvEXT(@GLuint int program, int location, + @AutoSize(value = "value", expression = " / (4 * 3)") @GLsizei int count, boolean transpose, @Const FloatBuffer value); + + /* + EXT_texture_buffer_object: New texture buffer object command + replaces "Tex" in name with "Texture" and adds initial "uint texture" + parameter + */ + + @Dependent("GL_EXT_texture_buffer_object") + void glTextureBufferEXT(@GLuint int texture, @GLenum int target, @GLenum int internalformat, @GLuint int buffer); + + /* + EXT_texture_buffer_object: New multitexture texture buffer command + prefixes "Multi" before "Tex" and add an initial "enum texunit" + parameter (to identify the texture unit) + */ + + @Dependent("GL_EXT_texture_buffer_object") + void glMultiTexBufferEXT(@GLenum int texunit, @GLenum int target, @GLenum int internalformat, @GLuint int buffer); + + /* + EXT_texture_integer: New integer texture object commands and queries + replace "Tex" in name with "Texture" and add initial "uint texture" + parameter + */ + + @Dependent("GL_EXT_texture_integer") + @StripPostfix("params") + void glTextureParameterIivEXT(@GLuint int texture, @GLenum int target, @GLenum int pname, @Check("4") @Const IntBuffer params); + + @Alternate("glTextureParameterIivEXT") + @Dependent("GL_EXT_texture_integer") + @StripPostfix("param") + void glTextureParameterIivEXT(@GLuint int texture, @GLenum int target, @GLenum int pname, @Constant(value = "APIUtils.getBufferInt().put(0, param), 0", keepParam = true) int param); + + @Dependent("GL_EXT_texture_integer") + @StripPostfix("params") + void glTextureParameterIuivEXT(@GLuint int texture, @GLenum int target, @GLenum int pname, @Check("4") @Const @GLuint IntBuffer params); + + @Alternate("glTextureParameterIuivEXT") + @Dependent("GL_EXT_texture_integer") + @StripPostfix("param") + void glTextureParameterIuivEXT(@GLuint int texture, @GLenum int target, @GLenum int pname, @Constant(value = "APIUtils.getBufferInt().put(0, param), 0", keepParam = true) @GLuint int param); + + @Dependent("GL_EXT_texture_integer") + @StripPostfix("params") + void glGetTextureParameterIivEXT(@GLuint int texture, @GLenum int target, @GLenum int pname, @Check("4") @OutParameter IntBuffer params); + + @Alternate("glGetTextureParameterIivEXT") + @GLreturn("params") + @Dependent("GL_EXT_texture_integer") + @StripPostfix(value = "params", postfix = "v") + void glGetTextureParameterIivEXT2(@GLuint int texture, @GLenum int target, @GLenum int pname, @OutParameter IntBuffer params); + + @Dependent("GL_EXT_texture_integer") + @StripPostfix("params") + void glGetTextureParameterIuivEXT(@GLuint int texture, @GLenum int target, @GLenum int pname, @Check("4") @OutParameter @GLuint IntBuffer params); + + @Alternate("glGetTextureParameterIuivEXT") + @GLreturn("params") + @Dependent("GL_EXT_texture_integer") + @StripPostfix(value = "params", postfix = "v") + void glGetTextureParameterIuivEXT2(@GLuint int texture, @GLenum int target, @GLenum int pname, @OutParameter @GLuint IntBuffer params); + + /* + EXT_texture_integer: New multitexture integer texture commands and + queries prefix "Multi" before "Tex" and add an initial "enum texunit" + parameter (to identify the texture unit) + */ + + @Dependent("GL_EXT_texture_integer") + @StripPostfix("params") + void glMultiTexParameterIivEXT(@GLenum int texunit, @GLenum int target, @GLenum int pname, @Check("4") @Const IntBuffer params); + + @Alternate("glMultiTexParameterIivEXT") + @Dependent("GL_EXT_texture_integer") + @StripPostfix("param") + void glMultiTexParameterIivEXT(@GLenum int texunit, @GLenum int target, @GLenum int pname, @Constant(value = "APIUtils.getBufferInt().put(0, param), 0", keepParam = true) int param); + + @Dependent("GL_EXT_texture_integer") + @StripPostfix("params") + void glMultiTexParameterIuivEXT(@GLenum int texunit, @GLenum int target, @GLenum int pname, @Check("4") @Const @GLuint IntBuffer params); + + @Alternate("glMultiTexParameterIuivEXT") + @Dependent("GL_EXT_texture_integer") + @StripPostfix("param") + void glMultiTexParameterIuivEXT(@GLenum int texunit, @GLenum int target, @GLenum int pname, @Constant(value = "APIUtils.getBufferInt().put(0, param), 0", keepParam = true) int param); + + @Dependent("GL_EXT_texture_integer") + @StripPostfix("params") + void glGetMultiTexParameterIivEXT(@GLenum int texunit, @GLenum int target, @GLenum int pname, @Check("4") @OutParameter IntBuffer params); + + @Alternate("glGetMultiTexParameterIivEXT") + @GLreturn("params") + @Dependent("GL_EXT_texture_integer") + @StripPostfix(value = "params", postfix = "v") + void glGetMultiTexParameterIivEXT2(@GLenum int texunit, @GLenum int target, @GLenum int pname, @OutParameter IntBuffer params); + + @Dependent("GL_EXT_texture_integer") + @StripPostfix("params") + void glGetMultiTexParameterIuivEXT(@GLenum int texunit, @GLenum int target, @GLenum int pname, @Check("4") @OutParameter @GLuint IntBuffer params); + + @Alternate("glGetMultiTexParameterIuivEXT") + @GLreturn("params") + @Dependent("GL_EXT_texture_integer") + @StripPostfix(value = "params", postfix = "v") + void glGetMultiTexParameterIuivEXT2(@GLenum int texunit, @GLenum int target, @GLenum int pname, @OutParameter @GLuint IntBuffer params); + + /* + EXT_gpu_shader4: New integer uniform commands add "Program" prefix + to name and add initial "uint program" parameter + */ + + @Dependent("GL_EXT_gpu_shader4") + void glProgramUniform1uiEXT(@GLuint int program, int location, @GLuint int v0); + + @Dependent("GL_EXT_gpu_shader4") + void glProgramUniform2uiEXT(@GLuint int program, int location, @GLuint int v0, @GLuint int v1); + + @Dependent("GL_EXT_gpu_shader4") + void glProgramUniform3uiEXT(@GLuint int program, int location, @GLuint int v0, @GLuint int v1, @GLuint int v2); + + @Dependent("GL_EXT_gpu_shader4") + void glProgramUniform4uiEXT(@GLuint int program, int location, @GLuint int v0, @GLuint int v1, @GLuint int v2, @GLuint int v3); + + @Dependent("GL_EXT_gpu_shader4") + @StripPostfix("value") + void glProgramUniform1uivEXT(@GLuint int program, int location, @AutoSize(value = "value") @GLsizei int count, @Const @GLuint IntBuffer value); + + @Dependent("GL_EXT_gpu_shader4") + @StripPostfix("value") + void glProgramUniform2uivEXT(@GLuint int program, int location, @AutoSize(value = "value", expression = " >> 1") @GLsizei int count, @Const @GLuint IntBuffer value); + + @Dependent("GL_EXT_gpu_shader4") + @StripPostfix("value") + void glProgramUniform3uivEXT(@GLuint int program, int location, @AutoSize(value = "value", expression = " / 3") @GLsizei int count, @Const @GLuint IntBuffer value); + + @Dependent("GL_EXT_gpu_shader4") + @StripPostfix("value") + void glProgramUniform4uivEXT(@GLuint int program, int location, @AutoSize(value = "value", expression = " >> 2") @GLsizei int count, @Const @GLuint IntBuffer value); + + /* + EXT_gpu_program_parameters: New program command adds "Named" prefix + to name and adds "uint program" parameter + */ + + @Dependent("GL_EXT_gpu_program_parameters") + @StripPostfix("params") + void glNamedProgramLocalParameters4fvEXT(@GLuint int program, @GLenum int target, @GLuint int index, + @AutoSize(value = "params", expression = " >> 2") @GLsizei int count, @Const FloatBuffer params); + + /* + NV_gpu_program4: New program commands and queries add "Named" + prefix to name and replace "enum target" with "uint program" + */ + + @Dependent("GL_NV_gpu_program4") + void glNamedProgramLocalParameterI4iEXT(@GLuint int program, @GLenum int target, @GLuint int index, int x, int y, int z, int w); + + @Dependent("GL_NV_gpu_program4") + @StripPostfix("params") + void glNamedProgramLocalParameterI4ivEXT(@GLuint int program, @GLenum int target, @GLuint int index, @Check("4") @Const IntBuffer params); + + @Dependent("GL_NV_gpu_program4") + @StripPostfix("params") + void glNamedProgramLocalParametersI4ivEXT(@GLuint int program, @GLenum int target, @GLuint int index, + @AutoSize(value = "params", expression = " >> 2") @GLsizei int count, @Const IntBuffer params); + + @Dependent("GL_NV_gpu_program4") + void glNamedProgramLocalParameterI4uiEXT(@GLuint int program, @GLenum int target, @GLuint int index, @GLuint int x, @GLuint int y, @GLuint int z, @GLuint int w); + + @Dependent("GL_NV_gpu_program4") + @StripPostfix("params") + void glNamedProgramLocalParameterI4uivEXT(@GLuint int program, @GLenum int target, @GLuint int index, @Check("4") @Const @GLuint IntBuffer params); + + @Dependent("GL_NV_gpu_program4") + @StripPostfix("params") + void glNamedProgramLocalParametersI4uivEXT(@GLuint int program, @GLenum int target, @GLuint int index, + @AutoSize(value = "params", expression = " >> 2") @GLsizei int count, @Const @GLuint IntBuffer params); + + @Dependent("GL_NV_gpu_program4") + @StripPostfix("params") + void glGetNamedProgramLocalParameterIivEXT(@GLuint int program, @GLenum int target, @GLuint int index, @Check("4") @OutParameter IntBuffer params); + + @Dependent("GL_NV_gpu_program4") + @StripPostfix("params") + void glGetNamedProgramLocalParameterIuivEXT(@GLuint int program, @GLenum int target, @GLuint int index, @Check("4") @OutParameter @GLuint IntBuffer params); + + /* + OpenGL 3.0: New renderbuffer commands add "Named" prefix to name + and replace "enum target" with "uint renderbuffer" + */ + + @Dependent("OpenGL30,GL_EXT_framebuffer_object") + void glNamedRenderbufferStorageEXT(@GLuint int renderbuffer, @GLenum int internalformat, @GLsizei int width, @GLsizei int height); + + @Dependent("OpenGL30,GL_EXT_framebuffer_object") + @StripPostfix("params") + void glGetNamedRenderbufferParameterivEXT(@GLuint int renderbuffer, @GLenum int pname, @Check("4") @OutParameter IntBuffer params); + + @Alternate("glGetNamedRenderbufferParameterivEXT") + @GLreturn("params") + @Dependent("OpenGL30,GL_EXT_framebuffer_object") + @StripPostfix("params") + void glGetNamedRenderbufferParameterivEXT2(@GLuint int renderbuffer, @GLenum int pname, @OutParameter IntBuffer params); + + /* + EXT_framebuffer_multisample: New renderbuffer commands add "Named" + prefix to name and replace "enum target" with "uint renderbuffer" + */ + + @Dependent("OpenGL30,GL_EXT_framebuffer_multisample") + void glNamedRenderbufferStorageMultisampleEXT(@GLuint int renderbuffer, @GLsizei int samples, @GLenum int internalformat, @GLsizei int width, @GLsizei int height); + + /* + NV_framebuffer_multisample_coverage: New renderbuffer commands + add "Named" prefix to name and replace "enum target" with "uint + renderbuffer" + */ + + @Dependent("GL_NV_framebuffer_multisample_coverage") + void glNamedRenderbufferStorageMultisampleCoverageEXT(@GLuint int renderbuffer, @GLsizei int coverageSamples, @GLsizei int colorSamples, @GLenum int internalformat, @GLsizei int width, @GLsizei int height); + + /* + OpenGL 3.0: New framebuffer commands add "Named" prefix to name + and replace "enum target" with "uint framebuffer" + */ + + @Dependent("OpenGL30,GL_EXT_framebuffer_object") + @GLenum + int glCheckNamedFramebufferStatusEXT(@GLuint int framebuffer, @GLenum int target); + + @Dependent("OpenGL30,GL_EXT_framebuffer_object") + void glNamedFramebufferTexture1DEXT(@GLuint int framebuffer, @GLenum int attachment, @GLenum int textarget, @GLuint int texture, int level); + + @Dependent("OpenGL30,GL_EXT_framebuffer_object") + void glNamedFramebufferTexture2DEXT(@GLuint int framebuffer, @GLenum int attachment, @GLenum int textarget, @GLuint int texture, int level); + + @Dependent("OpenGL30,GL_EXT_framebuffer_object") + void glNamedFramebufferTexture3DEXT(@GLuint int framebuffer, @GLenum int attachment, @GLenum int textarget, @GLuint int texture, int level, int zoffset); + + @Dependent("OpenGL30,GL_EXT_framebuffer_object") + void glNamedFramebufferRenderbufferEXT(@GLuint int framebuffer, @GLenum int attachment, @GLenum int renderbuffertarget, @GLuint int renderbuffer); + + @Dependent("OpenGL30,GL_EXT_framebuffer_object") + @StripPostfix("params") + void glGetNamedFramebufferAttachmentParameterivEXT(@GLuint int framebuffer, @GLenum int attachment, @GLenum int pname, @Check("4") @OutParameter IntBuffer params); + + @Alternate("glGetNamedFramebufferAttachmentParameterivEXT") + @GLreturn("params") + @Dependent("OpenGL30,GL_EXT_framebuffer_object") + @StripPostfix("params") + void glGetNamedFramebufferAttachmentParameterivEXT2(@GLuint int framebuffer, @GLenum int attachment, @GLenum int pname, @OutParameter IntBuffer params); + + /* + OpenGL 3.0: New texture commands add "Texture" within name and + replace "enum target" with "uint texture" + */ + + @Dependent("OpenGL30,GL_EXT_framebuffer_object") + void glGenerateTextureMipmapEXT(@GLuint int texture, @GLenum int target); + + /* + OpenGL 3.0: New texture commands add "MultiTex" within name and + replace "enum target" with "enum texunit" + */ + + @Dependent("OpenGL30,GL_EXT_framebuffer_object") + void glGenerateMultiTexMipmapEXT(@GLenum int texunit, @GLenum int target); + + /* + OpenGL 3.0: New framebuffer commands + */ + + @Dependent("OpenGL30,GL_EXT_framebuffer_object") + void glFramebufferDrawBufferEXT(@GLuint int framebuffer, @GLenum int mode); + + @Dependent("OpenGL30,GL_EXT_framebuffer_object") + void glFramebufferDrawBuffersEXT(@GLuint int framebuffer, @AutoSize("bufs") @GLsizei int n, @Const @GLenum IntBuffer bufs); + + @Dependent("OpenGL30,GL_EXT_framebuffer_object") + void glFramebufferReadBufferEXT(@GLuint int framebuffer, @GLenum int mode); + + /* + OpenGL 3.0: New framebuffer query + */ + + @Dependent("OpenGL30,GL_EXT_framebuffer_object") + @StripPostfix("param") + void glGetFramebufferParameterivEXT(@GLuint int framebuffer, @GLenum int pname, @Check("4") @OutParameter IntBuffer param); + + @Alternate("glGetFramebufferParameterivEXT") + @GLreturn("param") + @Dependent("OpenGL30,GL_EXT_framebuffer_object") + @StripPostfix("param") + void glGetFramebufferParameterivEXT2(@GLuint int framebuffer, @GLenum int pname, @OutParameter IntBuffer param); + + /* + OpenGL 3.1: New buffer data copy command + */ + + @Dependent("OpenGL31,GL_ARB_copy_buffer") + void glNamedCopyBufferSubDataEXT(@GLuint int readBuffer, @GLuint int writeBuffer, @GLintptr long readoffset, @GLintptr long writeoffset, @GLsizeiptr long size); + + /* + EXT_geometry_shader4 or NV_geometry_program4: New framebuffer commands + add "Named" prefix to name and replace "enum target" with "uint + framebuffer" + */ + + @Dependent("GL_EXT_geometry_shader4,NV_geometry_program4") + void glNamedFramebufferTextureEXT(@GLuint int framebuffer, @GLenum int attachment, @GLuint int texture, int level); + + @Dependent("GL_EXT_geometry_shader4,NV_geometry_program4") + void glNamedFramebufferTextureLayerEXT(@GLuint int framebuffer, @GLenum int attachment, @GLuint int texture, int level, int layer); + + @Dependent("GL_EXT_geometry_shader4,NV_geometry_program4") + void glNamedFramebufferTextureFaceEXT(@GLuint int framebuffer, @GLenum int attachment, @GLuint int texture, int level, @GLenum int face); + + /* + NV_explicit_multisample: New texture renderbuffer object command + replaces "Tex" in name with "Texture" and add initial "uint texture" + parameter + */ + + @Dependent("GL_NV_explicit_multisample") + void glTextureRenderbufferEXT(@GLuint int texture, @GLenum int target, @GLuint int renderbuffer); + + /* + NV_explicit_multisample: New multitexture texture renderbuffer command + prefixes "Multi" before "Tex" and add an initial "enum texunit" + parameter (to identify the texture unit) + */ + + @Dependent("GL_NV_explicit_multisample") + void glMultiTexRenderbufferEXT(@GLenum int texunit, @GLenum int target, @GLuint int renderbuffer); + + /* + OpenGL 3.0: New vertex array specification commands for vertex + array objects prefix "VertexArray", add initial "uint vaobj" and + "uint buffer" parameters, change "Pointer" suffix to "Offset", + and change the final parameter from "const void *" to "intptr offset" + */ + + @Dependent("OpenGL30") + @DeprecatedGL + void glVertexArrayVertexOffsetEXT(@GLuint int vaobj, @GLuint int buffer, int size, @GLenum int type, @GLsizei int stride, @GLintptr long offset); + + @Dependent("OpenGL30") + @DeprecatedGL + void glVertexArrayColorOffsetEXT(@GLuint int vaobj, @GLuint int buffer, int size, @GLenum int type, @GLsizei int stride, @GLintptr long offset); + + @Dependent("OpenGL30") + @DeprecatedGL + void glVertexArrayEdgeFlagOffsetEXT(@GLuint int vaobj, @GLuint int buffer, @GLsizei int stride, @GLintptr long offset); + + @Dependent("OpenGL30") + void glVertexArrayIndexOffsetEXT(@GLuint int vaobj, @GLuint int buffer, @GLenum int type, @GLsizei int stride, @GLintptr long offset); + + @Dependent("OpenGL30") + @DeprecatedGL + void glVertexArrayNormalOffsetEXT(@GLuint int vaobj, @GLuint int buffer, @GLenum int type, @GLsizei int stride, @GLintptr long offset); + + @Dependent("OpenGL30") + @DeprecatedGL + void glVertexArrayTexCoordOffsetEXT(@GLuint int vaobj, @GLuint int buffer, int size, @GLenum int type, @GLsizei int stride, @GLintptr long offset); + + @Dependent("OpenGL30") + @DeprecatedGL + void glVertexArrayMultiTexCoordOffsetEXT(@GLuint int vaobj, @GLuint int buffer, @GLenum int texunit, int size, @GLenum int type, @GLsizei int stride, @GLintptr long offset); + + @Dependent("OpenGL30") + @DeprecatedGL + void glVertexArrayFogCoordOffsetEXT(@GLuint int vaobj, @GLuint int buffer, @GLenum int type, @GLsizei int stride, @GLintptr long offset); + + @Dependent("OpenGL30") + @DeprecatedGL + void glVertexArraySecondaryColorOffsetEXT(@GLuint int vaobj, @GLuint int buffer, int size, @GLenum int type, @GLsizei int stride, @GLintptr long offset); + + @Dependent("OpenGL30") + void glVertexArrayVertexAttribOffsetEXT(@GLuint int vaobj, @GLuint int buffer, @GLuint int index, int size, @GLenum int type, boolean normalized, @GLsizei int stride, @GLintptr long offset); + + @Dependent("OpenGL30") + void glVertexArrayVertexAttribIOffsetEXT(@GLuint int vaobj, @GLuint int buffer, @GLuint int index, int size, @GLenum int type, @GLsizei int stride, @GLintptr long offset); + + /* + OpenGL 3.0: New vertex array enable commands for vertex array + objects change "ClientState" to "VertexArray" and add an initial + "uint vaobj" parameter + */ + + @Dependent("OpenGL30") + void glEnableVertexArrayEXT(@GLuint int vaobj, @GLenum int array); + + @Dependent("OpenGL30") + void glDisableVertexArrayEXT(@GLuint int vaobj, @GLenum int array); + + /* + OpenGL 3.0: New vertex attrib array enable commands for vertex + array objects change "VertexAttribArray" to "VertexArrayAttrib" + and add an initial "uint vaobj" parameter + */ + + @Dependent("OpenGL30") + void glEnableVertexArrayAttribEXT(@GLuint int vaobj, @GLuint int index); + + @Dependent("OpenGL30") + void glDisableVertexArrayAttribEXT(@GLuint int vaobj, @GLuint int index); + + /* + OpenGL 3.0: New queries for vertex array objects + */ + + @Dependent("OpenGL30") + @StripPostfix("param") + void glGetVertexArrayIntegervEXT(@GLuint int vaobj, @GLenum int pname, @OutParameter @Check("16") IntBuffer param); + + @Alternate("glGetVertexArrayIntegervEXT") + @GLreturn("param") + @Dependent("OpenGL30") + @StripPostfix("param") + void glGetVertexArrayIntegervEXT2(@GLuint int vaobj, @GLenum int pname, @OutParameter IntBuffer param); + + @Dependent("OpenGL30") + @StripPostfix("param") + void glGetVertexArrayPointervEXT(@GLuint int vaobj, @GLenum int pname, @Result @GLvoid ByteBuffer param); + + @Dependent("OpenGL30") + @StripPostfix(value = "param") + void glGetVertexArrayIntegeri_vEXT(@GLuint int vaobj, @GLuint int index, @GLenum int pname, @OutParameter @Check("16") IntBuffer param); + + @Alternate("glGetVertexArrayIntegeri_vEXT") + @GLreturn("param") + @Dependent("OpenGL30") + @StripPostfix(value = "param", postfix = "_v") + void glGetVertexArrayIntegeri_vEXT2(@GLuint int vaobj, @GLuint int index, @GLenum int pname, @OutParameter IntBuffer param); + + @Dependent("OpenGL30") + @StripPostfix(value = "param") + void glGetVertexArrayPointeri_vEXT(@GLuint int vaobj, @GLuint int index, @GLenum int pname, @Result @GLvoid ByteBuffer param); + + /* + OpenGL 3.0: New buffer commands replace "Buffer" with "NamedBuffer" + in name and replace "enum target" parameter with "uint buffer" + */ + + /** + * glMapNamedBufferRangeEXT maps a GL buffer object range to a ByteBuffer. The old_buffer argument can be null, + * in which case a new ByteBuffer will be created, pointing to the returned memory. If old_buffer is non-null, + * it will be returned if it points to the same mapped memory and has the same capacity as the buffer object, + * otherwise a new ByteBuffer is created. That way, an application will normally use glMapNamedBufferRangeEXT like this: + *

    + * ByteBuffer mapped_buffer; mapped_buffer = glMapNamedBufferRangeEXT(..., ..., ..., ..., null); ... // Another map on the same buffer mapped_buffer = glMapNamedBufferRangeEXT(..., ..., ..., ..., mapped_buffer); + *

    + * Only ByteBuffers returned from this method are to be passed as the old_buffer argument. User-created ByteBuffers cannot be reused. + * + * @param old_buffer A ByteBuffer. If this argument points to the same address and has the same capacity as the new mapping, it will be returned and no new buffer will be created. + * + * @return A ByteBuffer representing the mapped buffer memory. + */ + @Dependent("OpenGL30") + @CachedResult(isRange = true) + @GLvoid + @AutoResultSize("length") + ByteBuffer glMapNamedBufferRangeEXT(@GLuint int buffer, @GLintptr long offset, @GLsizeiptr long length, @GLbitfield int access); + + @Dependent("OpenGL30") + void glFlushMappedNamedBufferRangeEXT(@GLuint int buffer, @GLintptr long offset, @GLsizeiptr long length); + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/EXT_draw_buffers2.java b/src/templates/org/lwjgl/opengl/EXT_draw_buffers2.java new file mode 100644 index 0000000..8794b91 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/EXT_draw_buffers2.java @@ -0,0 +1,65 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +import java.nio.IntBuffer; +import java.nio.ByteBuffer; + +public interface EXT_draw_buffers2 { + + void glColorMaskIndexedEXT(@GLuint int buf, boolean r, boolean g, boolean b, boolean a); + + @StripPostfix("data") + void glGetBooleanIndexedvEXT(@GLenum int value, @GLuint int index, @OutParameter @Check("4") @GLboolean ByteBuffer data); + + @Alternate("glGetBooleanIndexedvEXT") + @GLreturn("data") + @StripPostfix("data") + void glGetBooleanIndexedvEXT2(@GLenum int value, @GLuint int index, @OutParameter @GLboolean ByteBuffer data); + + @StripPostfix("data") + void glGetIntegerIndexedvEXT(@GLenum int value, @GLuint int index, @OutParameter @Check("4") IntBuffer data); + + @Alternate("glGetIntegerIndexedvEXT") + @GLreturn("data") + @StripPostfix("data") + void glGetIntegerIndexedvEXT2(@GLenum int value, @GLuint int index, @OutParameter IntBuffer data); + + void glEnableIndexedEXT(@GLenum int target, @GLuint int index); + + void glDisableIndexedEXT(@GLenum int target, @GLuint int index); + + boolean glIsEnabledIndexedEXT(@GLenum int target, @GLuint int index); + +} diff --git a/src/templates/org/lwjgl/opengl/EXT_draw_instanced.java b/src/templates/org/lwjgl/opengl/EXT_draw_instanced.java new file mode 100644 index 0000000..5baa846 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/EXT_draw_instanced.java @@ -0,0 +1,49 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +import java.nio.Buffer; + +public interface EXT_draw_instanced { + + void glDrawArraysInstancedEXT(@GLenum int mode, int first, @GLsizei int count, @GLsizei int primcount); + + void glDrawElementsInstancedEXT(@GLenum int mode, @AutoSize("indices") @GLsizei int count, @AutoType("indices") @GLenum int type, + @BufferObject(BufferKind.ElementVBO) + @Const + @GLubyte + @GLushort + @GLuint Buffer indices, @GLsizei int primcount); + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/EXT_draw_range_elements.java b/src/templates/org/lwjgl/opengl/EXT_draw_range_elements.java new file mode 100644 index 0000000..1f47a45 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/EXT_draw_range_elements.java @@ -0,0 +1,48 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +import java.nio.*; + +public interface EXT_draw_range_elements { + int GL_MAX_ELEMENTS_VERTICES_EXT = 0x80E8; + int GL_MAX_ELEMENTS_INDICES_EXT = 0x80E9; + + void glDrawRangeElementsEXT(@GLenum int mode, @GLuint int start, @GLuint int end, @AutoSize("pIndices") @GLsizei int count, @AutoType("pIndices") @GLenum int type, + @BufferObject(BufferKind.ElementVBO) + @Const + @GLubyte + @GLushort + @GLuint Buffer pIndices); +} diff --git a/src/templates/org/lwjgl/opengl/EXT_fog_coord.java b/src/templates/org/lwjgl/opengl/EXT_fog_coord.java new file mode 100644 index 0000000..85ba367 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/EXT_fog_coord.java @@ -0,0 +1,59 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +import java.nio.*; + +public interface EXT_fog_coord { + int GL_FOG_COORDINATE_SOURCE_EXT = 0x8450; + int GL_FOG_COORDINATE_EXT = 0x8451; + int GL_FRAGMENT_DEPTH_EXT = 0x8452; + int GL_CURRENT_FOG_COORDINATE_EXT = 0x8453; + int GL_FOG_COORDINATE_ARRAY_TYPE_EXT = 0x8454; + int GL_FOG_COORDINATE_ARRAY_STRIDE_EXT = 0x8455; + int GL_FOG_COORDINATE_ARRAY_POINTER_EXT = 0x8456; + int GL_FOG_COORDINATE_ARRAY_EXT = 0x8457; + + void glFogCoordfEXT(float coord); + + void glFogCoorddEXT(double coord); + + void glFogCoordPointerEXT(@AutoType("data") @GLenum int type, @GLsizei int stride, + @CachedReference + @BufferObject(BufferKind.ArrayVBO) + @Check + @Const + @GLfloat + @GLdouble Buffer data); +} diff --git a/src/templates/org/lwjgl/opengl/EXT_framebuffer_blit.java b/src/templates/org/lwjgl/opengl/EXT_framebuffer_blit.java new file mode 100644 index 0000000..a473d69 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/EXT_framebuffer_blit.java @@ -0,0 +1,75 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +public interface EXT_framebuffer_blit { + + /** + Accepted by the <target> parameter of BindFramebufferEXT, + CheckFramebufferStatusEXT, FramebufferTexture{1D|2D|3D}EXT, + FramebufferRenderbufferEXT, and + GetFramebufferAttachmentParameterivEXT. + */ + int GL_READ_FRAMEBUFFER_EXT = 0x8CA8; + int GL_DRAW_FRAMEBUFFER_EXT = 0x8CA9; + + /** + Accepted by the <pname> parameters of GetIntegerv, GetFloatv, and GetDoublev. + */ + int GL_DRAW_FRAMEBUFFER_BINDING_EXT = 0x8CA6; // alias FRAMEBUFFER_BINDING_EXT + int GL_READ_FRAMEBUFFER_BINDING_EXT = 0x8CAA; + + /** + Transfers a rectangle of pixel values from one + region of the read framebuffer to another in the draw framebuffer. + <mask> is the bitwise OR of a number of values indicating which + buffers are to be copied. The values are COLOR_BUFFER_BIT, + DEPTH_BUFFER_BIT, and STENCIL_BUFFER_BIT. + The pixels corresponding to these buffers are + copied from the source rectangle, bound by the locations (srcX0, + srcY0) and (srcX1, srcY1) inclusive, to the destination rectangle, + bound by the locations (dstX0, dstY0) and (dstX1, dstY1) + inclusive. + If the source and destination rectangle dimensions do not match, + the source image is stretched to fit the destination + rectangle. <filter> must be LINEAR or NEAREST and specifies the + method of interpolation to be applied if the image is + stretched. + */ + void glBlitFramebufferEXT( + @GLint int srcX0, @GLint int srcY0, @GLint int srcX1, @GLint int srcY1, + @GLint int dstX0, @GLint int dstY0, @GLint int dstX1, @GLint int dstY1, + @GLbitfield int mask, @GLenum int filter); + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/EXT_framebuffer_multisample.java b/src/templates/org/lwjgl/opengl/EXT_framebuffer_multisample.java new file mode 100644 index 0000000..9996e3e --- /dev/null +++ b/src/templates/org/lwjgl/opengl/EXT_framebuffer_multisample.java @@ -0,0 +1,59 @@ +/* + * 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; + +import org.lwjgl.util.generator.GLenum; +import org.lwjgl.util.generator.GLsizei; + +public interface EXT_framebuffer_multisample { + + /** Accepted by the <pname> parameter of GetRenderbufferParameterivEXT. */ + int GL_RENDERBUFFER_SAMPLES_EXT = 0x8CAB; + + /** Returned by CheckFramebufferStatusEXT. */ + int GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT = 0x8D56; + + /** + * Accepted by the <pname> parameter of GetBooleanv, GetIntegerv, + * GetFloatv, and GetDoublev. + */ + int GL_MAX_SAMPLES_EXT = 0x8D57; + + /** + * Establishes the data storage, format, dimensions, and number of + * samples of a renderbuffer object's image. + */ + void glRenderbufferStorageMultisampleEXT( + @GLenum int target, @GLsizei int samples, + @GLenum int internalformat, + @GLsizei int width, @GLsizei int height); +} diff --git a/src/templates/org/lwjgl/opengl/EXT_framebuffer_object.java b/src/templates/org/lwjgl/opengl/EXT_framebuffer_object.java new file mode 100644 index 0000000..45e7b20 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/EXT_framebuffer_object.java @@ -0,0 +1,187 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +import java.nio.IntBuffer; + +public interface EXT_framebuffer_object { + + /** + * Accepted by the <target> parameter of BindFramebufferEXT, + * CheckFramebufferStatusEXT, FramebufferTexture{1D|2D|3D}EXT, and + * FramebufferRenderbufferEXT: + */ + int GL_FRAMEBUFFER_EXT = 0x8D40; + + /** + * Accepted by the <target> parameter of BindRenderbufferEXT, + * RenderbufferStorageEXT, and GetRenderbufferParameterivEXT, and + * returned by GetFramebufferAttachmentParameterivEXT: + */ + int GL_RENDERBUFFER_EXT = 0x8D41; + + /** + * Accepted by the <internalformat> parameter of + * RenderbufferStorageEXT: + */ + int GL_STENCIL_INDEX1_EXT = 0x8D46; + int GL_STENCIL_INDEX4_EXT = 0x8D47; + int GL_STENCIL_INDEX8_EXT = 0x8D48; + int GL_STENCIL_INDEX16_EXT = 0x8D49; + + /** Accepted by the <pname> parameter of GetRenderbufferParameterivEXT: */ + int GL_RENDERBUFFER_WIDTH_EXT = 0x8D42; + int GL_RENDERBUFFER_HEIGHT_EXT = 0x8D43; + int GL_RENDERBUFFER_INTERNAL_FORMAT_EXT = 0x8D44; + int GL_RENDERBUFFER_RED_SIZE_EXT = 0x8D50; + int GL_RENDERBUFFER_GREEN_SIZE_EXT = 0x8D51; + int GL_RENDERBUFFER_BLUE_SIZE_EXT = 0x8D52; + int GL_RENDERBUFFER_ALPHA_SIZE_EXT = 0x8D53; + int GL_RENDERBUFFER_DEPTH_SIZE_EXT = 0x8D54; + int GL_RENDERBUFFER_STENCIL_SIZE_EXT = 0x8D55; + + /** + * Accepted by the <pname> parameter of + * GetFramebufferAttachmentParameterivEXT: + */ + int GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT = 0x8CD0; + int GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT = 0x8CD1; + int GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT = 0x8CD2; + int GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT = 0x8CD3; + int GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT = 0x8CD4; + + /** + * Accepted by the <attachment> parameter of + * FramebufferTexture{1D|2D|3D}EXT, FramebufferRenderbufferEXT, and + * GetFramebufferAttachmentParameterivEXT + */ + int GL_COLOR_ATTACHMENT0_EXT = 0x8CE0; + int GL_COLOR_ATTACHMENT1_EXT = 0x8CE1; + int GL_COLOR_ATTACHMENT2_EXT = 0x8CE2; + int GL_COLOR_ATTACHMENT3_EXT = 0x8CE3; + int GL_COLOR_ATTACHMENT4_EXT = 0x8CE4; + int GL_COLOR_ATTACHMENT5_EXT = 0x8CE5; + int GL_COLOR_ATTACHMENT6_EXT = 0x8CE6; + int GL_COLOR_ATTACHMENT7_EXT = 0x8CE7; + int GL_COLOR_ATTACHMENT8_EXT = 0x8CE8; + int GL_COLOR_ATTACHMENT9_EXT = 0x8CE9; + int GL_COLOR_ATTACHMENT10_EXT = 0x8CEA; + int GL_COLOR_ATTACHMENT11_EXT = 0x8CEB; + int GL_COLOR_ATTACHMENT12_EXT = 0x8CEC; + int GL_COLOR_ATTACHMENT13_EXT = 0x8CED; + int GL_COLOR_ATTACHMENT14_EXT = 0x8CEE; + int GL_COLOR_ATTACHMENT15_EXT = 0x8CEF; + int GL_DEPTH_ATTACHMENT_EXT = 0x8D00; + int GL_STENCIL_ATTACHMENT_EXT = 0x8D20; + + /** Returned by CheckFramebufferStatusEXT(): */ + int GL_FRAMEBUFFER_COMPLETE_EXT = 0x8CD5; + int GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT = 0x8CD6; + int GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT = 0x8CD7; + int GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT = 0x8CD9; + int GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT = 0x8CDA; + int GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT = 0x8CDB; + int GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT = 0x8CDC; + int GL_FRAMEBUFFER_UNSUPPORTED_EXT = 0x8CDD; + + /** Accepted by GetIntegerv(): */ + int GL_FRAMEBUFFER_BINDING_EXT = 0x8CA6; + int GL_RENDERBUFFER_BINDING_EXT = 0x8CA7; + int GL_MAX_COLOR_ATTACHMENTS_EXT = 0x8CDF; + int GL_MAX_RENDERBUFFER_SIZE_EXT = 0x84E8; + + /** Returned by GetError(): */ + int GL_INVALID_FRAMEBUFFER_OPERATION_EXT = 0x0506; + + boolean glIsRenderbufferEXT(@GLuint int renderbuffer); + + void glBindRenderbufferEXT(@GLenum int target, @GLuint int renderbuffer); + + void glDeleteRenderbuffersEXT(@AutoSize("renderbuffers") int n, @Const @GLuint IntBuffer renderbuffers); + + @Alternate("glDeleteRenderbuffersEXT") + void glDeleteRenderbuffersEXT(@Constant("1") int n, @Constant(value = "APIUtils.getBufferInt().put(0, renderbuffer), 0", keepParam = true) int renderbuffer); + + void glGenRenderbuffersEXT(@AutoSize("renderbuffers") int n, @OutParameter @GLuint IntBuffer renderbuffers); + + @Alternate("glGenRenderbuffersEXT") + @GLreturn("renderbuffers") + void glGenRenderbuffersEXT2(@Constant("1") int n, @OutParameter @GLuint IntBuffer renderbuffers); + + void glRenderbufferStorageEXT(@GLenum int target, @GLenum int internalformat, @GLsizei int width, @GLsizei int height); + + @StripPostfix("params") + void glGetRenderbufferParameterivEXT(@GLenum int target, @GLenum int pname, @OutParameter @Check("4") IntBuffer params); + + @Alternate("glGetRenderbufferParameterivEXT") + @GLreturn("params") + @StripPostfix("params") + void glGetRenderbufferParameterivEXT2(@GLenum int target, @GLenum int pname, @OutParameter IntBuffer params); + + boolean glIsFramebufferEXT(@GLuint int framebuffer); + + void glBindFramebufferEXT(@GLenum int target, @GLuint int framebuffer); + + void glDeleteFramebuffersEXT(@AutoSize("framebuffers") int n, @Const @GLuint IntBuffer framebuffers); + + @Alternate("glDeleteFramebuffersEXT") + void glDeleteFramebuffersEXT(@Constant("1") int n, @Constant(value = "APIUtils.getBufferInt().put(0, framebuffer), 0", keepParam = true) int framebuffer); + + void glGenFramebuffersEXT(@AutoSize("framebuffers") int n, @OutParameter @GLuint IntBuffer framebuffers); + + @Alternate("glGenFramebuffersEXT") + @GLreturn("framebuffers") + void glGenFramebuffersEXT2(@Constant("1") int n, @OutParameter @GLuint IntBuffer framebuffers); + + @GLenum + int glCheckFramebufferStatusEXT(@GLenum int target); + + void glFramebufferTexture1DEXT(@GLenum int target, @GLenum int attachment, @GLenum int textarget, @GLuint int texture, int level); + + void glFramebufferTexture2DEXT(@GLenum int target, @GLenum int attachment, @GLenum int textarget, @GLuint int texture, int level); + + void glFramebufferTexture3DEXT(@GLenum int target, @GLenum int attachment, @GLenum int textarget, @GLuint int texture, int level, int zoffset); + + void glFramebufferRenderbufferEXT(@GLenum int target, @GLenum int attachment, @GLenum int renderbuffertarget, @GLuint int renderbuffer); + + @StripPostfix("params") + void glGetFramebufferAttachmentParameterivEXT(@GLenum int target, @GLenum int attachment, @GLenum int pname, @OutParameter @Check("4") IntBuffer params); + + @Alternate("glGetFramebufferAttachmentParameterivEXT") + @GLreturn("params") + @StripPostfix("params") + void glGetFramebufferAttachmentParameterivEXT2(@GLenum int target, @GLenum int attachment, @GLenum int pname, @OutParameter IntBuffer params); + + void glGenerateMipmapEXT(@GLenum int target); +} diff --git a/src/templates/org/lwjgl/opengl/EXT_framebuffer_sRGB.java b/src/templates/org/lwjgl/opengl/EXT_framebuffer_sRGB.java new file mode 100644 index 0000000..105f9ae --- /dev/null +++ b/src/templates/org/lwjgl/opengl/EXT_framebuffer_sRGB.java @@ -0,0 +1,62 @@ +/* + * 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; + +public interface EXT_framebuffer_sRGB { + + /** + * Accepted by the <attribList> parameter of glXChooseVisual, and by + * the <attrib> parameter of glXGetConfig: + */ + int GLX_FRAMEBUFFER_SRGB_CAPABLE_EXT = 0x20B2; + + /** + * Accepted by the <piAttributes> parameter of + * wglGetPixelFormatAttribivEXT, wglGetPixelFormatAttribfvEXT, and + * the <piAttribIList> and <pfAttribIList> of wglChoosePixelFormatEXT: + */ + int WGL_FRAMEBUFFER_SRGB_CAPABLE_EXT = 0x20A9; + + /** + * Accepted by the <cap> parameter of Enable, Disable, and IsEnabled, + * and by the <pname> parameter of GetBooleanv, GetIntegerv, GetFloatv, + * and GetDoublev: + */ + int GL_FRAMEBUFFER_SRGB_EXT = 0x8DB9; + + /** + * Accepted by the <pname> parameter of GetBooleanv, GetIntegerv, + * GetFloatv, and GetDoublev: + */ + int GL_FRAMEBUFFER_SRGB_CAPABLE_EXT = 0x8DBA; + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/EXT_geometry_shader4.java b/src/templates/org/lwjgl/opengl/EXT_geometry_shader4.java new file mode 100644 index 0000000..5745ca0 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/EXT_geometry_shader4.java @@ -0,0 +1,101 @@ +/* + * 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; + +import org.lwjgl.util.generator.GLenum; +import org.lwjgl.util.generator.GLuint; + +public interface EXT_geometry_shader4 { + + /** + * Accepted by the <type> parameter of CreateShader and returned by the + * <params> parameter of GetShaderiv: + */ + int GL_GEOMETRY_SHADER_EXT = 0x8DD9; + + /** + * Accepted by the <pname> parameter of ProgramParameteriEXT and + * GetProgramiv: + */ + int GL_GEOMETRY_VERTICES_OUT_EXT = 0x8DDA; + int GL_GEOMETRY_INPUT_TYPE_EXT = 0x8DDB; + int GL_GEOMETRY_OUTPUT_TYPE_EXT = 0x8DDC; + + /** + * Accepted by the <pname> parameter of GetBooleanv, GetIntegerv, + * GetFloatv, and GetDoublev: + */ + int GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_EXT = 0x8C29; + int GL_MAX_GEOMETRY_VARYING_COMPONENTS_EXT = 0x8DDD; + int GL_MAX_VERTEX_VARYING_COMPONENTS_EXT = 0x8DDE; + int GL_MAX_VARYING_COMPONENTS_EXT = 0x8B4B; + int GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_EXT = 0x8DDF; + int GL_MAX_GEOMETRY_OUTPUT_VERTICES_EXT = 0x8DE0; + int GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_EXT = 0x8DE1; + + /** + * Accepted by the <mode> parameter of Begin, DrawArrays, + * MultiDrawArrays, DrawElements, MultiDrawElements, and + * DrawRangeElements: + */ + int GL_LINES_ADJACENCY_EXT = 0xA; + int GL_LINE_STRIP_ADJACENCY_EXT = 0xB; + int GL_TRIANGLES_ADJACENCY_EXT = 0xC; + int GL_TRIANGLE_STRIP_ADJACENCY_EXT = 0xD; + + /** Returned by CheckFramebufferStatusEXT: */ + int GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT = 0x8DA8; + int GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_EXT = 0x8DA9; + + /** + * Accepted by the <pname> parameter of GetFramebufferAttachment- + * ParameterivEXT: + */ + int GL_FRAMEBUFFER_ATTACHMENT_LAYERED_EXT = 0x8DA7; + int GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT = 0x8CD4; + + /** + * Accepted by the <cap> parameter of Enable, Disable, and IsEnabled, + * and by the <pname> parameter of GetIntegerv, GetFloatv, GetDoublev, + * and GetBooleanv: + */ + int GL_PROGRAM_POINT_SIZE_EXT = 0x8642; + + void glProgramParameteriEXT(@GLuint int program, @GLenum int pname, int value); + + void glFramebufferTextureEXT(@GLenum int target, @GLenum int attachment, @GLuint int texture, int level); + + void glFramebufferTextureLayerEXT(@GLenum int target, @GLenum int attachment, @GLuint int texture, int level, int layer); + + void glFramebufferTextureFaceEXT(@GLenum int target, @GLenum int attachment, @GLuint int texture, int level, @GLenum int face); + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/EXT_gpu_program_parameters.java b/src/templates/org/lwjgl/opengl/EXT_gpu_program_parameters.java new file mode 100644 index 0000000..3cde1bf --- /dev/null +++ b/src/templates/org/lwjgl/opengl/EXT_gpu_program_parameters.java @@ -0,0 +1,46 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +import java.nio.*; + +public interface EXT_gpu_program_parameters { + + @StripPostfix("params") + void glProgramEnvParameters4fvEXT(@GLenum int target, @GLuint int index, @GLsizei int count, @Check("count << 2") @Const FloatBuffer params); + + @StripPostfix("params") + void glProgramLocalParameters4fvEXT(@GLenum int target, @GLuint int index, @GLsizei int count, @Check("count << 2") @Const FloatBuffer params); + +} diff --git a/src/templates/org/lwjgl/opengl/EXT_gpu_shader4.java b/src/templates/org/lwjgl/opengl/EXT_gpu_shader4.java new file mode 100644 index 0000000..283903f --- /dev/null +++ b/src/templates/org/lwjgl/opengl/EXT_gpu_shader4.java @@ -0,0 +1,209 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +import java.nio.Buffer; +import java.nio.ByteBuffer; +import java.nio.IntBuffer; +import java.nio.ShortBuffer; + +public interface EXT_gpu_shader4 { + + /** + * Accepted by the <pname> parameters of GetVertexAttribdv, + * GetVertexAttribfv, GetVertexAttribiv, GetVertexAttribIivEXT, and + * GetVertexAttribIuivEXT: + */ + int GL_VERTEX_ATTRIB_ARRAY_INTEGER_EXT = 0x88FD; + + /** Returned by the <type> parameter of GetActiveUniform: */ + + int GL_SAMPLER_1D_ARRAY_EXT = 0x8DC0; + int GL_SAMPLER_2D_ARRAY_EXT = 0x8DC1; + int GL_SAMPLER_BUFFER_EXT = 0x8DC2; + int GL_SAMPLER_1D_ARRAY_SHADOW_EXT = 0x8DC3; + int GL_SAMPLER_2D_ARRAY_SHADOW_EXT = 0x8DC4; + int GL_SAMPLER_CUBE_SHADOW_EXT = 0x8DC5; + int GL_UNSIGNED_INT = 0x1405; + int GL_UNSIGNED_INT_VEC2_EXT = 0x8DC6; + int GL_UNSIGNED_INT_VEC3_EXT = 0x8DC7; + int GL_UNSIGNED_INT_VEC4_EXT = 0x8DC8; + int GL_INT_SAMPLER_1D_EXT = 0x8DC9; + int GL_INT_SAMPLER_2D_EXT = 0x8DCA; + int GL_INT_SAMPLER_3D_EXT = 0x8DCB; + int GL_INT_SAMPLER_CUBE_EXT = 0x8DCC; + int GL_INT_SAMPLER_2D_RECT_EXT = 0x8DCD; + int GL_INT_SAMPLER_1D_ARRAY_EXT = 0x8DCE; + int GL_INT_SAMPLER_2D_ARRAY_EXT = 0x8DCF; + int GL_INT_SAMPLER_BUFFER_EXT = 0x8DD0; + int GL_UNSIGNED_INT_SAMPLER_1D_EXT = 0x8DD1; + int GL_UNSIGNED_INT_SAMPLER_2D_EXT = 0x8DD2; + int GL_UNSIGNED_INT_SAMPLER_3D_EXT = 0x8DD3; + int GL_UNSIGNED_INT_SAMPLER_CUBE_EXT = 0x8DD4; + int GL_UNSIGNED_INT_SAMPLER_2D_RECT_EXT = 0x8DD5; + int GL_UNSIGNED_INT_SAMPLER_1D_ARRAY_EXT = 0x8DD6; + int GL_UNSIGNED_INT_SAMPLER_2D_ARRAY_EXT = 0x8DD7; + int GL_UNSIGNED_INT_SAMPLER_BUFFER_EXT = 0x8DD8; + + /** + * Accepted by the <pname> parameter of GetBooleanv, GetIntegerv, GetFloatv, + * and GetDoublev: + */ + int GL_MIN_PROGRAM_TEXEL_OFFSET_EXT = 0x8904; + int GL_MAX_PROGRAM_TEXEL_OFFSET_EXT = 0x8905; + + @NoErrorCheck + void glVertexAttribI1iEXT(@GLuint int index, int x); + + @NoErrorCheck + void glVertexAttribI2iEXT(@GLuint int index, int x, int y); + + @NoErrorCheck + void glVertexAttribI3iEXT(@GLuint int index, int x, int y, int z); + + @NoErrorCheck + void glVertexAttribI4iEXT(@GLuint int index, int x, int y, int z, int w); + + @NoErrorCheck + void glVertexAttribI1uiEXT(@GLuint int index, @GLuint int x); + + @NoErrorCheck + void glVertexAttribI2uiEXT(@GLuint int index, @GLuint int x, @GLuint int y); + + @NoErrorCheck + void glVertexAttribI3uiEXT(@GLuint int index, @GLuint int x, @GLuint int y, @GLuint int z); + + @NoErrorCheck + void glVertexAttribI4uiEXT(@GLuint int index, @GLuint int x, @GLuint int y, @GLuint int z, @GLuint int w); + + @NoErrorCheck + @StripPostfix("v") + void glVertexAttribI1ivEXT(@GLuint int index, @Check("1") @Const IntBuffer v); + + @NoErrorCheck + @StripPostfix("v") + void glVertexAttribI2ivEXT(@GLuint int index, @Check("2") @Const IntBuffer v); + + @NoErrorCheck + @StripPostfix("v") + void glVertexAttribI3ivEXT(@GLuint int index, @Check("3") @Const IntBuffer v); + + @NoErrorCheck + @StripPostfix("v") + void glVertexAttribI4ivEXT(@GLuint int index, @Check("4") @Const IntBuffer v); + + @NoErrorCheck + @StripPostfix("v") + void glVertexAttribI1uivEXT(@GLuint int index, @Check("1") @Const @GLuint IntBuffer v); + + @NoErrorCheck + @StripPostfix("v") + void glVertexAttribI2uivEXT(@GLuint int index, @Check("2") @Const @GLuint IntBuffer v); + + @NoErrorCheck + @StripPostfix("v") + void glVertexAttribI3uivEXT(@GLuint int index, @Check("3") @Const @GLuint IntBuffer v); + + @NoErrorCheck + @StripPostfix("v") + void glVertexAttribI4uivEXT(@GLuint int index, @Check("4") @Const @GLuint IntBuffer v); + + @NoErrorCheck + @StripPostfix("v") + void glVertexAttribI4bvEXT(@GLuint int index, @Check("4") @Const ByteBuffer v); + + @NoErrorCheck + @StripPostfix("v") + void glVertexAttribI4svEXT(@GLuint int index, @Check("4") @Const ShortBuffer v); + + @NoErrorCheck + @StripPostfix("v") + void glVertexAttribI4ubvEXT(@GLuint int index, @Check("4") @Const @GLubyte ByteBuffer v); + + @NoErrorCheck + @StripPostfix("v") + void glVertexAttribI4usvEXT(@GLuint int index, @Check("4") @Const @GLushort ShortBuffer v); + + void glVertexAttribIPointerEXT(@GLuint int index, int size, @GLenum int type, @GLsizei int stride, + @CachedReference + @BufferObject(BufferKind.ArrayVBO) + @Check + @Const + @GLbyte + @GLubyte + @GLshort + @GLushort + @GLint + @GLuint Buffer buffer); + + @StripPostfix("params") + void glGetVertexAttribIivEXT(@GLuint int index, @GLenum int pname, @OutParameter @Check("4") IntBuffer params); + + @StripPostfix("params") + void glGetVertexAttribIuivEXT(@GLuint int index, @GLenum int pname, @OutParameter @Check("4") @GLuint IntBuffer params); + + void glUniform1uiEXT(int location, @GLuint int v0); + + void glUniform2uiEXT(int location, @GLuint int v0, @GLuint int v1); + + void glUniform3uiEXT(int location, @GLuint int v0, @GLuint int v1, @GLuint int v2); + + void glUniform4uiEXT(int location, @GLuint int v0, @GLuint int v1, @GLuint int v2, @GLuint int v3); + + @StripPostfix("value") + void glUniform1uivEXT(int location, @AutoSize("value") @GLsizei int count, @Const @GLuint IntBuffer value); + + @StripPostfix("value") + void glUniform2uivEXT(int location, @AutoSize(value = "value", expression = " >> 1") @GLsizei int count, @Const @GLuint IntBuffer value); + + @StripPostfix("value") + void glUniform3uivEXT(int location, @AutoSize(value = "value", expression = " / 3") @GLsizei int count, @Const @GLuint IntBuffer value); + + @StripPostfix("value") + void glUniform4uivEXT(int location, @AutoSize(value = "value", expression = " >> 2") @GLsizei int count, @Const @GLuint IntBuffer value); + + @StripPostfix("params") + void glGetUniformuivEXT(@GLuint int program, int location, @OutParameter @Check @GLuint IntBuffer params); + + void glBindFragDataLocationEXT(@GLuint int program, @GLuint int colorNumber, @NullTerminated @Const @GLchar ByteBuffer name); + + @Alternate("glBindFragDataLocationEXT") + void glBindFragDataLocationEXT(@GLuint int program, @GLuint int colorNumber, @NullTerminated CharSequence name); + + int glGetFragDataLocationEXT(@GLuint int program, @NullTerminated @Const @GLchar ByteBuffer name); + + @Alternate("glGetFragDataLocationEXT") + int glGetFragDataLocationEXT(@GLuint int program, @NullTerminated CharSequence name); + +} diff --git a/src/templates/org/lwjgl/opengl/EXT_multi_draw_arrays.java b/src/templates/org/lwjgl/opengl/EXT_multi_draw_arrays.java new file mode 100644 index 0000000..132fc11 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/EXT_multi_draw_arrays.java @@ -0,0 +1,40 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +import java.nio.*; + +public interface EXT_multi_draw_arrays { + void glMultiDrawArraysEXT(@GLenum int mode, IntBuffer piFirst, @Check("piFirst.remaining()") @GLsizei IntBuffer piCount, @AutoSize("piFirst") int primcount); +} diff --git a/src/templates/org/lwjgl/opengl/EXT_packed_depth_stencil.java b/src/templates/org/lwjgl/opengl/EXT_packed_depth_stencil.java new file mode 100644 index 0000000..0f4f10d --- /dev/null +++ b/src/templates/org/lwjgl/opengl/EXT_packed_depth_stencil.java @@ -0,0 +1,67 @@ +/* + * 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; + +public interface EXT_packed_depth_stencil { + + /** + Accepted by the <format> parameter of DrawPixels, ReadPixels, + TexImage1D, TexImage2D, TexImage3D, TexSubImage1D, TexSubImage2D, + TexSubImage3D, and GetTexImage, by the <type> parameter of + CopyPixels, by the <internalformat> parameter of TexImage1D, + TexImage2D, TexImage3D, CopyTexImage1D, CopyTexImage2D, and + RenderbufferStorageEXT, and returned in the <data> parameter of + GetTexLevelParameter and GetRenderbufferParameterivEXT. + */ + int GL_DEPTH_STENCIL_EXT = 0x84F9; + + /** + Accepted by the <type> parameter of DrawPixels, ReadPixels, + TexImage1D, TexImage2D, TexImage3D, TexSubImage1D, TexSubImage2D, + TexSubImage3D, and GetTexImage. + */ + int GL_UNSIGNED_INT_24_8_EXT = 0x84FA; + + /** + Accepted by the <internalformat> parameter of TexImage1D, + TexImage2D, TexImage3D, CopyTexImage1D, CopyTexImage2D, and + RenderbufferStorageEXT, and returned in the <data> parameter of + GetTexLevelParameter and GetRenderbufferParameterivEXT. + */ + int GL_DEPTH24_STENCIL8_EXT = 0x88F0; + + /** + Accepted by the <value> parameter of GetTexLevelParameter. + */ + int GL_TEXTURE_STENCIL_SIZE_EXT = 0x88F1; + +} diff --git a/src/templates/org/lwjgl/opengl/EXT_packed_float.java b/src/templates/org/lwjgl/opengl/EXT_packed_float.java new file mode 100644 index 0000000..6d1ae6f --- /dev/null +++ b/src/templates/org/lwjgl/opengl/EXT_packed_float.java @@ -0,0 +1,80 @@ +/* + * 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; + +public interface EXT_packed_float { + + /** + * Accepted by the <internalformat> parameter of TexImage1D, + * TexImage2D, TexImage3D, CopyTexImage1D, CopyTexImage2D, and + * RenderbufferStorageEXT: + */ + int GL_R11F_G11F_B10F_EXT = 0x8C3A; + + /** + * Accepted by the <type> parameter of DrawPixels, ReadPixels, + * TexImage1D, TexImage2D, GetTexImage, TexImage3D, TexSubImage1D, + * TexSubImage2D, TexSubImage3D, GetHistogram, GetMinmax, + * ConvolutionFilter1D, ConvolutionFilter2D, ConvolutionFilter3D, + * GetConvolutionFilter, SeparableFilter2D, GetSeparableFilter, + * ColorTable, ColorSubTable, and GetColorTable: + */ + int GL_UNSIGNED_INT_10F_11F_11F_REV_EXT = 0x8C3B; + + /** + * Accepted by the <pname> parameters of GetIntegerv, GetFloatv, and + * GetDoublev: + */ + int GL_RGBA_SIGNED_COMPONENTS_EXT = 0x8C3C; + + /** + * Accepted as a value in the <piAttribIList> and <pfAttribFList> + * parameter arrays of wglChoosePixelFormatARB, and returned in the + * <piValues> parameter array of wglGetPixelFormatAttribivARB, and the + * <pfValues> parameter array of wglGetPixelFormatAttribfvARB: + */ + int WGL_TYPE_RGBA_UNSIGNED_FLOAT_EXT = 0x20A8; + + /** + * Accepted as values of the <render_type> arguments in the + * glXCreateNewContext and glXCreateContext functions + */ + int GLX_RGBA_UNSIGNED_FLOAT_TYPE_EXT = 0x20B1; + + /** + * Returned by glXGetFBConfigAttrib (when <attribute> is set to + * GLX_RENDER_TYPE) and accepted by the <attrib_list> parameter of + * glXChooseFBConfig (following the GLX_RENDER_TYPE token): + */ + int GLX_RGBA_UNSIGNED_FLOAT_BIT_EXT = 0x00000008; + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/EXT_packed_pixels.java b/src/templates/org/lwjgl/opengl/EXT_packed_pixels.java new file mode 100644 index 0000000..a27c59e --- /dev/null +++ b/src/templates/org/lwjgl/opengl/EXT_packed_pixels.java @@ -0,0 +1,40 @@ +/* + * 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; + +public interface EXT_packed_pixels { + int GL_UNSIGNED_BYTE_3_3_2_EXT = 0x8032; + int GL_UNSIGNED_SHORT_4_4_4_4_EXT = 0x8033; + int GL_UNSIGNED_SHORT_5_5_5_1_EXT = 0x8034; + int GL_UNSIGNED_INT_8_8_8_8_EXT = 0x8035; + int GL_UNSIGNED_INT_10_10_10_2_EXT = 0x8036; +} diff --git a/src/templates/org/lwjgl/opengl/EXT_paletted_texture.java b/src/templates/org/lwjgl/opengl/EXT_paletted_texture.java new file mode 100644 index 0000000..ba27db9 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/EXT_paletted_texture.java @@ -0,0 +1,101 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +import java.nio.*; + +public interface EXT_paletted_texture { + + /** + * Accepted by the internalformat parameter of TexImage1D, TexImage2D and + * TexImage3DEXT: + */ + int GL_COLOR_INDEX1_EXT = 0x80E2; + int GL_COLOR_INDEX2_EXT = 0x80E3; + int GL_COLOR_INDEX4_EXT = 0x80E4; + int GL_COLOR_INDEX8_EXT = 0x80E5; + int GL_COLOR_INDEX12_EXT = 0x80E6; + int GL_COLOR_INDEX16_EXT = 0x80E7; + + /** + * Accepted by the pname parameter of GetColorTableParameterivEXT and + * GetColorTableParameterfvEXT: + */ + int GL_COLOR_TABLE_FORMAT_EXT = 0x80D8; + int GL_COLOR_TABLE_WIDTH_EXT = 0x80D9; + int GL_COLOR_TABLE_RED_SIZE_EXT = 0x80DA; + int GL_COLOR_TABLE_GREEN_SIZE_EXT = 0x80DB; + int GL_COLOR_TABLE_BLUE_SIZE_EXT = 0x80DC; + int GL_COLOR_TABLE_ALPHA_SIZE_EXT = 0x80DD; + int GL_COLOR_TABLE_LUMINANCE_SIZE_EXT = 0x80DE; + int GL_COLOR_TABLE_INTENSITY_SIZE_EXT = 0x80DF; + + /** + * Accepted by the value parameter of GetTexLevelParameter{if}v: + */ + int GL_TEXTURE_INDEX_SIZE_EXT = 0x80ED; + + void glColorTableEXT(@GLenum int target, @GLenum int internalFormat, @GLsizei int width, @GLenum int format, @GLenum int type, + @Check("GLChecks.calculateImageStorage(data, format, type, width, 1, 1)") + @Const + @GLbyte + @GLshort + @GLint + @GLfloat + @GLdouble Buffer data); + + void glColorSubTableEXT(@GLenum int target, @GLsizei int start, @GLsizei int count, @GLenum int format, @GLenum int type, + @Check("GLChecks.calculateImageStorage(data, format, type, count, 1, 1)") + @Const + @GLbyte + @GLshort + @GLint + @GLfloat + @GLdouble Buffer data); + + void glGetColorTableEXT(@GLenum int target, @GLenum int format, @GLenum int type, + @OutParameter + @Check + @GLbyte + @GLshort + @GLint + @GLfloat + @GLdouble Buffer data); + + @StripPostfix("params") + void glGetColorTableParameterivEXT(@GLenum int target, @GLenum int pname, @OutParameter @Check("4") IntBuffer params); + + @StripPostfix("params") + void glGetColorTableParameterfvEXT(@GLenum int target, @GLenum int pname, @OutParameter @Check("4") FloatBuffer params); +} diff --git a/src/templates/org/lwjgl/opengl/EXT_pixel_buffer_object.java b/src/templates/org/lwjgl/opengl/EXT_pixel_buffer_object.java new file mode 100644 index 0000000..237b489 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/EXT_pixel_buffer_object.java @@ -0,0 +1,50 @@ +/* + * 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; + +public interface EXT_pixel_buffer_object extends ARB_buffer_object { + + /** + * Accepted by the <target> parameters of BindBuffer, BufferData, + * BufferSubData, MapBuffer, UnmapBuffer, GetBufferSubData, + * GetBufferParameteriv, and GetBufferPointerv: + */ + int GL_PIXEL_PACK_BUFFER_EXT = 0x88EB; + int GL_PIXEL_UNPACK_BUFFER_EXT = 0x88EC; + + /** + * Accepted by the <pname> parameter of GetBooleanv, GetIntegerv, + * GetFloatv, and GetDoublev: + */ + int GL_PIXEL_PACK_BUFFER_BINDING_EXT = 0x88ED; + int GL_PIXEL_UNPACK_BUFFER_BINDING_EXT = 0x88EF; +} diff --git a/src/templates/org/lwjgl/opengl/EXT_point_parameters.java b/src/templates/org/lwjgl/opengl/EXT_point_parameters.java new file mode 100644 index 0000000..b2bce5f --- /dev/null +++ b/src/templates/org/lwjgl/opengl/EXT_point_parameters.java @@ -0,0 +1,48 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +import java.nio.*; + +public interface EXT_point_parameters { + int GL_POINT_SIZE_MIN_EXT = 0x8126; + int GL_POINT_SIZE_MAX_EXT = 0x8127; + int GL_POINT_FADE_THRESHOLD_SIZE_EXT = 0x8128; + int GL_DISTANCE_ATTENUATION_EXT = 0x8129; + + void glPointParameterfEXT(@GLenum int pname, float param); + + @StripPostfix("pfParams") + void glPointParameterfvEXT(@GLenum int pname, @Check("4") @Const FloatBuffer pfParams); +} diff --git a/src/templates/org/lwjgl/opengl/EXT_provoking_vertex.java b/src/templates/org/lwjgl/opengl/EXT_provoking_vertex.java new file mode 100644 index 0000000..7d91978 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/EXT_provoking_vertex.java @@ -0,0 +1,51 @@ +/* + * 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; + +import org.lwjgl.util.generator.GLenum; + +public interface EXT_provoking_vertex { + + /** Accepted by the <mode> parameter of ProvokingVertexEXT: */ + int GL_FIRST_VERTEX_CONVENTION_EXT = 0x8E4D; + int GL_LAST_VERTEX_CONVENTION_EXT = 0x8E4E; + + /** + * Accepted by the <pname> parameter of GetBooleanv, GetIntegerv, + * GetFloatv, and GetDoublev: + */ + int GL_PROVOKING_VERTEX_EXT = 0x8E4F; + int GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION_EXT = 0x8E4C; + + void glProvokingVertexEXT(@GLenum int mode); + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/EXT_rescale_normal.java b/src/templates/org/lwjgl/opengl/EXT_rescale_normal.java new file mode 100644 index 0000000..9d38af3 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/EXT_rescale_normal.java @@ -0,0 +1,36 @@ +/* + * 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; + +public interface EXT_rescale_normal { + int GL_RESCALE_NORMAL_EXT = 0x803A; +} diff --git a/src/templates/org/lwjgl/opengl/EXT_secondary_color.java b/src/templates/org/lwjgl/opengl/EXT_secondary_color.java new file mode 100644 index 0000000..ec0a0af --- /dev/null +++ b/src/templates/org/lwjgl/opengl/EXT_secondary_color.java @@ -0,0 +1,65 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +import java.nio.Buffer; + +public interface EXT_secondary_color { + + int GL_COLOR_SUM_EXT = 0x8458; + int GL_CURRENT_SECONDARY_COLOR_EXT = 0x8459; + int GL_SECONDARY_COLOR_ARRAY_SIZE_EXT = 0x845A; + int GL_SECONDARY_COLOR_ARRAY_TYPE_EXT = 0x845B; + int GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT = 0x845C; + int GL_SECONDARY_COLOR_ARRAY_POINTER_EXT = 0x845D; + int GL_SECONDARY_COLOR_ARRAY_EXT = 0x845E; + + void glSecondaryColor3bEXT(byte red, byte green, byte blue); + + void glSecondaryColor3fEXT(float red, float green, float blue); + + void glSecondaryColor3dEXT(double red, double green, double blue); + + void glSecondaryColor3ubEXT(@GLubyte byte red, @GLubyte byte green, @GLubyte byte blue); + + void glSecondaryColorPointerEXT(int size, @AutoType("pPointer") @GLenum int type, @GLsizei int stride, + @CachedReference + @BufferObject(BufferKind.ArrayVBO) + @Check + @Const + @GLbyte + @GLubyte + @GLfloat + @GLdouble Buffer pPointer); +} diff --git a/src/templates/org/lwjgl/opengl/EXT_separate_shader_objects.java b/src/templates/org/lwjgl/opengl/EXT_separate_shader_objects.java new file mode 100644 index 0000000..152d4b1 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/EXT_separate_shader_objects.java @@ -0,0 +1,53 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +import java.nio.ByteBuffer; + +public interface EXT_separate_shader_objects { + + /** Accepted by <type> parameter to GetIntegerv and GetFloatv: */ + int GL_ACTIVE_PROGRAM_EXT = 0x8B8D; + + void glUseShaderProgramEXT(@GLenum int type, @GLuint int program); + + void glActiveProgramEXT(@GLuint int program); + + @GLuint int glCreateShaderProgramEXT(@GLenum int type, @NullTerminated @Const @GLchar ByteBuffer string); + + @Alternate("glCreateShaderProgramEXT") + @GLuint + int glCreateShaderProgramEXT(@GLenum int type, @NullTerminated CharSequence string); + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/EXT_separate_specular_color.java b/src/templates/org/lwjgl/opengl/EXT_separate_specular_color.java new file mode 100644 index 0000000..e8f160f --- /dev/null +++ b/src/templates/org/lwjgl/opengl/EXT_separate_specular_color.java @@ -0,0 +1,38 @@ +/* + * 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; + +public interface EXT_separate_specular_color { + int GL_SINGLE_COLOR_EXT = 0x81F9; + int GL_SEPARATE_SPECULAR_COLOR_EXT = 0x81FA; + int GL_LIGHT_MODEL_COLOR_CONTROL_EXT = 0x81F8; +} diff --git a/src/templates/org/lwjgl/opengl/EXT_shader_image_load_store.java b/src/templates/org/lwjgl/opengl/EXT_shader_image_load_store.java new file mode 100644 index 0000000..02093bb --- /dev/null +++ b/src/templates/org/lwjgl/opengl/EXT_shader_image_load_store.java @@ -0,0 +1,110 @@ +/* + * 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; + +import org.lwjgl.util.generator.GLbitfield; +import org.lwjgl.util.generator.GLenum; +import org.lwjgl.util.generator.GLuint; + +public interface EXT_shader_image_load_store { + + /** + * Accepted by the <pname> parameter of GetBooleanv, GetIntegerv, + * GetFloatv, and GetDoublev: + */ + int GL_MAX_IMAGE_UNITS_EXT = 0x8F38; + int GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS_EXT = 0x8F39; + int GL_MAX_IMAGE_SAMPLES_EXT = 0x906D; + + /** Accepted by the <target> parameter of GetIntegeri_v and GetBooleani_v: */ + int GL_IMAGE_BINDING_NAME_EXT = 0x8F3A; + int GL_IMAGE_BINDING_LEVEL_EXT = 0x8F3B; + int GL_IMAGE_BINDING_LAYERED_EXT = 0x8F3C; + int GL_IMAGE_BINDING_LAYER_EXT = 0x8F3D; + int GL_IMAGE_BINDING_ACCESS_EXT = 0x8F3E; + int GL_IMAGE_BINDING_FORMAT_EXT = 0x906E; + + /** Accepted by the <barriers> parameter of MemoryBarrierEXT: */ + int GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT_EXT = 0x00000001; + int GL_ELEMENT_ARRAY_BARRIER_BIT_EXT = 0x00000002; + int GL_UNIFORM_BARRIER_BIT_EXT = 0x00000004; + int GL_TEXTURE_FETCH_BARRIER_BIT_EXT = 0x00000008; + int GL_SHADER_IMAGE_ACCESS_BARRIER_BIT_EXT = 0x00000020; + int GL_COMMAND_BARRIER_BIT_EXT = 0x00000040; + int GL_PIXEL_BUFFER_BARRIER_BIT_EXT = 0x00000080; + int GL_TEXTURE_UPDATE_BARRIER_BIT_EXT = 0x00000100; + int GL_BUFFER_UPDATE_BARRIER_BIT_EXT = 0x00000200; + int GL_FRAMEBUFFER_BARRIER_BIT_EXT = 0x00000400; + int GL_TRANSFORM_FEEDBACK_BARRIER_BIT_EXT = 0x00000800; + int GL_ATOMIC_COUNTER_BARRIER_BIT_EXT = 0x00001000; + int GL_ALL_BARRIER_BITS_EXT = 0xFFFFFFFF; + + /** Returned by the <type> parameter of GetActiveUniform: */ + int GL_IMAGE_1D_EXT = 0x904C; + int GL_IMAGE_2D_EXT = 0x904D; + int GL_IMAGE_3D_EXT = 0x904E; + int GL_IMAGE_2D_RECT_EXT = 0x904F; + int GL_IMAGE_CUBE_EXT = 0x9050; + int GL_IMAGE_BUFFER_EXT = 0x9051; + int GL_IMAGE_1D_ARRAY_EXT = 0x9052; + int GL_IMAGE_2D_ARRAY_EXT = 0x9053; + int GL_IMAGE_CUBE_MAP_ARRAY_EXT = 0x9054; + int GL_IMAGE_2D_MULTISAMPLE_EXT = 0x9055; + int GL_IMAGE_2D_MULTISAMPLE_ARRAY_EXT = 0x9056; + int GL_INT_IMAGE_1D_EXT = 0x9057; + int GL_INT_IMAGE_2D_EXT = 0x9058; + int GL_INT_IMAGE_3D_EXT = 0x9059; + int GL_INT_IMAGE_2D_RECT_EXT = 0x905A; + int GL_INT_IMAGE_CUBE_EXT = 0x905B; + int GL_INT_IMAGE_BUFFER_EXT = 0x905C; + int GL_INT_IMAGE_1D_ARRAY_EXT = 0x905D; + int GL_INT_IMAGE_2D_ARRAY_EXT = 0x905E; + int GL_INT_IMAGE_CUBE_MAP_ARRAY_EXT = 0x905F; + int GL_INT_IMAGE_2D_MULTISAMPLE_EXT = 0x9060; + int GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY_EXT = 0x9061; + int GL_UNSIGNED_INT_IMAGE_1D_EXT = 0x9062; + int GL_UNSIGNED_INT_IMAGE_2D_EXT = 0x9063; + int GL_UNSIGNED_INT_IMAGE_3D_EXT = 0x9064; + int GL_UNSIGNED_INT_IMAGE_2D_RECT_EXT = 0x9065; + int GL_UNSIGNED_INT_IMAGE_CUBE_EXT = 0x9066; + int GL_UNSIGNED_INT_IMAGE_BUFFER_EXT = 0x9067; + int GL_UNSIGNED_INT_IMAGE_1D_ARRAY_EXT = 0x9068; + int GL_UNSIGNED_INT_IMAGE_2D_ARRAY_EXT = 0x9069; + int GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY_EXT = 0x906A; + int GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_EXT = 0x906B; + int GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY_EXT = 0x906C; + + void glBindImageTextureEXT(@GLuint int index, @GLuint int texture, int level, boolean layered, int layer, @GLenum int access, int format); + + void glMemoryBarrierEXT(@GLbitfield int barriers); + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/EXT_shadow_funcs.java b/src/templates/org/lwjgl/opengl/EXT_shadow_funcs.java new file mode 100644 index 0000000..1fd57bb --- /dev/null +++ b/src/templates/org/lwjgl/opengl/EXT_shadow_funcs.java @@ -0,0 +1,35 @@ +/* + * 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; + +public interface EXT_shadow_funcs { +} diff --git a/src/templates/org/lwjgl/opengl/EXT_shared_texture_palette.java b/src/templates/org/lwjgl/opengl/EXT_shared_texture_palette.java new file mode 100644 index 0000000..1014d89 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/EXT_shared_texture_palette.java @@ -0,0 +1,36 @@ +/* + * 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; + +public interface EXT_shared_texture_palette { + int GL_SHARED_TEXTURE_PALETTE_EXT = 0x81FB; +} diff --git a/src/templates/org/lwjgl/opengl/EXT_stencil_clear_tag.java b/src/templates/org/lwjgl/opengl/EXT_stencil_clear_tag.java new file mode 100644 index 0000000..ba90125 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/EXT_stencil_clear_tag.java @@ -0,0 +1,52 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +public interface EXT_stencil_clear_tag { + + /** + Accepted by the <pname> parameter of GetBooleanv, GetIntegerv, + GetFloatv, and GetDoublev. + */ + int GL_STENCIL_TAG_BITS_EXT = 0x88F2; + int GL_STENCIL_CLEAR_TAG_VALUE_EXT = 0x88F3; + + /** + Controls the stencil clear tag state. stencilTagBits is a count of + the number of most-significant stencil buffer bits involved in the + stencil clear tag update. + */ + void glStencilClearTagEXT(@GLsizei int stencilTagBits, @GLuint int stencilClearTag); + +} diff --git a/src/templates/org/lwjgl/opengl/EXT_stencil_two_side.java b/src/templates/org/lwjgl/opengl/EXT_stencil_two_side.java new file mode 100644 index 0000000..a5b2703 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/EXT_stencil_two_side.java @@ -0,0 +1,41 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +public interface EXT_stencil_two_side { + int GL_STENCIL_TEST_TWO_SIDE_EXT = 0x8910; + int GL_ACTIVE_STENCIL_FACE_EXT = 0x8911; + + void glActiveStencilFaceEXT(@GLenum int face); +} diff --git a/src/templates/org/lwjgl/opengl/EXT_stencil_wrap.java b/src/templates/org/lwjgl/opengl/EXT_stencil_wrap.java new file mode 100644 index 0000000..6b00c53 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/EXT_stencil_wrap.java @@ -0,0 +1,37 @@ +/* + * 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; + +public interface EXT_stencil_wrap { + int GL_INCR_WRAP_EXT = 0x8507; + int GL_DECR_WRAP_EXT = 0x8508; +} diff --git a/src/templates/org/lwjgl/opengl/EXT_texture_3d.java b/src/templates/org/lwjgl/opengl/EXT_texture_3d.java new file mode 100644 index 0000000..a5397be --- /dev/null +++ b/src/templates/org/lwjgl/opengl/EXT_texture_3d.java @@ -0,0 +1,35 @@ +/* + * 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; + +public interface EXT_texture_3d { +} diff --git a/src/templates/org/lwjgl/opengl/EXT_texture_array.java b/src/templates/org/lwjgl/opengl/EXT_texture_array.java new file mode 100644 index 0000000..b9eed41 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/EXT_texture_array.java @@ -0,0 +1,88 @@ +/* + * 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; + +import org.lwjgl.util.generator.GLenum; +import org.lwjgl.util.generator.GLuint; + +public interface EXT_texture_array { + + /** + * Accepted by the <target> parameter of TexParameteri, TexParameteriv, + * TexParameterf, TexParameterfv, and BindTexture: + */ + int GL_TEXTURE_1D_ARRAY_EXT = 0x8C18; + int GL_TEXTURE_2D_ARRAY_EXT = 0x8C1A; + + /** + * Accepted by the <target> parameter of TexImage3D, TexSubImage3D, + * CopyTexSubImage3D, CompressedTexImage3D, and CompressedTexSubImage3D: + */ + int GL_PROXY_TEXTURE_2D_ARRAY_EXT = 0x8C1B; + + /** + * Accepted by the <target> parameter of TexImage2D, TexSubImage2D, + * CopyTexImage2D, CopyTexSubImage2D, CompressedTexImage2D, and + * CompressedTexSubImage2D: + */ + int GL_PROXY_TEXTURE_1D_ARRAY_EXT = 0x8C19; + + /** + * Accepted by the <pname> parameter of GetBooleanv, GetDoublev, GetIntegerv + * and GetFloatv: + */ + int GL_TEXTURE_BINDING_1D_ARRAY_EXT = 0x8C1C; + int GL_TEXTURE_BINDING_2D_ARRAY_EXT = 0x8C1D; + int GL_MAX_ARRAY_TEXTURE_LAYERS_EXT = 0x88FF; + + /** + * Accepted by the <param> parameter of TexParameterf, TexParameteri, + * TexParameterfv, and TexParameteriv when the <pname> parameter is + * TEXTURE_COMPARE_MODE_ARB: + */ + int GL_COMPARE_REF_DEPTH_TO_TEXTURE_EXT = 0x884E; + + /** + * Accepted by the <pname> parameter of + * GetFramebufferAttachmentParameterivEXT: + */ + int GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT = 0x8CD4; + + /** Returned by the <type> parameter of GetActiveUniform: */ + int GL_SAMPLER_1D_ARRAY_EXT = 0x8DC0; + int GL_SAMPLER_2D_ARRAY_EXT = 0x8DC1; + int GL_SAMPLER_1D_ARRAY_SHADOW_EXT = 0x8DC3; + int GL_SAMPLER_2D_ARRAY_SHADOW_EXT = 0x8DC4; + + void glFramebufferTextureLayerEXT(@GLenum int target, @GLenum int attachment, @GLuint int texture, int level, int layer); + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/EXT_texture_buffer_object.java b/src/templates/org/lwjgl/opengl/EXT_texture_buffer_object.java new file mode 100644 index 0000000..1601fc2 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/EXT_texture_buffer_object.java @@ -0,0 +1,59 @@ +/* + * 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; + +import org.lwjgl.util.generator.GLenum; +import org.lwjgl.util.generator.GLuint; + +public interface EXT_texture_buffer_object { + + /** + * Accepted by the <target> parameter of BindBuffer, BufferData, + * BufferSubData, MapBuffer, BindTexture, UnmapBuffer, GetBufferSubData, + * GetBufferParameteriv, GetBufferPointerv, and TexBufferEXT, and + * the <pname> parameter of GetBooleanv, GetDoublev, GetFloatv, and + * GetIntegerv: + */ + int GL_TEXTURE_BUFFER_EXT = 0x8C2A; + + /** + * Accepted by the <pname> parameters of GetBooleanv, GetDoublev, + * GetFloatv, and GetIntegerv: + */ + int GL_MAX_TEXTURE_BUFFER_SIZE_EXT = 0x8C2B; + int GL_TEXTURE_BINDING_BUFFER_EXT = 0x8C2C; + int GL_TEXTURE_BUFFER_DATA_STORE_BINDING_EXT = 0x8C2D; + int GL_TEXTURE_BUFFER_FORMAT_EXT = 0x8C2E; + + void glTexBufferEXT(@GLenum int target, @GLenum int internalformat, @GLuint int buffer); + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/EXT_texture_compression_latc.java b/src/templates/org/lwjgl/opengl/EXT_texture_compression_latc.java new file mode 100644 index 0000000..2abaa5f --- /dev/null +++ b/src/templates/org/lwjgl/opengl/EXT_texture_compression_latc.java @@ -0,0 +1,49 @@ +/* + * 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; + +import org.lwjgl.util.generator.Extension; + +@Extension(postfix = "EXT", className = "EXTTextureCompressionLATC") +public interface EXT_texture_compression_latc { + + /** + * Accepted by the <internalformat> parameter of TexImage2D, + * CopyTexImage2D, and CompressedTexImage2D and the <format> parameter + * of CompressedTexSubImage2D: + */ + int GL_COMPRESSED_LUMINANCE_LATC1_EXT = 0x8C70; + int GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT = 0x8C71; + int GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT = 0x8C72; + int GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT = 0x8C73; + +} diff --git a/src/templates/org/lwjgl/opengl/EXT_texture_compression_rgtc.java b/src/templates/org/lwjgl/opengl/EXT_texture_compression_rgtc.java new file mode 100644 index 0000000..0711dde --- /dev/null +++ b/src/templates/org/lwjgl/opengl/EXT_texture_compression_rgtc.java @@ -0,0 +1,49 @@ +/* + * 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; + +import org.lwjgl.util.generator.Extension; + +@Extension(postfix = "EXT", className = "EXTTextureCompressionRGTC") +public interface EXT_texture_compression_rgtc { + + /** + * Accepted by the <internalformat> parameter of TexImage2D, + * CopyTexImage2D, and CompressedTexImage2D and the <format> parameter + * of CompressedTexSubImage2D: + */ + int GL_COMPRESSED_RED_RGTC1_EXT = 0x8DBB; + int GL_COMPRESSED_SIGNED_RED_RGTC1_EXT = 0x8DBC; + int GL_COMPRESSED_RED_GREEN_RGTC2_EXT = 0x8DBD; + int GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT = 0x8DBE; + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/EXT_texture_compression_s3tc.java b/src/templates/org/lwjgl/opengl/EXT_texture_compression_s3tc.java new file mode 100644 index 0000000..d867701 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/EXT_texture_compression_s3tc.java @@ -0,0 +1,42 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +@Extension(postfix = "EXT", className = "EXTTextureCompressionS3TC") +public interface EXT_texture_compression_s3tc { + int GL_COMPRESSED_RGB_S3TC_DXT1_EXT = 0x83F0; + int GL_COMPRESSED_RGBA_S3TC_DXT1_EXT = 0x83F1; + int GL_COMPRESSED_RGBA_S3TC_DXT3_EXT = 0x83F2; + int GL_COMPRESSED_RGBA_S3TC_DXT5_EXT = 0x83F3; +} diff --git a/src/templates/org/lwjgl/opengl/EXT_texture_env_combine.java b/src/templates/org/lwjgl/opengl/EXT_texture_env_combine.java new file mode 100644 index 0000000..0d3bce1 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/EXT_texture_env_combine.java @@ -0,0 +1,56 @@ +/* + * 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; + +public interface EXT_texture_env_combine { + int GL_COMBINE_EXT = 0x8570; + int GL_COMBINE_RGB_EXT = 0x8571; + int GL_COMBINE_ALPHA_EXT = 0x8572; + int GL_SOURCE0_RGB_EXT = 0x8580; + int GL_SOURCE1_RGB_EXT = 0x8581; + int GL_SOURCE2_RGB_EXT = 0x8582; + int GL_SOURCE0_ALPHA_EXT = 0x8588; + int GL_SOURCE1_ALPHA_EXT = 0x8589; + int GL_SOURCE2_ALPHA_EXT = 0x858A; + int GL_OPERAND0_RGB_EXT = 0x8590; + int GL_OPERAND1_RGB_EXT = 0x8591; + int GL_OPERAND2_RGB_EXT = 0x8592; + int GL_OPERAND0_ALPHA_EXT = 0x8598; + int GL_OPERAND1_ALPHA_EXT = 0x8599; + int GL_OPERAND2_ALPHA_EXT = 0x859A; + int GL_RGB_SCALE_EXT = 0x8573; + int GL_ADD_SIGNED_EXT = 0x8574; + int GL_INTERPOLATE_EXT = 0x8575; + int GL_CONSTANT_EXT = 0x8576; + int GL_PRIMARY_COLOR_EXT = 0x8577; + int GL_PREVIOUS_EXT = 0x8578; +} diff --git a/src/templates/org/lwjgl/opengl/EXT_texture_env_dot3.java b/src/templates/org/lwjgl/opengl/EXT_texture_env_dot3.java new file mode 100644 index 0000000..4346fd8 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/EXT_texture_env_dot3.java @@ -0,0 +1,37 @@ +/* + * 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; + +public interface EXT_texture_env_dot3 { + int GL_DOT3_RGB_EXT = 0x8740; + int GL_DOT3_RGBA_EXT = 0x8741; +} diff --git a/src/templates/org/lwjgl/opengl/EXT_texture_filter_anisotropic.java b/src/templates/org/lwjgl/opengl/EXT_texture_filter_anisotropic.java new file mode 100644 index 0000000..f369dd9 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/EXT_texture_filter_anisotropic.java @@ -0,0 +1,37 @@ +/* + * 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; + +public interface EXT_texture_filter_anisotropic { + int GL_TEXTURE_MAX_ANISOTROPY_EXT = 0x84FE; + int GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT = 0x84FF; +} diff --git a/src/templates/org/lwjgl/opengl/EXT_texture_integer.java b/src/templates/org/lwjgl/opengl/EXT_texture_integer.java new file mode 100644 index 0000000..46bf003 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/EXT_texture_integer.java @@ -0,0 +1,142 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +import java.nio.IntBuffer; + +public interface EXT_texture_integer { + + /** + * Accepted by the <pname> parameters of GetBooleanv, GetIntegerv, + * GetFloatv, and GetDoublev: + */ + int GL_RGBA_INTEGER_MODE_EXT = 0x8D9E; + + /** + * Accepted by the <internalFormat> parameter of TexImage1D, + * TexImage2D, and TexImage3D: + */ + int GL_RGBA32UI_EXT = 0x8D70; + int GL_RGB32UI_EXT = 0x8D71; + int GL_ALPHA32UI_EXT = 0x8D72; + int GL_INTENSITY32UI_EXT = 0x8D73; + int GL_LUMINANCE32UI_EXT = 0x8D74; + int GL_LUMINANCE_ALPHA32UI_EXT = 0x8D75; + + int GL_RGBA16UI_EXT = 0x8D76; + int GL_RGB16UI_EXT = 0x8D77; + int GL_ALPHA16UI_EXT = 0x8D78; + int GL_INTENSITY16UI_EXT = 0x8D79; + int GL_LUMINANCE16UI_EXT = 0x8D7A; + int GL_LUMINANCE_ALPHA16UI_EXT = 0x8D7B; + + int GL_RGBA8UI_EXT = 0x8D7C; + int GL_RGB8UI_EXT = 0x8D7D; + int GL_ALPHA8UI_EXT = 0x8D7E; + int GL_INTENSITY8UI_EXT = 0x8D7F; + int GL_LUMINANCE8UI_EXT = 0x8D80; + int GL_LUMINANCE_ALPHA8UI_EXT = 0x8D81; + + int GL_RGBA32I_EXT = 0x8D82; + int GL_RGB32I_EXT = 0x8D83; + int GL_ALPHA32I_EXT = 0x8D84; + int GL_INTENSITY32I_EXT = 0x8D85; + int GL_LUMINANCE32I_EXT = 0x8D86; + int GL_LUMINANCE_ALPHA32I_EXT = 0x8D87; + + int GL_RGBA16I_EXT = 0x8D88; + int GL_RGB16I_EXT = 0x8D89; + int GL_ALPHA16I_EXT = 0x8D8A; + int GL_INTENSITY16I_EXT = 0x8D8B; + int GL_LUMINANCE16I_EXT = 0x8D8C; + int GL_LUMINANCE_ALPHA16I_EXT = 0x8D8D; + + int GL_RGBA8I_EXT = 0x8D8E; + int GL_RGB8I_EXT = 0x8D8F; + int GL_ALPHA8I_EXT = 0x8D90; + int GL_INTENSITY8I_EXT = 0x8D91; + int GL_LUMINANCE8I_EXT = 0x8D92; + int GL_LUMINANCE_ALPHA8I_EXT = 0x8D93; + + /** + * Accepted by the <format> parameter of TexImage1D, TexImage2D, + * TexImage3D, TexSubImage1D, TexSubImage2D, TexSubImage3D, + * DrawPixels and ReadPixels: + */ + int GL_RED_INTEGER_EXT = 0x8D94; + int GL_GREEN_INTEGER_EXT = 0x8D95; + int GL_BLUE_INTEGER_EXT = 0x8D96; + int GL_ALPHA_INTEGER_EXT = 0x8D97; + int GL_RGB_INTEGER_EXT = 0x8D98; + int GL_RGBA_INTEGER_EXT = 0x8D99; + int GL_BGR_INTEGER_EXT = 0x8D9A; + int GL_BGRA_INTEGER_EXT = 0x8D9B; + int GL_LUMINANCE_INTEGER_EXT = 0x8D9C; + int GL_LUMINANCE_ALPHA_INTEGER_EXT = 0x8D9D; + + void glClearColorIiEXT(int r, int g, int b, int a); + + void glClearColorIuiEXT(@GLuint int r, @GLuint int g, @GLuint int b, @GLuint int a); + + @StripPostfix("params") + void glTexParameterIivEXT(@GLenum int target, @GLenum int pname, @Check("4") IntBuffer params); + + @Alternate("glTexParameterIivEXT") + @StripPostfix(value = "param", postfix = "v") + void glTexParameterIivEXT(@GLenum int target, @GLenum int pname, @Constant(value = "APIUtils.getBufferInt().put(0, param), 0", keepParam = true) int param); + + @StripPostfix("params") + void glTexParameterIuivEXT(@GLenum int target, @GLenum int pname, @Check("4") @GLuint IntBuffer params); + + @Alternate("glTexParameterIuivEXT") + @StripPostfix(value = "param", postfix = "v") + void glTexParameterIuivEXT(@GLenum int target, @GLenum int pname, @Constant(value = "APIUtils.getBufferInt().put(0, param), 0", keepParam = true) int param); + + @StripPostfix("params") + void glGetTexParameterIivEXT(@GLenum int target, @GLenum int pname, @OutParameter @Check("4") IntBuffer params); + + @Alternate("glGetTexParameterIivEXT") + @GLreturn("params") + @StripPostfix(value = "params", postfix = "v") + void glGetTexParameterIivEXT2(@GLenum int target, @GLenum int pname, @OutParameter IntBuffer params); + + @StripPostfix("params") + void glGetTexParameterIuivEXT(@GLenum int target, @GLenum int pname, @OutParameter @Check("4") @GLuint IntBuffer params); + + @Alternate("glGetTexParameterIuivEXT") + @GLreturn("params") + @StripPostfix(value = "params", postfix = "v") + void glGetTexParameterIuivEXT2(@GLenum int target, @GLenum int pname, @OutParameter @GLuint IntBuffer params); + +} diff --git a/src/templates/org/lwjgl/opengl/EXT_texture_lod_bias.java b/src/templates/org/lwjgl/opengl/EXT_texture_lod_bias.java new file mode 100644 index 0000000..66545ae --- /dev/null +++ b/src/templates/org/lwjgl/opengl/EXT_texture_lod_bias.java @@ -0,0 +1,41 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +@Extension(postfix = "EXT", className = "EXTTextureLODBias") +public interface EXT_texture_lod_bias { + int GL_TEXTURE_FILTER_CONTROL_EXT = 0x8500; + int GL_TEXTURE_LOD_BIAS_EXT = 0x8501; + int GL_MAX_TEXTURE_LOD_BIAS_EXT = 0x84FD; +} diff --git a/src/templates/org/lwjgl/opengl/EXT_texture_mirror_clamp.java b/src/templates/org/lwjgl/opengl/EXT_texture_mirror_clamp.java new file mode 100644 index 0000000..33983a0 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/EXT_texture_mirror_clamp.java @@ -0,0 +1,45 @@ +/* + * 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; + +public interface EXT_texture_mirror_clamp { + + /** + * Accepted by the <param> parameter of TexParameteri and TexParameterf, + * and by the <params> parameter of TexParameteriv and TexParameterfv, + * when their <pname> parameter is TEXTURE_WRAP_S, TEXTURE_WRAP_T, + * or TEXTURE_WRAP_R: + */ + int GL_MIRROR_CLAMP_EXT = 0x8742; + int GL_MIRROR_CLAMP_TO_EDGE_EXT = 0x8743; + int GL_MIRROR_CLAMP_TO_BORDER_EXT = 0x8912; +} diff --git a/src/templates/org/lwjgl/opengl/EXT_texture_rectangle.java b/src/templates/org/lwjgl/opengl/EXT_texture_rectangle.java new file mode 100644 index 0000000..caa73fe --- /dev/null +++ b/src/templates/org/lwjgl/opengl/EXT_texture_rectangle.java @@ -0,0 +1,39 @@ +/* + * 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; + +public interface EXT_texture_rectangle { + int GL_TEXTURE_RECTANGLE_EXT = 0x84F5; + int GL_TEXTURE_BINDING_RECTANGLE_EXT = 0x84F6; + int GL_PROXY_TEXTURE_RECTANGLE_EXT = 0x84F7; + int GL_MAX_RECTANGLE_TEXTURE_SIZE_EXT = 0x84F8; +} diff --git a/src/templates/org/lwjgl/opengl/EXT_texture_sRGB.java b/src/templates/org/lwjgl/opengl/EXT_texture_sRGB.java new file mode 100644 index 0000000..e03d496 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/EXT_texture_sRGB.java @@ -0,0 +1,63 @@ +/* + * 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; + +public interface EXT_texture_sRGB { + + /** + Accepted by the <internalformat> parameter of TexImage1D, TexImage2D, + TexImage3D, CopyTexImage1D, CopyTexImage2D. + */ + int GL_SRGB_EXT = 0x8C40; + int GL_SRGB8_EXT = 0x8C41; + int GL_SRGB_ALPHA_EXT = 0x8C42; + int GL_SRGB8_ALPHA8_EXT = 0x8C43; + int GL_SLUMINANCE_ALPHA_EXT = 0x8C44; + int GL_SLUMINANCE8_ALPHA8_EXT = 0x8C45; + int GL_SLUMINANCE_EXT = 0x8C46; + int GL_SLUMINANCE8_EXT = 0x8C47; + int GL_COMPRESSED_SRGB_EXT = 0x8C48; + int GL_COMPRESSED_SRGB_ALPHA_EXT = 0x8C49; + int GL_COMPRESSED_SLUMINANCE_EXT = 0x8C4A; + int GL_COMPRESSED_SLUMINANCE_ALPHA_EXT = 0x8C4B; + + /** + Accepted by the <internalformat> parameter of TexImage2D, + CopyTexImage2D, and CompressedTexImage2DARB and the <format> parameter + of CompressedTexSubImage2DARB. + */ + int GL_COMPRESSED_SRGB_S3TC_DXT1_EXT = 0x8C4C; + int GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT = 0x8C4D; + int GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT = 0x8C4E; + int GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT = 0x8C4F; + +} diff --git a/src/templates/org/lwjgl/opengl/EXT_texture_shared_exponent.java b/src/templates/org/lwjgl/opengl/EXT_texture_shared_exponent.java new file mode 100644 index 0000000..91f9e43 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/EXT_texture_shared_exponent.java @@ -0,0 +1,59 @@ +/* + * 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; + +public interface EXT_texture_shared_exponent { + + /** + * Accepted by the <internalformat> parameter of TexImage1D, + * TexImage2D, TexImage3D, CopyTexImage1D, CopyTexImage2D, and + * RenderbufferStorageEXT: + */ + int GL_RGB9_E5_EXT = 0x8C3D; + + /** + * Accepted by the <type> parameter of DrawPixels, ReadPixels, + * TexImage1D, TexImage2D, GetTexImage, TexImage3D, TexSubImage1D, + * TexSubImage2D, TexSubImage3D, GetHistogram, GetMinmax, + * ConvolutionFilter1D, ConvolutionFilter2D, ConvolutionFilter3D, + * GetConvolutionFilter, SeparableFilter2D, GetSeparableFilter, + * ColorTable, ColorSubTable, and GetColorTable: + */ + int GL_UNSIGNED_INT_5_9_9_9_REV_EXT = 0x8C3E; + + /** + * Accepted by the <pname> parameter of GetTexLevelParameterfv and + * GetTexLevelParameteriv: + */ + int GL_TEXTURE_SHARED_SIZE_EXT = 0x8C3F; + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/EXT_texture_snorm.java b/src/templates/org/lwjgl/opengl/EXT_texture_snorm.java new file mode 100644 index 0000000..7782cc0 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/EXT_texture_snorm.java @@ -0,0 +1,70 @@ +/* + * 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; + +public interface EXT_texture_snorm { + + /** + * Accepted by the <internalFormat> parameter of TexImage1D, + * TexImage2D, and TexImage3D: + */ + int GL_RED_SNORM = 0x8F90; + int GL_RG_SNORM = 0x8F91; + int GL_RGB_SNORM = 0x8F92; + int GL_RGBA_SNORM = 0x8F93; + int GL_ALPHA_SNORM = 0x9010; + int GL_LUMINANCE_SNORM = 0x9011; + int GL_LUMINANCE_ALPHA_SNORM = 0x9012; + int GL_INTENSITY_SNORM = 0x9013; + + int GL_R8_SNORM = 0x8F94; + int GL_RG8_SNORM = 0x8F95; + int GL_RGB8_SNORM = 0x8F96; + int GL_RGBA8_SNORM = 0x8F97; + int GL_ALPHA8_SNORM = 0x9014; + int GL_LUMINANCE8_SNORM = 0x9015; + int GL_LUMINANCE8_ALPHA8_SNORM = 0x9016; + int GL_INTENSITY8_SNORM = 0x9017; + + int GL_R16_SNORM = 0x8F98; + int GL_RG16_SNORM = 0x8F99; + int GL_RGB16_SNORM = 0x8F9A; + int GL_RGBA16_SNORM = 0x8F9B; + int GL_ALPHA16_SNORM = 0x9018; + int GL_LUMINANCE16_SNORM = 0x9019; + int GL_LUMINANCE16_ALPHA16_SNORM = 0x901A; + int GL_INTENSITY16_SNORM = 0x901B; + + /** Returned by GetTexLevelParmeter */ + int GL_SIGNED_NORMALIZED = 0x8F9C; + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/EXT_texture_swizzle.java b/src/templates/org/lwjgl/opengl/EXT_texture_swizzle.java new file mode 100644 index 0000000..a7f985d --- /dev/null +++ b/src/templates/org/lwjgl/opengl/EXT_texture_swizzle.java @@ -0,0 +1,52 @@ +/* + * 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; + +public interface EXT_texture_swizzle { + + /** + * Accepted by the <pname> parameters of TexParameteri, + * TexParameterf, TexParameteriv, TexParameterfv, + * GetTexParameterfv, and GetTexParameteriv: + */ + int GL_TEXTURE_SWIZZLE_R_EXT = 0x8E42; + int GL_TEXTURE_SWIZZLE_G_EXT = 0x8E43; + int GL_TEXTURE_SWIZZLE_B_EXT = 0x8E44; + int GL_TEXTURE_SWIZZLE_A_EXT = 0x8E45; + + /** + * Accepted by the <pname> parameters of TexParameteriv, + * TexParameterfv, GetTexParameterfv, and GetTexParameteriv: + */ + int GL_TEXTURE_SWIZZLE_RGBA_EXT = 0x8E46; + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/EXT_timer_query.java b/src/templates/org/lwjgl/opengl/EXT_timer_query.java new file mode 100644 index 0000000..520c729 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/EXT_timer_query.java @@ -0,0 +1,62 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +import java.nio.*; + +public interface EXT_timer_query { + + /** + * Accepted by the <target> parameter of BeginQuery, EndQuery, and + * GetQueryiv: + */ + int GL_TIME_ELAPSED_EXT = 0x88BF; + + @StripPostfix("params") + void glGetQueryObjecti64vEXT(@GLuint int id, @GLenum int pname, @OutParameter @Check("1") @GLint64EXT LongBuffer params); + + @Alternate("glGetQueryObjecti64vEXT") + @GLreturn("params") + @StripPostfix("params") + void glGetQueryObjecti64vEXT2(@GLuint int id, @GLenum int pname, @OutParameter @GLint64EXT LongBuffer params); + + @StripPostfix("params") + void glGetQueryObjectui64vEXT(@GLuint int id, @GLenum int pname, @OutParameter @Check("1") @GLuint64EXT LongBuffer params); + + @Alternate("glGetQueryObjectui64vEXT") + @GLreturn("params") + @StripPostfix("params") + void glGetQueryObjectui64vEXT2(@GLuint int id, @GLenum int pname, @OutParameter @GLuint64EXT LongBuffer params); + +} diff --git a/src/templates/org/lwjgl/opengl/EXT_transform_feedback.java b/src/templates/org/lwjgl/opengl/EXT_transform_feedback.java new file mode 100644 index 0000000..66cdc3f --- /dev/null +++ b/src/templates/org/lwjgl/opengl/EXT_transform_feedback.java @@ -0,0 +1,127 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +import java.nio.ByteBuffer; +import java.nio.IntBuffer; + +public interface EXT_transform_feedback { + + /** + * Accepted by the <target> parameters of BindBuffer, BufferData, + * BufferSubData, MapBuffer, UnmapBuffer, GetBufferSubData, + * GetBufferPointerv, BindBufferRangeEXT, BindBufferOffsetEXT and + * BindBufferBaseEXT: + */ + int GL_TRANSFORM_FEEDBACK_BUFFER_EXT = 0x8C8E; + + /** + * Accepted by the <param> parameter of GetIntegerIndexedvEXT and + * GetBooleanIndexedvEXT: + */ + int GL_TRANSFORM_FEEDBACK_BUFFER_START_EXT = 0x8C84; + int GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_EXT = 0x8C85; + + /** + * Accepted by the <param> parameter of GetIntegerIndexedvEXT and + * GetBooleanIndexedvEXT, and by the <pname> parameter of GetBooleanv, + * GetDoublev, GetIntegerv, and GetFloatv: + */ + int GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_EXT = 0x8C8F; + + /** Accepted by the <bufferMode> parameter of TransformFeedbackVaryingsEXT: */ + int GL_INTERLEAVED_ATTRIBS_EXT = 0x8C8C; + int GL_SEPARATE_ATTRIBS_EXT = 0x8C8D; + + /** + * Accepted by the <target> parameter of BeginQuery, EndQuery, and + * GetQueryiv: + */ + int GL_PRIMITIVES_GENERATED_EXT = 0x8C87; + int GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_EXT = 0x8C88; + + /** + * Accepted by the <cap> parameter of Enable, Disable, and IsEnabled, and by + * the <pname> parameter of GetBooleanv, GetIntegerv, GetFloatv, and + * GetDoublev: + */ + int GL_RASTERIZER_DISCARD_EXT = 0x8C89; + + /** + * Accepted by the <pname> parameter of GetBooleanv, GetDoublev, GetIntegerv, + * and GetFloatv: + */ + int GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS_EXT = 0x8C8A; + int GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_EXT = 0x8C8B; + int GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_EXT = 0x8C80; + + /** Accepted by the <pname> parameter of GetProgramiv: */ + int GL_TRANSFORM_FEEDBACK_VARYINGS_EXT = 0x8C83; + int GL_TRANSFORM_FEEDBACK_BUFFER_MODE_EXT = 0x8C7F; + int GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH_EXT = 0x8C76; + + void glBindBufferRangeEXT(@GLenum int target, @GLuint int index, @GLuint int buffer, @GLintptr long offset, @GLsizeiptr long size); + + void glBindBufferOffsetEXT(@GLenum int target, @GLuint int index, @GLuint int buffer, @GLintptr long offset); + + void glBindBufferBaseEXT(@GLenum int target, @GLuint int index, @GLuint int buffer); + + void glBeginTransformFeedbackEXT(@GLenum int primitiveMode); + + void glEndTransformFeedbackEXT(); + + void glTransformFeedbackVaryingsEXT(@GLuint int program, @GLsizei int count, + @Const @NullTerminated("count") @GLchar @StringList("count") ByteBuffer varyings, + @GLenum int bufferMode); + + @Alternate("glTransformFeedbackVaryingsEXT") + void glTransformFeedbackVaryingsEXT(@GLuint int program, @Constant("varyings.length") @GLsizei int count, + @Const @NullTerminated @StringList("count") CharSequence[] varyings, + @GLenum int bufferMode); + + void glGetTransformFeedbackVaryingEXT(@GLuint int program, @GLuint int index, @AutoSize("name") @GLsizei int bufSize, + @OutParameter @GLsizei @Check(value = "1", canBeNull = true) IntBuffer length, + @OutParameter @GLsizei @Check("1") IntBuffer size, + @OutParameter @GLenum @Check("1") IntBuffer type, + @OutParameter @GLchar ByteBuffer name); + + @Alternate("glGetTransformFeedbackVaryingEXT") + @GLreturn(value = "name", maxLength = "bufSize") + void glGetTransformFeedbackVaryingEXT2(@GLuint int program, @GLuint int index, @GLsizei int bufSize, + @OutParameter @GLsizei @Constant("name_length, 0") IntBuffer length, + @OutParameter @GLsizei @Check("1") IntBuffer size, + @OutParameter @GLenum @Check("1") IntBuffer type, + @OutParameter @GLchar ByteBuffer name); + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/EXT_vertex_array_bgra.java b/src/templates/org/lwjgl/opengl/EXT_vertex_array_bgra.java new file mode 100644 index 0000000..c3d1baa --- /dev/null +++ b/src/templates/org/lwjgl/opengl/EXT_vertex_array_bgra.java @@ -0,0 +1,42 @@ +/* + * 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; + +public interface EXT_vertex_array_bgra { + + /** + * Accepted by the <size> parameter of ColorPointer, + * SecondaryColorPointer, and VertexAttribPointer: + */ + int GL_BGRA = 0x80E1; + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/EXT_vertex_attrib_64bit.java b/src/templates/org/lwjgl/opengl/EXT_vertex_attrib_64bit.java new file mode 100644 index 0000000..2794a93 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/EXT_vertex_attrib_64bit.java @@ -0,0 +1,87 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +import java.nio.Buffer; +import java.nio.DoubleBuffer; + +@Dependent +public interface EXT_vertex_attrib_64bit { + + /** Returned in the <type> parameter of GetActiveAttrib: */ + int GL_DOUBLE_VEC2_EXT = 0x8FFC; + int GL_DOUBLE_VEC3_EXT = 0x8FFD; + int GL_DOUBLE_VEC4_EXT = 0x8FFE; + int GL_DOUBLE_MAT2_EXT = 0x8F46; + int GL_DOUBLE_MAT3_EXT = 0x8F47; + int GL_DOUBLE_MAT4_EXT = 0x8F48; + int GL_DOUBLE_MAT2x3_EXT = 0x8F49; + int GL_DOUBLE_MAT2x4_EXT = 0x8F4A; + int GL_DOUBLE_MAT3x2_EXT = 0x8F4B; + int GL_DOUBLE_MAT3x4_EXT = 0x8F4C; + int GL_DOUBLE_MAT4x2_EXT = 0x8F4D; + int GL_DOUBLE_MAT4x3_EXT = 0x8F4E; + + void glVertexAttribL1dEXT(@GLuint int index, double x); + + void glVertexAttribL2dEXT(@GLuint int index, double x, double y); + + void glVertexAttribL3dEXT(@GLuint int index, double x, double y, double z); + + void glVertexAttribL4dEXT(@GLuint int index, double x, double y, double z, double w); + + @StripPostfix("v") + void glVertexAttribL1dvEXT(@GLuint int index, @Const @Check("1") DoubleBuffer v); + + @StripPostfix("v") + void glVertexAttribL2dvEXT(@GLuint int index, @Const @Check("2") DoubleBuffer v); + + @StripPostfix("v") + void glVertexAttribL3dvEXT(@GLuint int index, @Const @Check("3") DoubleBuffer v); + + @StripPostfix("v") + void glVertexAttribL4dvEXT(@GLuint int index, @Const @Check("4") DoubleBuffer v); + + void glVertexAttribLPointerEXT(@GLuint int index, int size, @Constant("GL11.GL_DOUBLE") @GLenum int type, @GLsizei int stride, + @CachedReference(index = "index", name = "glVertexAttribPointer_buffer") + @BufferObject(BufferKind.ArrayVBO) + @Check @Const @GLdouble Buffer pointer); + + @StripPostfix("params") + void glGetVertexAttribLdvEXT(@GLuint int index, @GLenum int pname, @OutParameter @Check("4") DoubleBuffer params); + + @Dependent("EXT_direct_state_access") + void glVertexArrayVertexAttribLOffsetEXT(@GLuint int vaobj, @GLuint int buffer, @GLuint int index, int size, @GLenum int type, @GLsizei int stride, @GLintptr long offset); + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/EXT_vertex_shader.java b/src/templates/org/lwjgl/opengl/EXT_vertex_shader.java new file mode 100644 index 0000000..b08d437 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/EXT_vertex_shader.java @@ -0,0 +1,290 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +import java.nio.*; + +public interface EXT_vertex_shader { + int GL_VERTEX_SHADER_EXT = 0x8780; + int GL_VERTEX_SHADER_BINDING_EXT = 0x8781; + int GL_OP_INDEX_EXT = 0x8782; + int GL_OP_NEGATE_EXT = 0x8783; + int GL_OP_DOT3_EXT = 0x8784; + int GL_OP_DOT4_EXT = 0x8785; + int GL_OP_MUL_EXT = 0x8786; + int GL_OP_ADD_EXT = 0x8787; + int GL_OP_MADD_EXT = 0x8788; + int GL_OP_FRAC_EXT = 0x8789; + int GL_OP_MAX_EXT = 0x878A; + int GL_OP_MIN_EXT = 0x878B; + int GL_OP_SET_GE_EXT = 0x878C; + int GL_OP_SET_LT_EXT = 0x878D; + int GL_OP_CLAMP_EXT = 0x878E; + int GL_OP_FLOOR_EXT = 0x878F; + int GL_OP_ROUND_EXT = 0x8790; + int GL_OP_EXP_BASE_2_EXT = 0x8791; + int GL_OP_LOG_BASE_2_EXT = 0x8792; + int GL_OP_POWER_EXT = 0x8793; + int GL_OP_RECIP_EXT = 0x8794; + int GL_OP_RECIP_SQRT_EXT = 0x8795; + int GL_OP_SUB_EXT = 0x8796; + int GL_OP_CROSS_PRODUCT_EXT = 0x8797; + int GL_OP_MULTIPLY_MATRIX_EXT = 0x8798; + int GL_OP_MOV_EXT = 0x8799; + int GL_OUTPUT_VERTEX_EXT = 0x879A; + int GL_OUTPUT_COLOR0_EXT = 0x879B; + int GL_OUTPUT_COLOR1_EXT = 0x879C; + int GL_OUTPUT_TEXTURE_COORD0_EXT = 0x879D; + int GL_OUTPUT_TEXTURE_COORD1_EXT = 0x879E; + int GL_OUTPUT_TEXTURE_COORD2_EXT = 0x879F; + int GL_OUTPUT_TEXTURE_COORD3_EXT = 0x87A0; + int GL_OUTPUT_TEXTURE_COORD4_EXT = 0x87A1; + int GL_OUTPUT_TEXTURE_COORD5_EXT = 0x87A2; + int GL_OUTPUT_TEXTURE_COORD6_EXT = 0x87A3; + int GL_OUTPUT_TEXTURE_COORD7_EXT = 0x87A4; + int GL_OUTPUT_TEXTURE_COORD8_EXT = 0x87A5; + int GL_OUTPUT_TEXTURE_COORD9_EXT = 0x87A6; + int GL_OUTPUT_TEXTURE_COORD10_EXT = 0x87A7; + int GL_OUTPUT_TEXTURE_COORD11_EXT = 0x87A8; + int GL_OUTPUT_TEXTURE_COORD12_EXT = 0x87A9; + int GL_OUTPUT_TEXTURE_COORD13_EXT = 0x87AA; + int GL_OUTPUT_TEXTURE_COORD14_EXT = 0x87AB; + int GL_OUTPUT_TEXTURE_COORD15_EXT = 0x87AC; + int GL_OUTPUT_TEXTURE_COORD16_EXT = 0x87AD; + int GL_OUTPUT_TEXTURE_COORD17_EXT = 0x87AE; + int GL_OUTPUT_TEXTURE_COORD18_EXT = 0x87AF; + int GL_OUTPUT_TEXTURE_COORD19_EXT = 0x87B0; + int GL_OUTPUT_TEXTURE_COORD20_EXT = 0x87B1; + int GL_OUTPUT_TEXTURE_COORD21_EXT = 0x87B2; + int GL_OUTPUT_TEXTURE_COORD22_EXT = 0x87B3; + int GL_OUTPUT_TEXTURE_COORD23_EXT = 0x87B4; + int GL_OUTPUT_TEXTURE_COORD24_EXT = 0x87B5; + int GL_OUTPUT_TEXTURE_COORD25_EXT = 0x87B6; + int GL_OUTPUT_TEXTURE_COORD26_EXT = 0x87B7; + int GL_OUTPUT_TEXTURE_COORD27_EXT = 0x87B8; + int GL_OUTPUT_TEXTURE_COORD28_EXT = 0x87B9; + int GL_OUTPUT_TEXTURE_COORD29_EXT = 0x87BA; + int GL_OUTPUT_TEXTURE_COORD30_EXT = 0x87BB; + int GL_OUTPUT_TEXTURE_COORD31_EXT = 0x87BC; + int GL_OUTPUT_FOG_EXT = 0x87BD; + int GL_SCALAR_EXT = 0x87BE; + int GL_VECTOR_EXT = 0x87BF; + int GL_MATRIX_EXT = 0x87C0; + int GL_VARIANT_EXT = 0x87C1; + int GL_INVARIANT_EXT = 0x87C2; + int GL_LOCAL_CONSTANT_EXT = 0x87C3; + int GL_LOCAL_EXT = 0x87C4; + int GL_MAX_VERTEX_SHADER_INSTRUCTIONS_EXT = 0x87C5; + int GL_MAX_VERTEX_SHADER_VARIANTS_EXT = 0x87C6; + int GL_MAX_VERTEX_SHADER_INVARIANTS_EXT = 0x87C7; + int GL_MAX_VERTEX_SHADER_LOCAL_CONSTANTS_EXT = 0x87C8; + int GL_MAX_VERTEX_SHADER_LOCALS_EXT = 0x87C9; + int GL_MAX_OPTIMIZED_VERTEX_SHADER_INSTRUCTIONS_EXT = 0x87CA; + int GL_MAX_OPTIMIZED_VERTEX_SHADER_VARIANTS_EXT = 0x87CB; + int GL_MAX_OPTIMIZED_VERTEX_SHADER_INVARIANTS_EXT = 0x87CC; + int GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCAL_CONSTANTS_EXT = 0x87CD; + int GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCALS_EXT = 0x87CE; + int GL_VERTEX_SHADER_INSTRUCTIONS_EXT = 0x87CF; + int GL_VERTEX_SHADER_VARIANTS_EXT = 0x87D0; + int GL_VERTEX_SHADER_INVARIANTS_EXT = 0x87D1; + int GL_VERTEX_SHADER_LOCAL_CONSTANTS_EXT = 0x87D2; + int GL_VERTEX_SHADER_LOCALS_EXT = 0x87D3; + int GL_VERTEX_SHADER_OPTIMIZED_EXT = 0x87D4; + int GL_X_EXT = 0x87D5; + int GL_Y_EXT = 0x87D6; + int GL_Z_EXT = 0x87D7; + int GL_W_EXT = 0x87D8; + int GL_NEGATIVE_X_EXT = 0x87D9; + int GL_NEGATIVE_Y_EXT = 0x87DA; + int GL_NEGATIVE_Z_EXT = 0x87DB; + int GL_NEGATIVE_W_EXT = 0x87DC; + int GL_ZERO_EXT = 0x87DD; + int GL_ONE_EXT = 0x87DE; + int GL_NEGATIVE_ONE_EXT = 0x87DF; + int GL_NORMALIZED_RANGE_EXT = 0x87E0; + int GL_FULL_RANGE_EXT = 0x87E1; + int GL_CURRENT_VERTEX_EXT = 0x87E2; + int GL_MVP_MATRIX_EXT = 0x87E3; + int GL_VARIANT_VALUE_EXT = 0x87E4; + int GL_VARIANT_DATATYPE_EXT = 0x87E5; + int GL_VARIANT_ARRAY_STRIDE_EXT = 0x87E6; + int GL_VARIANT_ARRAY_TYPE_EXT = 0x87E7; + int GL_VARIANT_ARRAY_EXT = 0x87E8; + int GL_VARIANT_ARRAY_POINTER_EXT = 0x87E9; + int GL_INVARIANT_VALUE_EXT = 0x87EA; + int GL_INVARIANT_DATATYPE_EXT = 0x87EB; + int GL_LOCAL_CONSTANT_VALUE_EXT = 0x87EC; + int GL_LOCAL_CONSTANT_DATATYPE_EXT = 0x87ED; + + void glBeginVertexShaderEXT(); + + void glEndVertexShaderEXT(); + + void glBindVertexShaderEXT(@GLuint int id); + + @GLuint + int glGenVertexShadersEXT(@GLuint int range); + + void glDeleteVertexShaderEXT(@GLuint int id); + + void glShaderOp1EXT(@GLenum int op, @GLuint int res, @GLuint int arg1); + + void glShaderOp2EXT(@GLenum int op, @GLuint int res, @GLuint int arg1, @GLuint int arg2); + + void glShaderOp3EXT(@GLenum int op, @GLuint int res, @GLuint int arg1, @GLuint int arg2, @GLuint int arg3); + + void glSwizzleEXT(@GLuint int res, @GLuint int in, @GLenum int outX, @GLenum int outY, @GLenum int outZ, @GLenum int outW); + + void glWriteMaskEXT(@GLuint int res, @GLuint int in, @GLenum int outX, @GLenum int outY, @GLenum int outZ, @GLenum int outW); + + void glInsertComponentEXT(@GLuint int res, @GLuint int src, @GLuint int num); + + void glExtractComponentEXT(@GLuint int res, @GLuint int src, @GLuint int num); + + @GLuint + int glGenSymbolsEXT(@GLenum int dataType, @GLenum int storageType, @GLenum int range, @GLuint int components); + + void glSetInvariantEXT(@GLuint int id, @AutoType("pAddr") @GLenum int type, + @Check("4") + @Const + @GLbyte + @GLubyte + @GLshort + @GLushort + @GLint + @GLuint + @GLfloat + @GLdouble Buffer pAddr); + + void glSetLocalConstantEXT(@GLuint int id, @AutoType("pAddr") @GLenum int type, + @Check("4") + @Const + @GLbyte + @GLubyte + @GLshort + @GLushort + @GLint + @GLuint + @GLfloat + @GLdouble Buffer pAddr); + + @StripPostfix("pAddr") + void glVariantbvEXT(@GLuint int id, @Check("4") @Const ByteBuffer pAddr); + + @StripPostfix("pAddr") + void glVariantsvEXT(@GLuint int id, @Check("4") @Const ShortBuffer pAddr); + + @StripPostfix("pAddr") + void glVariantivEXT(@GLuint int id, @Check("4") @Const IntBuffer pAddr); + + @StripPostfix("pAddr") + void glVariantfvEXT(@GLuint int id, @Check("4") @Const FloatBuffer pAddr); + + @StripPostfix("pAddr") + void glVariantdvEXT(@GLuint int id, @Check("4") @Const DoubleBuffer pAddr); + + @StripPostfix("pAddr") + void glVariantubvEXT(@GLuint int id, @Check("4") @Const @GLubyte ByteBuffer pAddr); + + @StripPostfix("pAddr") + void glVariantusvEXT(@GLuint int id, @Check("4") @Const @GLushort ShortBuffer pAddr); + + @StripPostfix("pAddr") + void glVariantuivEXT(@GLuint int id, @Check("4") @Const @GLuint IntBuffer pAddr); + + void glVariantPointerEXT(@GLuint int id, @AutoType("pAddr") @GLenum int type, @GLuint int stride, + @CachedReference + @BufferObject(BufferKind.ArrayVBO) + @Check + @Const + @GLbyte + @GLshort + @GLint + @GLubyte + @GLushort + @GLuint + @GLfloat + @GLdouble Buffer pAddr); + + void glEnableVariantClientStateEXT(@GLuint int id); + + void glDisableVariantClientStateEXT(@GLuint int id); + + @GLuint + int glBindLightParameterEXT(@GLenum int light, @GLenum int value); + + @GLuint + int glBindMaterialParameterEXT(@GLenum int face, @GLenum int value); + + @GLuint + int glBindTexGenParameterEXT(@GLenum int unit, @GLenum int coord, @GLenum int value); + + @GLuint + int glBindTextureUnitParameterEXT(@GLenum int unit, @GLenum int value); + + @GLuint + int glBindParameterEXT(@GLenum int value); + + boolean glIsVariantEnabledEXT(@GLuint int id, @GLenum int cap); + + @StripPostfix("pbData") + void glGetVariantBooleanvEXT(@GLuint int id, @GLenum int value, @OutParameter @Check("4") ByteBuffer pbData); + + @StripPostfix("pbData") + void glGetVariantIntegervEXT(@GLuint int id, @GLenum int value, @OutParameter @Check("4") IntBuffer pbData); + + @StripPostfix("pbData") + void glGetVariantFloatvEXT(@GLuint int id, @GLenum int value, @OutParameter @Check("4") FloatBuffer pbData); + + @StripPostfix("pbData") + void glGetVariantPointervEXT(@GLuint int id, @GLenum int value, @OutParameter @Result @GLvoid ByteBuffer pbData); + + @StripPostfix("pbData") + void glGetInvariantBooleanvEXT(@GLuint int id, @GLenum int value, @OutParameter @Check("4") ByteBuffer pbData); + + @StripPostfix("pbData") + void glGetInvariantIntegervEXT(@GLuint int id, @GLenum int value, @OutParameter @Check("4") IntBuffer pbData); + + @StripPostfix("pbData") + void glGetInvariantFloatvEXT(@GLuint int id, @GLenum int value, @OutParameter @Check("4") FloatBuffer pbData); + + @StripPostfix("pbData") + void glGetLocalConstantBooleanvEXT(@GLuint int id, @GLenum int value, @OutParameter @Check("4") ByteBuffer pbData); + + @StripPostfix("pbData") + void glGetLocalConstantIntegervEXT(@GLuint int id, @GLenum int value, @OutParameter @Check("4") IntBuffer pbData); + + @StripPostfix("pbData") + void glGetLocalConstantFloatvEXT(@GLuint int id, @GLenum int value, @OutParameter @Check("4") FloatBuffer pbData); +} diff --git a/src/templates/org/lwjgl/opengl/EXT_vertex_weighting.java b/src/templates/org/lwjgl/opengl/EXT_vertex_weighting.java new file mode 100644 index 0000000..cf2a5b6 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/EXT_vertex_weighting.java @@ -0,0 +1,62 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +import java.nio.*; + +public interface EXT_vertex_weighting { + int GL_MODELVIEW0_STACK_DEPTH_EXT = 0x0BA3; + int GL_MODELVIEW1_STACK_DEPTH_EXT = 0x8502; + int GL_MODELVIEW0_MATRIX_EXT = 0x0BA6; + int GL_MODELVIEW1_MATRIX_EXT = 0x8506; + int GL_VERTEX_WEIGHTING_EXT = 0x8509; + int GL_MODELVIEW0_EXT = 0x1700; + int GL_MODELVIEW1_EXT = 0x850A; + int GL_CURRENT_VERTEX_WEIGHT_EXT = 0x850B; + int GL_VERTEX_WEIGHT_ARRAY_EXT = 0x850C; + int GL_VERTEX_WEIGHT_ARRAY_SIZE_EXT = 0x850D; + int GL_VERTEX_WEIGHT_ARRAY_TYPE_EXT = 0x850E; + int GL_VERTEX_WEIGHT_ARRAY_STRIDE_EXT = 0x850F; + int GL_VERTEX_WEIGHT_ARRAY_POINTER_EXT = 0x8510; + + @NoErrorCheck + void glVertexWeightfEXT(float weight); + + void glVertexWeightPointerEXT(@GLsizei int size, @AutoType("pPointer") @GLenum int type, @GLsizei int stride, + @CachedReference + @BufferObject(BufferKind.ArrayVBO) + @Check + @Const + @GLfloat Buffer pPointer); +} diff --git a/src/templates/org/lwjgl/opengl/GL11.java b/src/templates/org/lwjgl/opengl/GL11.java new file mode 100644 index 0000000..4a19432 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/GL11.java @@ -0,0 +1,1612 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +import java.nio.*; + +/** + * The core OpenGL1.1 API. + * + * @author cix_foo + * @version $Revision: 3316 $ + * $Id: GL11.java 3316 2010-04-09 23:57:40Z spasi $ + */ +@DeprecatedGL +public interface GL11 { + /* AccumOp */ + int GL_ACCUM = 0x0100; + int GL_LOAD = 0x0101; + int GL_RETURN = 0x0102; + int GL_MULT = 0x0103; + int GL_ADD = 0x0104; + + /* AlphaFunction */ + int GL_NEVER = 0x0200; + int GL_LESS = 0x0201; + int GL_EQUAL = 0x0202; + int GL_LEQUAL = 0x0203; + int GL_GREATER = 0x0204; + int GL_NOTEQUAL = 0x0205; + int GL_GEQUAL = 0x0206; + int GL_ALWAYS = 0x0207; + + /* AttribMask */ + int GL_CURRENT_BIT = 0x00000001; + int GL_POINT_BIT = 0x00000002; + int GL_LINE_BIT = 0x00000004; + int GL_POLYGON_BIT = 0x00000008; + int GL_POLYGON_STIPPLE_BIT = 0x00000010; + int GL_PIXEL_MODE_BIT = 0x00000020; + int GL_LIGHTING_BIT = 0x00000040; + int GL_FOG_BIT = 0x00000080; + int GL_DEPTH_BUFFER_BIT = 0x00000100; + int GL_ACCUM_BUFFER_BIT = 0x00000200; + int GL_STENCIL_BUFFER_BIT = 0x00000400; + int GL_VIEWPORT_BIT = 0x00000800; + int GL_TRANSFORM_BIT = 0x00001000; + int GL_ENABLE_BIT = 0x00002000; + int GL_COLOR_BUFFER_BIT = 0x00004000; + int GL_HINT_BIT = 0x00008000; + int GL_EVAL_BIT = 0x00010000; + int GL_LIST_BIT = 0x00020000; + int GL_TEXTURE_BIT = 0x00040000; + int GL_SCISSOR_BIT = 0x00080000; + int GL_ALL_ATTRIB_BITS = 0x000fffff; + + /* BeginMode */ + int GL_POINTS = 0x0000; + int GL_LINES = 0x0001; + int GL_LINE_LOOP = 0x0002; + int GL_LINE_STRIP = 0x0003; + int GL_TRIANGLES = 0x0004; + int GL_TRIANGLE_STRIP = 0x0005; + int GL_TRIANGLE_FAN = 0x0006; + int GL_QUADS = 0x0007; + int GL_QUAD_STRIP = 0x0008; + int GL_POLYGON = 0x0009; + + /* BlendingFactorDest */ + int GL_ZERO = 0; + int GL_ONE = 1; + int GL_SRC_COLOR = 0x0300; + int GL_ONE_MINUS_SRC_COLOR = 0x0301; + int GL_SRC_ALPHA = 0x0302; + int GL_ONE_MINUS_SRC_ALPHA = 0x0303; + int GL_DST_ALPHA = 0x0304; + int GL_ONE_MINUS_DST_ALPHA = 0x0305; + + /* BlendingFactorSrc */ + /* GL_ZERO */ + /* GL_ONE */ + int GL_DST_COLOR = 0x0306; + int GL_ONE_MINUS_DST_COLOR = 0x0307; + int GL_SRC_ALPHA_SATURATE = 0x0308; + int GL_CONSTANT_COLOR = 0x8001; + int GL_ONE_MINUS_CONSTANT_COLOR = 0x8002; + int GL_CONSTANT_ALPHA = 0x8003; + int GL_ONE_MINUS_CONSTANT_ALPHA = 0x8004; + + /* Boolean */ + int GL_TRUE = 1; + int GL_FALSE = 0; + + /* ClipPlaneName */ + int GL_CLIP_PLANE0 = 0x3000; + int GL_CLIP_PLANE1 = 0x3001; + int GL_CLIP_PLANE2 = 0x3002; + int GL_CLIP_PLANE3 = 0x3003; + int GL_CLIP_PLANE4 = 0x3004; + int GL_CLIP_PLANE5 = 0x3005; + + /* DataType */ + int GL_BYTE = 0x1400; + int GL_UNSIGNED_BYTE = 0x1401; + int GL_SHORT = 0x1402; + int GL_UNSIGNED_SHORT = 0x1403; + int GL_INT = 0x1404; + int GL_UNSIGNED_INT = 0x1405; + int GL_FLOAT = 0x1406; + int GL_2_BYTES = 0x1407; + int GL_3_BYTES = 0x1408; + int GL_4_BYTES = 0x1409; + int GL_DOUBLE = 0x140A; + + /* DrawBufferMode */ + int GL_NONE = 0; + int GL_FRONT_LEFT = 0x0400; + int GL_FRONT_RIGHT = 0x0401; + int GL_BACK_LEFT = 0x0402; + int GL_BACK_RIGHT = 0x0403; + int GL_FRONT = 0x0404; + int GL_BACK = 0x0405; + int GL_LEFT = 0x0406; + int GL_RIGHT = 0x0407; + int GL_FRONT_AND_BACK = 0x0408; + int GL_AUX0 = 0x0409; + int GL_AUX1 = 0x040A; + int GL_AUX2 = 0x040B; + int GL_AUX3 = 0x040C; + + /* ErrorCode */ + int GL_NO_ERROR = 0; + int GL_INVALID_ENUM = 0x0500; + int GL_INVALID_VALUE = 0x0501; + int GL_INVALID_OPERATION = 0x0502; + int GL_STACK_OVERFLOW = 0x0503; + int GL_STACK_UNDERFLOW = 0x0504; + int GL_OUT_OF_MEMORY = 0x0505; + + /* FeedBackMode */ + int GL_2D = 0x0600; + int GL_3D = 0x0601; + int GL_3D_COLOR = 0x0602; + int GL_3D_COLOR_TEXTURE = 0x0603; + int GL_4D_COLOR_TEXTURE = 0x0604; + + /* FeedBackToken */ + int GL_PASS_THROUGH_TOKEN = 0x0700; + int GL_POINT_TOKEN = 0x0701; + int GL_LINE_TOKEN = 0x0702; + int GL_POLYGON_TOKEN = 0x0703; + int GL_BITMAP_TOKEN = 0x0704; + int GL_DRAW_PIXEL_TOKEN = 0x0705; + int GL_COPY_PIXEL_TOKEN = 0x0706; + int GL_LINE_RESET_TOKEN = 0x0707; + + /* FogMode */ + /* GL_LINEAR */ + int GL_EXP = 0x0800; + int GL_EXP2 = 0x0801; + + /* FrontFaceDirection */ + int GL_CW = 0x0900; + int GL_CCW = 0x0901; + + /* GetMapTarget */ + int GL_COEFF = 0x0A00; + int GL_ORDER = 0x0A01; + int GL_DOMAIN = 0x0A02; + + /* GetTarget */ + int GL_CURRENT_COLOR = 0x0B00; + int GL_CURRENT_INDEX = 0x0B01; + int GL_CURRENT_NORMAL = 0x0B02; + int GL_CURRENT_TEXTURE_COORDS = 0x0B03; + int GL_CURRENT_RASTER_COLOR = 0x0B04; + int GL_CURRENT_RASTER_INDEX = 0x0B05; + int GL_CURRENT_RASTER_TEXTURE_COORDS = 0x0B06; + int GL_CURRENT_RASTER_POSITION = 0x0B07; + int GL_CURRENT_RASTER_POSITION_VALID = 0x0B08; + int GL_CURRENT_RASTER_DISTANCE = 0x0B09; + int GL_POINT_SMOOTH = 0x0B10; + int GL_POINT_SIZE = 0x0B11; + int GL_POINT_SIZE_RANGE = 0x0B12; + int GL_POINT_SIZE_GRANULARITY = 0x0B13; + int GL_LINE_SMOOTH = 0x0B20; + int GL_LINE_WIDTH = 0x0B21; + int GL_LINE_WIDTH_RANGE = 0x0B22; + int GL_LINE_WIDTH_GRANULARITY = 0x0B23; + int GL_LINE_STIPPLE = 0x0B24; + int GL_LINE_STIPPLE_PATTERN = 0x0B25; + int GL_LINE_STIPPLE_REPEAT = 0x0B26; + int GL_LIST_MODE = 0x0B30; + int GL_MAX_LIST_NESTING = 0x0B31; + int GL_LIST_BASE = 0x0B32; + int GL_LIST_INDEX = 0x0B33; + int GL_POLYGON_MODE = 0x0B40; + int GL_POLYGON_SMOOTH = 0x0B41; + int GL_POLYGON_STIPPLE = 0x0B42; + int GL_EDGE_FLAG = 0x0B43; + int GL_CULL_FACE = 0x0B44; + int GL_CULL_FACE_MODE = 0x0B45; + int GL_FRONT_FACE = 0x0B46; + int GL_LIGHTING = 0x0B50; + int GL_LIGHT_MODEL_LOCAL_VIEWER = 0x0B51; + int GL_LIGHT_MODEL_TWO_SIDE = 0x0B52; + int GL_LIGHT_MODEL_AMBIENT = 0x0B53; + int GL_SHADE_MODEL = 0x0B54; + int GL_COLOR_MATERIAL_FACE = 0x0B55; + int GL_COLOR_MATERIAL_PARAMETER = 0x0B56; + int GL_COLOR_MATERIAL = 0x0B57; + int GL_FOG = 0x0B60; + int GL_FOG_INDEX = 0x0B61; + int GL_FOG_DENSITY = 0x0B62; + int GL_FOG_START = 0x0B63; + int GL_FOG_END = 0x0B64; + int GL_FOG_MODE = 0x0B65; + int GL_FOG_COLOR = 0x0B66; + int GL_DEPTH_RANGE = 0x0B70; + int GL_DEPTH_TEST = 0x0B71; + int GL_DEPTH_WRITEMASK = 0x0B72; + int GL_DEPTH_CLEAR_VALUE = 0x0B73; + int GL_DEPTH_FUNC = 0x0B74; + int GL_ACCUM_CLEAR_VALUE = 0x0B80; + int GL_STENCIL_TEST = 0x0B90; + int GL_STENCIL_CLEAR_VALUE = 0x0B91; + int GL_STENCIL_FUNC = 0x0B92; + int GL_STENCIL_VALUE_MASK = 0x0B93; + int GL_STENCIL_FAIL = 0x0B94; + int GL_STENCIL_PASS_DEPTH_FAIL = 0x0B95; + int GL_STENCIL_PASS_DEPTH_PASS = 0x0B96; + int GL_STENCIL_REF = 0x0B97; + int GL_STENCIL_WRITEMASK = 0x0B98; + int GL_MATRIX_MODE = 0x0BA0; + int GL_NORMALIZE = 0x0BA1; + int GL_VIEWPORT = 0x0BA2; + int GL_MODELVIEW_STACK_DEPTH = 0x0BA3; + int GL_PROJECTION_STACK_DEPTH = 0x0BA4; + int GL_TEXTURE_STACK_DEPTH = 0x0BA5; + int GL_MODELVIEW_MATRIX = 0x0BA6; + int GL_PROJECTION_MATRIX = 0x0BA7; + int GL_TEXTURE_MATRIX = 0x0BA8; + int GL_ATTRIB_STACK_DEPTH = 0x0BB0; + int GL_CLIENT_ATTRIB_STACK_DEPTH = 0x0BB1; + int GL_ALPHA_TEST = 0x0BC0; + int GL_ALPHA_TEST_FUNC = 0x0BC1; + int GL_ALPHA_TEST_REF = 0x0BC2; + int GL_DITHER = 0x0BD0; + int GL_BLEND_DST = 0x0BE0; + int GL_BLEND_SRC = 0x0BE1; + int GL_BLEND = 0x0BE2; + int GL_LOGIC_OP_MODE = 0x0BF0; + int GL_INDEX_LOGIC_OP = 0x0BF1; + int GL_COLOR_LOGIC_OP = 0x0BF2; + int GL_AUX_BUFFERS = 0x0C00; + int GL_DRAW_BUFFER = 0x0C01; + int GL_READ_BUFFER = 0x0C02; + int GL_SCISSOR_BOX = 0x0C10; + int GL_SCISSOR_TEST = 0x0C11; + int GL_INDEX_CLEAR_VALUE = 0x0C20; + int GL_INDEX_WRITEMASK = 0x0C21; + int GL_COLOR_CLEAR_VALUE = 0x0C22; + int GL_COLOR_WRITEMASK = 0x0C23; + int GL_INDEX_MODE = 0x0C30; + int GL_RGBA_MODE = 0x0C31; + int GL_DOUBLEBUFFER = 0x0C32; + int GL_STEREO = 0x0C33; + int GL_RENDER_MODE = 0x0C40; + int GL_PERSPECTIVE_CORRECTION_HINT = 0x0C50; + int GL_POINT_SMOOTH_HINT = 0x0C51; + int GL_LINE_SMOOTH_HINT = 0x0C52; + int GL_POLYGON_SMOOTH_HINT = 0x0C53; + int GL_FOG_HINT = 0x0C54; + int GL_TEXTURE_GEN_S = 0x0C60; + int GL_TEXTURE_GEN_T = 0x0C61; + int GL_TEXTURE_GEN_R = 0x0C62; + int GL_TEXTURE_GEN_Q = 0x0C63; + int GL_PIXEL_MAP_I_TO_I = 0x0C70; + int GL_PIXEL_MAP_S_TO_S = 0x0C71; + int GL_PIXEL_MAP_I_TO_R = 0x0C72; + int GL_PIXEL_MAP_I_TO_G = 0x0C73; + int GL_PIXEL_MAP_I_TO_B = 0x0C74; + int GL_PIXEL_MAP_I_TO_A = 0x0C75; + int GL_PIXEL_MAP_R_TO_R = 0x0C76; + int GL_PIXEL_MAP_G_TO_G = 0x0C77; + int GL_PIXEL_MAP_B_TO_B = 0x0C78; + int GL_PIXEL_MAP_A_TO_A = 0x0C79; + int GL_PIXEL_MAP_I_TO_I_SIZE = 0x0CB0; + int GL_PIXEL_MAP_S_TO_S_SIZE = 0x0CB1; + int GL_PIXEL_MAP_I_TO_R_SIZE = 0x0CB2; + int GL_PIXEL_MAP_I_TO_G_SIZE = 0x0CB3; + int GL_PIXEL_MAP_I_TO_B_SIZE = 0x0CB4; + int GL_PIXEL_MAP_I_TO_A_SIZE = 0x0CB5; + int GL_PIXEL_MAP_R_TO_R_SIZE = 0x0CB6; + int GL_PIXEL_MAP_G_TO_G_SIZE = 0x0CB7; + int GL_PIXEL_MAP_B_TO_B_SIZE = 0x0CB8; + int GL_PIXEL_MAP_A_TO_A_SIZE = 0x0CB9; + int GL_UNPACK_SWAP_BYTES = 0x0CF0; + int GL_UNPACK_LSB_FIRST = 0x0CF1; + int GL_UNPACK_ROW_LENGTH = 0x0CF2; + int GL_UNPACK_SKIP_ROWS = 0x0CF3; + int GL_UNPACK_SKIP_PIXELS = 0x0CF4; + int GL_UNPACK_ALIGNMENT = 0x0CF5; + int GL_PACK_SWAP_BYTES = 0x0D00; + int GL_PACK_LSB_FIRST = 0x0D01; + int GL_PACK_ROW_LENGTH = 0x0D02; + int GL_PACK_SKIP_ROWS = 0x0D03; + int GL_PACK_SKIP_PIXELS = 0x0D04; + int GL_PACK_ALIGNMENT = 0x0D05; + int GL_MAP_COLOR = 0x0D10; + int GL_MAP_STENCIL = 0x0D11; + int GL_INDEX_SHIFT = 0x0D12; + int GL_INDEX_OFFSET = 0x0D13; + int GL_RED_SCALE = 0x0D14; + int GL_RED_BIAS = 0x0D15; + int GL_ZOOM_X = 0x0D16; + int GL_ZOOM_Y = 0x0D17; + int GL_GREEN_SCALE = 0x0D18; + int GL_GREEN_BIAS = 0x0D19; + int GL_BLUE_SCALE = 0x0D1A; + int GL_BLUE_BIAS = 0x0D1B; + int GL_ALPHA_SCALE = 0x0D1C; + int GL_ALPHA_BIAS = 0x0D1D; + int GL_DEPTH_SCALE = 0x0D1E; + int GL_DEPTH_BIAS = 0x0D1F; + int GL_MAX_EVAL_ORDER = 0x0D30; + int GL_MAX_LIGHTS = 0x0D31; + int GL_MAX_CLIP_PLANES = 0x0D32; + int GL_MAX_TEXTURE_SIZE = 0x0D33; + int GL_MAX_PIXEL_MAP_TABLE = 0x0D34; + int GL_MAX_ATTRIB_STACK_DEPTH = 0x0D35; + int GL_MAX_MODELVIEW_STACK_DEPTH = 0x0D36; + int GL_MAX_NAME_STACK_DEPTH = 0x0D37; + int GL_MAX_PROJECTION_STACK_DEPTH = 0x0D38; + int GL_MAX_TEXTURE_STACK_DEPTH = 0x0D39; + int GL_MAX_VIEWPORT_DIMS = 0x0D3A; + int GL_MAX_CLIENT_ATTRIB_STACK_DEPTH = 0x0D3B; + int GL_SUBPIXEL_BITS = 0x0D50; + int GL_INDEX_BITS = 0x0D51; + int GL_RED_BITS = 0x0D52; + int GL_GREEN_BITS = 0x0D53; + int GL_BLUE_BITS = 0x0D54; + int GL_ALPHA_BITS = 0x0D55; + int GL_DEPTH_BITS = 0x0D56; + int GL_STENCIL_BITS = 0x0D57; + int GL_ACCUM_RED_BITS = 0x0D58; + int GL_ACCUM_GREEN_BITS = 0x0D59; + int GL_ACCUM_BLUE_BITS = 0x0D5A; + int GL_ACCUM_ALPHA_BITS = 0x0D5B; + int GL_NAME_STACK_DEPTH = 0x0D70; + int GL_AUTO_NORMAL = 0x0D80; + int GL_MAP1_COLOR_4 = 0x0D90; + int GL_MAP1_INDEX = 0x0D91; + int GL_MAP1_NORMAL = 0x0D92; + int GL_MAP1_TEXTURE_COORD_1 = 0x0D93; + int GL_MAP1_TEXTURE_COORD_2 = 0x0D94; + int GL_MAP1_TEXTURE_COORD_3 = 0x0D95; + int GL_MAP1_TEXTURE_COORD_4 = 0x0D96; + int GL_MAP1_VERTEX_3 = 0x0D97; + int GL_MAP1_VERTEX_4 = 0x0D98; + int GL_MAP2_COLOR_4 = 0x0DB0; + int GL_MAP2_INDEX = 0x0DB1; + int GL_MAP2_NORMAL = 0x0DB2; + int GL_MAP2_TEXTURE_COORD_1 = 0x0DB3; + int GL_MAP2_TEXTURE_COORD_2 = 0x0DB4; + int GL_MAP2_TEXTURE_COORD_3 = 0x0DB5; + int GL_MAP2_TEXTURE_COORD_4 = 0x0DB6; + int GL_MAP2_VERTEX_3 = 0x0DB7; + int GL_MAP2_VERTEX_4 = 0x0DB8; + int GL_MAP1_GRID_DOMAIN = 0x0DD0; + int GL_MAP1_GRID_SEGMENTS = 0x0DD1; + int GL_MAP2_GRID_DOMAIN = 0x0DD2; + int GL_MAP2_GRID_SEGMENTS = 0x0DD3; + int GL_TEXTURE_1D = 0x0DE0; + int GL_TEXTURE_2D = 0x0DE1; + int GL_FEEDBACK_BUFFER_POINTER = 0x0DF0; + int GL_FEEDBACK_BUFFER_SIZE = 0x0DF1; + int GL_FEEDBACK_BUFFER_TYPE = 0x0DF2; + int GL_SELECTION_BUFFER_POINTER = 0x0DF3; + int GL_SELECTION_BUFFER_SIZE = 0x0DF4; + + /* GetTextureParameter */ + /* GL_TEXTURE_MAG_FILTER */ + /* GL_TEXTURE_MIN_FILTER */ + /* GL_TEXTURE_WRAP_S */ + /* GL_TEXTURE_WRAP_T */ + int GL_TEXTURE_WIDTH = 0x1000; + int GL_TEXTURE_HEIGHT = 0x1001; + int GL_TEXTURE_INTERNAL_FORMAT = 0x1003; + int GL_TEXTURE_BORDER_COLOR = 0x1004; + int GL_TEXTURE_BORDER = 0x1005; + /* GL_TEXTURE_RED_SIZE */ + /* GL_TEXTURE_GREEN_SIZE */ + /* GL_TEXTURE_BLUE_SIZE */ + /* GL_TEXTURE_ALPHA_SIZE */ + /* GL_TEXTURE_LUMINANCE_SIZE */ + /* GL_TEXTURE_INTENSITY_SIZE */ + /* GL_TEXTURE_PRIORITY */ + /* GL_TEXTURE_RESIDENT */ + + /* HintMode */ + int GL_DONT_CARE = 0x1100; + int GL_FASTEST = 0x1101; + int GL_NICEST = 0x1102; + + /* LightName */ + int GL_LIGHT0 = 0x4000; + int GL_LIGHT1 = 0x4001; + int GL_LIGHT2 = 0x4002; + int GL_LIGHT3 = 0x4003; + int GL_LIGHT4 = 0x4004; + int GL_LIGHT5 = 0x4005; + int GL_LIGHT6 = 0x4006; + int GL_LIGHT7 = 0x4007; + + /* LightParameter */ + int GL_AMBIENT = 0x1200; + int GL_DIFFUSE = 0x1201; + int GL_SPECULAR = 0x1202; + int GL_POSITION = 0x1203; + int GL_SPOT_DIRECTION = 0x1204; + int GL_SPOT_EXPONENT = 0x1205; + int GL_SPOT_CUTOFF = 0x1206; + int GL_CONSTANT_ATTENUATION = 0x1207; + int GL_LINEAR_ATTENUATION = 0x1208; + int GL_QUADRATIC_ATTENUATION = 0x1209; + + /* ListMode */ + int GL_COMPILE = 0x1300; + int GL_COMPILE_AND_EXECUTE = 0x1301; + + /* LogicOp */ + int GL_CLEAR = 0x1500; + int GL_AND = 0x1501; + int GL_AND_REVERSE = 0x1502; + int GL_COPY = 0x1503; + int GL_AND_INVERTED = 0x1504; + int GL_NOOP = 0x1505; + int GL_XOR = 0x1506; + int GL_OR = 0x1507; + int GL_NOR = 0x1508; + int GL_EQUIV = 0x1509; + int GL_INVERT = 0x150A; + int GL_OR_REVERSE = 0x150B; + int GL_COPY_INVERTED = 0x150C; + int GL_OR_INVERTED = 0x150D; + int GL_NAND = 0x150E; + int GL_SET = 0x150F; + + /* MaterialParameter */ + int GL_EMISSION = 0x1600; + int GL_SHININESS = 0x1601; + int GL_AMBIENT_AND_DIFFUSE = 0x1602; + int GL_COLOR_INDEXES = 0x1603; + /* GL_AMBIENT */ + /* GL_DIFFUSE */ + /* GL_SPECULAR */ + + /* MatrixMode */ + int GL_MODELVIEW = 0x1700; + int GL_PROJECTION = 0x1701; + int GL_TEXTURE = 0x1702; + + /* PixelCopyType */ + int GL_COLOR = 0x1800; + int GL_DEPTH = 0x1801; + int GL_STENCIL = 0x1802; + + /* PixelFormat */ + int GL_COLOR_INDEX = 0x1900; + int GL_STENCIL_INDEX = 0x1901; + int GL_DEPTH_COMPONENT = 0x1902; + int GL_RED = 0x1903; + int GL_GREEN = 0x1904; + int GL_BLUE = 0x1905; + int GL_ALPHA = 0x1906; + int GL_RGB = 0x1907; + int GL_RGBA = 0x1908; + int GL_LUMINANCE = 0x1909; + int GL_LUMINANCE_ALPHA = 0x190A; + + /* PixelType */ + int GL_BITMAP = 0x1A00; + /* GL_BYTE */ + /* GL_UNSIGNED_BYTE */ + /* GL_SHORT */ + /* GL_UNSIGNED_SHORT */ + /* GL_INT */ + /* GL_UNSIGNED_INT */ + /* GL_FLOAT */ + + /* PolygonMode */ + int GL_POINT = 0x1B00; + int GL_LINE = 0x1B01; + int GL_FILL = 0x1B02; + + /* RenderingMode */ + int GL_RENDER = 0x1C00; + int GL_FEEDBACK = 0x1C01; + int GL_SELECT = 0x1C02; + + /* ShadingModel */ + int GL_FLAT = 0x1D00; + int GL_SMOOTH = 0x1D01; + + /* StencilOp */ + /* GL_ZERO */ + int GL_KEEP = 0x1E00; + int GL_REPLACE = 0x1E01; + int GL_INCR = 0x1E02; + int GL_DECR = 0x1E03; + /* GL_INVERT */ + + /* StringName */ + int GL_VENDOR = 0x1F00; + int GL_RENDERER = 0x1F01; + int GL_VERSION = 0x1F02; + int GL_EXTENSIONS = 0x1F03; + + /* TextureCoordName */ + int GL_S = 0x2000; + int GL_T = 0x2001; + int GL_R = 0x2002; + int GL_Q = 0x2003; + + /* TexCoordPointerType */ + /* GL_SHORT */ + /* GL_INT */ + /* GL_FLOAT */ + /* GL_DOUBLE */ + + /* TextureEnvMode */ + int GL_MODULATE = 0x2100; + int GL_DECAL = 0x2101; + /* GL_BLEND */ + /* GL_REPLACE */ + + /* TextureEnvParameter */ + int GL_TEXTURE_ENV_MODE = 0x2200; + int GL_TEXTURE_ENV_COLOR = 0x2201; + + /* TextureEnvTarget */ + int GL_TEXTURE_ENV = 0x2300; + + /* TextureGenMode */ + int GL_EYE_LINEAR = 0x2400; + int GL_OBJECT_LINEAR = 0x2401; + int GL_SPHERE_MAP = 0x2402; + + /* TextureGenParameter */ + int GL_TEXTURE_GEN_MODE = 0x2500; + int GL_OBJECT_PLANE = 0x2501; + int GL_EYE_PLANE = 0x2502; + + /* TextureMagFilter */ + int GL_NEAREST = 0x2600; + int GL_LINEAR = 0x2601; + + /* TextureMinFilter */ + /* GL_NEAREST */ + /* GL_LINEAR */ + int GL_NEAREST_MIPMAP_NEAREST = 0x2700; + int GL_LINEAR_MIPMAP_NEAREST = 0x2701; + int GL_NEAREST_MIPMAP_LINEAR = 0x2702; + int GL_LINEAR_MIPMAP_LINEAR = 0x2703; + + /* TextureParameterName */ + int GL_TEXTURE_MAG_FILTER = 0x2800; + int GL_TEXTURE_MIN_FILTER = 0x2801; + int GL_TEXTURE_WRAP_S = 0x2802; + int GL_TEXTURE_WRAP_T = 0x2803; + /* GL_TEXTURE_BORDER_COLOR */ + /* GL_TEXTURE_PRIORITY */ + + /* TextureWrapMode */ + int GL_CLAMP = 0x2900; + int GL_REPEAT = 0x2901; + + /* ClientAttribMask */ + int GL_CLIENT_PIXEL_STORE_BIT = 0x00000001; + int GL_CLIENT_VERTEX_ARRAY_BIT = 0x00000002; + int GL_ALL_CLIENT_ATTRIB_BITS = 0xffffffff; + + /* polygon_offset */ + int GL_POLYGON_OFFSET_FACTOR = 0x8038; + int GL_POLYGON_OFFSET_UNITS = 0x2A00; + int GL_POLYGON_OFFSET_POINT = 0x2A01; + int GL_POLYGON_OFFSET_LINE = 0x2A02; + int GL_POLYGON_OFFSET_FILL = 0x8037; + + /* texture */ + int GL_ALPHA4 = 0x803B; + int GL_ALPHA8 = 0x803C; + int GL_ALPHA12 = 0x803D; + int GL_ALPHA16 = 0x803E; + int GL_LUMINANCE4 = 0x803F; + int GL_LUMINANCE8 = 0x8040; + int GL_LUMINANCE12 = 0x8041; + int GL_LUMINANCE16 = 0x8042; + int GL_LUMINANCE4_ALPHA4 = 0x8043; + int GL_LUMINANCE6_ALPHA2 = 0x8044; + int GL_LUMINANCE8_ALPHA8 = 0x8045; + int GL_LUMINANCE12_ALPHA4 = 0x8046; + int GL_LUMINANCE12_ALPHA12 = 0x8047; + int GL_LUMINANCE16_ALPHA16 = 0x8048; + int GL_INTENSITY = 0x8049; + int GL_INTENSITY4 = 0x804A; + int GL_INTENSITY8 = 0x804B; + int GL_INTENSITY12 = 0x804C; + int GL_INTENSITY16 = 0x804D; + int GL_R3_G3_B2 = 0x2A10; + int GL_RGB4 = 0x804F; + int GL_RGB5 = 0x8050; + int GL_RGB8 = 0x8051; + int GL_RGB10 = 0x8052; + int GL_RGB12 = 0x8053; + int GL_RGB16 = 0x8054; + int GL_RGBA2 = 0x8055; + int GL_RGBA4 = 0x8056; + int GL_RGB5_A1 = 0x8057; + int GL_RGBA8 = 0x8058; + int GL_RGB10_A2 = 0x8059; + int GL_RGBA12 = 0x805A; + int GL_RGBA16 = 0x805B; + int GL_TEXTURE_RED_SIZE = 0x805C; + int GL_TEXTURE_GREEN_SIZE = 0x805D; + int GL_TEXTURE_BLUE_SIZE = 0x805E; + int GL_TEXTURE_ALPHA_SIZE = 0x805F; + int GL_TEXTURE_LUMINANCE_SIZE = 0x8060; + int GL_TEXTURE_INTENSITY_SIZE = 0x8061; + int GL_PROXY_TEXTURE_1D = 0x8063; + int GL_PROXY_TEXTURE_2D = 0x8064; + + /* texture_object */ + int GL_TEXTURE_PRIORITY = 0x8066; + int GL_TEXTURE_RESIDENT = 0x8067; + int GL_TEXTURE_BINDING_1D = 0x8068; + int GL_TEXTURE_BINDING_2D = 0x8069; + + /* vertex_array */ + int GL_VERTEX_ARRAY = 0x8074; + int GL_NORMAL_ARRAY = 0x8075; + int GL_COLOR_ARRAY = 0x8076; + int GL_INDEX_ARRAY = 0x8077; + int GL_TEXTURE_COORD_ARRAY = 0x8078; + int GL_EDGE_FLAG_ARRAY = 0x8079; + int GL_VERTEX_ARRAY_SIZE = 0x807A; + int GL_VERTEX_ARRAY_TYPE = 0x807B; + int GL_VERTEX_ARRAY_STRIDE = 0x807C; + int GL_NORMAL_ARRAY_TYPE = 0x807E; + int GL_NORMAL_ARRAY_STRIDE = 0x807F; + int GL_COLOR_ARRAY_SIZE = 0x8081; + int GL_COLOR_ARRAY_TYPE = 0x8082; + int GL_COLOR_ARRAY_STRIDE = 0x8083; + int GL_INDEX_ARRAY_TYPE = 0x8085; + int GL_INDEX_ARRAY_STRIDE = 0x8086; + int GL_TEXTURE_COORD_ARRAY_SIZE = 0x8088; + int GL_TEXTURE_COORD_ARRAY_TYPE = 0x8089; + int GL_TEXTURE_COORD_ARRAY_STRIDE = 0x808A; + int GL_EDGE_FLAG_ARRAY_STRIDE = 0x808C; + int GL_VERTEX_ARRAY_POINTER = 0x808E; + int GL_NORMAL_ARRAY_POINTER = 0x808F; + int GL_COLOR_ARRAY_POINTER = 0x8090; + int GL_INDEX_ARRAY_POINTER = 0x8091; + int GL_TEXTURE_COORD_ARRAY_POINTER = 0x8092; + int GL_EDGE_FLAG_ARRAY_POINTER = 0x8093; + int GL_V2F = 0x2A20; + int GL_V3F = 0x2A21; + int GL_C4UB_V2F = 0x2A22; + int GL_C4UB_V3F = 0x2A23; + int GL_C3F_V3F = 0x2A24; + int GL_N3F_V3F = 0x2A25; + int GL_C4F_N3F_V3F = 0x2A26; + int GL_T2F_V3F = 0x2A27; + int GL_T4F_V4F = 0x2A28; + int GL_T2F_C4UB_V3F = 0x2A29; + int GL_T2F_C3F_V3F = 0x2A2A; + int GL_T2F_N3F_V3F = 0x2A2B; + int GL_T2F_C4F_N3F_V3F = 0x2A2C; + int GL_T4F_C4F_N3F_V4F = 0x2A2D; + + /* For compatibility with OpenGL v1.0 */ + int GL_LOGIC_OP = GL_INDEX_LOGIC_OP; + int GL_TEXTURE_COMPONENTS = GL_TEXTURE_INTERNAL_FORMAT; + + @DeprecatedGL + void glAccum(@GLenum int op, float value); + + @DeprecatedGL + void glAlphaFunc(@GLenum int func, @GLclampf float ref); + + void glClearColor(@GLclampf float red, @GLclampf float green, @GLclampf float blue, @GLclampf float alpha); + + @DeprecatedGL + void glClearAccum(float red, float green, float blue, float alpha); + + void glClear(@GLbitfield int mask); + + @DeprecatedGL + void glCallLists(@AutoSize("lists") @GLsizei int n, @AutoType("lists") @GLenum int type, + @Const + @GLubyte + @GLushort + @GLuint Buffer lists); + + @DeprecatedGL + void glCallList(@GLuint int list); + + void glBlendFunc(@GLenum int sfactor, @GLenum int dfactor); + + @DeprecatedGL + void glBitmap(@GLsizei int width, @GLsizei int height, float xorig, float yorig, float xmove, float ymove, + @BufferObject(BufferKind.UnpackPBO) + @Check("(((width + 7)/8)*height)") + @Const + @GLubyte ByteBuffer bitmap); + + void glBindTexture(@GLenum int target, @GLuint int texture); + + @DeprecatedGL + void glPrioritizeTextures(@AutoSize("textures") @GLsizei int n, + @Const + @GLuint IntBuffer textures, + @Const + @Check("textures.remaining()") + @GLclampf FloatBuffer priorities); + + @DeprecatedGL + boolean glAreTexturesResident(@AutoSize("textures") @GLsizei int n, + @Const + @GLuint IntBuffer textures, + @Check("textures.remaining()") + @GLboolean ByteBuffer residences); + + @NoErrorCheck + @DeprecatedGL + @Code("\t\tif ( ContextCapabilities.DEBUG ) StateTracker.setBeginEnd(caps, true);") + void glBegin(@GLenum int mode); + + @DeprecatedGL + @Code("\t\tif ( ContextCapabilities.DEBUG ) StateTracker.setBeginEnd(caps, false);") + void glEnd(); + + @NoErrorCheck + void glArrayElement(int i); + + void glClearDepth(@GLclampd double depth); + + @DeprecatedGL + void glDeleteLists(@GLuint int list, @GLsizei int range); + + void glDeleteTextures(@AutoSize("textures") @GLsizei int n, @Const @GLuint IntBuffer textures); + + @Alternate("glDeleteTextures") + void glDeleteTextures(@Constant("1") @GLsizei int n, @Constant(value = "APIUtils.getBufferInt().put(0, texture), 0", keepParam = true) int texture); + + void glCullFace(@GLenum int mode); + + void glCopyTexSubImage2D(@GLenum int target, int level, int xoffset, int yoffset, int x, int y, @GLsizei int width, @GLsizei int height); + + void glCopyTexSubImage1D(@GLenum int target, int level, int xoffset, int x, int y, @GLsizei int width); + + void glCopyTexImage2D(@GLenum int target, int level, int internalFormat, int x, int y, @GLsizei int width, @GLsizei int height, int border); + + void glCopyTexImage1D(@GLenum int target, int level, int internalFormat, int x, int y, @GLsizei int width, int border); + + void glCopyPixels(int x, int y, int width, int height, int type); + + @DeprecatedGL + void glColorPointer(int size, @AutoType("pointer") @GLenum int type, @GLsizei int stride, + @CachedReference + @Check + @BufferObject(BufferKind.ArrayVBO) + @Const + @GLfloat + @GLdouble + @GLubyte + @GLbyte Buffer pointer); + + @DeprecatedGL + void glColorMaterial(@GLenum int face, @GLenum int mode); + + void glColorMask(boolean red, boolean green, boolean blue, boolean alpha); + + @NoErrorCheck + @DeprecatedGL + void glColor3b(byte red, byte green, byte blue); + + @NoErrorCheck + @DeprecatedGL + void glColor3f(float red, float green, float blue); + + @NoErrorCheck + @DeprecatedGL + void glColor3d(double red, double green, double blue); + + @NoErrorCheck + @DeprecatedGL + void glColor3ub(@GLubyte byte red, @GLubyte byte green, @GLubyte byte blue); + + @NoErrorCheck + @DeprecatedGL + void glColor4b(byte red, byte green, byte blue, byte alpha); + + @NoErrorCheck + @DeprecatedGL + void glColor4f(float red, float green, float blue, float alpha); + + @NoErrorCheck + @DeprecatedGL + void glColor4d(double red, double green, double blue, double alpha); + + @NoErrorCheck + @DeprecatedGL + void glColor4ub(@GLubyte byte red, @GLubyte byte green, @GLubyte byte blue, @GLubyte byte alpha); + + void glClipPlane(@GLenum int plane, @Check("4") @Const DoubleBuffer equation); + + void glClearStencil(int s); + + // This function is only used in indexed color mode + // void glClearIndex(float c); + + @DeprecatedGL + void glEvalPoint1(int i); + + @DeprecatedGL + void glEvalPoint2(int i, int j); + + @DeprecatedGL + void glEvalMesh1(@GLenum int mode, int i1, int i2); + + @DeprecatedGL + void glEvalMesh2(@GLenum int mode, int i1, int i2, int j1, int j2); + + @DeprecatedGL + void glEvalCoord1f(float u); + + @DeprecatedGL + void glEvalCoord1d(double u); + + @DeprecatedGL + void glEvalCoord2f(float u, float v); + + @DeprecatedGL + void glEvalCoord2d(double u, double v); + + @DeprecatedGL + void glEnableClientState(@GLenum int cap); + + @DeprecatedGL + void glDisableClientState(@GLenum int cap); + + void glEnable(@GLenum int cap); + + void glDisable(@GLenum int cap); + + @DeprecatedGL + void glEdgeFlagPointer(int stride, + @CachedReference + @BufferObject(BufferKind.ArrayVBO) + @Check + @Const + @GLbyte Buffer pointer); + + @DeprecatedGL + void glEdgeFlag(boolean flag); + + @DeprecatedGL + void glDrawPixels(@GLsizei int width, @GLsizei int height, @GLenum int format, @GLenum int type, + @Check("GLChecks.calculateImageStorage(pixels, format, type, width, height, 1)") + @BufferObject(BufferKind.UnpackPBO) + @Const + @GLbyte + @GLshort + @GLint Buffer pixels); + + void glDrawElements(@GLenum int mode, @AutoSize("indices") @GLsizei int count, @AutoType("indices") @GLenum int type, + @BufferObject(BufferKind.ElementVBO) + @Const + @GLubyte + @GLushort + @GLuint Buffer indices); + + void glDrawBuffer(@GLenum int mode); + + void glDrawArrays(@GLenum int mode, int first, @GLsizei int count); + + void glDepthRange(@GLclampd double zNear, @GLclampd double zFar); + + void glDepthMask(boolean flag); + + void glDepthFunc(@GLenum int func); + + @DeprecatedGL + void glFeedbackBuffer(@AutoSize("buffer") @GLsizei int size, @GLenum int type, FloatBuffer buffer); + + @StripPostfix("values") + @DeprecatedGL + void glGetPixelMapfv(@GLenum int map, @OutParameter @Check("256") @BufferObject(BufferKind.PackPBO) FloatBuffer values); + + @StripPostfix("values") + @DeprecatedGL + void glGetPixelMapuiv(@GLenum int map, @OutParameter @Check("256") @BufferObject(BufferKind.PackPBO) @GLuint IntBuffer values); + + @StripPostfix("values") + @DeprecatedGL + void glGetPixelMapusv(@GLenum int map, @OutParameter @Check("256") @BufferObject(BufferKind.PackPBO) @GLushort ShortBuffer values); + + @StripPostfix("params") + @DeprecatedGL + void glGetMaterialfv(@GLenum int face, @GLenum int pname, @OutParameter @Check("4") FloatBuffer params); + + @StripPostfix("params") + @DeprecatedGL + void glGetMaterialiv(@GLenum int face, @GLenum int pname, @OutParameter @Check("4") IntBuffer params); + + @StripPostfix("v") + @DeprecatedGL + void glGetMapfv(@GLenum int target, @GLenum int query, @OutParameter @Check("256") FloatBuffer v); + + @StripPostfix("v") + @DeprecatedGL + void glGetMapdv(@GLenum int target, @GLenum int query, @OutParameter @Check("256") DoubleBuffer v); + + @StripPostfix("v") + @DeprecatedGL + void glGetMapiv(@GLenum int target, @GLenum int query, @OutParameter @Check("256") IntBuffer v); + + @StripPostfix("params") + @DeprecatedGL + void glGetLightfv(@GLenum int light, @GLenum int pname, @OutParameter @Check("4") FloatBuffer params); + + @StripPostfix("params") + @DeprecatedGL + void glGetLightiv(@GLenum int light, @GLenum int pname, @OutParameter @Check("4") IntBuffer params); + + @NoErrorCheck + int glGetError(); + + void glGetClipPlane(@GLenum int plane, @OutParameter @Check("4") DoubleBuffer equation); + + @StripPostfix("params") + void glGetBooleanv(@GLenum int pname, @OutParameter @Check("16") @GLboolean ByteBuffer params); + + @Alternate("glGetBooleanv") + @GLreturn("params") + @StripPostfix("params") + void glGetBooleanv2(@GLenum int pname, @OutParameter @GLboolean ByteBuffer params); + + @StripPostfix("params") + void glGetDoublev(@GLenum int pname, @OutParameter @Check("16") DoubleBuffer params); + + @Alternate("glGetDoublev") + @GLreturn("params") + @StripPostfix("params") + void glGetDoublev2(@GLenum int pname, @OutParameter DoubleBuffer params); + + @StripPostfix("params") + void glGetFloatv(@GLenum int pname, @OutParameter @Check("16") FloatBuffer params); + + @Alternate("glGetFloatv") + @GLreturn("params") + @StripPostfix("params") + void glGetFloatv2(@GLenum int pname, @OutParameter FloatBuffer params); + + @StripPostfix("params") + void glGetIntegerv(@GLenum int pname, @OutParameter @Check("16") IntBuffer params); + + @Alternate("glGetIntegerv") + @GLreturn("params") + @StripPostfix("params") + void glGetIntegerv2(@GLenum int pname, @OutParameter IntBuffer params); + + void glGenTextures(@AutoSize("textures") @GLsizei int n, @OutParameter @GLuint IntBuffer textures); + + @Alternate("glGenTextures") + @GLreturn("textures") + void glGenTextures2(@Constant("1") @GLsizei int n, @OutParameter @GLuint IntBuffer textures); + + @GLuint + @DeprecatedGL + int glGenLists(@GLsizei int range); + + @DeprecatedGL + void glFrustum(double left, double right, double bottom, double top, double zNear, double zFar); + + void glFrontFace(@GLenum int mode); + + @DeprecatedGL + void glFogf(@GLenum int pname, float param); + + @DeprecatedGL + void glFogi(@GLenum int pname, int param); + + @StripPostfix("params") + @DeprecatedGL + void glFogfv(@GLenum int pname, @Check("4") @Const FloatBuffer params); + + @StripPostfix("params") + @DeprecatedGL + void glFogiv(@GLenum int pname, @Check("4") @Const IntBuffer params); + + void glFlush(); + + void glFinish(); + + @StripPostfix("result") + void glGetPointerv(@GLenum int pname, @Result @GLvoid ByteBuffer result); + + boolean glIsEnabled(@GLenum int cap); + + void glInterleavedArrays(@GLenum int format, @GLsizei int stride, + @BufferObject(BufferKind.ArrayVBO) + @Check + @Const + @GLbyte + @GLshort + @GLint + @GLfloat + @GLdouble Buffer pointer); + + @DeprecatedGL + void glInitNames(); + + void glHint(@GLenum int target, @GLenum int mode); + + @StripPostfix("params") + void glGetTexParameterfv(@GLenum int target, @GLenum int pname, @OutParameter @Check("4") FloatBuffer params); + + @Alternate("glGetTexParameterfv") + @GLreturn("params") + @StripPostfix(value = "params", postfix = "v") + void glGetTexParameterfv2(@GLenum int target, @GLenum int pname, @OutParameter FloatBuffer params); + + @StripPostfix("params") + void glGetTexParameteriv(@GLenum int target, @GLenum int pname, @OutParameter @Check("4") IntBuffer params); + + @Alternate("glGetTexParameteriv") + @GLreturn("params") + @StripPostfix(value = "params", postfix = "v") + void glGetTexParameteriv2(@GLenum int target, @GLenum int pname, @OutParameter IntBuffer params); + + @StripPostfix("params") + void glGetTexLevelParameterfv(@GLenum int target, int level, @GLenum int pname, @OutParameter @Check("4") FloatBuffer params); + + @Alternate("glGetTexLevelParameterfv") + @GLreturn("params") + @StripPostfix(value = "params", postfix = "v") + void glGetTexLevelParameterfv2(@GLenum int target, int level, @GLenum int pname, @OutParameter FloatBuffer params); + + @StripPostfix("params") + void glGetTexLevelParameteriv(@GLenum int target, int level, @GLenum int pname, @OutParameter @Check("4") IntBuffer params); + + @Alternate("glGetTexLevelParameteriv") + @GLreturn("params") + @StripPostfix(value = "params", postfix = "v") + void glGetTexLevelParameteriv2(@GLenum int target, int level, @GLenum int pname, @OutParameter IntBuffer params); + + void glGetTexImage(@GLenum int target, int level, @GLenum int format, @GLenum int type, + @OutParameter + @BufferObject(BufferKind.PackPBO) + @Check("GLChecks.calculateImageStorage(pixels, format, type, 1, 1, 1)") + @GLbyte + @GLshort + @GLint + @GLfloat + @GLdouble Buffer pixels); + + @StripPostfix("params") + @DeprecatedGL + void glGetTexGeniv(@GLenum int coord, @GLenum int pname, @OutParameter @Check("4") IntBuffer params); + + @Alternate("glGetTexGeniv") + @GLreturn("params") + @StripPostfix(value = "params", postfix = "v") + @DeprecatedGL + void glGetTexGeniv2(@GLenum int coord, @GLenum int pname, @OutParameter IntBuffer params); + + @StripPostfix("params") + @DeprecatedGL + void glGetTexGenfv(@GLenum int coord, @GLenum int pname, @OutParameter @Check("4") FloatBuffer params); + + @Alternate("glGetTexGenfv") + @GLreturn("params") + @StripPostfix(value = "params", postfix = "v") + @DeprecatedGL + void glGetTexGenfv2(@GLenum int coord, @GLenum int pname, @OutParameter FloatBuffer params); + + @StripPostfix("params") + @DeprecatedGL + void glGetTexGendv(@GLenum int coord, @GLenum int pname, @OutParameter @Check("4") DoubleBuffer params); + + @Alternate("glGetTexGendv") + @GLreturn("params") + @StripPostfix(value = "params", postfix = "v") + @DeprecatedGL + void glGetTexGendv2(@GLenum int coord, @GLenum int pname, @OutParameter DoubleBuffer params); + + @StripPostfix("params") + void glGetTexEnviv(@GLenum int coord, @GLenum int pname, @OutParameter @Check("4") IntBuffer params); + + @Alternate("glGetTexEnviv") + @GLreturn("params") + @StripPostfix(value = "params", postfix = "v") + void glGetTexEnviv2(@GLenum int coord, @GLenum int pname, @OutParameter IntBuffer params); + + @StripPostfix("params") + void glGetTexEnvfv(@GLenum int coord, @GLenum int pname, @OutParameter @Check("4") FloatBuffer params); + + @Alternate("glGetTexEnvfv") + @GLreturn("params") + @StripPostfix(value = "params", postfix = "v") + void glGetTexEnvfv2(@GLenum int coord, @GLenum int pname, @OutParameter FloatBuffer params); + + @Const + String glGetString(int name); + + @DeprecatedGL + void glGetPolygonStipple(@OutParameter @BufferObject(BufferKind.PackPBO) @Check("1024") @GLubyte ByteBuffer mask); + + @DeprecatedGL + boolean glIsList(@GLuint int list); + + @DeprecatedGL + void glMaterialf(@GLenum int face, @GLenum int pname, float param); + + @DeprecatedGL + void glMateriali(@GLenum int face, @GLenum int pname, int param); + + @StripPostfix("params") + @DeprecatedGL + void glMaterialfv(@GLenum int face, @GLenum int pname, @Check("4") @Const FloatBuffer params); + + @StripPostfix("params") + @DeprecatedGL + void glMaterialiv(@GLenum int face, @GLenum int pname, @Check("4") @Const IntBuffer params); + + @DeprecatedGL + void glMapGrid1f(int un, float u1, float u2); + + @DeprecatedGL + void glMapGrid1d(int un, double u1, double u2); + + @DeprecatedGL + void glMapGrid2f(int un, float u1, float u2, int vn, float v1, float v2); + + @DeprecatedGL + void glMapGrid2d(int un, double u1, double u2, int vn, double v1, double v2); + + // TODO: check buffer size valid + + @DeprecatedGL + void glMap2f(@GLenum int target, float u1, float u2, int ustride, int uorder, float v1, float v2, int vstride, int vorder, @Check @Const FloatBuffer points); + + @DeprecatedGL + void glMap2d(@GLenum int target, double u1, double u2, int ustride, int uorder, double v1, double v2, int vstride, int vorder, @Check @Const DoubleBuffer points); + + // TODO: check buffer size valid + + @DeprecatedGL + void glMap1f(@GLenum int target, float u1, float u2, int stride, int order, @Check @Const FloatBuffer points); + + @DeprecatedGL + void glMap1d(@GLenum int target, double u1, double u2, int stride, int order, @Check @Const DoubleBuffer points); + + void glLogicOp(@GLenum int opcode); + + @DeprecatedGL + void glLoadName(@GLuint int name); + + @StripPostfix("m") + @DeprecatedGL + void glLoadMatrixf(@Check("16") @Const FloatBuffer m); + + @StripPostfix("m") + @DeprecatedGL + void glLoadMatrixd(@Check("16") @Const DoubleBuffer m); + + @DeprecatedGL + void glLoadIdentity(); + + @DeprecatedGL + void glListBase(@GLuint int base); + + void glLineWidth(float width); + + @DeprecatedGL + void glLineStipple(int factor, @GLushort short pattern); + + @DeprecatedGL + void glLightModelf(@GLenum int pname, float param); + + @DeprecatedGL + void glLightModeli(@GLenum int pname, int param); + + @StripPostfix("params") + @DeprecatedGL + void glLightModelfv(@GLenum int pname, @Check("4") @Const FloatBuffer params); + + @StripPostfix("params") + @DeprecatedGL + void glLightModeliv(@GLenum int pname, @Check("4") @Const IntBuffer params); + + @DeprecatedGL + void glLightf(@GLenum int light, @GLenum int pname, float param); + + @DeprecatedGL + void glLighti(@GLenum int light, @GLenum int pname, int param); + + @StripPostfix("params") + @DeprecatedGL + void glLightfv(@GLenum int light, @GLenum int pname, @Check("4") @Const FloatBuffer params); + + @StripPostfix("params") + @DeprecatedGL + void glLightiv(@GLenum int light, @GLenum int pname, @Check("4") @Const IntBuffer params); + + boolean glIsTexture(@GLuint int texture); + + @DeprecatedGL + void glMatrixMode(@GLenum int mode); + + @DeprecatedGL + void glPolygonStipple(@BufferObject(BufferKind.UnpackPBO) @Check("1024") @Const @GLubyte ByteBuffer mask); + + void glPolygonOffset(float factor, float units); + + void glPolygonMode(@GLenum int face, @GLenum int mode); + + void glPointSize(float size); + + @DeprecatedGL + void glPixelZoom(float xfactor, float yfactor); + + @DeprecatedGL + void glPixelTransferf(@GLenum int pname, float param); + + @DeprecatedGL + void glPixelTransferi(@GLenum int pname, int param); + + void glPixelStoref(@GLenum int pname, float param); + + void glPixelStorei(@GLenum int pname, int param); + + @StripPostfix("values") + @DeprecatedGL + void glPixelMapfv(@GLenum int map, @AutoSize("values") @GLsizei int mapsize, @BufferObject(BufferKind.UnpackPBO) @Const FloatBuffer values); + + @StripPostfix("values") + @DeprecatedGL + void glPixelMapuiv(@GLenum int map, @AutoSize("values") @GLsizei int mapsize, @BufferObject(BufferKind.UnpackPBO) @Const @GLuint IntBuffer values); + + @StripPostfix("values") + @DeprecatedGL + void glPixelMapusv(@GLenum int map, @AutoSize("values") @GLsizei int mapsize, @BufferObject(BufferKind.UnpackPBO) @Const @GLushort ShortBuffer values); + + @DeprecatedGL + void glPassThrough(float token); + + @DeprecatedGL + void glOrtho(double left, double right, double bottom, double top, double zNear, double zFar); + + @DeprecatedGL + void glNormalPointer(@AutoType("pointer") @GLenum int type, @GLsizei int stride, + @CachedReference + @BufferObject(BufferKind.ArrayVBO) + @Check + @Const + @GLint + @GLbyte + @GLfloat + @GLdouble Buffer pointer); + + @NoErrorCheck + @DeprecatedGL + void glNormal3b(byte nx, byte ny, byte nz); + + @NoErrorCheck + @DeprecatedGL + void glNormal3f(float nx, float ny, float nz); + + @NoErrorCheck + @DeprecatedGL + void glNormal3d(double nx, double ny, double nz); + + @NoErrorCheck + @DeprecatedGL + void glNormal3i(int nx, int ny, int nz); + + @DeprecatedGL + void glNewList(@GLuint int list, @GLenum int mode); + + @DeprecatedGL + void glEndList(); + + @StripPostfix("m") + @DeprecatedGL + void glMultMatrixf(@Check("16") @Const FloatBuffer m); + + @StripPostfix("m") + @DeprecatedGL + void glMultMatrixd(@Check("16") @Const DoubleBuffer m); + + void glShadeModel(@GLenum int mode); + + @DeprecatedGL + void glSelectBuffer(@AutoSize("buffer") @GLsizei int size, @GLuint IntBuffer buffer); + + void glScissor(int x, int y, @GLsizei int width, @GLsizei int height); + + @DeprecatedGL + void glScalef(float x, float y, float z); + + @DeprecatedGL + void glScaled(double x, double y, double z); + + @DeprecatedGL + void glRotatef(float angle, float x, float y, float z); + + @DeprecatedGL + int glRenderMode(@GLenum int mode); + + @DeprecatedGL + void glRectf(float x1, float y1, float x2, float y2); + + @DeprecatedGL + void glRectd(double x1, double y1, double x2, double y2); + + @DeprecatedGL + void glRecti(int x1, int y1, int x2, int y2); + + void glReadPixels(int x, int y, @GLsizei int width, @GLsizei int height, @GLenum int format, @GLenum int type, + @OutParameter + @BufferObject(BufferKind.PackPBO) + @Check("GLChecks.calculateImageStorage(pixels, format, type, width, height, 1)") + @GLbyte + @GLshort + @GLint + @GLfloat + @GLdouble Buffer pixels); + + void glReadBuffer(@GLenum int mode); + + @DeprecatedGL + void glRasterPos2f(float x, float y); + + @DeprecatedGL + void glRasterPos2d(double x, double y); + + @DeprecatedGL + void glRasterPos2i(int x, int y); + + @DeprecatedGL + void glRasterPos3f(float x, float y, float z); + + @DeprecatedGL + void glRasterPos3d(double x, double y, double z); + + @DeprecatedGL + void glRasterPos3i(int x, int y, int z); + + @DeprecatedGL + void glRasterPos4f(float x, float y, float z, float w); + + @DeprecatedGL + void glRasterPos4d(double x, double y, double z, double w); + + @DeprecatedGL + void glRasterPos4i(int x, int y, int z, int w); + + @DeprecatedGL + void glPushName(@GLuint int name); + + @DeprecatedGL + void glPopName(); + + @DeprecatedGL + void glPushMatrix(); + + @DeprecatedGL + void glPopMatrix(); + + @Code(" StateTracker.pushAttrib(caps, mask);") + @DeprecatedGL + void glPushClientAttrib(@GLbitfield int mask); + + @Code(" StateTracker.popAttrib(caps);") + @DeprecatedGL + void glPopClientAttrib(); + + @DeprecatedGL + void glPushAttrib(@GLbitfield int mask); + + @DeprecatedGL + void glPopAttrib(); + + void glStencilFunc(@GLenum int func, int ref, @GLuint int mask); + + @DeprecatedGL + void glVertexPointer(int size, @AutoType("pointer") @GLenum int type, @GLsizei int stride, + @CachedReference + @BufferObject(BufferKind.ArrayVBO) + @Check + @Const + @GLshort + @GLint + @GLfloat + @GLdouble Buffer pointer); + + @NoErrorCheck + @DeprecatedGL + void glVertex2f(float x, float y); + + @NoErrorCheck + @DeprecatedGL + void glVertex2d(double x, double y); + + @NoErrorCheck + @DeprecatedGL + void glVertex2i(int x, int y); + + @NoErrorCheck + @DeprecatedGL + void glVertex3f(float x, float y, float z); + + @NoErrorCheck + @DeprecatedGL + void glVertex3d(double x, double y, double z); + + @NoErrorCheck + @DeprecatedGL + void glVertex3i(int x, int y, int z); + + @NoErrorCheck + @DeprecatedGL + void glVertex4f(float x, float y, float z, float w); + + @NoErrorCheck + @DeprecatedGL + void glVertex4d(double x, double y, double z, double w); + + @NoErrorCheck + @DeprecatedGL + void glVertex4i(int x, int y, int z, int w); + + @DeprecatedGL + void glTranslatef(float x, float y, float z); + + @DeprecatedGL + void glTranslated(double x, double y, double z); + + void glTexImage1D(@GLenum int target, int level, int internalformat, @GLsizei int width, int border, @GLenum int format, @GLenum int type, + @BufferObject(BufferKind.UnpackPBO) + @Check(value = "GLChecks.calculateTexImage1DStorage(pixels, format, type, width)", canBeNull = true) + @Const + @GLbyte + @GLshort + @GLint + @GLfloat + @GLdouble Buffer pixels); + + void glTexImage2D(@GLenum int target, int level, int internalformat, int width, int height, int border, @GLenum int format, @GLenum int type, + @BufferObject(BufferKind.UnpackPBO) + @Check(value = "GLChecks.calculateTexImage2DStorage(pixels, format, type, width, height)", canBeNull = true) + @Const + @GLbyte + @GLshort + @GLint + @GLfloat + @GLdouble Buffer pixels); + + void glTexSubImage1D(@GLenum int target, int level, int xoffset, @GLsizei int width, @GLenum int format, @GLenum int type, + @BufferObject(BufferKind.UnpackPBO) + @Check("GLChecks.calculateImageStorage(pixels, format, type, width, 1, 1)") + @Const + @GLbyte + @GLshort + @GLint + @GLfloat + @GLdouble Buffer pixels); + + void glTexSubImage2D(@GLenum int target, int level, int xoffset, int yoffset, @GLsizei int width, @GLsizei int height, @GLenum int format, @GLenum int type, + @BufferObject(BufferKind.UnpackPBO) + @Check("GLChecks.calculateImageStorage(pixels, format, type, width, height, 1)") + @Const + @GLbyte + @GLshort + @GLint + @GLfloat + @GLdouble Buffer pixels); + + void glTexParameterf(@GLenum int target, @GLenum int pname, float param); + + void glTexParameteri(@GLenum int target, @GLenum int pname, int param); + + @StripPostfix("param") + void glTexParameterfv(@GLenum int target, @GLenum int pname, @Check("4") @Const FloatBuffer param); + + @StripPostfix("param") + void glTexParameteriv(@GLenum int target, @GLenum int pname, @Check("4") @Const IntBuffer param); + + @DeprecatedGL + void glTexGenf(@GLenum int coord, @GLenum int pname, float param); + + @DeprecatedGL + void glTexGend(@GLenum int coord, @GLenum int pname, double param); + + @StripPostfix("params") + @DeprecatedGL + void glTexGenfv(@GLenum int coord, @GLenum int pname, @Check("4") @Const FloatBuffer params); + + @StripPostfix("params") + @DeprecatedGL + void glTexGendv(@GLenum int coord, @GLenum int pname, @Check("4") @Const DoubleBuffer params); + + @DeprecatedGL + void glTexGeni(@GLenum int coord, @GLenum int pname, int param); + + @StripPostfix("params") + @DeprecatedGL + void glTexGeniv(@GLenum int coord, @GLenum int pname, @Check("4") @Const IntBuffer params); + + void glTexEnvf(@GLenum int target, @GLenum int pname, float param); + + void glTexEnvi(@GLenum int target, @GLenum int pname, int param); + + @StripPostfix("params") + void glTexEnvfv(@GLenum int target, @GLenum int pname, @Check("4") @Const FloatBuffer params); + + @StripPostfix("params") + void glTexEnviv(@GLenum int target, @GLenum int pname, @Check("4") @Const IntBuffer params); + + @DeprecatedGL + void glTexCoordPointer(int size, @AutoType("pointer") @GLenum int type, @GLsizei int stride, + @CachedReference(index = "GLChecks.getReferences(caps).glClientActiveTexture", name = "glTexCoordPointer_buffer") + @BufferObject(BufferKind.ArrayVBO) + @Check + @Const + @GLint + @GLshort + @GLfloat + @GLdouble Buffer pointer); + + @NoErrorCheck + @DeprecatedGL + void glTexCoord1f(float s); + + @NoErrorCheck + @DeprecatedGL + void glTexCoord1d(double s); + + @NoErrorCheck + @DeprecatedGL + void glTexCoord2f(float s, float t); + + @NoErrorCheck + @DeprecatedGL + void glTexCoord2d(double s, double t); + + @NoErrorCheck + @DeprecatedGL + void glTexCoord3f(float s, float t, float r); + + @NoErrorCheck + @DeprecatedGL + void glTexCoord3d(double s, double t, double r); + + @NoErrorCheck + @DeprecatedGL + void glTexCoord4f(float s, float t, float r, float q); + + @NoErrorCheck + @DeprecatedGL + void glTexCoord4d(double s, double t, double r, double q); + + void glStencilOp(@GLenum int fail, @GLenum int zfail, @GLenum int zpass); + + void glStencilMask(@GLuint int mask); + + void glViewport(int x, int y, @GLsizei int width, @GLsizei int height); +} diff --git a/src/templates/org/lwjgl/opengl/GL12.java b/src/templates/org/lwjgl/opengl/GL12.java new file mode 100644 index 0000000..55ac853 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/GL12.java @@ -0,0 +1,122 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +import java.nio.Buffer; + +/** + *

    + * The core OpenGL1.2.1 API, with the imaging subset. + * + * @author cix_foo + * @version $Revision: 2984 $ + * $Id: GL12.java 2984 2008-04-07 18:39:53Z matzon $ + */ + +public interface GL12 { + + int GL_TEXTURE_BINDING_3D = 0x806A; + int GL_PACK_SKIP_IMAGES = 0x806B; + int GL_PACK_IMAGE_HEIGHT = 0x806C; + int GL_UNPACK_SKIP_IMAGES = 0x806D; + int GL_UNPACK_IMAGE_HEIGHT = 0x806E; + int GL_TEXTURE_3D = 0x806F; + int GL_PROXY_TEXTURE_3D = 0x8070; + int GL_TEXTURE_DEPTH = 0x8071; + int GL_TEXTURE_WRAP_R = 0x8072; + int GL_MAX_3D_TEXTURE_SIZE = 0x8073; + int GL_BGR = 0x80E0; + int GL_BGRA = 0x80E1; + int GL_UNSIGNED_BYTE_3_3_2 = 0x8032; + int GL_UNSIGNED_BYTE_2_3_3_REV = 0x8362; + int GL_UNSIGNED_SHORT_5_6_5 = 0x8363; + int GL_UNSIGNED_SHORT_5_6_5_REV = 0x8364; + int GL_UNSIGNED_SHORT_4_4_4_4 = 0x8033; + int GL_UNSIGNED_SHORT_4_4_4_4_REV = 0x8365; + int GL_UNSIGNED_SHORT_5_5_5_1 = 0x8034; + int GL_UNSIGNED_SHORT_1_5_5_5_REV = 0x8366; + int GL_UNSIGNED_INT_8_8_8_8 = 0x8035; + int GL_UNSIGNED_INT_8_8_8_8_REV = 0x8367; + int GL_UNSIGNED_INT_10_10_10_2 = 0x8036; + int GL_UNSIGNED_INT_2_10_10_10_REV = 0x8368; + int GL_RESCALE_NORMAL = 0x803A; + int GL_LIGHT_MODEL_COLOR_CONTROL = 0x81F8; + int GL_SINGLE_COLOR = 0x81F9; + int GL_SEPARATE_SPECULAR_COLOR = 0x81FA; + int GL_CLAMP_TO_EDGE = 0x812F; + int GL_TEXTURE_MIN_LOD = 0x813A; + int GL_TEXTURE_MAX_LOD = 0x813B; + int GL_TEXTURE_BASE_LEVEL = 0x813C; + int GL_TEXTURE_MAX_LEVEL = 0x813D; + int GL_MAX_ELEMENTS_VERTICES = 0x80E8; + int GL_MAX_ELEMENTS_INDICES = 0x80E9; + int GL_ALIASED_POINT_SIZE_RANGE = 0x846D; + int GL_ALIASED_LINE_WIDTH_RANGE = 0x846E; + + int GL_SMOOTH_POINT_SIZE_RANGE = 0x0B12; + int GL_SMOOTH_POINT_SIZE_GRANULARITY = 0x0B13; + int GL_SMOOTH_LINE_WIDTH_RANGE = 0x0B22; + int GL_SMOOTH_LINE_WIDTH_GRANULARITY = 0x0B23; + + void glDrawRangeElements(@GLenum int mode, @GLuint int start, @GLuint int end, @AutoSize("indices") @GLsizei int count, + @AutoType("indices") + @GLenum int type, + @BufferObject(BufferKind.ElementVBO) + @Const + @GLubyte + @GLushort + @GLuint Buffer indices); + + void glTexImage3D(@GLenum int target, int level, int internalFormat, @GLsizei int width, @GLsizei int height, @GLsizei int depth, int border, @GLenum int format, @GLenum int type, + @BufferObject(BufferKind.UnpackPBO) + @Check(value = "GLChecks.calculateTexImage3DStorage(pixels, format, type, width, height, depth)", canBeNull = true) + @Const + @GLbyte + @GLshort + @GLint + @GLfloat + @GLdouble Buffer pixels); + + void glTexSubImage3D(@GLenum int target, int level, int xoffset, int yoffset, int zoffset, @GLsizei int width, @GLsizei int height, @GLsizei int depth, @GLenum int format, @GLenum int type, + @BufferObject(BufferKind.UnpackPBO) + @Check("GLChecks.calculateImageStorage(pixels, format, type, width, height, depth)") + @Const + @GLbyte + @GLshort + @GLint + @GLfloat + @GLdouble Buffer pixels); + + void glCopyTexSubImage3D(@GLenum int target, int level, int xoffset, int yoffset, int zoffset, int x, int y, @GLsizei int width, @GLsizei int height); +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/GL13.java b/src/templates/org/lwjgl/opengl/GL13.java new file mode 100644 index 0000000..a170f1b --- /dev/null +++ b/src/templates/org/lwjgl/opengl/GL13.java @@ -0,0 +1,257 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +import java.nio.*; + +/** + *

    + * The core OpenGL1.3 API. + * + * @author cix_foo + * @version $Revision: 3116 $ + * $Id: GL13.java 3116 2008-08-19 16:46:03Z spasi $ + */ +@DeprecatedGL +public interface GL13 { + int GL_TEXTURE0 = 0x84C0; + int GL_TEXTURE1 = 0x84C1; + int GL_TEXTURE2 = 0x84C2; + int GL_TEXTURE3 = 0x84C3; + int GL_TEXTURE4 = 0x84C4; + int GL_TEXTURE5 = 0x84C5; + int GL_TEXTURE6 = 0x84C6; + int GL_TEXTURE7 = 0x84C7; + int GL_TEXTURE8 = 0x84C8; + int GL_TEXTURE9 = 0x84C9; + int GL_TEXTURE10 = 0x84CA; + int GL_TEXTURE11 = 0x84CB; + int GL_TEXTURE12 = 0x84CC; + int GL_TEXTURE13 = 0x84CD; + int GL_TEXTURE14 = 0x84CE; + int GL_TEXTURE15 = 0x84CF; + int GL_TEXTURE16 = 0x84D0; + int GL_TEXTURE17 = 0x84D1; + int GL_TEXTURE18 = 0x84D2; + int GL_TEXTURE19 = 0x84D3; + int GL_TEXTURE20 = 0x84D4; + int GL_TEXTURE21 = 0x84D5; + int GL_TEXTURE22 = 0x84D6; + int GL_TEXTURE23 = 0x84D7; + int GL_TEXTURE24 = 0x84D8; + int GL_TEXTURE25 = 0x84D9; + int GL_TEXTURE26 = 0x84DA; + int GL_TEXTURE27 = 0x84DB; + int GL_TEXTURE28 = 0x84DC; + int GL_TEXTURE29 = 0x84DD; + int GL_TEXTURE30 = 0x84DE; + int GL_TEXTURE31 = 0x84DF; + int GL_ACTIVE_TEXTURE = 0x84E0; + int GL_CLIENT_ACTIVE_TEXTURE = 0x84E1; + int GL_MAX_TEXTURE_UNITS = 0x84E2; + + int GL_NORMAL_MAP = 0x8511; + int GL_REFLECTION_MAP = 0x8512; + int GL_TEXTURE_CUBE_MAP = 0x8513; + int GL_TEXTURE_BINDING_CUBE_MAP = 0x8514; + int GL_TEXTURE_CUBE_MAP_POSITIVE_X = 0x8515; + int GL_TEXTURE_CUBE_MAP_NEGATIVE_X = 0x8516; + int GL_TEXTURE_CUBE_MAP_POSITIVE_Y = 0x8517; + int GL_TEXTURE_CUBE_MAP_NEGATIVE_Y = 0x8518; + int GL_TEXTURE_CUBE_MAP_POSITIVE_Z = 0x8519; + int GL_TEXTURE_CUBE_MAP_NEGATIVE_Z = 0x851A; + int GL_PROXY_TEXTURE_CUBE_MAP = 0x851B; + int GL_MAX_CUBE_MAP_TEXTURE_SIZE = 0x851C; + + int GL_COMPRESSED_ALPHA = 0x84E9; + int GL_COMPRESSED_LUMINANCE = 0x84EA; + int GL_COMPRESSED_LUMINANCE_ALPHA = 0x84EB; + int GL_COMPRESSED_INTENSITY = 0x84EC; + int GL_COMPRESSED_RGB = 0x84ED; + int GL_COMPRESSED_RGBA = 0x84EE; + int GL_TEXTURE_COMPRESSION_HINT = 0x84EF; + int GL_TEXTURE_COMPRESSED_IMAGE_SIZE = 0x86A0; + int GL_TEXTURE_COMPRESSED = 0x86A1; + int GL_NUM_COMPRESSED_TEXTURE_FORMATS = 0x86A2; + int GL_COMPRESSED_TEXTURE_FORMATS = 0x86A3; + + int GL_MULTISAMPLE = 0x809D; + int GL_SAMPLE_ALPHA_TO_COVERAGE = 0x809E; + int GL_SAMPLE_ALPHA_TO_ONE = 0x809F; + int GL_SAMPLE_COVERAGE = 0x80A0; + int GL_SAMPLE_BUFFERS = 0x80A8; + int GL_SAMPLES = 0x80A9; + int GL_SAMPLE_COVERAGE_VALUE = 0x80AA; + int GL_SAMPLE_COVERAGE_INVERT = 0x80AB; + int GL_MULTISAMPLE_BIT = 0x20000000; + + int GL_TRANSPOSE_MODELVIEW_MATRIX = 0x84E3; + int GL_TRANSPOSE_PROJECTION_MATRIX = 0x84E4; + int GL_TRANSPOSE_TEXTURE_MATRIX = 0x84E5; + int GL_TRANSPOSE_COLOR_MATRIX = 0x84E6; + + int GL_COMBINE = 0x8570; + int GL_COMBINE_RGB = 0x8571; + int GL_COMBINE_ALPHA = 0x8572; + int GL_SOURCE0_RGB = 0x8580; + int GL_SOURCE1_RGB = 0x8581; + int GL_SOURCE2_RGB = 0x8582; + int GL_SOURCE0_ALPHA = 0x8588; + int GL_SOURCE1_ALPHA = 0x8589; + int GL_SOURCE2_ALPHA = 0x858A; + int GL_OPERAND0_RGB = 0x8590; + int GL_OPERAND1_RGB = 0x8591; + int GL_OPERAND2_RGB = 0x8592; + int GL_OPERAND0_ALPHA = 0x8598; + int GL_OPERAND1_ALPHA = 0x8599; + int GL_OPERAND2_ALPHA = 0x859A; + int GL_RGB_SCALE = 0x8573; + int GL_ADD_SIGNED = 0x8574; + int GL_INTERPOLATE = 0x8575; + int GL_SUBTRACT = 0x84E7; + int GL_CONSTANT = 0x8576; + int GL_PRIMARY_COLOR = 0x8577; + int GL_PREVIOUS = 0x8578; + int GL_DOT3_RGB = 0x86AE; + int GL_DOT3_RGBA = 0x86AF; + int GL_CLAMP_TO_BORDER = 0x812D; + + void glActiveTexture(@GLenum int texture); + + @Code("\t\tGLChecks.getReferences(caps).glClientActiveTexture = texture - GL_TEXTURE0;") + @DeprecatedGL + void glClientActiveTexture(@GLenum int texture); + + void glCompressedTexImage1D(@GLenum int target, int level, @GLenum int internalformat, @GLsizei int width, int border, @AutoSize("data") @GLsizei int imageSize, + @BufferObject(BufferKind.UnpackPBO) + @Check + @Const + @GLvoid + Buffer data); + + void glCompressedTexImage2D(@GLenum int target, int level, @GLenum int internalformat, @GLsizei int width, @GLsizei int height, int border, @AutoSize("data") @GLsizei int imageSize, + @BufferObject(BufferKind.UnpackPBO) + @Check + @Const + @GLvoid + ByteBuffer data); + + void glCompressedTexImage3D(@GLenum int target, int level, @GLenum int internalformat, @GLsizei int width, @GLsizei int height, @GLsizei int depth, int border, @AutoSize("data") @GLsizei int imageSize, + @BufferObject(BufferKind.UnpackPBO) + @Check + @Const + @GLvoid + ByteBuffer data); + + void glCompressedTexSubImage1D(@GLenum int target, int level, int xoffset, @GLsizei int width, @GLenum int format, @AutoSize("data") @GLsizei int imageSize, + @BufferObject(BufferKind.UnpackPBO) + @Check + @Const + @GLvoid + ByteBuffer data); + + void glCompressedTexSubImage2D(@GLenum int target, int level, int xoffset, int yoffset, @GLsizei int width, @GLsizei int height, @GLenum int format, @AutoSize("data") @GLsizei int imageSize, + @BufferObject(BufferKind.UnpackPBO) + @Check + @Const + @GLvoid + ByteBuffer data); + + void glCompressedTexSubImage3D(@GLenum int target, int level, int xoffset, int yoffset, int zoffset, @GLsizei int width, @GLsizei int height, @GLsizei int depth, @GLenum int format, @AutoSize("data") @GLsizei int imageSize, + @BufferObject(BufferKind.UnpackPBO) + @Check + @Const + @GLvoid + ByteBuffer data); + + // TODO: check buffer size valid + void glGetCompressedTexImage(@GLenum int target, int lod, + @OutParameter + @BufferObject(BufferKind.PackPBO) + @Check + @GLbyte + @GLshort + @GLint Buffer img); + + @NoErrorCheck + @DeprecatedGL + void glMultiTexCoord1f(@GLenum int target, float s); + + @NoErrorCheck + @DeprecatedGL + void glMultiTexCoord1d(@GLenum int target, double s); + + @NoErrorCheck + @DeprecatedGL + void glMultiTexCoord2f(@GLenum int target, float s, float t); + + @NoErrorCheck + @DeprecatedGL + void glMultiTexCoord2d(@GLenum int target, double s, double t); + + @NoErrorCheck + @DeprecatedGL + void glMultiTexCoord3f(@GLenum int target, float s, float t, float r); + + @NoErrorCheck + @DeprecatedGL + void glMultiTexCoord3d(@GLenum int target, double s, double t, double r); + + @NoErrorCheck + @DeprecatedGL + void glMultiTexCoord4f(@GLenum int target, float s, float t, float r, float q); + + @NoErrorCheck + @DeprecatedGL + void glMultiTexCoord4d(@GLenum int target, double s, double t, double r, double q); + + @StripPostfix("m") + @DeprecatedGL + void glLoadTransposeMatrixf(@Check("16") @Const FloatBuffer m); + + @StripPostfix("m") + @DeprecatedGL + void glLoadTransposeMatrixd(@Check("16") @Const DoubleBuffer m); + + @StripPostfix("m") + @DeprecatedGL + void glMultTransposeMatrixf(@Check("16") @Const FloatBuffer m); + + @StripPostfix("m") + @DeprecatedGL + void glMultTransposeMatrixd(@Check("16") @Const DoubleBuffer m); + + void glSampleCoverage(@GLclampf float value, boolean invert); +} + diff --git a/src/templates/org/lwjgl/opengl/GL14.java b/src/templates/org/lwjgl/opengl/GL14.java new file mode 100644 index 0000000..1c1997a --- /dev/null +++ b/src/templates/org/lwjgl/opengl/GL14.java @@ -0,0 +1,172 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +import java.nio.*; + +/** + *

    + * The core OpenGL1.4 API. + * + * @author cix_foo + * @version $Revision: 3287 $ + * $Id: GL14.java 3287 2010-03-14 23:24:40Z spasi $ + */ +@DeprecatedGL +public interface GL14 { + int GL_GENERATE_MIPMAP = 0x8191; + int GL_GENERATE_MIPMAP_HINT = 0x8192; + int GL_DEPTH_COMPONENT16 = 0x81A5; + int GL_DEPTH_COMPONENT24 = 0x81A6; + int GL_DEPTH_COMPONENT32 = 0x81A7; + int GL_TEXTURE_DEPTH_SIZE = 0x884A; + int GL_DEPTH_TEXTURE_MODE = 0x884B; + int GL_TEXTURE_COMPARE_MODE = 0x884C; + int GL_TEXTURE_COMPARE_FUNC = 0x884D; + int GL_COMPARE_R_TO_TEXTURE = 0x884E; + int GL_FOG_COORDINATE_SOURCE = 0x8450; + int GL_FOG_COORDINATE = 0x8451; + int GL_FRAGMENT_DEPTH = 0x8452; + int GL_CURRENT_FOG_COORDINATE = 0x8453; + int GL_FOG_COORDINATE_ARRAY_TYPE = 0x8454; + int GL_FOG_COORDINATE_ARRAY_STRIDE = 0x8455; + int GL_FOG_COORDINATE_ARRAY_POINTER = 0x8456; + int GL_FOG_COORDINATE_ARRAY = 0x8457; + int GL_POINT_SIZE_MIN = 0x8126; + int GL_POINT_SIZE_MAX = 0x8127; + int GL_POINT_FADE_THRESHOLD_SIZE = 0x8128; + int GL_POINT_DISTANCE_ATTENUATION = 0x8129; + int GL_COLOR_SUM = 0x8458; + int GL_CURRENT_SECONDARY_COLOR = 0x8459; + int GL_SECONDARY_COLOR_ARRAY_SIZE = 0x845A; + int GL_SECONDARY_COLOR_ARRAY_TYPE = 0x845B; + int GL_SECONDARY_COLOR_ARRAY_STRIDE = 0x845C; + int GL_SECONDARY_COLOR_ARRAY_POINTER = 0x845D; + int GL_SECONDARY_COLOR_ARRAY = 0x845E; + int GL_BLEND_DST_RGB = 0x80C8; + int GL_BLEND_SRC_RGB = 0x80C9; + int GL_BLEND_DST_ALPHA = 0x80CA; + int GL_BLEND_SRC_ALPHA = 0x80CB; + int GL_INCR_WRAP = 0x8507; + int GL_DECR_WRAP = 0x8508; + int GL_TEXTURE_FILTER_CONTROL = 0x8500; + int GL_TEXTURE_LOD_BIAS = 0x8501; + int GL_MAX_TEXTURE_LOD_BIAS = 0x84FD; + int GL_MIRRORED_REPEAT = 0x8370; + + int GL_BLEND_COLOR = 0x8005; + int GL_BLEND_EQUATION = 0x8009; + + int GL_FUNC_ADD = 0x8006; + int GL_FUNC_SUBTRACT = 0x800A; + int GL_FUNC_REVERSE_SUBTRACT = 0x800B; + int GL_MIN = 0x8007; + int GL_MAX = 0x8008; + + void glBlendEquation(@GLenum int mode); + + void glBlendColor(@GLclampf float red, @GLclampf float green, @GLclampf float blue, @GLclampf float alpha); + + @DeprecatedGL + void glFogCoordf(float coord); + + @DeprecatedGL + void glFogCoordd(double coord); + + @DeprecatedGL + void glFogCoordPointer(@AutoType("data") @GLenum int type, @GLsizei int stride, + @CachedReference + @BufferObject(BufferKind.ArrayVBO) + @Check + @Const + @GLfloat + @GLdouble Buffer data); + + void glMultiDrawArrays(@GLenum int mode, IntBuffer piFirst, @Check("piFirst.remaining()") @GLsizei IntBuffer piCount, @AutoSize("piFirst") @GLsizei int primcount); + + //void glMultiDrawElements(int mode, int piCount, int type, int pIndices, int primcount); + + void glPointParameteri(@GLenum int pname, int param); + + void glPointParameterf(@GLenum int pname, float param); + + @StripPostfix("params") + void glPointParameteriv(@GLenum int pname, @Check("4") @Const IntBuffer params); + + @StripPostfix("params") + void glPointParameterfv(@GLenum int pname, @Check("4") @Const FloatBuffer params); + + @DeprecatedGL + void glSecondaryColor3b(byte red, byte green, byte blue); + + @DeprecatedGL + void glSecondaryColor3f(float red, float green, float blue); + + @DeprecatedGL + void glSecondaryColor3d(double red, double green, double blue); + + @DeprecatedGL + void glSecondaryColor3ub(@GLubyte byte red, @GLubyte byte green, @GLubyte byte blue); + + @DeprecatedGL + void glSecondaryColorPointer(int size, @AutoType("data") @GLenum int type, @GLsizei int stride, + @BufferObject(BufferKind.ArrayVBO) + @Check + @Const + @GLbyte + @GLubyte + @GLfloat + @GLdouble Buffer data); + + void glBlendFuncSeparate(@GLenum int sfactorRGB, @GLenum int dfactorRGB, @GLenum int sfactorAlpha, @GLenum int dfactorAlpha); + + @DeprecatedGL + void glWindowPos2f(float x, float y); + + @DeprecatedGL + void glWindowPos2d(double x, double y); + + @DeprecatedGL + void glWindowPos2i(int x, int y); + + @DeprecatedGL + void glWindowPos3f(float x, float y, float z); + + @DeprecatedGL + void glWindowPos3d(double x, double y, double z); + + @DeprecatedGL + void glWindowPos3i(int x, int y, int z); +} + diff --git a/src/templates/org/lwjgl/opengl/GL15.java b/src/templates/org/lwjgl/opengl/GL15.java new file mode 100644 index 0000000..1756093 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/GL15.java @@ -0,0 +1,237 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +import java.nio.Buffer; +import java.nio.ByteBuffer; +import java.nio.IntBuffer; + +public interface GL15 { + // ---------------------------------------------------------------------- + // ---------------------- ARB_vertex_buffer_object ---------------------- + // ---------------------------------------------------------------------- + + int GL_ARRAY_BUFFER = 0x8892; + int GL_ELEMENT_ARRAY_BUFFER = 0x8893; + int GL_ARRAY_BUFFER_BINDING = 0x8894; + int GL_ELEMENT_ARRAY_BUFFER_BINDING = 0x8895; + int GL_VERTEX_ARRAY_BUFFER_BINDING = 0x8896; + int GL_NORMAL_ARRAY_BUFFER_BINDING = 0x8897; + int GL_COLOR_ARRAY_BUFFER_BINDING = 0x8898; + int GL_INDEX_ARRAY_BUFFER_BINDING = 0x8899; + int GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING = 0x889A; + int GL_EDGE_FLAG_ARRAY_BUFFER_BINDING = 0x889B; + int GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING = 0x889C; + int GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING = 0x889D; + int GL_WEIGHT_ARRAY_BUFFER_BINDING = 0x889E; + int GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING = 0x889F; + int GL_STREAM_DRAW = 0x88E0; + int GL_STREAM_READ = 0x88E1; + int GL_STREAM_COPY = 0x88E2; + int GL_STATIC_DRAW = 0x88E4; + int GL_STATIC_READ = 0x88E5; + int GL_STATIC_COPY = 0x88E6; + int GL_DYNAMIC_DRAW = 0x88E8; + int GL_DYNAMIC_READ = 0x88E9; + int GL_DYNAMIC_COPY = 0x88EA; + int GL_READ_ONLY = 0x88B8; + int GL_WRITE_ONLY = 0x88B9; + int GL_READ_WRITE = 0x88BA; + int GL_BUFFER_SIZE = 0x8764; + int GL_BUFFER_USAGE = 0x8765; + int GL_BUFFER_ACCESS = 0x88BB; + int GL_BUFFER_MAPPED = 0x88BC; + int GL_BUFFER_MAP_POINTER = 0x88BD; + + int FOG_COORD_SRC = GL14.GL_FOG_COORDINATE_SOURCE; + int GL_FOG_COORD = GL14.GL_FOG_COORDINATE; + int GL_CURRENT_FOG_COORD = GL14.GL_CURRENT_FOG_COORDINATE; + int GL_FOG_COORD_ARRAY_TYPE = GL14.GL_FOG_COORDINATE_ARRAY_TYPE; + int GL_FOG_COORD_ARRAY_STRIDE = GL14.GL_FOG_COORDINATE_ARRAY_STRIDE; + int GL_FOG_COORD_ARRAY_POINTER = GL14.GL_FOG_COORDINATE_ARRAY_POINTER; + int GL_FOG_COORD_ARRAY = GL14.GL_FOG_COORDINATE_ARRAY; + int GL_FOG_COORD_ARRAY_BUFFER_BINDING = GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING; + int GL_SRC0_RGB = GL13.GL_SOURCE0_RGB; + int GL_SRC1_RGB = GL13.GL_SOURCE1_RGB; + int GL_SRC2_RGB = GL13.GL_SOURCE2_RGB; + int GL_SRC0_ALPHA = GL13.GL_SOURCE0_ALPHA; + int GL_SRC1_ALPHA = GL13.GL_SOURCE1_ALPHA; + int GL_SRC2_ALPHA = GL13.GL_SOURCE2_ALPHA; + + @Code(" StateTracker.bindBuffer(caps, target, buffer);") + void glBindBuffer(@GLenum int target, @GLuint int buffer); + + void glDeleteBuffers(@AutoSize("buffers") @GLsizei int n, @Const @GLuint IntBuffer buffers); + + @Alternate("glDeleteBuffers") + void glDeleteBuffers(@Constant("1") @GLsizei int n, @Constant(value = "APIUtils.getBufferInt().put(0, buffer), 0", keepParam = true) int buffer); + + void glGenBuffers(@AutoSize("buffers") @GLsizei int n, @OutParameter @GLuint IntBuffer buffers); + + @Alternate("glGenBuffers") + @GLreturn("buffers") + void glGenBuffers2(@Constant("1") @GLsizei int n, @OutParameter @GLuint IntBuffer buffers); + + boolean glIsBuffer(@GLuint int buffer); + + @GenerateAutos + void glBufferData(@GLenum int target, @AutoSize("data") @GLsizeiptr long size, + @Const + @GLbyte + @GLshort + @GLint + @GLfloat + @GLdouble Buffer data, @GLenum int usage); + + void glBufferSubData(@GLenum int target, @GLintptr long offset, @AutoSize("data") @GLsizeiptr long size, + @Check + @Const + @GLbyte + @GLshort + @GLint + @GLfloat + @GLdouble Buffer data); + + void glGetBufferSubData(@GLenum int target, @GLintptr long offset, @AutoSize("data") @GLsizeiptr long size, + @OutParameter + @Check + @GLbyte + @GLshort + @GLint + @GLfloat + @GLdouble Buffer data); + + /** + * glMapBuffer maps a GL buffer object to a ByteBuffer. The old_buffer argument can be null, + * in which case a new ByteBuffer will be created, pointing to the returned memory. If old_buffer is non-null, + * it will be returned if it points to the same mapped memory and has the same capacity as the buffer object, + * otherwise a new ByteBuffer is created. That way, an application will normally use glMapBuffer like this: + *

    + * ByteBuffer mapped_buffer; mapped_buffer = glMapBuffer(..., ..., null); ... // Another map on the same buffer mapped_buffer = glMapBuffer(..., ..., mapped_buffer); + *

    + * Only ByteBuffers returned from this method are to be passed as the old_buffer argument. User-created ByteBuffers cannot be reused. + *

    + * The version of this method without an explicit length argument calls glGetBufferParameter internally to + * retrieve the current buffer object size, which may cause a pipeline flush and reduce application performance. + *

    + * The version of this method with an explicit length argument is a fast alternative to the one without. No GL call + * is made to retrieve the buffer object size, so the user is responsible for tracking and using the appropriate length.
    + * Security warning: The length argument should match the buffer object size. Reading from or writing to outside + * the memory region that corresponds to the mapped buffer object will cause native crashes. + * + * @param old_buffer A ByteBuffer. If this argument points to the same address and has the same capacity as the new mapping, it will be returned and no new buffer will be created. + * + * @return A ByteBuffer representing the mapped buffer memory. + */ + @CachedResult + @GLvoid + @AutoResultSize("GLChecks.getBufferObjectSize(caps, target)") + ByteBuffer glMapBuffer(@GLenum int target, @GLenum int access); + + boolean glUnmapBuffer(@GLenum int target); + + @StripPostfix("params") + void glGetBufferParameteriv(@GLenum int target, @GLenum int pname, @OutParameter @Check("4") IntBuffer params); + + @Alternate("glGetBufferParameteriv") + @GLreturn("params") + @StripPostfix("params") + void glGetBufferParameteriv2(@GLenum int target, @GLenum int pname, @OutParameter IntBuffer params); + + @StripPostfix("pointer") + @AutoResultSize("GLChecks.getBufferObjectSize(caps, target)") + void glGetBufferPointerv(@GLenum int target, @GLenum int pname, @OutParameter @Result @GLvoid ByteBuffer pointer); + + // ----------------------------------------------------------------- + // ---------------------- ARB_occlusion_query ---------------------- + // ----------------------------------------------------------------- + + /** + * Accepted by the <target> parameter of BeginQuery, EndQuery, + * and GetQueryiv: + */ + int GL_SAMPLES_PASSED = 0x8914; + + /** Accepted by the <pname> parameter of GetQueryiv: */ + int GL_QUERY_COUNTER_BITS = 0x8864; + int GL_CURRENT_QUERY = 0x8865; + + /** + * Accepted by the <pname> parameter of GetQueryObjectiv and + * GetQueryObjectuiv: + */ + int GL_QUERY_RESULT = 0x8866; + int GL_QUERY_RESULT_AVAILABLE = 0x8867; + + void glGenQueries(@AutoSize("ids") @GLsizei int n, @OutParameter @GLuint IntBuffer ids); + + @Alternate("glGenQueries") + @GLreturn("ids") + void glGenQueries2(@Constant("1") @GLsizei int n, @OutParameter @GLuint IntBuffer ids); + + void glDeleteQueries(@AutoSize("ids") @GLsizei int n, @GLuint IntBuffer ids); + + @Alternate("glDeleteQueries") + void glDeleteQueries(@Constant("1") @GLsizei int n, @Constant(value = "APIUtils.getBufferInt().put(0, id), 0", keepParam = true) int id); + + boolean glIsQuery(@GLuint int id); + + void glBeginQuery(@GLenum int target, @GLuint int id); + + void glEndQuery(@GLenum int target); + + @StripPostfix("params") + void glGetQueryiv(@GLenum int target, @GLenum int pname, @OutParameter @Check("1") IntBuffer params); + + @Alternate("glGetQueryiv") + @GLreturn("params") + @StripPostfix("params") + void glGetQueryiv2(@GLenum int target, @GLenum int pname, @OutParameter IntBuffer params); + + @StripPostfix("params") + void glGetQueryObjectiv(@GLenum int id, @GLenum int pname, @OutParameter @Check("1") @GLint IntBuffer params); + + @Alternate("glGetQueryObjectiv") + @GLreturn("params") + @StripPostfix(value = "params", postfix = "v") + void glGetQueryObjectiv2(@GLenum int id, @GLenum int pname, @OutParameter @GLint IntBuffer params); + + @StripPostfix("params") + void glGetQueryObjectuiv(@GLenum int id, @GLenum int pname, @OutParameter @Check("1") @GLuint IntBuffer params); + + @Alternate("glGetQueryObjectuiv") + @GLreturn("params") + @StripPostfix(value = "params", postfix = "v") + void glGetQueryObjectuiv2(@GLenum int id, @GLenum int pname, @OutParameter @GLuint IntBuffer params); +} diff --git a/src/templates/org/lwjgl/opengl/GL20.java b/src/templates/org/lwjgl/opengl/GL20.java new file mode 100644 index 0000000..c53bc32 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/GL20.java @@ -0,0 +1,567 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +import java.nio.*; + +public interface GL20 { + // ------------------------------------------------------------------ + // -------------------[ ARB_shading_language_100 ]------------------- + // ------------------------------------------------------------------ + + /** Accepted by the <name> parameter of GetString: */ + int GL_SHADING_LANGUAGE_VERSION = 0x8B8C; + + // ------------------------------------------------------------------ + // ----------------------[ ARB_shader_objects ]---------------------- + // ------------------------------------------------------------------ + + /** Accepted by the <pname> argument of GetInteger: */ + int GL_CURRENT_PROGRAM = 0x8B8D; + + /** Accepted by the <pname> parameter of GetObjectParameter{fi}vARB: */ + int GL_SHADER_TYPE = 0x8B4F; + int GL_DELETE_STATUS = 0x8B80; + int GL_COMPILE_STATUS = 0x8B81; + int GL_LINK_STATUS = 0x8B82; + int GL_VALIDATE_STATUS = 0x8B83; + int GL_INFO_LOG_LENGTH = 0x8B84; + int GL_ATTACHED_SHADERS = 0x8B85; + int GL_ACTIVE_UNIFORMS = 0x8B86; + int GL_ACTIVE_UNIFORM_MAX_LENGTH = 0x8B87; + int GL_ACTIVE_ATTRIBUTES = 0x8B89; + int GL_ACTIVE_ATTRIBUTE_MAX_LENGTH = 0x8B8A; + int GL_SHADER_SOURCE_LENGTH = 0x8B88; + + /** Returned by the <params> parameter of GetObjectParameter{fi}vARB: */ + int GL_SHADER_OBJECT = 0x8B48; + + /** Returned by the <type> parameter of GetActiveUniformARB: */ + int GL_FLOAT_VEC2 = 0x8B50; + int GL_FLOAT_VEC3 = 0x8B51; + int GL_FLOAT_VEC4 = 0x8B52; + int GL_INT_VEC2 = 0x8B53; + int GL_INT_VEC3 = 0x8B54; + int GL_INT_VEC4 = 0x8B55; + int GL_BOOL = 0x8B56; + int GL_BOOL_VEC2 = 0x8B57; + int GL_BOOL_VEC3 = 0x8B58; + int GL_BOOL_VEC4 = 0x8B59; + int GL_FLOAT_MAT2 = 0x8B5A; + int GL_FLOAT_MAT3 = 0x8B5B; + int GL_FLOAT_MAT4 = 0x8B5C; + int GL_SAMPLER_1D = 0x8B5D; + int GL_SAMPLER_2D = 0x8B5E; + int GL_SAMPLER_3D = 0x8B5F; + int GL_SAMPLER_CUBE = 0x8B60; + int GL_SAMPLER_1D_SHADOW = 0x8B61; + int GL_SAMPLER_2D_SHADOW = 0x8B62; + + /** + * The ARB_shader_objects extension allows multiple, optionally null-terminated, source strings to define a shader program. + *

    + * This method uses just a single string, that should NOT be null-terminated. + * + * @param shader + * @param string + */ + void glShaderSource(@GLuint int shader, @Constant("1") @GLsizei int count, + @Indirect @Const @GLchar @Check ByteBuffer string, + @AutoSize("string") @Indirect @Const @GLint int length); + + @Alternate("glShaderSource") + void glShaderSource2(@GLuint int shader, @Constant("1") @GLsizei int count, CharSequence string, @Constant("string.length()") @Indirect @Const int length); + + @Alternate(value = "glShaderSource", nativeAlt = true) + void glShaderSource3(@GLuint int shader, @Constant("strings.length") @GLsizei int count, + @Const @StringList(value = "count", lengths = "length") CharSequence[] strings, + @Constant("APIUtils.getLengths(strings), 0") @Const IntBuffer length); + + int glCreateShader(@GLuint int type); + + boolean glIsShader(@GLuint int shader); + + void glCompileShader(@GLuint int shader); + + void glDeleteShader(@GLuint int shader); + + int glCreateProgram(); + + boolean glIsProgram(int program); + + void glAttachShader(@GLuint int program, @GLuint int shader); + + void glDetachShader(@GLuint int program, @GLuint int shader); + + void glLinkProgram(@GLuint int program); + + void glUseProgram(@GLuint int program); + + void glValidateProgram(@GLuint int program); + + void glDeleteProgram(@GLuint int program); + + void glUniform1f(int location, float v0); + + void glUniform2f(int location, float v0, float v1); + + void glUniform3f(int location, float v0, float v1, float v2); + + void glUniform4f(int location, float v0, float v1, float v2, float v3); + + void glUniform1i(int location, int v0); + + void glUniform2i(int location, int v0, int v1); + + void glUniform3i(int location, int v0, int v1, int v2); + + void glUniform4i(int location, int v0, int v1, int v2, int v3); + + @StripPostfix("values") + void glUniform1fv(int location, @AutoSize("values") @GLsizei int count, @Const FloatBuffer values); + + @StripPostfix("values") + void glUniform2fv(int location, @AutoSize(value = "values", expression = " >> 1") @GLsizei int count, @Const FloatBuffer values); + + @StripPostfix("values") + void glUniform3fv(int location, @AutoSize(value = "values", expression = " / 3") @GLsizei int count, @Const FloatBuffer values); + + @StripPostfix("values") + void glUniform4fv(int location, @AutoSize(value = "values", expression = " >> 2") @GLsizei int count, @Const FloatBuffer values); + + @StripPostfix("values") + void glUniform1iv(int location, @AutoSize("values") @GLsizei int count, @Const IntBuffer values); + + @StripPostfix("values") + void glUniform2iv(int location, @AutoSize(value = "values", expression = " >> 1") @GLsizei int count, @Const IntBuffer values); + + @StripPostfix("values") + void glUniform3iv(int location, @AutoSize(value = "values", expression = " / 3") @GLsizei int count, @Const IntBuffer values); + + @StripPostfix("values") + void glUniform4iv(int location, @AutoSize(value = "values", expression = " >> 2") @GLsizei int count, @Const IntBuffer values); + + @StripPostfix("matrices") + void glUniformMatrix2fv(int location, @AutoSize(value = "matrices", expression = " >> 2") @GLsizei int count, + boolean transpose, @Const FloatBuffer matrices); + + @StripPostfix("matrices") + void glUniformMatrix3fv(int location, @AutoSize(value = "matrices", expression = " / (3 * 3)") @GLsizei int count, + boolean transpose, @Const FloatBuffer matrices); + + @StripPostfix("matrices") + void glUniformMatrix4fv(int location, @AutoSize(value = "matrices", expression = " >> 4") @GLsizei int count, + boolean transpose, @Const FloatBuffer matrices); + + @StripPostfix("params") + void glGetShaderiv(@GLuint int shader, @GLenum int pname, @OutParameter @Check IntBuffer params); + + @Alternate("glGetShaderiv") + @GLreturn("params") + @StripPostfix("params") + void glGetShaderiv2(@GLuint int shader, @GLenum int pname, @OutParameter IntBuffer params); + + @StripPostfix("params") + void glGetProgramiv(@GLuint int program, @GLenum int pname, @OutParameter @Check IntBuffer params); + + @Alternate("glGetProgramiv") + @GLreturn("params") + @StripPostfix("params") + void glGetProgramiv2(@GLuint int program, @GLenum int pname, @OutParameter IntBuffer params); + + void glGetShaderInfoLog(@GLuint int shader, @AutoSize("infoLog") @GLsizei int maxLength, + @OutParameter @GLsizei @Check(value = "1", canBeNull = true) IntBuffer length, + @OutParameter @GLchar ByteBuffer infoLog); + + @Alternate("glGetShaderInfoLog") + @GLreturn(value = "infoLog", maxLength = "maxLength") + void glGetShaderInfoLog2(@GLuint int shader, @GLsizei int maxLength, + @OutParameter @GLsizei @Constant("infoLog_length, 0") IntBuffer length, + @OutParameter @GLchar ByteBuffer infoLog); + + void glGetProgramInfoLog(@GLuint int program, @AutoSize("infoLog") @GLsizei int maxLength, + @OutParameter @GLsizei @Check(value = "1", canBeNull = true) IntBuffer length, + @OutParameter @GLchar ByteBuffer infoLog); + + @Alternate("glGetProgramInfoLog") + @GLreturn(value = "infoLog", maxLength = "maxLength") + void glGetProgramInfoLog2(@GLuint int program, @GLsizei int maxLength, + @OutParameter @GLsizei @Constant("infoLog_length, 0") IntBuffer length, + @OutParameter @GLchar ByteBuffer infoLog); + + void glGetAttachedShaders(@GLuint int program, @AutoSize("shaders") @GLsizei int maxCount, + @OutParameter @GLsizei @Check(value = "1", canBeNull = true) IntBuffer count, + @OutParameter @GLuint IntBuffer shaders); + + /** + * Returns the location of the uniform with the specified name. The ByteBuffer should contain the uniform name as a + * null-terminated string. + * + * @param program + * @param name + */ + int glGetUniformLocation(@GLuint int program, @NullTerminated @Check("1") @Const @GLchar ByteBuffer name); + + @Alternate("glGetUniformLocation") + int glGetUniformLocation(@GLuint int program, @NullTerminated CharSequence name); + + void glGetActiveUniform(@GLuint int program, @GLuint int index, @AutoSize("name") @GLsizei int maxLength, + @OutParameter @GLsizei @Check(value = "1", canBeNull = true) IntBuffer length, + @OutParameter @GLsizei @Check("1") IntBuffer size, + @OutParameter @GLenum @Check("1") IntBuffer type, + @OutParameter @GLchar ByteBuffer name); + + /** Overloads glGetActiveUniform. This version returns both size and type in the sizeType buffer (at .position() and .position() + 1). */ + @Alternate("glGetActiveUniform") + @GLreturn(value = "name", maxLength = "maxLength") + void glGetActiveUniform2(@GLuint int program, @GLuint int index, @GLsizei int maxLength, + @OutParameter @GLsizei @Constant("name_length, 0") IntBuffer length, + @OutParameter @Check("2") IntBuffer sizeType, + @OutParameter @GLenum @Constant("sizeType, sizeType.position() + 1") IntBuffer type, + @OutParameter @GLchar ByteBuffer name); + + /** Overloads glGetActiveUniformARB. This version returns only the uniform name. */ + @Alternate(value = "glGetActiveUniform", javaAlt = true) + @GLreturn(value = "name", maxLength = "maxLength") + void glGetActiveUniform(@GLuint int program, @GLuint int index, @GLsizei int maxLength, + @OutParameter @GLsizei @Constant("name_length, 0, APIUtils.getBufferInt(), 0, APIUtils.getBufferInt(), 1") IntBuffer length, + @OutParameter @GLchar ByteBuffer name); + + /** Overloads glGetActiveUniform. This version returns only the uniform size. */ + @Alternate(value = "glGetActiveUniform", javaAlt = true) + @GLreturn(value = "size") + void glGetActiveUniformSize(@GLuint int program, @GLuint int index, @Constant("0") @GLsizei int maxLength, + @OutParameter @GLsizei @Constant("null, 0") IntBuffer length, + @OutParameter IntBuffer size, + @OutParameter @GLenum @Constant("size, 1") IntBuffer type, // Reuse size buffer and ignore + @OutParameter @GLchar @Constant("APIUtils.getBufferByte(0), 0") ByteBuffer name); + + /** Overloads glGetActiveUniform. This version returns only the uniform type. */ + @Alternate(value = "glGetActiveUniform", javaAlt = true) + @GLreturn(value = "type") + void glGetActiveUniformType(@GLuint int program, @GLuint int index, @Constant("0") @GLsizei int maxLength, + @OutParameter @GLsizei @Constant("null, 0") IntBuffer length, + @OutParameter @Constant("type, 1") IntBuffer size, // Reuse type buffer and ignore + @OutParameter @GLenum IntBuffer type, + @OutParameter @GLchar @Constant("APIUtils.getBufferByte(0), 0") ByteBuffer name); + + @StripPostfix("params") + void glGetUniformfv(@GLuint int program, int location, @OutParameter @Check FloatBuffer params); + + @StripPostfix("params") + void glGetUniformiv(@GLuint int program, int location, @OutParameter @Check IntBuffer params); + + void glGetShaderSource(@GLuint int shader, @AutoSize("source") @GLsizei int maxLength, + @OutParameter @GLsizei @Check(value = "1", canBeNull = true) IntBuffer length, + @OutParameter @GLchar ByteBuffer source); + + @Alternate("glGetShaderSource") + @GLreturn(value = "source", maxLength = "maxLength") + void glGetShaderSource2(@GLuint int shader, @GLsizei int maxLength, + @OutParameter @GLsizei @Constant("source_length, 0") IntBuffer length, + @OutParameter @GLchar ByteBuffer source); + + // ------------------------------------------------------------------ + // ----------------------[ ARB_vertex_program ]---------------------- + // ------------------------------------------------------------------ + + @NoErrorCheck + void glVertexAttrib1s(@GLuint int index, short x); + + @NoErrorCheck + void glVertexAttrib1f(@GLuint int index, float x); + + @NoErrorCheck + void glVertexAttrib1d(@GLuint int index, double x); + + @NoErrorCheck + void glVertexAttrib2s(@GLuint int index, short x, short y); + + @NoErrorCheck + void glVertexAttrib2f(@GLuint int index, float x, float y); + + @NoErrorCheck + void glVertexAttrib2d(@GLuint int index, double x, double y); + + @NoErrorCheck + void glVertexAttrib3s(@GLuint int index, short x, short y, short z); + + @NoErrorCheck + void glVertexAttrib3f(@GLuint int index, float x, float y, float z); + + @NoErrorCheck + void glVertexAttrib3d(@GLuint int index, double x, double y, double z); + + @NoErrorCheck + void glVertexAttrib4s(@GLuint int index, short x, short y, short z, short w); + + @NoErrorCheck + void glVertexAttrib4f(@GLuint int index, float x, float y, float z, float w); + + @NoErrorCheck + void glVertexAttrib4d(@GLuint int index, double x, double y, double z, double w); + + @NoErrorCheck + void glVertexAttrib4Nub(@GLuint int index, @GLubyte byte x, @GLubyte byte y, @GLubyte byte z, @GLubyte byte w); + + void glVertexAttribPointer(@GLuint int index, int size, @AutoType("buffer") @GLenum int type, boolean normalized, @GLsizei int stride, + @CachedReference(index = "index", name = "glVertexAttribPointer_buffer") + @BufferObject(BufferKind.ArrayVBO) + @Check + @Const + @GLubyte + @GLbyte + @GLshort + @GLushort + @GLint + @GLuint + @GLfloat + @GLdouble Buffer buffer); + + void glEnableVertexAttribArray(@GLuint int index); + + void glDisableVertexAttribArray(@GLuint int index); + + @StripPostfix("params") + void glGetVertexAttribfv(@GLuint int index, @GLenum int pname, @OutParameter @Check("4") FloatBuffer params); + + @StripPostfix("params") + void glGetVertexAttribdv(@GLuint int index, @GLenum int pname, @OutParameter @Check("4") DoubleBuffer params); + + @StripPostfix("params") + void glGetVertexAttribiv(@GLuint int index, @GLenum int pname, @OutParameter @Check("4") IntBuffer params); + + @StripPostfix("pointer") + void glGetVertexAttribPointerv(@GLuint int index, @GLenum int pname, @Result @GLvoid ByteBuffer pointer); + + // ----------------------------------------------------------------- + // ----------------------[ ARB_vertex_shader ]---------------------- + // ----------------------------------------------------------------- + + /** + * Accepted by the <shaderType> argument of CreateShader and + * returned by the <params> parameter of GetShader{if}v: + */ + int GL_VERTEX_SHADER = 0x8B31; + + /** + * Accepted by the <pname> parameter of GetBooleanv, GetIntegerv, + * GetFloatv, and GetDoublev: + */ + int GL_MAX_VERTEX_UNIFORM_COMPONENTS = 0x8B4A; + int GL_MAX_VARYING_FLOATS = 0x8B4B; + int GL_MAX_VERTEX_ATTRIBS = 0x8869; + int GL_MAX_TEXTURE_IMAGE_UNITS = 0x8872; + int GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS = 0x8B4C; + int GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS = 0x8B4D; + int GL_MAX_TEXTURE_COORDS = 0x8871; + + /** + * Accepted by the <cap> parameter of Disable, Enable, and IsEnabled, and + * by the <pname> parameter of GetBooleanv, GetIntegerv, GetFloatv, and + * GetDoublev: + */ + int GL_VERTEX_PROGRAM_POINT_SIZE = 0x8642; + int GL_VERTEX_PROGRAM_TWO_SIDE = 0x8643; + + /** Accepted by the <pname> parameter of GetVertexAttrib{dfi}vARB: */ + int GL_VERTEX_ATTRIB_ARRAY_ENABLED = 0x8622; + int GL_VERTEX_ATTRIB_ARRAY_SIZE = 0x8623; + int GL_VERTEX_ATTRIB_ARRAY_STRIDE = 0x8624; + int GL_VERTEX_ATTRIB_ARRAY_TYPE = 0x8625; + int GL_VERTEX_ATTRIB_ARRAY_NORMALIZED = 0x886A; + int GL_CURRENT_VERTEX_ATTRIB = 0x8626; + + /** Accepted by the <pname> parameter of GetVertexAttribPointervARB: */ + int GL_VERTEX_ATTRIB_ARRAY_POINTER = 0x8645; + + void glBindAttribLocation(@GLuint int program, @GLuint int index, @NullTerminated @Const @GLchar ByteBuffer name); + + @Alternate("glBindAttribLocation") + void glBindAttribLocation(@GLuint int program, @GLuint int index, @NullTerminated CharSequence name); + + void glGetActiveAttrib(@GLuint int program, @GLuint int index, @AutoSize("name") @GLsizei int maxLength, + @OutParameter @GLsizei @Check(value = "1", canBeNull = true) IntBuffer length, + @OutParameter @Check("1") IntBuffer size, + @OutParameter @GLenum @Check("1") IntBuffer type, + @OutParameter @GLchar ByteBuffer name); + + /** Overloads glGetActiveAttrib. This version returns both size and type in the sizeType buffer (at .position() and .position() + 1). */ + @Alternate("glGetActiveAttrib") + @GLreturn(value = "name", maxLength = "maxLength") + void glGetActiveAttrib2(@GLuint int program, @GLuint int index, @GLsizei int maxLength, + @OutParameter @GLsizei @Constant("name_length, 0") IntBuffer length, + @OutParameter @Check("2") IntBuffer sizeType, + @OutParameter @GLenum @Constant("sizeType, sizeType.position() + 1") IntBuffer type, + @OutParameter @GLchar ByteBuffer name); + + /** Overloads glGetActiveAttrib. This version returns only the attrib name. */ + @Alternate(value = "glGetActiveAttrib", javaAlt = true) + @GLreturn(value = "name", maxLength = "maxLength") + void glGetActiveAttrib(@GLuint int program, @GLuint int index, @GLsizei int maxLength, + @OutParameter @GLsizei @Constant("name_length, 0, APIUtils.getBufferInt(), 0, APIUtils.getBufferInt(), 1") IntBuffer length, + @OutParameter @GLchar ByteBuffer name); + + /** Overloads glGetActiveAttribARB. This version returns only the attrib size. */ + @Alternate(value = "glGetActiveAttrib", javaAlt = true) + @GLreturn(value = "size") + void glGetActiveAttribSize(@GLuint int program, @GLuint int index, @Constant("0") @GLsizei int maxLength, + @OutParameter @GLsizei @Constant("null, 0") IntBuffer length, + @OutParameter IntBuffer size, + @OutParameter @GLenum @Constant("size, 1") IntBuffer type, // Reuse size buffer and ignore + @OutParameter @GLchar @Constant("APIUtils.getBufferByte(0), 0") ByteBuffer name); + + /** Overloads glGetActiveAttrib. This version returns only the attrib type. */ + @Alternate(value = "glGetActiveAttrib", javaAlt = true) + @GLreturn(value = "type") + void glGetActiveAttribType(@GLuint int program, @GLuint int index, @Constant("0") @GLsizei int maxLength, + @OutParameter @GLsizei @Constant("null, 0") IntBuffer length, + @OutParameter @Constant("type, 1") IntBuffer size, // Reuse type buffer and ignore + @OutParameter @GLenum IntBuffer type, + @OutParameter @GLchar @Constant("APIUtils.getBufferByte(0), 0") ByteBuffer name); + + int glGetAttribLocation(@GLuint int program, @NullTerminated @Const @GLchar ByteBuffer name); + + @Alternate("glGetAttribLocation") + int glGetAttribLocation(@GLuint int program, @NullTerminated CharSequence name); + + // ------------------------------------------------------------------- + // ----------------------[ ARB_fragment_shader ]---------------------- + // ------------------------------------------------------------------- + + /** + * Accepted by the <shaderType> argument of CreateShader and + * returned by the <params> parameter of GetShader{fi}vARB: + */ + int GL_FRAGMENT_SHADER = 0x8B30; + + /** + * Accepted by the <pname> parameter of GetBooleanv, GetIntegerv, + * GetFloatv, and GetDoublev: + */ + int GL_MAX_FRAGMENT_UNIFORM_COMPONENTS = 0x8B49; + + /** + * Accepted by the <target> parameter of Hint and the <pname> parameter of + * GetBooleanv, GetIntegerv, GetFloatv, and GetDoublev: + */ + int GL_FRAGMENT_SHADER_DERIVATIVE_HINT = 0x8B8B; + + // ---------------------------------------------------------------- + // ----------------------[ ARB_draw_buffers ]---------------------- + // ---------------------------------------------------------------- + + /** + * Accepted by the <pname> parameters of GetIntegerv, GetFloatv, + * and GetDoublev: + */ + int GL_MAX_DRAW_BUFFERS = 0x8824; + int GL_DRAW_BUFFER0 = 0x8825; + int GL_DRAW_BUFFER1 = 0x8826; + int GL_DRAW_BUFFER2 = 0x8827; + int GL_DRAW_BUFFER3 = 0x8828; + int GL_DRAW_BUFFER4 = 0x8829; + int GL_DRAW_BUFFER5 = 0x882A; + int GL_DRAW_BUFFER6 = 0x882B; + int GL_DRAW_BUFFER7 = 0x882C; + int GL_DRAW_BUFFER8 = 0x882D; + int GL_DRAW_BUFFER9 = 0x882E; + int GL_DRAW_BUFFER10 = 0x882F; + int GL_DRAW_BUFFER11 = 0x8830; + int GL_DRAW_BUFFER12 = 0x8831; + int GL_DRAW_BUFFER13 = 0x8832; + int GL_DRAW_BUFFER14 = 0x8833; + int GL_DRAW_BUFFER15 = 0x8834; + + void glDrawBuffers(@AutoSize("buffers") @GLsizei int size, @Const @GLenum IntBuffer buffers); + + @Alternate("glDrawBuffers") + void glDrawBuffers(@Constant("1") @GLsizei int size, @Constant(value = "APIUtils.getBufferInt().put(0, buffer), 0", keepParam = true) int buffer); + + // ---------------------------------------------------------------- + // ----------------------[ ARB_point_sprite ]---------------------- + // ---------------------------------------------------------------- + + /** + * Accepted by the <cap> parameter of Enable, Disable, and IsEnabled, by + * the <pname> parameter of GetBooleanv, GetIntegerv, GetFloatv, and + * GetDoublev, and by the <target> parameter of TexEnvi, TexEnviv, + * TexEnvf, TexEnvfv, GetTexEnviv, and GetTexEnvfv: + */ + int GL_POINT_SPRITE = 0x8861; + + /** + * When the <target> parameter of TexEnvf, TexEnvfv, TexEnvi, TexEnviv, + * GetTexEnvfv, or GetTexEnviv is POINT_SPRITE, then the value of + * <pname> may be: + */ + int GL_COORD_REPLACE = 0x8862; + + /** + * Accepted by the <pname> parameter of PointParameter{if}vARB, and the + * <pname> of Get: + */ + int GL_POINT_SPRITE_COORD_ORIGIN = 0x8CA0; + + /** Accepted by the <param> parameter of PointParameter{if}vARB: */ + int GL_LOWER_LEFT = 0x8CA1; + int GL_UPPER_LEFT = 0x8CA2; + + // ----------------------------------------------------------------- + // ----------------------[ Two-Sided Stencil ]---------------------- + // ----------------------------------------------------------------- + + int GL_STENCIL_BACK_FUNC = 0x8800; + int GL_STENCIL_BACK_FAIL = 0x8801; + int GL_STENCIL_BACK_PASS_DEPTH_FAIL = 0x8802; + int GL_STENCIL_BACK_PASS_DEPTH_PASS = 0x8803; + int GL_STENCIL_BACK_REF = 0x8CA3; + int GL_STENCIL_BACK_VALUE_MASK = 0x8CA4; + int GL_STENCIL_BACK_WRITEMASK = 0x8CA5; + + void glStencilOpSeparate(@GLenum int face, @GLenum int sfail, @GLenum int dpfail, @GLenum int dppass); + + void glStencilFuncSeparate(@GLenum int face, @GLenum int func, int ref, @GLuint int mask); + + void glStencilMaskSeparate(@GLenum int face, @GLuint int mask); + + // ------------------------------------------------------------- + // ----------------------[ EXT_blend_equation_separate ]---------------------- + // ------------------------------------------------------------- + + int GL_BLEND_EQUATION_RGB = 0x8009; + int GL_BLEND_EQUATION_ALPHA = 0x883D; + + void glBlendEquationSeparate(@GLenum int modeRGB, @GLenum int modeAlpha); +} diff --git a/src/templates/org/lwjgl/opengl/GL21.java b/src/templates/org/lwjgl/opengl/GL21.java new file mode 100644 index 0000000..5c84559 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/GL21.java @@ -0,0 +1,125 @@ +/* + * 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; + +import org.lwjgl.util.generator.AutoSize; +import org.lwjgl.util.generator.GLsizei; +import org.lwjgl.util.generator.StripPostfix; + +import java.nio.FloatBuffer; + +public interface GL21 { + + // ------------------------------------------------------------------ + // --------------------------[ GLSL 1.20 ]--------------------------- + // ------------------------------------------------------------------ + + /** Returned by the <type> parameter of GetActiveAttribARB. */ + int GL_FLOAT_MAT2x3 = 0x8B65; + int GL_FLOAT_MAT2x4 = 0x8B66; + int GL_FLOAT_MAT3x2 = 0x8B67; + int GL_FLOAT_MAT3x4 = 0x8B68; + int GL_FLOAT_MAT4x2 = 0x8B69; + int GL_FLOAT_MAT4x3 = 0x8B6A; + + @StripPostfix("matrices") + void glUniformMatrix2x3fv(int location, @AutoSize(value = "matrices", expression = " / (2 * 3)") @GLsizei int count, + boolean transpose, FloatBuffer matrices); + + @StripPostfix("matrices") + void glUniformMatrix3x2fv(int location, @AutoSize(value = "matrices", expression = " / (3 * 2)") @GLsizei int count, + boolean transpose, FloatBuffer matrices); + + @StripPostfix("matrices") + void glUniformMatrix2x4fv(int location, @AutoSize(value = "matrices", expression = " >> 3") @GLsizei int count, + boolean transpose, FloatBuffer matrices); + + @StripPostfix("matrices") + void glUniformMatrix4x2fv(int location, @AutoSize(value = "matrices", expression = " >> 3") @GLsizei int count, + boolean transpose, FloatBuffer matrices); + + @StripPostfix("matrices") + void glUniformMatrix3x4fv(int location, @AutoSize(value = "matrices", expression = " / (3 * 4)") @GLsizei int count, + boolean transpose, FloatBuffer matrices); + + @StripPostfix("matrices") + void glUniformMatrix4x3fv(int location, @AutoSize(value = "matrices", expression = " / (4 * 3)") @GLsizei int count, + boolean transpose, FloatBuffer matrices); + + // ------------------------------------------------------------------ + // -------------------[ ARB_pixel_buffer_object ]-------------------- + // ------------------------------------------------------------------ + + /** + * Accepted by the <target> parameters of BindBuffer, BufferData, + * BufferSubData, MapBuffer, UnmapBuffer, GetBufferSubData, + * GetBufferParameteriv, and GetBufferPointerv. + */ + int GL_PIXEL_PACK_BUFFER = 0x88EB; + int GL_PIXEL_UNPACK_BUFFER = 0x88EC; + + /** + * Accepted by the <pname> parameter of GetBooleanv, GetIntegerv, + * GetFloatv, and GetDoublev. + */ + int GL_PIXEL_PACK_BUFFER_BINDING = 0x88ED; + int GL_PIXEL_UNPACK_BUFFER_BINDING = 0x88EF; + + // ------------------------------------------------------------------ + // ----------------------[ EXT_texture_sRGB ]------------------------ + // ------------------------------------------------------------------ + + /** + * Accepted by the <internalformat> parameter of TexImage1D, TexImage2D, + * TexImage3D, CopyTexImage1D, CopyTexImage2D. + */ + int GL_SRGB = 0x8C40; + int GL_SRGB8 = 0x8C41; + int GL_SRGB_ALPHA = 0x8C42; + int GL_SRGB8_ALPHA8 = 0x8C43; + int GL_SLUMINANCE_ALPHA = 0x8C44; + int GL_SLUMINANCE8_ALPHA8 = 0x8C45; + int GL_SLUMINANCE = 0x8C46; + int GL_SLUMINANCE8 = 0x8C47; + int GL_COMPRESSED_SRGB = 0x8C48; + int GL_COMPRESSED_SRGB_ALPHA = 0x8C49; + int GL_COMPRESSED_SLUMINANCE = 0x8C4A; + int GL_COMPRESSED_SLUMINANCE_ALPHA = 0x8C4B; + + // ------------------------------------------------------------------ + // -----------------------[ Misc additions ]------------------------- + // ------------------------------------------------------------------ + + /** Accepted by the <pname> parameter of GetIntegerv and GetFloatv. */ + int GL_CURRENT_RASTER_SECONDARY_COLOR = 0x845F; + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/GL30.java b/src/templates/org/lwjgl/opengl/GL30.java new file mode 100644 index 0000000..2835b30 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/GL30.java @@ -0,0 +1,1036 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +import java.nio.*; + +public interface GL30 { + + // ---------------------------------------------------------- + // ----------------------[ OpenGL 3.0 ]---------------------- + // ---------------------------------------------------------- + + int GL_MAJOR_VERSION = 0x821B; + int GL_MINOR_VERSION = 0x821C; + int GL_NUM_EXTENSIONS = 0x821D; + + int GL_CONTEXT_FLAGS = 0x821E; + int GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT = 0x0001; + + int GL_DEPTH_BUFFER = 0x8223; + int GL_STENCIL_BUFFER = 0x8224; + + int GL_COMPRESSED_RED = 0x8225; + int GL_COMPRESSED_RG = 0x8226; + + int GL_COMPARE_REF_TO_TEXTURE = ARB_shadow.GL_COMPARE_R_TO_TEXTURE_ARB; + + int GL_CLIP_DISTANCE0 = GL11.GL_CLIP_PLANE0; + int GL_CLIP_DISTANCE1 = GL11.GL_CLIP_PLANE1; + int GL_CLIP_DISTANCE2 = GL11.GL_CLIP_PLANE2; + int GL_CLIP_DISTANCE3 = GL11.GL_CLIP_PLANE3; + int GL_CLIP_DISTANCE4 = GL11.GL_CLIP_PLANE4; + int GL_CLIP_DISTANCE5 = GL11.GL_CLIP_PLANE5; + int GL_CLIP_DISTANCE6 = 0x3006; + int GL_CLIP_DISTANCE7 = 0x3007; + + int GL_MAX_CLIP_DISTANCES = GL11.GL_MAX_CLIP_PLANES; + + int GL_MAX_VARYING_COMPONENTS = GL20.GL_MAX_VARYING_FLOATS; + + int GL_BUFFER_ACCESS_FLAGS = 0x911F; + int GL_BUFFER_MAP_LENGTH = 0x9120; + int GL_BUFFER_MAP_OFFSET = 0x9121; + + String glGetStringi(@GLenum int name, @GLuint int index); + + @StripPostfix("value") + void glClearBufferfv(@GLenum int buffer, int drawbuffer, @Const @Check("4") FloatBuffer value); + + @StripPostfix("value") + void glClearBufferiv(@GLenum int buffer, int drawbuffer, @Const @Check("4") IntBuffer value); + + @StripPostfix("value") + void glClearBufferuiv(@GLenum int buffer, int drawbuffer, @Const @Check("4") IntBuffer value); + + void glClearBufferfi(@GLenum int buffer, int drawbuffer, float depth, int stencil); + + // --------------------------------------------------------------- + // ----------------------[ EXT_gpu_shader4 ]---------------------- + // --------------------------------------------------------------- + + /** + * Accepted by the <pname> parameters of GetVertexAttribdv, + * GetVertexAttribfv, GetVertexAttribiv, GetVertexAttribIiv, and + * GetVertexAttribIuiv: + */ + int GL_VERTEX_ATTRIB_ARRAY_INTEGER = 0x88FD; + + /** Returned by the <type> parameter of GetActiveUniform: */ + + int GL_SAMPLER_BUFFER = 0x8DC2; + int GL_SAMPLER_CUBE_SHADOW = 0x8DC5; + int GL_UNSIGNED_INT_VEC2 = 0x8DC6; + int GL_UNSIGNED_INT_VEC3 = 0x8DC7; + int GL_UNSIGNED_INT_VEC4 = 0x8DC8; + int GL_INT_SAMPLER_1D = 0x8DC9; + int GL_INT_SAMPLER_2D = 0x8DCA; + int GL_INT_SAMPLER_3D = 0x8DCB; + int GL_INT_SAMPLER_CUBE = 0x8DCC; + int GL_INT_SAMPLER_2D_RECT = 0x8DCD; + int GL_INT_SAMPLER_1D_ARRAY = 0x8DCE; + int GL_INT_SAMPLER_2D_ARRAY = 0x8DCF; + int GL_INT_SAMPLER_BUFFER = 0x8DD0; + + int GL_UNSIGNED_INT_SAMPLER_1D = 0x8DD1; + int GL_UNSIGNED_INT_SAMPLER_2D = 0x8DD2; + int GL_UNSIGNED_INT_SAMPLER_3D = 0x8DD3; + int GL_UNSIGNED_INT_SAMPLER_CUBE = 0x8DD4; + int GL_UNSIGNED_INT_SAMPLER_2D_RECT = 0x8DD5; + int GL_UNSIGNED_INT_SAMPLER_1D_ARRAY = 0x8DD6; + int GL_UNSIGNED_INT_SAMPLER_2D_ARRAY = 0x8DD7; + int GL_UNSIGNED_INT_SAMPLER_BUFFER = 0x8DD8; + + /** + * Accepted by the <pname> parameter of GetBooleanv, GetIntegerv, GetFloatv, + * and GetDoublev: + */ + int GL_MIN_PROGRAM_TEXEL_OFFSET = 0x8904; + int GL_MAX_PROGRAM_TEXEL_OFFSET = 0x8905; + + @NoErrorCheck + void glVertexAttribI1i(@GLuint int index, int x); + + @NoErrorCheck + void glVertexAttribI2i(@GLuint int index, int x, int y); + + @NoErrorCheck + void glVertexAttribI3i(@GLuint int index, int x, int y, int z); + + @NoErrorCheck + void glVertexAttribI4i(@GLuint int index, int x, int y, int z, int w); + + @NoErrorCheck + void glVertexAttribI1ui(@GLuint int index, @GLuint int x); + + @NoErrorCheck + void glVertexAttribI2ui(@GLuint int index, @GLuint int x, @GLuint int y); + + @NoErrorCheck + void glVertexAttribI3ui(@GLuint int index, @GLuint int x, @GLuint int y, @GLuint int z); + + @NoErrorCheck + void glVertexAttribI4ui(@GLuint int index, @GLuint int x, @GLuint int y, @GLuint int z, @GLuint int w); + + @NoErrorCheck + @StripPostfix("v") + void glVertexAttribI1iv(@GLuint int index, @Check("1") @Const IntBuffer v); + + @NoErrorCheck + @StripPostfix("v") + void glVertexAttribI2iv(@GLuint int index, @Check("2") @Const IntBuffer v); + + @NoErrorCheck + @StripPostfix("v") + void glVertexAttribI3iv(@GLuint int index, @Check("3") @Const IntBuffer v); + + @NoErrorCheck + @StripPostfix("v") + void glVertexAttribI4iv(@GLuint int index, @Check("4") @Const IntBuffer v); + + @NoErrorCheck + @StripPostfix("v") + void glVertexAttribI1uiv(@GLuint int index, @Check("1") @Const @GLuint IntBuffer v); + + @NoErrorCheck + @StripPostfix("v") + void glVertexAttribI2uiv(@GLuint int index, @Check("2") @Const @GLuint IntBuffer v); + + @NoErrorCheck + @StripPostfix("v") + void glVertexAttribI3uiv(@GLuint int index, @Check("3") @Const @GLuint IntBuffer v); + + @NoErrorCheck + @StripPostfix("v") + void glVertexAttribI4uiv(@GLuint int index, @Check("4") @Const @GLuint IntBuffer v); + + @NoErrorCheck + @StripPostfix("v") + void glVertexAttribI4bv(@GLuint int index, @Check("4") @Const ByteBuffer v); + + @NoErrorCheck + @StripPostfix("v") + void glVertexAttribI4sv(@GLuint int index, @Check("4") @Const ShortBuffer v); + + @NoErrorCheck + @StripPostfix("v") + void glVertexAttribI4ubv(@GLuint int index, @Check("4") @Const @GLubyte ByteBuffer v); + + @NoErrorCheck + @StripPostfix("v") + void glVertexAttribI4usv(@GLuint int index, @Check("4") @Const @GLushort ShortBuffer v); + + void glVertexAttribIPointer(@GLuint int index, int size, @GLenum int type, @GLsizei int stride, + @CachedReference + @BufferObject(BufferKind.ArrayVBO) + @Check + @Const + @GLbyte + @GLubyte + @GLshort + @GLushort + @GLint + @GLuint Buffer buffer); + + @StripPostfix("params") + void glGetVertexAttribIiv(@GLuint int index, @GLenum int pname, @OutParameter @Check("4") IntBuffer params); + + @StripPostfix("params") + void glGetVertexAttribIuiv(@GLuint int index, @GLenum int pname, @OutParameter @Check("4") @GLuint IntBuffer params); + + void glUniform1ui(int location, @GLuint int v0); + + void glUniform2ui(int location, @GLuint int v0, @GLuint int v1); + + void glUniform3ui(int location, @GLuint int v0, @GLuint int v1, @GLuint int v2); + + void glUniform4ui(int location, @GLuint int v0, @GLuint int v1, @GLuint int v2, @GLuint int v3); + + @StripPostfix("value") + void glUniform1uiv(int location, @AutoSize("value") @GLsizei int count, @Const @GLuint IntBuffer value); + + @StripPostfix("value") + void glUniform2uiv(int location, @AutoSize(value = "value", expression = " >> 1") @GLsizei int count, @Const @GLuint IntBuffer value); + + @StripPostfix("value") + void glUniform3uiv(int location, @AutoSize(value = "value", expression = " / 3") @GLsizei int count, @Const @GLuint IntBuffer value); + + @StripPostfix("value") + void glUniform4uiv(int location, @AutoSize(value = "value", expression = " >> 2") @GLsizei int count, @Const @GLuint IntBuffer value); + + @StripPostfix("params") + void glGetUniformuiv(@GLuint int program, int location, @OutParameter @Check @GLuint IntBuffer params); + + void glBindFragDataLocation(@GLuint int program, @GLuint int colorNumber, @NullTerminated @Const @GLchar ByteBuffer name); + + @Alternate("glBindFragDataLocation") + void glBindFragDataLocation(@GLuint int program, @GLuint int colorNumber, @NullTerminated CharSequence name); + + int glGetFragDataLocation(@GLuint int program, @NullTerminated @Const @GLchar ByteBuffer name); + + @Alternate("glGetFragDataLocation") + int glGetFragDataLocation(@GLuint int program, @NullTerminated CharSequence name); + + // --------------------------------------------------------------------- + // ----------------------[ NV_conditional_render ]---------------------- + // --------------------------------------------------------------------- + + /** Accepted by the <mode> parameter of BeginConditionalRender: */ + int GL_QUERY_WAIT = 0x8E13; + int GL_QUERY_NO_WAIT = 0x8E14; + int GL_QUERY_BY_REGION_WAIT = 0x8E15; + int GL_QUERY_BY_REGION_NO_WAIT = 0x8E16; + + void glBeginConditionalRender(@GLuint int id, @GLenum int mode); + + void glEndConditionalRender(); + + // -------------------------------------------------------------------- + // ----------------------[ ARB_map_buffer_range ]---------------------- + // -------------------------------------------------------------------- + + /** Accepted by the <access> parameter of MapBufferRange: */ + int GL_MAP_READ_BIT = 0x0001; + int GL_MAP_WRITE_BIT = 0x0002; + int GL_MAP_INVALIDATE_RANGE_BIT = 0x0004; + int GL_MAP_INVALIDATE_BUFFER_BIT = 0x0008; + int GL_MAP_FLUSH_EXPLICIT_BIT = 0x0010; + int GL_MAP_UNSYNCHRONIZED_BIT = 0x0020; + + /** + * glMapBufferRange maps a GL buffer object range to a ByteBuffer. The old_buffer argument can be null, + * in which case a new ByteBuffer will be created, pointing to the returned memory. If old_buffer is non-null, + * it will be returned if it points to the same mapped memory and has the same capacity as the buffer object, + * otherwise a new ByteBuffer is created. That way, an application will normally use glMapBufferRange like this: + *

    + * ByteBuffer mapped_buffer; mapped_buffer = glMapBufferRange(..., ..., ..., ..., null); ... // Another map on the same buffer mapped_buffer = glMapBufferRange(..., ..., ..., ..., mapped_buffer); + *

    + * Only ByteBuffers returned from this method are to be passed as the old_buffer argument. User-created ByteBuffers cannot be reused. + * + * @param old_buffer A ByteBuffer. If this argument points to the same address and has the same capacity as the new mapping, it will be returned and no new buffer will be created. + * + * @return A ByteBuffer representing the mapped buffer memory. + */ + @CachedResult(isRange = true) + @GLvoid + @AutoResultSize("length") + ByteBuffer glMapBufferRange(@GLenum int target, @GLintptr long offset, @GLsizeiptr long length, @GLbitfield int access); + + void glFlushMappedBufferRange(@GLenum int target, @GLintptr long offset, @GLsizeiptr long length); + + // ---------------------------------------------------------------------- + // ----------------------[ ARB_color_buffer_float ]---------------------- + // ---------------------------------------------------------------------- + + /** + * Accepted by the <target> parameter of ClampColor and the <pname> + * parameter of GetBooleanv, GetIntegerv, GetFloatv, and GetDoublev. + */ + int GL_CLAMP_VERTEX_COLOR = 0x891A; + int GL_CLAMP_FRAGMENT_COLOR = 0x891B; + int GL_CLAMP_READ_COLOR = 0x891C; + + /** Accepted by the <clamp> parameter of ClampColor. */ + int GL_FIXED_ONLY = 0x891D; + + void glClampColor(@GLenum int target, @GLenum int clamp); + + // ---------------------------------------------------------------------- + // ----------------------[ NV_depth_buffer_float ]---------------------- + // ---------------------------------------------------------------------- + + /** + * Accepted by the <internalformat> parameter of TexImage1D, TexImage2D, + * TexImage3D, CopyTexImage1D, CopyTexImage2D, and RenderbufferStorageEXT, + * and returned in the <data> parameter of GetTexLevelParameter and + * GetRenderbufferParameterivEXT: + */ + int GL_DEPTH_COMPONENT32F = 0x8DAB; + int GL_DEPTH32F_STENCIL8 = 0x8DAC; + + /** + * Accepted by the <type> parameter of DrawPixels, ReadPixels, TexImage1D, + * TexImage2D, TexImage3D, TexSubImage1D, TexSubImage2D, TexSubImage3D, and + * GetTexImage: + */ + int GL_FLOAT_32_UNSIGNED_INT_24_8_REV = 0x8DAD; + + // ----------------------------------------------------------------- + // ----------------------[ ARB_texture_float ]---------------------- + // ----------------------------------------------------------------- + + /** Accepted by the <value> parameter of GetTexLevelParameter: */ + int GL_TEXTURE_RED_TYPE = 0x8C10; + int GL_TEXTURE_GREEN_TYPE = 0x8C11; + int GL_TEXTURE_BLUE_TYPE = 0x8C12; + int GL_TEXTURE_ALPHA_TYPE = 0x8C13; + int GL_TEXTURE_LUMINANCE_TYPE = 0x8C14; + int GL_TEXTURE_INTENSITY_TYPE = 0x8C15; + int GL_TEXTURE_DEPTH_TYPE = 0x8C16; + + /** Returned by the <params> parameter of GetTexLevelParameter: */ + int GL_UNSIGNED_NORMALIZED = 0x8C17; + + /** + * Accepted by the <internalFormat> parameter of TexImage1D, + * TexImage2D, and TexImage3D: + */ + int GL_RGBA32F = 0x8814; + int GL_RGB32F = 0x8815; + int GL_ALPHA32F = 0x8816; + int GL_RGBA16F = 0x881A; + int GL_RGB16F = 0x881B; + int GL_ALPHA16F = 0x881C; + + // ---------------------------------------------------------------- + // ----------------------[ EXT_packed_float ]---------------------- + // ---------------------------------------------------------------- + + /** + * Accepted by the <internalformat> parameter of TexImage1D, + * TexImage2D, TexImage3D, CopyTexImage1D, CopyTexImage2D, and + * RenderbufferStorage: + */ + int GL_R11F_G11F_B10F = 0x8C3A; + + /** + * Accepted by the <type> parameter of DrawPixels, ReadPixels, + * TexImage1D, TexImage2D, GetTexImage, TexImage3D, TexSubImage1D, + * TexSubImage2D, TexSubImage3D, GetHistogram, GetMinmax, + * ConvolutionFilter1D, ConvolutionFilter2D, ConvolutionFilter3D, + * GetConvolutionFilter, SeparableFilter2D, GetSeparableFilter, + * ColorTable, ColorSubTable, and GetColorTable: + */ + int GL_UNSIGNED_INT_10F_11F_11F_REV = 0x8C3B; + + // --------------------------------------------------------------------------- + // ----------------------[ EXT_texture_shared_exponent ]---------------------- + // --------------------------------------------------------------------------- + + /** + * Accepted by the <internalformat> parameter of TexImage1D, + * TexImage2D, TexImage3D, CopyTexImage1D, CopyTexImage2D, and + * RenderbufferStorage: + */ + int GL_RGB9_E5 = 0x8C3D; + + /** + * Accepted by the <type> parameter of DrawPixels, ReadPixels, + * TexImage1D, TexImage2D, GetTexImage, TexImage3D, TexSubImage1D, + * TexSubImage2D, TexSubImage3D, GetHistogram, GetMinmax, + * ConvolutionFilter1D, ConvolutionFilter2D, ConvolutionFilter3D, + * GetConvolutionFilter, SeparableFilter2D, GetSeparableFilter, + * ColorTable, ColorSubTable, and GetColorTable: + */ + int GL_UNSIGNED_INT_5_9_9_9_REV = 0x8C3E; + + /** + * Accepted by the <pname> parameter of GetTexLevelParameterfv and + * GetTexLevelParameteriv: + */ + int GL_TEXTURE_SHARED_SIZE = 0x8C3F; + + // ---------------------------------------------------------------------- + // ----------------------[ EXT_framebuffer_object ]---------------------- + // ---------------------------------------------------------------------- + + /** + * Accepted by the <target> parameter of BindFramebuffer, + * CheckFramebufferStatus, FramebufferTexture{1D|2D|3D}, and + * FramebufferRenderbuffer: + */ + int GL_FRAMEBUFFER = 0x8D40; + + /** + * Accepted by the <target> parameter of BindRenderbuffer, + * RenderbufferStorage, and GetRenderbufferParameteriv, and + * returned by GetFramebufferAttachmentParameteriv: + */ + int GL_RENDERBUFFER = 0x8D41; + + /** + * Accepted by the <internalformat> parameter of + * RenderbufferStorage: + */ + int GL_STENCIL_INDEX1 = 0x8D46; + int GL_STENCIL_INDEX4 = 0x8D47; + int GL_STENCIL_INDEX8 = 0x8D48; + int GL_STENCIL_INDEX16 = 0x8D49; + + /** Accepted by the <pname> parameter of GetRenderbufferParameteriv: */ + int GL_RENDERBUFFER_WIDTH = 0x8D42; + int GL_RENDERBUFFER_HEIGHT = 0x8D43; + int GL_RENDERBUFFER_INTERNAL_FORMAT = 0x8D44; + int GL_RENDERBUFFER_RED_SIZE = 0x8D50; + int GL_RENDERBUFFER_GREEN_SIZE = 0x8D51; + int GL_RENDERBUFFER_BLUE_SIZE = 0x8D52; + int GL_RENDERBUFFER_ALPHA_SIZE = 0x8D53; + int GL_RENDERBUFFER_DEPTH_SIZE = 0x8D54; + int GL_RENDERBUFFER_STENCIL_SIZE = 0x8D55; + + /** + * Accepted by the <pname> parameter of + * GetFramebufferAttachmentParameteriv: + */ + int GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE = 0x8CD0; + int GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME = 0x8CD1; + int GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL = 0x8CD2; + int GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE = 0x8CD3; + int GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET = 0x8CD4; + + /** + * Accepted by the <attachment> parameter of + * FramebufferTexture{1D|2D|3D}, FramebufferRenderbuffer, and + * GetFramebufferAttachmentParameteriv + */ + int GL_COLOR_ATTACHMENT0 = 0x8CE0; + int GL_COLOR_ATTACHMENT1 = 0x8CE1; + int GL_COLOR_ATTACHMENT2 = 0x8CE2; + int GL_COLOR_ATTACHMENT3 = 0x8CE3; + int GL_COLOR_ATTACHMENT4 = 0x8CE4; + int GL_COLOR_ATTACHMENT5 = 0x8CE5; + int GL_COLOR_ATTACHMENT6 = 0x8CE6; + int GL_COLOR_ATTACHMENT7 = 0x8CE7; + int GL_COLOR_ATTACHMENT8 = 0x8CE8; + int GL_COLOR_ATTACHMENT9 = 0x8CE9; + int GL_COLOR_ATTACHMENT10 = 0x8CEA; + int GL_COLOR_ATTACHMENT11 = 0x8CEB; + int GL_COLOR_ATTACHMENT12 = 0x8CEC; + int GL_COLOR_ATTACHMENT13 = 0x8CED; + int GL_COLOR_ATTACHMENT14 = 0x8CEE; + int GL_COLOR_ATTACHMENT15 = 0x8CEF; + int GL_DEPTH_ATTACHMENT = 0x8D00; + int GL_STENCIL_ATTACHMENT = 0x8D20; + + /** Returned by CheckFramebufferStatus(): */ + int GL_FRAMEBUFFER_COMPLETE = 0x8CD5; + int GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT = 0x8CD6; + int GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT = 0x8CD7; + int GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS = 0x8CD9; + int GL_FRAMEBUFFER_INCOMPLETE_FORMATS = 0x8CDA; + int GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER = 0x8CDB; + int GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER = 0x8CDC; + int GL_FRAMEBUFFER_UNSUPPORTED = 0x8CDD; + + /** Accepted by GetIntegerv(): */ + int GL_FRAMEBUFFER_BINDING = 0x8CA6; + int GL_RENDERBUFFER_BINDING = 0x8CA7; + int GL_MAX_COLOR_ATTACHMENTS = 0x8CDF; + int GL_MAX_RENDERBUFFER_SIZE = 0x84E8; + + /** Returned by GetError(): */ + int GL_INVALID_FRAMEBUFFER_OPERATION = 0x0506; + + boolean glIsRenderbuffer(@GLuint int renderbuffer); + + void glBindRenderbuffer(@GLenum int target, @GLuint int renderbuffer); + + void glDeleteRenderbuffers(@AutoSize("renderbuffers") int n, @Const @GLuint IntBuffer renderbuffers); + + @Alternate("glDeleteRenderbuffers") + void glDeleteRenderbuffers(@Constant("1") int n, @Constant(value = "APIUtils.getBufferInt().put(0, renderbuffer), 0", keepParam = true) int renderbuffer); + + void glGenRenderbuffers(@AutoSize("renderbuffers") int n, @OutParameter @GLuint IntBuffer renderbuffers); + + @Alternate("glGenRenderbuffers") + @GLreturn("renderbuffers") + void glGenRenderbuffers2(@Constant("1") int n, @OutParameter @GLuint IntBuffer renderbuffers); + + void glRenderbufferStorage(@GLenum int target, @GLenum int internalformat, @GLsizei int width, @GLsizei int height); + + @StripPostfix("params") + void glGetRenderbufferParameteriv(@GLenum int target, @GLenum int pname, @OutParameter @Check("4") IntBuffer params); + + @Alternate("glGetRenderbufferParameteriv") + @GLreturn("params") + @StripPostfix("params") + void glGetRenderbufferParameteriv2(@GLenum int target, @GLenum int pname, @OutParameter IntBuffer params); + + boolean glIsFramebuffer(@GLuint int framebuffer); + + void glBindFramebuffer(@GLenum int target, @GLuint int framebuffer); + + void glDeleteFramebuffers(@AutoSize("framebuffers") int n, @Const @GLuint IntBuffer framebuffers); + + @Alternate("glDeleteFramebuffers") + void glDeleteFramebuffers(@Constant("1") int n, @Constant(value = "APIUtils.getBufferInt().put(0, framebuffer), 0", keepParam = true) int framebuffer); + + void glGenFramebuffers(@AutoSize("framebuffers") int n, @OutParameter @GLuint IntBuffer framebuffers); + + @Alternate("glGenFramebuffers") + @GLreturn("framebuffers") + void glGenFramebuffers2(@Constant("1") int n, @OutParameter @GLuint IntBuffer framebuffers); + + @GLenum + int glCheckFramebufferStatus(@GLenum int target); + + void glFramebufferTexture1D(@GLenum int target, @GLenum int attachment, @GLenum int textarget, @GLuint int texture, int level); + + void glFramebufferTexture2D(@GLenum int target, @GLenum int attachment, @GLenum int textarget, @GLuint int texture, int level); + + void glFramebufferTexture3D(@GLenum int target, @GLenum int attachment, @GLenum int textarget, @GLuint int texture, int level, int zoffset); + + void glFramebufferRenderbuffer(@GLenum int target, @GLenum int attachment, @GLenum int renderbuffertarget, @GLuint int renderbuffer); + + @StripPostfix("params") + void glGetFramebufferAttachmentParameteriv(@GLenum int target, @GLenum int attachment, @GLenum int pname, @OutParameter @Check("4") IntBuffer params); + + @Alternate("glGetFramebufferAttachmentParameteriv") + @GLreturn("params") + @StripPostfix("params") + void glGetFramebufferAttachmentParameteriv2(@GLenum int target, @GLenum int attachment, @GLenum int pname, @OutParameter IntBuffer params); + + void glGenerateMipmap(@GLenum int target); + + // -------------------------------------------------------------------------------------------- + // ----------------------[ ARB_half_float_vertex & ARB_half_float_pixel ]---------------------- + // -------------------------------------------------------------------------------------------- + + /** + * Accepted by the <type> parameter of DrawPixels, ReadPixels, + * TexImage1D, TexImage2D, TexImage3D, GetTexImage, TexSubImage1D, + * TexSubImage2D, TexSubImage3D, GetHistogram, GetMinmax, + * ConvolutionFilter1D, ConvolutionFilter2D, GetConvolutionFilter, + * SeparableFilter2D, GetSeparableFilter, ColorTable, ColorSubTable, + * and GetColorTable: + *

    + * Accepted by the <type> argument of VertexPointer, NormalPointer, + * ColorPointer, SecondaryColorPointer, FogCoordPointer, TexCoordPointer, + * and VertexAttribPointer: + */ + int GL_HALF_FLOAT = 0x140B; + + // --------------------------------------------------------------------------- + // ----------------------[ EXT_framebuffer_multisample ]---------------------- + // --------------------------------------------------------------------------- + + /** Accepted by the <pname> parameter of GetRenderbufferParameteriv. */ + int GL_RENDERBUFFER_SAMPLES = 0x8CAB; + + /** Returned by CheckFramebufferStatus. */ + int GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE = 0x8D56; + + /** + * Accepted by the <pname> parameter of GetBooleanv, GetIntegerv, + * GetFloatv, and GetDoublev. + */ + int GL_MAX_SAMPLES = 0x8D57; + + /** + * Establishes the data storage, format, dimensions, and number of + * samples of a renderbuffer object's image. + */ + void glRenderbufferStorageMultisample( + @GLenum int target, @GLsizei int samples, + @GLenum int internalformat, + @GLsizei int width, @GLsizei int height); + + // -------------------------------------------------------------------- + // ----------------------[ EXT_framebuffer_blit ]---------------------- + // -------------------------------------------------------------------- + + /** + * Accepted by the <target> parameter of BindFramebuffer, + * CheckFramebufferStatus, FramebufferTexture{1D|2D|3D}, + * FramebufferRenderbuffer, and + * GetFramebufferAttachmentParameteriv. + */ + int GL_READ_FRAMEBUFFER = 0x8CA8; + int GL_DRAW_FRAMEBUFFER = 0x8CA9; + + /** Accepted by the <pname> parameters of GetIntegerv, GetFloatv, and GetDoublev. */ + int GL_DRAW_FRAMEBUFFER_BINDING = 0x8CA6; // alias FRAMEBUFFER_BINDING + int GL_READ_FRAMEBUFFER_BINDING = 0x8CAA; + + /** + * Transfers a rectangle of pixel values from one + * region of the read framebuffer to another in the draw framebuffer. + * <mask> is the bitwise OR of a number of values indicating which + * buffers are to be copied. The values are COLOR_BUFFER_BIT, + * DEPTH_BUFFER_BIT, and STENCIL_BUFFER_BIT. + * The pixels corresponding to these buffers are + * copied from the source rectangle, bound by the locations (srcX0, + * srcY0) and (srcX1, srcY1) inclusive, to the destination rectangle, + * bound by the locations (dstX0, dstY0) and (dstX1, dstY1) + * inclusive. + * If the source and destination rectangle dimensions do not match, + * the source image is stretched to fit the destination + * rectangle. <filter> must be LINEAR or NEAREST and specifies the + * method of interpolation to be applied if the image is + * stretched. + */ + void glBlitFramebuffer( + @GLint int srcX0, @GLint int srcY0, @GLint int srcX1, @GLint int srcY1, + @GLint int dstX0, @GLint int dstY0, @GLint int dstX1, @GLint int dstY1, + @GLbitfield int mask, @GLenum int filter); + + // ------------------------------------------------------------------- + // ----------------------[ EXT_texture_integer ]---------------------- + // ------------------------------------------------------------------- + + /** + * Accepted by the <pname> parameters of GetBooleanv, GetIntegerv, + * GetFloatv, and GetDoublev: + */ + int GL_RGBA_INTEGER_MODE = 0x8D9E; + + /** + * Accepted by the <internalFormat> parameter of TexImage1D, + * TexImage2D, and TexImage3D: + */ + int GL_RGBA32UI = 0x8D70; + int GL_RGB32UI = 0x8D71; + int GL_ALPHA32UI = 0x8D72; + + int GL_RGBA16UI = 0x8D76; + int GL_RGB16UI = 0x8D77; + int GL_ALPHA16UI = 0x8D78; + + int GL_RGBA8UI = 0x8D7C; + int GL_RGB8UI = 0x8D7D; + int GL_ALPHA8UI = 0x8D7E; + + int GL_RGBA32I = 0x8D82; + int GL_RGB32I = 0x8D83; + int GL_ALPHA32I = 0x8D84; + + int GL_RGBA16I = 0x8D88; + int GL_RGB16I = 0x8D89; + int GL_ALPHA16I = 0x8D8A; + + int GL_RGBA8I = 0x8D8E; + int GL_RGB8I = 0x8D8F; + int GL_ALPHA8I = 0x8D90; + + /** + * Accepted by the <format> parameter of TexImage1D, TexImage2D, + * TexImage3D, TexSubImage1D, TexSubImage2D, TexSubImage3D, + * DrawPixels and ReadPixels: + */ + int GL_RED_INTEGER = 0x8D94; + int GL_GREEN_INTEGER = 0x8D95; + int GL_BLUE_INTEGER = 0x8D96; + int GL_ALPHA_INTEGER = 0x8D97; + int GL_RGB_INTEGER = 0x8D98; + int GL_RGBA_INTEGER = 0x8D99; + int GL_BGR_INTEGER = 0x8D9A; + int GL_BGRA_INTEGER = 0x8D9B; + + @StripPostfix("params") + void glTexParameterIiv(@GLenum int target, @GLenum int pname, @Check("4") IntBuffer params); + + @Alternate("glTexParameterIiv") + @StripPostfix(value = "param", postfix = "v") + void glTexParameterIiv(@GLenum int target, @GLenum int pname, @Constant(value = "APIUtils.getBufferInt().put(0, param), 0", keepParam = true) int param); + + @StripPostfix("params") + void glTexParameterIuiv(@GLenum int target, @GLenum int pname, @Check("4") @GLuint IntBuffer params); + + @Alternate("glTexParameterIuiv") + @StripPostfix(value = "param", postfix = "v") + void glTexParameterIuiv(@GLenum int target, @GLenum int pname, @Constant(value = "APIUtils.getBufferInt().put(0, param), 0", keepParam = true) int param); + + @StripPostfix("params") + void glGetTexParameterIiv(@GLenum int target, @GLenum int pname, @OutParameter @Check("4") IntBuffer params); + + @Alternate("glGetTexParameterIiv") + @GLreturn("params") + @StripPostfix(value = "params", postfix = "v") + void glGetTexParameterIiv2(@GLenum int target, @GLenum int pname, @OutParameter IntBuffer params); + + @StripPostfix("params") + void glGetTexParameterIuiv(@GLenum int target, @GLenum int pname, @OutParameter @Check("4") @GLuint IntBuffer params); + + @Alternate("glGetTexParameterIuiv") + @GLreturn("params") + @StripPostfix(value = "params", postfix = "v") + void glGetTexParameterIuiv2(@GLenum int target, @GLenum int pname, @OutParameter @GLuint IntBuffer params); + + // ----------------------------------------------------------------- + // ----------------------[ EXT_texture_array ]---------------------- + // ----------------------------------------------------------------- + + /** + * Accepted by the <target> parameter of TexParameteri, TexParameteriv, + * TexParameterf, TexParameterfv, and BindTexture: + */ + int GL_TEXTURE_1D_ARRAY = 0x8C18; + int GL_TEXTURE_2D_ARRAY = 0x8C1A; + + /** + * Accepted by the <target> parameter of TexImage3D, TexSubImage3D, + * CopyTexSubImage3D, CompressedTexImage3D, and CompressedTexSubImage3D: + */ + int GL_PROXY_TEXTURE_2D_ARRAY = 0x8C1B; + + /** + * Accepted by the <target> parameter of TexImage2D, TexSubImage2D, + * CopyTexImage2D, CopyTexSubImage2D, CompressedTexImage2D, and + * CompressedTexSubImage2D: + */ + int GL_PROXY_TEXTURE_1D_ARRAY = 0x8C19; + + /** + * Accepted by the <pname> parameter of GetBooleanv, GetDoublev, GetIntegerv + * and GetFloatv: + */ + int GL_TEXTURE_BINDING_1D_ARRAY = 0x8C1C; + int GL_TEXTURE_BINDING_2D_ARRAY = 0x8C1D; + int GL_MAX_ARRAY_TEXTURE_LAYERS = 0x88FF; + + /** + * Accepted by the <param> parameter of TexParameterf, TexParameteri, + * TexParameterfv, and TexParameteriv when the <pname> parameter is + * TEXTURE_COMPARE_MODE_ARB: + */ + int GL_COMPARE_REF_DEPTH_TO_TEXTURE = 0x884E; + + /** + * Accepted by the <pname> parameter of + * GetFramebufferAttachmentParameteriv: + */ + int GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER = 0x8CD4; + + /** Returned by the <type> parameter of GetActiveUniform: */ + int GL_SAMPLER_1D_ARRAY = 0x8DC0; + int GL_SAMPLER_2D_ARRAY = 0x8DC1; + int GL_SAMPLER_1D_ARRAY_SHADOW = 0x8DC3; + int GL_SAMPLER_2D_ARRAY_SHADOW = 0x8DC4; + + void glFramebufferTextureLayer(@GLenum int target, @GLenum int attachment, @GLuint int texture, int level, int layer); + + // ------------------------------------------------------------------------ + // ----------------------[ EXT_packed_depth_stencil ]---------------------- + // ------------------------------------------------------------------------ + + /** + * Accepted by the <format> parameter of DrawPixels, ReadPixels, + * TexImage1D, TexImage2D, TexImage3D, TexSubImage1D, TexSubImage2D, + * TexSubImage3D, and GetTexImage, by the <type> parameter of + * CopyPixels, by the <internalformat> parameter of TexImage1D, + * TexImage2D, TexImage3D, CopyTexImage1D, CopyTexImage2D, and + * RenderbufferStorage, and returned in the <data> parameter of + * GetTexLevelParameter and GetRenderbufferParameteriv. + */ + int GL_DEPTH_STENCIL = 0x84F9; + + /** + * Accepted by the <type> parameter of DrawPixels, ReadPixels, + * TexImage1D, TexImage2D, TexImage3D, TexSubImage1D, TexSubImage2D, + * TexSubImage3D, and GetTexImage. + */ + int GL_UNSIGNED_INT_24_8 = 0x84FA; + + /** + * Accepted by the <internalformat> parameter of TexImage1D, + * TexImage2D, TexImage3D, CopyTexImage1D, CopyTexImage2D, and + * RenderbufferStorage, and returned in the <data> parameter of + * GetTexLevelParameter and GetRenderbufferParameteriv. + */ + int GL_DEPTH24_STENCIL8 = 0x88F0; + + /** Accepted by the <value> parameter of GetTexLevelParameter. */ + int GL_TEXTURE_STENCIL_SIZE = 0x88F1; + + // ----------------------------------------------------------------- + // ----------------------[ EXT_draw_buffers2 ]---------------------- + // ----------------------------------------------------------------- + + void glColorMaski(@GLuint int buf, boolean r, boolean g, boolean b, boolean a); + + @StripPostfix(value = "data", hasPostfix = false) + void glGetBooleani_v(@GLenum int value, @GLuint int index, @OutParameter @Check("4") @GLboolean ByteBuffer data); + + @Alternate("glGetBooleani_v") + @GLreturn("data") + @StripPostfix(value = "data", hasPostfix = false) + void glGetBooleani_v2(@GLenum int value, @GLuint int index, @OutParameter @GLboolean ByteBuffer data); + + @StripPostfix("data") + void glGetIntegeri_v(@GLenum int value, @GLuint int index, @OutParameter @Check("4") IntBuffer data); + + @Alternate("glGetIntegeri_v") + @GLreturn("data") + @StripPostfix("data") + void glGetIntegeri_v2(@GLenum int value, @GLuint int index, @OutParameter IntBuffer data); + + void glEnablei(@GLenum int target, @GLuint int index); + + void glDisablei(@GLenum int target, @GLuint int index); + + boolean glIsEnabledi(@GLenum int target, @GLuint int index); + + // ---------------------------------------------------------------------------- + // ----------------------[ ARB_texture_compression_rgtc ]---------------------- + // ---------------------------------------------------------------------------- + + /** + * Accepted by the <internalformat> parameter of TexImage2D, + * CopyTexImage2D, and CompressedTexImage2D and the <format> parameter + * of CompressedTexSubImage2D: + */ + int GL_COMPRESSED_RED_RGTC1 = 0x8DBB; + int GL_COMPRESSED_SIGNED_RED_RGTC1 = 0x8DBC; + int GL_COMPRESSED_RED_GREEN_RGTC2 = 0x8DBD; + int GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2 = 0x8DBE; + + // -------------------------------------------------------------- + // ----------------------[ ARB_texture_rg ]---------------------- + // -------------------------------------------------------------- + + /** + * Accepted by the <internalFormat> parameter of TexImage1D, TexImage2D, + * TexImage3D, CopyTexImage1D, and CopyTexImage2D: + */ + int GL_R8 = 0x8229; + int GL_R16 = 0x822A; + + int GL_RG8 = 0x822B; + int GL_RG16 = 0x822C; + + int GL_R16F = 0x822D; + int GL_R32F = 0x822E; + + int GL_RG16F = 0x822F; + int GL_RG32F = 0x8230; + + int GL_R8I = 0x8231; + int GL_R8UI = 0x8232; + int GL_R16I = 0x8233; + int GL_R16UI = 0x8234; + int GL_R32I = 0x8235; + int GL_R32UI = 0x8236; + + int GL_RG8I = 0x8237; + int GL_RG8UI = 0x8238; + int GL_RG16I = 0x8239; + int GL_RG16UI = 0x823A; + int GL_RG32I = 0x823B; + int GL_RG32UI = 0x823C; + + /** + * Accepted by the <format> parameter of TexImage3D, TexImage2D, + * TexImage3D, TexSubImage1D, TexSubImage2D, TexSubImage3D, + * DrawPixels and ReadPixels: + */ + int GL_RG = 0x8227; + int GL_RG_INTEGER = 0x8228; + + /** + * Accepted by the <param> parameter of the TexParameter{if}* + * functions when <pname> is DEPTH_TEXTURE_MODE: + */ + int GL_RED = 0x1903; + + // ---------------------------------------------------------------------- + // ----------------------[ EXT_transform_feedback ]---------------------- + // ---------------------------------------------------------------------- + + /** + * Accepted by the <target> parameters of BindBuffer, BufferData, + * BufferSubData, MapBuffer, UnmapBuffer, GetBufferSubData, + * GetBufferPointerv, BindBufferRange, BindBufferOffset and + * BindBufferBase: + */ + int GL_TRANSFORM_FEEDBACK_BUFFER = 0x8C8E; + + /** + * Accepted by the <param> parameter of GetIntegerIndexedv and + * GetBooleanIndexedv: + */ + int GL_TRANSFORM_FEEDBACK_BUFFER_START = 0x8C84; + int GL_TRANSFORM_FEEDBACK_BUFFER_SIZE = 0x8C85; + + /** + * Accepted by the <param> parameter of GetIntegerIndexedv and + * GetBooleanIndexedv, and by the <pname> parameter of GetBooleanv, + * GetDoublev, GetIntegerv, and GetFloatv: + */ + int GL_TRANSFORM_FEEDBACK_BUFFER_BINDING = 0x8C8F; + + /** Accepted by the <bufferMode> parameter of TransformFeedbackVaryings: */ + int GL_INTERLEAVED_ATTRIBS = 0x8C8C; + int GL_SEPARATE_ATTRIBS = 0x8C8D; + + /** + * Accepted by the <target> parameter of BeginQuery, EndQuery, and + * GetQueryiv: + */ + int GL_PRIMITIVES_GENERATED = 0x8C87; + int GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN = 0x8C88; + + /** + * Accepted by the <cap> parameter of Enable, Disable, and IsEnabled, and by + * the <pname> parameter of GetBooleanv, GetIntegerv, GetFloatv, and + * GetDoublev: + */ + int GL_RASTERIZER_DISCARD = 0x8C89; + + /** + * Accepted by the <pname> parameter of GetBooleanv, GetDoublev, GetIntegerv, + * and GetFloatv: + */ + int GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS = 0x8C8A; + int GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS = 0x8C8B; + int GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS = 0x8C80; + + /** Accepted by the <pname> parameter of GetProgramiv: */ + int GL_TRANSFORM_FEEDBACK_VARYINGS = 0x8C83; + int GL_TRANSFORM_FEEDBACK_BUFFER_MODE = 0x8C7F; + int GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH = 0x8C76; + + void glBindBufferRange(@GLenum int target, @GLuint int index, @GLuint int buffer, @GLintptr long offset, @GLsizeiptr long size); + + void glBindBufferBase(@GLenum int target, @GLuint int index, @GLuint int buffer); + + void glBeginTransformFeedback(@GLenum int primitiveMode); + + void glEndTransformFeedback(); + + void glTransformFeedbackVaryings(@GLuint int program, @GLsizei int count, + @Const @NullTerminated("count") @GLchar @StringList("count") ByteBuffer varyings, + @GLenum int bufferMode); + + @Alternate("glTransformFeedbackVaryings") + void glTransformFeedbackVaryings(@GLuint int program, @Constant("varyings.length") @GLsizei int count, + @Const @NullTerminated @StringList("count") CharSequence[] varyings, + @GLenum int bufferMode); + + void glGetTransformFeedbackVarying(@GLuint int program, @GLuint int index, @AutoSize("name") @GLsizei int bufSize, + @OutParameter @GLsizei @Check(value = "1", canBeNull = true) IntBuffer length, + @OutParameter @GLsizei @Check("1") IntBuffer size, + @OutParameter @GLenum @Check("1") IntBuffer type, + @OutParameter @GLchar ByteBuffer name); + + @Alternate("glGetTransformFeedbackVarying") + @GLreturn(value = "name", maxLength = "bufSize") + void glGetTransformFeedbackVarying2(@GLuint int program, @GLuint int index, @GLsizei int bufSize, + @OutParameter @GLsizei @Constant("name_length, 0") IntBuffer length, + @OutParameter @GLsizei @Check("1") IntBuffer size, + @OutParameter @GLenum @Check("1") IntBuffer type, + @OutParameter @GLchar ByteBuffer name); + + // ----------------------------------------------------------------------- + // ----------------------[ ARB_vertex_array_object ]---------------------- + // ----------------------------------------------------------------------- + + /** + * Accepted by the <pname> parameter of GetBooleanv, GetIntegerv, + * GetFloatv, and GetDoublev: + */ + int GL_VERTEX_ARRAY_BINDING = 0x85B5; + + void glBindVertexArray(@GLuint int array); + + void glDeleteVertexArrays(@AutoSize("arrays") @GLsizei int n, @Const @GLuint IntBuffer arrays); + + @Alternate("glDeleteVertexArrays") + void glDeleteVertexArrays(@Constant("1") @GLsizei int n, @Constant(value = "APIUtils.getBufferInt().put(0, array), 0", keepParam = true) int array); + + void glGenVertexArrays(@AutoSize("arrays") @GLsizei int n, @OutParameter @GLuint IntBuffer arrays); + + @Alternate("glGenVertexArrays") + @GLreturn("arrays") + void glGenVertexArrays2(@Constant("1") @GLsizei int n, @OutParameter @GLuint IntBuffer arrays); + + boolean glIsVertexArray(@GLuint int array); + + // -------------------------------------------------------------------- + // ----------------------[ ARB_framebuffer_sRGB ]---------------------- + // -------------------------------------------------------------------- + + /** + * Accepted by the <cap> parameter of Enable, Disable, and IsEnabled, + * and by the <pname> parameter of GetBooleanv, GetIntegerv, GetFloatv, + * and GetDoublev: + */ + int GL_FRAMEBUFFER_SRGB = 0x8DB9; + + /** + * Accepted by the <pname> parameter of GetBooleanv, GetIntegerv, + * GetFloatv, and GetDoublev: + */ + int GL_FRAMEBUFFER_SRGB_CAPABLE = 0x8DBA; + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/GL31.java b/src/templates/org/lwjgl/opengl/GL31.java new file mode 100644 index 0000000..4baaad7 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/GL31.java @@ -0,0 +1,296 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +import java.nio.Buffer; +import java.nio.ByteBuffer; +import java.nio.IntBuffer; + +public interface GL31 { + + // ---------------------------------------------------------- + // ----------------------[ OpenGL 3.1 ]---------------------- + // ---------------------------------------------------------- + + int GL_RED_SNORM = 0x8F90; + int GL_RG_SNORM = 0x8F91; + int GL_RGB_SNORM = 0x8F92; + int GL_RGBA_SNORM = 0x8F93; + int GL_R8_SNORM = 0x8F94; + int GL_RG8_SNORM = 0x8F95; + int GL_RGB8_SNORM = 0x8F96; + int GL_RGBA8_SNORM = 0x8F97; + int GL_R16_SNORM = 0x8F98; + int GL_RG16_SNORM = 0x8F99; + int GL_RGB16_SNORM = 0x8F9A; + int GL_RGBA16_SNORM = 0x8F9B; + int GL_SIGNED_NORMALIZED = 0x8F9C; + + // ------------------------------------------------------------------ + // ----------------------[ ARB_draw_instanced ]---------------------- + // ------------------------------------------------------------------ + + void glDrawArraysInstanced(@GLenum int mode, int first, @GLsizei int count, @GLsizei int primcount); + + void glDrawElementsInstanced(@GLenum int mode, @AutoSize("indices") @GLsizei int count, @AutoType("indices") @GLenum int type, + @BufferObject(BufferKind.ElementVBO) + @Const + @GLubyte + @GLushort + @GLuint Buffer indices, @GLsizei int primcount); + + // --------------------------------------------------------------- + // ----------------------[ EXT_copy_buffer ]---------------------- + // --------------------------------------------------------------- + + int GL_COPY_READ_BUFFER = 0x8F36; + int GL_COPY_WRITE_BUFFER = 0x8F37; + + void glCopyBufferSubData(@GLenum int readtarget, @GLenum int writetarget, @GLintptr long readoffset, @GLintptr long writeoffset, @GLsizeiptr long size); + + // -------------------------------------------------------------------- + // ----------------------[ NV_primitive_restart ]---------------------- + // -------------------------------------------------------------------- + + /** + * Accepted by the <cap> parameter of IsEnabled, and by + * the <pname> parameter of GetBooleanv, GetIntegerv, GetFloatv, and + * GetDoublev: + */ + int GL_PRIMITIVE_RESTART = 0x8F9D; + + /** + * Accepted by the <pname> parameter of GetBooleanv, GetIntegerv, + * GetFloatv, and GetDoublev: + */ + int GL_PRIMITIVE_RESTART_INDEX = 0x8F9E; + + void glPrimitiveRestartIndex(@GLuint int index); + + // ------------------------------------------------------------------------- + // ----------------------[ ARB_texture_buffer_object ]---------------------- + // ------------------------------------------------------------------------- + + /** + * Accepted by the <target> parameter of BindBuffer, BufferData, + * BufferSubData, MapBuffer, MapBufferRange, BindTexture, UnmapBuffer, + * GetBufferSubData, GetBufferParameteriv, GetBufferPointerv, and TexBuffer, + * and the parameter of GetBooleanv, GetDoublev, GetFloatv, and + * GetIntegerv: + */ + int GL_TEXTURE_BUFFER = 0x8C2A; + + /** + * Accepted by the <pname> parameters of GetBooleanv, GetDoublev, + * GetFloatv, and GetIntegerv: + */ + int GL_MAX_TEXTURE_BUFFER_SIZE = 0x8C2B; + int GL_TEXTURE_BINDING_BUFFER = 0x8C2C; + int GL_TEXTURE_BUFFER_DATA_STORE_BINDING = 0x8C2D; + int GL_TEXTURE_BUFFER_FORMAT = 0x8C2E; + + void glTexBuffer(@GLenum int target, @GLenum int internalformat, @GLuint int buffer); + + // --------------------------------------------------------------------- + // ----------------------[ ARB_texture_rectangle ]---------------------- + // --------------------------------------------------------------------- + + /** + * Accepted by the <cap> parameter of Enable, Disable and IsEnabled; + * by the <pname> parameter of GetBooleanv, GetIntegerv, GetFloatv + * and GetDoublev; and by the <target> parameter of BindTexture, + * GetTexParameterfv, GetTexParameteriv, TexParameterf, TexParameteri, + * TexParameterfv and TexParameteriv: + * Accepted by the <target> parameter of GetTexImage, + * GetTexLevelParameteriv, GetTexLevelParameterfv, TexImage2D, + * CopyTexImage2D, TexSubImage2D and CopySubTexImage2D: + */ + int GL_TEXTURE_RECTANGLE = 0x84F5; + + /** + * Accepted by the <pname> parameter of GetBooleanv, GetIntegerv, + * GetFloatv and GetDoublev: + */ + int GL_TEXTURE_BINDING_RECTANGLE = 0x84F6; + + /** + * Accepted by the <target> parameter of GetTexLevelParameteriv, + * GetTexLevelParameterfv, GetTexParameteriv and TexImage2D: + */ + int GL_PROXY_TEXTURE_RECTANGLE = 0x84F7; + + /** + * Accepted by the <pname> parameter of GetBooleanv, GetDoublev, + * GetIntegerv and GetFloatv: + */ + int GL_MAX_RECTANGLE_TEXTURE_SIZE = 0x84F8; + + /** + * Returned by <type> parameter of GetActiveUniform when the location + * <index> for program object <program> is of type sampler2DRect: + */ + int GL_SAMPLER_2D_RECT = 0x8B63; + + /** + * Returned by <type> parameter of GetActiveUniform when the location + * <index> for program object <program> is of type sampler2DRectShadow: + */ + int GL_SAMPLER_2D_RECT_SHADOW = 0x8B64; + + // ------------------------------------------------------------------------- + // ----------------------[ ARB_uniform_buffer_object ]---------------------- + // ------------------------------------------------------------------------- + + /** + * Accepted by the <target> parameters of BindBuffer, BufferData, + * BufferSubData, MapBuffer, UnmapBuffer, GetBufferSubData, and + * GetBufferPointerv: + */ + int GL_UNIFORM_BUFFER = 0x8A11; + + /** + * Accepted by the <pname> parameter of GetIntegeri_v, GetBooleanv, + * GetIntegerv, GetFloatv, and GetDoublev: + */ + int GL_UNIFORM_BUFFER_BINDING = 0x8A28; + + /** Accepted by the <pname> parameter of GetIntegeri_v: */ + int GL_UNIFORM_BUFFER_START = 0x8A29; + int GL_UNIFORM_BUFFER_SIZE = 0x8A2A; + + /** + * Accepted by the <pname> parameter of GetBooleanv, GetIntegerv, + * GetFloatv, and GetDoublev: + */ + int GL_MAX_VERTEX_UNIFORM_BLOCKS = 0x8A2B; + int GL_MAX_GEOMETRY_UNIFORM_BLOCKS = 0x8A2C; + int GL_MAX_FRAGMENT_UNIFORM_BLOCKS = 0x8A2D; + int GL_MAX_COMBINED_UNIFORM_BLOCKS = 0x8A2E; + int GL_MAX_UNIFORM_BUFFER_BINDINGS = 0x8A2F; + int GL_MAX_UNIFORM_BLOCK_SIZE = 0x8A30; + int GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS = 0x8A31; + int GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS = 0x8A32; + int GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS = 0x8A33; + int GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT = 0x8A34; + + /** Accepted by the <pname> parameter of GetProgramiv: */ + int GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH = 0x8A35; + int GL_ACTIVE_UNIFORM_BLOCKS = 0x8A36; + + /** Accepted by the <pname> parameter of GetActiveUniformsiv: */ + int GL_UNIFORM_TYPE = 0x8A37; + int GL_UNIFORM_SIZE = 0x8A38; + int GL_UNIFORM_NAME_LENGTH = 0x8A39; + int GL_UNIFORM_BLOCK_INDEX = 0x8A3A; + int GL_UNIFORM_OFFSET = 0x8A3B; + int GL_UNIFORM_ARRAY_STRIDE = 0x8A3C; + int GL_UNIFORM_MATRIX_STRIDE = 0x8A3D; + int GL_UNIFORM_IS_ROW_MAJOR = 0x8A3E; + + /** Accepted by the <pname> parameter of GetActiveUniformBlockiv: */ + int GL_UNIFORM_BLOCK_BINDING = 0x8A3F; + int GL_UNIFORM_BLOCK_DATA_SIZE = 0x8A40; + int GL_UNIFORM_BLOCK_NAME_LENGTH = 0x8A41; + int GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS = 0x8A42; + int GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES = 0x8A43; + int GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER = 0x8A44; + int GL_UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER = 0x8A45; + int GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER = 0x8A46; + + /** Returned by GetActiveUniformsiv and GetUniformBlockIndex */ + int GL_INVALID_INDEX = 0xFFFFFFFF; + + void glGetUniformIndices(@GLuint int program, @AutoSize("uniformIndices") @GLsizei int uniformCount, + @Const @NullTerminated("uniformIndices.remaining()") @GLchar @StringList("uniformCount") ByteBuffer uniformNames, + @OutParameter @GLuint IntBuffer uniformIndices); + + @Alternate("glGetUniformIndices") + void glGetUniformIndices(@GLuint int program, @Constant("uniformNames.length") @GLsizei int uniformCount, + @Const @NullTerminated @StringList("uniformCount") CharSequence[] uniformNames, + @OutParameter @Check("uniformNames.length") @GLuint IntBuffer uniformIndices); + + @StripPostfix("params") + void glGetActiveUniformsiv(@GLuint int program, @AutoSize("uniformIndices") @GLsizei int uniformCount, + @Const @GLuint IntBuffer uniformIndices, + @GLenum int pname, + @OutParameter @Check("uniformIndices.remaining()") @GLint IntBuffer params); + + @Alternate("glGetActiveUniformsiv") + @GLreturn("params") + @StripPostfix("params") + void glGetActiveUniformsiv(@GLuint int program, @Constant("1") @GLsizei int uniformCount, + @Constant(value = "params.put(1, uniformIndex), 1", keepParam = true) int uniformIndex, // Reuse params buffer + @GLenum int pname, + @OutParameter @GLint IntBuffer params); + + void glGetActiveUniformName(@GLuint int program, @GLuint int uniformIndex, @AutoSize("uniformName") @GLsizei int bufSize, + @OutParameter @GLsizei @Check(value = "1", canBeNull = true) IntBuffer length, + @OutParameter @GLchar ByteBuffer uniformName); + + @Alternate("glGetActiveUniformName") + @GLreturn(value = "uniformName", maxLength = "bufSize") + void glGetActiveUniformName2(@GLuint int program, @GLuint int uniformIndex, @GLsizei int bufSize, + @OutParameter @GLsizei @Constant("uniformName_length, 0") IntBuffer length, + @OutParameter @GLchar ByteBuffer uniformName); + + @GLuint + int glGetUniformBlockIndex(@GLuint int program, @Const @NullTerminated @GLchar ByteBuffer uniformBlockName); + + @Alternate("glGetUniformBlockIndex") + @GLuint + int glGetUniformBlockIndex(@GLuint int program, @NullTerminated CharSequence uniformBlockName); + + @StripPostfix("params") + void glGetActiveUniformBlockiv(@GLuint int program, @GLuint int uniformBlockIndex, @GLenum int pname, + @OutParameter @Check(value = "16") @GLint IntBuffer params); + + @Alternate("glGetActiveUniformBlockiv") + @GLreturn("params") + @StripPostfix("params") + void glGetActiveUniformBlockiv2(@GLuint int program, @GLuint int uniformBlockIndex, @GLenum int pname, + @OutParameter @GLint IntBuffer params); + + void glGetActiveUniformBlockName(@GLuint int program, @GLuint int uniformBlockIndex, @AutoSize("uniformBlockName") @GLsizei int bufSize, + @OutParameter @GLsizei @Check(value = "1", canBeNull = true) IntBuffer length, + @OutParameter @GLchar ByteBuffer uniformBlockName); + + @Alternate("glGetActiveUniformBlockName") + @GLreturn(value = "uniformBlockName", maxLength = "bufSize") + void glGetActiveUniformBlockName2(@GLuint int program, @GLuint int uniformBlockIndex, @GLsizei int bufSize, + @OutParameter @GLsizei @Constant("uniformBlockName_length, 0") IntBuffer length, + @OutParameter @GLchar ByteBuffer uniformBlockName); + + void glUniformBlockBinding(@GLuint int program, @GLuint int uniformBlockIndex, @GLuint int uniformBlockBinding); + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/GL32.java b/src/templates/org/lwjgl/opengl/GL32.java new file mode 100644 index 0000000..d823725 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/GL32.java @@ -0,0 +1,339 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +import java.nio.Buffer; +import java.nio.FloatBuffer; +import java.nio.IntBuffer; +import java.nio.LongBuffer; + +public interface GL32 { + + // ---------------------------------------------------------- + // ----------------------[ OpenGL 3.2 ]---------------------- + // ---------------------------------------------------------- + + int GL_CONTEXT_PROFILE_MASK = 0x9126; + int GL_CONTEXT_CORE_PROFILE_BIT = 0x00000001; + int GL_CONTEXT_COMPATIBILITY_PROFILE_BIT = 0x00000002; + + int GL_MAX_VERTEX_OUTPUT_COMPONENTS = 0x9122; + int GL_MAX_GEOMETRY_INPUT_COMPONENTS = 0x9123; + int GL_MAX_GEOMETRY_OUTPUT_COMPONENTS = 0x9124; + int GL_MAX_FRAGMENT_INPUT_COMPONENTS = 0x9125; + + // --------------------------------------------------------------------- + // ----------------------[ ARB_vertex_array_bgra ]---------------------- + // --------------------------------------------------------------------- + + int GL_BGRA = 0x80E1; + + // ----------------------------------------------------------------------------- + // ----------------------[ ARB_draw_elements_base_vertex ]---------------------- + // ----------------------------------------------------------------------------- + + void glDrawElementsBaseVertex(@GLenum int mode, @AutoSize("indices") @GLsizei int count, @AutoType("indices") @GLenum int type, + @BufferObject(BufferKind.ElementVBO) + @Const + @GLubyte + @GLushort + @GLuint Buffer indices, int basevertex); + + void glDrawRangeElementsBaseVertex(@GLenum int mode, @GLuint int start, @GLuint int end, @AutoSize("indices") @GLsizei int count, @AutoType("indices") @GLenum int type, + @BufferObject(BufferKind.ElementVBO) + @Const + @GLubyte + @GLushort + @GLuint Buffer indices, int basevertex); + + void glDrawElementsInstancedBaseVertex(@GLenum int mode, @AutoSize("indices") @GLsizei int count, @AutoType("indices") @GLenum int type, + @BufferObject(BufferKind.ElementVBO) + @Const + @GLubyte + @GLushort + @GLuint Buffer indices, @GLsizei int primcount, int basevertex); + + //void glMultiDrawElementsBaseVertex(@GLenum int mode, @GLsizei*count, @GLenum int type, void**indices, @GLsizei int primcount, int*basevertex) + + // -------------------------------------------------------------------- + // ----------------------[ ARB_provoking_vertex ]---------------------- + // -------------------------------------------------------------------- + + /** Accepted by the <mode> parameter of ProvokingVertex: */ + int GL_FIRST_VERTEX_CONVENTION = 0x8E4D; + int GL_LAST_VERTEX_CONVENTION = 0x8E4E; + + /** + * Accepted by the <pname> parameter of GetBooleanv, GetIntegerv, + * GetFloatv, and GetDoublev: + */ + int GL_PROVOKING_VERTEX = 0x8E4F; + int GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION = 0x8E4C; + + void glProvokingVertex(@GLenum int mode); + + // --------------------------------------------------------------------- + // ----------------------[ ARB_seamless_cube_map ]---------------------- + // --------------------------------------------------------------------- + + /** + * Accepted by the <cap> parameter of Enable, Disable and IsEnabled, + * and by the <pname> parameter of GetBooleanv, GetIntegerv, GetFloatv + * and GetDoublev: + */ + int GL_TEXTURE_CUBE_MAP_SEAMLESS = 0x884F; + + // ----------------------------------------------------------------------- + // ----------------------[ ARB_texture_multisample ]---------------------- + // ----------------------------------------------------------------------- + + /** Accepted by the <pname> parameter of GetMultisamplefv: */ + int GL_SAMPLE_POSITION = 0x8E50; + + /** + * Accepted by the <cap> parameter of Enable, Disable, and IsEnabled, and by + * the <pname> parameter of GetBooleanv, GetIntegerv, GetFloatv, and + * GetDoublev: + */ + int GL_SAMPLE_MASK = 0x8E51; + + /** + * Accepted by the <target> parameter of GetBooleani_v and + * GetIntegeri_v: + */ + int GL_SAMPLE_MASK_VALUE = 0x8E52; + + /** + * Accepted by the <target> parameter of BindTexture and + * TexImage2DMultisample: + */ + int GL_TEXTURE_2D_MULTISAMPLE = 0x9100; + + /** Accepted by the <target> parameter of TexImage2DMultisample: */ + int GL_PROXY_TEXTURE_2D_MULTISAMPLE = 0x9101; + + /** + * Accepted by the <target> parameter of BindTexture and + * TexImage3DMultisample: + */ + int GL_TEXTURE_2D_MULTISAMPLE_ARRAY = 0x9102; + + /** Accepted by the <target> parameter of TexImage3DMultisample: */ + int GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY = 0x9103; + + /** + * Accepted by the <pname> parameter of GetBooleanv, GetDoublev, GetIntegerv, + * and GetFloatv: + */ + int GL_MAX_SAMPLE_MASK_WORDS = 0x8E59; + int GL_MAX_COLOR_TEXTURE_SAMPLES = 0x910E; + int GL_MAX_DEPTH_TEXTURE_SAMPLES = 0x910F; + int GL_MAX_INTEGER_SAMPLES = 0x9110; + int GL_TEXTURE_BINDING_2D_MULTISAMPLE = 0x9104; + int GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY = 0x9105; + + /** Accepted by the <pname> parameter of GetTexLevelParameter */ + int GL_TEXTURE_SAMPLES = 0x9106; + int GL_TEXTURE_FIXED_SAMPLE_LOCATIONS = 0x9107; + + /** Returned by the <type> parameter of GetActiveUniform: */ + int GL_SAMPLER_2D_MULTISAMPLE = 0x9108; + int GL_INT_SAMPLER_2D_MULTISAMPLE = 0x9109; + int GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE = 0x910A; + int GL_SAMPLER_2D_MULTISAMPLE_ARRAY = 0x910B; + int GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY = 0x910C; + int GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY = 0x910D; + + void glTexImage2DMultisample(@GLenum int target, @GLsizei int samples, int internalformat, + @GLsizei int width, @GLsizei int height, + boolean fixedsamplelocations); + + void glTexImage3DMultisample(@GLenum int target, @GLsizei int samples, int internalformat, + @GLsizei int width, @GLsizei int height, @GLsizei int depth, + boolean fixedsamplelocations); + + @StripPostfix("val") + void glGetMultisamplefv(@GLenum int pname, @GLuint int index, @OutParameter @Check("2") FloatBuffer val); + + void glSampleMaski(@GLuint int index, @GLbitfield int mask); + + // --------------------------------------------------------------- + // ----------------------[ ARB_depth_clamp ]---------------------- + // --------------------------------------------------------------- + + /** + * Accepted by the <cap> parameter of Enable, Disable, and IsEnabled, + * and by the <pname> parameter of GetBooleanv, GetIntegerv, + * GetFloatv, and GetDoublev: + */ + int GL_DEPTH_CLAMP = 0x864F; + + // -------------------------------------------------------------------- + // ----------------------[ ARB_geometry_shader4 ]---------------------- + // -------------------------------------------------------------------- + + /** + * Accepted by the <type> parameter of CreateShader and returned by the + * <params> parameter of GetShaderiv: + */ + int GL_GEOMETRY_SHADER = 0x8DD9; + + /** + * Accepted by the <pname> parameter of ProgramParameteriEXT and + * GetProgramiv: + */ + int GL_GEOMETRY_VERTICES_OUT = 0x8DDA; + int GL_GEOMETRY_INPUT_TYPE = 0x8DDB; + int GL_GEOMETRY_OUTPUT_TYPE = 0x8DDC; + + /** + * Accepted by the <pname> parameter of GetBooleanv, GetIntegerv, + * GetFloatv, and GetDoublev: + */ + int GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS = 0x8C29; + //int GL_MAX_GEOMETRY_VARYING_COMPONENTS = 0x8DDD; -- Missing from 3.2 spec + //int GL_MAX_VERTEX_VARYING_COMPONENTS = 0x8DDE; -- Missing from 3.2 spec + int GL_MAX_VARYING_COMPONENTS = 0x8B4B; + int GL_MAX_GEOMETRY_UNIFORM_COMPONENTS = 0x8DDF; + int GL_MAX_GEOMETRY_OUTPUT_VERTICES = 0x8DE0; + int GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS = 0x8DE1; + + /** + * Accepted by the <mode> parameter of Begin, DrawArrays, + * MultiDrawArrays, DrawElements, MultiDrawElements, and + * DrawRangeElements: + */ + int GL_LINES_ADJACENCY = 0xA; + int GL_LINE_STRIP_ADJACENCY = 0xB; + int GL_TRIANGLES_ADJACENCY = 0xC; + int GL_TRIANGLE_STRIP_ADJACENCY = 0xD; + + /** Returned by CheckFramebufferStatusEXT: */ + int GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS = 0x8DA8; + int GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT = 0x8DA9; + + /** + * Accepted by the <pname> parameter of GetFramebufferAttachment- + * ParameterivEXT: + */ + int GL_FRAMEBUFFER_ATTACHMENT_LAYERED = 0x8DA7; + int GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER = 0x8CD4; + + /** + * Accepted by the <cap> parameter of Enable, Disable, and IsEnabled, + * and by the <pname> parameter of GetIntegerv, GetFloatv, GetDoublev, + * and GetBooleanv: + */ + int GL_PROGRAM_POINT_SIZE = 0x8642; + + void glFramebufferTexture(@GLenum int target, @GLenum int attachment, @GLuint int texture, int level); + + void glFramebufferTextureLayer(@GLenum int target, @GLenum int attachment, @GLuint int texture, int level, int layer); + + // -------------------------------------------------------- + // ----------------------[ ARB_sync ]---------------------- + // -------------------------------------------------------- + + /** Accepted as the <pname> parameter of GetInteger64v: */ + int GL_MAX_SERVER_WAIT_TIMEOUT = 0x9111; + + /** Accepted as the <pname> parameter of GetSynciv: */ + int GL_OBJECT_TYPE = 0x9112; + int GL_SYNC_CONDITION = 0x9113; + int GL_SYNC_STATUS = 0x9114; + int GL_SYNC_FLAGS = 0x9115; + + /** Returned in <values> for GetSynciv <pname> OBJECT_TYPE: */ + int GL_SYNC_FENCE = 0x9116; + + /** Returned in <values> for GetSynciv <pname> SYNC_CONDITION: */ + int GL_SYNC_GPU_COMMANDS_COMPLETE = 0x9117; + + /** Returned in <values> for GetSynciv <pname> SYNC_STATUS: */ + int GL_UNSIGNALED = 0x9118; + int GL_SIGNALED = 0x9119; + + /** Accepted in the <flags> parameter of ClientWaitSync: */ + int GL_SYNC_FLUSH_COMMANDS_BIT = 0x00000001; + + /** Accepted in the <timeout> parameter of WaitSync: */ + long GL_TIMEOUT_IGNORED = 0xFFFFFFFFFFFFFFFFl; + + /** Returned by ClientWaitSync: */ + int GL_ALREADY_SIGNALED = 0x911A; + int GL_TIMEOUT_EXPIRED = 0x911B; + int GL_CONDITION_SATISFIED = 0x911C; + int GL_WAIT_FAILED = 0x911D; + + @GLpointer("GLsync") + GLSync glFenceSync(@GLenum int condition, @GLbitfield int flags); + + boolean glIsSync(@GLpointer("GLsync") GLSync sync); + + void glDeleteSync(@GLpointer("GLsync") GLSync sync); + + @GLenum + int glClientWaitSync(@GLpointer("GLsync") GLSync sync, @GLbitfield int flags, @GLuint64 long timeout); + + void glWaitSync(@GLpointer("GLsync") GLSync sync, @GLbitfield int flags, @GLuint64 long timeout); + + @StripPostfix(value = "data", postfix = "64") + void glGetInteger64v(@GLenum int pname, @OutParameter @Check("1") @GLint64 LongBuffer data); + + @Alternate("glGetInteger64v") + @GLreturn("data") + @StripPostfix(value = "data", postfix = "64") + void glGetInteger64v2(@GLenum int pname, @OutParameter @GLint64 LongBuffer data); + + @StripPostfix(value = "data", postfix = "64") + @Optional(reason = "NV's 3.2 implementation does not expose this (last driver checked: 19?.??)") + void glGetInteger64i_v(@GLenum int value, @GLuint int index, @OutParameter @Check("4") @GLint64 LongBuffer data); + + @Alternate("glGetInteger64i_v") + @GLreturn("data") + @StripPostfix(value = "data", postfix = "64") + void glGetInteger64i_v2(@GLenum int value, @GLuint int index, @OutParameter @GLint64 LongBuffer data); + + @StripPostfix("values") + void glGetSynciv(@GLpointer("GLsync") GLSync sync, @GLenum int pname, @AutoSize("values") @GLsizei int bufSize, + @OutParameter @GLsizei @Check(value = "1", canBeNull = true) IntBuffer length, + @OutParameter IntBuffer values); + + @Alternate("glGetSynciv") + @GLreturn("values") + @StripPostfix("values") + void glGetSynciv2(@GLpointer("GLsync") GLSync sync, @GLenum int pname, @Constant("1") @GLsizei int bufSize, + @OutParameter @GLsizei @Constant("null, 0") IntBuffer length, + @OutParameter IntBuffer values); +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/GL33.java b/src/templates/org/lwjgl/opengl/GL33.java new file mode 100644 index 0000000..0a6330f --- /dev/null +++ b/src/templates/org/lwjgl/opengl/GL33.java @@ -0,0 +1,418 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +import java.nio.ByteBuffer; +import java.nio.FloatBuffer; +import java.nio.IntBuffer; +import java.nio.LongBuffer; + +@DeprecatedGL +public interface GL33 { + + // ----------------------------------------------------------------------- + // ----------------------[ ARB_blend_func_extended ]---------------------- + // ----------------------------------------------------------------------- + + /** + * Accepted by the <src> and <dst> parameters of BlendFunc and + * BlendFunci, and by the <srcRGB>, <dstRGB>, <srcAlpha> and <dstAlpha> + * parameters of BlendFuncSeparate and BlendFuncSeparatei: + */ + int GL_SRC1_COLOR = 0x88F9; + int GL_SRC1_ALPHA = GL15.GL_SRC1_ALPHA; + int GL_ONE_MINUS_SRC1_COLOR = 0x88FA; + int GL_ONE_MINUS_SRC1_ALPHA = 0x88FB; + + /** + * Accepted by the <pname> parameter of GetBooleanv, GetIntegerv, GetFloatv + * and GetDoublev: + */ + int GL_MAX_DUAL_SOURCE_DRAW_BUFFERS = 0x88FC; + + void glBindFragDataLocationIndexed(@GLuint int program, @GLuint int colorNumber, @GLuint int index, @NullTerminated @Const @GLchar ByteBuffer name); + + @Alternate("glBindFragDataLocationIndexed") + void glBindFragDataLocationIndexed(@GLuint int program, @GLuint int colorNumber, @GLuint int index, @NullTerminated CharSequence name); + + int glGetFragDataIndex(@GLuint int program, @NullTerminated @Const @GLchar ByteBuffer name); + + @Alternate("glGetFragDataIndex") + int glGetFragDataIndex(@GLuint int program, @NullTerminated CharSequence name); + + // -------------------------------------------------------------------- + // ----------------------[ ARB_occlusion_query2 ]---------------------- + // -------------------------------------------------------------------- + + /** + * Accepted by the <target> parameter of BeginQuery, EndQuery, + * and GetQueryiv: + */ + int GL_ANY_SAMPLES_PASSED = 0x8C2F; + + // ------------------------------------------------------------------- + // ----------------------[ ARB_sampler_objects ]---------------------- + // ------------------------------------------------------------------- + + /** + * Accepted by the <value> parameter of the GetBooleanv, GetIntegerv, + * GetInteger64v, GetFloatv and GetDoublev functions: + */ + int GL_SAMPLER_BINDING = 0x8919; + + void glGenSamplers(@AutoSize("samplers") @GLsizei int count, @OutParameter @GLuint IntBuffer samplers); + + @Alternate("glGenSamplers") + @GLreturn("samplers") + void glGenSamplers2(@Constant("1") @GLsizei int count, @OutParameter @GLuint IntBuffer samplers); + + void glDeleteSamplers(@AutoSize("samplers") @GLsizei int count, @Const @GLuint IntBuffer samplers); + + @Alternate("glDeleteSamplers") + void glDeleteSamplers(@Constant("1") @GLsizei int count, @Constant(value = "APIUtils.getBufferInt().put(0, sampler), 0", keepParam = true) int sampler); + + boolean glIsSampler(@GLuint int sampler); + + void glBindSampler(@GLenum int unit, @GLuint int sampler); + + void glSamplerParameteri(@GLuint int sampler, @GLenum int pname, int param); + + void glSamplerParameterf(@GLuint int sampler, @GLenum int pname, float param); + + @StripPostfix("params") + void glSamplerParameteriv(@GLuint int sampler, @GLenum int pname, @Check("4") @Const IntBuffer params); + + @StripPostfix("params") + void glSamplerParameterfv(@GLuint int sampler, @GLenum int pname, @Check("4") @Const FloatBuffer params); + + @StripPostfix("params") + void glSamplerParameterIiv(@GLuint int sampler, @GLenum int pname, @Check("4") @Const IntBuffer params); + + @StripPostfix("params") + void glSamplerParameterIuiv(@GLuint int sampler, @GLenum int pname, @Check("4") @Const @GLuint IntBuffer params); + + @StripPostfix("params") + void glGetSamplerParameteriv(@GLuint int sampler, @GLenum int pname, @Check("4") @OutParameter IntBuffer params); + + @Alternate("glGetSamplerParameteriv") + @GLreturn("params") + @StripPostfix(value = "params", postfix = "v") + void glGetSamplerParameteriv2(@GLuint int sampler, @GLenum int pname, @OutParameter IntBuffer params); + + @StripPostfix("params") + void glGetSamplerParameterfv(@GLuint int sampler, @GLenum int pname, @Check("4") @OutParameter FloatBuffer params); + + @Alternate("glGetSamplerParameterfv") + @GLreturn("params") + @StripPostfix(value = "params", postfix = "v") + void glGetSamplerParameterfv2(@GLuint int sampler, @GLenum int pname, @OutParameter FloatBuffer params); + + @StripPostfix("params") + void glGetSamplerParameterIiv(@GLuint int sampler, @GLenum int pname, @Check("4") @OutParameter IntBuffer params); + + @Alternate("glGetSamplerParameterIiv") + @GLreturn("params") + @StripPostfix(value = "params", postfix = "v") + void glGetSamplerParameterIiv2(@GLuint int sampler, @GLenum int pname, @OutParameter IntBuffer params); + + @StripPostfix("params") + void glGetSamplerParameterIuiv(@GLuint int sampler, @GLenum int pname, @Check("4") @OutParameter IntBuffer params); + + @Alternate("glGetSamplerParameterIuiv") + @GLreturn("params") + @StripPostfix(value = "params", postfix = "v") + void glGetSamplerParameterIuiv2(@GLuint int sampler, @GLenum int pname, @OutParameter IntBuffer params); + + // ------------------------------------------------------------------- + // ----------------------[ ARB_texture_rgb10_a2ui ]---------------------- + // ------------------------------------------------------------------- + + /** + * Accepted by the <internalFormat> parameter of TexImage1D, TexImage2D, + * TexImage3D, CopyTexImage1D, CopyTexImage2D, RenderbufferStorage and + * RenderbufferStorageMultisample: + */ + int GL_RGB10_A2UI = 0x906F; + + // ------------------------------------------------------------------- + // ----------------------[ ARB_texture_swizzle ]---------------------- + // ------------------------------------------------------------------- + + /** + * Accepted by the <pname> parameters of TexParameteri, + * TexParameterf, TexParameteriv, TexParameterfv, + * GetTexParameterfv, and GetTexParameteriv: + */ + int GL_TEXTURE_SWIZZLE_R = 0x8E42; + int GL_TEXTURE_SWIZZLE_G = 0x8E43; + int GL_TEXTURE_SWIZZLE_B = 0x8E44; + int GL_TEXTURE_SWIZZLE_A = 0x8E45; + + /** + * Accepted by the <pname> parameters of TexParameteriv, + * TexParameterfv, GetTexParameterfv, and GetTexParameteriv: + */ + int GL_TEXTURE_SWIZZLE_RGBA = 0x8E46; + + // --------------------------------------------------------------- + // ----------------------[ ARB_timer_query ]---------------------- + // --------------------------------------------------------------- + + /** + * Accepted by the <target> parameter of BeginQuery, EndQuery, and + * GetQueryiv: + */ + int GL_TIME_ELAPSED = 0x88BF; + + /** + * Accepted by the <target> parameter of GetQueryiv and QueryCounter. + * Accepted by the <value> parameter of GetBooleanv, GetIntegerv, + * GetInteger64v, GetFloatv, and GetDoublev: + */ + int GL_TIMESTAMP = 0x8E28; + + void glQueryCounter(@GLuint int id, @GLenum int target); + + @StripPostfix("params") + void glGetQueryObjecti64v(@GLuint int id, @GLenum int pname, @OutParameter @Check("1") @GLint64 LongBuffer params); + + @Alternate("glGetQueryObjecti64v") + @GLreturn("params") + @StripPostfix("params") + void glGetQueryObjecti64v2(@GLuint int id, @GLenum int pname, @OutParameter @GLint64 LongBuffer params); + + @StripPostfix("params") + void glGetQueryObjectui64v(@GLuint int id, @GLenum int pname, @OutParameter @Check("1") @GLuint64 LongBuffer params); + + @Alternate("glGetQueryObjectui64v") + @GLreturn("params") + @StripPostfix("params") + void glGetQueryObjectui64v2(@GLuint int id, @GLenum int pname, @OutParameter @GLuint64 LongBuffer params); + + // -------------------------------------------------------------------- + // ----------------------[ ARB_instanced_arrays ]---------------------- + // -------------------------------------------------------------------- + + /** + * Accepted by the <pname> parameters of GetVertexAttribdv, + * GetVertexAttribfv, and GetVertexAttribiv: + */ + int GL_VERTEX_ATTRIB_ARRAY_DIVISOR = 0x88FE; + + void glVertexAttribDivisor(@GLuint int index, @GLuint int divisor); + + // ------------------------------------------------------------------------------ + // ----------------------[ ARB_vertex_type_2_10_10_10_rev ]---------------------- + // ------------------------------------------------------------------------------ + + /** + * Accepted by the <type> parameter of VertexAttribPointer, VertexPointer, + * NormalPointer, ColorPointer, SecondaryColorPointer, TexCoordPointer, + * VertexAttribP{1234}ui, VertexP*, TexCoordP*, MultiTexCoordP*, NormalP3ui, + * ColorP*, SecondaryColorP* and VertexAttribP* + */ + int GL_INT_2_10_10_10_REV = 0x8D9F; + + @NoErrorCheck + @DeprecatedGL + void glVertexP2ui(@GLenum int type, @GLuint int value); + + @NoErrorCheck + @DeprecatedGL + void glVertexP3ui(@GLenum int type, @GLuint int value); + + @NoErrorCheck + @DeprecatedGL + void glVertexP4ui(@GLenum int type, @GLuint int value); + + @NoErrorCheck + @DeprecatedGL + @StripPostfix("value") + void glVertexP2uiv(@GLenum int type, @Check("2") @Const @GLuint IntBuffer value); + + @NoErrorCheck + @DeprecatedGL + @StripPostfix("value") + void glVertexP3uiv(@GLenum int type, @Check("3") @Const @GLuint IntBuffer value); + + @NoErrorCheck + @DeprecatedGL + @StripPostfix("value") + void glVertexP4uiv(@GLenum int type, @Check("4") @Const @GLuint IntBuffer value); + + @NoErrorCheck + @DeprecatedGL + void glTexCoordP1ui(@GLenum int type, @GLuint int coords); + + @NoErrorCheck + @DeprecatedGL + void glTexCoordP2ui(@GLenum int type, @GLuint int coords); + + @NoErrorCheck + @DeprecatedGL + void glTexCoordP3ui(@GLenum int type, @GLuint int coords); + + @NoErrorCheck + @DeprecatedGL + void glTexCoordP4ui(@GLenum int type, @GLuint int coords); + + @NoErrorCheck + @DeprecatedGL + @StripPostfix("coords") + void glTexCoordP1uiv(@GLenum int type, @Check("1") @Const @GLuint IntBuffer coords); + + @NoErrorCheck + @DeprecatedGL + @StripPostfix("coords") + void glTexCoordP2uiv(@GLenum int type, @Check("2") @Const @GLuint IntBuffer coords); + + @NoErrorCheck + @DeprecatedGL + @StripPostfix("coords") + void glTexCoordP3uiv(@GLenum int type, @Check("3") @Const @GLuint IntBuffer coords); + + @NoErrorCheck + @DeprecatedGL + @StripPostfix("coords") + void glTexCoordP4uiv(@GLenum int type, @Check("4") @Const @GLuint IntBuffer coords); + + @NoErrorCheck + @DeprecatedGL + void glMultiTexCoordP1ui(@GLenum int texture, @GLenum int type, @GLuint int coords); + + @NoErrorCheck + @DeprecatedGL + void glMultiTexCoordP2ui(@GLenum int texture, @GLenum int type, @GLuint int coords); + + @NoErrorCheck + @DeprecatedGL + void glMultiTexCoordP3ui(@GLenum int texture, @GLenum int type, @GLuint int coords); + + @NoErrorCheck + @DeprecatedGL + void glMultiTexCoordP4ui(@GLenum int texture, @GLenum int type, @GLuint int coords); + + @NoErrorCheck + @DeprecatedGL + @StripPostfix("coords") + void glMultiTexCoordP1uiv(@GLenum int texture, @GLenum int type, @Check("1") @Const @GLuint IntBuffer coords); + + @NoErrorCheck + @DeprecatedGL + @StripPostfix("coords") + void glMultiTexCoordP2uiv(@GLenum int texture, @GLenum int type, @Check("2") @Const @GLuint IntBuffer coords); + + @NoErrorCheck + @DeprecatedGL + @StripPostfix("coords") + void glMultiTexCoordP3uiv(@GLenum int texture, @GLenum int type, @Check("3") @Const @GLuint IntBuffer coords); + + @NoErrorCheck + @DeprecatedGL + @StripPostfix("coords") + void glMultiTexCoordP4uiv(@GLenum int texture, @GLenum int type, @Check("4") @Const @GLuint IntBuffer coords); + + @NoErrorCheck + @DeprecatedGL + void glNormalP3ui(@GLenum int type, @GLuint int coords); + + @NoErrorCheck + @DeprecatedGL + @StripPostfix("coords") + void glNormalP3uiv(@GLenum int type, @Check("3") @Const @GLuint IntBuffer coords); + + @NoErrorCheck + @DeprecatedGL + void glColorP3ui(@GLenum int type, @GLuint int color); + + @NoErrorCheck + @DeprecatedGL + void glColorP4ui(@GLenum int type, @GLuint int color); + + @NoErrorCheck + @DeprecatedGL + @StripPostfix("color") + void glColorP3uiv(@GLenum int type, @Check("3") @Const @GLuint IntBuffer color); + + @NoErrorCheck + @DeprecatedGL + @StripPostfix("color") + void glColorP4uiv(@GLenum int type, @Check("4") @Const @GLuint IntBuffer color); + + @NoErrorCheck + @DeprecatedGL + void glSecondaryColorP3ui(@GLenum int type, @GLuint int color); + + @NoErrorCheck + @DeprecatedGL + @StripPostfix("color") + void glSecondaryColorP3uiv(@GLenum int type, @Check("3") @Const @GLuint IntBuffer color); + + @NoErrorCheck + @DeprecatedGL + void glVertexAttribP1ui(@GLuint int index, @GLenum int type, boolean normalized, @GLuint int value); + + @NoErrorCheck + @DeprecatedGL + void glVertexAttribP2ui(@GLuint int index, @GLenum int type, boolean normalized, @GLuint int value); + + @NoErrorCheck + @DeprecatedGL + void glVertexAttribP3ui(@GLuint int index, @GLenum int type, boolean normalized, @GLuint int value); + + @NoErrorCheck + @DeprecatedGL + void glVertexAttribP4ui(@GLuint int index, @GLenum int type, boolean normalized, @GLuint int value); + + @NoErrorCheck + @DeprecatedGL + @StripPostfix("value") + void glVertexAttribP1uiv(@GLuint int index, @GLenum int type, boolean normalized, @Check("1") @Const @GLuint IntBuffer value); + + @NoErrorCheck + @DeprecatedGL + @StripPostfix("value") + void glVertexAttribP2uiv(@GLuint int index, @GLenum int type, boolean normalized, @Check("2") @Const @GLuint IntBuffer value); + + @NoErrorCheck + @DeprecatedGL + @StripPostfix("value") + void glVertexAttribP3uiv(@GLuint int index, @GLenum int type, boolean normalized, @Check("3") @Const @GLuint IntBuffer value); + + @NoErrorCheck + @DeprecatedGL + @StripPostfix("value") + void glVertexAttribP4uiv(@GLuint int index, @GLenum int type, boolean normalized, @Check("4") @Const @GLuint IntBuffer value); + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/GL40.java b/src/templates/org/lwjgl/opengl/GL40.java new file mode 100644 index 0000000..c899798 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/GL40.java @@ -0,0 +1,449 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +import java.nio.ByteBuffer; +import java.nio.DoubleBuffer; +import java.nio.FloatBuffer; +import java.nio.IntBuffer; + +import com.sun.mirror.type.PrimitiveType; + +public interface GL40 { + + // ---------------------------------------------------------------------- + // ----------------------[ ARB_draw_buffers_blend ]---------------------- + // ---------------------------------------------------------------------- + + @Optional(reason = "AMD's 4.0 implementation does not expose this (last driver checked: 10.3)") + void glBlendEquationi(@GLuint int buf, @GLenum int mode); + + @Optional(reason = "AMD's 4.0 implementation does not expose this (last driver checked: 10.3)") + void glBlendEquationSeparatei(@GLuint int buf, @GLenum int modeRGB, @GLenum int modeAlpha); + + @Optional(reason = "AMD's 4.0 implementation does not expose this (last driver checked: 10.3)") + void glBlendFunci(@GLuint int buf, @GLenum int src, @GLenum int dst); + + @Optional(reason = "AMD's 4.0 implementation does not expose this (last driver checked: 10.3)") + void glBlendFuncSeparatei(@GLuint int buf, @GLenum int srcRGB, @GLenum int dstRGB, @GLenum int srcAlpha, @GLenum int dstAlpha); + + // ----------------------------------------------------------------- + // ----------------------[ ARB_draw_indirect ]---------------------- + // ----------------------------------------------------------------- + + /** + * Accepted by the <target> parameters of BindBuffer, BufferData, + * BufferSubData, MapBuffer, UnmapBuffer, GetBufferSubData, + * GetBufferPointerv, MapBufferRange, FlushMappedBufferRange, + * GetBufferParameteriv, BindBufferRange, BindBufferBase, and + * CopyBufferSubData: + */ + int GL_DRAW_INDIRECT_BUFFER = 0x8F3F; + + /** + * Accepted by the <value> parameter of GetIntegerv, GetBooleanv, GetFloatv, + * and GetDoublev: + */ + int GL_DRAW_INDIRECT_BUFFER_BINDING = 0x8F43; + + void glDrawArraysIndirect(@GLenum int mode, @BufferObject(BufferKind.IndirectBO) @Check("4") @NullTerminated @Const @GLvoid(PrimitiveType.Kind.INT) IntBuffer indirect); + + void glDrawElementsIndirect(@GLenum int mode, @GLenum int type, @BufferObject(BufferKind.IndirectBO) @Check("5") @NullTerminated @Const @GLvoid(PrimitiveType.Kind.INT) IntBuffer indirect); + + // --------------------------------------------------------------- + // ----------------------[ ARB_gpu_shader5 ]---------------------- + // --------------------------------------------------------------- + + /** Accepted by the <pname> parameter of GetProgramiv: */ + int GL_GEOMETRY_SHADER_INVOCATIONS = 0x887F; + + /** + * Accepted by the <pname> parameter of GetBooleanv, GetIntegerv, GetFloatv, + * GetDoublev, and GetInteger64v: + */ + int GL_MAX_GEOMETRY_SHADER_INVOCATIONS = 0x8E5A; + int GL_MIN_FRAGMENT_INTERPOLATION_OFFSET = 0x8E5B; + int GL_MAX_FRAGMENT_INTERPOLATION_OFFSET = 0x8E5C; + int GL_FRAGMENT_INTERPOLATION_OFFSET_BITS = 0x8E5D; + int GL_MAX_VERTEX_STREAMS = 0x8E71; + + // ------------------------------------------------------------------- + // ----------------------[ ARB_gpu_shader_fp64 ]---------------------- + // ------------------------------------------------------------------- + + /** + * Returned in the <type> parameter of GetActiveUniform, and + * GetTransformFeedbackVarying: + */ + int GL_DOUBLE_VEC2 = 0x8FFC; + int GL_DOUBLE_VEC3 = 0x8FFD; + int GL_DOUBLE_VEC4 = 0x8FFE; + int GL_DOUBLE_MAT2 = 0x8F46; + int GL_DOUBLE_MAT3 = 0x8F47; + int GL_DOUBLE_MAT4 = 0x8F48; + int GL_DOUBLE_MAT2x3 = 0x8F49; + int GL_DOUBLE_MAT2x4 = 0x8F4A; + int GL_DOUBLE_MAT3x2 = 0x8F4B; + int GL_DOUBLE_MAT3x4 = 0x8F4C; + int GL_DOUBLE_MAT4x2 = 0x8F4D; + int GL_DOUBLE_MAT4x3 = 0x8F4E; + + void glUniform1d(int location, double x); + + void glUniform2d(int location, double x, double y); + + void glUniform3d(int location, double x, double y, double z); + + void glUniform4d(int location, double x, double y, double z, double w); + + @StripPostfix("value") + void glUniform1dv(int location, @AutoSize("value") @GLsizei int count, @Const DoubleBuffer value); + + @StripPostfix("value") + void glUniform2dv(int location, @AutoSize(value = "value", expression = " >> 1") @GLsizei int count, @Const DoubleBuffer value); + + @StripPostfix("value") + void glUniform3dv(int location, @AutoSize(value = "value", expression = " / 3") @GLsizei int count, @Const DoubleBuffer value); + + @StripPostfix("value") + void glUniform4dv(int location, @AutoSize(value = "value", expression = " >> 2") @GLsizei int count, @Const DoubleBuffer value); + + @StripPostfix("value") + void glUniformMatrix2dv(int location, @AutoSize(value = "value", expression = " >> 2") @GLsizei int count, boolean transpose, @Const DoubleBuffer value); + + @StripPostfix("value") + void glUniformMatrix3dv(int location, @AutoSize(value = "value", expression = " / (3 * 3)") @GLsizei int count, boolean transpose, @Const DoubleBuffer value); + + @StripPostfix("value") + void glUniformMatrix4dv(int location, @AutoSize(value = "value", expression = " >> 4") @GLsizei int count, boolean transpose, @Const DoubleBuffer value); + + @StripPostfix("value") + void glUniformMatrix2x3dv(int location, @AutoSize(value = "value", expression = " / (2 * 3)") @GLsizei int count, boolean transpose, @Const DoubleBuffer value); + + @StripPostfix("value") + void glUniformMatrix2x4dv(int location, @AutoSize(value = "value", expression = " >> 3") @GLsizei int count, boolean transpose, @Const DoubleBuffer value); + + @StripPostfix("value") + void glUniformMatrix3x2dv(int location, @AutoSize(value = "value", expression = " / (3 * 2)") @GLsizei int count, boolean transpose, @Const DoubleBuffer value); + + @StripPostfix("value") + void glUniformMatrix3x4dv(int location, @AutoSize(value = "value", expression = " / (3 * 4)") @GLsizei int count, boolean transpose, @Const DoubleBuffer value); + + @StripPostfix("value") + void glUniformMatrix4x2dv(int location, @AutoSize(value = "value", expression = " >> 3") @GLsizei int count, boolean transpose, @Const DoubleBuffer value); + + @StripPostfix("value") + void glUniformMatrix4x3dv(int location, @AutoSize(value = "value", expression = " / (4 * 3)") @GLsizei int count, boolean transpose, @Const DoubleBuffer value); + + @StripPostfix("params") + void glGetUniformdv(@GLuint int program, int location, @OutParameter @Check DoubleBuffer params); + + // ------------------------------------------------------------------ + // ----------------------[ ARB_sample_shading ]---------------------- + // ------------------------------------------------------------------ + + /** + * Accepted by the <cap> parameter of Enable, Disable, and IsEnabled, + * and by the <pname> parameter of GetBooleanv, GetIntegerv, GetFloatv, + * and GetDoublev: + */ + int GL_SAMPLE_SHADING = 0x8C36; + + /** + * Accepted by the <pname> parameter of GetBooleanv, GetDoublev, + * GetIntegerv, and GetFloatv: + */ + int GL_MIN_SAMPLE_SHADING_VALUE = 0x8C37; + + @Optional(reason = "AMD's 4.0 implementation does not expose this (last driver checked: 10.3)") + void glMinSampleShading(@GLclampf float value); + + // --------------------------------------------------------------------- + // ----------------------[ ARB_shader_subroutine ]---------------------- + // --------------------------------------------------------------------- + + /** Accepted by the <pname> parameter of GetProgramStageiv: */ + int GL_ACTIVE_SUBROUTINES = 0x8DE5; + int GL_ACTIVE_SUBROUTINE_UNIFORMS = 0x8DE6; + int GL_ACTIVE_SUBROUTINE_UNIFORM_LOCATIONS = 0x8E47; + int GL_ACTIVE_SUBROUTINE_MAX_LENGTH = 0x8E48; + int GL_ACTIVE_SUBROUTINE_UNIFORM_MAX_LENGTH = 0x8E49; + + /** + * Accepted by the <pname> parameter of GetBooleanv, GetIntegerv, + * GetFloatv, GetDoublev, and GetInteger64v: + */ + int GL_MAX_SUBROUTINES = 0x8DE7; + int GL_MAX_SUBROUTINE_UNIFORM_LOCATIONS = 0x8DE8; + + /** Accepted by the <pname> parameter of GetActiveSubroutineUniformiv: */ + int GL_NUM_COMPATIBLE_SUBROUTINES = 0x8E4A; + int GL_COMPATIBLE_SUBROUTINES = 0x8E4B; + int GL_UNIFORM_SIZE = GL31.GL_UNIFORM_SIZE; + int GL_UNIFORM_NAME_LENGTH = GL31.GL_UNIFORM_NAME_LENGTH; + + int glGetSubroutineUniformLocation(@GLuint int program, @GLenum int shadertype, @Const @NullTerminated ByteBuffer name); + + @GLuint + int glGetSubroutineIndex(@GLuint int program, @GLenum int shadertype, @Const @NullTerminated ByteBuffer name); + + @StripPostfix("values") + void glGetActiveSubroutineUniformiv(@GLuint int program, @GLenum int shadertype, @GLuint int index, @GLenum int pname, + @OutParameter @Check("1") IntBuffer values); + + @Alternate("glGetActiveSubroutineUniformiv") + @GLreturn("values") + @StripPostfix("values") + void glGetActiveSubroutineUniformiv2(@GLuint int program, @GLenum int shadertype, @GLuint int index, @GLenum int pname, + @OutParameter IntBuffer values); + + void glGetActiveSubroutineUniformName(@GLuint int program, @GLenum int shadertype, @GLuint int index, @AutoSize("name") @GLsizei int bufsize, + @OutParameter @Check(value = "1", canBeNull = true) @GLsizei IntBuffer length, + @OutParameter @GLchar ByteBuffer name); + + @Alternate("glGetActiveSubroutineUniformName") + @GLreturn(value = "name", maxLength = "bufsize") + void glGetActiveSubroutineUniformName2(@GLuint int program, @GLenum int shadertype, @GLuint int index, @GLsizei int bufsize, + @OutParameter @Constant("name_length, 0") @GLsizei IntBuffer length, + @OutParameter @GLchar ByteBuffer name); + + void glGetActiveSubroutineName(@GLuint int program, @GLenum int shadertype, @GLuint int index, @AutoSize("name") @GLsizei int bufsize, + @OutParameter @Check(value = "1", canBeNull = true) @GLsizei IntBuffer length, + @OutParameter @GLchar ByteBuffer name); + + @Alternate("glGetActiveSubroutineName") + @GLreturn(value = "name", maxLength = "bufsize") + void glGetActiveSubroutineName2(@GLuint int program, @GLenum int shadertype, @GLuint int index, @GLsizei int bufsize, + @OutParameter @Constant("name_length, 0") @GLsizei IntBuffer length, + @OutParameter @GLchar ByteBuffer name); + + @StripPostfix("indices") + void glUniformSubroutinesuiv(@GLenum int shadertype, @AutoSize("indices") @GLsizei int count, @Const @GLuint IntBuffer indices); + + @StripPostfix("params") + void glGetUniformSubroutineuiv(@GLenum int shadertype, int location, @Check("1") @OutParameter @GLuint IntBuffer params); + + @Alternate("glGetUniformSubroutineuiv") + @GLreturn("params") + @StripPostfix("params") + void glGetUniformSubroutineuiv2(@GLenum int shadertype, int location, @OutParameter @GLuint IntBuffer params); + + @StripPostfix("values") + void glGetProgramStageiv(@GLuint int program, @GLenum int shadertype, @GLenum int pname, @Check("1") @OutParameter IntBuffer values); + + @Alternate("glGetProgramStageiv") + @GLreturn("values") + @StripPostfix("values") + void glGetProgramStageiv2(@GLuint int program, @GLenum int shadertype, @GLenum int pname, @OutParameter IntBuffer values); + + // ----------------------------------------------------------------------- + // ----------------------[ ARB_tessellation_shader ]---------------------- + // ----------------------------------------------------------------------- + + /** + * Accepted by the <mode> parameter of Begin and all vertex array functions + * that implicitly call Begin: + */ + int GL_PATCHES = 0xE; + + /** + * Accepted by the <pname> parameter of PatchParameteri, GetBooleanv, + * GetDoublev, GetFloatv, GetIntegerv, and GetInteger64v: + */ + int GL_PATCH_VERTICES = 0x8E72; + + /** + * Accepted by the <pname> parameter of PatchParameterfv, GetBooleanv, + * GetDoublev, GetFloatv, and GetIntegerv, and GetInteger64v: + */ + int GL_PATCH_DEFAULT_INNER_LEVEL = 0x8E73; + int GL_PATCH_DEFAULT_OUTER_LEVEL = 0x8E74; + + /** Accepted by the <pname> parameter of GetProgramiv: */ + int GL_TESS_CONTROL_OUTPUT_VERTICES = 0x8E75; + int GL_TESS_GEN_MODE = 0x8E76; + int GL_TESS_GEN_SPACING = 0x8E77; + int GL_TESS_GEN_VERTEX_ORDER = 0x8E78; + int GL_TESS_GEN_POINT_MODE = 0x8E79; + + /** Returned by GetProgramiv when <pname> is TESS_GEN_MODE: */ + int GL_ISOLINES = 0x8E7A; + + /** Returned by GetProgramiv when <pname> is TESS_GEN_SPACING: */ + int GL_FRACTIONAL_ODD = 0x8E7B; + int GL_FRACTIONAL_EVEN = 0x8E7C; + + /** + * Accepted by the <pname> parameter of GetBooleanv, GetDoublev, GetFloatv, + * GetIntegerv, and GetInteger64v: + */ + int GL_MAX_PATCH_VERTICES = 0x8E7D; + int GL_MAX_TESS_GEN_LEVEL = 0x8E7E; + int GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS = 0x8E7F; + int GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS = 0x8E80; + int GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS = 0x8E81; + int GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS = 0x8E82; + int GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS = 0x8E83; + int GL_MAX_TESS_PATCH_COMPONENTS = 0x8E84; + int GL_MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS = 0x8E85; + int GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS = 0x8E86; + int GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS = 0x8E89; + int GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS = 0x8E8A; + int GL_MAX_TESS_CONTROL_INPUT_COMPONENTS = 0x886C; + int GL_MAX_TESS_EVALUATION_INPUT_COMPONENTS = 0x886D; + int GL_MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS = 0x8E1E; + int GL_MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS = 0x8E1F; + + /** Accepted by the <pname> parameter of GetActiveUniformBlockiv: */ + int GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_CONTROL_SHADER = 0x84F0; + int GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_EVALUATION_SHADER = 0x84F1; + + /** + * Accepted by the <type> parameter of CreateShader and returned by the + * <params> parameter of GetShaderiv: + */ + int GL_TESS_EVALUATION_SHADER = 0x8E87; + int GL_TESS_CONTROL_SHADER = 0x8E88; + + void glPatchParameteri(@GLenum int pname, int value); + + @StripPostfix("values") + void glPatchParameterfv(@GLenum int pname, @Check("4") @Const FloatBuffer values); + + // -------------------------------------------------------------------------- + // ----------------------[ ARB_texture_cube_map_array ]---------------------- + // -------------------------------------------------------------------------- + + /** + * Accepted by the <target> parameter of TexParameteri, TexParameteriv, + * TexParameterf, TexParameterfv, BindTexture, and GenerateMipmap: + *

    + * Accepted by the <target> parameter of TexImage3D, TexSubImage3D, + * CompressedTeximage3D, CompressedTexSubImage3D and CopyTexSubImage3D: + *

    + * Accepted by the <tex> parameter of GetTexImage: + */ + int GL_TEXTURE_CUBE_MAP_ARRAY = 0x9009; + + /** + * Accepted by the <pname> parameter of GetBooleanv, GetDoublev, + * GetIntegerv and GetFloatv: + */ + int GL_TEXTURE_BINDING_CUBE_MAP_ARRAY = 0x900A; + + /** + * Accepted by the <target> parameter of TexImage3D, TexSubImage3D, + * CompressedTeximage3D, CompressedTexSubImage3D and CopyTexSubImage3D: + */ + int GL_PROXY_TEXTURE_CUBE_MAP_ARRAY = 0x900B; + + /** Returned by the <type> parameter of GetActiveUniform: */ + int GL_SAMPLER_CUBE_MAP_ARRAY = 0x900C; + int GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW = 0x900D; + int GL_INT_SAMPLER_CUBE_MAP_ARRAY = 0x900E; + int GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY = 0x900F; + + // ------------------------------------------------------------------ + // ----------------------[ ARB_texture_gather ]---------------------- + // ------------------------------------------------------------------ + + /** + * Accepted by the <pname> parameter of GetBooleanv, GetIntegerv, + * GetFloatv, and GetDoublev: + */ + int GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET_ARB = 0x8E5E; + int GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET_ARB = 0x8E5F; + int GL_MAX_PROGRAM_TEXTURE_GATHER_COMPONENTS_ARB = 0x8F9F; + + // ----------------------------------------------------------------------- + // ----------------------[ ARB_transform_feedback2 ]---------------------- + // ----------------------------------------------------------------------- + + /** Accepted by the <target> parameter of BindTransformFeedback: */ + int GL_TRANSFORM_FEEDBACK = 0x8E22; + + /** + * Accepted by the <pname> parameter of GetBooleanv, GetDoublev, GetIntegerv, + * and GetFloatv: + */ + int GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED = 0x8E23; + int GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE = 0x8E24; + int GL_TRANSFORM_FEEDBACK_BINDING = 0x8E25; + + void glBindTransformFeedback(@GLenum int target, @GLuint int id); + + void glDeleteTransformFeedbacks(@AutoSize("ids") @GLsizei int n, @Const @GLuint IntBuffer ids); + + @Alternate("glDeleteTransformFeedbacks") + void glDeleteTransformFeedbacks(@Constant("1") @GLsizei int n, @Constant(value = "APIUtils.getBufferInt().put(0, id), 0", keepParam = true) int id); + + void glGenTransformFeedbacks(@AutoSize("ids") @GLsizei int n, @OutParameter @GLuint IntBuffer ids); + + @Alternate("glGenTransformFeedbacks") + @GLreturn("ids") + void glGenTransformFeedbacks2(@Constant("1") @GLsizei int n, @OutParameter @GLuint IntBuffer ids); + + boolean glIsTransformFeedback(@GLuint int id); + + void glPauseTransformFeedback(); + + void glResumeTransformFeedback(); + + void glDrawTransformFeedback(@GLenum int mode, @GLuint int id); + + // ----------------------------------------------------------------------- + // ----------------------[ ARB_transform_feedback3 ]---------------------- + // ----------------------------------------------------------------------- + + /** + * Accepted by the <pname> parameter of GetBooleanv, GetDoublev, GetIntegerv, + * and GetFloatv: + */ + int GL_MAX_TRANSFORM_FEEDBACK_BUFFERS = 0x8E70; + + void glDrawTransformFeedbackStream(@GLenum int mode, @GLuint int id, @GLuint int stream); + + void glBeginQueryIndexed(@GLenum int target, @GLuint int index, @GLuint int id); + + void glEndQueryIndexed(@GLenum int target, @GLuint int index); + + @StripPostfix("params") + void glGetQueryIndexediv(@GLenum int target, @GLuint int index, @GLenum int pname, @OutParameter @Check("1") IntBuffer params); + + @Alternate("glGetQueryIndexediv") + @GLreturn("params") + @StripPostfix("params") + void glGetQueryIndexediv2(@GLenum int target, @GLuint int index, @GLenum int pname, @OutParameter IntBuffer params); + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/GREMEDY_string_marker.java b/src/templates/org/lwjgl/opengl/GREMEDY_string_marker.java new file mode 100644 index 0000000..465ba27 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/GREMEDY_string_marker.java @@ -0,0 +1,45 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +import java.nio.ByteBuffer; + +public interface GREMEDY_string_marker { + + void glStringMarkerGREMEDY(@AutoSize("string") @GLsizei int len, @Const ByteBuffer string); + + @Alternate("glStringMarkerGREMEDY") + void glStringMarkerGREMEDY(@Constant("string.length()") @GLsizei int len, CharSequence string); + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/HP_occlusion_test.java b/src/templates/org/lwjgl/opengl/HP_occlusion_test.java new file mode 100644 index 0000000..f919519 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/HP_occlusion_test.java @@ -0,0 +1,48 @@ +/* + * 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; + +public interface HP_occlusion_test { + + /** + * Accepted by the <cap> parameter of Enable, Disable, and IsEnabled, by + * the <pname> of GetBooleanv, GetIntegerv, GetFloatv, and GetDoublev : + */ + int GL_OCCLUSION_TEST_HP = 0x8165; + + /** + * Accepted by the <pname> of GetBooleanv, GetIntegerv, GetFloatv, and + * GetDoublev : + */ + int GL_OCCLUSION_TEST_RESULT_HP = 0x8166; + +} diff --git a/src/templates/org/lwjgl/opengl/IBM_rasterpos_clip.java b/src/templates/org/lwjgl/opengl/IBM_rasterpos_clip.java new file mode 100644 index 0000000..a88cbee --- /dev/null +++ b/src/templates/org/lwjgl/opengl/IBM_rasterpos_clip.java @@ -0,0 +1,42 @@ +/* + * 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; + +public interface IBM_rasterpos_clip { + + /** + * Accepted by the <target> parameter of Enable and Disable and the <value> + * parameter of IsEnabled, GetBooleanv, GetIntegerv, GetFloatv, GetDoublev: + */ + int GL_RASTER_POSITION_UNCLIPPED_IBM = 103010; + +} diff --git a/src/templates/org/lwjgl/opengl/NVX_gpu_memory_info.java b/src/templates/org/lwjgl/opengl/NVX_gpu_memory_info.java new file mode 100644 index 0000000..694e719 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/NVX_gpu_memory_info.java @@ -0,0 +1,44 @@ +/* + * 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; + +/** Experimental extension, may be removed/changed in the future. */ +public interface NVX_gpu_memory_info { + + /** Accepted by the <pname> parameter of GetIntegerv: */ + int GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX = 0x9047; + int GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX = 0x9048; + int GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX = 0x9049; + int GL_GPU_MEMORY_INFO_EVICTION_COUNT_NVX = 0x904A; + int GL_GPU_MEMORY_INFO_EVICTED_MEMORY_NVX = 0x904B; + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/NV_blend_square.java b/src/templates/org/lwjgl/opengl/NV_blend_square.java new file mode 100644 index 0000000..fc61d50 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/NV_blend_square.java @@ -0,0 +1,35 @@ +/* + * 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; + +public interface NV_blend_square { +} diff --git a/src/templates/org/lwjgl/opengl/NV_conditional_render.java b/src/templates/org/lwjgl/opengl/NV_conditional_render.java new file mode 100644 index 0000000..61c1394 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/NV_conditional_render.java @@ -0,0 +1,50 @@ +/* + * 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; + +import org.lwjgl.util.generator.GLenum; +import org.lwjgl.util.generator.GLuint; + +public interface NV_conditional_render { + + /** + * Accepted by the <mode> parameter of BeginConditionalRenderNV: + */ + int GL_QUERY_WAIT_NV = 0x8E13; + int GL_QUERY_NO_WAIT_NV = 0x8E14; + int GL_QUERY_BY_REGION_WAIT_NV = 0x8E15; + int GL_QUERY_BY_REGION_NO_WAIT_NV = 0x8E16; + + void glBeginConditionalRenderNV(@GLuint int id, @GLenum int mode); + void glEndConditionalRenderNV(); + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/NV_copy_depth_to_color.java b/src/templates/org/lwjgl/opengl/NV_copy_depth_to_color.java new file mode 100644 index 0000000..4c9acb2 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/NV_copy_depth_to_color.java @@ -0,0 +1,37 @@ +/* + * 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; + +public interface NV_copy_depth_to_color { + int GL_DEPTH_STENCIL_TO_RGBA_NV = 0x886E; + int GL_DEPTH_STENCIL_TO_BGRA_NV = 0x886F; +} diff --git a/src/templates/org/lwjgl/opengl/NV_copy_image.java b/src/templates/org/lwjgl/opengl/NV_copy_image.java new file mode 100644 index 0000000..c70f47b --- /dev/null +++ b/src/templates/org/lwjgl/opengl/NV_copy_image.java @@ -0,0 +1,49 @@ +/* + * 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; + +import org.lwjgl.util.generator.GLenum; +import org.lwjgl.util.generator.GLsizei; +import org.lwjgl.util.generator.GLuint; + +public interface NV_copy_image { + + void glCopyImageSubDataNV( + @GLuint int srcName, @GLenum int srcTarget, int srcLevel, + int srcX, int srcY, int srcZ, + @GLuint int dstName, @GLenum int dstTarget, int dstLevel, + int dstX, int dstY, int dstZ, + @GLsizei int width, @GLsizei int height, @GLsizei int depth); + + // TODO: Implement WGL and GLX cross-context copying. + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/NV_depth_buffer_float.java b/src/templates/org/lwjgl/opengl/NV_depth_buffer_float.java new file mode 100644 index 0000000..2f6e78e --- /dev/null +++ b/src/templates/org/lwjgl/opengl/NV_depth_buffer_float.java @@ -0,0 +1,64 @@ +/* + * 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; + +public interface NV_depth_buffer_float { + + /** + * Accepted by the <internalformat> parameter of TexImage1D, TexImage2D, + * TexImage3D, CopyTexImage1D, CopyTexImage2D, and RenderbufferStorageEXT, + * and returned in the <data> parameter of GetTexLevelParameter and + * GetRenderbufferParameterivEXT: + */ + int GL_DEPTH_COMPONENT32F_NV = 0x8DAB; + int GL_DEPTH32F_STENCIL8_NV = 0x8DAC; + + /** + * Accepted by the <type> parameter of DrawPixels, ReadPixels, TexImage1D, + * TexImage2D, TexImage3D, TexSubImage1D, TexSubImage2D, TexSubImage3D, and + * GetTexImage: + */ + int GL_FLOAT_32_UNSIGNED_INT_24_8_REV_NV = 0x8DAD; + + /** + * Accepted by the <pname> parameters of GetBooleanv, GetIntegerv, + * GetFloatv, and GetDoublev: + */ + int GL_DEPTH_BUFFER_FLOAT_MODE_NV = 0x8DAF; + + void glDepthRangedNV(double n, double f); + + void glClearDepthdNV(double d); + + void glDepthBoundsdNV(double zmin, double zmax); + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/NV_depth_clamp.java b/src/templates/org/lwjgl/opengl/NV_depth_clamp.java new file mode 100644 index 0000000..33b81d6 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/NV_depth_clamp.java @@ -0,0 +1,36 @@ +/* + * 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; + +public interface NV_depth_clamp { + int GL_DEPTH_CLAMP_NV = 0x864F; +} diff --git a/src/templates/org/lwjgl/opengl/NV_evaluators.java b/src/templates/org/lwjgl/opengl/NV_evaluators.java new file mode 100644 index 0000000..f690c78 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/NV_evaluators.java @@ -0,0 +1,91 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +import java.nio.*; + +public interface NV_evaluators { + int GL_EVAL_2D_NV = 0x86C0; + int GL_EVAL_TRIANGULAR_2D_NV = 0x86C1; + int GL_MAP_TESSELLATION_NV = 0x86C2; + int GL_MAP_ATTRIB_U_ORDER_NV = 0x86C3; + int GL_MAP_ATTRIB_V_ORDER_NV = 0x86C4; + int GL_EVAL_FRACTIONAL_TESSELLATION_NV = 0x86C5; + int GL_EVAL_VERTEX_ATTRIB0_NV = 0x86C6; + int GL_EVAL_VERTEX_ATTRIB1_NV = 0x86C7; + int GL_EVAL_VERTEX_ATTRIB2_NV = 0x86C8; + int GL_EVAL_VERTEX_ATTRIB3_NV = 0x86C9; + int GL_EVAL_VERTEX_ATTRIB4_NV = 0x86CA; + int GL_EVAL_VERTEX_ATTRIB5_NV = 0x86CB; + int GL_EVAL_VERTEX_ATTRIB6_NV = 0x86CC; + int GL_EVAL_VERTEX_ATTRIB7_NV = 0x86CD; + int GL_EVAL_VERTEX_ATTRIB8_NV = 0x86CE; + int GL_EVAL_VERTEX_ATTRIB9_NV = 0x86CF; + int GL_EVAL_VERTEX_ATTRIB10_NV = 0x86D0; + int GL_EVAL_VERTEX_ATTRIB11_NV = 0x86D1; + int GL_EVAL_VERTEX_ATTRIB12_NV = 0x86D2; + int GL_EVAL_VERTEX_ATTRIB13_NV = 0x86D3; + int GL_EVAL_VERTEX_ATTRIB14_NV = 0x86D4; + int GL_EVAL_VERTEX_ATTRIB15_NV = 0x86D5; + int GL_MAX_MAP_TESSELLATION_NV = 0x86D6; + int GL_MAX_RATIONAL_EVAL_ORDER_NV = 0x86D7; + + void glGetMapControlPointsNV(@GLenum int target, @GLuint int index, @GLenum int type, @GLsizei int ustride, @GLsizei int vstride, boolean packed, + @OutParameter + @Check + @Const + @GLfloat Buffer pPoints); + + void glMapControlPointsNV(@GLenum int target, @GLuint int index, @GLenum int type, @GLsizei int ustride, @GLsizei int vstride, int uorder, int vorder, boolean packed, @Check @Const @GLfloat Buffer pPoints); + + @StripPostfix("params") + void glMapParameterfvNV(@GLenum int target, @GLenum int pname, @Check("4") @Const FloatBuffer params); + + @StripPostfix("params") + void glMapParameterivNV(@GLenum int target, @GLenum int pname, @Check("4") @Const IntBuffer params); + + @StripPostfix("params") + void glGetMapParameterfvNV(@GLenum int target, @GLenum int pname, @OutParameter @Check("4") @Const FloatBuffer params); + + @StripPostfix("params") + void glGetMapParameterivNV(@GLenum int target, @GLenum int pname, @OutParameter @Check("4") @Const IntBuffer params); + + @StripPostfix("params") + void glGetMapAttribParameterfvNV(@GLenum int target, @GLuint int index, @GLenum int pname, @OutParameter @Check("4") FloatBuffer params); + + @StripPostfix("params") + void glGetMapAttribParameterivNV(@GLenum int target, @GLuint int index, @GLenum int pname, @OutParameter @Check("4") IntBuffer params); + + void glEvalMapsNV(@GLenum int target, @GLenum int mode); +} diff --git a/src/templates/org/lwjgl/opengl/NV_explicit_multisample.java b/src/templates/org/lwjgl/opengl/NV_explicit_multisample.java new file mode 100644 index 0000000..4e12545 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/NV_explicit_multisample.java @@ -0,0 +1,101 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +import java.nio.ByteBuffer; +import java.nio.FloatBuffer; +import java.nio.IntBuffer; + +public interface NV_explicit_multisample { + + /** Accepted by the <pname> parameter of GetMultisamplefvNV: */ + int GL_SAMPLE_POSITION_NV = 0x8E50; + + /** + * Accepted by the <cap> parameter of Enable, Disable, and IsEnabled, and by + * the <pname> parameter of GetBooleanv, GetIntegerv, GetFloatv, and + * GetDoublev: + */ + + int GL_SAMPLE_MASK_NV = 0x8E51; + + /** + * Accepted by the <pname> parameter of GetBooleanIndexedvEXT and + * GetIntegerIndexedvEXT: + */ + + int GL_SAMPLE_MASK_VALUE_NV = 0x8E52; + + /** + * Accepted by the <pname> parameter of GetBooleanv, GetDoublev, GetIntegerv, + * and GetFloatv: + */ + + int GL_TEXTURE_BINDING_RENDERBUFFER_NV = 0x8E53; + int GL_TEXTURE_RENDERBUFFER_DATA_STORE_BINDING_NV = 0x8E54; + int GL_MAX_SAMPLE_MASK_WORDS_NV = 0x8E59; + + /** Accepted by the <target> parameter of BindTexture, and TexRenderbufferNV: */ + + int GL_TEXTURE_RENDERBUFFER_NV = 0x8E55; + + /** Returned by the <type> parameter of GetActiveUniform: */ + int GL_SAMPLER_RENDERBUFFER_NV = 0x8E56; + int GL_INT_SAMPLER_RENDERBUFFER_NV = 0x8E57; + int GL_UNSIGNED_INT_SAMPLER_RENDERBUFFER_NV = 0x8E58; + + @StripPostfix(value = "data", extension = "EXT") + void glGetBooleanIndexedvEXT(@GLenum int pname, @GLuint int index, @OutParameter @Check("16") @GLboolean ByteBuffer data); + + @Alternate("glGetBooleanIndexedvEXT") + @GLreturn("data") + @StripPostfix(value = "data", extension = "EXT") + void glGetBooleanIndexedvEXT2(@GLenum int pname, @GLuint int index, @OutParameter @GLboolean ByteBuffer data); + + @StripPostfix(value = "data", extension = "EXT") + void glGetIntegerIndexedvEXT(@GLenum int pname, @GLuint int index, @OutParameter @Check("16") IntBuffer data); + + @Alternate("glGetIntegerIndexedvEXT") + @GLreturn("data") + @StripPostfix(value = "data", extension = "EXT") + void glGetIntegerIndexedvEXT2(@GLenum int pname, @GLuint int index, @OutParameter IntBuffer data); + + @StripPostfix("val") + void glGetMultisamplefvNV(@GLenum int pname, @GLuint int index, @OutParameter @Check("2") FloatBuffer val); + + void glSampleMaskIndexedNV(@GLuint int index, @GLbitfield int mask); + + void glTexRenderbufferNV(@GLenum int target, @GLuint int renderbuffer); + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/NV_fence.java b/src/templates/org/lwjgl/opengl/NV_fence.java new file mode 100644 index 0000000..3d6abc9 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/NV_fence.java @@ -0,0 +1,56 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +import java.nio.*; + +public interface NV_fence { + int GL_ALL_COMPLETED_NV = 0x84F2; + int GL_FENCE_STATUS_NV = 0x84F3; + int GL_FENCE_CONDITION_NV = 0x84F4; + + void glGenFencesNV(@AutoSize("piFences") @GLsizei int n, @OutParameter @GLuint IntBuffer piFences); + + void glDeleteFencesNV(@AutoSize("piFences") @GLsizei int n, @Const @GLuint IntBuffer piFences); + + void glSetFenceNV(@GLuint int fence, @GLenum int condition); + + boolean glTestFenceNV(@GLuint int fence); + + void glFinishFenceNV(@GLuint int fence); + + boolean glIsFenceNV(@GLuint int fence); + + void glGetFenceivNV(@GLuint int fence, @GLenum int pname, @OutParameter @Check("4") IntBuffer piParams); +} diff --git a/src/templates/org/lwjgl/opengl/NV_float_buffer.java b/src/templates/org/lwjgl/opengl/NV_float_buffer.java new file mode 100644 index 0000000..343aa95 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/NV_float_buffer.java @@ -0,0 +1,91 @@ +/* + * 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; + +public interface NV_float_buffer { + + /** + * Accepted by the <internalformat> parameter of TexImage2D and + * CopyTexImage2D: + */ + int GL_FLOAT_R_NV = 0x8880; + int GL_FLOAT_RG_NV = 0x8881; + int GL_FLOAT_RGB_NV = 0x8882; + int GL_FLOAT_RGBA_NV = 0x8883; + int GL_FLOAT_R16_NV = 0x8884; + int GL_FLOAT_R32_NV = 0x8885; + int GL_FLOAT_RG16_NV = 0x8886; + int GL_FLOAT_RG32_NV = 0x8887; + int GL_FLOAT_RGB16_NV = 0x8888; + int GL_FLOAT_RGB32_NV = 0x8889; + int GL_FLOAT_RGBA16_NV = 0x888A; + int GL_FLOAT_RGBA32_NV = 0x888B; + + /** + * Accepted by the <pname> parameter of GetTexLevelParameterfv and + * GetTexLevelParameteriv: + */ + int GL_TEXTURE_FLOAT_COMPONENTS_NV = 0x888C; + + /** + * Accepted by the <pname> parameter of GetBooleanv, GetIntegerv, GetFloatv, + * and GetDoublev: + */ + int GL_FLOAT_CLEAR_COLOR_VALUE_NV = 0x888D; + int GL_FLOAT_RGBA_MODE_NV = 0x888E; + + /** + * Accepted in the <piAttributes> array of wglGetPixelFormatAttribivARB and + * wglGetPixelFormatAttribfvARB and in the <piAttribIList> and + * <pfAttribFList> arrays of wglChoosePixelFormatARB: + */ + /* + int WGL_FLOAT_COMPONENTS_NV = 0x20B0; + int WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_R_NV = 0x20B1; + int WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RG_NV = 0x20B2; + int WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGB_NV = 0x20B3; + int WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGBA_NV = 0x20B4; + */ + + /** + * Accepted in the <piAttribIList> array of wglCreatePbufferARB and returned + * in the <value> parameter of wglQueryPbufferARB when <iAttribute> is + * WGL_TEXTURE_FORMAT_ARB: + */ + /* + int WGL_TEXTURE_FLOAT_R_NV = 0x20B5; + int WGL_TEXTURE_FLOAT_RG_NV = 0x20B6; + int WGL_TEXTURE_FLOAT_RGB_NV = 0x20B7; + int WGL_TEXTURE_FLOAT_RGBA_NV = 0x20B8; + */ + +} diff --git a/src/templates/org/lwjgl/opengl/NV_fog_distance.java b/src/templates/org/lwjgl/opengl/NV_fog_distance.java new file mode 100644 index 0000000..201d738 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/NV_fog_distance.java @@ -0,0 +1,38 @@ +/* + * 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; + +public interface NV_fog_distance { + int GL_FOG_DISTANCE_MODE_NV = 0x855A; + int GL_EYE_RADIAL_NV = 0x855B; + int GL_EYE_PLANE_ABSOLUTE_NV = 0x855C; +} diff --git a/src/templates/org/lwjgl/opengl/NV_fragment_program.java b/src/templates/org/lwjgl/opengl/NV_fragment_program.java new file mode 100644 index 0000000..360f2ff --- /dev/null +++ b/src/templates/org/lwjgl/opengl/NV_fragment_program.java @@ -0,0 +1,69 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +import java.nio.*; + +public interface NV_fragment_program extends NV_program { + + /** + * Accepted by the <cap> parameter of Disable, Enable, and IsEnabled, by the + * <pname> parameter of GetBooleanv, GetIntegerv, GetFloatv, and GetDoublev, + * and by the <target> parameter of BindProgramNV, LoadProgramNV, + * ProgramLocalParameter4dARB, ProgramLocalParameter4dvARB, + * ProgramLocalParameter4fARB, ProgramLocalParameter4fvARB, + * GetProgramLocalParameterdvARB, and GetProgramLocalParameterfvARB: + */ + int GL_FRAGMENT_PROGRAM_NV = 0x8870; + + /** + * Accepted by the <pname> parameter of GetBooleanv, GetIntegerv, GetFloatv, + * and GetDoublev: + */ + int GL_MAX_TEXTURE_COORDS_NV = 0x8871; + int GL_MAX_TEXTURE_IMAGE_UNITS_NV = 0x8872; + int GL_FRAGMENT_PROGRAM_BINDING_NV = 0x8873; + int GL_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMETERS_NV = 0x8868; + + void glProgramNamedParameter4fNV(@GLuint int id, @AutoSize("name") @GLsizei int length, @Const @GLubyte ByteBuffer name, float x, float y, float z, float w); + + void glProgramNamedParameter4dNV(@GLuint int id, @AutoSize("name") @GLsizei int length, @Const @GLubyte ByteBuffer name, double x, double y, double z, double w); + + @StripPostfix("params") + void glGetProgramNamedParameterfvNV(@GLuint int id, @AutoSize("name") @GLsizei int length, @Const @GLubyte ByteBuffer name, @OutParameter @Check("4") FloatBuffer params); + + @StripPostfix("params") + void glGetProgramNamedParameterdvNV(@GLuint int id, @AutoSize("name") @GLsizei int length, @Const @GLubyte ByteBuffer name, @OutParameter @Check("4") DoubleBuffer params); +} + diff --git a/src/templates/org/lwjgl/opengl/NV_fragment_program2.java b/src/templates/org/lwjgl/opengl/NV_fragment_program2.java new file mode 100644 index 0000000..edb8c38 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/NV_fragment_program2.java @@ -0,0 +1,44 @@ +/* + * 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; + +public interface NV_fragment_program2 { + + /** + * Accepted by the <pname> parameter of GetProgramivARB: + */ + int GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV = 0x88F4; + int GL_MAX_PROGRAM_CALL_DEPTH_NV = 0x88F5; + int GL_MAX_PROGRAM_IF_DEPTH_NV = 0x88F6; + int GL_MAX_PROGRAM_LOOP_DEPTH_NV = 0x88F7; + int GL_MAX_PROGRAM_LOOP_COUNT_NV = 0x88F8; +} diff --git a/src/templates/org/lwjgl/opengl/NV_fragment_program4.java b/src/templates/org/lwjgl/opengl/NV_fragment_program4.java new file mode 100644 index 0000000..a735729 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/NV_fragment_program4.java @@ -0,0 +1,36 @@ +/* + * 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; + +public interface NV_fragment_program4 { + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/NV_fragment_program_option.java b/src/templates/org/lwjgl/opengl/NV_fragment_program_option.java new file mode 100644 index 0000000..56e04b1 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/NV_fragment_program_option.java @@ -0,0 +1,35 @@ +/* + * 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; + +public interface NV_fragment_program_option { +} diff --git a/src/templates/org/lwjgl/opengl/NV_framebuffer_multisample_coverage.java b/src/templates/org/lwjgl/opengl/NV_framebuffer_multisample_coverage.java new file mode 100644 index 0000000..7238b5f --- /dev/null +++ b/src/templates/org/lwjgl/opengl/NV_framebuffer_multisample_coverage.java @@ -0,0 +1,49 @@ +/* + * 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; + +import org.lwjgl.util.generator.GLenum; +import org.lwjgl.util.generator.GLsizei; + +public interface NV_framebuffer_multisample_coverage { + + /** Accepted by the <pname> parameter of GetRenderbufferParameterivEXT. */ + int GL_RENDERBUFFER_COVERAGE_SAMPLES_NV = 0x8CAB; + int GL_RENDERBUFFER_COLOR_SAMPLES_NV = 0x8E10; + + /** Accepted by the <pname> parameter of GetIntegerv. */ + int GL_MAX_MULTISAMPLE_COVERAGE_MODES_NV = 0x8E11; + int GL_MULITSAMPLE_COVERAGE_MODES_NV = 0x8E12; + + void glRenderbufferStorageMultisampleCoverageNV(@GLenum int target, @GLsizei int coverageSamples, @GLsizei int colorSamples, + @GLenum int internalformat, @GLsizei int width, @GLsizei int height); +} diff --git a/src/templates/org/lwjgl/opengl/NV_geometry_program4.java b/src/templates/org/lwjgl/opengl/NV_geometry_program4.java new file mode 100644 index 0000000..8db5045 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/NV_geometry_program4.java @@ -0,0 +1,58 @@ +/* + * 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; + +import org.lwjgl.util.generator.GLenum; +import org.lwjgl.util.generator.GLuint; + +public interface NV_geometry_program4 { + + /** + * Accepted by the <cap> parameter of Disable, Enable, and IsEnabled, and by + * the <pname> parameter of GetBooleanv, GetIntegerv, GetFloatv, and + * GetDoublev: + */ + int GL_GEOMETRY_PROGRAM_NV = 0x8C26; + + /** Accepted by the <pname> parameter of GetProgramivARB: */ + int GL_MAX_PROGRAM_OUTPUT_VERTICES_NV = 0x8C27; + int GL_MAX_PROGRAM_TOTAL_OUTPUT_COMPONENTS_NV = 0x8C28; + + void glProgramVertexLimitNV(@GLenum int target, int limit); + + void glFramebufferTextureEXT(@GLenum int target, @GLenum int attachment, @GLuint int texture, int level); + + void glFramebufferTextureLayerEXT(@GLenum int target, @GLenum int attachment, @GLuint int texture, int level, int layer); + + void glFramebufferTextureFaceEXT(@GLenum int target, @GLenum int attachment, @GLuint int texture, int level, @GLenum int face); + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/NV_geometry_shader4.java b/src/templates/org/lwjgl/opengl/NV_geometry_shader4.java new file mode 100644 index 0000000..b1e173c --- /dev/null +++ b/src/templates/org/lwjgl/opengl/NV_geometry_shader4.java @@ -0,0 +1,36 @@ +/* + * 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; + +public interface NV_geometry_shader4 { + +} diff --git a/src/templates/org/lwjgl/opengl/NV_gpu_program4.java b/src/templates/org/lwjgl/opengl/NV_gpu_program4.java new file mode 100644 index 0000000..6275ca2 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/NV_gpu_program4.java @@ -0,0 +1,108 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +import java.nio.IntBuffer; + +public interface NV_gpu_program4 { + + /** Accepted by the <pname> parameter of GetProgramivARB: */ + int GL_PROGRAM_ATTRIB_COMPONENTS_NV = 0x8906; + int GL_PROGRAM_RESULT_COMPONENTS_NV = 0x8907; + int GL_MAX_PROGRAM_ATTRIB_COMPONENTS_NV = 0x8908; + int GL_MAX_PROGRAM_RESULT_COMPONENTS_NV = 0x8909; + int GL_MAX_PROGRAM_GENERIC_ATTRIBS_NV = 0x8DA5; + int GL_MAX_PROGRAM_GENERIC_RESULTS_NV = 0x8DA6; + + // --- + + void glProgramLocalParameterI4iNV(@GLenum int target, @GLuint int index, int x, int y, int z, int w); + + @StripPostfix("params") + void glProgramLocalParameterI4ivNV(@GLenum int target, @GLuint int index, @Check("4") @Const IntBuffer params); + + @StripPostfix("params") + void glProgramLocalParametersI4ivNV(@GLenum int target, @GLuint int index, + @AutoSize(value = "params", expression = " >> 2") @GLsizei int count, @Const IntBuffer params); + + // --- + + void glProgramLocalParameterI4uiNV(@GLenum int target, @GLuint int index, @GLuint int x, @GLuint int y, @GLuint int z, @GLuint int w); + + @StripPostfix("params") + void glProgramLocalParameterI4uivNV(@GLenum int target, @GLuint int index, @Check("4") @Const @GLuint IntBuffer params); + + @StripPostfix("params") + void glProgramLocalParametersI4uivNV(@GLenum int target, @GLuint int index, + @AutoSize(value = "params", expression = " >> 2") @GLsizei int count, @Const @GLuint IntBuffer params); + + // --- + + void glProgramEnvParameterI4iNV(@GLenum int target, @GLuint int index, int x, int y, int z, int w); + + @StripPostfix("params") + void glProgramEnvParameterI4ivNV(@GLenum int target, @GLuint int index, @Check("4") @Const IntBuffer params); + + @StripPostfix("params") + void glProgramEnvParametersI4ivNV(@GLenum int target, @GLuint int index, + @AutoSize(value = "params", expression = " >> 2") @GLsizei int count, @Const IntBuffer params); + + // --- + + void glProgramEnvParameterI4uiNV(@GLenum int target, @GLuint int index, @GLuint int x, @GLuint int y, @GLuint int z, @GLuint int w); + + @StripPostfix("params") + void glProgramEnvParameterI4uivNV(@GLenum int target, @GLuint int index, @Check("4") @Const @GLuint IntBuffer params); + + @StripPostfix("params") + void glProgramEnvParametersI4uivNV(@GLenum int target, @GLuint int index, + @AutoSize(value = "params", expression = " >> 2") @GLsizei int count, @Const @GLuint IntBuffer params); + + // --- + + @StripPostfix("params") + void glGetProgramLocalParameterIivNV(@GLenum int target, @GLuint int index, @OutParameter @Check("4") IntBuffer params); + + @StripPostfix("params") + void glGetProgramLocalParameterIuivNV(@GLenum int target, @GLuint int index, @OutParameter @Check("4") @GLuint IntBuffer params); + + // --- + + @StripPostfix("params") + void glGetProgramEnvParameterIivNV(@GLenum int target, @GLuint int index, @OutParameter @Check("4")IntBuffer params); + + @StripPostfix("params") + void glGetProgramEnvParameterIuivNV(@GLenum int target, @GLuint int index, @OutParameter @Check("4") @GLuint IntBuffer params); + +} diff --git a/src/templates/org/lwjgl/opengl/NV_gpu_program5.java b/src/templates/org/lwjgl/opengl/NV_gpu_program5.java new file mode 100644 index 0000000..b8b47f8 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/NV_gpu_program5.java @@ -0,0 +1,45 @@ +/* + * 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; + +public interface NV_gpu_program5 { + + /** + * Accepted by the <pname> parameter of GetBooleanv, GetIntegerv, + * GetFloatv, and GetDoublev: + */ + int GL_MAX_GEOMETRY_PROGRAM_INVOCATIONS_NV = 0x8E5A; + int GL_MIN_FRAGMENT_INTERPOLATION_OFFSET_NV = 0x8E5B; + int GL_MAX_FRAGMENT_INTERPOLATION_OFFSET_NV = 0x8E5C; + int GL_FRAGMENT_PROGRAM_INTERPOLATION_OFFSET_BITS_NV = 0x8E5D; + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/NV_gpu_shader5.java b/src/templates/org/lwjgl/opengl/NV_gpu_shader5.java new file mode 100644 index 0000000..f81c43c --- /dev/null +++ b/src/templates/org/lwjgl/opengl/NV_gpu_shader5.java @@ -0,0 +1,182 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +import java.nio.LongBuffer; + +@Dependent +public interface NV_gpu_shader5 { + + /** + * Returned by the <type> parameter of GetActiveAttrib, GetActiveUniform, and + * GetTransformFeedbackVarying: + */ + int GL_INT64_NV = 0x140E; + int GL_UNSIGNED_INT64_NV = 0x140F; + + int GL_INT8_NV = 0x8FE0; + int GL_INT8_VEC2_NV = 0x8FE1; + int GL_INT8_VEC3_NV = 0x8FE2; + int GL_INT8_VEC4_NV = 0x8FE3; + int GL_INT16_NV = 0x8FE4; + int GL_INT16_VEC2_NV = 0x8FE5; + int GL_INT16_VEC3_NV = 0x8FE6; + int GL_INT16_VEC4_NV = 0x8FE7; + int GL_INT64_VEC2_NV = 0x8FE9; + int GL_INT64_VEC3_NV = 0x8FEA; + int GL_INT64_VEC4_NV = 0x8FEB; + int GL_UNSIGNED_INT8_NV = 0x8FEC; + int GL_UNSIGNED_INT8_VEC2_NV = 0x8FED; + int GL_UNSIGNED_INT8_VEC3_NV = 0x8FEE; + int GL_UNSIGNED_INT8_VEC4_NV = 0x8FEF; + int GL_UNSIGNED_INT16_NV = 0x8FF0; + int GL_UNSIGNED_INT16_VEC2_NV = 0x8FF1; + int GL_UNSIGNED_INT16_VEC3_NV = 0x8FF2; + int GL_UNSIGNED_INT16_VEC4_NV = 0x8FF3; + int GL_UNSIGNED_INT64_VEC2_NV = 0x8FF5; + int GL_UNSIGNED_INT64_VEC3_NV = 0x8FF6; + int GL_UNSIGNED_INT64_VEC4_NV = 0x8FF7; + int GL_FLOAT16_NV = 0x8FF8; + int GL_FLOAT16_VEC2_NV = 0x8FF9; + int GL_FLOAT16_VEC3_NV = 0x8FFA; + int GL_FLOAT16_VEC4_NV = 0x8FFB; + + /** Accepted by the <primitiveMode> parameter of BeginTransformFeedback: */ + int GL_PATCHES = ARB_tessellation_shader.GL_PATCHES; + + void glUniform1i64NV(int location, @GLint64EXT long x); + + void glUniform2i64NV(int location, @GLint64EXT long x, @GLint64EXT long y); + + void glUniform3i64NV(int location, @GLint64EXT long x, @GLint64EXT long y, @GLint64EXT long z); + + void glUniform4i64NV(int location, @GLint64EXT long x, @GLint64EXT long y, @GLint64EXT long z, @GLint64EXT long w); + + @StripPostfix("value") + void glUniform1i64vNV(int location, @GLsizei int count, @Const @GLint64EXT @Check("1") LongBuffer value); + + @StripPostfix("value") + void glUniform2i64vNV(int location, @GLsizei int count, @Const @GLint64EXT @Check("2") LongBuffer value); + + @StripPostfix("value") + void glUniform3i64vNV(int location, @GLsizei int count, @Const @GLint64EXT @Check("3") LongBuffer value); + + @StripPostfix("value") + void glUniform4i64vNV(int location, @GLsizei int count, @Const @GLint64EXT @Check("4") LongBuffer value); + + void glUniform1ui64NV(int location, @GLuint64EXT long x); + + void glUniform2ui64NV(int location, @GLuint64EXT long x, @GLuint64EXT long y); + + void glUniform3ui64NV(int location, @GLuint64EXT long x, @GLuint64EXT long y, @GLuint64EXT long z); + + void glUniform4ui64NV(int location, @GLuint64EXT long x, @GLuint64EXT long y, @GLuint64EXT long z, @GLuint64EXT long w); + + @StripPostfix("value") + void glUniform1ui64vNV(int location, @GLsizei int count, @Const @GLuint64EXT @Check("1") LongBuffer value); + + @StripPostfix("value") + void glUniform2ui64vNV(int location, @GLsizei int count, @Const @GLuint64EXT @Check("2") LongBuffer value); + + @StripPostfix("value") + void glUniform3ui64vNV(int location, @GLsizei int count, @Const @GLuint64EXT @Check("3") LongBuffer value); + + @StripPostfix("value") + void glUniform4ui64vNV(int location, @GLsizei int count, @Const @GLuint64EXT @Check("4") LongBuffer value); + + @StripPostfix("params") + void glGetUniformi64vNV(@GLuint int program, int location, @GLint64EXT @Check LongBuffer params); + + @StripPostfix("params") + void glGetUniformui64vNV(@GLuint int program, int location, @GLuint64EXT @Check LongBuffer params); + + // ------------- + + @Dependent("EXT_direct_state_access") + void glProgramUniform1i64NV(@GLuint int program, int location, @GLint64EXT long x); + + @Dependent("EXT_direct_state_access") + void glProgramUniform2i64NV(@GLuint int program, int location, @GLint64EXT long x, @GLint64EXT long y); + + @Dependent("EXT_direct_state_access") + void glProgramUniform3i64NV(@GLuint int program, int location, @GLint64EXT long x, @GLint64EXT long y, @GLint64EXT long z); + + @Dependent("EXT_direct_state_access") + void glProgramUniform4i64NV(@GLuint int program, int location, @GLint64EXT long x, @GLint64EXT long y, @GLint64EXT long z, @GLint64EXT long w); + + @Dependent("EXT_direct_state_access") + @StripPostfix("value") + void glProgramUniform1i64vNV(@GLuint int program, int location, @GLsizei int count, @Const @GLint64EXT @Check("1") LongBuffer value); + + @Dependent("EXT_direct_state_access") + @StripPostfix("value") + void glProgramUniform2i64vNV(@GLuint int program, int location, @GLsizei int count, @Const @GLint64EXT @Check("2") LongBuffer value); + + @Dependent("EXT_direct_state_access") + @StripPostfix("value") + void glProgramUniform3i64vNV(@GLuint int program, int location, @GLsizei int count, @Const @GLint64EXT @Check("3") LongBuffer value); + + @Dependent("EXT_direct_state_access") + @StripPostfix("value") + void glProgramUniform4i64vNV(@GLuint int program, int location, @GLsizei int count, @Const @GLint64EXT @Check("4") LongBuffer value); + + @Dependent("EXT_direct_state_access") + void glProgramUniform1ui64NV(@GLuint int program, int location, @GLuint64EXT long x); + + @Dependent("EXT_direct_state_access") + void glProgramUniform2ui64NV(@GLuint int program, int location, @GLuint64EXT long x, @GLuint64EXT long y); + + @Dependent("EXT_direct_state_access") + void glProgramUniform3ui64NV(@GLuint int program, int location, @GLuint64EXT long x, @GLuint64EXT long y, @GLuint64EXT long z); + + @Dependent("EXT_direct_state_access") + void glProgramUniform4ui64NV(@GLuint int program, int location, @GLuint64EXT long x, @GLuint64EXT long y, @GLuint64EXT long z, @GLuint64EXT long w); + + @Dependent("EXT_direct_state_access") + @StripPostfix("value") + void glProgramUniform1ui64vNV(@GLuint int program, int location, @GLsizei int count, @Const @GLuint64EXT @Check("1") LongBuffer value); + + @Dependent("EXT_direct_state_access") + @StripPostfix("value") + void glProgramUniform2ui64vNV(@GLuint int program, int location, @GLsizei int count, @Const @GLuint64EXT @Check("2") LongBuffer value); + + @Dependent("EXT_direct_state_access") + @StripPostfix("value") + void glProgramUniform3ui64vNV(@GLuint int program, int location, @GLsizei int count, @Const @GLuint64EXT @Check("3") LongBuffer value); + + @Dependent("EXT_direct_state_access") + @StripPostfix("value") + void glProgramUniform4ui64vNV(@GLuint int program, int location, @GLsizei int count, @Const @GLuint64EXT @Check("4") LongBuffer value); + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/NV_half_float.java b/src/templates/org/lwjgl/opengl/NV_half_float.java new file mode 100644 index 0000000..af90b89 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/NV_half_float.java @@ -0,0 +1,136 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +import java.nio.*; + +public interface NV_half_float { + + /** + * Accepted by the <type> argument of VertexPointer, NormalPointer, + * ColorPointer, TexCoordPointer, FogCoordPointerEXT, + * SecondaryColorPointerEXT, VertexWeightPointerEXT, VertexAttribPointerNV, + * DrawPixels, ReadPixels, TexImage1D, TexImage2D, TexImage3D, TexSubImage1D, + * TexSubImage2D, TexSubImage3D, and GetTexImage: + */ + int GL_HALF_FLOAT_NV = 0x140B; + + @NoErrorCheck + void glVertex2hNV(@GLhalf short x, @GLhalf short y); + + @NoErrorCheck + void glVertex3hNV(@GLhalf short x, @GLhalf short y, @GLhalf short z); + + @NoErrorCheck + void glVertex4hNV(@GLhalf short x, @GLhalf short y, @GLhalf short z, @GLhalf short w); + + @NoErrorCheck + void glNormal3hNV(@GLhalf short nx, @GLhalf short ny, @GLhalf short nz); + + @NoErrorCheck + void glColor3hNV(@GLhalf short red, @GLhalf short green, @GLhalf short blue); + + @NoErrorCheck + void glColor4hNV(@GLhalf short red, @GLhalf short green, @GLhalf short blue, @GLhalf short alpha); + + @NoErrorCheck + void glTexCoord1hNV(@GLhalf short s); + + @NoErrorCheck + void glTexCoord2hNV(@GLhalf short s, @GLhalf short t); + + @NoErrorCheck + void glTexCoord3hNV(@GLhalf short s, @GLhalf short t, @GLhalf short r); + + @NoErrorCheck + void glTexCoord4hNV(@GLhalf short s, @GLhalf short t, @GLhalf short r, @GLhalf short q); + + @NoErrorCheck + void glMultiTexCoord1hNV(@GLenum int target, @GLhalf short s); + + @NoErrorCheck + void glMultiTexCoord2hNV(@GLenum int target, @GLhalf short s, @GLhalf short t); + + @NoErrorCheck + void glMultiTexCoord3hNV(@GLenum int target, @GLhalf short s, @GLhalf short t, @GLhalf short r); + + @NoErrorCheck + void glMultiTexCoord4hNV(@GLenum int target, @GLhalf short s, @GLhalf short t, @GLhalf short r, @GLhalf short q); + + @NoErrorCheck + void glFogCoordhNV(@GLhalf short fog); + + @NoErrorCheck + void glSecondaryColor3hNV(@GLhalf short red, @GLhalf short green, @GLhalf short blue); + + @Optional(reason = "AMD does not expose this (last driver checked: 10.3)") + @NoErrorCheck + void glVertexWeighthNV(@GLhalf short weight); + + @Optional(reason = "AMD does not expose this (last driver checked: 10.3)") + @NoErrorCheck + void glVertexAttrib1hNV(@GLuint int index, @GLhalf short x); + + @Optional(reason = "AMD does not expose this (last driver checked: 10.3)") + @NoErrorCheck + void glVertexAttrib2hNV(@GLuint int index, @GLhalf short x, @GLhalf short y); + + @Optional(reason = "AMD does not expose this (last driver checked: 10.3)") + @NoErrorCheck + void glVertexAttrib3hNV(@GLuint int index, @GLhalf short x, @GLhalf short y, @GLhalf short z); + + @Optional(reason = "AMD does not expose this (last driver checked: 10.3)") + @NoErrorCheck + void glVertexAttrib4hNV(@GLuint int index, @GLhalf short x, @GLhalf short y, @GLhalf short z, @GLhalf short w); + + @Optional(reason = "AMD does not expose this (last driver checked: 10.3)") + @NoErrorCheck + @StripPostfix("attribs") + void glVertexAttribs1hvNV(@GLuint int index, @AutoSize("attribs") @GLsizei int n, @Const @GLhalf ShortBuffer attribs); + + @Optional(reason = "AMD does not expose this (last driver checked: 10.3)") + @NoErrorCheck + @StripPostfix("attribs") + void glVertexAttribs2hvNV(@GLuint int index, @AutoSize(value = "attribs", expression = " >> 1") @GLsizei int n, @Const @GLhalf ShortBuffer attribs); + + @Optional(reason = "AMD does not expose this (last driver checked: 10.3)") + @NoErrorCheck + @StripPostfix("attribs") + void glVertexAttribs3hvNV(@GLuint int index, @AutoSize(value = "attribs", expression = " / 3") @GLsizei int n, @Const @GLhalf ShortBuffer attribs); + + @Optional(reason = "AMD does not expose this (last driver checked: 10.3)") + @NoErrorCheck + @StripPostfix("attribs") + void glVertexAttribs4hvNV(@GLuint int index, @AutoSize(value = "attribs", expression = " >> 2") @GLsizei int n, @Const @GLhalf ShortBuffer attribs); +} diff --git a/src/templates/org/lwjgl/opengl/NV_light_max_exponent.java b/src/templates/org/lwjgl/opengl/NV_light_max_exponent.java new file mode 100644 index 0000000..3dde7e6 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/NV_light_max_exponent.java @@ -0,0 +1,37 @@ +/* + * 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; + +public interface NV_light_max_exponent { + int GL_MAX_SHININESS_NV = 0x8504; + int GL_MAX_SPOT_EXPONENT_NV = 0x8505; +} diff --git a/src/templates/org/lwjgl/opengl/NV_multisample_filter_hint.java b/src/templates/org/lwjgl/opengl/NV_multisample_filter_hint.java new file mode 100644 index 0000000..96f8e4e --- /dev/null +++ b/src/templates/org/lwjgl/opengl/NV_multisample_filter_hint.java @@ -0,0 +1,41 @@ +/* + * 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; + +public interface NV_multisample_filter_hint { + + /** + * Accepted by the <target> parameter of Hint and by the <pname> + * parameter of GetBooleanv, GetIntegerv, GetFloatv, and GetDoublev: + */ + int GL_MULTISAMPLE_FILTER_HINT_NV = 0x8534; +} diff --git a/src/templates/org/lwjgl/opengl/NV_occlusion_query.java b/src/templates/org/lwjgl/opengl/NV_occlusion_query.java new file mode 100644 index 0000000..d0c0863 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/NV_occlusion_query.java @@ -0,0 +1,80 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +import java.nio.IntBuffer; + +public interface NV_occlusion_query { + + int GL_OCCLUSION_TEST_HP = 0x8165; + int GL_OCCLUSION_TEST_RESULT_HP = 0x8166; + /* HP_occlusion_test */ + int GL_PIXEL_COUNTER_BITS_NV = 0x8864; + int GL_CURRENT_OCCLUSION_QUERY_ID_NV = 0x8865; + int GL_PIXEL_COUNT_NV = 0x8866; + int GL_PIXEL_COUNT_AVAILABLE_NV = 0x8867; + + void glGenOcclusionQueriesNV(@AutoSize("piIDs") @GLsizei int n, @OutParameter @GLuint IntBuffer piIDs); + + @Alternate("glGenOcclusionQueriesNV") + @GLreturn("piIDs") + void glGenOcclusionQueriesNV2(@Constant("1") @GLsizei int n, @OutParameter @GLuint IntBuffer piIDs); + + void glDeleteOcclusionQueriesNV(@AutoSize("piIDs") @GLsizei int n, @Const @GLuint IntBuffer piIDs); + + @Alternate("glDeleteOcclusionQueriesNV") + void glDeleteOcclusionQueriesNV(@Constant("1") @GLsizei int n, @Constant(value = "APIUtils.getBufferInt().put(0, piID), 0", keepParam = true) int piID); + + boolean glIsOcclusionQueryNV(@GLuint int id); + + void glBeginOcclusionQueryNV(@GLuint int id); + + void glEndOcclusionQueryNV(); + + @StripPostfix("params") + void glGetOcclusionQueryuivNV(@GLuint int id, @GLenum int pname, @OutParameter @Check("1") @GLuint IntBuffer params); + + @Alternate("glGetOcclusionQueryuivNV") + @GLreturn("params") + @StripPostfix(value = "params", postfix = "v") + void glGetOcclusionQueryuivNV2(@GLuint int id, @GLenum int pname, @OutParameter @GLuint IntBuffer params); + + @StripPostfix("params") + void glGetOcclusionQueryivNV(@GLuint int id, @GLenum int pname, @OutParameter @Check("1") IntBuffer params); + + @Alternate("glGetOcclusionQueryivNV") + @GLreturn("params") + @StripPostfix(value = "params", postfix = "v") + void glGetOcclusionQueryivNV2(@GLuint int id, @GLenum int pname, @OutParameter IntBuffer params); +} diff --git a/src/templates/org/lwjgl/opengl/NV_packed_depth_stencil.java b/src/templates/org/lwjgl/opengl/NV_packed_depth_stencil.java new file mode 100644 index 0000000..552447f --- /dev/null +++ b/src/templates/org/lwjgl/opengl/NV_packed_depth_stencil.java @@ -0,0 +1,37 @@ +/* + * 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; + +public interface NV_packed_depth_stencil { + int GL_DEPTH_STENCIL_NV = 0x84F9; + int GL_UNSIGNED_INT_24_8_NV = 0x84FA; +} diff --git a/src/templates/org/lwjgl/opengl/NV_parameter_buffer_object.java b/src/templates/org/lwjgl/opengl/NV_parameter_buffer_object.java new file mode 100644 index 0000000..d7c39da --- /dev/null +++ b/src/templates/org/lwjgl/opengl/NV_parameter_buffer_object.java @@ -0,0 +1,67 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +import java.nio.FloatBuffer; +import java.nio.IntBuffer; + +public interface NV_parameter_buffer_object { + + /** Accepted by the <pname> parameter of GetProgramivARB: */ + int GL_MAX_PROGRAM_PARAMETER_BUFFER_BINDINGS_NV = 0x8DA0; + int GL_MAX_PROGRAM_PARAMETER_BUFFER_SIZE_NV = 0x8DA1; + + /** + * Accepted by the <target> parameter of ProgramBufferParametersfvNV, + * ProgramBufferParametersIivNV, and ProgramBufferParametersIuivNV, + * BindBufferRangeNV, BindBufferOffsetNV, BindBufferBaseNV, and BindBuffer + * and the <value> parameter of GetIntegerIndexedvEXT: + */ + int GL_VERTEX_PROGRAM_PARAMETER_BUFFER_NV = 0x8DA2; + int GL_GEOMETRY_PROGRAM_PARAMETER_BUFFER_NV = 0x8DA3; + int GL_FRAGMENT_PROGRAM_PARAMETER_BUFFER_NV = 0x8DA4; + + @StripPostfix("params") + void glProgramBufferParametersfvNV(@GLenum int target, @GLuint int buffer, @GLuint int index, + @AutoSize(value = "params", expression = " >> 2") @GLsizei int count, @Const FloatBuffer params); + + @StripPostfix("params") + void glProgramBufferParametersIivNV(@GLenum int target, @GLuint int buffer, @GLuint int index, + @AutoSize(value = "params", expression = " >> 2") @GLsizei int count, @Const IntBuffer params); + + @StripPostfix("params") + void glProgramBufferParametersIuivNV(@GLenum int target, @GLuint int buffer, @GLuint int index, + @AutoSize(value = "params", expression = " >> 2") @GLuint int count, @Const @GLuint IntBuffer params); + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/NV_parameter_buffer_object2.java b/src/templates/org/lwjgl/opengl/NV_parameter_buffer_object2.java new file mode 100644 index 0000000..9f37f48 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/NV_parameter_buffer_object2.java @@ -0,0 +1,36 @@ +/* + * 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; + +public interface NV_parameter_buffer_object2 { + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/NV_pixel_data_range.java b/src/templates/org/lwjgl/opengl/NV_pixel_data_range.java new file mode 100644 index 0000000..1deb726 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/NV_pixel_data_range.java @@ -0,0 +1,69 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +import java.nio.*; + +public interface NV_pixel_data_range { + + /** + * Accepted by the <target> parameter of PixelDataRangeNV and + * FlushPixelDataRangeNV, and by the <cap> parameter of + * EnableClientState, DisableClientState, and IsEnabled: + */ + int GL_WRITE_PIXEL_DATA_RANGE_NV = 0x8878; + int GL_READ_PIXEL_DATA_RANGE_NV = 0x8879; + + /** + * Accepted by the <pname> parameter of GetBooleanv, GetIntegerv, + * GetFloatv, and GetDoublev: + */ + int GL_WRITE_PIXEL_DATA_RANGE_LENGTH_NV = 0x887A; + int GL_READ_PIXEL_DATA_RANGE_LENGTH_NV = 0x887B; + + /** + * Accepted by the <pname> parameter of GetPointerv: + */ + int GL_WRITE_PIXEL_DATA_RANGE_POINTER_NV = 0x887C; + int GL_READ_PIXEL_DATA_RANGE_POINTER_NV = 0x887D; + + void glPixelDataRangeNV(@GLenum int target, @AutoSize("data") @GLsizei int length, + @GLbyte + @GLshort + @GLint + @GLfloat + @GLdouble Buffer data); + + void glFlushPixelDataRangeNV(@GLenum int target); +} diff --git a/src/templates/org/lwjgl/opengl/NV_point_sprite.java b/src/templates/org/lwjgl/opengl/NV_point_sprite.java new file mode 100644 index 0000000..fb8f627 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/NV_point_sprite.java @@ -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.opengl; + +import org.lwjgl.util.generator.*; + +import java.nio.*; + +public interface NV_point_sprite { + int GL_POINT_SPRITE_NV = 0x8861; + int GL_COORD_REPLACE_NV = 0x8862; + int GL_POINT_SPRITE_R_MODE_NV = 0x8863; + + void glPointParameteriNV(@GLenum int pname, int param); + + @StripPostfix("params") + void glPointParameterivNV(@GLenum int pname, @Check("4") @Const IntBuffer params); +} diff --git a/src/templates/org/lwjgl/opengl/NV_primitive_restart.java b/src/templates/org/lwjgl/opengl/NV_primitive_restart.java new file mode 100644 index 0000000..de0ca10 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/NV_primitive_restart.java @@ -0,0 +1,56 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +@ForceInit +public interface NV_primitive_restart { + + /** + * Accepted by the <array> parameter of EnableClientState and + * DisableClientState, by the <cap> parameter of IsEnabled, and by + * the <pname> parameter of GetBooleanv, GetIntegerv, GetFloatv, and + * GetDoublev: + */ + int GL_PRIMITIVE_RESTART_NV = 0x8558; + + /** + * Accepted by the <pname> parameter of GetBooleanv, GetIntegerv, + * GetFloatv, and GetDoublev: + */ + int GL_PRIMITIVE_RESTART_INDEX_NV = 0x8559; + + void glPrimitiveRestartNV(); + + void glPrimitiveRestartIndexNV(@GLuint int index); +} diff --git a/src/templates/org/lwjgl/opengl/NV_program.java b/src/templates/org/lwjgl/opengl/NV_program.java new file mode 100644 index 0000000..2c4c1f8 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/NV_program.java @@ -0,0 +1,104 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +import java.nio.Buffer; +import java.nio.ByteBuffer; +import java.nio.IntBuffer; + +@Extension(postfix = "NV", isFinal = false) +public interface NV_program { + + /** Accepted by the <pname> parameter of GetProgramivNV: */ + int GL_PROGRAM_TARGET_NV = 0x8646; + int GL_PROGRAM_LENGTH_NV = 0x8627; + int GL_PROGRAM_RESIDENT_NV = 0x8647; + + /** Accepted by the <pname> parameter of GetProgramStringNV: */ + int GL_PROGRAM_STRING_NV = 0x8628; + + /** + * Accepted by the <pname> parameter of GetBooleanv, GetIntegerv, + * GetFloatv, and GetDoublev: + */ + int GL_PROGRAM_ERROR_POSITION_NV = 0x864B; + + /** Accepted by the <name> parameter of GetString: */ + int GL_PROGRAM_ERROR_STRING_NV = 0x8874; + + void glLoadProgramNV(@GLenum int target, @GLuint int programID, @AutoSize("string") @GLsizei int length, @Const @GLubyte Buffer string); + + @Alternate("glLoadProgramNV") + void glLoadProgramNV(@GLenum int target, @GLuint int programID, @Constant("string.length()") @GLsizei int length, CharSequence string); + + void glBindProgramNV(@GLenum int target, @GLuint int programID); + + void glDeleteProgramsNV(@AutoSize("programs") @GLsizei int n, @Const @GLuint IntBuffer programs); + + @Alternate("glDeleteProgramsNV") + void glDeleteProgramsNV(@Constant("1") @GLsizei int n, @Constant(value = "APIUtils.getBufferInt().put(0, program), 0", keepParam = true) int program); + + void glGenProgramsNV(@AutoSize("programs") @GLsizei int n, @OutParameter @GLuint IntBuffer programs); + + @Alternate("glGenProgramsNV") + @GLreturn("programs") + void glGenProgramsNV2(@Constant("1") @GLsizei int n, @OutParameter @GLuint IntBuffer programs); + + @StripPostfix("params") + void glGetProgramivNV(@GLuint int programID, @GLenum int parameterName, @OutParameter @Check @GLint IntBuffer params); + + @Alternate("glGetProgramivNV") + @GLreturn("params") + @StripPostfix("params") + void glGetProgramivNV2(@GLuint int programID, @GLenum int parameterName, @OutParameter @GLint IntBuffer params); + + void glGetProgramStringNV(@GLuint int programID, @GLenum int parameterName, @OutParameter @Check @GLubyte Buffer paramString); + + @Alternate("glGetProgramStringNV") + @Code("\t\tint programLength = glGetProgramNV(programID, GL_PROGRAM_LENGTH_NV);") + @GLreturn(value="paramString", maxLength = "programLength", forceMaxLength = true) + void glGetProgramStringNV2(@GLuint int programID, @GLenum int parameterName, @OutParameter @GLchar ByteBuffer paramString); + + boolean glIsProgramNV(@GLuint int programID); + + boolean glAreProgramsResidentNV(@AutoSize("programIDs") @GLsizei int n, + @Const @GLuint IntBuffer programIDs, + @OutParameter @GLboolean @Check("programIDs.remaining()") ByteBuffer programResidences); + + void glRequestResidentProgramsNV(@AutoSize("programIDs") @GLsizei int n, @GLuint IntBuffer programIDs); + + @Alternate("glRequestResidentProgramsNV") + void glRequestResidentProgramsNV(@Constant("1") @GLsizei int n, @Constant(value = "APIUtils.getBufferInt().put(0, programID), 0", keepParam = true) int programID); +} + diff --git a/src/templates/org/lwjgl/opengl/NV_register_combiners.java b/src/templates/org/lwjgl/opengl/NV_register_combiners.java new file mode 100644 index 0000000..26b0f2f --- /dev/null +++ b/src/templates/org/lwjgl/opengl/NV_register_combiners.java @@ -0,0 +1,154 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +import java.nio.*; + +public interface NV_register_combiners { + int GL_REGISTER_COMBINERS_NV = 0x8522; + int GL_COMBINER0_NV = 0x8550; + int GL_COMBINER1_NV = 0x8551; + int GL_COMBINER2_NV = 0x8552; + int GL_COMBINER3_NV = 0x8553; + int GL_COMBINER4_NV = 0x8554; + int GL_COMBINER5_NV = 0x8555; + int GL_COMBINER6_NV = 0x8556; + int GL_COMBINER7_NV = 0x8557; + int GL_VARIABLE_A_NV = 0x8523; + int GL_VARIABLE_B_NV = 0x8524; + int GL_VARIABLE_C_NV = 0x8525; + int GL_VARIABLE_D_NV = 0x8526; + int GL_VARIABLE_E_NV = 0x8527; + int GL_VARIABLE_F_NV = 0x8528; + int GL_VARIABLE_G_NV = 0x8529; + int GL_CONSTANT_COLOR0_NV = 0x852A; + int GL_CONSTANT_COLOR1_NV = 0x852B; + int GL_PRIMARY_COLOR_NV = 0x852C; + int GL_SECONDARY_COLOR_NV = 0x852D; + int GL_SPARE0_NV = 0x852E; + int GL_SPARE1_NV = 0x852F; + int GL_UNSIGNED_IDENTITY_NV = 0x8536; + int GL_UNSIGNED_INVERT_NV = 0x8537; + int GL_EXPAND_NORMAL_NV = 0x8538; + int GL_EXPAND_NEGATE_NV = 0x8539; + int GL_HALF_BIAS_NORMAL_NV = 0x853A; + int GL_HALF_BIAS_NEGATE_NV = 0x853B; + int GL_SIGNED_IDENTITY_NV = 0x853C; + int GL_SIGNED_NEGATE_NV = 0x853D; + int GL_E_TIMES_F_NV = 0x8531; + int GL_SPARE0_PLUS_SECONDARY_COLOR_NV = 0x8532; + int GL_SCALE_BY_TWO_NV = 0x853E; + int GL_SCALE_BY_FOUR_NV = 0x853F; + int GL_SCALE_BY_ONE_HALF_NV = 0x8540; + int GL_BIAS_BY_NEGATIVE_ONE_HALF_NV = 0x8541; + int GL_DISCARD_NV = 0x8530; + int GL_COMBINER_INPUT_NV = 0x8542; + int GL_COMBINER_MAPPING_NV = 0x8543; + int GL_COMBINER_COMPONENT_USAGE_NV = 0x8544; + int GL_COMBINER_AB_DOT_PRODUCT_NV = 0x8545; + int GL_COMBINER_CD_DOT_PRODUCT_NV = 0x8546; + int GL_COMBINER_MUX_SUM_NV = 0x8547; + int GL_COMBINER_SCALE_NV = 0x8548; + int GL_COMBINER_BIAS_NV = 0x8549; + int GL_COMBINER_AB_OUTPUT_NV = 0x854A; + int GL_COMBINER_CD_OUTPUT_NV = 0x854B; + int GL_COMBINER_SUM_OUTPUT_NV = 0x854C; + int GL_NUM_GENERAL_COMBINERS_NV = 0x854E; + int GL_COLOR_SUM_CLAMP_NV = 0x854F; + int GL_MAX_GENERAL_COMBINERS_NV = 0x854D; + + void glCombinerParameterfNV(@GLenum int pname, float param); + + @StripPostfix("params") + void glCombinerParameterfvNV(@GLenum int pname, @Check("4") @Const FloatBuffer params); + + void glCombinerParameteriNV(@GLenum int pname, int param); + + @StripPostfix("params") + void glCombinerParameterivNV(@GLenum int pname, @Check("4") @Const IntBuffer params); + + void glCombinerInputNV(@GLenum int stage, @GLenum int portion, @GLenum int variable, @GLenum int input, @GLenum int mapping, @GLenum int componentUsage); + + void glCombinerOutputNV(@GLenum int stage, @GLenum int portion, @GLenum int abOutput, @GLenum int cdOutput, @GLenum int sumOutput, @GLenum int scale, @GLenum int bias, boolean abDotProduct, boolean cdDotProduct, boolean muxSum); + + void glFinalCombinerInputNV(@GLenum int variable, @GLenum int input, @GLenum int mapping, @GLenum int componentUsage); + + @StripPostfix("params") + void glGetCombinerInputParameterfvNV(@GLenum int stage, @GLenum int portion, @GLenum int variable, @GLenum int pname, @OutParameter @Check("4") FloatBuffer params); + + @Alternate("glGetCombinerInputParameterfvNV") + @GLreturn("params") + @StripPostfix(value = "params", postfix = "v") + void glGetCombinerInputParameterfvNV2(@GLenum int stage, @GLenum int portion, @GLenum int variable, @GLenum int pname, @OutParameter FloatBuffer params); + + @StripPostfix("params") + void glGetCombinerInputParameterivNV(@GLenum int stage, @GLenum int portion, @GLenum int variable, @GLenum int pname, @OutParameter @Check("4") IntBuffer params); + + @Alternate("glGetCombinerInputParameterivNV") + @GLreturn("params") + @StripPostfix(value = "params", postfix = "v") + void glGetCombinerInputParameterivNV2(@GLenum int stage, @GLenum int portion, @GLenum int variable, @GLenum int pname, @OutParameter IntBuffer params); + + @StripPostfix("params") + void glGetCombinerOutputParameterfvNV(@GLenum int stage, @GLenum int portion, @GLenum int pname, @OutParameter @Check("4") FloatBuffer params); + + @Alternate("glGetCombinerOutputParameterfvNV") + @GLreturn("params") + @StripPostfix(value = "params", postfix = "v") + void glGetCombinerOutputParameterfvNV2(@GLenum int stage, @GLenum int portion, @GLenum int pname, @OutParameter FloatBuffer params); + + @StripPostfix("params") + void glGetCombinerOutputParameterivNV(@GLenum int stage, @GLenum int portion, @GLenum int pname, @OutParameter @Check("4") IntBuffer params); + + @Alternate("glGetCombinerOutputParameterivNV") + @GLreturn("params") + @StripPostfix(value = "params", postfix = "v") + void glGetCombinerOutputParameterivNV2(@GLenum int stage, @GLenum int portion, @GLenum int pname, @OutParameter IntBuffer params); + + @StripPostfix("params") + void glGetFinalCombinerInputParameterfvNV(@GLenum int variable, @GLenum int pname, @OutParameter @Check("4") FloatBuffer params); + + @Alternate("glGetFinalCombinerInputParameterfvNV") + @GLreturn("params") + @StripPostfix(value = "params", postfix = "v") + void glGetFinalCombinerInputParameterfvNV2(@GLenum int variable, @GLenum int pname, @OutParameter FloatBuffer params); + + @StripPostfix("params") + void glGetFinalCombinerInputParameterivNV(@GLenum int variable, @GLenum int pname, @OutParameter @Check("4") IntBuffer params); + + @Alternate("glGetFinalCombinerInputParameterivNV") + @GLreturn("params") + @StripPostfix(value = "params", postfix = "v") + void glGetFinalCombinerInputParameterivNV2(@GLenum int variable, @GLenum int pname, @OutParameter IntBuffer params); +} diff --git a/src/templates/org/lwjgl/opengl/NV_register_combiners2.java b/src/templates/org/lwjgl/opengl/NV_register_combiners2.java new file mode 100644 index 0000000..4c7cd01 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/NV_register_combiners2.java @@ -0,0 +1,46 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +import java.nio.*; + +public interface NV_register_combiners2 { + int GL_PER_STAGE_CONSTANTS_NV = 0x8535; + + @StripPostfix("params") + void glCombinerStageParameterfvNV(@GLenum int stage, @GLenum int pname, @Const @Check("4") FloatBuffer params); + + @StripPostfix("params") + void glGetCombinerStageParameterfvNV(@GLenum int stage, @GLenum int pname, @OutParameter @Check("4") FloatBuffer params); +} diff --git a/src/templates/org/lwjgl/opengl/NV_shader_buffer_load.java b/src/templates/org/lwjgl/opengl/NV_shader_buffer_load.java new file mode 100644 index 0000000..6c1e5c8 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/NV_shader_buffer_load.java @@ -0,0 +1,101 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +import java.nio.LongBuffer; + +public interface NV_shader_buffer_load { + + /** + * Accepted by the <pname> parameter of GetBufferParameterui64vNV, + * GetNamedBufferParameterui64vNV: + */ + int GL_BUFFER_GPU_ADDRESS_NV = 0x8F1D; + + /** Returned by the <type> parameter of GetActiveUniform: */ + int GL_GPU_ADDRESS_NV = 0x8F34; + + /** Accepted by the <value> parameter of GetIntegerui64vNV: */ + int GL_MAX_SHADER_BUFFER_ADDRESS_NV = 0x8F35; + + void glMakeBufferResidentNV(@GLenum int target, @GLenum int access); + + void glMakeBufferNonResidentNV(@GLenum int target); + + boolean glIsBufferResidentNV(@GLenum int target); + + void glMakeNamedBufferResidentNV(@GLuint int buffer, @GLenum int access); + + void glMakeNamedBufferNonResidentNV(@GLuint int buffer); + + boolean glIsNamedBufferResidentNV(@GLuint int buffer); + + @StripPostfix("params") + void glGetBufferParameterui64vNV(@GLenum int target, @GLenum int pname, @OutParameter @Check("1") @GLuint64EXT LongBuffer params); + + @Alternate("glGetBufferParameterui64vNV") + @GLreturn("params") + @StripPostfix("params") + void glGetBufferParameterui64vNV2(@GLenum int target, @GLenum int pname, @OutParameter @GLuint64EXT LongBuffer params); + + @StripPostfix("params") + void glGetNamedBufferParameterui64vNV(@GLuint int buffer, @GLenum int pname, @OutParameter @Check("1") @GLuint64EXT LongBuffer params); + + @Alternate("glGetNamedBufferParameterui64vNV") + @GLreturn("params") + @StripPostfix("params") + void glGetNamedBufferParameterui64vNV2(@GLuint int buffer, @GLenum int pname, @OutParameter @GLuint64EXT LongBuffer params); + + @StripPostfix("result") + void glGetIntegerui64vNV(@GLenum int value, @OutParameter @Check("1") @GLuint64EXT LongBuffer result); + + @Alternate("glGetIntegerui64vNV") + @GLreturn("result") + @StripPostfix("result") + void glGetIntegerui64vNV2(@GLenum int value, @OutParameter @GLuint64EXT LongBuffer result); + + void glUniformui64NV(int location, @GLuint64EXT long value); + + @StripPostfix("value") + void glUniformui64vNV(int location, @AutoSize("value") @GLsizei int count, @Const @GLuint64EXT LongBuffer value); + + @StripPostfix("params") + void glGetUniformui64vNV(@GLuint int program, int location, @OutParameter @Check("1") @GLuint64EXT LongBuffer params); + + void glProgramUniformui64NV(@GLuint int program, int location, @GLuint64EXT long value); + + @StripPostfix("value") + void glProgramUniformui64vNV(@GLuint int program, int location, @AutoSize("value") @GLsizei int count, @Const @GLuint64EXT LongBuffer value); + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/NV_shader_buffer_store.java b/src/templates/org/lwjgl/opengl/NV_shader_buffer_store.java new file mode 100644 index 0000000..f20da04 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/NV_shader_buffer_store.java @@ -0,0 +1,43 @@ +/* + * 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; + +public interface NV_shader_buffer_store { + + /** Accepted by the <barriers> parameter of MemoryBarrierNV: */ + int GL_SHADER_GLOBAL_ACCESS_BARRIER_BIT_NV = 0x00000010; + + /** Accepted by the <access> parameter of MakeBufferResidentNV: */ + int GL_READ_WRITE = GL15.GL_READ_WRITE; + int GL_WRITE_ONLY = GL15.GL_WRITE_ONLY; + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/NV_tessellation_program5.java b/src/templates/org/lwjgl/opengl/NV_tessellation_program5.java new file mode 100644 index 0000000..f322838 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/NV_tessellation_program5.java @@ -0,0 +1,60 @@ +/* + * 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; + +public interface NV_tessellation_program5 { + + /** + * Accepted by the <cap> parameter of Disable, Enable, and IsEnabled, + * by the <pname> parameter of GetBooleanv, GetIntegerv, GetFloatv, + * and GetDoublev, and by the <target> parameter of ProgramStringARB, + * BindProgramARB, ProgramEnvParameter4[df][v]ARB, + * ProgramLocalParameter4[df][v]ARB, GetProgramEnvParameter[df]vARB, + * GetProgramLocalParameter[df]vARB, GetProgramivARB and + * GetProgramStringARB: + */ + int GL_TESS_CONTROL_PROGRAM_NV = 0x891E; + int GL_TESS_EVALUATION_PROGRAM_NV = 0x891F; + + /** + * Accepted by the <target> parameter of ProgramBufferParametersfvNV, + * ProgramBufferParametersIivNV, and ProgramBufferParametersIuivNV, + * BindBufferRangeNV, BindBufferOffsetNV, BindBufferBaseNV, and BindBuffer + * and the <value> parameter of GetIntegerIndexedvEXT: + */ + int GL_TESS_CONTROL_PROGRAM_PARAMETER_BUFFER_NV = 0x8C74; + int GL_TESS_EVALUATION_PROGRAM_PARAMETER_BUFFER_NV = 0x8C75; + + /** Accepted by the <pname> parameter of GetProgramivARB: */ + int GL_MAX_PROGRAM_PATCH_ATTRIBS_NV = 0x86D8; + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/NV_texgen_reflection.java b/src/templates/org/lwjgl/opengl/NV_texgen_reflection.java new file mode 100644 index 0000000..fe0582a --- /dev/null +++ b/src/templates/org/lwjgl/opengl/NV_texgen_reflection.java @@ -0,0 +1,37 @@ +/* + * 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; + +public interface NV_texgen_reflection { + int GL_NORMAL_MAP_NV = 0x8511; + int GL_REFLECTION_MAP_NV = 0x8512; +} diff --git a/src/templates/org/lwjgl/opengl/NV_texture_barrier.java b/src/templates/org/lwjgl/opengl/NV_texture_barrier.java new file mode 100644 index 0000000..71858b2 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/NV_texture_barrier.java @@ -0,0 +1,38 @@ +/* + * 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; + +public interface NV_texture_barrier { + + void glTextureBarrierNV(); + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/NV_texture_compression_vtc.java b/src/templates/org/lwjgl/opengl/NV_texture_compression_vtc.java new file mode 100644 index 0000000..f3414be --- /dev/null +++ b/src/templates/org/lwjgl/opengl/NV_texture_compression_vtc.java @@ -0,0 +1,48 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +@Extension(postfix = "NV", className = "NVTextureCompressionVTC") +public interface NV_texture_compression_vtc { + + /** + * Accepted by the <internalformat> parameter of TexImage3D and + * CompressedTexImage3DARB and the <format> parameter of + * CompressedTexSubImage2DARB: + */ + int GL_COMPRESSED_RGB_S3TC_DXT1_EXT = 0x83F0; + int GL_COMPRESSED_RGBA_S3TC_DXT1_EXT = 0x83F1; + int GL_COMPRESSED_RGBA_S3TC_DXT3_EXT = 0x83F2; + int GL_COMPRESSED_RGBA_S3TC_DXT5_EXT = 0x83F3; +} diff --git a/src/templates/org/lwjgl/opengl/NV_texture_env_combine4.java b/src/templates/org/lwjgl/opengl/NV_texture_env_combine4.java new file mode 100644 index 0000000..5e2ae59 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/NV_texture_env_combine4.java @@ -0,0 +1,40 @@ +/* + * 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; + +public interface NV_texture_env_combine4 { + int GL_COMBINE4_NV = 0x8503; + int GL_SOURCE3_RGB_NV = 0x8583; + int GL_SOURCE3_ALPHA_NV = 0x858B; + int GL_OPERAND3_RGB_NV = 0x8593; + int GL_OPERAND3_ALPHA_NV = 0x859B; +} diff --git a/src/templates/org/lwjgl/opengl/NV_texture_expand_normal.java b/src/templates/org/lwjgl/opengl/NV_texture_expand_normal.java new file mode 100644 index 0000000..46a1aef --- /dev/null +++ b/src/templates/org/lwjgl/opengl/NV_texture_expand_normal.java @@ -0,0 +1,42 @@ +/* + * 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; + +public interface NV_texture_expand_normal { + + /** + * Accepted by the <pname> parameters of TexParameteri, + * TexParameteriv, TexParameterf, TexParameterfv, GetTexParameteri, + * and GetTexParameteriv: + */ + int GL_TEXTURE_UNSIGNED_REMAP_MODE_NV = 0x888F; +} diff --git a/src/templates/org/lwjgl/opengl/NV_texture_rectangle.java b/src/templates/org/lwjgl/opengl/NV_texture_rectangle.java new file mode 100644 index 0000000..5948814 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/NV_texture_rectangle.java @@ -0,0 +1,39 @@ +/* + * 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; + +public interface NV_texture_rectangle { + int GL_TEXTURE_RECTANGLE_NV = 0x84F5; + int GL_TEXTURE_BINDING_RECTANGLE_NV = 0x84F6; + int GL_PROXY_TEXTURE_RECTANGLE_NV = 0x84F7; + int GL_MAX_RECTANGLE_TEXTURE_SIZE_NV = 0x84F8; +} diff --git a/src/templates/org/lwjgl/opengl/NV_texture_shader.java b/src/templates/org/lwjgl/opengl/NV_texture_shader.java new file mode 100644 index 0000000..4cf0d7c --- /dev/null +++ b/src/templates/org/lwjgl/opengl/NV_texture_shader.java @@ -0,0 +1,175 @@ +/* + * 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; + +public interface NV_texture_shader { + + /** + * Accepted by the <cap> parameter of Enable, Disable, and IsEnabled, + * and by the <pname> parameter of GetBooleanv, GetIntegerv, GetFloatv, + * and GetDoublev, and by the <target> parameter of TexEnvf, TexEnvfv, + * TexEnvi, TexEnviv, GetTexEnvfv, and GetTexEnviv. + */ + int GL_TEXTURE_SHADER_NV = 0x86DE; + + /** + * When the <target> parameter of TexEnvf, TexEnvfv, TexEnvi, TexEnviv, + * GetTexEnvfv, and GetTexEnviv is TEXTURE_SHADER_NV, then the value + * of <pname> may be: + */ + int GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV = 0x86D9; + int GL_SHADER_OPERATION_NV = 0x86DF; + int GL_OFFSET_TEXTURE_SCALE_NV = 0x86E2; + int GL_OFFSET_TEXTURE_BIAS_NV = 0x86E3; + int GL_OFFSET_TEXTURE_2D_SCALE_NV = GL_OFFSET_TEXTURE_SCALE_NV; + int GL_OFFSET_TEXTURE_2D_BIAS_NV = GL_OFFSET_TEXTURE_BIAS_NV; + int GL_PREVIOUS_TEXTURE_INPUT_NV = 0x86E4; + + /** + * When the <target> parameter of TexEnvfv, TexEnviv, GetTexEnvfv, and + * GetTexEnviv is TEXTURE_SHADER_NV, then the value of <pname> may be: + */ + int GL_CULL_MODES_NV = 0x86E0; + int GL_OFFSET_TEXTURE_MATRIX_NV = 0x86E1; + int GL_OFFSET_TEXTURE_2D_MATRIX_NV = GL_OFFSET_TEXTURE_MATRIX_NV; + int GL_CONST_EYE_NV = 0x86E5; + + /** + * When the <target> parameter GetTexEnvfv and GetTexEnviv is + * TEXTURE_SHADER_NV, then the value of <pname> may be: + */ + int GL_SHADER_CONSISTENT_NV = 0x86DD; + + /** + * When the <target> and <pname> parameters of TexEnvf, TexEnvfv, + * TexEnvi, and TexEnviv are TEXTURE_SHADER_NV and SHADER_OPERATION_NV + * respectively, then the value of <param> or the value pointed to by + * <params> may be: + */ + int GL_PASS_THROUGH_NV = 0x86E6; + int GL_CULL_FRAGMENT_NV = 0x86E7; + + int GL_OFFSET_TEXTURE_2D_NV = 0x86E8; + int GL_OFFSET_TEXTURE_RECTANGLE_NV = 0x864C; + int GL_OFFSET_TEXTURE_RECTANGLE_SCALE_NV = 0x864D; + int GL_DEPENDENT_AR_TEXTURE_2D_NV = 0x86E9; + int GL_DEPENDENT_GB_TEXTURE_2D_NV = 0x86EA; + + int GL_DOT_PRODUCT_NV = 0x86EC; + int GL_DOT_PRODUCT_DEPTH_REPLACE_NV = 0x86ED; + int GL_DOT_PRODUCT_TEXTURE_2D_NV = 0x86EE; + int GL_DOT_PRODUCT_TEXTURE_RECTANGLE_NV = 0x864E; + int GL_DOT_PRODUCT_TEXTURE_CUBE_MAP_NV = 0x86F0; + int GL_DOT_PRODUCT_DIFFUSE_CUBE_MAP_NV = 0x86F1; + int GL_DOT_PRODUCT_REFLECT_CUBE_MAP_NV = 0x86F2; + int GL_DOT_PRODUCT_CONST_EYE_REFLECT_CUBE_MAP_NV = 0x86F3; + + /** + * Accepted by the <format> parameter of GetTexImage, TexImage1D, + * TexImage2D, TexSubImage1D, and TexSubImage2D. + */ + int GL_HILO_NV = 0x86F4; + int GL_DSDT_NV = 0x86F5; + int GL_DSDT_MAG_NV = 0x86F6; + int GL_DSDT_MAG_VIB_NV = 0x86F7; + + /** + * Accepted by the <type> parameter of GetTexImage, TexImage1D, + * TexImage2D, TexSubImage1D, and TexSubImage2D. + */ + int GL_UNSIGNED_INT_S8_S8_8_8_NV = 0x86DA; + int GL_UNSIGNED_INT_8_8_S8_S8_REV_NV = 0x86DB; + + /** + * Accepted by the <internalformat> parameter of CopyTexImage1D, + * CopyTexImage2D, TexImage1D, and TexImage2D. + */ + int GL_SIGNED_RGBA_NV = 0x86FB; + int GL_SIGNED_RGBA8_NV = 0x86FC; + int GL_SIGNED_RGB_NV = 0x86FE; + int GL_SIGNED_RGB8_NV = 0x86FF; + int GL_SIGNED_LUMINANCE_NV = 0x8701; + int GL_SIGNED_LUMINANCE8_NV = 0x8702; + int GL_SIGNED_LUMINANCE_ALPHA_NV = 0x8703; + int GL_SIGNED_LUMINANCE8_ALPHA8_NV = 0x8704; + int GL_SIGNED_ALPHA_NV = 0x8705; + int GL_SIGNED_ALPHA8_NV = 0x8706; + int GL_SIGNED_INTENSITY_NV = 0x8707; + int GL_SIGNED_INTENSITY8_NV = 0x8708; + int GL_SIGNED_RGB_UNSIGNED_ALPHA_NV = 0x870C; + int GL_SIGNED_RGB8_UNSIGNED_ALPHA8_NV = 0x870D; + + /** + * Accepted by the <internalformat> parameter of TexImage1D and + * TexImage2D. + */ + int GL_HILO16_NV = 0x86F8; + int GL_SIGNED_HILO_NV = 0x86F9; + int GL_SIGNED_HILO16_NV = 0x86FA; + int GL_DSDT8_NV = 0x8709; + int GL_DSDT8_MAG8_NV = 0x870A; + int GL_DSDT_MAG_INTENSITY_NV = 0x86DC; + int GL_DSDT8_MAG8_INTENSITY8_NV = 0x870B; + + /** + * Accepted by the <pname> parameter of GetBooleanv, GetIntegerv, + * GetFloatv, GetDoublev, PixelTransferf, and PixelTransferi. + */ + int GL_HI_SCALE_NV = 0x870E; + int GL_LO_SCALE_NV = 0x870F; + int GL_DS_SCALE_NV = 0x8710; + int GL_DT_SCALE_NV = 0x8711; + int GL_MAGNITUDE_SCALE_NV = 0x8712; + int GL_VIBRANCE_SCALE_NV = 0x8713; + int GL_HI_BIAS_NV = 0x8714; + int GL_LO_BIAS_NV = 0x8715; + int GL_DS_BIAS_NV = 0x8716; + int GL_DT_BIAS_NV = 0x8717; + int GL_MAGNITUDE_BIAS_NV = 0x8718; + int GL_VIBRANCE_BIAS_NV = 0x8719; + + /** + * Accepted by the <pname> parameter of TexParameteriv, TexParameterfv, + * GetTexParameterfv and GetTexParameteriv. + */ + int GL_TEXTURE_BORDER_VALUES_NV = 0x871A; + + /** + * Accepted by the <pname> parameter of GetTexLevelParameterfv and + * GetTexLevelParameteriv. + */ + int GL_TEXTURE_HI_SIZE_NV = 0x871B; + int GL_TEXTURE_LO_SIZE_NV = 0x871C; + int GL_TEXTURE_DS_SIZE_NV = 0x871D; + int GL_TEXTURE_DT_SIZE_NV = 0x871E; + int GL_TEXTURE_MAG_SIZE_NV = 0x871F; +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/NV_texture_shader2.java b/src/templates/org/lwjgl/opengl/NV_texture_shader2.java new file mode 100644 index 0000000..3cc4ace --- /dev/null +++ b/src/templates/org/lwjgl/opengl/NV_texture_shader2.java @@ -0,0 +1,63 @@ +/* + * 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; + +public interface NV_texture_shader2 { + int GL_DOT_PRODUCT_TEXTURE_3D_NV = 0x86EF; + int GL_HILO_NV = 0x86F4; + int GL_DSDT_NV = 0x86F5; + int GL_DSDT_MAG_NV = 0x86F6; + int GL_DSDT_MAG_VIB_NV = 0x86F7; + int GL_UNSIGNED_INT_S8_S8_8_8_NV = 0x86DA; + int GL_UNSIGNED_INT_8_8_S8_S8_REV_NV = 0x86DB; + int GL_SIGNED_RGBA_NV = 0x86FB; + int GL_SIGNED_RGBA8_NV = 0x86FC; + int GL_SIGNED_RGB_NV = 0x86FE; + int GL_SIGNED_RGB8_NV = 0x86FF; + int GL_SIGNED_LUMINANCE_NV = 0x8701; + int GL_SIGNED_LUMINANCE8_NV = 0x8702; + int GL_SIGNED_LUMINANCE_ALPHA_NV = 0x8703; + int GL_SIGNED_LUMINANCE8_ALPHA8_NV = 0x8704; + int GL_SIGNED_ALPHA_NV = 0x8705; + int GL_SIGNED_ALPHA8_NV = 0x8706; + int GL_SIGNED_INTENSITY_NV = 0x8707; + int GL_SIGNED_INTENSITY8_NV = 0x8708; + int GL_SIGNED_RGB_UNSIGNED_ALPHA_NV = 0x870C; + int GL_SIGNED_RGB8_UNSIGNED_ALPHA8_NV = 0x870D; + int GL_HILO16_NV = 0x86F8; + int GL_SIGNED_HILO_NV = 0x86F9; + int GL_SIGNED_HILO16_NV = 0x86FA; + int GL_DSDT8_NV = 0x8709; + int GL_DSDT8_MAG8_NV = 0x870A; + int GL_DSDT_MAG_INTENSITY_NV = 0x86DC; + int GL_DSDT8_MAG8_INTENSITY8_NV = 0x870B; +} diff --git a/src/templates/org/lwjgl/opengl/NV_texture_shader3.java b/src/templates/org/lwjgl/opengl/NV_texture_shader3.java new file mode 100644 index 0000000..f4fecfa --- /dev/null +++ b/src/templates/org/lwjgl/opengl/NV_texture_shader3.java @@ -0,0 +1,52 @@ +/* + * 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; + +public interface NV_texture_shader3 { + int GL_OFFSET_PROJECTIVE_TEXTURE_2D_NV = 0x8850; + int GL_OFFSET_PROJECTIVE_TEXTURE_2D_SCALE_NV = 0x8851; + int GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_NV = 0x8852; + int GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_SCALE_NV = 0x8853; + int GL_OFFSET_HILO_TEXTURE_2D_NV = 0x8854; + int GL_OFFSET_HILO_TEXTURE_RECTANGLE_NV = 0x8855; + int GL_OFFSET_HILO_PROJECTIVE_TEXTURE_2D_NV = 0x8856; + int GL_OFFSET_HILO_PROJECTIVE_TEXTURE_RECTANGLE_NV = 0x8857; + int GL_DEPENDENT_HILO_TEXTURE_2D_NV = 0x8858; + int GL_DEPENDENT_RGB_TEXTURE_3D_NV = 0x8859; + int GL_DEPENDENT_RGB_TEXTURE_CUBE_MAP_NV = 0x885A; + int GL_DOT_PRODUCT_PASS_THROUGH_NV = 0x885B; + int GL_DOT_PRODUCT_TEXTURE_1D_NV = 0x885C; + int GL_DOT_PRODUCT_AFFINE_DEPTH_REPLACE_NV = 0x885D; + int GL_HILO8_NV = 0x885E; + int GL_SIGNED_HILO8_NV = 0x885F; + int GL_FORCE_BLUE_TO_ONE_NV = 0x8860; +} diff --git a/src/templates/org/lwjgl/opengl/NV_transform_feedback.java b/src/templates/org/lwjgl/opengl/NV_transform_feedback.java new file mode 100644 index 0000000..b0e72e2 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/NV_transform_feedback.java @@ -0,0 +1,185 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +import java.nio.ByteBuffer; +import java.nio.IntBuffer; + +public interface NV_transform_feedback { + + /** + * Accepted by the <target> parameters of BindBuffer, BufferData, + * BufferSubData, MapBuffer, UnmapBuffer, GetBufferSubData, + * GetBufferPointerv, BindBufferRangeNV, BindBufferOffsetNV and + * BindBufferBaseNV: + */ + int GL_TRANSFORM_FEEDBACK_BUFFER_NV = 0x8C8E; + + /** + * Accepted by the <param> parameter of GetIntegerIndexedvEXT and + * GetBooleanIndexedvEXT: + */ + int GL_TRANSFORM_FEEDBACK_BUFFER_START_NV = 0x8C84; + int GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_NV = 0x8C85; + int GL_TRANSFORM_FEEDBACK_RECORD_NV = 0x8C86; + + /** + * Accepted by the <param> parameter of GetIntegerIndexedvEXT and + * GetBooleanIndexedvEXT, and by the <pname> parameter of GetBooleanv, + * GetDoublev, GetIntegerv, and GetFloatv: + */ + int GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_NV = 0x8C8F; + + /** + * Accepted by the <bufferMode> parameter of TransformFeedbackAttribsNV and + * TransformFeedbackVaryingsNV: + */ + int GL_INTERLEAVED_ATTRIBS_NV = 0x8C8C; + int GL_SEPARATE_ATTRIBS_NV = 0x8C8D; + + /** + * Accepted by the <target> parameter of BeginQuery, EndQuery, and + * GetQueryiv: + */ + int GL_PRIMITIVES_GENERATED_NV = 0x8C87; + int GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_NV = 0x8C88; + + /** + * Accepted by the <cap> parameter of Enable, Disable, and IsEnabled, and by + * the <pname> parameter of GetBooleanv, GetIntegerv, GetFloatv, and + * GetDoublev: + */ + int GL_RASTERIZER_DISCARD_NV = 0x8C89; + + /** + * Accepted by the <pname> parameter of GetBooleanv, GetDoublev, GetIntegerv, + * and GetFloatv: + */ + int GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS_NV = 0x8C8A; + int GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_NV = 0x8C8B; + int GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_NV = 0x8C80; + int GL_TRANSFORM_FEEDBACK_ATTRIBS_NV = 0x8C7E; + + /** Accepted by the <pname> parameter of GetProgramiv: */ + int GL_ACTIVE_VARYINGS_NV = 0x8C81; + int GL_ACTIVE_VARYING_MAX_LENGTH_NV = 0x8C82; + int GL_TRANSFORM_FEEDBACK_VARYINGS_NV = 0x8C83; + + /** + * Accepted by the <pname> parameter of GetBooleanv, GetDoublev, GetIntegerv, + * GetFloatv, and GetProgramiv: + */ + int GL_TRANSFORM_FEEDBACK_BUFFER_MODE_NV = 0x8C7F; + + /** Accepted by the <attribs> parameter of TransformFeedbackAttribsNV: */ + int GL_BACK_PRIMARY_COLOR_NV = 0x8C77; + int GL_BACK_SECONDARY_COLOR_NV = 0x8C78; + int GL_TEXTURE_COORD_NV = 0x8C79; + int GL_CLIP_DISTANCE_NV = 0x8C7A; + int GL_VERTEX_ID_NV = 0x8C7B; + int GL_PRIMITIVE_ID_NV = 0x8C7C; + int GL_GENERIC_ATTRIB_NV = 0x8C7D; + int GL_LAYER_NV = 0x8DAA; + + void glBindBufferRangeNV(@GLenum int target, @GLuint int index, @GLuint int buffer, @GLintptr long offset, @GLsizeiptr long size); + + void glBindBufferOffsetNV(@GLenum int target, @GLuint int index, @GLuint int buffer, @GLintptr long offset); + + void glBindBufferBaseNV(@GLenum int target, @GLuint int index, @GLuint int buffer); + + void glTransformFeedbackAttribsNV(@AutoSize("attribs") @GLsizei int count, @Const IntBuffer attribs, @GLenum int bufferMode); + + void glTransformFeedbackVaryingsNV(@GLuint int program, @AutoSize("locations") @GLsizei int count, @Const IntBuffer locations, @GLenum int bufferMode); + + void glBeginTransformFeedbackNV(@GLenum int primitiveMode); + + void glEndTransformFeedbackNV(); + + int glGetVaryingLocationNV(@GLuint int program, @NullTerminated @Const @GLchar ByteBuffer name); + + @Alternate("glGetVaryingLocationNV") + int glGetVaryingLocationNV(@GLuint int program, @NullTerminated CharSequence name); + + void glGetActiveVaryingNV(@GLuint int program, @GLuint int index, @AutoSize("name") @GLsizei int bufSize, + @OutParameter @GLsizei @Check(value = "1", canBeNull = true) IntBuffer length, + @OutParameter @GLsizei @Check("1") IntBuffer size, + @OutParameter @GLenum @Check("1") IntBuffer type, + @OutParameter @GLchar ByteBuffer name); + + /** Overloads glGetActiveVaryingNV. This version returns both size and type in the sizeType buffer (at .position() and .position() + 1). */ + @Alternate("glGetActiveVaryingNV") + @GLreturn(value = "name", maxLength = "bufSize") + void glGetActiveVaryingNV2(@GLuint int program, @GLuint int index, @GLsizei int bufSize, + @OutParameter @GLsizei @Constant("name_length, 0") IntBuffer length, + @OutParameter @Check("2") IntBuffer sizeType, + @OutParameter @GLenum @Constant("sizeType, sizeType.position() + 1") IntBuffer type, + @OutParameter @GLchar ByteBuffer name); + + /** Overloads glGetActiveVaryingNV. This version returns only the varying name. */ + @Alternate(value = "glGetActiveVaryingNV", javaAlt = true) + @GLreturn(value = "name", maxLength = "bufSize") + void glGetActiveVaryingNV(@GLuint int program, @GLuint int index, @GLsizei int bufSize, + @OutParameter @GLsizei @Constant("name_length, 0, APIUtils.getBufferInt(), 0, APIUtils.getBufferInt(), 1") IntBuffer length, + @OutParameter @GLchar ByteBuffer name); + + /** Overloads glGetActiveVaryingNV. This version returns only the varying size. */ + @Alternate(value = "glGetActiveVaryingNV", javaAlt = true) + @GLreturn(value = "size") + void glGetActiveVaryingSizeNV(@GLuint int program, @GLuint int index, @Constant("0") @GLsizei int bufSize, + @OutParameter @GLsizei @Constant("null, 0") IntBuffer length, + @OutParameter IntBuffer size, + @OutParameter @GLenum @Constant("size, 1") IntBuffer type, // Reuse size buffer and ignore + @OutParameter @GLchar @Constant("APIUtils.getBufferByte(0), 0") ByteBuffer name); + + /** Overloads glGetActiveVaryingNV. This version returns only the varying type. */ + @Alternate(value = "glGetActiveVaryingNV", javaAlt = true) + @GLreturn(value = "type") + void glGetActiveVaryingTypeNV(@GLuint int program, @GLuint int index, @Constant("0") @GLsizei int bufSize, + @OutParameter @GLsizei @Constant("null, 0") IntBuffer length, + @OutParameter @Constant("type, 1") IntBuffer size, // Reuse type buffer and ignore + @OutParameter @GLenum IntBuffer type, + @OutParameter @GLchar @Constant("APIUtils.getBufferByte(0), 0") ByteBuffer name); + + void glActiveVaryingNV(@GLuint int program, @NullTerminated @Const @GLchar ByteBuffer name); + + @Alternate("glActiveVaryingNV") + void glActiveVaryingNV(@GLuint int program, @NullTerminated CharSequence name); + + void glGetTransformFeedbackVaryingNV(@GLuint int program, @GLuint int index, @OutParameter @Check("1") IntBuffer location); + + @Alternate("glGetTransformFeedbackVaryingNV") + @GLreturn("location") + void glGetTransformFeedbackVaryingNV2(@GLuint int program, @GLuint int index, @OutParameter IntBuffer location); + +} diff --git a/src/templates/org/lwjgl/opengl/NV_transform_feedback2.java b/src/templates/org/lwjgl/opengl/NV_transform_feedback2.java new file mode 100644 index 0000000..5a55be4 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/NV_transform_feedback2.java @@ -0,0 +1,73 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +import java.nio.IntBuffer; + +public interface NV_transform_feedback2 { + + /** Accepted by the <target> parameter of BindTransformFeedbackNV: */ + + int GL_TRANSFORM_FEEDBACK_NV = 0x8E22; + + /** + * Accepted by the <pname> parameter of GetBooleanv, GetDoublev, GetIntegerv, + * and GetFloatv: + */ + int GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED_NV = 0x8E23; + int GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE_NV = 0x8E24; + int GL_TRANSFORM_FEEDBACK_BINDING_NV = 0x8E25; + + void glBindTransformFeedbackNV(@GLenum int target, @GLuint int id); + + void glDeleteTransformFeedbacksNV(@AutoSize("ids") @GLsizei int n, @Const @GLuint IntBuffer ids); + + @Alternate("glDeleteTransformFeedbacksNV") + void glDeleteTransformFeedbacksNV(@Constant("1") @GLsizei int n, @Constant(value = "APIUtils.getBufferInt().put(0, id), 0", keepParam = true) int id); + + void glGenTransformFeedbacksNV(@AutoSize("ids") @GLsizei int n, @OutParameter @GLuint IntBuffer ids); + + @Alternate("glGenTransformFeedbacksNV") + @GLreturn("ids") + void glGenTransformFeedbacksNV2(@Constant("1") @GLsizei int n, @OutParameter @GLuint IntBuffer ids); + + boolean glIsTransformFeedbackNV(@GLuint int id); + + void glPauseTransformFeedbackNV(); + + void glResumeTransformFeedbackNV(); + + void glDrawTransformFeedbackNV(@GLenum int mode, @GLuint int id); + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/NV_vertex_array_range.java b/src/templates/org/lwjgl/opengl/NV_vertex_array_range.java new file mode 100644 index 0000000..a266aed --- /dev/null +++ b/src/templates/org/lwjgl/opengl/NV_vertex_array_range.java @@ -0,0 +1,62 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +import java.nio.*; + +public interface NV_vertex_array_range { + int GL_VERTEX_ARRAY_RANGE_NV = 0x851D; + int GL_VERTEX_ARRAY_RANGE_LENGTH_NV = 0x851E; + int GL_VERTEX_ARRAY_RANGE_VALID_NV = 0x851F; + int GL_MAX_VERTEX_ARRAY_RANGE_ELEMENT_NV = 0x8520; + int GL_VERTEX_ARRAY_RANGE_POINTER_NV = 0x8521; + + void glVertexArrayRangeNV(@AutoSize("pPointer") @GLsizei int size, + @Const + @GLbyte + @GLshort + @GLint + @GLfloat + @GLdouble Buffer pPointer); + + void glFlushVertexArrayRangeNV(); + + @PlatformDependent({Platform.WGL, Platform.GLX}) + @GLvoid + @AutoResultSize("size") + ByteBuffer glAllocateMemoryNV(int size, float readFrequency, float writeFrequency, float priority); + + @PlatformDependent({Platform.WGL, Platform.GLX}) + void glFreeMemoryNV(@Check @GLbyte Buffer pointer); +} diff --git a/src/templates/org/lwjgl/opengl/NV_vertex_array_range2.java b/src/templates/org/lwjgl/opengl/NV_vertex_array_range2.java new file mode 100644 index 0000000..2972f1a --- /dev/null +++ b/src/templates/org/lwjgl/opengl/NV_vertex_array_range2.java @@ -0,0 +1,36 @@ +/* + * 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; + +public interface NV_vertex_array_range2 { + int GL_VERTEX_ARRAY_RANGE_WITHOUT_FLUSH_NV = 0x8533; +} diff --git a/src/templates/org/lwjgl/opengl/NV_vertex_attrib_integer_64bit.java b/src/templates/org/lwjgl/opengl/NV_vertex_attrib_integer_64bit.java new file mode 100644 index 0000000..5558afc --- /dev/null +++ b/src/templates/org/lwjgl/opengl/NV_vertex_attrib_integer_64bit.java @@ -0,0 +1,97 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +import java.nio.LongBuffer; + +@Dependent +public interface NV_vertex_attrib_integer_64bit { + + /** + * Accepted by the <type> parameter of VertexAttribLPointerEXT, + * VertexArrayVertexAttribLOffsetEXT, and VertexAttribLFormatNV: + */ + int GL_INT64_NV = 0x140E; + int GL_UNSIGNED_INT64_NV = 0x140F; + + void glVertexAttribL1i64NV(@GLuint int index, @GLint64EXT long x); + + void glVertexAttribL2i64NV(@GLuint int index, @GLint64EXT long x, @GLint64EXT long y); + + void glVertexAttribL3i64NV(@GLuint int index, @GLint64EXT long x, @GLint64EXT long y, @GLint64EXT long z); + + void glVertexAttribL4i64NV(@GLuint int index, @GLint64EXT long x, @GLint64EXT long y, @GLint64EXT long z, @GLint64EXT long w); + + @StripPostfix("v") + void glVertexAttribL1i64vNV(@GLuint int index, @Const @GLint64EXT @Check("1") LongBuffer v); + + @StripPostfix("v") + void glVertexAttribL2i64vNV(@GLuint int index, @Const @GLint64EXT @Check("2") LongBuffer v); + + @StripPostfix("v") + void glVertexAttribL3i64vNV(@GLuint int index, @Const @GLint64EXT @Check("3") LongBuffer v); + + @StripPostfix("v") + void glVertexAttribL4i64vNV(@GLuint int index, @Const @GLint64EXT @Check("4") LongBuffer v); + + void glVertexAttribL1ui64NV(@GLuint int index, @GLuint64EXT long x); + + void glVertexAttribL2ui64NV(@GLuint int index, @GLuint64EXT long x, @GLuint64EXT long y); + + void glVertexAttribL3ui64NV(@GLuint int index, @GLuint64EXT long x, @GLuint64EXT long y, @GLuint64EXT long z); + + void glVertexAttribL4ui64NV(@GLuint int index, @GLuint64EXT long x, @GLuint64EXT long y, @GLuint64EXT long z, @GLuint64EXT long w); + + @StripPostfix("v") + void glVertexAttribL1ui64vNV(@GLuint int index, @Const @GLuint64EXT @Check("1") LongBuffer v); + + @StripPostfix("v") + void glVertexAttribL2ui64vNV(@GLuint int index, @Const @GLuint64EXT @Check("2") LongBuffer v); + + @StripPostfix("v") + void glVertexAttribL3ui64vNV(@GLuint int index, @Const @GLuint64EXT @Check("3") LongBuffer v); + + @StripPostfix("v") + void glVertexAttribL4ui64vNV(@GLuint int index, @Const @GLuint64EXT @Check("4") LongBuffer v); + + @StripPostfix("params") + void glGetVertexAttribLi64vNV(@GLuint int index, @GLenum int pname, @OutParameter @GLint64EXT @Check("4") LongBuffer params); + + @StripPostfix("params") + void glGetVertexAttribLui64vNV(@GLuint int index, @GLenum int pname, @OutParameter @GLuint64EXT @Check("4") LongBuffer params); + + @Dependent("NV_vertex_buffer_unified_memory") + void glVertexAttribLFormatNV(@GLuint int index, int size, @GLenum int type, @GLsizei int stride); + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/NV_vertex_buffer_unified_memory.java b/src/templates/org/lwjgl/opengl/NV_vertex_buffer_unified_memory.java new file mode 100644 index 0000000..0b5f77e --- /dev/null +++ b/src/templates/org/lwjgl/opengl/NV_vertex_buffer_unified_memory.java @@ -0,0 +1,111 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +import java.nio.LongBuffer; + +public interface NV_vertex_buffer_unified_memory { + + /** + * Accepted by the <cap> parameter of DisableClientState, + * EnableClientState, IsEnabled: + */ + int GL_VERTEX_ATTRIB_ARRAY_UNIFIED_NV = 0x8F1E; + int GL_ELEMENT_ARRAY_UNIFIED_NV = 0x8F1F; + + /** + * Accepted by the <pname> parameter of BufferAddressRangeNV + * and the <value> parameter of GetIntegerui64i_vNV: + */ + int GL_VERTEX_ATTRIB_ARRAY_ADDRESS_NV = 0x8F20; + int GL_TEXTURE_COORD_ARRAY_ADDRESS_NV = 0x8F25; + + /** + * Accepted by the <pname> parameter of BufferAddressRangeNV + * and the <value> parameter of GetIntegerui64vNV: + */ + int GL_VERTEX_ARRAY_ADDRESS_NV = 0x8F21; + int GL_NORMAL_ARRAY_ADDRESS_NV = 0x8F22; + int GL_COLOR_ARRAY_ADDRESS_NV = 0x8F23; + int GL_INDEX_ARRAY_ADDRESS_NV = 0x8F24; + int GL_EDGE_FLAG_ARRAY_ADDRESS_NV = 0x8F26; + int GL_SECONDARY_COLOR_ARRAY_ADDRESS_NV = 0x8F27; + int GL_FOG_COORD_ARRAY_ADDRESS_NV = 0x8F28; + int GL_ELEMENT_ARRAY_ADDRESS_NV = 0x8F29; + + /** Accepted by the <target> parameter of GetIntegeri_vNV: */ + int GL_VERTEX_ATTRIB_ARRAY_LENGTH_NV = 0x8F2A; + int GL_TEXTURE_COORD_ARRAY_LENGTH_NV = 0x8F2F; + + /** Accepted by the <value> parameter of GetIntegerv: */ + int GL_VERTEX_ARRAY_LENGTH_NV = 0x8F2B; + int GL_NORMAL_ARRAY_LENGTH_NV = 0x8F2C; + int GL_COLOR_ARRAY_LENGTH_NV = 0x8F2D; + int GL_INDEX_ARRAY_LENGTH_NV = 0x8F2E; + int GL_EDGE_FLAG_ARRAY_LENGTH_NV = 0x8F30; + int GL_SECONDARY_COLOR_ARRAY_LENGTH_NV = 0x8F31; + int GL_FOG_COORD_ARRAY_LENGTH_NV = 0x8F32; + int GL_ELEMENT_ARRAY_LENGTH_NV = 0x8F33; + + void glBufferAddressRangeNV(@GLenum int pname, @GLuint int index, @GLuint64EXT long address, @GLsizeiptr long length); + + void glVertexFormatNV(int size, @GLenum int type, @GLsizei int stride); + + void glNormalFormatNV(@GLenum int type, @GLsizei int stride); + + void glColorFormatNV(int size, @GLenum int type, @GLsizei int stride); + + void glIndexFormatNV(@GLenum int type, @GLsizei int stride); + + void glTexCoordFormatNV(int size, @GLenum int type, @GLsizei int stride); + + void glEdgeFlagFormatNV(@GLsizei int stride); + + void glSecondaryColorFormatNV(int size, @GLenum int type, @GLsizei int stride); + + void glFogCoordFormatNV(@GLenum int type, @GLsizei int stride); + + void glVertexAttribFormatNV(@GLuint int index, int size, @GLenum int type, boolean normalized, @GLsizei int stride); + + void glVertexAttribIFormatNV(@GLuint int index, int size, @GLenum int type, @GLsizei int stride); + + @StripPostfix("result") + void glGetIntegerui64i_vNV(@GLenum int value, @GLuint int index, @OutParameter @Check("1") @GLuint64EXT LongBuffer result); + + @Alternate("glGetIntegerui64i_vNV") + @GLreturn("result") + @StripPostfix("result") + void glGetIntegerui64i_vNV2(@GLenum int value, @GLuint int index, @OutParameter @GLuint64EXT LongBuffer result); + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/NV_vertex_program.java b/src/templates/org/lwjgl/opengl/NV_vertex_program.java new file mode 100644 index 0000000..23d8f8f --- /dev/null +++ b/src/templates/org/lwjgl/opengl/NV_vertex_program.java @@ -0,0 +1,330 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +import java.nio.*; + +public interface NV_vertex_program extends NV_program { + + /** + Accepted by the <cap> parameter of Disable, Enable, and IsEnabled, + and by the <pname> parameter of GetBooleanv, GetIntegerv, GetFloatv, + and GetDoublev, and by the <target> parameter of BindProgramNV, + ExecuteProgramNV, GetProgramParameter[df]vNV, GetTrackMatrixivNV, + LoadProgramNV, ProgramParameter[s]4[df][v]NV, and TrackMatrixNV: + */ + int GL_VERTEX_PROGRAM_NV = 0x8620; + + /** + Accepted by the <cap> parameter of Disable, Enable, and IsEnabled, + and by the <pname> parameter of GetBooleanv, GetIntegerv, GetFloatv, + and GetDoublev: + */ + int GL_VERTEX_PROGRAM_POINT_SIZE_NV = 0x8642; + int GL_VERTEX_PROGRAM_TWO_SIDE_NV = 0x8643; + + /** + Accepted by the <target> parameter of ExecuteProgramNV and + LoadProgramNV: + */ + int GL_VERTEX_STATE_PROGRAM_NV = 0x8621; + + /** + Accepted by the <pname> parameter of GetVertexAttrib[dfi]vNV: + */ + int GL_ATTRIB_ARRAY_SIZE_NV = 0x8623; + int GL_ATTRIB_ARRAY_STRIDE_NV = 0x8624; + int GL_ATTRIB_ARRAY_TYPE_NV = 0x8625; + int GL_CURRENT_ATTRIB_NV = 0x8626; + + /** + Accepted by the <pname> parameter of GetProgramParameterfvNV + and GetProgramParameterdvNV: + */ + int GL_PROGRAM_PARAMETER_NV = 0x8644; + + /** + Accepted by the <pname> parameter of GetVertexAttribPointervNV: + */ + int GL_ATTRIB_ARRAY_POINTER_NV = 0x8645; + + /** + Accepted by the <pname> parameter of GetTrackMatrixivNV: + */ + int GL_TRACK_MATRIX_NV = 0x8648; + int GL_TRACK_MATRIX_TRANSFORM_NV = 0x8649; + + /** + Accepted by the <pname> parameter of GetBooleanv, GetIntegerv, + GetFloatv, and GetDoublev: + */ + int GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV = 0x862E; + int GL_MAX_TRACK_MATRICES_NV = 0x862F; + int GL_CURRENT_MATRIX_STACK_DEPTH_NV = 0x8640; + int GL_CURRENT_MATRIX_NV = 0x8641; + int GL_VERTEX_PROGRAM_BINDING_NV = 0x864A; + + /** + Accepted by the <matrix> parameter of TrackMatrixNV: + */ + int GL_MODELVIEW_PROJECTION_NV = 0x8629; + + /** + Accepted by the <matrix> parameter of TrackMatrixNV and by the + <mode> parameter of MatrixMode: + */ + int GL_MATRIX0_NV = 0x8630; + int GL_MATRIX1_NV = 0x8631; + int GL_MATRIX2_NV = 0x8632; + int GL_MATRIX3_NV = 0x8633; + int GL_MATRIX4_NV = 0x8634; + int GL_MATRIX5_NV = 0x8635; + int GL_MATRIX6_NV = 0x8636; + int GL_MATRIX7_NV = 0x8637; + + /** + Accepted by the <transform> parameter of TrackMatrixNV: + */ + int GL_IDENTITY_NV = 0x862A; + int GL_INVERSE_NV = 0x862B; + int GL_TRANSPOSE_NV = 0x862C; + int GL_INVERSE_TRANSPOSE_NV = 0x862D; + + /** + Accepted by the <array> parameter of EnableClientState and + DisableClientState, by the <cap> parameter of IsEnabled, and by + the <pname> parameter of GetBooleanv, GetIntegerv, GetFloatv, and + GetDoublev: + */ + int GL_VERTEX_ATTRIB_ARRAY0_NV = 0x8650; + int GL_VERTEX_ATTRIB_ARRAY1_NV = 0x8651; + int GL_VERTEX_ATTRIB_ARRAY2_NV = 0x8652; + int GL_VERTEX_ATTRIB_ARRAY3_NV = 0x8653; + int GL_VERTEX_ATTRIB_ARRAY4_NV = 0x8654; + int GL_VERTEX_ATTRIB_ARRAY5_NV = 0x8655; + int GL_VERTEX_ATTRIB_ARRAY6_NV = 0x8656; + int GL_VERTEX_ATTRIB_ARRAY7_NV = 0x8657; + int GL_VERTEX_ATTRIB_ARRAY8_NV = 0x8658; + int GL_VERTEX_ATTRIB_ARRAY9_NV = 0x8659; + int GL_VERTEX_ATTRIB_ARRAY10_NV = 0x865A; + int GL_VERTEX_ATTRIB_ARRAY11_NV = 0x865B; + int GL_VERTEX_ATTRIB_ARRAY12_NV = 0x865C; + int GL_VERTEX_ATTRIB_ARRAY13_NV = 0x865D; + int GL_VERTEX_ATTRIB_ARRAY14_NV = 0x865E; + int GL_VERTEX_ATTRIB_ARRAY15_NV = 0x865F; + + /** + Accepted by the <target> parameter of GetMapdv, GetMapfv, GetMapiv, + Map1d and Map1f and by the <cap> parameter of Enable, Disable, and + IsEnabled, and by the <pname> parameter of GetBooleanv, GetIntegerv, + GetFloatv, and GetDoublev: + */ + int GL_MAP1_VERTEX_ATTRIB0_4_NV = 0x8660; + int GL_MAP1_VERTEX_ATTRIB1_4_NV = 0x8661; + int GL_MAP1_VERTEX_ATTRIB2_4_NV = 0x8662; + int GL_MAP1_VERTEX_ATTRIB3_4_NV = 0x8663; + int GL_MAP1_VERTEX_ATTRIB4_4_NV = 0x8664; + int GL_MAP1_VERTEX_ATTRIB5_4_NV = 0x8665; + int GL_MAP1_VERTEX_ATTRIB6_4_NV = 0x8666; + int GL_MAP1_VERTEX_ATTRIB7_4_NV = 0x8667; + int GL_MAP1_VERTEX_ATTRIB8_4_NV = 0x8668; + int GL_MAP1_VERTEX_ATTRIB9_4_NV = 0x8669; + int GL_MAP1_VERTEX_ATTRIB10_4_NV = 0x866A; + int GL_MAP1_VERTEX_ATTRIB11_4_NV = 0x866B; + int GL_MAP1_VERTEX_ATTRIB12_4_NV = 0x866C; + int GL_MAP1_VERTEX_ATTRIB13_4_NV = 0x866D; + int GL_MAP1_VERTEX_ATTRIB14_4_NV = 0x866E; + int GL_MAP1_VERTEX_ATTRIB15_4_NV = 0x866F; + + /** + Accepted by the <target> parameter of GetMapdv, GetMapfv, GetMapiv, + Map2d and Map2f and by the <cap> parameter of Enable, Disable, and + IsEnabled, and by the <pname> parameter of GetBooleanv, GetIntegerv, + GetFloatv, and GetDoublev: + */ + int GL_MAP2_VERTEX_ATTRIB0_4_NV = 0x8670; + int GL_MAP2_VERTEX_ATTRIB1_4_NV = 0x8671; + int GL_MAP2_VERTEX_ATTRIB2_4_NV = 0x8672; + int GL_MAP2_VERTEX_ATTRIB3_4_NV = 0x8673; + int GL_MAP2_VERTEX_ATTRIB4_4_NV = 0x8674; + int GL_MAP2_VERTEX_ATTRIB5_4_NV = 0x8675; + int GL_MAP2_VERTEX_ATTRIB6_4_NV = 0x8676; + int GL_MAP2_VERTEX_ATTRIB7_4_NV = 0x8677; + int GL_MAP2_VERTEX_ATTRIB8_4_NV = 0x8678; + int GL_MAP2_VERTEX_ATTRIB9_4_NV = 0x8679; + int GL_MAP2_VERTEX_ATTRIB10_4_NV = 0x867A; + int GL_MAP2_VERTEX_ATTRIB11_4_NV = 0x867B; + int GL_MAP2_VERTEX_ATTRIB12_4_NV = 0x867C; + int GL_MAP2_VERTEX_ATTRIB13_4_NV = 0x867D; + int GL_MAP2_VERTEX_ATTRIB14_4_NV = 0x867E; + int GL_MAP2_VERTEX_ATTRIB15_4_NV = 0x867F; + + void glExecuteProgramNV(@GLenum int target, @GLuint int id, @Check("4") @Const FloatBuffer params); + + @StripPostfix("params") + void glGetProgramParameterfvNV(@GLenum int target, @GLuint int index, @GLenum int parameterName, @OutParameter @Check("4") FloatBuffer params); + + @StripPostfix("params") + void glGetProgramParameterdvNV(@GLenum int target, @GLuint int index, @GLenum int parameterName, @OutParameter @Check("4") DoubleBuffer params); + + @StripPostfix("params") + void glGetTrackMatrixivNV(@GLenum int target, @GLuint int address, @GLenum int parameterName, @OutParameter @Check("4") IntBuffer params); + + @StripPostfix("params") + void glGetVertexAttribfvNV(@GLuint int index, @GLenum int parameterName, @OutParameter @Check("4") FloatBuffer params); + + @StripPostfix("params") + void glGetVertexAttribdvNV(@GLuint int index, @GLenum int parameterName, @OutParameter @Check("4") DoubleBuffer params); + + @StripPostfix("params") + void glGetVertexAttribivNV(@GLuint int index, @GLenum int parameterName, @OutParameter @Check("4") IntBuffer params); + + @StripPostfix("pointer") + void glGetVertexAttribPointervNV(@GLuint int index, @GLenum int parameterName, @Result @GLvoid ByteBuffer pointer); + + void glProgramParameter4fNV(@GLenum int target, @GLuint int index, float x, float y, float z, float w); + + void glProgramParameter4dNV(@GLenum int target, @GLuint int index, double x, double y, double z, double w); + + @StripPostfix("params") + void glProgramParameters4fvNV(@GLenum int target, @GLuint int index, @AutoSize(value = "params", expression = " >> 2") @GLuint int count, + @Const FloatBuffer params); + + @StripPostfix("params") + void glProgramParameters4dvNV(@GLenum int target, @GLuint int index, @AutoSize(value = "params", expression = " >> 2") @GLuint int count, + @Const DoubleBuffer params); + + void glTrackMatrixNV(@GLenum int target, @GLuint int address, @GLenum int matrix, @GLenum int transform); + + void glVertexAttribPointerNV(@GLuint int index, int size, @GLenum int type, @GLsizei int stride, + @CachedReference(index="index",name="glVertexAttribPointer_buffer") + @BufferObject(BufferKind.ArrayVBO) + @Check + @Const + @GLbyte + @GLubyte + @GLshort + @GLushort + @GLint + @GLuint + @GLfloat + @GLdouble Buffer buffer); + + @NoErrorCheck + void glVertexAttrib1sNV(@GLuint int index, short x); + + @NoErrorCheck + void glVertexAttrib1fNV(@GLuint int index, float x); + + @NoErrorCheck + void glVertexAttrib1dNV(@GLuint int index, double x); + + @NoErrorCheck + void glVertexAttrib2sNV(@GLuint int index, short x, short y); + + @NoErrorCheck + void glVertexAttrib2fNV(@GLuint int index, float x, float y); + + @NoErrorCheck + void glVertexAttrib2dNV(@GLuint int index, double x, double y); + + @NoErrorCheck + void glVertexAttrib3sNV(@GLuint int index, short x, short y, short z); + + @NoErrorCheck + void glVertexAttrib3fNV(@GLuint int index, float x, float y, float z); + + @NoErrorCheck + void glVertexAttrib3dNV(@GLuint int index, double x, double y, double z); + + @NoErrorCheck + void glVertexAttrib4sNV(@GLuint int index, short x, short y, short z, short w); + + @NoErrorCheck + void glVertexAttrib4fNV(@GLuint int index, float x, float y, float z, float w); + + @NoErrorCheck + void glVertexAttrib4dNV(@GLuint int index, double x, double y, double z, double w); + + @NoErrorCheck + void glVertexAttrib4ubNV(@GLuint int index, @GLubyte byte x, @GLubyte byte y, @GLubyte byte z, @GLubyte byte w); + + @NoErrorCheck + @StripPostfix("v") + void glVertexAttribs1svNV(@GLuint int index, @AutoSize("v") @GLsizei int n, @Const ShortBuffer v); + + @NoErrorCheck + @StripPostfix("v") + void glVertexAttribs1fvNV(@GLuint int index, @AutoSize("v") @GLsizei int n, @Const FloatBuffer v); + + @NoErrorCheck + @StripPostfix("v") + void glVertexAttribs1dvNV(@GLuint int index, @AutoSize("v") @GLsizei int n, @Const DoubleBuffer v); + + @NoErrorCheck + @StripPostfix("v") + void glVertexAttribs2svNV(@GLuint int index, @AutoSize(value = "v", expression = " >> 1") @GLsizei int n, @Const ShortBuffer v); + + @NoErrorCheck + @StripPostfix("v") + void glVertexAttribs2fvNV(@GLuint int index, @AutoSize(value = "v", expression = " >> 1") @GLsizei int n, @Const FloatBuffer v); + + @NoErrorCheck + @StripPostfix("v") + void glVertexAttribs2dvNV(@GLuint int index, @AutoSize(value = "v", expression = " >> 1") @GLsizei int n, @Const DoubleBuffer v); + + @NoErrorCheck + @StripPostfix("v") + void glVertexAttribs3svNV(@GLuint int index, @AutoSize(value = "v", expression = " / 3") @GLsizei int n, @Const ShortBuffer v); + + @NoErrorCheck + @StripPostfix("v") + void glVertexAttribs3fvNV(@GLuint int index, @AutoSize(value = "v", expression = " / 3") @GLsizei int n, @Const FloatBuffer v); + + @NoErrorCheck + @StripPostfix("v") + void glVertexAttribs3dvNV(@GLuint int index, @AutoSize(value = "v", expression = " / 3") @GLsizei int n, @Const DoubleBuffer v); + + @NoErrorCheck + @StripPostfix("v") + void glVertexAttribs4svNV(@GLuint int index, @AutoSize(value = "v", expression = " >> 2") @GLsizei int n, @Const ShortBuffer v); + + @NoErrorCheck + @StripPostfix("v") + void glVertexAttribs4fvNV(@GLuint int index, @AutoSize(value = "v", expression = " >> 2") @GLsizei int n, @Const FloatBuffer v); + + @NoErrorCheck + @StripPostfix("v") + void glVertexAttribs4dvNV(@GLuint int index, @AutoSize(value = "v", expression = " >> 2") @GLsizei int n, @Const DoubleBuffer v); +} diff --git a/src/templates/org/lwjgl/opengl/NV_vertex_program1_1.java b/src/templates/org/lwjgl/opengl/NV_vertex_program1_1.java new file mode 100644 index 0000000..1f1e89f --- /dev/null +++ b/src/templates/org/lwjgl/opengl/NV_vertex_program1_1.java @@ -0,0 +1,35 @@ +/* + * 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; + +public interface NV_vertex_program1_1 { +} diff --git a/src/templates/org/lwjgl/opengl/NV_vertex_program2.java b/src/templates/org/lwjgl/opengl/NV_vertex_program2.java new file mode 100644 index 0000000..d6f3d74 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/NV_vertex_program2.java @@ -0,0 +1,35 @@ +/* + * 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; + +public interface NV_vertex_program2 { +} diff --git a/src/templates/org/lwjgl/opengl/NV_vertex_program2_option.java b/src/templates/org/lwjgl/opengl/NV_vertex_program2_option.java new file mode 100644 index 0000000..0d87f4e --- /dev/null +++ b/src/templates/org/lwjgl/opengl/NV_vertex_program2_option.java @@ -0,0 +1,41 @@ +/* + * 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; + +public interface NV_vertex_program2_option { + + /** + * Accepted by the <pname> parameter of GetProgramivARB: + */ + int GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV = 0x88F4; + int GL_MAX_PROGRAM_CALL_DEPTH_NV = 0x88F5; +} diff --git a/src/templates/org/lwjgl/opengl/NV_vertex_program3.java b/src/templates/org/lwjgl/opengl/NV_vertex_program3.java new file mode 100644 index 0000000..61342ea --- /dev/null +++ b/src/templates/org/lwjgl/opengl/NV_vertex_program3.java @@ -0,0 +1,41 @@ +/* + * 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; + +public interface NV_vertex_program3 { + + /** + * Accepted by the <pname> parameter of GetBooleanv, GetIntegerv, + * GetFloatv, and GetDoublev: + */ + int GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB = 0x8B4C; +} diff --git a/src/templates/org/lwjgl/opengl/NV_vertex_program4.java b/src/templates/org/lwjgl/opengl/NV_vertex_program4.java new file mode 100644 index 0000000..b5ae5f6 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/NV_vertex_program4.java @@ -0,0 +1,36 @@ +/* + * 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; + +public interface NV_vertex_program4 { + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/SGIS_generate_mipmap.java b/src/templates/org/lwjgl/opengl/SGIS_generate_mipmap.java new file mode 100644 index 0000000..f68622b --- /dev/null +++ b/src/templates/org/lwjgl/opengl/SGIS_generate_mipmap.java @@ -0,0 +1,50 @@ +/* + * 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; + +import org.lwjgl.util.generator.*; + +public interface SGIS_generate_mipmap { + + /** + * Accepted by the <pname> parameter of TexParameteri, TexParameterf, + * TexParameteriv, TexParameterfv, GetTexParameteriv, and GetTexParameterfv. + */ + int GL_GENERATE_MIPMAP_SGIS = 0x8191; + + /** + * Accepted by the <target> parameter of Hint, and by the + * parameter of GetBooleanv, GetIntegerv, GetFloatv, and GetDoublev. + */ + int GL_GENERATE_MIPMAP_HINT_SGIS = 0x8192; + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/SGIS_texture_lod.java b/src/templates/org/lwjgl/opengl/SGIS_texture_lod.java new file mode 100644 index 0000000..9cd0cec --- /dev/null +++ b/src/templates/org/lwjgl/opengl/SGIS_texture_lod.java @@ -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.opengl; + +import org.lwjgl.util.generator.*; + +@Extension(postfix = "SGIS", className = "SGISTextureLOD") +public interface SGIS_texture_lod { + + /** + * Accepted by the <pname> parameter of TexParameteri, TexParameterf, + * TexParameteriv, TexParameterfv, GetTexParameteriv, and GetTexParameterfv. + */ + int GL_TEXTURE_MIN_LOD_SGIS = 0x813A; + int GL_TEXTURE_MAX_LOD_SGIS = 0x813B; + int GL_TEXTURE_BASE_LEVEL_SGIS = 0x813C; + int GL_TEXTURE_MAX_LEVEL_SGIS = 0x813D; +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/SUN_slice_accum.java b/src/templates/org/lwjgl/opengl/SUN_slice_accum.java new file mode 100644 index 0000000..b4f9e27 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/SUN_slice_accum.java @@ -0,0 +1,41 @@ +/* + * 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; + +public interface SUN_slice_accum { + + /** + * Accepted by the <op> parameter of Accum, + */ + int GL_SLICE_ACCUM_SUN = 0x85CC; + +}