diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index 686d052e0..653a7514f 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -22,8 +22,10 @@ jobs: # Build JRE JAR files (security manager, etc...) ./gradlew clean build - mkdir app_pojavlauncher/src/main/assets/components/internal_libs - cp jre_securitymanager/build/libs/jre_securitymanager-1.0.jar app_pojavlauncher/src/main/assets/components/internal_libs + # mkdir app_pojavlauncher/src/main/assets/components/internal_libs + rm app_pojavlauncher/src/main/assets/components/lwjgl3/lwjgl-glfw-classes.jar + cp jre_lwjgl3glfw/build/libs/jre_lwjgl3glfw-3.2.3.jar app_pojavlauncher/src/main/assets/components/lwjgl3/lwjgl3 +-glfw-classes.jar # Build the launcher ./gradlew assembleDebug diff --git a/jre_securitymanager/build.gradle b/jre_lwjgl3glfw/build.gradle similarity index 64% rename from jre_securitymanager/build.gradle rename to jre_lwjgl3glfw/build.gradle index a7476c222..ac7a70846 100644 --- a/jre_securitymanager/build.gradle +++ b/jre_lwjgl3glfw/build.gradle @@ -1,8 +1,8 @@ apply plugin: 'java' apply plugin: 'eclipse' -group = 'net.pojavlauncher.security' -version = '1.0' +group = 'org.lwjgl.glfw' +version = '3.2.3' sourceCompatibility = 1.8 targetCompatibility = 1.8 @@ -15,6 +15,6 @@ repositories { } dependencies { - // implementation "..." + implementation fileTree(dir: 'libs', include: ['*.jar']) } diff --git a/jre_securitymanager/jre_securitymanager.iml b/jre_lwjgl3glfw/jre_lwjgl3glfw.iml similarity index 82% rename from jre_securitymanager/jre_securitymanager.iml rename to jre_lwjgl3glfw/jre_lwjgl3glfw.iml index abd55253e..cbfaf964b 100644 --- a/jre_securitymanager/jre_securitymanager.iml +++ b/jre_lwjgl3glfw/jre_lwjgl3glfw.iml @@ -1,9 +1,9 @@ - + - diff --git a/jre_lwjgl3glfw/libs/lwjgl-core-3.2.3.jar b/jre_lwjgl3glfw/libs/lwjgl-core-3.2.3.jar new file mode 100644 index 000000000..756d423fd Binary files /dev/null and b/jre_lwjgl3glfw/libs/lwjgl-core-3.2.3.jar differ diff --git a/jre_lwjgl3glfw/libs/lwjgl-openal-3.2.3.jar b/jre_lwjgl3glfw/libs/lwjgl-openal-3.2.3.jar new file mode 100644 index 000000000..9ccbc2e10 Binary files /dev/null and b/jre_lwjgl3glfw/libs/lwjgl-openal-3.2.3.jar differ diff --git a/jre_lwjgl3glfw/libs/lwjgl-opengl-3.2.3.jar b/jre_lwjgl3glfw/libs/lwjgl-opengl-3.2.3.jar new file mode 100644 index 000000000..6b0f45982 Binary files /dev/null and b/jre_lwjgl3glfw/libs/lwjgl-opengl-3.2.3.jar differ diff --git a/jre_lwjgl3glfw/src/main/java/android/util/ArrayMap.java b/jre_lwjgl3glfw/src/main/java/android/util/ArrayMap.java new file mode 100644 index 000000000..a28c34321 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/android/util/ArrayMap.java @@ -0,0 +1,884 @@ +/* + * Copyright (C) 2013 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.util; + +import java.util.Collection; +import java.util.Map; +import java.util.Set; + +/** + * ArrayMap is a generic key->value mapping data structure that is + * designed to be more memory efficient than a traditional {@link java.util.HashMap}. + * It keeps its mappings in an array data structure -- an integer array of hash + * codes for each item, and an Object array of the key/value pairs. This allows it to + * avoid having to create an extra object for every entry put in to the map, and it + * also tries to control the growth of the size of these arrays more aggressively + * (since growing them only requires copying the entries in the array, not rebuilding + * a hash map). + * + *

Note that this implementation is not intended to be appropriate for data structures + * that may contain large numbers of items. It is generally slower than a traditional + * HashMap, since lookups require a binary search and adds and removes require inserting + * and deleting entries in the array. For containers holding up to hundreds of items, + * the performance difference is not significant, less than 50%.

+ * + *

Because this container is intended to better balance memory use, unlike most other + * standard Java containers it will shrink its array as items are removed from it. Currently + * you have no control over this shrinking -- if you set a capacity and then remove an + * item, it may reduce the capacity to better match the current size. In the future an + * explicit call to set the capacity should turn off this aggressive shrinking behavior.

+ */ +public final class ArrayMap implements Map { + private static final boolean DEBUG = false; + private static final String TAG = "ArrayMap"; + + /** + * The minimum amount by which the capacity of a ArrayMap will increase. + * This is tuned to be relatively space-efficient. + */ + private static final int BASE_SIZE = 4; + + /** + * Maximum number of entries to have in array caches. + */ + private static final int CACHE_SIZE = 10; + + /** + * Special hash array value that indicates the container is immutable. + */ + static final int[] EMPTY_IMMUTABLE_INTS = new int[0]; + + /** + * @hide Special immutable empty ArrayMap. + */ + public static final ArrayMap EMPTY = new ArrayMap(true); + + /** + * Caches of small array objects to avoid spamming garbage. The cache + * Object[] variable is a pointer to a linked list of array objects. + * The first entry in the array is a pointer to the next array in the + * list; the second entry is a pointer to the int[] hash code array for it. + */ + static Object[] mBaseCache; + static int mBaseCacheSize; + static Object[] mTwiceBaseCache; + static int mTwiceBaseCacheSize; + + int[] mHashes; + Object[] mArray; + int mSize; + MapCollections mCollections; + + int indexOf(Object key, int hash) { + final int N = mSize; + + // Important fast case: if nothing is in here, nothing to look for. + if (N == 0) { + return ~0; + } + + int index = ContainerHelpers.binarySearch(mHashes, N, hash); + + // If the hash code wasn't found, then we have no entry for this key. + if (index < 0) { + return index; + } + + // If the key at the returned index matches, that's what we want. + if (key.equals(mArray[index<<1])) { + return index; + } + + // Search for a matching key after the index. + int end; + for (end = index + 1; end < N && mHashes[end] == hash; end++) { + if (key.equals(mArray[end << 1])) return end; + } + + // Search for a matching key before the index. + for (int i = index - 1; i >= 0 && mHashes[i] == hash; i--) { + if (key.equals(mArray[i << 1])) return i; + } + + // Key not found -- return negative value indicating where a + // new entry for this key should go. We use the end of the + // hash chain to reduce the number of array entries that will + // need to be copied when inserting. + return ~end; + } + + int indexOfNull() { + final int N = mSize; + + // Important fast case: if nothing is in here, nothing to look for. + if (N == 0) { + return ~0; + } + + int index = ContainerHelpers.binarySearch(mHashes, N, 0); + + // If the hash code wasn't found, then we have no entry for this key. + if (index < 0) { + return index; + } + + // If the key at the returned index matches, that's what we want. + if (null == mArray[index<<1]) { + return index; + } + + // Search for a matching key after the index. + int end; + for (end = index + 1; end < N && mHashes[end] == 0; end++) { + if (null == mArray[end << 1]) return end; + } + + // Search for a matching key before the index. + for (int i = index - 1; i >= 0 && mHashes[i] == 0; i--) { + if (null == mArray[i << 1]) return i; + } + + // Key not found -- return negative value indicating where a + // new entry for this key should go. We use the end of the + // hash chain to reduce the number of array entries that will + // need to be copied when inserting. + return ~end; + } + + private void allocArrays(final int size) { + if (mHashes == EMPTY_IMMUTABLE_INTS) { + throw new UnsupportedOperationException("ArrayMap is immutable"); + } + if (size == (BASE_SIZE*2)) { + synchronized (ArrayMap.class) { + if (mTwiceBaseCache != null) { + final Object[] array = mTwiceBaseCache; + mArray = array; + mTwiceBaseCache = (Object[])array[0]; + mHashes = (int[])array[1]; + array[0] = array[1] = null; + mTwiceBaseCacheSize--; + if (DEBUG) System.out.println("Retrieving 2x cache " + mHashes + + " now have " + mTwiceBaseCacheSize + " entries"); + return; + } + } + } else if (size == BASE_SIZE) { + synchronized (ArrayMap.class) { + if (mBaseCache != null) { + final Object[] array = mBaseCache; + mArray = array; + mBaseCache = (Object[])array[0]; + mHashes = (int[])array[1]; + array[0] = array[1] = null; + mBaseCacheSize--; + if (DEBUG) System.out.println("Retrieving 1x cache " + mHashes + + " now have " + mBaseCacheSize + " entries"); + return; + } + } + } + + mHashes = new int[size]; + mArray = new Object[size<<1]; + } + + private static void freeArrays(final int[] hashes, final Object[] array, final int size) { + if (hashes.length == (BASE_SIZE*2)) { + synchronized (ArrayMap.class) { + if (mTwiceBaseCacheSize < CACHE_SIZE) { + array[0] = mTwiceBaseCache; + array[1] = hashes; + for (int i=(size<<1)-1; i>=2; i--) { + array[i] = null; + } + mTwiceBaseCache = array; + mTwiceBaseCacheSize++; + if (DEBUG) System.out.println("Storing 2x cache " + array + + " now have " + mTwiceBaseCacheSize + " entries"); + } + } + } else if (hashes.length == BASE_SIZE) { + synchronized (ArrayMap.class) { + if (mBaseCacheSize < CACHE_SIZE) { + array[0] = mBaseCache; + array[1] = hashes; + for (int i=(size<<1)-1; i>=2; i--) { + array[i] = null; + } + mBaseCache = array; + mBaseCacheSize++; + if (DEBUG) System.out.println("Storing 1x cache " + array + + " now have " + mBaseCacheSize + " entries"); + } + } + } + } + + /** + * Create a new empty ArrayMap. The default capacity of an array map is 0, and + * will grow once items are added to it. + */ + public ArrayMap() { + mHashes = EmptyArray.INT; + mArray = EmptyArray.OBJECT; + mSize = 0; + } + + /** + * Create a new ArrayMap with a given initial capacity. + */ + public ArrayMap(int capacity) { + if (capacity == 0) { + mHashes = EmptyArray.INT; + mArray = EmptyArray.OBJECT; + } else { + allocArrays(capacity); + } + mSize = 0; + } + + private ArrayMap(boolean immutable) { + // If this is immutable, use the sentinal EMPTY_IMMUTABLE_INTS + // instance instead of the usual EmptyArray.INT. The reference + // is checked later to see if the array is allowed to grow. + mHashes = immutable ? EMPTY_IMMUTABLE_INTS : EmptyArray.INT; + mArray = EmptyArray.OBJECT; + mSize = 0; + } + + /** + * Create a new ArrayMap with the mappings from the given ArrayMap. + */ + public ArrayMap(ArrayMap map) { + this(); + if (map != null) { + putAll(map); + } + } + + /** + * Make the array map empty. All storage is released. + */ + @Override + public void clear() { + if (mSize > 0) { + freeArrays(mHashes, mArray, mSize); + mHashes = EmptyArray.INT; + mArray = EmptyArray.OBJECT; + mSize = 0; + } + } + + /** + * @hide + * Like {@link #clear}, but doesn't reduce the capacity of the ArrayMap. + */ + public void erase() { + if (mSize > 0) { + final int N = mSize<<1; + final Object[] array = mArray; + for (int i=0; iminimumCapacity + * items. + */ + public void ensureCapacity(int minimumCapacity) { + if (mHashes.length < minimumCapacity) { + final int[] ohashes = mHashes; + final Object[] oarray = mArray; + allocArrays(minimumCapacity); + if (mSize > 0) { + System.arraycopy(ohashes, 0, mHashes, 0, mSize); + System.arraycopy(oarray, 0, mArray, 0, mSize<<1); + } + freeArrays(ohashes, oarray, mSize); + } + } + + /** + * Check whether a key exists in the array. + * + * @param key The key to search for. + * @return Returns true if the key exists, else false. + */ + @Override + public boolean containsKey(Object key) { + return indexOfKey(key) >= 0; + } + + /** + * Returns the index of a key in the set. + * + * @param key The key to search for. + * @return Returns the index of the key if it exists, else a negative integer. + */ + public int indexOfKey(Object key) { + return key == null ? indexOfNull() : indexOf(key, key.hashCode()); + } + + int indexOfValue(Object value) { + final int N = mSize*2; + final Object[] array = mArray; + if (value == null) { + for (int i=1; i>1; + } + } + } else { + for (int i=1; i>1; + } + } + } + return -1; + } + + /** + * Check whether a value exists in the array. This requires a linear search + * through the entire array. + * + * @param value The value to search for. + * @return Returns true if the value exists, else false. + */ + @Override + public boolean containsValue(Object value) { + return indexOfValue(value) >= 0; + } + + /** + * Retrieve a value from the array. + * @param key The key of the value to retrieve. + * @return Returns the value associated with the given key, + * or null if there is no such key. + */ + @Override + public V get(Object key) { + final int index = indexOfKey(key); + return index >= 0 ? (V)mArray[(index<<1)+1] : null; + } + + /** + * Return the key at the given index in the array. + * @param index The desired index, must be between 0 and {@link #size()}-1. + * @return Returns the key stored at the given index. + */ + public K keyAt(int index) { + return (K)mArray[index << 1]; + } + + /** + * Return the value at the given index in the array. + * @param index The desired index, must be between 0 and {@link #size()}-1. + * @return Returns the value stored at the given index. + */ + public V valueAt(int index) { + return (V)mArray[(index << 1) + 1]; + } + + /** + * Set the value at a given index in the array. + * @param index The desired index, must be between 0 and {@link #size()}-1. + * @param value The new value to store at this index. + * @return Returns the previous value at the given index. + */ + public V setValueAt(int index, V value) { + index = (index << 1) + 1; + V old = (V)mArray[index]; + mArray[index] = value; + return old; + } + + /** + * Return true if the array map contains no items. + */ + @Override + public boolean isEmpty() { + return mSize <= 0; + } + + /** + * Add a new value to the array map. + * @param key The key under which to store the value. If + * this key already exists in the array, its value will be replaced. + * @param value The value to store for the given key. + * @return Returns the old value that was stored for the given key, or null if there + * was no such key. + */ + @Override + public V put(K key, V value) { + final int hash; + int index; + if (key == null) { + hash = 0; + index = indexOfNull(); + } else { + hash = key.hashCode(); + index = indexOf(key, hash); + } + if (index >= 0) { + index = (index<<1) + 1; + final V old = (V)mArray[index]; + mArray[index] = value; + return old; + } + + index = ~index; + if (mSize >= mHashes.length) { + final int n = mSize >= (BASE_SIZE*2) ? (mSize+(mSize>>1)) + : (mSize >= BASE_SIZE ? (BASE_SIZE*2) : BASE_SIZE); + + if (DEBUG) System.out.println("put: grow from " + mHashes.length + " to " + n); + + final int[] ohashes = mHashes; + final Object[] oarray = mArray; + allocArrays(n); + + if (mHashes.length > 0) { + if (DEBUG) System.out.println("put: copy 0-" + mSize + " to 0"); + System.arraycopy(ohashes, 0, mHashes, 0, ohashes.length); + System.arraycopy(oarray, 0, mArray, 0, oarray.length); + } + + freeArrays(ohashes, oarray, mSize); + } + + if (index < mSize) { + if (DEBUG) System.out.println("put: move " + index + "-" + (mSize-index) + + " to " + (index+1)); + System.arraycopy(mHashes, index, mHashes, index + 1, mSize - index); + System.arraycopy(mArray, index << 1, mArray, (index + 1) << 1, (mSize - index) << 1); + } + + mHashes[index] = hash; + mArray[index<<1] = key; + mArray[(index<<1)+1] = value; + mSize++; + return null; + } + + /** + * Special fast path for appending items to the end of the array without validation. + * The array must already be large enough to contain the item. + * @hide + */ + public void append(K key, V value) { + int index = mSize; + final int hash = key == null ? 0 : key.hashCode(); + if (index >= mHashes.length) { + throw new IllegalStateException("Array is full"); + } + if (index > 0 && mHashes[index-1] > hash) { + RuntimeException e = new RuntimeException("here"); + e.fillInStackTrace(); + System.out.println("New hash " + hash + + " is before end of array hash " + mHashes[index-1] + + " at index " + index + " key " + key); + e.printStackTrace(); + put(key, value); + return; + } + mSize = index+1; + mHashes[index] = hash; + index <<= 1; + mArray[index] = key; + mArray[index+1] = value; + } + + /** + * The use of the {@link #append} function can result in invalid array maps, in particular + * an array map where the same key appears multiple times. This function verifies that + * the array map is valid, throwing IllegalArgumentException if a problem is found. The + * main use for this method is validating an array map after unpacking from an IPC, to + * protect against malicious callers. + * @hide + */ + public void validate() { + final int N = mSize; + if (N <= 1) { + // There can't be dups. + return; + } + int basehash = mHashes[0]; + int basei = 0; + for (int i=1; i=basei; j--) { + final Object prev = mArray[j<<1]; + if (cur == prev) { + throw new IllegalArgumentException("Duplicate key in ArrayMap: " + cur); + } + if (cur != null && prev != null && cur.equals(prev)) { + throw new IllegalArgumentException("Duplicate key in ArrayMap: " + cur); + } + } + } + } + + /** + * Perform a {@link #put(Object, Object)} of all key/value pairs in array + * @param array The array whose contents are to be retrieved. + */ + public void putAll(ArrayMap array) { + final int N = array.mSize; + ensureCapacity(mSize + N); + if (mSize == 0) { + if (N > 0) { + System.arraycopy(array.mHashes, 0, mHashes, 0, N); + System.arraycopy(array.mArray, 0, mArray, 0, N<<1); + mSize = N; + } + } else { + for (int i=0; i= 0) { + return removeAt(index); + } + + return null; + } + + /** + * Remove the key/value mapping at the given index. + * @param index The desired index, must be between 0 and {@link #size()}-1. + * @return Returns the value that was stored at this index. + */ + public V removeAt(int index) { + final Object old = mArray[(index << 1) + 1]; + if (mSize <= 1) { + // Now empty. + if (DEBUG) System.out.println("remove: shrink from " + mHashes.length + " to 0"); + freeArrays(mHashes, mArray, mSize); + mHashes = EmptyArray.INT; + mArray = EmptyArray.OBJECT; + mSize = 0; + } else { + if (mHashes.length > (BASE_SIZE*2) && mSize < mHashes.length/3) { + // Shrunk enough to reduce size of arrays. We don't allow it to + // shrink smaller than (BASE_SIZE*2) to avoid flapping between + // that and BASE_SIZE. + final int n = mSize > (BASE_SIZE*2) ? (mSize + (mSize>>1)) : (BASE_SIZE*2); + + if (DEBUG) System.out.println("remove: shrink from " + mHashes.length + " to " + n); + + final int[] ohashes = mHashes; + final Object[] oarray = mArray; + allocArrays(n); + + mSize--; + if (index > 0) { + if (DEBUG) System.out.println("remove: copy from 0-" + index + " to 0"); + System.arraycopy(ohashes, 0, mHashes, 0, index); + System.arraycopy(oarray, 0, mArray, 0, index << 1); + } + if (index < mSize) { + if (DEBUG) System.out.println("remove: copy from " + (index+1) + "-" + mSize + + " to " + index); + System.arraycopy(ohashes, index + 1, mHashes, index, mSize - index); + System.arraycopy(oarray, (index + 1) << 1, mArray, index << 1, + (mSize - index) << 1); + } + } else { + mSize--; + if (index < mSize) { + if (DEBUG) System.out.println("remove: move " + (index+1) + "-" + mSize + + " to " + index); + System.arraycopy(mHashes, index + 1, mHashes, index, mSize - index); + System.arraycopy(mArray, (index + 1) << 1, mArray, index << 1, + (mSize - index) << 1); + } + mArray[mSize << 1] = null; + mArray[(mSize << 1) + 1] = null; + } + } + return (V)old; + } + + /** + * Return the number of items in this array map. + */ + @Override + public int size() { + return mSize; + } + + /** + * {@inheritDoc} + * + *

This implementation returns false if the object is not a map, or + * if the maps have different sizes. Otherwise, for each key in this map, + * values of both maps are compared. If the values for any key are not + * equal, the method returns false, otherwise it returns true. + */ + @Override + public boolean equals(Object object) { + if (this == object) { + return true; + } + if (object instanceof Map) { + Map map = (Map) object; + if (size() != map.size()) { + return false; + } + + try { + for (int i=0; iThis implementation composes a string by iterating over its mappings. If + * this map contains itself as a key or a value, the string "(this Map)" + * will appear in its place. + */ + @Override + public String toString() { + if (isEmpty()) { + return "{}"; + } + + StringBuilder buffer = new StringBuilder(mSize * 28); + buffer.append('{'); + for (int i=0; i 0) { + buffer.append(", "); + } + Object key = keyAt(i); + if (key != this) { + buffer.append(key); + } else { + buffer.append("(this Map)"); + } + buffer.append('='); + Object value = valueAt(i); + if (value != this) { + buffer.append(value); + } else { + buffer.append("(this Map)"); + } + } + buffer.append('}'); + return buffer.toString(); + } + + // ------------------------------------------------------------------------ + // Interop with traditional Java containers. Not as efficient as using + // specialized collection APIs. + // ------------------------------------------------------------------------ + + private MapCollections getCollection() { + if (mCollections == null) { + mCollections = new MapCollections() { + @Override + protected int colGetSize() { + return mSize; + } + + @Override + protected Object colGetEntry(int index, int offset) { + return mArray[(index<<1) + offset]; + } + + @Override + protected int colIndexOfKey(Object key) { + return indexOfKey(key); + } + + @Override + protected int colIndexOfValue(Object value) { + return indexOfValue(value); + } + + @Override + protected Map colGetMap() { + return ArrayMap.this; + } + + @Override + protected void colPut(K key, V value) { + put(key, value); + } + + @Override + protected V colSetValue(int index, V value) { + return setValueAt(index, value); + } + + @Override + protected void colRemoveAt(int index) { + removeAt(index); + } + + @Override + protected void colClear() { + clear(); + } + }; + } + return mCollections; + } + + /** + * Determine if the array map contains all of the keys in the given collection. + * @param collection The collection whose contents are to be checked against. + * @return Returns true if this array map contains a key for every entry + * in collection, else returns false. + */ + public boolean containsAll(Collection collection) { + return MapCollections.containsAllHelper(this, collection); + } + + /** + * Perform a {@link #put(Object, Object)} of all key/value pairs in map + * @param map The map whose contents are to be retrieved. + */ + @Override + public void putAll(Map map) { + ensureCapacity(mSize + map.size()); + for (Map.Entry entry : map.entrySet()) { + put(entry.getKey(), entry.getValue()); + } + } + + /** + * Remove all keys in the array map that exist in the given collection. + * @param collection The collection whose contents are to be used to remove keys. + * @return Returns true if any keys were removed from the array map, else false. + */ + public boolean removeAll(Collection collection) { + return MapCollections.removeAllHelper(this, collection); + } + + /** + * Remove all keys in the array map that do not exist in the given collection. + * @param collection The collection whose contents are to be used to determine which + * keys to keep. + * @return Returns true if any keys were removed from the array map, else false. + */ + public boolean retainAll(Collection collection) { + return MapCollections.retainAllHelper(this, collection); + } + + /** + * Return a {@link java.util.Set} for iterating over and interacting with all mappings + * in the array map. + * + *

Note: this is a very inefficient way to access the array contents, it + * requires generating a number of temporary objects and allocates additional state + * information associated with the container that will remain for the life of the container.

+ * + *

Note:

the semantics of this + * Set are subtly different than that of a {@link java.util.HashMap}: most important, + * the {@link java.util.Map.Entry Map.Entry} object returned by its iterator is a single + * object that exists for the entire iterator, so you can not hold on to it + * after calling {@link java.util.Iterator#next() Iterator.next}.

+ */ + @Override + public Set> entrySet() { + return getCollection().getEntrySet(); + } + + /** + * Return a {@link java.util.Set} for iterating over and interacting with all keys + * in the array map. + * + *

Note: this is a fairly inefficient way to access the array contents, it + * requires generating a number of temporary objects and allocates additional state + * information associated with the container that will remain for the life of the container.

+ */ + @Override + public Set keySet() { + return getCollection().getKeySet(); + } + + /** + * Return a {@link java.util.Collection} for iterating over and interacting with all values + * in the array map. + * + *

Note: this is a fairly inefficient way to access the array contents, it + * requires generating a number of temporary objects and allocates additional state + * information associated with the container that will remain for the life of the container.

+ */ + @Override + public Collection values() { + return getCollection().getValues(); + } +} diff --git a/jre_lwjgl3glfw/src/main/java/android/util/ContainerHelpers.java b/jre_lwjgl3glfw/src/main/java/android/util/ContainerHelpers.java new file mode 100644 index 000000000..4e5fefb9d --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/android/util/ContainerHelpers.java @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2013 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.util; + +class ContainerHelpers { + + // This is Arrays.binarySearch(), but doesn't do any argument validation. + static int binarySearch(int[] array, int size, int value) { + int lo = 0; + int hi = size - 1; + + while (lo <= hi) { + final int mid = (lo + hi) >>> 1; + final int midVal = array[mid]; + + if (midVal < value) { + lo = mid + 1; + } else if (midVal > value) { + hi = mid - 1; + } else { + return mid; // value found + } + } + return ~lo; // value not present + } + + static int binarySearch(long[] array, int size, long value) { + int lo = 0; + int hi = size - 1; + + while (lo <= hi) { + final int mid = (lo + hi) >>> 1; + final long midVal = array[mid]; + + if (midVal < value) { + lo = mid + 1; + } else if (midVal > value) { + hi = mid - 1; + } else { + return mid; // value found + } + } + return ~lo; // value not present + } +} diff --git a/jre_lwjgl3glfw/src/main/java/android/util/EmptyArray.java b/jre_lwjgl3glfw/src/main/java/android/util/EmptyArray.java new file mode 100644 index 000000000..a5735fbc5 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/android/util/EmptyArray.java @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package android.util; + +public final class EmptyArray { + private EmptyArray() {} + public static final boolean[] BOOLEAN = new boolean[0]; + public static final byte[] BYTE = new byte[0]; + public static final char[] CHAR = new char[0]; + public static final double[] DOUBLE = new double[0]; + public static final int[] INT = new int[0]; + public static final Class[] CLASS = new Class[0]; + public static final Object[] OBJECT = new Object[0]; + public static final String[] STRING = new String[0]; + public static final Throwable[] THROWABLE = new Throwable[0]; + public static final StackTraceElement[] STACK_TRACE_ELEMENT = new StackTraceElement[0]; +} diff --git a/jre_lwjgl3glfw/src/main/java/android/util/MapCollections.java b/jre_lwjgl3glfw/src/main/java/android/util/MapCollections.java new file mode 100644 index 000000000..acfc1adad --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/android/util/MapCollections.java @@ -0,0 +1,557 @@ +/* + * Copyright (C) 2013 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.util; + +import java.lang.reflect.Array; +import java.util.Collection; +import java.util.Iterator; +import java.util.Map; +import java.util.Set; + +/** + * Helper for writing standard Java collection interfaces to a data + * structure like {@link ArrayMap}. + * @hide + */ +abstract class MapCollections { + EntrySet mEntrySet; + KeySet mKeySet; + ValuesCollection mValues; + + final class ArrayIterator implements Iterator { + final int mOffset; + int mSize; + int mIndex; + boolean mCanRemove = false; + + ArrayIterator(int offset) { + mOffset = offset; + mSize = colGetSize(); + } + + @Override + public boolean hasNext() { + return mIndex < mSize; + } + + @Override + public T next() { + Object res = colGetEntry(mIndex, mOffset); + mIndex++; + mCanRemove = true; + return (T)res; + } + + @Override + public void remove() { + if (!mCanRemove) { + throw new IllegalStateException(); + } + mIndex--; + mSize--; + mCanRemove = false; + colRemoveAt(mIndex); + } + } + + final class MapIterator implements Iterator>, Map.Entry { + int mEnd; + int mIndex; + boolean mEntryValid = false; + + MapIterator() { + mEnd = colGetSize() - 1; + mIndex = -1; + } + + @Override + public boolean hasNext() { + return mIndex < mEnd; + } + + @Override + public Map.Entry next() { + mIndex++; + mEntryValid = true; + return this; + } + + @Override + public void remove() { + if (!mEntryValid) { + throw new IllegalStateException(); + } + colRemoveAt(mIndex); + mIndex--; + mEnd--; + mEntryValid = false; + } + + @Override + public K getKey() { + if (!mEntryValid) { + throw new IllegalStateException( + "This container does not support retaining Map.Entry objects"); + } + return (K)colGetEntry(mIndex, 0); + } + + @Override + public V getValue() { + if (!mEntryValid) { + throw new IllegalStateException( + "This container does not support retaining Map.Entry objects"); + } + return (V)colGetEntry(mIndex, 1); + } + + @Override + public V setValue(V object) { + if (!mEntryValid) { + throw new IllegalStateException( + "This container does not support retaining Map.Entry objects"); + } + return colSetValue(mIndex, object); + } + + @Override + public final boolean equals(Object o) { + if (!mEntryValid) { + throw new IllegalStateException( + "This container does not support retaining Map.Entry objects"); + } + if (!(o instanceof Map.Entry)) { + return false; + } + Map.Entry e = (Map.Entry) o; + return Objects.equal(e.getKey(), colGetEntry(mIndex, 0)) + && Objects.equal(e.getValue(), colGetEntry(mIndex, 1)); + } + + @Override + public final int hashCode() { + if (!mEntryValid) { + throw new IllegalStateException( + "This container does not support retaining Map.Entry objects"); + } + final Object key = colGetEntry(mIndex, 0); + final Object value = colGetEntry(mIndex, 1); + return (key == null ? 0 : key.hashCode()) ^ + (value == null ? 0 : value.hashCode()); + } + + @Override + public final String toString() { + return getKey() + "=" + getValue(); + } + } + + final class EntrySet implements Set> { + @Override + public boolean add(Map.Entry object) { + throw new UnsupportedOperationException(); + } + + @Override + public boolean addAll(Collection> collection) { + int oldSize = colGetSize(); + for (Map.Entry entry : collection) { + colPut(entry.getKey(), entry.getValue()); + } + return oldSize != colGetSize(); + } + + @Override + public void clear() { + colClear(); + } + + @Override + public boolean contains(Object o) { + if (!(o instanceof Map.Entry)) + return false; + Map.Entry e = (Map.Entry) o; + int index = colIndexOfKey(e.getKey()); + if (index < 0) { + return false; + } + Object foundVal = colGetEntry(index, 1); + return Objects.equal(foundVal, e.getValue()); + } + + @Override + public boolean containsAll(Collection collection) { + Iterator it = collection.iterator(); + while (it.hasNext()) { + if (!contains(it.next())) { + return false; + } + } + return true; + } + + @Override + public boolean isEmpty() { + return colGetSize() == 0; + } + + @Override + public Iterator> iterator() { + return new MapIterator(); + } + + @Override + public boolean remove(Object object) { + throw new UnsupportedOperationException(); + } + + @Override + public boolean removeAll(Collection collection) { + throw new UnsupportedOperationException(); + } + + @Override + public boolean retainAll(Collection collection) { + throw new UnsupportedOperationException(); + } + + @Override + public int size() { + return colGetSize(); + } + + @Override + public Object[] toArray() { + throw new UnsupportedOperationException(); + } + + @Override + public T[] toArray(T[] array) { + throw new UnsupportedOperationException(); + } + + @Override + public boolean equals(Object object) { + return equalsSetHelper(this, object); + } + + @Override + public int hashCode() { + int result = 0; + for (int i=colGetSize()-1; i>=0; i--) { + final Object key = colGetEntry(i, 0); + final Object value = colGetEntry(i, 1); + result += ( (key == null ? 0 : key.hashCode()) ^ + (value == null ? 0 : value.hashCode()) ); + } + return result; + } + }; + + final class KeySet implements Set { + + @Override + public boolean add(K object) { + throw new UnsupportedOperationException(); + } + + @Override + public boolean addAll(Collection collection) { + throw new UnsupportedOperationException(); + } + + @Override + public void clear() { + colClear(); + } + + @Override + public boolean contains(Object object) { + return colIndexOfKey(object) >= 0; + } + + @Override + public boolean containsAll(Collection collection) { + return containsAllHelper(colGetMap(), collection); + } + + @Override + public boolean isEmpty() { + return colGetSize() == 0; + } + + @Override + public Iterator iterator() { + return new ArrayIterator(0); + } + + @Override + public boolean remove(Object object) { + int index = colIndexOfKey(object); + if (index >= 0) { + colRemoveAt(index); + return true; + } + return false; + } + + @Override + public boolean removeAll(Collection collection) { + return removeAllHelper(colGetMap(), collection); + } + + @Override + public boolean retainAll(Collection collection) { + return retainAllHelper(colGetMap(), collection); + } + + @Override + public int size() { + return colGetSize(); + } + + @Override + public Object[] toArray() { + return toArrayHelper(0); + } + + @Override + public T[] toArray(T[] array) { + return toArrayHelper(array, 0); + } + + @Override + public boolean equals(Object object) { + return equalsSetHelper(this, object); + } + + @Override + public int hashCode() { + int result = 0; + for (int i=colGetSize()-1; i>=0; i--) { + Object obj = colGetEntry(i, 0); + result += obj == null ? 0 : obj.hashCode(); + } + return result; + } + }; + + final class ValuesCollection implements Collection { + + @Override + public boolean add(V object) { + throw new UnsupportedOperationException(); + } + + @Override + public boolean addAll(Collection collection) { + throw new UnsupportedOperationException(); + } + + @Override + public void clear() { + colClear(); + } + + @Override + public boolean contains(Object object) { + return colIndexOfValue(object) >= 0; + } + + @Override + public boolean containsAll(Collection collection) { + Iterator it = collection.iterator(); + while (it.hasNext()) { + if (!contains(it.next())) { + return false; + } + } + return true; + } + + @Override + public boolean isEmpty() { + return colGetSize() == 0; + } + + @Override + public Iterator iterator() { + return new ArrayIterator(1); + } + + @Override + public boolean remove(Object object) { + int index = colIndexOfValue(object); + if (index >= 0) { + colRemoveAt(index); + return true; + } + return false; + } + + @Override + public boolean removeAll(Collection collection) { + int N = colGetSize(); + boolean changed = false; + for (int i=0; i collection) { + int N = colGetSize(); + boolean changed = false; + for (int i=0; i T[] toArray(T[] array) { + return toArrayHelper(array, 1); + } + }; + + public static boolean containsAllHelper(Map map, Collection collection) { + Iterator it = collection.iterator(); + while (it.hasNext()) { + if (!map.containsKey(it.next())) { + return false; + } + } + return true; + } + + public static boolean removeAllHelper(Map map, Collection collection) { + int oldSize = map.size(); + Iterator it = collection.iterator(); + while (it.hasNext()) { + map.remove(it.next()); + } + return oldSize != map.size(); + } + + public static boolean retainAllHelper(Map map, Collection collection) { + int oldSize = map.size(); + Iterator it = map.keySet().iterator(); + while (it.hasNext()) { + if (!collection.contains(it.next())) { + it.remove(); + } + } + return oldSize != map.size(); + } + + public Object[] toArrayHelper(int offset) { + final int N = colGetSize(); + Object[] result = new Object[N]; + for (int i=0; i T[] toArrayHelper(T[] array, int offset) { + final int N = colGetSize(); + if (array.length < N) { + @SuppressWarnings("unchecked") T[] newArray + = (T[]) Array.newInstance(array.getClass().getComponentType(), N); + array = newArray; + } + for (int i=0; i N) { + array[N] = null; + } + return array; + } + + public static boolean equalsSetHelper(Set set, Object object) { + if (set == object) { + return true; + } + if (object instanceof Set) { + Set s = (Set) object; + + try { + return set.size() == s.size() && set.containsAll(s); + } catch (NullPointerException ignored) { + return false; + } catch (ClassCastException ignored) { + return false; + } + } + return false; + } + + public Set> getEntrySet() { + if (mEntrySet == null) { + mEntrySet = new EntrySet(); + } + return mEntrySet; + } + + public Set getKeySet() { + if (mKeySet == null) { + mKeySet = new KeySet(); + } + return mKeySet; + } + + public Collection getValues() { + if (mValues == null) { + mValues = new ValuesCollection(); + } + return mValues; + } + + protected abstract int colGetSize(); + protected abstract Object colGetEntry(int index, int offset); + protected abstract int colIndexOfKey(Object key); + protected abstract int colIndexOfValue(Object key); + protected abstract Map colGetMap(); + protected abstract void colPut(K key, V value); + protected abstract V colSetValue(int index, V value); + protected abstract void colRemoveAt(int index); + protected abstract void colClear(); +} diff --git a/jre_lwjgl3glfw/src/main/java/android/util/Objects.java b/jre_lwjgl3glfw/src/main/java/android/util/Objects.java new file mode 100644 index 000000000..64693903b --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/android/util/Objects.java @@ -0,0 +1,87 @@ +/* + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package android.util; +import java.lang.reflect.Field; +import java.lang.reflect.Modifier; +import java.util.Arrays; +public final class Objects { + private Objects() {} + /** + * Returns true if two possibly-null objects are equal. + */ + public static boolean equal(Object a, Object b) { + return a == b || (a != null && a.equals(b)); + } + public static int hashCode(Object o) { + return (o == null) ? 0 : o.hashCode(); + } + /** + * Returns a string reporting the value of each declared field, via reflection. + * Static and transient fields are automatically skipped. Produces output like + * "SimpleClassName[integer=1234,string="hello",character='c',intArray=[1,2,3]]". + */ + public static String toString(Object o) { + Class c = o.getClass(); + StringBuilder sb = new StringBuilder(); + sb.append(c.getSimpleName()).append('['); + int i = 0; + for (Field f : c.getDeclaredFields()) { + if ((f.getModifiers() & (Modifier.STATIC | Modifier.TRANSIENT)) != 0) { + continue; + } + f.setAccessible(true); + try { + Object value = f.get(o); + if (i++ > 0) { + sb.append(','); + } + sb.append(f.getName()); + sb.append('='); + if (value.getClass().isArray()) { + if (value.getClass() == boolean[].class) { + sb.append(Arrays.toString((boolean[]) value)); + } else if (value.getClass() == byte[].class) { + sb.append(Arrays.toString((byte[]) value)); + } else if (value.getClass() == char[].class) { + sb.append(Arrays.toString((char[]) value)); + } else if (value.getClass() == double[].class) { + sb.append(Arrays.toString((double[]) value)); + } else if (value.getClass() == float[].class) { + sb.append(Arrays.toString((float[]) value)); + } else if (value.getClass() == int[].class) { + sb.append(Arrays.toString((int[]) value)); + } else if (value.getClass() == long[].class) { + sb.append(Arrays.toString((long[]) value)); + } else if (value.getClass() == short[].class) { + sb.append(Arrays.toString((short[]) value)); + } else { + sb.append(Arrays.toString((Object[]) value)); + } + } else if (value.getClass() == Character.class) { + sb.append('\'').append(value).append('\''); + } else if (value.getClass() == String.class) { + sb.append('"').append(value).append('"'); + } else { + sb.append(value); + } + } catch (IllegalAccessException unexpected) { + throw new AssertionError(unexpected); + } + } + sb.append("]"); + return sb.toString(); + } +} diff --git a/jre_lwjgl3glfw/src/main/java/net/minecraft/client/ClientBrandRetriever.java.z b/jre_lwjgl3glfw/src/main/java/net/minecraft/client/ClientBrandRetriever.java.z new file mode 100644 index 000000000..987a62f05 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/net/minecraft/client/ClientBrandRetriever.java.z @@ -0,0 +1,8 @@ +package net.minecraft.client; + +public class ClientBrandRetriever { + public static String getClientModName() { + // return "vanilla"; + return System.getProperty("net.minecraft.clientmodname", "vanilla"); + } +} diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/BufferChecks.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/BufferChecks.java new file mode 100644 index 000000000..1160c72e1 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/BufferChecks.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; + +import java.nio.*; + +/** + *

+ * 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$ $Id$ + */ +public class BufferChecks { + private BufferChecks() { + } + + /** + * Helper methods to ensure a function pointer is not-null (0) + */ + public static void checkFunctionAddress(long pointer) { + if (LWJGLUtil.CHECKS && 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 (LWJGLUtil.CHECKS && buf.get(buf.limit() - 1) != 0) + throw new IllegalArgumentException("Missing null termination"); + } + + public static void checkNullTerminated(ByteBuffer buf, int count) { + if (LWJGLUtil.CHECKS) { + 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 method to ensure an IntBuffer is null-terminated */ + public static void checkNullTerminated(IntBuffer buf) { + if (LWJGLUtil.CHECKS && buf.get(buf.limit() - 1) != 0) + throw new IllegalArgumentException("Missing null termination"); + + } + + /** Helper method to ensure a LongBuffer is null-terminated */ + public static void checkNullTerminated(LongBuffer buf) { + if (LWJGLUtil.CHECKS && buf.get(buf.limit() - 1) != 0) + throw new IllegalArgumentException("Missing null termination"); + + } + + /** Helper method to ensure a PointerBuffer is null-terminated */ + public static void checkNullTerminated(PointerBuffer buf) { + if (LWJGLUtil.CHECKS && buf.get(buf.limit() - 1) != 0) + throw new IllegalArgumentException("Missing null termination"); + + } + + public static void checkNotNull(Object o) { + if (LWJGLUtil.CHECKS && 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 (LWJGLUtil.CHECKS && !buf.isDirect()) + throw new IllegalArgumentException("ByteBuffer is not direct"); + + } + + public static void checkDirect(ShortBuffer buf) { + if (LWJGLUtil.CHECKS && !buf.isDirect()) + throw new IllegalArgumentException("ShortBuffer is not direct"); + + } + + public static void checkDirect(IntBuffer buf) { + if (LWJGLUtil.CHECKS && !buf.isDirect()) + throw new IllegalArgumentException("IntBuffer is not direct"); + + } + + public static void checkDirect(LongBuffer buf) { + if (LWJGLUtil.CHECKS && !buf.isDirect()) { + throw new IllegalArgumentException("LongBuffer is not direct"); + } + } + + public static void checkDirect(FloatBuffer buf) { + if (LWJGLUtil.CHECKS && !buf.isDirect()) + throw new IllegalArgumentException("FloatBuffer is not direct"); + + } + + public static void checkDirect(DoubleBuffer buf) { + if (LWJGLUtil.CHECKS && !buf.isDirect()) + throw new IllegalArgumentException("DoubleBuffer is not direct"); + + } + + public static void checkDirect(PointerBuffer buf) { + // NO-OP, PointerBuffer is always direct. + } + + public static void checkArray(Object[] array) { + if (LWJGLUtil.CHECKS && (array == null || array.length == 0)) + throw new IllegalArgumentException("Invalid array"); + } + + /** + * 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 + + ". Because at most " + size + " elements can be returned, a buffer with at least " + size + + " elements is required, regardless of actual returned element count"); + } + + private static void throwBufferSizeException(PointerBuffer buf, int size) { + throw new IllegalArgumentException( + "Number of remaining pointer buffer elements is " + buf.remaining() + ", must be at least " + size); + } + + private static void throwArraySizeException(Object[] array, int size) { + throw new IllegalArgumentException( + "Number of array elements is " + array.length + ", must be at least " + size); + } + + private static void throwArraySizeException(long[] array, int size) { + throw new IllegalArgumentException( + "Number of array elements is " + array.length + ", 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 (LWJGLUtil.CHECKS && buf.remaining() < size) + throwBufferSizeException(buf, size); + + } + + /** + * Detects the buffer type and performs the corresponding check and also + * returns the buffer position in bytes. + * + * @param buffer + * the buffer to check + * @param size + * the size to check + * + * @return the buffer position in bytes + */ + public static int checkBuffer(final Buffer buffer, final int size) { + final int posShift; + if (buffer instanceof ByteBuffer) { + BufferChecks.checkBuffer((ByteBuffer) buffer, size); + posShift = 0; + } else if (buffer instanceof ShortBuffer) { + BufferChecks.checkBuffer((ShortBuffer) buffer, size); + posShift = 1; + } else if (buffer instanceof IntBuffer) { + BufferChecks.checkBuffer((IntBuffer) buffer, size); + posShift = 2; + } else if (buffer instanceof LongBuffer) { + BufferChecks.checkBuffer((LongBuffer) buffer, size); + posShift = 4; + } else if (buffer instanceof FloatBuffer) { + BufferChecks.checkBuffer((FloatBuffer) buffer, size); + posShift = 2; + } else if (buffer instanceof DoubleBuffer) { + BufferChecks.checkBuffer((DoubleBuffer) buffer, size); + posShift = 4; + } else + throw new IllegalArgumentException("Unsupported Buffer type specified: " + buffer.getClass()); + + return buffer.position() << posShift; + } + + public static void checkBuffer(ByteBuffer buf, int size) { + if (LWJGLUtil.CHECKS) { + checkBufferSize(buf, size); + checkDirect(buf); + } + } + + public static void checkBuffer(ShortBuffer buf, int size) { + if (LWJGLUtil.CHECKS) { + checkBufferSize(buf, size); + checkDirect(buf); + } + } + + public static void checkBuffer(IntBuffer buf, int size) { + if (LWJGLUtil.CHECKS) { + checkBufferSize(buf, size); + checkDirect(buf); + } + } + + public static void checkBuffer(LongBuffer buf, int size) { + if (LWJGLUtil.CHECKS) { + checkBufferSize(buf, size); + checkDirect(buf); + } + } + + public static void checkBuffer(FloatBuffer buf, int size) { + if (LWJGLUtil.CHECKS) { + checkBufferSize(buf, size); + checkDirect(buf); + } + } + + public static void checkBuffer(DoubleBuffer buf, int size) { + if (LWJGLUtil.CHECKS) { + checkBufferSize(buf, size); + checkDirect(buf); + } + } + + public static void checkBuffer(PointerBuffer buf, int size) { + if (LWJGLUtil.CHECKS && buf.remaining() < size) { + throwBufferSizeException(buf, size); + } + } + + public static void checkArray(Object[] array, int size) { + if (LWJGLUtil.CHECKS && array.length < size) + throwArraySizeException(array, size); + } + + public static void checkArray(long[] array, int size) { + if (LWJGLUtil.CHECKS && array.length < size) + throwArraySizeException(array, size); + } + +} diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/BufferUtils.java.z b/jre_lwjgl3glfw/src/main/java/org/lwjgl/BufferUtils.java.z new file mode 100644 index 000000000..643170c53 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/BufferUtils.java.z @@ -0,0 +1,269 @@ +/* + * Copyright LWJGL. All rights reserved. + * License terms: https://www.lwjgl.org/license + */ +package org.lwjgl; + +import org.lwjgl.system.*; + +import java.nio.*; + +import static org.lwjgl.system.APIUtil.*; +import static org.lwjgl.system.MemoryUtil.*; + +/** + *

This class makes it easy and safe to work with direct buffers. It is the recommended way to allocate memory to use with LWJGL.

+ * + *

Direct buffers

+ * + *

LWJGL requires that all NIO buffers passed to it are direct buffers. Direct buffers essentially wrap an address that points to off-heap memory, i.e. a + * native pointer. This is the only way LWJGL can safely pass data from Java code to native code, and vice-versa, without a performance penalty. It does not + * support on-heap Java arrays (or plain NIO buffers, which wrap them) because arrays may be moved around in memory by the JVM's garbage collector while native + * code is accessing them. In addition, Java arrays have an unspecified layout, i.e. they are not necessarily contiguous in memory.

+ * + *

Usage

+ * + *

When a direct buffer is passed as an argument to an LWJGL method, no data is copied. Instead, the current buffer position is added to the buffer's memory + * address and the resulting value is passed to native code. The native code interprets that value as a pointer and reads or copies from it as necessary. LWJGL + * will often also use the current buffer limit (via {@link Buffer#remaining()}) to automatically pass length/maxlength arguments. This means that, just like + * other APIs that use NIO buffers, the current {@link Buffer#position()} and {@link Buffer#limit()} at the time of the call is very important. Contrary to + * other APIs, LWJGL never modifies the current position, it will be the same value before and after the call.

+ * + *

Arrays of pointers

+ * + *

In addition to the standard NIO buffer classes, LWJGL provides a {@link PointerBuffer} class for storing pointer data in an architecture independent way. + * It is used in bindings for pointer-to-pointers arguments, usually to provide arrays of data (input parameter) or to store returned pointer values (output + * parameter). Also, there's the {@link CLongBuffer} class which is similar to {@code PointerBuffer}, but for C {@code long} data.

+ * + *

Memory management

+ * + *

Using NIO buffers for off-heap memory has some drawbacks:

+ *
    + *
  • Memory blocks bigger than {@link Integer#MAX_VALUE} bytes cannot be allocated.
  • + *
  • Memory blocks are zeroed-out on allocation, for safety. This has (sometimes unwanted) performance implications.
  • + *
  • There is no way to free a buffer explicitly (without JVM specific reflection). Buffer objects are subject to GC and it usually takes two GC cycles to + * free the off-heap memory after the buffer object becomes unreachable.
  • + *
+ * + *

An alternative API for allocating off-heap memory can be found in the {@link org.lwjgl.system.MemoryUtil} class. This has none of the above drawbacks, + * but requires allocated memory to be explictly freed when not used anymore.

+ * + *

Memory alignment

+ * + *

Allocations done via this class have a guaranteed alignment of 8 bytes. If higher alignment values are required, use the explicit memory management API + * or pad the requested memory with extra bytes and align manually.

+ * + *

Structs and arrays of structs

+ * + *

Java does not support struct value types, so LWJGL requires struct values that are backed by off-heap memory. Each struct type defined in a binding + * has a corresponding class in LWJGL that can be used to access its members. Each struct class also has a {@code Buffer} inner class that can be used to + * access (packed) arrays of struct values. Both struct and struct buffer classes may be backed by direct {@link ByteBuffer}s allocated from this class, but it + * is highly recommended to use explicit memory management for performance.

+ */ +public final class BufferUtils { +// -- Begin LWJGL2 parts -- + /** + * @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); + } + + /** + * Returns the memory address of the specified buffer. + * + * @param buffer + * the buffer + * + * @return the memory address + */ + static long getBufferAddress(Buffer buffer) { + // Should be below or memAddress0() ? + return memAddress(buffer); + } +// -- End LWJGL2 parts -- + + private BufferUtils() {} + + /** + * Allocates a direct native-ordered {@code ByteBuffer} with the specified capacity. + * + * @param capacity the capacity, in bytes + * + * @return a {@code ByteBuffer} + */ + public static ByteBuffer createByteBuffer(int capacity) { + return ByteBuffer.allocateDirect(capacity).order(ByteOrder.nativeOrder()); + } + + static int getAllocationSize(int elements, int elementShift) { + apiCheckAllocation(elements, apiGetBytes(elements, elementShift), 0x7FFF_FFFFL); + return elements << elementShift; + } + + /** + * Allocates a direct native-order {@code ShortBuffer} with the specified number of elements. + * + * @param capacity the capacity, in shorts + * + * @return a {@code ShortBuffer} + */ + public static ShortBuffer createShortBuffer(int capacity) { + return createByteBuffer(getAllocationSize(capacity, 1)).asShortBuffer(); + } + + /** + * Allocates a direct native-order {@code CharBuffer} with the specified number of elements. + * + * @param capacity the capacity, in chars + * + * @return a {@code CharBuffer} + */ + public static CharBuffer createCharBuffer(int capacity) { + return createByteBuffer(getAllocationSize(capacity, 1)).asCharBuffer(); + } + + /** + * Allocates a direct native-order {@code IntBuffer} with the specified number of elements. + * + * @param capacity the capacity, in ints + * + * @return an {@code IntBuffer} + */ + public static IntBuffer createIntBuffer(int capacity) { + return createByteBuffer(getAllocationSize(capacity, 2)).asIntBuffer(); + } + + /** + * Allocates a direct native-order {@code LongBuffer} with the specified number of elements. + * + * @param capacity the capacity, in longs + * + * @return a {@code LongBuffer} + */ + public static LongBuffer createLongBuffer(int capacity) { + return createByteBuffer(getAllocationSize(capacity, 3)).asLongBuffer(); + } + + /** + * Allocates a {@code CLongBuffer} with the specified number of elements. + * + * @param capacity the capacity, in memory addresses + * + * @return a {@code CLongBuffer} + */ + public static CLongBuffer createCLongBuffer(int capacity) { + return CLongBuffer.allocateDirect(capacity); + } + + /** + * Allocates a direct native-order {@code FloatBuffer} with the specified number of elements. + * + * @param capacity the capacity, in floats + * + * @return a FloatBuffer + */ + public static FloatBuffer createFloatBuffer(int capacity) { + return createByteBuffer(getAllocationSize(capacity, 2)).asFloatBuffer(); + } + + /** + * Allocates a direct native-order {@code DoubleBuffer} with the specified number of elements. + * + * @param capacity the capacity, in doubles + * + * @return a {@code DoubleBuffer} + */ + public static DoubleBuffer createDoubleBuffer(int capacity) { + return createByteBuffer(getAllocationSize(capacity, 3)).asDoubleBuffer(); + } + + /** + * Allocates a {@code PointerBuffer} with the specified number of elements. + * + * @param capacity the capacity, in memory addresses + * + * @return a {@code PointerBuffer} + */ + public static PointerBuffer createPointerBuffer(int capacity) { + return PointerBuffer.allocateDirect(capacity); + } + + // memsets + + /** + * Fills the specified buffer with zeros from the current position to the current limit. + * + * @param buffer the buffer to fill with zeros + */ + public static void zeroBuffer(ByteBuffer buffer) { memSet(buffer, 0); } + + /** + * Fills the specified buffer with zeros from the current position to the current limit. + * + * @param buffer the buffer to fill with zeros + */ + public static void zeroBuffer(ShortBuffer buffer) { memSet(buffer, 0); } + + /** + * Fills the specified buffer with zeros from the current position to the current limit. + * + * @param buffer the buffer to fill with zeros + */ + public static void zeroBuffer(CharBuffer buffer) { memSet(buffer, 0); } + + /** + * Fills the specified buffer with zeros from the current position to the current limit. + * + * @param buffer the buffer to fill with zeros + */ + public static void zeroBuffer(IntBuffer buffer) { memSet(buffer, 0); } + + /** + * Fills the specified buffer with zeros from the current position to the current limit. + * + * @param buffer the buffer to fill with zeros + */ + public static void zeroBuffer(FloatBuffer buffer) { memSet(buffer, 0); } + + /** + * Fills the specified buffer with zeros from the current position to the current limit. + * + * @param buffer the buffer to fill with zeros + */ + public static void zeroBuffer(LongBuffer buffer) { memSet(buffer, 0); } + + /** + * Fills the specified buffer with zeros from the current position to the current limit. + * + * @param buffer the buffer to fill with zeros + */ + public static void zeroBuffer(DoubleBuffer buffer) { memSet(buffer, 0); } + + /** + * Fills the specified buffer with zeros from the current position to the current limit. + * + * @param buffer the buffer to fill with zeros + */ + public static > void zeroBuffer(T buffer) { memSet(buffer, 0); } + +} diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/LWJGLUtil.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/LWJGLUtil.java new file mode 100644 index 000000000..e074d9a2b --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/LWJGLUtil.java @@ -0,0 +1,640 @@ +/* + * Copyright (c) 2002-2008 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR 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.Field; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.nio.ByteBuffer; +import java.security.AccessController; +import java.security.PrivilegedAction; +import java.security.PrivilegedActionException; +import java.security.PrivilegedExceptionAction; +import java.util.*; + +/** + *

+ * Internal library methods + *

+ * + * @author Brian Matzon + * @version $Revision: 3608 $ $Id: LWJGLUtil.java 3608 2011-08-10 16:05:46Z + * spasi $ + */ +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"; + + private static final String LWJGL_ICON_DATA_16x16 = "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + + "\377\377\377\377\377\377\377\377\376\377\377\377\302\327\350\377" + + "\164\244\313\377\120\213\275\377\124\216\277\377\206\257\322\377" + + "\347\357\366\377\377\377\377\377\377\377\377\377\377\377\377\377" + + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + + "\377\377\377\377\365\365\365\377\215\217\221\377\166\202\215\377" + + "\175\215\233\377\204\231\252\377\224\267\325\377\072\175\265\377" + + "\110\206\272\377\332\347\361\377\377\377\377\377\377\377\377\377" + + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + + "\364\370\373\377\234\236\240\377\000\000\000\377\000\000\000\377" + + "\000\000\000\377\000\000\000\377\344\344\344\377\204\255\320\377" + + "\072\175\265\377\133\222\301\377\374\375\376\377\377\377\377\377" + + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + + "\221\266\325\377\137\137\137\377\000\000\000\377\000\000\000\377" + + "\000\000\000\377\042\042\042\377\377\377\377\377\350\360\366\377" + + "\071\174\265\377\072\175\265\377\304\330\351\377\377\377\377\377" + + "\377\377\377\377\377\377\377\377\377\377\377\377\306\331\351\377" + + "\201\253\316\377\035\035\035\377\000\000\000\377\000\000\000\377" + + "\000\000\000\377\146\146\146\377\377\377\377\377\320\340\355\377" + + "\072\175\265\377\072\175\265\377\215\264\324\377\377\377\377\377" + + "\362\362\362\377\245\245\245\377\337\337\337\377\242\301\334\377" + + "\260\305\326\377\012\012\012\377\000\000\000\377\000\000\000\377" + + "\000\000\000\377\250\250\250\377\377\377\377\377\227\272\330\377" + + "\072\175\265\377\072\175\265\377\161\241\312\377\377\377\377\377" + + "\241\241\241\377\000\000\000\377\001\001\001\377\043\043\043\377" + + "\314\314\314\377\320\320\320\377\245\245\245\377\204\204\204\377" + + "\134\134\134\377\357\357\357\377\377\377\377\377\140\226\303\377" + + "\072\175\265\377\072\175\265\377\155\236\310\377\377\377\377\377" + + "\136\136\136\377\000\000\000\377\000\000\000\377\000\000\000\377" + + "\317\317\317\377\037\037\037\377\003\003\003\377\053\053\053\377" + + "\154\154\154\377\306\306\306\377\372\374\375\377\236\277\332\377" + + "\167\245\314\377\114\211\274\377\174\250\316\377\377\377\377\377" + + "\033\033\033\377\000\000\000\377\000\000\000\377\027\027\027\377" + + "\326\326\326\377\001\001\001\377\000\000\000\377\000\000\000\377" + + "\000\000\000\377\122\122\122\377\345\345\345\377\075\075\075\377" + + "\150\150\150\377\246\246\247\377\332\336\341\377\377\377\377\377" + + "\164\164\164\377\016\016\016\377\000\000\000\377\131\131\131\377" + + "\225\225\225\377\000\000\000\377\000\000\000\377\000\000\000\377" + + "\000\000\000\377\221\221\221\377\233\233\233\377\000\000\000\377" + + "\000\000\000\377\000\000\000\377\002\002\002\377\103\103\103\377" + + "\377\377\377\377\356\356\356\377\214\214\214\377\277\277\277\377" + + "\126\126\126\377\000\000\000\377\000\000\000\377\000\000\000\377" + + "\000\000\000\377\323\323\323\377\130\130\130\377\000\000\000\377" + + "\000\000\000\377\000\000\000\377\000\000\000\377\063\063\063\377" + + "\377\377\377\377\377\377\377\377\374\375\376\377\377\377\377\377" + + "\300\300\300\377\100\100\100\377\002\002\002\377\000\000\000\377" + + "\033\033\033\377\373\373\373\377\027\027\027\377\000\000\000\377" + + "\000\000\000\377\000\000\000\377\000\000\000\377\170\170\170\377" + + "\377\377\377\377\377\377\377\377\322\341\356\377\176\251\316\377" + + "\340\352\363\377\377\377\377\377\324\324\324\377\155\155\155\377" + + "\204\204\204\377\323\323\323\377\000\000\000\377\000\000\000\377" + + "\000\000\000\377\000\000\000\377\000\000\000\377\275\275\275\377" + + "\377\377\377\377\377\377\377\377\376\376\376\377\146\232\305\377" + + "\075\177\266\377\202\254\320\377\344\355\365\377\377\377\377\377" + + "\377\377\377\377\345\345\345\377\055\055\055\377\000\000\000\377" + + "\000\000\000\377\000\000\000\377\014\014\014\377\366\366\366\377" + + "\377\377\377\377\377\377\377\377\377\377\377\377\342\354\364\377" + + "\115\211\274\377\072\175\265\377\076\200\266\377\207\260\322\377" + + "\347\357\366\377\377\377\377\377\376\376\376\377\274\274\274\377" + + "\117\117\117\377\003\003\003\377\112\112\112\377\377\377\377\377" + + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + + "\353\362\370\377\214\263\324\377\126\220\300\377\120\214\275\377" + + "\167\245\314\377\355\363\370\377\377\377\377\377\377\377\377\377" + + "\377\377\377\377\337\337\337\377\346\346\346\377\377\377\377\377"; + + private static final String LWJGL_ICON_DATA_32x32 = "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\372\374\375\377" + + "\313\335\354\377\223\267\326\377\157\240\311\377\134\223\302\377\140\226\303\377\172\247\315\377\254\310\340\377\355\363\370\377" + + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\374\375\376\377\265\316\343\377\132\222\301\377" + + "\072\175\265\377\072\175\265\377\072\175\265\377\072\175\265\377\072\175\265\377\072\175\265\377\072\175\265\377\105\205\271\377" + + "\241\301\334\377\374\375\376\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\374\374\374\377\342\352\361\377\270\317\343\377\256\311\340\377" + + "\243\302\334\377\230\272\330\377\214\263\323\377\201\254\317\377\156\237\310\377\075\177\266\377\072\175\265\377\072\175\265\377" + + "\072\175\265\377\162\242\312\377\365\370\373\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + + "\377\377\377\377\377\377\377\377\377\377\377\377\330\330\330\377\061\061\061\377\044\044\044\377\061\061\061\377\100\100\100\377" + + "\122\122\122\377\145\145\145\377\164\164\164\377\217\217\217\377\367\370\370\377\254\310\337\377\073\175\265\377\072\175\265\377" + + "\072\175\265\377\072\175\265\377\171\247\315\377\374\375\376\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + + "\377\377\377\377\377\377\377\377\376\376\376\377\150\150\150\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377" + + "\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\266\266\266\377\376\376\376\377\206\256\321\377\072\175\265\377" + + "\072\175\265\377\072\175\265\377\072\175\265\377\256\312\341\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + + "\377\377\377\377\323\342\356\377\341\352\362\377\050\050\050\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377" + + "\000\000\000\377\000\000\000\377\000\000\000\377\002\002\002\377\336\336\336\377\377\377\377\377\365\370\373\377\133\222\301\377" + + "\072\175\265\377\072\175\265\377\072\175\265\377\110\206\272\377\364\370\373\377\377\377\377\377\377\377\377\377\377\377\377\377" + + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + + "\354\363\370\377\144\231\305\377\327\331\333\377\005\005\005\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377" + + "\000\000\000\377\000\000\000\377\000\000\000\377\044\044\044\377\376\376\376\377\377\377\377\377\377\377\377\377\300\325\347\377" + + "\071\174\265\377\072\175\265\377\072\175\265\377\072\175\265\377\253\310\340\377\377\377\377\377\377\377\377\377\377\377\377\377" + + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\376\377\377\377" + + "\170\246\314\377\173\247\315\377\236\236\236\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377" + + "\000\000\000\377\000\000\000\377\000\000\000\377\145\145\145\377\377\377\377\377\377\377\377\377\377\377\377\377\342\354\364\377" + + "\067\173\264\377\072\175\265\377\072\175\265\377\072\175\265\377\146\232\305\377\377\377\377\377\377\377\377\377\377\377\377\377" + + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\303\327\350\377" + + "\071\175\265\377\262\314\341\377\130\130\130\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377" + + "\000\000\000\377\000\000\000\377\000\000\000\377\251\251\251\377\377\377\377\377\377\377\377\377\377\377\377\377\274\322\345\377" + + "\072\175\265\377\072\175\265\377\072\175\265\377\072\175\265\377\100\201\267\377\356\364\371\377\377\377\377\377\377\377\377\377" + + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\372\374\375\377\132\222\301\377" + + "\075\177\266\377\335\345\355\377\034\034\034\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377" + + "\000\000\000\377\000\000\000\377\007\007\007\377\347\347\347\377\377\377\377\377\377\377\377\377\377\377\377\377\205\256\321\377" + + "\072\175\265\377\072\175\265\377\072\175\265\377\072\175\265\377\071\175\265\377\314\336\354\377\377\377\377\377\377\377\377\377" + + "\377\377\377\377\377\377\377\377\376\376\376\377\377\377\377\377\377\377\377\377\377\377\377\377\272\322\345\377\072\175\265\377" + + "\127\220\277\377\320\321\321\377\003\003\003\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377" + + "\000\000\000\377\000\000\000\377\063\063\063\377\375\375\375\377\377\377\377\377\377\377\377\377\373\374\375\377\120\213\275\377" + + "\072\175\265\377\072\175\265\377\072\175\265\377\072\175\265\377\071\175\265\377\261\314\342\377\377\377\377\377\377\377\377\377" + + "\377\377\377\377\312\312\312\377\067\067\067\377\141\141\141\377\242\242\242\377\335\335\335\377\344\354\363\377\261\313\341\377" + + "\264\315\342\377\346\346\346\377\043\043\043\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377" + + "\000\000\000\377\000\000\000\377\162\162\162\377\377\377\377\377\377\377\377\377\377\377\377\377\330\345\360\377\072\175\265\377" + + "\072\175\265\377\072\175\265\377\072\175\265\377\072\175\265\377\072\175\265\377\240\300\333\377\377\377\377\377\377\377\377\377" + + "\377\377\377\377\146\146\146\377\000\000\000\377\000\000\000\377\000\000\000\377\006\006\006\377\047\047\047\377\146\146\146\377" + + "\324\324\324\377\377\377\377\377\366\366\366\377\320\320\320\377\227\227\227\377\136\136\136\377\047\047\047\377\004\004\004\377" + + "\000\000\000\377\003\003\003\377\300\300\300\377\377\377\377\377\377\377\377\377\377\377\377\377\242\301\333\377\072\175\265\377" + + "\072\175\265\377\072\175\265\377\072\175\265\377\072\175\265\377\072\175\265\377\236\277\332\377\377\377\377\377\377\377\377\377" + + "\373\373\373\377\045\045\045\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377" + + "\134\134\134\377\377\377\377\377\352\352\352\377\217\217\217\377\265\265\265\377\351\351\351\377\375\375\375\377\347\347\347\377" + + "\262\262\262\377\275\275\275\377\376\376\376\377\377\377\377\377\377\377\377\377\377\377\377\377\153\235\307\377\072\175\265\377" + + "\072\175\265\377\072\175\265\377\072\175\265\377\072\175\265\377\072\175\265\377\241\301\334\377\377\377\377\377\377\377\377\377" + + "\333\333\333\377\003\003\003\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377" + + "\203\203\203\377\377\377\377\377\137\137\137\377\000\000\000\377\000\000\000\377\013\013\013\377\067\067\067\377\166\166\166\377" + + "\267\267\267\377\360\360\360\377\377\377\377\377\377\377\377\377\377\377\377\377\360\365\371\377\113\210\273\377\075\177\266\377" + + "\071\174\265\377\072\175\265\377\072\175\265\377\072\175\265\377\072\175\265\377\262\314\342\377\377\377\377\377\377\377\377\377" + + "\232\232\232\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377" + + "\305\305\305\377\367\367\367\377\035\035\035\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377" + + "\000\000\000\377\007\007\007\377\074\074\074\377\337\337\337\377\377\377\377\377\373\374\375\377\374\375\376\377\363\367\372\377" + + "\314\335\353\377\236\276\332\377\162\241\311\377\114\211\273\377\072\175\265\377\311\334\353\377\377\377\377\377\377\377\377\377" + + "\126\126\126\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\017\017\017\377" + + "\371\371\371\377\321\321\321\377\003\003\003\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377" + + "\000\000\000\377\000\000\000\377\000\000\000\377\216\216\216\377\377\377\377\377\371\371\371\377\204\204\204\377\160\160\160\377" + + "\260\260\260\377\352\352\352\377\377\377\377\377\371\373\374\377\334\350\362\377\366\371\374\377\377\377\377\377\377\377\377\377" + + "\025\025\025\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\116\116\116\377" + + "\377\377\377\377\221\221\221\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377" + + "\000\000\000\377\000\000\000\377\000\000\000\377\273\273\273\377\377\377\377\377\236\236\236\377\000\000\000\377\000\000\000\377" + + "\000\000\000\377\004\004\004\377\057\057\057\377\160\160\160\377\260\260\260\377\346\346\346\377\376\376\376\377\377\377\377\377" + + "\071\071\071\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\220\220\220\377" + + "\377\377\377\377\115\115\115\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377" + + "\000\000\000\377\000\000\000\377\020\020\020\377\360\360\360\377\377\377\377\377\132\132\132\377\000\000\000\377\000\000\000\377" + + "\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\011\011\011\377\062\062\062\377\261\261\261\377" + + "\366\366\366\377\241\241\241\377\065\065\065\377\002\002\002\377\000\000\000\377\000\000\000\377\002\002\002\377\321\321\321\377" + + "\365\365\365\377\023\023\023\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377" + + "\000\000\000\377\000\000\000\377\105\105\105\377\376\376\376\377\370\370\370\377\035\035\035\377\000\000\000\377\000\000\000\377" + + "\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\053\053\053\377" + + "\377\377\377\377\377\377\377\377\374\374\374\377\276\276\276\377\120\120\120\377\005\005\005\377\045\045\045\377\371\371\371\377" + + "\302\302\302\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377" + + "\000\000\000\377\000\000\000\377\206\206\206\377\377\377\377\377\322\322\322\377\001\001\001\377\000\000\000\377\000\000\000\377" + + "\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\103\103\103\377" + + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\376\376\376\377\334\334\334\377\340\340\340\377\377\377\377\377" + + "\225\225\225\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377" + + "\000\000\000\377\001\001\001\377\310\310\310\377\377\377\377\377\216\216\216\377\000\000\000\377\000\000\000\377\000\000\000\377" + + "\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\210\210\210\377" + + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + + "\337\337\337\377\051\051\051\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377" + + "\000\000\000\377\030\030\030\377\365\365\365\377\377\377\377\377\112\112\112\377\000\000\000\377\000\000\000\377\000\000\000\377" + + "\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\317\317\317\377" + + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\361\366\372\377\377\377\377\377\377\377\377\377" + + "\377\377\377\377\371\371\371\377\265\265\265\377\113\113\113\377\006\006\006\377\000\000\000\377\000\000\000\377\000\000\000\377" + + "\000\000\000\377\122\122\122\377\377\377\377\377\370\370\370\377\020\020\020\377\000\000\000\377\000\000\000\377\000\000\000\377" + + "\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\034\034\034\377\370\370\370\377" + + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\206\257\321\377\220\265\325\377\352\361\367\377" + + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\333\333\333\377\170\170\170\377\033\033\033\377\000\000\000\377" + + "\000\000\000\377\226\226\226\377\377\377\377\377\306\306\306\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377" + + "\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\132\132\132\377\377\377\377\377" + + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\303\330\351\377\072\175\265\377\103\203\270\377" + + "\224\270\326\377\355\363\370\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\364\364\364\377\247\247\247\377" + + "\205\205\205\377\364\364\364\377\377\377\377\377\206\206\206\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377" + + "\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\235\235\235\377\377\377\377\377" + + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\372\373\375\377\135\224\302\377\072\175\265\377" + + "\072\175\265\377\106\205\271\377\230\273\330\377\357\364\371\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + + "\377\377\377\377\377\377\377\377\377\377\377\377\233\233\233\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377" + + "\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\005\005\005\377\335\335\335\377\377\377\377\377" + + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\305\331\351\377\073\176\266\377" + + "\072\175\265\377\072\175\265\377\072\175\265\377\110\206\272\377\236\276\332\377\362\366\372\377\377\377\377\377\377\377\377\377" + + "\377\377\377\377\377\377\377\377\377\377\377\377\373\373\373\377\216\216\216\377\045\045\045\377\001\001\001\377\000\000\000\377" + + "\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\054\054\054\377\374\374\374\377\377\377\377\377" + + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\217\265\325\377" + + "\072\175\265\377\072\175\265\377\072\175\265\377\072\175\265\377\072\175\265\377\112\207\273\377\243\302\334\377\363\367\372\377" + + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\372\372\372\377\260\260\260\377\105\105\105\377" + + "\004\004\004\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\156\156\156\377\377\377\377\377\377\377\377\377" + + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\374\375\376\377" + + "\205\257\321\377\072\175\265\377\072\175\265\377\072\175\265\377\072\175\265\377\072\175\265\377\072\175\265\377\115\211\274\377" + + "\250\305\336\377\366\371\374\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\376\376\376\377" + + "\322\322\322\377\150\150\150\377\016\016\016\377\000\000\000\377\001\001\001\377\270\270\270\377\377\377\377\377\377\377\377\377" + + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + + "\376\376\377\377\261\313\342\377\114\211\274\377\071\175\265\377\072\175\265\377\072\175\265\377\072\175\265\377\072\175\265\377" + + "\072\175\265\377\115\211\274\377\277\324\347\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + + "\377\377\377\377\377\377\377\377\354\354\354\377\223\223\223\377\233\233\233\377\375\375\375\377\377\377\377\377\377\377\377\377" + + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + + "\377\377\377\377\377\377\377\377\363\367\372\377\265\316\343\377\201\254\320\377\145\231\305\377\141\227\304\377\154\236\310\377" + + "\217\265\325\377\305\331\351\377\367\372\374\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"; + + /** LWJGL Logo - 16 by 16 pixels */ + public static final ByteBuffer LWJGLIcon16x16 = loadIcon(LWJGL_ICON_DATA_16x16); + + /** LWJGL Logo - 32 by 32 pixels */ + public static final ByteBuffer LWJGLIcon32x32 = loadIcon(LWJGL_ICON_DATA_32x32); + + /** Debug flag. */ + public static final boolean DEBUG = getPrivilegedBoolean("org.lwjgl.util.Debug"); + + public static final boolean CHECKS = !getPrivilegedBoolean("org.lwjgl.util.NoChecks"); + + private static final int PLATFORM; + + static { + final String osName = getPrivilegedProperty("os.name"); + if (osName.startsWith("Windows")) + PLATFORM = PLATFORM_WINDOWS; + else if (osName.startsWith("Linux") || osName.startsWith("FreeBSD") || osName.startsWith("SunOS") + || osName.startsWith("Unix") || osName.startsWith("Android")) + PLATFORM = PLATFORM_LINUX; + else if (osName.startsWith("Mac OS X") || osName.startsWith("Darwin")) + PLATFORM = PLATFORM_MACOSX; + else + throw new LinkageError("Unknown platform: " + osName); + } + + private static ByteBuffer loadIcon(String data) { + int len = data.length(); + ByteBuffer bb = BufferUtils.createByteBuffer(len); + for (int i = 0; i < len; i++) { + bb.put(i, (byte) data.charAt(i)); + } + return bb.asReadOnlyBuffer(); + } + + /** + * @see #PLATFORM_WINDOWS + * @see #PLATFORM_LINUX + * @see #PLATFORM_MACOSX + * @return the current platform type + */ + public static int getPlatform() { + return PLATFORM; + } + + /** + * @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 (String platform_lib_name : platform_lib_names) { + 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 + return possible_paths.toArray(new String[possible_paths.size()]); + } + + static void execPrivileged(final String[] cmd_array) throws Exception { + try { + Process process = AccessController.doPrivileged(new PrivilegedExceptionAction() { + public Process 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 AccessController.doPrivileged(new PrivilegedAction() { + public String 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 AccessController.doPrivileged(new PrivilegedExceptionAction() { + public String run() throws Exception { + Method findLibrary = clazz.getDeclaredMethod("findLibrary", String.class); + findLibrary.setAccessible(true); + String path = (String) findLibrary.invoke(classloader, libname); + 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. + */ + public static boolean getPrivilegedBoolean(final String property_name) { + return AccessController.doPrivileged(new PrivilegedAction() { + public Boolean run() { + return Boolean.getBoolean(property_name); + } + }); + } + + /** + * Gets an integer property as a privileged action. + * + * @param property_name + * the integer property name + * + * @return the property value + */ + public static Integer getPrivilegedInteger(final String property_name) { + return AccessController.doPrivileged(new PrivilegedAction() { + public Integer run() { + return Integer.getInteger(property_name); + } + }); + } + + /** + * Gets an integer property as a privileged action. + * + * @param property_name + * the integer property name + * @param default_val + * the default value to use if the property is not defined + * + * @return the property value + */ + public static Integer getPrivilegedInteger(final String property_name, final int default_val) { + return AccessController.doPrivileged(new PrivilegedAction() { + public Integer run() { + return Integer.getInteger(property_name, default_val); + } + }); + } + + /** + * Prints the given message to System.err if DEBUG is true. + * + * @param msg + * Message to print + */ + public static void log(CharSequence msg) { + if (DEBUG) { + System.err.println("[LWJGL] " + 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); + } + + /** + * Returns a map of public static final integer fields in the specified + * classes, to their String representations. An optional filter can be + * specified to only include specific fields. The target map may be null, in + * which case a new map is allocated and returned. + *

+ * This method is useful when debugging to quickly identify values returned + * from the AL/GL/CL APIs. + * + * @param filter + * the filter to use (optional) + * @param target + * the target map (optional) + * @param tokenClasses + * an array of classes to get tokens from + * + * @return the token map + */ + + public static Map getClassTokens(final TokenFilter filter, final Map target, + final Class... tokenClasses) { + return getClassTokens(filter, target, Arrays.asList(tokenClasses)); + } + + /** + * Returns a map of public static final integer fields in the specified + * classes, to their String representations. An optional filter can be + * specified to only include specific fields. The target map may be null, in + * which case a new map is allocated and returned. + *

+ * This method is useful when debugging to quickly identify values returned + * from the AL/GL/CL APIs. + * + * @param filter + * the filter to use (optional) + * @param target + * the target map (optional) + * @param tokenClasses + * the classes to get tokens from + * + * @return the token map + */ + public static Map getClassTokens(final TokenFilter filter, Map target, + final Iterable tokenClasses) { + if (target == null) + target = new HashMap(); + + final int TOKEN_MODIFIERS = Modifier.PUBLIC | Modifier.STATIC | Modifier.FINAL; + + for (final Class tokenClass : tokenClasses) { + for (final Field field : tokenClass.getDeclaredFields()) { + // Get only fields. + if ((field.getModifiers() & TOKEN_MODIFIERS) == TOKEN_MODIFIERS && field.getType() == int.class) { + try { + final int value = field.getInt(null); + if (filter != null && !filter.accept(field, value)) + continue; + + if (target.containsKey(value)) // Print colliding tokens + // in their hex + // representation. + target.put(value, toHexString(value)); + else + target.put(value, field.getName()); + } catch (IllegalAccessException e) { + // Ignore + } + } + } + } + + return target; + } + + /** + * Returns a string representation of the integer argument as an unsigned + * integer in base 16. The string will be uppercase and will have a + * leading '0x'. + * + * @param value + * the integer value + * + * @return the hex string representation + */ + public static String toHexString(final int value) { + return "0x" + Integer.toHexString(value).toUpperCase(); + } + + /** Simple interface for Field filtering. */ + public interface TokenFilter { + + /** + * Should return true if the specified Field passes the filter. + * + * @param field + * the Field to test + * @param value + * the integer value of the field + * + * @result true if the Field is accepted + */ + boolean accept(Field field, int value); + + } + +} diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/MemoryUtil.java.z b/jre_lwjgl3glfw/src/main/java/org/lwjgl/MemoryUtil.java.z new file mode 100644 index 000000000..9dd389abf --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/MemoryUtil.java.z @@ -0,0 +1,430 @@ +/* + * Copyright (c) 2002-2011 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR 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.lang.reflect.Field; +import java.nio.*; +import java.nio.charset.*; + +/** + * [INTERNAL USE ONLY] + *

+ * This class provides utility methods for passing buffers to JNI API calls. + * + * @author Spasi + */ +public final class MemoryUtil { + + private static final Charset ascii; + private static final Charset utf8; + private static final Charset utf16; + + static { + ascii = Charset.forName("ISO-8859-1"); + utf8 = Charset.forName("UTF-8"); + utf16 = Charset.forName("UTF-16LE"); + } + + private static final Accessor memUtil; + + static { + Accessor util; + try { + // Depends on java.nio.Buffer#address and sun.misc.Unsafe + util = loadAccessor("org.lwjgl.MemoryUtilSun$AccessorUnsafe"); + } catch (Exception e0) { + try { + // Depends on java.nio.Buffer#address and sun.reflect.FieldAccessor + util = loadAccessor("org.lwjgl.MemoryUtilSun$AccessorReflectFast"); + } catch (Exception e1) { + try { + // Depends on java.nio.Buffer#address + util = new AccessorReflect(); + } catch (Exception e2) { + LWJGLUtil.log("Unsupported JVM detected, this will likely result in low performance. Please inform LWJGL developers."); + util = new AccessorJNI(); + } + } + } + + LWJGLUtil.log("MemoryUtil Accessor: " + util.getClass().getSimpleName()); + memUtil = util; + + /* + BENCHMARK RESULTS - Oracle Server VM: + + Unsafe: 4ns + ReflectFast: 8ns + Reflect: 10ns + JNI: 82ns + + BENCHMARK RESULTS - Oracle Client VM: + + Unsafe: 5ns + ReflectFast: 81ns + Reflect: 85ns + JNI: 87ns + + On non-Oracle VMs, Unsafe should be the fastest implementation as well. In the absence + of Unsafe, performance will depend on how reflection and JNI are implemented. For now + we'll go with what we see on the Oracle VM (that is, we'll prefer reflection over JNI). + */ + } + + private MemoryUtil() { + } + + /** + * Returns the memory address of the specified buffer. [INTERNAL USE ONLY] + * + * @param buffer the buffer + * + * @return the memory address + */ + public static long getAddress0(Buffer buffer) { return memUtil.getAddress(buffer); } + + public static long getAddress0Safe(Buffer buffer) { return buffer == null ? 0L : memUtil.getAddress(buffer); } + + public static long getAddress0(PointerBuffer buffer) { return memUtil.getAddress(buffer.getBuffer()); } + + public static long getAddress0Safe(PointerBuffer buffer) { return buffer == null ? 0L : memUtil.getAddress(buffer.getBuffer()); } + + // --- [ API utilities ] --- + + public static long getAddress(ByteBuffer buffer) { return getAddress(buffer, buffer.position()); } + + public static long getAddress(ByteBuffer buffer, int position) { return getAddress0(buffer) + position; } + + public static long getAddress(ShortBuffer buffer) { return getAddress(buffer, buffer.position()); } + + public static long getAddress(ShortBuffer buffer, int position) { return getAddress0(buffer) + (position << 1); } + + public static long getAddress(CharBuffer buffer) { return getAddress(buffer, buffer.position()); } + + public static long getAddress(CharBuffer buffer, int position) { return getAddress0(buffer) + (position << 1); } + + public static long getAddress(IntBuffer buffer) { return getAddress(buffer, buffer.position()); } + + public static long getAddress(IntBuffer buffer, int position) { return getAddress0(buffer) + (position << 2); } + + public static long getAddress(FloatBuffer buffer) { return getAddress(buffer, buffer.position()); } + + public static long getAddress(FloatBuffer buffer, int position) { return getAddress0(buffer) + (position << 2); } + + public static long getAddress(LongBuffer buffer) { return getAddress(buffer, buffer.position()); } + + public static long getAddress(LongBuffer buffer, int position) { return getAddress0(buffer) + (position << 3); } + + public static long getAddress(DoubleBuffer buffer) { return getAddress(buffer, buffer.position()); } + + public static long getAddress(DoubleBuffer buffer, int position) { return getAddress0(buffer) + (position << 3); } + + public static long getAddress(PointerBuffer buffer) { return getAddress(buffer, buffer.position()); } + + public static long getAddress(PointerBuffer buffer, int position) { return getAddress0(buffer) + (position * PointerBuffer.getPointerSize()); } + + // --- [ API utilities - Safe ] --- + + public static long getAddressSafe(ByteBuffer buffer) { return buffer == null ? 0L : getAddress(buffer); } + + public static long getAddressSafe(ByteBuffer buffer, int position) { return buffer == null ? 0L : getAddress(buffer, position); } + + public static long getAddressSafe(ShortBuffer buffer) { return buffer == null ? 0L : getAddress(buffer); } + + public static long getAddressSafe(ShortBuffer buffer, int position) { return buffer == null ? 0L : getAddress(buffer, position); } + + public static long getAddressSafe(CharBuffer buffer) { return buffer == null ? 0L : getAddress(buffer); } + + public static long getAddressSafe(CharBuffer buffer, int position) { return buffer == null ? 0L : getAddress(buffer, position); } + + public static long getAddressSafe(IntBuffer buffer) { return buffer == null ? 0L : getAddress(buffer); } + + public static long getAddressSafe(IntBuffer buffer, int position) { return buffer == null ? 0L : getAddress(buffer, position); } + + public static long getAddressSafe(FloatBuffer buffer) { return buffer == null ? 0L : getAddress(buffer); } + + public static long getAddressSafe(FloatBuffer buffer, int position) { return buffer == null ? 0L : getAddress(buffer, position); } + + public static long getAddressSafe(LongBuffer buffer) { return buffer == null ? 0L : getAddress(buffer); } + + public static long getAddressSafe(LongBuffer buffer, int position) { return buffer == null ? 0L : getAddress(buffer, position); } + + public static long getAddressSafe(DoubleBuffer buffer) { return buffer == null ? 0L : getAddress(buffer); } + + public static long getAddressSafe(DoubleBuffer buffer, int position) { return buffer == null ? 0L : getAddress(buffer, position); } + + public static long getAddressSafe(PointerBuffer buffer) { return buffer == null ? 0L : getAddress(buffer); } + + public static long getAddressSafe(PointerBuffer buffer, int position) { return buffer == null ? 0L : getAddress(buffer, position); } + + // --- [ String utilities ] --- + + /** + * Returns a ByteBuffer containing the specified text ASCII encoded and null-terminated. + * If text is null, null is returned. + * + * @param text the text to encode + * + * @return the encoded text or null + * + * @see String#getBytes() + */ + public static ByteBuffer encodeASCII(final CharSequence text) { + return encode(text, ascii); + } + + /** + * Returns a ByteBuffer containing the specified text UTF-8 encoded and null-terminated. + * If text is null, null is returned. + * + * @param text the text to encode + * + * @return the encoded text or null + * + * @see String#getBytes() + */ + public static ByteBuffer encodeUTF8(final CharSequence text) { + return encode(text, utf8); + } + + /** + * Returns a ByteBuffer containing the specified text UTF-16LE encoded and null-terminated. + * If text is null, null is returned. + * + * @param text the text to encode + * + * @return the encoded text + */ + public static ByteBuffer encodeUTF16(final CharSequence text) { + return encode(text, utf16); + } + + /** + * Wraps the specified text in a null-terminated CharBuffer and encodes it using the specified Charset. + * + * @param text the text to encode + * @param charset the charset to use for encoding + * + * @return the encoded text + */ + private static ByteBuffer encode(final CharSequence text, final Charset charset) { + if ( text == null ) + return null; + + return encode(CharBuffer.wrap(new CharSequenceNT(text)), charset); + } + + /** + * A {@link CharsetEncoder#encode(java.nio.CharBuffer)} implementation that uses {@link BufferUtils#createByteBuffer(int)} + * instead of {@link ByteBuffer#allocate(int)}. + * + * @see CharsetEncoder#encode(java.nio.CharBuffer) + */ + private static ByteBuffer encode(final CharBuffer in, final Charset charset) { + final CharsetEncoder encoder = charset.newEncoder(); // encoders are not thread-safe, create a new one on every call + + int n = (int)(in.remaining() * encoder.averageBytesPerChar()); + ByteBuffer out = BufferUtils.createByteBuffer(n); + + if ( n == 0 && in.remaining() == 0 ) + return out; + + encoder.reset(); + while ( true ) { + CoderResult cr = in.hasRemaining() ? encoder.encode(in, out, true) : CoderResult.UNDERFLOW; + if ( cr.isUnderflow() ) + cr = encoder.flush(out); + + if ( cr.isUnderflow() ) + break; + + if ( cr.isOverflow() ) { + n = 2 * n + 1; // Ensure progress; n might be 0! + ByteBuffer o = BufferUtils.createByteBuffer(n); + out.flip(); + o.put(out); + out = o; + continue; + } + + try { + cr.throwException(); + } catch (CharacterCodingException e) { + throw new RuntimeException(e); + } + } + out.flip(); + return out; + } + + public static String decodeASCII(final ByteBuffer buffer) { + return decode(buffer, ascii); + } + + public static String decodeUTF8(final ByteBuffer buffer) { + return decode(buffer, utf8); + } + + public static String decodeUTF16(final ByteBuffer buffer) { + return decode(buffer, utf16); + } + + private static String decode(final ByteBuffer buffer, final Charset charset) { + if ( buffer == null ) + return null; + + return decodeImpl(buffer, charset); + } + + private static String decodeImpl(final ByteBuffer in, final Charset charset) { + final CharsetDecoder decoder = charset.newDecoder(); // decoders are not thread-safe, create a new one on every call + + int n = (int)(in.remaining() * decoder.averageCharsPerByte()); + CharBuffer out = BufferUtils.createCharBuffer(n); + + if ( (n == 0) && (in.remaining() == 0) ) + return ""; + + decoder.reset(); + for (; ; ) { + CoderResult cr = in.hasRemaining() ? decoder.decode(in, out, true) : CoderResult.UNDERFLOW; + if ( cr.isUnderflow() ) + cr = decoder.flush(out); + + if ( cr.isUnderflow() ) + break; + if ( cr.isOverflow() ) { + n = 2 * n + 1; // Ensure progress; n might be 0! + CharBuffer o = BufferUtils.createCharBuffer(n); + out.flip(); + o.put(out); + out = o; + continue; + } + try { + cr.throwException(); + } catch (CharacterCodingException e) { + throw new RuntimeException(e); + } + } + out.flip(); + return out.toString(); + } + + /** A null-terminated CharSequence. */ + private static class CharSequenceNT implements CharSequence { + + final CharSequence source; + + CharSequenceNT(CharSequence source) { + this.source = source; + } + + public int length() { + return source.length() + 1; + + } + + public char charAt(final int index) { + return index == source.length() ? '\0' : source.charAt(index); + + } + + public CharSequence subSequence(final int start, final int end) { + return new CharSequenceNT(source.subSequence(start, Math.min(end, source.length()))); + } + + } + + interface Accessor { + + long getAddress(Buffer buffer); + + } + + private static Accessor loadAccessor(final String className) throws Exception { + return (Accessor)Class.forName(className).newInstance(); + } + + /** Default implementation. */ + private static class AccessorJNI implements Accessor { + + public long getAddress(final Buffer buffer) { + return BufferUtils.getBufferAddress(buffer); + } + + } + + /** Implementation using reflection on ByteBuffer. */ + private static class AccessorReflect implements Accessor { + + private final Field address; + + AccessorReflect() { + try { + address = getAddressField(); + } catch (NoSuchFieldException e) { + throw new UnsupportedOperationException(e); + } + address.setAccessible(true); + } + + public long getAddress(final Buffer buffer) { + try { + return address.getLong(buffer); + } catch (IllegalAccessException e) { + // cannot happen + return 0L; + } + } + + } + + static Field getAddressField() throws NoSuchFieldException { + return getDeclaredFieldRecursive(ByteBuffer.class, "address"); + } + + private static Field getDeclaredFieldRecursive(final Class root, final String fieldName) throws NoSuchFieldException { + Class type = root; + + do { + try { + return type.getDeclaredField(fieldName); + } catch (NoSuchFieldException e) { + type = type.getSuperclass(); + } + } while ( type != null ); + + throw new NoSuchFieldException(fieldName + " does not exist in " + root.getSimpleName() + " or any of its superclasses."); + } + +} diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/PointerBuffer.java.z b/jre_lwjgl3glfw/src/main/java/org/lwjgl/PointerBuffer.java.z new file mode 100644 index 000000000..990185312 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/PointerBuffer.java.z @@ -0,0 +1,807 @@ +/* + * Copyright LWJGL. All rights reserved. + * License terms: https://www.lwjgl.org/license + */ +package org.lwjgl; + +import org.lwjgl.system.*; + +import javax.annotation.*; +import java.nio.*; + +import static org.lwjgl.system.CheckIntrinsics.*; +import static org.lwjgl.system.Checks.*; +import static org.lwjgl.system.MemoryUtil.*; + +/** This class is a container for architecture-independent pointer data. Its interface mirrors the {@link LongBuffer} API for convenience. */ +public class PointerBuffer extends CustomBuffer implements Comparable { +// -- Begin LWJGL2 parts -- + public PointerBuffer(final int capacity) { + this(allocateDirect(capacity)); + } + + public PointerBuffer(final ByteBuffer source) { + this(create(source)); + } + + // Workaround for LWJGL2 bridge + protected PointerBuffer(PointerBuffer copy) { + this(copy.address0(), copy.container, copy.mark, copy.position, copy.limit, copy.capacity); + } + + /** + * Returns the ByteBuffer that backs this PointerBuffer. + * + * @return the pointer ByteBuffer + */ + public ByteBuffer getBuffer() { + return container; + } + + /** Returns true if the underlying architecture is 64bit. */ + public static boolean is64Bit() { + return POINTER_SIZE == 8; + } + + /** + * Returns the pointer size in bytes, based on the underlying architecture. + * + * @return The pointer size in bytes + */ + public static int getPointerSize() { + return POINTER_SIZE; + } + + /** + * Returns this buffer's position, in bytes.

+ * + * @return The position of this buffer in bytes. + */ + public final int positionByte() { + return position() * getPointerSize(); + } + + /** + * Returns the number of bytes between the current position and the + * limit.

+ * + * @return The number of bytes remaining in this buffer + */ + public final int remainingByte() { + return remaining() * getPointerSize(); + } + + /** + * Creates a new, read-only pointer buffer that shares this buffer's + * content. + *

+ *

The content of the new buffer will be that of this buffer. Changes + * to this buffer's content will be visible in the new buffer; the new + * buffer itself, however, will be read-only and will not allow the shared + * content to be modified. The two buffers' position, limit, and mark + * values will be independent. + *

+ *

The new buffer's capacity, limit and position will be + * identical to those of this buffer. + *

+ *

If this buffer is itself read-only then this method behaves in + * exactly the same way as the {@link #duplicate duplicate} method.

+ * + * @return The new, read-only pointer buffer + */ + public PointerBuffer asReadOnlyBuffer() { + final PointerBuffer buffer = new PointerBufferR(container); + + buffer.position(position()); + buffer.limit(limit()); + + return buffer; + } + + public boolean isReadOnly() { + return false; + } + + + /** + * Read-only version of PointerBuffer. + * + * @author Spasi + */ + private static final class PointerBufferR extends PointerBuffer { + + PointerBufferR(final ByteBuffer source) { + super(source); + } + + public boolean isReadOnly() { + return true; + } + + protected PointerBuffer newInstance(final ByteBuffer source) { + return new PointerBufferR(source); + } + + public PointerBuffer asReadOnlyBuffer() { + return duplicate(); + } + + public PointerBuffer put(final long l) { + throw new ReadOnlyBufferException(); + } + + public PointerBuffer put(final int index, final long l) { + throw new ReadOnlyBufferException(); + } + + public PointerBuffer put(final PointerBuffer src) { + throw new ReadOnlyBufferException(); + } + + public PointerBuffer put(final long[] src, final int offset, final int length) { + throw new ReadOnlyBufferException(); + } + + public PointerBuffer compact() { + throw new ReadOnlyBufferException(); + } + + } +// -- End LWJGL2 parts -- + + protected PointerBuffer(long address, @Nullable ByteBuffer container, int mark, int position, int limit, int capacity) { + super(address, container, mark, position, limit, capacity); + } + + /** + * Allocates a new pointer buffer. + * + *

The new buffer's position will be zero, its limit will be its capacity, and its mark will be undefined.

+ * + * @param capacity the new buffer's capacity, in pointers + * + * @return the new pointer buffer + * + * @throws IllegalArgumentException If the {@code capacity} is a negative integer + */ + public static PointerBuffer allocateDirect(int capacity) { + ByteBuffer source = BufferUtils.createByteBuffer(BufferUtils.getAllocationSize(capacity, POINTER_SHIFT)); + return wrap(PointerBuffer.class, memAddress(source), capacity, source); + } + + /** + * Creates a new PointerBuffer that starts at the specified memory address and has the specified capacity. + * + * @param address the starting memory address + * @param capacity the buffer capacity, in number of pointers + */ + public static PointerBuffer create(long address, int capacity) { + return wrap(PointerBuffer.class, address, capacity); + } + + /** + * Creates a new PointerBuffer using the specified ByteBuffer as its pointer data source. + * + * @param source the source buffer + */ + public static PointerBuffer create(ByteBuffer source) { + int capacity = source.remaining() >> POINTER_SHIFT; + return wrap(PointerBuffer.class, memAddress(source), capacity, source); + } + + @Override + protected PointerBuffer self() { + return this; + } + + @Override + public int sizeof() { + return POINTER_SIZE; + } + + /** + * Relative get method. Reads the pointer at this buffer's current position, and then increments the position. + * + * @return the pointer at the buffer's current position + * + * @throws BufferUnderflowException If the buffer's current position is not smaller than its limit + */ + public long get() { + return memGetAddress(address + Integer.toUnsignedLong(nextGetIndex()) * POINTER_SIZE); + } + + /** + * Convenience relative get from a source ByteBuffer. + * + * @param source the source ByteBuffer + */ + public static long get(ByteBuffer source) { + if (source.remaining() < POINTER_SIZE) { + throw new BufferUnderflowException(); + } + + try { + return memGetAddress(memAddress(source)); + } finally { + source.position(source.position() + POINTER_SIZE); + } + } + + /** + * Relative put method  (optional operation). + * + *

Writes the specified pointer into this buffer at the current position, and then increments the position.

+ * + * @param p the pointer to be written + * + * @return This buffer + * + * @throws BufferOverflowException If this buffer's current position is not smaller than its limit + */ + public PointerBuffer put(long p) { + memPutAddress(address + Integer.toUnsignedLong(nextPutIndex()) * POINTER_SIZE, p); + return this; + } + + /** + * Convenience relative put on a target ByteBuffer. + * + * @param target the target ByteBuffer + * @param p the pointer value to be written + */ + public static void put(ByteBuffer target, long p) { + if (target.remaining() < POINTER_SIZE) { + throw new BufferOverflowException(); + } + + try { + memPutAddress(memAddress(target), p); + } finally { + target.position(target.position() + POINTER_SIZE); + } + } + + /** + * Absolute get method. Reads the pointer at the specified {@code index}. + * + * @param index the index from which the pointer will be read + * + * @return the pointer at the specified {@code index} + * + * @throws IndexOutOfBoundsException If {@code index} is negative or not smaller than the buffer's limit + */ + public long get(int index) { + return memGetAddress(address + check(index, limit) * POINTER_SIZE); + } + + /** + * Convenience absolute get from a source ByteBuffer. + * + * @param source the source ByteBuffer + * @param index the index at which the pointer will be read + */ + public static long get(ByteBuffer source, int index) { + checkFromIndexSize(index, POINTER_SIZE, source.limit()); + return memGetAddress(memAddress0(source) + index); + } + + /** + * Absolute put method  (optional operation). + * + *

Writes the specified pointer into this buffer at the specified {@code index}.

+ * + * @param index the index at which the pointer will be written + * @param p the pointer value to be written + * + * @return This buffer + * + * @throws IndexOutOfBoundsException If {@code index} is negative or not smaller than the buffer's limit + */ + public PointerBuffer put(int index, long p) { + memPutAddress(address + check(index, limit) * POINTER_SIZE, p); + return this; + } + + /** + * Convenience absolute put on a target ByteBuffer. + * + * @param target the target ByteBuffer + * @param index the index at which the pointer will be written + * @param p the pointer value to be written + */ + public static void put(ByteBuffer target, int index, long p) { + checkFromIndexSize(index, POINTER_SIZE, target.limit()); + memPutAddress(memAddress0(target) + index, p); + } + + // -- PointerWrapper operations -- + + /** Puts the pointer value of the specified {@link Pointer} at the current position and then increments the position. */ + public PointerBuffer put(Pointer pointer) { + put(pointer.address()); + return this; + } + + /** Puts the pointer value of the specified {@link Pointer} at the specified {@code index}. */ + public PointerBuffer put(int index, Pointer pointer) { + put(index, pointer.address()); + return this; + } + + // -- Buffer address operations -- + + /** + *

Writes the address of the specified {@code buffer} into this buffer at the current position, and then increments the position.

+ * + * @param buffer the pointer to be written + * + * @return this buffer + * + * @throws BufferOverflowException If this buffer's current position is not smaller than its limit + */ + public PointerBuffer put(ByteBuffer buffer) { + put(memAddress(buffer)); + return this; + } + + /** + *

Writes the address of the specified {@code buffer} into this buffer at the current position, and then increments the position.

+ * + * @param buffer the pointer to be written + * + * @return this buffer + * + * @throws BufferOverflowException If this buffer's current position is not smaller than its limit + */ + public PointerBuffer put(ShortBuffer buffer) { + put(memAddress(buffer)); + return this; + } + + /** + *

Writes the address of the specified {@code buffer} into this buffer at the current position, and then increments the position.

+ * + * @param buffer the pointer to be written + * + * @return this buffer + * + * @throws BufferOverflowException If this buffer's current position is not smaller than its limit + */ + public PointerBuffer put(IntBuffer buffer) { + put(memAddress(buffer)); + return this; + } + + /** + *

Writes the address of the specified {@code buffer} into this buffer at the current position, and then increments the position.

+ * + * @param buffer the pointer to be written + * + * @return this buffer + * + * @throws BufferOverflowException If this buffer's current position is not smaller than its limit + */ + public PointerBuffer put(LongBuffer buffer) { + put(memAddress(buffer)); + return this; + } + + /** + *

Writes the address of the specified {@code buffer} into this buffer at the current position, and then increments the position.

+ * + * @param buffer the pointer to be written + * + * @return this buffer + * + * @throws BufferOverflowException If this buffer's current position is not smaller than its limit + */ + public PointerBuffer put(FloatBuffer buffer) { + put(memAddress(buffer)); + return this; + } + + /** + *

Writes the address of the specified {@code buffer} into this buffer at the current position, and then increments the position.

+ * + * @param buffer the pointer to be written + * + * @return this buffer + * + * @throws BufferOverflowException If this buffer's current position is not smaller than its limit + */ + public PointerBuffer put(DoubleBuffer buffer) { + put(memAddress(buffer)); + return this; + } + + /** + *

Writes the address of the specified {@code buffer} into this buffer at the current position, and then increments the position.

+ * + * @param buffer the pointer to be written + * + * @return this buffer + * + * @throws BufferOverflowException If this buffer's current position is not smaller than its limit + */ + public PointerBuffer putAddressOf(CustomBuffer buffer) { + put(memAddress(buffer)); + return this; + } + + // --- + + /** Puts the address of the specified {@code buffer} at the specified {@code index}. */ + public PointerBuffer put(int index, ByteBuffer buffer) { + put(index, memAddress(buffer)); + return this; + } + + /** Puts the address of the specified {@code buffer} at the specified {@code index}. */ + public PointerBuffer put(int index, ShortBuffer buffer) { + put(index, memAddress(buffer)); + return this; + } + + /** Puts the address of the specified {@code buffer} at the specified {@code index}. */ + public PointerBuffer put(int index, IntBuffer buffer) { + put(index, memAddress(buffer)); + return this; + } + + /** Puts the address of the specified {@code buffer} at the specified {@code index}. */ + public PointerBuffer put(int index, LongBuffer buffer) { + put(index, memAddress(buffer)); + return this; + } + + /** Puts the address of the specified {@code buffer} at the specified {@code index}. */ + public PointerBuffer put(int index, FloatBuffer buffer) { + put(index, memAddress(buffer)); + return this; + } + + /** Puts the address of the specified {@code buffer} at the specified {@code index}. */ + public PointerBuffer put(int index, DoubleBuffer buffer) { + put(index, memAddress(buffer)); + return this; + } + + /** Puts the address of the specified {@code buffer} at the specified {@code index}. */ + public PointerBuffer putAddressOf(int index, CustomBuffer buffer) { + put(index, memAddress(buffer)); + return this; + } + + // --- + + /** + * Reads the pointer at this buffer's current position, and then increments the position. The pointer is returned as a {@link ByteBuffer} instance that + * starts at the pointer address and has capacity equal to the specified {@code size}. + * + * @throws BufferUnderflowException If the buffer's current position is not smaller than its limit + */ + public ByteBuffer getByteBuffer(int size) { return memByteBuffer(get(), size); } + + /** + * Reads the pointer at this buffer's current position, and then increments the position. The pointer is returned as a {@link ShortBuffer} instance that + * starts at the pointer address and has capacity equal to the specified {@code size}. + * + * @throws BufferUnderflowException If the buffer's current position is not smaller than its limit + */ + public ShortBuffer getShortBuffer(int size) { return memShortBuffer(get(), size); } + + /** + * Reads the pointer at this buffer's current position, and then increments the position. The pointer is returned as a {@link IntBuffer} instance that + * starts at the pointer address and has capacity equal to the specified {@code size}. + * + * @throws BufferUnderflowException If the buffer's current position is not smaller than its limit + */ + public IntBuffer getIntBuffer(int size) { return memIntBuffer(get(), size); } + + /** + * Reads the pointer at this buffer's current position, and then increments the position. The pointer is returned as a {@link LongBuffer} instance that + * starts at the pointer address and has capacity equal to the specified {@code size}. + * + * @throws BufferUnderflowException If the buffer's current position is not smaller than its limit + */ + public LongBuffer getLongBuffer(int size) { return memLongBuffer(get(), size); } + + /** + * Reads the pointer at this buffer's current position, and then increments the position. The pointer is returned as a {@link FloatBuffer} instance that + * starts at the pointer address and has capacity equal to the specified {@code size}. + * + * @throws BufferUnderflowException If the buffer's current position is not smaller than its limit + */ + public FloatBuffer getFloatBuffer(int size) { return memFloatBuffer(get(), size); } + + /** + * Reads the pointer at this buffer's current position, and then increments the position. The pointer is returned as a {@link DoubleBuffer} instance that + * starts at the pointer address and has capacity equal to the specified {@code size}. + * + * @throws BufferUnderflowException If the buffer's current position is not smaller than its limit + */ + public DoubleBuffer getDoubleBuffer(int size) { return memDoubleBuffer(get(), size); } + + /** + * Reads the pointer at this buffer's current position, and then increments the position. The pointer is returned as a {@code PointerBuffer} instance that + * starts at the pointer address and has capacity equal to the specified {@code size}. + * + * @throws BufferUnderflowException If the buffer's current position is not smaller than its limit + */ + public PointerBuffer getPointerBuffer(int size) { return memPointerBuffer(get(), size); } + + /** + * Reads the pointer at this buffer's current position, and then increments the position. The pointer is evaluated as a null-terminated ASCII string, which + * is decoded and returned as a {@link String} instance. + * + * @throws BufferUnderflowException If the buffer's current position is not smaller than its limit + */ + public String getStringASCII() { return memASCII(get()); } + + /** + * Reads the pointer at this buffer's current position, and then increments the position. The pointer is evaluated as a null-terminated UTF-8 string, which + * is decoded and returned as a {@link String} instance. + * + * @throws BufferUnderflowException If the buffer's current position is not smaller than its limit + */ + public String getStringUTF8() { return memUTF8(get()); } + + /** + * Reads the pointer at this buffer's current position, and then increments the position. The pointer is evaluated as a null-terminated UTF-16 string, + * which is decoded and returned as a {@link String} instance. + * + * @throws BufferUnderflowException If the buffer's current position is not smaller than its limit + */ + public String getStringUTF16() { return memUTF16(get()); } + + // --- + + /** Returns a {@link ByteBuffer} instance that starts at the address found at the specified {@code index} and has capacity equal to the specified size. */ + public ByteBuffer getByteBuffer(int index, int size) { return memByteBuffer(get(index), size); } + + /** Returns a {@link ShortBuffer} instance that starts at the address found at the specified {@code index} and has capacity equal to the specified size. */ + public ShortBuffer getShortBuffer(int index, int size) { return memShortBuffer(get(index), size); } + + /** Returns a {@link IntBuffer} instance that starts at the address found at the specified {@code index} and has capacity equal to the specified size. */ + public IntBuffer getIntBuffer(int index, int size) { return memIntBuffer(get(index), size); } + + /** Returns a {@link LongBuffer} instance that starts at the address found at the specified {@code index} and has capacity equal to the specified size. */ + public LongBuffer getLongBuffer(int index, int size) { return memLongBuffer(get(index), size); } + + /** Returns a {@link FloatBuffer} instance that starts at the address found at the specified {@code index} and has capacity equal to the specified size. */ + public FloatBuffer getFloatBuffer(int index, int size) { return memFloatBuffer(get(index), size); } + + /** Returns a {@link DoubleBuffer} instance that starts at the address found at the specified {@code index} and has capacity equal to the specified size. */ + public DoubleBuffer getDoubleBuffer(int index, int size) { return memDoubleBuffer(get(index), size); } + + /** Returns a {@code PointerBuffer} instance that starts at the address found at the specified {@code index} and has capacity equal to the specified size. */ + public PointerBuffer getPointerBuffer(int index, int size) { return memPointerBuffer(get(index), size); } + + /** Decodes the ASCII string that starts at the address found at the specified {@code index}. */ + public String getStringASCII(int index) { return memASCII(get(index)); } + + /** Decodes the UTF-8 string that starts at the address found at the specified {@code index}. */ + public String getStringUTF8(int index) { return memUTF8(get(index)); } + + /** Decodes the UTF-16 string that starts at the address found at the specified {@code index}. */ + public String getStringUTF16(int index) { return memUTF16(get(index)); } + + // -- Bulk get operations -- + + /** + * Relative bulk get method. + * + *

This method transfers pointers from this buffer into the specified destination array. An invocation of this method of the form {@code src.get(a)} + * behaves in exactly the same way as the invocation + * + *

+     *     src.get(a, 0, a.length) 
+ * + * @return This buffer + * + * @throws BufferUnderflowException If there are fewer than {@code length} pointers remaining in this buffer + */ + public PointerBuffer get(long[] dst) { + return get(dst, 0, dst.length); + } + + /** + * Relative bulk get method. + * + *

This method transfers pointers from this buffer into the specified destination array. If there are fewer pointers remaining in the buffer than are + * required to satisfy the request, that is, if {@code length} {@code >} {@code remaining()}, then no pointers are transferred and a + * {@link BufferUnderflowException} is thrown. + * + *

Otherwise, this method copies {@code length} pointers from this buffer into the specified array, starting at the current position of this buffer and + * at the specified offset in the array. The position of this buffer is then incremented by {@code length}. + * + *

In other words, an invocation of this method of the form {@code src.get(dst, off, len)} has exactly the same effect as the loop

+ * + *
+     *     for (int i = off; i < off + len; i++)
+     *         dst[i] = src.get(); 
+ * + *

except that it first checks that there are sufficient pointers in this buffer and it is potentially much more efficient.

+ * + * @param dst the array into which pointers are to be written + * @param offset the offset within the array of the first pointer to be written; must be non-negative and no larger than {@code dst.length} + * @param length the maximum number of pointers to be written to the specified array; must be non-negative and no larger than {@code dst.length - offset} + * + * @return This buffer + * + * @throws BufferUnderflowException If there are fewer than {@code length} pointers remaining in this buffer + * @throws IndexOutOfBoundsException If the preconditions on the {@code offset} and {@code length} parameters do not hold + */ + public PointerBuffer get(long[] dst, int offset, int length) { + if (BITS64) { + memLongBuffer(address(), remaining()).get(dst, offset, length); + position(position() + length); + } else { + get32(dst, offset, length); + } + + return this; + } + + private void get32(long[] dst, int offset, int length) { + checkFromIndexSize(offset, length, dst.length); + if (remaining() < length) { + throw new BufferUnderflowException(); + } + for (int i = offset, end = offset + length; i < end; i++) { + dst[i] = get(); + } + } + + /** + * Relative bulk put method  (optional operation). + * + *

This method transfers the entire content of the specified source pointer array into this buffer. An invocation of this method of the form + * {@code dst.put(a)} behaves in exactly the same way as the invocation

+ * + *
+     *     dst.put(a, 0, a.length) 
+ * + * @return This buffer + * + * @throws BufferOverflowException If there is insufficient space in this buffer + */ + public PointerBuffer put(long[] src) { + return put(src, 0, src.length); + } + + /** + * Relative bulk put method  (optional operation). + * + *

This method transfers pointers into this buffer from the specified source array. If there are more pointers to be copied from the array than remain + * in this buffer, that is, if {@code length} {@code >} {@code remaining()}, then no pointers are transferred and a + * {@link BufferOverflowException} is thrown. + * + *

Otherwise, this method copies {@code length} pointers from the specified array into this buffer, starting at the specified offset in the array and + * at the current position of this buffer. The position of this buffer is then incremented by {@code length}.

+ * + *

In other words, an invocation of this method of the form {@code dst.put(src, off, len)} has exactly the same effect as the loop

+ * + *
+     *     for (int i = off; i < off + len; i++)
+     *         dst.put(a[i]); 
+ * + *

except that it first checks that there is sufficient space in this buffer and it is potentially much more efficient.

+ * + * @param src the array from which pointers are to be read + * @param offset the offset within the array of the first pointer to be read; must be non-negative and no larger than {@code array.length} + * @param length the number of pointers to be read from the specified array; must be non-negative and no larger than {@code array.length - offset} + * + * @return This buffer + * + * @throws BufferOverflowException If there is insufficient space in this buffer + * @throws IndexOutOfBoundsException If the preconditions on the {@code offset} and {@code length} parameters do not hold + */ + public PointerBuffer put(long[] src, int offset, int length) { + if (BITS64) { + memLongBuffer(address(), remaining()).put(src, offset, length); + position(position() + length); + } else { + put32(src, offset, length); + } + + return this; + } + + private void put32(long[] src, int offset, int length) { + checkFromIndexSize(offset, length, src.length); + if (remaining() < length) { + throw new BufferOverflowException(); + } + int end = offset + length; + for (int i = offset; i < end; i++) { + put(src[i]); + } + } + + /** + * Returns the current hash code of this buffer. + * + *

The hash code of a pointer buffer depends only upon its remaining elements; that is, upon the elements from {@code position()} up to, and including, + * the element at {@code limit()} - {@code 1}.

+ * + *

Because buffer hash codes are content-dependent, it is inadvisable to use buffers as keys in hash maps or similar data structures unless it is known + * that their contents will not change.

+ * + * @return the current hash code of this buffer + */ + public int hashCode() { + int h = 1; + int p = position(); + for (int i = limit() - 1; i >= p; i--) { + h = 31 * h + (int)get(i); + } + return h; + } + + /** + * Tells whether or not this buffer is equal to another object. + * + *

Two pointer buffers are equal if, and only if,

+ * + *
    + *
  1. They have the same element type,
  2. + *
  3. They have the same number of remaining elements, and
  4. + *
  5. The two sequences of remaining elements, considered + * independently of their starting positions, are pointwise equal.
  6. + *
+ * + *

A pointer buffer is not equal to any other type of object.

+ * + * @param ob the object to which this buffer is to be compared + * + * @return {@code true} if, and only if, this buffer is equal to the + * given object + */ + public boolean equals(Object ob) { + if (!(ob instanceof PointerBuffer)) { + return false; + } + PointerBuffer that = (PointerBuffer)ob; + if (this.remaining() != that.remaining()) { + return false; + } + int p = this.position(); + for (int i = this.limit() - 1, j = that.limit() - 1; i >= p; i--, j--) { + long v1 = this.get(i); + long v2 = that.get(j); + if (v1 != v2) { + return false; + } + } + return true; + } + + /** + * Compares this buffer to another. + * + *

Two pointer buffers are compared by comparing their sequences of remaining elements lexicographically, without regard to the starting position of + * each sequence within its corresponding buffer.

+ * + *

A pointer buffer is not comparable to any other type of object.

+ * + * @return A negative integer, zero, or a positive integer as this buffer is less than, equal to, or greater than the specified buffer + */ + @Override + public int compareTo(PointerBuffer that) { + int n = this.position() + Math.min(this.remaining(), that.remaining()); + for (int i = this.position(), j = that.position(); i < n; i++, j++) { + long v1 = this.get(i); + long v2 = that.get(j); + if (v1 == v2) { + continue; + } + if (v1 < v2) { + return -1; + } + return +1; + } + return this.remaining() - that.remaining(); + } + +} diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/PointerWrapper.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/PointerWrapper.java new file mode 100644 index 000000000..f68f18dd9 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/PointerWrapper.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; + +/** + * A common interface for classes that wrap pointer addresses. + * + * @author Spasi + */ +public interface PointerWrapper { + + long getPointer(); + +} diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/PointerWrapperAbstract.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/PointerWrapperAbstract.java new file mode 100644 index 000000000..56f17aebf --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/PointerWrapperAbstract.java @@ -0,0 +1,92 @@ +/* + * 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; + +/** + * Base PointerWrapper implementation. + * + * @author Spasi + */ +public abstract class PointerWrapperAbstract implements PointerWrapper { + + protected final long pointer; + + protected PointerWrapperAbstract(final long pointer) { + this.pointer = pointer; + } + + /** + * Returns true if this object represents a valid pointer. + * The pointer might be invalid because it is NULL or because + * some other action has deleted the object that this pointer + * represents. + * + * @return true if the pointer is valid + */ + public boolean isValid() { + return pointer != 0; + } + + /** + * Checks if the pointer is valid and throws an IllegalStateException if + * it is not. This method is a NO-OP, unless the org.lwjgl.util.Debug + * property has been set to true. + */ + public final void checkValid() { + if ( LWJGLUtil.DEBUG && !isValid() ) + throw new IllegalStateException("This " + getClass().getSimpleName() + " pointer is not valid."); + } + + public final long getPointer() { + checkValid(); + return pointer; + } + + public boolean equals(final Object o) { + if ( this == o ) return true; + if ( !(o instanceof PointerWrapperAbstract) ) return false; + + final PointerWrapperAbstract that = (PointerWrapperAbstract)o; + + if ( pointer != that.pointer ) return false; + + return true; + } + + public int hashCode() { + return (int)(pointer ^ (pointer >>> 32)); + } + + public String toString() { + return getClass().getSimpleName() + " pointer (0x" + Long.toHexString(pointer).toUpperCase() + ")"; + } +} diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/Sys.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/Sys.java new file mode 100644 index 000000000..17299f66f --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/Sys.java @@ -0,0 +1,87 @@ +package org.lwjgl; + +import org.lwjgl.opengl.GL11; +import org.lwjgl.glfw.GLFW; + +import java.awt.Desktop; +import java.net.URI; + +import javax.swing.JOptionPane; +import javax.swing.UIManager; + +public class Sys { + + /** + * No constructor for Sys. + */ + private Sys() { + } + + /** Returns the LWJGL version. */ + public static String getVersion() { + return org.lwjgl.Version.getVersion(); + } + + public static void initialize() { + if (!GLFW.glfwInit()) + throw new IllegalStateException("Unable to initialize GLFW"); + } + + /** + * GLFW automatically recomputes the time via + * {@link GLFW#glfwGetTimerValue()}, no need to divide the frequency + * + * @return 1 + */ + public static long getTimerResolution() { + return 1000; + } + + /** + * Gets the current value of the hires timer, in ticks. When the Sys class + * is first loaded the hi-res timer is reset to 0. If no hi-res timer is + * present then this method will always return 0. + *

+ * PLEASE NOTE: the hi-res timer WILL wrap around. + * + * @return the current hi-res time, in ticks (always >= 0) + */ + public static long getTime() { + return GLFW.glfwGetTimerValue(); + } + + public static long getNanoTime() { + return System.nanoTime(); + // return getTime() * 1000L * 1000L; + } + + public static boolean openURL(String url) { + if (!Desktop.isDesktopSupported()) + return false; + + Desktop desktop = Desktop.getDesktop(); + if (!desktop.isSupported(Desktop.Action.BROWSE)) + return false; + + try { + desktop.browse(new URI(url)); + return true; + } catch (Exception ex) { + ex.printStackTrace(); + return false; + } + } + + public static void alert(String title, String message) { + try { + UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); + } catch (Exception e) { + LWJGLUtil.log("Caught exception while setting Look-and-Feel: " + e); + } + JOptionPane.showMessageDialog(null, message, title, JOptionPane.WARNING_MESSAGE); + } + + public static String getClipboard() { + return GLFW.glfwGetClipboardString(GLFW.glfwGetPrimaryMonitor()); + } +} diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/CallbackBridge.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/CallbackBridge.java new file mode 100644 index 000000000..e9a34a682 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/CallbackBridge.java @@ -0,0 +1,82 @@ +package org.lwjgl.glfw; +import java.io.*; +import java.util.*; +import android.util.*; + +public class CallbackBridge { + public static final int CLIPBOARD_COPY = 2000; + public static final int CLIPBOARD_PASTE = 2001; + + public static final int EVENT_TYPE_CHAR = 1000; + public static final int EVENT_TYPE_CHAR_MODS = 1001; + public static final int EVENT_TYPE_CURSOR_ENTER = 1002; + public static final int EVENT_TYPE_CURSOR_POS = 1003; + public static final int EVENT_TYPE_FRAMEBUFFER_SIZE = 1004; + public static final int EVENT_TYPE_KEY = 1005; + public static final int EVENT_TYPE_MOUSE_BUTTON = 1006; + public static final int EVENT_TYPE_SCROLL = 1007; + public static final int EVENT_TYPE_WINDOW_SIZE = 1008; + + public static final int ANDROID_TYPE_GRAB_STATE = 0; + + // Should pending events be limited? + volatile public static List PENDING_EVENT_LIST = new ArrayList<>(); + volatile public static boolean PENDING_EVENT_READY = false; + + public static final boolean INPUT_DEBUG_ENABLED; + + // TODO send grab state event to Android + + static { + INPUT_DEBUG_ENABLED = Boolean.parseBoolean(System.getProperty("glfwstub.debugInput", "false")); + + +/* + if (isDebugEnabled) { + //try { + //debugEventStream = new PrintStream(new File(System.getProperty("user.dir"), "glfwstub_inputeventlog.txt")); + debugEventStream = System.out; + //} catch (FileNotFoundException e) { + // e.printStackTrace(); + //} + } + + //Quick and dirty: debul all key inputs to System.out +*/ + } + + public static void sendGrabbing(boolean grab, int xset, int yset) { + // sendData(ANDROID_TYPE_GRAB_STATE, Boolean.toString(grab)); + + GLFW.mGLFWIsGrabbing = grab; + nativeSetGrabbing(grab, xset, yset); + } + + // Called from Android side + public static void receiveCallback(int type, int i1, int i2, int i3, int i4) { + /* + if (INPUT_DEBUG_ENABLED) { + System.out.println("LWJGL GLFW Callback received type=" + Integer.toString(type) + ", data=" + i1 + ", " + i2 + ", " + i3 + ", " + i4); + } + */ + if (PENDING_EVENT_READY) { + if (type == EVENT_TYPE_CURSOR_POS) { + GLFW.mGLFWCursorX = i1; + GLFW.mGLFWCursorY = i2; + } else { + PENDING_EVENT_LIST.add(new Integer[]{type, i1, i2, i3, i4}); + } + } // else System.out.println("Event input is not ready yet!"); + } + + public static void sendData(int type, String data) { + nativeSendData(false, type, data); + } + + public static native void nativeSendData(boolean isAndroid, int type, String data); + public static native boolean nativeSetInputReady(boolean ready); + public static native String nativeClipboard(int action, String copy); + + private static native void nativeSetGrabbing(boolean grab, int xset, int yset); +} + diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/Callbacks.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/Callbacks.java new file mode 100644 index 000000000..9216a1c34 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/Callbacks.java @@ -0,0 +1,72 @@ +/* + * Copyright LWJGL. All rights reserved. + * License terms: https://www.lwjgl.org/license + */ +package org.lwjgl.glfw; + +import org.lwjgl.system.*; + +import static org.lwjgl.system.Checks.*; +import static org.lwjgl.system.JNI.*; +import static org.lwjgl.system.MemoryUtil.*; +import java.lang.reflect.*; + +/** Utility class for GLFW callbacks. */ +public final class Callbacks { + + private Callbacks() {} + + /** + * Resets all callbacks for the specified GLFW window to {@code NULL} and {@link Callback#free frees} all previously set callbacks. + * + *

This method resets only callbacks registered with a GLFW window. Non-window callbacks (registered with + * {@link GLFW#glfwSetErrorCallback SetErrorCallback}, {@link GLFW#glfwSetMonitorCallback SetMonitorCallback}, etc.) must be reset and freed + * separately.

+ * + *

This method is not official GLFW API. It exists in LWJGL to simplify window callback cleanup.

+ * + * @param window the GLFW window + */ + public static void glfwFreeCallbacks(@NativeType("GLFWwindow *") long window) { + if (Checks.CHECKS) { + check(window); + } + + try { + for (Field callback : GLFW.class.getFields()) { + if (callback.getName().startsWith("mGLFW") && callback.getName().endsWith("Callback")) { + callback.set(null, null); + } + } + } catch (IllegalAccessException|NullPointerException e) { + throw new RuntimeException("org.lwjgl.GLFW.mGLFWxxxCallbacks must be set to public and static", e); + } + +/* + for (long callback : new long[] { + GLFW.Functions.SetWindowPosCallback, + GLFW.Functions.SetWindowSizeCallback, + GLFW.Functions.SetWindowCloseCallback, + GLFW.Functions.SetWindowRefreshCallback, + GLFW.Functions.SetWindowFocusCallback, + GLFW.Functions.SetWindowIconifyCallback, + GLFW.Functions.SetWindowMaximizeCallback, + GLFW.Functions.SetFramebufferSizeCallback, + GLFW.Functions.SetWindowContentScaleCallback, + GLFW.Functions.SetKeyCallback, + GLFW.Functions.SetCharCallback, + GLFW.Functions.SetCharModsCallback, + GLFW.Functions.SetMouseButtonCallback, + GLFW.Functions.SetCursorPosCallback, + GLFW.Functions.SetCursorEnterCallback, + GLFW.Functions.SetScrollCallback, + GLFW.Functions.SetDropCallback + }) { + long prevCB = invokePPP(window, NULL, callback); + if (prevCB != NULL) { + Callback.free(prevCB); + } + } +*/ + } +} diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/EventLoop.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/EventLoop.java new file mode 100644 index 000000000..8f8113f1a --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/EventLoop.java @@ -0,0 +1,85 @@ +/* + * Copyright LWJGL. All rights reserved. + * License terms: https://www.lwjgl.org/license + */ +package org.lwjgl.glfw; + +import org.lwjgl.system.*; +import org.lwjgl.system.macosx.*; + +import static org.lwjgl.system.JNI.*; +import static org.lwjgl.system.macosx.LibC.*; +import static org.lwjgl.system.macosx.ObjCRuntime.*; + +/** + * Contains checks for the event loop issues on OS X. + * + *

On-screen GLFW windows can only be used in the main thread and only if that thread is the first thread in the process. This requires running the JVM with + * {@code -XstartOnFirstThread}, which means that other window toolkits (AWT/Swing, JavaFX, etc.) cannot be used at the same time.

+ * + *

Another window toolkit can be used if GLFW windows are never shown (created with {@link GLFW#GLFW_VISIBLE GLFW_VISIBLE} equal to + * {@link GLFW#GLFW_FALSE GLFW_FALSE}) and only used as contexts for offscreen rendering. This is possible if the window toolkit has initialized and created + * the shared application (NSApp) before a GLFW window is created.

+ */ +final class EventLoop { + + static final class OffScreen { + static { + if (Platform.get() == Platform.MACOSX && !isMainThread()) { + // The only way to avoid a crash is if the shared application (NSApp) has been created by something else + throw new IllegalStateException( + isJavaStartedOnFirstThread() + ? "GLFW windows may only be created on the main thread." + : "GLFW windows may only be created on the main thread and that thread must be the first thread in the process. Please run " + + "the JVM with -XstartOnFirstThread. For offscreen rendering, make sure another window toolkit (e.g. AWT or JavaFX) is " + + "initialized before GLFW and Configuration.GLFW_CHECK_THREAD0 is set to false." + ); + } + } + + private OffScreen() { + } + + static void check() { + // intentionally empty to trigger the static initializer + } + } + + static final class OnScreen { + static { + if (Platform.get() == Platform.MACOSX && !isMainThread()) { + throw new IllegalStateException( + "Please run the JVM with -XstartOnFirstThread and make sure a window toolkit other than GLFW (e.g. AWT or JavaFX) is not initialized." + ); + } + } + + private OnScreen() { + } + + static void check() { + // intentionally empty to trigger the static initializer + } + } + + private EventLoop() { + } + + private static boolean isMainThread() { + if (!Configuration.GLFW_CHECK_THREAD0.get(true)) { + return true; + } + + long objc_msgSend = ObjCRuntime.getLibrary().getFunctionAddress("objc_msgSend"); + + long NSThread = objc_getClass("NSThread"); + long currentThread = invokePPP(NSThread, sel_getUid("currentThread"), objc_msgSend); + + return invokePPZ(currentThread, sel_getUid("isMainThread"), objc_msgSend); + } + + private static boolean isJavaStartedOnFirstThread() { + return "1".equals(System.getenv().get("JAVA_STARTED_ON_FIRST_THREAD_" + getpid())); + } + +} \ No newline at end of file diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFW.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFW.java new file mode 100644 index 000000000..641aa1e9e --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFW.java @@ -0,0 +1,1224 @@ +/* + * Copyright LWJGL. All rights reserved. + * License terms: https://www.lwjgl.org/license + */ +package org.lwjgl.glfw; + +import android.util.*; + +import java.lang.reflect.*; +import java.nio.*; + +import javax.annotation.*; + +import org.lwjgl.*; +import org.lwjgl.opengl.GL; +import org.lwjgl.system.*; + +import static org.lwjgl.system.APIUtil.*; +import static org.lwjgl.system.Checks.*; +import static org.lwjgl.system.JNI.*; +import static org.lwjgl.system.MemoryStack.*; +import static org.lwjgl.system.MemoryUtil.*; +import java.util.*; + +public class GLFW +{ + /** The major version number of the GLFW library. This is incremented when the API is changed in non-compatible ways. */ + public static final int GLFW_VERSION_MAJOR = 3; + + /** The minor version number of the GLFW library. This is incremented when features are added to the API but it remains backward-compatible. */ + public static final int GLFW_VERSION_MINOR = 4; + + /** The revision number of the GLFW library. This is incremented when a bug fix release is made that does not contain any API changes. */ + public static final int GLFW_VERSION_REVISION = 0; + + /** Boolean values. */ + public static final int + GLFW_TRUE = 1, + GLFW_FALSE = 0; + + /** The key or button was released. */ + public static final int GLFW_RELEASE = 0; + + /** The key or button was pressed. */ + public static final int GLFW_PRESS = 1; + + /** The key was held down until it repeated. */ + public static final int GLFW_REPEAT = 2; + + /** Joystick hat states. */ + public static final int + GLFW_HAT_CENTERED = 0, + GLFW_HAT_UP = 1, + GLFW_HAT_RIGHT = 2, + GLFW_HAT_DOWN = 4, + GLFW_HAT_LEFT = 8, + GLFW_HAT_RIGHT_UP = (GLFW_HAT_RIGHT | GLFW_HAT_UP), + GLFW_HAT_RIGHT_DOWN = (GLFW_HAT_RIGHT | GLFW_HAT_DOWN), + GLFW_HAT_LEFT_UP = (GLFW_HAT_LEFT | GLFW_HAT_UP), + GLFW_HAT_LEFT_DOWN = (GLFW_HAT_LEFT | GLFW_HAT_DOWN); + + /** The unknown key. */ + public static final int GLFW_KEY_UNKNOWN = -1; + + /** Printable keys. */ + public static final int + GLFW_KEY_SPACE = 32, + GLFW_KEY_APOSTROPHE = 39, + GLFW_KEY_COMMA = 44, + GLFW_KEY_MINUS = 45, + GLFW_KEY_PERIOD = 46, + GLFW_KEY_SLASH = 47, + GLFW_KEY_0 = 48, + GLFW_KEY_1 = 49, + GLFW_KEY_2 = 50, + GLFW_KEY_3 = 51, + GLFW_KEY_4 = 52, + GLFW_KEY_5 = 53, + GLFW_KEY_6 = 54, + GLFW_KEY_7 = 55, + GLFW_KEY_8 = 56, + GLFW_KEY_9 = 57, + GLFW_KEY_SEMICOLON = 59, + GLFW_KEY_EQUAL = 61, + GLFW_KEY_A = 65, + GLFW_KEY_B = 66, + GLFW_KEY_C = 67, + GLFW_KEY_D = 68, + GLFW_KEY_E = 69, + GLFW_KEY_F = 70, + GLFW_KEY_G = 71, + GLFW_KEY_H = 72, + GLFW_KEY_I = 73, + GLFW_KEY_J = 74, + GLFW_KEY_K = 75, + GLFW_KEY_L = 76, + GLFW_KEY_M = 77, + GLFW_KEY_N = 78, + GLFW_KEY_O = 79, + GLFW_KEY_P = 80, + GLFW_KEY_Q = 81, + GLFW_KEY_R = 82, + GLFW_KEY_S = 83, + GLFW_KEY_T = 84, + GLFW_KEY_U = 85, + GLFW_KEY_V = 86, + GLFW_KEY_W = 87, + GLFW_KEY_X = 88, + GLFW_KEY_Y = 89, + GLFW_KEY_Z = 90, + GLFW_KEY_LEFT_BRACKET = 91, + GLFW_KEY_BACKSLASH = 92, + GLFW_KEY_RIGHT_BRACKET = 93, + GLFW_KEY_GRAVE_ACCENT = 96, + GLFW_KEY_WORLD_1 = 161, + GLFW_KEY_WORLD_2 = 162; + + /** Function keys. */ + public static final int + GLFW_KEY_ESCAPE = 256, + GLFW_KEY_ENTER = 257, + GLFW_KEY_TAB = 258, + GLFW_KEY_BACKSPACE = 259, + GLFW_KEY_INSERT = 260, + GLFW_KEY_DELETE = 261, + GLFW_KEY_RIGHT = 262, + GLFW_KEY_LEFT = 263, + GLFW_KEY_DOWN = 264, + GLFW_KEY_UP = 265, + GLFW_KEY_PAGE_UP = 266, + GLFW_KEY_PAGE_DOWN = 267, + GLFW_KEY_HOME = 268, + GLFW_KEY_END = 269, + GLFW_KEY_CAPS_LOCK = 280, + GLFW_KEY_SCROLL_LOCK = 281, + GLFW_KEY_NUM_LOCK = 282, + GLFW_KEY_PRINT_SCREEN = 283, + GLFW_KEY_PAUSE = 284, + GLFW_KEY_F1 = 290, + GLFW_KEY_F2 = 291, + GLFW_KEY_F3 = 292, + GLFW_KEY_F4 = 293, + GLFW_KEY_F5 = 294, + GLFW_KEY_F6 = 295, + GLFW_KEY_F7 = 296, + GLFW_KEY_F8 = 297, + GLFW_KEY_F9 = 298, + GLFW_KEY_F10 = 299, + GLFW_KEY_F11 = 300, + GLFW_KEY_F12 = 301, + GLFW_KEY_F13 = 302, + GLFW_KEY_F14 = 303, + GLFW_KEY_F15 = 304, + GLFW_KEY_F16 = 305, + GLFW_KEY_F17 = 306, + GLFW_KEY_F18 = 307, + GLFW_KEY_F19 = 308, + GLFW_KEY_F20 = 309, + GLFW_KEY_F21 = 310, + GLFW_KEY_F22 = 311, + GLFW_KEY_F23 = 312, + GLFW_KEY_F24 = 313, + GLFW_KEY_F25 = 314, + GLFW_KEY_KP_0 = 320, + GLFW_KEY_KP_1 = 321, + GLFW_KEY_KP_2 = 322, + GLFW_KEY_KP_3 = 323, + GLFW_KEY_KP_4 = 324, + GLFW_KEY_KP_5 = 325, + GLFW_KEY_KP_6 = 326, + GLFW_KEY_KP_7 = 327, + GLFW_KEY_KP_8 = 328, + GLFW_KEY_KP_9 = 329, + GLFW_KEY_KP_DECIMAL = 330, + GLFW_KEY_KP_DIVIDE = 331, + GLFW_KEY_KP_MULTIPLY = 332, + GLFW_KEY_KP_SUBTRACT = 333, + GLFW_KEY_KP_ADD = 334, + GLFW_KEY_KP_ENTER = 335, + GLFW_KEY_KP_EQUAL = 336, + GLFW_KEY_LEFT_SHIFT = 340, + GLFW_KEY_LEFT_CONTROL = 341, + GLFW_KEY_LEFT_ALT = 342, + GLFW_KEY_LEFT_SUPER = 343, + GLFW_KEY_RIGHT_SHIFT = 344, + GLFW_KEY_RIGHT_CONTROL = 345, + GLFW_KEY_RIGHT_ALT = 346, + GLFW_KEY_RIGHT_SUPER = 347, + GLFW_KEY_MENU = 348, + GLFW_KEY_LAST = GLFW_KEY_MENU; + + /** If this bit is set one or more Shift keys were held down. */ + public static final int GLFW_MOD_SHIFT = 0x1; + + /** If this bit is set one or more Control keys were held down. */ + public static final int GLFW_MOD_CONTROL = 0x2; + + /** If this bit is set one or more Alt keys were held down. */ + public static final int GLFW_MOD_ALT = 0x4; + + /** If this bit is set one or more Super keys were held down. */ + public static final int GLFW_MOD_SUPER = 0x8; + + /** If this bit is set the Caps Lock key is enabled and the {@link #GLFW_LOCK_KEY_MODS LOCK_KEY_MODS} input mode is set. */ + public static final int GLFW_MOD_CAPS_LOCK = 0x10; + + /** If this bit is set the Num Lock key is enabled and the {@link #GLFW_LOCK_KEY_MODS LOCK_KEY_MODS} input mode is set. */ + public static final int GLFW_MOD_NUM_LOCK = 0x20; + + + /** Mouse buttons. See mouse button input for how these are used. */ + public static final int + GLFW_MOUSE_BUTTON_1 = 0, + GLFW_MOUSE_BUTTON_2 = 1, + GLFW_MOUSE_BUTTON_3 = 2, + GLFW_MOUSE_BUTTON_4 = 3, + GLFW_MOUSE_BUTTON_5 = 4, + GLFW_MOUSE_BUTTON_6 = 5, + GLFW_MOUSE_BUTTON_7 = 6, + GLFW_MOUSE_BUTTON_8 = 7, + GLFW_MOUSE_BUTTON_LAST = GLFW_MOUSE_BUTTON_8, + GLFW_MOUSE_BUTTON_LEFT = GLFW_MOUSE_BUTTON_1, + GLFW_MOUSE_BUTTON_RIGHT = GLFW_MOUSE_BUTTON_2, + GLFW_MOUSE_BUTTON_MIDDLE = GLFW_MOUSE_BUTTON_3; + + /** Joysticks. See joystick input for how these are used. */ + public static final int + GLFW_JOYSTICK_1 = 0, + GLFW_JOYSTICK_2 = 1, + GLFW_JOYSTICK_3 = 2, + GLFW_JOYSTICK_4 = 3, + GLFW_JOYSTICK_5 = 4, + GLFW_JOYSTICK_6 = 5, + GLFW_JOYSTICK_7 = 6, + GLFW_JOYSTICK_8 = 7, + GLFW_JOYSTICK_9 = 8, + GLFW_JOYSTICK_10 = 9, + GLFW_JOYSTICK_11 = 10, + GLFW_JOYSTICK_12 = 11, + GLFW_JOYSTICK_13 = 12, + GLFW_JOYSTICK_14 = 13, + GLFW_JOYSTICK_15 = 14, + GLFW_JOYSTICK_16 = 15, + GLFW_JOYSTICK_LAST = GLFW_JOYSTICK_16; + + /** Gamepad buttons. See gamepad for how these are used. */ + public static final int + GLFW_GAMEPAD_BUTTON_A = 0, + GLFW_GAMEPAD_BUTTON_B = 1, + GLFW_GAMEPAD_BUTTON_X = 2, + GLFW_GAMEPAD_BUTTON_Y = 3, + GLFW_GAMEPAD_BUTTON_LEFT_BUMPER = 4, + GLFW_GAMEPAD_BUTTON_RIGHT_BUMPER = 5, + GLFW_GAMEPAD_BUTTON_BACK = 6, + GLFW_GAMEPAD_BUTTON_START = 7, + GLFW_GAMEPAD_BUTTON_GUIDE = 8, + GLFW_GAMEPAD_BUTTON_LEFT_THUMB = 9, + GLFW_GAMEPAD_BUTTON_RIGHT_THUMB = 10, + GLFW_GAMEPAD_BUTTON_DPAD_UP = 11, + GLFW_GAMEPAD_BUTTON_DPAD_RIGHT = 12, + GLFW_GAMEPAD_BUTTON_DPAD_DOWN = 13, + GLFW_GAMEPAD_BUTTON_DPAD_LEFT = 14, + GLFW_GAMEPAD_BUTTON_LAST = GLFW_GAMEPAD_BUTTON_DPAD_LEFT, + GLFW_GAMEPAD_BUTTON_CROSS = GLFW_GAMEPAD_BUTTON_A, + GLFW_GAMEPAD_BUTTON_CIRCLE = GLFW_GAMEPAD_BUTTON_B, + GLFW_GAMEPAD_BUTTON_SQUARE = GLFW_GAMEPAD_BUTTON_X, + GLFW_GAMEPAD_BUTTON_TRIANGLE = GLFW_GAMEPAD_BUTTON_Y; + + /** Gamepad axes. See gamepad for how these are used. */ + public static final int + GLFW_GAMEPAD_AXIS_LEFT_X = 0, + GLFW_GAMEPAD_AXIS_LEFT_Y = 1, + GLFW_GAMEPAD_AXIS_RIGHT_X = 2, + GLFW_GAMEPAD_AXIS_RIGHT_Y = 3, + GLFW_GAMEPAD_AXIS_LEFT_TRIGGER = 4, + GLFW_GAMEPAD_AXIS_RIGHT_TRIGGER = 5, + GLFW_GAMEPAD_AXIS_LAST = GLFW_GAMEPAD_AXIS_RIGHT_TRIGGER; + + public static final int + GLFW_NO_ERROR = 0, + GLFW_NOT_INITIALIZED = 0x10001, + GLFW_NO_CURRENT_CONTEXT = 0x10002, + GLFW_INVALID_ENUM = 0x10003, + GLFW_INVALID_VALUE = 0x10004, + GLFW_OUT_OF_MEMORY = 0x10005, + GLFW_API_UNAVAILABLE = 0x10006, + GLFW_VERSION_UNAVAILABLE = 0x10007, + GLFW_PLATFORM_ERROR = 0x10008, + GLFW_FORMAT_UNAVAILABLE = 0x10009, + GLFW_NO_WINDOW_CONTEXT = 0x1000A, + GLFW_CURSOR_UNAVAILABLE = 0x1000B, + GLFW_FEATURE_UNAVAILABLE = 0x1000C, + GLFW_FEATURE_UNIMPLEMENTED = 0x1000D; + + public static final int + GLFW_FOCUSED = 0x20001, + GLFW_ICONIFIED = 0x20002, + GLFW_RESIZABLE = 0x20003, + GLFW_VISIBLE = 0x20004, + GLFW_DECORATED = 0x20005, + GLFW_AUTO_ICONIFY = 0x20006, + GLFW_FLOATING = 0x20007, + GLFW_MAXIMIZED = 0x20008, + GLFW_CENTER_CURSOR = 0x20009, + GLFW_TRANSPARENT_FRAMEBUFFER = 0x2000A, + GLFW_HOVERED = 0x2000B, + GLFW_FOCUS_ON_SHOW = 0x2000C; + + /** Input options. */ + public static final int + GLFW_CURSOR = 0x33001, + GLFW_STICKY_KEYS = 0x33002, + GLFW_STICKY_MOUSE_BUTTONS = 0x33003, + GLFW_LOCK_KEY_MODS = 0x33004, + GLFW_RAW_MOUSE_MOTION = 0x33005; + + /** Cursor state. */ + public static final int + GLFW_CURSOR_NORMAL = 0x34001, + GLFW_CURSOR_HIDDEN = 0x34002, + GLFW_CURSOR_DISABLED = 0x34003; + + /** The regular arrow cursor shape. */ + public static final int GLFW_ARROW_CURSOR = 0x36001; + + /** The text input I-beam cursor shape. */ + public static final int GLFW_IBEAM_CURSOR = 0x36002; + + /** The crosshair cursor shape. */ + public static final int GLFW_CROSSHAIR_CURSOR = 0x36003; + + /** The pointing hand cursor shape. */ + public static final int GLFW_POINTING_HAND_CURSOR = 0x36004; + + public static final int GLFW_RESIZE_EW_CURSOR = 0x36005; + public static final int GLFW_RESIZE_NS_CURSOR = 0x36006; + public static final int GLFW_RESIZE_NWSE_CURSOR = 0x36007; + public static final int GLFW_RESIZE_NESW_CURSOR = 0x36008; + + /** + * The omni-directional resize cursor/move shape. + * + *

This is usually either a combined horizontal and vertical double-headed arrow or a grabbing hand.

+ */ + public static final int GLFW_RESIZE_ALL_CURSOR = 0x36009; + + public static final int GLFW_NOT_ALLOWED_CURSOR = 0x3600A; + + /** Legacy name for compatibility. */ + public static final int GLFW_HRESIZE_CURSOR = GLFW_RESIZE_EW_CURSOR; + + /** Legacy name for compatibility. */ + public static final int GLFW_VRESIZE_CURSOR = GLFW_RESIZE_NS_CURSOR; + + /** Legacy name for compatibility. */ + public static final int GLFW_HAND_CURSOR = GLFW_POINTING_HAND_CURSOR; + + /** Monitor events. */ + public static final int + GLFW_CONNECTED = 0x40001, + GLFW_DISCONNECTED = 0x40002; + + /** Init hints. */ + public static final int + GLFW_JOYSTICK_HAT_BUTTONS = 0x50001, + GLFW_COCOA_CHDIR_RESOURCES = 0x51001, + GLFW_COCOA_MENUBAR = 0x51002; + + /** Don't care value. */ + public static final int GLFW_DONT_CARE = -1; + + /** PixelFormat hints. */ + public static final int + GLFW_RED_BITS = 0x21001, + GLFW_GREEN_BITS = 0x21002, + GLFW_BLUE_BITS = 0x21003, + GLFW_ALPHA_BITS = 0x21004, + GLFW_DEPTH_BITS = 0x21005, + GLFW_STENCIL_BITS = 0x21006, + GLFW_ACCUM_RED_BITS = 0x21007, + GLFW_ACCUM_GREEN_BITS = 0x21008, + GLFW_ACCUM_BLUE_BITS = 0x21009, + GLFW_ACCUM_ALPHA_BITS = 0x2100A, + GLFW_AUX_BUFFERS = 0x2100B, + GLFW_STEREO = 0x2100C, + GLFW_SAMPLES = 0x2100D, + GLFW_SRGB_CAPABLE = 0x2100E, + GLFW_REFRESH_RATE = 0x2100F, + GLFW_DOUBLEBUFFER = 0x21010; + + public static final int + GLFW_CLIENT_API = 0x22001, + GLFW_CONTEXT_VERSION_MAJOR = 0x22002, + GLFW_CONTEXT_VERSION_MINOR = 0x22003, + GLFW_CONTEXT_REVISION = 0x22004, + GLFW_CONTEXT_ROBUSTNESS = 0x22005, + GLFW_OPENGL_FORWARD_COMPAT = 0x22006, + GLFW_OPENGL_DEBUG_CONTEXT = 0x22007, + GLFW_OPENGL_PROFILE = 0x22008, + GLFW_CONTEXT_RELEASE_BEHAVIOR = 0x22009, + GLFW_CONTEXT_NO_ERROR = 0x2200A, + GLFW_CONTEXT_CREATION_API = 0x2200B, + GLFW_SCALE_TO_MONITOR = 0x2200C; + + /** Specifies whether to use full resolution framebuffers on Retina displays. This is ignored on other platforms. */ + public static final int GLFW_COCOA_RETINA_FRAMEBUFFER = 0x23001; + + /** + * Specifies the UTF-8 encoded name to use for autosaving the window frame, or if empty disables frame autosaving for the window. This is ignored on other + * platforms. This is set with {@link #glfwWindowHintString WindowHintString}. + */ + public static final int GLFW_COCOA_FRAME_NAME = 0x23002; + + /** + * Specifies whether to enable Automatic Graphics Switching, i.e. to allow the system to choose the integrated GPU for the OpenGL context and move it + * between GPUs if necessary or whether to force it to always run on the discrete GPU. This only affects systems with both integrated and discrete GPUs. + * This is ignored on other platforms. + */ + public static final int GLFW_COCOA_GRAPHICS_SWITCHING = 0x23003; + + /** The desired ASCII encoded class and instance parts of the ICCCM {@code WM_CLASS} window property. These are set with {@link #glfwWindowHintString WindowHintString}. */ + public static final int + GLFW_X11_CLASS_NAME = 0x24001, + GLFW_X11_INSTANCE_NAME = 0x24002; + + /** + * Specifies whether to allow access to the window menu via the Alt+Space and Alt-and-then-Space keyboard shortcuts. + * + *

This is ignored on other platforms.

+ */ + public static final int GLFW_WIN32_KEYBOARD_MENU = 0x25001; + + /** Values for the {@link #GLFW_CLIENT_API CLIENT_API} hint. */ + public static final int + GLFW_NO_API = 0, + GLFW_OPENGL_API = 0x30001, + GLFW_OPENGL_ES_API = 0x30002; + + /** Values for the {@link #GLFW_CONTEXT_ROBUSTNESS CONTEXT_ROBUSTNESS} hint. */ + public static final int + GLFW_NO_ROBUSTNESS = 0, + GLFW_NO_RESET_NOTIFICATION = 0x31001, + GLFW_LOSE_CONTEXT_ON_RESET = 0x31002; + + /** Values for the {@link #GLFW_OPENGL_PROFILE OPENGL_PROFILE} hint. */ + public static final int + GLFW_OPENGL_ANY_PROFILE = 0, + GLFW_OPENGL_CORE_PROFILE = 0x32001, + GLFW_OPENGL_COMPAT_PROFILE = 0x32002; + + /** Values for the {@link #GLFW_CONTEXT_RELEASE_BEHAVIOR CONTEXT_RELEASE_BEHAVIOR} hint. */ + public static final int + GLFW_ANY_RELEASE_BEHAVIOR = 0, + GLFW_RELEASE_BEHAVIOR_FLUSH = 0x35001, + GLFW_RELEASE_BEHAVIOR_NONE = 0x35002; + + /** Values for the {@link #GLFW_CONTEXT_CREATION_API CONTEXT_CREATION_API} hint. */ + public static final int + GLFW_NATIVE_CONTEXT_API = 0x36001, + GLFW_EGL_CONTEXT_API = 0x36002, + GLFW_OSMESA_CONTEXT_API = 0x36003; + + // GLFW Callbacks + /* volatile */ public static GLFWCharCallback mGLFWCharCallback; + /* volatile */ public static GLFWCharModsCallback mGLFWCharModsCallback; + /* volatile */ public static GLFWCursorEnterCallback mGLFWCursorEnterCallback; + /* volatile */ public static GLFWCursorPosCallback mGLFWCursorPosCallback; + /* volatile */ public static GLFWDropCallback mGLFWDropCallback; + /* volatile */ public static GLFWErrorCallback mGLFWErrorCallback; + /* volatile */ public static GLFWFramebufferSizeCallback mGLFWFramebufferSizeCallback; + /* volatile */ public static GLFWJoystickCallback mGLFWJoystickCallback; + /* volatile */ public static GLFWKeyCallback mGLFWKeyCallback; + /* volatile */ public static GLFWMonitorCallback mGLFWMonitorCallback; + /* volatile */ public static GLFWMouseButtonCallback mGLFWMouseButtonCallback; + /* volatile */ public static GLFWScrollCallback mGLFWScrollCallback; + /* volatile */ public static GLFWWindowCloseCallback mGLFWWindowCloseCallback; + /* volatile */ public static GLFWWindowContentScaleCallback mGLFWWindowContentScaleCallback; + /* volatile */ public static GLFWWindowFocusCallback mGLFWWindowFocusCallback; + /* volatile */ public static GLFWWindowIconifyCallback mGLFWWindowIconifyCallback; + /* volatile */ public static GLFWWindowMaximizeCallback mGLFWWindowMaximizeCallback; + /* volatile */ public static GLFWWindowPosCallback mGLFWWindowPosCallback; + /* volatile */ public static GLFWWindowRefreshCallback mGLFWWindowRefreshCallback; + /* volatile */ public static GLFWWindowSizeCallback mGLFWWindowSizeCallback; + + volatile public static int mGLFWWindowWidth, mGLFWWindowHeight; + volatile public static double mGLFWCursorX, mGLFWCursorY, mGLFWCursorLastX, mGLFWCursorLastY; + + private static GLFWGammaRamp mGLFWGammaRamp; + private static Map mGLFWKeyCodes; + private static GLFWVidMode mGLFWVideoMode; + private static long mGLFWWindowMonitor; + + private static double mGLFWInitialTime; + + private static ArrayMap mGLFWWindowMap; + + public static boolean mGLFWIsGrabbing, mGLFWIsInputReady, mGLFWIsUseStackQueue = false; + + private static final String PROP_WINDOW_WIDTH = "glfwstub.windowWidth"; + private static final String PROP_WINDOW_HEIGHT= "glfwstub.windowHeight"; + + static { + String windowWidth = System.getProperty(PROP_WINDOW_WIDTH); + String windowHeight = System.getProperty(PROP_WINDOW_HEIGHT); + if (windowWidth == null || windowHeight == null) { + System.err.println("Warning: Property " + PROP_WINDOW_WIDTH + " or " + PROP_WINDOW_HEIGHT + " not set, defaulting to 1280 and 720"); + + mGLFWWindowWidth = 1280; + mGLFWWindowHeight = 720; + } else { + mGLFWWindowWidth = Integer.parseInt(windowWidth); + mGLFWWindowHeight = Integer.parseInt(windowHeight); + } + + // Minecraft triggers a glfwPollEvents() on splash screen, so update window size there. + CallbackBridge.receiveCallback(CallbackBridge.EVENT_TYPE_FRAMEBUFFER_SIZE, mGLFWWindowWidth, mGLFWWindowHeight, 0, 0); + CallbackBridge.receiveCallback(CallbackBridge.EVENT_TYPE_WINDOW_SIZE, mGLFWWindowWidth, mGLFWWindowHeight, 0, 0); + + try { + System.loadLibrary("pojavexec"); + } catch (UnsatisfiedLinkError e) { + e.printStackTrace(); + } + + mGLFWErrorCallback = GLFWErrorCallback.createPrint(); + mGLFWKeyCodes = new ArrayMap<>(); + + mGLFWWindowMap = new ArrayMap<>(); + + mGLFWVideoMode = new GLFWVidMode(ByteBuffer.allocateDirect(GLFWVidMode.SIZEOF)); + memPutInt(mGLFWVideoMode.address() + mGLFWVideoMode.WIDTH, mGLFWWindowWidth); + memPutInt(mGLFWVideoMode.address() + mGLFWVideoMode.HEIGHT, mGLFWWindowHeight); + memPutInt(mGLFWVideoMode.address() + mGLFWVideoMode.REDBITS, 8); + memPutInt(mGLFWVideoMode.address() + mGLFWVideoMode.GREENBITS, 8); + memPutInt(mGLFWVideoMode.address() + mGLFWVideoMode.BLUEBITS, 8); + memPutInt(mGLFWVideoMode.address() + mGLFWVideoMode.REFRESHRATE, 60); + + // A way to generate key code names + Field[] thisFieldArr = GLFW.class.getFields(); + try { + for (Field thisField : thisFieldArr) { + if (thisField.getName().startsWith("GLFW_KEY_")) { + mGLFWKeyCodes.put( + (int) thisField.get(null), + thisField.getName().substring(9, 10).toUpperCase() + + thisField.getName().substring(10).replace("_", " ").toLowerCase() + ); + } + } + } catch (IllegalAccessException e) { + // This will never happend since this is accessing itself + } + + /* + mGLFWMonitorCallback = new GLFWMonitorCallback(){ + + // Fake one!!! + @Override + public void free() {} + + @Override + public void callback(long args) { + // TODO: Implement this method + } + }; + */ + } + + private static native long nativeEglGetCurrentContext(); + private static native boolean nativeEglInit(); + public static native boolean nativeEglMakeCurrent(long window); + private static native boolean nativeEglTerminate(); + private static native boolean nativeEglSwapBuffers(); + private static native boolean nativeEglSwapInterval(int inverval); + + private static native long nglfwSetCharCallback(long window, long ptr); + private static native long nglfwSetCharModsCallback(long window, long ptr); + private static native long nglfwSetCursorEnterCallback(long window, long ptr); + private static native long nglfwSetCursorPosCallback(long window, long ptr); + private static native long nglfwSetFramebufferSizeCallback(long window, long ptr); + private static native long nglfwSetKeyCallback(long window, long ptr); + private static native long nglfwSetMouseButtonCallback(long window, long ptr); + private static native long nglfwSetScrollCallback(long window, long ptr); + private static native long nglfwSetWindowSizeCallback(long window, long ptr); + // private static native void nglfwSetInputReady(); + private static native void nglfwSetShowingWindow(long window); + + /* + private static void priGlfwSetError(int error) { + mGLFW_currentError = error; + if (error != GLFW_NO_ERROR && mGLFWErrorCallback != null) { + mGLFWErrorCallback.invoke(error, 0); + } + } + + private static void priGlfwNoError() { + priGlfwSetError(GLFW_NO_ERROR); + } + */ + protected GLFW() { + throw new UnsupportedOperationException(); + } + + private static final SharedLibrary GLFW = new SharedLibrary() { + @java.lang.Override + public String getName() { + return "GLFW"; + } + + @Nullable + @java.lang.Override + public String getPath() { + return null; + } + + @java.lang.Override + public long getFunctionAddress(ByteBuffer functionName) { + return 1; + } + + @java.lang.Override + public void free() { + + } + + @java.lang.Override + public long address() { + return 1; + } + }; + // Library.loadNative(GLFW.class, "org.lwjgl.glfw", Configuration.GLFW_LIBRARY_NAME.get(Platform.mapLibraryNameBundled("glfw")), true); + + public static SharedLibrary getLibrary() { + return GLFW; + } + + public static GLFWWindowProperties internalGetWindow(long window) { + GLFWWindowProperties win = mGLFWWindowMap.get(window); + if (win == null) { + throw new IllegalArgumentException("No window pointer found: " + window); + } + return win; + } + +// Generated stub callback methods + public static GLFWCharCallback glfwSetCharCallback(@NativeType("GLFWwindow *") long window, @Nullable @NativeType("GLFWcharfun") GLFWCharCallbackI cbfun) { + return mGLFWCharCallback = GLFWCharCallback.createSafe(nglfwSetCharCallback(window, memAddressSafe(cbfun))); + } + + public static GLFWCharModsCallback glfwSetCharModsCallback(@NativeType("GLFWwindow *") long window, @Nullable @NativeType("GLFWcharmodsfun") GLFWCharModsCallbackI cbfun) { + return mGLFWCharModsCallback = GLFWCharModsCallback.createSafe(nglfwSetCharModsCallback(window, memAddressSafe(cbfun))); + } + + public static GLFWCursorEnterCallback glfwSetCursorEnterCallback(@NativeType("GLFWwindow *") long window, @Nullable @NativeType("GLFWcursorenterfun") GLFWCursorEnterCallbackI cbfun) { + return mGLFWCursorEnterCallback = GLFWCursorEnterCallback.createSafe(nglfwSetCursorEnterCallback(window, memAddressSafe(cbfun))); + } + + public static GLFWCursorPosCallback glfwSetCursorPosCallback(@NativeType("GLFWwindow *") long window, @Nullable @NativeType("GLFWcursorposfun") GLFWCursorPosCallbackI cbfun) { + return mGLFWCursorPosCallback = GLFWCursorPosCallback.createSafe(nglfwSetCursorPosCallback(window, memAddressSafe(cbfun))); + } + + public static GLFWDropCallback glfwSetDropCallback(@NativeType("GLFWwindow *") long window, @Nullable @NativeType("GLFWdropfun") GLFWDropCallbackI cbfun) { + GLFWDropCallback lastCallback = mGLFWDropCallback; + if (cbfun == null) mGLFWDropCallback = null; + else mGLFWDropCallback = GLFWDropCallback.create(cbfun); + + return lastCallback; + } + + public static GLFWErrorCallback glfwSetErrorCallback(@Nullable @NativeType("GLFWerrorfun") GLFWErrorCallbackI cbfun) { + GLFWErrorCallback lastCallback = mGLFWErrorCallback; + if (cbfun == null) mGLFWErrorCallback = null; + else mGLFWErrorCallback = GLFWErrorCallback.create(cbfun); + + return lastCallback; + } + + public static GLFWFramebufferSizeCallback glfwSetFramebufferSizeCallback(@NativeType("GLFWwindow *") long window, @Nullable @NativeType("GLFWframebuffersizefun") GLFWFramebufferSizeCallbackI cbfun) { + return mGLFWFramebufferSizeCallback = GLFWFramebufferSizeCallback.createSafe(nglfwSetFramebufferSizeCallback(window, memAddressSafe(cbfun))); + } + + public static GLFWJoystickCallback glfwSetJoystickCallback(/* @NativeType("GLFWwindow *") long window, */ @Nullable @NativeType("GLFWjoystickfun") GLFWJoystickCallbackI cbfun) { + GLFWJoystickCallback lastCallback = mGLFWJoystickCallback; + if (cbfun == null) mGLFWJoystickCallback = null; + else mGLFWJoystickCallback = GLFWJoystickCallback.create(cbfun); + + return lastCallback; + } + + public static GLFWKeyCallback glfwSetKeyCallback(@NativeType("GLFWwindow *") long window, @Nullable @NativeType("GLFWkeyfun") GLFWKeyCallbackI cbfun) { + return mGLFWKeyCallback = GLFWKeyCallback.createSafe(nglfwSetKeyCallback(window, memAddressSafe(cbfun))); + } + + public static GLFWMonitorCallback glfwSetMonitorCallback(@Nullable @NativeType("GLFWmonitorfun") GLFWMonitorCallbackI cbfun) { + GLFWMonitorCallback lastCallback = mGLFWMonitorCallback; + if (cbfun == null) mGLFWMonitorCallback = null; + else mGLFWMonitorCallback = GLFWMonitorCallback.create(cbfun); + + return lastCallback; + } + + public static GLFWMouseButtonCallback glfwSetMouseButtonCallback(@NativeType("GLFWwindow *") long window, @Nullable @NativeType("GLFWmousebuttonfun") GLFWMouseButtonCallbackI cbfun) { + return mGLFWMouseButtonCallback = GLFWMouseButtonCallback.createSafe(nglfwSetMouseButtonCallback(window, memAddressSafe(cbfun))); + } + + public static GLFWScrollCallback glfwSetScrollCallback(@NativeType("GLFWwindow *") long window, @Nullable @NativeType("GLFWscrollfun") GLFWScrollCallbackI cbfun) { + return mGLFWScrollCallback = GLFWScrollCallback.createSafe(nglfwSetScrollCallback(window, memAddressSafe(cbfun))); + } + + public static GLFWWindowCloseCallback glfwSetWindowCloseCallback(@NativeType("GLFWwindow *") long window, @Nullable @NativeType("GLFWwindowclosefun") GLFWWindowCloseCallbackI cbfun) { + GLFWWindowCloseCallback lastCallback = mGLFWWindowCloseCallback; + if (cbfun == null) mGLFWWindowCloseCallback = null; + else mGLFWWindowCloseCallback = GLFWWindowCloseCallback.create(cbfun); + + return lastCallback; + } + + public static GLFWWindowContentScaleCallback glfwSetWindowContentScaleCallback(@NativeType("GLFWwindow *") long window, @Nullable @NativeType("GLFWwindowcontentscalefun") GLFWWindowContentScaleCallbackI cbfun) { + GLFWWindowContentScaleCallback lastCallback = mGLFWWindowContentScaleCallback; + if (cbfun == null) mGLFWWindowContentScaleCallback = null; + else mGLFWWindowContentScaleCallback = GLFWWindowContentScaleCallback.create(cbfun); + + return lastCallback; + } + + public static GLFWWindowFocusCallback glfwSetWindowFocusCallback(@NativeType("GLFWwindow *") long window, @Nullable @NativeType("GLFWwindowfocusfun") GLFWWindowFocusCallbackI cbfun) { + GLFWWindowFocusCallback lastCallback = mGLFWWindowFocusCallback; + if (cbfun == null) mGLFWWindowFocusCallback = null; + else mGLFWWindowFocusCallback = GLFWWindowFocusCallback.create(cbfun); + return lastCallback; + } + + public static GLFWWindowIconifyCallback glfwSetWindowIconifyCallback(@NativeType("GLFWwindow *") long window, @Nullable @NativeType("GLFWwindowiconifyfun") GLFWWindowIconifyCallbackI cbfun) { + GLFWWindowIconifyCallback lastCallback = mGLFWWindowIconifyCallback; + if (cbfun == null) mGLFWWindowIconifyCallback = null; + else mGLFWWindowIconifyCallback = GLFWWindowIconifyCallback.create(cbfun); + + return lastCallback; + } + + public static GLFWWindowMaximizeCallback glfwSetWindowMaximizeCallback(@NativeType("GLFWwindow *") long window, @Nullable @NativeType("GLFWwindowmaximizefun") GLFWWindowMaximizeCallbackI cbfun) { + GLFWWindowMaximizeCallback lastCallback = mGLFWWindowMaximizeCallback; + if (cbfun == null) mGLFWWindowMaximizeCallback = null; + else mGLFWWindowMaximizeCallback = GLFWWindowMaximizeCallback.create(cbfun); + + return lastCallback; + } + + public static GLFWWindowPosCallback glfwSetWindowPosCallback(@NativeType("GLFWwindow *") long window, @Nullable @NativeType("GLFWwindowposfun") GLFWWindowPosCallbackI cbfun) { + GLFWWindowPosCallback lastCallback = mGLFWWindowPosCallback; + if (cbfun == null) mGLFWWindowPosCallback = null; + else mGLFWWindowPosCallback = GLFWWindowPosCallback.create(cbfun); + + return lastCallback; + } + + public static GLFWWindowRefreshCallback glfwSetWindowRefreshCallback(@NativeType("GLFWwindow *") long window, @Nullable @NativeType("GLFWwindowrefreshfun") GLFWWindowRefreshCallbackI cbfun) { + GLFWWindowRefreshCallback lastCallback = mGLFWWindowRefreshCallback; + if (cbfun == null) mGLFWWindowRefreshCallback = null; + else mGLFWWindowRefreshCallback = GLFWWindowRefreshCallback.create(cbfun); + + return lastCallback; + } + + public static GLFWWindowSizeCallback glfwSetWindowSizeCallback(@NativeType("GLFWwindow *") long window, @Nullable @NativeType("GLFWwindowsizefun") GLFWWindowSizeCallbackI cbfun) { + return mGLFWWindowSizeCallback = GLFWWindowSizeCallback.createSafe(nglfwSetWindowSizeCallback(window, memAddressSafe(cbfun))); + } + + public static boolean glfwInit() { + mGLFWInitialTime = (double) System.nanoTime(); + return nativeEglInit(); + } + + public static void glfwTerminate() { + mGLFWIsInputReady = false; + CallbackBridge.nativeSetInputReady(false); + + nativeEglTerminate(); + } + + public static void glfwInitHint(int hint, int value) { } + + @NativeType("GLFWwindow *") + public static long glfwGetCurrentContext() { + // Stub prevent NULL check + return nativeEglGetCurrentContext(); + } + + public static void glfwGetFramebufferSize(@NativeType("GLFWwindow *") long window, @Nullable @NativeType("int *") IntBuffer width, @Nullable @NativeType("int *") IntBuffer height) { + if (CHECKS) { + checkSafe(width, 1); + checkSafe(height, 1); + } + width.put(internalGetWindow(window).width); + height.put(internalGetWindow(window).height); + } + + public static void glfwGetFramebufferSize(@NativeType("GLFWwindow *") long window, @Nullable @NativeType("int *") int[] width, @Nullable @NativeType("int *") int[] height) { + if (CHECKS) { + // check(window); + checkSafe(width, 1); + checkSafe(height, 1); + } + + width[0] = internalGetWindow(window).width; + height[0] = internalGetWindow(window).height; + } + + @Nullable + @NativeType("GLFWmonitor **") + public static PointerBuffer glfwGetMonitors() { + PointerBuffer pBuffer = PointerBuffer.allocateDirect(1); + pBuffer.put(glfwGetPrimaryMonitor()); + return pBuffer; + } + + public static long glfwGetPrimaryMonitor() { + // Prevent NULL check + return 1L; + } + + public static void glfwGetMonitorPos(@NativeType("GLFWmonitor *") long monitor, @Nullable @NativeType("int *") IntBuffer xpos, @Nullable @NativeType("int *") IntBuffer ypos) { + if (CHECKS) { + checkSafe(xpos, 1); + checkSafe(ypos, 1); + } + + xpos.put(0); + ypos.put(0); + } + + public static void glfwGetMonitorWorkarea(@NativeType("GLFWmonitor *") long monitor, @Nullable @NativeType("int *") IntBuffer xpos, @Nullable @NativeType("int *") IntBuffer ypos, @Nullable @NativeType("int *") IntBuffer width, @Nullable @NativeType("int *") IntBuffer height) { + if (CHECKS) { + checkSafe(xpos, 1); + checkSafe(ypos, 1); + checkSafe(width, 1); + checkSafe(height, 1); + } + + xpos.put(0); + ypos.put(0); + width.put(mGLFWWindowWidth); + height.put(mGLFWWindowHeight); + } + + public static void glfwGetMonitorPos(@NativeType("GLFWmonitor *") long monitor, @Nullable @NativeType("int *") int[] xpos, @Nullable @NativeType("int *") int[] ypos) { + if (CHECKS) { + // check(monitor); + checkSafe(xpos, 1); + checkSafe(ypos, 1); + } + + xpos[0] = 0; + ypos[0] = 0; + } + + /** Array version of: {@link #glfwGetMonitorWorkarea GetMonitorWorkarea} */ + public static void glfwGetMonitorWorkarea(@NativeType("GLFWmonitor *") long monitor, @Nullable @NativeType("int *") int[] xpos, @Nullable @NativeType("int *") int[] ypos, @Nullable @NativeType("int *") int[] width, @Nullable @NativeType("int *") int[] height) { + if (CHECKS) { + // check(monitor); + checkSafe(xpos, 1); + checkSafe(ypos, 1); + checkSafe(width, 1); + checkSafe(height, 1); + } + + xpos[0] = 0; + ypos[0] = 0; + width[0] = mGLFWWindowWidth; + height[0] = mGLFWWindowHeight; + } + + @NativeType("GLFWmonitor *") + public static long glfwGetWindowMonitor(@NativeType("GLFWwindow *") long window) { + return mGLFWWindowMonitor; + } + + public static void glfwSetWindowMonitor(@NativeType("GLFWwindow *") long window, @NativeType("GLFWmonitor *") long monitor, int xpos, int ypos, int width, int height, int refreshRate) { + // weird calculation to fake pointer + mGLFWWindowMonitor = window * monitor; + } + + public static int glfwGetWindowAttrib(@NativeType("GLFWwindow *") long window, int attrib) { + return internalGetWindow(window).windowAttribs.get(attrib); + } + + public static void glfwSetWindowAttrib(@NativeType("GLFWwindow *") long window, int attrib, int value) { + internalGetWindow(window).windowAttribs.put(attrib, value); + } + + public static void glfwGetVersion(IntBuffer major, IntBuffer minor, IntBuffer rev) { + if (CHECKS) { + checkSafe(major, 1); + checkSafe(minor, 1); + checkSafe(rev, 1); + } + + major.put(GLFW_VERSION_MAJOR); + minor.put(GLFW_VERSION_MINOR); + rev.put(GLFW_VERSION_REVISION); + } + + public static String glfwGetVersionString() { + return GLFW_VERSION_MAJOR + "." + GLFW_VERSION_MINOR + "." + GLFW_VERSION_REVISION; + } + + public static int glfwGetError(@Nullable PointerBuffer description) { + return GLFW_NO_ERROR; + } + + @Nullable + @NativeType("GLFWvidmode const *") + public static GLFWVidMode.Buffer glfwGetVideoModes(@NativeType("GLFWmonitor *") long monitor) { + MemoryStack stack = stackGet(); int stackPointer = stack.getPointer(); + IntBuffer count = stack.callocInt(1); + try { + // long __result = nglfwGetVideoModes(monitor, memAddress(count)); + long __result = memAddress(stack.callocLong(1)); + return GLFWVidMode.createSafe(__result, 1); + } finally { + stack.setPointer(stackPointer); + } + } + + @Nullable + public static GLFWVidMode glfwGetVideoMode(long monitor) { + return mGLFWVideoMode; + } + + public static GLFWGammaRamp glfwGetGammaRamp(@NativeType("GLFWmonitor *") long monitor) { + return mGLFWGammaRamp; + } + public static void glfwSetGammaRamp(@NativeType("GLFWmonitor *") long monitor, @NativeType("const GLFWgammaramp *") GLFWGammaRamp ramp) { + mGLFWGammaRamp = ramp; + } + + public static void glfwMakeContextCurrent(long window) { + long currentGLThreadId = Thread.currentThread().getId(); + // Long.parseLong(System.getProperty("glfwstub.internal.glthreadid", "-1")); + System.out.println("GLFW: glfwMakeContextCurrent() calling from thread ID " + currentGLThreadId + ", name: " + Thread.currentThread().getName()); + if (currentGLThreadId != -1 && currentGLThreadId != Thread.currentThread().getId()) { + System.out.println("GLFW: Current context is set, creating shared context"); + if (!nativeEglMakeCurrent(window)) { + throw new RuntimeException("eglMakeCurrent() failed, check log file for more details"); + } + } else { + System.out.println("GLFW: glfwMakeContextCurrent() request is skipped"); + } + } + + public static void glfwSwapBuffers(long window) { + nativeEglSwapBuffers(); + } + + public static void glfwSwapInterval(int interval) { + nativeEglSwapInterval(interval); + } + + // private static double mTime = 0d; + public static double glfwGetTime() { + // Boardwalk: just use system timer + // System.out.println("glfwGetTime"); + return (System.nanoTime() - mGLFWInitialTime) / 1.e9; + } + + public static void glfwSetTime(double time) { + mGLFWInitialTime = System.nanoTime() - (long) time; + } + + public static long glfwGetTimerValue() { + return System.currentTimeMillis(); + } + + public static long glfwGetTimerFrequency() { + // FIXME set correct value!! + return 60; + } + + // GLFW Window functions + public static long glfwCreateWindow(int width, int height, CharSequence title, long monitor, long share) { + EventLoop.OffScreen.check(); + + // A good idea to fake pointer + long ptr = System.currentTimeMillis(); + + GLFWWindowProperties win = new GLFWWindowProperties(); + // win.width = width; + // win.height = height; + + win.width = mGLFWWindowWidth; + win.height = mGLFWWindowHeight; + + win.title = title; + + mGLFWWindowMap.put(ptr, win); + + // Prevent NULL check + return ptr; + } + + public static void glfwDestroyWindow(long window) { + // Check window exists + internalGetWindow(window); + mGLFWWindowMap.remove(window); + nglfwSetShowingWindow(mGLFWWindowMap.size() == 0 ? 0 : mGLFWWindowMap.keyAt(mGLFWWindowMap.size() - 1)); + } + + public static void glfwDefaultWindowHints() {} + + public static void glfwGetWindowSize(long window, IntBuffer width, IntBuffer height) { + if (width != null) width.put(internalGetWindow(window).width); + if (height != null) height.put(internalGetWindow(window).height); + } + + public static void glfwSetWindowPos(long window, int x, int y) { + internalGetWindow(window).x = x; + internalGetWindow(window).y = y; + } + + public static void glfwSetWindowSize(long window, int width, int height) { + internalGetWindow(window).width = width; + internalGetWindow(window).height = height; + + System.out.println("GLFW: Set size for window " + window + ", width=" + width + ", height=" + height); + } + + public static void glfwShowWindow(long window) { + nglfwSetShowingWindow(window); + } + public static void glfwWindowHint(int hint, int value) {} + public static void glfwWindowHintString(int hint, @NativeType("const char *") ByteBuffer value) {} + public static void glfwWindowHintString(int hint, @NativeType("const char *") CharSequence value) {} + + public static boolean glfwWindowShouldClose(long window) { + return internalGetWindow(window).shouldClose; + } + + public static void glfwSetWindowShouldClose(long window, boolean close) { + internalGetWindow(window).shouldClose = close; + } + + + public static void glfwSetWindowTitle(@NativeType("GLFWwindow *") long window, @NativeType("char const *") ByteBuffer title) { + + } + public static void glfwSetWindowTitle(@NativeType("GLFWwindow *") long window, @NativeType("char const *") CharSequence title) { + internalGetWindow(window).title = title; + } + + public static void glfwSetWindowIcon(@NativeType("GLFWwindow *") long window, @Nullable @NativeType("GLFWimage const *") GLFWImage.Buffer images) {} + + public static void glfwPollEvents() { + if (!mGLFWIsInputReady) { + mGLFWIsInputReady = true; + mGLFWIsUseStackQueue = CallbackBridge.nativeSetInputReady(true); + } + + if (!CallbackBridge.PENDING_EVENT_READY) { + CallbackBridge.PENDING_EVENT_READY = true; + // nglfwSetInputReady(); + } + + // Indirect event + while (CallbackBridge.PENDING_EVENT_LIST.size() > 0) { + Integer[] dataArr = CallbackBridge.PENDING_EVENT_LIST.remove(0); + + if (dataArr == null) { // It should not be null, but still should be catched + // System.out.println("GLFW: popped callback is null, skipping"); + continue; + } + + for (Long ptr : mGLFWWindowMap.keySet()) { + switch (dataArr[0]) { + case CallbackBridge.EVENT_TYPE_CHAR: + if (mGLFWCharCallback != null) { + mGLFWCharCallback.invoke(ptr, dataArr[1]); + } + break; + case CallbackBridge.EVENT_TYPE_CHAR_MODS: + if (mGLFWCharModsCallback != null) { + mGLFWCharModsCallback.invoke(ptr, dataArr[1], dataArr[2]); + } + break; + case CallbackBridge.EVENT_TYPE_CURSOR_ENTER: + if (mGLFWCursorEnterCallback != null) { + mGLFWCursorEnterCallback.invoke(ptr, dataArr[1] == 1); + } + break; + case CallbackBridge.EVENT_TYPE_KEY: + if (mGLFWKeyCallback != null) { + mGLFWKeyCallback.invoke(ptr, dataArr[1], dataArr[2], dataArr[3], dataArr[4]); + } + break; + case CallbackBridge.EVENT_TYPE_MOUSE_BUTTON: + if (mGLFWMouseButtonCallback != null) { + mGLFWMouseButtonCallback.invoke(ptr, dataArr[1], dataArr[2], dataArr[3]); + } + break; + case CallbackBridge.EVENT_TYPE_SCROLL: + if (mGLFWScrollCallback != null) { + mGLFWScrollCallback.invoke(ptr, dataArr[1], dataArr[2]); + } + break; + case CallbackBridge.EVENT_TYPE_FRAMEBUFFER_SIZE: + case CallbackBridge.EVENT_TYPE_WINDOW_SIZE: + mGLFWWindowWidth = dataArr[1]; + mGLFWWindowHeight = dataArr[2]; + glfwSetWindowSize(ptr, mGLFWWindowWidth, mGLFWWindowHeight); + if (dataArr[0] == CallbackBridge.EVENT_TYPE_FRAMEBUFFER_SIZE && mGLFWFramebufferSizeCallback != null) { + mGLFWFramebufferSizeCallback.invoke(ptr, mGLFWWindowWidth, mGLFWWindowHeight); + } else if (dataArr[0] == CallbackBridge.EVENT_TYPE_WINDOW_SIZE && mGLFWWindowSizeCallback != null) { + mGLFWWindowSizeCallback.invoke(ptr, mGLFWWindowWidth, mGLFWWindowHeight); + } + break; + default: + System.err.println("GLFWEvent: unknown callback type " + dataArr[0]); + break; + } + } + } + + if ((mGLFWCursorX != mGLFWCursorLastX || mGLFWCursorY != mGLFWCursorLastY) && mGLFWCursorPosCallback != null) { + mGLFWCursorLastX = mGLFWCursorX; + mGLFWCursorLastY = mGLFWCursorY; + for (Long ptr : mGLFWWindowMap.keySet()) { + mGLFWCursorPosCallback.invoke(ptr, mGLFWCursorX, mGLFWCursorY); + } + // System.out.println("CursorPos updated to x=" + mGLFWCursorX + ",y=" + mGLFWCursorY); + } + } + + public static void glfwWaitEvents() {} + + public static void glfwWaitEventsTimeout(double timeout) { + // Boardwalk: this isn't how you do a frame limiter, but oh well + // System.out.println("Frame limiter"); + /* + try { + Thread.sleep((long)(timeout * 1000)); + } catch (InterruptedException ie) { + } + */ + // System.out.println("Out of the frame limiter"); + + } + + public static void glfwPostEmptyEvent() {} + + public static int glfwGetInputMode(@NativeType("GLFWwindow *") long window, int mode) { + return internalGetWindow(window).inputModes.get(mode); + } + + public static void glfwSetInputMode(@NativeType("GLFWwindow *") long window, int mode, int value) { + if (mode == GLFW_CURSOR) { + switch (value) { + case GLFW_CURSOR_DISABLED: + CallbackBridge.sendGrabbing(true, (int) mGLFWCursorX, (int) mGLFWCursorY); + break; + default: CallbackBridge.sendGrabbing(false, (int) mGLFWCursorX, (int) mGLFWCursorY); + } + } + + internalGetWindow(window).inputModes.put(mode, value); + } + public static String glfwGetKeyName(int key, int scancode) { + // TODO keyname list from GLFW + return mGLFWKeyCodes.get(key); + } + + public static int glfwGetKeyScancode(int key) { + return 0; + } + + public static int glfwGetKey(@NativeType("GLFWwindow *") long window, int key) { + return 0; + } + + public static int glfwGetMouseButton(@NativeType("GLFWwindow *") long window, int button) { + return 0; + } + + public static void glfwGetCursorPos(@NativeType("GLFWwindow *") long window, @Nullable @NativeType("double *") DoubleBuffer xpos, @Nullable @NativeType("double *") DoubleBuffer ypos) { + if (CHECKS) { + checkSafe(xpos, 1); + checkSafe(ypos, 1); + } + + xpos.put(mGLFWCursorX); + ypos.put(mGLFWCursorY); + } + + public static void glfwSetCursorPos(@NativeType("GLFWwindow *") long window, double xpos, double ypos) { + mGLFWCursorX = mGLFWCursorLastX = xpos; + mGLFWCursorY = mGLFWCursorLastY = ypos; + + CallbackBridge.sendGrabbing(mGLFWIsGrabbing, (int) xpos, (int) ypos); + } + + public static long glfwCreateCursor(@NativeType("const GLFWimage *") GLFWImage image, int xhot, int yhot) { + return 4L; + } + public static long glfwCreateStandardCursor(int shape) { + return 4L; + } + public static void glfwDestroyCursor(@NativeType("GLFWcursor *") long cursor) {} + public static void glfwSetCursor(@NativeType("GLFWwindow *") long window, @NativeType("GLFWcursor *") long cursor) {} + + public static boolean glfwRawMouseMotionSupported() { + // Should be not supported? + return false; + } + + public static void glfwSetClipboardString(@NativeType("GLFWwindow *") long window, @NativeType("char const *") ByteBuffer string) { + glfwSetClipboardString(window, memUTF8Safe(string)); + } + + public static void glfwSetClipboardString(@NativeType("GLFWwindow *") long window, @NativeType("char const *") CharSequence string) { + CallbackBridge.nativeClipboard(CallbackBridge.CLIPBOARD_COPY, string.toString()); + } + + public static String glfwGetClipboardString(@NativeType("GLFWwindow *") long window) { + return CallbackBridge.nativeClipboard(CallbackBridge.CLIPBOARD_PASTE, null); + } +} diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWCharCallback.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWCharCallback.java new file mode 100644 index 000000000..a349d2253 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWCharCallback.java @@ -0,0 +1,86 @@ +/* + * Copyright LWJGL. All rights reserved. + * License terms: https://www.lwjgl.org/license + * MACHINE GENERATED FILE, DO NOT EDIT + */ +package org.lwjgl.glfw; + +import javax.annotation.*; + +import org.lwjgl.system.*; + +import static org.lwjgl.system.MemoryUtil.*; + +import static org.lwjgl.glfw.GLFW.*; + +/** + * Instances of this class may be passed to the {@link GLFW#glfwSetCharCallback SetCharCallback} method. + * + *

Type

+ * + *

+ * void (*) (
+ *     GLFWwindow *window,
+ *     unsigned int codepoint
+ * )
+ * + * @since version 2.4 + */ +public abstract class GLFWCharCallback extends Callback implements GLFWCharCallbackI { + + /** + * Creates a {@code GLFWCharCallback} instance from the specified function pointer. + * + * @return the new {@code GLFWCharCallback} + */ + public static GLFWCharCallback create(long functionPointer) { + GLFWCharCallbackI instance = Callback.get(functionPointer); + return instance instanceof GLFWCharCallback + ? (GLFWCharCallback)instance + : new Container(functionPointer, instance); + } + + /** Like {@link #create(long) create}, but returns {@code null} if {@code functionPointer} is {@code NULL}. */ + @Nullable + public static GLFWCharCallback createSafe(long functionPointer) { + return functionPointer == NULL ? null : create(functionPointer); + } + + /** Creates a {@code GLFWCharCallback} instance that delegates to the specified {@code GLFWCharCallbackI} instance. */ + public static GLFWCharCallback create(GLFWCharCallbackI instance) { + return instance instanceof GLFWCharCallback + ? (GLFWCharCallback)instance + : new Container(instance.address(), instance); + } + + protected GLFWCharCallback() { + super(SIGNATURE); + } + + GLFWCharCallback(long functionPointer) { + super(functionPointer); + } + + /** See {@link GLFW#glfwSetCharCallback SetCharCallback}. */ + public GLFWCharCallback set(long window) { + glfwSetCharCallback(window, this); + return this; + } + + private static final class Container extends GLFWCharCallback { + + private final GLFWCharCallbackI delegate; + + Container(long functionPointer, GLFWCharCallbackI delegate) { + super(functionPointer); + this.delegate = delegate; + } + + @Override + public void invoke(long window, int codepoint) { + delegate.invoke(window, codepoint); + } + + } + +} \ No newline at end of file diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWCharCallbackI.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWCharCallbackI.java new file mode 100644 index 000000000..338b05c5f --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWCharCallbackI.java @@ -0,0 +1,50 @@ +/* + * Copyright LWJGL. All rights reserved. + * License terms: https://www.lwjgl.org/license + * MACHINE GENERATED FILE, DO NOT EDIT + */ +package org.lwjgl.glfw; + +import org.lwjgl.system.*; + +import static org.lwjgl.system.dyncall.DynCallback.*; + +/** + * Instances of this interface may be passed to the {@link GLFW#glfwSetCharCallback SetCharCallback} method. + * + *

Type

+ * + *

+ * void (*) (
+ *     GLFWwindow *window,
+ *     unsigned int codepoint
+ * )
+ * + * @since version 2.4 + */ +@FunctionalInterface +@NativeType("GLFWcharfun") +public interface GLFWCharCallbackI extends CallbackI.V { + + String SIGNATURE = "(pi)v"; + + @Override + default String getSignature() { return SIGNATURE; } + + @Override + default void callback(long args) { + invoke( + dcbArgPointer(args), + dcbArgInt(args) + ); + } + + /** + * Will be called when a Unicode character is input. + * + * @param window the window that received the event + * @param codepoint the Unicode code point of the character + */ + void invoke(@NativeType("GLFWwindow *") long window, @NativeType("unsigned int") int codepoint); + +} \ No newline at end of file diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWCharModsCallback.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWCharModsCallback.java new file mode 100644 index 000000000..c9edc08fa --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWCharModsCallback.java @@ -0,0 +1,89 @@ +/* + * Copyright LWJGL. All rights reserved. + * License terms: https://www.lwjgl.org/license + * MACHINE GENERATED FILE, DO NOT EDIT + */ +package org.lwjgl.glfw; + +import javax.annotation.*; + +import org.lwjgl.system.*; + +import static org.lwjgl.system.MemoryUtil.*; + +import static org.lwjgl.glfw.GLFW.*; + +/** + * Instances of this class may be passed to the {@link GLFW#glfwSetCharModsCallback SetCharModsCallback} method. + * + *

Deprecared: scheduled for removal in version 4.0.

+ * + *

Type

+ * + *

+ * void (*) (
+ *     GLFWwindow *window,
+ *     unsigned int codepoint,
+ *     int mods
+ * )
+ * + * @since version 3.1 + */ +public abstract class GLFWCharModsCallback extends Callback implements GLFWCharModsCallbackI { + + /** + * Creates a {@code GLFWCharModsCallback} instance from the specified function pointer. + * + * @return the new {@code GLFWCharModsCallback} + */ + public static GLFWCharModsCallback create(long functionPointer) { + GLFWCharModsCallbackI instance = Callback.get(functionPointer); + return instance instanceof GLFWCharModsCallback + ? (GLFWCharModsCallback)instance + : new Container(functionPointer, instance); + } + + /** Like {@link #create(long) create}, but returns {@code null} if {@code functionPointer} is {@code NULL}. */ + @Nullable + public static GLFWCharModsCallback createSafe(long functionPointer) { + return functionPointer == NULL ? null : create(functionPointer); + } + + /** Creates a {@code GLFWCharModsCallback} instance that delegates to the specified {@code GLFWCharModsCallbackI} instance. */ + public static GLFWCharModsCallback create(GLFWCharModsCallbackI instance) { + return instance instanceof GLFWCharModsCallback + ? (GLFWCharModsCallback)instance + : new Container(instance.address(), instance); + } + + protected GLFWCharModsCallback() { + super(SIGNATURE); + } + + GLFWCharModsCallback(long functionPointer) { + super(functionPointer); + } + + /** See {@link GLFW#glfwSetCharModsCallback SetCharModsCallback}. */ + public GLFWCharModsCallback set(long window) { + glfwSetCharModsCallback(window, this); + return this; + } + + private static final class Container extends GLFWCharModsCallback { + + private final GLFWCharModsCallbackI delegate; + + Container(long functionPointer, GLFWCharModsCallbackI delegate) { + super(functionPointer); + this.delegate = delegate; + } + + @Override + public void invoke(long window, int codepoint, int mods) { + delegate.invoke(window, codepoint, mods); + } + + } + +} \ No newline at end of file diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWCharModsCallbackI.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWCharModsCallbackI.java new file mode 100644 index 000000000..3008caad3 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWCharModsCallbackI.java @@ -0,0 +1,55 @@ +/* + * Copyright LWJGL. All rights reserved. + * License terms: https://www.lwjgl.org/license + * MACHINE GENERATED FILE, DO NOT EDIT + */ +package org.lwjgl.glfw; + +import org.lwjgl.system.*; + +import static org.lwjgl.system.dyncall.DynCallback.*; + +/** + * Instances of this interface may be passed to the {@link GLFW#glfwSetCharModsCallback SetCharModsCallback} method. + * + *

Deprecared: scheduled for removal in version 4.0.

+ * + *

Type

+ * + *

+ * void (*) (
+ *     GLFWwindow *window,
+ *     unsigned int codepoint,
+ *     int mods
+ * )
+ * + * @since version 3.1 + */ +@FunctionalInterface +@NativeType("GLFWcharmodsfun") +public interface GLFWCharModsCallbackI extends CallbackI.V { + + String SIGNATURE = "(pii)v"; + + @Override + default String getSignature() { return SIGNATURE; } + + @Override + default void callback(long args) { + invoke( + dcbArgPointer(args), + dcbArgInt(args), + dcbArgInt(args) + ); + } + + /** + * Will be called when a Unicode character is input regardless of what modifier keys are used. + * + * @param window the window that received the event + * @param codepoint the Unicode code point of the character + * @param mods bitfield describing which modifier keys were held down + */ + void invoke(@NativeType("GLFWwindow *") long window, @NativeType("unsigned int") int codepoint, int mods); + +} \ No newline at end of file diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWCursorEnterCallback.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWCursorEnterCallback.java new file mode 100644 index 000000000..bd02ce774 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWCursorEnterCallback.java @@ -0,0 +1,86 @@ +/* + * Copyright LWJGL. All rights reserved. + * License terms: https://www.lwjgl.org/license + * MACHINE GENERATED FILE, DO NOT EDIT + */ +package org.lwjgl.glfw; + +import javax.annotation.*; + +import org.lwjgl.system.*; + +import static org.lwjgl.system.MemoryUtil.*; + +import static org.lwjgl.glfw.GLFW.*; + +/** + * Instances of this class may be passed to the {@link GLFW#glfwSetCursorEnterCallback SetCursorEnterCallback} method. + * + *

Type

+ * + *

+ * void (*) (
+ *     GLFWwindow *window,
+ *     int entered
+ * )
+ * + * @since version 3.0 + */ +public abstract class GLFWCursorEnterCallback extends Callback implements GLFWCursorEnterCallbackI { + + /** + * Creates a {@code GLFWCursorEnterCallback} instance from the specified function pointer. + * + * @return the new {@code GLFWCursorEnterCallback} + */ + public static GLFWCursorEnterCallback create(long functionPointer) { + GLFWCursorEnterCallbackI instance = Callback.get(functionPointer); + return instance instanceof GLFWCursorEnterCallback + ? (GLFWCursorEnterCallback)instance + : new Container(functionPointer, instance); + } + + /** Like {@link #create(long) create}, but returns {@code null} if {@code functionPointer} is {@code NULL}. */ + @Nullable + public static GLFWCursorEnterCallback createSafe(long functionPointer) { + return functionPointer == NULL ? null : create(functionPointer); + } + + /** Creates a {@code GLFWCursorEnterCallback} instance that delegates to the specified {@code GLFWCursorEnterCallbackI} instance. */ + public static GLFWCursorEnterCallback create(GLFWCursorEnterCallbackI instance) { + return instance instanceof GLFWCursorEnterCallback + ? (GLFWCursorEnterCallback)instance + : new Container(instance.address(), instance); + } + + protected GLFWCursorEnterCallback() { + super(SIGNATURE); + } + + GLFWCursorEnterCallback(long functionPointer) { + super(functionPointer); + } + + /** See {@link GLFW#glfwSetCursorEnterCallback SetCursorEnterCallback}. */ + public GLFWCursorEnterCallback set(long window) { + glfwSetCursorEnterCallback(window, this); + return this; + } + + private static final class Container extends GLFWCursorEnterCallback { + + private final GLFWCursorEnterCallbackI delegate; + + Container(long functionPointer, GLFWCursorEnterCallbackI delegate) { + super(functionPointer); + this.delegate = delegate; + } + + @Override + public void invoke(long window, boolean entered) { + delegate.invoke(window, entered); + } + + } + +} \ No newline at end of file diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWCursorEnterCallbackI.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWCursorEnterCallbackI.java new file mode 100644 index 000000000..9be574b09 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWCursorEnterCallbackI.java @@ -0,0 +1,50 @@ +/* + * Copyright LWJGL. All rights reserved. + * License terms: https://www.lwjgl.org/license + * MACHINE GENERATED FILE, DO NOT EDIT + */ +package org.lwjgl.glfw; + +import org.lwjgl.system.*; + +import static org.lwjgl.system.dyncall.DynCallback.*; + +/** + * Instances of this interface may be passed to the {@link GLFW#glfwSetCursorEnterCallback SetCursorEnterCallback} method. + * + *

Type

+ * + *

+ * void (*) (
+ *     GLFWwindow *window,
+ *     int entered
+ * )
+ * + * @since version 3.0 + */ +@FunctionalInterface +@NativeType("GLFWcursorenterfun") +public interface GLFWCursorEnterCallbackI extends CallbackI.V { + + String SIGNATURE = "(pi)v"; + + @Override + default String getSignature() { return SIGNATURE; } + + @Override + default void callback(long args) { + invoke( + dcbArgPointer(args), + dcbArgInt(args) != 0 + ); + } + + /** + * Will be called when the cursor enters or leaves the client area of the window. + * + * @param window the window that received the event + * @param entered {@link GLFW#GLFW_TRUE TRUE} if the cursor entered the window's content area, or {@link GLFW#GLFW_FALSE FALSE} if it left it + */ + void invoke(@NativeType("GLFWwindow *") long window, @NativeType("int") boolean entered); + +} \ No newline at end of file diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWCursorPosCallback.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWCursorPosCallback.java new file mode 100644 index 000000000..1a4fa68d9 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWCursorPosCallback.java @@ -0,0 +1,87 @@ +/* + * Copyright LWJGL. All rights reserved. + * License terms: https://www.lwjgl.org/license + * MACHINE GENERATED FILE, DO NOT EDIT + */ +package org.lwjgl.glfw; + +import javax.annotation.*; + +import org.lwjgl.system.*; + +import static org.lwjgl.system.MemoryUtil.*; + +import static org.lwjgl.glfw.GLFW.*; + +/** + * Instances of this class may be passed to the {@link GLFW#glfwSetCursorPosCallback SetCursorPosCallback} method. + * + *

Type

+ * + *

+ * void (*) (
+ *     GLFWwindow *window,
+ *     double xpos,
+ *     double ypos
+ * )
+ * + * @since version 3.0 + */ +public abstract class GLFWCursorPosCallback extends Callback implements GLFWCursorPosCallbackI { + + /** + * Creates a {@code GLFWCursorPosCallback} instance from the specified function pointer. + * + * @return the new {@code GLFWCursorPosCallback} + */ + public static GLFWCursorPosCallback create(long functionPointer) { + GLFWCursorPosCallbackI instance = Callback.get(functionPointer); + return instance instanceof GLFWCursorPosCallback + ? (GLFWCursorPosCallback)instance + : new Container(functionPointer, instance); + } + + /** Like {@link #create(long) create}, but returns {@code null} if {@code functionPointer} is {@code NULL}. */ + @Nullable + public static GLFWCursorPosCallback createSafe(long functionPointer) { + return functionPointer == NULL ? null : create(functionPointer); + } + + /** Creates a {@code GLFWCursorPosCallback} instance that delegates to the specified {@code GLFWCursorPosCallbackI} instance. */ + public static GLFWCursorPosCallback create(GLFWCursorPosCallbackI instance) { + return instance instanceof GLFWCursorPosCallback + ? (GLFWCursorPosCallback)instance + : new Container(instance.address(), instance); + } + + protected GLFWCursorPosCallback() { + super(SIGNATURE); + } + + GLFWCursorPosCallback(long functionPointer) { + super(functionPointer); + } + + /** See {@link GLFW#glfwSetCursorPosCallback SetCursorPosCallback}. */ + public GLFWCursorPosCallback set(long window) { + glfwSetCursorPosCallback(window, this); + return this; + } + + private static final class Container extends GLFWCursorPosCallback { + + private final GLFWCursorPosCallbackI delegate; + + Container(long functionPointer, GLFWCursorPosCallbackI delegate) { + super(functionPointer); + this.delegate = delegate; + } + + @Override + public void invoke(long window, double xpos, double ypos) { + delegate.invoke(window, xpos, ypos); + } + + } + +} \ No newline at end of file diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWCursorPosCallbackI.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWCursorPosCallbackI.java new file mode 100644 index 000000000..8e4f717c2 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWCursorPosCallbackI.java @@ -0,0 +1,56 @@ +/* + * Copyright LWJGL. All rights reserved. + * License terms: https://www.lwjgl.org/license + * MACHINE GENERATED FILE, DO NOT EDIT + */ +package org.lwjgl.glfw; + +import org.lwjgl.system.*; + +import static org.lwjgl.system.dyncall.DynCallback.*; + +/** + * Instances of this interface may be passed to the {@link GLFW#glfwSetCursorPosCallback SetCursorPosCallback} method. + * + *

Type

+ * + *

+ * void (*) (
+ *     GLFWwindow *window,
+ *     double xpos,
+ *     double ypos
+ * )
+ * + * @since version 3.0 + */ +@FunctionalInterface +@NativeType("GLFWcursorposfun") +public interface GLFWCursorPosCallbackI extends CallbackI.V { + + String SIGNATURE = "(pdd)v"; + + @Override + default String getSignature() { return SIGNATURE; } + + @Override + default void callback(long args) { + invoke( + dcbArgPointer(args), + dcbArgDouble(args), + dcbArgDouble(args) + ); + } + + /** + * Will be called when the cursor is moved. + * + *

The callback function receives the cursor position, measured in screen coordinates but relative to the top-left corner of the window client area. On + * platforms that provide it, the full sub-pixel cursor position is passed on.

+ * + * @param window the window that received the event + * @param xpos the new cursor x-coordinate, relative to the left edge of the content area + * @param ypos the new cursor y-coordinate, relative to the top edge of the content area + */ + void invoke(@NativeType("GLFWwindow *") long window, double xpos, double ypos); + +} \ No newline at end of file diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWDropCallback.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWDropCallback.java new file mode 100644 index 000000000..eaf831c2d --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWDropCallback.java @@ -0,0 +1,101 @@ +/* + * Copyright LWJGL. All rights reserved. + * License terms: https://www.lwjgl.org/license + * MACHINE GENERATED FILE, DO NOT EDIT + */ +package org.lwjgl.glfw; + +import javax.annotation.*; + +import org.lwjgl.system.*; + +import static org.lwjgl.system.MemoryUtil.*; + +import static org.lwjgl.glfw.GLFW.*; + +/** + * Instances of this class may be passed to the {@link GLFW#glfwSetDropCallback SetDropCallback} method. + * + *

Type

+ * + *

+ * void (*) (
+ *     GLFWwindow *window,
+ *     int count,
+ *     char const **names
+ * )
+ * + * @since version 3.1 + */ +public abstract class GLFWDropCallback extends Callback implements GLFWDropCallbackI { + + /** + * Creates a {@code GLFWDropCallback} instance from the specified function pointer. + * + * @return the new {@code GLFWDropCallback} + */ + public static GLFWDropCallback create(long functionPointer) { + GLFWDropCallbackI instance = Callback.get(functionPointer); + return instance instanceof GLFWDropCallback + ? (GLFWDropCallback)instance + : new Container(functionPointer, instance); + } + + /** Like {@link #create(long) create}, but returns {@code null} if {@code functionPointer} is {@code NULL}. */ + @Nullable + public static GLFWDropCallback createSafe(long functionPointer) { + return functionPointer == NULL ? null : create(functionPointer); + } + + /** Creates a {@code GLFWDropCallback} instance that delegates to the specified {@code GLFWDropCallbackI} instance. */ + public static GLFWDropCallback create(GLFWDropCallbackI instance) { + return instance instanceof GLFWDropCallback + ? (GLFWDropCallback)instance + : new Container(instance.address(), instance); + } + + protected GLFWDropCallback() { + super(SIGNATURE); + } + + GLFWDropCallback(long functionPointer) { + super(functionPointer); + } + + /** + * Decodes the specified {@link GLFWDropCallback} arguments to a String. + * + *

This method may only be used inside a {@code GLFWDropCallback} invocation.

+ * + * @param names pointer to the array of UTF-8 encoded path names of the dropped files + * @param index the index to decode + * + * @return the name at the specified index as a String + */ + public static String getName(long names, int index) { + return memUTF8(memGetAddress(names + Pointer.POINTER_SIZE * index)); + } + + /** See {@link GLFW#glfwSetDropCallback SetDropCallback}. */ + public GLFWDropCallback set(long window) { + glfwSetDropCallback(window, this); + return this; + } + + private static final class Container extends GLFWDropCallback { + + private final GLFWDropCallbackI delegate; + + Container(long functionPointer, GLFWDropCallbackI delegate) { + super(functionPointer); + this.delegate = delegate; + } + + @Override + public void invoke(long window, int count, long names) { + delegate.invoke(window, count, names); + } + + } + +} \ No newline at end of file diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWDropCallbackI.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWDropCallbackI.java new file mode 100644 index 000000000..7528629e1 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWDropCallbackI.java @@ -0,0 +1,53 @@ +/* + * Copyright LWJGL. All rights reserved. + * License terms: https://www.lwjgl.org/license + * MACHINE GENERATED FILE, DO NOT EDIT + */ +package org.lwjgl.glfw; + +import org.lwjgl.system.*; + +import static org.lwjgl.system.dyncall.DynCallback.*; + +/** + * Instances of this interface may be passed to the {@link GLFW#glfwSetDropCallback SetDropCallback} method. + * + *

Type

+ * + *

+ * void (*) (
+ *     GLFWwindow *window,
+ *     int count,
+ *     char const **names
+ * )
+ * + * @since version 3.1 + */ +@FunctionalInterface +@NativeType("GLFWdropfun") +public interface GLFWDropCallbackI extends CallbackI.V { + + String SIGNATURE = "(pip)v"; + + @Override + default String getSignature() { return SIGNATURE; } + + @Override + default void callback(long args) { + invoke( + dcbArgPointer(args), + dcbArgInt(args), + dcbArgPointer(args) + ); + } + + /** + * Will be called when one or more dragged files are dropped on the window. + * + * @param window the window that received the event + * @param count the number of dropped files + * @param names pointer to the array of UTF-8 encoded path names of the dropped files + */ + void invoke(@NativeType("GLFWwindow *") long window, int count, @NativeType("char const **") long names); + +} \ No newline at end of file diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWErrorCallback.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWErrorCallback.java new file mode 100644 index 000000000..1c52cca51 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWErrorCallback.java @@ -0,0 +1,156 @@ +/* + * Copyright LWJGL. All rights reserved. + * License terms: https://www.lwjgl.org/license + * MACHINE GENERATED FILE, DO NOT EDIT + */ +package org.lwjgl.glfw; + +import javax.annotation.*; + +import org.lwjgl.system.*; + +import static org.lwjgl.system.MemoryUtil.*; + +import java.io.PrintStream; +import java.util.Map; + +import static org.lwjgl.glfw.GLFW.*; + +/** + * Instances of this class may be passed to the {@link GLFW#glfwSetErrorCallback SetErrorCallback} method. + * + *

Type

+ * + *

+ * void (*) (
+ *     int error,
+ *     char *description
+ * )
+ * + * @since version 3.0 + */ +public abstract class GLFWErrorCallback extends Callback implements GLFWErrorCallbackI { + + /** + * Creates a {@code GLFWErrorCallback} instance from the specified function pointer. + * + * @return the new {@code GLFWErrorCallback} + */ + public static GLFWErrorCallback create(long functionPointer) { + GLFWErrorCallbackI instance = Callback.get(functionPointer); + return instance instanceof GLFWErrorCallback + ? (GLFWErrorCallback)instance + : new Container(functionPointer, instance); + } + + /** Like {@link #create(long) create}, but returns {@code null} if {@code functionPointer} is {@code NULL}. */ + @Nullable + public static GLFWErrorCallback createSafe(long functionPointer) { + return functionPointer == NULL ? null : create(functionPointer); + } + + /** Creates a {@code GLFWErrorCallback} instance that delegates to the specified {@code GLFWErrorCallbackI} instance. */ + public static GLFWErrorCallback create(GLFWErrorCallbackI instance) { + return instance instanceof GLFWErrorCallback + ? (GLFWErrorCallback)instance + : new Container(instance.address(), instance); + } + + protected GLFWErrorCallback() { + super(SIGNATURE); + } + + GLFWErrorCallback(long functionPointer) { + super(functionPointer); + } + + /** + * Converts the specified {@link GLFWErrorCallback} argument to a String. + * + *

This method may only be used inside a GLFWErrorCallback invocation.

+ * + * @param description pointer to the UTF-8 encoded description string + * + * @return the description as a String + */ + public static String getDescription(long description) { + try { + return memUTF8(description); + } catch (NullPointerException e) { + return "null (unknown " + Long.toHexString(description) + ")"; + } + } + + /** + * Returns a {@link GLFWErrorCallback} instance that prints the error to the {@link APIUtil#DEBUG_STREAM}. + * + * @return the GLFWerrorCallback + */ + public static GLFWErrorCallback createPrint() { + return createPrint(APIUtil.DEBUG_STREAM); + } + + /** + * Returns a {@link GLFWErrorCallback} instance that prints the error in the specified {@link PrintStream}. + * + * @param stream the PrintStream to use + * + * @return the GLFWerrorCallback + */ + public static GLFWErrorCallback createPrint(PrintStream stream) { + return new GLFWErrorCallback() { + private Map ERROR_CODES = APIUtil.apiClassTokens((field, value) -> 0x10000 < value && value < 0x20000, null, GLFW.class); + + @Override + public void invoke(int error, long description) { + String msg = getDescription(description); + + stream.printf("[LWJGL] %s error\n", ERROR_CODES.get(error)); + stream.println("\tDescription : " + msg); + stream.println("\tStacktrace :"); + StackTraceElement[] stack = Thread.currentThread().getStackTrace(); + for ( int i = 4; i < stack.length; i++ ) { + stream.print("\t\t"); + stream.println(stack[i].toString()); + } + } + }; + } + + /** + * Returns a {@link GLFWErrorCallback} instance that throws an {@link IllegalStateException} when an error occurs. + * + * @return the GLFWerrorCallback + */ + public static GLFWErrorCallback createThrow() { + return new GLFWErrorCallback() { + @Override + public void invoke(int error, long description) { + throw new IllegalStateException(String.format("GLFW error [0x%X]: %s", error, getDescription(description))); + } + }; + } + + /** See {@link GLFW#glfwSetErrorCallback SetErrorCallback}. */ + public GLFWErrorCallback set() { + glfwSetErrorCallback(this); + return this; + } + + private static final class Container extends GLFWErrorCallback { + + private final GLFWErrorCallbackI delegate; + + Container(long functionPointer, GLFWErrorCallbackI delegate) { + super(functionPointer); + this.delegate = delegate; + } + + @Override + public void invoke(int error, long description) { + delegate.invoke(error, description); + } + + } + +} diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWErrorCallbackI.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWErrorCallbackI.java new file mode 100644 index 000000000..62841da17 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWErrorCallbackI.java @@ -0,0 +1,50 @@ +/* + * Copyright LWJGL. All rights reserved. + * License terms: https://www.lwjgl.org/license + * MACHINE GENERATED FILE, DO NOT EDIT + */ +package org.lwjgl.glfw; + +import org.lwjgl.system.*; + +import static org.lwjgl.system.dyncall.DynCallback.*; + +/** + * Instances of this interface may be passed to the {@link GLFW#glfwSetErrorCallback SetErrorCallback} method. + * + *

Type

+ * + *

+ * void (*) (
+ *     int error,
+ *     char *description
+ * )
+ * + * @since version 3.0 + */ +@FunctionalInterface +@NativeType("GLFWerrorfun") +public interface GLFWErrorCallbackI extends CallbackI.V { + + String SIGNATURE = "(ip)v"; + + @Override + default String getSignature() { return SIGNATURE; } + + @Override + default void callback(long args) { + invoke( + dcbArgInt(args), + dcbArgPointer(args) + ); + } + + /** + * Will be called with an error code and a human-readable description when a GLFW error occurs. + * + * @param error the error code + * @param description a pointer to a UTF-8 encoded string describing the error + */ + void invoke(int error, @NativeType("char *") long description); + +} diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWFramebufferSizeCallback.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWFramebufferSizeCallback.java new file mode 100644 index 000000000..2e66f76f2 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWFramebufferSizeCallback.java @@ -0,0 +1,87 @@ +/* + * Copyright LWJGL. All rights reserved. + * License terms: https://www.lwjgl.org/license + * MACHINE GENERATED FILE, DO NOT EDIT + */ +package org.lwjgl.glfw; + +import javax.annotation.*; + +import org.lwjgl.system.*; + +import static org.lwjgl.system.MemoryUtil.*; + +import static org.lwjgl.glfw.GLFW.*; + +/** + * Instances of this class may be passed to the {@link GLFW#glfwSetFramebufferSizeCallback SetFramebufferSizeCallback} method. + * + *

Type

+ * + *

+ * void (*) (
+ *     GLFWwindow *window,
+ *     int width,
+ *     int height
+ * )
+ * + * @since version 3.0 + */ +public abstract class GLFWFramebufferSizeCallback extends Callback implements GLFWFramebufferSizeCallbackI { + + /** + * Creates a {@code GLFWFramebufferSizeCallback} instance from the specified function pointer. + * + * @return the new {@code GLFWFramebufferSizeCallback} + */ + public static GLFWFramebufferSizeCallback create(long functionPointer) { + GLFWFramebufferSizeCallbackI instance = Callback.get(functionPointer); + return instance instanceof GLFWFramebufferSizeCallback + ? (GLFWFramebufferSizeCallback)instance + : new Container(functionPointer, instance); + } + + /** Like {@link #create(long) create}, but returns {@code null} if {@code functionPointer} is {@code NULL}. */ + @Nullable + public static GLFWFramebufferSizeCallback createSafe(long functionPointer) { + return functionPointer == NULL ? null : create(functionPointer); + } + + /** Creates a {@code GLFWFramebufferSizeCallback} instance that delegates to the specified {@code GLFWFramebufferSizeCallbackI} instance. */ + public static GLFWFramebufferSizeCallback create(GLFWFramebufferSizeCallbackI instance) { + return instance instanceof GLFWFramebufferSizeCallback + ? (GLFWFramebufferSizeCallback)instance + : new Container(instance.address(), instance); + } + + protected GLFWFramebufferSizeCallback() { + super(SIGNATURE); + } + + GLFWFramebufferSizeCallback(long functionPointer) { + super(functionPointer); + } + + /** See {@link GLFW#glfwSetFramebufferSizeCallback SetFramebufferSizeCallback}. */ + public GLFWFramebufferSizeCallback set(long window) { + glfwSetFramebufferSizeCallback(window, this); + return this; + } + + private static final class Container extends GLFWFramebufferSizeCallback { + + private final GLFWFramebufferSizeCallbackI delegate; + + Container(long functionPointer, GLFWFramebufferSizeCallbackI delegate) { + super(functionPointer); + this.delegate = delegate; + } + + @Override + public void invoke(long window, int width, int height) { + delegate.invoke(window, width, height); + } + + } + +} \ No newline at end of file diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWFramebufferSizeCallbackI.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWFramebufferSizeCallbackI.java new file mode 100644 index 000000000..098e2b2c5 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWFramebufferSizeCallbackI.java @@ -0,0 +1,53 @@ +/* + * Copyright LWJGL. All rights reserved. + * License terms: https://www.lwjgl.org/license + * MACHINE GENERATED FILE, DO NOT EDIT + */ +package org.lwjgl.glfw; + +import org.lwjgl.system.*; + +import static org.lwjgl.system.dyncall.DynCallback.*; + +/** + * Instances of this interface may be passed to the {@link GLFW#glfwSetFramebufferSizeCallback SetFramebufferSizeCallback} method. + * + *

Type

+ * + *

+ * void (*) (
+ *     GLFWwindow *window,
+ *     int width,
+ *     int height
+ * )
+ * + * @since version 3.0 + */ +@FunctionalInterface +@NativeType("GLFWframebuffersizefun") +public interface GLFWFramebufferSizeCallbackI extends CallbackI.V { + + String SIGNATURE = "(pii)v"; + + @Override + default String getSignature() { return SIGNATURE; } + + @Override + default void callback(long args) { + invoke( + dcbArgPointer(args), + dcbArgInt(args), + dcbArgInt(args) + ); + } + + /** + * Will be called when the framebuffer of the specified window is resized. + * + * @param window the window whose framebuffer was resized + * @param width the new width, in pixels, of the framebuffer + * @param height the new height, in pixels, of the framebuffer + */ + void invoke(@NativeType("GLFWwindow *") long window, int width, int height); + +} \ No newline at end of file diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWGamepadState.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWGamepadState.java new file mode 100644 index 000000000..17792e416 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWGamepadState.java @@ -0,0 +1,359 @@ +/* + * Copyright LWJGL. All rights reserved. + * License terms: https://www.lwjgl.org/license + * MACHINE GENERATED FILE, DO NOT EDIT + */ +package org.lwjgl.glfw; + +import javax.annotation.*; + +import java.nio.*; + +import org.lwjgl.*; +import org.lwjgl.system.*; + +import static org.lwjgl.system.Checks.*; +import static org.lwjgl.system.MemoryUtil.*; +import static org.lwjgl.system.MemoryStack.*; + +/** + * Describes the input state of a gamepad. + * + *

Member documentation

+ * + *
    + *
  • {@code buttons[15]} – the states of each gamepad button, {@link GLFW#GLFW_PRESS PRESS} or {@link GLFW#GLFW_RELEASE RELEASE}
  • + *
  • {@code axes[6]} – the states of each gamepad axis, in the range -1.0 to 1.0 inclusive
  • + *
+ * + *

Layout

+ * + *

+ * struct GLFWgamepadstate {
+ *     unsigned char buttons[15];
+ *     float axes[6];
+ * }
+ * + * @since version 3.3 + */ +@NativeType("struct GLFWgamepadstate") +public class GLFWGamepadState extends Struct implements NativeResource { + + /** The struct size in bytes. */ + public static final int SIZEOF; + + /** The struct alignment in bytes. */ + public static final int ALIGNOF; + + /** The struct member offsets. */ + public static final int + BUTTONS, + AXES; + + static { + Layout layout = __struct( + __array(1, 15), + __array(4, 6) + ); + + SIZEOF = layout.getSize(); + ALIGNOF = layout.getAlignment(); + + BUTTONS = layout.offsetof(0); + AXES = layout.offsetof(1); + } + + /** + * Creates a {@code GLFWGamepadState} instance at the current position of the specified {@link ByteBuffer} container. Changes to the buffer's content will be + * visible to the struct instance and vice versa. + * + *

The created instance holds a strong reference to the container object.

+ */ + public GLFWGamepadState(ByteBuffer container) { + super(memAddress(container), __checkContainer(container, SIZEOF)); + } + + @Override + public int sizeof() { return SIZEOF; } + + /** Returns a {@link ByteBuffer} view of the {@code buttons} field. */ + @NativeType("unsigned char[15]") + public ByteBuffer buttons() { return nbuttons(address()); } + /** Returns the value at the specified index of the {@code buttons} field. */ + @NativeType("unsigned char") + public byte buttons(int index) { return nbuttons(address(), index); } + /** Returns a {@link FloatBuffer} view of the {@code axes} field. */ + @NativeType("float[6]") + public FloatBuffer axes() { return naxes(address()); } + /** Returns the value at the specified index of the {@code axes} field. */ + public float axes(int index) { return naxes(address(), index); } + + /** Copies the specified {@link ByteBuffer} to the {@code buttons} field. */ + public GLFWGamepadState buttons(@NativeType("unsigned char[15]") ByteBuffer value) { nbuttons(address(), value); return this; } + /** Sets the specified value at the specified index of the {@code buttons} field. */ + public GLFWGamepadState buttons(int index, @NativeType("unsigned char") byte value) { nbuttons(address(), index, value); return this; } + /** Copies the specified {@link FloatBuffer} to the {@code axes} field. */ + public GLFWGamepadState axes(@NativeType("float[6]") FloatBuffer value) { naxes(address(), value); return this; } + /** Sets the specified value at the specified index of the {@code axes} field. */ + public GLFWGamepadState axes(int index, float value) { naxes(address(), index, value); return this; } + + /** Initializes this struct with the specified values. */ + public GLFWGamepadState set( + ByteBuffer buttons, + FloatBuffer axes + ) { + buttons(buttons); + axes(axes); + + return this; + } + + /** + * Copies the specified struct data to this struct. + * + * @param src the source struct + * + * @return this struct + */ + public GLFWGamepadState set(GLFWGamepadState src) { + memCopy(src.address(), address(), SIZEOF); + return this; + } + + // ----------------------------------- + + /** Returns a new {@code GLFWGamepadState} instance allocated with {@link MemoryUtil#memAlloc memAlloc}. The instance must be explicitly freed. */ + public static GLFWGamepadState malloc() { + return wrap(GLFWGamepadState.class, nmemAllocChecked(SIZEOF)); + } + + /** Returns a new {@code GLFWGamepadState} instance allocated with {@link MemoryUtil#memCalloc memCalloc}. The instance must be explicitly freed. */ + public static GLFWGamepadState calloc() { + return wrap(GLFWGamepadState.class, nmemCallocChecked(1, SIZEOF)); + } + + /** Returns a new {@code GLFWGamepadState} instance allocated with {@link BufferUtils}. */ + public static GLFWGamepadState create() { + ByteBuffer container = BufferUtils.createByteBuffer(SIZEOF); + return wrap(GLFWGamepadState.class, memAddress(container), container); + } + + /** Returns a new {@code GLFWGamepadState} instance for the specified memory address. */ + public static GLFWGamepadState create(long address) { + return wrap(GLFWGamepadState.class, address); + } + + /** Like {@link #create(long) create}, but returns {@code null} if {@code address} is {@code NULL}. */ + @Nullable + public static GLFWGamepadState createSafe(long address) { + return address == NULL ? null : wrap(GLFWGamepadState.class, address); + } + + /** + * Returns a new {@link GLFWGamepadState.Buffer} instance allocated with {@link MemoryUtil#memAlloc memAlloc}. The instance must be explicitly freed. + * + * @param capacity the buffer capacity + */ + public static GLFWGamepadState.Buffer malloc(int capacity) { + return wrap(Buffer.class, nmemAllocChecked(__checkMalloc(capacity, SIZEOF)), capacity); + } + + /** + * Returns a new {@link GLFWGamepadState.Buffer} instance allocated with {@link MemoryUtil#memCalloc memCalloc}. The instance must be explicitly freed. + * + * @param capacity the buffer capacity + */ + public static GLFWGamepadState.Buffer calloc(int capacity) { + return wrap(Buffer.class, nmemCallocChecked(capacity, SIZEOF), capacity); + } + + /** + * Returns a new {@link GLFWGamepadState.Buffer} instance allocated with {@link BufferUtils}. + * + * @param capacity the buffer capacity + */ + public static GLFWGamepadState.Buffer create(int capacity) { + ByteBuffer container = __create(capacity, SIZEOF); + return wrap(Buffer.class, memAddress(container), capacity, container); + } + + /** + * Create a {@link GLFWGamepadState.Buffer} instance at the specified memory. + * + * @param address the memory address + * @param capacity the buffer capacity + */ + public static GLFWGamepadState.Buffer create(long address, int capacity) { + return wrap(Buffer.class, address, capacity); + } + + /** Like {@link #create(long, int) create}, but returns {@code null} if {@code address} is {@code NULL}. */ + @Nullable + public static GLFWGamepadState.Buffer createSafe(long address, int capacity) { + return address == NULL ? null : wrap(Buffer.class, address, capacity); + } + + // ----------------------------------- + + /** Returns a new {@code GLFWGamepadState} instance allocated on the thread-local {@link MemoryStack}. */ + public static GLFWGamepadState mallocStack() { + return mallocStack(stackGet()); + } + + /** Returns a new {@code GLFWGamepadState} instance allocated on the thread-local {@link MemoryStack} and initializes all its bits to zero. */ + public static GLFWGamepadState callocStack() { + return callocStack(stackGet()); + } + + /** + * Returns a new {@code GLFWGamepadState} instance allocated on the specified {@link MemoryStack}. + * + * @param stack the stack from which to allocate + */ + public static GLFWGamepadState mallocStack(MemoryStack stack) { + return wrap(GLFWGamepadState.class, stack.nmalloc(ALIGNOF, SIZEOF)); + } + + /** + * Returns a new {@code GLFWGamepadState} instance allocated on the specified {@link MemoryStack} and initializes all its bits to zero. + * + * @param stack the stack from which to allocate + */ + public static GLFWGamepadState callocStack(MemoryStack stack) { + return wrap(GLFWGamepadState.class, stack.ncalloc(ALIGNOF, 1, SIZEOF)); + } + + /** + * Returns a new {@link GLFWGamepadState.Buffer} instance allocated on the thread-local {@link MemoryStack}. + * + * @param capacity the buffer capacity + */ + public static GLFWGamepadState.Buffer mallocStack(int capacity) { + return mallocStack(capacity, stackGet()); + } + + /** + * Returns a new {@link GLFWGamepadState.Buffer} instance allocated on the thread-local {@link MemoryStack} and initializes all its bits to zero. + * + * @param capacity the buffer capacity + */ + public static GLFWGamepadState.Buffer callocStack(int capacity) { + return callocStack(capacity, stackGet()); + } + + /** + * Returns a new {@link GLFWGamepadState.Buffer} instance allocated on the specified {@link MemoryStack}. + * + * @param stack the stack from which to allocate + * @param capacity the buffer capacity + */ + public static GLFWGamepadState.Buffer mallocStack(int capacity, MemoryStack stack) { + return wrap(Buffer.class, stack.nmalloc(ALIGNOF, capacity * SIZEOF), capacity); + } + + /** + * Returns a new {@link GLFWGamepadState.Buffer} instance allocated on the specified {@link MemoryStack} and initializes all its bits to zero. + * + * @param stack the stack from which to allocate + * @param capacity the buffer capacity + */ + public static GLFWGamepadState.Buffer callocStack(int capacity, MemoryStack stack) { + return wrap(Buffer.class, stack.ncalloc(ALIGNOF, capacity, SIZEOF), capacity); + } + + // ----------------------------------- + + /** Unsafe version of {@link #buttons}. */ + public static ByteBuffer nbuttons(long struct) { return memByteBuffer(struct + GLFWGamepadState.BUTTONS, 15); } + /** Unsafe version of {@link #buttons(int) buttons}. */ + public static byte nbuttons(long struct, int index) { + return UNSAFE.getByte(null, struct + GLFWGamepadState.BUTTONS + check(index, 15) * 1); + } + /** Unsafe version of {@link #axes}. */ + public static FloatBuffer naxes(long struct) { return memFloatBuffer(struct + GLFWGamepadState.AXES, 6); } + /** Unsafe version of {@link #axes(int) axes}. */ + public static float naxes(long struct, int index) { + return UNSAFE.getFloat(null, struct + GLFWGamepadState.AXES + check(index, 6) * 4); + } + + /** Unsafe version of {@link #buttons(ByteBuffer) buttons}. */ + public static void nbuttons(long struct, ByteBuffer value) { + if (CHECKS) { checkGT(value, 15); } + memCopy(memAddress(value), struct + GLFWGamepadState.BUTTONS, value.remaining() * 1); + } + /** Unsafe version of {@link #buttons(int, byte) buttons}. */ + public static void nbuttons(long struct, int index, byte value) { + UNSAFE.putByte(null, struct + GLFWGamepadState.BUTTONS + check(index, 15) * 1, value); + } + /** Unsafe version of {@link #axes(FloatBuffer) axes}. */ + public static void naxes(long struct, FloatBuffer value) { + if (CHECKS) { checkGT(value, 6); } + memCopy(memAddress(value), struct + GLFWGamepadState.AXES, value.remaining() * 4); + } + /** Unsafe version of {@link #axes(int, float) axes}. */ + public static void naxes(long struct, int index, float value) { + UNSAFE.putFloat(null, struct + GLFWGamepadState.AXES + check(index, 6) * 4, value); + } + + // ----------------------------------- + + /** An array of {@link GLFWGamepadState} structs. */ + public static class Buffer extends StructBuffer implements NativeResource { + + private static final GLFWGamepadState ELEMENT_FACTORY = GLFWGamepadState.create(-1L); + + /** + * Creates a new {@code GLFWGamepadState.Buffer} instance backed by the specified container. + * + * Changes to the container's content will be visible to the struct buffer instance and vice versa. The two buffers' position, limit, and mark values + * will be independent. The new buffer's position will be zero, its capacity and its limit will be the number of bytes remaining in this buffer divided + * by {@link GLFWGamepadState#SIZEOF}, and its mark will be undefined. + * + *

The created buffer instance holds a strong reference to the container object.

+ */ + public Buffer(ByteBuffer container) { + super(container, container.remaining() / SIZEOF); + } + + public Buffer(long address, int cap) { + super(address, null, -1, 0, cap, cap); + } + + Buffer(long address, @Nullable ByteBuffer container, int mark, int pos, int lim, int cap) { + super(address, container, mark, pos, lim, cap); + } + + @Override + protected Buffer self() { + return this; + } + + @Override + protected GLFWGamepadState getElementFactory() { + return ELEMENT_FACTORY; + } + + /** Returns a {@link ByteBuffer} view of the {@code buttons} field. */ + @NativeType("unsigned char[15]") + public ByteBuffer buttons() { return GLFWGamepadState.nbuttons(address()); } + /** Returns the value at the specified index of the {@code buttons} field. */ + @NativeType("unsigned char") + public byte buttons(int index) { return GLFWGamepadState.nbuttons(address(), index); } + /** Returns a {@link FloatBuffer} view of the {@code axes} field. */ + @NativeType("float[6]") + public FloatBuffer axes() { return GLFWGamepadState.naxes(address()); } + /** Returns the value at the specified index of the {@code axes} field. */ + public float axes(int index) { return GLFWGamepadState.naxes(address(), index); } + + /** Copies the specified {@link ByteBuffer} to the {@code buttons} field. */ + public GLFWGamepadState.Buffer buttons(@NativeType("unsigned char[15]") ByteBuffer value) { GLFWGamepadState.nbuttons(address(), value); return this; } + /** Sets the specified value at the specified index of the {@code buttons} field. */ + public GLFWGamepadState.Buffer buttons(int index, @NativeType("unsigned char") byte value) { GLFWGamepadState.nbuttons(address(), index, value); return this; } + /** Copies the specified {@link FloatBuffer} to the {@code axes} field. */ + public GLFWGamepadState.Buffer axes(@NativeType("float[6]") FloatBuffer value) { GLFWGamepadState.naxes(address(), value); return this; } + /** Sets the specified value at the specified index of the {@code axes} field. */ + public GLFWGamepadState.Buffer axes(int index, float value) { GLFWGamepadState.naxes(address(), index, value); return this; } + + } + +} \ No newline at end of file diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWGammaRamp.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWGammaRamp.java new file mode 100644 index 000000000..b0c051bfd --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWGammaRamp.java @@ -0,0 +1,384 @@ +/* + * Copyright LWJGL. All rights reserved. + * License terms: https://www.lwjgl.org/license + * MACHINE GENERATED FILE, DO NOT EDIT + */ +package org.lwjgl.glfw; + +import javax.annotation.*; + +import java.nio.*; + +import org.lwjgl.*; +import org.lwjgl.system.*; + +import static org.lwjgl.system.Checks.*; +import static org.lwjgl.system.MemoryUtil.*; +import static org.lwjgl.system.MemoryStack.*; + +/** + * Describes the gamma ramp for a monitor. + * + *

Member documentation

+ * + *
    + *
  • {@code red} – an array of values describing the response of the red channel
  • + *
  • {@code green} – an array of values describing the response of the green channel
  • + *
  • {@code blue} – an array of values describing the response of the blue channel
  • + *
  • {@code size} – the number of elements in each array
  • + *
+ * + *

Layout

+ * + *

+ * struct GLFWgammaramp {
+ *     unsigned short * red;
+ *     unsigned short * green;
+ *     unsigned short * blue;
+ *     unsigned int size;
+ * }
+ * + * @since version 3.0 + */ +@NativeType("struct GLFWgammaramp") +public class GLFWGammaRamp extends Struct implements NativeResource { + + /** The struct size in bytes. */ + public static final int SIZEOF; + + /** The struct alignment in bytes. */ + public static final int ALIGNOF; + + /** The struct member offsets. */ + public static final int + RED, + GREEN, + BLUE, + SIZE; + + static { + Layout layout = __struct( + __member(POINTER_SIZE), + __member(POINTER_SIZE), + __member(POINTER_SIZE), + __member(4) + ); + + SIZEOF = layout.getSize(); + ALIGNOF = layout.getAlignment(); + + RED = layout.offsetof(0); + GREEN = layout.offsetof(1); + BLUE = layout.offsetof(2); + SIZE = layout.offsetof(3); + } + + /** + * Creates a {@code GLFWGammaRamp} instance at the current position of the specified {@link ByteBuffer} container. Changes to the buffer's content will be + * visible to the struct instance and vice versa. + * + *

The created instance holds a strong reference to the container object.

+ */ + public GLFWGammaRamp(ByteBuffer container) { + super(memAddress(container), __checkContainer(container, SIZEOF)); + } + + @Override + public int sizeof() { return SIZEOF; } + + /** Returns a {@link ShortBuffer} view of the data pointed to by the {@code red} field. */ + @NativeType("unsigned short *") + public ShortBuffer red() { return nred(address()); } + /** Returns a {@link ShortBuffer} view of the data pointed to by the {@code green} field. */ + @NativeType("unsigned short *") + public ShortBuffer green() { return ngreen(address()); } + /** Returns a {@link ShortBuffer} view of the data pointed to by the {@code blue} field. */ + @NativeType("unsigned short *") + public ShortBuffer blue() { return nblue(address()); } + /** Returns the value of the {@code size} field. */ + @NativeType("unsigned int") + public int size() { return nsize(address()); } + + /** Sets the address of the specified {@link ShortBuffer} to the {@code red} field. */ + public GLFWGammaRamp red(@NativeType("unsigned short *") ShortBuffer value) { nred(address(), value); return this; } + /** Sets the address of the specified {@link ShortBuffer} to the {@code green} field. */ + public GLFWGammaRamp green(@NativeType("unsigned short *") ShortBuffer value) { ngreen(address(), value); return this; } + /** Sets the address of the specified {@link ShortBuffer} to the {@code blue} field. */ + public GLFWGammaRamp blue(@NativeType("unsigned short *") ShortBuffer value) { nblue(address(), value); return this; } + /** Sets the specified value to the {@code size} field. */ + public GLFWGammaRamp size(@NativeType("unsigned int") int value) { nsize(address(), value); return this; } + + /** Initializes this struct with the specified values. */ + public GLFWGammaRamp set( + ShortBuffer red, + ShortBuffer green, + ShortBuffer blue, + int size + ) { + red(red); + green(green); + blue(blue); + size(size); + + return this; + } + + /** + * Copies the specified struct data to this struct. + * + * @param src the source struct + * + * @return this struct + */ + public GLFWGammaRamp set(GLFWGammaRamp src) { + memCopy(src.address(), address(), SIZEOF); + return this; + } + + // ----------------------------------- + + /** Returns a new {@code GLFWGammaRamp} instance allocated with {@link MemoryUtil#memAlloc memAlloc}. The instance must be explicitly freed. */ + public static GLFWGammaRamp malloc() { + return wrap(GLFWGammaRamp.class, nmemAllocChecked(SIZEOF)); + } + + /** Returns a new {@code GLFWGammaRamp} instance allocated with {@link MemoryUtil#memCalloc memCalloc}. The instance must be explicitly freed. */ + public static GLFWGammaRamp calloc() { + return wrap(GLFWGammaRamp.class, nmemCallocChecked(1, SIZEOF)); + } + + /** Returns a new {@code GLFWGammaRamp} instance allocated with {@link BufferUtils}. */ + public static GLFWGammaRamp create() { + ByteBuffer container = BufferUtils.createByteBuffer(SIZEOF); + return wrap(GLFWGammaRamp.class, memAddress(container), container); + } + + /** Returns a new {@code GLFWGammaRamp} instance for the specified memory address. */ + public static GLFWGammaRamp create(long address) { + return wrap(GLFWGammaRamp.class, address); + } + + /** Like {@link #create(long) create}, but returns {@code null} if {@code address} is {@code NULL}. */ + @Nullable + public static GLFWGammaRamp createSafe(long address) { + return address == NULL ? null : wrap(GLFWGammaRamp.class, address); + } + + /** + * Returns a new {@link GLFWGammaRamp.Buffer} instance allocated with {@link MemoryUtil#memAlloc memAlloc}. The instance must be explicitly freed. + * + * @param capacity the buffer capacity + */ + public static GLFWGammaRamp.Buffer malloc(int capacity) { + return wrap(Buffer.class, nmemAllocChecked(__checkMalloc(capacity, SIZEOF)), capacity); + } + + /** + * Returns a new {@link GLFWGammaRamp.Buffer} instance allocated with {@link MemoryUtil#memCalloc memCalloc}. The instance must be explicitly freed. + * + * @param capacity the buffer capacity + */ + public static GLFWGammaRamp.Buffer calloc(int capacity) { + return wrap(Buffer.class, nmemCallocChecked(capacity, SIZEOF), capacity); + } + + /** + * Returns a new {@link GLFWGammaRamp.Buffer} instance allocated with {@link BufferUtils}. + * + * @param capacity the buffer capacity + */ + public static GLFWGammaRamp.Buffer create(int capacity) { + ByteBuffer container = __create(capacity, SIZEOF); + return wrap(Buffer.class, memAddress(container), capacity, container); + } + + /** + * Create a {@link GLFWGammaRamp.Buffer} instance at the specified memory. + * + * @param address the memory address + * @param capacity the buffer capacity + */ + public static GLFWGammaRamp.Buffer create(long address, int capacity) { + return wrap(Buffer.class, address, capacity); + } + + /** Like {@link #create(long, int) create}, but returns {@code null} if {@code address} is {@code NULL}. */ + @Nullable + public static GLFWGammaRamp.Buffer createSafe(long address, int capacity) { + return address == NULL ? null : wrap(Buffer.class, address, capacity); + } + + // ----------------------------------- + + /** Returns a new {@code GLFWGammaRamp} instance allocated on the thread-local {@link MemoryStack}. */ + public static GLFWGammaRamp mallocStack() { + return mallocStack(stackGet()); + } + + /** Returns a new {@code GLFWGammaRamp} instance allocated on the thread-local {@link MemoryStack} and initializes all its bits to zero. */ + public static GLFWGammaRamp callocStack() { + return callocStack(stackGet()); + } + + /** + * Returns a new {@code GLFWGammaRamp} instance allocated on the specified {@link MemoryStack}. + * + * @param stack the stack from which to allocate + */ + public static GLFWGammaRamp mallocStack(MemoryStack stack) { + return wrap(GLFWGammaRamp.class, stack.nmalloc(ALIGNOF, SIZEOF)); + } + + /** + * Returns a new {@code GLFWGammaRamp} instance allocated on the specified {@link MemoryStack} and initializes all its bits to zero. + * + * @param stack the stack from which to allocate + */ + public static GLFWGammaRamp callocStack(MemoryStack stack) { + return wrap(GLFWGammaRamp.class, stack.ncalloc(ALIGNOF, 1, SIZEOF)); + } + + /** + * Returns a new {@link GLFWGammaRamp.Buffer} instance allocated on the thread-local {@link MemoryStack}. + * + * @param capacity the buffer capacity + */ + public static GLFWGammaRamp.Buffer mallocStack(int capacity) { + return mallocStack(capacity, stackGet()); + } + + /** + * Returns a new {@link GLFWGammaRamp.Buffer} instance allocated on the thread-local {@link MemoryStack} and initializes all its bits to zero. + * + * @param capacity the buffer capacity + */ + public static GLFWGammaRamp.Buffer callocStack(int capacity) { + return callocStack(capacity, stackGet()); + } + + /** + * Returns a new {@link GLFWGammaRamp.Buffer} instance allocated on the specified {@link MemoryStack}. + * + * @param stack the stack from which to allocate + * @param capacity the buffer capacity + */ + public static GLFWGammaRamp.Buffer mallocStack(int capacity, MemoryStack stack) { + return wrap(Buffer.class, stack.nmalloc(ALIGNOF, capacity * SIZEOF), capacity); + } + + /** + * Returns a new {@link GLFWGammaRamp.Buffer} instance allocated on the specified {@link MemoryStack} and initializes all its bits to zero. + * + * @param stack the stack from which to allocate + * @param capacity the buffer capacity + */ + public static GLFWGammaRamp.Buffer callocStack(int capacity, MemoryStack stack) { + return wrap(Buffer.class, stack.ncalloc(ALIGNOF, capacity, SIZEOF), capacity); + } + + // ----------------------------------- + + /** Unsafe version of {@link #red() red}. */ + public static ShortBuffer nred(long struct) { return memShortBuffer(memGetAddress(struct + GLFWGammaRamp.RED), nsize(struct)); } + /** Unsafe version of {@link #green() green}. */ + public static ShortBuffer ngreen(long struct) { return memShortBuffer(memGetAddress(struct + GLFWGammaRamp.GREEN), nsize(struct)); } + /** Unsafe version of {@link #blue() blue}. */ + public static ShortBuffer nblue(long struct) { return memShortBuffer(memGetAddress(struct + GLFWGammaRamp.BLUE), nsize(struct)); } + /** Unsafe version of {@link #size}. */ + public static int nsize(long struct) { return UNSAFE.getInt(null, struct + GLFWGammaRamp.SIZE); } + + /** Unsafe version of {@link #red(ShortBuffer) red}. */ + public static void nred(long struct, ShortBuffer value) { memPutAddress(struct + GLFWGammaRamp.RED, memAddress(value)); } + /** Unsafe version of {@link #green(ShortBuffer) green}. */ + public static void ngreen(long struct, ShortBuffer value) { memPutAddress(struct + GLFWGammaRamp.GREEN, memAddress(value)); } + /** Unsafe version of {@link #blue(ShortBuffer) blue}. */ + public static void nblue(long struct, ShortBuffer value) { memPutAddress(struct + GLFWGammaRamp.BLUE, memAddress(value)); } + /** Sets the specified value to the {@code size} field of the specified {@code struct}. */ + public static void nsize(long struct, int value) { UNSAFE.putInt(null, struct + GLFWGammaRamp.SIZE, value); } + + /** + * Validates pointer members that should not be {@code NULL}. + * + * @param struct the struct to validate + */ + public static void validate(long struct) { + check(memGetAddress(struct + GLFWGammaRamp.RED)); + check(memGetAddress(struct + GLFWGammaRamp.GREEN)); + check(memGetAddress(struct + GLFWGammaRamp.BLUE)); + } + + /** + * Calls {@link #validate(long)} for each struct contained in the specified struct array. + * + * @param array the struct array to validate + * @param count the number of structs in {@code array} + */ + public static void validate(long array, int count) { + for (int i = 0; i < count; i++) { + validate(array + Integer.toUnsignedLong(i) * SIZEOF); + } + } + + // ----------------------------------- + + /** An array of {@link GLFWGammaRamp} structs. */ + public static class Buffer extends StructBuffer implements NativeResource { + + private static final GLFWGammaRamp ELEMENT_FACTORY = GLFWGammaRamp.create(-1L); + + /** + * Creates a new {@code GLFWGammaRamp.Buffer} instance backed by the specified container. + * + * Changes to the container's content will be visible to the struct buffer instance and vice versa. The two buffers' position, limit, and mark values + * will be independent. The new buffer's position will be zero, its capacity and its limit will be the number of bytes remaining in this buffer divided + * by {@link GLFWGammaRamp#SIZEOF}, and its mark will be undefined. + * + *

The created buffer instance holds a strong reference to the container object.

+ */ + public Buffer(ByteBuffer container) { + super(container, container.remaining() / SIZEOF); + } + + public Buffer(long address, int cap) { + super(address, null, -1, 0, cap, cap); + } + + Buffer(long address, @Nullable ByteBuffer container, int mark, int pos, int lim, int cap) { + super(address, container, mark, pos, lim, cap); + } + + @Override + protected Buffer self() { + return this; + } + + @Override + protected GLFWGammaRamp getElementFactory() { + return ELEMENT_FACTORY; + } + + /** Returns a {@link ShortBuffer} view of the data pointed to by the {@code red} field. */ + @NativeType("unsigned short *") + public ShortBuffer red() { return GLFWGammaRamp.nred(address()); } + /** Returns a {@link ShortBuffer} view of the data pointed to by the {@code green} field. */ + @NativeType("unsigned short *") + public ShortBuffer green() { return GLFWGammaRamp.ngreen(address()); } + /** Returns a {@link ShortBuffer} view of the data pointed to by the {@code blue} field. */ + @NativeType("unsigned short *") + public ShortBuffer blue() { return GLFWGammaRamp.nblue(address()); } + /** Returns the value of the {@code size} field. */ + @NativeType("unsigned int") + public int size() { return GLFWGammaRamp.nsize(address()); } + + /** Sets the address of the specified {@link ShortBuffer} to the {@code red} field. */ + public GLFWGammaRamp.Buffer red(@NativeType("unsigned short *") ShortBuffer value) { GLFWGammaRamp.nred(address(), value); return this; } + /** Sets the address of the specified {@link ShortBuffer} to the {@code green} field. */ + public GLFWGammaRamp.Buffer green(@NativeType("unsigned short *") ShortBuffer value) { GLFWGammaRamp.ngreen(address(), value); return this; } + /** Sets the address of the specified {@link ShortBuffer} to the {@code blue} field. */ + public GLFWGammaRamp.Buffer blue(@NativeType("unsigned short *") ShortBuffer value) { GLFWGammaRamp.nblue(address(), value); return this; } + /** Sets the specified value to the {@code size} field. */ + public GLFWGammaRamp.Buffer size(@NativeType("unsigned int") int value) { GLFWGammaRamp.nsize(address(), value); return this; } + + } + +} \ No newline at end of file diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWImage.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWImage.java new file mode 100644 index 000000000..c6feeb53a --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWImage.java @@ -0,0 +1,367 @@ +/* + * Copyright LWJGL. All rights reserved. + * License terms: https://www.lwjgl.org/license + * MACHINE GENERATED FILE, DO NOT EDIT + */ +package org.lwjgl.glfw; + +import javax.annotation.*; + +import java.nio.*; + +import org.lwjgl.*; +import org.lwjgl.system.*; + +import static org.lwjgl.system.Checks.*; +import static org.lwjgl.system.MemoryUtil.*; +import static org.lwjgl.system.MemoryStack.*; + +/** + * Image data. + * + *

This describes a single 2D image. See the documentation for each related function to see what the expected pixel format is.

+ * + *

Member documentation

+ * + *
    + *
  • {@code width} – the width, in pixels, of this image
  • + *
  • {@code height} – the height, in pixels, of this image
  • + *
  • {@code pixels} – the pixel data of this image, arranged left-to-right, top-to-bottom
  • + *
+ * + *

Layout

+ * + *

+ * struct GLFWimage {
+ *     int width;
+ *     int height;
+ *     unsigned char * pixels;
+ * }
+ * + * @since version 2.1 + */ +@NativeType("struct GLFWimage") +public class GLFWImage extends Struct implements NativeResource { + + /** The struct size in bytes. */ + public static final int SIZEOF; + + /** The struct alignment in bytes. */ + public static final int ALIGNOF; + + /** The struct member offsets. */ + public static final int + WIDTH, + HEIGHT, + PIXELS; + + static { + Layout layout = __struct( + __member(4), + __member(4), + __member(POINTER_SIZE) + ); + + SIZEOF = layout.getSize(); + ALIGNOF = layout.getAlignment(); + + WIDTH = layout.offsetof(0); + HEIGHT = layout.offsetof(1); + PIXELS = layout.offsetof(2); + } + + /** + * Creates a {@code GLFWImage} instance at the current position of the specified {@link ByteBuffer} container. Changes to the buffer's content will be + * visible to the struct instance and vice versa. + * + *

The created instance holds a strong reference to the container object.

+ */ + public GLFWImage(ByteBuffer container) { + super(memAddress(container), __checkContainer(container, SIZEOF)); + } + + @Override + public int sizeof() { return SIZEOF; } + + /** Returns the value of the {@code width} field. */ + public int width() { return nwidth(address()); } + /** Returns the value of the {@code height} field. */ + public int height() { return nheight(address()); } + /** + * Returns a {@link ByteBuffer} view of the data pointed to by the {@code pixels} field. + * + * @param capacity the number of elements in the returned buffer + */ + @NativeType("unsigned char *") + public ByteBuffer pixels(int capacity) { return npixels(address(), capacity); } + + /** Sets the specified value to the {@code width} field. */ + public GLFWImage width(int value) { nwidth(address(), value); return this; } + /** Sets the specified value to the {@code height} field. */ + public GLFWImage height(int value) { nheight(address(), value); return this; } + /** Sets the address of the specified {@link ByteBuffer} to the {@code pixels} field. */ + public GLFWImage pixels(@NativeType("unsigned char *") ByteBuffer value) { npixels(address(), value); return this; } + + /** Initializes this struct with the specified values. */ + public GLFWImage set( + int width, + int height, + ByteBuffer pixels + ) { + width(width); + height(height); + pixels(pixels); + + return this; + } + + /** + * Copies the specified struct data to this struct. + * + * @param src the source struct + * + * @return this struct + */ + public GLFWImage set(GLFWImage src) { + memCopy(src.address(), address(), SIZEOF); + return this; + } + + // ----------------------------------- + + /** Returns a new {@code GLFWImage} instance allocated with {@link MemoryUtil#memAlloc memAlloc}. The instance must be explicitly freed. */ + public static GLFWImage malloc() { + return wrap(GLFWImage.class, nmemAllocChecked(SIZEOF)); + } + + /** Returns a new {@code GLFWImage} instance allocated with {@link MemoryUtil#memCalloc memCalloc}. The instance must be explicitly freed. */ + public static GLFWImage calloc() { + return wrap(GLFWImage.class, nmemCallocChecked(1, SIZEOF)); + } + + /** Returns a new {@code GLFWImage} instance allocated with {@link BufferUtils}. */ + public static GLFWImage create() { + ByteBuffer container = BufferUtils.createByteBuffer(SIZEOF); + return wrap(GLFWImage.class, memAddress(container), container); + } + + /** Returns a new {@code GLFWImage} instance for the specified memory address. */ + public static GLFWImage create(long address) { + return wrap(GLFWImage.class, address); + } + + /** Like {@link #create(long) create}, but returns {@code null} if {@code address} is {@code NULL}. */ + @Nullable + public static GLFWImage createSafe(long address) { + return address == NULL ? null : wrap(GLFWImage.class, address); + } + + /** + * Returns a new {@link GLFWImage.Buffer} instance allocated with {@link MemoryUtil#memAlloc memAlloc}. The instance must be explicitly freed. + * + * @param capacity the buffer capacity + */ + public static GLFWImage.Buffer malloc(int capacity) { + return wrap(Buffer.class, nmemAllocChecked(__checkMalloc(capacity, SIZEOF)), capacity); + } + + /** + * Returns a new {@link GLFWImage.Buffer} instance allocated with {@link MemoryUtil#memCalloc memCalloc}. The instance must be explicitly freed. + * + * @param capacity the buffer capacity + */ + public static GLFWImage.Buffer calloc(int capacity) { + return wrap(Buffer.class, nmemCallocChecked(capacity, SIZEOF), capacity); + } + + /** + * Returns a new {@link GLFWImage.Buffer} instance allocated with {@link BufferUtils}. + * + * @param capacity the buffer capacity + */ + public static GLFWImage.Buffer create(int capacity) { + ByteBuffer container = __create(capacity, SIZEOF); + return wrap(Buffer.class, memAddress(container), capacity, container); + } + + /** + * Create a {@link GLFWImage.Buffer} instance at the specified memory. + * + * @param address the memory address + * @param capacity the buffer capacity + */ + public static GLFWImage.Buffer create(long address, int capacity) { + return wrap(Buffer.class, address, capacity); + } + + /** Like {@link #create(long, int) create}, but returns {@code null} if {@code address} is {@code NULL}. */ + @Nullable + public static GLFWImage.Buffer createSafe(long address, int capacity) { + return address == NULL ? null : wrap(Buffer.class, address, capacity); + } + + // ----------------------------------- + + /** Returns a new {@code GLFWImage} instance allocated on the thread-local {@link MemoryStack}. */ + public static GLFWImage mallocStack() { + return mallocStack(stackGet()); + } + + /** Returns a new {@code GLFWImage} instance allocated on the thread-local {@link MemoryStack} and initializes all its bits to zero. */ + public static GLFWImage callocStack() { + return callocStack(stackGet()); + } + + /** + * Returns a new {@code GLFWImage} instance allocated on the specified {@link MemoryStack}. + * + * @param stack the stack from which to allocate + */ + public static GLFWImage mallocStack(MemoryStack stack) { + return wrap(GLFWImage.class, stack.nmalloc(ALIGNOF, SIZEOF)); + } + + /** + * Returns a new {@code GLFWImage} instance allocated on the specified {@link MemoryStack} and initializes all its bits to zero. + * + * @param stack the stack from which to allocate + */ + public static GLFWImage callocStack(MemoryStack stack) { + return wrap(GLFWImage.class, stack.ncalloc(ALIGNOF, 1, SIZEOF)); + } + + /** + * Returns a new {@link GLFWImage.Buffer} instance allocated on the thread-local {@link MemoryStack}. + * + * @param capacity the buffer capacity + */ + public static GLFWImage.Buffer mallocStack(int capacity) { + return mallocStack(capacity, stackGet()); + } + + /** + * Returns a new {@link GLFWImage.Buffer} instance allocated on the thread-local {@link MemoryStack} and initializes all its bits to zero. + * + * @param capacity the buffer capacity + */ + public static GLFWImage.Buffer callocStack(int capacity) { + return callocStack(capacity, stackGet()); + } + + /** + * Returns a new {@link GLFWImage.Buffer} instance allocated on the specified {@link MemoryStack}. + * + * @param stack the stack from which to allocate + * @param capacity the buffer capacity + */ + public static GLFWImage.Buffer mallocStack(int capacity, MemoryStack stack) { + return wrap(Buffer.class, stack.nmalloc(ALIGNOF, capacity * SIZEOF), capacity); + } + + /** + * Returns a new {@link GLFWImage.Buffer} instance allocated on the specified {@link MemoryStack} and initializes all its bits to zero. + * + * @param stack the stack from which to allocate + * @param capacity the buffer capacity + */ + public static GLFWImage.Buffer callocStack(int capacity, MemoryStack stack) { + return wrap(Buffer.class, stack.ncalloc(ALIGNOF, capacity, SIZEOF), capacity); + } + + // ----------------------------------- + + /** Unsafe version of {@link #width}. */ + public static int nwidth(long struct) { return UNSAFE.getInt(null, struct + GLFWImage.WIDTH); } + /** Unsafe version of {@link #height}. */ + public static int nheight(long struct) { return UNSAFE.getInt(null, struct + GLFWImage.HEIGHT); } + /** Unsafe version of {@link #pixels(int) pixels}. */ + public static ByteBuffer npixels(long struct, int capacity) { return memByteBuffer(memGetAddress(struct + GLFWImage.PIXELS), capacity); } + + /** Unsafe version of {@link #width(int) width}. */ + public static void nwidth(long struct, int value) { UNSAFE.putInt(null, struct + GLFWImage.WIDTH, value); } + /** Unsafe version of {@link #height(int) height}. */ + public static void nheight(long struct, int value) { UNSAFE.putInt(null, struct + GLFWImage.HEIGHT, value); } + /** Unsafe version of {@link #pixels(ByteBuffer) pixels}. */ + public static void npixels(long struct, ByteBuffer value) { memPutAddress(struct + GLFWImage.PIXELS, memAddress(value)); } + + /** + * Validates pointer members that should not be {@code NULL}. + * + * @param struct the struct to validate + */ + public static void validate(long struct) { + check(memGetAddress(struct + GLFWImage.PIXELS)); + } + + /** + * Calls {@link #validate(long)} for each struct contained in the specified struct array. + * + * @param array the struct array to validate + * @param count the number of structs in {@code array} + */ + public static void validate(long array, int count) { + for (int i = 0; i < count; i++) { + validate(array + Integer.toUnsignedLong(i) * SIZEOF); + } + } + + // ----------------------------------- + + /** An array of {@link GLFWImage} structs. */ + public static class Buffer extends StructBuffer implements NativeResource { + + private static final GLFWImage ELEMENT_FACTORY = GLFWImage.create(-1L); + + /** + * Creates a new {@code GLFWImage.Buffer} instance backed by the specified container. + * + * Changes to the container's content will be visible to the struct buffer instance and vice versa. The two buffers' position, limit, and mark values + * will be independent. The new buffer's position will be zero, its capacity and its limit will be the number of bytes remaining in this buffer divided + * by {@link GLFWImage#SIZEOF}, and its mark will be undefined. + * + *

The created buffer instance holds a strong reference to the container object.

+ */ + public Buffer(ByteBuffer container) { + super(container, container.remaining() / SIZEOF); + } + + public Buffer(long address, int cap) { + super(address, null, -1, 0, cap, cap); + } + + Buffer(long address, @Nullable ByteBuffer container, int mark, int pos, int lim, int cap) { + super(address, container, mark, pos, lim, cap); + } + + @Override + protected Buffer self() { + return this; + } + + @Override + protected GLFWImage getElementFactory() { + return ELEMENT_FACTORY; + } + + /** Returns the value of the {@code width} field. */ + public int width() { return GLFWImage.nwidth(address()); } + /** Returns the value of the {@code height} field. */ + public int height() { return GLFWImage.nheight(address()); } + /** + * Returns a {@link ByteBuffer} view of the data pointed to by the {@code pixels} field. + * + * @param capacity the number of elements in the returned buffer + */ + @NativeType("unsigned char *") + public ByteBuffer pixels(int capacity) { return GLFWImage.npixels(address(), capacity); } + + /** Sets the specified value to the {@code width} field. */ + public GLFWImage.Buffer width(int value) { GLFWImage.nwidth(address(), value); return this; } + /** Sets the specified value to the {@code height} field. */ + public GLFWImage.Buffer height(int value) { GLFWImage.nheight(address(), value); return this; } + /** Sets the address of the specified {@link ByteBuffer} to the {@code pixels} field. */ + public GLFWImage.Buffer pixels(@NativeType("unsigned char *") ByteBuffer value) { GLFWImage.npixels(address(), value); return this; } + + } + +} \ No newline at end of file diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWJoystickCallback.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWJoystickCallback.java new file mode 100644 index 000000000..85efe06eb --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWJoystickCallback.java @@ -0,0 +1,86 @@ +/* + * Copyright LWJGL. All rights reserved. + * License terms: https://www.lwjgl.org/license + * MACHINE GENERATED FILE, DO NOT EDIT + */ +package org.lwjgl.glfw; + +import javax.annotation.*; + +import org.lwjgl.system.*; + +import static org.lwjgl.system.MemoryUtil.*; + +import static org.lwjgl.glfw.GLFW.*; + +/** + * Instances of this class may be passed to the {@link GLFW#glfwSetJoystickCallback SetJoystickCallback} method. + * + *

Type

+ * + *

+ * void (*) (
+ *     int jid,
+ *     int event
+ * )
+ * + * @since version 3.2 + */ +public abstract class GLFWJoystickCallback extends Callback implements GLFWJoystickCallbackI { + + /** + * Creates a {@code GLFWJoystickCallback} instance from the specified function pointer. + * + * @return the new {@code GLFWJoystickCallback} + */ + public static GLFWJoystickCallback create(long functionPointer) { + GLFWJoystickCallbackI instance = Callback.get(functionPointer); + return instance instanceof GLFWJoystickCallback + ? (GLFWJoystickCallback)instance + : new Container(functionPointer, instance); + } + + /** Like {@link #create(long) create}, but returns {@code null} if {@code functionPointer} is {@code NULL}. */ + @Nullable + public static GLFWJoystickCallback createSafe(long functionPointer) { + return functionPointer == NULL ? null : create(functionPointer); + } + + /** Creates a {@code GLFWJoystickCallback} instance that delegates to the specified {@code GLFWJoystickCallbackI} instance. */ + public static GLFWJoystickCallback create(GLFWJoystickCallbackI instance) { + return instance instanceof GLFWJoystickCallback + ? (GLFWJoystickCallback)instance + : new Container(instance.address(), instance); + } + + protected GLFWJoystickCallback() { + super(SIGNATURE); + } + + GLFWJoystickCallback(long functionPointer) { + super(functionPointer); + } + + /** See {@link GLFW#glfwSetJoystickCallback SetJoystickCallback}. */ + public GLFWJoystickCallback set() { + glfwSetJoystickCallback(this); + return this; + } + + private static final class Container extends GLFWJoystickCallback { + + private final GLFWJoystickCallbackI delegate; + + Container(long functionPointer, GLFWJoystickCallbackI delegate) { + super(functionPointer); + this.delegate = delegate; + } + + @Override + public void invoke(int jid, int event) { + delegate.invoke(jid, event); + } + + } + +} \ No newline at end of file diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWJoystickCallbackI.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWJoystickCallbackI.java new file mode 100644 index 000000000..2bea9c27a --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWJoystickCallbackI.java @@ -0,0 +1,50 @@ +/* + * Copyright LWJGL. All rights reserved. + * License terms: https://www.lwjgl.org/license + * MACHINE GENERATED FILE, DO NOT EDIT + */ +package org.lwjgl.glfw; + +import org.lwjgl.system.*; + +import static org.lwjgl.system.dyncall.DynCallback.*; + +/** + * Instances of this interface may be passed to the {@link GLFW#glfwSetJoystickCallback SetJoystickCallback} method. + * + *

Type

+ * + *

+ * void (*) (
+ *     int jid,
+ *     int event
+ * )
+ * + * @since version 3.2 + */ +@FunctionalInterface +@NativeType("GLFWjoystickfun") +public interface GLFWJoystickCallbackI extends CallbackI.V { + + String SIGNATURE = "(ii)v"; + + @Override + default String getSignature() { return SIGNATURE; } + + @Override + default void callback(long args) { + invoke( + dcbArgInt(args), + dcbArgInt(args) + ); + } + + /** + * Will be called when a joystick is connected to or disconnected from the system. + * + * @param jid the joystick that was connected or disconnected + * @param event one of {@link GLFW#GLFW_CONNECTED CONNECTED} or {@link GLFW#GLFW_DISCONNECTED DISCONNECTED}. Remaining values reserved for future use. + */ + void invoke(int jid, int event); + +} \ No newline at end of file diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWKeyCallback.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWKeyCallback.java new file mode 100644 index 000000000..eb7703342 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWKeyCallback.java @@ -0,0 +1,87 @@ +/* + * Copyright LWJGL. All rights reserved. + * License terms: https://www.lwjgl.org/license + * MACHINE GENERATED FILE, DO NOT EDIT + */ +package org.lwjgl.glfw; + +import javax.annotation.*; + +import org.lwjgl.system.*; + +import static org.lwjgl.system.MemoryUtil.*; + +import static org.lwjgl.glfw.GLFW.*; + +/** + * Instances of this class may be passed to the {@link GLFW#glfwSetKeyCallback SetKeyCallback} method. + * + *

Type

+ * + *

+ * void (*) (
+ *     GLFWwindow *window,
+ *     int key,
+ *     int scancode,
+ *     int action,
+ *     int mods
+ * )
+ */ +public abstract class GLFWKeyCallback extends Callback implements GLFWKeyCallbackI { + + /** + * Creates a {@code GLFWKeyCallback} instance from the specified function pointer. + * + * @return the new {@code GLFWKeyCallback} + */ + public static GLFWKeyCallback create(long functionPointer) { + GLFWKeyCallbackI instance = Callback.get(functionPointer); + return instance instanceof GLFWKeyCallback + ? (GLFWKeyCallback)instance + : new Container(functionPointer, instance); + } + + /** Like {@link #create(long) create}, but returns {@code null} if {@code functionPointer} is {@code NULL}. */ + @Nullable + public static GLFWKeyCallback createSafe(long functionPointer) { + return functionPointer == NULL ? null : create(functionPointer); + } + + /** Creates a {@code GLFWKeyCallback} instance that delegates to the specified {@code GLFWKeyCallbackI} instance. */ + public static GLFWKeyCallback create(GLFWKeyCallbackI instance) { + return instance instanceof GLFWKeyCallback + ? (GLFWKeyCallback)instance + : new Container(instance.address(), instance); + } + + protected GLFWKeyCallback() { + super(SIGNATURE); + } + + GLFWKeyCallback(long functionPointer) { + super(functionPointer); + } + + /** See {@link GLFW#glfwSetKeyCallback SetKeyCallback}. */ + public GLFWKeyCallback set(long window) { + glfwSetKeyCallback(window, this); + return this; + } + + private static final class Container extends GLFWKeyCallback { + + private final GLFWKeyCallbackI delegate; + + Container(long functionPointer, GLFWKeyCallbackI delegate) { + super(functionPointer); + this.delegate = delegate; + } + + @Override + public void invoke(long window, int key, int scancode, int action, int mods) { + delegate.invoke(window, key, scancode, action, mods); + } + + } + +} \ No newline at end of file diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWKeyCallbackI.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWKeyCallbackI.java new file mode 100644 index 000000000..ed506cf34 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWKeyCallbackI.java @@ -0,0 +1,57 @@ +/* + * Copyright LWJGL. All rights reserved. + * License terms: https://www.lwjgl.org/license + * MACHINE GENERATED FILE, DO NOT EDIT + */ +package org.lwjgl.glfw; + +import org.lwjgl.system.*; + +import static org.lwjgl.system.dyncall.DynCallback.*; + +/** + * Instances of this interface may be passed to the {@link GLFW#glfwSetKeyCallback SetKeyCallback} method. + * + *

Type

+ * + *

+ * void (*) (
+ *     GLFWwindow *window,
+ *     int key,
+ *     int scancode,
+ *     int action,
+ *     int mods
+ * )
+ */ +@FunctionalInterface +@NativeType("GLFWkeyfun") +public interface GLFWKeyCallbackI extends CallbackI.V { + + String SIGNATURE = "(piiii)v"; + + @Override + default String getSignature() { return SIGNATURE; } + + @Override + default void callback(long args) { + invoke( + dcbArgPointer(args), + dcbArgInt(args), + dcbArgInt(args), + dcbArgInt(args), + dcbArgInt(args) + ); + } + + /** + * Will be called when a key is pressed, repeated or released. + * + * @param window the window that received the event + * @param key the keyboard key that was pressed or released + * @param scancode the system-specific scancode of the key + * @param action the key action. One of:
{@link GLFW#GLFW_PRESS PRESS}{@link GLFW#GLFW_RELEASE RELEASE}{@link GLFW#GLFW_REPEAT REPEAT}
+ * @param mods bitfield describing which modifiers keys were held down + */ + void invoke(@NativeType("GLFWwindow *") long window, int key, int scancode, int action, int mods); + +} \ No newline at end of file diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWMonitorCallback.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWMonitorCallback.java new file mode 100644 index 000000000..a67265e27 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWMonitorCallback.java @@ -0,0 +1,86 @@ +/* + * Copyright LWJGL. All rights reserved. + * License terms: https://www.lwjgl.org/license + * MACHINE GENERATED FILE, DO NOT EDIT + */ +package org.lwjgl.glfw; + +import javax.annotation.*; + +import org.lwjgl.system.*; + +import static org.lwjgl.system.MemoryUtil.*; + +import static org.lwjgl.glfw.GLFW.*; + +/** + * Instances of this class may be passed to the {@link GLFW#glfwSetMonitorCallback SetMonitorCallback} method. + * + *

Type

+ * + *

+ * void (*) (
+ *     GLFWmonitor *monitor,
+ *     int event
+ * )
+ * + * @since version 3.0 + */ +public abstract class GLFWMonitorCallback extends Callback implements GLFWMonitorCallbackI { + + /** + * Creates a {@code GLFWMonitorCallback} instance from the specified function pointer. + * + * @return the new {@code GLFWMonitorCallback} + */ + public static GLFWMonitorCallback create(long functionPointer) { + GLFWMonitorCallbackI instance = Callback.get(functionPointer); + return instance instanceof GLFWMonitorCallback + ? (GLFWMonitorCallback)instance + : new Container(functionPointer, instance); + } + + /** Like {@link #create(long) create}, but returns {@code null} if {@code functionPointer} is {@code NULL}. */ + @Nullable + public static GLFWMonitorCallback createSafe(long functionPointer) { + return functionPointer == NULL ? null : create(functionPointer); + } + + /** Creates a {@code GLFWMonitorCallback} instance that delegates to the specified {@code GLFWMonitorCallbackI} instance. */ + public static GLFWMonitorCallback create(GLFWMonitorCallbackI instance) { + return instance instanceof GLFWMonitorCallback + ? (GLFWMonitorCallback)instance + : new Container(instance.address(), instance); + } + + protected GLFWMonitorCallback() { + super(SIGNATURE); + } + + GLFWMonitorCallback(long functionPointer) { + super(functionPointer); + } + + /** See {@link GLFW#glfwSetMonitorCallback SetMonitorCallback}. */ + public GLFWMonitorCallback set() { + glfwSetMonitorCallback(this); + return this; + } + + private static final class Container extends GLFWMonitorCallback { + + private final GLFWMonitorCallbackI delegate; + + Container(long functionPointer, GLFWMonitorCallbackI delegate) { + super(functionPointer); + this.delegate = delegate; + } + + @Override + public void invoke(long monitor, int event) { + delegate.invoke(monitor, event); + } + + } + +} \ No newline at end of file diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWMonitorCallbackI.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWMonitorCallbackI.java new file mode 100644 index 000000000..b0a215afd --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWMonitorCallbackI.java @@ -0,0 +1,50 @@ +/* + * Copyright LWJGL. All rights reserved. + * License terms: https://www.lwjgl.org/license + * MACHINE GENERATED FILE, DO NOT EDIT + */ +package org.lwjgl.glfw; + +import org.lwjgl.system.*; + +import static org.lwjgl.system.dyncall.DynCallback.*; + +/** + * Instances of this interface may be passed to the {@link GLFW#glfwSetMonitorCallback SetMonitorCallback} method. + * + *

Type

+ * + *

+ * void (*) (
+ *     GLFWmonitor *monitor,
+ *     int event
+ * )
+ * + * @since version 3.0 + */ +@FunctionalInterface +@NativeType("GLFWmonitorfun") +public interface GLFWMonitorCallbackI extends CallbackI.V { + + String SIGNATURE = "(pi)v"; + + @Override + default String getSignature() { return SIGNATURE; } + + @Override + default void callback(long args) { + invoke( + dcbArgPointer(args), + dcbArgInt(args) + ); + } + + /** + * Will be called when a monitor is connected to or disconnected from the system. + * + * @param monitor the monitor that was connected or disconnected + * @param event one of {@link GLFW#GLFW_CONNECTED CONNECTED} or {@link GLFW#GLFW_DISCONNECTED DISCONNECTED}. Remaining values reserved for future use. + */ + void invoke(@NativeType("GLFWmonitor *") long monitor, int event); + +} \ No newline at end of file diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWMouseButtonCallback.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWMouseButtonCallback.java new file mode 100644 index 000000000..0edc6ff30 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWMouseButtonCallback.java @@ -0,0 +1,86 @@ +/* + * Copyright LWJGL. All rights reserved. + * License terms: https://www.lwjgl.org/license + * MACHINE GENERATED FILE, DO NOT EDIT + */ +package org.lwjgl.glfw; + +import javax.annotation.*; + +import org.lwjgl.system.*; + +import static org.lwjgl.system.MemoryUtil.*; + +import static org.lwjgl.glfw.GLFW.*; + +/** + * Instances of this class may be passed to the {@link GLFW#glfwSetMouseButtonCallback SetMouseButtonCallback} method. + * + *

Type

+ * + *

+ * void (*) (
+ *     GLFWwindow *window,
+ *     int button,
+ *     int action,
+ *     int mods
+ * )
+ */ +public abstract class GLFWMouseButtonCallback extends Callback implements GLFWMouseButtonCallbackI { + + /** + * Creates a {@code GLFWMouseButtonCallback} instance from the specified function pointer. + * + * @return the new {@code GLFWMouseButtonCallback} + */ + public static GLFWMouseButtonCallback create(long functionPointer) { + GLFWMouseButtonCallbackI instance = Callback.get(functionPointer); + return instance instanceof GLFWMouseButtonCallback + ? (GLFWMouseButtonCallback)instance + : new Container(functionPointer, instance); + } + + /** Like {@link #create(long) create}, but returns {@code null} if {@code functionPointer} is {@code NULL}. */ + @Nullable + public static GLFWMouseButtonCallback createSafe(long functionPointer) { + return functionPointer == NULL ? null : create(functionPointer); + } + + /** Creates a {@code GLFWMouseButtonCallback} instance that delegates to the specified {@code GLFWMouseButtonCallbackI} instance. */ + public static GLFWMouseButtonCallback create(GLFWMouseButtonCallbackI instance) { + return instance instanceof GLFWMouseButtonCallback + ? (GLFWMouseButtonCallback)instance + : new Container(instance.address(), instance); + } + + protected GLFWMouseButtonCallback() { + super(SIGNATURE); + } + + GLFWMouseButtonCallback(long functionPointer) { + super(functionPointer); + } + + /** See {@link GLFW#glfwSetMouseButtonCallback SetMouseButtonCallback}. */ + public GLFWMouseButtonCallback set(long window) { + glfwSetMouseButtonCallback(window, this); + return this; + } + + private static final class Container extends GLFWMouseButtonCallback { + + private final GLFWMouseButtonCallbackI delegate; + + Container(long functionPointer, GLFWMouseButtonCallbackI delegate) { + super(functionPointer); + this.delegate = delegate; + } + + @Override + public void invoke(long window, int button, int action, int mods) { + delegate.invoke(window, button, action, mods); + } + + } + +} \ No newline at end of file diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWMouseButtonCallbackI.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWMouseButtonCallbackI.java new file mode 100644 index 000000000..e010c1c1a --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWMouseButtonCallbackI.java @@ -0,0 +1,54 @@ +/* + * Copyright LWJGL. All rights reserved. + * License terms: https://www.lwjgl.org/license + * MACHINE GENERATED FILE, DO NOT EDIT + */ +package org.lwjgl.glfw; + +import org.lwjgl.system.*; + +import static org.lwjgl.system.dyncall.DynCallback.*; + +/** + * Instances of this interface may be passed to the {@link GLFW#glfwSetMouseButtonCallback SetMouseButtonCallback} method. + * + *

Type

+ * + *

+ * void (*) (
+ *     GLFWwindow *window,
+ *     int button,
+ *     int action,
+ *     int mods
+ * )
+ */ +@FunctionalInterface +@NativeType("GLFWmousebuttonfun") +public interface GLFWMouseButtonCallbackI extends CallbackI.V { + + String SIGNATURE = "(piii)v"; + + @Override + default String getSignature() { return SIGNATURE; } + + @Override + default void callback(long args) { + invoke( + dcbArgPointer(args), + dcbArgInt(args), + dcbArgInt(args), + dcbArgInt(args) + ); + } + + /** + * Will be called when a mouse button is pressed or released. + * + * @param window the window that received the event + * @param button the mouse button that was pressed or released + * @param action the button action. One of:
{@link GLFW#GLFW_PRESS PRESS}{@link GLFW#GLFW_RELEASE RELEASE}
+ * @param mods bitfield describing which modifiers keys were held down + */ + void invoke(@NativeType("GLFWwindow *") long window, int button, int action, int mods); + +} \ No newline at end of file diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWNativeGLX.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWNativeGLX.java new file mode 100644 index 000000000..eaf7c2a2a --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWNativeGLX.java @@ -0,0 +1,125 @@ +/* + * Copyright LWJGL. All rights reserved. + * License terms: https://www.lwjgl.org/license + * MACHINE GENERATED FILE, DO NOT EDIT + */ +package org.lwjgl.glfw; + +import org.lwjgl.system.*; + +import static org.lwjgl.system.APIUtil.*; +import static org.lwjgl.system.Checks.*; +import static org.lwjgl.system.JNI.*; + +import javax.annotation.*; +import org.lwjgl.opengl.GL; + +import static org.lwjgl.system.MemoryUtil.*; + +/** Native bindings to the GLFW library's GLX native access functions. */ +public class GLFWNativeGLX { + + protected GLFWNativeGLX() { + throw new UnsupportedOperationException(); + } + + /** Contains the function pointers loaded from {@code GLFW.getLibrary()}. */ + public static final class Functions { + + private Functions() {} + + /** Function address. */ + public static final long + GetGLXContext = apiGetFunctionAddress(GLFW.getLibrary(), "glfwGetGLXContext"), + GetGLXWindow = apiGetFunctionAddress(GLFW.getLibrary(), "glfwGetGLXWindow"); + + } + + // --- [ glfwGetGLXContext ] --- + + /** + * Returns the {@code GLXContext} of the specified window. + * + *

This function may be called from any thread. Access is not synchronized.

+ * + * @param window a GLFW window + * + * @return the {@code GLXContext} of the specified window, or {@code NULL} if an error occurred. + * + * @since version 3.0 + */ + @NativeType("GLXContext") + public static long glfwGetGLXContext(@NativeType("GLFWwindow *") long window) { + long __functionAddress = Functions.GetGLXContext; + if (CHECKS) { + check(window); + } + return invokePP(window, __functionAddress); + } + + // --- [ glfwGetGLXWindow ] --- + + /** + * Returns the {@code GLXWindow} of the specified window. + * + *

This function may be called from any thread. Access is not synchronized.

+ * + * @param window a GLFW window + * + * @return the {@code GLXWindow} of the specified window, or {@code None} if an error occurred. + * + * @since version 3.2 + */ + @NativeType("GLXWindow") + public static long glfwGetGLXWindow(@NativeType("GLFWwindow *") long window) { + long __functionAddress = Functions.GetGLXWindow; + if (CHECKS) { + check(window); + } + return invokePP(window, __functionAddress); + } + + /** Calls {@link #setPath(String)} with the path of the OpenGL shared library loaded by LWJGL. */ + public static void setPathLWJGL() { + FunctionProvider fp = GL.getFunctionProvider(); + if (!(fp instanceof SharedLibrary)) { + apiLog("GLFW OpenGL path override not set: OpenGL function provider is not a shared library."); + return; + + } + + String path = ((SharedLibrary)fp).getPath(); + if (path == null) { + apiLog("GLFW OpenGL path override not set: Could not resolve the OpenGL shared library path."); + return; + + } + + setPath(path); + } + + /** + * Overrides the OpenGL shared library that GLFW loads internally. + * + *

This is useful when there's a mismatch between the shared libraries loaded by LWJGL and GLFW.

+ * + *

This method must be called before GLFW initializes OpenGL. The override is available only in the default GLFW build bundled with LWJGL. Using the + * override with a custom GLFW build will produce a warning in {@code DEBUG} mode (but not an error).

+ * + * @param path the OpenGL shared library path, or {@code null} to remove the override. + */ + public static void setPath(@Nullable String path) { + long override = GLFW.getLibrary().getFunctionAddress("_glfw_opengl_library"); + if (override == NULL) { + apiLog("GLFW OpenGL path override not set: Could not resolve override symbol."); + return; + } + + long a = memGetAddress(override); + if (a != NULL) { + nmemFree(a); + } + memPutAddress(override, path == null ? NULL : memAddress(memUTF8(path))); + } + +} \ No newline at end of file diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWScrollCallback.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWScrollCallback.java new file mode 100644 index 000000000..4a305a8bd --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWScrollCallback.java @@ -0,0 +1,87 @@ +/* + * Copyright LWJGL. All rights reserved. + * License terms: https://www.lwjgl.org/license + * MACHINE GENERATED FILE, DO NOT EDIT + */ +package org.lwjgl.glfw; + +import javax.annotation.*; + +import org.lwjgl.system.*; + +import static org.lwjgl.system.MemoryUtil.*; + +import static org.lwjgl.glfw.GLFW.*; + +/** + * Instances of this class may be passed to the {@link GLFW#glfwSetScrollCallback SetScrollCallback} method. + * + *

Type

+ * + *

+ * void (*) (
+ *     GLFWwindow *window,
+ *     double xoffset,
+ *     double yoffset
+ * )
+ * + * @since version 3.0 + */ +public abstract class GLFWScrollCallback extends Callback implements GLFWScrollCallbackI { + + /** + * Creates a {@code GLFWScrollCallback} instance from the specified function pointer. + * + * @return the new {@code GLFWScrollCallback} + */ + public static GLFWScrollCallback create(long functionPointer) { + GLFWScrollCallbackI instance = Callback.get(functionPointer); + return instance instanceof GLFWScrollCallback + ? (GLFWScrollCallback)instance + : new Container(functionPointer, instance); + } + + /** Like {@link #create(long) create}, but returns {@code null} if {@code functionPointer} is {@code NULL}. */ + @Nullable + public static GLFWScrollCallback createSafe(long functionPointer) { + return functionPointer == NULL ? null : create(functionPointer); + } + + /** Creates a {@code GLFWScrollCallback} instance that delegates to the specified {@code GLFWScrollCallbackI} instance. */ + public static GLFWScrollCallback create(GLFWScrollCallbackI instance) { + return instance instanceof GLFWScrollCallback + ? (GLFWScrollCallback)instance + : new Container(instance.address(), instance); + } + + protected GLFWScrollCallback() { + super(SIGNATURE); + } + + GLFWScrollCallback(long functionPointer) { + super(functionPointer); + } + + /** See {@link GLFW#glfwSetScrollCallback SetScrollCallback}. */ + public GLFWScrollCallback set(long window) { + glfwSetScrollCallback(window, this); + return this; + } + + private static final class Container extends GLFWScrollCallback { + + private final GLFWScrollCallbackI delegate; + + Container(long functionPointer, GLFWScrollCallbackI delegate) { + super(functionPointer); + this.delegate = delegate; + } + + @Override + public void invoke(long window, double xoffset, double yoffset) { + delegate.invoke(window, xoffset, yoffset); + } + + } + +} \ No newline at end of file diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWScrollCallbackI.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWScrollCallbackI.java new file mode 100644 index 000000000..b467832a0 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWScrollCallbackI.java @@ -0,0 +1,53 @@ +/* + * Copyright LWJGL. All rights reserved. + * License terms: https://www.lwjgl.org/license + * MACHINE GENERATED FILE, DO NOT EDIT + */ +package org.lwjgl.glfw; + +import org.lwjgl.system.*; + +import static org.lwjgl.system.dyncall.DynCallback.*; + +/** + * Instances of this interface may be passed to the {@link GLFW#glfwSetScrollCallback SetScrollCallback} method. + * + *

Type

+ * + *

+ * void (*) (
+ *     GLFWwindow *window,
+ *     double xoffset,
+ *     double yoffset
+ * )
+ * + * @since version 3.0 + */ +@FunctionalInterface +@NativeType("GLFWscrollfun") +public interface GLFWScrollCallbackI extends CallbackI.V { + + String SIGNATURE = "(pdd)v"; + + @Override + default String getSignature() { return SIGNATURE; } + + @Override + default void callback(long args) { + invoke( + dcbArgPointer(args), + dcbArgDouble(args), + dcbArgDouble(args) + ); + } + + /** + * Will be called when a scrolling device is used, such as a mouse wheel or scrolling area of a touchpad. + * + * @param window the window that received the event + * @param xoffset the scroll offset along the x-axis + * @param yoffset the scroll offset along the y-axis + */ + void invoke(@NativeType("GLFWwindow *") long window, double xoffset, double yoffset); + +} \ No newline at end of file diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWVidMode.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWVidMode.java new file mode 100644 index 000000000..5e06259dc --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWVidMode.java @@ -0,0 +1,204 @@ +/* + * Copyright LWJGL. All rights reserved. + * License terms: https://www.lwjgl.org/license + * MACHINE GENERATED FILE, DO NOT EDIT + */ +package org.lwjgl.glfw; + +import javax.annotation.*; + +import java.nio.*; + +import org.lwjgl.system.*; + +import static org.lwjgl.system.MemoryUtil.*; + +/** + * Describes a single video mode. + * + *

Member documentation

+ * + *
    + *
  • {@code width} – the width, in screen coordinates, of the video mode
  • + *
  • {@code height} – the height, in screen coordinates, of the video mode
  • + *
  • {@code redBits} – the bit depth of the red channel of the video mode
  • + *
  • {@code greenBits} – the bit depth of the green channel of the video mode
  • + *
  • {@code blueBits} – the bit depth of the blue channel of the video mode
  • + *
  • {@code refreshRate} – the refresh rate, in Hz, of the video mode
  • + *
+ * + *

Layout

+ * + *

+ * struct GLFWvidmode {
+ *     int width;
+ *     int height;
+ *     int redBits;
+ *     int greenBits;
+ *     int blueBits;
+ *     int refreshRate;
+ * }
+ */ +@NativeType("struct GLFWvidmode") +public class GLFWVidMode extends Struct { + + /** The struct size in bytes. */ + public static final int SIZEOF; + + /** The struct alignment in bytes. */ + public static final int ALIGNOF; + + /** The struct member offsets. */ + public static final int + WIDTH, + HEIGHT, + REDBITS, + GREENBITS, + BLUEBITS, + REFRESHRATE; + + static { + Layout layout = __struct( + __member(4), + __member(4), + __member(4), + __member(4), + __member(4), + __member(4) + ); + + SIZEOF = layout.getSize(); + ALIGNOF = layout.getAlignment(); + + WIDTH = layout.offsetof(0); + HEIGHT = layout.offsetof(1); + REDBITS = layout.offsetof(2); + GREENBITS = layout.offsetof(3); + BLUEBITS = layout.offsetof(4); + REFRESHRATE = layout.offsetof(5); + } + + /** + * Creates a {@code GLFWVidMode} instance at the current position of the specified {@link ByteBuffer} container. Changes to the buffer's content will be + * visible to the struct instance and vice versa. + * + *

The created instance holds a strong reference to the container object.

+ */ + public GLFWVidMode(ByteBuffer container) { + super(memAddress(container), __checkContainer(container, SIZEOF)); + } + + @Override + public int sizeof() { return SIZEOF; } + + /** Returns the value of the {@code width} field. */ + public int width() { return nwidth(address()); } + /** Returns the value of the {@code height} field. */ + public int height() { return nheight(address()); } + /** Returns the value of the {@code redBits} field. */ + public int redBits() { return nredBits(address()); } + /** Returns the value of the {@code greenBits} field. */ + public int greenBits() { return ngreenBits(address()); } + /** Returns the value of the {@code blueBits} field. */ + public int blueBits() { return nblueBits(address()); } + /** Returns the value of the {@code refreshRate} field. */ + public int refreshRate() { return nrefreshRate(address()); } + + // ----------------------------------- + + /** Returns a new {@code GLFWVidMode} instance for the specified memory address. */ + public static GLFWVidMode create(long address) { + return wrap(GLFWVidMode.class, address); + } + + /** Like {@link #create(long) create}, but returns {@code null} if {@code address} is {@code NULL}. */ + @Nullable + public static GLFWVidMode createSafe(long address) { + return address == NULL ? null : wrap(GLFWVidMode.class, address); + } + + /** + * Create a {@link GLFWVidMode.Buffer} instance at the specified memory. + * + * @param address the memory address + * @param capacity the buffer capacity + */ + public static GLFWVidMode.Buffer create(long address, int capacity) { + return wrap(Buffer.class, address, capacity); + } + + /** Like {@link #create(long, int) create}, but returns {@code null} if {@code address} is {@code NULL}. */ + @Nullable + public static GLFWVidMode.Buffer createSafe(long address, int capacity) { + return address == NULL ? null : wrap(Buffer.class, address, capacity); + } + + // ----------------------------------- + + /** Unsafe version of {@link #width}. */ + public static int nwidth(long struct) { return UNSAFE.getInt(null, struct + GLFWVidMode.WIDTH); } + /** Unsafe version of {@link #height}. */ + public static int nheight(long struct) { return UNSAFE.getInt(null, struct + GLFWVidMode.HEIGHT); } + /** Unsafe version of {@link #redBits}. */ + public static int nredBits(long struct) { return UNSAFE.getInt(null, struct + GLFWVidMode.REDBITS); } + /** Unsafe version of {@link #greenBits}. */ + public static int ngreenBits(long struct) { return UNSAFE.getInt(null, struct + GLFWVidMode.GREENBITS); } + /** Unsafe version of {@link #blueBits}. */ + public static int nblueBits(long struct) { return UNSAFE.getInt(null, struct + GLFWVidMode.BLUEBITS); } + /** Unsafe version of {@link #refreshRate}. */ + public static int nrefreshRate(long struct) { return UNSAFE.getInt(null, struct + GLFWVidMode.REFRESHRATE); } + + // ----------------------------------- + + /** An array of {@link GLFWVidMode} structs. */ + public static class Buffer extends StructBuffer { + + private static final GLFWVidMode ELEMENT_FACTORY = GLFWVidMode.create(-1L); + + /** + * Creates a new {@code GLFWVidMode.Buffer} instance backed by the specified container. + * + * Changes to the container's content will be visible to the struct buffer instance and vice versa. The two buffers' position, limit, and mark values + * will be independent. The new buffer's position will be zero, its capacity and its limit will be the number of bytes remaining in this buffer divided + * by {@link GLFWVidMode#SIZEOF}, and its mark will be undefined. + * + *

The created buffer instance holds a strong reference to the container object.

+ */ + public Buffer(ByteBuffer container) { + super(container, container.remaining() / SIZEOF); + } + + public Buffer(long address, int cap) { + super(address, null, -1, 0, cap, cap); + } + + Buffer(long address, @Nullable ByteBuffer container, int mark, int pos, int lim, int cap) { + super(address, container, mark, pos, lim, cap); + } + + @Override + protected Buffer self() { + return this; + } + + @Override + protected GLFWVidMode getElementFactory() { + return ELEMENT_FACTORY; + } + + /** Returns the value of the {@code width} field. */ + public int width() { return GLFWVidMode.nwidth(address()); } + /** Returns the value of the {@code height} field. */ + public int height() { return GLFWVidMode.nheight(address()); } + /** Returns the value of the {@code redBits} field. */ + public int redBits() { return GLFWVidMode.nredBits(address()); } + /** Returns the value of the {@code greenBits} field. */ + public int greenBits() { return GLFWVidMode.ngreenBits(address()); } + /** Returns the value of the {@code blueBits} field. */ + public int blueBits() { return GLFWVidMode.nblueBits(address()); } + /** Returns the value of the {@code refreshRate} field. */ + public int refreshRate() { return GLFWVidMode.nrefreshRate(address()); } + + } + +} \ No newline at end of file diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWWindowCloseCallback.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWWindowCloseCallback.java new file mode 100644 index 000000000..da74a99c6 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWWindowCloseCallback.java @@ -0,0 +1,85 @@ +/* + * Copyright LWJGL. All rights reserved. + * License terms: https://www.lwjgl.org/license + * MACHINE GENERATED FILE, DO NOT EDIT + */ +package org.lwjgl.glfw; + +import javax.annotation.*; + +import org.lwjgl.system.*; + +import static org.lwjgl.system.MemoryUtil.*; + +import static org.lwjgl.glfw.GLFW.*; + +/** + * Instances of this class may be passed to the {@link GLFW#glfwSetWindowCloseCallback SetWindowCloseCallback} method. + * + *

Type

+ * + *

+ * void (*) (
+ *     GLFWwindow *window
+ * )
+ * + * @since version 2.5 + */ +public abstract class GLFWWindowCloseCallback extends Callback implements GLFWWindowCloseCallbackI { + + /** + * Creates a {@code GLFWWindowCloseCallback} instance from the specified function pointer. + * + * @return the new {@code GLFWWindowCloseCallback} + */ + public static GLFWWindowCloseCallback create(long functionPointer) { + GLFWWindowCloseCallbackI instance = Callback.get(functionPointer); + return instance instanceof GLFWWindowCloseCallback + ? (GLFWWindowCloseCallback)instance + : new Container(functionPointer, instance); + } + + /** Like {@link #create(long) create}, but returns {@code null} if {@code functionPointer} is {@code NULL}. */ + @Nullable + public static GLFWWindowCloseCallback createSafe(long functionPointer) { + return functionPointer == NULL ? null : create(functionPointer); + } + + /** Creates a {@code GLFWWindowCloseCallback} instance that delegates to the specified {@code GLFWWindowCloseCallbackI} instance. */ + public static GLFWWindowCloseCallback create(GLFWWindowCloseCallbackI instance) { + return instance instanceof GLFWWindowCloseCallback + ? (GLFWWindowCloseCallback)instance + : new Container(instance.address(), instance); + } + + protected GLFWWindowCloseCallback() { + super(SIGNATURE); + } + + GLFWWindowCloseCallback(long functionPointer) { + super(functionPointer); + } + + /** See {@link GLFW#glfwSetWindowCloseCallback SetWindowCloseCallback}. */ + public GLFWWindowCloseCallback set(long window) { + glfwSetWindowCloseCallback(window, this); + return this; + } + + private static final class Container extends GLFWWindowCloseCallback { + + private final GLFWWindowCloseCallbackI delegate; + + Container(long functionPointer, GLFWWindowCloseCallbackI delegate) { + super(functionPointer); + this.delegate = delegate; + } + + @Override + public void invoke(long window) { + delegate.invoke(window); + } + + } + +} \ No newline at end of file diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWWindowCloseCallbackI.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWWindowCloseCallbackI.java new file mode 100644 index 000000000..f4357e29f --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWWindowCloseCallbackI.java @@ -0,0 +1,47 @@ +/* + * Copyright LWJGL. All rights reserved. + * License terms: https://www.lwjgl.org/license + * MACHINE GENERATED FILE, DO NOT EDIT + */ +package org.lwjgl.glfw; + +import org.lwjgl.system.*; + +import static org.lwjgl.system.dyncall.DynCallback.*; + +/** + * Instances of this interface may be passed to the {@link GLFW#glfwSetWindowCloseCallback SetWindowCloseCallback} method. + * + *

Type

+ * + *

+ * void (*) (
+ *     GLFWwindow *window
+ * )
+ * + * @since version 2.5 + */ +@FunctionalInterface +@NativeType("GLFWwindowclosefun") +public interface GLFWWindowCloseCallbackI extends CallbackI.V { + + String SIGNATURE = "(p)v"; + + @Override + default String getSignature() { return SIGNATURE; } + + @Override + default void callback(long args) { + invoke( + dcbArgPointer(args) + ); + } + + /** + * Will be called when the user attempts to close the specified window, for example by clicking the close widget in the title bar. + * + * @param window the window that the user attempted to close + */ + void invoke(@NativeType("GLFWwindow *") long window); + +} \ No newline at end of file diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWWindowContentScaleCallback.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWWindowContentScaleCallback.java new file mode 100644 index 000000000..8b61d6377 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWWindowContentScaleCallback.java @@ -0,0 +1,87 @@ +/* + * Copyright LWJGL. All rights reserved. + * License terms: https://www.lwjgl.org/license + * MACHINE GENERATED FILE, DO NOT EDIT + */ +package org.lwjgl.glfw; + +import javax.annotation.*; + +import org.lwjgl.system.*; + +import static org.lwjgl.system.MemoryUtil.*; + +import static org.lwjgl.glfw.GLFW.*; + +/** + * Instances of this class may be passed to the {@link GLFW#glfwSetWindowContentScaleCallback SetWindowContentScaleCallback} method. + * + *

Type

+ * + *

+ * void (*) (
+ *     GLFWwindow *window,
+ *     float xscale,
+ *     float yscale
+ * )
+ * + * @since version 3.3 + */ +public abstract class GLFWWindowContentScaleCallback extends Callback implements GLFWWindowContentScaleCallbackI { + + /** + * Creates a {@code GLFWWindowContentScaleCallback} instance from the specified function pointer. + * + * @return the new {@code GLFWWindowContentScaleCallback} + */ + public static GLFWWindowContentScaleCallback create(long functionPointer) { + GLFWWindowContentScaleCallbackI instance = Callback.get(functionPointer); + return instance instanceof GLFWWindowContentScaleCallback + ? (GLFWWindowContentScaleCallback)instance + : new Container(functionPointer, instance); + } + + /** Like {@link #create(long) create}, but returns {@code null} if {@code functionPointer} is {@code NULL}. */ + @Nullable + public static GLFWWindowContentScaleCallback createSafe(long functionPointer) { + return functionPointer == NULL ? null : create(functionPointer); + } + + /** Creates a {@code GLFWWindowContentScaleCallback} instance that delegates to the specified {@code GLFWWindowContentScaleCallbackI} instance. */ + public static GLFWWindowContentScaleCallback create(GLFWWindowContentScaleCallbackI instance) { + return instance instanceof GLFWWindowContentScaleCallback + ? (GLFWWindowContentScaleCallback)instance + : new Container(instance.address(), instance); + } + + protected GLFWWindowContentScaleCallback() { + super(SIGNATURE); + } + + GLFWWindowContentScaleCallback(long functionPointer) { + super(functionPointer); + } + + /** See {@link GLFW#glfwSetWindowContentScaleCallback SetWindowContentScaleCallback}. */ + public GLFWWindowContentScaleCallback set(long window) { + glfwSetWindowContentScaleCallback(window, this); + return this; + } + + private static final class Container extends GLFWWindowContentScaleCallback { + + private final GLFWWindowContentScaleCallbackI delegate; + + Container(long functionPointer, GLFWWindowContentScaleCallbackI delegate) { + super(functionPointer); + this.delegate = delegate; + } + + @Override + public void invoke(long window, float xscale, float yscale) { + delegate.invoke(window, xscale, yscale); + } + + } + +} \ No newline at end of file diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWWindowContentScaleCallbackI.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWWindowContentScaleCallbackI.java new file mode 100644 index 000000000..d3c979f63 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWWindowContentScaleCallbackI.java @@ -0,0 +1,53 @@ +/* + * Copyright LWJGL. All rights reserved. + * License terms: https://www.lwjgl.org/license + * MACHINE GENERATED FILE, DO NOT EDIT + */ +package org.lwjgl.glfw; + +import org.lwjgl.system.*; + +import static org.lwjgl.system.dyncall.DynCallback.*; + +/** + * Instances of this interface may be passed to the {@link GLFW#glfwSetWindowContentScaleCallback SetWindowContentScaleCallback} method. + * + *

Type

+ * + *

+ * void (*) (
+ *     GLFWwindow *window,
+ *     float xscale,
+ *     float yscale
+ * )
+ * + * @since version 3.3 + */ +@FunctionalInterface +@NativeType("GLFWwindowcontentscalefun") +public interface GLFWWindowContentScaleCallbackI extends CallbackI.V { + + String SIGNATURE = "(pff)v"; + + @Override + default String getSignature() { return SIGNATURE; } + + @Override + default void callback(long args) { + invoke( + dcbArgPointer(args), + dcbArgFloat(args), + dcbArgFloat(args) + ); + } + + /** + * Will be called when the window content scale changes. + * + * @param window the window whose content scale changed + * @param xscale the new x-axis content scale of the window + * @param yscale the new y-axis content scale of the window + */ + void invoke(@NativeType("GLFWwindow *") long window, float xscale, float yscale); + +} \ No newline at end of file diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWWindowFocusCallback.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWWindowFocusCallback.java new file mode 100644 index 000000000..74b466658 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWWindowFocusCallback.java @@ -0,0 +1,86 @@ +/* + * Copyright LWJGL. All rights reserved. + * License terms: https://www.lwjgl.org/license + * MACHINE GENERATED FILE, DO NOT EDIT + */ +package org.lwjgl.glfw; + +import javax.annotation.*; + +import org.lwjgl.system.*; + +import static org.lwjgl.system.MemoryUtil.*; + +import static org.lwjgl.glfw.GLFW.*; + +/** + * Instances of this class may be passed to the {@link GLFW#glfwSetWindowFocusCallback SetWindowFocusCallback} method. + * + *

Type

+ * + *

+ * void (*) (
+ *     GLFWwindow *window,
+ *     int focused
+ * )
+ * + * @since version 3.0 + */ +public abstract class GLFWWindowFocusCallback extends Callback implements GLFWWindowFocusCallbackI { + + /** + * Creates a {@code GLFWWindowFocusCallback} instance from the specified function pointer. + * + * @return the new {@code GLFWWindowFocusCallback} + */ + public static GLFWWindowFocusCallback create(long functionPointer) { + GLFWWindowFocusCallbackI instance = Callback.get(functionPointer); + return instance instanceof GLFWWindowFocusCallback + ? (GLFWWindowFocusCallback)instance + : new Container(functionPointer, instance); + } + + /** Like {@link #create(long) create}, but returns {@code null} if {@code functionPointer} is {@code NULL}. */ + @Nullable + public static GLFWWindowFocusCallback createSafe(long functionPointer) { + return functionPointer == NULL ? null : create(functionPointer); + } + + /** Creates a {@code GLFWWindowFocusCallback} instance that delegates to the specified {@code GLFWWindowFocusCallbackI} instance. */ + public static GLFWWindowFocusCallback create(GLFWWindowFocusCallbackI instance) { + return instance instanceof GLFWWindowFocusCallback + ? (GLFWWindowFocusCallback)instance + : new Container(instance.address(), instance); + } + + protected GLFWWindowFocusCallback() { + super(SIGNATURE); + } + + GLFWWindowFocusCallback(long functionPointer) { + super(functionPointer); + } + + /** See {@link GLFW#glfwSetWindowFocusCallback SetWindowFocusCallback}. */ + public GLFWWindowFocusCallback set(long window) { + glfwSetWindowFocusCallback(window, this); + return this; + } + + private static final class Container extends GLFWWindowFocusCallback { + + private final GLFWWindowFocusCallbackI delegate; + + Container(long functionPointer, GLFWWindowFocusCallbackI delegate) { + super(functionPointer); + this.delegate = delegate; + } + + @Override + public void invoke(long window, boolean focused) { + delegate.invoke(window, focused); + } + + } + +} \ No newline at end of file diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWWindowFocusCallbackI.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWWindowFocusCallbackI.java new file mode 100644 index 000000000..6ea92b122 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWWindowFocusCallbackI.java @@ -0,0 +1,50 @@ +/* + * Copyright LWJGL. All rights reserved. + * License terms: https://www.lwjgl.org/license + * MACHINE GENERATED FILE, DO NOT EDIT + */ +package org.lwjgl.glfw; + +import org.lwjgl.system.*; + +import static org.lwjgl.system.dyncall.DynCallback.*; + +/** + * Instances of this interface may be passed to the {@link GLFW#glfwSetWindowFocusCallback SetWindowFocusCallback} method. + * + *

Type

+ * + *

+ * void (*) (
+ *     GLFWwindow *window,
+ *     int focused
+ * )
+ * + * @since version 3.0 + */ +@FunctionalInterface +@NativeType("GLFWwindowfocusfun") +public interface GLFWWindowFocusCallbackI extends CallbackI.V { + + String SIGNATURE = "(pi)v"; + + @Override + default String getSignature() { return SIGNATURE; } + + @Override + default void callback(long args) { + invoke( + dcbArgPointer(args), + dcbArgInt(args) != 0 + ); + } + + /** + * Will be called when the specified window gains or loses focus. + * + * @param window the window that was focused or defocused + * @param focused {@link GLFW#GLFW_TRUE TRUE} if the window was focused, or {@link GLFW#GLFW_FALSE FALSE} if it was defocused + */ + void invoke(@NativeType("GLFWwindow *") long window, @NativeType("int") boolean focused); + +} \ No newline at end of file diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWWindowIconifyCallback.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWWindowIconifyCallback.java new file mode 100644 index 000000000..a9616a17f --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWWindowIconifyCallback.java @@ -0,0 +1,86 @@ +/* + * Copyright LWJGL. All rights reserved. + * License terms: https://www.lwjgl.org/license + * MACHINE GENERATED FILE, DO NOT EDIT + */ +package org.lwjgl.glfw; + +import javax.annotation.*; + +import org.lwjgl.system.*; + +import static org.lwjgl.system.MemoryUtil.*; + +import static org.lwjgl.glfw.GLFW.*; + +/** + * Instances of this class may be passed to the {@link GLFW#glfwSetWindowIconifyCallback SetWindowIconifyCallback} method. + * + *

Type

+ * + *

+ * void (*) (
+ *     GLFWwindow *window,
+ *     int iconified
+ * )
+ * + * @since version 3.0 + */ +public abstract class GLFWWindowIconifyCallback extends Callback implements GLFWWindowIconifyCallbackI { + + /** + * Creates a {@code GLFWWindowIconifyCallback} instance from the specified function pointer. + * + * @return the new {@code GLFWWindowIconifyCallback} + */ + public static GLFWWindowIconifyCallback create(long functionPointer) { + GLFWWindowIconifyCallbackI instance = Callback.get(functionPointer); + return instance instanceof GLFWWindowIconifyCallback + ? (GLFWWindowIconifyCallback)instance + : new Container(functionPointer, instance); + } + + /** Like {@link #create(long) create}, but returns {@code null} if {@code functionPointer} is {@code NULL}. */ + @Nullable + public static GLFWWindowIconifyCallback createSafe(long functionPointer) { + return functionPointer == NULL ? null : create(functionPointer); + } + + /** Creates a {@code GLFWWindowIconifyCallback} instance that delegates to the specified {@code GLFWWindowIconifyCallbackI} instance. */ + public static GLFWWindowIconifyCallback create(GLFWWindowIconifyCallbackI instance) { + return instance instanceof GLFWWindowIconifyCallback + ? (GLFWWindowIconifyCallback)instance + : new Container(instance.address(), instance); + } + + protected GLFWWindowIconifyCallback() { + super(SIGNATURE); + } + + GLFWWindowIconifyCallback(long functionPointer) { + super(functionPointer); + } + + /** See {@link GLFW#glfwSetWindowIconifyCallback SetWindowIconifyCallback}. */ + public GLFWWindowIconifyCallback set(long window) { + glfwSetWindowIconifyCallback(window, this); + return this; + } + + private static final class Container extends GLFWWindowIconifyCallback { + + private final GLFWWindowIconifyCallbackI delegate; + + Container(long functionPointer, GLFWWindowIconifyCallbackI delegate) { + super(functionPointer); + this.delegate = delegate; + } + + @Override + public void invoke(long window, boolean iconified) { + delegate.invoke(window, iconified); + } + + } + +} \ No newline at end of file diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWWindowIconifyCallbackI.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWWindowIconifyCallbackI.java new file mode 100644 index 000000000..b21159683 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWWindowIconifyCallbackI.java @@ -0,0 +1,50 @@ +/* + * Copyright LWJGL. All rights reserved. + * License terms: https://www.lwjgl.org/license + * MACHINE GENERATED FILE, DO NOT EDIT + */ +package org.lwjgl.glfw; + +import org.lwjgl.system.*; + +import static org.lwjgl.system.dyncall.DynCallback.*; + +/** + * Instances of this interface may be passed to the {@link GLFW#glfwSetWindowIconifyCallback SetWindowIconifyCallback} method. + * + *

Type

+ * + *

+ * void (*) (
+ *     GLFWwindow *window,
+ *     int iconified
+ * )
+ * + * @since version 3.0 + */ +@FunctionalInterface +@NativeType("GLFWwindowiconifyfun") +public interface GLFWWindowIconifyCallbackI extends CallbackI.V { + + String SIGNATURE = "(pi)v"; + + @Override + default String getSignature() { return SIGNATURE; } + + @Override + default void callback(long args) { + invoke( + dcbArgPointer(args), + dcbArgInt(args) != 0 + ); + } + + /** + * Will be called when the specified window is iconified or restored. + * + * @param window the window that was iconified or restored. + * @param iconified {@link GLFW#GLFW_TRUE TRUE} if the window was iconified, or {@link GLFW#GLFW_FALSE FALSE} if it was restored + */ + void invoke(@NativeType("GLFWwindow *") long window, @NativeType("int") boolean iconified); + +} \ No newline at end of file diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWWindowMaximizeCallback.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWWindowMaximizeCallback.java new file mode 100644 index 000000000..b8e93649f --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWWindowMaximizeCallback.java @@ -0,0 +1,86 @@ +/* + * Copyright LWJGL. All rights reserved. + * License terms: https://www.lwjgl.org/license + * MACHINE GENERATED FILE, DO NOT EDIT + */ +package org.lwjgl.glfw; + +import javax.annotation.*; + +import org.lwjgl.system.*; + +import static org.lwjgl.system.MemoryUtil.*; + +import static org.lwjgl.glfw.GLFW.*; + +/** + * Instances of this class may be passed to the {@link GLFW#glfwSetWindowMaximizeCallback SetWindowMaximizeCallback} method. + * + *

Type

+ * + *

+ * void (*) (
+ *     GLFWwindow *window,
+ *     int maximized
+ * )
+ * + * @since version 3.3 + */ +public abstract class GLFWWindowMaximizeCallback extends Callback implements GLFWWindowMaximizeCallbackI { + + /** + * Creates a {@code GLFWWindowMaximizeCallback} instance from the specified function pointer. + * + * @return the new {@code GLFWWindowMaximizeCallback} + */ + public static GLFWWindowMaximizeCallback create(long functionPointer) { + GLFWWindowMaximizeCallbackI instance = Callback.get(functionPointer); + return instance instanceof GLFWWindowMaximizeCallback + ? (GLFWWindowMaximizeCallback)instance + : new Container(functionPointer, instance); + } + + /** Like {@link #create(long) create}, but returns {@code null} if {@code functionPointer} is {@code NULL}. */ + @Nullable + public static GLFWWindowMaximizeCallback createSafe(long functionPointer) { + return functionPointer == NULL ? null : create(functionPointer); + } + + /** Creates a {@code GLFWWindowMaximizeCallback} instance that delegates to the specified {@code GLFWWindowMaximizeCallbackI} instance. */ + public static GLFWWindowMaximizeCallback create(GLFWWindowMaximizeCallbackI instance) { + return instance instanceof GLFWWindowMaximizeCallback + ? (GLFWWindowMaximizeCallback)instance + : new Container(instance.address(), instance); + } + + protected GLFWWindowMaximizeCallback() { + super(SIGNATURE); + } + + GLFWWindowMaximizeCallback(long functionPointer) { + super(functionPointer); + } + + /** See {@link GLFW#glfwSetWindowMaximizeCallback SetWindowMaximizeCallback}. */ + public GLFWWindowMaximizeCallback set(long window) { + glfwSetWindowMaximizeCallback(window, this); + return this; + } + + private static final class Container extends GLFWWindowMaximizeCallback { + + private final GLFWWindowMaximizeCallbackI delegate; + + Container(long functionPointer, GLFWWindowMaximizeCallbackI delegate) { + super(functionPointer); + this.delegate = delegate; + } + + @Override + public void invoke(long window, boolean maximized) { + delegate.invoke(window, maximized); + } + + } + +} \ No newline at end of file diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWWindowMaximizeCallbackI.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWWindowMaximizeCallbackI.java new file mode 100644 index 000000000..a698aaf27 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWWindowMaximizeCallbackI.java @@ -0,0 +1,50 @@ +/* + * Copyright LWJGL. All rights reserved. + * License terms: https://www.lwjgl.org/license + * MACHINE GENERATED FILE, DO NOT EDIT + */ +package org.lwjgl.glfw; + +import org.lwjgl.system.*; + +import static org.lwjgl.system.dyncall.DynCallback.*; + +/** + * Instances of this interface may be passed to the {@link GLFW#glfwSetWindowMaximizeCallback SetWindowMaximizeCallback} method. + * + *

Type

+ * + *

+ * void (*) (
+ *     GLFWwindow *window,
+ *     int maximized
+ * )
+ * + * @since version 3.3 + */ +@FunctionalInterface +@NativeType("GLFWwindowmaximizefun") +public interface GLFWWindowMaximizeCallbackI extends CallbackI.V { + + String SIGNATURE = "(pi)v"; + + @Override + default String getSignature() { return SIGNATURE; } + + @Override + default void callback(long args) { + invoke( + dcbArgPointer(args), + dcbArgInt(args) != 0 + ); + } + + /** + * Will be called when the specified window is maximized or restored. + * + * @param window the window that was maximized or restored. + * @param maximized {@link GLFW#GLFW_TRUE TRUE} if the window was maximized, or {@link GLFW#GLFW_FALSE FALSE} if it was restored + */ + void invoke(@NativeType("GLFWwindow *") long window, @NativeType("int") boolean maximized); + +} \ No newline at end of file diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWWindowPosCallback.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWWindowPosCallback.java new file mode 100644 index 000000000..e4e1ee3d5 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWWindowPosCallback.java @@ -0,0 +1,87 @@ +/* + * Copyright LWJGL. All rights reserved. + * License terms: https://www.lwjgl.org/license + * MACHINE GENERATED FILE, DO NOT EDIT + */ +package org.lwjgl.glfw; + +import javax.annotation.*; + +import org.lwjgl.system.*; + +import static org.lwjgl.system.MemoryUtil.*; + +import static org.lwjgl.glfw.GLFW.*; + +/** + * Instances of this class may be passed to the {@link GLFW#glfwSetWindowPosCallback SetWindowPosCallback} method. + * + *

Type

+ * + *

+ * void (*) (
+ *     GLFWwindow *window,
+ *     int xpos,
+ *     int ypos
+ * )
+ * + * @since version 3.0 + */ +public abstract class GLFWWindowPosCallback extends Callback implements GLFWWindowPosCallbackI { + + /** + * Creates a {@code GLFWWindowPosCallback} instance from the specified function pointer. + * + * @return the new {@code GLFWWindowPosCallback} + */ + public static GLFWWindowPosCallback create(long functionPointer) { + GLFWWindowPosCallbackI instance = Callback.get(functionPointer); + return instance instanceof GLFWWindowPosCallback + ? (GLFWWindowPosCallback)instance + : new Container(functionPointer, instance); + } + + /** Like {@link #create(long) create}, but returns {@code null} if {@code functionPointer} is {@code NULL}. */ + @Nullable + public static GLFWWindowPosCallback createSafe(long functionPointer) { + return functionPointer == NULL ? null : create(functionPointer); + } + + /** Creates a {@code GLFWWindowPosCallback} instance that delegates to the specified {@code GLFWWindowPosCallbackI} instance. */ + public static GLFWWindowPosCallback create(GLFWWindowPosCallbackI instance) { + return instance instanceof GLFWWindowPosCallback + ? (GLFWWindowPosCallback)instance + : new Container(instance.address(), instance); + } + + protected GLFWWindowPosCallback() { + super(SIGNATURE); + } + + GLFWWindowPosCallback(long functionPointer) { + super(functionPointer); + } + + /** See {@link GLFW#glfwSetWindowPosCallback SetWindowPosCallback}. */ + public GLFWWindowPosCallback set(long window) { + glfwSetWindowPosCallback(window, this); + return this; + } + + private static final class Container extends GLFWWindowPosCallback { + + private final GLFWWindowPosCallbackI delegate; + + Container(long functionPointer, GLFWWindowPosCallbackI delegate) { + super(functionPointer); + this.delegate = delegate; + } + + @Override + public void invoke(long window, int xpos, int ypos) { + delegate.invoke(window, xpos, ypos); + } + + } + +} \ No newline at end of file diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWWindowPosCallbackI.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWWindowPosCallbackI.java new file mode 100644 index 000000000..a945a27d8 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWWindowPosCallbackI.java @@ -0,0 +1,53 @@ +/* + * Copyright LWJGL. All rights reserved. + * License terms: https://www.lwjgl.org/license + * MACHINE GENERATED FILE, DO NOT EDIT + */ +package org.lwjgl.glfw; + +import org.lwjgl.system.*; + +import static org.lwjgl.system.dyncall.DynCallback.*; + +/** + * Instances of this interface may be passed to the {@link GLFW#glfwSetWindowPosCallback SetWindowPosCallback} method. + * + *

Type

+ * + *

+ * void (*) (
+ *     GLFWwindow *window,
+ *     int xpos,
+ *     int ypos
+ * )
+ * + * @since version 3.0 + */ +@FunctionalInterface +@NativeType("GLFWwindowposfun") +public interface GLFWWindowPosCallbackI extends CallbackI.V { + + String SIGNATURE = "(pii)v"; + + @Override + default String getSignature() { return SIGNATURE; } + + @Override + default void callback(long args) { + invoke( + dcbArgPointer(args), + dcbArgInt(args), + dcbArgInt(args) + ); + } + + /** + * Will be called when the specified window moves. + * + * @param window the window that was moved + * @param xpos the new x-coordinate, in screen coordinates, of the upper-left corner of the content area of the window + * @param ypos the new y-coordinate, in screen coordinates, of the upper-left corner of the content area of the window + */ + void invoke(@NativeType("GLFWwindow *") long window, int xpos, int ypos); + +} \ No newline at end of file diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWWindowProperties.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWWindowProperties.java new file mode 100644 index 000000000..0596bad1f --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWWindowProperties.java @@ -0,0 +1,13 @@ +package org.lwjgl.glfw; + +import java.util.*; + +public class GLFWWindowProperties { + public int width = GLFW.mGLFWWindowWidth; + public int height = GLFW.mGLFWWindowHeight; + public int x, y; + public CharSequence title; + public boolean shouldClose, isInitialSizeCalled, isCursorEntered; + public Map inputModes = new HashMap<>(); + public Map windowAttribs = new HashMap<>(); +} diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWWindowRefreshCallback.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWWindowRefreshCallback.java new file mode 100644 index 000000000..11ea1ed99 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWWindowRefreshCallback.java @@ -0,0 +1,85 @@ +/* + * Copyright LWJGL. All rights reserved. + * License terms: https://www.lwjgl.org/license + * MACHINE GENERATED FILE, DO NOT EDIT + */ +package org.lwjgl.glfw; + +import javax.annotation.*; + +import org.lwjgl.system.*; + +import static org.lwjgl.system.MemoryUtil.*; + +import static org.lwjgl.glfw.GLFW.*; + +/** + * Instances of this class may be passed to the {@link GLFW#glfwSetWindowRefreshCallback SetWindowRefreshCallback} method. + * + *

Type

+ * + *

+ * void (*) (
+ *     GLFWwindow *window
+ * )
+ * + * @since version 2.5 + */ +public abstract class GLFWWindowRefreshCallback extends Callback implements GLFWWindowRefreshCallbackI { + + /** + * Creates a {@code GLFWWindowRefreshCallback} instance from the specified function pointer. + * + * @return the new {@code GLFWWindowRefreshCallback} + */ + public static GLFWWindowRefreshCallback create(long functionPointer) { + GLFWWindowRefreshCallbackI instance = Callback.get(functionPointer); + return instance instanceof GLFWWindowRefreshCallback + ? (GLFWWindowRefreshCallback)instance + : new Container(functionPointer, instance); + } + + /** Like {@link #create(long) create}, but returns {@code null} if {@code functionPointer} is {@code NULL}. */ + @Nullable + public static GLFWWindowRefreshCallback createSafe(long functionPointer) { + return functionPointer == NULL ? null : create(functionPointer); + } + + /** Creates a {@code GLFWWindowRefreshCallback} instance that delegates to the specified {@code GLFWWindowRefreshCallbackI} instance. */ + public static GLFWWindowRefreshCallback create(GLFWWindowRefreshCallbackI instance) { + return instance instanceof GLFWWindowRefreshCallback + ? (GLFWWindowRefreshCallback)instance + : new Container(instance.address(), instance); + } + + protected GLFWWindowRefreshCallback() { + super(SIGNATURE); + } + + GLFWWindowRefreshCallback(long functionPointer) { + super(functionPointer); + } + + /** See {@link GLFW#glfwSetWindowRefreshCallback SetWindowRefreshCallback}. */ + public GLFWWindowRefreshCallback set(long window) { + glfwSetWindowRefreshCallback(window, this); + return this; + } + + private static final class Container extends GLFWWindowRefreshCallback { + + private final GLFWWindowRefreshCallbackI delegate; + + Container(long functionPointer, GLFWWindowRefreshCallbackI delegate) { + super(functionPointer); + this.delegate = delegate; + } + + @Override + public void invoke(long window) { + delegate.invoke(window); + } + + } + +} \ No newline at end of file diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWWindowRefreshCallbackI.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWWindowRefreshCallbackI.java new file mode 100644 index 000000000..0fae18261 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWWindowRefreshCallbackI.java @@ -0,0 +1,48 @@ +/* + * Copyright LWJGL. All rights reserved. + * License terms: https://www.lwjgl.org/license + * MACHINE GENERATED FILE, DO NOT EDIT + */ +package org.lwjgl.glfw; + +import org.lwjgl.system.*; + +import static org.lwjgl.system.dyncall.DynCallback.*; + +/** + * Instances of this interface may be passed to the {@link GLFW#glfwSetWindowRefreshCallback SetWindowRefreshCallback} method. + * + *

Type

+ * + *

+ * void (*) (
+ *     GLFWwindow *window
+ * )
+ * + * @since version 2.5 + */ +@FunctionalInterface +@NativeType("GLFWwindowrefreshfun") +public interface GLFWWindowRefreshCallbackI extends CallbackI.V { + + String SIGNATURE = "(p)v"; + + @Override + default String getSignature() { return SIGNATURE; } + + @Override + default void callback(long args) { + invoke( + dcbArgPointer(args) + ); + } + + /** + * Will be called when the client area of the specified window needs to be redrawn, for example if the window has been exposed after having been covered by + * another window. + * + * @param window the window whose content needs to be refreshed + */ + void invoke(@NativeType("GLFWwindow *") long window); + +} \ No newline at end of file diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWWindowSizeCallback.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWWindowSizeCallback.java new file mode 100644 index 000000000..f630ab395 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWWindowSizeCallback.java @@ -0,0 +1,85 @@ +/* + * Copyright LWJGL. All rights reserved. + * License terms: https://www.lwjgl.org/license + * MACHINE GENERATED FILE, DO NOT EDIT + */ +package org.lwjgl.glfw; + +import javax.annotation.*; + +import org.lwjgl.system.*; + +import static org.lwjgl.system.MemoryUtil.*; + +import static org.lwjgl.glfw.GLFW.*; + +/** + * Instances of this class may be passed to the {@link GLFW#glfwSetWindowSizeCallback SetWindowSizeCallback} method. + * + *

Type

+ * + *

+ * void (*) (
+ *     GLFWwindow *window,
+ *     int width,
+ *     int height
+ * )
+ */ +public abstract class GLFWWindowSizeCallback extends Callback implements GLFWWindowSizeCallbackI { + + /** + * Creates a {@code GLFWWindowSizeCallback} instance from the specified function pointer. + * + * @return the new {@code GLFWWindowSizeCallback} + */ + public static GLFWWindowSizeCallback create(long functionPointer) { + GLFWWindowSizeCallbackI instance = Callback.get(functionPointer); + return instance instanceof GLFWWindowSizeCallback + ? (GLFWWindowSizeCallback)instance + : new Container(functionPointer, instance); + } + + /** Like {@link #create(long) create}, but returns {@code null} if {@code functionPointer} is {@code NULL}. */ + @Nullable + public static GLFWWindowSizeCallback createSafe(long functionPointer) { + return functionPointer == NULL ? null : create(functionPointer); + } + + /** Creates a {@code GLFWWindowSizeCallback} instance that delegates to the specified {@code GLFWWindowSizeCallbackI} instance. */ + public static GLFWWindowSizeCallback create(GLFWWindowSizeCallbackI instance) { + return instance instanceof GLFWWindowSizeCallback + ? (GLFWWindowSizeCallback)instance + : new Container(instance.address(), instance); + } + + protected GLFWWindowSizeCallback() { + super(SIGNATURE); + } + + GLFWWindowSizeCallback(long functionPointer) { + super(functionPointer); + } + + /** See {@link GLFW#glfwSetWindowSizeCallback SetWindowSizeCallback}. */ + public GLFWWindowSizeCallback set(long window) { + glfwSetWindowSizeCallback(window, this); + return this; + } + + private static final class Container extends GLFWWindowSizeCallback { + + private final GLFWWindowSizeCallbackI delegate; + + Container(long functionPointer, GLFWWindowSizeCallbackI delegate) { + super(functionPointer); + this.delegate = delegate; + } + + @Override + public void invoke(long window, int width, int height) { + delegate.invoke(window, width, height); + } + + } + +} \ No newline at end of file diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWWindowSizeCallbackI.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWWindowSizeCallbackI.java new file mode 100644 index 000000000..9e1d4f023 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWWindowSizeCallbackI.java @@ -0,0 +1,51 @@ +/* + * Copyright LWJGL. All rights reserved. + * License terms: https://www.lwjgl.org/license + * MACHINE GENERATED FILE, DO NOT EDIT + */ +package org.lwjgl.glfw; + +import org.lwjgl.system.*; + +import static org.lwjgl.system.dyncall.DynCallback.*; + +/** + * Instances of this interface may be passed to the {@link GLFW#glfwSetWindowSizeCallback SetWindowSizeCallback} method. + * + *

Type

+ * + *

+ * void (*) (
+ *     GLFWwindow *window,
+ *     int width,
+ *     int height
+ * )
+ */ +@FunctionalInterface +@NativeType("GLFWwindowsizefun") +public interface GLFWWindowSizeCallbackI extends CallbackI.V { + + String SIGNATURE = "(pii)v"; + + @Override + default String getSignature() { return SIGNATURE; } + + @Override + default void callback(long args) { + invoke( + dcbArgPointer(args), + dcbArgInt(args), + dcbArgInt(args) + ); + } + + /** + * Will be called when the specified window is resized. + * + * @param window the window that was resized + * @param width the new width, in screen coordinates, of the window + * @param height the new height, in screen coordinates, of the window + */ + void invoke(@NativeType("GLFWwindow *") long window, int width, int height); + +} \ No newline at end of file diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/package-info.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/package-info.java new file mode 100644 index 000000000..d3c700296 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright LWJGL. All rights reserved. + * License terms: https://www.lwjgl.org/license + * MACHINE GENERATED FILE, DO NOT EDIT + */ + +/** + * Contains bindings to the GLFW library. + * + *

GLFW comes with extensive documentation, which you can read online here. The + * Frequently Asked Questions are also useful.

+ * + *

On macOS the JVM must be started with the {@code -XstartOnFirstThread} argument for GLFW to work. This is necessary because most GLFW functions must be + * called on the main thread and the Cocoa API on macOS requires that thread to be the first thread in the process. For this reason, on-screen GLFW + * windows and the GLFW event loop are incompatible with other window toolkits (such as AWT/Swing or JavaFX) on macOS. Off-screen GLFW windows can be used + * with other window toolkits, but only if the window toolkit is initialized before GLFW.

+ */ +@org.lwjgl.system.NonnullDefault +package org.lwjgl.glfw; + diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/input/Cursor.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/input/Cursor.java new file mode 100644 index 000000000..9604aea47 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/input/Cursor.java @@ -0,0 +1,270 @@ +package org.lwjgl.input; + +import java.nio.ByteBuffer; +import java.nio.IntBuffer; + +import org.lwjgl.BufferUtils; +import org.lwjgl.glfw.GLFW; +import org.lwjgl.glfw.GLFWImage; +import org.lwjgl.system.MemoryUtil; +import org.lwjgl.LWJGLException; + +public class Cursor { + + /** 1 bit transparency for native cursor */ + public static final int CURSOR_ONE_BIT_TRANSPARENCY = 1; + + /** 8 bit alpha native cursor */ + public static final int CURSOR_8_BIT_ALPHA = 2; + + /** Animation native cursor */ + public static final int CURSOR_ANIMATION = 4; + + /** Elements to display */ + private final CursorElement[] cursors; + + /** Index into list of cursors */ + private int index; + + /** Flag set when the cursor has been destroyed */ + 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 transparency 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 { + + cursors = new CursorElement[numImages]; + + IntBuffer flippedImages = BufferUtils.createIntBuffer(images.limit()); + flipImages(width, height, numImages, images, flippedImages); + + ByteBuffer pixels = convertARGBIntBuffertoRGBAByteBuffer(width, height, flippedImages); + + for (int i = 0; i < numImages; i++) { + int size = width * height; + ByteBuffer image = BufferUtils.createByteBuffer(size); + for (int j = 0; j < size; j++) + image.put(pixels.get()); + + GLFWImage cursorImage = GLFWImage.malloc(); + cursorImage.width(width); + cursorImage.height(height); + cursorImage.pixels(image); + + long delay = (delays != null) ? delays.get(i) : 0; + long timeout = GLFW.glfwGetTimerValue(); + cursors[i] = new CursorElement(xHotspot, yHotspot, delay, timeout, cursorImage); + } + } + + private static ByteBuffer convertARGBIntBuffertoRGBAByteBuffer(int width, int height, IntBuffer imageBuffer) { + ByteBuffer pixels = BufferUtils.createByteBuffer(width * height * 4); + + for (int i = 0; i < imageBuffer.limit(); i++) { + int argbColor = imageBuffer.get(i); + + byte alpha = (byte) (argbColor >>> 24); + byte blue = (byte) (argbColor >>> 16); + byte green = (byte) (argbColor >>> 8); + byte red = (byte) argbColor; + + pixels.put(red); + pixels.put(green); + pixels.put(blue); + pixels.put(alpha); + } + + pixels.flip(); + + return pixels; + } + + /** + * 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 minimum size of a native cursor + */ + public static int getMinCursorSize() { + return 1; + } + + /** + * Gets the maximum size of a native cursor. Can only be called if the + * cursor caps includes at least {@link #CURSOR_ONE_BIT_TRANSPARENCY}. + * + * @return the maximum size of a native cursor + */ + public static int getMaxCursorSize() { + return 512; + } + + /** + * Get the capabilities of the native cursor. Return a bit mask of the + * native cursor capabilities. + *
    + *
  • CURSOR_ONE_BIT_TRANSPARENCY indicates support for + * cursors with one bit transparency.
  • + * + *
  • CURSOR_8_BIT_ALPHA indicates support for 8 bit + * alpha.
  • + * + *
  • CURSOR_ANIMATION indicates support for cursor + * animations.
  • + *
+ * + * @return A bit mask with native cursor capabilities. + */ + public static int getCapabilities() { + return CURSOR_8_BIT_ALPHA | CURSOR_ANIMATION; + } + + /** + * 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. + */ + long getHandle() { + checkValid(); + return cursors[index].cursorHandle; + } + + /** + * Checks whether the cursor is still active and not yet destroyed. + */ + private void checkValid() { + if (destroyed) + throw new IllegalStateException("The cursor is already destroyed"); + } + + /** + * Destroy the current cursor. If the cursor is current, the current native + * cursor is set to null (the default OS cursor) + */ + public void destroy() { + for (CursorElement cursor : cursors) + GLFW.glfwDestroyCursor(cursor.cursorHandle); + + destroyed = true; + } + + /** + * Sets the timout property to the time it should be changed + */ + + protected void setTimeout() { + checkValid(); + cursors[index].timeout = GLFW.glfwGetTimerValue() + cursors[index].delay; + } + + /** + * Determines whether this cursor has timed out + * + * @return true if the this cursor has timed out, false if not + */ + + protected boolean hasTimedOut() { + checkValid(); + return cursors.length > 1 && cursors[index].timeout < GLFW.glfwGetTimerValue(); + } + + /** + * Changes to the next cursor + */ + protected void nextCursor() { + checkValid(); + index = ++index % cursors.length; + } + + /** + * A single cursor element, used when animating + */ + private static class CursorElement { + + final long cursorHandle; + long delay; + long timeout; + + CursorElement(int xHotspot, int yHotspot, long delay, long timeout, GLFWImage image) { + this.delay = delay; + this.timeout = timeout; + + this.cursorHandle = GLFW.glfwCreateCursor(image, xHotspot, yHotspot); + if (cursorHandle == MemoryUtil.NULL) + throw new RuntimeException("Error creating GLFW cursor"); + } + } + +} diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/input/EventQueue.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/input/EventQueue.java new file mode 100644 index 000000000..c498facfb --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/input/EventQueue.java @@ -0,0 +1,61 @@ +package org.lwjgl.input; + +/** + * Internal utility class to keep track of event positions in an array. When the + * array is full the position will wrap to the beginning. + */ +class EventQueue { + + private int maxEvents = 32; + private int currentEventPos = -1; + private int nextEventPos = 0; + + EventQueue(int maxEvents) { + this.maxEvents = maxEvents; + } + + /** + * add event to the queue + */ + void add() { + nextEventPos++; // increment next event position + if (nextEventPos == maxEvents) + nextEventPos = 0; // wrap next event position + + if (nextEventPos == currentEventPos) { + currentEventPos++; // skip oldest event is queue full + if (currentEventPos == maxEvents) + currentEventPos = 0; // wrap current event position + } + } + + /** + * Increment the event queue + * + * @return - true if there is an event available + */ + boolean next() { + if (currentEventPos == nextEventPos - 1) + return false; + if (nextEventPos == 0 && currentEventPos == maxEvents - 1) + return false; + + currentEventPos++; // increment current event position + if (currentEventPos == maxEvents) + currentEventPos = 0; // wrap current event position + + return true; + } + + int getMaxEvents() { + return maxEvents; + } + + int getCurrentPos() { + return currentEventPos; + } + + int getNextPos() { + return nextEventPos; + } +} diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/input/KeyCodes.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/input/KeyCodes.java new file mode 100644 index 000000000..55fa70649 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/input/KeyCodes.java @@ -0,0 +1,321 @@ +package org.lwjgl.input; + +import org.lwjgl.glfw.GLFW; + +public class KeyCodes { + + public static int toLwjglKey(int glfwKeyCode) { + + switch(glfwKeyCode) { + + case GLFW.GLFW_KEY_ESCAPE : return Keyboard.KEY_ESCAPE; + case GLFW.GLFW_KEY_BACKSPACE: return Keyboard.KEY_BACK; + case GLFW.GLFW_KEY_TAB : return Keyboard.KEY_TAB; + case GLFW.GLFW_KEY_ENTER : return Keyboard.KEY_RETURN; + case GLFW.GLFW_KEY_SPACE : return Keyboard.KEY_SPACE; + + case GLFW.GLFW_KEY_LEFT_CONTROL : return Keyboard.KEY_LCONTROL; + case GLFW.GLFW_KEY_LEFT_SHIFT : return Keyboard.KEY_LSHIFT; + case GLFW.GLFW_KEY_LEFT_ALT : return Keyboard.KEY_LMENU; + case GLFW.GLFW_KEY_LEFT_SUPER : return Keyboard.KEY_LMETA; + + case GLFW.GLFW_KEY_RIGHT_CONTROL: return Keyboard.KEY_RCONTROL; + case GLFW.GLFW_KEY_RIGHT_SHIFT : return Keyboard.KEY_RSHIFT; + case GLFW.GLFW_KEY_RIGHT_ALT : return Keyboard.KEY_RMENU; + case GLFW.GLFW_KEY_RIGHT_SUPER : return Keyboard.KEY_RMETA; + + case GLFW.GLFW_KEY_1 : return Keyboard.KEY_1; + case GLFW.GLFW_KEY_2 : return Keyboard.KEY_2; + case GLFW.GLFW_KEY_3 : return Keyboard.KEY_3; + case GLFW.GLFW_KEY_4 : return Keyboard.KEY_4; + case GLFW.GLFW_KEY_5 : return Keyboard.KEY_5; + case GLFW.GLFW_KEY_6 : return Keyboard.KEY_6; + case GLFW.GLFW_KEY_7 : return Keyboard.KEY_7; + case GLFW.GLFW_KEY_8 : return Keyboard.KEY_8; + case GLFW.GLFW_KEY_9 : return Keyboard.KEY_9; + case GLFW.GLFW_KEY_0 : return Keyboard.KEY_0; + + case GLFW.GLFW_KEY_A : return Keyboard.KEY_A; + case GLFW.GLFW_KEY_B : return Keyboard.KEY_B; + case GLFW.GLFW_KEY_C : return Keyboard.KEY_C; + case GLFW.GLFW_KEY_D : return Keyboard.KEY_D; + case GLFW.GLFW_KEY_E : return Keyboard.KEY_E; + case GLFW.GLFW_KEY_F : return Keyboard.KEY_F; + case GLFW.GLFW_KEY_G : return Keyboard.KEY_G; + case GLFW.GLFW_KEY_H : return Keyboard.KEY_H; + case GLFW.GLFW_KEY_I : return Keyboard.KEY_I; + case GLFW.GLFW_KEY_J : return Keyboard.KEY_J; + case GLFW.GLFW_KEY_K : return Keyboard.KEY_K; + case GLFW.GLFW_KEY_L : return Keyboard.KEY_L; + case GLFW.GLFW_KEY_M : return Keyboard.KEY_M; + case GLFW.GLFW_KEY_N : return Keyboard.KEY_N; + case GLFW.GLFW_KEY_O : return Keyboard.KEY_O; + case GLFW.GLFW_KEY_P : return Keyboard.KEY_P; + case GLFW.GLFW_KEY_Q : return Keyboard.KEY_Q; + case GLFW.GLFW_KEY_R : return Keyboard.KEY_R; + case GLFW.GLFW_KEY_S : return Keyboard.KEY_S; + case GLFW.GLFW_KEY_T : return Keyboard.KEY_T; + case GLFW.GLFW_KEY_U : return Keyboard.KEY_U; + case GLFW.GLFW_KEY_V : return Keyboard.KEY_V; + case GLFW.GLFW_KEY_W : return Keyboard.KEY_W; + case GLFW.GLFW_KEY_X : return Keyboard.KEY_X; + case GLFW.GLFW_KEY_Y : return Keyboard.KEY_Y; + case GLFW.GLFW_KEY_Z : return Keyboard.KEY_Z; + + case GLFW.GLFW_KEY_UP : return Keyboard.KEY_UP; + case GLFW.GLFW_KEY_DOWN : return Keyboard.KEY_DOWN; + case GLFW.GLFW_KEY_LEFT : return Keyboard.KEY_LEFT; + case GLFW.GLFW_KEY_RIGHT : return Keyboard.KEY_RIGHT; + + case GLFW.GLFW_KEY_INSERT : return Keyboard.KEY_INSERT; + case GLFW.GLFW_KEY_DELETE : return Keyboard.KEY_DELETE; + case GLFW.GLFW_KEY_HOME : return Keyboard.KEY_HOME; + case GLFW.GLFW_KEY_END : return Keyboard.KEY_END; + case GLFW.GLFW_KEY_PAGE_UP : return Keyboard.KEY_PRIOR; + case GLFW.GLFW_KEY_PAGE_DOWN: return Keyboard.KEY_NEXT; + + case GLFW.GLFW_KEY_F1 : return Keyboard.KEY_F1; + case GLFW.GLFW_KEY_F2 : return Keyboard.KEY_F2; + case GLFW.GLFW_KEY_F3 : return Keyboard.KEY_F3; + case GLFW.GLFW_KEY_F4 : return Keyboard.KEY_F4; + case GLFW.GLFW_KEY_F5 : return Keyboard.KEY_F5; + case GLFW.GLFW_KEY_F6 : return Keyboard.KEY_F6; + case GLFW.GLFW_KEY_F7 : return Keyboard.KEY_F7; + case GLFW.GLFW_KEY_F8 : return Keyboard.KEY_F8; + case GLFW.GLFW_KEY_F9 : return Keyboard.KEY_F9; + case GLFW.GLFW_KEY_F10 : return Keyboard.KEY_F10; + case GLFW.GLFW_KEY_F11 : return Keyboard.KEY_F11; + case GLFW.GLFW_KEY_F12 : return Keyboard.KEY_F12; + case GLFW.GLFW_KEY_F13 : return Keyboard.KEY_F13; + case GLFW.GLFW_KEY_F14 : return Keyboard.KEY_F14; + case GLFW.GLFW_KEY_F15 : return Keyboard.KEY_F15; + case GLFW.GLFW_KEY_F16 : return Keyboard.KEY_F16; + case GLFW.GLFW_KEY_F17 : return Keyboard.KEY_F17; + case GLFW.GLFW_KEY_F18 : return Keyboard.KEY_F18; + case GLFW.GLFW_KEY_F19 : return Keyboard.KEY_F19; + + case GLFW.GLFW_KEY_KP_1 : return Keyboard.KEY_NUMPAD1; + case GLFW.GLFW_KEY_KP_2 : return Keyboard.KEY_NUMPAD2; + case GLFW.GLFW_KEY_KP_3 : return Keyboard.KEY_NUMPAD3; + case GLFW.GLFW_KEY_KP_4 : return Keyboard.KEY_NUMPAD4; + case GLFW.GLFW_KEY_KP_5 : return Keyboard.KEY_NUMPAD5; + case GLFW.GLFW_KEY_KP_6 : return Keyboard.KEY_NUMPAD6; + case GLFW.GLFW_KEY_KP_7 : return Keyboard.KEY_NUMPAD7; + case GLFW.GLFW_KEY_KP_8 : return Keyboard.KEY_NUMPAD8; + case GLFW.GLFW_KEY_KP_9 : return Keyboard.KEY_NUMPAD9; + case GLFW.GLFW_KEY_KP_0 : return Keyboard.KEY_NUMPAD0; + + case GLFW.GLFW_KEY_KP_ADD : return Keyboard.KEY_ADD; + case GLFW.GLFW_KEY_KP_SUBTRACT : return Keyboard.KEY_SUBTRACT; + case GLFW.GLFW_KEY_KP_MULTIPLY : return Keyboard.KEY_MULTIPLY; + case GLFW.GLFW_KEY_KP_DIVIDE: return Keyboard.KEY_DIVIDE; + case GLFW.GLFW_KEY_KP_DECIMAL : return Keyboard.KEY_DECIMAL; + case GLFW.GLFW_KEY_KP_EQUAL : return Keyboard.KEY_NUMPADEQUALS; + case GLFW.GLFW_KEY_KP_ENTER : return Keyboard.KEY_NUMPADENTER; + case GLFW.GLFW_KEY_NUM_LOCK : return Keyboard.KEY_NUMLOCK; + + case GLFW.GLFW_KEY_SEMICOLON: return Keyboard.KEY_SEMICOLON; + case GLFW.GLFW_KEY_BACKSLASH: return Keyboard.KEY_BACKSLASH; + case GLFW.GLFW_KEY_COMMA : return Keyboard.KEY_COMMA; + case GLFW.GLFW_KEY_PERIOD : return Keyboard.KEY_PERIOD; + case GLFW.GLFW_KEY_SLASH : return Keyboard.KEY_SLASH; + case GLFW.GLFW_KEY_GRAVE_ACCENT : return Keyboard.KEY_GRAVE; + + case GLFW.GLFW_KEY_CAPS_LOCK: return Keyboard.KEY_CAPITAL; + case GLFW.GLFW_KEY_SCROLL_LOCK : return Keyboard.KEY_SCROLL; + + case GLFW.GLFW_KEY_WORLD_1 : return Keyboard.KEY_CIRCUMFLEX; // TODO not sure if correct + case GLFW.GLFW_KEY_PAUSE : return Keyboard.KEY_PAUSE; + + case GLFW.GLFW_KEY_MINUS : return Keyboard.KEY_MINUS; + case GLFW.GLFW_KEY_EQUAL : return Keyboard.KEY_EQUALS; + case GLFW.GLFW_KEY_LEFT_BRACKET : return Keyboard.KEY_LBRACKET; + case GLFW.GLFW_KEY_RIGHT_BRACKET: return Keyboard.KEY_RBRACKET; + case GLFW.GLFW_KEY_APOSTROPHE : return Keyboard.KEY_APOSTROPHE; +// 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_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_CIRCUMFLEX = 0x90; /* (Japanese keyboard) */ +// 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_SECTION = 0xA7; /* Section symbol (Mac) */ +// public static final int KEY_NUMPADCOMMA = 0xB3; /* , on numeric keypad (NEC PC98) */ +// public static final int KEY_SYSRQ = 0xB7; +// public static final int KEY_FUNCTION = 0xC4; /* Function (Mac) */ +// public static final int KEY_CLEAR = 0xDA; /* Clear key (Mac) */ + +// public static final int KEY_APPS = 0xDD; /* AppMenu key */ +// public static final int KEY_POWER = 0xDE; +// public static final int KEY_SLEEP = 0xDF; + + default: System.out.println("UNKNOWN GLFW KEY CODE: " + glfwKeyCode); + return Keyboard.KEY_NONE; + } + } + + public static int toGlfwKey(int lwjglKeyCode) { + + switch(lwjglKeyCode) { + + case Keyboard.KEY_ESCAPE : return GLFW.GLFW_KEY_ESCAPE; + case Keyboard.KEY_BACK : return GLFW.GLFW_KEY_BACKSPACE; + case Keyboard.KEY_TAB : return GLFW.GLFW_KEY_TAB; + case Keyboard.KEY_RETURN : return GLFW.GLFW_KEY_ENTER; + case Keyboard.KEY_SPACE : return GLFW.GLFW_KEY_SPACE; + + case Keyboard.KEY_LCONTROL : return GLFW.GLFW_KEY_LEFT_CONTROL; + case Keyboard.KEY_LSHIFT : return GLFW.GLFW_KEY_LEFT_SHIFT; + case Keyboard.KEY_LMENU : return GLFW.GLFW_KEY_LEFT_ALT; + case Keyboard.KEY_LMETA : return GLFW.GLFW_KEY_LEFT_SUPER; + + case Keyboard.KEY_RCONTROL : return GLFW.GLFW_KEY_RIGHT_CONTROL; + case Keyboard.KEY_RSHIFT : return GLFW.GLFW_KEY_RIGHT_SHIFT; + case Keyboard.KEY_RMENU : return GLFW.GLFW_KEY_RIGHT_ALT; + case Keyboard.KEY_RMETA : return GLFW.GLFW_KEY_RIGHT_SUPER; + + case Keyboard.KEY_1 : return GLFW.GLFW_KEY_1; + case Keyboard.KEY_2 : return GLFW.GLFW_KEY_2; + case Keyboard.KEY_3 : return GLFW.GLFW_KEY_3; + case Keyboard.KEY_4 : return GLFW.GLFW_KEY_4; + case Keyboard.KEY_5 : return GLFW.GLFW_KEY_5; + case Keyboard.KEY_6 : return GLFW.GLFW_KEY_6; + case Keyboard.KEY_7 : return GLFW.GLFW_KEY_7; + case Keyboard.KEY_8 : return GLFW.GLFW_KEY_8; + case Keyboard.KEY_9 : return GLFW.GLFW_KEY_9; + case Keyboard.KEY_0 : return GLFW.GLFW_KEY_0; + + case Keyboard.KEY_A : return GLFW.GLFW_KEY_A; + case Keyboard.KEY_B : return GLFW.GLFW_KEY_B; + case Keyboard.KEY_C : return GLFW.GLFW_KEY_C; + case Keyboard.KEY_D : return GLFW.GLFW_KEY_D; + case Keyboard.KEY_E : return GLFW.GLFW_KEY_E; + case Keyboard.KEY_F : return GLFW.GLFW_KEY_F; + case Keyboard.KEY_G : return GLFW.GLFW_KEY_G; + case Keyboard.KEY_H : return GLFW.GLFW_KEY_H; + case Keyboard.KEY_I : return GLFW.GLFW_KEY_I; + case Keyboard.KEY_J : return GLFW.GLFW_KEY_J; + case Keyboard.KEY_K : return GLFW.GLFW_KEY_K; + case Keyboard.KEY_L : return GLFW.GLFW_KEY_L; + case Keyboard.KEY_M : return GLFW.GLFW_KEY_M; + case Keyboard.KEY_N : return GLFW.GLFW_KEY_N; + case Keyboard.KEY_O : return GLFW.GLFW_KEY_O; + case Keyboard.KEY_P : return GLFW.GLFW_KEY_P; + case Keyboard.KEY_Q : return GLFW.GLFW_KEY_Q; + case Keyboard.KEY_R : return GLFW.GLFW_KEY_R; + case Keyboard.KEY_S : return GLFW.GLFW_KEY_S; + case Keyboard.KEY_T : return GLFW.GLFW_KEY_T; + case Keyboard.KEY_U : return GLFW.GLFW_KEY_U; + case Keyboard.KEY_V : return GLFW.GLFW_KEY_V; + case Keyboard.KEY_W : return GLFW.GLFW_KEY_W; + case Keyboard.KEY_X : return GLFW.GLFW_KEY_X; + case Keyboard.KEY_Y : return GLFW.GLFW_KEY_Y; + case Keyboard.KEY_Z : return GLFW.GLFW_KEY_Z; + + case Keyboard.KEY_UP : return GLFW.GLFW_KEY_UP; + case Keyboard.KEY_DOWN : return GLFW.GLFW_KEY_DOWN; + case Keyboard.KEY_LEFT : return GLFW.GLFW_KEY_LEFT; + case Keyboard.KEY_RIGHT : return GLFW.GLFW_KEY_RIGHT; + + case Keyboard.KEY_INSERT : return GLFW.GLFW_KEY_INSERT; + case Keyboard.KEY_DELETE : return GLFW.GLFW_KEY_DELETE; + case Keyboard.KEY_HOME : return GLFW.GLFW_KEY_HOME; + case Keyboard.KEY_END : return GLFW.GLFW_KEY_END; + case Keyboard.KEY_PRIOR : return GLFW.GLFW_KEY_PAGE_UP; + case Keyboard.KEY_NEXT : return GLFW.GLFW_KEY_PAGE_DOWN; + + case Keyboard.KEY_F1 : return GLFW.GLFW_KEY_F1; + case Keyboard.KEY_F2 : return GLFW.GLFW_KEY_F2; + case Keyboard.KEY_F3 : return GLFW.GLFW_KEY_F3; + case Keyboard.KEY_F4 : return GLFW.GLFW_KEY_F4; + case Keyboard.KEY_F5 : return GLFW.GLFW_KEY_F5; + case Keyboard.KEY_F6 : return GLFW.GLFW_KEY_F6; + case Keyboard.KEY_F7 : return GLFW.GLFW_KEY_F7; + case Keyboard.KEY_F8 : return GLFW.GLFW_KEY_F8; + case Keyboard.KEY_F9 : return GLFW.GLFW_KEY_F9; + case Keyboard.KEY_F10 : return GLFW.GLFW_KEY_F10; + case Keyboard.KEY_F11 : return GLFW.GLFW_KEY_F11; + case Keyboard.KEY_F12 : return GLFW.GLFW_KEY_F12; + case Keyboard.KEY_F13 : return GLFW.GLFW_KEY_F13; + case Keyboard.KEY_F14 : return GLFW.GLFW_KEY_F14; + case Keyboard.KEY_F15 : return GLFW.GLFW_KEY_F15; + case Keyboard.KEY_F16 : return GLFW.GLFW_KEY_F16; + case Keyboard.KEY_F17 : return GLFW.GLFW_KEY_F17; + case Keyboard.KEY_F18 : return GLFW.GLFW_KEY_F18; + case Keyboard.KEY_F19 : return GLFW.GLFW_KEY_F19; + + case Keyboard.KEY_NUMPAD1 : return GLFW.GLFW_KEY_KP_1; + case Keyboard.KEY_NUMPAD2 : return GLFW.GLFW_KEY_KP_2; + case Keyboard.KEY_NUMPAD3 : return GLFW.GLFW_KEY_KP_3; + case Keyboard.KEY_NUMPAD4 : return GLFW.GLFW_KEY_KP_4; + case Keyboard.KEY_NUMPAD5 : return GLFW.GLFW_KEY_KP_5; + case Keyboard.KEY_NUMPAD6 : return GLFW.GLFW_KEY_KP_6; + case Keyboard.KEY_NUMPAD7 : return GLFW.GLFW_KEY_KP_7; + case Keyboard.KEY_NUMPAD8 : return GLFW.GLFW_KEY_KP_8; + case Keyboard.KEY_NUMPAD9 : return GLFW.GLFW_KEY_KP_9; + case Keyboard.KEY_NUMPAD0 : return GLFW.GLFW_KEY_KP_0; + + case Keyboard.KEY_ADD : return GLFW.GLFW_KEY_KP_ADD; + case Keyboard.KEY_SUBTRACT : return GLFW.GLFW_KEY_KP_SUBTRACT; + case Keyboard.KEY_MULTIPLY : return GLFW.GLFW_KEY_KP_MULTIPLY; + case Keyboard.KEY_DIVIDE : return GLFW.GLFW_KEY_KP_DIVIDE; + case Keyboard.KEY_DECIMAL : return GLFW.GLFW_KEY_KP_DECIMAL; + case Keyboard.KEY_NUMPADEQUALS : return GLFW.GLFW_KEY_KP_EQUAL; + case Keyboard.KEY_NUMPADENTER : return GLFW.GLFW_KEY_KP_ENTER; + case Keyboard.KEY_NUMLOCK : return GLFW.GLFW_KEY_NUM_LOCK; + + case Keyboard.KEY_SEMICOLON : return GLFW.GLFW_KEY_SEMICOLON; + case Keyboard.KEY_BACKSLASH : return GLFW.GLFW_KEY_BACKSLASH; + case Keyboard.KEY_COMMA : return GLFW.GLFW_KEY_COMMA; + case Keyboard.KEY_PERIOD : return GLFW.GLFW_KEY_PERIOD; + case Keyboard.KEY_SLASH : return GLFW.GLFW_KEY_SLASH; + case Keyboard.KEY_GRAVE : return GLFW.GLFW_KEY_GRAVE_ACCENT; + + case Keyboard.KEY_CAPITAL : return GLFW.GLFW_KEY_CAPS_LOCK; + case Keyboard.KEY_SCROLL : return GLFW.GLFW_KEY_SCROLL_LOCK; + + case Keyboard.KEY_PAUSE : return GLFW.GLFW_KEY_PAUSE; + case Keyboard.KEY_CIRCUMFLEX: return GLFW.GLFW_KEY_WORLD_1; // TODO not sure if correct + + case Keyboard.KEY_MINUS : return GLFW.GLFW_KEY_MINUS; + case Keyboard.KEY_EQUALS : return GLFW.GLFW_KEY_EQUAL; + case Keyboard.KEY_LBRACKET : return GLFW.GLFW_KEY_LEFT_BRACKET; + case Keyboard.KEY_RBRACKET : return GLFW.GLFW_KEY_RIGHT_BRACKET; + case Keyboard.KEY_APOSTROPHE: return GLFW.GLFW_KEY_APOSTROPHE; +// 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_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_CIRCUMFLEX = 0x90; /* (Japanese keyboard) */ +// 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_SECTION = 0xA7; /* Section symbol (Mac) */ +// public static final int KEY_NUMPADCOMMA = 0xB3; /* , on numeric keypad (NEC PC98) */ +// public static final int KEY_SYSRQ = 0xB7; +// public static final int KEY_FUNCTION = 0xC4; /* Function (Mac) */ + +// public static final int KEY_CLEAR = 0xDA; /* Clear key (Mac) */ + +// public static final int KEY_APPS = 0xDD; /* AppMenu key */ +// public static final int KEY_POWER = 0xDE; +// public static final int KEY_SLEEP = 0xDF; + + default: System.out.println("UNKNOWN LWJGL KEY CODE: " + lwjglKeyCode); + return GLFW.GLFW_KEY_UNKNOWN; + } + } + +} diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/input/Keyboard.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/input/Keyboard.java new file mode 100644 index 000000000..5b2b57c09 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/input/Keyboard.java @@ -0,0 +1,309 @@ +package org.lwjgl.input; + +import java.lang.reflect.Field; +import java.lang.reflect.Modifier; +import java.util.HashMap; +import java.util.Map; + +import org.lwjgl.glfw.GLFW; +import org.lwjgl.LWJGLException; +import org.lwjgl.Sys; +import org.lwjgl.opengl.Display; + +public class Keyboard { + + /** + * 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_F16 = 0x67; /* Extended Function keys - (Mac) */ + public static final int KEY_F17 = 0x68; + public static final int KEY_F18 = 0x69; + public static final int KEY_KANA = 0x70; /* (Japanese keyboard) */ + public static final int KEY_F19 = 0x71; /* Extended Function keys - (Mac) */ + 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_SECTION = 0xA7; /* Section symbol (Mac) */ + 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_FUNCTION = 0xC4; /* Function (Mac) */ + 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_CLEAR = 0xDA; /* Clear key (Mac) */ + public static final int KEY_LMETA = 0xDB; /* Left Windows/Option key */ + public static final int KEY_LWIN = KEY_LMETA; /* Left Windows key */ + public static final int KEY_RMETA = 0xDC; /* Right Windows/Option key */ + 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; + + private static EventQueue queue = new EventQueue(32); + // private static int maxEvents = 32; + + // private static int eventCount = 0; + // private static int currentEventPos = -1; + // private static int nextEventPos = 0; + + private static int[] keyEvents = new int[queue.getMaxEvents()]; + private static boolean[] keyEventStates = new boolean[queue.getMaxEvents()]; + private static long[] nanoTimeEvents = new long[queue.getMaxEvents()]; + private static char[] keyEventChars = new char[256]; + + private static boolean repeatEvents = false; + private static int latestEventKey = 0; + + public static final int KEYBOARD_SIZE = 256; + + private static final String[] keyName = new String[KEYBOARD_SIZE]; + private static final Map keyMap = new HashMap(253); + + static { + // Use reflection to find out key names + Field[] fields = Keyboard.class.getFields(); + try { + for (Field field : fields) { + if (Modifier.isStatic(field.getModifiers()) && Modifier.isPublic(field.getModifiers()) + && Modifier.isFinal(field.getModifiers()) && field.getType().equals(int.class) + && field.getName().startsWith("KEY_") && !field.getName().endsWith( + "WIN")) { /* Don't use deprecated names */ + + int key = field.getInt(null); + String name = field.getName().substring(4); + keyName[key] = name; + keyMap.put(name, key); + } + + } + } catch (Exception e) { + } + + } + + public static void addKeyEvent(int key, int status) { + // eventCount++; + // if (eventCount > maxEvents) eventCount = maxEvents; + + switch (status) { + case GLFW.GLFW_REPEAT: + if (!repeatEvents) + break; + case GLFW.GLFW_RELEASE: + case GLFW.GLFW_PRESS: + keyEvents[queue.getNextPos()] = KeyCodes.toLwjglKey(key); + keyEventStates[queue.getNextPos()] = status == GLFW.GLFW_PRESS || status == GLFW.GLFW_REPEAT; + + nanoTimeEvents[queue.getNextPos()] = Sys.getNanoTime(); + + queue.add(); + } + /* + * nextEventPos++; if (nextEventPos == maxEvents) nextEventPos = 0; + * + * if (currentEventPos == nextEventPos) currentEventPos++; if + * (currentEventPos == maxEvents) currentEventPos = 0; + */ + } + + public static void addCharEvent(int key, char c) { + int index = KeyCodes.toLwjglKey(key); + keyEventChars[index] = c; + } + + public static boolean areRepeatEventsEnabled() { + return false; + } + + public static void create() throws LWJGLException { + + } + + public static boolean isKeyDown(int key) { + int k = GLFW.glfwGetKey(Display.getWindow(), KeyCodes.toGlfwKey(key)); + + return k == GLFW.GLFW_PRESS || k == GLFW.GLFW_REPEAT; + } + + public static void poll() { + // TODO + } + + public static void enableRepeatEvents(boolean enable) { + // TODO + // System.out.println("TODO: Implement + // Keyboad.enableRepeatEvents(boolean)"); + repeatEvents = enable; + } + + public static boolean isRepeatEvent() { + // TODO + return repeatEvents; + } + + public static boolean next() { + return queue.next(); + /* + * if (eventCount == 0) return false; + * + * eventCount--; currentEventPos++; if (currentEventPos == maxEvents) + * currentEventPos = 0; + * + * return true; + */ + } + + public static int getEventKey() { + return keyEvents[queue.getCurrentPos()]; + } + + public static char getEventCharacter() { + return keyEventChars[getEventKey()]; + } + + public static boolean getEventKeyState() { + return keyEventStates[queue.getCurrentPos()]; + } + + public static long getEventNanoseconds() { + return nanoTimeEvents[queue.getCurrentPos()]; + } + + public static String getKeyName(int key) { + return keyName[key]; + } + + public static int getKeyIndex(java.lang.String keyName) { + Integer ret = keyMap.get(keyName); + if (ret == null) + return KEY_NONE; + else + return ret; + } + + public static boolean isCreated() { + return Display.isCreated(); + } + + public static void destroy() { + + } +} diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/input/Mouse.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/input/Mouse.java new file mode 100644 index 000000000..452fdaf92 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/input/Mouse.java @@ -0,0 +1,241 @@ +package org.lwjgl.input; + +import org.lwjgl.glfw.GLFW; +import org.lwjgl.system.MemoryUtil; +import org.lwjgl.LWJGLException; +import org.lwjgl.Sys; +import org.lwjgl.opengl.Display; + +public class Mouse { + + private static boolean grabbed = false; + + private static int lastX = 0; + private static int lastY = 0; + + private static int latestX = 0; + private static int latestY = 0; + + private static int x = 0; + private static int y = 0; + + private static int lastDWheel = 0; + + private static EventQueue queue = new EventQueue(32); + + private static int[] buttonEvents = new int[queue.getMaxEvents()]; + private static int[] wheelEvents = new int[queue.getMaxEvents()]; + private static boolean[] buttonEventStates = new boolean[queue.getMaxEvents()]; + private static int[] xEvents = new int[queue.getMaxEvents()]; + private static int[] yEvents = new int[queue.getMaxEvents()]; + private static int[] lastxEvents = new int[queue.getMaxEvents()]; + private static int[] lastyEvents = new int[queue.getMaxEvents()]; + private static long[] nanoTimeEvents = new long[queue.getMaxEvents()]; + + private static boolean clipPostionToDisplay = true; + + private static boolean isMouseInsideWindow = true; + + private static Cursor currentCursor = null; + + public static void addMoveEvent(double mouseX, double mouseY) { + latestX = (int) mouseX; + latestY = Display.getHeight() - (int) mouseY; + + lastxEvents[queue.getNextPos()] = xEvents[queue.getNextPos()]; + lastyEvents[queue.getNextPos()] = yEvents[queue.getNextPos()]; + + xEvents[queue.getNextPos()] = latestX; + yEvents[queue.getNextPos()] = latestY; + + buttonEvents[queue.getNextPos()] = -1; + buttonEventStates[queue.getNextPos()] = false; + + wheelEvents[queue.getNextPos()] = 0; + + nanoTimeEvents[queue.getNextPos()] = Sys.getNanoTime(); + + queue.add(); + } + + public static void addButtonEvent(int button, boolean pressed) { + lastxEvents[queue.getNextPos()] = xEvents[queue.getNextPos()]; + lastyEvents[queue.getNextPos()] = yEvents[queue.getNextPos()]; + + xEvents[queue.getNextPos()] = latestX; + yEvents[queue.getNextPos()] = latestY; + + buttonEvents[queue.getNextPos()] = button; + buttonEventStates[queue.getNextPos()] = pressed; + + wheelEvents[queue.getNextPos()] = 0; + + nanoTimeEvents[queue.getNextPos()] = Sys.getNanoTime(); + + queue.add(); + } + + public static void addWheelEvent(int wheel) { + lastxEvents[queue.getNextPos()] = xEvents[queue.getNextPos()]; + lastyEvents[queue.getNextPos()] = yEvents[queue.getNextPos()]; + + xEvents[queue.getNextPos()] = latestX; + yEvents[queue.getNextPos()] = latestY; + + buttonEvents[queue.getNextPos()] = -1; + buttonEventStates[queue.getNextPos()] = false; + + wheelEvents[queue.getNextPos()] = wheel; + lastDWheel = wheel; + + nanoTimeEvents[queue.getNextPos()] = Sys.getNanoTime(); + + queue.add(); + } + + public static void setMouseInsideWindow(boolean mouseInsideWindow) { + isMouseInsideWindow = mouseInsideWindow; + } + + public static void poll() { + lastX = x; + lastY = y; + + if (!grabbed && clipPostionToDisplay) { + if (latestX < 0) + latestX = 0; + if (latestY < 0) + latestY = 0; + if (latestX > Display.getWidth() - 1) + latestX = Display.getWidth() - 1; + if (latestY > Display.getHeight() - 1) + latestY = Display.getHeight() - 1; + } + + x = latestX; + y = latestY; + } + + public static void create() throws LWJGLException { + + } + + public static boolean isCreated() { + return Display.isCreated(); + } + + public static void setGrabbed(boolean grab) { + GLFW.glfwSetInputMode(Display.getWindow(), GLFW.GLFW_CURSOR, + grab ? GLFW.GLFW_CURSOR_DISABLED : GLFW.GLFW_CURSOR_NORMAL); + grabbed = grab; + } + + public static boolean isGrabbed() { + return grabbed; + } + + public static boolean isButtonDown(int button) { + return GLFW.glfwGetMouseButton(Display.getWindow(), button) == GLFW.GLFW_PRESS; + } + + public static boolean next() { + return queue.next(); + } + + public static int getEventX() { + return xEvents[queue.getCurrentPos()]; + } + + public static int getEventY() { + return yEvents[queue.getCurrentPos()]; + } + + public static int getEventDX() { + return xEvents[queue.getCurrentPos()] - lastxEvents[queue.getCurrentPos()]; + } + + public static int getEventDY() { + return yEvents[queue.getCurrentPos()] - lastyEvents[queue.getCurrentPos()]; + } + + public static long getEventNanoseconds() { + return nanoTimeEvents[queue.getCurrentPos()]; + } + + public static int getEventButton() { + return buttonEvents[queue.getCurrentPos()]; + } + + public static boolean getEventButtonState() { + return buttonEventStates[queue.getCurrentPos()]; + } + + public static int getEventDWheel() { + return wheelEvents[queue.getCurrentPos()]; + } + + public static int getX() { + return x; + } + + public static int getY() { + return y; + } + + public static int getDX() { + return x - lastX; + } + + public static int getDY() { + return y - lastY; + } + + public static int getDWheel() { + int dwheel = lastDWheel; + lastDWheel = 0; + return dwheel; + } + + public static int getButtonCount() { + return 8; // max mouse buttons supported by GLFW + } + + public static boolean isInsideWindow() { + return isMouseInsideWindow; + } + + public static void setClipMouseCoordinatesToWindow(boolean clip) { + clipPostionToDisplay = clip; + } + + public static void setCursorPosition(int new_x, int new_y) { + GLFW.glfwSetCursorPos(Display.getWindow(), new_x, new_y); + } + + public static Cursor setNativeCursor(Cursor cursor) throws LWJGLException { + if (cursor == null) { + GLFW.glfwSetCursor(Display.getWindow(), MemoryUtil.NULL); + return null; + } + + GLFW.glfwSetCursor(Display.getWindow(), cursor.getHandle()); + currentCursor = cursor; + return cursor; + } + + public static Cursor getCurrentCursor() { + return currentCursor; + } + + public static Cursor getNativeCursor() { + return currentCursor; + } + + public static boolean hasWheel() { + return true; + } + + public static void destroy() { + + } +} diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/openal/AL.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/openal/AL.java new file mode 100644 index 000000000..9b75b4b3c --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/openal/AL.java @@ -0,0 +1,330 @@ +/* + * Copyright LWJGL. All rights reserved. + * License terms: https://www.lwjgl.org/license + */ +package org.lwjgl.openal; + +import org.lwjgl.*; +import org.lwjgl.system.*; + +import javax.annotation.*; +import java.nio.*; +import java.util.*; + +import static org.lwjgl.openal.AL10.*; +import static org.lwjgl.openal.EXTThreadLocalContext.*; +import static org.lwjgl.system.APIUtil.*; +import static org.lwjgl.system.JNI.*; +import static org.lwjgl.system.MemoryStack.*; +import static org.lwjgl.system.MemoryUtil.*; + +/** + * This class must be used before any OpenAL function is called. It has the following responsibilities: + *
    + *
  • Creates instances of {@link ALCapabilities} classes. An {@code ALCapabilities} instance contains flags for functionality that is available in an OpenAL + * context. Internally, it also contains function pointers that are only valid in that specific OpenAL context.
  • + *
  • Maintains thread-local and global state for {@code ALCapabilities} instances, corresponding to OpenAL contexts that are current in those threads and the + * entire process, respectively.
  • + *
+ * + *

ALCapabilities creation

+ *

Instances of {@code ALCapabilities} can be created with the {@link #createCapabilities} method. An OpenAL context must be current in the current thread + * or process before it is called. Calling this method is expensive, so {@code ALCapabilities} instances should be cached in user code.

+ * + *

Thread-local state

+ *

Before a function for a given OpenAL context can be called, the corresponding {@code ALCapabilities} instance must be made current in the current + * thread or process. The user is also responsible for clearing the current {@code ALCapabilities} instance when the context is destroyed or made current in + * another thread.

+ * + *

Note that OpenAL contexts are made current process-wide by default. Current thread-local contexts are only available if the + * {@link EXTThreadLocalContext ALC_EXT_thread_local_context} extension is supported by the OpenAL implementation. OpenAL Soft, the implementation + * that LWJGL ships with, supports this extension and performs better when it is used.

+ * + * @see ALC + */ +public final class AL { +// -- Begin LWJGL2 part -- + static { + // FIXME should be? + // Sys.initialize(); // init using dummy sys method + } + static long alContext; + static ALCdevice alcDevice; + static ALCCapabilities alContextCaps; + static ALCapabilities alCaps; + + private static boolean created_lwjgl2 = false; + + public static void create() throws LWJGLException { + if (alContext == MemoryUtil.NULL) { + //ALDevice alDevice = ALDevice.create(); + long alDevice = ALC10.alcOpenDevice((ByteBuffer)null); + if(alDevice == MemoryUtil.NULL){ + throw new LWJGLException("Cannot open the device"); + } + + IntBuffer attribs = BufferUtils.createIntBuffer(16); + + attribs.put(ALC10.ALC_FREQUENCY); + attribs.put(44100); + + attribs.put(ALC10.ALC_REFRESH); + attribs.put(60); + + attribs.put(ALC10.ALC_SYNC); + attribs.put(ALC10.ALC_FALSE); + + attribs.put(0); + attribs.flip(); + + long contextHandle = ALC10.alcCreateContext(alDevice, attribs); + ALC10.alcMakeContextCurrent(contextHandle); + //alContext = new ALContext(alDevice, contextHandle); + alContext = ALC10.alcCreateContext(contextHandle, (IntBuffer)null); + alContextCaps = ALC.createCapabilities(alContext); + + alCaps = AL.createCapabilities(alContextCaps); + + alcDevice = new ALCdevice(alDevice); + created_lwjgl2 = true; + } + } + + public static boolean isCreated() { + return created_lwjgl2; + } + + public static ALCdevice getDevice() { + return alcDevice; + } +// -- End LWJGL2 part + + @Nullable + private static FunctionProvider functionProvider; + + @Nullable + private static ALCapabilities processCaps; + + private static final ThreadLocal capabilitiesTLS = new ThreadLocal<>(); + + private static ICD icd = new ICDStatic(); + + private AL() {} + + static void init() { + functionProvider = new FunctionProvider() { + // We'll use alGetProcAddress for both core and extension entry points. + // To do that, we need to first grab the alGetProcAddress function from + // the OpenAL native library. + private final long alGetProcAddress = ALC.getFunctionProvider().getFunctionAddress("alGetProcAddress"); + + @Override + public long getFunctionAddress(ByteBuffer functionName) { + long address = invokePP(memAddress(functionName), alGetProcAddress); + if (address == NULL && Checks.DEBUG_FUNCTIONS) { + apiLog("Failed to locate address for AL function " + memASCII(functionName)); + } + return address; + } + }; + } + + public static void destroy() { + if (functionProvider == null) { + return; + } + + // LWJGL2 code + if (created_lwjgl2) { + ALC10.alcMakeContextCurrent(MemoryUtil.NULL); + ALC10.alcDestroyContext(alContext); + ALC10.alcCloseDevice(alcDevice.device); + alContext = -1; + alcDevice = null; + created_lwjgl2 = false; + } + + setCurrentProcess(null); + + functionProvider = null; + } + + /** + * Sets the specified {@link ALCapabilities} for the current process-wide OpenAL context. + * + *

If the current thread had a context current (see {@link #setCurrentThread}), those {@code ALCapabilities} are cleared. Any OpenAL functions called in + * the current thread, or any threads that have no context current, will use the specified {@code ALCapabilities}.

+ * + * @param caps the {@link ALCapabilities} to make current, or null + */ + public static void setCurrentProcess(@Nullable ALCapabilities caps) { + processCaps = caps; + capabilitiesTLS.set(null); // See EXT_thread_local_context, second Q. + icd.set(caps); + } + + /** + * Sets the specified {@link ALCapabilities} for the current OpenAL context in the current thread. + * + *

Any OpenAL functions called in the current thread will use the specified {@code ALCapabilities}.

+ * + * @param caps the {@link ALCapabilities} to make current, or null + */ + public static void setCurrentThread(@Nullable ALCapabilities caps) { + capabilitiesTLS.set(caps); + icd.set(caps); + } + + /** + * Returns the {@link ALCapabilities} for the OpenAL context that is current in the current thread or process. + * + * @throws IllegalStateException if no OpenAL context is current in the current thread or process + */ + public static ALCapabilities getCapabilities() { + ALCapabilities caps = capabilitiesTLS.get(); + if (caps == null) { + caps = processCaps; + } + + return checkCapabilities(caps); + } + + private static ALCapabilities checkCapabilities(@Nullable ALCapabilities caps) { + if (caps == null) { + throw new IllegalStateException( + "No ALCapabilities instance set for the current thread or process. Possible solutions:\n" + + "\ta) Call AL.createCapabilities() after making a context current.\n" + + "\tb) Call AL.setCurrentProcess() or AL.setCurrentThread() if an ALCapabilities instance already exists." + ); + } + return caps; + } + + /** + * Creates a new {@link ALCapabilities} instance for the OpenAL context that is current in the current thread or process. + * + * @param alcCaps the {@link ALCCapabilities} of the device associated with the current context + * + * @return the ALCapabilities instance + */ + public static ALCapabilities createCapabilities(ALCCapabilities alcCaps) { + FunctionProvider functionProvider = ALC.check(AL.functionProvider); + + ALCapabilities caps = null; + + try { + long GetString = functionProvider.getFunctionAddress("alGetString"); + long GetError = functionProvider.getFunctionAddress("alGetError"); + long IsExtensionPresent = functionProvider.getFunctionAddress("alIsExtensionPresent"); + if (GetString == NULL || GetError == NULL || IsExtensionPresent == NULL) { + throw new IllegalStateException("Core OpenAL functions could not be found. Make sure that the OpenAL library has been loaded correctly."); + } + + String versionString = memASCIISafe(invokeP(AL_VERSION, GetString)); + if (versionString == null || invokeI(GetError) != AL_NO_ERROR) { + throw new IllegalStateException("There is no OpenAL context current in the current thread or process."); + } + + APIVersion apiVersion = apiParseVersion(versionString); + + int majorVersion = apiVersion.major; + int minorVersion = apiVersion.minor; + + int[][] AL_VERSIONS = { + {0, 1} // OpenAL 1 + }; + + Set supportedExtensions = new HashSet<>(32); + + for (int major = 1; major <= AL_VERSIONS.length; major++) { + int[] minors = AL_VERSIONS[major - 1]; + for (int minor : minors) { + if (major < majorVersion || (major == majorVersion && minor <= minorVersion)) { + supportedExtensions.add("OpenAL" + major + minor); + } + } + } + + // Parse EXTENSIONS string + String extensionsString = memASCIISafe(invokeP(AL_EXTENSIONS, GetString)); + if (extensionsString != null) { + MemoryStack stack = stackGet(); + + StringTokenizer tokenizer = new StringTokenizer(extensionsString); + while (tokenizer.hasMoreTokens()) { + String extName = tokenizer.nextToken(); + try (MemoryStack frame = stack.push()) { + if (invokePZ(memAddress(frame.ASCII(extName, true)), IsExtensionPresent)) { + supportedExtensions.add(extName); + } + } + } + } + + if (alcCaps.ALC_EXT_EFX) { + supportedExtensions.add("ALC_EXT_EFX"); + } + + return caps = new ALCapabilities(functionProvider, supportedExtensions); + } finally { + if (alcCaps.ALC_EXT_thread_local_context && alcGetThreadContext() != NULL) { + setCurrentThread(caps); + } else { + setCurrentProcess(caps); + } + } + } + + static ALCapabilities getICD() { + return ALC.check(icd.get()); + } + + /** Function pointer provider. */ + private interface ICD { + default void set(@Nullable ALCapabilities caps) {} + @Nullable ALCapabilities get(); + } + + /** + * Write-once {@link ICD}. + * + *

This is the default implementation that skips the thread/process lookup. When a new ALCapabilities is set, we compare it to the write-once + * capabilities. If different function pointers are found, we fall back to the expensive lookup. This will never happen with the OpenAL-Soft + * implementation.

+ */ + private static class ICDStatic implements ICD { + + @Nullable + private static ALCapabilities tempCaps; + + @Override + public void set(@Nullable ALCapabilities caps) { + if (tempCaps == null) { + tempCaps = caps; + } else if (caps != null && caps != tempCaps && ThreadLocalUtil.areCapabilitiesDifferent(tempCaps.addresses, caps.addresses)) { + apiLog("[WARNING] Incompatible context detected. Falling back to thread/process lookup for AL contexts."); + icd = AL::getCapabilities; // fall back to thread/process lookup + } + } + + @Override + @Nullable + public ALCapabilities get() { + return WriteOnce.caps; + } + + private static final class WriteOnce { + // This will be initialized the first time get() above is called + @Nullable + static final ALCapabilities caps = ICDStatic.tempCaps; + + static { + if (caps == null) { + throw new IllegalStateException("No ALCapabilities instance has been set"); + } + } + } + + } + +} diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/openal/AL10.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/openal/AL10.java new file mode 100644 index 000000000..9c5d15a33 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/openal/AL10.java @@ -0,0 +1,1931 @@ +/* + * Copyright LWJGL. All rights reserved. + * License terms: https://www.lwjgl.org/license + * MACHINE GENERATED FILE, DO NOT EDIT + */ +package org.lwjgl.openal; + +import javax.annotation.*; + +import java.nio.*; + +import org.lwjgl.system.*; + +import static org.lwjgl.system.Checks.*; +import static org.lwjgl.system.JNI.*; +import static org.lwjgl.system.MemoryStack.*; +import static org.lwjgl.system.MemoryUtil.*; + +/** Native bindings to AL 1.0 functionality. */ +public class AL10 { +// -- Begin LWJGL2 Bridge -- + public static void alGetDouble(int p1, DoubleBuffer p2) { + alGetDoublev(p1, p2); + } +/* + public static int alGetEnumValue(String p1) { + alGetEnumValue((CharSequence) p1); + } +*/ + public static void alGetFloat(int p1, FloatBuffer p2) { + alGetFloatv(p1, p2); + } + + public static void alGetInteger(int p1, IntBuffer p2) { + alGetIntegerv(p1, p2); + } + + public static void alGetListener(int p1, FloatBuffer p2) { + alGetListenerfv(p1, p2); + } + + public static void alGetSource(int p1, int p2, FloatBuffer p3) { + alGetSourcefv(p1, p2, p3); + } +/* + public static boolean alIsExtensionPresent(String p1) { + return alIsExtensionPresent((CharSequence) p1); + } +*/ + public static void alListener(int pname, FloatBuffer value) { + alListenerfv(pname, value); + } + + public static void alSource(int p1, int p2, FloatBuffer p3) { + alSourcefv(p1, p2, p3); + } + + public static void alSourcePause(IntBuffer p1) { + alSourcePausev(p1); + } + + public static void alSourcePlay(IntBuffer p1) { + alSourcePlayv(p1); + } + + public static void alSourceRewind(IntBuffer p1) { + alSourceRewindv(p1); + } + + public static void alSourceStop(IntBuffer p1) { + alSourceStopv(p1); + } +// -- End LWJGL2 Bridge -- + + /** General tokens. */ + public static final int + AL_INVALID = 0xFFFFFFFF, + AL_NONE = 0x0, + AL_FALSE = 0x0, + AL_TRUE = 0x1; + + /** Error conditions. */ + public static final int + AL_NO_ERROR = 0x0, + AL_INVALID_NAME = 0xA001, + AL_INVALID_ENUM = 0xA002, + AL_INVALID_VALUE = 0xA003, + AL_INVALID_OPERATION = 0xA004, + AL_OUT_OF_MEMORY = 0xA005; + + /** Numerical queries. */ + public static final int + AL_DOPPLER_FACTOR = 0xC000, + AL_DISTANCE_MODEL = 0xD000; + + /** String queries. */ + public static final int + AL_VENDOR = 0xB001, + AL_VERSION = 0xB002, + AL_RENDERER = 0xB003, + AL_EXTENSIONS = 0xB004; + + /** Distance attenuation models. */ + public static final int + AL_INVERSE_DISTANCE = 0xD001, + AL_INVERSE_DISTANCE_CLAMPED = 0xD002; + + /** Source types. */ + public static final int + AL_SOURCE_ABSOLUTE = 0x201, + AL_SOURCE_RELATIVE = 0x202; + + /** Listener and Source attributes. */ + public static final int + AL_POSITION = 0x1004, + AL_VELOCITY = 0x1006, + AL_GAIN = 0x100A; + + /** Source attributes. */ + public static final int + AL_CONE_INNER_ANGLE = 0x1001, + AL_CONE_OUTER_ANGLE = 0x1002, + AL_PITCH = 0x1003, + AL_DIRECTION = 0x1005, + AL_LOOPING = 0x1007, + AL_BUFFER = 0x1009, + AL_SOURCE_STATE = 0x1010, + AL_CONE_OUTER_GAIN = 0x1022, + AL_SOURCE_TYPE = 0x1027; + + /** Source state. */ + public static final int + AL_INITIAL = 0x1011, + AL_PLAYING = 0x1012, + AL_PAUSED = 0x1013, + AL_STOPPED = 0x1014; + + /** Listener attributes. */ + public static final int AL_ORIENTATION = 0x100F; + + /** Queue state. */ + public static final int + AL_BUFFERS_QUEUED = 0x1015, + AL_BUFFERS_PROCESSED = 0x1016; + + /** Gain bounds. */ + public static final int + AL_MIN_GAIN = 0x100D, + AL_MAX_GAIN = 0x100E; + + /** Distance model attributes, */ + public static final int + AL_REFERENCE_DISTANCE = 0x1020, + AL_ROLLOFF_FACTOR = 0x1021, + AL_MAX_DISTANCE = 0x1023; + + /** Buffer attributes, */ + public static final int + AL_FREQUENCY = 0x2001, + AL_BITS = 0x2002, + AL_CHANNELS = 0x2003, + AL_SIZE = 0x2004; + + /** Buffer formats. */ + public static final int + AL_FORMAT_MONO8 = 0x1100, + AL_FORMAT_MONO16 = 0x1101, + AL_FORMAT_STEREO8 = 0x1102, + AL_FORMAT_STEREO16 = 0x1103; + + /** Buffer state. */ + public static final int + AL_UNUSED = 0x2010, + AL_PENDING = 0x2011, + AL_PROCESSED = 0x2012; + + protected AL10() { + throw new UnsupportedOperationException(); + } + + static boolean isAvailable(ALCapabilities caps) { + return checkFunctions( + caps.alGetError, caps.alEnable, caps.alDisable, caps.alIsEnabled, caps.alGetBoolean, caps.alGetInteger, caps.alGetFloat, caps.alGetDouble, + caps.alGetBooleanv, caps.alGetIntegerv, caps.alGetFloatv, caps.alGetDoublev, caps.alGetString, caps.alDistanceModel, caps.alDopplerFactor, + caps.alDopplerVelocity, caps.alListenerf, caps.alListeneri, caps.alListener3f, caps.alListenerfv, caps.alGetListenerf, caps.alGetListeneri, + caps.alGetListener3f, caps.alGetListenerfv, caps.alGenSources, caps.alDeleteSources, caps.alIsSource, caps.alSourcef, caps.alSource3f, + caps.alSourcefv, caps.alSourcei, caps.alGetSourcef, caps.alGetSource3f, caps.alGetSourcefv, caps.alGetSourcei, caps.alGetSourceiv, + caps.alSourceQueueBuffers, caps.alSourceUnqueueBuffers, caps.alSourcePlay, caps.alSourcePause, caps.alSourceStop, caps.alSourceRewind, + caps.alSourcePlayv, caps.alSourcePausev, caps.alSourceStopv, caps.alSourceRewindv, caps.alGenBuffers, caps.alDeleteBuffers, caps.alIsBuffer, + caps.alGetBufferf, caps.alGetBufferi, caps.alBufferData, caps.alGetEnumValue, caps.alGetProcAddress, caps.alIsExtensionPresent + ); + } + + // --- [ alGetError ] --- + + /** + * Obtains error information. + * + *

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 alGetError 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 alGetError returns AL_NO_ERROR then there has been no detectable error since the last call to alGetError (or since the AL + * was initialized).

+ * + *

Error codes can be mapped to strings. The alGetString 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.

+ */ + @NativeType("ALenum") + public static int alGetError() { + long __functionAddress = AL.getICD().alGetError; + return invokeI(__functionAddress); + } + + // --- [ alEnable ] --- + + /** + * Enables AL capabilities. + * + * @param target the capability to enable + */ + @NativeType("ALvoid") + public static void alEnable(@NativeType("ALenum") int target) { + long __functionAddress = AL.getICD().alEnable; + invokeV(target, __functionAddress); + } + + // --- [ alDisable ] --- + + /** + * Disables AL capabilities. + * + * @param target the capability to disable + */ + @NativeType("ALvoid") + public static void alDisable(@NativeType("ALenum") int target) { + long __functionAddress = AL.getICD().alDisable; + invokeV(target, __functionAddress); + } + + // --- [ alIsEnabled ] --- + + /** + * Queries whether a given capability is currently enabled or not. + * + * @param target the capability to query + */ + @NativeType("ALboolean") + public static boolean alIsEnabled(@NativeType("ALenum") int target) { + long __functionAddress = AL.getICD().alIsEnabled; + return invokeZ(target, __functionAddress); + } + + // --- [ alGetBoolean ] --- + + /** + * Returns the boolean value of the specified parameter. + * + * @param paramName the parameter to query + */ + @NativeType("ALboolean") + public static boolean alGetBoolean(@NativeType("ALenum") int paramName) { + long __functionAddress = AL.getICD().alGetBoolean; + return invokeZ(paramName, __functionAddress); + } + + // --- [ alGetInteger ] --- + + /** + * Returns the integer value of the specified parameter. + * + * @param paramName the parameter to query. One of:
{@link #AL_DOPPLER_FACTOR DOPPLER_FACTOR}{@link #AL_DISTANCE_MODEL DISTANCE_MODEL}{@link AL11#AL_SPEED_OF_SOUND SPEED_OF_SOUND}
+ */ + @NativeType("ALint") + public static int alGetInteger(@NativeType("ALenum") int paramName) { + long __functionAddress = AL.getICD().alGetInteger; + return invokeI(paramName, __functionAddress); + } + + // --- [ alGetFloat ] --- + + /** + * Returns the float value of the specified parameter. + * + * @param paramName the parameter to query. One of:
{@link #AL_DOPPLER_FACTOR DOPPLER_FACTOR}{@link #AL_DISTANCE_MODEL DISTANCE_MODEL}{@link AL11#AL_SPEED_OF_SOUND SPEED_OF_SOUND}
+ */ + @NativeType("ALfloat") + public static float alGetFloat(@NativeType("ALenum") int paramName) { + long __functionAddress = AL.getICD().alGetFloat; + return invokeF(paramName, __functionAddress); + } + + // --- [ alGetDouble ] --- + + /** + * Returns the double value of the specified parameter. + * + * @param paramName the parameter to query. One of:
{@link #AL_DOPPLER_FACTOR DOPPLER_FACTOR}{@link #AL_DISTANCE_MODEL DISTANCE_MODEL}{@link AL11#AL_SPEED_OF_SOUND SPEED_OF_SOUND}
+ */ + @NativeType("ALdouble") + public static double alGetDouble(@NativeType("ALenum") int paramName) { + long __functionAddress = AL.getICD().alGetDouble; + return invokeD(paramName, __functionAddress); + } + + // --- [ alGetBooleanv ] --- + + /** Unsafe version of: {@link #alGetBooleanv GetBooleanv} */ + public static void nalGetBooleanv(int paramName, long dest) { + long __functionAddress = AL.getICD().alGetBooleanv; + invokePV(paramName, dest, __functionAddress); + } + + /** + * Pointer version of {@link #alGetBoolean GetBoolean}. + * + * @param paramName the parameter to query + * @param dest a buffer that will receive the parameter values + */ + @NativeType("ALvoid") + public static void alGetBooleanv(@NativeType("ALenum") int paramName, @NativeType("ALboolean *") ByteBuffer dest) { + if (CHECKS) { + check(dest, 1); + } + nalGetBooleanv(paramName, memAddress(dest)); + } + + // --- [ alGetIntegerv ] --- + + /** Unsafe version of: {@link #alGetIntegerv GetIntegerv} */ + public static void nalGetIntegerv(int paramName, long dest) { + long __functionAddress = AL.getICD().alGetIntegerv; + invokePV(paramName, dest, __functionAddress); + } + + /** + * Pointer version of {@link #alGetInteger GetInteger}. + * + * @param paramName the parameter to query + * @param dest a buffer that will receive the parameter values + */ + @NativeType("ALvoid") + public static void alGetIntegerv(@NativeType("ALenum") int paramName, @NativeType("ALint *") IntBuffer dest) { + if (CHECKS) { + check(dest, 1); + } + nalGetIntegerv(paramName, memAddress(dest)); + } + + // --- [ alGetFloatv ] --- + + /** Unsafe version of: {@link #alGetFloatv GetFloatv} */ + public static void nalGetFloatv(int paramName, long dest) { + long __functionAddress = AL.getICD().alGetFloatv; + invokePV(paramName, dest, __functionAddress); + } + + /** + * Pointer version of {@link #alGetFloat GetFloat}. + * + * @param paramName the parameter to query + * @param dest a buffer that will receive the parameter values + */ + @NativeType("ALvoid") + public static void alGetFloatv(@NativeType("ALenum") int paramName, @NativeType("ALfloat *") FloatBuffer dest) { + if (CHECKS) { + check(dest, 1); + } + nalGetFloatv(paramName, memAddress(dest)); + } + + // --- [ alGetDoublev ] --- + + /** Unsafe version of: {@link #alGetDoublev GetDoublev} */ + public static void nalGetDoublev(int paramName, long dest) { + long __functionAddress = AL.getICD().alGetDoublev; + invokePV(paramName, dest, __functionAddress); + } + + /** + * Pointer version of {@link #alGetDouble GetDouble}. + * + * @param paramName the parameter to query + * @param dest a buffer that will receive the parameter values + */ + @NativeType("ALvoid") + public static void alGetDoublev(@NativeType("ALenum") int paramName, @NativeType("ALdouble *") DoubleBuffer dest) { + if (CHECKS) { + check(dest, 1); + } + nalGetDoublev(paramName, memAddress(dest)); + } + + // --- [ alGetString ] --- + + /** Unsafe version of: {@link #alGetString GetString} */ + public static long nalGetString(int paramName) { + long __functionAddress = AL.getICD().alGetString; + return invokeP(paramName, __functionAddress); + } + + /** + * Returns the string value of the specified parameter + * + * @param paramName the parameter to query. One of:
{@link #AL_VENDOR VENDOR}{@link #AL_VERSION VERSION}{@link #AL_RENDERER RENDERER}{@link #AL_EXTENSIONS EXTENSIONS}
+ */ + @Nullable + @NativeType("ALchar const *") + public static String alGetString(@NativeType("ALenum") int paramName) { + long __result = nalGetString(paramName); + return memUTF8Safe(__result); + } + + // --- [ alDistanceModel ] --- + + /** + * Sets the distance attenuation model. + * + *

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

+ * + *

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

+ * + *

OpenAL currently supports three modes of operation with respect to distance attenuation, including one that is similar to the IASIG I3DL2 model. The + * application can choose one of these models (or chooses to disable distance-dependent attenuation) on a per-context basis.

+ * + * @param modelName the distance attenuation model to set. One of:
{@link #AL_INVERSE_DISTANCE INVERSE_DISTANCE}{@link #AL_INVERSE_DISTANCE_CLAMPED INVERSE_DISTANCE_CLAMPED}{@link AL11#AL_LINEAR_DISTANCE LINEAR_DISTANCE}{@link AL11#AL_LINEAR_DISTANCE_CLAMPED LINEAR_DISTANCE_CLAMPED}
{@link AL11#AL_EXPONENT_DISTANCE EXPONENT_DISTANCE}{@link AL11#AL_EXPONENT_DISTANCE_CLAMPED EXPONENT_DISTANCE_CLAMPED}{@link #AL_NONE NONE}
+ */ + @NativeType("ALvoid") + public static void alDistanceModel(@NativeType("ALenum") int modelName) { + long __functionAddress = AL.getICD().alDistanceModel; + invokeV(modelName, __functionAddress); + } + + // --- [ alDopplerFactor ] --- + + /** + * Sets the doppler effect factor. + * + *

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 Doppler Effect as implemented by + * OpenAL is described by the formula below. Effects of the medium (air, water) moving with respect to listener and source are ignored.

+ * + *

+     * SS: AL_SPEED_OF_SOUND = speed of sound (default value 343.3)
+     * DF: AL_DOPPLER_FACTOR = Doppler factor (default 1.0)
+     * vls: Listener velocity scalar (scalar, projected on source-to-listener vector)
+     * vss: Source velocity scalar (scalar, projected on source-to-listener vector)
+     * f: Frequency of sample
+     * f': effective Doppler shifted frequency
+     * 
+     * 3D Mathematical representation of vls and vss:
+     * 
+     * Mag(vector) = sqrt(vector.x * vector.x + vector.y * vector.y + vector.z * vector.z)
+     * DotProduct(v1, v2) = (v1.x * v2.x + v1.y * v2.y + v1.z * v2.z)
+     * 
+     * SL = source to listener vector
+     * SV = Source velocity vector
+     * LV = Listener velocity vector
+     * 
+     * vls = DotProduct(SL, LV) / Mag(SL)
+     * vss = DotProduct(SL, SV) / Mag(SL)
+     * 
+     * Dopper Calculation:
+     * 
+     * vss = min(vss, SS / DF)
+     * vls = min(vls, SS / DF)
+     * 
+     * f' = f * (SS - DF * vls) / (SS - DF * vss)
+ * + *

The {@code dopplerFactor} is a simple scaling of source and listener velocities to exaggerate or deemphasize the Doppler (pitch) shift resulting from + * the calculation.

+ * + * @param dopplerFactor the doppler factor + */ + @NativeType("ALvoid") + public static void alDopplerFactor(@NativeType("ALfloat") float dopplerFactor) { + long __functionAddress = AL.getICD().alDopplerFactor; + invokeV(dopplerFactor, __functionAddress); + } + + // --- [ alDopplerVelocity ] --- + + /** + * Sets the doppler effect propagation velocity. + * + *

The OpenAL 1.1 Doppler implementation is different than that of OpenAL 1.0, because the older implementation was confusing and not implemented + * consistently. The new "speed of sound" property makes the 1.1 implementation more intuitive than the old implementation. If your implementation wants to + * support the AL_DOPPLER_VELOCITY parameter (the alDopplerVelocity call will remain as an entry point so that 1.0 applications can link with a 1.1 + * library), the above formula can be changed to the following:

+ * + *

+     * vss = min(vss, (SS * DV)/DF)
+     * vls = min(vls, (SS * DV)/DF)
+     * 
+     * f' = f * (SS * DV - DF*vls) / (SS * DV - DF * vss)
+ * + *

OpenAL 1.1 programmers would never use AL_DOPPLER_VELOCITY (which defaults to 1.0).

+ * + * @param dopplerVelocity the doppler velocity + */ + @NativeType("ALvoid") + public static void alDopplerVelocity(@NativeType("ALfloat") float dopplerVelocity) { + long __functionAddress = AL.getICD().alDopplerVelocity; + invokeV(dopplerVelocity, __functionAddress); + } + + // --- [ alListenerf ] --- + + /** + * Sets the float value of a listener parameter. + * + * @param paramName the parameter to modify. One of:
{@link #AL_ORIENTATION ORIENTATION}{@link #AL_POSITION POSITION}{@link #AL_VELOCITY VELOCITY}{@link #AL_GAIN GAIN}
+ * @param value the parameter value + */ + @NativeType("ALvoid") + public static void alListenerf(@NativeType("ALenum") int paramName, @NativeType("ALfloat") float value) { + long __functionAddress = AL.getICD().alListenerf; + invokeV(paramName, value, __functionAddress); + } + + // --- [ alListeneri ] --- + + /** + * Integer version of {@link #alListenerf Listenerf}. + * + * @param paramName the parameter to modify. One of:
{@link #AL_ORIENTATION ORIENTATION}{@link #AL_POSITION POSITION}{@link #AL_VELOCITY VELOCITY}{@link #AL_GAIN GAIN}
+ * @param values the parameter value + */ + @NativeType("ALvoid") + public static void alListeneri(@NativeType("ALenum") int paramName, @NativeType("ALint") int values) { + long __functionAddress = AL.getICD().alListeneri; + invokeV(paramName, values, __functionAddress); + } + + // --- [ alListener3f ] --- + + /** + * Sets the 3 dimensional float values of a listener parameter. + * + * @param paramName the parameter to modify. One of:
{@link #AL_ORIENTATION ORIENTATION}{@link #AL_POSITION POSITION}{@link #AL_VELOCITY VELOCITY}{@link #AL_GAIN GAIN}
+ * @param value1 the first value + * @param value2 the second value + * @param value3 the third value + */ + @NativeType("ALvoid") + public static void alListener3f(@NativeType("ALenum") int paramName, @NativeType("ALfloat") float value1, @NativeType("ALfloat") float value2, @NativeType("ALfloat") float value3) { + long __functionAddress = AL.getICD().alListener3f; + invokeV(paramName, value1, value2, value3, __functionAddress); + } + + // --- [ alListenerfv ] --- + + /** Unsafe version of: {@link #alListenerfv Listenerfv} */ + public static void nalListenerfv(int paramName, long values) { + long __functionAddress = AL.getICD().alListenerfv; + invokePV(paramName, values, __functionAddress); + } + + /** + * Pointer version of {@link #alListenerf Listenerf}. + * + * @param paramName the parameter to modify + * @param values the parameter values + */ + @NativeType("ALvoid") + public static void alListenerfv(@NativeType("ALenum") int paramName, @NativeType("ALfloat const *") FloatBuffer values) { + if (CHECKS) { + check(values, 1); + } + nalListenerfv(paramName, memAddress(values)); + } + + // --- [ alGetListenerf ] --- + + /** Unsafe version of: {@link #alGetListenerf GetListenerf} */ + public static void nalGetListenerf(int paramName, long value) { + long __functionAddress = AL.getICD().alGetListenerf; + invokePV(paramName, value, __functionAddress); + } + + /** + * Returns the float value of a listener parameter. + * + * @param paramName the parameter to query. One of:
{@link #AL_ORIENTATION ORIENTATION}{@link #AL_POSITION POSITION}{@link #AL_VELOCITY VELOCITY}{@link #AL_GAIN GAIN}
+ * @param value the parameter value + */ + @NativeType("ALvoid") + public static void alGetListenerf(@NativeType("ALenum") int paramName, @NativeType("ALfloat *") FloatBuffer value) { + if (CHECKS) { + check(value, 1); + } + nalGetListenerf(paramName, memAddress(value)); + } + + /** + * Returns the float value of a listener parameter. + * + * @param paramName the parameter to query. One of:
{@link #AL_ORIENTATION ORIENTATION}{@link #AL_POSITION POSITION}{@link #AL_VELOCITY VELOCITY}{@link #AL_GAIN GAIN}
+ */ + @NativeType("ALvoid") + public static float alGetListenerf(@NativeType("ALenum") int paramName) { + MemoryStack stack = stackGet(); int stackPointer = stack.getPointer(); + try { + FloatBuffer value = stack.callocFloat(1); + nalGetListenerf(paramName, memAddress(value)); + return value.get(0); + } finally { + stack.setPointer(stackPointer); + } + } + + // --- [ alGetListeneri ] --- + + /** Unsafe version of: {@link #alGetListeneri GetListeneri} */ + public static void nalGetListeneri(int paramName, long value) { + long __functionAddress = AL.getICD().alGetListeneri; + invokePV(paramName, value, __functionAddress); + } + + /** + * Returns the integer value of a listener parameter. + * + * @param paramName the parameter to query. One of:
{@link #AL_ORIENTATION ORIENTATION}{@link #AL_POSITION POSITION}{@link #AL_VELOCITY VELOCITY}{@link #AL_GAIN GAIN}
+ * @param value the parameter value + */ + @NativeType("ALvoid") + public static void alGetListeneri(@NativeType("ALenum") int paramName, @NativeType("ALint *") IntBuffer value) { + if (CHECKS) { + check(value, 1); + } + nalGetListeneri(paramName, memAddress(value)); + } + + /** + * Returns the integer value of a listener parameter. + * + * @param paramName the parameter to query. One of:
{@link #AL_ORIENTATION ORIENTATION}{@link #AL_POSITION POSITION}{@link #AL_VELOCITY VELOCITY}{@link #AL_GAIN GAIN}
+ */ + @NativeType("ALvoid") + public static int alGetListeneri(@NativeType("ALenum") int paramName) { + MemoryStack stack = stackGet(); int stackPointer = stack.getPointer(); + try { + IntBuffer value = stack.callocInt(1); + nalGetListeneri(paramName, memAddress(value)); + return value.get(0); + } finally { + stack.setPointer(stackPointer); + } + } + + // --- [ alGetListener3f ] --- + + /** Unsafe version of: {@link #alGetListener3f GetListener3f} */ + public static void nalGetListener3f(int paramName, long value1, long value2, long value3) { + long __functionAddress = AL.getICD().alGetListener3f; + invokePPPV(paramName, value1, value2, value3, __functionAddress); + } + + /** + * Returns the 3 dimensional values of a listener parameter. + * + * @param paramName the parameter to query. One of:
{@link #AL_ORIENTATION ORIENTATION}{@link #AL_POSITION POSITION}{@link #AL_VELOCITY VELOCITY}{@link #AL_GAIN GAIN}
+ * @param value1 the first parameter value + * @param value2 the second parameter value + * @param value3 the third parameter value + */ + @NativeType("ALvoid") + public static void alGetListener3f(@NativeType("ALenum") int paramName, @NativeType("ALfloat *") FloatBuffer value1, @NativeType("ALfloat *") FloatBuffer value2, @NativeType("ALfloat *") FloatBuffer value3) { + if (CHECKS) { + check(value1, 1); + check(value2, 1); + check(value3, 1); + } + nalGetListener3f(paramName, memAddress(value1), memAddress(value2), memAddress(value3)); + } + + // --- [ alGetListenerfv ] --- + + /** Unsafe version of: {@link #alGetListenerfv GetListenerfv} */ + public static void nalGetListenerfv(int paramName, long values) { + long __functionAddress = AL.getICD().alGetListenerfv; + invokePV(paramName, values, __functionAddress); + } + + /** + * Returns float values of a listener parameter. + * + * @param paramName the parameter to query. One of:
{@link #AL_ORIENTATION ORIENTATION}{@link #AL_POSITION POSITION}{@link #AL_VELOCITY VELOCITY}{@link #AL_GAIN GAIN}
+ * @param values the parameter values + */ + @NativeType("ALvoid") + public static void alGetListenerfv(@NativeType("ALenum") int paramName, @NativeType("ALfloat *") FloatBuffer values) { + if (CHECKS) { + check(values, 1); + } + nalGetListenerfv(paramName, memAddress(values)); + } + + // --- [ alGenSources ] --- + + /** + * Unsafe version of: {@link #alGenSources GenSources} + * + * @param n the number of source names to generated + */ + public static void nalGenSources(int n, long srcNames) { + long __functionAddress = AL.getICD().alGenSources; + invokePV(n, srcNames, __functionAddress); + } + + /** + * Requests a number of source names. + * + * @param srcNames the buffer that will receive the source names + */ + @NativeType("ALvoid") + public static void alGenSources(@NativeType("ALuint *") IntBuffer srcNames) { + nalGenSources(srcNames.remaining(), memAddress(srcNames)); + } + + /** Requests a number of source names. */ + @NativeType("ALvoid") + public static int alGenSources() { + MemoryStack stack = stackGet(); int stackPointer = stack.getPointer(); + try { + IntBuffer srcNames = stack.callocInt(1); + nalGenSources(1, memAddress(srcNames)); + return srcNames.get(0); + } finally { + stack.setPointer(stackPointer); + } + } + + // --- [ alDeleteSources ] --- + + /** + * Unsafe version of: {@link #alDeleteSources DeleteSources} + * + * @param n the number of sources to delete + */ + public static void nalDeleteSources(int n, long sources) { + long __functionAddress = AL.getICD().alDeleteSources; + invokePV(n, sources, __functionAddress); + } + + /** + * Requests the deletion of a number of sources. + * + * @param sources the sources to delete + */ + @NativeType("ALvoid") + public static void alDeleteSources(@NativeType("ALuint *") IntBuffer sources) { + nalDeleteSources(sources.remaining(), memAddress(sources)); + } + + /** Requests the deletion of a number of sources. */ + @NativeType("ALvoid") + public static void alDeleteSources(@NativeType("ALuint *") int source) { + MemoryStack stack = stackGet(); int stackPointer = stack.getPointer(); + try { + IntBuffer sources = stack.ints(source); + nalDeleteSources(1, memAddress(sources)); + } finally { + stack.setPointer(stackPointer); + } + } + + // --- [ alIsSource ] --- + + /** + * Verifies whether the specified object name is a source name. + * + * @param sourceName a value that may be a source name + */ + @NativeType("ALboolean") + public static boolean alIsSource(@NativeType("ALuint") int sourceName) { + long __functionAddress = AL.getICD().alIsSource; + return invokeZ(sourceName, __functionAddress); + } + + // --- [ alSourcef ] --- + + /** + * Sets the float value of a source parameter. + * + * @param source the source to modify + * @param param the parameter to modify. One of:
{@link #AL_CONE_INNER_ANGLE CONE_INNER_ANGLE}{@link #AL_CONE_OUTER_ANGLE CONE_OUTER_ANGLE}{@link #AL_PITCH PITCH}{@link #AL_DIRECTION DIRECTION}{@link #AL_LOOPING LOOPING}{@link #AL_BUFFER BUFFER}{@link #AL_SOURCE_STATE SOURCE_STATE}
{@link #AL_CONE_OUTER_GAIN CONE_OUTER_GAIN}{@link #AL_SOURCE_TYPE SOURCE_TYPE}{@link #AL_POSITION POSITION}{@link #AL_VELOCITY VELOCITY}{@link #AL_GAIN GAIN}{@link #AL_REFERENCE_DISTANCE REFERENCE_DISTANCE}{@link #AL_ROLLOFF_FACTOR ROLLOFF_FACTOR}
{@link #AL_MAX_DISTANCE MAX_DISTANCE}
+ * @param value the parameter value + */ + @NativeType("ALvoid") + public static void alSourcef(@NativeType("ALuint") int source, @NativeType("ALenum") int param, @NativeType("ALfloat") float value) { + long __functionAddress = AL.getICD().alSourcef; + invokeV(source, param, value, __functionAddress); + } + + // --- [ alSource3f ] --- + + /** + * Sets the 3 dimensional values of a source parameter. + * + * @param source the source to modify + * @param param the parameter to modify. One of:
{@link #AL_CONE_INNER_ANGLE CONE_INNER_ANGLE}{@link #AL_CONE_OUTER_ANGLE CONE_OUTER_ANGLE}{@link #AL_PITCH PITCH}{@link #AL_DIRECTION DIRECTION}{@link #AL_LOOPING LOOPING}{@link #AL_BUFFER BUFFER}{@link #AL_SOURCE_STATE SOURCE_STATE}
{@link #AL_CONE_OUTER_GAIN CONE_OUTER_GAIN}{@link #AL_SOURCE_TYPE SOURCE_TYPE}{@link #AL_POSITION POSITION}{@link #AL_VELOCITY VELOCITY}{@link #AL_GAIN GAIN}{@link #AL_REFERENCE_DISTANCE REFERENCE_DISTANCE}{@link #AL_ROLLOFF_FACTOR ROLLOFF_FACTOR}
{@link #AL_MAX_DISTANCE MAX_DISTANCE}
+ * @param v1 the first parameter value + * @param v2 the second parameter value + * @param v3 the third parameter value + */ + @NativeType("ALvoid") + public static void alSource3f(@NativeType("ALuint") int source, @NativeType("ALenum") int param, @NativeType("ALfloat") float v1, @NativeType("ALfloat") float v2, @NativeType("ALfloat") float v3) { + long __functionAddress = AL.getICD().alSource3f; + invokeV(source, param, v1, v2, v3, __functionAddress); + } + + // --- [ alSourcefv ] --- + + /** Unsafe version of: {@link #alSourcefv Sourcefv} */ + public static void nalSourcefv(int source, int param, long values) { + long __functionAddress = AL.getICD().alSourcefv; + invokePV(source, param, values, __functionAddress); + } + + /** + * Pointer version of {@link #alSourcef Sourcef}. + * + * @param source the source to modify + * @param param the parameter to modify + * @param values the parameter values + */ + @NativeType("ALvoid") + public static void alSourcefv(@NativeType("ALuint") int source, @NativeType("ALenum") int param, @NativeType("ALfloat const *") FloatBuffer values) { + if (CHECKS) { + check(values, 1); + } + nalSourcefv(source, param, memAddress(values)); + } + + // --- [ alSourcei ] --- + + /** + * Integer version of {@link #alSourcef Sourcef}. + * + * @param source the source to modify + * @param param the parameter to modify + * @param value the parameter value + */ + @NativeType("ALvoid") + public static void alSourcei(@NativeType("ALuint") int source, @NativeType("ALenum") int param, @NativeType("ALint") int value) { + long __functionAddress = AL.getICD().alSourcei; + invokeV(source, param, value, __functionAddress); + } + + // --- [ alGetSourcef ] --- + + /** Unsafe version of: {@link #alGetSourcef GetSourcef} */ + public static void nalGetSourcef(int source, int param, long value) { + long __functionAddress = AL.getICD().alGetSourcef; + invokePV(source, param, value, __functionAddress); + } + + /** + * Returns the float value of the specified source parameter. + * + * @param source the source to query + * @param param the parameter to query. One of:
{@link #AL_CONE_INNER_ANGLE CONE_INNER_ANGLE}{@link #AL_CONE_OUTER_ANGLE CONE_OUTER_ANGLE}{@link #AL_PITCH PITCH}{@link #AL_DIRECTION DIRECTION}{@link #AL_LOOPING LOOPING}{@link #AL_BUFFER BUFFER}{@link #AL_SOURCE_STATE SOURCE_STATE}
{@link #AL_CONE_OUTER_GAIN CONE_OUTER_GAIN}{@link #AL_SOURCE_TYPE SOURCE_TYPE}{@link #AL_POSITION POSITION}{@link #AL_VELOCITY VELOCITY}{@link #AL_GAIN GAIN}{@link #AL_REFERENCE_DISTANCE REFERENCE_DISTANCE}{@link #AL_ROLLOFF_FACTOR ROLLOFF_FACTOR}
{@link #AL_MAX_DISTANCE MAX_DISTANCE}
+ * @param value the parameter value + */ + @NativeType("ALvoid") + public static void alGetSourcef(@NativeType("ALuint") int source, @NativeType("ALenum") int param, @NativeType("ALfloat *") FloatBuffer value) { + if (CHECKS) { + check(value, 1); + } + nalGetSourcef(source, param, memAddress(value)); + } + + /** + * Returns the float value of the specified source parameter. + * + * @param source the source to query + * @param param the parameter to query. One of:
{@link #AL_CONE_INNER_ANGLE CONE_INNER_ANGLE}{@link #AL_CONE_OUTER_ANGLE CONE_OUTER_ANGLE}{@link #AL_PITCH PITCH}{@link #AL_DIRECTION DIRECTION}{@link #AL_LOOPING LOOPING}{@link #AL_BUFFER BUFFER}{@link #AL_SOURCE_STATE SOURCE_STATE}
{@link #AL_CONE_OUTER_GAIN CONE_OUTER_GAIN}{@link #AL_SOURCE_TYPE SOURCE_TYPE}{@link #AL_POSITION POSITION}{@link #AL_VELOCITY VELOCITY}{@link #AL_GAIN GAIN}{@link #AL_REFERENCE_DISTANCE REFERENCE_DISTANCE}{@link #AL_ROLLOFF_FACTOR ROLLOFF_FACTOR}
{@link #AL_MAX_DISTANCE MAX_DISTANCE}
+ */ + @NativeType("ALvoid") + public static float alGetSourcef(@NativeType("ALuint") int source, @NativeType("ALenum") int param) { + MemoryStack stack = stackGet(); int stackPointer = stack.getPointer(); + try { + FloatBuffer value = stack.callocFloat(1); + nalGetSourcef(source, param, memAddress(value)); + return value.get(0); + } finally { + stack.setPointer(stackPointer); + } + } + + // --- [ alGetSource3f ] --- + + /** Unsafe version of: {@link #alGetSource3f GetSource3f} */ + public static void nalGetSource3f(int source, int param, long v1, long v2, long v3) { + long __functionAddress = AL.getICD().alGetSource3f; + invokePPPV(source, param, v1, v2, v3, __functionAddress); + } + + /** + * Returns the 3 dimensional values of the specified source parameter. + * + * @param source the source to query + * @param param the parameter to query. One of:
{@link #AL_CONE_INNER_ANGLE CONE_INNER_ANGLE}{@link #AL_CONE_OUTER_ANGLE CONE_OUTER_ANGLE}{@link #AL_PITCH PITCH}{@link #AL_DIRECTION DIRECTION}{@link #AL_LOOPING LOOPING}{@link #AL_BUFFER BUFFER}{@link #AL_SOURCE_STATE SOURCE_STATE}
{@link #AL_CONE_OUTER_GAIN CONE_OUTER_GAIN}{@link #AL_SOURCE_TYPE SOURCE_TYPE}{@link #AL_POSITION POSITION}{@link #AL_VELOCITY VELOCITY}{@link #AL_GAIN GAIN}{@link #AL_REFERENCE_DISTANCE REFERENCE_DISTANCE}{@link #AL_ROLLOFF_FACTOR ROLLOFF_FACTOR}
{@link #AL_MAX_DISTANCE MAX_DISTANCE}
+ * @param v1 the first parameter value + * @param v2 the second parameter value + * @param v3 the third parameter value + */ + @NativeType("ALvoid") + public static void alGetSource3f(@NativeType("ALuint") int source, @NativeType("ALenum") int param, @NativeType("ALfloat *") FloatBuffer v1, @NativeType("ALfloat *") FloatBuffer v2, @NativeType("ALfloat *") FloatBuffer v3) { + if (CHECKS) { + check(v1, 1); + check(v2, 1); + check(v3, 1); + } + nalGetSource3f(source, param, memAddress(v1), memAddress(v2), memAddress(v3)); + } + + // --- [ alGetSourcefv ] --- + + /** Unsafe version of: {@link #alGetSourcefv GetSourcefv} */ + public static void nalGetSourcefv(int source, int param, long values) { + long __functionAddress = AL.getICD().alGetSourcefv; + invokePV(source, param, values, __functionAddress); + } + + /** + * Returns the float values of the specified source parameter. + * + * @param source the source to query + * @param param the parameter to query. One of:
{@link #AL_CONE_INNER_ANGLE CONE_INNER_ANGLE}{@link #AL_CONE_OUTER_ANGLE CONE_OUTER_ANGLE}{@link #AL_PITCH PITCH}{@link #AL_DIRECTION DIRECTION}{@link #AL_LOOPING LOOPING}{@link #AL_BUFFER BUFFER}{@link #AL_SOURCE_STATE SOURCE_STATE}
{@link #AL_CONE_OUTER_GAIN CONE_OUTER_GAIN}{@link #AL_SOURCE_TYPE SOURCE_TYPE}{@link #AL_POSITION POSITION}{@link #AL_VELOCITY VELOCITY}{@link #AL_GAIN GAIN}{@link #AL_REFERENCE_DISTANCE REFERENCE_DISTANCE}{@link #AL_ROLLOFF_FACTOR ROLLOFF_FACTOR}
{@link #AL_MAX_DISTANCE MAX_DISTANCE}
+ * @param values the parameter values + */ + @NativeType("ALvoid") + public static void alGetSourcefv(@NativeType("ALuint") int source, @NativeType("ALenum") int param, @NativeType("ALfloat *") FloatBuffer values) { + if (CHECKS) { + check(values, 1); + } + nalGetSourcefv(source, param, memAddress(values)); + } + + // --- [ alGetSourcei ] --- + + /** Unsafe version of: {@link #alGetSourcei GetSourcei} */ + public static void nalGetSourcei(int source, int param, long value) { + long __functionAddress = AL.getICD().alGetSourcei; + invokePV(source, param, value, __functionAddress); + } + + /** + * Returns the integer value of the specified source parameter. + * + * @param source the source to query + * @param param the parameter to query. One of:
{@link #AL_CONE_INNER_ANGLE CONE_INNER_ANGLE}{@link #AL_CONE_OUTER_ANGLE CONE_OUTER_ANGLE}{@link #AL_PITCH PITCH}{@link #AL_DIRECTION DIRECTION}{@link #AL_LOOPING LOOPING}{@link #AL_BUFFER BUFFER}{@link #AL_SOURCE_STATE SOURCE_STATE}
{@link #AL_CONE_OUTER_GAIN CONE_OUTER_GAIN}{@link #AL_SOURCE_TYPE SOURCE_TYPE}{@link #AL_POSITION POSITION}{@link #AL_VELOCITY VELOCITY}{@link #AL_GAIN GAIN}{@link #AL_REFERENCE_DISTANCE REFERENCE_DISTANCE}{@link #AL_ROLLOFF_FACTOR ROLLOFF_FACTOR}
{@link #AL_MAX_DISTANCE MAX_DISTANCE}
+ * @param value the parameter value + */ + @NativeType("ALvoid") + public static void alGetSourcei(@NativeType("ALuint") int source, @NativeType("ALenum") int param, @NativeType("ALint *") IntBuffer value) { + if (CHECKS) { + check(value, 1); + } + nalGetSourcei(source, param, memAddress(value)); + } + + /** + * Returns the integer value of the specified source parameter. + * + * @param source the source to query + * @param param the parameter to query. One of:
{@link #AL_CONE_INNER_ANGLE CONE_INNER_ANGLE}{@link #AL_CONE_OUTER_ANGLE CONE_OUTER_ANGLE}{@link #AL_PITCH PITCH}{@link #AL_DIRECTION DIRECTION}{@link #AL_LOOPING LOOPING}{@link #AL_BUFFER BUFFER}{@link #AL_SOURCE_STATE SOURCE_STATE}
{@link #AL_CONE_OUTER_GAIN CONE_OUTER_GAIN}{@link #AL_SOURCE_TYPE SOURCE_TYPE}{@link #AL_POSITION POSITION}{@link #AL_VELOCITY VELOCITY}{@link #AL_GAIN GAIN}{@link #AL_REFERENCE_DISTANCE REFERENCE_DISTANCE}{@link #AL_ROLLOFF_FACTOR ROLLOFF_FACTOR}
{@link #AL_MAX_DISTANCE MAX_DISTANCE}
+ */ + @NativeType("ALvoid") + public static int alGetSourcei(@NativeType("ALuint") int source, @NativeType("ALenum") int param) { + MemoryStack stack = stackGet(); int stackPointer = stack.getPointer(); + try { + IntBuffer value = stack.callocInt(1); + nalGetSourcei(source, param, memAddress(value)); + return value.get(0); + } finally { + stack.setPointer(stackPointer); + } + } + + // --- [ alGetSourceiv ] --- + + /** Unsafe version of: {@link #alGetSourceiv GetSourceiv} */ + public static void nalGetSourceiv(int source, int param, long values) { + long __functionAddress = AL.getICD().alGetSourceiv; + invokePV(source, param, values, __functionAddress); + } + + /** + * Returns the integer values of the specified source parameter. + * + * @param source the source to query + * @param param the parameter to query. One of:
{@link #AL_CONE_INNER_ANGLE CONE_INNER_ANGLE}{@link #AL_CONE_OUTER_ANGLE CONE_OUTER_ANGLE}{@link #AL_PITCH PITCH}{@link #AL_DIRECTION DIRECTION}{@link #AL_LOOPING LOOPING}{@link #AL_BUFFER BUFFER}{@link #AL_SOURCE_STATE SOURCE_STATE}
{@link #AL_CONE_OUTER_GAIN CONE_OUTER_GAIN}{@link #AL_SOURCE_TYPE SOURCE_TYPE}{@link #AL_POSITION POSITION}{@link #AL_VELOCITY VELOCITY}{@link #AL_GAIN GAIN}{@link #AL_REFERENCE_DISTANCE REFERENCE_DISTANCE}{@link #AL_ROLLOFF_FACTOR ROLLOFF_FACTOR}
{@link #AL_MAX_DISTANCE MAX_DISTANCE}
+ * @param values the parameter values + */ + @NativeType("ALvoid") + public static void alGetSourceiv(@NativeType("ALuint") int source, @NativeType("ALenum") int param, @NativeType("ALint *") IntBuffer values) { + if (CHECKS) { + check(values, 1); + } + nalGetSourceiv(source, param, memAddress(values)); + } + + // --- [ alSourceQueueBuffers ] --- + + /** + * Unsafe version of: {@link #alSourceQueueBuffers SourceQueueBuffers} + * + * @param numBuffers the number of buffers to queue + */ + public static void nalSourceQueueBuffers(int sourceName, int numBuffers, long bufferNames) { + long __functionAddress = AL.getICD().alSourceQueueBuffers; + invokePV(sourceName, numBuffers, bufferNames, __functionAddress); + } + + /** + * Queues up one or multiple buffer names to the specified source. + * + *

The buffers will be queued in the sequence in which they appear in the array. This command is legal on a source in any playback state (to allow for + * streaming, queuing has to be possible on a AL_PLAYING source). All buffers in a queue must have the same format and attributes, with the exception of + * the {@code NULL} buffer (i.e., 0) which can always be queued.

+ * + * @param sourceName the target source + * @param bufferNames the buffer names + */ + @NativeType("ALvoid") + public static void alSourceQueueBuffers(@NativeType("ALuint") int sourceName, @NativeType("ALuint *") IntBuffer bufferNames) { + nalSourceQueueBuffers(sourceName, bufferNames.remaining(), memAddress(bufferNames)); + } + + /** + * Queues up one or multiple buffer names to the specified source. + * + *

The buffers will be queued in the sequence in which they appear in the array. This command is legal on a source in any playback state (to allow for + * streaming, queuing has to be possible on a AL_PLAYING source). All buffers in a queue must have the same format and attributes, with the exception of + * the {@code NULL} buffer (i.e., 0) which can always be queued.

+ * + * @param sourceName the target source + */ + @NativeType("ALvoid") + public static void alSourceQueueBuffers(@NativeType("ALuint") int sourceName, @NativeType("ALuint *") int bufferName) { + MemoryStack stack = stackGet(); int stackPointer = stack.getPointer(); + try { + IntBuffer bufferNames = stack.ints(bufferName); + nalSourceQueueBuffers(sourceName, 1, memAddress(bufferNames)); + } finally { + stack.setPointer(stackPointer); + } + } + + // --- [ alSourceUnqueueBuffers ] --- + + /** + * Unsafe version of: {@link #alSourceUnqueueBuffers SourceUnqueueBuffers} + * + * @param numEntries the number of buffers to unqueue + */ + public static void nalSourceUnqueueBuffers(int sourceName, int numEntries, long bufferNames) { + long __functionAddress = AL.getICD().alSourceUnqueueBuffers; + invokePV(sourceName, numEntries, bufferNames, __functionAddress); + } + + /** + * Removes a number of buffer entries that have finished processing, in the order of apperance, from the queue of the specified source. + * + *

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 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). A playing source will enter the AL_STOPPED state if it completes playback of the last buffer in its queue (the same + * behavior as when a single buffer has been attached to a source and has finished playback).

+ * + * @param sourceName the target source + * @param bufferNames the buffer names + */ + @NativeType("ALvoid") + public static void alSourceUnqueueBuffers(@NativeType("ALuint") int sourceName, @NativeType("ALuint *") IntBuffer bufferNames) { + nalSourceUnqueueBuffers(sourceName, bufferNames.remaining(), memAddress(bufferNames)); + } + + /** + * Removes a number of buffer entries that have finished processing, in the order of apperance, from the queue of the specified source. + * + *

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 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). A playing source will enter the AL_STOPPED state if it completes playback of the last buffer in its queue (the same + * behavior as when a single buffer has been attached to a source and has finished playback).

+ * + * @param sourceName the target source + */ + @NativeType("ALvoid") + public static int alSourceUnqueueBuffers(@NativeType("ALuint") int sourceName) { + MemoryStack stack = stackGet(); int stackPointer = stack.getPointer(); + try { + IntBuffer bufferNames = stack.callocInt(1); + nalSourceUnqueueBuffers(sourceName, 1, memAddress(bufferNames)); + return bufferNames.get(0); + } finally { + stack.setPointer(stackPointer); + } + } + + // --- [ alSourcePlay ] --- + + /** + * Sets the source state to AL_PLAYING. + * + *

alSourcePlay 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. alSourcePlay 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. alSourcePlay applied to a AL_PAUSED source will resume + * processing using the source state as preserved at the alSourcePause operation. alSourcePlay applied to a AL_STOPPED source will propagate it to + * AL_INITIAL then to AL_PLAYING immediately.

+ * + * @param source the source to play + */ + @NativeType("ALvoid") + public static void alSourcePlay(@NativeType("ALuint") int source) { + long __functionAddress = AL.getICD().alSourcePlay; + invokeV(source, __functionAddress); + } + + // --- [ alSourcePause ] --- + + /** + * Sets the source state to AL_PAUSED. + * + *

alSourcePause applied to an AL_INITIAL source is a legal NOP. alSourcePause applied to a AL_PLAYING source will change its state to AL_PAUSED. The + * source is exempt from processing, its current state is preserved. alSourcePause applied to a AL_PAUSED source is a legal NOP. alSourcePause applied to a + * AL_STOPPED source is a legal NOP.

+ * + * @param source the source to pause + */ + @NativeType("ALvoid") + public static void alSourcePause(@NativeType("ALuint") int source) { + long __functionAddress = AL.getICD().alSourcePause; + invokeV(source, __functionAddress); + } + + // --- [ alSourceStop ] --- + + /** + * Sets the source state to AL_STOPPED. + * + *

alSourceStop applied to an AL_INITIAL source is a legal NOP. alSourceStop applied to a AL_PLAYING source will change its state to AL_STOPPED. The source + * is exempt from processing, its current state is preserved. alSourceStop applied to a AL_PAUSED source will change its state to AL_STOPPED, with the same + * consequences as on a AL_PLAYING source. alSourceStop applied to a AL_STOPPED source is a legal NOP.

+ * + * @param source the source to stop + */ + @NativeType("ALvoid") + public static void alSourceStop(@NativeType("ALuint") int source) { + long __functionAddress = AL.getICD().alSourceStop; + invokeV(source, __functionAddress); + } + + // --- [ alSourceRewind ] --- + + /** + * Sets the source state to AL_INITIAL. + * + *

alSourceRewind applied to an AL_INITIAL source is a legal NOP. alSourceRewind 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. alSourceRewind applied to a AL_PAUSED source will change its state to AL_INITIAL, with the same consequences as on a AL_PLAYING source. + * alSourceRewind applied to an AL_STOPPED source promotes the source to AL_INITIAL, resetting the sampling offset to the beginning.

+ * + * @param source the source to rewind + */ + @NativeType("ALvoid") + public static void alSourceRewind(@NativeType("ALuint") int source) { + long __functionAddress = AL.getICD().alSourceRewind; + invokeV(source, __functionAddress); + } + + // --- [ alSourcePlayv ] --- + + /** + * Unsafe version of: {@link #alSourcePlayv SourcePlayv} + * + * @param n the number of sources to play + */ + public static void nalSourcePlayv(int n, long sources) { + long __functionAddress = AL.getICD().alSourcePlayv; + invokePV(n, sources, __functionAddress); + } + + /** + * Pointer version of {@link #alSourcePlay SourcePlay}. + * + * @param sources the sources to play + */ + @NativeType("ALvoid") + public static void alSourcePlayv(@NativeType("ALuint const *") IntBuffer sources) { + nalSourcePlayv(sources.remaining(), memAddress(sources)); + } + + // --- [ alSourcePausev ] --- + + /** + * Unsafe version of: {@link #alSourcePausev SourcePausev} + * + * @param n the number of sources to pause + */ + public static void nalSourcePausev(int n, long sources) { + long __functionAddress = AL.getICD().alSourcePausev; + invokePV(n, sources, __functionAddress); + } + + /** + * Pointer version of {@link #alSourcePause SourcePause}. + * + * @param sources the sources to pause + */ + @NativeType("ALvoid") + public static void alSourcePausev(@NativeType("ALuint const *") IntBuffer sources) { + nalSourcePausev(sources.remaining(), memAddress(sources)); + } + + // --- [ alSourceStopv ] --- + + /** + * Unsafe version of: {@link #alSourceStopv SourceStopv} + * + * @param n the number of sources to stop + */ + public static void nalSourceStopv(int n, long sources) { + long __functionAddress = AL.getICD().alSourceStopv; + invokePV(n, sources, __functionAddress); + } + + /** + * Pointer version of {@link #alSourceStop SourceStop}. + * + * @param sources the sources to stop + */ + @NativeType("ALvoid") + public static void alSourceStopv(@NativeType("ALuint const *") IntBuffer sources) { + nalSourceStopv(sources.remaining(), memAddress(sources)); + } + + // --- [ alSourceRewindv ] --- + + /** + * Unsafe version of: {@link #alSourceRewindv SourceRewindv} + * + * @param n the number of sources to rewind + */ + public static void nalSourceRewindv(int n, long sources) { + long __functionAddress = AL.getICD().alSourceRewindv; + invokePV(n, sources, __functionAddress); + } + + /** + * Pointer version of {@link #alSourceRewind SourceRewind}. + * + * @param sources the sources to rewind + */ + @NativeType("ALvoid") + public static void alSourceRewindv(@NativeType("ALuint const *") IntBuffer sources) { + nalSourceRewindv(sources.remaining(), memAddress(sources)); + } + + // --- [ alGenBuffers ] --- + + /** + * Unsafe version of: {@link #alGenBuffers GenBuffers} + * + * @param n the number of buffer names to generate + */ + public static void nalGenBuffers(int n, long bufferNames) { + long __functionAddress = AL.getICD().alGenBuffers; + invokePV(n, bufferNames, __functionAddress); + } + + /** + * Requests a number of buffer names. + * + * @param bufferNames the buffer that will receive the buffer names + */ + @NativeType("ALvoid") + public static void alGenBuffers(@NativeType("ALuint *") IntBuffer bufferNames) { + nalGenBuffers(bufferNames.remaining(), memAddress(bufferNames)); + } + + /** Requests a number of buffer names. */ + @NativeType("ALvoid") + public static int alGenBuffers() { + MemoryStack stack = stackGet(); int stackPointer = stack.getPointer(); + try { + IntBuffer bufferNames = stack.callocInt(1); + nalGenBuffers(1, memAddress(bufferNames)); + return bufferNames.get(0); + } finally { + stack.setPointer(stackPointer); + } + } + + // --- [ alDeleteBuffers ] --- + + /** + * Unsafe version of: {@link #alDeleteBuffers DeleteBuffers} + * + * @param n the number of buffers to delete + */ + public static void nalDeleteBuffers(int n, long bufferNames) { + long __functionAddress = AL.getICD().alDeleteBuffers; + invokePV(n, bufferNames, __functionAddress); + } + + /** + * Requests the deletion of a number of buffers. + * + * @param bufferNames the buffers to delete + */ + @NativeType("ALvoid") + public static void alDeleteBuffers(@NativeType("ALuint const *") IntBuffer bufferNames) { + nalDeleteBuffers(bufferNames.remaining(), memAddress(bufferNames)); + } + + /** Requests the deletion of a number of buffers. */ + @NativeType("ALvoid") + public static void alDeleteBuffers(@NativeType("ALuint const *") int bufferName) { + MemoryStack stack = stackGet(); int stackPointer = stack.getPointer(); + try { + IntBuffer bufferNames = stack.ints(bufferName); + nalDeleteBuffers(1, memAddress(bufferNames)); + } finally { + stack.setPointer(stackPointer); + } + } + + // --- [ alIsBuffer ] --- + + /** + * Verifies whether the specified object name is a buffer name. + * + * @param bufferName a value that may be a buffer name + */ + @NativeType("ALboolean") + public static boolean alIsBuffer(@NativeType("ALuint") int bufferName) { + long __functionAddress = AL.getICD().alIsBuffer; + return invokeZ(bufferName, __functionAddress); + } + + // --- [ alGetBufferf ] --- + + /** Unsafe version of: {@link #alGetBufferf GetBufferf} */ + public static void nalGetBufferf(int bufferName, int paramName, long value) { + long __functionAddress = AL.getICD().alGetBufferf; + invokePV(bufferName, paramName, value, __functionAddress); + } + + /** + * Returns the float value of the specified buffer parameter. + * + * @param bufferName the buffer to query + * @param paramName the parameter to query. One of:
{@link #AL_FREQUENCY FREQUENCY}{@link #AL_BITS BITS}{@link #AL_CHANNELS CHANNELS}{@link #AL_SIZE SIZE}
+ * @param value the parameter value + */ + @NativeType("ALvoid") + public static void alGetBufferf(@NativeType("ALuint") int bufferName, @NativeType("ALenum") int paramName, @NativeType("ALfloat *") FloatBuffer value) { + if (CHECKS) { + check(value, 1); + } + nalGetBufferf(bufferName, paramName, memAddress(value)); + } + + /** + * Returns the float value of the specified buffer parameter. + * + * @param bufferName the buffer to query + * @param paramName the parameter to query. One of:
{@link #AL_FREQUENCY FREQUENCY}{@link #AL_BITS BITS}{@link #AL_CHANNELS CHANNELS}{@link #AL_SIZE SIZE}
+ */ + @NativeType("ALvoid") + public static float alGetBufferf(@NativeType("ALuint") int bufferName, @NativeType("ALenum") int paramName) { + MemoryStack stack = stackGet(); int stackPointer = stack.getPointer(); + try { + FloatBuffer value = stack.callocFloat(1); + nalGetBufferf(bufferName, paramName, memAddress(value)); + return value.get(0); + } finally { + stack.setPointer(stackPointer); + } + } + + // --- [ alGetBufferi ] --- + + /** Unsafe version of: {@link #alGetBufferi GetBufferi} */ + public static void nalGetBufferi(int bufferName, int paramName, long value) { + long __functionAddress = AL.getICD().alGetBufferi; + invokePV(bufferName, paramName, value, __functionAddress); + } + + /** + * Returns the integer value of the specified buffer parameter. + * + * @param bufferName the buffer to query + * @param paramName the parameter to query. One of:
{@link #AL_FREQUENCY FREQUENCY}{@link #AL_BITS BITS}{@link #AL_CHANNELS CHANNELS}{@link #AL_SIZE SIZE}
+ * @param value the parameter value + */ + @NativeType("ALvoid") + public static void alGetBufferi(@NativeType("ALuint") int bufferName, @NativeType("ALenum") int paramName, @NativeType("ALint *") IntBuffer value) { + if (CHECKS) { + check(value, 1); + } + nalGetBufferi(bufferName, paramName, memAddress(value)); + } + + /** + * Returns the integer value of the specified buffer parameter. + * + * @param bufferName the buffer to query + * @param paramName the parameter to query. One of:
{@link #AL_FREQUENCY FREQUENCY}{@link #AL_BITS BITS}{@link #AL_CHANNELS CHANNELS}{@link #AL_SIZE SIZE}
+ */ + @NativeType("ALvoid") + public static int alGetBufferi(@NativeType("ALuint") int bufferName, @NativeType("ALenum") int paramName) { + MemoryStack stack = stackGet(); int stackPointer = stack.getPointer(); + try { + IntBuffer value = stack.callocInt(1); + nalGetBufferi(bufferName, paramName, memAddress(value)); + return value.get(0); + } finally { + stack.setPointer(stackPointer); + } + } + + // --- [ alBufferData ] --- + + /** + * Unsafe version of: {@link #alBufferData BufferData} + * + * @param size the data buffer size, in bytes + */ + public static void nalBufferData(int bufferName, int format, long data, int size, int frequency) { + long __functionAddress = AL.getICD().alBufferData; + invokePV(bufferName, format, data, size, frequency, __functionAddress); + } + + /** + * Sets the sample data of the specified buffer. + * + *

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.

+ * + *

8-bit data is expressed as an unsigned value over the range 0 to 255, 128 being an audio output level of zero.

+ * + *

16-bit data is expressed as a signed value over the range -32768 to 32767, 0 being an audio output level of zero. Byte order for 16-bit values is + * determined by the native format of the CPU.

+ * + *

Stereo data is expressed in an interleaved format, left channel sample followed by the right channel sample.

+ * + *

Buffers containing audio data with more than one channel will be played without 3D spatialization features – these formats are normally used for + * background music.

+ * + * @param bufferName the buffer to modify + * @param format the data format. One of:
{@link #AL_FORMAT_MONO8 FORMAT_MONO8}{@link #AL_FORMAT_MONO16 FORMAT_MONO16}{@link #AL_FORMAT_STEREO8 FORMAT_STEREO8}{@link #AL_FORMAT_STEREO16 FORMAT_STEREO16}
+ * @param data the sample data + * @param frequency the data frequency + */ + @NativeType("ALvoid") + public static void alBufferData(@NativeType("ALuint") int bufferName, @NativeType("ALenum") int format, @NativeType("ALvoid const *") ByteBuffer data, @NativeType("ALsizei") int frequency) { + nalBufferData(bufferName, format, memAddress(data), data.remaining(), frequency); + } + + /** + * Sets the sample data of the specified buffer. + * + *

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.

+ * + *

8-bit data is expressed as an unsigned value over the range 0 to 255, 128 being an audio output level of zero.

+ * + *

16-bit data is expressed as a signed value over the range -32768 to 32767, 0 being an audio output level of zero. Byte order for 16-bit values is + * determined by the native format of the CPU.

+ * + *

Stereo data is expressed in an interleaved format, left channel sample followed by the right channel sample.

+ * + *

Buffers containing audio data with more than one channel will be played without 3D spatialization features – these formats are normally used for + * background music.

+ * + * @param bufferName the buffer to modify + * @param format the data format. One of:
{@link #AL_FORMAT_MONO8 FORMAT_MONO8}{@link #AL_FORMAT_MONO16 FORMAT_MONO16}{@link #AL_FORMAT_STEREO8 FORMAT_STEREO8}{@link #AL_FORMAT_STEREO16 FORMAT_STEREO16}
+ * @param data the sample data + * @param frequency the data frequency + */ + @NativeType("ALvoid") + public static void alBufferData(@NativeType("ALuint") int bufferName, @NativeType("ALenum") int format, @NativeType("ALvoid const *") ShortBuffer data, @NativeType("ALsizei") int frequency) { + nalBufferData(bufferName, format, memAddress(data), data.remaining() << 1, frequency); + } + + /** + * Sets the sample data of the specified buffer. + * + *

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.

+ * + *

8-bit data is expressed as an unsigned value over the range 0 to 255, 128 being an audio output level of zero.

+ * + *

16-bit data is expressed as a signed value over the range -32768 to 32767, 0 being an audio output level of zero. Byte order for 16-bit values is + * determined by the native format of the CPU.

+ * + *

Stereo data is expressed in an interleaved format, left channel sample followed by the right channel sample.

+ * + *

Buffers containing audio data with more than one channel will be played without 3D spatialization features – these formats are normally used for + * background music.

+ * + * @param bufferName the buffer to modify + * @param format the data format. One of:
{@link #AL_FORMAT_MONO8 FORMAT_MONO8}{@link #AL_FORMAT_MONO16 FORMAT_MONO16}{@link #AL_FORMAT_STEREO8 FORMAT_STEREO8}{@link #AL_FORMAT_STEREO16 FORMAT_STEREO16}
+ * @param data the sample data + * @param frequency the data frequency + */ + @NativeType("ALvoid") + public static void alBufferData(@NativeType("ALuint") int bufferName, @NativeType("ALenum") int format, @NativeType("ALvoid const *") IntBuffer data, @NativeType("ALsizei") int frequency) { + nalBufferData(bufferName, format, memAddress(data), data.remaining() << 2, frequency); + } + + /** + * Sets the sample data of the specified buffer. + * + *

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.

+ * + *

8-bit data is expressed as an unsigned value over the range 0 to 255, 128 being an audio output level of zero.

+ * + *

16-bit data is expressed as a signed value over the range -32768 to 32767, 0 being an audio output level of zero. Byte order for 16-bit values is + * determined by the native format of the CPU.

+ * + *

Stereo data is expressed in an interleaved format, left channel sample followed by the right channel sample.

+ * + *

Buffers containing audio data with more than one channel will be played without 3D spatialization features – these formats are normally used for + * background music.

+ * + * @param bufferName the buffer to modify + * @param format the data format. One of:
{@link #AL_FORMAT_MONO8 FORMAT_MONO8}{@link #AL_FORMAT_MONO16 FORMAT_MONO16}{@link #AL_FORMAT_STEREO8 FORMAT_STEREO8}{@link #AL_FORMAT_STEREO16 FORMAT_STEREO16}
+ * @param data the sample data + * @param frequency the data frequency + */ + @NativeType("ALvoid") + public static void alBufferData(@NativeType("ALuint") int bufferName, @NativeType("ALenum") int format, @NativeType("ALvoid const *") FloatBuffer data, @NativeType("ALsizei") int frequency) { + nalBufferData(bufferName, format, memAddress(data), data.remaining() << 2, frequency); + } + + // --- [ alGetEnumValue ] --- + + /** Unsafe version of: {@link #alGetEnumValue GetEnumValue} */ + public static int nalGetEnumValue(long enumName) { + long __functionAddress = AL.getICD().alGetEnumValue; + return invokePI(enumName, __functionAddress); + } + + /** + * Returns the enumeration value of the specified enum. + * + * @param enumName the enum name + */ + @NativeType("ALuint") + public static int alGetEnumValue(@NativeType("ALchar const *") ByteBuffer enumName) { + if (CHECKS) { + checkNT1(enumName); + } + return nalGetEnumValue(memAddress(enumName)); + } + + /** + * Returns the enumeration value of the specified enum. + * + * @param enumName the enum name + */ + @NativeType("ALuint") + public static int alGetEnumValue(@NativeType("ALchar const *") CharSequence enumName) { + MemoryStack stack = stackGet(); int stackPointer = stack.getPointer(); + try { + stack.nASCII(enumName, true); + long enumNameEncoded = stack.getPointerAddress(); + return nalGetEnumValue(enumNameEncoded); + } finally { + stack.setPointer(stackPointer); + } + } + + // --- [ alGetProcAddress ] --- + + /** Unsafe version of: {@link #alGetProcAddress GetProcAddress} */ + public static long nalGetProcAddress(long funcName) { + long __functionAddress = AL.getICD().alGetProcAddress; + return invokePP(funcName, __functionAddress); + } + + /** + * Retrieves extension entry points. + * + *

Returns {@code NULL} if no entry point with the name funcName can be found. Implementations are free to return {@code NULL} if an entry point is present, but not + * applicable for the current context. However the specification does not guarantee this behavior.

+ * + *

Applications can use alGetProcAddress to obtain core API entry points, not just extensions. This is the recommended way to dynamically load and unload + * OpenAL DLL's as sound drivers.

+ * + * @param funcName the function name + */ + @NativeType("void *") + public static long alGetProcAddress(@NativeType("ALchar const *") ByteBuffer funcName) { + if (CHECKS) { + checkNT1(funcName); + } + return nalGetProcAddress(memAddress(funcName)); + } + + /** + * Retrieves extension entry points. + * + *

Returns {@code NULL} if no entry point with the name funcName can be found. Implementations are free to return {@code NULL} if an entry point is present, but not + * applicable for the current context. However the specification does not guarantee this behavior.

+ * + *

Applications can use alGetProcAddress to obtain core API entry points, not just extensions. This is the recommended way to dynamically load and unload + * OpenAL DLL's as sound drivers.

+ * + * @param funcName the function name + */ + @NativeType("void *") + public static long alGetProcAddress(@NativeType("ALchar const *") CharSequence funcName) { + MemoryStack stack = stackGet(); int stackPointer = stack.getPointer(); + try { + stack.nASCII(funcName, true); + long funcNameEncoded = stack.getPointerAddress(); + return nalGetProcAddress(funcNameEncoded); + } finally { + stack.setPointer(stackPointer); + } + } + + // --- [ alIsExtensionPresent ] --- + + /** Unsafe version of: {@link #alIsExtensionPresent IsExtensionPresent} */ + public static boolean nalIsExtensionPresent(long extName) { + long __functionAddress = AL.getICD().alIsExtensionPresent; + return invokePZ(extName, __functionAddress); + } + + /** + * Verifies that a given extension is available for the current context and the device it is associated with. + * + *

Invalid and unsupported string tokens return ALC_FALSE. {@code extName} is not case sensitive – the implementation will convert the name to all + * upper-case internally (and will express extension names in upper-case).

+ * + * @param extName the extension name + */ + @NativeType("ALCboolean") + public static boolean alIsExtensionPresent(@NativeType("ALchar const *") ByteBuffer extName) { + if (CHECKS) { + checkNT1(extName); + } + return nalIsExtensionPresent(memAddress(extName)); + } + + /** + * Verifies that a given extension is available for the current context and the device it is associated with. + * + *

Invalid and unsupported string tokens return ALC_FALSE. {@code extName} is not case sensitive – the implementation will convert the name to all + * upper-case internally (and will express extension names in upper-case).

+ * + * @param extName the extension name + */ + @NativeType("ALCboolean") + public static boolean alIsExtensionPresent(@NativeType("ALchar const *") CharSequence extName) { + MemoryStack stack = stackGet(); int stackPointer = stack.getPointer(); + try { + stack.nASCII(extName, true); + long extNameEncoded = stack.getPointerAddress(); + return nalIsExtensionPresent(extNameEncoded); + } finally { + stack.setPointer(stackPointer); + } + } + + /** Array version of: {@link #alGetIntegerv GetIntegerv} */ + @NativeType("ALvoid") + public static void alGetIntegerv(@NativeType("ALenum") int paramName, @NativeType("ALint *") int[] dest) { + long __functionAddress = AL.getICD().alGetIntegerv; + if (CHECKS) { + check(dest, 1); + } + invokePV(paramName, dest, __functionAddress); + } + + /** Array version of: {@link #alGetFloatv GetFloatv} */ + @NativeType("ALvoid") + public static void alGetFloatv(@NativeType("ALenum") int paramName, @NativeType("ALfloat *") float[] dest) { + long __functionAddress = AL.getICD().alGetFloatv; + if (CHECKS) { + check(dest, 1); + } + invokePV(paramName, dest, __functionAddress); + } + + /** Array version of: {@link #alGetDoublev GetDoublev} */ + @NativeType("ALvoid") + public static void alGetDoublev(@NativeType("ALenum") int paramName, @NativeType("ALdouble *") double[] dest) { + long __functionAddress = AL.getICD().alGetDoublev; + if (CHECKS) { + check(dest, 1); + } + invokePV(paramName, dest, __functionAddress); + } + + /** Array version of: {@link #alListenerfv Listenerfv} */ + @NativeType("ALvoid") + public static void alListenerfv(@NativeType("ALenum") int paramName, @NativeType("ALfloat const *") float[] values) { + long __functionAddress = AL.getICD().alListenerfv; + if (CHECKS) { + check(values, 1); + } + invokePV(paramName, values, __functionAddress); + } + + /** Array version of: {@link #alGetListenerf GetListenerf} */ + @NativeType("ALvoid") + public static void alGetListenerf(@NativeType("ALenum") int paramName, @NativeType("ALfloat *") float[] value) { + long __functionAddress = AL.getICD().alGetListenerf; + if (CHECKS) { + check(value, 1); + } + invokePV(paramName, value, __functionAddress); + } + + /** Array version of: {@link #alGetListeneri GetListeneri} */ + @NativeType("ALvoid") + public static void alGetListeneri(@NativeType("ALenum") int paramName, @NativeType("ALint *") int[] value) { + long __functionAddress = AL.getICD().alGetListeneri; + if (CHECKS) { + check(value, 1); + } + invokePV(paramName, value, __functionAddress); + } + + /** Array version of: {@link #alGetListener3f GetListener3f} */ + @NativeType("ALvoid") + public static void alGetListener3f(@NativeType("ALenum") int paramName, @NativeType("ALfloat *") float[] value1, @NativeType("ALfloat *") float[] value2, @NativeType("ALfloat *") float[] value3) { + long __functionAddress = AL.getICD().alGetListener3f; + if (CHECKS) { + check(value1, 1); + check(value2, 1); + check(value3, 1); + } + invokePPPV(paramName, value1, value2, value3, __functionAddress); + } + + /** Array version of: {@link #alGetListenerfv GetListenerfv} */ + @NativeType("ALvoid") + public static void alGetListenerfv(@NativeType("ALenum") int paramName, @NativeType("ALfloat *") float[] values) { + long __functionAddress = AL.getICD().alGetListenerfv; + if (CHECKS) { + check(values, 1); + } + invokePV(paramName, values, __functionAddress); + } + + /** Array version of: {@link #alGenSources GenSources} */ + @NativeType("ALvoid") + public static void alGenSources(@NativeType("ALuint *") int[] srcNames) { + long __functionAddress = AL.getICD().alGenSources; + invokePV(srcNames.length, srcNames, __functionAddress); + } + + /** Array version of: {@link #alDeleteSources DeleteSources} */ + @NativeType("ALvoid") + public static void alDeleteSources(@NativeType("ALuint *") int[] sources) { + long __functionAddress = AL.getICD().alDeleteSources; + invokePV(sources.length, sources, __functionAddress); + } + + /** Array version of: {@link #alSourcefv Sourcefv} */ + @NativeType("ALvoid") + public static void alSourcefv(@NativeType("ALuint") int source, @NativeType("ALenum") int param, @NativeType("ALfloat const *") float[] values) { + long __functionAddress = AL.getICD().alSourcefv; + if (CHECKS) { + check(values, 1); + } + invokePV(source, param, values, __functionAddress); + } + + /** Array version of: {@link #alGetSourcef GetSourcef} */ + @NativeType("ALvoid") + public static void alGetSourcef(@NativeType("ALuint") int source, @NativeType("ALenum") int param, @NativeType("ALfloat *") float[] value) { + long __functionAddress = AL.getICD().alGetSourcef; + if (CHECKS) { + check(value, 1); + } + invokePV(source, param, value, __functionAddress); + } + + /** Array version of: {@link #alGetSource3f GetSource3f} */ + @NativeType("ALvoid") + public static void alGetSource3f(@NativeType("ALuint") int source, @NativeType("ALenum") int param, @NativeType("ALfloat *") float[] v1, @NativeType("ALfloat *") float[] v2, @NativeType("ALfloat *") float[] v3) { + long __functionAddress = AL.getICD().alGetSource3f; + if (CHECKS) { + check(v1, 1); + check(v2, 1); + check(v3, 1); + } + invokePPPV(source, param, v1, v2, v3, __functionAddress); + } + + /** Array version of: {@link #alGetSourcefv GetSourcefv} */ + @NativeType("ALvoid") + public static void alGetSourcefv(@NativeType("ALuint") int source, @NativeType("ALenum") int param, @NativeType("ALfloat *") float[] values) { + long __functionAddress = AL.getICD().alGetSourcefv; + if (CHECKS) { + check(values, 1); + } + invokePV(source, param, values, __functionAddress); + } + + /** Array version of: {@link #alGetSourcei GetSourcei} */ + @NativeType("ALvoid") + public static void alGetSourcei(@NativeType("ALuint") int source, @NativeType("ALenum") int param, @NativeType("ALint *") int[] value) { + long __functionAddress = AL.getICD().alGetSourcei; + if (CHECKS) { + check(value, 1); + } + invokePV(source, param, value, __functionAddress); + } + + /** Array version of: {@link #alGetSourceiv GetSourceiv} */ + @NativeType("ALvoid") + public static void alGetSourceiv(@NativeType("ALuint") int source, @NativeType("ALenum") int param, @NativeType("ALint *") int[] values) { + long __functionAddress = AL.getICD().alGetSourceiv; + if (CHECKS) { + check(values, 1); + } + invokePV(source, param, values, __functionAddress); + } + + /** Array version of: {@link #alSourceQueueBuffers SourceQueueBuffers} */ + @NativeType("ALvoid") + public static void alSourceQueueBuffers(@NativeType("ALuint") int sourceName, @NativeType("ALuint *") int[] bufferNames) { + long __functionAddress = AL.getICD().alSourceQueueBuffers; + invokePV(sourceName, bufferNames.length, bufferNames, __functionAddress); + } + + /** Array version of: {@link #alSourceUnqueueBuffers SourceUnqueueBuffers} */ + @NativeType("ALvoid") + public static void alSourceUnqueueBuffers(@NativeType("ALuint") int sourceName, @NativeType("ALuint *") int[] bufferNames) { + long __functionAddress = AL.getICD().alSourceUnqueueBuffers; + invokePV(sourceName, bufferNames.length, bufferNames, __functionAddress); + } + + /** Array version of: {@link #alSourcePlayv SourcePlayv} */ + @NativeType("ALvoid") + public static void alSourcePlayv(@NativeType("ALuint const *") int[] sources) { + long __functionAddress = AL.getICD().alSourcePlayv; + invokePV(sources.length, sources, __functionAddress); + } + + /** Array version of: {@link #alSourcePausev SourcePausev} */ + @NativeType("ALvoid") + public static void alSourcePausev(@NativeType("ALuint const *") int[] sources) { + long __functionAddress = AL.getICD().alSourcePausev; + invokePV(sources.length, sources, __functionAddress); + } + + /** Array version of: {@link #alSourceStopv SourceStopv} */ + @NativeType("ALvoid") + public static void alSourceStopv(@NativeType("ALuint const *") int[] sources) { + long __functionAddress = AL.getICD().alSourceStopv; + invokePV(sources.length, sources, __functionAddress); + } + + /** Array version of: {@link #alSourceRewindv SourceRewindv} */ + @NativeType("ALvoid") + public static void alSourceRewindv(@NativeType("ALuint const *") int[] sources) { + long __functionAddress = AL.getICD().alSourceRewindv; + invokePV(sources.length, sources, __functionAddress); + } + + /** Array version of: {@link #alGenBuffers GenBuffers} */ + @NativeType("ALvoid") + public static void alGenBuffers(@NativeType("ALuint *") int[] bufferNames) { + long __functionAddress = AL.getICD().alGenBuffers; + invokePV(bufferNames.length, bufferNames, __functionAddress); + } + + /** Array version of: {@link #alDeleteBuffers DeleteBuffers} */ + @NativeType("ALvoid") + public static void alDeleteBuffers(@NativeType("ALuint const *") int[] bufferNames) { + long __functionAddress = AL.getICD().alDeleteBuffers; + invokePV(bufferNames.length, bufferNames, __functionAddress); + } + + /** Array version of: {@link #alGetBufferf GetBufferf} */ + @NativeType("ALvoid") + public static void alGetBufferf(@NativeType("ALuint") int bufferName, @NativeType("ALenum") int paramName, @NativeType("ALfloat *") float[] value) { + long __functionAddress = AL.getICD().alGetBufferf; + if (CHECKS) { + check(value, 1); + } + invokePV(bufferName, paramName, value, __functionAddress); + } + + /** Array version of: {@link #alGetBufferi GetBufferi} */ + @NativeType("ALvoid") + public static void alGetBufferi(@NativeType("ALuint") int bufferName, @NativeType("ALenum") int paramName, @NativeType("ALint *") int[] value) { + long __functionAddress = AL.getICD().alGetBufferi; + if (CHECKS) { + check(value, 1); + } + invokePV(bufferName, paramName, value, __functionAddress); + } + + /** Array version of: {@link #alBufferData BufferData} */ + @NativeType("ALvoid") + public static void alBufferData(@NativeType("ALuint") int bufferName, @NativeType("ALenum") int format, @NativeType("ALvoid const *") short[] data, @NativeType("ALsizei") int frequency) { + long __functionAddress = AL.getICD().alBufferData; + invokePV(bufferName, format, data, data.length << 1, frequency, __functionAddress); + } + + /** Array version of: {@link #alBufferData BufferData} */ + @NativeType("ALvoid") + public static void alBufferData(@NativeType("ALuint") int bufferName, @NativeType("ALenum") int format, @NativeType("ALvoid const *") int[] data, @NativeType("ALsizei") int frequency) { + long __functionAddress = AL.getICD().alBufferData; + invokePV(bufferName, format, data, data.length << 2, frequency, __functionAddress); + } + + /** Array version of: {@link #alBufferData BufferData} */ + @NativeType("ALvoid") + public static void alBufferData(@NativeType("ALuint") int bufferName, @NativeType("ALenum") int format, @NativeType("ALvoid const *") float[] data, @NativeType("ALsizei") int frequency) { + long __functionAddress = AL.getICD().alBufferData; + invokePV(bufferName, format, data, data.length << 2, frequency, __functionAddress); + } + +} diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/openal/ALC10.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/openal/ALC10.java new file mode 100644 index 000000000..5d52edd3f --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/openal/ALC10.java @@ -0,0 +1,530 @@ +/* + * Copyright LWJGL. All rights reserved. + * License terms: https://www.lwjgl.org/license + * MACHINE GENERATED FILE, DO NOT EDIT + */ +package org.lwjgl.openal; + +import javax.annotation.*; + +import java.nio.*; + +import org.lwjgl.system.*; + +import static org.lwjgl.system.Checks.*; +import static org.lwjgl.system.JNI.*; +import static org.lwjgl.system.MemoryStack.*; +import static org.lwjgl.system.MemoryUtil.*; + +/** Native bindings to ALC 1.0 functionality. */ +public class ALC10 { + + /** General tokens. */ + public static final int + ALC_INVALID = 0xFFFFFFFF, + ALC_FALSE = 0x0, + ALC_TRUE = 0x1; + + /** Context creation attributes. */ + public static final int + ALC_FREQUENCY = 0x1007, + ALC_REFRESH = 0x1008, + ALC_SYNC = 0x1009; + + /** Error conditions. */ + public static final int + ALC_NO_ERROR = 0x0, + ALC_INVALID_DEVICE = 0xA001, + ALC_INVALID_CONTEXT = 0xA002, + ALC_INVALID_ENUM = 0xA003, + ALC_INVALID_VALUE = 0xA004, + ALC_OUT_OF_MEMORY = 0xA005; + + /** String queries. */ + public static final int + ALC_DEFAULT_DEVICE_SPECIFIER = 0x1004, + ALC_DEVICE_SPECIFIER = 0x1005, + ALC_EXTENSIONS = 0x1006; + + /** Integer queries. */ + public static final int + ALC_MAJOR_VERSION = 0x1000, + ALC_MINOR_VERSION = 0x1001, + ALC_ATTRIBUTES_SIZE = 0x1002, + ALC_ALL_ATTRIBUTES = 0x1003; + + protected ALC10() { + throw new UnsupportedOperationException(); + } + + static boolean isAvailable(ALCCapabilities caps) { + return checkFunctions( + caps.alcOpenDevice, caps.alcCloseDevice, caps.alcCreateContext, caps.alcMakeContextCurrent, caps.alcProcessContext, caps.alcSuspendContext, + caps.alcDestroyContext, caps.alcGetCurrentContext, caps.alcGetContextsDevice, caps.alcIsExtensionPresent, caps.alcGetProcAddress, + caps.alcGetEnumValue, caps.alcGetError, caps.alcGetString, caps.alcGetIntegerv + ); + } + +// -- Begin LWJGL2 -- + static ALCcontext alcContext; + + public static ALCcontext alcCreateContext(ALCdevice device, java.nio.IntBuffer attrList) { + long alContextHandle = alcCreateContext(device.device, attrList); + alcContext = new ALCcontext(alContextHandle); + return alcContext; + } + + // FIXME if Minecraft 1.12.2 and below crashes here! +/* + public static ALCcontext alcGetCurrentContext() { + return alcContext; + } +*/ + public static ALCdevice alcGetContextsDevice(ALCcontext context) { + return AL.alcDevice; + } + + public static void alcGetInteger(ALCdevice device, int pname, java.nio.IntBuffer integerdata) { + int res = alcGetInteger(device.device, pname); + integerdata.put(0, res); + } +// -- End LWJGL2 -- + + // --- [ alcOpenDevice ] --- + + /** Unsafe version of: {@link #alcOpenDevice OpenDevice} */ + public static long nalcOpenDevice(long deviceSpecifier) { + long __functionAddress = ALC.getICD().alcOpenDevice; + return invokePP(deviceSpecifier, __functionAddress); + } + + /** + * Allows the application to connect to a device. + * + *

If the function returns {@code 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 {@code NULL} is specified, the implementation will provide an implementation specific default.

+ * + * @param deviceSpecifier the requested device or device configuration + */ + @NativeType("ALCdevice *") + public static long alcOpenDevice(@Nullable @NativeType("ALCchar const *") ByteBuffer deviceSpecifier) { + if (CHECKS) { + checkNT1Safe(deviceSpecifier); + } + return nalcOpenDevice(memAddressSafe(deviceSpecifier)); + } + + /** + * Allows the application to connect to a device. + * + *

If the function returns {@code 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 {@code NULL} is specified, the implementation will provide an implementation specific default.

+ * + * @param deviceSpecifier the requested device or device configuration + */ + @NativeType("ALCdevice *") + public static long alcOpenDevice(@Nullable @NativeType("ALCchar const *") CharSequence deviceSpecifier) { + MemoryStack stack = stackGet(); int stackPointer = stack.getPointer(); + try { + stack.nUTF8Safe(deviceSpecifier, true); + long deviceSpecifierEncoded = deviceSpecifier == null ? NULL : stack.getPointerAddress(); + return nalcOpenDevice(deviceSpecifierEncoded); + } finally { + stack.setPointer(stackPointer); + } + } + + // --- [ alcCloseDevice ] --- + + /** + * Allows the application to disconnect from a device. + * + *

The return code will be ALC_TRUE or ALC_FALSE, indicating success or failure. Failure will occur if all the device's contexts and buffers have not been + * destroyed. Once closed, the {@code deviceHandle} is invalid.

+ * + * @param deviceHandle the device to close + */ + @NativeType("ALCboolean") + public static boolean alcCloseDevice(@NativeType("ALCdevice const *") long deviceHandle) { + long __functionAddress = ALC.getICD().alcCloseDevice; + if (CHECKS) { + check(deviceHandle); + } + return invokePZ(deviceHandle, __functionAddress); + } + + // --- [ alcCreateContext ] --- + + /** Unsafe version of: {@link #alcCreateContext CreateContext} */ + public static long nalcCreateContext(long deviceHandle, long attrList) { + long __functionAddress = ALC.getICD().alcCreateContext; + if (CHECKS) { + check(deviceHandle); + } + return invokePPP(deviceHandle, attrList, __functionAddress); + } + + /** + * Creates an AL context. + * + * @param deviceHandle a valid device + * @param attrList null or a zero terminated list of integer pairs composed of valid ALC attribute tokens and requested values. One of:
{@link #ALC_FREQUENCY FREQUENCY}{@link #ALC_REFRESH REFRESH}{@link #ALC_SYNC SYNC}{@link ALC11#ALC_MONO_SOURCES MONO_SOURCES}{@link ALC11#ALC_STEREO_SOURCES STEREO_SOURCES}
+ */ + @NativeType("ALCcontext *") + public static long alcCreateContext(@NativeType("ALCdevice const *") long deviceHandle, @Nullable @NativeType("ALCint const *") IntBuffer attrList) { + if (CHECKS) { + checkNTSafe(attrList); + } + return nalcCreateContext(deviceHandle, memAddressSafe(attrList)); + } + + // --- [ alcMakeContextCurrent ] --- + + /** + * Makes a context current with respect to OpenAL operation. + * + *

The context parameter can be {@code NULL} or a valid context pointer. Using {@code NULL} results in no context being current, which is useful when shutting OpenAL down. + * 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 the context to make current + */ + @NativeType("ALCboolean") + public static boolean alcMakeContextCurrent(@NativeType("ALCcontext *") long context) { + long __functionAddress = ALC.getICD().alcMakeContextCurrent; + return invokePZ(context, __functionAddress); + } + + // --- [ alcProcessContext ] --- + + /** + * 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 such as the + * offset increments are to be performed), the application uses {@code 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 processing.

+ * + * @param context the context to mark for processing + */ + @NativeType("ALCvoid") + public static void alcProcessContext(@NativeType("ALCcontext *") long context) { + long __functionAddress = ALC.getICD().alcProcessContext; + if (CHECKS) { + check(context); + } + invokePV(context, __functionAddress); + } + + // --- [ alcSuspendContext ] --- + + /** + * 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 such as offset increments are not to be changed), the application uses {@code alcSuspendContext}. + * + *

Repeated calls to alcSuspendContext are legal, and do not affect a context that is already marked as suspended.

+ * + * @param context the context to mark as suspended + */ + @NativeType("ALCvoid") + public static void alcSuspendContext(@NativeType("ALCcontext *") long context) { + long __functionAddress = ALC.getICD().alcSuspendContext; + if (CHECKS) { + check(context); + } + invokePV(context, __functionAddress); + } + + // --- [ alcDestroyContext ] --- + + /** + * Destroys a context. + * + *

The correct way to destroy a context is to first release it using alcMakeCurrent with a {@code NULL} context. Applications should not attempt to destroy a + * current context – doing so will not work and will result in an ALC_INVALID_OPERATION error. All sources within a context will automatically be deleted + * during context destruction.

+ * + * @param context the context to destroy + */ + @NativeType("ALCvoid") + public static void alcDestroyContext(@NativeType("ALCcontext *") long context) { + long __functionAddress = ALC.getICD().alcDestroyContext; + if (CHECKS) { + check(context); + } + invokePV(context, __functionAddress); + } + + // --- [ alcGetCurrentContext ] --- + + /** Queries for, and obtains a handle to, the current context for the application. If there is no current context, {@code NULL} is returned. */ + @NativeType("ALCcontext *") + public static long alcGetCurrentContext() { + long __functionAddress = ALC.getICD().alcGetCurrentContext; + return invokeP(__functionAddress); + } + + // --- [ alcGetContextsDevice ] --- + + /** + * Queries for, and obtains a handle to, the device of a given context. + * + * @param context the context to query + */ + @NativeType("ALCdevice *") + public static long alcGetContextsDevice(@NativeType("ALCcontext *") long context) { + long __functionAddress = ALC.getICD().alcGetContextsDevice; + if (CHECKS) { + check(context); + } + return invokePP(context, __functionAddress); + } + + // --- [ alcIsExtensionPresent ] --- + + /** Unsafe version of: {@link #alcIsExtensionPresent IsExtensionPresent} */ + public static boolean nalcIsExtensionPresent(long deviceHandle, long extName) { + long __functionAddress = ALC.getICD().alcIsExtensionPresent; + return invokePPZ(deviceHandle, extName, __functionAddress); + } + + /** + * Verifies that a given extension is available for the current context and the device it is associated with. + * + *

Invalid and unsupported string tokens return ALC_FALSE. A {@code NULL} deviceHandle is acceptable. {@code extName} is not case sensitive – the implementation + * will convert the name to all upper-case internally (and will express extension names in upper-case).

+ * + * @param deviceHandle the device to query + * @param extName the extension name + */ + @NativeType("ALCboolean") + public static boolean alcIsExtensionPresent(@NativeType("ALCdevice const *") long deviceHandle, @NativeType("ALCchar const *") ByteBuffer extName) { + if (CHECKS) { + checkNT1(extName); + } + return nalcIsExtensionPresent(deviceHandle, memAddress(extName)); + } + + /** + * Verifies that a given extension is available for the current context and the device it is associated with. + * + *

Invalid and unsupported string tokens return ALC_FALSE. A {@code NULL} deviceHandle is acceptable. {@code extName} is not case sensitive – the implementation + * will convert the name to all upper-case internally (and will express extension names in upper-case).

+ * + * @param deviceHandle the device to query + * @param extName the extension name + */ + @NativeType("ALCboolean") + public static boolean alcIsExtensionPresent(@NativeType("ALCdevice const *") long deviceHandle, @NativeType("ALCchar const *") CharSequence extName) { + MemoryStack stack = stackGet(); int stackPointer = stack.getPointer(); + try { + stack.nASCII(extName, true); + long extNameEncoded = stack.getPointerAddress(); + return nalcIsExtensionPresent(deviceHandle, extNameEncoded); + } finally { + stack.setPointer(stackPointer); + } + } + + // --- [ alcGetProcAddress ] --- + + /** Unsafe version of: {@link #alcGetProcAddress GetProcAddress} */ + public static long nalcGetProcAddress(long deviceHandle, long funcName) { + long __functionAddress = ALC.getICD().alcGetProcAddress; + return invokePPP(deviceHandle, funcName, __functionAddress); + } + + /** + * Retrieves extension entry points. + * + *

The application is expected to verify the applicability of an extension or core function entry point before requesting it by name, by use of + * {@link #alcIsExtensionPresent IsExtensionPresent}.

+ * + *

Entry points can be device specific, but are not context specific. Using a {@code NULL} device handle does not guarantee that the entry point is returned, + * even if available for one of the available devices.

+ * + * @param deviceHandle the device to query + * @param funcName the function name + */ + @NativeType("void *") + public static long alcGetProcAddress(@NativeType("ALCdevice const *") long deviceHandle, @NativeType("ALchar const *") ByteBuffer funcName) { + if (CHECKS) { + checkNT1(funcName); + } + return nalcGetProcAddress(deviceHandle, memAddress(funcName)); + } + + /** + * Retrieves extension entry points. + * + *

The application is expected to verify the applicability of an extension or core function entry point before requesting it by name, by use of + * {@link #alcIsExtensionPresent IsExtensionPresent}.

+ * + *

Entry points can be device specific, but are not context specific. Using a {@code NULL} device handle does not guarantee that the entry point is returned, + * even if available for one of the available devices.

+ * + * @param deviceHandle the device to query + * @param funcName the function name + */ + @NativeType("void *") + public static long alcGetProcAddress(@NativeType("ALCdevice const *") long deviceHandle, @NativeType("ALchar const *") CharSequence funcName) { + MemoryStack stack = stackGet(); int stackPointer = stack.getPointer(); + try { + stack.nASCII(funcName, true); + long funcNameEncoded = stack.getPointerAddress(); + return nalcGetProcAddress(deviceHandle, funcNameEncoded); + } finally { + stack.setPointer(stackPointer); + } + } + + // --- [ alcGetEnumValue ] --- + + /** Unsafe version of: {@link #alcGetEnumValue GetEnumValue} */ + public static int nalcGetEnumValue(long deviceHandle, long enumName) { + long __functionAddress = ALC.getICD().alcGetEnumValue; + return invokePPI(deviceHandle, enumName, __functionAddress); + } + + /** + * Returns extension enum values. + * + *

Enumeration/token values are device independent, but tokens defined for extensions might not be present for a given device. Using a {@code NULL} handle is + * legal, but only the tokens defined by the AL core are guaranteed. Availability of extension tokens depends on the ALC extension.

+ * + * @param deviceHandle the device to query + * @param enumName the enum name + */ + @NativeType("ALCenum") + public static int alcGetEnumValue(@NativeType("ALCdevice const *") long deviceHandle, @NativeType("ALCchar const *") ByteBuffer enumName) { + if (CHECKS) { + checkNT1(enumName); + } + return nalcGetEnumValue(deviceHandle, memAddress(enumName)); + } + + /** + * Returns extension enum values. + * + *

Enumeration/token values are device independent, but tokens defined for extensions might not be present for a given device. Using a {@code NULL} handle is + * legal, but only the tokens defined by the AL core are guaranteed. Availability of extension tokens depends on the ALC extension.

+ * + * @param deviceHandle the device to query + * @param enumName the enum name + */ + @NativeType("ALCenum") + public static int alcGetEnumValue(@NativeType("ALCdevice const *") long deviceHandle, @NativeType("ALCchar const *") CharSequence enumName) { + MemoryStack stack = stackGet(); int stackPointer = stack.getPointer(); + try { + stack.nASCII(enumName, true); + long enumNameEncoded = stack.getPointerAddress(); + return nalcGetEnumValue(deviceHandle, enumNameEncoded); + } finally { + stack.setPointer(stackPointer); + } + } + + // --- [ alcGetError ] --- + + /** + * Queries ALC errors. + * + *

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).

+ * + *

Error conditions are specific to the device, and (like AL) a call to alcGetError resets the error state.

+ * + * @param deviceHandle the device to query + */ + @NativeType("ALCenum") + public static int alcGetError(@NativeType("ALCdevice *") long deviceHandle) { + long __functionAddress = ALC.getICD().alcGetError; + return invokePI(deviceHandle, __functionAddress); + } + + // --- [ alcGetString ] --- + + /** Unsafe version of: {@link #alcGetString GetString} */ + public static long nalcGetString(long deviceHandle, int token) { + long __functionAddress = ALC.getICD().alcGetString; + return invokePP(deviceHandle, token, __functionAddress); + } + + /** + * Obtains string value(s) from ALC. + * + *

LWJGL note: Use {@link ALUtil#getStringList} for those tokens that return multiple values.

+ * + * @param deviceHandle the device to query + * @param token the information to query. One of:
{@link #ALC_DEFAULT_DEVICE_SPECIFIER DEFAULT_DEVICE_SPECIFIER}{@link #ALC_DEVICE_SPECIFIER DEVICE_SPECIFIER}{@link #ALC_EXTENSIONS EXTENSIONS}
{@link ALC11#ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER CAPTURE_DEFAULT_DEVICE_SPECIFIER}{@link ALC11#ALC_CAPTURE_DEVICE_SPECIFIER CAPTURE_DEVICE_SPECIFIER}
+ */ + @Nullable + @NativeType("ALCchar const *") + public static String alcGetString(@NativeType("ALCdevice *") long deviceHandle, @NativeType("ALCenum") int token) { + long __result = nalcGetString(deviceHandle, token); + return memUTF8Safe(__result); + } + + // --- [ alcGetIntegerv ] --- + + /** + * Unsafe version of: {@link #alcGetIntegerv GetIntegerv} + * + * @param size the size of the {@code dest} buffer + */ + public static void nalcGetIntegerv(long deviceHandle, int token, int size, long dest) { + long __functionAddress = ALC.getICD().alcGetIntegerv; + invokePPV(deviceHandle, token, size, dest, __functionAddress); + } + + /** + * Obtains integer value(s) from ALC. + * + * @param deviceHandle the device to query + * @param token the information to query. One of:
{@link #ALC_MAJOR_VERSION MAJOR_VERSION}{@link #ALC_MINOR_VERSION MINOR_VERSION}{@link #ALC_ATTRIBUTES_SIZE ATTRIBUTES_SIZE}{@link #ALC_ALL_ATTRIBUTES ALL_ATTRIBUTES}{@link ALC11#ALC_CAPTURE_SAMPLES CAPTURE_SAMPLES}
+ * @param dest the destination buffer + */ + @NativeType("ALCvoid") + public static void alcGetIntegerv(@NativeType("ALCdevice *") long deviceHandle, @NativeType("ALCenum") int token, @NativeType("ALCint *") IntBuffer dest) { + nalcGetIntegerv(deviceHandle, token, dest.remaining(), memAddress(dest)); + } + + /** + * Obtains integer value(s) from ALC. + * + * @param deviceHandle the device to query + * @param token the information to query. One of:
{@link #ALC_MAJOR_VERSION MAJOR_VERSION}{@link #ALC_MINOR_VERSION MINOR_VERSION}{@link #ALC_ATTRIBUTES_SIZE ATTRIBUTES_SIZE}{@link #ALC_ALL_ATTRIBUTES ALL_ATTRIBUTES}{@link ALC11#ALC_CAPTURE_SAMPLES CAPTURE_SAMPLES}
+ */ + @NativeType("ALCvoid") + public static int alcGetInteger(@NativeType("ALCdevice *") long deviceHandle, @NativeType("ALCenum") int token) { + MemoryStack stack = stackGet(); int stackPointer = stack.getPointer(); + try { + IntBuffer dest = stack.callocInt(1); + nalcGetIntegerv(deviceHandle, token, 1, memAddress(dest)); + return dest.get(0); + } finally { + stack.setPointer(stackPointer); + } + } + + /** Array version of: {@link #alcCreateContext CreateContext} */ + @NativeType("ALCcontext *") + public static long alcCreateContext(@NativeType("ALCdevice const *") long deviceHandle, @Nullable @NativeType("ALCint const *") int[] attrList) { + long __functionAddress = ALC.getICD().alcCreateContext; + if (CHECKS) { + check(deviceHandle); + checkNTSafe(attrList); + } + return invokePPP(deviceHandle, attrList, __functionAddress); + } + + /** Array version of: {@link #alcGetIntegerv GetIntegerv} */ + @NativeType("ALCvoid") + public static void alcGetIntegerv(@NativeType("ALCdevice *") long deviceHandle, @NativeType("ALCenum") int token, @NativeType("ALCint *") int[] dest) { + long __functionAddress = ALC.getICD().alcGetIntegerv; + invokePPV(deviceHandle, token, dest.length, dest, __functionAddress); + } + +} diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/openal/ALCcontext.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/openal/ALCcontext.java new file mode 100644 index 000000000..2d99d4c1d --- /dev/null +++ b/jre_lwjgl3glfw/src/main/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$ + * $Id$ + */ +public final class ALCcontext { + + /** Address of actual context */ + final long context; + + /** Whether this context is valid */ + private boolean valid; + + /** + * 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/jre_lwjgl3glfw/src/main/java/org/lwjgl/openal/ALCdevice.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/openal/ALCdevice.java new file mode 100644 index 000000000..9cc06a97a --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/openal/ALCdevice.java @@ -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. + */ +package org.lwjgl.openal; + +import java.util.HashMap; + +/** + * 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$ + * $Id$ + */ +public final class ALCdevice { + + /** Address of actual device */ + final long device; + + /** Whether this device is valid */ + private boolean valid; + + /** List of contexts belonging to the device */ + private final 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(context.context, context); + } + } + + /** + * Remove context associated with device + * + * @param context Context to disassociate with device + */ + void removeContext(ALCcontext context) { + synchronized (contexts) { + contexts.remove(context.context); + } + } + + /** + * Marks this device and all of its contexts invalid + */ + void setInvalid() { + valid = false; + synchronized (contexts) { + for ( ALCcontext context : contexts.values() ) + context.setInvalid(); + } + contexts.clear(); + } + + /** + * @return true if this device is still valid + */ + public boolean isValid() { + return valid; + } +} diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/openal/EFX10.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/openal/EFX10.java new file mode 100644 index 000000000..b755b7c4d --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/openal/EFX10.java @@ -0,0 +1,143 @@ +package org.lwjgl.openal; + +import java.nio.IntBuffer; + +import org.lwjgl.openal.EXTEfx; + +public class EFX10 { + + public static final int AL_EFFECT_TYPE = EXTEfx.AL_EFFECT_TYPE; + public static final int AL_EFFECTSLOT_EFFECT = EXTEfx.AL_EFFECTSLOT_EFFECT; + public static final int AL_EFFECT_ECHO = EXTEfx.AL_EFFECT_ECHO; + public static final float AL_ECHO_MIN_DAMPING = EXTEfx.AL_ECHO_MIN_DAMPING; + public static final int AL_ECHO_DAMPING = EXTEfx.AL_ECHO_DAMPING; + public static final float AL_ECHO_MAX_DAMPING = EXTEfx.AL_ECHO_MAX_DAMPING; + public static final float AL_ECHO_MIN_DELAY = EXTEfx.AL_ECHO_MIN_DELAY; + public static final int AL_ECHO_DELAY = EXTEfx.AL_ECHO_DELAY; + public static final float AL_ECHO_MAX_DELAY = EXTEfx.AL_ECHO_MAX_DELAY; + public static final float AL_ECHO_MIN_FEEDBACK = EXTEfx.AL_ECHO_MIN_FEEDBACK; + public static final int AL_ECHO_FEEDBACK = EXTEfx.AL_ECHO_FEEDBACK; + public static final float AL_ECHO_MAX_FEEDBACK = EXTEfx.AL_ECHO_MAX_FEEDBACK; + public static final float AL_ECHO_MIN_LRDELAY = EXTEfx.AL_ECHO_MIN_LRDELAY; + public static final int AL_ECHO_LRDELAY = EXTEfx.AL_ECHO_LRDELAY; + public static final float AL_ECHO_MAX_LRDELAY = EXTEfx.AL_ECHO_MAX_LRDELAY; + public static final float AL_ECHO_MIN_SPREAD = EXTEfx.AL_ECHO_MIN_SPREAD; + public static final int AL_ECHO_SPREAD = EXTEfx.AL_ECHO_SPREAD; + public static final float AL_ECHO_MAX_SPREAD = EXTEfx.AL_ECHO_MAX_SPREAD; + public static final int AL_EFFECT_REVERB = EXTEfx.AL_EFFECT_REVERB; + public static final int AL_RING_MODULATOR_SINUSOID = EXTEfx.AL_RING_MODULATOR_SINUSOID; + public static final int AL_RING_MODULATOR_SAWTOOTH = EXTEfx.AL_RING_MODULATOR_SAWTOOTH; + public static final int AL_RING_MODULATOR_SQUARE = EXTEfx.AL_RING_MODULATOR_SQUARE; + public static final int AL_EFFECT_RING_MODULATOR = EXTEfx.AL_EFFECT_RING_MODULATOR; + public static final float AL_RING_MODULATOR_MAX_FREQUENCY = EXTEfx.AL_RING_MODULATOR_MAX_FREQUENCY; + public static final int AL_RING_MODULATOR_FREQUENCY = EXTEfx.AL_RING_MODULATOR_FREQUENCY; + public static final float AL_RING_MODULATOR_MIN_FREQUENCY = EXTEfx.AL_RING_MODULATOR_MIN_FREQUENCY; + public static final float AL_RING_MODULATOR_MAX_HIGHPASS_CUTOFF = EXTEfx.AL_RING_MODULATOR_MAX_HIGHPASS_CUTOFF; + public static final int AL_RING_MODULATOR_HIGHPASS_CUTOFF = EXTEfx.AL_RING_MODULATOR_HIGHPASS_CUTOFF; + public static final float AL_RING_MODULATOR_MIN_HIGHPASS_CUTOFF = EXTEfx.AL_RING_MODULATOR_MIN_HIGHPASS_CUTOFF; + public static final int AL_RING_MODULATOR_WAVEFORM = EXTEfx.AL_RING_MODULATOR_WAVEFORM; + public static final int AL_FILTER_TYPE = EXTEfx.AL_FILTER_TYPE; + public static final int AL_FILTER_LOWPASS = EXTEfx.AL_FILTER_LOWPASS; + public static final int AL_LOWPASS_GAIN = EXTEfx.AL_LOWPASS_GAIN; + public static final int AL_LOWPASS_GAINHF = EXTEfx.AL_LOWPASS_GAINHF; + public static final int AL_EFFECTSLOT_NULL = EXTEfx.AL_EFFECTSLOT_NULL; + public static final int AL_FILTER_NULL = EXTEfx.AL_FILTER_NULL; + public static final int AL_AUXILIARY_SEND_FILTER = EXTEfx.AL_AUXILIARY_SEND_FILTER; + public static final int AL_DIRECT_FILTER = EXTEfx.AL_DIRECT_FILTER; + public static final int ALC_MAX_AUXILIARY_SENDS = EXTEfx.ALC_MAX_AUXILIARY_SENDS; + public static final int ALC_EFX_MAJOR_VERSION = EXTEfx.ALC_EFX_MAJOR_VERSION; + public static final int AL_REVERB_DECAY_TIME = EXTEfx.AL_REVERB_DECAY_TIME; + public static final int AL_FILTER_HIGHPASS = EXTEfx.AL_FILTER_HIGHPASS; + public static final int AL_FILTER_BANDPASS = EXTEfx.AL_FILTER_BANDPASS; + public static final int AL_EFFECT_NULL = EXTEfx.AL_EFFECT_NULL; + public static final int AL_EFFECT_EAXREVERB = EXTEfx.AL_EFFECT_EAXREVERB; + public static final int AL_EFFECT_CHORUS = EXTEfx.AL_EFFECT_CHORUS; + public static final int AL_EFFECT_DISTORTION = EXTEfx.AL_EFFECT_DISTORTION; + public static final int AL_EFFECT_FLANGER = EXTEfx.AL_EFFECT_FLANGER; + public static final int AL_EFFECT_FREQUENCY_SHIFTER = EXTEfx.AL_EFFECT_FREQUENCY_SHIFTER; + public static final int AL_EFFECT_VOCAL_MORPHER = EXTEfx.AL_EFFECT_VOCAL_MORPHER; + public static final int AL_EFFECT_PITCH_SHIFTER = EXTEfx.AL_EFFECT_PITCH_SHIFTER; + public static final int AL_EFFECT_AUTOWAH = EXTEfx.AL_EFFECT_AUTOWAH; + public static final int AL_EFFECT_COMPRESSOR = EXTEfx.AL_EFFECT_COMPRESSOR; + public static final int AL_EFFECT_EQUALIZER = EXTEfx.AL_EFFECT_EQUALIZER; + + public static int alGenAuxiliaryEffectSlots() { + return EXTEfx.alGenAuxiliaryEffectSlots(); + } + + public static int alGenFilters() { + return EXTEfx.alGenFilters(); + } + + public static void alDeleteFilters(int filter) { + EXTEfx.alDeleteFilters(filter); + } + + public static void alFilteri(int filter, int param, int value) { + EXTEfx.alFilteri(filter, param, value); + } + + public static void alFilterf(int filter, int param, float value) { + EXTEfx.alFilterf(filter, param, value); + } + + public static float alGetFilterf(int filter, int param) { + return EXTEfx.alGetFilterf(filter, param); + } + + public static int alGenEffects() { + return EXTEfx.alGenEffects(); + } + + public static void alDeleteEffects(int effect) { + EXTEfx.alDeleteAuxiliaryEffectSlots(effect); + } + + public static void alDeleteAuxiliaryEffectSlots(int effectSlot) { + EXTEfx.alDeleteAuxiliaryEffectSlots(effectSlot); + } + + public static void alEffecti(int effect, int param, int value) { + EXTEfx.alEffecti(effect, param, value); + } + + public static float alGetEffectf(int effect, int param) { + return EXTEfx.alGetEffectf(effect, param); + } + + public static int alGetEffecti(int effect, int param) { + return EXTEfx.alGetEffecti(effect, param); + } + + public static void alEffectf(int effect, int param, float value) { + EXTEfx.alEffectf(effect, param, value); + } + + public static void alAuxiliaryEffectSloti(int effectSlot, int param, int value) { + EXTEfx.alAuxiliaryEffectSloti(effectSlot, param, value); + } + + public static void alGenAuxiliaryEffectSlots(IntBuffer effectSlots) { + EXTEfx.alGenAuxiliaryEffectSlots(effectSlots); + } + + public static void alGenEffects(IntBuffer effects) { + EXTEfx.alGenEffects(effects); + } + + public static void alDeleteEffects(IntBuffer effects) { + EXTEfx.alDeleteEffects(effects); + } + + public static void alDeleteAuxiliaryEffectSlots(IntBuffer effectSlots) { + EXTEfx.alDeleteAuxiliaryEffectSlots(effectSlots); + } + + public static void alGenFilters(IntBuffer filters) { + EXTEfx.alGenFilters(filters); + } + + public static void alDeleteFilters(IntBuffer filters) { + EXTEfx.alDeleteFilters(filters); + } +} diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/openal/EFXUtil.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/openal/EFXUtil.java new file mode 100644 index 000000000..57b4348cc --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/openal/EFXUtil.java @@ -0,0 +1,210 @@ +/* + * Copyright LWJGL. All rights reserved. + * License terms: http://lwjgl.org/license.php + */ +package org.lwjgl.openal; + +import static org.lwjgl.openal.AL10.*; +import static org.lwjgl.openal.EXTEfx.*; + +import org.lwjgl.openal.ALC; +import org.lwjgl.openal.ALCCapabilities; + +/** + * Utility class for the OpenAL extension AL_EXT_EFX. Provides functions to check for the extension + * and support of various effects and filters. + *

+ * Currently supports AL_EXT_EFX version 1.0 effects and filters. + * + * @author Ciardhubh + */ +public final class EFXUtil { + + /** Constant for testSupportGeneric to check an effect. */ + private static final int EFFECT = 1111; + /** Constant for testSupportGeneric to check a filter. */ + private static final int FILTER = 2222; + + /** Utility class, hidden contructor. */ + private EFXUtil() { + } + + /** + * Checks if OpenAL implementation is loaded and supports AL_EXT_EFX. + * + * @return True if AL_EXT_EFX is supported, false if not. + * + * @throws org.lwjgl.openal.OpenALException + * If OpenAL has not been created yet. + */ + public static boolean isEfxSupported() { + //return ALC.getCapabilities().ALC_EXT_EFX; + return ALC.createCapabilities(AL.alcDevice.device).ALC_EXT_EFX; + } + + /** + * Tests OpenAL to see whether the given effect type is supported. This is done by creating an + * effect of the given type. If creation succeeds the effect is supported. + * + * @param effectType Type of effect whose support is to be tested, e.g. AL_EFFECT_REVERB. + * + * @return True if it is supported, false if not. + * + * @throws org.lwjgl.openal.OpenALException + * If the request fails due to an AL_OUT_OF_MEMORY error or OpenAL has + * not been created yet. + * @throws IllegalArgumentException effectType is not a valid effect type. + */ + public static boolean isEffectSupported(int effectType) { + // Make sure type is a real effect. + switch ( effectType ) { + case AL_EFFECT_NULL: + case AL_EFFECT_EAXREVERB: + case AL_EFFECT_REVERB: + case AL_EFFECT_CHORUS: + case AL_EFFECT_DISTORTION: + case AL_EFFECT_ECHO: + case AL_EFFECT_FLANGER: + case AL_EFFECT_FREQUENCY_SHIFTER: + case AL_EFFECT_VOCAL_MORPHER: + case AL_EFFECT_PITCH_SHIFTER: + case AL_EFFECT_RING_MODULATOR: + case AL_EFFECT_AUTOWAH: + case AL_EFFECT_COMPRESSOR: + case AL_EFFECT_EQUALIZER: + break; + default: + throw new IllegalArgumentException("Unknown or invalid effect type: " + effectType); + } + + return testSupportGeneric(EFFECT, effectType); + } + + /** + * Tests OpenAL to see whether the given filter type is supported. This is done by creating a + * filter of the given type. If creation succeeds the filter is supported. + * + * @param filterType Type of filter whose support is to be tested, e.g. AL_FILTER_LOWPASS. + * + * @return True if it is supported, false if not. + * + * @throws org.lwjgl.openal.OpenALException + * If the request fails due to an AL_OUT_OF_MEMORY error or OpenAL has + * not been created yet. + * @throws IllegalArgumentException filterType is not a valid filter type. + */ + public static boolean isFilterSupported(int filterType) { + // Make sure type is a real filter. + switch ( filterType ) { + case AL_FILTER_NULL: + case AL_FILTER_LOWPASS: + case AL_FILTER_HIGHPASS: + case AL_FILTER_BANDPASS: + break; + default: + throw new IllegalArgumentException("Unknown or invalid filter type: " + filterType); + } + + return testSupportGeneric(FILTER, filterType); + } + + /** + * Generic test function to see if an EFX object supports a given kind of type. Works for + * effects and filters. + * + * @param objectType Type of object to test. Must be either EFXUtil.EFFECT or EFXUtil.FILTER. + * @param typeValue OpenAL type the object should be tested for support, e.g. AL_FILTER_LOWPASS + * or AL_EFFECT_REVERB. + * + * @return True if object supports typeValue, false else. + */ + private static boolean testSupportGeneric(int objectType, int typeValue) { + // Check for supported objectType. + switch ( objectType ) { + case EFFECT: + case FILTER: + break; + default: + throw new IllegalArgumentException("Invalid objectType: " + objectType); + } + + boolean supported = false; + if ( isEfxSupported() ) { + + // Try to create object in order to check AL's response. + alGetError(); + int genError; + int testObject = 0; + try { + switch ( objectType ) { // Create object based on type + case EFFECT: + testObject = alGenEffects(); + break; + case FILTER: + testObject = alGenFilters(); + break; + default: + throw new IllegalArgumentException("Invalid objectType: " + objectType); + } + genError = alGetError(); + } catch (OpenALException debugBuildException) { + // Hack because OpenALException hides the original error code (short of parsing the + // error message String which would break if it gets changed). + if ( debugBuildException.getMessage().contains("AL_OUT_OF_MEMORY") ) { + genError = AL_OUT_OF_MEMORY; + } else { + genError = AL_INVALID_OPERATION; + } + } + + if ( genError == AL_NO_ERROR ) { + // Successfully created, now try to set type. + alGetError(); + int setError; + try { + switch ( objectType ) { // Set based on object type + case EFFECT: + alEffecti(testObject, AL_EFFECT_TYPE, typeValue); + break; + case FILTER: + alFilteri(testObject, AL_FILTER_TYPE, typeValue); + break; + default: + throw new IllegalArgumentException("Invalid objectType: " + objectType); + } + setError = alGetError(); + } catch (OpenALException debugBuildException) { + // Hack because OpenALException hides the original error code (short of parsing + // the error message String which would break when it gets changed). + setError = AL_INVALID_VALUE; + } + + if ( setError == AL_NO_ERROR ) { + supported = true; + } + + // Cleanup + try { + switch ( objectType ) { // Set based on object type + case EFFECT: + alDeleteEffects(testObject); + break; + case FILTER: + alDeleteFilters(testObject); + break; + default: + throw new IllegalArgumentException("Invalid objectType: " + objectType); + } + } catch (OpenALException debugBuildException) { + // Don't care about cleanup errors. + } + + } else if ( genError == AL_OUT_OF_MEMORY ) { + throw new OpenALException(AL10.alGetString(genError)); + } + } + + return supported; + } + +} diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/openal/OpenALException.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/openal/OpenALException.java new file mode 100644 index 000000000..6ed4d0b97 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/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$ + * $Id$ + */ +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: " + org.lwjgl.openal.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/jre_lwjgl3glfw/src/main/java/org/lwjgl/openal/Util.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/openal/Util.java new file mode 100644 index 000000000..0930c2a7a --- /dev/null +++ b/jre_lwjgl3glfw/src/main/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$ + */ + +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.device); + if (err != ALC10.ALC_NO_ERROR) + throw new OpenALException(ALC10.alcGetString(AL.getDevice().device, 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/jre_lwjgl3glfw/src/main/java/org/lwjgl/opengl/ARBBufferObject.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/opengl/ARBBufferObject.java new file mode 100644 index 000000000..c83120376 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/opengl/ARBBufferObject.java @@ -0,0 +1,5 @@ +package org.lwjgl.opengl; + +public class ARBBufferObject extends ARBVertexBufferObject +{ +} diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/opengl/ARBShaderObjects.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/opengl/ARBShaderObjects.java new file mode 100644 index 000000000..c5ee33188 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/opengl/ARBShaderObjects.java @@ -0,0 +1,1363 @@ +/* + * Copyright LWJGL. All rights reserved. + * License terms: https://www.lwjgl.org/license + * MACHINE GENERATED FILE, DO NOT EDIT + */ +package org.lwjgl.opengl; + +import javax.annotation.*; + +import java.nio.*; + +import org.lwjgl.*; + +import org.lwjgl.system.*; + +import static org.lwjgl.system.Checks.*; +import static org.lwjgl.system.JNI.*; +import static org.lwjgl.system.MemoryStack.*; +import static org.lwjgl.system.MemoryUtil.*; + +/** + * Native bindings to the ARB_shader_objects extension. + * + *

This extension adds API calls that are necessary to manage shader objects and program objects as defined in the OpenGL 2.0 white papers by 3Dlabs.

+ * + *

The generation of an executable that runs on one of OpenGL's programmable units is modeled to that of developing a typical C/C++ application. There are + * one or more source files, each of which are stored by OpenGL in a shader object. Each shader object (source file) needs to be compiled and attached to a + * program object. Once all shader objects are compiled successfully, the program object needs to be linked to produce an executable. This executable is + * part of the program object, and can now be loaded onto the programmable units to make it part of the current OpenGL state. Both the compile and link + * stages generate a text string that can be queried to get more information. This information could be, but is not limited to, compile errors, link errors, + * optimization hints, etc. Values for uniform variables, declared in a shader, can be set by the application and used to control a shader's behavior.

+ * + *

This extension defines functions for creating shader objects and program objects, for compiling shader objects, for linking program objects, for + * attaching shader objects to program objects, and for using a program object as part of current state. Functions to load uniform values are also defined. + * Some house keeping functions, like deleting an object and querying object state, are also provided.

+ * + *

Although this extension defines the API for creating shader objects, it does not define any specific types of shader objects. It is assumed that this + * extension will be implemented along with at least one such additional extension for creating a specific type of OpenGL 2.0 shader (e.g., the + * {@link ARBFragmentShader ARB_fragment_shader} extension or the {@link ARBVertexShader ARB_vertex_shader} extension).

+ * + *

Promoted to core in {@link GL20 OpenGL 2.0}.

+ */ +public class ARBShaderObjects { + + /** Accepted by the {@code pname} argument of GetHandleARB. */ + public static final int GL_PROGRAM_OBJECT_ARB = 0x8B40; + + /** Accepted by the {@code pname} parameter of GetObjectParameter{fi}vARB. */ + public static final int + GL_OBJECT_TYPE_ARB = 0x8B4E, + GL_OBJECT_SUBTYPE_ARB = 0x8B4F, + GL_OBJECT_DELETE_STATUS_ARB = 0x8B80, + GL_OBJECT_COMPILE_STATUS_ARB = 0x8B81, + GL_OBJECT_LINK_STATUS_ARB = 0x8B82, + GL_OBJECT_VALIDATE_STATUS_ARB = 0x8B83, + GL_OBJECT_INFO_LOG_LENGTH_ARB = 0x8B84, + GL_OBJECT_ATTACHED_OBJECTS_ARB = 0x8B85, + GL_OBJECT_ACTIVE_UNIFORMS_ARB = 0x8B86, + GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB = 0x8B87, + GL_OBJECT_SHADER_SOURCE_LENGTH_ARB = 0x8B88; + + /** Returned by the {@code params} parameter of GetObjectParameter{fi}vARB. */ + public static final int GL_SHADER_OBJECT_ARB = 0x8B48; + + /** Returned by the {@code type} parameter of GetActiveUniformARB. */ + public static final int + GL_FLOAT_VEC2_ARB = 0x8B50, + GL_FLOAT_VEC3_ARB = 0x8B51, + GL_FLOAT_VEC4_ARB = 0x8B52, + GL_INT_VEC2_ARB = 0x8B53, + GL_INT_VEC3_ARB = 0x8B54, + GL_INT_VEC4_ARB = 0x8B55, + GL_BOOL_ARB = 0x8B56, + GL_BOOL_VEC2_ARB = 0x8B57, + GL_BOOL_VEC3_ARB = 0x8B58, + GL_BOOL_VEC4_ARB = 0x8B59, + GL_FLOAT_MAT2_ARB = 0x8B5A, + GL_FLOAT_MAT3_ARB = 0x8B5B, + GL_FLOAT_MAT4_ARB = 0x8B5C, + GL_SAMPLER_1D_ARB = 0x8B5D, + GL_SAMPLER_2D_ARB = 0x8B5E, + GL_SAMPLER_3D_ARB = 0x8B5F, + GL_SAMPLER_CUBE_ARB = 0x8B60, + GL_SAMPLER_1D_SHADOW_ARB = 0x8B61, + GL_SAMPLER_2D_SHADOW_ARB = 0x8B62, + GL_SAMPLER_2D_RECT_ARB = 0x8B63, + GL_SAMPLER_2D_RECT_SHADOW_ARB = 0x8B64; + + static { GL.initialize(); } + + protected ARBShaderObjects() { + throw new UnsupportedOperationException(); + } + + static boolean isAvailable(GLCapabilities caps) { + return checkFunctions( + caps.glDeleteObjectARB, caps.glGetHandleARB, caps.glDetachObjectARB, caps.glCreateShaderObjectARB, caps.glShaderSourceARB, caps.glCompileShaderARB, + caps.glCreateProgramObjectARB, caps.glAttachObjectARB, caps.glLinkProgramARB, caps.glUseProgramObjectARB, caps.glValidateProgramARB, + caps.glUniform1fARB, caps.glUniform2fARB, caps.glUniform3fARB, caps.glUniform4fARB, caps.glUniform1iARB, caps.glUniform2iARB, caps.glUniform3iARB, + caps.glUniform4iARB, caps.glUniform1fvARB, caps.glUniform2fvARB, caps.glUniform3fvARB, caps.glUniform4fvARB, caps.glUniform1ivARB, + caps.glUniform2ivARB, caps.glUniform3ivARB, caps.glUniform4ivARB, caps.glUniformMatrix2fvARB, caps.glUniformMatrix3fvARB, + caps.glUniformMatrix4fvARB, caps.glGetObjectParameterfvARB, caps.glGetObjectParameterivARB, caps.glGetInfoLogARB, caps.glGetAttachedObjectsARB, + caps.glGetUniformLocationARB, caps.glGetActiveUniformARB, caps.glGetUniformfvARB, caps.glGetUniformivARB, caps.glGetShaderSourceARB + ); + } + +// -- Begin LWJGL2 part -- + public static void glShaderSourceARB(int shader, java.nio.ByteBuffer string) { + byte[] b = new byte[string.remaining()]; + string.get(b); + org.lwjgl.opengl.ARBShaderObjects.glShaderSourceARB(shader, new String(b)); + } + + public static void glUniform1ARB(@NativeType("GLint") int location, @NativeType("GLfloat const *") FloatBuffer value) { + glUniform1fvARB(location, value); + } + + public static void glUniform2ARB(@NativeType("GLint") int location, @NativeType("GLfloat const *") FloatBuffer value) { + glUniform2fvARB(location, value); + } + + public static void glUniform3ARB(@NativeType("GLint") int location, @NativeType("GLfloat const *") FloatBuffer value) { + glUniform3fvARB(location, value); + } + + public static void glUniform4ARB(@NativeType("GLint") int location, @NativeType("GLfloat const *") FloatBuffer value) { + glUniform4fvARB(location, value); + } + + public static void glUniform1ARB(@NativeType("GLint") int location, @NativeType("GLfloat const *") IntBuffer value) { + glUniform1ivARB(location, value); + } + + public static void glUniform2ARB(@NativeType("GLint") int location, @NativeType("GLfloat const *") IntBuffer value) { + glUniform2ivARB(location, value); + } + + public static void glUniform3ARB(@NativeType("GLint") int location, @NativeType("GLfloat const *") IntBuffer value) { + glUniform3ivARB(location, value); + } + + public static void glUniform4ARB(@NativeType("GLint") int location, @NativeType("GLfloat const *") IntBuffer value) { + glUniform4ivARB(location, value); + } + + public static void glGetObjectParameterARB(@NativeType("GLhandleARB") int obj, @NativeType("GLenum") int pname, @NativeType("GLint *") IntBuffer params) { + glGetObjectParameterivARB(obj, pname, params); + } +// -- End LWJGL2 part -- + + // --- [ glDeleteObjectARB ] --- + + /** + * Either deletes the object, or flags it for deletion. An object that is attached to a container object is not deleted until it is no longer attached to + * any container object, for any context. If it is still attached to at least one container object, the object is flagged for deletion. If the object is + * part of the current rendering state, it is not deleted until it is no longer part of the current rendering state for any context. If the object is still + * part of the rendering state of at least one context, it is flagged for deletion. + * + *

If an object is flagged for deletion, its Boolean status bit {@link #GL_OBJECT_DELETE_STATUS_ARB OBJECT_DELETE_STATUS_ARB} is set to true.

+ * + *

DeleteObjectARB will silently ignore the value zero.

+ * + *

When a container object is deleted, it will detach each attached object as part of the deletion process. When an object is deleted, all information for + * the object referenced is lost. The data for the object is also deleted.

+ * + * @param obj the shader object to delete + */ + public static native void glDeleteObjectARB(@NativeType("GLhandleARB") int obj); + + // --- [ glGetHandleARB ] --- + + /** + * Returns the handle to an object that is in use as part of current state. + * + * @param pname the state item for which the current object is to be returned. Must be:
{@link #GL_PROGRAM_OBJECT_ARB PROGRAM_OBJECT_ARB}
+ */ + @NativeType("GLhandleARB") + public static native int glGetHandleARB(@NativeType("GLenum") int pname); + + // --- [ glDetachObjectARB ] --- + + /** + * Detaches an object from the container object it is attached to. + * + * @param containerObj the container object + * @param attachedObj the object to detach + */ + public static native void glDetachObjectARB(@NativeType("GLhandleARB") int containerObj, @NativeType("GLhandleARB") int attachedObj); + + // --- [ glCreateShaderObjectARB ] --- + + /** + * Creates a shader object. + * + * @param shaderType the type of the shader object to be created. One of:
{@link ARBVertexShader#GL_VERTEX_SHADER_ARB VERTEX_SHADER_ARB}{@link ARBFragmentShader#GL_FRAGMENT_SHADER_ARB FRAGMENT_SHADER_ARB}
+ */ + @NativeType("GLhandleARB") + public static native int glCreateShaderObjectARB(@NativeType("GLenum") int shaderType); + + // --- [ glShaderSourceARB ] --- + + /** + * Unsafe version of: {@link #glShaderSourceARB ShaderSourceARB} + * + * @param count the number of strings in the array + */ + public static native void nglShaderSourceARB(int shaderObj, int count, long string, long length); + + /** + * Sets the source code for the specified shader object {@code shaderObj} to the text strings in the {@code string} array. If the object previously had + * source code loaded into it, it is completely replaced. + * + *

The strings that are loaded into a shader object are expected to form the source code for a valid shader as defined in the OpenGL Shading Language + * Specification.

+ * + * @param shaderObj the shader object + * @param string an array of pointers to one or more, optionally null terminated, character strings that make up the source code + * @param length an array with the number of charARBs in each string (the string length). Each element in this array can be set to negative one (or smaller), + * indicating that its accompanying string is null terminated. If {@code length} is set to {@code NULL}, all strings in the {@code string} argument are + * considered null terminated. + */ + public static void glShaderSourceARB(@NativeType("GLhandleARB") int shaderObj, @NativeType("GLcharARB const **") PointerBuffer string, @Nullable @NativeType("GLint const *") IntBuffer length) { + if (CHECKS) { + checkSafe(length, string.remaining()); + } + nglShaderSourceARB(shaderObj, string.remaining(), memAddress(string), memAddressSafe(length)); + } + + /** + * Sets the source code for the specified shader object {@code shaderObj} to the text strings in the {@code string} array. If the object previously had + * source code loaded into it, it is completely replaced. + * + *

The strings that are loaded into a shader object are expected to form the source code for a valid shader as defined in the OpenGL Shading Language + * Specification.

+ * + * @param shaderObj the shader object + * @param string an array of pointers to one or more, optionally null terminated, character strings that make up the source code + */ + public static void glShaderSourceARB(@NativeType("GLhandleARB") int shaderObj, @NativeType("GLcharARB const **") CharSequence... string) { + MemoryStack stack = stackGet(); int stackPointer = stack.getPointer(); + try { + long stringAddress = org.lwjgl.system.APIUtil.apiArrayi(stack, MemoryUtil::memUTF8, string); + nglShaderSourceARB(shaderObj, string.length, stringAddress, stringAddress - (string.length << 2)); + org.lwjgl.system.APIUtil.apiArrayFree(stringAddress, string.length); + } finally { + stack.setPointer(stackPointer); + } + } + + /** + * Sets the source code for the specified shader object {@code shaderObj} to the text strings in the {@code string} array. If the object previously had + * source code loaded into it, it is completely replaced. + * + *

The strings that are loaded into a shader object are expected to form the source code for a valid shader as defined in the OpenGL Shading Language + * Specification.

+ * + * @param shaderObj the shader object + * @param string an array of pointers to one or more, optionally null terminated, character strings that make up the source code + */ + public static void glShaderSourceARB(@NativeType("GLhandleARB") int shaderObj, @NativeType("GLcharARB const **") CharSequence string) { + MemoryStack stack = stackGet(); int stackPointer = stack.getPointer(); + try { + long stringAddress = org.lwjgl.system.APIUtil.apiArrayi(stack, MemoryUtil::memUTF8, string); + nglShaderSourceARB(shaderObj, 1, stringAddress, stringAddress - 4); + org.lwjgl.system.APIUtil.apiArrayFree(stringAddress, 1); + } finally { + stack.setPointer(stackPointer); + } + } + + // --- [ glCompileShaderARB ] --- + + /** + * Compiles a shader object. Each shader object has a Boolean status, {@link #GL_OBJECT_COMPILE_STATUS_ARB OBJECT_COMPILE_STATUS_ARB}, that is modified as a result of compilation. This status + * can be queried with {@link #glGetObjectParameterivARB GetObjectParameterivARB}. This status will be set to {@link GL11#GL_TRUE TRUE} if the shader {@code shaderObj} was compiled without errors and is + * ready for use, and {@link GL11#GL_FALSE FALSE} otherwise. Compilation can fail for a variety of reasons as listed in the OpenGL Shading Language Specification. If + * CompileShaderARB failed, any information about a previous compile is lost and is not restored. Thus a failed compile does not restore the old state of + * {@code shaderObj}. If {@code shaderObj} does not reference a shader object, the error {@link GL11#GL_INVALID_OPERATION INVALID_OPERATION} is generated. + * + *

Note that changing the source code of a shader object, through ShaderSourceARB, does not change its compile status {@link #GL_OBJECT_COMPILE_STATUS_ARB OBJECT_COMPILE_STATUS_ARB}.

+ * + *

Each shader object has an information log that is modified as a result of compilation. This information log can be queried with {@link #glGetInfoLogARB GetInfoLogARB} to + * obtain more information about the compilation attempt.

+ * + * @param shaderObj the shader object to compile + */ + public static native void glCompileShaderARB(@NativeType("GLhandleARB") int shaderObj); + + // --- [ glCreateProgramObjectARB ] --- + + /** + * Creates a program object. + * + *

A program object is a container object. Shader objects are attached to a program object with the command AttachObjectARB. It is permissible to attach + * shader objects to program objects before source code has been loaded into the shader object, or before the shader object has been compiled. It is + * permissible to attach multiple shader objects of the same type to a single program object, and it is permissible to attach a shader object to more than + * one program object.

+ */ + @NativeType("GLhandleARB") + public static native int glCreateProgramObjectARB(); + + // --- [ glAttachObjectARB ] --- + + /** + * Attaches an object to a container object. + * + * @param containerObj the container object + * @param obj the object to attach + */ + public static native void glAttachObjectARB(@NativeType("GLhandleARB") int containerObj, @NativeType("GLhandleARB") int obj); + + // --- [ glLinkProgramARB ] --- + + /** + * Links a program object. + * + *

Each program object has a Boolean status, {@link #GL_OBJECT_LINK_STATUS_ARB OBJECT_LINK_STATUS_ARB}, that is modified as a result of linking. This status can be queried with + * {@link #glGetObjectParameterivARB GetObjectParameterivARB}. This status will be set to {@link GL11#GL_TRUE TRUE} if a valid executable is created, and {@link GL11#GL_FALSE FALSE} otherwise. Linking can fail for a + * variety of reasons as specified in the OpenGL Shading Language Specification. Linking will also fail if one or more of the shader objects, attached to + * {@code programObj}, are not compiled successfully, or if more active uniform or active sampler variables are used in {@code programObj} than allowed. + * If LinkProgramARB failed, any information about a previous link is lost and is not restored. Thus a failed link does not restore the old state of + * {@code programObj}. If {@code programObj} is not of type {@link #GL_PROGRAM_OBJECT_ARB PROGRAM_OBJECT_ARB}, the error {@link GL11#GL_INVALID_OPERATION INVALID_OPERATION} is generated.

+ * + *

Each program object has an information log that is modified as a result of a link operation. This information log can be queried with {@link #glGetInfoLogARB GetInfoLogARB} + * to obtain more information about the link operation.

+ * + * @param programObj the program object to link + */ + public static native void glLinkProgramARB(@NativeType("GLhandleARB") int programObj); + + // --- [ glUseProgramObjectARB ] --- + + /** + * Installs the executable code as part of current rendering state if the program object {@code programObj} contains valid executable code, i.e. has been + * linked successfully. If UseProgramObjectARB is called with the handle set to 0, it is as if the GL had no programmable stages and the fixed + * functionality paths will be used instead. If {@code programObj} cannot be made part of the current rendering state, an {@link GL11#GL_INVALID_OPERATION INVALID_OPERATION} error will + * be generated and the current rendering state left unmodified. This error will be set, for example, if {@code programObj} has not been linked + * successfully. If {@code programObj} is not of type {@link #GL_PROGRAM_OBJECT_ARB PROGRAM_OBJECT_ARB}, the error {@link GL11#GL_INVALID_OPERATION INVALID_OPERATION} is generated. + * + *

While a program object is in use, applications are free to modify attached shader objects, compile attached shader objects, attach additional shader + * objects, and detach shader objects. This does not affect the link status {@link #GL_OBJECT_LINK_STATUS_ARB OBJECT_LINK_STATUS_ARB} of the program object. This does not affect the + * executable code that is part of the current state either. That executable code is only affected when the program object has been re-linked successfully. + * After such a successful re-link, the {@link #glLinkProgramARB LinkProgramARB} command will install the generated executable code as part of the current rendering state if the + * specified program object was already in use as a result of a previous call to UseProgramObjectARB. If this re-link failed, then the executable code part + * of the current state does not change.

+ * + * @param programObj the program object to use + */ + public static native void glUseProgramObjectARB(@NativeType("GLhandleARB") int programObj); + + // --- [ glValidateProgramARB ] --- + + /** + * Validates the program object {@code programObj} against the GL state at that moment. Each program object has a Boolean status, + * {@link #GL_OBJECT_VALIDATE_STATUS_ARB OBJECT_VALIDATE_STATUS_ARB}, that is modified as a result of validation. This status can be queried with {@link #glGetObjectParameterivARB GetObjectParameterivARB}. If validation + * succeeded this status will be set to {@link GL11#GL_TRUE TRUE}, otherwise it will be set to {@link GL11#GL_FALSE FALSE}. If validation succeeded the program object is guaranteed to + * execute, given the current GL state. If validation failed, the program object is guaranteed to not execute, given the current GL state. If + * {@code programObj} is not of type {@link #GL_PROGRAM_OBJECT_ARB PROGRAM_OBJECT_ARB}, the error {@link GL11#GL_INVALID_OPERATION INVALID_OPERATION} is generated. + * + *

ValidateProgramARB will validate at least as much as is done when a rendering command is issued, and it could validate more. For example, it could give + * a hint on how to optimize some piece of shader code.

+ * + *

ValidateProgramARB will store its information in the info log. This information will either be an empty string or it will contain validation information.

+ * + *

ValidateProgramARB is typically only useful during application development. An application should not expect different OpenGL implementations to produce + * identical information.

+ * + * @param programObj the program object to validate + */ + public static native void glValidateProgramARB(@NativeType("GLhandleARB") int programObj); + + // --- [ glUniform1fARB ] --- + + /** + * float version of {@link #glUniform4fARB Uniform4fARB}. + * + * @param location the uniform variable location + * @param v0 the uniform x value + */ + public static native void glUniform1fARB(@NativeType("GLint") int location, @NativeType("GLfloat") float v0); + + // --- [ glUniform2fARB ] --- + + /** + * vec2 version of {@link #glUniform4fARB Uniform4fARB}. + * + * @param location the uniform variable location + * @param v0 the uniform x value + * @param v1 the uniform y value + */ + public static native void glUniform2fARB(@NativeType("GLint") int location, @NativeType("GLfloat") float v0, @NativeType("GLfloat") float v1); + + // --- [ glUniform3fARB ] --- + + /** + * vec3 version of {@link #glUniform4fARB Uniform4fARB}. + * + * @param location the uniform variable location + * @param v0 the uniform x value + * @param v1 the uniform y value + * @param v2 the uniform z value + */ + public static native void glUniform3fARB(@NativeType("GLint") int location, @NativeType("GLfloat") float v0, @NativeType("GLfloat") float v1, @NativeType("GLfloat") float v2); + + // --- [ glUniform4fARB ] --- + + /** + * Loads a vec4 value into a uniform variable of the program object that is currently in use. + * + * @param location the uniform variable location + * @param v0 the uniform x value + * @param v1 the uniform y value + * @param v2 the uniform z value + * @param v3 the uniform w value + */ + public static native void glUniform4fARB(@NativeType("GLint") int location, @NativeType("GLfloat") float v0, @NativeType("GLfloat") float v1, @NativeType("GLfloat") float v2, @NativeType("GLfloat") float v3); + + // --- [ glUniform1iARB ] --- + + /** + * int version of {@link #glUniform1fARB Uniform1fARB}. + * + * @param location the uniform variable location + * @param v0 the uniform x value + */ + public static native void glUniform1iARB(@NativeType("GLint") int location, @NativeType("GLint") int v0); + + // --- [ glUniform2iARB ] --- + + /** + * ivec2 version of {@link #glUniform2fARB Uniform2fARB}. + * + * @param location the uniform variable location + * @param v0 the uniform x value + * @param v1 the uniform y value + */ + public static native void glUniform2iARB(@NativeType("GLint") int location, @NativeType("GLint") int v0, @NativeType("GLint") int v1); + + // --- [ glUniform3iARB ] --- + + /** + * ivec3 version of {@link #glUniform3fARB Uniform3fARB}. + * + * @param location the uniform variable location + * @param v0 the uniform x value + * @param v1 the uniform y value + * @param v2 the uniform z value + */ + public static native void glUniform3iARB(@NativeType("GLint") int location, @NativeType("GLint") int v0, @NativeType("GLint") int v1, @NativeType("GLint") int v2); + + // --- [ glUniform4iARB ] --- + + /** + * ivec4 version of {@link #glUniform4fARB Uniform4fARB}. + * + * @param location the uniform variable location + * @param v0 the uniform x value + * @param v1 the uniform y value + * @param v2 the uniform z value + * @param v3 the uniform w value + */ + public static native void glUniform4iARB(@NativeType("GLint") int location, @NativeType("GLint") int v0, @NativeType("GLint") int v1, @NativeType("GLint") int v2, @NativeType("GLint") int v3); + + // --- [ glUniform1fvARB ] --- + + /** + * Unsafe version of: {@link #glUniform1fvARB Uniform1fvARB} + * + * @param count the number of float values to load + */ + public static native void nglUniform1fvARB(int location, int count, long value); + + /** + * Loads floating-point values {@code count} times into a uniform location defined as an array of float values. + * + * @param location the uniform variable location + * @param value the values to load + */ + public static void glUniform1fvARB(@NativeType("GLint") int location, @NativeType("GLfloat const *") FloatBuffer value) { + nglUniform1fvARB(location, value.remaining(), memAddress(value)); + } + + // --- [ glUniform2fvARB ] --- + + /** + * Unsafe version of: {@link #glUniform2fvARB Uniform2fvARB} + * + * @param count the number of vec2 vectors to load + */ + public static native void nglUniform2fvARB(int location, int count, long value); + + /** + * Loads floating-point values {@code count} times into a uniform location defined as an array of vec2 vectors. + * + * @param location the uniform variable location + * @param value the values to load + */ + public static void glUniform2fvARB(@NativeType("GLint") int location, @NativeType("GLfloat const *") FloatBuffer value) { + nglUniform2fvARB(location, value.remaining() >> 1, memAddress(value)); + } + + // --- [ glUniform3fvARB ] --- + + /** + * Unsafe version of: {@link #glUniform3fvARB Uniform3fvARB} + * + * @param count the number of vec3 vectors to load + */ + public static native void nglUniform3fvARB(int location, int count, long value); + + /** + * Loads floating-point values {@code count} times into a uniform location defined as an array of vec3 vectors. + * + * @param location the uniform variable location + * @param value the values to load + */ + public static void glUniform3fvARB(@NativeType("GLint") int location, @NativeType("GLfloat const *") FloatBuffer value) { + nglUniform3fvARB(location, value.remaining() / 3, memAddress(value)); + } + + // --- [ glUniform4fvARB ] --- + + /** + * Unsafe version of: {@link #glUniform4fvARB Uniform4fvARB} + * + * @param count the number of vec4 vectors to load + */ + public static native void nglUniform4fvARB(int location, int count, long value); + + /** + * Loads floating-point values {@code count} times into a uniform location defined as an array of vec4 vectors. + * + * @param location the uniform variable location + * @param value the values to load + */ + public static void glUniform4fvARB(@NativeType("GLint") int location, @NativeType("GLfloat const *") FloatBuffer value) { + nglUniform4fvARB(location, value.remaining() >> 2, memAddress(value)); + } + + // --- [ glUniform1ivARB ] --- + + /** + * Unsafe version of: {@link #glUniform1ivARB Uniform1ivARB} + * + * @param count the number of integer values to load + */ + public static native void nglUniform1ivARB(int location, int count, long value); + + /** + * Loads integer values {@code count} times into a uniform location defined as an array of integer values. + * + * @param location the uniform variable location + * @param value the values to load + */ + public static void glUniform1ivARB(@NativeType("GLint") int location, @NativeType("GLint const *") IntBuffer value) { + nglUniform1ivARB(location, value.remaining(), memAddress(value)); + } + + // --- [ glUniform2ivARB ] --- + + /** + * Unsafe version of: {@link #glUniform2ivARB Uniform2ivARB} + * + * @param count the number of ivec2 vectors to load + */ + public static native void nglUniform2ivARB(int location, int count, long value); + + /** + * Loads integer values {@code count} times into a uniform location defined as an array of ivec2 vectors. + * + * @param location the uniform variable location + * @param value the values to load + */ + public static void glUniform2ivARB(@NativeType("GLint") int location, @NativeType("GLint const *") IntBuffer value) { + nglUniform2ivARB(location, value.remaining() >> 1, memAddress(value)); + } + + // --- [ glUniform3ivARB ] --- + + /** + * Unsafe version of: {@link #glUniform3ivARB Uniform3ivARB} + * + * @param count the number of ivec3 vectors to load + */ + public static native void nglUniform3ivARB(int location, int count, long value); + + /** + * Loads integer values {@code count} times into a uniform location defined as an array of ivec3 vectors. + * + * @param location the uniform variable location + * @param value the values to load + */ + public static void glUniform3ivARB(@NativeType("GLint") int location, @NativeType("GLint const *") IntBuffer value) { + nglUniform3ivARB(location, value.remaining() / 3, memAddress(value)); + } + + // --- [ glUniform4ivARB ] --- + + /** + * Unsafe version of: {@link #glUniform4ivARB Uniform4ivARB} + * + * @param count the number of ivec4 vectors to load + */ + public static native void nglUniform4ivARB(int location, int count, long value); + + /** + * Loads integer values {@code count} times into a uniform location defined as an array of ivec4 vectors. + * + * @param location the uniform variable location + * @param value the values to load + */ + public static void glUniform4ivARB(@NativeType("GLint") int location, @NativeType("GLint const *") IntBuffer value) { + nglUniform4ivARB(location, value.remaining() >> 2, memAddress(value)); + } + + // --- [ glUniformMatrix2fvARB ] --- + + /** + * Unsafe version of: {@link #glUniformMatrix2fvARB UniformMatrix2fvARB} + * + * @param count the number of 2x2 matrices to load + */ + public static native void nglUniformMatrix2fvARB(int location, int count, boolean transpose, long value); + + /** + * Loads a 2x2 matrix of floating-point values {@code count} times into a uniform location defined as a matrix or an array of matrices. + * + * @param location the uniform variable location + * @param transpose if {@link GL11#GL_FALSE FALSE}, the matrix is specified in column major order, otherwise in row major order + * @param value the matrix values to load + */ + public static void glUniformMatrix2fvARB(@NativeType("GLint") int location, @NativeType("GLboolean") boolean transpose, @NativeType("GLfloat const *") FloatBuffer value) { + nglUniformMatrix2fvARB(location, value.remaining() >> 2, transpose, memAddress(value)); + } + + // --- [ glUniformMatrix3fvARB ] --- + + /** + * Unsafe version of: {@link #glUniformMatrix3fvARB UniformMatrix3fvARB} + * + * @param count the number of 3x3 matrices to load + */ + public static native void nglUniformMatrix3fvARB(int location, int count, boolean transpose, long value); + + /** + * Loads a 3x3 matrix of floating-point values {@code count} times into a uniform location defined as a matrix or an array of matrices. + * + * @param location the uniform variable location + * @param transpose if {@link GL11#GL_FALSE FALSE}, the matrix is specified in column major order, otherwise in row major order + * @param value the matrix values to load + */ + public static void glUniformMatrix3fvARB(@NativeType("GLint") int location, @NativeType("GLboolean") boolean transpose, @NativeType("GLfloat const *") FloatBuffer value) { + nglUniformMatrix3fvARB(location, value.remaining() / 9, transpose, memAddress(value)); + } + + // --- [ glUniformMatrix4fvARB ] --- + + /** + * Unsafe version of: {@link #glUniformMatrix4fvARB UniformMatrix4fvARB} + * + * @param count the number of 4x4 matrices to load + */ + public static native void nglUniformMatrix4fvARB(int location, int count, boolean transpose, long value); + + /** + * Loads a 4x4 matrix of floating-point values {@code count} times into a uniform location defined as a matrix or an array of matrices. + * + * @param location the uniform variable location + * @param transpose if {@link GL11#GL_FALSE FALSE}, the matrix is specified in column major order, otherwise in row major order + * @param value the matrix values to load + */ + public static void glUniformMatrix4fvARB(@NativeType("GLint") int location, @NativeType("GLboolean") boolean transpose, @NativeType("GLfloat const *") FloatBuffer value) { + nglUniformMatrix4fvARB(location, value.remaining() >> 4, transpose, memAddress(value)); + } + + // --- [ glGetObjectParameterfvARB ] --- + + /** Unsafe version of: {@link #glGetObjectParameterfvARB GetObjectParameterfvARB} */ + public static native void nglGetObjectParameterfvARB(int obj, int pname, long params); + + /** + * Returns object specific parameter values. + * + * @param obj the object to query + * @param pname the parameter to query + * @param params a buffer in which to return the parameter value + */ + public static void glGetObjectParameterfvARB(@NativeType("GLhandleARB") int obj, @NativeType("GLenum") int pname, @NativeType("GLfloat *") FloatBuffer params) { + if (CHECKS) { + check(params, 1); + } + nglGetObjectParameterfvARB(obj, pname, memAddress(params)); + } + + // --- [ glGetObjectParameterivARB ] --- + + /** Unsafe version of: {@link #glGetObjectParameterivARB GetObjectParameterivARB} */ + public static native void nglGetObjectParameterivARB(int obj, int pname, long params); + + /** + * Returns object specific parameter values. + * + * @param obj the object to query + * @param pname the parameter to query. One of:
{@link #GL_OBJECT_TYPE_ARB OBJECT_TYPE_ARB}{@link #GL_OBJECT_SUBTYPE_ARB OBJECT_SUBTYPE_ARB}{@link #GL_OBJECT_DELETE_STATUS_ARB OBJECT_DELETE_STATUS_ARB}
{@link #GL_OBJECT_COMPILE_STATUS_ARB OBJECT_COMPILE_STATUS_ARB}{@link #GL_OBJECT_LINK_STATUS_ARB OBJECT_LINK_STATUS_ARB}{@link #GL_OBJECT_VALIDATE_STATUS_ARB OBJECT_VALIDATE_STATUS_ARB}
{@link #GL_OBJECT_INFO_LOG_LENGTH_ARB OBJECT_INFO_LOG_LENGTH_ARB}{@link #GL_OBJECT_ATTACHED_OBJECTS_ARB OBJECT_ATTACHED_OBJECTS_ARB}{@link #GL_OBJECT_ACTIVE_UNIFORMS_ARB OBJECT_ACTIVE_UNIFORMS_ARB}
{@link #GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB}{@link #GL_OBJECT_SHADER_SOURCE_LENGTH_ARB OBJECT_SHADER_SOURCE_LENGTH_ARB}
+ * @param params a buffer in which to return the parameter value + */ + public static void glGetObjectParameterivARB(@NativeType("GLhandleARB") int obj, @NativeType("GLenum") int pname, @NativeType("GLint *") IntBuffer params) { + if (CHECKS) { + check(params, 1); + } + nglGetObjectParameterivARB(obj, pname, memAddress(params)); + } + + /** + * Returns object specific parameter values. + * + * @param obj the object to query + * @param pname the parameter to query. One of:
{@link #GL_OBJECT_TYPE_ARB OBJECT_TYPE_ARB}{@link #GL_OBJECT_SUBTYPE_ARB OBJECT_SUBTYPE_ARB}{@link #GL_OBJECT_DELETE_STATUS_ARB OBJECT_DELETE_STATUS_ARB}
{@link #GL_OBJECT_COMPILE_STATUS_ARB OBJECT_COMPILE_STATUS_ARB}{@link #GL_OBJECT_LINK_STATUS_ARB OBJECT_LINK_STATUS_ARB}{@link #GL_OBJECT_VALIDATE_STATUS_ARB OBJECT_VALIDATE_STATUS_ARB}
{@link #GL_OBJECT_INFO_LOG_LENGTH_ARB OBJECT_INFO_LOG_LENGTH_ARB}{@link #GL_OBJECT_ATTACHED_OBJECTS_ARB OBJECT_ATTACHED_OBJECTS_ARB}{@link #GL_OBJECT_ACTIVE_UNIFORMS_ARB OBJECT_ACTIVE_UNIFORMS_ARB}
{@link #GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB}{@link #GL_OBJECT_SHADER_SOURCE_LENGTH_ARB OBJECT_SHADER_SOURCE_LENGTH_ARB}
+ */ + @NativeType("void") + public static int glGetObjectParameteriARB(@NativeType("GLhandleARB") int obj, @NativeType("GLenum") int pname) { + MemoryStack stack = stackGet(); int stackPointer = stack.getPointer(); + try { + IntBuffer params = stack.callocInt(1); + nglGetObjectParameterivARB(obj, pname, memAddress(params)); + return params.get(0); + } finally { + stack.setPointer(stackPointer); + } + } + + // --- [ glGetInfoLogARB ] --- + + /** + * Unsafe version of: {@link #glGetInfoLogARB GetInfoLogARB} + * + * @param maxLength the maximum number of characters the GL is allowed to write into {@code infoLog} + */ + public static native void nglGetInfoLogARB(int obj, int maxLength, long length, long infoLog); + + /** + * A string that contains information about the last link or validation attempt and last compilation attempt are kept per program or shader object. This + * string is called the info log and can be obtained with this command. + * + *

This string will be null terminated. The number of characters in the info log is given by {@link #GL_OBJECT_INFO_LOG_LENGTH_ARB OBJECT_INFO_LOG_LENGTH_ARB}, which can be queried with + * {@link #glGetObjectParameterivARB GetObjectParameterivARB}. If {@code obj} is a shader object, the returned info log will either be an empty string or it will contain + * information about the last compilation attempt for that object. If {@code obj} is a program object, the returned info log will either be an empty string + * or it will contain information about the last link attempt or last validation attempt for that object. If {@code obj} is not of type {@link #GL_PROGRAM_OBJECT_ARB PROGRAM_OBJECT_ARB} + * or {@link #GL_SHADER_OBJECT_ARB SHADER_OBJECT_ARB}, the error {@link GL11#GL_INVALID_OPERATION INVALID_OPERATION} is generated. If an error occurred, the return parameters {@code length} and {@code infoLog} + * will be unmodified.

+ * + *

The info log is typically only useful during application development and an application should not expect different OpenGL implementations to produce + * identical info logs.

+ * + * @param obj the shader object to query + * @param length the actual number of characters written by the GL into {@code infoLog} is returned in {@code length}, excluding the null termination. If + * {@code length} is {@code NULL} then the GL ignores this parameter. + * @param infoLog a buffer in which to return the info log + */ + public static void glGetInfoLogARB(@NativeType("GLhandleARB") int obj, @Nullable @NativeType("GLsizei *") IntBuffer length, @NativeType("GLcharARB *") ByteBuffer infoLog) { + if (CHECKS) { + checkSafe(length, 1); + } + nglGetInfoLogARB(obj, infoLog.remaining(), memAddressSafe(length), memAddress(infoLog)); + } + + /** + * A string that contains information about the last link or validation attempt and last compilation attempt are kept per program or shader object. This + * string is called the info log and can be obtained with this command. + * + *

This string will be null terminated. The number of characters in the info log is given by {@link #GL_OBJECT_INFO_LOG_LENGTH_ARB OBJECT_INFO_LOG_LENGTH_ARB}, which can be queried with + * {@link #glGetObjectParameterivARB GetObjectParameterivARB}. If {@code obj} is a shader object, the returned info log will either be an empty string or it will contain + * information about the last compilation attempt for that object. If {@code obj} is a program object, the returned info log will either be an empty string + * or it will contain information about the last link attempt or last validation attempt for that object. If {@code obj} is not of type {@link #GL_PROGRAM_OBJECT_ARB PROGRAM_OBJECT_ARB} + * or {@link #GL_SHADER_OBJECT_ARB SHADER_OBJECT_ARB}, the error {@link GL11#GL_INVALID_OPERATION INVALID_OPERATION} is generated. If an error occurred, the return parameters {@code length} and {@code infoLog} + * will be unmodified.

+ * + *

The info log is typically only useful during application development and an application should not expect different OpenGL implementations to produce + * identical info logs.

+ * + * @param obj the shader object to query + * @param maxLength the maximum number of characters the GL is allowed to write into {@code infoLog} + */ + @NativeType("void") + public static String glGetInfoLogARB(@NativeType("GLhandleARB") int obj, @NativeType("GLsizei") int maxLength) { + MemoryStack stack = stackGet(); int stackPointer = stack.getPointer(); + ByteBuffer infoLog = memAlloc(maxLength); + try { + IntBuffer length = stack.ints(0); + nglGetInfoLogARB(obj, maxLength, memAddress(length), memAddress(infoLog)); + return memUTF8(infoLog, length.get(0)); + } finally { + memFree(infoLog); + stack.setPointer(stackPointer); + } + } + + /** + * A string that contains information about the last link or validation attempt and last compilation attempt are kept per program or shader object. This + * string is called the info log and can be obtained with this command. + * + *

This string will be null terminated. The number of characters in the info log is given by {@link #GL_OBJECT_INFO_LOG_LENGTH_ARB OBJECT_INFO_LOG_LENGTH_ARB}, which can be queried with + * {@link #glGetObjectParameterivARB GetObjectParameterivARB}. If {@code obj} is a shader object, the returned info log will either be an empty string or it will contain + * information about the last compilation attempt for that object. If {@code obj} is a program object, the returned info log will either be an empty string + * or it will contain information about the last link attempt or last validation attempt for that object. If {@code obj} is not of type {@link #GL_PROGRAM_OBJECT_ARB PROGRAM_OBJECT_ARB} + * or {@link #GL_SHADER_OBJECT_ARB SHADER_OBJECT_ARB}, the error {@link GL11#GL_INVALID_OPERATION INVALID_OPERATION} is generated. If an error occurred, the return parameters {@code length} and {@code infoLog} + * will be unmodified.

+ * + *

The info log is typically only useful during application development and an application should not expect different OpenGL implementations to produce + * identical info logs.

+ * + * @param obj the shader object to query + */ + @NativeType("void") + public static String glGetInfoLogARB(@NativeType("GLhandleARB") int obj) { + return glGetInfoLogARB(obj, glGetObjectParameteriARB(obj, GL_OBJECT_INFO_LOG_LENGTH_ARB)); + } + + // --- [ glGetAttachedObjectsARB ] --- + + /** + * Unsafe version of: {@link #glGetAttachedObjectsARB GetAttachedObjectsARB} + * + * @param maxCount the maximum number of handles the GL is allowed to write into {@code obj} + */ + public static native void nglGetAttachedObjectsARB(int containerObj, int maxCount, long count, long obj); + + /** + * Returns the handles of objects attached to {@code containerObj} in {@code obj}. . The number of objects attached to {@code containerObj} is given by + * {@link #GL_OBJECT_ATTACHED_OBJECTS_ARB OBJECT_ATTACHED_OBJECTS_ARB}, which can be queried with {@link #glGetObjectParameterivARB GetObjectParameterivARB}. If {@code containerObj} is not of type {@link #GL_PROGRAM_OBJECT_ARB PROGRAM_OBJECT_ARB}, the + * error {@link GL11#GL_INVALID_OPERATION INVALID_OPERATION} is generated. If an error occurred, the return parameters {@code count} and {@code obj} will be unmodified. + * + * @param containerObj the container object to query + * @param count a buffer in which to return the actual number of object handles written by the GL into {@code obj}. If {@code NULL} then the GL ignores this parameter. + * @param obj a buffer in which to return the attached object handles + */ + public static void glGetAttachedObjectsARB(@NativeType("GLhandleARB") int containerObj, @Nullable @NativeType("GLsizei *") IntBuffer count, @NativeType("GLhandleARB *") IntBuffer obj) { + if (CHECKS) { + checkSafe(count, 1); + } + nglGetAttachedObjectsARB(containerObj, obj.remaining(), memAddressSafe(count), memAddress(obj)); + } + + // --- [ glGetUniformLocationARB ] --- + + /** Unsafe version of: {@link #glGetUniformLocationARB GetUniformLocationARB} */ + public static native int nglGetUniformLocationARB(int programObj, long name); + + /** + * Returns the location of uniform variable {@code name}. {@code name} has to be a null terminated string, without white space. The value of -1 will be + * returned if {@code name} does not correspond to an active uniform variable name in {@code programObj} or if {@code name} starts with the reserved prefix + * "gl_". If {@code programObj} has not been successfully linked, or if {@code programObj} is not of type {@link #GL_PROGRAM_OBJECT_ARB PROGRAM_OBJECT_ARB}, the error + * {@link GL11#GL_INVALID_OPERATION INVALID_OPERATION} is generated. The location of a uniform variable does not change until the next link command is issued. + * + *

A valid {@code name} cannot be a structure, an array of structures, or a subcomponent of a vector or a matrix. In order to identify a valid {@code name}, + * the "." (dot) and "[]" operators can be used in {@code name} to operate on a structure or to operate on an array.

+ * + *

The first element of a uniform array is identified using the name of the uniform array appended with "[0]". Except if the last part of the string + * {@code name} indicates a uniform array, then the location of the first element of that array can be retrieved by either using the name of the uniform + * array, or the name of the uniform array appended with "[0]".

+ * + * @param programObj the program object to query + * @param name the name of the uniform variable whose location is to be queried + */ + @NativeType("GLint") + public static int glGetUniformLocationARB(@NativeType("GLhandleARB") int programObj, @NativeType("GLcharARB const *") ByteBuffer name) { + if (CHECKS) { + checkNT1(name); + } + return nglGetUniformLocationARB(programObj, memAddress(name)); + } + + /** + * Returns the location of uniform variable {@code name}. {@code name} has to be a null terminated string, without white space. The value of -1 will be + * returned if {@code name} does not correspond to an active uniform variable name in {@code programObj} or if {@code name} starts with the reserved prefix + * "gl_". If {@code programObj} has not been successfully linked, or if {@code programObj} is not of type {@link #GL_PROGRAM_OBJECT_ARB PROGRAM_OBJECT_ARB}, the error + * {@link GL11#GL_INVALID_OPERATION INVALID_OPERATION} is generated. The location of a uniform variable does not change until the next link command is issued. + * + *

A valid {@code name} cannot be a structure, an array of structures, or a subcomponent of a vector or a matrix. In order to identify a valid {@code name}, + * the "." (dot) and "[]" operators can be used in {@code name} to operate on a structure or to operate on an array.

+ * + *

The first element of a uniform array is identified using the name of the uniform array appended with "[0]". Except if the last part of the string + * {@code name} indicates a uniform array, then the location of the first element of that array can be retrieved by either using the name of the uniform + * array, or the name of the uniform array appended with "[0]".

+ * + * @param programObj the program object to query + * @param name the name of the uniform variable whose location is to be queried + */ + @NativeType("GLint") + public static int glGetUniformLocationARB(@NativeType("GLhandleARB") int programObj, @NativeType("GLcharARB const *") CharSequence name) { + MemoryStack stack = stackGet(); int stackPointer = stack.getPointer(); + try { + stack.nUTF8(name, true); + long nameEncoded = stack.getPointerAddress(); + return nglGetUniformLocationARB(programObj, nameEncoded); + } finally { + stack.setPointer(stackPointer); + } + } + + // --- [ glGetActiveUniformARB ] --- + + /** + * Unsafe version of: {@link #glGetActiveUniformARB GetActiveUniformARB} + * + * @param maxLength the maximum number of characters the GL is allowed to write into {@code name}. + */ + public static native void nglGetActiveUniformARB(int programObj, int index, int maxLength, long length, long size, long type, long name); + + /** + * Determines which of the declared uniform variables are active and their sizes and types. + * + *

This command provides information about the uniform selected by {@code index}. The {@code index} of 0 selects the first active uniform, and + * {@code index} of {@link #GL_OBJECT_ACTIVE_UNIFORMS_ARB OBJECT_ACTIVE_UNIFORMS_ARB} - 1 selects the last active uniform. The value of {@link #GL_OBJECT_ACTIVE_UNIFORMS_ARB OBJECT_ACTIVE_UNIFORMS_ARB} can be queried with + * {@link #glGetObjectParameterivARB GetObjectParameterivARB}. If {@code index} is greater than or equal to {@link #GL_OBJECT_ACTIVE_UNIFORMS_ARB OBJECT_ACTIVE_UNIFORMS_ARB}, the error {@link GL11#GL_INVALID_VALUE INVALID_VALUE} is generated.

+ * + *

If an error occurred, the return parameters {@code length}, {@code size}, {@code type} and {@code name} will be unmodified.

+ * + *

The returned uniform name can be the name of built-in uniform state as well. The length of the longest uniform name in {@code programObj} is given by + * {@link #GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB}, which can be queried with {@link #glGetObjectParameterivARB GetObjectParameterivARB}.

+ * + *

Each uniform variable, declared in a shader, is broken down into one or more strings using the "." (dot) and "[]" operators, if necessary, to the point + * that it is legal to pass each string back into {@link #glGetUniformLocationARB GetUniformLocationARB}. Each of these strings constitutes one active uniform, and each string is + * assigned an index.

+ * + *

If one or more elements of an array are active, GetActiveUniformARB will return the name of the array in {@code name}, subject to the restrictions + * listed above. The type of the array is returned in {@code type}. The {@code size} parameter contains the highest array element index used, plus one. The + * compiler or linker determines the highest index used. There will be only one active uniform reported by the GL per uniform array.

+ * + *

This command will return as much information about active uniforms as possible. If no information is available, {@code length} will be set to zero and + * {@code name} will be an empty string. This situation could arise if GetActiveUniformARB is issued after a failed link.

+ * + * @param programObj a handle to a program object for which the command {@link #glLinkProgramARB LinkProgramARB} has been issued in the past. It is not necessary for {@code programObj} to have + * been linked successfully. The link could have failed because the number of active uniforms exceeded the limit. + * @param index the uniform index + * @param length a buffer in which to return the actual number of characters written by the GL into {@code name}. This count excludes the null termination. If + * {@code length} is {@code NULL} then the GL ignores this parameter. + * @param size a buffer in which to return the uniform size. The size is in units of the type returned in {@code type}. + * @param type a buffer in which to return the uniform type + * @param name a buffer in which to return the uniform name + */ + public static void glGetActiveUniformARB(@NativeType("GLhandleARB") int programObj, @NativeType("GLuint") int index, @Nullable @NativeType("GLsizei *") IntBuffer length, @NativeType("GLint *") IntBuffer size, @NativeType("GLenum *") IntBuffer type, @NativeType("GLcharARB *") ByteBuffer name) { + if (CHECKS) { + checkSafe(length, 1); + check(size, 1); + check(type, 1); + } + nglGetActiveUniformARB(programObj, index, name.remaining(), memAddressSafe(length), memAddress(size), memAddress(type), memAddress(name)); + } + + /** + * Determines which of the declared uniform variables are active and their sizes and types. + * + *

This command provides information about the uniform selected by {@code index}. The {@code index} of 0 selects the first active uniform, and + * {@code index} of {@link #GL_OBJECT_ACTIVE_UNIFORMS_ARB OBJECT_ACTIVE_UNIFORMS_ARB} - 1 selects the last active uniform. The value of {@link #GL_OBJECT_ACTIVE_UNIFORMS_ARB OBJECT_ACTIVE_UNIFORMS_ARB} can be queried with + * {@link #glGetObjectParameterivARB GetObjectParameterivARB}. If {@code index} is greater than or equal to {@link #GL_OBJECT_ACTIVE_UNIFORMS_ARB OBJECT_ACTIVE_UNIFORMS_ARB}, the error {@link GL11#GL_INVALID_VALUE INVALID_VALUE} is generated.

+ * + *

If an error occurred, the return parameters {@code length}, {@code size}, {@code type} and {@code name} will be unmodified.

+ * + *

The returned uniform name can be the name of built-in uniform state as well. The length of the longest uniform name in {@code programObj} is given by + * {@link #GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB}, which can be queried with {@link #glGetObjectParameterivARB GetObjectParameterivARB}.

+ * + *

Each uniform variable, declared in a shader, is broken down into one or more strings using the "." (dot) and "[]" operators, if necessary, to the point + * that it is legal to pass each string back into {@link #glGetUniformLocationARB GetUniformLocationARB}. Each of these strings constitutes one active uniform, and each string is + * assigned an index.

+ * + *

If one or more elements of an array are active, GetActiveUniformARB will return the name of the array in {@code name}, subject to the restrictions + * listed above. The type of the array is returned in {@code type}. The {@code size} parameter contains the highest array element index used, plus one. The + * compiler or linker determines the highest index used. There will be only one active uniform reported by the GL per uniform array.

+ * + *

This command will return as much information about active uniforms as possible. If no information is available, {@code length} will be set to zero and + * {@code name} will be an empty string. This situation could arise if GetActiveUniformARB is issued after a failed link.

+ * + * @param programObj a handle to a program object for which the command {@link #glLinkProgramARB LinkProgramARB} has been issued in the past. It is not necessary for {@code programObj} to have + * been linked successfully. The link could have failed because the number of active uniforms exceeded the limit. + * @param index the uniform index + * @param maxLength the maximum number of characters the GL is allowed to write into {@code name}. + * @param size a buffer in which to return the uniform size. The size is in units of the type returned in {@code type}. + * @param type a buffer in which to return the uniform type + */ + @NativeType("void") + public static String glGetActiveUniformARB(@NativeType("GLhandleARB") int programObj, @NativeType("GLuint") int index, @NativeType("GLsizei") int maxLength, @NativeType("GLint *") IntBuffer size, @NativeType("GLenum *") IntBuffer type) { + if (CHECKS) { + check(size, 1); + check(type, 1); + } + MemoryStack stack = stackGet(); int stackPointer = stack.getPointer(); + try { + IntBuffer length = stack.ints(0); + ByteBuffer name = stack.malloc(maxLength); + nglGetActiveUniformARB(programObj, index, maxLength, memAddress(length), memAddress(size), memAddress(type), memAddress(name)); + return memUTF8(name, length.get(0)); + } finally { + stack.setPointer(stackPointer); + } + } + + /** + * Determines which of the declared uniform variables are active and their sizes and types. + * + *

This command provides information about the uniform selected by {@code index}. The {@code index} of 0 selects the first active uniform, and + * {@code index} of {@link #GL_OBJECT_ACTIVE_UNIFORMS_ARB OBJECT_ACTIVE_UNIFORMS_ARB} - 1 selects the last active uniform. The value of {@link #GL_OBJECT_ACTIVE_UNIFORMS_ARB OBJECT_ACTIVE_UNIFORMS_ARB} can be queried with + * {@link #glGetObjectParameterivARB GetObjectParameterivARB}. If {@code index} is greater than or equal to {@link #GL_OBJECT_ACTIVE_UNIFORMS_ARB OBJECT_ACTIVE_UNIFORMS_ARB}, the error {@link GL11#GL_INVALID_VALUE INVALID_VALUE} is generated.

+ * + *

If an error occurred, the return parameters {@code length}, {@code size}, {@code type} and {@code name} will be unmodified.

+ * + *

The returned uniform name can be the name of built-in uniform state as well. The length of the longest uniform name in {@code programObj} is given by + * {@link #GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB}, which can be queried with {@link #glGetObjectParameterivARB GetObjectParameterivARB}.

+ * + *

Each uniform variable, declared in a shader, is broken down into one or more strings using the "." (dot) and "[]" operators, if necessary, to the point + * that it is legal to pass each string back into {@link #glGetUniformLocationARB GetUniformLocationARB}. Each of these strings constitutes one active uniform, and each string is + * assigned an index.

+ * + *

If one or more elements of an array are active, GetActiveUniformARB will return the name of the array in {@code name}, subject to the restrictions + * listed above. The type of the array is returned in {@code type}. The {@code size} parameter contains the highest array element index used, plus one. The + * compiler or linker determines the highest index used. There will be only one active uniform reported by the GL per uniform array.

+ * + *

This command will return as much information about active uniforms as possible. If no information is available, {@code length} will be set to zero and + * {@code name} will be an empty string. This situation could arise if GetActiveUniformARB is issued after a failed link.

+ * + * @param programObj a handle to a program object for which the command {@link #glLinkProgramARB LinkProgramARB} has been issued in the past. It is not necessary for {@code programObj} to have + * been linked successfully. The link could have failed because the number of active uniforms exceeded the limit. + * @param index the uniform index + * @param size a buffer in which to return the uniform size. The size is in units of the type returned in {@code type}. + * @param type a buffer in which to return the uniform type + */ + @NativeType("void") + public static String glGetActiveUniformARB(@NativeType("GLhandleARB") int programObj, @NativeType("GLuint") int index, @NativeType("GLint *") IntBuffer size, @NativeType("GLenum *") IntBuffer type) { + return glGetActiveUniformARB(programObj, index, glGetObjectParameteriARB(programObj, GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB), size, type); + } + + // --- [ glGetUniformfvARB ] --- + + /** Unsafe version of: {@link #glGetUniformfvARB GetUniformfvARB} */ + public static native void nglGetUniformfvARB(int programObj, int location, long params); + + /** + * Returns the floating-point value or values of a uniform. + * + * @param programObj the program object to query + * @param location the uniform variable location + * @param params a buffer in which to return the uniform values + */ + public static void glGetUniformfvARB(@NativeType("GLhandleARB") int programObj, @NativeType("GLint") int location, @NativeType("GLfloat *") FloatBuffer params) { + if (CHECKS) { + check(params, 1); + } + nglGetUniformfvARB(programObj, location, memAddress(params)); + } + + /** + * Returns the floating-point value or values of a uniform. + * + * @param programObj the program object to query + * @param location the uniform variable location + */ + @NativeType("void") + public static float glGetUniformfARB(@NativeType("GLhandleARB") int programObj, @NativeType("GLint") int location) { + MemoryStack stack = stackGet(); int stackPointer = stack.getPointer(); + try { + FloatBuffer params = stack.callocFloat(1); + nglGetUniformfvARB(programObj, location, memAddress(params)); + return params.get(0); + } finally { + stack.setPointer(stackPointer); + } + } + + // --- [ glGetUniformivARB ] --- + + /** Unsafe version of: {@link #glGetUniformivARB GetUniformivARB} */ + public static native void nglGetUniformivARB(int programObj, int location, long params); + + /** + * Returns the integer value or values of a uniform. + * + * @param programObj the program object to query + * @param location the uniform variable location + * @param params a buffer in which to return the uniform values + */ + public static void glGetUniformivARB(@NativeType("GLhandleARB") int programObj, @NativeType("GLint") int location, @NativeType("GLint *") IntBuffer params) { + if (CHECKS) { + check(params, 1); + } + nglGetUniformivARB(programObj, location, memAddress(params)); + } + + /** + * Returns the integer value or values of a uniform. + * + * @param programObj the program object to query + * @param location the uniform variable location + */ + @NativeType("void") + public static int glGetUniformiARB(@NativeType("GLhandleARB") int programObj, @NativeType("GLint") int location) { + MemoryStack stack = stackGet(); int stackPointer = stack.getPointer(); + try { + IntBuffer params = stack.callocInt(1); + nglGetUniformivARB(programObj, location, memAddress(params)); + return params.get(0); + } finally { + stack.setPointer(stackPointer); + } + } + + // --- [ glGetShaderSourceARB ] --- + + /** + * Unsafe version of: {@link #glGetShaderSourceARB GetShaderSourceARB} + * + * @param maxLength the maximum number of characters the GL is allowed to write into {@code source} + */ + public static native void nglGetShaderSourceARB(int obj, int maxLength, long length, long source); + + /** + * Returns the string making up the source code for a shader object. + * + *

The string {@code source} is a concatenation of the strings passed to OpenGL using {@link #glShaderSourceARB ShaderSourceARB}. The length of this concatenation is given by + * {@link #GL_OBJECT_SHADER_SOURCE_LENGTH_ARB OBJECT_SHADER_SOURCE_LENGTH_ARB}, which can be queried with {@link #glGetObjectParameterivARB GetObjectParameterivARB}. If {@code obj} is not of type {@link #GL_SHADER_OBJECT_ARB SHADER_OBJECT_ARB}, the error + * {@link GL11#GL_INVALID_OPERATION INVALID_OPERATION} is generated. If an error occurred, the return parameters {@code length} and {@code source} will be unmodified.

+ * + * @param obj the shader object to query + * @param length a buffer in which to return the actual number of characters written by the GL into {@code source}, excluding the null termination. If + * {@code length} is {@code NULL} then the GL ignores this parameter. + * @param source a buffer in which to return the shader object source + */ + public static void glGetShaderSourceARB(@NativeType("GLhandleARB") int obj, @Nullable @NativeType("GLsizei *") IntBuffer length, @NativeType("GLcharARB *") ByteBuffer source) { + if (CHECKS) { + checkSafe(length, 1); + } + nglGetShaderSourceARB(obj, source.remaining(), memAddressSafe(length), memAddress(source)); + } + + /** + * Returns the string making up the source code for a shader object. + * + *

The string {@code source} is a concatenation of the strings passed to OpenGL using {@link #glShaderSourceARB ShaderSourceARB}. The length of this concatenation is given by + * {@link #GL_OBJECT_SHADER_SOURCE_LENGTH_ARB OBJECT_SHADER_SOURCE_LENGTH_ARB}, which can be queried with {@link #glGetObjectParameterivARB GetObjectParameterivARB}. If {@code obj} is not of type {@link #GL_SHADER_OBJECT_ARB SHADER_OBJECT_ARB}, the error + * {@link GL11#GL_INVALID_OPERATION INVALID_OPERATION} is generated. If an error occurred, the return parameters {@code length} and {@code source} will be unmodified.

+ * + * @param obj the shader object to query + * @param maxLength the maximum number of characters the GL is allowed to write into {@code source} + */ + @NativeType("void") + public static String glGetShaderSourceARB(@NativeType("GLhandleARB") int obj, @NativeType("GLsizei") int maxLength) { + MemoryStack stack = stackGet(); int stackPointer = stack.getPointer(); + ByteBuffer source = memAlloc(maxLength); + try { + IntBuffer length = stack.ints(0); + nglGetShaderSourceARB(obj, maxLength, memAddress(length), memAddress(source)); + return memUTF8(source, length.get(0)); + } finally { + memFree(source); + stack.setPointer(stackPointer); + } + } + + /** + * Returns the string making up the source code for a shader object. + * + *

The string {@code source} is a concatenation of the strings passed to OpenGL using {@link #glShaderSourceARB ShaderSourceARB}. The length of this concatenation is given by + * {@link #GL_OBJECT_SHADER_SOURCE_LENGTH_ARB OBJECT_SHADER_SOURCE_LENGTH_ARB}, which can be queried with {@link #glGetObjectParameterivARB GetObjectParameterivARB}. If {@code obj} is not of type {@link #GL_SHADER_OBJECT_ARB SHADER_OBJECT_ARB}, the error + * {@link GL11#GL_INVALID_OPERATION INVALID_OPERATION} is generated. If an error occurred, the return parameters {@code length} and {@code source} will be unmodified.

+ * + * @param obj the shader object to query + */ + @NativeType("void") + public static String glGetShaderSourceARB(@NativeType("GLhandleARB") int obj) { + return glGetShaderSourceARB(obj, glGetObjectParameteriARB(obj, GL_OBJECT_SHADER_SOURCE_LENGTH_ARB)); + } + + /** Array version of: {@link #glShaderSourceARB ShaderSourceARB} */ + public static void glShaderSourceARB(@NativeType("GLhandleARB") int shaderObj, @NativeType("GLcharARB const **") PointerBuffer string, @Nullable @NativeType("GLint const *") int[] length) { + long __functionAddress = GL.getICD().glShaderSourceARB; + if (CHECKS) { + check(__functionAddress); + checkSafe(length, string.remaining()); + } + callPPV(shaderObj, string.remaining(), memAddress(string), length, __functionAddress); + } + + /** Array version of: {@link #glUniform1fvARB Uniform1fvARB} */ + public static void glUniform1fvARB(@NativeType("GLint") int location, @NativeType("GLfloat const *") float[] value) { + long __functionAddress = GL.getICD().glUniform1fvARB; + if (CHECKS) { + check(__functionAddress); + } + callPV(location, value.length, value, __functionAddress); + } + + /** Array version of: {@link #glUniform2fvARB Uniform2fvARB} */ + public static void glUniform2fvARB(@NativeType("GLint") int location, @NativeType("GLfloat const *") float[] value) { + long __functionAddress = GL.getICD().glUniform2fvARB; + if (CHECKS) { + check(__functionAddress); + } + callPV(location, value.length >> 1, value, __functionAddress); + } + + /** Array version of: {@link #glUniform3fvARB Uniform3fvARB} */ + public static void glUniform3fvARB(@NativeType("GLint") int location, @NativeType("GLfloat const *") float[] value) { + long __functionAddress = GL.getICD().glUniform3fvARB; + if (CHECKS) { + check(__functionAddress); + } + callPV(location, value.length / 3, value, __functionAddress); + } + + /** Array version of: {@link #glUniform4fvARB Uniform4fvARB} */ + public static void glUniform4fvARB(@NativeType("GLint") int location, @NativeType("GLfloat const *") float[] value) { + long __functionAddress = GL.getICD().glUniform4fvARB; + if (CHECKS) { + check(__functionAddress); + } + callPV(location, value.length >> 2, value, __functionAddress); + } + + /** Array version of: {@link #glUniform1ivARB Uniform1ivARB} */ + public static void glUniform1ivARB(@NativeType("GLint") int location, @NativeType("GLint const *") int[] value) { + long __functionAddress = GL.getICD().glUniform1ivARB; + if (CHECKS) { + check(__functionAddress); + } + callPV(location, value.length, value, __functionAddress); + } + + /** Array version of: {@link #glUniform2ivARB Uniform2ivARB} */ + public static void glUniform2ivARB(@NativeType("GLint") int location, @NativeType("GLint const *") int[] value) { + long __functionAddress = GL.getICD().glUniform2ivARB; + if (CHECKS) { + check(__functionAddress); + } + callPV(location, value.length >> 1, value, __functionAddress); + } + + /** Array version of: {@link #glUniform3ivARB Uniform3ivARB} */ + public static void glUniform3ivARB(@NativeType("GLint") int location, @NativeType("GLint const *") int[] value) { + long __functionAddress = GL.getICD().glUniform3ivARB; + if (CHECKS) { + check(__functionAddress); + } + callPV(location, value.length / 3, value, __functionAddress); + } + + /** Array version of: {@link #glUniform4ivARB Uniform4ivARB} */ + public static void glUniform4ivARB(@NativeType("GLint") int location, @NativeType("GLint const *") int[] value) { + long __functionAddress = GL.getICD().glUniform4ivARB; + if (CHECKS) { + check(__functionAddress); + } + callPV(location, value.length >> 2, value, __functionAddress); + } + + /** Array version of: {@link #glUniformMatrix2fvARB UniformMatrix2fvARB} */ + public static void glUniformMatrix2fvARB(@NativeType("GLint") int location, @NativeType("GLboolean") boolean transpose, @NativeType("GLfloat const *") float[] value) { + long __functionAddress = GL.getICD().glUniformMatrix2fvARB; + if (CHECKS) { + check(__functionAddress); + } + callPV(location, value.length >> 2, transpose, value, __functionAddress); + } + + /** Array version of: {@link #glUniformMatrix3fvARB UniformMatrix3fvARB} */ + public static void glUniformMatrix3fvARB(@NativeType("GLint") int location, @NativeType("GLboolean") boolean transpose, @NativeType("GLfloat const *") float[] value) { + long __functionAddress = GL.getICD().glUniformMatrix3fvARB; + if (CHECKS) { + check(__functionAddress); + } + callPV(location, value.length / 9, transpose, value, __functionAddress); + } + + /** Array version of: {@link #glUniformMatrix4fvARB UniformMatrix4fvARB} */ + public static void glUniformMatrix4fvARB(@NativeType("GLint") int location, @NativeType("GLboolean") boolean transpose, @NativeType("GLfloat const *") float[] value) { + long __functionAddress = GL.getICD().glUniformMatrix4fvARB; + if (CHECKS) { + check(__functionAddress); + } + callPV(location, value.length >> 4, transpose, value, __functionAddress); + } + + /** Array version of: {@link #glGetObjectParameterfvARB GetObjectParameterfvARB} */ + public static void glGetObjectParameterfvARB(@NativeType("GLhandleARB") int obj, @NativeType("GLenum") int pname, @NativeType("GLfloat *") float[] params) { + long __functionAddress = GL.getICD().glGetObjectParameterfvARB; + if (CHECKS) { + check(__functionAddress); + check(params, 1); + } + callPV(obj, pname, params, __functionAddress); + } + + /** Array version of: {@link #glGetObjectParameterivARB GetObjectParameterivARB} */ + public static void glGetObjectParameterivARB(@NativeType("GLhandleARB") int obj, @NativeType("GLenum") int pname, @NativeType("GLint *") int[] params) { + long __functionAddress = GL.getICD().glGetObjectParameterivARB; + if (CHECKS) { + check(__functionAddress); + check(params, 1); + } + callPV(obj, pname, params, __functionAddress); + } + + /** Array version of: {@link #glGetInfoLogARB GetInfoLogARB} */ + public static void glGetInfoLogARB(@NativeType("GLhandleARB") int obj, @Nullable @NativeType("GLsizei *") int[] length, @NativeType("GLcharARB *") ByteBuffer infoLog) { + long __functionAddress = GL.getICD().glGetInfoLogARB; + if (CHECKS) { + check(__functionAddress); + checkSafe(length, 1); + } + callPPV(obj, infoLog.remaining(), length, memAddress(infoLog), __functionAddress); + } + + /** Array version of: {@link #glGetAttachedObjectsARB GetAttachedObjectsARB} */ + public static void glGetAttachedObjectsARB(@NativeType("GLhandleARB") int containerObj, @Nullable @NativeType("GLsizei *") int[] count, @NativeType("GLhandleARB *") int[] obj) { + long __functionAddress = GL.getICD().glGetAttachedObjectsARB; + if (CHECKS) { + check(__functionAddress); + checkSafe(count, 1); + } + callPPV(containerObj, obj.length, count, obj, __functionAddress); + } + + /** Array version of: {@link #glGetActiveUniformARB GetActiveUniformARB} */ + public static void glGetActiveUniformARB(@NativeType("GLhandleARB") int programObj, @NativeType("GLuint") int index, @Nullable @NativeType("GLsizei *") int[] length, @NativeType("GLint *") int[] size, @NativeType("GLenum *") int[] type, @NativeType("GLcharARB *") ByteBuffer name) { + long __functionAddress = GL.getICD().glGetActiveUniformARB; + if (CHECKS) { + check(__functionAddress); + checkSafe(length, 1); + check(size, 1); + check(type, 1); + } + callPPPPV(programObj, index, name.remaining(), length, size, type, memAddress(name), __functionAddress); + } + + /** Array version of: {@link #glGetUniformfvARB GetUniformfvARB} */ + public static void glGetUniformfvARB(@NativeType("GLhandleARB") int programObj, @NativeType("GLint") int location, @NativeType("GLfloat *") float[] params) { + long __functionAddress = GL.getICD().glGetUniformfvARB; + if (CHECKS) { + check(__functionAddress); + check(params, 1); + } + callPV(programObj, location, params, __functionAddress); + } + + /** Array version of: {@link #glGetUniformivARB GetUniformivARB} */ + public static void glGetUniformivARB(@NativeType("GLhandleARB") int programObj, @NativeType("GLint") int location, @NativeType("GLint *") int[] params) { + long __functionAddress = GL.getICD().glGetUniformivARB; + if (CHECKS) { + check(__functionAddress); + check(params, 1); + } + callPV(programObj, location, params, __functionAddress); + } + + /** Array version of: {@link #glGetShaderSourceARB GetShaderSourceARB} */ + public static void glGetShaderSourceARB(@NativeType("GLhandleARB") int obj, @Nullable @NativeType("GLsizei *") int[] length, @NativeType("GLcharARB *") ByteBuffer source) { + long __functionAddress = GL.getICD().glGetShaderSourceARB; + if (CHECKS) { + check(__functionAddress); + checkSafe(length, 1); + } + callPPV(obj, source.remaining(), length, memAddress(source), __functionAddress); + } + +} diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/opengl/AWTGLCanvas.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/opengl/AWTGLCanvas.java new file mode 100644 index 000000000..e97e97de0 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/opengl/AWTGLCanvas.java @@ -0,0 +1,203 @@ +/* + * Copyright (c) 2002-2008 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) 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.PointerBuffer; + +import java.awt.*; +import java.awt.event.ComponentEvent; +import java.awt.event.ComponentListener; +import java.awt.event.HierarchyEvent; +import java.awt.event.HierarchyListener; + +public class AWTGLCanvas extends Canvas implements Drawable, ComponentListener, HierarchyListener { + + private static final long serialVersionUID = 1L; + + private ContextGL mContextGL; + private PixelFormatLWJGL mPixelFormat; + private ContextAttribs mCtxAttrs; + + public void setPixelFormat(final PixelFormatLWJGL pf) throws LWJGLException { + mPixelFormat = pf; + } + + public void setPixelFormat(final PixelFormatLWJGL pf, final ContextAttribs attribs) throws LWJGLException { + mPixelFormat = pf; + mCtxAttrs = attribs; + } + + public PixelFormatLWJGL getPixelFormat() { + return mPixelFormat; + } + + public ContextGL getContext() { + return mContextGL; + } + + public ContextGL createSharedContext() throws LWJGLException { + mContextGL = new ContextGL(getContext().getPeerInfo(), mCtxAttrs, null); + return mContextGL; + } + + public void checkGLError() { + // GL11.glGetError(); + } + + public void initContext(final float r, final float g, final float b) { + Display.setInitialBackground(r, g, b); + } + + public AWTGLCanvas() throws LWJGLException { + Display.create(); + } + + public AWTGLCanvas(PixelFormat pixel_format) throws LWJGLException { + Display.create(pixel_format); + } + + public AWTGLCanvas(GraphicsDevice device, PixelFormat pixel_format) throws LWJGLException { + this(pixel_format); + } + + public AWTGLCanvas(GraphicsDevice device, PixelFormat pixel_format, Drawable drawable) throws LWJGLException { + this(pixel_format); + } + + public AWTGLCanvas(GraphicsDevice device, PixelFormat pixel_format, Drawable drawable, ContextAttribs attribs) throws LWJGLException { + this(pixel_format); + } + + public void addNotify() { + + } + + public void removeNotify() { + + } + + public void setSwapInterval(int swap_interval) { + mContextGL.setSwapInterval(swap_interval); + } + + public void setVSyncEnabled(boolean enabled) { + mContextGL.setSwapInterval(enabled ? 1 : 0); + } + + public void swapBuffers() throws LWJGLException { + mContextGL.swapBuffers(); + } + + public boolean isCurrent() throws LWJGLException { + return mContextGL.isCurrent(); + } + + public void makeCurrent() throws LWJGLException { + mContextGL.makeCurrent(); + } + + public void releaseContext() throws LWJGLException { + mContextGL.releaseCurrent(); + } + + public final void destroy() { + try { + mContextGL.destroy(); + } catch (LWJGLException e) {throw new RuntimeException(e);} + } + + public final void setCLSharingProperties(final PointerBuffer properties) throws LWJGLException { + mContextGL.setCLSharingProperties(properties); + } + + protected void initGL() { + + } + + protected void paintGL() { + + } + + public final void paint(Graphics g) { + + } + + protected void exceptionOccurred(LWJGLException exception) { + + } + + public void update(Graphics g) { + + } + + public void componentShown(ComponentEvent e) { + + } + + public void componentHidden(ComponentEvent e) { + + } + + public void componentResized(ComponentEvent e) { + + } + + public void componentMoved(ComponentEvent e) { + + } + + public void setLocation(int x, int y) { + + } + + public void setLocation(Point p) { + + } + + public void setSize(Dimension d) { + + } + + public void setSize(int width, int height) { + + } + + public void setBounds(int x, int y, int width, int height) { + + } + + public void hierarchyChanged(HierarchyEvent e) { + + } + +} diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/opengl/Context.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/opengl/Context.java new file mode 100644 index 000000000..01c4fded3 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/opengl/Context.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2002-2011 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) 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; + +/** + * @author Spasi + * @since 14/5/2011 + */ +interface Context { + + boolean isCurrent() throws LWJGLException; + + void makeCurrent() throws LWJGLException; + + void releaseCurrent() throws LWJGLException; + + void releaseDrawable() throws LWJGLException; + +} diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/opengl/ContextAttribs.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/opengl/ContextAttribs.java new file mode 100644 index 000000000..ba1700530 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/opengl/ContextAttribs.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.opengl; + +public final class ContextAttribs { + + public ContextAttribs() { + + } + + public ContextAttribs(final int majorVersion, final int minorVersion) { + + } + + public int getMajorVersion() { + return 0; + } + + public int getMinorVersion() { + return 0; + } + + public int getLayerPlane() { + return 0; + } + + public boolean isDebug() { + return false; + } + + public boolean isForwardCompatible() { + return false; + } + + public boolean isProfileCore() { + return false; + } + + public boolean isProfileCompatibility() { + return false; + } + + public boolean isProfileES() { + return false; + } + + public ContextAttribs withLayer(final int layerPlane) { + return null; + } + + public ContextAttribs withDebug(final boolean debug) { + return null; + } + + public ContextAttribs withForwardCompatible(final boolean forwardCompatible) { + return null; + } + + public ContextAttribs withProfileCore(final boolean profileCore) { + return null; + } + + public ContextAttribs withProfileCompatibility(final boolean profileCompatibility) { + return null; + } + + public ContextAttribs withProfileES(final boolean profileES) { + return null; + } + + public ContextAttribs withLoseContextOnReset(final boolean loseContextOnReset) { + return null; + } + + public ContextAttribs withContextResetIsolation(final boolean contextResetIsolation) { + return null; + } + + public String toString() { + return null; + } + +} diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/opengl/ContextCapabilities.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/opengl/ContextCapabilities.java new file mode 100644 index 000000000..ac8906fe8 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/opengl/ContextCapabilities.java @@ -0,0 +1,402 @@ +package org.lwjgl.opengl; + +import java.lang.reflect.Field; + +public class ContextCapabilities { + + org.lwjgl.opengl.GLCapabilities cap = org.lwjgl.opengl.GL.createCapabilities(); + + public ContextCapabilities() { + + Field[] fields = org.lwjgl.opengl.GLCapabilities.class.getFields(); + + try { + for ( Field field : fields ) { + + String name = field.getName(); + + if (name.startsWith("GL_") || name.startsWith("OpenGL")) { + + boolean value = field.getBoolean(cap); + + try { + Field f = this.getClass().getField(name); + f.setBoolean(this, value); + } catch (Exception e) { + } + } + } + } catch (Exception e) { + System.out.println(e); + } + } + + public boolean GL_AMD_blend_minmax_factor; + public boolean GL_AMD_conservative_depth; + public boolean GL_AMD_debug_output; + public boolean GL_AMD_depth_clamp_separate; + public boolean GL_AMD_draw_buffers_blend; + public boolean GL_AMD_interleaved_elements; + public boolean GL_AMD_multi_draw_indirect; + public boolean GL_AMD_name_gen_delete; + public boolean GL_AMD_performance_monitor; + public boolean GL_AMD_pinned_memory; + public boolean GL_AMD_query_buffer_object; + public boolean GL_AMD_sample_positions; + public boolean GL_AMD_seamless_cubemap_per_texture; + public boolean GL_AMD_shader_atomic_counter_ops; + public boolean GL_AMD_shader_stencil_export; + public boolean GL_AMD_shader_trinary_minmax; + public boolean GL_AMD_sparse_texture; + public boolean GL_AMD_stencil_operation_extended; + public boolean GL_AMD_texture_texture4; + public boolean GL_AMD_transform_feedback3_lines_triangles; + public boolean GL_AMD_vertex_shader_layer; + public boolean GL_AMD_vertex_shader_tessellator; + public boolean GL_AMD_vertex_shader_viewport_index; + public boolean GL_APPLE_aux_depth_stencil; + public boolean GL_APPLE_client_storage; + public boolean GL_APPLE_element_array; + public boolean GL_APPLE_fence; + public boolean GL_APPLE_float_pixels; + public boolean GL_APPLE_flush_buffer_range; + public boolean GL_APPLE_object_purgeable; + public boolean GL_APPLE_packed_pixels; + public boolean GL_APPLE_rgb_422; + public boolean GL_APPLE_row_bytes; + public boolean GL_APPLE_texture_range; + public boolean GL_APPLE_vertex_array_object; + public boolean GL_APPLE_vertex_array_range; + public boolean GL_APPLE_vertex_program_evaluators; + public boolean GL_APPLE_ycbcr_422; + public boolean GL_ARB_ES2_compatibility; + public boolean GL_ARB_ES3_compatibility; + public boolean GL_ARB_arrays_of_arrays; + public boolean GL_ARB_base_instance; + public boolean GL_ARB_bindless_texture; + public boolean GL_ARB_blend_func_extended; + public boolean GL_ARB_buffer_storage; + public boolean GL_ARB_cl_event; + public boolean GL_ARB_clear_buffer_object; + public boolean GL_ARB_clear_texture; + public boolean GL_ARB_color_buffer_float; + public boolean GL_ARB_compatibility; + public boolean GL_ARB_compressed_texture_pixel_storage; + public boolean GL_ARB_compute_shader; + public boolean GL_ARB_compute_variable_group_size; + public boolean GL_ARB_conservative_depth; + public boolean GL_ARB_copy_buffer; + public boolean GL_ARB_copy_image; + public boolean GL_ARB_debug_output; + public boolean GL_ARB_depth_buffer_float; + public boolean GL_ARB_depth_clamp; + public boolean GL_ARB_depth_texture; + public boolean GL_ARB_draw_buffers; + public boolean GL_ARB_draw_buffers_blend; + public boolean GL_ARB_draw_elements_base_vertex; + public boolean GL_ARB_draw_indirect; + public boolean GL_ARB_draw_instanced; + public boolean GL_ARB_enhanced_layouts; + public boolean GL_ARB_explicit_attrib_location; + public boolean GL_ARB_explicit_uniform_location; + public boolean GL_ARB_fragment_coord_conventions; + public boolean GL_ARB_fragment_layer_viewport; + public boolean GL_ARB_fragment_program; + public boolean GL_ARB_fragment_program_shadow; + public boolean GL_ARB_fragment_shader; + public boolean GL_ARB_framebuffer_no_attachments; + public boolean GL_ARB_framebuffer_object; + public boolean GL_ARB_framebuffer_sRGB; + public boolean GL_ARB_geometry_shader4; + public boolean GL_ARB_get_program_binary; + public boolean GL_ARB_gpu_shader5; + public boolean GL_ARB_gpu_shader_fp64; + public boolean GL_ARB_half_float_pixel; + public boolean GL_ARB_half_float_vertex; + public boolean GL_ARB_imaging; + public boolean GL_ARB_indirect_parameters; + public boolean GL_ARB_instanced_arrays; + public boolean GL_ARB_internalformat_query; + public boolean GL_ARB_internalformat_query2; + public boolean GL_ARB_invalidate_subdata; + public boolean GL_ARB_map_buffer_alignment; + public boolean GL_ARB_map_buffer_range; + public boolean GL_ARB_matrix_palette; + public boolean GL_ARB_multi_bind; + public boolean GL_ARB_multi_draw_indirect; + public boolean GL_ARB_multisample; + public boolean GL_ARB_multitexture; + public boolean GL_ARB_occlusion_query; + public boolean GL_ARB_occlusion_query2; + public boolean GL_ARB_pixel_buffer_object; + public boolean GL_ARB_point_parameters; + public boolean GL_ARB_point_sprite; + public boolean GL_ARB_program_interface_query; + public boolean GL_ARB_provoking_vertex; + public boolean GL_ARB_query_buffer_object; + public boolean GL_ARB_robust_buffer_access_behavior; + public boolean GL_ARB_robustness; + public boolean GL_ARB_robustness_isolation; + public boolean GL_ARB_sample_shading; + public boolean GL_ARB_sampler_objects; + public boolean GL_ARB_seamless_cube_map; + public boolean GL_ARB_seamless_cubemap_per_texture; + public boolean GL_ARB_separate_shader_objects; + public boolean GL_ARB_shader_atomic_counters; + public boolean GL_ARB_shader_bit_encoding; + public boolean GL_ARB_shader_draw_parameters; + public boolean GL_ARB_shader_group_vote; + public boolean GL_ARB_shader_image_load_store; + public boolean GL_ARB_shader_image_size; + public boolean GL_ARB_shader_objects; + public boolean GL_ARB_shader_precision; + public boolean GL_ARB_shader_stencil_export; + public boolean GL_ARB_shader_storage_buffer_object; + public boolean GL_ARB_shader_subroutine; + public boolean GL_ARB_shader_texture_lod; + public boolean GL_ARB_shading_language_100; + public boolean GL_ARB_shading_language_420pack; + public boolean GL_ARB_shading_language_include; + public boolean GL_ARB_shading_language_packing; + public boolean GL_ARB_shadow; + public boolean GL_ARB_shadow_ambient; + public boolean GL_ARB_sparse_texture; + public boolean GL_ARB_stencil_texturing; + public boolean GL_ARB_sync; + public boolean GL_ARB_tessellation_shader; + public boolean GL_ARB_texture_border_clamp; + public boolean GL_ARB_texture_buffer_object; + public boolean GL_ARB_texture_buffer_object_rgb32; + public boolean GL_ARB_texture_buffer_range; + public boolean GL_ARB_texture_compression; + public boolean GL_ARB_texture_compression_bptc; + public boolean GL_ARB_texture_compression_rgtc; + public boolean GL_ARB_texture_cube_map; + public boolean GL_ARB_texture_cube_map_array; + public boolean GL_ARB_texture_env_add; + public boolean GL_ARB_texture_env_combine; + public boolean GL_ARB_texture_env_crossbar; + public boolean GL_ARB_texture_env_dot3; + public boolean GL_ARB_texture_float;; + public boolean GL_ARB_texture_gather; + public boolean GL_ARB_texture_mirror_clamp_to_edge; + public boolean GL_ARB_texture_mirrored_repeat; + public boolean GL_ARB_texture_multisample; + public boolean GL_ARB_texture_non_power_of_two; + public boolean GL_ARB_texture_query_levels; + public boolean GL_ARB_texture_query_lod; + public boolean GL_ARB_texture_rectangle; + public boolean GL_ARB_texture_rg; + public boolean GL_ARB_texture_rgb10_a2ui; + public boolean GL_ARB_texture_stencil8; + public boolean GL_ARB_texture_storage; + public boolean GL_ARB_texture_storage_multisample; + public boolean GL_ARB_texture_swizzle; + public boolean GL_ARB_texture_view; + public boolean GL_ARB_timer_query; + public boolean GL_ARB_transform_feedback2; + public boolean GL_ARB_transform_feedback3; + public boolean GL_ARB_transform_feedback_instanced; + public boolean GL_ARB_transpose_matrix; + public boolean GL_ARB_uniform_buffer_object; + public boolean GL_ARB_vertex_array_bgra; + public boolean GL_ARB_vertex_array_object; + public boolean GL_ARB_vertex_attrib_64bit; + public boolean GL_ARB_vertex_attrib_binding; + public boolean GL_ARB_vertex_blend; + public boolean GL_ARB_vertex_buffer_object; + public boolean GL_ARB_vertex_program; + public boolean GL_ARB_vertex_shader; + public boolean GL_ARB_vertex_type_10f_11f_11f_rev; + public boolean GL_ARB_vertex_type_2_10_10_10_rev; + public boolean GL_ARB_viewport_array; + public boolean GL_ARB_window_pos; + public boolean GL_ATI_draw_buffers; + public boolean GL_ATI_element_array; + public boolean GL_ATI_envmap_bumpmap; + public boolean GL_ATI_fragment_shader; + public boolean GL_ATI_map_object_buffer; + public boolean GL_ATI_meminfo; + public boolean GL_ATI_pn_triangles; + public boolean GL_ATI_separate_stencil; + public boolean GL_ATI_shader_texture_lod; + public boolean GL_ATI_text_fragment_shader; + public boolean GL_ATI_texture_compression_3dc; + public boolean GL_ATI_texture_env_combine3; + public boolean GL_ATI_texture_float; + public boolean GL_ATI_texture_mirror_once; + public boolean GL_ATI_vertex_array_object; + public boolean GL_ATI_vertex_attrib_array_object; + public boolean GL_ATI_vertex_streams; + public boolean GL_EXT_abgr; + public boolean GL_EXT_bgra; + public boolean GL_EXT_bindable_uniform; + public boolean GL_EXT_blend_color; + public boolean GL_EXT_blend_equation_separate; + public boolean GL_EXT_blend_func_separate; + public boolean GL_EXT_blend_minmax; + public boolean GL_EXT_blend_subtract; + public boolean GL_EXT_Cg_shader; + public boolean GL_EXT_compiled_vertex_array; + public boolean GL_EXT_depth_bounds_test; + public boolean GL_EXT_direct_state_access; + public boolean GL_EXT_draw_buffers2; + public boolean GL_EXT_draw_instanced; + public boolean GL_EXT_draw_range_elements; + public boolean GL_EXT_fog_coord; + public boolean GL_EXT_framebuffer_blit; + public boolean GL_EXT_framebuffer_multisample; + public boolean GL_EXT_framebuffer_multisample_blit_scaled; + public boolean GL_EXT_framebuffer_object; + public boolean GL_EXT_framebuffer_sRGB; + public boolean GL_EXT_geometry_shader4; + public boolean GL_EXT_gpu_program_parameters; + public boolean GL_EXT_gpu_shader4; + public boolean GL_EXT_multi_draw_arrays; + public boolean GL_EXT_packed_depth_stencil; + public boolean GL_EXT_packed_float; + public boolean GL_EXT_packed_pixels; + public boolean GL_EXT_paletted_texture; + public boolean GL_EXT_pixel_buffer_object; + public boolean GL_EXT_point_parameters; + public boolean GL_EXT_provoking_vertex; + public boolean GL_EXT_rescale_normal; + public boolean GL_EXT_secondary_color; + public boolean GL_EXT_separate_shader_objects; + public boolean GL_EXT_separate_specular_color; + public boolean GL_EXT_shader_image_load_store; + public boolean GL_EXT_shadow_funcs; + public boolean GL_EXT_shared_texture_palette; + public boolean GL_EXT_stencil_clear_tag; + public boolean GL_EXT_stencil_two_side; + public boolean GL_EXT_stencil_wrap; + public boolean GL_EXT_texture_3d; + public boolean GL_EXT_texture_array; + public boolean GL_EXT_texture_buffer_object; + public boolean GL_EXT_texture_compression_latc; + public boolean GL_EXT_texture_compression_rgtc; + public boolean GL_EXT_texture_compression_s3tc; + public boolean GL_EXT_texture_env_combine; + public boolean GL_EXT_texture_env_dot3; + public boolean GL_EXT_texture_filter_anisotropic; + public boolean GL_EXT_texture_integer; + public boolean GL_EXT_texture_lod_bias; + public boolean GL_EXT_texture_mirror_clamp; + public boolean GL_EXT_texture_rectangle; + public boolean GL_EXT_texture_sRGB; + public boolean GL_EXT_texture_sRGB_decode; + public boolean GL_EXT_texture_shared_exponent; + public boolean GL_EXT_texture_snorm; + public boolean GL_EXT_texture_swizzle; + public boolean GL_EXT_timer_query; + public boolean GL_EXT_transform_feedback; + public boolean GL_EXT_vertex_array_bgra; + public boolean GL_EXT_vertex_attrib_64bit; + public boolean GL_EXT_vertex_shader; + public boolean GL_EXT_vertex_weighting; + public boolean OpenGL11; + public boolean OpenGL12; + public boolean OpenGL13; + public boolean OpenGL14; + public boolean OpenGL15; + public boolean OpenGL20; + public boolean OpenGL21; + public boolean OpenGL30; + public boolean OpenGL31; + public boolean OpenGL32; + public boolean OpenGL33; + public boolean OpenGL40; + public boolean OpenGL41; + public boolean OpenGL42; + public boolean OpenGL43; + public boolean OpenGL44; + public boolean GL_GREMEDY_frame_terminator; + public boolean GL_GREMEDY_string_marker; + public boolean GL_HP_occlusion_test; + public boolean GL_IBM_rasterpos_clip; + public boolean GL_INTEL_map_texture; + public boolean GL_KHR_debug; + public boolean GL_KHR_texture_compression_astc_ldr; + public boolean GL_NVX_gpu_memory_info; + public boolean GL_NV_bindless_multi_draw_indirect; + public boolean GL_NV_bindless_texture; + public boolean GL_NV_blend_equation_advanced; + public boolean GL_NV_blend_square; + public boolean GL_NV_compute_program5; + public boolean GL_NV_conditional_render; + public boolean GL_NV_copy_depth_to_color; + public boolean GL_NV_copy_image; + public boolean GL_NV_deep_texture3D; + public boolean GL_NV_depth_buffer_float; + public boolean GL_NV_depth_clamp; + public boolean GL_NV_draw_texture; + public boolean GL_NV_evaluators; + public boolean GL_NV_explicit_multisample; + public boolean GL_NV_fence; + public boolean GL_NV_float_buffer; + public boolean GL_NV_fog_distance; + public boolean GL_NV_fragment_program; + public boolean GL_NV_fragment_program2; + public boolean GL_NV_fragment_program4; + public boolean GL_NV_fragment_program_option; + public boolean GL_NV_framebuffer_multisample_coverage; + public boolean GL_NV_geometry_program4; + public boolean GL_NV_geometry_shader4; + public boolean GL_NV_gpu_program4; + public boolean GL_NV_gpu_program5; + public boolean GL_NV_gpu_program5_mem_extended; + public boolean GL_NV_gpu_shader5; + public boolean GL_NV_half_float; + public boolean GL_NV_light_max_exponent; + public boolean GL_NV_multisample_coverage; + public boolean GL_NV_multisample_filter_hint; + public boolean GL_NV_occlusion_query; + public boolean GL_NV_packed_depth_stencil; + public boolean GL_NV_parameter_buffer_object; + public boolean GL_NV_parameter_buffer_object2; + public boolean GL_NV_path_rendering; + public boolean GL_NV_pixel_data_range; + public boolean GL_NV_point_sprite; + public boolean GL_NV_present_video; + public boolean GL_NV_primitive_restart; + public boolean GL_NV_register_combiners; + public boolean GL_NV_register_combiners2; + public boolean GL_NV_shader_atomic_counters; + public boolean GL_NV_shader_atomic_float; + public boolean GL_NV_shader_buffer_load; + public boolean GL_NV_shader_buffer_store; + public boolean GL_NV_shader_storage_buffer_object; + public boolean GL_NV_tessellation_program5; + public boolean GL_NV_texgen_reflection; + public boolean GL_NV_texture_barrier; + public boolean GL_NV_texture_compression_vtc; + public boolean GL_NV_texture_env_combine4; + public boolean GL_NV_texture_expand_normal; + public boolean GL_NV_texture_multisample; + public boolean GL_NV_texture_rectangle; + public boolean GL_NV_texture_shader; + public boolean GL_NV_texture_shader2; + public boolean GL_NV_texture_shader3; + public boolean GL_NV_transform_feedback; + public boolean GL_NV_transform_feedback2; + public boolean GL_NV_vertex_array_range; + public boolean GL_NV_vertex_array_range2; + public boolean GL_NV_vertex_attrib_integer_64bit; + public boolean GL_NV_vertex_buffer_unified_memory; + public boolean GL_NV_vertex_program; + public boolean GL_NV_vertex_program1_1; + public boolean GL_NV_vertex_program2; + public boolean GL_NV_vertex_program2_option; + public boolean GL_NV_vertex_program3; + public boolean GL_NV_vertex_program4; + public boolean GL_NV_video_capture; + public boolean GL_SGIS_generate_mipmap; + public boolean GL_SGIS_texture_lod; + public boolean GL_SUN_slice_accum; + + public static void main(String[] arg) { + System.out.println("START!"); + new ContextCapabilities(); + } + +} diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/opengl/ContextGL.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/opengl/ContextGL.java new file mode 100644 index 000000000..9df0f9608 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/opengl/ContextGL.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; + +import org.lwjgl.LWJGLException; +import org.lwjgl.LWJGLUtil; +import org.lwjgl.PointerBuffer; +import org.lwjgl.Sys; + +import org.lwjgl.glfw.GLFW; + +import java.nio.ByteBuffer; +import java.nio.IntBuffer; + +import static org.lwjgl.opengl.GL11.*; + +/** + *

+ * Context encapsulates an OpenGL context. + *

+ *

+ * This class is thread-safe. + * + * @author elias_naur + * @version $Revision$ + * $Id$ + */ +final class ContextGL implements Context { + + /** The platform specific implementation of context methods */ + // private static final ContextImplementation implementation; + + /** The current Context */ + private static final ThreadLocal current_context_local = new ThreadLocal(); + + /** Handle to the native GL rendering context */ + private final ByteBuffer handle; + private final PeerInfo peer_info; + + private final ContextAttribs contextAttribs; + 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; + + private boolean isCurrent; + + static { + Sys.initialize(); + // implementation = createImplementation(); + } + + PeerInfo getPeerInfo() { + return peer_info; + } + + ContextAttribs getContextAttribs() { + return contextAttribs; + } + + static ContextGL getCurrentContext() { + return current_context_local.get(); + } + + /** Create a context with the specified peer info and shared context */ + ContextGL(PeerInfo peer_info, ContextAttribs attribs, ContextGL shared_context) throws LWJGLException { + ContextGL 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; + this.contextAttribs = attribs; +/* + IntBuffer attribList; + if ( attribs != null ) { + attribList = attribs.getAttribList(); + forwardCompatible = attribs.isForwardCompatible(); + } else { + attribList = null; + forwardCompatible = false; + } +*/ + + forwardCompatible = false; + + this.handle = null; + // 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 void releaseCurrent() throws LWJGLException { + ContextGL current_context = getCurrentContext(); + if ( current_context != null ) { + GLFW.glfwMakeContextCurrent(0l); + isCurrent = false; + 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 { + Display.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); + GLFW.glfwMakeContextCurrent(Display.Window.handle); + isCurrent = true; + } + + 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 isCurrent; + } + + private void checkDestroy() { + if ( !destroyed && destroy_requested ) { + try { + releaseDrawable(); + // implementation.destroy(peer_info, handle); + // CallbackUtil.unregisterCallbacks(this); + destroyed = true; + thread = null; + // GLContext.unloadOpenGLLibrary(); + + Display.destroy(); + } 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) { + GLFW.glfwSwapInterval(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 = GL_NO_ERROR; + if ( was_current ) { + if ( GLContext.getCapabilities() != null && GLContext.getCapabilities().OpenGL11 ) + error = glGetError(); + releaseCurrent(); + } + checkDestroy(); + if ( was_current && error != GL_NO_ERROR ) + throw new OpenGLException(error); + } + + public synchronized void setCLSharingProperties(final PointerBuffer properties) throws LWJGLException { + final ByteBuffer peer_handle = peer_info.lockAndGetHandle(); + try { + /* + switch ( LWJGLUtil.getPlatform() ) { + case LWJGLUtil.PLATFORM_WINDOWS: + final WindowsContextImplementation implWindows = (WindowsContextImplementation)implementation; + properties.put(KHRGLSharing.CL_GL_CONTEXT_KHR).put(implWindows.getHGLRC(handle)); + properties.put(KHRGLSharing.CL_WGL_HDC_KHR).put(implWindows.getHDC(peer_handle)); + break; + case LWJGLUtil.PLATFORM_LINUX: + final LinuxContextImplementation implLinux = (LinuxContextImplementation)implementation; + properties.put(KHRGLSharing.CL_GL_CONTEXT_KHR).put(implLinux.getGLXContext(handle)); + properties.put(KHRGLSharing.CL_GLX_DISPLAY_KHR).put(implLinux.getDisplay(peer_handle)); + break; + case LWJGLUtil.PLATFORM_MACOSX: + if (LWJGLUtil.isMacOSXEqualsOrBetterThan(10, 6)) { // only supported on OS X 10.6+ + // http://oscarbg.blogspot.com/2009/10/about-opencl-opengl-interop.html + final MacOSXContextImplementation implMacOSX = (MacOSXContextImplementation)implementation; + final long CGLShareGroup = implMacOSX.getCGLShareGroup(handle); + properties.put(APPLEGLSharing.CL_CONTEXT_PROPERTY_USE_CGL_SHAREGROUP_APPLE).put(CGLShareGroup); + break; + } + default: + throw new UnsupportedOperationException("CL/GL context sharing is not supported on this platform."); + } + */ + } finally { + // peer_info.unlock(); + } + } + +} diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/opengl/Display.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/opengl/Display.java new file mode 100644 index 000000000..06177f461 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/opengl/Display.java @@ -0,0 +1,1124 @@ +package org.lwjgl.opengl; + +import static org.lwjgl.opengl.GL11.GL_FALSE; +import static org.lwjgl.opengl.GL11.GL_TRUE; +import static org.lwjgl.system.MemoryUtil.NULL; +import static org.lwjgl.glfw.GLFW.*; + +import java.awt.Canvas; +import java.nio.ByteBuffer; +import java.nio.FloatBuffer; +import java.nio.IntBuffer; + +import org.lwjgl.BufferUtils; +import org.lwjgl.glfw.*; +import org.lwjgl.LWJGLUtil; +import org.lwjgl.opengl.GL11; +import org.lwjgl.system.MemoryUtil; +import org.lwjgl.LWJGLException; +import org.lwjgl.Sys; +import org.lwjgl.input.Cursor; +import org.lwjgl.input.Keyboard; +import org.lwjgl.input.Mouse; + +public class Display { + + private static String windowTitle = "Game"; + + private static org.lwjgl.opengl.GLContext context; + + private static DisplayImplementation display_impl; + + private static boolean displayCreated = false; + private static boolean displayFocused = true; + private static boolean displayVisible = true; + private static boolean displayDirty = false; + private static boolean displayResizable = false; + + private static DisplayMode mode, desktopDisplayMode; + + private static int latestEventKey = 0; + + private static int displayX = -1; + private static int displayY = -1; + + private static boolean displayResized = false; + private static int displayWidth = 0; + private static int displayHeight = 0; + private static int displayFramebufferWidth = 0; + private static int displayFramebufferHeight = 0; + + private static boolean latestResized = false; + private static int latestWidth = 0; + private static int latestHeight = 0; + + private static boolean vsyncEnabled = false; + private static boolean displayFullscreen = true; + private static float fps; + + private static boolean window_created; + + /** The Drawable instance that tracks the current Display context */ + private static DrawableLWJGL drawable; + + private static Canvas parent; + + private static GLFWImage.Buffer icons; + + private static int swap_interval; + + static { + Sys.initialize(); // init using dummy sys method + + long monitor = glfwGetPrimaryMonitor(); + GLFWVidMode vidmode = glfwGetVideoMode(monitor); + + int monitorWidth = displayWidth = displayFramebufferWidth = vidmode.width(); + int monitorHeight = displayHeight = displayFramebufferHeight = vidmode.height(); + int monitorBitPerPixel = vidmode.redBits() + vidmode.greenBits() + vidmode.blueBits(); + int monitorRefreshRate = vidmode.refreshRate(); + + mode = desktopDisplayMode = new DisplayMode(monitorWidth, monitorHeight, monitorBitPerPixel, monitorRefreshRate); + LWJGLUtil.log("Initial mode: " + desktopDisplayMode); + + // additional code workaround not called yet! + LWJGLUtil.log("Calling Display.create()"); + try { + create(); + } catch (LWJGLException e) {throw new RuntimeException(e);} + } + + public static void setSwapInterval(int value) { + synchronized ( GlobalLock.lock ) { + swap_interval = value; + if ( isCreated() ) { + drawable.setSwapInterval(swap_interval); + + } + } + } + + private static void makeCurrentAndSetSwapInterval() throws LWJGLException { + makeCurrent(); + try { + drawable.checkGLError(); + } catch (OpenGLException e) { + LWJGLUtil.log("OpenGL error during context creation: " + e.getMessage()); + } + setSwapInterval(swap_interval); + } + + private static void initContext() { + drawable.initContext(0, 0, 0); + update(); + } + + private static void initControls() { + // Automatically create mouse, keyboard and controller + if ( true ) { + if ( !Mouse.isCreated() ) { + try { + Mouse.create(); + } catch (LWJGLException e) { + if ( LWJGLUtil.DEBUG ) { + e.printStackTrace(System.err); + } else { + LWJGLUtil.log("Failed to create Mouse: " + e); + } + } + } + if ( !Keyboard.isCreated() ) { + try { + Keyboard.create(); + } catch (LWJGLException e) { + if ( LWJGLUtil.DEBUG ) { + e.printStackTrace(System.err); + } else { + LWJGLUtil.log("Failed to create Keyboard: " + e); + } + } + } + } + } + + private static void releaseDrawable() { + try { + Context context = drawable.getContext(); + if ( context != null && context.isCurrent() ) { + context.releaseCurrent(); + context.releaseDrawable(); + } + } catch (LWJGLException e) { + LWJGLUtil.log("Exception occurred while trying to release context: " + e); + } + } + + private static void destroyWindow() { + if ( !window_created ) { + return; + } + releaseDrawable(); + + // Automatically destroy keyboard & mouse + if ( Mouse.isCreated() ) { + Mouse.destroy(); + } + if ( Keyboard.isCreated() ) { + Keyboard.destroy(); + } + display_impl.destroyWindow(); + window_created = false; + } + + private static void reset() { + display_impl.resetDisplayMode(); + } + + private static void createWindow() throws LWJGLException { + if ( window_created ) { + return; + } + DisplayMode mode = Display.getDisplayMode(); + display_impl.createWindow(drawable, mode, null, 0, 0 /* getWindowX(), getWindowY() */); + window_created = true; + + displayWidth = mode.getWidth(); + displayHeight = mode.getHeight(); + + // setTitle(title); + initControls(); + + // set cached window icon if exists + /* + if ( cached_icons != null ) { + setIcon(cached_icons); + } else { + + } + */ + + setIcon(new ByteBuffer[] { LWJGLUtil.LWJGLIcon32x32, LWJGLUtil.LWJGLIcon16x16 }); + } + + public static void create(PixelFormat pixel_format, Drawable shared_drawable) throws LWJGLException { + // System.out.println("TODO: Implement Display.create(PixelFormat, + // Drawable)"); // TODO + create(pixel_format); + + final DrawableGL drawable = new DrawableGL() { + public void destroy() { + synchronized ( GlobalLock.lock ) { + if ( !isCreated() ) + return; + + releaseDrawable(); + super.destroy(); + destroyWindow(); + // x = y = -1; + // cached_icons = null; + reset(); + } + } + }; + Display.drawable = drawable; + + try { + drawable.setPixelFormat(pixel_format, null); + try { + createWindow(); + try { + drawable.context = new ContextGL(drawable.peer_info, null /* attribs */, shared_drawable != null ? ((DrawableGL)shared_drawable).getContext() : null); + try { + makeCurrentAndSetSwapInterval(); + initContext(); + } catch (LWJGLException e) { + //drawable.destroy(); + throw e; + } + } catch (LWJGLException e) { + destroyWindow(); + throw e; + } + } catch (LWJGLException e) { + drawable.destroy(); + throw e; + } + } catch (LWJGLException e) { + display_impl.resetDisplayMode(); + throw e; + } + } + + public static void create(PixelFormat pixel_format, ContextAttribs attribs) throws LWJGLException { + // System.out.println("TODO: Implement Display.create(PixelFormat, + // ContextAttribs)"); // TODO + create(pixel_format); + } + + public static void create(PixelFormat format) throws LWJGLException { + glfwWindowHint(GLFW_ACCUM_ALPHA_BITS, format.getAccumulationBitsPerPixel()); + glfwWindowHint(GLFW_ALPHA_BITS, format.getAlphaBits()); + glfwWindowHint(GLFW_AUX_BUFFERS, format.getAuxBuffers()); + glfwWindowHint(GLFW_DEPTH_BITS, format.getDepthBits()); + glfwWindowHint(GLFW_SAMPLES, format.getSamples()); + glfwWindowHint(GLFW_STENCIL_BITS, format.getStencilBits()); + create(); + } + + private static boolean isCreated = false; + public static void create() throws LWJGLException { + if (isCreated) return; + else isCreated = true; + + if (Window.handle != MemoryUtil.NULL) + glfwDestroyWindow(Window.handle); + + long monitor = glfwGetPrimaryMonitor(); + GLFWVidMode vidmode = glfwGetVideoMode(monitor); + + int monitorWidth = vidmode.width(); + int monitorHeight = vidmode.height(); + int monitorBitPerPixel = vidmode.redBits() + vidmode.greenBits() + vidmode.blueBits(); + int monitorRefreshRate = vidmode.refreshRate(); + + desktopDisplayMode = new DisplayMode(monitorWidth, monitorHeight, monitorBitPerPixel, monitorRefreshRate); + + glfwDefaultWindowHints(); + glfwWindowHint(GLFW_VISIBLE, GL_FALSE); + glfwWindowHint(GLFW_RESIZABLE, displayResizable ? GL_TRUE : GL_FALSE); + glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GL_TRUE); + + Window.handle = glfwCreateWindow(mode.getWidth(), mode.getHeight(), windowTitle, NULL, NULL); + if (Window.handle == NULL) + throw new LWJGLException("Failed to create Display window"); + + Window.keyCallback = new GLFWKeyCallback() { + @Override + public void invoke(long window, int key, int scancode, int action, int mods) { + latestEventKey = key; + + // if (action == GLFW_RELEASE || action == GLFW.GLFW_PRESS) { + // Keyboard.addKeyEvent(key, action == GLFW.GLFW_PRESS ? true : + // false); + // } + + Keyboard.addKeyEvent(key, action); + } + }; + + Window.charCallback = new GLFWCharCallback() { + @Override + public void invoke(long window, int codepoint) { + Keyboard.addCharEvent(latestEventKey, (char) codepoint); + } + }; + + Window.cursorEnterCallback = new GLFWCursorEnterCallback() { + @Override + public void invoke(long window, boolean entered) { + Mouse.setMouseInsideWindow(entered == true); + } + }; + + Window.cursorPosCallback = new GLFWCursorPosCallback() { + @Override + public void invoke(long window, double xpos, double ypos) { + Mouse.addMoveEvent(xpos, ypos); + } + }; + + Window.mouseButtonCallback = new GLFWMouseButtonCallback() { + @Override + public void invoke(long window, int button, int action, int mods) { + Mouse.addButtonEvent(button, action == GLFW.GLFW_PRESS ? true : false); + } + }; + + Window.windowFocusCallback = new GLFWWindowFocusCallback() { + @Override + public void invoke(long window, boolean focused) { + displayFocused = focused == true; + } + }; + + Window.windowIconifyCallback = new GLFWWindowIconifyCallback() { + @Override + public void invoke(long window, boolean iconified) { + displayVisible = iconified == false; + } + }; + + Window.windowSizeCallback = new GLFWWindowSizeCallback() { + @Override + public void invoke(long window, int width, int height) { + latestResized = true; + latestWidth = width; + latestHeight = height; + } + }; + + Window.windowPosCallback = new GLFWWindowPosCallback() { + @Override + public void invoke(long window, int xpos, int ypos) { + displayX = xpos; + displayY = ypos; + } + }; + + Window.windowRefreshCallback = new GLFWWindowRefreshCallback() { + @Override + public void invoke(long window) { + displayDirty = true; + } + }; + + Window.framebufferSizeCallback = new GLFWFramebufferSizeCallback() { + @Override + public void invoke(long window, int width, int height) { + displayFramebufferWidth = width; + displayFramebufferHeight = height; + } + }; + + Window.scrollCallback = new GLFWScrollCallback() { + @Override + public void invoke(long window, double xoffset, double yoffset) { + Mouse.addWheelEvent((int) (yoffset * 120)); + } + }; + + Window.setCallbacks(); + + displayWidth = mode.getWidth(); + displayHeight = mode.getHeight(); + + IntBuffer fbw = BufferUtils.createIntBuffer(1); + IntBuffer fbh = BufferUtils.createIntBuffer(1); + glfwGetFramebufferSize(Window.handle, fbw, fbh); + displayFramebufferWidth = fbw.get(0); + displayFramebufferHeight = fbh.get(0); + + glfwSetWindowPos(Window.handle, (monitorWidth - mode.getWidth()) / 2, (monitorHeight - mode.getHeight()) / 2); + + if (displayX == -1) { + displayX = (monitorWidth - mode.getWidth()) / 2; + } + + if (displayY == -1) { + displayY = (monitorHeight - mode.getHeight()) / 2; + } + + glfwMakeContextCurrent(Window.handle); + context = org.lwjgl.opengl.GLContext.createFromCurrent(); + + glfwSwapInterval(0); + glfwShowWindow(Window.handle); + + Mouse.create(); + Keyboard.create(); + + // glfwSetWindowIcon(Window.handle, icons); + display_impl = new DisplayImplementation() { + + @Override + public void setNativeCursor(Object handle) throws LWJGLException { + try { + Mouse.setNativeCursor((Cursor) handle); + } catch (ClassCastException e) { + throw new LWJGLException("Handle is not an instance of cursor"); + } + } + + @Override + public void setCursorPosition(int x, int y) { + Mouse.setCursorPosition(x, y); + } + + @Override + public void readMouse(ByteBuffer buffer) { + + } + + @Override + public void readKeyboard(ByteBuffer buffer) { + // TODO Auto-generated method stub + + } + + @Override + public void pollMouse(IntBuffer coord_buffer, ByteBuffer buttons) { + + } + + @Override + public void pollKeyboard(ByteBuffer keyDownBuffer) { + // TODO Auto-generated method stub + + } + + @Override + public boolean isInsideWindow() { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean hasWheel() { + // TODO Auto-generated method stub + return false; + } + + @Override + public void grabMouse(boolean grab) { + Mouse.setGrabbed(grab); + } + + @Override + public int getNativeCursorCapabilities() { + // TODO Auto-generated method stub + return 0; + } + + @Override + public int getMinCursorSize() { + // TODO Auto-generated method stub + return 0; + } + + @Override + public int getMaxCursorSize() { + // TODO Auto-generated method stub + return 0; + } + + @Override + public int getButtonCount() { + // TODO Auto-generated method stub + return 0; + } + + @Override + public void destroyMouse() { + // TODO Auto-generated method stub + + } + + @Override + public void destroyKeyboard() { + // TODO Auto-generated method stub + + } + + @Override + public void destroyCursor(Object cursor_handle) { + // TODO Auto-generated method stub + + } + + @Override + public void createMouse() throws LWJGLException { + // TODO Auto-generated method stub + + } + + @Override + public void createKeyboard() throws LWJGLException { + // TODO Auto-generated method stub + + } + + @Override + public Object createCursor(int width, int height, int xHotspot, int yHotspot, int numImages, + IntBuffer images, IntBuffer delays) throws LWJGLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public boolean wasResized() { + // TODO Auto-generated method stub + return false; + } + + @Override + public void update() { + Display.update(); + } + + @Override + public void switchDisplayMode(DisplayMode mode) throws LWJGLException { + Display.setDisplayMode(mode); + } + + @Override + public void setTitle(String title) { + windowTitle = title; + } + + @Override + public void setResizable(boolean resizable) { + Display.setResizable(resizable); + } + + @Override + public void setPbufferAttrib(PeerInfo handle, int attrib, int value) { + // TODO Auto-generated method stub + + } + + @Override + public int setIcon(ByteBuffer[] icons) { + // TODO Auto-generated method stub + Display.setIcon(icons); + return 0; + } + + @Override + public void setGammaRamp(FloatBuffer gammaRamp) throws LWJGLException { + // TODO Auto-generated method stub + + } + + @Override + public void reshape(int x, int y, int width, int height) { + // TODO Auto-generated method stub + + } + + @Override + public void resetDisplayMode() { + try { + Display.setDisplayMode(desktopDisplayMode); + } catch (LWJGLException e) { + } + } + + @Override + public void releaseTexImageFromPbuffer(PeerInfo handle, int buffer) { + // TODO Auto-generated method stub + + } + + @Override + public boolean isVisible() { + // TODO Auto-generated method stub + return Display.displayVisible; + } + + @Override + public boolean isDirty() { + // TODO Auto-generated method stub + return Display.displayDirty; + } + + @Override + public boolean isCloseRequested() { + // TODO Auto-generated method stub + return GLFW.glfwWindowShouldClose(Window.handle); + } + + @Override + public boolean isBufferLost(PeerInfo handle) { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean isActive() { + // TODO Auto-generated method stub + return Display.displayFocused; + } + + @Override + public DisplayMode init() throws LWJGLException { + // TODO Auto-generated method stub + return desktopDisplayMode; + } + + @Override + public int getY() { + // TODO Auto-generated method stub + return Display.displayY; + } + + @Override + public int getX() { + // TODO Auto-generated method stub + return Display.displayX; + } + + @Override + public int getWidth() { + // TODO Auto-generated method stub + return Display.latestWidth; + } + + @Override + public String getVersion() { + // TODO Auto-generated method stub + return Sys.getVersion(); + } + + @Override + public float getPixelScaleFactor() { + // TODO Auto-generated method stub + return 0; + } + + @Override + public int getPbufferCapabilities() { + // TODO Auto-generated method stub + return 0; + } + + @Override + public int getHeight() { + // TODO Auto-generated method stub + return Display.latestHeight; + } + + @Override + public int getGammaRampLength() { + // TODO Auto-generated method stub + return 0; + } + + @Override + public DisplayMode[] getAvailableDisplayModes() throws LWJGLException { + // TODO Auto-generated method stub + return Display.getAvailableDisplayModes(); + } + + @Override + public String getAdapter() { + // TODO Auto-generated method stub + return Display.getAdapter(); + } + + @Override + public void destroyWindow() { + Display.destroy(); + } + + @Override + public void createWindow(DrawableLWJGL drawable, DisplayMode mode, Canvas parent, int x, int y) + throws LWJGLException { + // TODO Auto-generated method stub + + } + + @Override + public PeerInfo createPeerInfo(PixelFormat pixel_format, ContextAttribs attribs) throws LWJGLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public PeerInfo createPbuffer(int width, int height, PixelFormat pixel_format, ContextAttribs attribs, + IntBuffer pixelFormatCaps, IntBuffer pBufferAttribs) throws LWJGLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public void bindTexImageToPbuffer(PeerInfo handle, int buffer) { + // TODO Auto-generated method stub + + } + }; + + displayCreated = true; + + } + + public static boolean isCreated() { + return displayCreated; + } + + public static boolean isActive() { + return displayFocused; + } + + public static boolean isVisible() { + return displayVisible; + } + + public static org.lwjgl.opengl.GLContext getContext() { + return context; + } + + public static void setLocation(int new_x, int new_y) { + if (Window.handle == 0L) { + Display.displayX = new_x; + Display.displayY = new_y; + } else { + GLFW.glfwSetWindowPos(Window.handle, new_x, new_y); + } + } + + public static void setVSyncEnabled(boolean sync) { + vsyncEnabled = sync; + } + + public static long getWindow() { + return Window.handle; + } + + public static void update() { + update(true); + } + + public static void update(boolean processMessages) { + try { + swapBuffers(); + displayDirty = false; + + } catch (LWJGLException e) { + throw new RuntimeException(e); + } + + if (processMessages) + processMessages(); + } + + public static void processMessages() { + glfwPollEvents(); + Keyboard.poll(); + Mouse.poll(); + + if (latestResized) { + latestResized = false; + displayResized = true; + displayWidth = latestWidth; + displayHeight = latestHeight; + } else { + displayResized = false; + } + } + + /** Return the last parent set with setParent(). */ + public static Canvas getParent() { + 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 { + if ( Display.parent != parent ) { + Display.parent = parent; + /* + if ( !isCreated() ) + return; + destroyWindow(); + try { + if ( isFullscreen() ) { + switchDisplayMode(); + } else { + display_impl.resetDisplayMode(); + } + createWindow(); + makeCurrentAndSetSwapInterval(); + } catch (LWJGLException e) { + drawable.destroy(); + display_impl.resetDisplayMode(); + throw e; + } + */ + } + } + + public static void swapBuffers() throws LWJGLException { + glfwSwapBuffers(Window.handle); + } + + public static void destroy() { + Window.releaseCallbacks(); + glfwDestroyWindow(Window.handle); + + displayCreated = false; + } + + public static void setDisplayMode(DisplayMode dm) throws LWJGLException { + mode = dm; + newCurrentWindow(GLFW.glfwCreateWindow(dm.getWidth(), dm.getHeight(), windowTitle, 0, 0)); + } + + public static DisplayMode getDisplayMode() { + return mode; + } + + public static DisplayMode[] getAvailableDisplayModes() throws LWJGLException { + GLFWVidMode.Buffer modes = GLFW.glfwGetVideoModes(GLFW.glfwGetPrimaryMonitor()); + + DisplayMode[] displayModes = new DisplayMode[modes.capacity()]; + + for (int i = 0; i < modes.capacity(); i++) { + modes.position(i); + + int w = modes.width(); + int h = modes.height(); + int b = modes.redBits() + modes.greenBits() + modes.blueBits(); + int r = modes.refreshRate(); + + displayModes[i] = new DisplayMode(w, h, b, r); + } + + return displayModes; + } + + public static DisplayMode getDesktopDisplayMode() { + long mon = GLFW.glfwGetPrimaryMonitor(); + GLFWVidMode mode = GLFW.glfwGetVideoMode(mon); + return new DisplayMode(mode.width(), mode.height(), mode.redBits() + mode.greenBits() + mode.blueBits(), + mode.refreshRate()); + } + + public static boolean wasResized() { + return displayResized; + } + + public static int getX() { + return displayX; + } + + public static int getY() { + return displayY; + } + + public static int getWidth() { + return displayWidth; + } + + public static int getHeight() { + return displayHeight; + } + + public static int getFramebufferWidth() { + return displayFramebufferWidth; + } + + public static int getFramebufferHeight() { + return displayFramebufferHeight; + } + + public static void setTitle(String title) { + windowTitle = title; + } + + public static boolean isCloseRequested() { + return glfwWindowShouldClose(Window.handle) == true; + } + + public static boolean isDirty() { + return displayDirty; + } + + public static void setInitialBackground(float red, float green, float blue) { + // System.out.println("TODO: Implement Display.setInitialBackground(float, float, float)"); + + if (Window.handle != MemoryUtil.NULL) { + GL11.glClearColor(red, green, blue, 1f); + GL11.glClear(GL11.GL_COLOR_BUFFER_BIT); + } + } + + public static int setIcon(java.nio.ByteBuffer[] icons) { + // TODO + try { + if (Window.handle == MemoryUtil.NULL) { + Display.icons = new GLFWImage.Buffer(icons[1]); + } else { + glfwSetWindowIcon(Window.handle, new GLFWImage.Buffer(icons[0])); + } + } catch (NullPointerException e) { + LWJGLUtil.log("Couldn't set icon"); + e.printStackTrace(); + } + return 0; + } + + public static void setResizable(boolean resizable) { + displayResizable = resizable; + if (displayResizable ^ resizable) { + if (Window.handle != 0) { + IntBuffer width = BufferUtils.createIntBuffer(1); + IntBuffer height = BufferUtils.createIntBuffer(1); + GLFW.glfwGetWindowSize(Window.handle, width, height); + width.rewind(); + height.rewind(); + + GLFW.glfwDefaultWindowHints(); + glfwWindowHint(GLFW_VISIBLE, displayVisible ? GL_TRUE : GL_FALSE); + glfwWindowHint(GLFW_RESIZABLE, displayResizable ? GL_TRUE : GL_FALSE); + glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GL_TRUE); + + newCurrentWindow(GLFW.glfwCreateWindow(width.get(), height.get(), windowTitle, + GLFW.glfwGetWindowMonitor(Window.handle), NULL)); + } + } + displayResizable = resizable; + } + + public static boolean isResizable() { + return displayResizable; + } + + public static void setDisplayModeAndFullscreen(DisplayMode mode) throws LWJGLException { + Display.mode = mode; + newCurrentWindow(glfwCreateWindow(mode.getWidth(), mode.getHeight(), windowTitle, + mode.isFullscreenCapable() ? glfwGetPrimaryMonitor() : NULL, NULL)); + } + + public static void setFullscreen(boolean fullscreen) throws LWJGLException { + System.out.println("LWJGLX: switch fullscreen to " + fullscreen); + if (isFullscreen() ^ fullscreen) { + if (fullscreen && (!mode.isFullscreenCapable())) + throw new LWJGLException("Display mode is not fullscreen capable"); + if (Window.handle != 0) { + IntBuffer width = BufferUtils.createIntBuffer(1); + IntBuffer height = BufferUtils.createIntBuffer(1); + glfwGetWindowSize(Window.handle, width, height); + width.rewind(); + height.rewind(); + + glfwDefaultWindowHints(); + glfwWindowHint(GLFW_VISIBLE, displayVisible ? GL_TRUE : GL_FALSE); + glfwWindowHint(GLFW_RESIZABLE, displayResizable ? GL_TRUE : GL_FALSE); + glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GL_TRUE); + + if (fullscreen) + newCurrentWindow(glfwCreateWindow(width.get(), height.get(), windowTitle, + glfwGetPrimaryMonitor(), NULL)); + else + newCurrentWindow(glfwCreateWindow(width.get(), height.get(), windowTitle, NULL, NULL)); + } + } + displayFullscreen = fullscreen; + } + + public static boolean isFullscreen() { + return displayFullscreen; + } + + public static void releaseContext() throws LWJGLException { + glfwMakeContextCurrent(0); + } + + public static boolean isCurrent() throws LWJGLException { + return glfwGetCurrentContext() == Window.handle; + } + + public static void makeCurrent() throws LWJGLException { + if (!isCurrent()) { + // -glfwMakeContextCurrent(Window.handle); + } + } + + public static java.lang.String getAdapter() { + // TODO + return "GeNotSupportedAdapter"; + } + + public static java.lang.String getVersion() { + // TODO + return "1.0 NOT SUPPORTED"; + } + + /** + * An accurate sync method that will attempt to run at a constant frame + * rate. It should be called once every frame. + * + * @param fps + * - the desired frame rate, in frames per second + */ + public static void sync(int fps) { + if (vsyncEnabled) + Sync.sync(fps); + } + + public static Drawable getDrawable() { + return drawable; + } + + static DisplayImplementation getImplementation() { + return display_impl; + } + + private static void newCurrentWindow(long newWindow) { + if (Window.handle != MemoryUtil.NULL) + glfwDestroyWindow(Window.handle); + Window.handle = newWindow; + try { + Mouse.setNativeCursor(Mouse.getCurrentCursor()); + } catch (LWJGLException e) { + System.err.println("Failed to set new window cursor!"); + e.printStackTrace(); + } + GLFW.glfwSetWindowTitle(newWindow, windowTitle); + Window.setCallbacks(); + + // glfwMakeContextCurrent(Window.handle); + context = org.lwjgl.opengl.GLContext.createFromCurrent(); + + glfwSwapInterval(0); + glfwShowWindow(Window.handle); + } + + static class Window { + static long handle; + + static GLFWKeyCallback keyCallback; + static GLFWCharCallback charCallback; + static GLFWCursorEnterCallback cursorEnterCallback; + static GLFWCursorPosCallback cursorPosCallback; + static GLFWMouseButtonCallback mouseButtonCallback; + static GLFWWindowFocusCallback windowFocusCallback; + static GLFWWindowIconifyCallback windowIconifyCallback; + static GLFWWindowSizeCallback windowSizeCallback; + static GLFWWindowPosCallback windowPosCallback; + static GLFWWindowRefreshCallback windowRefreshCallback; + static GLFWFramebufferSizeCallback framebufferSizeCallback; + static GLFWScrollCallback scrollCallback; + + public static void setCallbacks() { + glfwSetKeyCallback(handle, keyCallback); + glfwSetCharCallback(handle, charCallback); + glfwSetCursorEnterCallback(handle, cursorEnterCallback); + glfwSetCursorPosCallback(handle, cursorPosCallback); + glfwSetMouseButtonCallback(handle, mouseButtonCallback); + glfwSetWindowFocusCallback(handle, windowFocusCallback); + glfwSetWindowIconifyCallback(handle, windowIconifyCallback); + glfwSetWindowSizeCallback(handle, windowSizeCallback); + glfwSetWindowPosCallback(handle, windowPosCallback); + glfwSetWindowRefreshCallback(handle, windowRefreshCallback); + glfwSetFramebufferSizeCallback(handle, framebufferSizeCallback); + glfwSetScrollCallback(handle, scrollCallback); + } + + public static void releaseCallbacks() { + Callbacks.glfwFreeCallbacks(handle); + keyCallback = null; + charCallback = null; + cursorEnterCallback = null; + cursorPosCallback = null; + mouseButtonCallback = null; + windowFocusCallback = null; + windowIconifyCallback = null; + windowSizeCallback = null; + windowPosCallback = null; + windowRefreshCallback = null; + framebufferSizeCallback = null; + scrollCallback = null; + System.gc(); + } + } + +} diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/opengl/DisplayImplementation.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/opengl/DisplayImplementation.java new file mode 100644 index 000000000..7f76555f2 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/opengl/DisplayImplementation.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.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(DrawableLWJGL drawable, 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, ContextAttribs attribs) 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, ContextAttribs attribs, + 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); + + /** + * Enable or disable the Display window to be resized. + * + * @param resizable set to true to make the Display window resizable; + * false to disable resizing on the Display window. + */ + void setResizable(boolean resizable); + + /** + * @return true if the Display window has been resized since this method was last called. + */ + boolean wasResized(); + + /** + * @return this method will return the width of the Display window. + */ + int getWidth(); + + /** + * @return this method will return the height of the Display window. + */ + int getHeight(); + + /** + * @return this method will return the top-left x position of the Display window. + */ + int getX(); + + /** + * @return this method will return the top-left y position of the Display window. + */ + int getY(); + + /** + * @return this method will return the pixel scale factor of the Display window useful for high resolution modes. + */ + float getPixelScaleFactor(); +} diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/opengl/DisplayMode.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/opengl/DisplayMode.java new file mode 100644 index 000000000..23bd84aca --- /dev/null +++ b/jre_lwjgl3glfw/src/main/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$ + * $Id$ + */ + +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 if 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() { + StringBuilder sb = new StringBuilder(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/jre_lwjgl3glfw/src/main/java/org/lwjgl/opengl/Drawable.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/opengl/Drawable.java new file mode 100644 index 000000000..d5fdc4b82 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/opengl/Drawable.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.LWJGLException; +import org.lwjgl.PointerBuffer; + +/** + * The Drawable interface describes an OpenGL drawable with an associated + * Context. + * + * @author elias_naur + */ + +public interface Drawable { + + /** Returns true if the Drawable's context is current in the current thread. */ + boolean isCurrent() throws LWJGLException; + + /** + * Makes the Drawable's context current in the current thread. + * + * @throws LWJGLException + */ + void makeCurrent() throws LWJGLException; + + /** + * If the Drawable's context is current in the current thread, no context will be current after a call to this method. + * + * @throws LWJGLException + */ + void releaseContext() throws LWJGLException; + + /** Destroys the Drawable. */ + void destroy(); + + /** + * Sets the appropriate khr_gl_sharing properties in the target PointerBuffer, + * so that if it is used in a clCreateContext(FromType) call, the created CL + * context will be sharing objects with this Drawable's GL context. After a + * call to this method, the target buffer position will have advanced by 2 to 4 positions, + * depending on the implementation. + * + * @param properties The target properties buffer. It must have at least 4 positions remaining. + */ + void setCLSharingProperties(PointerBuffer properties) throws LWJGLException; + +} diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/opengl/DrawableGL.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/opengl/DrawableGL.java new file mode 100644 index 000000000..85b9bbce8 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/opengl/DrawableGL.java @@ -0,0 +1,156 @@ +/* + * Copyright (c) 2002-2011 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) 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.PointerBuffer; + +import static org.lwjgl.opengl.GL11.*; + +/** @author Spasi */ +abstract class DrawableGL implements DrawableLWJGL { + + /** The PixelFormat used to create the drawable. */ + protected PixelFormat pixel_format; + + /** Handle to the native GL rendering context */ + protected PeerInfo peer_info; + + /** The OpenGL Context. */ + protected ContextGL context; + + protected DrawableGL() { + } + + public void setPixelFormat(final PixelFormatLWJGL pf) throws LWJGLException { + throw new UnsupportedOperationException(); + } + + public void setPixelFormat(final PixelFormatLWJGL pf, final ContextAttribs attribs) throws LWJGLException { + this.pixel_format = (PixelFormat)pf; + this.peer_info = Display.getImplementation().createPeerInfo(pixel_format, attribs); + } + + public PixelFormatLWJGL getPixelFormat() { + return pixel_format; + } + + public ContextGL getContext() { + synchronized ( GlobalLock.lock ) { + return context; + } + } + + public ContextGL createSharedContext() throws LWJGLException { + synchronized ( GlobalLock.lock ) { + checkDestroyed(); + return new ContextGL(peer_info, context.getContextAttribs(), context); + // return null; + } + } + + public void checkGLError() { + Util.checkGLError(); + } + + public void setSwapInterval(final int swap_interval) { + ContextGL.setSwapInterval(swap_interval); + } + + public void swapBuffers() throws LWJGLException { + ContextGL.swapBuffers(); + } + + public void initContext(final float r, final float g, final float b) { + // set background clear color + glClearColor(r, g, b, 0.0f); + // Clear window to avoid the desktop "showing through" + glClear(GL_COLOR_BUFFER_BIT); + } + + public boolean isCurrent() throws LWJGLException { + synchronized ( GlobalLock.lock ) { + checkDestroyed(); + return context.isCurrent(); + } + } + + public void makeCurrent() throws LWJGLException { + synchronized ( GlobalLock.lock ) { + checkDestroyed(); + context.makeCurrent(); + } + } + + public void releaseContext() throws LWJGLException { + synchronized ( GlobalLock.lock ) { + checkDestroyed(); + if ( context.isCurrent() ) + context.releaseCurrent(); + } + } + + public void destroy() { + synchronized ( GlobalLock.lock ) { + if ( context == null ) + return; + + try { + releaseContext(); + + context.forceDestroy(); + context = null; + + if ( peer_info != null ) { + peer_info.destroy(); + peer_info = null; + } + } catch (LWJGLException e) { + LWJGLUtil.log("Exception occurred while destroying Drawable: " + e); + } + } + } + + public void setCLSharingProperties(final PointerBuffer properties) throws LWJGLException { + synchronized ( GlobalLock.lock ) { + checkDestroyed(); + context.setCLSharingProperties(properties); + } + } + + protected final void checkDestroyed() { + if ( context == null ) + throw new IllegalStateException("The Drawable has no context available."); + } + +} diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/opengl/DrawableLWJGL.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/opengl/DrawableLWJGL.java new file mode 100644 index 000000000..f80ad4645 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/opengl/DrawableLWJGL.java @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2002-2011 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) 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; + +/** + * [INTERNAL USE ONLY] + * + * @author Spasi + */ +interface DrawableLWJGL extends Drawable { + + void setPixelFormat(PixelFormatLWJGL pf) throws LWJGLException; + + void setPixelFormat(PixelFormatLWJGL pf, ContextAttribs attribs) throws LWJGLException; + + PixelFormatLWJGL getPixelFormat(); + + /** + * [INTERNAL USE ONLY] Returns the Drawable's Context. + * + * @return the Drawable's Context + */ + Context getContext(); + + /** + * [INTERNAL USE ONLY] Creates a new Context that is shared with the Drawable's Context. + * + * @return a Context shared with the Drawable's Context. + */ + Context createSharedContext() throws LWJGLException; + + void checkGLError(); + + void setSwapInterval(int swap_interval); + + void swapBuffers() throws LWJGLException; + + void initContext(final float r, final float g, final float b); + +} diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/opengl/EXTAbgr.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/opengl/EXTAbgr.java new file mode 100644 index 000000000..606f4a08e --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/opengl/EXTAbgr.java @@ -0,0 +1,7 @@ +package org.lwjgl.opengl; + +import org.lwjgl.opengl.EXTABGR; + +public class EXTAbgr { + public final static int GL_ABGR_EXT = EXTABGR.GL_ABGR_EXT; +} diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/opengl/EXTTextureRectangle.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/opengl/EXTTextureRectangle.java new file mode 100644 index 000000000..ba3c9c5c0 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/opengl/EXTTextureRectangle.java @@ -0,0 +1,8 @@ +package org.lwjgl.opengl; + +public class EXTTextureRectangle { + public final static int GL_MAX_RECTANGLE_TEXTURE_SIZE_EXT = 34040; + public final static int GL_PROXY_TEXTURE_RECTANGLE_EXT = 34039; + public final static int GL_TEXTURE_BINDING_RECTANGLE_EXT = 34038; + public final static int GL_TEXTURE_RECTANGLE_EXT = 34037; +} diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/opengl/GL.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/opengl/GL.java new file mode 100644 index 000000000..c86cd67c3 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/opengl/GL.java @@ -0,0 +1,743 @@ +/* + * Copyright LWJGL. All rights reserved. + * License terms: https://www.lwjgl.org/license + */ +package org.lwjgl.opengl; + +import org.lwjgl.system.*; +import org.lwjgl.system.macosx.*; +import org.lwjgl.system.windows.*; +import org.lwjgl.glfw.*; + +import javax.annotation.*; +import java.nio.*; +import java.util.*; + +import static java.lang.Math.*; +import static org.lwjgl.opengl.GL32C.*; +import static org.lwjgl.opengl.GLX.*; +import static org.lwjgl.opengl.GLX11.*; +import static org.lwjgl.opengl.WGL.*; +import static org.lwjgl.system.APIUtil.*; +import static org.lwjgl.system.Checks.*; +import static org.lwjgl.system.JNI.*; +import static org.lwjgl.system.MemoryStack.*; +import static org.lwjgl.system.MemoryUtil.*; +import static org.lwjgl.system.linux.X11.*; +import static org.lwjgl.system.windows.GDI32.*; +import static org.lwjgl.system.windows.User32.*; +import static org.lwjgl.system.windows.WindowsUtil.*; + +/** + * This class must be used before any OpenGL function is called. It has the following responsibilities: + *
    + *
  • Loads the OpenGL native library into the JVM process.
  • + *
  • Creates instances of {@link GLCapabilities} classes. A {@code GLCapabilities} instance contains flags for functionality that is available in an OpenGL + * context. Internally, it also contains function pointers that are only valid in that specific OpenGL context.
  • + *
  • Maintains thread-local state for {@code GLCapabilities} instances, corresponding to OpenGL contexts that are current in those threads.
  • + *
+ * + *

Library lifecycle

+ *

The OpenGL library is loaded automatically when this class is initialized. Set the {@link Configuration#OPENGL_EXPLICIT_INIT} option to override this + * behavior. Manual loading/unloading can be achieved with the {@link #create} and {@link #destroy} functions. The name of the library loaded can be overridden + * with the {@link Configuration#OPENGL_LIBRARY_NAME} option. The maximum OpenGL version loaded can be set with the {@link Configuration#OPENGL_MAXVERSION} + * option. This can be useful to ensure that no functionality above a specific version is used during development.

+ * + *

GLCapabilities creation

+ *

Instances of {@code GLCapabilities} can be created with the {@link #createCapabilities} method. An OpenGL context must be current in the current thread + * before it is called. Calling this method is expensive, so the {@code GLCapabilities} instance should be associated with the OpenGL context and reused as + * necessary.

+ * + *

Thread-local state

+ *

Before a function for a given OpenGL context can be called, the corresponding {@code GLCapabilities} instance must be passed to the + * {@link #setCapabilities} method. The user is also responsible for clearing the current {@code GLCapabilities} instance when the context is destroyed or made + * current in another thread.

+ * + *

Note that the {@link #createCapabilities} method implicitly calls {@link #setCapabilities} with the newly created instance.

+ */ +public final class GL { + + @Nullable + private static final APIVersion MAX_VERSION; + + @Nullable + private static FunctionProvider functionProvider; + + private static final ThreadLocal capabilitiesTLS = new ThreadLocal<>(); + + private static ICD icd = new ICDStatic(); + + @Nullable + private static WGLCapabilities capabilitiesWGL; + + @Nullable + private static GLXCapabilities capabilitiesGLXClient; + @Nullable + private static GLXCapabilities capabilitiesGLX; + + private static final boolean isUsingRegal; + + static { + isUsingRegal = System.getProperty("org.lwjgl.opengl.libname").contains("libRegal.so"); + // if (isUsingRegal) + + + Library.loadSystem(System::load, System::loadLibrary, GL.class, "org.lwjgl.opengl", Platform.mapLibraryNameBundled("lwjgl_opengl")); + + MAX_VERSION = apiParseVersion(Configuration.OPENGL_MAXVERSION); + + if (!Configuration.OPENGL_EXPLICIT_INIT.get(false)) { + create(); + } + } + + private static native void nativeRegalMakeCurrent(); + + private GL() {} + + /** Ensures that the lwjgl_opengl shared library has been loaded. */ + static void initialize() { + // intentionally empty to trigger static initializer + } + + /** Loads the OpenGL native library, using the default library name. */ + public static void create() { + SharedLibrary GL; + switch (Platform.get()) { + case LINUX: + GL = Library.loadNative(GL.class, "org.lwjgl.opengl", Configuration.OPENGL_LIBRARY_NAME, "libGL.so.1", "libGL.so"); + break; + case MACOSX: + String override = Configuration.OPENGL_LIBRARY_NAME.get(); + GL = override != null + ? Library.loadNative(GL.class, "org.lwjgl.opengl", override) + : MacOSXLibrary.getWithIdentifier("com.apple.opengl"); + break; + case WINDOWS: + GL = Library.loadNative(GL.class, "org.lwjgl.opengl", Configuration.OPENGL_LIBRARY_NAME, "opengl32"); + break; + default: + throw new IllegalStateException(); + } + create(GL); + } + + /** + * Loads the OpenGL native library, using the specified library name. + * + * @param libName the native library name + */ + public static void create(String libName) { + create(Library.loadNative(GL.class, "org.lwjgl.opengl", libName)); + } + + private abstract static class SharedLibraryGL extends SharedLibrary.Delegate { + + SharedLibraryGL(SharedLibrary library) { + super(library); + } + abstract long getExtensionAddress(long name); + + @Override + public long getFunctionAddress(ByteBuffer functionName) { + long address = getExtensionAddress(memAddress(functionName)); + if (address == NULL) { + address = library.getFunctionAddress(functionName); + if (address == NULL && DEBUG_FUNCTIONS) { + apiLog("Failed to locate address for GL function " + memASCII(functionName)); + } + } + + return address; + } + + } + + private static void create(SharedLibrary OPENGL) { + FunctionProvider functionProvider; + try { + switch (Platform.get()) { + case WINDOWS: + functionProvider = new SharedLibraryGL(OPENGL) { + private final long wglGetProcAddress = library.getFunctionAddress("wglGetProcAddress"); + + @Override + long getExtensionAddress(long name) { + return callPP(name, wglGetProcAddress); + } + }; + break; + case LINUX: + functionProvider = new SharedLibraryGL(OPENGL) { + private final long glXGetProcAddress; + + { + long GetProcAddress = library.getFunctionAddress(isUsingRegal ? "glGetProcAddressREGAL" : "glXGetProcAddress"); + if (GetProcAddress == NULL) { + GetProcAddress = library.getFunctionAddress("glXGetProcAddressARB"); + } + + glXGetProcAddress = GetProcAddress; + } + + @Override + long getExtensionAddress(long name) { + return glXGetProcAddress == NULL ? NULL : callPP(name, glXGetProcAddress); + } + }; + break; + case MACOSX: + functionProvider = new SharedLibraryGL(OPENGL) { + @Override + long getExtensionAddress(long name) { + return NULL; + } + }; + break; + default: + throw new IllegalStateException(); + } + create(functionProvider); + } catch (RuntimeException e) { + OPENGL.free(); + throw e; + } + } + + /** + * Initializes OpenGL with the specified {@link FunctionProvider}. This method can be used to implement custom OpenGL library loading. + * + * @param functionProvider the provider of OpenGL function addresses + */ + public static void create(FunctionProvider functionProvider) { + if (GL.functionProvider != null) { + throw new IllegalStateException("OpenGL library has already been loaded."); + } + + GL.functionProvider = functionProvider; + ThreadLocalUtil.setFunctionMissingAddresses(GLCapabilities.class, 3); + } + + /** Unloads the OpenGL native library. */ + public static void destroy() { + if (functionProvider == null) { + return; + } + + ThreadLocalUtil.setFunctionMissingAddresses(null, 3); + + capabilitiesWGL = null; + capabilitiesGLX = null; + + if (functionProvider instanceof NativeResource) { + ((NativeResource)functionProvider).free(); + } + functionProvider = null; + } + + /** Returns the {@link FunctionProvider} for the OpenGL native library. */ + @Nullable + public static FunctionProvider getFunctionProvider() { + return functionProvider; + } + + /** + * Sets the {@link GLCapabilities} of the OpenGL context that is current in the current thread. + * + *

This {@code GLCapabilities} instance will be used by any OpenGL call in the current thread, until {@code setCapabilities} is called again with a + * different value.

+ */ + public static void setCapabilities(@Nullable GLCapabilities caps) { + capabilitiesTLS.set(caps); + ThreadLocalUtil.setEnv(caps == null ? NULL : memAddress(caps.addresses), 3); + icd.set(caps); + } + + /** + * Returns the {@link GLCapabilities} of the OpenGL context that is current in the current thread. + * + * @throws IllegalStateException if {@link #setCapabilities} has never been called in the current thread or was last called with a {@code null} value + */ + public static GLCapabilities getCapabilities() { + return checkCapabilities(capabilitiesTLS.get()); + } + + private static GLCapabilities checkCapabilities(@Nullable GLCapabilities caps) { + if (CHECKS && caps == null) { + throw new IllegalStateException( + "No GLCapabilities instance set for the current thread. Possible solutions:\n" + + "\ta) Call GL.createCapabilities() after making a context current in the current thread.\n" + + "\tb) Call GL.setCapabilities() if a GLCapabilities instance already exists for the current context." + ); + } + //noinspection ConstantConditions + return caps; + } + + /** + * Returns the WGL capabilities. + * + *

This method may only be used on Windows.

+ */ + public static WGLCapabilities getCapabilitiesWGL() { + if (capabilitiesWGL == null) { + capabilitiesWGL = createCapabilitiesWGLDummy(); + } + + return capabilitiesWGL; + } + + /** Returns the GLX client capabilities. */ + static GLXCapabilities getCapabilitiesGLXClient() { + if (capabilitiesGLXClient == null) { + capabilitiesGLXClient = initCapabilitiesGLX(true); + } + + return capabilitiesGLXClient; + } + + /** + * Returns the GLX capabilities. + * + *

This method may only be used on Linux.

+ */ + public static GLXCapabilities getCapabilitiesGLX() { + if (capabilitiesGLX == null) { + capabilitiesGLX = initCapabilitiesGLX(false); + } + + return capabilitiesGLX; + } + + private static GLXCapabilities initCapabilitiesGLX(boolean client) { + long display = nXOpenDisplay(NULL); + try { + return createCapabilitiesGLX(display, client ? -1 : XDefaultScreen(display)); + } finally { + XCloseDisplay(display); + } + } + + /** + * Creates a new {@link GLCapabilities} instance for the OpenGL context that is current in the current thread. + * + *

Depending on the current context, the instance returned may or may not contain the deprecated functionality removed since OpenGL version 3.1.

+ * + *

This method calls {@link #setCapabilities(GLCapabilities)} with the new instance before returning.

+ * + * @return the GLCapabilities instance + */ + public static GLCapabilities createCapabilities() { + return createCapabilities(false); + } + + /** + * Creates a new {@link GLCapabilities} instance for the OpenGL context that is current in the current thread. + * + *

Depending on the current context, the instance returned may or may not contain the deprecated functionality removed since OpenGL version 3.1. The + * {@code forwardCompatible} flag will force LWJGL to not load the deprecated functions, even if the current context exposes them.

+ * + *

This method calls {@link #setCapabilities(GLCapabilities)} with the new instance before returning.

+ * + * @param forwardCompatible if true, LWJGL will create forward compatible capabilities + * + * @return the GLCapabilities instance + */ + @SuppressWarnings("AssignmentToMethodParameter") + public static GLCapabilities createCapabilities(boolean forwardCompatible) { + // This fixed framebuffer issue on 1.13+ 64-bit by another making current + GLFW.nativeEglMakeCurrent(1); + + if (isUsingRegal /* && Long.parseLong(System.getProperty("glfwstub.internal.glthreadid", "-1")) != Thread.currentThread().getId() */) { + nativeRegalMakeCurrent(); + } + // System.setProperty("glfwstub.internal.glthreadid", Long.toString(Thread.currentThread().getId())); + + FunctionProvider functionProvider = GL.functionProvider; + if (functionProvider == null) { + throw new IllegalStateException("OpenGL library has not been loaded."); + } + + GLCapabilities caps = null; + + try { + // We don't have a current ContextCapabilities when this method is called + // so we have to use the native bindings directly. + long GetError = functionProvider.getFunctionAddress("glGetError"); + long GetString = functionProvider.getFunctionAddress("glGetString"); + long GetIntegerv = functionProvider.getFunctionAddress("glGetIntegerv"); + + if (GetError == NULL || GetString == NULL || GetIntegerv == NULL) { + throw new IllegalStateException("Core OpenGL functions could not be found. Make sure that the OpenGL library has been loaded correctly."); + } + + int errorCode = callI(GetError); + if (errorCode != GL_NO_ERROR) { + apiLog(String.format("An OpenGL context was in an error state before the creation of its capabilities instance. Error: 0x%X", errorCode)); + } + + int majorVersion; + int minorVersion; + + try (MemoryStack stack = stackPush()) { + IntBuffer version = stack.ints(0); + + // Try the 3.0+ version query first + callPV(GL_MAJOR_VERSION, memAddress(version), GetIntegerv); + if (callI(GetError) == GL_NO_ERROR && 3 <= (majorVersion = version.get(0))) { + // We're on an 3.0+ context. + callPV(GL_MINOR_VERSION, memAddress(version), GetIntegerv); + minorVersion = version.get(0); + } else { + // Fallback to the string query. + String versionString = memUTF8Safe(callP(GL_VERSION, GetString)); + if (versionString == null || callI(GetError) != GL_NO_ERROR) { + throw new IllegalStateException("There is no OpenGL context current in the current thread."); + } + + APIVersion apiVersion = apiParseVersion(versionString); + + majorVersion = apiVersion.major; + minorVersion = apiVersion.minor; + } + } + + if (majorVersion < 1 || (majorVersion == 1 && minorVersion < 1)) { + throw new IllegalStateException("OpenGL 1.1 is required."); + } + + int[] GL_VERSIONS = { + 5, // OpenGL 1.1 to 1.5 + 1, // OpenGL 2.0 to 2.1 + 3, // OpenGL 3.0 to 3.3 + 6, // OpenGL 4.0 to 4.6 + }; + + Set supportedExtensions = new HashSet<>(512); + + int maxMajor = min(majorVersion, GL_VERSIONS.length); + if (MAX_VERSION != null) { + maxMajor = min(MAX_VERSION.major, maxMajor); + } + for (int M = 1; M <= maxMajor; M++) { + int maxMinor = GL_VERSIONS[M - 1]; + if (M == majorVersion) { + maxMinor = min(minorVersion, maxMinor); + } + if (MAX_VERSION != null && M == MAX_VERSION.major) { + maxMinor = min(MAX_VERSION.minor, maxMinor); + } + + for (int m = M == 1 ? 1 : 0; m <= maxMinor; m++) { + supportedExtensions.add(String.format("OpenGL%d%d", M, m)); + } + } + + if (majorVersion < 3) { + // Parse EXTENSIONS string + String extensionsString = memASCIISafe(callP(GL_EXTENSIONS, GetString)); + if (extensionsString != null) { + StringTokenizer tokenizer = new StringTokenizer(extensionsString); + while (tokenizer.hasMoreTokens()) { + supportedExtensions.add(tokenizer.nextToken()); + } + } + } else { + // Use indexed EXTENSIONS + try (MemoryStack stack = stackPush()) { + IntBuffer pi = stack.ints(0); + + callPV(GL_NUM_EXTENSIONS, memAddress(pi), GetIntegerv); + int extensionCount = pi.get(0); + + long GetStringi = apiGetFunctionAddress(functionProvider, "glGetStringi"); + for (int i = 0; i < extensionCount; i++) { + supportedExtensions.add(memASCII(callP(GL_EXTENSIONS, i, GetStringi))); + } + + // In real drivers, we may encounter the following weird scenarios: + // - 3.1 context without GL_ARB_compatibility but with deprecated functionality exposed and working. + // - Core or forward-compatible context with GL_ARB_compatibility exposed, but not working when used. + // We ignore these and go by the spec. + + // Force forwardCompatible to true if the context is a forward-compatible context. + callPV(GL_CONTEXT_FLAGS, memAddress(pi), GetIntegerv); + if ((pi.get(0) & GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT) != 0) { + forwardCompatible = true; + } else { + // Force forwardCompatible to true if the context is a core profile context. + if ((3 < majorVersion || 1 <= minorVersion)) { // OpenGL 3.1+ + if (3 < majorVersion || 2 <= minorVersion) { // OpenGL 3.2+ + callPV(GL_CONTEXT_PROFILE_MASK, memAddress(pi), GetIntegerv); + if ((pi.get(0) & GL_CONTEXT_CORE_PROFILE_BIT) != 0) { + forwardCompatible = true; + } + } else { + forwardCompatible = !supportedExtensions.contains("GL_ARB_compatibility"); + } + } + } + } + } + + return caps = new GLCapabilities(functionProvider, supportedExtensions, forwardCompatible); + } finally { + setCapabilities(caps); + } + } + + /** Creates a dummy context and retrieves the WGL capabilities. */ + private static WGLCapabilities createCapabilitiesWGLDummy() { + long hdc = wglGetCurrentDC(); // just use the current context if one exists + if (hdc != NULL) { + return createCapabilitiesWGL(hdc); + } + + short classAtom = 0; + long hwnd = NULL; + long hglrc = NULL; + try (MemoryStack stack = stackPush()) { + WNDCLASSEX wc = WNDCLASSEX.callocStack(stack) + .cbSize(WNDCLASSEX.SIZEOF) + .style(CS_HREDRAW | CS_VREDRAW) + .hInstance(WindowsLibrary.HINSTANCE) + .lpszClassName(stack.UTF16("WGL")); + + memPutAddress( + wc.address() + WNDCLASSEX.LPFNWNDPROC, + User32.Functions.DefWindowProc + ); + + classAtom = RegisterClassEx(wc); + if (classAtom == 0) { + throw new IllegalStateException("Failed to register WGL window class"); + } + + hwnd = check(nCreateWindowEx( + 0, classAtom & 0xFFFF, NULL, + WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, + 0, 0, 1, 1, + NULL, NULL, NULL, NULL + )); + + hdc = check(GetDC(hwnd)); + + PIXELFORMATDESCRIPTOR pfd = PIXELFORMATDESCRIPTOR.callocStack(stack) + .nSize((short)PIXELFORMATDESCRIPTOR.SIZEOF) + .nVersion((short)1) + .dwFlags(PFD_SUPPORT_OPENGL); // we don't care about anything else + + int pixelFormat = ChoosePixelFormat(hdc, pfd); + if (pixelFormat == 0) { + windowsThrowException("Failed to choose an OpenGL-compatible pixel format"); + } + + if (DescribePixelFormat(hdc, pixelFormat, pfd) == 0) { + windowsThrowException("Failed to obtain pixel format information"); + } + + if (!SetPixelFormat(hdc, pixelFormat, pfd)) { + windowsThrowException("Failed to set the pixel format"); + } + + hglrc = check(wglCreateContext(hdc)); + wglMakeCurrent(hdc, hglrc); + + return createCapabilitiesWGL(hdc); + } finally { + if (hglrc != NULL) { + wglMakeCurrent(NULL, NULL); + wglDeleteContext(hglrc); + } + + if (hwnd != NULL) { + DestroyWindow(hwnd); + } + + if (classAtom != 0) { + nUnregisterClass(classAtom & 0xFFFF, WindowsLibrary.HINSTANCE); + } + } + } + + /** + * Creates a {@link WGLCapabilities} instance for the context that is current in the current thread. + * + *

This method may only be used on Windows.

+ */ + public static WGLCapabilities createCapabilitiesWGL() { + long hdc = wglGetCurrentDC(); + if (hdc == NULL) { + throw new IllegalStateException("Failed to retrieve the device context of the current OpenGL context"); + } + + return createCapabilitiesWGL(hdc); + } + + /** + * Creates a {@link WGLCapabilities} instance for the specified device context. + * + * @param hdc the device context handle ({@code HDC}) + */ + private static WGLCapabilities createCapabilitiesWGL(long hdc) { + FunctionProvider functionProvider = GL.functionProvider; + if (functionProvider == null) { + throw new IllegalStateException("OpenGL library has not been loaded."); + } + + String extensionsString = null; + + long wglGetExtensionsString = functionProvider.getFunctionAddress("wglGetExtensionsStringARB"); + if (wglGetExtensionsString != NULL) { + extensionsString = memASCII(callPP(hdc, wglGetExtensionsString)); + } else { + wglGetExtensionsString = functionProvider.getFunctionAddress("wglGetExtensionsStringEXT"); + if (wglGetExtensionsString != NULL) { + extensionsString = memASCII(callP(wglGetExtensionsString)); + } + } + + Set supportedExtensions = new HashSet<>(32); + + if (extensionsString != null) { + StringTokenizer tokenizer = new StringTokenizer(extensionsString); + while (tokenizer.hasMoreTokens()) { + supportedExtensions.add(tokenizer.nextToken()); + } + } + + return new WGLCapabilities(functionProvider, supportedExtensions); + } + + /** + * Creates a {@link GLXCapabilities} instance for the default screen of the specified X connection. + * + *

This method may only be used on Linux.

+ * + * @param display the X connection handle ({@code DISPLAY}) + */ + public static GLXCapabilities createCapabilitiesGLX(long display) { + return createCapabilitiesGLX(display, XDefaultScreen(display)); + } + + /** + * Creates a {@link GLXCapabilities} instance for the specified screen of the specified X connection. + * + *

This method may only be used on Linux.

+ * + * @param display the X connection handle ({@code DISPLAY}) + * @param screen the screen index + */ + public static GLXCapabilities createCapabilitiesGLX(long display, int screen) { + FunctionProvider functionProvider = GL.functionProvider; + if (functionProvider == null) { + throw new IllegalStateException("OpenGL library has not been loaded."); + } + + int majorVersion = 1; + int minorVersion = 4; + + Set supportedExtensions = new HashSet<>(32); + + int[][] GLX_VERSIONS = { + {1, 2, 3, 4} + }; + + try (MemoryStack stack = stackPush()) { + IntBuffer piMajor = stack.ints(0); + IntBuffer piMinor = stack.ints(0); + + if (!glXQueryVersion(display, piMajor, piMinor)) { + throw new IllegalStateException("Failed to query GLX version"); + } + + majorVersion = piMajor.get(0); + minorVersion = piMinor.get(0); + if (majorVersion != 1) { + throw new IllegalStateException("Invalid GLX major version: " + majorVersion); + } + } + + for (int major = 1; major <= GLX_VERSIONS.length; major++) { + int[] minors = GLX_VERSIONS[major - 1]; + for (int minor : minors) { + if (major < majorVersion || (major == majorVersion && minor <= minorVersion)) { + supportedExtensions.add("GLX" + major + minor); + } + } + } + + if (1 <= minorVersion) { + String extensionsString; + + if (screen == -1) { + long glXGetClientString = functionProvider.getFunctionAddress("glXGetClientString"); + extensionsString = memASCIISafe(callPP(display, GLX_EXTENSIONS, glXGetClientString)); + } else { + long glXQueryExtensionsString = functionProvider.getFunctionAddress("glXQueryExtensionsString"); + extensionsString = memASCIISafe(callPP(display, screen, glXQueryExtensionsString)); + } + + if (extensionsString != null) { + StringTokenizer tokenizer = new StringTokenizer(extensionsString); + while (tokenizer.hasMoreTokens()) { + supportedExtensions.add(tokenizer.nextToken()); + } + } + } + + return new GLXCapabilities(functionProvider, supportedExtensions); + } + + // Only used by array overloads + static GLCapabilities getICD() { + return checkCapabilities(icd.get()); + } + + /** Function pointer provider. */ + private interface ICD { + default void set(@Nullable GLCapabilities caps) {} + @Nullable GLCapabilities get(); + } + + /** + * Write-once {@link ICD}. + * + *

This is the default implementation that skips the thread-local lookup. When a new GLCapabilities is set, we compare it to the write-once capabilities. + * If different function pointers are found, we fall back to the expensive lookup.

+ */ + private static class ICDStatic implements ICD { + + @Nullable + private static GLCapabilities tempCaps; + + @Override + public void set(@Nullable GLCapabilities caps) { + if (tempCaps == null) { + tempCaps = caps; + } else if (caps != null && caps != tempCaps && ThreadLocalUtil.areCapabilitiesDifferent(tempCaps.addresses, caps.addresses)) { + apiLog("[WARNING] Incompatible context detected. Falling back to thread-local lookup for GL contexts."); + icd = GL::getCapabilities; // fall back to thread/process lookup + } + } + + @Override + public GLCapabilities get() { + return WriteOnce.caps; + } + + private static final class WriteOnce { + // This will be initialized the first time get() above is called + @Nullable + static final GLCapabilities caps = ICDStatic.tempCaps; + + static { + if (caps == null) { + throw new IllegalStateException("No GLCapabilities instance has been set"); + } + } + } + + } + +} diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/opengl/GL11.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/opengl/GL11.java new file mode 100644 index 000000000..32835e5e2 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/opengl/GL11.java @@ -0,0 +1,10225 @@ +/* + * Copyright LWJGL. All rights reserved. + * License terms: https://www.lwjgl.org/license + * MACHINE GENERATED FILE, DO NOT EDIT + */ +package org.lwjgl.opengl; + +import javax.annotation.*; + +import java.nio.*; + +import org.lwjgl.*; + +import org.lwjgl.system.*; + +import static org.lwjgl.system.Checks.*; +import static org.lwjgl.system.JNI.*; +import static org.lwjgl.system.MemoryStack.*; +import static org.lwjgl.system.MemoryUtil.*; + +/** + * The OpenGL functionality up to version 1.1. Includes the deprecated symbols of the Compatibility Profile. + * + *

Extensions promoted to core in this release:

+ * + * + */ +public class GL11 { +// -- Begin LWJGL2 Bridge -- + public static void glColorPointer(int size, boolean unsigned, int stride, java.nio.ByteBuffer pointer) { + glColorPointer(size, unsigned ? GL11.GL_UNSIGNED_BYTE : GL11.GL_BYTE, stride, pointer); + } + + public static void glColorPointer(int size, int stride, FloatBuffer pointer) { + glColorPointer(size, GL11.GL_FLOAT, stride, pointer); + } + + public static void glFog(int p1, java.nio.FloatBuffer p2) { + glFogfv(p1, p2); + } + + public static void glFog(int p1, java.nio.IntBuffer p2) { + glFogiv(p1, p2); + } + + public static void glGetBoolean(int p1, java.nio.ByteBuffer p2) { + glGetBooleanv(p1, p2); + } + + public static void glGetDouble(int p1, java.nio.DoubleBuffer p2) { + glGetDoublev(p1, p2); + } + + public static void glGetFloat(int p1, FloatBuffer p2) { + glGetFloatv(p1, p2); + } + + public static void glGetInteger(int p1, IntBuffer p2) { + glGetIntegerv(p1, p2); + } + + public static void glGetLight(int p1, int p2, FloatBuffer p3) { + glGetLightfv(p1, p2, p3); + } + + public static void glGetLight(int p1, int p2, IntBuffer p3) { + glGetLightiv(p1, p2, p3); + } + + public static void glGetMap(int p1, int p2, DoubleBuffer p3) { + glGetMapdv(p1, p2, p3); + } + + public static void glGetMap(int p1, int p2, FloatBuffer p3) { + glGetMapfv(p1, p2, p3); + } + + public static void glGetMap(int p1, int p2, IntBuffer p3) { + glGetMapiv(p1, p2, p3); + } + + public static void glGetMaterial(int p1, int p2, FloatBuffer p3) { + glGetMaterialfv(p1, p2, p3); + } + + public static void glGetMaterial(int p1, int p2, IntBuffer p3) { + glGetMaterialiv(p1, p2, p3); + } + + public static void glGetPixelMap(int p1, FloatBuffer p2) { + glGetPixelMapfv(p1, p2); + } + + public static void glGetPixelMapu(int p1, IntBuffer p2) { + glGetPixelMapuiv(p1, p2); + } + + public static void glGetPixelMapu(int p1, ShortBuffer p2) { + glGetPixelMapusv(p1, p2); + } + + public static void glGetTexEnv(int p1, int p2, FloatBuffer p3) { + glGetTexEnvfv(p1, p2, p3); + } + + public static void glGetTexEnv(int p1, int p2, IntBuffer p3) { + glGetTexEnviv(p1, p2, p3); + } + + public static void glGetTexGen(int p1, int p2, DoubleBuffer p3) { + glGetTexGendv(p1, p2, p3); + } + + public static void glGetTexGen(int p1, int p2, FloatBuffer p3) { + glGetTexGenfv(p1, p2, p3); + } + + public static void glGetTexGen(int p1, int p2, IntBuffer p3) { + glGetTexGeniv(p1, p2, p3); + } + + public static void glGetTexLevelParameter(int target, int level, int pname, FloatBuffer params) { + glGetTexLevelParameterfv(target, level, pname, params); + } + + public static void glGetTexLevelParameter(int target, int level, int pname, IntBuffer params) { + glGetTexLevelParameteriv(target, level, pname, params); + } + + public static void glGetTexParameter(int target, int pname, FloatBuffer params) { + glGetTexParameterfv(target, pname, params); + } + + public static void glGetTexParameter(int target, int pname, IntBuffer params) { + glGetTexParameteriv(target, pname, params); + } + + public static void glLight(int light, int pname, FloatBuffer params) { + glLightfv(light, pname, params); + } + + public static void glLight(int light, int pname, IntBuffer params) { + glLightiv(light, pname, params); + } + + public static void glLightModel(int pname, FloatBuffer params) { + glLightModelfv(pname, params); + } + + public static void glLightModel(int pname, IntBuffer params) { + glLightModeliv(pname, params); + } + + public static void glLoadMatrix(DoubleBuffer m) { + glLoadMatrixd(m); + } + + public static void glLoadMatrix(FloatBuffer m) { + glLoadMatrixf(m); + } + + public static void glMaterial(int p1, int p2, java.nio.FloatBuffer p3) { + glMaterialfv(p1, p2, p3); + } + + public static void glMaterial(int p1, int p2, java.nio.IntBuffer p3) { + glMaterialiv(p1, p2, p3); + } + + public static void glMultMatrix(java.nio.DoubleBuffer p1) { + glMultMatrixd(p1); + } + + public static void glMultMatrix(java.nio.FloatBuffer p1) { + glMultMatrixf(p1); + } + + public static void glNormalPointer(int stride, ByteBuffer pointer) { + glNormalPointer(GL11.GL_BYTE, stride, pointer); + } + + public static void glNormalPointer(int stride, FloatBuffer pointer) { + glNormalPointer(GL11.GL_FLOAT, stride, pointer); + } + + public static void glNormalPointer(int stride, IntBuffer pointer) { + glNormalPointer(GL11.GL_INT, stride, pointer); + } + + public static void glNormalPointer(int stride, ShortBuffer pointer) { + glNormalPointer(GL11.GL_SHORT, stride, pointer); + } + + public static void glPixelMap(int p1, java.nio.FloatBuffer p2) { + glPixelMapfv(p1, p2); + } + + public static void glPixelMapu(int p1, java.nio.IntBuffer p2) { + glPixelMapuiv(p1, p2); + } + + public static void glPixelMapu(int p1, java.nio.ShortBuffer p2) { + glPixelMapusv(p1, p2); + } + + // todo texcoordptr bytebuffer + public static void glTexCoordPointer(int size, int stride, FloatBuffer pointer) { + glTexCoordPointer(size, GL11.GL_FLOAT, stride, pointer); + } + + public static void glTexCoordPointer(int size, int stride, IntBuffer pointer) { + glTexCoordPointer(size, GL11.GL_INT, stride, pointer); + } + + public static void glTexCoordPointer(int size, int stride, ShortBuffer pointer) { + glTexCoordPointer(size, GL11.GL_SHORT, stride, pointer); + } + + public static void glTexEnv(int p1, int p2, java.nio.FloatBuffer p3) { + glTexEnvfv(p1, p2, p3); + } + + public static void glTexEnv(int p1, int p2, java.nio.IntBuffer p3) { + glTexEnviv(p1, p2, p3); + } + + public static void glTexGen(int p1, int p2, java.nio.DoubleBuffer p3) { + glTexGendv(p1, p2, p3); + } + + public static void glTexGen(int p1, int p2, java.nio.FloatBuffer p3) { + glTexGenfv(p1, p2, p3); + } + + public static void glTexGen(int p1, int p2, java.nio.IntBuffer p3) { + glTexGeniv(p1, p2, p3); + } + + public static void glVertexPointer(int size, int stride, FloatBuffer pointer) { + glVertexPointer(size, GL11.GL_FLOAT, stride, pointer); + } + + public static void glVertexPointer(int size, int stride, IntBuffer pointer) { + glVertexPointer(size, GL11.GL_INT, stride, pointer); + } + + public static void glVertexPointer(int size, int stride, ShortBuffer pointer) { + glVertexPointer(size, GL11.GL_SHORT, stride, pointer); + } +// ------- end test duplicate --------- + + /** AccumOp */ + public static final int + GL_ACCUM = 0x100, + GL_LOAD = 0x101, + GL_RETURN = 0x102, + GL_MULT = 0x103, + GL_ADD = 0x104; + + /** AlphaFunction */ + public static final int + GL_NEVER = 0x200, + GL_LESS = 0x201, + GL_EQUAL = 0x202, + GL_LEQUAL = 0x203, + GL_GREATER = 0x204, + GL_NOTEQUAL = 0x205, + GL_GEQUAL = 0x206, + GL_ALWAYS = 0x207; + + /** AttribMask */ + public static final int + GL_CURRENT_BIT = 0x1, + GL_POINT_BIT = 0x2, + GL_LINE_BIT = 0x4, + GL_POLYGON_BIT = 0x8, + GL_POLYGON_STIPPLE_BIT = 0x10, + GL_PIXEL_MODE_BIT = 0x20, + GL_LIGHTING_BIT = 0x40, + GL_FOG_BIT = 0x80, + GL_DEPTH_BUFFER_BIT = 0x100, + GL_ACCUM_BUFFER_BIT = 0x200, + GL_STENCIL_BUFFER_BIT = 0x400, + GL_VIEWPORT_BIT = 0x800, + GL_TRANSFORM_BIT = 0x1000, + GL_ENABLE_BIT = 0x2000, + GL_COLOR_BUFFER_BIT = 0x4000, + GL_HINT_BIT = 0x8000, + GL_EVAL_BIT = 0x10000, + GL_LIST_BIT = 0x20000, + GL_TEXTURE_BIT = 0x40000, + GL_SCISSOR_BIT = 0x80000, + GL_ALL_ATTRIB_BITS = 0xFFFFF; + + /** BeginMode */ + public static final int + GL_POINTS = 0x0, + GL_LINES = 0x1, + GL_LINE_LOOP = 0x2, + GL_LINE_STRIP = 0x3, + GL_TRIANGLES = 0x4, + GL_TRIANGLE_STRIP = 0x5, + GL_TRIANGLE_FAN = 0x6, + GL_QUADS = 0x7, + GL_QUAD_STRIP = 0x8, + GL_POLYGON = 0x9; + + /** BlendingFactorDest */ + public static final int + GL_ZERO = 0, + GL_ONE = 1, + GL_SRC_COLOR = 0x300, + GL_ONE_MINUS_SRC_COLOR = 0x301, + GL_SRC_ALPHA = 0x302, + GL_ONE_MINUS_SRC_ALPHA = 0x303, + GL_DST_ALPHA = 0x304, + GL_ONE_MINUS_DST_ALPHA = 0x305; + + /** BlendingFactorSrc */ + public static final int + GL_DST_COLOR = 0x306, + GL_ONE_MINUS_DST_COLOR = 0x307, + GL_SRC_ALPHA_SATURATE = 0x308; + + /** Boolean */ + public static final int + GL_TRUE = 1, + GL_FALSE = 0; + + /** ClipPlaneName */ + public static final int + GL_CLIP_PLANE0 = 0x3000, + GL_CLIP_PLANE1 = 0x3001, + GL_CLIP_PLANE2 = 0x3002, + GL_CLIP_PLANE3 = 0x3003, + GL_CLIP_PLANE4 = 0x3004, + GL_CLIP_PLANE5 = 0x3005; + + /** DataType */ + public static final int + GL_BYTE = 0x1400, + GL_UNSIGNED_BYTE = 0x1401, + GL_SHORT = 0x1402, + GL_UNSIGNED_SHORT = 0x1403, + GL_INT = 0x1404, + GL_UNSIGNED_INT = 0x1405, + GL_FLOAT = 0x1406, + GL_2_BYTES = 0x1407, + GL_3_BYTES = 0x1408, + GL_4_BYTES = 0x1409, + GL_DOUBLE = 0x140A; + + /** DrawBufferMode */ + public static final int + GL_NONE = 0, + GL_FRONT_LEFT = 0x400, + GL_FRONT_RIGHT = 0x401, + GL_BACK_LEFT = 0x402, + GL_BACK_RIGHT = 0x403, + GL_FRONT = 0x404, + GL_BACK = 0x405, + GL_LEFT = 0x406, + GL_RIGHT = 0x407, + GL_FRONT_AND_BACK = 0x408, + GL_AUX0 = 0x409, + GL_AUX1 = 0x40A, + GL_AUX2 = 0x40B, + GL_AUX3 = 0x40C; + + /** ErrorCode */ + public static final int + GL_NO_ERROR = 0, + GL_INVALID_ENUM = 0x500, + GL_INVALID_VALUE = 0x501, + GL_INVALID_OPERATION = 0x502, + GL_STACK_OVERFLOW = 0x503, + GL_STACK_UNDERFLOW = 0x504, + GL_OUT_OF_MEMORY = 0x505; + + /** FeedBackMode */ + public static final int + GL_2D = 0x600, + GL_3D = 0x601, + GL_3D_COLOR = 0x602, + GL_3D_COLOR_TEXTURE = 0x603, + GL_4D_COLOR_TEXTURE = 0x604; + + /** FeedBackToken */ + public static final int + GL_PASS_THROUGH_TOKEN = 0x700, + GL_POINT_TOKEN = 0x701, + GL_LINE_TOKEN = 0x702, + GL_POLYGON_TOKEN = 0x703, + GL_BITMAP_TOKEN = 0x704, + GL_DRAW_PIXEL_TOKEN = 0x705, + GL_COPY_PIXEL_TOKEN = 0x706, + GL_LINE_RESET_TOKEN = 0x707; + + /** FogMode */ + public static final int + GL_EXP = 0x800, + GL_EXP2 = 0x801; + + /** FrontFaceDirection */ + public static final int + GL_CW = 0x900, + GL_CCW = 0x901; + + /** GetMapTarget */ + public static final int + GL_COEFF = 0xA00, + GL_ORDER = 0xA01, + GL_DOMAIN = 0xA02; + + /** GetTarget */ + public static final int + GL_CURRENT_COLOR = 0xB00, + GL_CURRENT_INDEX = 0xB01, + GL_CURRENT_NORMAL = 0xB02, + GL_CURRENT_TEXTURE_COORDS = 0xB03, + GL_CURRENT_RASTER_COLOR = 0xB04, + GL_CURRENT_RASTER_INDEX = 0xB05, + GL_CURRENT_RASTER_TEXTURE_COORDS = 0xB06, + GL_CURRENT_RASTER_POSITION = 0xB07, + GL_CURRENT_RASTER_POSITION_VALID = 0xB08, + GL_CURRENT_RASTER_DISTANCE = 0xB09, + GL_POINT_SMOOTH = 0xB10, + GL_POINT_SIZE = 0xB11, + GL_POINT_SIZE_RANGE = 0xB12, + GL_POINT_SIZE_GRANULARITY = 0xB13, + GL_LINE_SMOOTH = 0xB20, + GL_LINE_WIDTH = 0xB21, + GL_LINE_WIDTH_RANGE = 0xB22, + GL_LINE_WIDTH_GRANULARITY = 0xB23, + GL_LINE_STIPPLE = 0xB24, + GL_LINE_STIPPLE_PATTERN = 0xB25, + GL_LINE_STIPPLE_REPEAT = 0xB26, + GL_LIST_MODE = 0xB30, + GL_MAX_LIST_NESTING = 0xB31, + GL_LIST_BASE = 0xB32, + GL_LIST_INDEX = 0xB33, + GL_POLYGON_MODE = 0xB40, + GL_POLYGON_SMOOTH = 0xB41, + GL_POLYGON_STIPPLE = 0xB42, + GL_EDGE_FLAG = 0xB43, + GL_CULL_FACE = 0xB44, + GL_CULL_FACE_MODE = 0xB45, + GL_FRONT_FACE = 0xB46, + GL_LIGHTING = 0xB50, + GL_LIGHT_MODEL_LOCAL_VIEWER = 0xB51, + GL_LIGHT_MODEL_TWO_SIDE = 0xB52, + GL_LIGHT_MODEL_AMBIENT = 0xB53, + GL_SHADE_MODEL = 0xB54, + GL_COLOR_MATERIAL_FACE = 0xB55, + GL_COLOR_MATERIAL_PARAMETER = 0xB56, + GL_COLOR_MATERIAL = 0xB57, + GL_FOG = 0xB60, + GL_FOG_INDEX = 0xB61, + GL_FOG_DENSITY = 0xB62, + GL_FOG_START = 0xB63, + GL_FOG_END = 0xB64, + GL_FOG_MODE = 0xB65, + GL_FOG_COLOR = 0xB66, + GL_DEPTH_RANGE = 0xB70, + GL_DEPTH_TEST = 0xB71, + GL_DEPTH_WRITEMASK = 0xB72, + GL_DEPTH_CLEAR_VALUE = 0xB73, + GL_DEPTH_FUNC = 0xB74, + GL_ACCUM_CLEAR_VALUE = 0xB80, + GL_STENCIL_TEST = 0xB90, + GL_STENCIL_CLEAR_VALUE = 0xB91, + GL_STENCIL_FUNC = 0xB92, + GL_STENCIL_VALUE_MASK = 0xB93, + GL_STENCIL_FAIL = 0xB94, + GL_STENCIL_PASS_DEPTH_FAIL = 0xB95, + GL_STENCIL_PASS_DEPTH_PASS = 0xB96, + GL_STENCIL_REF = 0xB97, + GL_STENCIL_WRITEMASK = 0xB98, + GL_MATRIX_MODE = 0xBA0, + GL_NORMALIZE = 0xBA1, + GL_VIEWPORT = 0xBA2, + GL_MODELVIEW_STACK_DEPTH = 0xBA3, + GL_PROJECTION_STACK_DEPTH = 0xBA4, + GL_TEXTURE_STACK_DEPTH = 0xBA5, + GL_MODELVIEW_MATRIX = 0xBA6, + GL_PROJECTION_MATRIX = 0xBA7, + GL_TEXTURE_MATRIX = 0xBA8, + GL_ATTRIB_STACK_DEPTH = 0xBB0, + GL_CLIENT_ATTRIB_STACK_DEPTH = 0xBB1, + GL_ALPHA_TEST = 0xBC0, + GL_ALPHA_TEST_FUNC = 0xBC1, + GL_ALPHA_TEST_REF = 0xBC2, + GL_DITHER = 0xBD0, + GL_BLEND_DST = 0xBE0, + GL_BLEND_SRC = 0xBE1, + GL_BLEND = 0xBE2, + GL_LOGIC_OP_MODE = 0xBF0, + GL_INDEX_LOGIC_OP = 0xBF1, + GL_LOGIC_OP = 0xBF1, + GL_COLOR_LOGIC_OP = 0xBF2, + GL_AUX_BUFFERS = 0xC00, + GL_DRAW_BUFFER = 0xC01, + GL_READ_BUFFER = 0xC02, + GL_SCISSOR_BOX = 0xC10, + GL_SCISSOR_TEST = 0xC11, + GL_INDEX_CLEAR_VALUE = 0xC20, + GL_INDEX_WRITEMASK = 0xC21, + GL_COLOR_CLEAR_VALUE = 0xC22, + GL_COLOR_WRITEMASK = 0xC23, + GL_INDEX_MODE = 0xC30, + GL_RGBA_MODE = 0xC31, + GL_DOUBLEBUFFER = 0xC32, + GL_STEREO = 0xC33, + GL_RENDER_MODE = 0xC40, + GL_PERSPECTIVE_CORRECTION_HINT = 0xC50, + GL_POINT_SMOOTH_HINT = 0xC51, + GL_LINE_SMOOTH_HINT = 0xC52, + GL_POLYGON_SMOOTH_HINT = 0xC53, + GL_FOG_HINT = 0xC54, + GL_TEXTURE_GEN_S = 0xC60, + GL_TEXTURE_GEN_T = 0xC61, + GL_TEXTURE_GEN_R = 0xC62, + GL_TEXTURE_GEN_Q = 0xC63, + GL_PIXEL_MAP_I_TO_I = 0xC70, + GL_PIXEL_MAP_S_TO_S = 0xC71, + GL_PIXEL_MAP_I_TO_R = 0xC72, + GL_PIXEL_MAP_I_TO_G = 0xC73, + GL_PIXEL_MAP_I_TO_B = 0xC74, + GL_PIXEL_MAP_I_TO_A = 0xC75, + GL_PIXEL_MAP_R_TO_R = 0xC76, + GL_PIXEL_MAP_G_TO_G = 0xC77, + GL_PIXEL_MAP_B_TO_B = 0xC78, + GL_PIXEL_MAP_A_TO_A = 0xC79, + GL_PIXEL_MAP_I_TO_I_SIZE = 0xCB0, + GL_PIXEL_MAP_S_TO_S_SIZE = 0xCB1, + GL_PIXEL_MAP_I_TO_R_SIZE = 0xCB2, + GL_PIXEL_MAP_I_TO_G_SIZE = 0xCB3, + GL_PIXEL_MAP_I_TO_B_SIZE = 0xCB4, + GL_PIXEL_MAP_I_TO_A_SIZE = 0xCB5, + GL_PIXEL_MAP_R_TO_R_SIZE = 0xCB6, + GL_PIXEL_MAP_G_TO_G_SIZE = 0xCB7, + GL_PIXEL_MAP_B_TO_B_SIZE = 0xCB8, + GL_PIXEL_MAP_A_TO_A_SIZE = 0xCB9, + GL_UNPACK_SWAP_BYTES = 0xCF0, + GL_UNPACK_LSB_FIRST = 0xCF1, + GL_UNPACK_ROW_LENGTH = 0xCF2, + GL_UNPACK_SKIP_ROWS = 0xCF3, + GL_UNPACK_SKIP_PIXELS = 0xCF4, + GL_UNPACK_ALIGNMENT = 0xCF5, + GL_PACK_SWAP_BYTES = 0xD00, + GL_PACK_LSB_FIRST = 0xD01, + GL_PACK_ROW_LENGTH = 0xD02, + GL_PACK_SKIP_ROWS = 0xD03, + GL_PACK_SKIP_PIXELS = 0xD04, + GL_PACK_ALIGNMENT = 0xD05, + GL_MAP_COLOR = 0xD10, + GL_MAP_STENCIL = 0xD11, + GL_INDEX_SHIFT = 0xD12, + GL_INDEX_OFFSET = 0xD13, + GL_RED_SCALE = 0xD14, + GL_RED_BIAS = 0xD15, + GL_ZOOM_X = 0xD16, + GL_ZOOM_Y = 0xD17, + GL_GREEN_SCALE = 0xD18, + GL_GREEN_BIAS = 0xD19, + GL_BLUE_SCALE = 0xD1A, + GL_BLUE_BIAS = 0xD1B, + GL_ALPHA_SCALE = 0xD1C, + GL_ALPHA_BIAS = 0xD1D, + GL_DEPTH_SCALE = 0xD1E, + GL_DEPTH_BIAS = 0xD1F, + GL_MAX_EVAL_ORDER = 0xD30, + GL_MAX_LIGHTS = 0xD31, + GL_MAX_CLIP_PLANES = 0xD32, + GL_MAX_TEXTURE_SIZE = 0xD33, + GL_MAX_PIXEL_MAP_TABLE = 0xD34, + GL_MAX_ATTRIB_STACK_DEPTH = 0xD35, + GL_MAX_MODELVIEW_STACK_DEPTH = 0xD36, + GL_MAX_NAME_STACK_DEPTH = 0xD37, + GL_MAX_PROJECTION_STACK_DEPTH = 0xD38, + GL_MAX_TEXTURE_STACK_DEPTH = 0xD39, + GL_MAX_VIEWPORT_DIMS = 0xD3A, + GL_MAX_CLIENT_ATTRIB_STACK_DEPTH = 0xD3B, + GL_SUBPIXEL_BITS = 0xD50, + GL_INDEX_BITS = 0xD51, + GL_RED_BITS = 0xD52, + GL_GREEN_BITS = 0xD53, + GL_BLUE_BITS = 0xD54, + GL_ALPHA_BITS = 0xD55, + GL_DEPTH_BITS = 0xD56, + GL_STENCIL_BITS = 0xD57, + GL_ACCUM_RED_BITS = 0xD58, + GL_ACCUM_GREEN_BITS = 0xD59, + GL_ACCUM_BLUE_BITS = 0xD5A, + GL_ACCUM_ALPHA_BITS = 0xD5B, + GL_NAME_STACK_DEPTH = 0xD70, + GL_AUTO_NORMAL = 0xD80, + GL_MAP1_COLOR_4 = 0xD90, + GL_MAP1_INDEX = 0xD91, + GL_MAP1_NORMAL = 0xD92, + GL_MAP1_TEXTURE_COORD_1 = 0xD93, + GL_MAP1_TEXTURE_COORD_2 = 0xD94, + GL_MAP1_TEXTURE_COORD_3 = 0xD95, + GL_MAP1_TEXTURE_COORD_4 = 0xD96, + GL_MAP1_VERTEX_3 = 0xD97, + GL_MAP1_VERTEX_4 = 0xD98, + GL_MAP2_COLOR_4 = 0xDB0, + GL_MAP2_INDEX = 0xDB1, + GL_MAP2_NORMAL = 0xDB2, + GL_MAP2_TEXTURE_COORD_1 = 0xDB3, + GL_MAP2_TEXTURE_COORD_2 = 0xDB4, + GL_MAP2_TEXTURE_COORD_3 = 0xDB5, + GL_MAP2_TEXTURE_COORD_4 = 0xDB6, + GL_MAP2_VERTEX_3 = 0xDB7, + GL_MAP2_VERTEX_4 = 0xDB8, + GL_MAP1_GRID_DOMAIN = 0xDD0, + GL_MAP1_GRID_SEGMENTS = 0xDD1, + GL_MAP2_GRID_DOMAIN = 0xDD2, + GL_MAP2_GRID_SEGMENTS = 0xDD3, + GL_TEXTURE_1D = 0xDE0, + GL_TEXTURE_2D = 0xDE1, + GL_FEEDBACK_BUFFER_POINTER = 0xDF0, + GL_FEEDBACK_BUFFER_SIZE = 0xDF1, + GL_FEEDBACK_BUFFER_TYPE = 0xDF2, + GL_SELECTION_BUFFER_POINTER = 0xDF3, + GL_SELECTION_BUFFER_SIZE = 0xDF4; + + /** GetTextureParameter */ + public static final int + GL_TEXTURE_WIDTH = 0x1000, + GL_TEXTURE_HEIGHT = 0x1001, + GL_TEXTURE_INTERNAL_FORMAT = 0x1003, + GL_TEXTURE_COMPONENTS = 0x1003, + GL_TEXTURE_BORDER_COLOR = 0x1004, + GL_TEXTURE_BORDER = 0x1005; + + /** HintMode */ + public static final int + GL_DONT_CARE = 0x1100, + GL_FASTEST = 0x1101, + GL_NICEST = 0x1102; + + /** LightName */ + public static final int + GL_LIGHT0 = 0x4000, + GL_LIGHT1 = 0x4001, + GL_LIGHT2 = 0x4002, + GL_LIGHT3 = 0x4003, + GL_LIGHT4 = 0x4004, + GL_LIGHT5 = 0x4005, + GL_LIGHT6 = 0x4006, + GL_LIGHT7 = 0x4007; + + /** LightParameter */ + public static final int + GL_AMBIENT = 0x1200, + GL_DIFFUSE = 0x1201, + GL_SPECULAR = 0x1202, + GL_POSITION = 0x1203, + GL_SPOT_DIRECTION = 0x1204, + GL_SPOT_EXPONENT = 0x1205, + GL_SPOT_CUTOFF = 0x1206, + GL_CONSTANT_ATTENUATION = 0x1207, + GL_LINEAR_ATTENUATION = 0x1208, + GL_QUADRATIC_ATTENUATION = 0x1209; + + /** ListMode */ + public static final int + GL_COMPILE = 0x1300, + GL_COMPILE_AND_EXECUTE = 0x1301; + + /** LogicOp */ + public static final int + GL_CLEAR = 0x1500, + GL_AND = 0x1501, + GL_AND_REVERSE = 0x1502, + GL_COPY = 0x1503, + GL_AND_INVERTED = 0x1504, + GL_NOOP = 0x1505, + GL_XOR = 0x1506, + GL_OR = 0x1507, + GL_NOR = 0x1508, + GL_EQUIV = 0x1509, + GL_INVERT = 0x150A, + GL_OR_REVERSE = 0x150B, + GL_COPY_INVERTED = 0x150C, + GL_OR_INVERTED = 0x150D, + GL_NAND = 0x150E, + GL_SET = 0x150F; + + /** MaterialParameter */ + public static final int + GL_EMISSION = 0x1600, + GL_SHININESS = 0x1601, + GL_AMBIENT_AND_DIFFUSE = 0x1602, + GL_COLOR_INDEXES = 0x1603; + + /** MatrixMode */ + public static final int + GL_MODELVIEW = 0x1700, + GL_PROJECTION = 0x1701, + GL_TEXTURE = 0x1702; + + /** PixelCopyType */ + public static final int + GL_COLOR = 0x1800, + GL_DEPTH = 0x1801, + GL_STENCIL = 0x1802; + + /** PixelFormat */ + public static final int + GL_COLOR_INDEX = 0x1900, + GL_STENCIL_INDEX = 0x1901, + GL_DEPTH_COMPONENT = 0x1902, + GL_RED = 0x1903, + GL_GREEN = 0x1904, + GL_BLUE = 0x1905, + GL_ALPHA = 0x1906, + GL_RGB = 0x1907, + GL_RGBA = 0x1908, + GL_LUMINANCE = 0x1909, + GL_LUMINANCE_ALPHA = 0x190A; + + /** PixelType */ + public static final int GL_BITMAP = 0x1A00; + + /** PolygonMode */ + public static final int + GL_POINT = 0x1B00, + GL_LINE = 0x1B01, + GL_FILL = 0x1B02; + + /** RenderingMode */ + public static final int + GL_RENDER = 0x1C00, + GL_FEEDBACK = 0x1C01, + GL_SELECT = 0x1C02; + + /** ShadingModel */ + public static final int + GL_FLAT = 0x1D00, + GL_SMOOTH = 0x1D01; + + /** StencilOp */ + public static final int + GL_KEEP = 0x1E00, + GL_REPLACE = 0x1E01, + GL_INCR = 0x1E02, + GL_DECR = 0x1E03; + + /** StringName */ + public static final int + GL_VENDOR = 0x1F00, + GL_RENDERER = 0x1F01, + GL_VERSION = 0x1F02, + GL_EXTENSIONS = 0x1F03; + + /** TextureCoordName */ + public static final int + GL_S = 0x2000, + GL_T = 0x2001, + GL_R = 0x2002, + GL_Q = 0x2003; + + /** TextureEnvMode */ + public static final int + GL_MODULATE = 0x2100, + GL_DECAL = 0x2101; + + /** TextureEnvParameter */ + public static final int + GL_TEXTURE_ENV_MODE = 0x2200, + GL_TEXTURE_ENV_COLOR = 0x2201; + + /** TextureEnvTarget */ + public static final int GL_TEXTURE_ENV = 0x2300; + + /** TextureGenMode */ + public static final int + GL_EYE_LINEAR = 0x2400, + GL_OBJECT_LINEAR = 0x2401, + GL_SPHERE_MAP = 0x2402; + + /** TextureGenParameter */ + public static final int + GL_TEXTURE_GEN_MODE = 0x2500, + GL_OBJECT_PLANE = 0x2501, + GL_EYE_PLANE = 0x2502; + + /** TextureMagFilter */ + public static final int + GL_NEAREST = 0x2600, + GL_LINEAR = 0x2601; + + /** TextureMinFilter */ + public static final int + GL_NEAREST_MIPMAP_NEAREST = 0x2700, + GL_LINEAR_MIPMAP_NEAREST = 0x2701, + GL_NEAREST_MIPMAP_LINEAR = 0x2702, + GL_LINEAR_MIPMAP_LINEAR = 0x2703; + + /** TextureParameterName */ + public static final int + GL_TEXTURE_MAG_FILTER = 0x2800, + GL_TEXTURE_MIN_FILTER = 0x2801, + GL_TEXTURE_WRAP_S = 0x2802, + GL_TEXTURE_WRAP_T = 0x2803; + + /** TextureWrapMode */ + public static final int + GL_CLAMP = 0x2900, + GL_REPEAT = 0x2901; + + /** ClientAttribMask */ + public static final int + GL_CLIENT_PIXEL_STORE_BIT = 0x1, + GL_CLIENT_VERTEX_ARRAY_BIT = 0x2, + GL_CLIENT_ALL_ATTRIB_BITS = 0xFFFFFFFF; + + /** polygon_offset */ + public static final int + GL_POLYGON_OFFSET_FACTOR = 0x8038, + GL_POLYGON_OFFSET_UNITS = 0x2A00, + GL_POLYGON_OFFSET_POINT = 0x2A01, + GL_POLYGON_OFFSET_LINE = 0x2A02, + GL_POLYGON_OFFSET_FILL = 0x8037; + + /** texture */ + public static final int + GL_ALPHA4 = 0x803B, + GL_ALPHA8 = 0x803C, + GL_ALPHA12 = 0x803D, + GL_ALPHA16 = 0x803E, + GL_LUMINANCE4 = 0x803F, + GL_LUMINANCE8 = 0x8040, + GL_LUMINANCE12 = 0x8041, + GL_LUMINANCE16 = 0x8042, + GL_LUMINANCE4_ALPHA4 = 0x8043, + GL_LUMINANCE6_ALPHA2 = 0x8044, + GL_LUMINANCE8_ALPHA8 = 0x8045, + GL_LUMINANCE12_ALPHA4 = 0x8046, + GL_LUMINANCE12_ALPHA12 = 0x8047, + GL_LUMINANCE16_ALPHA16 = 0x8048, + GL_INTENSITY = 0x8049, + GL_INTENSITY4 = 0x804A, + GL_INTENSITY8 = 0x804B, + GL_INTENSITY12 = 0x804C, + GL_INTENSITY16 = 0x804D, + GL_R3_G3_B2 = 0x2A10, + GL_RGB4 = 0x804F, + GL_RGB5 = 0x8050, + GL_RGB8 = 0x8051, + GL_RGB10 = 0x8052, + GL_RGB12 = 0x8053, + GL_RGB16 = 0x8054, + GL_RGBA2 = 0x8055, + GL_RGBA4 = 0x8056, + GL_RGB5_A1 = 0x8057, + GL_RGBA8 = 0x8058, + GL_RGB10_A2 = 0x8059, + GL_RGBA12 = 0x805A, + GL_RGBA16 = 0x805B, + GL_TEXTURE_RED_SIZE = 0x805C, + GL_TEXTURE_GREEN_SIZE = 0x805D, + GL_TEXTURE_BLUE_SIZE = 0x805E, + GL_TEXTURE_ALPHA_SIZE = 0x805F, + GL_TEXTURE_LUMINANCE_SIZE = 0x8060, + GL_TEXTURE_INTENSITY_SIZE = 0x8061, + GL_PROXY_TEXTURE_1D = 0x8063, + GL_PROXY_TEXTURE_2D = 0x8064; + + /** texture_object */ + public static final int + GL_TEXTURE_PRIORITY = 0x8066, + GL_TEXTURE_RESIDENT = 0x8067, + GL_TEXTURE_BINDING_1D = 0x8068, + GL_TEXTURE_BINDING_2D = 0x8069; + + /** vertex_array */ + public static final int + GL_VERTEX_ARRAY = 0x8074, + GL_NORMAL_ARRAY = 0x8075, + GL_COLOR_ARRAY = 0x8076, + GL_INDEX_ARRAY = 0x8077, + GL_TEXTURE_COORD_ARRAY = 0x8078, + GL_EDGE_FLAG_ARRAY = 0x8079, + GL_VERTEX_ARRAY_SIZE = 0x807A, + GL_VERTEX_ARRAY_TYPE = 0x807B, + GL_VERTEX_ARRAY_STRIDE = 0x807C, + GL_NORMAL_ARRAY_TYPE = 0x807E, + GL_NORMAL_ARRAY_STRIDE = 0x807F, + GL_COLOR_ARRAY_SIZE = 0x8081, + GL_COLOR_ARRAY_TYPE = 0x8082, + GL_COLOR_ARRAY_STRIDE = 0x8083, + GL_INDEX_ARRAY_TYPE = 0x8085, + GL_INDEX_ARRAY_STRIDE = 0x8086, + GL_TEXTURE_COORD_ARRAY_SIZE = 0x8088, + GL_TEXTURE_COORD_ARRAY_TYPE = 0x8089, + GL_TEXTURE_COORD_ARRAY_STRIDE = 0x808A, + GL_EDGE_FLAG_ARRAY_STRIDE = 0x808C, + GL_VERTEX_ARRAY_POINTER = 0x808E, + GL_NORMAL_ARRAY_POINTER = 0x808F, + GL_COLOR_ARRAY_POINTER = 0x8090, + GL_INDEX_ARRAY_POINTER = 0x8091, + GL_TEXTURE_COORD_ARRAY_POINTER = 0x8092, + GL_EDGE_FLAG_ARRAY_POINTER = 0x8093, + GL_V2F = 0x2A20, + GL_V3F = 0x2A21, + GL_C4UB_V2F = 0x2A22, + GL_C4UB_V3F = 0x2A23, + GL_C3F_V3F = 0x2A24, + GL_N3F_V3F = 0x2A25, + GL_C4F_N3F_V3F = 0x2A26, + GL_T2F_V3F = 0x2A27, + GL_T4F_V4F = 0x2A28, + GL_T2F_C4UB_V3F = 0x2A29, + GL_T2F_C3F_V3F = 0x2A2A, + GL_T2F_N3F_V3F = 0x2A2B, + GL_T2F_C4F_N3F_V3F = 0x2A2C, + GL_T4F_C4F_N3F_V4F = 0x2A2D; + + static { GL.initialize(); } + + protected GL11() { + throw new UnsupportedOperationException(); + } + + static boolean isAvailable(GLCapabilities caps, java.util.Set ext, boolean fc) { + return (fc || checkFunctions( + caps.glAccum, caps.glAlphaFunc, caps.glAreTexturesResident, caps.glArrayElement, caps.glBegin, caps.glBitmap, caps.glCallList, caps.glCallLists, + caps.glClearAccum, caps.glClearIndex, caps.glClipPlane, caps.glColor3b, caps.glColor3s, caps.glColor3i, caps.glColor3f, caps.glColor3d, + caps.glColor3ub, caps.glColor3us, caps.glColor3ui, caps.glColor3bv, caps.glColor3sv, caps.glColor3iv, caps.glColor3fv, caps.glColor3dv, + caps.glColor3ubv, caps.glColor3usv, caps.glColor3uiv, caps.glColor4b, caps.glColor4s, caps.glColor4i, caps.glColor4f, caps.glColor4d, + caps.glColor4ub, caps.glColor4us, caps.glColor4ui, caps.glColor4bv, caps.glColor4sv, caps.glColor4iv, caps.glColor4fv, caps.glColor4dv, + caps.glColor4ubv, caps.glColor4usv, caps.glColor4uiv, caps.glColorMaterial, caps.glColorPointer, caps.glCopyPixels, caps.glDeleteLists, + caps.glDrawPixels, caps.glEdgeFlag, caps.glEdgeFlagv, caps.glEdgeFlagPointer, caps.glEnd, caps.glEvalCoord1f, caps.glEvalCoord1fv, + caps.glEvalCoord1d, caps.glEvalCoord1dv, caps.glEvalCoord2f, caps.glEvalCoord2fv, caps.glEvalCoord2d, caps.glEvalCoord2dv, caps.glEvalMesh1, + caps.glEvalMesh2, caps.glEvalPoint1, caps.glEvalPoint2, caps.glFeedbackBuffer, caps.glFogi, caps.glFogiv, caps.glFogf, caps.glFogfv, + caps.glGenLists, caps.glGetClipPlane, caps.glGetLightiv, caps.glGetLightfv, caps.glGetMapiv, caps.glGetMapfv, caps.glGetMapdv, caps.glGetMaterialiv, + caps.glGetMaterialfv, caps.glGetPixelMapfv, caps.glGetPixelMapusv, caps.glGetPixelMapuiv, caps.glGetPolygonStipple, caps.glGetTexEnviv, + caps.glGetTexEnvfv, caps.glGetTexGeniv, caps.glGetTexGenfv, caps.glGetTexGendv, caps.glIndexi, caps.glIndexub, caps.glIndexs, caps.glIndexf, + caps.glIndexd, caps.glIndexiv, caps.glIndexubv, caps.glIndexsv, caps.glIndexfv, caps.glIndexdv, caps.glIndexMask, caps.glIndexPointer, + caps.glInitNames, caps.glInterleavedArrays, caps.glIsList, caps.glLightModeli, caps.glLightModelf, caps.glLightModeliv, caps.glLightModelfv, + caps.glLighti, caps.glLightf, caps.glLightiv, caps.glLightfv, caps.glLineStipple, caps.glListBase, caps.glLoadMatrixf, caps.glLoadMatrixd, + caps.glLoadIdentity, caps.glLoadName, caps.glMap1f, caps.glMap1d, caps.glMap2f, caps.glMap2d, caps.glMapGrid1f, caps.glMapGrid1d, caps.glMapGrid2f, + caps.glMapGrid2d, caps.glMateriali, caps.glMaterialf, caps.glMaterialiv, caps.glMaterialfv, caps.glMatrixMode, caps.glMultMatrixf, + caps.glMultMatrixd, caps.glFrustum, caps.glNewList, caps.glEndList, caps.glNormal3f, caps.glNormal3b, caps.glNormal3s, caps.glNormal3i, + caps.glNormal3d, caps.glNormal3fv, caps.glNormal3bv, caps.glNormal3sv, caps.glNormal3iv, caps.glNormal3dv, caps.glNormalPointer, caps.glOrtho, + caps.glPassThrough, caps.glPixelMapfv, caps.glPixelMapusv, caps.glPixelMapuiv, caps.glPixelTransferi, caps.glPixelTransferf, caps.glPixelZoom, + caps.glPolygonStipple, caps.glPushAttrib, caps.glPushClientAttrib, caps.glPopAttrib, caps.glPopClientAttrib, caps.glPopMatrix, caps.glPopName, + caps.glPrioritizeTextures, caps.glPushMatrix, caps.glPushName, caps.glRasterPos2i, caps.glRasterPos2s, caps.glRasterPos2f, caps.glRasterPos2d, + caps.glRasterPos2iv, caps.glRasterPos2sv, caps.glRasterPos2fv, caps.glRasterPos2dv, caps.glRasterPos3i, caps.glRasterPos3s, caps.glRasterPos3f, + caps.glRasterPos3d, caps.glRasterPos3iv, caps.glRasterPos3sv, caps.glRasterPos3fv, caps.glRasterPos3dv, caps.glRasterPos4i, caps.glRasterPos4s, + caps.glRasterPos4f, caps.glRasterPos4d, caps.glRasterPos4iv, caps.glRasterPos4sv, caps.glRasterPos4fv, caps.glRasterPos4dv, caps.glRecti, + caps.glRects, caps.glRectf, caps.glRectd, caps.glRectiv, caps.glRectsv, caps.glRectfv, caps.glRectdv, caps.glRenderMode, caps.glRotatef, + caps.glRotated, caps.glScalef, caps.glScaled, caps.glSelectBuffer, caps.glShadeModel, caps.glTexCoord1f, caps.glTexCoord1s, caps.glTexCoord1i, + caps.glTexCoord1d, caps.glTexCoord1fv, caps.glTexCoord1sv, caps.glTexCoord1iv, caps.glTexCoord1dv, caps.glTexCoord2f, caps.glTexCoord2s, + caps.glTexCoord2i, caps.glTexCoord2d, caps.glTexCoord2fv, caps.glTexCoord2sv, caps.glTexCoord2iv, caps.glTexCoord2dv, caps.glTexCoord3f, + caps.glTexCoord3s, caps.glTexCoord3i, caps.glTexCoord3d, caps.glTexCoord3fv, caps.glTexCoord3sv, caps.glTexCoord3iv, caps.glTexCoord3dv, + caps.glTexCoord4f, caps.glTexCoord4s, caps.glTexCoord4i, caps.glTexCoord4d, caps.glTexCoord4fv, caps.glTexCoord4sv, caps.glTexCoord4iv, + caps.glTexCoord4dv, caps.glTexCoordPointer, caps.glTexEnvi, caps.glTexEnviv, caps.glTexEnvf, caps.glTexEnvfv, caps.glTexGeni, caps.glTexGeniv, + caps.glTexGenf, caps.glTexGenfv, caps.glTexGend, caps.glTexGendv, caps.glTranslatef, caps.glTranslated, caps.glVertex2f, caps.glVertex2s, + caps.glVertex2i, caps.glVertex2d, caps.glVertex2fv, caps.glVertex2sv, caps.glVertex2iv, caps.glVertex2dv, caps.glVertex3f, caps.glVertex3s, + caps.glVertex3i, caps.glVertex3d, caps.glVertex3fv, caps.glVertex3sv, caps.glVertex3iv, caps.glVertex3dv, caps.glVertex4f, caps.glVertex4s, + caps.glVertex4i, caps.glVertex4d, caps.glVertex4fv, caps.glVertex4sv, caps.glVertex4iv, caps.glVertex4dv, caps.glVertexPointer + )) && checkFunctions( + caps.glEnable, caps.glDisable, caps.glBindTexture, caps.glBlendFunc, caps.glClear, caps.glClearColor, caps.glClearDepth, caps.glClearStencil, + caps.glColorMask, caps.glCullFace, caps.glDepthFunc, caps.glDepthMask, caps.glDepthRange, + ext.contains("GL_NV_vertex_buffer_unified_memory") ? caps.glDisableClientState : -1L, caps.glDrawArrays, caps.glDrawBuffer, caps.glDrawElements, + ext.contains("GL_NV_vertex_buffer_unified_memory") ? caps.glEnableClientState : -1L, caps.glFinish, caps.glFlush, caps.glFrontFace, + caps.glGenTextures, caps.glDeleteTextures, caps.glGetBooleanv, caps.glGetFloatv, caps.glGetIntegerv, caps.glGetDoublev, caps.glGetError, + caps.glGetPointerv, caps.glGetString, caps.glGetTexImage, caps.glGetTexLevelParameteriv, caps.glGetTexLevelParameterfv, caps.glGetTexParameteriv, + caps.glGetTexParameterfv, caps.glHint, caps.glIsEnabled, caps.glIsTexture, caps.glLineWidth, caps.glLogicOp, caps.glPixelStorei, caps.glPixelStoref, + caps.glPointSize, caps.glPolygonMode, caps.glPolygonOffset, caps.glReadBuffer, caps.glReadPixels, caps.glScissor, caps.glStencilFunc, + caps.glStencilMask, caps.glStencilOp, caps.glTexImage1D, caps.glTexImage2D, caps.glCopyTexImage1D, caps.glCopyTexImage2D, caps.glCopyTexSubImage1D, + caps.glCopyTexSubImage2D, caps.glTexParameteri, caps.glTexParameteriv, caps.glTexParameterf, caps.glTexParameterfv, caps.glTexSubImage1D, + caps.glTexSubImage2D, caps.glViewport + ); + } + + // --- [ glEnable ] --- + + /** + * Enables the specified OpenGL state. + * + * @param target the OpenGL state to enable + * + * @see Reference Page + */ + public static void glEnable(@NativeType("GLenum") int target) { + GL11C.glEnable(target); + } + + // --- [ glDisable ] --- + + /** + * Disables the specified OpenGL state. + * + * @param target the OpenGL state to disable + * + * @see Reference Page + */ + public static void glDisable(@NativeType("GLenum") int target) { + GL11C.glDisable(target); + } + + // --- [ glAccum ] --- + + /** + * Each portion of a pixel in the accumulation buffer consists of four values: one for each of R, G, B, and A. The accumulation buffer is controlled + * exclusively through the use of this method (except for clearing it). + * + * @param op a symbolic constant indicating an accumulation buffer operation + * @param value a floating-point value to be used in that operation. One of:
{@link #GL_ACCUM ACCUM}{@link #GL_LOAD LOAD}{@link #GL_RETURN RETURN}{@link #GL_MULT MULT}{@link #GL_ADD ADD}
+ * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glAccum(@NativeType("GLenum") int op, @NativeType("GLfloat") float value); + + // --- [ glAlphaFunc ] --- + + /** + * The alpha test discards a fragment conditionally based on the outcome of a comparison between the incoming fragment’s alpha value and a constant value. + * The comparison is enabled or disabled with the generic {@link #glEnable Enable} and {@link #glDisable Disable} commands using the symbolic constant {@link #GL_ALPHA_TEST ALPHA_TEST}. + * When disabled, it is as if the comparison always passes. The test is controlled with this method. + * + * @param func a symbolic constant indicating the alpha test function. One of:
{@link #GL_NEVER NEVER}{@link #GL_ALWAYS ALWAYS}{@link #GL_LESS LESS}{@link #GL_LEQUAL LEQUAL}{@link #GL_EQUAL EQUAL}{@link #GL_GEQUAL GEQUAL}{@link #GL_GREATER GREATER}{@link #GL_NOTEQUAL NOTEQUAL}
+ * @param ref a reference value clamped to the range [0, 1]. When performing the alpha test, the GL will convert the reference value to the same representation as the fragment's alpha value (floating-point or fixed-point). + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glAlphaFunc(@NativeType("GLenum") int func, @NativeType("GLfloat") float ref); + + // --- [ glAreTexturesResident ] --- + + /** + * Unsafe version of: {@link #glAreTexturesResident AreTexturesResident} + * + * @param n the number of texture objects in {@code textures} + */ + public static native boolean nglAreTexturesResident(int n, long textures, long residences); + + /** + * Returns {@link #GL_TRUE TRUE} if all of the texture objects named in textures are resident, or if the implementation does not distinguish a working set. If + * at least one of the texture objects named in textures is not resident, then {@link #GL_FALSE FALSE} is returned, and the residence of each texture object is + * returned in residences. Otherwise the contents of residences are not changed. + * + * @param textures an array of texture objects + * @param residences returns the residences of each texture object + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + @NativeType("GLboolean") + public static boolean glAreTexturesResident(@NativeType("GLuint const *") IntBuffer textures, @NativeType("GLboolean *") ByteBuffer residences) { + if (CHECKS) { + check(residences, textures.remaining()); + } + return nglAreTexturesResident(textures.remaining(), memAddress(textures), memAddress(residences)); + } + + /** + * Returns {@link #GL_TRUE TRUE} if all of the texture objects named in textures are resident, or if the implementation does not distinguish a working set. If + * at least one of the texture objects named in textures is not resident, then {@link #GL_FALSE FALSE} is returned, and the residence of each texture object is + * returned in residences. Otherwise the contents of residences are not changed. + * + * @param residences returns the residences of each texture object + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + @NativeType("GLboolean") + public static boolean glAreTexturesResident(@NativeType("GLuint const *") int texture, @NativeType("GLboolean *") ByteBuffer residences) { + if (CHECKS) { + check(residences, 1); + } + MemoryStack stack = stackGet(); int stackPointer = stack.getPointer(); + try { + IntBuffer textures = stack.ints(texture); + return nglAreTexturesResident(1, memAddress(textures), memAddress(residences)); + } finally { + stack.setPointer(stackPointer); + } + } + + // --- [ glArrayElement ] --- + + /** + * Transfers the ith element of every enabled, non-instanced array, and the first element of every enabled, instanced array to the GL. + * + * @param i the element to transfer + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glArrayElement(@NativeType("GLint") int i); + + // --- [ glBegin ] --- + + /** + * Begins the definition of vertex attributes of a sequence of primitives to be transferred to the GL. + * + * @param mode the primitive type being defined. One of:
{@link #GL_POINTS POINTS}{@link #GL_LINE_STRIP LINE_STRIP}{@link #GL_LINE_LOOP LINE_LOOP}{@link #GL_LINES LINES}{@link #GL_TRIANGLE_STRIP TRIANGLE_STRIP}{@link #GL_TRIANGLE_FAN TRIANGLE_FAN}{@link #GL_TRIANGLES TRIANGLES}
{@link GL32#GL_LINES_ADJACENCY LINES_ADJACENCY}{@link GL32#GL_LINE_STRIP_ADJACENCY LINE_STRIP_ADJACENCY}{@link GL32#GL_TRIANGLES_ADJACENCY TRIANGLES_ADJACENCY}{@link GL32#GL_TRIANGLE_STRIP_ADJACENCY TRIANGLE_STRIP_ADJACENCY}{@link GL40#GL_PATCHES PATCHES}{@link #GL_POLYGON POLYGON}{@link #GL_QUADS QUADS}
{@link #GL_QUAD_STRIP QUAD_STRIP}
+ * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glBegin(@NativeType("GLenum") int mode); + + // --- [ glBindTexture ] --- + + /** + * Binds the a texture to a texture target. + * + *

While a texture object is bound, GL operations on the target to which it is bound affect the bound object, and queries of the target to which it is + * bound return state from the bound object. If texture mapping of the dimensionality of the target to which a texture object is bound is enabled, the + * state of the bound texture object directs the texturing operation.

+ * + * @param target the texture target. One of:
{@link GL11C#GL_TEXTURE_1D TEXTURE_1D}{@link GL11C#GL_TEXTURE_2D TEXTURE_2D}{@link GL30#GL_TEXTURE_1D_ARRAY TEXTURE_1D_ARRAY}{@link GL31#GL_TEXTURE_RECTANGLE TEXTURE_RECTANGLE}{@link GL13#GL_TEXTURE_CUBE_MAP TEXTURE_CUBE_MAP}
{@link GL12#GL_TEXTURE_3D TEXTURE_3D}{@link GL30#GL_TEXTURE_2D_ARRAY TEXTURE_2D_ARRAY}{@link GL40#GL_TEXTURE_CUBE_MAP_ARRAY TEXTURE_CUBE_MAP_ARRAY}{@link GL31#GL_TEXTURE_BUFFER TEXTURE_BUFFER}{@link GL32#GL_TEXTURE_2D_MULTISAMPLE TEXTURE_2D_MULTISAMPLE}
{@link GL32#GL_TEXTURE_2D_MULTISAMPLE_ARRAY TEXTURE_2D_MULTISAMPLE_ARRAY}
+ * @param texture the texture object to bind + * + * @see Reference Page + */ + public static void glBindTexture(@NativeType("GLenum") int target, @NativeType("GLuint") int texture) { + GL11C.glBindTexture(target, texture); + } + + // --- [ glBitmap ] --- + + /** Unsafe version of: {@link #glBitmap Bitmap} */ + public static native void nglBitmap(int w, int h, float xOrig, float yOrig, float xInc, float yInc, long data); + + /** + * Sents a bitmap to the GL. Bitmaps are rectangles of zeros and ones specifying a particular pattern of fragments to be produced. Each of these fragments + * has the same associated data. These data are those associated with the current raster position. + * + * @param w the bitmap width + * @param h the bitmap width + * @param xOrig the bitmap origin x coordinate + * @param yOrig the bitmap origin y coordinate + * @param xInc the x increment added to the raster position + * @param yInc the y increment added to the raster position + * @param data the buffer containing the bitmap data. + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glBitmap(@NativeType("GLsizei") int w, @NativeType("GLsizei") int h, @NativeType("GLfloat") float xOrig, @NativeType("GLfloat") float yOrig, @NativeType("GLfloat") float xInc, @NativeType("GLfloat") float yInc, @Nullable @NativeType("GLubyte const *") ByteBuffer data) { + if (CHECKS) { + checkSafe(data, ((w + 7) >> 3) * h); + } + nglBitmap(w, h, xOrig, yOrig, xInc, yInc, memAddressSafe(data)); + } + + /** + * Sents a bitmap to the GL. Bitmaps are rectangles of zeros and ones specifying a particular pattern of fragments to be produced. Each of these fragments + * has the same associated data. These data are those associated with the current raster position. + * + * @param w the bitmap width + * @param h the bitmap width + * @param xOrig the bitmap origin x coordinate + * @param yOrig the bitmap origin y coordinate + * @param xInc the x increment added to the raster position + * @param yInc the y increment added to the raster position + * @param data the buffer containing the bitmap data. + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glBitmap(@NativeType("GLsizei") int w, @NativeType("GLsizei") int h, @NativeType("GLfloat") float xOrig, @NativeType("GLfloat") float yOrig, @NativeType("GLfloat") float xInc, @NativeType("GLfloat") float yInc, @Nullable @NativeType("GLubyte const *") long data) { + nglBitmap(w, h, xOrig, yOrig, xInc, yInc, data); + } + + // --- [ glBlendFunc ] --- + + /** + * Specifies the weighting factors used by the blend equation, for both RGB and alpha functions and for all draw buffers. + * + * @param sfactor the source weighting factor. One of:
{@link GL11C#GL_ZERO ZERO}{@link GL11C#GL_ONE ONE}{@link GL11C#GL_SRC_COLOR SRC_COLOR}{@link GL11C#GL_ONE_MINUS_SRC_COLOR ONE_MINUS_SRC_COLOR}{@link GL11C#GL_DST_COLOR DST_COLOR}
{@link GL11C#GL_ONE_MINUS_DST_COLOR ONE_MINUS_DST_COLOR}{@link GL11C#GL_SRC_ALPHA SRC_ALPHA}{@link GL11C#GL_ONE_MINUS_SRC_ALPHA ONE_MINUS_SRC_ALPHA}{@link GL11C#GL_DST_ALPHA DST_ALPHA}{@link GL11C#GL_ONE_MINUS_DST_ALPHA ONE_MINUS_DST_ALPHA}
{@link GL14#GL_CONSTANT_COLOR CONSTANT_COLOR}{@link GL14#GL_ONE_MINUS_CONSTANT_COLOR ONE_MINUS_CONSTANT_COLOR}{@link GL14#GL_CONSTANT_ALPHA CONSTANT_ALPHA}{@link GL14#GL_ONE_MINUS_CONSTANT_ALPHA ONE_MINUS_CONSTANT_ALPHA}{@link GL11C#GL_SRC_ALPHA_SATURATE SRC_ALPHA_SATURATE}
{@link GL33#GL_SRC1_COLOR SRC1_COLOR}{@link GL33#GL_ONE_MINUS_SRC1_COLOR ONE_MINUS_SRC1_COLOR}{@link GL15#GL_SRC1_ALPHA SRC1_ALPHA}{@link GL33#GL_ONE_MINUS_SRC1_ALPHA ONE_MINUS_SRC1_ALPHA}
+ * @param dfactor the destination weighting factor + * + * @see Reference Page + */ + public static void glBlendFunc(@NativeType("GLenum") int sfactor, @NativeType("GLenum") int dfactor) { + GL11C.glBlendFunc(sfactor, dfactor); + } + + // --- [ glCallList ] --- + + /** + * Executes a display list. Causes the commands saved in the display list to be executed, in order, just as if they were issued without using a display list. + * + * @param list the index of the display list to be called + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glCallList(@NativeType("GLuint") int list); + + // --- [ glCallLists ] --- + + /** + * Unsafe version of: {@link #glCallLists CallLists} + * + * @param n the number of display lists to be called + * @param type the data type of each element in {@code lists}. One of:
{@link #GL_BYTE BYTE}{@link #GL_UNSIGNED_BYTE UNSIGNED_BYTE}{@link #GL_SHORT SHORT}{@link #GL_UNSIGNED_SHORT UNSIGNED_SHORT}{@link #GL_INT INT}{@link #GL_UNSIGNED_INT UNSIGNED_INT}{@link #GL_FLOAT FLOAT}{@link #GL_2_BYTES 2_BYTES}{@link #GL_3_BYTES 3_BYTES}{@link #GL_4_BYTES 4_BYTES}
+ */ + public static native void nglCallLists(int n, int type, long lists); + + /** + * Provides an efficient means for executing a number of display lists. + * + * @param type the data type of each element in {@code lists}. One of:
{@link #GL_BYTE BYTE}{@link #GL_UNSIGNED_BYTE UNSIGNED_BYTE}{@link #GL_SHORT SHORT}{@link #GL_UNSIGNED_SHORT UNSIGNED_SHORT}{@link #GL_INT INT}{@link #GL_UNSIGNED_INT UNSIGNED_INT}{@link #GL_FLOAT FLOAT}{@link #GL_2_BYTES 2_BYTES}{@link #GL_3_BYTES 3_BYTES}{@link #GL_4_BYTES 4_BYTES}
+ * @param lists an array of offsets. Each offset is added to the display list base to obtain the display list number. + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glCallLists(@NativeType("GLenum") int type, @NativeType("void const *") ByteBuffer lists) { + nglCallLists(lists.remaining() / GLChecks.typeToBytes(type), type, memAddress(lists)); + } + + /** + * Provides an efficient means for executing a number of display lists. + * + * @param lists an array of offsets. Each offset is added to the display list base to obtain the display list number. + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glCallLists(@NativeType("void const *") ByteBuffer lists) { + nglCallLists(lists.remaining(), GL11.GL_UNSIGNED_BYTE, memAddress(lists)); + } + + /** + * Provides an efficient means for executing a number of display lists. + * + * @param lists an array of offsets. Each offset is added to the display list base to obtain the display list number. + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glCallLists(@NativeType("void const *") ShortBuffer lists) { + nglCallLists(lists.remaining(), GL11.GL_UNSIGNED_SHORT, memAddress(lists)); + } + + /** + * Provides an efficient means for executing a number of display lists. + * + * @param lists an array of offsets. Each offset is added to the display list base to obtain the display list number. + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glCallLists(@NativeType("void const *") IntBuffer lists) { + nglCallLists(lists.remaining(), GL11.GL_UNSIGNED_INT, memAddress(lists)); + } + + // --- [ glClear ] --- + + /** + * Sets portions of every pixel in a particular buffer to the same value. The value to which each buffer is cleared depends on the setting of the clear + * value for that buffer. + * + * @param mask Zero or the bitwise OR of one or more values indicating which buffers are to be cleared. One or more of:
{@link GL11C#GL_COLOR_BUFFER_BIT COLOR_BUFFER_BIT}{@link GL11C#GL_DEPTH_BUFFER_BIT DEPTH_BUFFER_BIT}{@link GL11C#GL_STENCIL_BUFFER_BIT STENCIL_BUFFER_BIT}
+ * + * @see Reference Page + */ + public static void glClear(@NativeType("GLbitfield") int mask) { + GL11C.glClear(mask); + } + + // --- [ glClearAccum ] --- + + /** + * Sets the clear values for the accumulation buffer. These values are clamped to the range [-1,1] when they are specified. + * + * @param red the value to which to clear the R values of the accumulation buffer + * @param green the value to which to clear the G values of the accumulation buffer + * @param blue the value to which to clear the B values of the accumulation buffer + * @param alpha the value to which to clear the A values of the accumulation buffer + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glClearAccum(@NativeType("GLfloat") float red, @NativeType("GLfloat") float green, @NativeType("GLfloat") float blue, @NativeType("GLfloat") float alpha); + + // --- [ glClearColor ] --- + + /** + * Sets the clear value for fixed-point and floating-point color buffers in RGBA mode. The specified components are stored as floating-point values. + * + * @param red the value to which to clear the R channel of the color buffer + * @param green the value to which to clear the G channel of the color buffer + * @param blue the value to which to clear the B channel of the color buffer + * @param alpha the value to which to clear the A channel of the color buffer + * + * @see Reference Page + */ + public static void glClearColor(@NativeType("GLfloat") float red, @NativeType("GLfloat") float green, @NativeType("GLfloat") float blue, @NativeType("GLfloat") float alpha) { + GL11C.glClearColor(red, green, blue, alpha); + } + + // --- [ glClearDepth ] --- + + /** + * Sets the depth value used when clearing the depth buffer. When clearing a fixedpoint depth buffer, {@code depth} is clamped to the range [0,1] and + * converted to fixed-point. No conversion is applied when clearing a floating-point depth buffer. + * + * @param depth the value to which to clear the depth buffer + * + * @see Reference Page + */ + public static void glClearDepth(@NativeType("GLdouble") double depth) { + GL11C.glClearDepth(depth); + } + + // --- [ glClearIndex ] --- + + /** + * sets the clear color index. index is converted to a fixed-point value with unspecified precision to the left of the binary point; the integer part of + * this value is then masked with 2m – 1, where {@code m} is the number of bits in a color index value stored in the + * framebuffer. + * + * @param index the value to which to clear the color buffer in color index mode + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glClearIndex(@NativeType("GLfloat") float index); + + // --- [ glClearStencil ] --- + + /** + * Sets the value to which to clear the stencil buffer. {@code s} is masked to the number of bitplanes in the stencil buffer. + * + * @param s the value to which to clear the stencil buffer + * + * @see Reference Page + */ + public static void glClearStencil(@NativeType("GLint") int s) { + GL11C.glClearStencil(s); + } + + // --- [ glClipPlane ] --- + + /** Unsafe version of: {@link #glClipPlane ClipPlane} */ + public static native void nglClipPlane(int plane, long equation); + + /** + * Specifies a client-defined clip plane. + * + *

The value of the first argument, {@code plane}, is a symbolic constant, CLIP_PLANEi, where i is an integer between 0 and n – 1, indicating one of + * n client-defined clip planes. {@code equation} is an array of four double-precision floating-point values. These are the coefficients of a plane + * equation in object coordinates: p1, p2, p3, and p4 (in that order).

+ * + * @param plane the clip plane to define + * @param equation the clip plane coefficients + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glClipPlane(@NativeType("GLenum") int plane, @NativeType("GLdouble const *") DoubleBuffer equation) { + if (CHECKS) { + check(equation, 4); + } + nglClipPlane(plane, memAddress(equation)); + } + + // --- [ glColor3b ] --- + + /** + * Sets the R, G, and B components of the current color. The alpha component is set to 1.0. + * + * @param red the red component of the current color + * @param green the green component of the current color + * @param blue the blue component of the current color + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glColor3b(@NativeType("GLbyte") byte red, @NativeType("GLbyte") byte green, @NativeType("GLbyte") byte blue); + + // --- [ glColor3s ] --- + + /** + * Short version of {@link #glColor3b Color3b} + * + * @param red the red component of the current color + * @param green the green component of the current color + * @param blue the blue component of the current color + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glColor3s(@NativeType("GLshort") short red, @NativeType("GLshort") short green, @NativeType("GLshort") short blue); + + // --- [ glColor3i ] --- + + /** + * Integer version of {@link #glColor3b Color3b} + * + * @param red the red component of the current color + * @param green the green component of the current color + * @param blue the blue component of the current color + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glColor3i(@NativeType("GLint") int red, @NativeType("GLint") int green, @NativeType("GLint") int blue); + + // --- [ glColor3f ] --- + + /** + * Float version of {@link #glColor3b Color3b} + * + * @param red the red component of the current color + * @param green the green component of the current color + * @param blue the blue component of the current color + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glColor3f(@NativeType("GLfloat") float red, @NativeType("GLfloat") float green, @NativeType("GLfloat") float blue); + + // --- [ glColor3d ] --- + + /** + * Double version of {@link #glColor3b Color3b} + * + * @param red the red component of the current color + * @param green the green component of the current color + * @param blue the blue component of the current color + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glColor3d(@NativeType("GLdouble") double red, @NativeType("GLdouble") double green, @NativeType("GLdouble") double blue); + + // --- [ glColor3ub ] --- + + /** + * Unsigned version of {@link #glColor3b Color3b} + * + * @param red the red component of the current color + * @param green the green component of the current color + * @param blue the blue component of the current color + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glColor3ub(@NativeType("GLubyte") byte red, @NativeType("GLubyte") byte green, @NativeType("GLubyte") byte blue); + + // --- [ glColor3us ] --- + + /** + * Unsigned short version of {@link #glColor3b Color3b} + * + * @param red the red component of the current color + * @param green the green component of the current color + * @param blue the blue component of the current color + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glColor3us(@NativeType("GLushort") short red, @NativeType("GLushort") short green, @NativeType("GLushort") short blue); + + // --- [ glColor3ui ] --- + + /** + * Unsigned int version of {@link #glColor3b Color3b} + * + * @param red the red component of the current color + * @param green the green component of the current color + * @param blue the blue component of the current color + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glColor3ui(@NativeType("GLint") int red, @NativeType("GLint") int green, @NativeType("GLint") int blue); + + // --- [ glColor3bv ] --- + + /** Unsafe version of: {@link #glColor3bv Color3bv} */ + public static native void nglColor3bv(long v); + + /** + * Byte pointer version of {@link #glColor3b Color3b}. + * + * @param v the color buffer + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glColor3bv(@NativeType("GLbyte const *") ByteBuffer v) { + if (CHECKS) { + check(v, 3); + } + nglColor3bv(memAddress(v)); + } + + // --- [ glColor3sv ] --- + + /** Unsafe version of: {@link #glColor3sv Color3sv} */ + public static native void nglColor3sv(long v); + + /** + * Pointer version of {@link #glColor3s Color3s}. + * + * @param v the color buffer + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glColor3sv(@NativeType("GLshort const *") ShortBuffer v) { + if (CHECKS) { + check(v, 3); + } + nglColor3sv(memAddress(v)); + } + + // --- [ glColor3iv ] --- + + /** Unsafe version of: {@link #glColor3iv Color3iv} */ + public static native void nglColor3iv(long v); + + /** + * Pointer version of {@link #glColor3i Color3i}. + * + * @param v the color buffer + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glColor3iv(@NativeType("GLint const *") IntBuffer v) { + if (CHECKS) { + check(v, 3); + } + nglColor3iv(memAddress(v)); + } + + // --- [ glColor3fv ] --- + + /** Unsafe version of: {@link #glColor3fv Color3fv} */ + public static native void nglColor3fv(long v); + + /** + * Pointer version of {@link #glColor3f Color3f}. + * + * @param v the color buffer + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glColor3fv(@NativeType("GLfloat const *") FloatBuffer v) { + if (CHECKS) { + check(v, 3); + } + nglColor3fv(memAddress(v)); + } + + // --- [ glColor3dv ] --- + + /** Unsafe version of: {@link #glColor3dv Color3dv} */ + public static native void nglColor3dv(long v); + + /** + * Pointer version of {@link #glColor3d Color3d}. + * + * @param v the color buffer + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glColor3dv(@NativeType("GLdouble const *") DoubleBuffer v) { + if (CHECKS) { + check(v, 3); + } + nglColor3dv(memAddress(v)); + } + + // --- [ glColor3ubv ] --- + + /** Unsafe version of: {@link #glColor3ubv Color3ubv} */ + public static native void nglColor3ubv(long v); + + /** + * Pointer version of {@link #glColor3ub Color3ub}. + * + * @param v the color buffer + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glColor3ubv(@NativeType("GLubyte const *") ByteBuffer v) { + if (CHECKS) { + check(v, 3); + } + nglColor3ubv(memAddress(v)); + } + + // --- [ glColor3usv ] --- + + /** Unsafe version of: {@link #glColor3usv Color3usv} */ + public static native void nglColor3usv(long v); + + /** + * Pointer version of {@link #glColor3us Color3us}. + * + * @param v the color buffer + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glColor3usv(@NativeType("GLushort const *") ShortBuffer v) { + if (CHECKS) { + check(v, 3); + } + nglColor3usv(memAddress(v)); + } + + // --- [ glColor3uiv ] --- + + /** Unsafe version of: {@link #glColor3uiv Color3uiv} */ + public static native void nglColor3uiv(long v); + + /** + * Pointer version of {@link #glColor3ui Color3ui}. + * + * @param v the color buffer + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glColor3uiv(@NativeType("GLuint const *") IntBuffer v) { + if (CHECKS) { + check(v, 3); + } + nglColor3uiv(memAddress(v)); + } + + // --- [ glColor4b ] --- + + /** + * Sets the current color. + * + * @param red the red component of the current color + * @param green the green component of the current color + * @param blue the blue component of the current color + * @param alpha the alpha component of the current color + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glColor4b(@NativeType("GLbyte") byte red, @NativeType("GLbyte") byte green, @NativeType("GLbyte") byte blue, @NativeType("GLbyte") byte alpha); + + // --- [ glColor4s ] --- + + /** + * Short version of {@link #glColor4b Color4b} + * + * @param red the red component of the current color + * @param green the green component of the current color + * @param blue the blue component of the current color + * @param alpha the alpha component of the current color + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glColor4s(@NativeType("GLshort") short red, @NativeType("GLshort") short green, @NativeType("GLshort") short blue, @NativeType("GLshort") short alpha); + + // --- [ glColor4i ] --- + + /** + * Integer version of {@link #glColor4b Color4b} + * + * @param red the red component of the current color + * @param green the green component of the current color + * @param blue the blue component of the current color + * @param alpha the alpha component of the current color + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glColor4i(@NativeType("GLint") int red, @NativeType("GLint") int green, @NativeType("GLint") int blue, @NativeType("GLint") int alpha); + + // --- [ glColor4f ] --- + + /** + * Float version of {@link #glColor4b Color4b} + * + * @param red the red component of the current color + * @param green the green component of the current color + * @param blue the blue component of the current color + * @param alpha the alpha component of the current color + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glColor4f(@NativeType("GLfloat") float red, @NativeType("GLfloat") float green, @NativeType("GLfloat") float blue, @NativeType("GLfloat") float alpha); + + // --- [ glColor4d ] --- + + /** + * Double version of {@link #glColor4b Color4b} + * + * @param red the red component of the current color + * @param green the green component of the current color + * @param blue the blue component of the current color + * @param alpha the alpha component of the current color + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glColor4d(@NativeType("GLdouble") double red, @NativeType("GLdouble") double green, @NativeType("GLdouble") double blue, @NativeType("GLdouble") double alpha); + + // --- [ glColor4ub ] --- + + /** + * Unsigned version of {@link #glColor4b Color4b} + * + * @param red the red component of the current color + * @param green the green component of the current color + * @param blue the blue component of the current color + * @param alpha the alpha component of the current color + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glColor4ub(@NativeType("GLubyte") byte red, @NativeType("GLubyte") byte green, @NativeType("GLubyte") byte blue, @NativeType("GLubyte") byte alpha); + + // --- [ glColor4us ] --- + + /** + * Unsigned short version of {@link #glColor4b Color4b} + * + * @param red the red component of the current color + * @param green the green component of the current color + * @param blue the blue component of the current color + * @param alpha the alpha component of the current color + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glColor4us(@NativeType("GLushort") short red, @NativeType("GLushort") short green, @NativeType("GLushort") short blue, @NativeType("GLushort") short alpha); + + // --- [ glColor4ui ] --- + + /** + * Unsigned int version of {@link #glColor4b Color4b} + * + * @param red the red component of the current color + * @param green the green component of the current color + * @param blue the blue component of the current color + * @param alpha the alpha component of the current color + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glColor4ui(@NativeType("GLint") int red, @NativeType("GLint") int green, @NativeType("GLint") int blue, @NativeType("GLint") int alpha); + + // --- [ glColor4bv ] --- + + /** Unsafe version of: {@link #glColor4bv Color4bv} */ + public static native void nglColor4bv(long v); + + /** + * Pointer version of {@link #glColor4b Color4b}. + * + * @param v the color buffer + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glColor4bv(@NativeType("GLbyte const *") ByteBuffer v) { + if (CHECKS) { + check(v, 4); + } + nglColor4bv(memAddress(v)); + } + + // --- [ glColor4sv ] --- + + /** Unsafe version of: {@link #glColor4sv Color4sv} */ + public static native void nglColor4sv(long v); + + /** + * Pointer version of {@link #glColor4s Color4s}. + * + * @param v the color buffer + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glColor4sv(@NativeType("GLshort const *") ShortBuffer v) { + if (CHECKS) { + check(v, 4); + } + nglColor4sv(memAddress(v)); + } + + // --- [ glColor4iv ] --- + + /** Unsafe version of: {@link #glColor4iv Color4iv} */ + public static native void nglColor4iv(long v); + + /** + * Pointer version of {@link #glColor4i Color4i}. + * + * @param v the color buffer + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glColor4iv(@NativeType("GLint const *") IntBuffer v) { + if (CHECKS) { + check(v, 4); + } + nglColor4iv(memAddress(v)); + } + + // --- [ glColor4fv ] --- + + /** Unsafe version of: {@link #glColor4fv Color4fv} */ + public static native void nglColor4fv(long v); + + /** + * Pointer version of {@link #glColor4f Color4f}. + * + * @param v the color buffer + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glColor4fv(@NativeType("GLfloat const *") FloatBuffer v) { + if (CHECKS) { + check(v, 4); + } + nglColor4fv(memAddress(v)); + } + + // --- [ glColor4dv ] --- + + /** Unsafe version of: {@link #glColor4dv Color4dv} */ + public static native void nglColor4dv(long v); + + /** + * Pointer version of {@link #glColor4d Color4d}. + * + * @param v the color buffer + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glColor4dv(@NativeType("GLdouble const *") DoubleBuffer v) { + if (CHECKS) { + check(v, 4); + } + nglColor4dv(memAddress(v)); + } + + // --- [ glColor4ubv ] --- + + /** Unsafe version of: {@link #glColor4ubv Color4ubv} */ + public static native void nglColor4ubv(long v); + + /** + * Pointer version of {@link #glColor4ub Color4ub}. + * + * @param v the color buffer + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glColor4ubv(@NativeType("GLubyte const *") ByteBuffer v) { + if (CHECKS) { + check(v, 4); + } + nglColor4ubv(memAddress(v)); + } + + // --- [ glColor4usv ] --- + + /** Unsafe version of: {@link #glColor4usv Color4usv} */ + public static native void nglColor4usv(long v); + + /** + * Pointer version of {@link #glColor4us Color4us}. + * + * @param v the color buffer + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glColor4usv(@NativeType("GLushort const *") ShortBuffer v) { + if (CHECKS) { + check(v, 4); + } + nglColor4usv(memAddress(v)); + } + + // --- [ glColor4uiv ] --- + + /** Unsafe version of: {@link #glColor4uiv Color4uiv} */ + public static native void nglColor4uiv(long v); + + /** + * Pointer version of {@link #glColor4ui Color4ui}. + * + * @param v the color buffer + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glColor4uiv(@NativeType("GLuint const *") IntBuffer v) { + if (CHECKS) { + check(v, 4); + } + nglColor4uiv(memAddress(v)); + } + + // --- [ glColorMask ] --- + + /** + * Masks the writing of R, G, B and A values to all draw buffers. In the initial state, all color values are enabled for writing for all draw buffers. + * + * @param red whether R values are written or not + * @param green whether G values are written or not + * @param blue whether B values are written or not + * @param alpha whether A values are written or not + * + * @see Reference Page + */ + public static void glColorMask(@NativeType("GLboolean") boolean red, @NativeType("GLboolean") boolean green, @NativeType("GLboolean") boolean blue, @NativeType("GLboolean") boolean alpha) { + GL11C.glColorMask(red, green, blue, alpha); + } + + // --- [ glColorMaterial ] --- + + /** + * It is possible to attach one or more material properties to the current color, so that they continuously track its component values. This behavior is + * enabled and disabled by calling {@link #glEnable Enable} or {@link #glDisable Disable} with the symbolic value {@link #GL_COLOR_MATERIAL COLOR_MATERIAL}. This function controls which + * of these modes is selected. + * + * @param face specifies which material face is affected by the current color. One of:
{@link #GL_FRONT FRONT}{@link #GL_BACK BACK}{@link #GL_FRONT_AND_BACK FRONT_AND_BACK}
+ * @param mode specifies which material property or properties track the current color. One of:
{@link #GL_EMISSION EMISSION}{@link #GL_AMBIENT AMBIENT}{@link #GL_DIFFUSE DIFFUSE}{@link #GL_SPECULAR SPECULAR}{@link #GL_AMBIENT_AND_DIFFUSE AMBIENT_AND_DIFFUSE}
+ * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glColorMaterial(@NativeType("GLenum") int face, @NativeType("GLenum") int mode); + + // --- [ glColorPointer ] --- + + /** Unsafe version of: {@link #glColorPointer ColorPointer} */ + public static native void nglColorPointer(int size, int type, int stride, long pointer); + + /** + * Specifies the location and organization of a color array. + * + * @param size the number of values per vertex that are stored in the array, as well as their component ordering. One of:
34{@link GL12#GL_BGRA BGRA}
+ * @param type the data type of the values stored in the array. One of:
{@link #GL_BYTE BYTE}{@link #GL_UNSIGNED_BYTE UNSIGNED_BYTE}{@link #GL_SHORT SHORT}{@link #GL_UNSIGNED_SHORT UNSIGNED_SHORT}{@link #GL_INT INT}{@link #GL_UNSIGNED_INT UNSIGNED_INT}{@link GL30#GL_HALF_FLOAT HALF_FLOAT}
{@link #GL_FLOAT FLOAT}{@link #GL_DOUBLE DOUBLE}{@link GL12#GL_UNSIGNED_INT_2_10_10_10_REV UNSIGNED_INT_2_10_10_10_REV}{@link GL33#GL_INT_2_10_10_10_REV INT_2_10_10_10_REV}
+ * @param stride the vertex stride in bytes. If specified as zero, then array elements are stored sequentially + * @param pointer the color array data + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glColorPointer(@NativeType("GLint") int size, @NativeType("GLenum") int type, @NativeType("GLsizei") int stride, @NativeType("void const *") ByteBuffer pointer) { + nglColorPointer(size, type, stride, memAddress(pointer)); + } + + /** + * Specifies the location and organization of a color array. + * + * @param size the number of values per vertex that are stored in the array, as well as their component ordering. One of:
34{@link GL12#GL_BGRA BGRA}
+ * @param type the data type of the values stored in the array. One of:
{@link #GL_BYTE BYTE}{@link #GL_UNSIGNED_BYTE UNSIGNED_BYTE}{@link #GL_SHORT SHORT}{@link #GL_UNSIGNED_SHORT UNSIGNED_SHORT}{@link #GL_INT INT}{@link #GL_UNSIGNED_INT UNSIGNED_INT}{@link GL30#GL_HALF_FLOAT HALF_FLOAT}
{@link #GL_FLOAT FLOAT}{@link #GL_DOUBLE DOUBLE}{@link GL12#GL_UNSIGNED_INT_2_10_10_10_REV UNSIGNED_INT_2_10_10_10_REV}{@link GL33#GL_INT_2_10_10_10_REV INT_2_10_10_10_REV}
+ * @param stride the vertex stride in bytes. If specified as zero, then array elements are stored sequentially + * @param pointer the color array data + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glColorPointer(@NativeType("GLint") int size, @NativeType("GLenum") int type, @NativeType("GLsizei") int stride, @NativeType("void const *") long pointer) { + nglColorPointer(size, type, stride, pointer); + } + + /** + * Specifies the location and organization of a color array. + * + * @param size the number of values per vertex that are stored in the array, as well as their component ordering. One of:
34{@link GL12#GL_BGRA BGRA}
+ * @param type the data type of the values stored in the array. One of:
{@link #GL_BYTE BYTE}{@link #GL_UNSIGNED_BYTE UNSIGNED_BYTE}{@link #GL_SHORT SHORT}{@link #GL_UNSIGNED_SHORT UNSIGNED_SHORT}{@link #GL_INT INT}{@link #GL_UNSIGNED_INT UNSIGNED_INT}{@link GL30#GL_HALF_FLOAT HALF_FLOAT}
{@link #GL_FLOAT FLOAT}{@link #GL_DOUBLE DOUBLE}{@link GL12#GL_UNSIGNED_INT_2_10_10_10_REV UNSIGNED_INT_2_10_10_10_REV}{@link GL33#GL_INT_2_10_10_10_REV INT_2_10_10_10_REV}
+ * @param stride the vertex stride in bytes. If specified as zero, then array elements are stored sequentially + * @param pointer the color array data + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glColorPointer(@NativeType("GLint") int size, @NativeType("GLenum") int type, @NativeType("GLsizei") int stride, @NativeType("void const *") ShortBuffer pointer) { + nglColorPointer(size, type, stride, memAddress(pointer)); + } + + /** + * Specifies the location and organization of a color array. + * + * @param size the number of values per vertex that are stored in the array, as well as their component ordering. One of:
34{@link GL12#GL_BGRA BGRA}
+ * @param type the data type of the values stored in the array. One of:
{@link #GL_BYTE BYTE}{@link #GL_UNSIGNED_BYTE UNSIGNED_BYTE}{@link #GL_SHORT SHORT}{@link #GL_UNSIGNED_SHORT UNSIGNED_SHORT}{@link #GL_INT INT}{@link #GL_UNSIGNED_INT UNSIGNED_INT}{@link GL30#GL_HALF_FLOAT HALF_FLOAT}
{@link #GL_FLOAT FLOAT}{@link #GL_DOUBLE DOUBLE}{@link GL12#GL_UNSIGNED_INT_2_10_10_10_REV UNSIGNED_INT_2_10_10_10_REV}{@link GL33#GL_INT_2_10_10_10_REV INT_2_10_10_10_REV}
+ * @param stride the vertex stride in bytes. If specified as zero, then array elements are stored sequentially + * @param pointer the color array data + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glColorPointer(@NativeType("GLint") int size, @NativeType("GLenum") int type, @NativeType("GLsizei") int stride, @NativeType("void const *") IntBuffer pointer) { + nglColorPointer(size, type, stride, memAddress(pointer)); + } + + /** + * Specifies the location and organization of a color array. + * + * @param size the number of values per vertex that are stored in the array, as well as their component ordering. One of:
34{@link GL12#GL_BGRA BGRA}
+ * @param type the data type of the values stored in the array. One of:
{@link #GL_BYTE BYTE}{@link #GL_UNSIGNED_BYTE UNSIGNED_BYTE}{@link #GL_SHORT SHORT}{@link #GL_UNSIGNED_SHORT UNSIGNED_SHORT}{@link #GL_INT INT}{@link #GL_UNSIGNED_INT UNSIGNED_INT}{@link GL30#GL_HALF_FLOAT HALF_FLOAT}
{@link #GL_FLOAT FLOAT}{@link #GL_DOUBLE DOUBLE}{@link GL12#GL_UNSIGNED_INT_2_10_10_10_REV UNSIGNED_INT_2_10_10_10_REV}{@link GL33#GL_INT_2_10_10_10_REV INT_2_10_10_10_REV}
+ * @param stride the vertex stride in bytes. If specified as zero, then array elements are stored sequentially + * @param pointer the color array data + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glColorPointer(@NativeType("GLint") int size, @NativeType("GLenum") int type, @NativeType("GLsizei") int stride, @NativeType("void const *") FloatBuffer pointer) { + nglColorPointer(size, type, stride, memAddress(pointer)); + } + + // --- [ glCopyPixels ] --- + + /** + * Transfers a rectangle of pixel values from one region of the read framebuffer to another in the draw framebuffer + * + * @param x the left framebuffer pixel coordinate + * @param y the lower framebuffer pixel coordinate + * @param width the rectangle width + * @param height the rectangle height + * @param type Indicates the type of values to be transfered. One of:
{@link #GL_COLOR COLOR}{@link #GL_STENCIL STENCIL}{@link #GL_DEPTH DEPTH}{@link GL30#GL_DEPTH_STENCIL DEPTH_STENCIL}
+ * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glCopyPixels(@NativeType("GLint") int x, @NativeType("GLint") int y, @NativeType("GLsizei") int width, @NativeType("GLsizei") int height, @NativeType("GLenum") int type); + + // --- [ glCullFace ] --- + + /** + * Specifies which polygon faces are culled if {@link GL11C#GL_CULL_FACE CULL_FACE} is enabled. Front-facing polygons are rasterized if either culling is disabled or the + * CullFace mode is {@link GL11C#GL_BACK BACK} while back-facing polygons are rasterized only if either culling is disabled or the CullFace mode is + * {@link GL11C#GL_FRONT FRONT}. The initial setting of the CullFace mode is {@link GL11C#GL_BACK BACK}. Initially, culling is disabled. + * + * @param mode the CullFace mode. One of:
{@link GL11C#GL_FRONT FRONT}{@link GL11C#GL_BACK BACK}{@link GL11C#GL_FRONT_AND_BACK FRONT_AND_BACK}
+ * + * @see Reference Page + */ + public static void glCullFace(@NativeType("GLenum") int mode) { + GL11C.glCullFace(mode); + } + + // --- [ glDeleteLists ] --- + + /** + * Deletes a contiguous group of display lists. All information about the display lists is lost, and the indices become unused. Indices to which no display + * list corresponds are ignored. If {@code range} is zero, nothing happens. + * + * @param list the index of the first display list to be deleted + * @param range the number of display lists to be deleted + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glDeleteLists(@NativeType("GLuint") int list, @NativeType("GLsizei") int range); + + // --- [ glDepthFunc ] --- + + /** + * Specifies the comparison that takes place during the depth buffer test (when {@link GL11C#GL_DEPTH_TEST DEPTH_TEST} is enabled). + * + * @param func the depth test comparison. One of:
{@link GL11C#GL_NEVER NEVER}{@link GL11C#GL_ALWAYS ALWAYS}{@link GL11C#GL_LESS LESS}{@link GL11C#GL_LEQUAL LEQUAL}{@link GL11C#GL_EQUAL EQUAL}{@link GL11C#GL_GREATER GREATER}{@link GL11C#GL_GEQUAL GEQUAL}{@link GL11C#GL_NOTEQUAL NOTEQUAL}
+ * + * @see Reference Page + */ + public static void glDepthFunc(@NativeType("GLenum") int func) { + GL11C.glDepthFunc(func); + } + + // --- [ glDepthMask ] --- + + /** + * Masks the writing of depth values to the depth buffer. In the initial state, the depth buffer is enabled for writing. + * + * @param flag whether depth values are written or not. + * + * @see Reference Page + */ + public static void glDepthMask(@NativeType("GLboolean") boolean flag) { + GL11C.glDepthMask(flag); + } + + // --- [ glDepthRange ] --- + + /** + * Sets the depth range for all viewports to the same values. + * + * @param zNear the near depth range + * @param zFar the far depth range + * + * @see Reference Page + */ + public static void glDepthRange(@NativeType("GLdouble") double zNear, @NativeType("GLdouble") double zFar) { + GL11C.glDepthRange(zNear, zFar); + } + + // --- [ glDisableClientState ] --- + + /** + * Disables a client-side capability. + * + *

If the {@link NVVertexBufferUnifiedMemory} extension is supported, this function is available even in a core profile context.

+ * + * @param cap the capability to disable. One of:
{@link #GL_COLOR_ARRAY COLOR_ARRAY}{@link #GL_EDGE_FLAG_ARRAY EDGE_FLAG_ARRAY}{@link GL15#GL_FOG_COORD_ARRAY FOG_COORD_ARRAY}{@link #GL_INDEX_ARRAY INDEX_ARRAY}
{@link #GL_NORMAL_ARRAY NORMAL_ARRAY}{@link GL14#GL_SECONDARY_COLOR_ARRAY SECONDARY_COLOR_ARRAY}{@link #GL_TEXTURE_COORD_ARRAY TEXTURE_COORD_ARRAY}{@link #GL_VERTEX_ARRAY VERTEX_ARRAY}
{@link NVVertexBufferUnifiedMemory#GL_VERTEX_ATTRIB_ARRAY_UNIFIED_NV VERTEX_ATTRIB_ARRAY_UNIFIED_NV}{@link NVVertexBufferUnifiedMemory#GL_ELEMENT_ARRAY_UNIFIED_NV ELEMENT_ARRAY_UNIFIED_NV}
+ * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glDisableClientState(@NativeType("GLenum") int cap); + + // --- [ glDrawArrays ] --- + + /** + * Constructs a sequence of geometric primitives by successively transferring elements for {@code count} vertices. Elements {@code first} through + * first + count – 1 of each enabled non-instanced array are transferred to the GL. + * + *

If an array corresponding to an attribute required by a vertex shader is not enabled, then the corresponding element is taken from the current attribute + * state. If an array is enabled, the corresponding current vertex attribute value is unaffected by the execution of this function.

+ * + * @param mode the kind of primitives being constructed + * @param first the first vertex to transfer to the GL + * @param count the number of vertices after {@code first} to transfer to the GL + * + * @see Reference Page + */ + public static void glDrawArrays(@NativeType("GLenum") int mode, @NativeType("GLint") int first, @NativeType("GLsizei") int count) { + GL11C.glDrawArrays(mode, first, count); + } + + // --- [ glDrawBuffer ] --- + + /** + * Defines the color buffer to which fragment color zero is written. + * + *

Acceptable values for {@code buf} depend on whether the GL is using the default framebuffer (i.e., {@link GL30#GL_DRAW_FRAMEBUFFER_BINDING DRAW_FRAMEBUFFER_BINDING} is zero), or + * a framebuffer object (i.e., {@link GL30#GL_DRAW_FRAMEBUFFER_BINDING DRAW_FRAMEBUFFER_BINDING} is non-zero). In the initial state, the GL is bound to the default framebuffer.

+ * + * @param buf the color buffer to draw to. One of:
{@link GL11C#GL_NONE NONE}{@link GL11C#GL_FRONT_LEFT FRONT_LEFT}{@link GL11C#GL_FRONT_RIGHT FRONT_RIGHT}{@link GL11C#GL_BACK_LEFT BACK_LEFT}{@link GL11C#GL_BACK_RIGHT BACK_RIGHT}{@link GL11C#GL_FRONT FRONT}{@link GL11C#GL_BACK BACK}{@link GL11C#GL_LEFT LEFT}
{@link GL11C#GL_RIGHT RIGHT}{@link GL11C#GL_FRONT_AND_BACK FRONT_AND_BACK}{@link GL30#GL_COLOR_ATTACHMENT0 COLOR_ATTACHMENT0}GL30.GL_COLOR_ATTACHMENT[1-15]
+ * + * @see Reference Page + */ + public static void glDrawBuffer(@NativeType("GLenum") int buf) { + GL11C.glDrawBuffer(buf); + } + + // --- [ glDrawElements ] --- + + /** + * Unsafe version of: {@link #glDrawElements DrawElements} + * + * @param count the number of vertices to transfer to the GL + * @param type indicates the type of index values in {@code indices}. One of:
{@link #GL_UNSIGNED_BYTE UNSIGNED_BYTE}{@link #GL_UNSIGNED_SHORT UNSIGNED_SHORT}{@link #GL_UNSIGNED_INT UNSIGNED_INT}
+ */ + public static void nglDrawElements(int mode, int count, int type, long indices) { + GL11C.nglDrawElements(mode, count, type, indices); + } + + /** + * Constructs a sequence of geometric primitives by successively transferring elements for {@code count} vertices to the GL. + * The ith element transferred by {@code DrawElements} will be taken from element {@code indices[i]} (if no element array buffer is bound), or + * from the element whose index is stored in the currently bound element array buffer at offset {@code indices + i}. + * + * @param mode the kind of primitives being constructed. One of:
{@link GL11C#GL_POINTS POINTS}{@link GL11C#GL_LINE_STRIP LINE_STRIP}{@link GL11C#GL_LINE_LOOP LINE_LOOP}{@link GL11C#GL_LINES LINES}{@link GL11C#GL_TRIANGLE_STRIP TRIANGLE_STRIP}{@link GL11C#GL_TRIANGLE_FAN TRIANGLE_FAN}
{@link GL11C#GL_TRIANGLES TRIANGLES}{@link GL32#GL_LINES_ADJACENCY LINES_ADJACENCY}{@link GL32#GL_LINE_STRIP_ADJACENCY LINE_STRIP_ADJACENCY}{@link GL32#GL_TRIANGLES_ADJACENCY TRIANGLES_ADJACENCY}{@link GL32#GL_TRIANGLE_STRIP_ADJACENCY TRIANGLE_STRIP_ADJACENCY}{@link GL40#GL_PATCHES PATCHES}
+ * @param count the number of vertices to transfer to the GL + * @param type indicates the type of index values in {@code indices}. One of:
{@link GL11C#GL_UNSIGNED_BYTE UNSIGNED_BYTE}{@link GL11C#GL_UNSIGNED_SHORT UNSIGNED_SHORT}{@link GL11C#GL_UNSIGNED_INT UNSIGNED_INT}
+ * @param indices the index values + * + * @see Reference Page + */ + public static void glDrawElements(@NativeType("GLenum") int mode, @NativeType("GLsizei") int count, @NativeType("GLenum") int type, @NativeType("void const *") long indices) { + GL11C.glDrawElements(mode, count, type, indices); + } + + /** + * Constructs a sequence of geometric primitives by successively transferring elements for {@code count} vertices to the GL. + * The ith element transferred by {@code DrawElements} will be taken from element {@code indices[i]} (if no element array buffer is bound), or + * from the element whose index is stored in the currently bound element array buffer at offset {@code indices + i}. + * + * @param mode the kind of primitives being constructed. One of:
{@link GL11C#GL_POINTS POINTS}{@link GL11C#GL_LINE_STRIP LINE_STRIP}{@link GL11C#GL_LINE_LOOP LINE_LOOP}{@link GL11C#GL_LINES LINES}{@link GL11C#GL_TRIANGLE_STRIP TRIANGLE_STRIP}{@link GL11C#GL_TRIANGLE_FAN TRIANGLE_FAN}
{@link GL11C#GL_TRIANGLES TRIANGLES}{@link GL32#GL_LINES_ADJACENCY LINES_ADJACENCY}{@link GL32#GL_LINE_STRIP_ADJACENCY LINE_STRIP_ADJACENCY}{@link GL32#GL_TRIANGLES_ADJACENCY TRIANGLES_ADJACENCY}{@link GL32#GL_TRIANGLE_STRIP_ADJACENCY TRIANGLE_STRIP_ADJACENCY}{@link GL40#GL_PATCHES PATCHES}
+ * @param type indicates the type of index values in {@code indices}. One of:
{@link GL11C#GL_UNSIGNED_BYTE UNSIGNED_BYTE}{@link GL11C#GL_UNSIGNED_SHORT UNSIGNED_SHORT}{@link GL11C#GL_UNSIGNED_INT UNSIGNED_INT}
+ * @param indices the index values + * + * @see Reference Page + */ + public static void glDrawElements(@NativeType("GLenum") int mode, @NativeType("GLenum") int type, @NativeType("void const *") ByteBuffer indices) { + GL11C.glDrawElements(mode, type, indices); + } + + /** + * Constructs a sequence of geometric primitives by successively transferring elements for {@code count} vertices to the GL. + * The ith element transferred by {@code DrawElements} will be taken from element {@code indices[i]} (if no element array buffer is bound), or + * from the element whose index is stored in the currently bound element array buffer at offset {@code indices + i}. + * + * @param mode the kind of primitives being constructed. One of:
{@link GL11C#GL_POINTS POINTS}{@link GL11C#GL_LINE_STRIP LINE_STRIP}{@link GL11C#GL_LINE_LOOP LINE_LOOP}{@link GL11C#GL_LINES LINES}{@link GL11C#GL_TRIANGLE_STRIP TRIANGLE_STRIP}{@link GL11C#GL_TRIANGLE_FAN TRIANGLE_FAN}
{@link GL11C#GL_TRIANGLES TRIANGLES}{@link GL32#GL_LINES_ADJACENCY LINES_ADJACENCY}{@link GL32#GL_LINE_STRIP_ADJACENCY LINE_STRIP_ADJACENCY}{@link GL32#GL_TRIANGLES_ADJACENCY TRIANGLES_ADJACENCY}{@link GL32#GL_TRIANGLE_STRIP_ADJACENCY TRIANGLE_STRIP_ADJACENCY}{@link GL40#GL_PATCHES PATCHES}
+ * @param indices the index values + * + * @see Reference Page + */ + public static void glDrawElements(@NativeType("GLenum") int mode, @NativeType("void const *") ByteBuffer indices) { + GL11C.glDrawElements(mode, indices); + } + + /** + * Constructs a sequence of geometric primitives by successively transferring elements for {@code count} vertices to the GL. + * The ith element transferred by {@code DrawElements} will be taken from element {@code indices[i]} (if no element array buffer is bound), or + * from the element whose index is stored in the currently bound element array buffer at offset {@code indices + i}. + * + * @param mode the kind of primitives being constructed. One of:
{@link GL11C#GL_POINTS POINTS}{@link GL11C#GL_LINE_STRIP LINE_STRIP}{@link GL11C#GL_LINE_LOOP LINE_LOOP}{@link GL11C#GL_LINES LINES}{@link GL11C#GL_TRIANGLE_STRIP TRIANGLE_STRIP}{@link GL11C#GL_TRIANGLE_FAN TRIANGLE_FAN}
{@link GL11C#GL_TRIANGLES TRIANGLES}{@link GL32#GL_LINES_ADJACENCY LINES_ADJACENCY}{@link GL32#GL_LINE_STRIP_ADJACENCY LINE_STRIP_ADJACENCY}{@link GL32#GL_TRIANGLES_ADJACENCY TRIANGLES_ADJACENCY}{@link GL32#GL_TRIANGLE_STRIP_ADJACENCY TRIANGLE_STRIP_ADJACENCY}{@link GL40#GL_PATCHES PATCHES}
+ * @param indices the index values + * + * @see Reference Page + */ + public static void glDrawElements(@NativeType("GLenum") int mode, @NativeType("void const *") ShortBuffer indices) { + GL11C.glDrawElements(mode, indices); + } + + /** + * Constructs a sequence of geometric primitives by successively transferring elements for {@code count} vertices to the GL. + * The ith element transferred by {@code DrawElements} will be taken from element {@code indices[i]} (if no element array buffer is bound), or + * from the element whose index is stored in the currently bound element array buffer at offset {@code indices + i}. + * + * @param mode the kind of primitives being constructed. One of:
{@link GL11C#GL_POINTS POINTS}{@link GL11C#GL_LINE_STRIP LINE_STRIP}{@link GL11C#GL_LINE_LOOP LINE_LOOP}{@link GL11C#GL_LINES LINES}{@link GL11C#GL_TRIANGLE_STRIP TRIANGLE_STRIP}{@link GL11C#GL_TRIANGLE_FAN TRIANGLE_FAN}
{@link GL11C#GL_TRIANGLES TRIANGLES}{@link GL32#GL_LINES_ADJACENCY LINES_ADJACENCY}{@link GL32#GL_LINE_STRIP_ADJACENCY LINE_STRIP_ADJACENCY}{@link GL32#GL_TRIANGLES_ADJACENCY TRIANGLES_ADJACENCY}{@link GL32#GL_TRIANGLE_STRIP_ADJACENCY TRIANGLE_STRIP_ADJACENCY}{@link GL40#GL_PATCHES PATCHES}
+ * @param indices the index values + * + * @see Reference Page + */ + public static void glDrawElements(@NativeType("GLenum") int mode, @NativeType("void const *") IntBuffer indices) { + GL11C.glDrawElements(mode, indices); + } + + // --- [ glDrawPixels ] --- + + /** Unsafe version of: {@link #glDrawPixels DrawPixels} */ + public static native void nglDrawPixels(int width, int height, int format, int type, long pixels); + + /** + * Draws a pixel rectangle to the active draw buffers. + * + * @param width the pixel rectangle width + * @param height the pixel rectangle height + * @param format the pixel data format. One of:
{@link #GL_RED RED}{@link #GL_GREEN GREEN}{@link #GL_BLUE BLUE}{@link #GL_ALPHA ALPHA}{@link GL30#GL_RG RG}{@link #GL_RGB RGB}{@link GL11C#GL_RGBA RGBA}{@link GL12#GL_BGR BGR}
{@link GL12#GL_BGRA BGRA}{@link GL30#GL_RED_INTEGER RED_INTEGER}{@link GL30#GL_GREEN_INTEGER GREEN_INTEGER}{@link GL30#GL_BLUE_INTEGER BLUE_INTEGER}{@link GL30#GL_ALPHA_INTEGER ALPHA_INTEGER}{@link GL30#GL_RG_INTEGER RG_INTEGER}{@link GL30#GL_RGB_INTEGER RGB_INTEGER}{@link GL30#GL_RGBA_INTEGER RGBA_INTEGER}
{@link GL30#GL_BGR_INTEGER BGR_INTEGER}{@link GL30#GL_BGRA_INTEGER BGRA_INTEGER}{@link #GL_STENCIL_INDEX STENCIL_INDEX}{@link #GL_DEPTH_COMPONENT DEPTH_COMPONENT}{@link GL30#GL_DEPTH_STENCIL DEPTH_STENCIL}{@link #GL_LUMINANCE LUMINANCE}{@link #GL_LUMINANCE_ALPHA LUMINANCE_ALPHA}
+ * @param type the pixel data type. One of:
{@link #GL_UNSIGNED_BYTE UNSIGNED_BYTE}{@link #GL_BYTE BYTE}{@link #GL_UNSIGNED_SHORT UNSIGNED_SHORT}{@link #GL_SHORT SHORT}
{@link #GL_UNSIGNED_INT UNSIGNED_INT}{@link #GL_INT INT}{@link GL30#GL_HALF_FLOAT HALF_FLOAT}{@link #GL_FLOAT FLOAT}
{@link GL12#GL_UNSIGNED_BYTE_3_3_2 UNSIGNED_BYTE_3_3_2}{@link GL12#GL_UNSIGNED_BYTE_2_3_3_REV UNSIGNED_BYTE_2_3_3_REV}{@link GL12#GL_UNSIGNED_SHORT_5_6_5 UNSIGNED_SHORT_5_6_5}{@link GL12#GL_UNSIGNED_SHORT_5_6_5_REV UNSIGNED_SHORT_5_6_5_REV}
{@link GL12#GL_UNSIGNED_SHORT_4_4_4_4 UNSIGNED_SHORT_4_4_4_4}{@link GL12#GL_UNSIGNED_SHORT_4_4_4_4_REV UNSIGNED_SHORT_4_4_4_4_REV}{@link GL12#GL_UNSIGNED_SHORT_5_5_5_1 UNSIGNED_SHORT_5_5_5_1}{@link GL12#GL_UNSIGNED_SHORT_1_5_5_5_REV UNSIGNED_SHORT_1_5_5_5_REV}
{@link GL12#GL_UNSIGNED_INT_8_8_8_8 UNSIGNED_INT_8_8_8_8}{@link GL12#GL_UNSIGNED_INT_8_8_8_8_REV UNSIGNED_INT_8_8_8_8_REV}{@link GL12#GL_UNSIGNED_INT_10_10_10_2 UNSIGNED_INT_10_10_10_2}{@link GL12#GL_UNSIGNED_INT_2_10_10_10_REV UNSIGNED_INT_2_10_10_10_REV}
{@link GL30#GL_UNSIGNED_INT_24_8 UNSIGNED_INT_24_8}{@link GL30#GL_UNSIGNED_INT_10F_11F_11F_REV UNSIGNED_INT_10F_11F_11F_REV}{@link GL30#GL_UNSIGNED_INT_5_9_9_9_REV UNSIGNED_INT_5_9_9_9_REV}{@link GL30#GL_FLOAT_32_UNSIGNED_INT_24_8_REV FLOAT_32_UNSIGNED_INT_24_8_REV}
{@link #GL_BITMAP BITMAP}
+ * @param pixels the pixel data + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glDrawPixels(@NativeType("GLsizei") int width, @NativeType("GLsizei") int height, @NativeType("GLenum") int format, @NativeType("GLenum") int type, @NativeType("void const *") ByteBuffer pixels) { + nglDrawPixels(width, height, format, type, memAddress(pixels)); + } + + /** + * Draws a pixel rectangle to the active draw buffers. + * + * @param width the pixel rectangle width + * @param height the pixel rectangle height + * @param format the pixel data format. One of:
{@link #GL_RED RED}{@link #GL_GREEN GREEN}{@link #GL_BLUE BLUE}{@link #GL_ALPHA ALPHA}{@link GL30#GL_RG RG}{@link #GL_RGB RGB}{@link GL11C#GL_RGBA RGBA}{@link GL12#GL_BGR BGR}
{@link GL12#GL_BGRA BGRA}{@link GL30#GL_RED_INTEGER RED_INTEGER}{@link GL30#GL_GREEN_INTEGER GREEN_INTEGER}{@link GL30#GL_BLUE_INTEGER BLUE_INTEGER}{@link GL30#GL_ALPHA_INTEGER ALPHA_INTEGER}{@link GL30#GL_RG_INTEGER RG_INTEGER}{@link GL30#GL_RGB_INTEGER RGB_INTEGER}{@link GL30#GL_RGBA_INTEGER RGBA_INTEGER}
{@link GL30#GL_BGR_INTEGER BGR_INTEGER}{@link GL30#GL_BGRA_INTEGER BGRA_INTEGER}{@link #GL_STENCIL_INDEX STENCIL_INDEX}{@link #GL_DEPTH_COMPONENT DEPTH_COMPONENT}{@link GL30#GL_DEPTH_STENCIL DEPTH_STENCIL}{@link #GL_LUMINANCE LUMINANCE}{@link #GL_LUMINANCE_ALPHA LUMINANCE_ALPHA}
+ * @param type the pixel data type. One of:
{@link #GL_UNSIGNED_BYTE UNSIGNED_BYTE}{@link #GL_BYTE BYTE}{@link #GL_UNSIGNED_SHORT UNSIGNED_SHORT}{@link #GL_SHORT SHORT}
{@link #GL_UNSIGNED_INT UNSIGNED_INT}{@link #GL_INT INT}{@link GL30#GL_HALF_FLOAT HALF_FLOAT}{@link #GL_FLOAT FLOAT}
{@link GL12#GL_UNSIGNED_BYTE_3_3_2 UNSIGNED_BYTE_3_3_2}{@link GL12#GL_UNSIGNED_BYTE_2_3_3_REV UNSIGNED_BYTE_2_3_3_REV}{@link GL12#GL_UNSIGNED_SHORT_5_6_5 UNSIGNED_SHORT_5_6_5}{@link GL12#GL_UNSIGNED_SHORT_5_6_5_REV UNSIGNED_SHORT_5_6_5_REV}
{@link GL12#GL_UNSIGNED_SHORT_4_4_4_4 UNSIGNED_SHORT_4_4_4_4}{@link GL12#GL_UNSIGNED_SHORT_4_4_4_4_REV UNSIGNED_SHORT_4_4_4_4_REV}{@link GL12#GL_UNSIGNED_SHORT_5_5_5_1 UNSIGNED_SHORT_5_5_5_1}{@link GL12#GL_UNSIGNED_SHORT_1_5_5_5_REV UNSIGNED_SHORT_1_5_5_5_REV}
{@link GL12#GL_UNSIGNED_INT_8_8_8_8 UNSIGNED_INT_8_8_8_8}{@link GL12#GL_UNSIGNED_INT_8_8_8_8_REV UNSIGNED_INT_8_8_8_8_REV}{@link GL12#GL_UNSIGNED_INT_10_10_10_2 UNSIGNED_INT_10_10_10_2}{@link GL12#GL_UNSIGNED_INT_2_10_10_10_REV UNSIGNED_INT_2_10_10_10_REV}
{@link GL30#GL_UNSIGNED_INT_24_8 UNSIGNED_INT_24_8}{@link GL30#GL_UNSIGNED_INT_10F_11F_11F_REV UNSIGNED_INT_10F_11F_11F_REV}{@link GL30#GL_UNSIGNED_INT_5_9_9_9_REV UNSIGNED_INT_5_9_9_9_REV}{@link GL30#GL_FLOAT_32_UNSIGNED_INT_24_8_REV FLOAT_32_UNSIGNED_INT_24_8_REV}
{@link #GL_BITMAP BITMAP}
+ * @param pixels the pixel data + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glDrawPixels(@NativeType("GLsizei") int width, @NativeType("GLsizei") int height, @NativeType("GLenum") int format, @NativeType("GLenum") int type, @NativeType("void const *") long pixels) { + nglDrawPixels(width, height, format, type, pixels); + } + + /** + * Draws a pixel rectangle to the active draw buffers. + * + * @param width the pixel rectangle width + * @param height the pixel rectangle height + * @param format the pixel data format. One of:
{@link #GL_RED RED}{@link #GL_GREEN GREEN}{@link #GL_BLUE BLUE}{@link #GL_ALPHA ALPHA}{@link GL30#GL_RG RG}{@link #GL_RGB RGB}{@link GL11C#GL_RGBA RGBA}{@link GL12#GL_BGR BGR}
{@link GL12#GL_BGRA BGRA}{@link GL30#GL_RED_INTEGER RED_INTEGER}{@link GL30#GL_GREEN_INTEGER GREEN_INTEGER}{@link GL30#GL_BLUE_INTEGER BLUE_INTEGER}{@link GL30#GL_ALPHA_INTEGER ALPHA_INTEGER}{@link GL30#GL_RG_INTEGER RG_INTEGER}{@link GL30#GL_RGB_INTEGER RGB_INTEGER}{@link GL30#GL_RGBA_INTEGER RGBA_INTEGER}
{@link GL30#GL_BGR_INTEGER BGR_INTEGER}{@link GL30#GL_BGRA_INTEGER BGRA_INTEGER}{@link #GL_STENCIL_INDEX STENCIL_INDEX}{@link #GL_DEPTH_COMPONENT DEPTH_COMPONENT}{@link GL30#GL_DEPTH_STENCIL DEPTH_STENCIL}{@link #GL_LUMINANCE LUMINANCE}{@link #GL_LUMINANCE_ALPHA LUMINANCE_ALPHA}
+ * @param type the pixel data type. One of:
{@link #GL_UNSIGNED_BYTE UNSIGNED_BYTE}{@link #GL_BYTE BYTE}{@link #GL_UNSIGNED_SHORT UNSIGNED_SHORT}{@link #GL_SHORT SHORT}
{@link #GL_UNSIGNED_INT UNSIGNED_INT}{@link #GL_INT INT}{@link GL30#GL_HALF_FLOAT HALF_FLOAT}{@link #GL_FLOAT FLOAT}
{@link GL12#GL_UNSIGNED_BYTE_3_3_2 UNSIGNED_BYTE_3_3_2}{@link GL12#GL_UNSIGNED_BYTE_2_3_3_REV UNSIGNED_BYTE_2_3_3_REV}{@link GL12#GL_UNSIGNED_SHORT_5_6_5 UNSIGNED_SHORT_5_6_5}{@link GL12#GL_UNSIGNED_SHORT_5_6_5_REV UNSIGNED_SHORT_5_6_5_REV}
{@link GL12#GL_UNSIGNED_SHORT_4_4_4_4 UNSIGNED_SHORT_4_4_4_4}{@link GL12#GL_UNSIGNED_SHORT_4_4_4_4_REV UNSIGNED_SHORT_4_4_4_4_REV}{@link GL12#GL_UNSIGNED_SHORT_5_5_5_1 UNSIGNED_SHORT_5_5_5_1}{@link GL12#GL_UNSIGNED_SHORT_1_5_5_5_REV UNSIGNED_SHORT_1_5_5_5_REV}
{@link GL12#GL_UNSIGNED_INT_8_8_8_8 UNSIGNED_INT_8_8_8_8}{@link GL12#GL_UNSIGNED_INT_8_8_8_8_REV UNSIGNED_INT_8_8_8_8_REV}{@link GL12#GL_UNSIGNED_INT_10_10_10_2 UNSIGNED_INT_10_10_10_2}{@link GL12#GL_UNSIGNED_INT_2_10_10_10_REV UNSIGNED_INT_2_10_10_10_REV}
{@link GL30#GL_UNSIGNED_INT_24_8 UNSIGNED_INT_24_8}{@link GL30#GL_UNSIGNED_INT_10F_11F_11F_REV UNSIGNED_INT_10F_11F_11F_REV}{@link GL30#GL_UNSIGNED_INT_5_9_9_9_REV UNSIGNED_INT_5_9_9_9_REV}{@link GL30#GL_FLOAT_32_UNSIGNED_INT_24_8_REV FLOAT_32_UNSIGNED_INT_24_8_REV}
{@link #GL_BITMAP BITMAP}
+ * @param pixels the pixel data + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glDrawPixels(@NativeType("GLsizei") int width, @NativeType("GLsizei") int height, @NativeType("GLenum") int format, @NativeType("GLenum") int type, @NativeType("void const *") ShortBuffer pixels) { + nglDrawPixels(width, height, format, type, memAddress(pixels)); + } + + /** + * Draws a pixel rectangle to the active draw buffers. + * + * @param width the pixel rectangle width + * @param height the pixel rectangle height + * @param format the pixel data format. One of:
{@link #GL_RED RED}{@link #GL_GREEN GREEN}{@link #GL_BLUE BLUE}{@link #GL_ALPHA ALPHA}{@link GL30#GL_RG RG}{@link #GL_RGB RGB}{@link GL11C#GL_RGBA RGBA}{@link GL12#GL_BGR BGR}
{@link GL12#GL_BGRA BGRA}{@link GL30#GL_RED_INTEGER RED_INTEGER}{@link GL30#GL_GREEN_INTEGER GREEN_INTEGER}{@link GL30#GL_BLUE_INTEGER BLUE_INTEGER}{@link GL30#GL_ALPHA_INTEGER ALPHA_INTEGER}{@link GL30#GL_RG_INTEGER RG_INTEGER}{@link GL30#GL_RGB_INTEGER RGB_INTEGER}{@link GL30#GL_RGBA_INTEGER RGBA_INTEGER}
{@link GL30#GL_BGR_INTEGER BGR_INTEGER}{@link GL30#GL_BGRA_INTEGER BGRA_INTEGER}{@link #GL_STENCIL_INDEX STENCIL_INDEX}{@link #GL_DEPTH_COMPONENT DEPTH_COMPONENT}{@link GL30#GL_DEPTH_STENCIL DEPTH_STENCIL}{@link #GL_LUMINANCE LUMINANCE}{@link #GL_LUMINANCE_ALPHA LUMINANCE_ALPHA}
+ * @param type the pixel data type. One of:
{@link #GL_UNSIGNED_BYTE UNSIGNED_BYTE}{@link #GL_BYTE BYTE}{@link #GL_UNSIGNED_SHORT UNSIGNED_SHORT}{@link #GL_SHORT SHORT}
{@link #GL_UNSIGNED_INT UNSIGNED_INT}{@link #GL_INT INT}{@link GL30#GL_HALF_FLOAT HALF_FLOAT}{@link #GL_FLOAT FLOAT}
{@link GL12#GL_UNSIGNED_BYTE_3_3_2 UNSIGNED_BYTE_3_3_2}{@link GL12#GL_UNSIGNED_BYTE_2_3_3_REV UNSIGNED_BYTE_2_3_3_REV}{@link GL12#GL_UNSIGNED_SHORT_5_6_5 UNSIGNED_SHORT_5_6_5}{@link GL12#GL_UNSIGNED_SHORT_5_6_5_REV UNSIGNED_SHORT_5_6_5_REV}
{@link GL12#GL_UNSIGNED_SHORT_4_4_4_4 UNSIGNED_SHORT_4_4_4_4}{@link GL12#GL_UNSIGNED_SHORT_4_4_4_4_REV UNSIGNED_SHORT_4_4_4_4_REV}{@link GL12#GL_UNSIGNED_SHORT_5_5_5_1 UNSIGNED_SHORT_5_5_5_1}{@link GL12#GL_UNSIGNED_SHORT_1_5_5_5_REV UNSIGNED_SHORT_1_5_5_5_REV}
{@link GL12#GL_UNSIGNED_INT_8_8_8_8 UNSIGNED_INT_8_8_8_8}{@link GL12#GL_UNSIGNED_INT_8_8_8_8_REV UNSIGNED_INT_8_8_8_8_REV}{@link GL12#GL_UNSIGNED_INT_10_10_10_2 UNSIGNED_INT_10_10_10_2}{@link GL12#GL_UNSIGNED_INT_2_10_10_10_REV UNSIGNED_INT_2_10_10_10_REV}
{@link GL30#GL_UNSIGNED_INT_24_8 UNSIGNED_INT_24_8}{@link GL30#GL_UNSIGNED_INT_10F_11F_11F_REV UNSIGNED_INT_10F_11F_11F_REV}{@link GL30#GL_UNSIGNED_INT_5_9_9_9_REV UNSIGNED_INT_5_9_9_9_REV}{@link GL30#GL_FLOAT_32_UNSIGNED_INT_24_8_REV FLOAT_32_UNSIGNED_INT_24_8_REV}
{@link #GL_BITMAP BITMAP}
+ * @param pixels the pixel data + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glDrawPixels(@NativeType("GLsizei") int width, @NativeType("GLsizei") int height, @NativeType("GLenum") int format, @NativeType("GLenum") int type, @NativeType("void const *") IntBuffer pixels) { + nglDrawPixels(width, height, format, type, memAddress(pixels)); + } + + /** + * Draws a pixel rectangle to the active draw buffers. + * + * @param width the pixel rectangle width + * @param height the pixel rectangle height + * @param format the pixel data format. One of:
{@link #GL_RED RED}{@link #GL_GREEN GREEN}{@link #GL_BLUE BLUE}{@link #GL_ALPHA ALPHA}{@link GL30#GL_RG RG}{@link #GL_RGB RGB}{@link GL11C#GL_RGBA RGBA}{@link GL12#GL_BGR BGR}
{@link GL12#GL_BGRA BGRA}{@link GL30#GL_RED_INTEGER RED_INTEGER}{@link GL30#GL_GREEN_INTEGER GREEN_INTEGER}{@link GL30#GL_BLUE_INTEGER BLUE_INTEGER}{@link GL30#GL_ALPHA_INTEGER ALPHA_INTEGER}{@link GL30#GL_RG_INTEGER RG_INTEGER}{@link GL30#GL_RGB_INTEGER RGB_INTEGER}{@link GL30#GL_RGBA_INTEGER RGBA_INTEGER}
{@link GL30#GL_BGR_INTEGER BGR_INTEGER}{@link GL30#GL_BGRA_INTEGER BGRA_INTEGER}{@link #GL_STENCIL_INDEX STENCIL_INDEX}{@link #GL_DEPTH_COMPONENT DEPTH_COMPONENT}{@link GL30#GL_DEPTH_STENCIL DEPTH_STENCIL}{@link #GL_LUMINANCE LUMINANCE}{@link #GL_LUMINANCE_ALPHA LUMINANCE_ALPHA}
+ * @param type the pixel data type. One of:
{@link #GL_UNSIGNED_BYTE UNSIGNED_BYTE}{@link #GL_BYTE BYTE}{@link #GL_UNSIGNED_SHORT UNSIGNED_SHORT}{@link #GL_SHORT SHORT}
{@link #GL_UNSIGNED_INT UNSIGNED_INT}{@link #GL_INT INT}{@link GL30#GL_HALF_FLOAT HALF_FLOAT}{@link #GL_FLOAT FLOAT}
{@link GL12#GL_UNSIGNED_BYTE_3_3_2 UNSIGNED_BYTE_3_3_2}{@link GL12#GL_UNSIGNED_BYTE_2_3_3_REV UNSIGNED_BYTE_2_3_3_REV}{@link GL12#GL_UNSIGNED_SHORT_5_6_5 UNSIGNED_SHORT_5_6_5}{@link GL12#GL_UNSIGNED_SHORT_5_6_5_REV UNSIGNED_SHORT_5_6_5_REV}
{@link GL12#GL_UNSIGNED_SHORT_4_4_4_4 UNSIGNED_SHORT_4_4_4_4}{@link GL12#GL_UNSIGNED_SHORT_4_4_4_4_REV UNSIGNED_SHORT_4_4_4_4_REV}{@link GL12#GL_UNSIGNED_SHORT_5_5_5_1 UNSIGNED_SHORT_5_5_5_1}{@link GL12#GL_UNSIGNED_SHORT_1_5_5_5_REV UNSIGNED_SHORT_1_5_5_5_REV}
{@link GL12#GL_UNSIGNED_INT_8_8_8_8 UNSIGNED_INT_8_8_8_8}{@link GL12#GL_UNSIGNED_INT_8_8_8_8_REV UNSIGNED_INT_8_8_8_8_REV}{@link GL12#GL_UNSIGNED_INT_10_10_10_2 UNSIGNED_INT_10_10_10_2}{@link GL12#GL_UNSIGNED_INT_2_10_10_10_REV UNSIGNED_INT_2_10_10_10_REV}
{@link GL30#GL_UNSIGNED_INT_24_8 UNSIGNED_INT_24_8}{@link GL30#GL_UNSIGNED_INT_10F_11F_11F_REV UNSIGNED_INT_10F_11F_11F_REV}{@link GL30#GL_UNSIGNED_INT_5_9_9_9_REV UNSIGNED_INT_5_9_9_9_REV}{@link GL30#GL_FLOAT_32_UNSIGNED_INT_24_8_REV FLOAT_32_UNSIGNED_INT_24_8_REV}
{@link #GL_BITMAP BITMAP}
+ * @param pixels the pixel data + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glDrawPixels(@NativeType("GLsizei") int width, @NativeType("GLsizei") int height, @NativeType("GLenum") int format, @NativeType("GLenum") int type, @NativeType("void const *") FloatBuffer pixels) { + nglDrawPixels(width, height, format, type, memAddress(pixels)); + } + + // --- [ glEdgeFlag ] --- + + /** + * Each edge of each polygon primitive generated is flagged as either boundary or non-boundary. These classifications are used during polygon + * rasterization; some modes affect the interpretation of polygon boundary edges. By default, all edges are boundary edges, but the flagging of polygons, + * separate triangles, or separate quadrilaterals may be altered by calling this function. + * + *

When a primitive of type {@link #GL_POLYGON POLYGON}, {@link #GL_TRIANGLES TRIANGLES}, or {@link #GL_QUADS QUADS} is drawn, each vertex transferred begins an edge. If the edge + * flag bit is TRUE, then each specified vertex begins an edge that is flagged as boundary. If the bit is FALSE, then induced edges are flagged as + * non-boundary.

+ * + * @param flag the edge flag bit + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glEdgeFlag(@NativeType("GLboolean") boolean flag); + + // --- [ glEdgeFlagv ] --- + + /** Unsafe version of: {@link #glEdgeFlagv EdgeFlagv} */ + public static native void nglEdgeFlagv(long flag); + + /** + * Pointer version of {@link #glEdgeFlag EdgeFlag}. + * + * @param flag the edge flag buffer + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glEdgeFlagv(@NativeType("GLboolean const *") ByteBuffer flag) { + if (CHECKS) { + check(flag, 1); + } + nglEdgeFlagv(memAddress(flag)); + } + + // --- [ glEdgeFlagPointer ] --- + + /** Unsafe version of: {@link #glEdgeFlagPointer EdgeFlagPointer} */ + public static native void nglEdgeFlagPointer(int stride, long pointer); + + /** + * Specifies the location and organization of an edge flag array. + * + * @param stride the vertex stride in bytes. If specified as zero, then array elements are stored sequentially + * @param pointer the edge flag array data + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glEdgeFlagPointer(@NativeType("GLsizei") int stride, @NativeType("GLboolean const *") ByteBuffer pointer) { + nglEdgeFlagPointer(stride, memAddress(pointer)); + } + + /** + * Specifies the location and organization of an edge flag array. + * + * @param stride the vertex stride in bytes. If specified as zero, then array elements are stored sequentially + * @param pointer the edge flag array data + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glEdgeFlagPointer(@NativeType("GLsizei") int stride, @NativeType("GLboolean const *") long pointer) { + nglEdgeFlagPointer(stride, pointer); + } + + // --- [ glEnableClientState ] --- + + /** + * Enables a client-side capability. + * + *

If the {@link NVVertexBufferUnifiedMemory} extension is supported, this function is available even in a core profile context.

+ * + * @param cap the capability to enable. One of:
{@link #GL_COLOR_ARRAY COLOR_ARRAY}{@link #GL_EDGE_FLAG_ARRAY EDGE_FLAG_ARRAY}{@link GL15#GL_FOG_COORD_ARRAY FOG_COORD_ARRAY}{@link #GL_INDEX_ARRAY INDEX_ARRAY}
{@link #GL_NORMAL_ARRAY NORMAL_ARRAY}{@link GL14#GL_SECONDARY_COLOR_ARRAY SECONDARY_COLOR_ARRAY}{@link #GL_TEXTURE_COORD_ARRAY TEXTURE_COORD_ARRAY}{@link #GL_VERTEX_ARRAY VERTEX_ARRAY}
{@link NVVertexBufferUnifiedMemory#GL_VERTEX_ATTRIB_ARRAY_UNIFIED_NV VERTEX_ATTRIB_ARRAY_UNIFIED_NV}{@link NVVertexBufferUnifiedMemory#GL_ELEMENT_ARRAY_UNIFIED_NV ELEMENT_ARRAY_UNIFIED_NV}
+ * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glEnableClientState(@NativeType("GLenum") int cap); + + // --- [ glEnd ] --- + + /** + * Ends the definition of vertex attributes of a sequence of primitives to be transferred to the GL. + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glEnd(); + + // --- [ glEvalCoord1f ] --- + + /** + * Causes evaluation of the enabled one-dimensional evaluator maps. + * + * @param u the domain coordinate u + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glEvalCoord1f(@NativeType("GLfloat") float u); + + // --- [ glEvalCoord1fv ] --- + + /** Unsafe version of: {@link #glEvalCoord1fv EvalCoord1fv} */ + public static native void nglEvalCoord1fv(long u); + + /** + * Pointer version of {@link #glEvalCoord1f EvalCoord1f}. + * + * @param u the domain coordinate buffer + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glEvalCoord1fv(@NativeType("GLfloat const *") FloatBuffer u) { + if (CHECKS) { + check(u, 1); + } + nglEvalCoord1fv(memAddress(u)); + } + + // --- [ glEvalCoord1d ] --- + + /** + * Double version of {@link #glEvalCoord1f EvalCoord1f}. + * + * @param u the domain coordinate u + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glEvalCoord1d(@NativeType("GLdouble") double u); + + // --- [ glEvalCoord1dv ] --- + + /** Unsafe version of: {@link #glEvalCoord1dv EvalCoord1dv} */ + public static native void nglEvalCoord1dv(long u); + + /** + * Pointer version of {@link #glEvalCoord1d EvalCoord1d}. + * + * @param u the domain coordinate buffer + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glEvalCoord1dv(@NativeType("GLdouble const *") DoubleBuffer u) { + if (CHECKS) { + check(u, 1); + } + nglEvalCoord1dv(memAddress(u)); + } + + // --- [ glEvalCoord2f ] --- + + /** + * Causes evaluation of the enabled two-dimensional evaluator maps. + * + * @param u the domain coordinate u + * @param v the domain coordinate v + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glEvalCoord2f(@NativeType("GLfloat") float u, @NativeType("GLfloat") float v); + + // --- [ glEvalCoord2fv ] --- + + /** Unsafe version of: {@link #glEvalCoord2fv EvalCoord2fv} */ + public static native void nglEvalCoord2fv(long u); + + /** + * Pointer version of {@link #glEvalCoord2f EvalCoord2f}. + * + * @param u the domain coordinate buffer + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glEvalCoord2fv(@NativeType("GLfloat const *") FloatBuffer u) { + if (CHECKS) { + check(u, 2); + } + nglEvalCoord2fv(memAddress(u)); + } + + // --- [ glEvalCoord2d ] --- + + /** + * Double version of {@link #glEvalCoord2f EvalCoord2f}. + * + * @param u the domain coordinate u + * @param v the domain coordinate v + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glEvalCoord2d(@NativeType("GLdouble") double u, @NativeType("GLdouble") double v); + + // --- [ glEvalCoord2dv ] --- + + /** Unsafe version of: {@link #glEvalCoord2dv EvalCoord2dv} */ + public static native void nglEvalCoord2dv(long u); + + /** + * Pointer version of {@link #glEvalCoord2d EvalCoord2d}. + * + * @param u the domain coordinate buffer + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glEvalCoord2dv(@NativeType("GLdouble const *") DoubleBuffer u) { + if (CHECKS) { + check(u, 2); + } + nglEvalCoord2dv(memAddress(u)); + } + + // --- [ glEvalMesh1 ] --- + + /** + * Carries out an evaluation on a subset of the one-dimensional map grid. + * + * @param mode the mesh type. One of:
{@link #GL_POINT POINT}{@link #GL_LINE LINE}
+ * @param i1 the start index + * @param i2 the end index + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glEvalMesh1(@NativeType("GLenum") int mode, @NativeType("GLint") int i1, @NativeType("GLint") int i2); + + // --- [ glEvalMesh2 ] --- + + /** + * Carries out an evaluation on a rectangular subset of the two-dimensional map grid. + * + * @param mode the mesh type. One of:
{@link #GL_FILL FILL}{@link #GL_LINE LINE}{@link #GL_POINT POINT}
+ * @param i1 the u-dimension start index + * @param i2 the u-dimension end index + * @param j1 the v-dimension start index + * @param j2 the v-dimension end index + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glEvalMesh2(@NativeType("GLenum") int mode, @NativeType("GLint") int i1, @NativeType("GLint") int i2, @NativeType("GLint") int j1, @NativeType("GLint") int j2); + + // --- [ glEvalPoint1 ] --- + + /** + * Carries out an evalutation of a single point on the one-dimensional map grid. + * + * @param i the grid index + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glEvalPoint1(@NativeType("GLint") int i); + + // --- [ glEvalPoint2 ] --- + + /** + * Carries out an evalutation of a single point on the two-dimensional map grid. + * + * @param i the u-dimension grid index + * @param j the v-dimension grid index + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glEvalPoint2(@NativeType("GLint") int i, @NativeType("GLint") int j); + + // --- [ glFeedbackBuffer ] --- + + /** + * Unsafe version of: {@link #glFeedbackBuffer FeedbackBuffer} + * + * @param size the maximum number of values that can be written to {@code buffer} + */ + public static native void nglFeedbackBuffer(int size, int type, long buffer); + + /** + * Returns information about primitives when the GL is in feedback mode. + * + * @param type the type of information to feed back for each vertex. One of:
{@link #GL_2D 2D}{@link #GL_3D 3D}{@link #GL_3D_COLOR 3D_COLOR}{@link #GL_3D_COLOR_TEXTURE 3D_COLOR_TEXTURE}{@link #GL_4D_COLOR_TEXTURE 4D_COLOR_TEXTURE}
+ * @param buffer an array of floating-point values into which feedback information will be placed + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glFeedbackBuffer(@NativeType("GLenum") int type, @NativeType("GLfloat *") FloatBuffer buffer) { + nglFeedbackBuffer(buffer.remaining(), type, memAddress(buffer)); + } + + // --- [ glFinish ] --- + + /** + * Forces all previously issued GL commands to complete. {@code Finish} does not return until all effects from such commands on GL client and server + * state and the framebuffer are fully realized. + * + * @see Reference Page + */ + public static void glFinish() { + GL11C.glFinish(); + } + + // --- [ glFlush ] --- + + /** + * Causes all previously issued GL commands to complete in finite time (although such commands may still be executing when {@code Flush} returns). + * + * @see Reference Page + */ + public static void glFlush() { + GL11C.glFlush(); + } + + // --- [ glFogi ] --- + + /** + * Sets the integer value of a fog parameter. + * + * @param pname the fog parameter. One of:
{@link #GL_FOG_MODE FOG_MODE}{@link GL15#GL_FOG_COORD_SRC FOG_COORD_SRC}
+ * @param param the fog parameter value. One of:
{@link #GL_EXP EXP}{@link #GL_EXP2 EXP2}{@link #GL_LINEAR LINEAR}{@link GL14#GL_FRAGMENT_DEPTH FRAGMENT_DEPTH}{@link GL15#GL_FOG_COORD FOG_COORD}
+ * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glFogi(@NativeType("GLenum") int pname, @NativeType("GLint") int param); + + // --- [ glFogiv ] --- + + /** Unsafe version of: {@link #glFogiv Fogiv} */ + public static native void nglFogiv(int pname, long params); + + /** + * Pointer version of {@link #glFogi Fogi}. + * + * @param pname the fog parameter. One of:
{@link #GL_FOG_MODE FOG_MODE}{@link GL15#GL_FOG_COORD_SRC FOG_COORD_SRC}
+ * @param params the fog parameter buffer + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glFogiv(@NativeType("GLenum") int pname, @NativeType("GLint const *") IntBuffer params) { + if (CHECKS) { + check(params, 1); + } + nglFogiv(pname, memAddress(params)); + } + + // --- [ glFogf ] --- + + /** + * Sets the float value of a fog parameter. + * + * @param pname the fog parameter. One of:
{@link #GL_FOG_DENSITY FOG_DENSITY}{@link #GL_FOG_START FOG_START}{@link #GL_FOG_END FOG_END}
+ * @param param the fog parameter value + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glFogf(@NativeType("GLenum") int pname, @NativeType("GLfloat") float param); + + // --- [ glFogfv ] --- + + /** Unsafe version of: {@link #glFogfv Fogfv} */ + public static native void nglFogfv(int pname, long params); + + /** + * Pointer version of {@link #glFogf Fogf}. + * + * @param pname the fog parameter. One of:
{@link #GL_FOG_DENSITY FOG_DENSITY}{@link #GL_FOG_START FOG_START}{@link #GL_FOG_END FOG_END}
+ * @param params the fog parameter buffer + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glFogfv(@NativeType("GLenum") int pname, @NativeType("GLfloat const *") FloatBuffer params) { + if (CHECKS) { + check(params, 1); + } + nglFogfv(pname, memAddress(params)); + } + + // --- [ glFrontFace ] --- + + /** + * The first step of polygon rasterization is to determine if the polygon is back-facing or front-facing. This determination is made based on the sign of + * the (clipped or unclipped) polygon's area computed in window coordinates. The interpretation of the sign of this value is controlled with this function. + * In the initial state, the front face direction is set to {@link GL11C#GL_CCW CCW}. + * + * @param dir the front face direction. One of:
{@link GL11C#GL_CCW CCW}{@link GL11C#GL_CW CW}
+ * + * @see Reference Page + */ + public static void glFrontFace(@NativeType("GLenum") int dir) { + GL11C.glFrontFace(dir); + } + + // --- [ glGenLists ] --- + + /** + * Returns an integer n such that the indices {@code n,..., n + s - 1} are previously unused (i.e. there are {@code s} previously unused display list + * indices starting at n). {@code GenLists} also has the effect of creating an empty display list for each of the indices {@code n,..., n + s - 1}, so + * that these indices all become used. {@code GenLists} returns zero if there is no group of {@code s} contiguous previously unused display list indices, + * or if {@code s = 0}. + * + * @param s the number of display lists to create + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + @NativeType("GLuint") + public static native int glGenLists(@NativeType("GLsizei") int s); + + // --- [ glGenTextures ] --- + + /** + * Unsafe version of: {@link #glGenTextures GenTextures} + * + * @param n the number of textures to create + */ + public static void nglGenTextures(int n, long textures) { + GL11C.nglGenTextures(n, textures); + } + + /** + * Returns n previously unused texture names in textures. These names are marked as used, for the purposes of GenTextures only, but they acquire texture + * state and a dimensionality only when they are first bound, just as if they were unused. + * + * @param textures a scalar or buffer in which to place the returned texture names + * + * @see Reference Page + */ + public static void glGenTextures(@NativeType("GLuint *") IntBuffer textures) { + GL11C.glGenTextures(textures); + } + + /** + * Returns n previously unused texture names in textures. These names are marked as used, for the purposes of GenTextures only, but they acquire texture + * state and a dimensionality only when they are first bound, just as if they were unused. + * + * @see Reference Page + */ + @NativeType("void") + public static int glGenTextures() { + return GL11C.glGenTextures(); + } + + // --- [ glDeleteTextures ] --- + + /** + * Unsafe version of: {@link #glDeleteTextures DeleteTextures} + * + * @param n the number of texture names in the {@code textures} parameter + */ + public static void nglDeleteTextures(int n, long textures) { + GL11C.nglDeleteTextures(n, textures); + } + + /** + * Deletes texture objects. After a texture object is deleted, it has no contents or dimensionality, and its name is again unused. If a texture that is + * currently bound to any of the target bindings of {@link #glBindTexture BindTexture} is deleted, it is as though {@link #glBindTexture BindTexture} had been executed with the + * same target and texture zero. Additionally, special care must be taken when deleting a texture if any of the images of the texture are attached to a + * framebuffer object. + * + *

Unused names in textures that have been marked as used for the purposes of {@link #glGenTextures GenTextures} are marked as unused again. Unused names in textures are + * silently ignored, as is the name zero.

+ * + * @param textures contains {@code n} names of texture objects to be deleted + * + * @see Reference Page + */ + public static void glDeleteTextures(@NativeType("GLuint const *") IntBuffer textures) { + GL11C.glDeleteTextures(textures); + } + + /** + * Deletes texture objects. After a texture object is deleted, it has no contents or dimensionality, and its name is again unused. If a texture that is + * currently bound to any of the target bindings of {@link #glBindTexture BindTexture} is deleted, it is as though {@link #glBindTexture BindTexture} had been executed with the + * same target and texture zero. Additionally, special care must be taken when deleting a texture if any of the images of the texture are attached to a + * framebuffer object. + * + *

Unused names in textures that have been marked as used for the purposes of {@link #glGenTextures GenTextures} are marked as unused again. Unused names in textures are + * silently ignored, as is the name zero.

+ * + * @see Reference Page + */ + public static void glDeleteTextures(@NativeType("GLuint const *") int texture) { + GL11C.glDeleteTextures(texture); + } + + // --- [ glGetClipPlane ] --- + + /** Unsafe version of: {@link #glGetClipPlane GetClipPlane} */ + public static native void nglGetClipPlane(int plane, long equation); + + /** + * Returns four double-precision values in {@code equation}; these are the coefficients of the plane equation of plane in eye coordinates (these + * coordinates are those that were computed when the plane was specified). + * + * @param plane the clip plane + * @param equation a buffer in which to place the returned values + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glGetClipPlane(@NativeType("GLenum") int plane, @NativeType("GLdouble *") DoubleBuffer equation) { + if (CHECKS) { + check(equation, 4); + } + nglGetClipPlane(plane, memAddress(equation)); + } + + // --- [ glGetBooleanv ] --- + + /** Unsafe version of: {@link #glGetBooleanv GetBooleanv} */ + public static void nglGetBooleanv(int pname, long params) { + GL11C.nglGetBooleanv(pname, params); + } + + /** + * Returns the current boolean value of the specified state variable. + * + *

LWJGL note: The state that corresponds to the state variable may be a single value or an array of values. In the case of an array of values, + * LWJGL will not validate if {@code params} has enough space to store that array. Doing so would introduce significant overhead, as the + * OpenGL state variables are too many. It is the user's responsibility to avoid JVM crashes by ensuring enough space for the returned values.

+ * + * @param pname the state variable + * @param params a scalar or buffer in which to place the returned data + * + * @see Reference Page + */ + public static void glGetBooleanv(@NativeType("GLenum") int pname, @NativeType("GLboolean *") ByteBuffer params) { + GL11C.glGetBooleanv(pname, params); + } + + /** + * Returns the current boolean value of the specified state variable. + * + *

LWJGL note: The state that corresponds to the state variable may be a single value or an array of values. In the case of an array of values, + * LWJGL will not validate if {@code params} has enough space to store that array. Doing so would introduce significant overhead, as the + * OpenGL state variables are too many. It is the user's responsibility to avoid JVM crashes by ensuring enough space for the returned values.

+ * + * @param pname the state variable + * + * @see Reference Page + */ + @NativeType("void") + public static boolean glGetBoolean(@NativeType("GLenum") int pname) { + return GL11C.glGetBoolean(pname); + } + + // --- [ glGetFloatv ] --- + + /** Unsafe version of: {@link #glGetFloatv GetFloatv} */ + public static void nglGetFloatv(int pname, long params) { + GL11C.nglGetFloatv(pname, params); + } + + /** + * Returns the current float value of the specified state variable. + * + *

LWJGL note: The state that corresponds to the state variable may be a single value or an array of values. In the case of an array of values, + * LWJGL will not validate if {@code params} has enough space to store that array. Doing so would introduce significant overhead, as the + * OpenGL state variables are too many. It is the user's responsibility to avoid JVM crashes by ensuring enough space for the returned values.

+ * + * @param pname the state variable + * @param params a scalar or buffer in which to place the returned data + * + * @see Reference Page + */ + public static void glGetFloatv(@NativeType("GLenum") int pname, @NativeType("GLfloat *") FloatBuffer params) { + GL11C.glGetFloatv(pname, params); + } + + /** + * Returns the current float value of the specified state variable. + * + *

LWJGL note: The state that corresponds to the state variable may be a single value or an array of values. In the case of an array of values, + * LWJGL will not validate if {@code params} has enough space to store that array. Doing so would introduce significant overhead, as the + * OpenGL state variables are too many. It is the user's responsibility to avoid JVM crashes by ensuring enough space for the returned values.

+ * + * @param pname the state variable + * + * @see Reference Page + */ + @NativeType("void") + public static float glGetFloat(@NativeType("GLenum") int pname) { + return GL11C.glGetFloat(pname); + } + + // --- [ glGetIntegerv ] --- + + /** Unsafe version of: {@link #glGetIntegerv GetIntegerv} */ + public static void nglGetIntegerv(int pname, long params) { + GL11C.nglGetIntegerv(pname, params); + } + + /** + * Returns the current integer value of the specified state variable. + * + *

LWJGL note: The state that corresponds to the state variable may be a single value or an array of values. In the case of an array of values, + * LWJGL will not validate if {@code params} has enough space to store that array. Doing so would introduce significant overhead, as the + * OpenGL state variables are too many. It is the user's responsibility to avoid JVM crashes by ensuring enough space for the returned values.

+ * + * @param pname the state variable + * @param params a scalar or buffer in which to place the returned data + * + * @see Reference Page + */ + public static void glGetIntegerv(@NativeType("GLenum") int pname, @NativeType("GLint *") IntBuffer params) { + GL11C.glGetIntegerv(pname, params); + } + + /** + * Returns the current integer value of the specified state variable. + * + *

LWJGL note: The state that corresponds to the state variable may be a single value or an array of values. In the case of an array of values, + * LWJGL will not validate if {@code params} has enough space to store that array. Doing so would introduce significant overhead, as the + * OpenGL state variables are too many. It is the user's responsibility to avoid JVM crashes by ensuring enough space for the returned values.

+ * + * @param pname the state variable + * + * @see Reference Page + */ + @NativeType("void") + public static int glGetInteger(@NativeType("GLenum") int pname) { + return GL11C.glGetInteger(pname); + } + + // --- [ glGetDoublev ] --- + + /** Unsafe version of: {@link #glGetDoublev GetDoublev} */ + public static void nglGetDoublev(int pname, long params) { + GL11C.nglGetDoublev(pname, params); + } + + /** + * Returns the current double value of the specified state variable. + * + *

LWJGL note: The state that corresponds to the state variable may be a single value or an array of values. In the case of an array of values, + * LWJGL will not validate if {@code params} has enough space to store that array. Doing so would introduce significant overhead, as the + * OpenGL state variables are too many. It is the user's responsibility to avoid JVM crashes by ensuring enough space for the returned values.

+ * + * @param pname the state variable + * @param params a scalar or buffer in which to place the returned data + * + * @see Reference Page + */ + public static void glGetDoublev(@NativeType("GLenum") int pname, @NativeType("GLdouble *") DoubleBuffer params) { + GL11C.glGetDoublev(pname, params); + } + + /** + * Returns the current double value of the specified state variable. + * + *

LWJGL note: The state that corresponds to the state variable may be a single value or an array of values. In the case of an array of values, + * LWJGL will not validate if {@code params} has enough space to store that array. Doing so would introduce significant overhead, as the + * OpenGL state variables are too many. It is the user's responsibility to avoid JVM crashes by ensuring enough space for the returned values.

+ * + * @param pname the state variable + * + * @see Reference Page + */ + @NativeType("void") + public static double glGetDouble(@NativeType("GLenum") int pname) { + return GL11C.glGetDouble(pname); + } + + // --- [ glGetError ] --- + + /** + * Returns error information. + * + *

Each detectable error is assigned a numeric code. When an error is detected, a flag is set and the code is recorded. Further errors, if they occur, do + * not affect this recorded code. When {@code 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 {@code GetError} returns {@link GL11C#GL_NO_ERROR NO_ERROR}, then there has been no detectable error since the last call to {@code GetError} (or since + * the GL was initialized).

+ * + * @see Reference Page + */ + @NativeType("GLenum") + public static int glGetError() { + return GL11C.glGetError(); + } + + // --- [ glGetLightiv ] --- + + /** Unsafe version of: {@link #glGetLightiv GetLightiv} */ + public static native void nglGetLightiv(int light, int pname, long data); + + /** + * Returns integer information about light parameter {@code pname} for {@code light} in {@code data}. + * + * @param light the light for which to return information. One of:
{@link #GL_LIGHT0 LIGHT0}GL_LIGHT[1-7]
+ * @param pname the light parameter to query. One of:
{@link #GL_AMBIENT AMBIENT}{@link #GL_DIFFUSE DIFFUSE}{@link #GL_SPECULAR SPECULAR}{@link #GL_POSITION POSITION}{@link #GL_CONSTANT_ATTENUATION CONSTANT_ATTENUATION}{@link #GL_LINEAR_ATTENUATION LINEAR_ATTENUATION}
{@link #GL_QUADRATIC_ATTENUATION QUADRATIC_ATTENUATION}{@link #GL_SPOT_DIRECTION SPOT_DIRECTION}{@link #GL_SPOT_EXPONENT SPOT_EXPONENT}{@link #GL_SPOT_CUTOFF SPOT_CUTOFF}
+ * @param data a scalar or buffer in which to place the returned data + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glGetLightiv(@NativeType("GLenum") int light, @NativeType("GLenum") int pname, @NativeType("GLint *") IntBuffer data) { + if (CHECKS) { + check(data, 4); + } + nglGetLightiv(light, pname, memAddress(data)); + } + + /** + * Returns integer information about light parameter {@code pname} for {@code light} in {@code data}. + * + * @param light the light for which to return information. One of:
{@link #GL_LIGHT0 LIGHT0}GL_LIGHT[1-7]
+ * @param pname the light parameter to query. One of:
{@link #GL_AMBIENT AMBIENT}{@link #GL_DIFFUSE DIFFUSE}{@link #GL_SPECULAR SPECULAR}{@link #GL_POSITION POSITION}{@link #GL_CONSTANT_ATTENUATION CONSTANT_ATTENUATION}{@link #GL_LINEAR_ATTENUATION LINEAR_ATTENUATION}
{@link #GL_QUADRATIC_ATTENUATION QUADRATIC_ATTENUATION}{@link #GL_SPOT_DIRECTION SPOT_DIRECTION}{@link #GL_SPOT_EXPONENT SPOT_EXPONENT}{@link #GL_SPOT_CUTOFF SPOT_CUTOFF}
+ * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + @NativeType("void") + public static int glGetLighti(@NativeType("GLenum") int light, @NativeType("GLenum") int pname) { + MemoryStack stack = stackGet(); int stackPointer = stack.getPointer(); + try { + IntBuffer data = stack.callocInt(1); + nglGetLightiv(light, pname, memAddress(data)); + return data.get(0); + } finally { + stack.setPointer(stackPointer); + } + } + + // --- [ glGetLightfv ] --- + + /** Unsafe version of: {@link #glGetLightfv GetLightfv} */ + public static native void nglGetLightfv(int light, int pname, long data); + + /** + * Float version of {@link #glGetLightiv GetLightiv}. + * + * @param light the light for which to return information + * @param pname the light parameter to query + * @param data a scalar or buffer in which to place the returned data + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glGetLightfv(@NativeType("GLenum") int light, @NativeType("GLenum") int pname, @NativeType("GLfloat *") FloatBuffer data) { + if (CHECKS) { + check(data, 4); + } + nglGetLightfv(light, pname, memAddress(data)); + } + + /** + * Float version of {@link #glGetLightiv GetLightiv}. + * + * @param light the light for which to return information + * @param pname the light parameter to query + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + @NativeType("void") + public static float glGetLightf(@NativeType("GLenum") int light, @NativeType("GLenum") int pname) { + MemoryStack stack = stackGet(); int stackPointer = stack.getPointer(); + try { + FloatBuffer data = stack.callocFloat(1); + nglGetLightfv(light, pname, memAddress(data)); + return data.get(0); + } finally { + stack.setPointer(stackPointer); + } + } + + // --- [ glGetMapiv ] --- + + /** Unsafe version of: {@link #glGetMapiv GetMapiv} */ + public static native void nglGetMapiv(int target, int query, long data); + + /** + * Returns integer information about {@code query} for evaluator map {@code target} in {@code data}. + * + * @param target the evaluator target. One of:
{@link #GL_MAP1_VERTEX_3 MAP1_VERTEX_3}{@link #GL_MAP1_VERTEX_4 MAP1_VERTEX_4}{@link #GL_MAP1_COLOR_4 MAP1_COLOR_4}{@link #GL_MAP1_NORMAL MAP1_NORMAL}{@link #GL_MAP1_TEXTURE_COORD_1 MAP1_TEXTURE_COORD_1}
{@link #GL_MAP1_TEXTURE_COORD_2 MAP1_TEXTURE_COORD_2}{@link #GL_MAP1_TEXTURE_COORD_3 MAP1_TEXTURE_COORD_3}{@link #GL_MAP1_TEXTURE_COORD_4 MAP1_TEXTURE_COORD_4}{@link #GL_MAP2_VERTEX_3 MAP2_VERTEX_3}{@link #GL_MAP2_VERTEX_4 MAP2_VERTEX_4}
{@link #GL_MAP2_COLOR_4 MAP2_COLOR_4}{@link #GL_MAP2_NORMAL MAP2_NORMAL}{@link #GL_MAP2_TEXTURE_COORD_1 MAP2_TEXTURE_COORD_1}{@link #GL_MAP2_TEXTURE_COORD_2 MAP2_TEXTURE_COORD_2}{@link #GL_MAP2_TEXTURE_COORD_3 MAP2_TEXTURE_COORD_3}
{@link #GL_MAP2_TEXTURE_COORD_4 MAP2_TEXTURE_COORD_4}
+ * @param query the information to query. One of:
{@link #GL_ORDER ORDER}{@link #GL_COEFF COEFF}{@link #GL_DOMAIN DOMAIN}
+ * @param data a scalar or buffer in which to place the returned data + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glGetMapiv(@NativeType("GLenum") int target, @NativeType("GLenum") int query, @NativeType("GLint *") IntBuffer data) { + if (CHECKS) { + check(data, 4); + } + nglGetMapiv(target, query, memAddress(data)); + } + + /** + * Returns integer information about {@code query} for evaluator map {@code target} in {@code data}. + * + * @param target the evaluator target. One of:
{@link #GL_MAP1_VERTEX_3 MAP1_VERTEX_3}{@link #GL_MAP1_VERTEX_4 MAP1_VERTEX_4}{@link #GL_MAP1_COLOR_4 MAP1_COLOR_4}{@link #GL_MAP1_NORMAL MAP1_NORMAL}{@link #GL_MAP1_TEXTURE_COORD_1 MAP1_TEXTURE_COORD_1}
{@link #GL_MAP1_TEXTURE_COORD_2 MAP1_TEXTURE_COORD_2}{@link #GL_MAP1_TEXTURE_COORD_3 MAP1_TEXTURE_COORD_3}{@link #GL_MAP1_TEXTURE_COORD_4 MAP1_TEXTURE_COORD_4}{@link #GL_MAP2_VERTEX_3 MAP2_VERTEX_3}{@link #GL_MAP2_VERTEX_4 MAP2_VERTEX_4}
{@link #GL_MAP2_COLOR_4 MAP2_COLOR_4}{@link #GL_MAP2_NORMAL MAP2_NORMAL}{@link #GL_MAP2_TEXTURE_COORD_1 MAP2_TEXTURE_COORD_1}{@link #GL_MAP2_TEXTURE_COORD_2 MAP2_TEXTURE_COORD_2}{@link #GL_MAP2_TEXTURE_COORD_3 MAP2_TEXTURE_COORD_3}
{@link #GL_MAP2_TEXTURE_COORD_4 MAP2_TEXTURE_COORD_4}
+ * @param query the information to query. One of:
{@link #GL_ORDER ORDER}{@link #GL_COEFF COEFF}{@link #GL_DOMAIN DOMAIN}
+ * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + @NativeType("void") + public static int glGetMapi(@NativeType("GLenum") int target, @NativeType("GLenum") int query) { + MemoryStack stack = stackGet(); int stackPointer = stack.getPointer(); + try { + IntBuffer data = stack.callocInt(1); + nglGetMapiv(target, query, memAddress(data)); + return data.get(0); + } finally { + stack.setPointer(stackPointer); + } + } + + // --- [ glGetMapfv ] --- + + /** Unsafe version of: {@link #glGetMapfv GetMapfv} */ + public static native void nglGetMapfv(int target, int query, long data); + + /** + * Float version of {@link #glGetMapiv GetMapiv}. + * + * @param target the evaluator map + * @param query the information to query + * @param data a scalar or buffer in which to place the returned data + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glGetMapfv(@NativeType("GLenum") int target, @NativeType("GLenum") int query, @NativeType("GLfloat *") FloatBuffer data) { + if (CHECKS) { + check(data, 4); + } + nglGetMapfv(target, query, memAddress(data)); + } + + /** + * Float version of {@link #glGetMapiv GetMapiv}. + * + * @param target the evaluator map + * @param query the information to query + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + @NativeType("void") + public static float glGetMapf(@NativeType("GLenum") int target, @NativeType("GLenum") int query) { + MemoryStack stack = stackGet(); int stackPointer = stack.getPointer(); + try { + FloatBuffer data = stack.callocFloat(1); + nglGetMapfv(target, query, memAddress(data)); + return data.get(0); + } finally { + stack.setPointer(stackPointer); + } + } + + // --- [ glGetMapdv ] --- + + /** Unsafe version of: {@link #glGetMapdv GetMapdv} */ + public static native void nglGetMapdv(int target, int query, long data); + + /** + * Double version of {@link #glGetMapiv GetMapiv}. + * + * @param target the evaluator map + * @param query the information to query + * @param data a scalar or buffer in which to place the returned data + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glGetMapdv(@NativeType("GLenum") int target, @NativeType("GLenum") int query, @NativeType("GLdouble *") DoubleBuffer data) { + if (CHECKS) { + check(data, 4); + } + nglGetMapdv(target, query, memAddress(data)); + } + + /** + * Double version of {@link #glGetMapiv GetMapiv}. + * + * @param target the evaluator map + * @param query the information to query + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + @NativeType("void") + public static double glGetMapd(@NativeType("GLenum") int target, @NativeType("GLenum") int query) { + MemoryStack stack = stackGet(); int stackPointer = stack.getPointer(); + try { + DoubleBuffer data = stack.callocDouble(1); + nglGetMapdv(target, query, memAddress(data)); + return data.get(0); + } finally { + stack.setPointer(stackPointer); + } + } + + // --- [ glGetMaterialiv ] --- + + /** Unsafe version of: {@link #glGetMaterialiv GetMaterialiv} */ + public static native void nglGetMaterialiv(int face, int pname, long data); + + /** + * Returns integer information about material property {@code pname} for {@code face} in {@code data}. + * + * @param face the material face for which to return information. One of:
{@link #GL_FRONT FRONT}{@link #GL_BACK BACK}
+ * @param pname the information to query. One of:
{@link #GL_AMBIENT AMBIENT}{@link #GL_DIFFUSE DIFFUSE}{@link #GL_SPECULAR SPECULAR}{@link #GL_EMISSION EMISSION}{@link #GL_SHININESS SHININESS}
+ * @param data a scalar or buffer in which to place the returned data + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glGetMaterialiv(@NativeType("GLenum") int face, @NativeType("GLenum") int pname, @NativeType("GLint *") IntBuffer data) { + if (CHECKS) { + check(data, 1); + } + nglGetMaterialiv(face, pname, memAddress(data)); + } + + // --- [ glGetMaterialfv ] --- + + /** Unsafe version of: {@link #glGetMaterialfv GetMaterialfv} */ + public static native void nglGetMaterialfv(int face, int pname, long data); + + /** + * Float version of {@link #glGetMaterialiv GetMaterialiv}. + * + * @param face the material face for which to return information + * @param pname the information to query + * @param data a scalar or buffer in which to place the returned data + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glGetMaterialfv(@NativeType("GLenum") int face, @NativeType("GLenum") int pname, @NativeType("GLfloat *") FloatBuffer data) { + if (CHECKS) { + check(data, 1); + } + nglGetMaterialfv(face, pname, memAddress(data)); + } + + // --- [ glGetPixelMapfv ] --- + + /** Unsafe version of: {@link #glGetPixelMapfv GetPixelMapfv} */ + public static native void nglGetPixelMapfv(int map, long data); + + /** + * Returns all float values in the pixel map {@code map} in {@code data}. + * + * @param map the pixel map parameter to query. One of:
{@link #GL_PIXEL_MAP_I_TO_I PIXEL_MAP_I_TO_I}{@link #GL_PIXEL_MAP_S_TO_S PIXEL_MAP_S_TO_S}{@link #GL_PIXEL_MAP_I_TO_R PIXEL_MAP_I_TO_R}{@link #GL_PIXEL_MAP_I_TO_G PIXEL_MAP_I_TO_G}{@link #GL_PIXEL_MAP_I_TO_B PIXEL_MAP_I_TO_B}
{@link #GL_PIXEL_MAP_I_TO_A PIXEL_MAP_I_TO_A}{@link #GL_PIXEL_MAP_R_TO_R PIXEL_MAP_R_TO_R}{@link #GL_PIXEL_MAP_G_TO_G PIXEL_MAP_G_TO_G}{@link #GL_PIXEL_MAP_B_TO_B PIXEL_MAP_B_TO_B}{@link #GL_PIXEL_MAP_A_TO_A PIXEL_MAP_A_TO_A}
+ * @param data a buffer in which to place the returned data + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glGetPixelMapfv(@NativeType("GLenum") int map, @NativeType("GLfloat *") FloatBuffer data) { + if (CHECKS) { + check(data, 32); + } + nglGetPixelMapfv(map, memAddress(data)); + } + + /** + * Returns all float values in the pixel map {@code map} in {@code data}. + * + * @param map the pixel map parameter to query. One of:
{@link #GL_PIXEL_MAP_I_TO_I PIXEL_MAP_I_TO_I}{@link #GL_PIXEL_MAP_S_TO_S PIXEL_MAP_S_TO_S}{@link #GL_PIXEL_MAP_I_TO_R PIXEL_MAP_I_TO_R}{@link #GL_PIXEL_MAP_I_TO_G PIXEL_MAP_I_TO_G}{@link #GL_PIXEL_MAP_I_TO_B PIXEL_MAP_I_TO_B}
{@link #GL_PIXEL_MAP_I_TO_A PIXEL_MAP_I_TO_A}{@link #GL_PIXEL_MAP_R_TO_R PIXEL_MAP_R_TO_R}{@link #GL_PIXEL_MAP_G_TO_G PIXEL_MAP_G_TO_G}{@link #GL_PIXEL_MAP_B_TO_B PIXEL_MAP_B_TO_B}{@link #GL_PIXEL_MAP_A_TO_A PIXEL_MAP_A_TO_A}
+ * @param data a buffer in which to place the returned data + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glGetPixelMapfv(@NativeType("GLenum") int map, @NativeType("GLfloat *") long data) { + nglGetPixelMapfv(map, data); + } + + // --- [ glGetPixelMapusv ] --- + + /** Unsafe version of: {@link #glGetPixelMapusv GetPixelMapusv} */ + public static native void nglGetPixelMapusv(int map, long data); + + /** + * Unsigned short version of {@link #glGetPixelMapfv GetPixelMapfv}. + * + * @param map the pixel map parameter to query + * @param data a buffer in which to place the returned data + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glGetPixelMapusv(@NativeType("GLenum") int map, @NativeType("GLushort *") ShortBuffer data) { + if (CHECKS) { + check(data, 32); + } + nglGetPixelMapusv(map, memAddress(data)); + } + + /** + * Unsigned short version of {@link #glGetPixelMapfv GetPixelMapfv}. + * + * @param map the pixel map parameter to query + * @param data a buffer in which to place the returned data + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glGetPixelMapusv(@NativeType("GLenum") int map, @NativeType("GLushort *") long data) { + nglGetPixelMapusv(map, data); + } + + // --- [ glGetPixelMapuiv ] --- + + /** Unsafe version of: {@link #glGetPixelMapuiv GetPixelMapuiv} */ + public static native void nglGetPixelMapuiv(int map, long data); + + /** + * Unsigned integer version of {@link #glGetPixelMapfv GetPixelMapfv}. + * + * @param map the pixel map parameter to query + * @param data a buffer in which to place the returned data + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glGetPixelMapuiv(@NativeType("GLenum") int map, @NativeType("GLuint *") IntBuffer data) { + if (CHECKS) { + check(data, 32); + } + nglGetPixelMapuiv(map, memAddress(data)); + } + + /** + * Unsigned integer version of {@link #glGetPixelMapfv GetPixelMapfv}. + * + * @param map the pixel map parameter to query + * @param data a buffer in which to place the returned data + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glGetPixelMapuiv(@NativeType("GLenum") int map, @NativeType("GLuint *") long data) { + nglGetPixelMapuiv(map, data); + } + + // --- [ glGetPointerv ] --- + + /** Unsafe version of: {@link #glGetPointerv GetPointerv} */ + public static void nglGetPointerv(int pname, long params) { + GL11C.nglGetPointerv(pname, params); + } + + /** + * Returns a pointer in the current GL context. + * + * @param pname the pointer to return. One of:
{@link GL43#GL_DEBUG_CALLBACK_FUNCTION DEBUG_CALLBACK_FUNCTION}{@link GL43#GL_DEBUG_CALLBACK_USER_PARAM DEBUG_CALLBACK_USER_PARAM}
+ * @param params a buffer in which to place the returned pointer + * + * @see Reference Page + */ + public static void glGetPointerv(@NativeType("GLenum") int pname, @NativeType("void **") PointerBuffer params) { + GL11C.glGetPointerv(pname, params); + } + + /** + * Returns a pointer in the current GL context. + * + * @param pname the pointer to return. One of:
{@link GL43#GL_DEBUG_CALLBACK_FUNCTION DEBUG_CALLBACK_FUNCTION}{@link GL43#GL_DEBUG_CALLBACK_USER_PARAM DEBUG_CALLBACK_USER_PARAM}
+ * + * @see Reference Page + */ + @NativeType("void") + public static long glGetPointer(@NativeType("GLenum") int pname) { + return GL11C.glGetPointer(pname); + } + + // --- [ glGetPolygonStipple ] --- + + /** Unsafe version of: {@link #glGetPolygonStipple GetPolygonStipple} */ + public static native void nglGetPolygonStipple(long pattern); + + /** + * Obtains the polygon stipple. + * + * @param pattern a buffer in which to place the returned data + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glGetPolygonStipple(@NativeType("void *") ByteBuffer pattern) { + if (CHECKS) { + check(pattern, 128); + } + nglGetPolygonStipple(memAddress(pattern)); + } + + /** + * Obtains the polygon stipple. + * + * @param pattern a buffer in which to place the returned data + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glGetPolygonStipple(@NativeType("void *") long pattern) { + nglGetPolygonStipple(pattern); + } + + // --- [ glGetString ] --- + + /** Unsafe version of: {@link #glGetString GetString} */ + public static long nglGetString(int name) { + return GL11C.nglGetString(name); + } + + /** + * Return strings describing properties of the current GL context. + * + * @param name the property to query. One of:
{@link GL11C#GL_RENDERER RENDERER}{@link GL11C#GL_VENDOR VENDOR}{@link GL11C#GL_EXTENSIONS EXTENSIONS}{@link GL11C#GL_VERSION VERSION}{@link GL20#GL_SHADING_LANGUAGE_VERSION SHADING_LANGUAGE_VERSION}
+ * + * @see Reference Page + */ + @Nullable + @NativeType("GLubyte const *") + public static String glGetString(@NativeType("GLenum") int name) { + return GL11C.glGetString(name); + } + + // --- [ glGetTexEnviv ] --- + + /** Unsafe version of: {@link #glGetTexEnviv GetTexEnviv} */ + public static native void nglGetTexEnviv(int env, int pname, long data); + + /** + * Returns integer information about {@code pname} for {@code env} in {@code data}. + * + * @param env the texture environment to query. One of:
{@link GL20#GL_POINT_SPRITE POINT_SPRITE}{@link #GL_TEXTURE_ENV TEXTURE_ENV}{@link GL14#GL_TEXTURE_FILTER_CONTROL TEXTURE_FILTER_CONTROL}
+ * @param pname the parameter to query. One of:
{@link GL20#GL_COORD_REPLACE COORD_REPLACE}{@link #GL_TEXTURE_ENV_MODE TEXTURE_ENV_MODE}{@link #GL_TEXTURE_ENV_COLOR TEXTURE_ENV_COLOR}{@link GL14#GL_TEXTURE_LOD_BIAS TEXTURE_LOD_BIAS}{@link GL13#GL_COMBINE_RGB COMBINE_RGB}{@link GL13#GL_COMBINE_ALPHA COMBINE_ALPHA}
{@link GL15#GL_SRC0_RGB SRC0_RGB}{@link GL15#GL_SRC1_RGB SRC1_RGB}{@link GL15#GL_SRC2_RGB SRC2_RGB}{@link GL15#GL_SRC0_ALPHA SRC0_ALPHA}{@link GL15#GL_SRC1_ALPHA SRC1_ALPHA}{@link GL15#GL_SRC2_ALPHA SRC2_ALPHA}
{@link GL13#GL_OPERAND0_RGB OPERAND0_RGB}{@link GL13#GL_OPERAND1_RGB OPERAND1_RGB}{@link GL13#GL_OPERAND2_RGB OPERAND2_RGB}{@link GL13#GL_OPERAND0_ALPHA OPERAND0_ALPHA}{@link GL13#GL_OPERAND1_ALPHA OPERAND1_ALPHA}{@link GL13#GL_OPERAND2_ALPHA OPERAND2_ALPHA}
{@link GL13#GL_RGB_SCALE RGB_SCALE}{@link #GL_ALPHA_SCALE ALPHA_SCALE}
+ * @param data a scalar or buffer in which to place the returned data + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glGetTexEnviv(@NativeType("GLenum") int env, @NativeType("GLenum") int pname, @NativeType("GLint *") IntBuffer data) { + if (CHECKS) { + check(data, 1); + } + nglGetTexEnviv(env, pname, memAddress(data)); + } + + /** + * Returns integer information about {@code pname} for {@code env} in {@code data}. + * + * @param env the texture environment to query. One of:
{@link GL20#GL_POINT_SPRITE POINT_SPRITE}{@link #GL_TEXTURE_ENV TEXTURE_ENV}{@link GL14#GL_TEXTURE_FILTER_CONTROL TEXTURE_FILTER_CONTROL}
+ * @param pname the parameter to query. One of:
{@link GL20#GL_COORD_REPLACE COORD_REPLACE}{@link #GL_TEXTURE_ENV_MODE TEXTURE_ENV_MODE}{@link #GL_TEXTURE_ENV_COLOR TEXTURE_ENV_COLOR}{@link GL14#GL_TEXTURE_LOD_BIAS TEXTURE_LOD_BIAS}{@link GL13#GL_COMBINE_RGB COMBINE_RGB}{@link GL13#GL_COMBINE_ALPHA COMBINE_ALPHA}
{@link GL15#GL_SRC0_RGB SRC0_RGB}{@link GL15#GL_SRC1_RGB SRC1_RGB}{@link GL15#GL_SRC2_RGB SRC2_RGB}{@link GL15#GL_SRC0_ALPHA SRC0_ALPHA}{@link GL15#GL_SRC1_ALPHA SRC1_ALPHA}{@link GL15#GL_SRC2_ALPHA SRC2_ALPHA}
{@link GL13#GL_OPERAND0_RGB OPERAND0_RGB}{@link GL13#GL_OPERAND1_RGB OPERAND1_RGB}{@link GL13#GL_OPERAND2_RGB OPERAND2_RGB}{@link GL13#GL_OPERAND0_ALPHA OPERAND0_ALPHA}{@link GL13#GL_OPERAND1_ALPHA OPERAND1_ALPHA}{@link GL13#GL_OPERAND2_ALPHA OPERAND2_ALPHA}
{@link GL13#GL_RGB_SCALE RGB_SCALE}{@link #GL_ALPHA_SCALE ALPHA_SCALE}
+ * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + @NativeType("void") + public static int glGetTexEnvi(@NativeType("GLenum") int env, @NativeType("GLenum") int pname) { + MemoryStack stack = stackGet(); int stackPointer = stack.getPointer(); + try { + IntBuffer data = stack.callocInt(1); + nglGetTexEnviv(env, pname, memAddress(data)); + return data.get(0); + } finally { + stack.setPointer(stackPointer); + } + } + + // --- [ glGetTexEnvfv ] --- + + /** Unsafe version of: {@link #glGetTexEnvfv GetTexEnvfv} */ + public static native void nglGetTexEnvfv(int env, int pname, long data); + + /** + * Float version of {@link #glGetTexEnviv GetTexEnviv}. + * + * @param env the texture environment to query + * @param pname the parameter to query + * @param data a scalar or buffer in which to place the returned data + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glGetTexEnvfv(@NativeType("GLenum") int env, @NativeType("GLenum") int pname, @NativeType("GLfloat *") FloatBuffer data) { + if (CHECKS) { + check(data, 1); + } + nglGetTexEnvfv(env, pname, memAddress(data)); + } + + /** + * Float version of {@link #glGetTexEnviv GetTexEnviv}. + * + * @param env the texture environment to query + * @param pname the parameter to query + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + @NativeType("void") + public static float glGetTexEnvf(@NativeType("GLenum") int env, @NativeType("GLenum") int pname) { + MemoryStack stack = stackGet(); int stackPointer = stack.getPointer(); + try { + FloatBuffer data = stack.callocFloat(1); + nglGetTexEnvfv(env, pname, memAddress(data)); + return data.get(0); + } finally { + stack.setPointer(stackPointer); + } + } + + // --- [ glGetTexGeniv ] --- + + /** Unsafe version of: {@link #glGetTexGeniv GetTexGeniv} */ + public static native void nglGetTexGeniv(int coord, int pname, long data); + + /** + * Returns integer information about {@code pname} for {@code coord} in {@code data}. + * + * @param coord the coord to query. One of:
{@link #GL_S S}{@link #GL_T T}{@link #GL_R R}{@link #GL_Q Q}
+ * @param pname the parameter to query. One of:
{@link #GL_EYE_PLANE EYE_PLANE}{@link #GL_OBJECT_PLANE OBJECT_PLANE}{@link #GL_TEXTURE_GEN_MODE TEXTURE_GEN_MODE}
+ * @param data a scalar or buffer in which to place the returned data + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glGetTexGeniv(@NativeType("GLenum") int coord, @NativeType("GLenum") int pname, @NativeType("GLint *") IntBuffer data) { + if (CHECKS) { + check(data, 1); + } + nglGetTexGeniv(coord, pname, memAddress(data)); + } + + /** + * Returns integer information about {@code pname} for {@code coord} in {@code data}. + * + * @param coord the coord to query. One of:
{@link #GL_S S}{@link #GL_T T}{@link #GL_R R}{@link #GL_Q Q}
+ * @param pname the parameter to query. One of:
{@link #GL_EYE_PLANE EYE_PLANE}{@link #GL_OBJECT_PLANE OBJECT_PLANE}{@link #GL_TEXTURE_GEN_MODE TEXTURE_GEN_MODE}
+ * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + @NativeType("void") + public static int glGetTexGeni(@NativeType("GLenum") int coord, @NativeType("GLenum") int pname) { + MemoryStack stack = stackGet(); int stackPointer = stack.getPointer(); + try { + IntBuffer data = stack.callocInt(1); + nglGetTexGeniv(coord, pname, memAddress(data)); + return data.get(0); + } finally { + stack.setPointer(stackPointer); + } + } + + // --- [ glGetTexGenfv ] --- + + /** Unsafe version of: {@link #glGetTexGenfv GetTexGenfv} */ + public static native void nglGetTexGenfv(int coord, int pname, long data); + + /** + * Float version of {@link #glGetTexGeniv GetTexGeniv}. + * + * @param coord the coord to query + * @param pname the parameter to query + * @param data a scalar or buffer in which to place the returned data + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glGetTexGenfv(@NativeType("GLenum") int coord, @NativeType("GLenum") int pname, @NativeType("GLfloat *") FloatBuffer data) { + if (CHECKS) { + check(data, 4); + } + nglGetTexGenfv(coord, pname, memAddress(data)); + } + + /** + * Float version of {@link #glGetTexGeniv GetTexGeniv}. + * + * @param coord the coord to query + * @param pname the parameter to query + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + @NativeType("void") + public static float glGetTexGenf(@NativeType("GLenum") int coord, @NativeType("GLenum") int pname) { + MemoryStack stack = stackGet(); int stackPointer = stack.getPointer(); + try { + FloatBuffer data = stack.callocFloat(1); + nglGetTexGenfv(coord, pname, memAddress(data)); + return data.get(0); + } finally { + stack.setPointer(stackPointer); + } + } + + // --- [ glGetTexGendv ] --- + + /** Unsafe version of: {@link #glGetTexGendv GetTexGendv} */ + public static native void nglGetTexGendv(int coord, int pname, long data); + + /** + * Double version of {@link #glGetTexGeniv GetTexGeniv}. + * + * @param coord the coord to query + * @param pname the parameter to query + * @param data a scalar or buffer in which to place the returned data + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glGetTexGendv(@NativeType("GLenum") int coord, @NativeType("GLenum") int pname, @NativeType("GLdouble *") DoubleBuffer data) { + if (CHECKS) { + check(data, 4); + } + nglGetTexGendv(coord, pname, memAddress(data)); + } + + /** + * Double version of {@link #glGetTexGeniv GetTexGeniv}. + * + * @param coord the coord to query + * @param pname the parameter to query + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + @NativeType("void") + public static double glGetTexGend(@NativeType("GLenum") int coord, @NativeType("GLenum") int pname) { + MemoryStack stack = stackGet(); int stackPointer = stack.getPointer(); + try { + DoubleBuffer data = stack.callocDouble(1); + nglGetTexGendv(coord, pname, memAddress(data)); + return data.get(0); + } finally { + stack.setPointer(stackPointer); + } + } + + // --- [ glGetTexImage ] --- + + /** Unsafe version of: {@link #glGetTexImage GetTexImage} */ + public static void nglGetTexImage(int tex, int level, int format, int type, long pixels) { + GL11C.nglGetTexImage(tex, level, format, type, pixels); + } + + /** + * Obtains texture images. + * + * @param tex the texture (or texture face) to be obtained. One of:
{@link GL11C#GL_TEXTURE_1D TEXTURE_1D}{@link GL11C#GL_TEXTURE_2D TEXTURE_2D}{@link GL12#GL_TEXTURE_3D TEXTURE_3D}{@link GL30#GL_TEXTURE_1D_ARRAY TEXTURE_1D_ARRAY}
{@link GL30#GL_TEXTURE_2D_ARRAY TEXTURE_2D_ARRAY}{@link GL31#GL_TEXTURE_RECTANGLE TEXTURE_RECTANGLE}{@link GL13#GL_TEXTURE_CUBE_MAP_POSITIVE_X TEXTURE_CUBE_MAP_POSITIVE_X}{@link GL13#GL_TEXTURE_CUBE_MAP_NEGATIVE_X TEXTURE_CUBE_MAP_NEGATIVE_X}
{@link GL13#GL_TEXTURE_CUBE_MAP_POSITIVE_Y TEXTURE_CUBE_MAP_POSITIVE_Y}{@link GL13#GL_TEXTURE_CUBE_MAP_NEGATIVE_Y TEXTURE_CUBE_MAP_NEGATIVE_Y}{@link GL13#GL_TEXTURE_CUBE_MAP_POSITIVE_Z TEXTURE_CUBE_MAP_POSITIVE_Z}{@link GL13#GL_TEXTURE_CUBE_MAP_NEGATIVE_Z TEXTURE_CUBE_MAP_NEGATIVE_Z}
+ * @param level the level-of-detail number + * @param format the pixel format. One of:
{@link GL11C#GL_RED RED}{@link GL11C#GL_GREEN GREEN}{@link GL11C#GL_BLUE BLUE}{@link GL11C#GL_ALPHA ALPHA}{@link GL30#GL_RG RG}{@link GL11C#GL_RGB RGB}{@link GL11C#GL_RGBA RGBA}{@link GL12#GL_BGR BGR}
{@link GL12#GL_BGRA BGRA}{@link GL30#GL_RED_INTEGER RED_INTEGER}{@link GL30#GL_GREEN_INTEGER GREEN_INTEGER}{@link GL30#GL_BLUE_INTEGER BLUE_INTEGER}{@link GL30#GL_ALPHA_INTEGER ALPHA_INTEGER}{@link GL30#GL_RG_INTEGER RG_INTEGER}{@link GL30#GL_RGB_INTEGER RGB_INTEGER}{@link GL30#GL_RGBA_INTEGER RGBA_INTEGER}
{@link GL30#GL_BGR_INTEGER BGR_INTEGER}{@link GL30#GL_BGRA_INTEGER BGRA_INTEGER}{@link GL11C#GL_STENCIL_INDEX STENCIL_INDEX}{@link GL11C#GL_DEPTH_COMPONENT DEPTH_COMPONENT}{@link GL30#GL_DEPTH_STENCIL DEPTH_STENCIL}
+ * @param type the pixel type. One of:
{@link GL11C#GL_UNSIGNED_BYTE UNSIGNED_BYTE}{@link GL11C#GL_BYTE BYTE}{@link GL11C#GL_UNSIGNED_SHORT UNSIGNED_SHORT}{@link GL11C#GL_SHORT SHORT}
{@link GL11C#GL_UNSIGNED_INT UNSIGNED_INT}{@link GL11C#GL_INT INT}{@link GL30#GL_HALF_FLOAT HALF_FLOAT}{@link GL11C#GL_FLOAT FLOAT}
{@link GL12#GL_UNSIGNED_BYTE_3_3_2 UNSIGNED_BYTE_3_3_2}{@link GL12#GL_UNSIGNED_BYTE_2_3_3_REV UNSIGNED_BYTE_2_3_3_REV}{@link GL12#GL_UNSIGNED_SHORT_5_6_5 UNSIGNED_SHORT_5_6_5}{@link GL12#GL_UNSIGNED_SHORT_5_6_5_REV UNSIGNED_SHORT_5_6_5_REV}
{@link GL12#GL_UNSIGNED_SHORT_4_4_4_4 UNSIGNED_SHORT_4_4_4_4}{@link GL12#GL_UNSIGNED_SHORT_4_4_4_4_REV UNSIGNED_SHORT_4_4_4_4_REV}{@link GL12#GL_UNSIGNED_SHORT_5_5_5_1 UNSIGNED_SHORT_5_5_5_1}{@link GL12#GL_UNSIGNED_SHORT_1_5_5_5_REV UNSIGNED_SHORT_1_5_5_5_REV}
{@link GL12#GL_UNSIGNED_INT_8_8_8_8 UNSIGNED_INT_8_8_8_8}{@link GL12#GL_UNSIGNED_INT_8_8_8_8_REV UNSIGNED_INT_8_8_8_8_REV}{@link GL12#GL_UNSIGNED_INT_10_10_10_2 UNSIGNED_INT_10_10_10_2}{@link GL12#GL_UNSIGNED_INT_2_10_10_10_REV UNSIGNED_INT_2_10_10_10_REV}
{@link GL30#GL_UNSIGNED_INT_24_8 UNSIGNED_INT_24_8}{@link GL30#GL_UNSIGNED_INT_10F_11F_11F_REV UNSIGNED_INT_10F_11F_11F_REV}{@link GL30#GL_UNSIGNED_INT_5_9_9_9_REV UNSIGNED_INT_5_9_9_9_REV}{@link GL30#GL_FLOAT_32_UNSIGNED_INT_24_8_REV FLOAT_32_UNSIGNED_INT_24_8_REV}
+ * @param pixels the buffer in which to place the returned data + * + * @see Reference Page + */ + public static void glGetTexImage(@NativeType("GLenum") int tex, @NativeType("GLint") int level, @NativeType("GLenum") int format, @NativeType("GLenum") int type, @NativeType("void *") ByteBuffer pixels) { + GL11C.glGetTexImage(tex, level, format, type, pixels); + } + + /** + * Obtains texture images. + * + * @param tex the texture (or texture face) to be obtained. One of:
{@link GL11C#GL_TEXTURE_1D TEXTURE_1D}{@link GL11C#GL_TEXTURE_2D TEXTURE_2D}{@link GL12#GL_TEXTURE_3D TEXTURE_3D}{@link GL30#GL_TEXTURE_1D_ARRAY TEXTURE_1D_ARRAY}
{@link GL30#GL_TEXTURE_2D_ARRAY TEXTURE_2D_ARRAY}{@link GL31#GL_TEXTURE_RECTANGLE TEXTURE_RECTANGLE}{@link GL13#GL_TEXTURE_CUBE_MAP_POSITIVE_X TEXTURE_CUBE_MAP_POSITIVE_X}{@link GL13#GL_TEXTURE_CUBE_MAP_NEGATIVE_X TEXTURE_CUBE_MAP_NEGATIVE_X}
{@link GL13#GL_TEXTURE_CUBE_MAP_POSITIVE_Y TEXTURE_CUBE_MAP_POSITIVE_Y}{@link GL13#GL_TEXTURE_CUBE_MAP_NEGATIVE_Y TEXTURE_CUBE_MAP_NEGATIVE_Y}{@link GL13#GL_TEXTURE_CUBE_MAP_POSITIVE_Z TEXTURE_CUBE_MAP_POSITIVE_Z}{@link GL13#GL_TEXTURE_CUBE_MAP_NEGATIVE_Z TEXTURE_CUBE_MAP_NEGATIVE_Z}
+ * @param level the level-of-detail number + * @param format the pixel format. One of:
{@link GL11C#GL_RED RED}{@link GL11C#GL_GREEN GREEN}{@link GL11C#GL_BLUE BLUE}{@link GL11C#GL_ALPHA ALPHA}{@link GL30#GL_RG RG}{@link GL11C#GL_RGB RGB}{@link GL11C#GL_RGBA RGBA}{@link GL12#GL_BGR BGR}
{@link GL12#GL_BGRA BGRA}{@link GL30#GL_RED_INTEGER RED_INTEGER}{@link GL30#GL_GREEN_INTEGER GREEN_INTEGER}{@link GL30#GL_BLUE_INTEGER BLUE_INTEGER}{@link GL30#GL_ALPHA_INTEGER ALPHA_INTEGER}{@link GL30#GL_RG_INTEGER RG_INTEGER}{@link GL30#GL_RGB_INTEGER RGB_INTEGER}{@link GL30#GL_RGBA_INTEGER RGBA_INTEGER}
{@link GL30#GL_BGR_INTEGER BGR_INTEGER}{@link GL30#GL_BGRA_INTEGER BGRA_INTEGER}{@link GL11C#GL_STENCIL_INDEX STENCIL_INDEX}{@link GL11C#GL_DEPTH_COMPONENT DEPTH_COMPONENT}{@link GL30#GL_DEPTH_STENCIL DEPTH_STENCIL}
+ * @param type the pixel type. One of:
{@link GL11C#GL_UNSIGNED_BYTE UNSIGNED_BYTE}{@link GL11C#GL_BYTE BYTE}{@link GL11C#GL_UNSIGNED_SHORT UNSIGNED_SHORT}{@link GL11C#GL_SHORT SHORT}
{@link GL11C#GL_UNSIGNED_INT UNSIGNED_INT}{@link GL11C#GL_INT INT}{@link GL30#GL_HALF_FLOAT HALF_FLOAT}{@link GL11C#GL_FLOAT FLOAT}
{@link GL12#GL_UNSIGNED_BYTE_3_3_2 UNSIGNED_BYTE_3_3_2}{@link GL12#GL_UNSIGNED_BYTE_2_3_3_REV UNSIGNED_BYTE_2_3_3_REV}{@link GL12#GL_UNSIGNED_SHORT_5_6_5 UNSIGNED_SHORT_5_6_5}{@link GL12#GL_UNSIGNED_SHORT_5_6_5_REV UNSIGNED_SHORT_5_6_5_REV}
{@link GL12#GL_UNSIGNED_SHORT_4_4_4_4 UNSIGNED_SHORT_4_4_4_4}{@link GL12#GL_UNSIGNED_SHORT_4_4_4_4_REV UNSIGNED_SHORT_4_4_4_4_REV}{@link GL12#GL_UNSIGNED_SHORT_5_5_5_1 UNSIGNED_SHORT_5_5_5_1}{@link GL12#GL_UNSIGNED_SHORT_1_5_5_5_REV UNSIGNED_SHORT_1_5_5_5_REV}
{@link GL12#GL_UNSIGNED_INT_8_8_8_8 UNSIGNED_INT_8_8_8_8}{@link GL12#GL_UNSIGNED_INT_8_8_8_8_REV UNSIGNED_INT_8_8_8_8_REV}{@link GL12#GL_UNSIGNED_INT_10_10_10_2 UNSIGNED_INT_10_10_10_2}{@link GL12#GL_UNSIGNED_INT_2_10_10_10_REV UNSIGNED_INT_2_10_10_10_REV}
{@link GL30#GL_UNSIGNED_INT_24_8 UNSIGNED_INT_24_8}{@link GL30#GL_UNSIGNED_INT_10F_11F_11F_REV UNSIGNED_INT_10F_11F_11F_REV}{@link GL30#GL_UNSIGNED_INT_5_9_9_9_REV UNSIGNED_INT_5_9_9_9_REV}{@link GL30#GL_FLOAT_32_UNSIGNED_INT_24_8_REV FLOAT_32_UNSIGNED_INT_24_8_REV}
+ * @param pixels the buffer in which to place the returned data + * + * @see Reference Page + */ + public static void glGetTexImage(@NativeType("GLenum") int tex, @NativeType("GLint") int level, @NativeType("GLenum") int format, @NativeType("GLenum") int type, @NativeType("void *") long pixels) { + GL11C.glGetTexImage(tex, level, format, type, pixels); + } + + /** + * Obtains texture images. + * + * @param tex the texture (or texture face) to be obtained. One of:
{@link GL11C#GL_TEXTURE_1D TEXTURE_1D}{@link GL11C#GL_TEXTURE_2D TEXTURE_2D}{@link GL12#GL_TEXTURE_3D TEXTURE_3D}{@link GL30#GL_TEXTURE_1D_ARRAY TEXTURE_1D_ARRAY}
{@link GL30#GL_TEXTURE_2D_ARRAY TEXTURE_2D_ARRAY}{@link GL31#GL_TEXTURE_RECTANGLE TEXTURE_RECTANGLE}{@link GL13#GL_TEXTURE_CUBE_MAP_POSITIVE_X TEXTURE_CUBE_MAP_POSITIVE_X}{@link GL13#GL_TEXTURE_CUBE_MAP_NEGATIVE_X TEXTURE_CUBE_MAP_NEGATIVE_X}
{@link GL13#GL_TEXTURE_CUBE_MAP_POSITIVE_Y TEXTURE_CUBE_MAP_POSITIVE_Y}{@link GL13#GL_TEXTURE_CUBE_MAP_NEGATIVE_Y TEXTURE_CUBE_MAP_NEGATIVE_Y}{@link GL13#GL_TEXTURE_CUBE_MAP_POSITIVE_Z TEXTURE_CUBE_MAP_POSITIVE_Z}{@link GL13#GL_TEXTURE_CUBE_MAP_NEGATIVE_Z TEXTURE_CUBE_MAP_NEGATIVE_Z}
+ * @param level the level-of-detail number + * @param format the pixel format. One of:
{@link GL11C#GL_RED RED}{@link GL11C#GL_GREEN GREEN}{@link GL11C#GL_BLUE BLUE}{@link GL11C#GL_ALPHA ALPHA}{@link GL30#GL_RG RG}{@link GL11C#GL_RGB RGB}{@link GL11C#GL_RGBA RGBA}{@link GL12#GL_BGR BGR}
{@link GL12#GL_BGRA BGRA}{@link GL30#GL_RED_INTEGER RED_INTEGER}{@link GL30#GL_GREEN_INTEGER GREEN_INTEGER}{@link GL30#GL_BLUE_INTEGER BLUE_INTEGER}{@link GL30#GL_ALPHA_INTEGER ALPHA_INTEGER}{@link GL30#GL_RG_INTEGER RG_INTEGER}{@link GL30#GL_RGB_INTEGER RGB_INTEGER}{@link GL30#GL_RGBA_INTEGER RGBA_INTEGER}
{@link GL30#GL_BGR_INTEGER BGR_INTEGER}{@link GL30#GL_BGRA_INTEGER BGRA_INTEGER}{@link GL11C#GL_STENCIL_INDEX STENCIL_INDEX}{@link GL11C#GL_DEPTH_COMPONENT DEPTH_COMPONENT}{@link GL30#GL_DEPTH_STENCIL DEPTH_STENCIL}
+ * @param type the pixel type. One of:
{@link GL11C#GL_UNSIGNED_BYTE UNSIGNED_BYTE}{@link GL11C#GL_BYTE BYTE}{@link GL11C#GL_UNSIGNED_SHORT UNSIGNED_SHORT}{@link GL11C#GL_SHORT SHORT}
{@link GL11C#GL_UNSIGNED_INT UNSIGNED_INT}{@link GL11C#GL_INT INT}{@link GL30#GL_HALF_FLOAT HALF_FLOAT}{@link GL11C#GL_FLOAT FLOAT}
{@link GL12#GL_UNSIGNED_BYTE_3_3_2 UNSIGNED_BYTE_3_3_2}{@link GL12#GL_UNSIGNED_BYTE_2_3_3_REV UNSIGNED_BYTE_2_3_3_REV}{@link GL12#GL_UNSIGNED_SHORT_5_6_5 UNSIGNED_SHORT_5_6_5}{@link GL12#GL_UNSIGNED_SHORT_5_6_5_REV UNSIGNED_SHORT_5_6_5_REV}
{@link GL12#GL_UNSIGNED_SHORT_4_4_4_4 UNSIGNED_SHORT_4_4_4_4}{@link GL12#GL_UNSIGNED_SHORT_4_4_4_4_REV UNSIGNED_SHORT_4_4_4_4_REV}{@link GL12#GL_UNSIGNED_SHORT_5_5_5_1 UNSIGNED_SHORT_5_5_5_1}{@link GL12#GL_UNSIGNED_SHORT_1_5_5_5_REV UNSIGNED_SHORT_1_5_5_5_REV}
{@link GL12#GL_UNSIGNED_INT_8_8_8_8 UNSIGNED_INT_8_8_8_8}{@link GL12#GL_UNSIGNED_INT_8_8_8_8_REV UNSIGNED_INT_8_8_8_8_REV}{@link GL12#GL_UNSIGNED_INT_10_10_10_2 UNSIGNED_INT_10_10_10_2}{@link GL12#GL_UNSIGNED_INT_2_10_10_10_REV UNSIGNED_INT_2_10_10_10_REV}
{@link GL30#GL_UNSIGNED_INT_24_8 UNSIGNED_INT_24_8}{@link GL30#GL_UNSIGNED_INT_10F_11F_11F_REV UNSIGNED_INT_10F_11F_11F_REV}{@link GL30#GL_UNSIGNED_INT_5_9_9_9_REV UNSIGNED_INT_5_9_9_9_REV}{@link GL30#GL_FLOAT_32_UNSIGNED_INT_24_8_REV FLOAT_32_UNSIGNED_INT_24_8_REV}
+ * @param pixels the buffer in which to place the returned data + * + * @see Reference Page + */ + public static void glGetTexImage(@NativeType("GLenum") int tex, @NativeType("GLint") int level, @NativeType("GLenum") int format, @NativeType("GLenum") int type, @NativeType("void *") ShortBuffer pixels) { + GL11C.glGetTexImage(tex, level, format, type, pixels); + } + + /** + * Obtains texture images. + * + * @param tex the texture (or texture face) to be obtained. One of:
{@link GL11C#GL_TEXTURE_1D TEXTURE_1D}{@link GL11C#GL_TEXTURE_2D TEXTURE_2D}{@link GL12#GL_TEXTURE_3D TEXTURE_3D}{@link GL30#GL_TEXTURE_1D_ARRAY TEXTURE_1D_ARRAY}
{@link GL30#GL_TEXTURE_2D_ARRAY TEXTURE_2D_ARRAY}{@link GL31#GL_TEXTURE_RECTANGLE TEXTURE_RECTANGLE}{@link GL13#GL_TEXTURE_CUBE_MAP_POSITIVE_X TEXTURE_CUBE_MAP_POSITIVE_X}{@link GL13#GL_TEXTURE_CUBE_MAP_NEGATIVE_X TEXTURE_CUBE_MAP_NEGATIVE_X}
{@link GL13#GL_TEXTURE_CUBE_MAP_POSITIVE_Y TEXTURE_CUBE_MAP_POSITIVE_Y}{@link GL13#GL_TEXTURE_CUBE_MAP_NEGATIVE_Y TEXTURE_CUBE_MAP_NEGATIVE_Y}{@link GL13#GL_TEXTURE_CUBE_MAP_POSITIVE_Z TEXTURE_CUBE_MAP_POSITIVE_Z}{@link GL13#GL_TEXTURE_CUBE_MAP_NEGATIVE_Z TEXTURE_CUBE_MAP_NEGATIVE_Z}
+ * @param level the level-of-detail number + * @param format the pixel format. One of:
{@link GL11C#GL_RED RED}{@link GL11C#GL_GREEN GREEN}{@link GL11C#GL_BLUE BLUE}{@link GL11C#GL_ALPHA ALPHA}{@link GL30#GL_RG RG}{@link GL11C#GL_RGB RGB}{@link GL11C#GL_RGBA RGBA}{@link GL12#GL_BGR BGR}
{@link GL12#GL_BGRA BGRA}{@link GL30#GL_RED_INTEGER RED_INTEGER}{@link GL30#GL_GREEN_INTEGER GREEN_INTEGER}{@link GL30#GL_BLUE_INTEGER BLUE_INTEGER}{@link GL30#GL_ALPHA_INTEGER ALPHA_INTEGER}{@link GL30#GL_RG_INTEGER RG_INTEGER}{@link GL30#GL_RGB_INTEGER RGB_INTEGER}{@link GL30#GL_RGBA_INTEGER RGBA_INTEGER}
{@link GL30#GL_BGR_INTEGER BGR_INTEGER}{@link GL30#GL_BGRA_INTEGER BGRA_INTEGER}{@link GL11C#GL_STENCIL_INDEX STENCIL_INDEX}{@link GL11C#GL_DEPTH_COMPONENT DEPTH_COMPONENT}{@link GL30#GL_DEPTH_STENCIL DEPTH_STENCIL}
+ * @param type the pixel type. One of:
{@link GL11C#GL_UNSIGNED_BYTE UNSIGNED_BYTE}{@link GL11C#GL_BYTE BYTE}{@link GL11C#GL_UNSIGNED_SHORT UNSIGNED_SHORT}{@link GL11C#GL_SHORT SHORT}
{@link GL11C#GL_UNSIGNED_INT UNSIGNED_INT}{@link GL11C#GL_INT INT}{@link GL30#GL_HALF_FLOAT HALF_FLOAT}{@link GL11C#GL_FLOAT FLOAT}
{@link GL12#GL_UNSIGNED_BYTE_3_3_2 UNSIGNED_BYTE_3_3_2}{@link GL12#GL_UNSIGNED_BYTE_2_3_3_REV UNSIGNED_BYTE_2_3_3_REV}{@link GL12#GL_UNSIGNED_SHORT_5_6_5 UNSIGNED_SHORT_5_6_5}{@link GL12#GL_UNSIGNED_SHORT_5_6_5_REV UNSIGNED_SHORT_5_6_5_REV}
{@link GL12#GL_UNSIGNED_SHORT_4_4_4_4 UNSIGNED_SHORT_4_4_4_4}{@link GL12#GL_UNSIGNED_SHORT_4_4_4_4_REV UNSIGNED_SHORT_4_4_4_4_REV}{@link GL12#GL_UNSIGNED_SHORT_5_5_5_1 UNSIGNED_SHORT_5_5_5_1}{@link GL12#GL_UNSIGNED_SHORT_1_5_5_5_REV UNSIGNED_SHORT_1_5_5_5_REV}
{@link GL12#GL_UNSIGNED_INT_8_8_8_8 UNSIGNED_INT_8_8_8_8}{@link GL12#GL_UNSIGNED_INT_8_8_8_8_REV UNSIGNED_INT_8_8_8_8_REV}{@link GL12#GL_UNSIGNED_INT_10_10_10_2 UNSIGNED_INT_10_10_10_2}{@link GL12#GL_UNSIGNED_INT_2_10_10_10_REV UNSIGNED_INT_2_10_10_10_REV}
{@link GL30#GL_UNSIGNED_INT_24_8 UNSIGNED_INT_24_8}{@link GL30#GL_UNSIGNED_INT_10F_11F_11F_REV UNSIGNED_INT_10F_11F_11F_REV}{@link GL30#GL_UNSIGNED_INT_5_9_9_9_REV UNSIGNED_INT_5_9_9_9_REV}{@link GL30#GL_FLOAT_32_UNSIGNED_INT_24_8_REV FLOAT_32_UNSIGNED_INT_24_8_REV}
+ * @param pixels the buffer in which to place the returned data + * + * @see Reference Page + */ + public static void glGetTexImage(@NativeType("GLenum") int tex, @NativeType("GLint") int level, @NativeType("GLenum") int format, @NativeType("GLenum") int type, @NativeType("void *") IntBuffer pixels) { + GL11C.glGetTexImage(tex, level, format, type, pixels); + } + + /** + * Obtains texture images. + * + * @param tex the texture (or texture face) to be obtained. One of:
{@link GL11C#GL_TEXTURE_1D TEXTURE_1D}{@link GL11C#GL_TEXTURE_2D TEXTURE_2D}{@link GL12#GL_TEXTURE_3D TEXTURE_3D}{@link GL30#GL_TEXTURE_1D_ARRAY TEXTURE_1D_ARRAY}
{@link GL30#GL_TEXTURE_2D_ARRAY TEXTURE_2D_ARRAY}{@link GL31#GL_TEXTURE_RECTANGLE TEXTURE_RECTANGLE}{@link GL13#GL_TEXTURE_CUBE_MAP_POSITIVE_X TEXTURE_CUBE_MAP_POSITIVE_X}{@link GL13#GL_TEXTURE_CUBE_MAP_NEGATIVE_X TEXTURE_CUBE_MAP_NEGATIVE_X}
{@link GL13#GL_TEXTURE_CUBE_MAP_POSITIVE_Y TEXTURE_CUBE_MAP_POSITIVE_Y}{@link GL13#GL_TEXTURE_CUBE_MAP_NEGATIVE_Y TEXTURE_CUBE_MAP_NEGATIVE_Y}{@link GL13#GL_TEXTURE_CUBE_MAP_POSITIVE_Z TEXTURE_CUBE_MAP_POSITIVE_Z}{@link GL13#GL_TEXTURE_CUBE_MAP_NEGATIVE_Z TEXTURE_CUBE_MAP_NEGATIVE_Z}
+ * @param level the level-of-detail number + * @param format the pixel format. One of:
{@link GL11C#GL_RED RED}{@link GL11C#GL_GREEN GREEN}{@link GL11C#GL_BLUE BLUE}{@link GL11C#GL_ALPHA ALPHA}{@link GL30#GL_RG RG}{@link GL11C#GL_RGB RGB}{@link GL11C#GL_RGBA RGBA}{@link GL12#GL_BGR BGR}
{@link GL12#GL_BGRA BGRA}{@link GL30#GL_RED_INTEGER RED_INTEGER}{@link GL30#GL_GREEN_INTEGER GREEN_INTEGER}{@link GL30#GL_BLUE_INTEGER BLUE_INTEGER}{@link GL30#GL_ALPHA_INTEGER ALPHA_INTEGER}{@link GL30#GL_RG_INTEGER RG_INTEGER}{@link GL30#GL_RGB_INTEGER RGB_INTEGER}{@link GL30#GL_RGBA_INTEGER RGBA_INTEGER}
{@link GL30#GL_BGR_INTEGER BGR_INTEGER}{@link GL30#GL_BGRA_INTEGER BGRA_INTEGER}{@link GL11C#GL_STENCIL_INDEX STENCIL_INDEX}{@link GL11C#GL_DEPTH_COMPONENT DEPTH_COMPONENT}{@link GL30#GL_DEPTH_STENCIL DEPTH_STENCIL}
+ * @param type the pixel type. One of:
{@link GL11C#GL_UNSIGNED_BYTE UNSIGNED_BYTE}{@link GL11C#GL_BYTE BYTE}{@link GL11C#GL_UNSIGNED_SHORT UNSIGNED_SHORT}{@link GL11C#GL_SHORT SHORT}
{@link GL11C#GL_UNSIGNED_INT UNSIGNED_INT}{@link GL11C#GL_INT INT}{@link GL30#GL_HALF_FLOAT HALF_FLOAT}{@link GL11C#GL_FLOAT FLOAT}
{@link GL12#GL_UNSIGNED_BYTE_3_3_2 UNSIGNED_BYTE_3_3_2}{@link GL12#GL_UNSIGNED_BYTE_2_3_3_REV UNSIGNED_BYTE_2_3_3_REV}{@link GL12#GL_UNSIGNED_SHORT_5_6_5 UNSIGNED_SHORT_5_6_5}{@link GL12#GL_UNSIGNED_SHORT_5_6_5_REV UNSIGNED_SHORT_5_6_5_REV}
{@link GL12#GL_UNSIGNED_SHORT_4_4_4_4 UNSIGNED_SHORT_4_4_4_4}{@link GL12#GL_UNSIGNED_SHORT_4_4_4_4_REV UNSIGNED_SHORT_4_4_4_4_REV}{@link GL12#GL_UNSIGNED_SHORT_5_5_5_1 UNSIGNED_SHORT_5_5_5_1}{@link GL12#GL_UNSIGNED_SHORT_1_5_5_5_REV UNSIGNED_SHORT_1_5_5_5_REV}
{@link GL12#GL_UNSIGNED_INT_8_8_8_8 UNSIGNED_INT_8_8_8_8}{@link GL12#GL_UNSIGNED_INT_8_8_8_8_REV UNSIGNED_INT_8_8_8_8_REV}{@link GL12#GL_UNSIGNED_INT_10_10_10_2 UNSIGNED_INT_10_10_10_2}{@link GL12#GL_UNSIGNED_INT_2_10_10_10_REV UNSIGNED_INT_2_10_10_10_REV}
{@link GL30#GL_UNSIGNED_INT_24_8 UNSIGNED_INT_24_8}{@link GL30#GL_UNSIGNED_INT_10F_11F_11F_REV UNSIGNED_INT_10F_11F_11F_REV}{@link GL30#GL_UNSIGNED_INT_5_9_9_9_REV UNSIGNED_INT_5_9_9_9_REV}{@link GL30#GL_FLOAT_32_UNSIGNED_INT_24_8_REV FLOAT_32_UNSIGNED_INT_24_8_REV}
+ * @param pixels the buffer in which to place the returned data + * + * @see Reference Page + */ + public static void glGetTexImage(@NativeType("GLenum") int tex, @NativeType("GLint") int level, @NativeType("GLenum") int format, @NativeType("GLenum") int type, @NativeType("void *") FloatBuffer pixels) { + GL11C.glGetTexImage(tex, level, format, type, pixels); + } + + /** + * Obtains texture images. + * + * @param tex the texture (or texture face) to be obtained. One of:
{@link GL11C#GL_TEXTURE_1D TEXTURE_1D}{@link GL11C#GL_TEXTURE_2D TEXTURE_2D}{@link GL12#GL_TEXTURE_3D TEXTURE_3D}{@link GL30#GL_TEXTURE_1D_ARRAY TEXTURE_1D_ARRAY}
{@link GL30#GL_TEXTURE_2D_ARRAY TEXTURE_2D_ARRAY}{@link GL31#GL_TEXTURE_RECTANGLE TEXTURE_RECTANGLE}{@link GL13#GL_TEXTURE_CUBE_MAP_POSITIVE_X TEXTURE_CUBE_MAP_POSITIVE_X}{@link GL13#GL_TEXTURE_CUBE_MAP_NEGATIVE_X TEXTURE_CUBE_MAP_NEGATIVE_X}
{@link GL13#GL_TEXTURE_CUBE_MAP_POSITIVE_Y TEXTURE_CUBE_MAP_POSITIVE_Y}{@link GL13#GL_TEXTURE_CUBE_MAP_NEGATIVE_Y TEXTURE_CUBE_MAP_NEGATIVE_Y}{@link GL13#GL_TEXTURE_CUBE_MAP_POSITIVE_Z TEXTURE_CUBE_MAP_POSITIVE_Z}{@link GL13#GL_TEXTURE_CUBE_MAP_NEGATIVE_Z TEXTURE_CUBE_MAP_NEGATIVE_Z}
+ * @param level the level-of-detail number + * @param format the pixel format. One of:
{@link GL11C#GL_RED RED}{@link GL11C#GL_GREEN GREEN}{@link GL11C#GL_BLUE BLUE}{@link GL11C#GL_ALPHA ALPHA}{@link GL30#GL_RG RG}{@link GL11C#GL_RGB RGB}{@link GL11C#GL_RGBA RGBA}{@link GL12#GL_BGR BGR}
{@link GL12#GL_BGRA BGRA}{@link GL30#GL_RED_INTEGER RED_INTEGER}{@link GL30#GL_GREEN_INTEGER GREEN_INTEGER}{@link GL30#GL_BLUE_INTEGER BLUE_INTEGER}{@link GL30#GL_ALPHA_INTEGER ALPHA_INTEGER}{@link GL30#GL_RG_INTEGER RG_INTEGER}{@link GL30#GL_RGB_INTEGER RGB_INTEGER}{@link GL30#GL_RGBA_INTEGER RGBA_INTEGER}
{@link GL30#GL_BGR_INTEGER BGR_INTEGER}{@link GL30#GL_BGRA_INTEGER BGRA_INTEGER}{@link GL11C#GL_STENCIL_INDEX STENCIL_INDEX}{@link GL11C#GL_DEPTH_COMPONENT DEPTH_COMPONENT}{@link GL30#GL_DEPTH_STENCIL DEPTH_STENCIL}
+ * @param type the pixel type. One of:
{@link GL11C#GL_UNSIGNED_BYTE UNSIGNED_BYTE}{@link GL11C#GL_BYTE BYTE}{@link GL11C#GL_UNSIGNED_SHORT UNSIGNED_SHORT}{@link GL11C#GL_SHORT SHORT}
{@link GL11C#GL_UNSIGNED_INT UNSIGNED_INT}{@link GL11C#GL_INT INT}{@link GL30#GL_HALF_FLOAT HALF_FLOAT}{@link GL11C#GL_FLOAT FLOAT}
{@link GL12#GL_UNSIGNED_BYTE_3_3_2 UNSIGNED_BYTE_3_3_2}{@link GL12#GL_UNSIGNED_BYTE_2_3_3_REV UNSIGNED_BYTE_2_3_3_REV}{@link GL12#GL_UNSIGNED_SHORT_5_6_5 UNSIGNED_SHORT_5_6_5}{@link GL12#GL_UNSIGNED_SHORT_5_6_5_REV UNSIGNED_SHORT_5_6_5_REV}
{@link GL12#GL_UNSIGNED_SHORT_4_4_4_4 UNSIGNED_SHORT_4_4_4_4}{@link GL12#GL_UNSIGNED_SHORT_4_4_4_4_REV UNSIGNED_SHORT_4_4_4_4_REV}{@link GL12#GL_UNSIGNED_SHORT_5_5_5_1 UNSIGNED_SHORT_5_5_5_1}{@link GL12#GL_UNSIGNED_SHORT_1_5_5_5_REV UNSIGNED_SHORT_1_5_5_5_REV}
{@link GL12#GL_UNSIGNED_INT_8_8_8_8 UNSIGNED_INT_8_8_8_8}{@link GL12#GL_UNSIGNED_INT_8_8_8_8_REV UNSIGNED_INT_8_8_8_8_REV}{@link GL12#GL_UNSIGNED_INT_10_10_10_2 UNSIGNED_INT_10_10_10_2}{@link GL12#GL_UNSIGNED_INT_2_10_10_10_REV UNSIGNED_INT_2_10_10_10_REV}
{@link GL30#GL_UNSIGNED_INT_24_8 UNSIGNED_INT_24_8}{@link GL30#GL_UNSIGNED_INT_10F_11F_11F_REV UNSIGNED_INT_10F_11F_11F_REV}{@link GL30#GL_UNSIGNED_INT_5_9_9_9_REV UNSIGNED_INT_5_9_9_9_REV}{@link GL30#GL_FLOAT_32_UNSIGNED_INT_24_8_REV FLOAT_32_UNSIGNED_INT_24_8_REV}
+ * @param pixels the buffer in which to place the returned data + * + * @see Reference Page + */ + public static void glGetTexImage(@NativeType("GLenum") int tex, @NativeType("GLint") int level, @NativeType("GLenum") int format, @NativeType("GLenum") int type, @NativeType("void *") DoubleBuffer pixels) { + GL11C.glGetTexImage(tex, level, format, type, pixels); + } + + // --- [ glGetTexLevelParameteriv ] --- + + /** Unsafe version of: {@link #glGetTexLevelParameteriv GetTexLevelParameteriv} */ + public static void nglGetTexLevelParameteriv(int target, int level, int pname, long params) { + GL11C.nglGetTexLevelParameteriv(target, level, pname, params); + } + + /** + * Places integer information about texture image parameter {@code pname} for level-of-detail {@code level} of the specified {@code target} into {@code params}. + * + * @param target the texture image target. One of:
{@link GL11C#GL_TEXTURE_2D TEXTURE_2D}{@link GL30#GL_TEXTURE_1D_ARRAY TEXTURE_1D_ARRAY}{@link GL31#GL_TEXTURE_RECTANGLE TEXTURE_RECTANGLE}{@link GL13#GL_TEXTURE_CUBE_MAP TEXTURE_CUBE_MAP}
{@link GL11C#GL_PROXY_TEXTURE_2D PROXY_TEXTURE_2D}{@link GL30#GL_PROXY_TEXTURE_1D_ARRAY PROXY_TEXTURE_1D_ARRAY}{@link GL31#GL_PROXY_TEXTURE_RECTANGLE PROXY_TEXTURE_RECTANGLE}{@link GL13#GL_PROXY_TEXTURE_CUBE_MAP PROXY_TEXTURE_CUBE_MAP}
{@link GL11C#GL_TEXTURE_1D TEXTURE_1D}{@link GL12#GL_TEXTURE_3D TEXTURE_3D}{@link GL30#GL_TEXTURE_2D_ARRAY TEXTURE_2D_ARRAY}{@link GL40#GL_TEXTURE_CUBE_MAP_ARRAY TEXTURE_CUBE_MAP_ARRAY}
{@link GL32#GL_TEXTURE_2D_MULTISAMPLE TEXTURE_2D_MULTISAMPLE}{@link GL32#GL_TEXTURE_2D_MULTISAMPLE_ARRAY TEXTURE_2D_MULTISAMPLE_ARRAY}{@link GL11C#GL_PROXY_TEXTURE_1D PROXY_TEXTURE_1D}{@link GL12#GL_PROXY_TEXTURE_3D PROXY_TEXTURE_3D}
{@link GL30#GL_PROXY_TEXTURE_2D_ARRAY PROXY_TEXTURE_2D_ARRAY}{@link GL40#GL_PROXY_TEXTURE_CUBE_MAP_ARRAY PROXY_TEXTURE_CUBE_MAP_ARRAY}{@link GL32#GL_PROXY_TEXTURE_2D_MULTISAMPLE PROXY_TEXTURE_2D_MULTISAMPLE}{@link GL32#GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY}
+ * @param level the level-of-detail number + * @param pname the parameter to query. One of:
{@link GL11C#GL_TEXTURE_WIDTH TEXTURE_WIDTH}{@link GL11C#GL_TEXTURE_HEIGHT TEXTURE_HEIGHT}{@link GL12#GL_TEXTURE_DEPTH TEXTURE_DEPTH}{@link GL32#GL_TEXTURE_SAMPLES TEXTURE_SAMPLES}
{@link GL32#GL_TEXTURE_FIXED_SAMPLE_LOCATIONS TEXTURE_FIXED_SAMPLE_LOCATIONS}{@link GL11C#GL_TEXTURE_INTERNAL_FORMAT TEXTURE_INTERNAL_FORMAT}{@link GL11C#GL_TEXTURE_RED_SIZE TEXTURE_RED_SIZE}{@link GL11C#GL_TEXTURE_GREEN_SIZE TEXTURE_GREEN_SIZE}
{@link GL11C#GL_TEXTURE_BLUE_SIZE TEXTURE_BLUE_SIZE}{@link GL11C#GL_TEXTURE_ALPHA_SIZE TEXTURE_ALPHA_SIZE}{@link GL14#GL_TEXTURE_DEPTH_SIZE TEXTURE_DEPTH_SIZE}{@link GL30#GL_TEXTURE_STENCIL_SIZE TEXTURE_STENCIL_SIZE}
{@link GL30#GL_TEXTURE_SHARED_SIZE TEXTURE_SHARED_SIZE}{@link GL30#GL_TEXTURE_ALPHA_TYPE TEXTURE_ALPHA_TYPE}{@link GL30#GL_TEXTURE_DEPTH_TYPE TEXTURE_DEPTH_TYPE}{@link GL13#GL_TEXTURE_COMPRESSED TEXTURE_COMPRESSED}
{@link GL13#GL_TEXTURE_COMPRESSED_IMAGE_SIZE TEXTURE_COMPRESSED_IMAGE_SIZE}{@link GL31#GL_TEXTURE_BUFFER_DATA_STORE_BINDING TEXTURE_BUFFER_DATA_STORE_BINDING}{@link GL43#GL_TEXTURE_BUFFER_OFFSET TEXTURE_BUFFER_OFFSET}{@link GL43#GL_TEXTURE_BUFFER_SIZE TEXTURE_BUFFER_SIZE}
+ * @param params a scalar or buffer in which to place the returned data + * + * @see Reference Page + */ + public static void glGetTexLevelParameteriv(@NativeType("GLenum") int target, @NativeType("GLint") int level, @NativeType("GLenum") int pname, @NativeType("GLint *") IntBuffer params) { + GL11C.glGetTexLevelParameteriv(target, level, pname, params); + } + + /** + * Places integer information about texture image parameter {@code pname} for level-of-detail {@code level} of the specified {@code target} into {@code params}. + * + * @param target the texture image target. One of:
{@link GL11C#GL_TEXTURE_2D TEXTURE_2D}{@link GL30#GL_TEXTURE_1D_ARRAY TEXTURE_1D_ARRAY}{@link GL31#GL_TEXTURE_RECTANGLE TEXTURE_RECTANGLE}{@link GL13#GL_TEXTURE_CUBE_MAP TEXTURE_CUBE_MAP}
{@link GL11C#GL_PROXY_TEXTURE_2D PROXY_TEXTURE_2D}{@link GL30#GL_PROXY_TEXTURE_1D_ARRAY PROXY_TEXTURE_1D_ARRAY}{@link GL31#GL_PROXY_TEXTURE_RECTANGLE PROXY_TEXTURE_RECTANGLE}{@link GL13#GL_PROXY_TEXTURE_CUBE_MAP PROXY_TEXTURE_CUBE_MAP}
{@link GL11C#GL_TEXTURE_1D TEXTURE_1D}{@link GL12#GL_TEXTURE_3D TEXTURE_3D}{@link GL30#GL_TEXTURE_2D_ARRAY TEXTURE_2D_ARRAY}{@link GL40#GL_TEXTURE_CUBE_MAP_ARRAY TEXTURE_CUBE_MAP_ARRAY}
{@link GL32#GL_TEXTURE_2D_MULTISAMPLE TEXTURE_2D_MULTISAMPLE}{@link GL32#GL_TEXTURE_2D_MULTISAMPLE_ARRAY TEXTURE_2D_MULTISAMPLE_ARRAY}{@link GL11C#GL_PROXY_TEXTURE_1D PROXY_TEXTURE_1D}{@link GL12#GL_PROXY_TEXTURE_3D PROXY_TEXTURE_3D}
{@link GL30#GL_PROXY_TEXTURE_2D_ARRAY PROXY_TEXTURE_2D_ARRAY}{@link GL40#GL_PROXY_TEXTURE_CUBE_MAP_ARRAY PROXY_TEXTURE_CUBE_MAP_ARRAY}{@link GL32#GL_PROXY_TEXTURE_2D_MULTISAMPLE PROXY_TEXTURE_2D_MULTISAMPLE}{@link GL32#GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY}
+ * @param level the level-of-detail number + * @param pname the parameter to query. One of:
{@link GL11C#GL_TEXTURE_WIDTH TEXTURE_WIDTH}{@link GL11C#GL_TEXTURE_HEIGHT TEXTURE_HEIGHT}{@link GL12#GL_TEXTURE_DEPTH TEXTURE_DEPTH}{@link GL32#GL_TEXTURE_SAMPLES TEXTURE_SAMPLES}
{@link GL32#GL_TEXTURE_FIXED_SAMPLE_LOCATIONS TEXTURE_FIXED_SAMPLE_LOCATIONS}{@link GL11C#GL_TEXTURE_INTERNAL_FORMAT TEXTURE_INTERNAL_FORMAT}{@link GL11C#GL_TEXTURE_RED_SIZE TEXTURE_RED_SIZE}{@link GL11C#GL_TEXTURE_GREEN_SIZE TEXTURE_GREEN_SIZE}
{@link GL11C#GL_TEXTURE_BLUE_SIZE TEXTURE_BLUE_SIZE}{@link GL11C#GL_TEXTURE_ALPHA_SIZE TEXTURE_ALPHA_SIZE}{@link GL14#GL_TEXTURE_DEPTH_SIZE TEXTURE_DEPTH_SIZE}{@link GL30#GL_TEXTURE_STENCIL_SIZE TEXTURE_STENCIL_SIZE}
{@link GL30#GL_TEXTURE_SHARED_SIZE TEXTURE_SHARED_SIZE}{@link GL30#GL_TEXTURE_ALPHA_TYPE TEXTURE_ALPHA_TYPE}{@link GL30#GL_TEXTURE_DEPTH_TYPE TEXTURE_DEPTH_TYPE}{@link GL13#GL_TEXTURE_COMPRESSED TEXTURE_COMPRESSED}
{@link GL13#GL_TEXTURE_COMPRESSED_IMAGE_SIZE TEXTURE_COMPRESSED_IMAGE_SIZE}{@link GL31#GL_TEXTURE_BUFFER_DATA_STORE_BINDING TEXTURE_BUFFER_DATA_STORE_BINDING}{@link GL43#GL_TEXTURE_BUFFER_OFFSET TEXTURE_BUFFER_OFFSET}{@link GL43#GL_TEXTURE_BUFFER_SIZE TEXTURE_BUFFER_SIZE}
+ * + * @see Reference Page + */ + @NativeType("void") + public static int glGetTexLevelParameteri(@NativeType("GLenum") int target, @NativeType("GLint") int level, @NativeType("GLenum") int pname) { + return GL11C.glGetTexLevelParameteri(target, level, pname); + } + + // --- [ glGetTexLevelParameterfv ] --- + + /** Unsafe version of: {@link #glGetTexLevelParameterfv GetTexLevelParameterfv} */ + public static void nglGetTexLevelParameterfv(int target, int level, int pname, long params) { + GL11C.nglGetTexLevelParameterfv(target, level, pname, params); + } + + /** + * Float version of {@link #glGetTexLevelParameteriv GetTexLevelParameteriv}. + * + * @param target the texture image target + * @param level the level-of-detail number + * @param pname the parameter to query + * @param params a scalar or buffer in which to place the returned data + * + * @see Reference Page + */ + public static void glGetTexLevelParameterfv(@NativeType("GLenum") int target, @NativeType("GLint") int level, @NativeType("GLenum") int pname, @NativeType("GLfloat *") FloatBuffer params) { + GL11C.glGetTexLevelParameterfv(target, level, pname, params); + } + + /** + * Float version of {@link #glGetTexLevelParameteriv GetTexLevelParameteriv}. + * + * @param target the texture image target + * @param level the level-of-detail number + * @param pname the parameter to query + * + * @see Reference Page + */ + @NativeType("void") + public static float glGetTexLevelParameterf(@NativeType("GLenum") int target, @NativeType("GLint") int level, @NativeType("GLenum") int pname) { + return GL11C.glGetTexLevelParameterf(target, level, pname); + } + + // --- [ glGetTexParameteriv ] --- + + /** Unsafe version of: {@link #glGetTexParameteriv GetTexParameteriv} */ + public static void nglGetTexParameteriv(int target, int pname, long params) { + GL11C.nglGetTexParameteriv(target, pname, params); + } + + /** + * Place integer information about texture parameter {@code pname} for the specified {@code target} into {@code params}. + * + * @param target the texture target. One of:
{@link GL11C#GL_TEXTURE_1D TEXTURE_1D}{@link GL11C#GL_TEXTURE_2D TEXTURE_2D}{@link GL12#GL_TEXTURE_3D TEXTURE_3D}{@link GL30#GL_TEXTURE_1D_ARRAY TEXTURE_1D_ARRAY}
{@link GL30#GL_TEXTURE_2D_ARRAY TEXTURE_2D_ARRAY}{@link GL31#GL_TEXTURE_RECTANGLE TEXTURE_RECTANGLE}{@link GL13#GL_TEXTURE_CUBE_MAP TEXTURE_CUBE_MAP}{@link GL40#GL_TEXTURE_CUBE_MAP_ARRAY TEXTURE_CUBE_MAP_ARRAY}
{@link GL32#GL_TEXTURE_2D_MULTISAMPLE TEXTURE_2D_MULTISAMPLE}{@link GL32#GL_TEXTURE_2D_MULTISAMPLE_ARRAY TEXTURE_2D_MULTISAMPLE_ARRAY}
+ * @param pname the parameter to query. One of:
{@link GL12#GL_TEXTURE_BASE_LEVEL TEXTURE_BASE_LEVEL}{@link GL11C#GL_TEXTURE_BORDER_COLOR TEXTURE_BORDER_COLOR}{@link GL14#GL_TEXTURE_COMPARE_MODE TEXTURE_COMPARE_MODE}{@link GL14#GL_TEXTURE_COMPARE_FUNC TEXTURE_COMPARE_FUNC}
{@link GL14#GL_TEXTURE_LOD_BIAS TEXTURE_LOD_BIAS}{@link GL11C#GL_TEXTURE_MAG_FILTER TEXTURE_MAG_FILTER}{@link GL12#GL_TEXTURE_MAX_LEVEL TEXTURE_MAX_LEVEL}{@link GL12#GL_TEXTURE_MAX_LOD TEXTURE_MAX_LOD}
{@link GL11C#GL_TEXTURE_MIN_FILTER TEXTURE_MIN_FILTER}{@link GL12#GL_TEXTURE_MIN_LOD TEXTURE_MIN_LOD}{@link GL33#GL_TEXTURE_SWIZZLE_R TEXTURE_SWIZZLE_R}{@link GL33#GL_TEXTURE_SWIZZLE_G TEXTURE_SWIZZLE_G}
{@link GL33#GL_TEXTURE_SWIZZLE_B TEXTURE_SWIZZLE_B}{@link GL33#GL_TEXTURE_SWIZZLE_A TEXTURE_SWIZZLE_A}{@link GL33#GL_TEXTURE_SWIZZLE_RGBA TEXTURE_SWIZZLE_RGBA}{@link GL11C#GL_TEXTURE_WRAP_S TEXTURE_WRAP_S}
{@link GL11C#GL_TEXTURE_WRAP_T TEXTURE_WRAP_T}{@link GL12#GL_TEXTURE_WRAP_R TEXTURE_WRAP_R}{@link GL14#GL_DEPTH_TEXTURE_MODE DEPTH_TEXTURE_MODE}{@link GL14#GL_GENERATE_MIPMAP GENERATE_MIPMAP}
{@link GL42#GL_IMAGE_FORMAT_COMPATIBILITY_TYPE IMAGE_FORMAT_COMPATIBILITY_TYPE}{@link GL42#GL_TEXTURE_IMMUTABLE_FORMAT TEXTURE_IMMUTABLE_FORMAT}{@link GL43#GL_TEXTURE_IMMUTABLE_LEVELS TEXTURE_IMMUTABLE_LEVELS}{@link GL43#GL_TEXTURE_VIEW_MIN_LEVEL TEXTURE_VIEW_MIN_LEVEL}
{@link GL43#GL_TEXTURE_VIEW_NUM_LEVELS TEXTURE_VIEW_NUM_LEVELS}{@link GL43#GL_TEXTURE_VIEW_MIN_LAYER TEXTURE_VIEW_MIN_LAYER}{@link GL43#GL_TEXTURE_VIEW_NUM_LAYERS TEXTURE_VIEW_NUM_LAYERS}
+ * @param params a scalar or buffer in which to place the returned data + * + * @see Reference Page + */ + public static void glGetTexParameteriv(@NativeType("GLenum") int target, @NativeType("GLenum") int pname, @NativeType("GLint *") IntBuffer params) { + GL11C.glGetTexParameteriv(target, pname, params); + } + + /** + * Place integer information about texture parameter {@code pname} for the specified {@code target} into {@code params}. + * + * @param target the texture target. One of:
{@link GL11C#GL_TEXTURE_1D TEXTURE_1D}{@link GL11C#GL_TEXTURE_2D TEXTURE_2D}{@link GL12#GL_TEXTURE_3D TEXTURE_3D}{@link GL30#GL_TEXTURE_1D_ARRAY TEXTURE_1D_ARRAY}
{@link GL30#GL_TEXTURE_2D_ARRAY TEXTURE_2D_ARRAY}{@link GL31#GL_TEXTURE_RECTANGLE TEXTURE_RECTANGLE}{@link GL13#GL_TEXTURE_CUBE_MAP TEXTURE_CUBE_MAP}{@link GL40#GL_TEXTURE_CUBE_MAP_ARRAY TEXTURE_CUBE_MAP_ARRAY}
{@link GL32#GL_TEXTURE_2D_MULTISAMPLE TEXTURE_2D_MULTISAMPLE}{@link GL32#GL_TEXTURE_2D_MULTISAMPLE_ARRAY TEXTURE_2D_MULTISAMPLE_ARRAY}
+ * @param pname the parameter to query. One of:
{@link GL12#GL_TEXTURE_BASE_LEVEL TEXTURE_BASE_LEVEL}{@link GL11C#GL_TEXTURE_BORDER_COLOR TEXTURE_BORDER_COLOR}{@link GL14#GL_TEXTURE_COMPARE_MODE TEXTURE_COMPARE_MODE}{@link GL14#GL_TEXTURE_COMPARE_FUNC TEXTURE_COMPARE_FUNC}
{@link GL14#GL_TEXTURE_LOD_BIAS TEXTURE_LOD_BIAS}{@link GL11C#GL_TEXTURE_MAG_FILTER TEXTURE_MAG_FILTER}{@link GL12#GL_TEXTURE_MAX_LEVEL TEXTURE_MAX_LEVEL}{@link GL12#GL_TEXTURE_MAX_LOD TEXTURE_MAX_LOD}
{@link GL11C#GL_TEXTURE_MIN_FILTER TEXTURE_MIN_FILTER}{@link GL12#GL_TEXTURE_MIN_LOD TEXTURE_MIN_LOD}{@link GL33#GL_TEXTURE_SWIZZLE_R TEXTURE_SWIZZLE_R}{@link GL33#GL_TEXTURE_SWIZZLE_G TEXTURE_SWIZZLE_G}
{@link GL33#GL_TEXTURE_SWIZZLE_B TEXTURE_SWIZZLE_B}{@link GL33#GL_TEXTURE_SWIZZLE_A TEXTURE_SWIZZLE_A}{@link GL33#GL_TEXTURE_SWIZZLE_RGBA TEXTURE_SWIZZLE_RGBA}{@link GL11C#GL_TEXTURE_WRAP_S TEXTURE_WRAP_S}
{@link GL11C#GL_TEXTURE_WRAP_T TEXTURE_WRAP_T}{@link GL12#GL_TEXTURE_WRAP_R TEXTURE_WRAP_R}{@link GL14#GL_DEPTH_TEXTURE_MODE DEPTH_TEXTURE_MODE}{@link GL14#GL_GENERATE_MIPMAP GENERATE_MIPMAP}
{@link GL42#GL_IMAGE_FORMAT_COMPATIBILITY_TYPE IMAGE_FORMAT_COMPATIBILITY_TYPE}{@link GL42#GL_TEXTURE_IMMUTABLE_FORMAT TEXTURE_IMMUTABLE_FORMAT}{@link GL43#GL_TEXTURE_IMMUTABLE_LEVELS TEXTURE_IMMUTABLE_LEVELS}{@link GL43#GL_TEXTURE_VIEW_MIN_LEVEL TEXTURE_VIEW_MIN_LEVEL}
{@link GL43#GL_TEXTURE_VIEW_NUM_LEVELS TEXTURE_VIEW_NUM_LEVELS}{@link GL43#GL_TEXTURE_VIEW_MIN_LAYER TEXTURE_VIEW_MIN_LAYER}{@link GL43#GL_TEXTURE_VIEW_NUM_LAYERS TEXTURE_VIEW_NUM_LAYERS}
+ * + * @see Reference Page + */ + @NativeType("void") + public static int glGetTexParameteri(@NativeType("GLenum") int target, @NativeType("GLenum") int pname) { + return GL11C.glGetTexParameteri(target, pname); + } + + // --- [ glGetTexParameterfv ] --- + + /** Unsafe version of: {@link #glGetTexParameterfv GetTexParameterfv} */ + public static void nglGetTexParameterfv(int target, int pname, long params) { + GL11C.nglGetTexParameterfv(target, pname, params); + } + + /** + * Float version of {@link #glGetTexParameteriv GetTexParameteriv}. + * + * @param target the texture target + * @param pname the parameter to query + * @param params a scalar or buffer in which to place the returned data + * + * @see Reference Page + */ + public static void glGetTexParameterfv(@NativeType("GLenum") int target, @NativeType("GLenum") int pname, @NativeType("GLfloat *") FloatBuffer params) { + GL11C.glGetTexParameterfv(target, pname, params); + } + + /** + * Float version of {@link #glGetTexParameteriv GetTexParameteriv}. + * + * @param target the texture target + * @param pname the parameter to query + * + * @see Reference Page + */ + @NativeType("void") + public static float glGetTexParameterf(@NativeType("GLenum") int target, @NativeType("GLenum") int pname) { + return GL11C.glGetTexParameterf(target, pname); + } + + // --- [ glHint ] --- + + /** + * Certain aspects of GL behavior, when there is room for variation, may be controlled with this function. The initial value for all hints is + * {@link GL11C#GL_DONT_CARE DONT_CARE}. + * + * @param target the behavior to control. One of:
{@link GL11C#GL_LINE_SMOOTH_HINT LINE_SMOOTH_HINT}{@link GL11C#GL_POLYGON_SMOOTH_HINT POLYGON_SMOOTH_HINT}{@link GL13#GL_TEXTURE_COMPRESSION_HINT TEXTURE_COMPRESSION_HINT}
{@link GL20#GL_FRAGMENT_SHADER_DERIVATIVE_HINT FRAGMENT_SHADER_DERIVATIVE_HINT}
+ * @param hint the behavior hint. One of:
{@link GL11C#GL_FASTEST FASTEST}{@link GL11C#GL_NICEST NICEST}{@link GL11C#GL_DONT_CARE DONT_CARE}
+ * + * @see Reference Page + */ + public static void glHint(@NativeType("GLenum") int target, @NativeType("GLenum") int hint) { + GL11C.glHint(target, hint); + } + + // --- [ glIndexi ] --- + + /** + * Updates the current (single-valued) color index. + * + * @param index the value to which the current color index should be set + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glIndexi(@NativeType("GLint") int index); + + // --- [ glIndexub ] --- + + /** + * Unsigned byte version of {@link #glIndexi Indexi}. + * + * @param index the value to which the current color index should be set + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glIndexub(@NativeType("GLubyte") byte index); + + // --- [ glIndexs ] --- + + /** + * Short version of {@link #glIndexi Indexi}. + * + * @param index the value to which the current color index should be set + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glIndexs(@NativeType("GLshort") short index); + + // --- [ glIndexf ] --- + + /** + * Float version of {@link #glIndexi Indexi}. + * + * @param index the value to which the current color index should be set + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glIndexf(@NativeType("GLfloat") float index); + + // --- [ glIndexd ] --- + + /** + * Double version of {@link #glIndexi Indexi}. + * + * @param index the value to which the current color index should be set + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glIndexd(@NativeType("GLdouble") double index); + + // --- [ glIndexiv ] --- + + /** Unsafe version of: {@link #glIndexiv Indexiv} */ + public static native void nglIndexiv(long index); + + /** + * Pointer version of {@link #glIndexi Indexi} + * + * @param index the value to which the current color index should be set + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glIndexiv(@NativeType("GLint const *") IntBuffer index) { + if (CHECKS) { + check(index, 1); + } + nglIndexiv(memAddress(index)); + } + + // --- [ glIndexubv ] --- + + /** Unsafe version of: {@link #glIndexubv Indexubv} */ + public static native void nglIndexubv(long index); + + /** + * Pointer version of {@link #glIndexub Indexub}. + * + * @param index the value to which the current color index should be set + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glIndexubv(@NativeType("GLubyte const *") ByteBuffer index) { + if (CHECKS) { + check(index, 1); + } + nglIndexubv(memAddress(index)); + } + + // --- [ glIndexsv ] --- + + /** Unsafe version of: {@link #glIndexsv Indexsv} */ + public static native void nglIndexsv(long index); + + /** + * Pointer version of {@link #glIndexs Indexs}. + * + * @param index the value to which the current color index should be set + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glIndexsv(@NativeType("GLshort const *") ShortBuffer index) { + if (CHECKS) { + check(index, 1); + } + nglIndexsv(memAddress(index)); + } + + // --- [ glIndexfv ] --- + + /** Unsafe version of: {@link #glIndexfv Indexfv} */ + public static native void nglIndexfv(long index); + + /** + * Pointer version of {@link #glIndexf Indexf}. + * + * @param index the value to which the current color index should be set + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glIndexfv(@NativeType("GLfloat const *") FloatBuffer index) { + if (CHECKS) { + check(index, 1); + } + nglIndexfv(memAddress(index)); + } + + // --- [ glIndexdv ] --- + + /** Unsafe version of: {@link #glIndexdv Indexdv} */ + public static native void nglIndexdv(long index); + + /** + * Pointer version of {@link #glIndexd Indexd}. + * + * @param index the value to which the current color index should be set + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glIndexdv(@NativeType("GLdouble const *") DoubleBuffer index) { + if (CHECKS) { + check(index, 1); + } + nglIndexdv(memAddress(index)); + } + + // --- [ glIndexMask ] --- + + /** + * The least significant n bits of mask, where n is the number of bits in a color index buffer, specify a mask. Where a 1 appears in this mask, the + * corresponding bit in the color index buffer (or buffers) is written; where a 0 appears, the bit is not written. This mask applies only in color index + * mode. + * + * @param mask the color index mask value + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glIndexMask(@NativeType("GLuint") int mask); + + // --- [ glIndexPointer ] --- + + /** + * Unsafe version of: {@link #glIndexPointer IndexPointer} + * + * @param type the data type of the values stored in the array. One of:
{@link #GL_UNSIGNED_BYTE UNSIGNED_BYTE}{@link #GL_SHORT SHORT}{@link #GL_INT INT}{@link #GL_FLOAT FLOAT}{@link #GL_DOUBLE DOUBLE}
+ */ + public static native void nglIndexPointer(int type, int stride, long pointer); + + /** + * Specifies the location and organization of a color index array. + * + * @param type the data type of the values stored in the array. One of:
{@link #GL_UNSIGNED_BYTE UNSIGNED_BYTE}{@link #GL_SHORT SHORT}{@link #GL_INT INT}{@link #GL_FLOAT FLOAT}{@link #GL_DOUBLE DOUBLE}
+ * @param stride the vertex stride in bytes. If specified as zero, then array elements are stored sequentially + * @param pointer the color index array data + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glIndexPointer(@NativeType("GLenum") int type, @NativeType("GLsizei") int stride, @NativeType("void const *") ByteBuffer pointer) { + nglIndexPointer(type, stride, memAddress(pointer)); + } + + /** + * Specifies the location and organization of a color index array. + * + * @param type the data type of the values stored in the array. One of:
{@link #GL_UNSIGNED_BYTE UNSIGNED_BYTE}{@link #GL_SHORT SHORT}{@link #GL_INT INT}{@link #GL_FLOAT FLOAT}{@link #GL_DOUBLE DOUBLE}
+ * @param stride the vertex stride in bytes. If specified as zero, then array elements are stored sequentially + * @param pointer the color index array data + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glIndexPointer(@NativeType("GLenum") int type, @NativeType("GLsizei") int stride, @NativeType("void const *") long pointer) { + nglIndexPointer(type, stride, pointer); + } + + /** + * Specifies the location and organization of a color index array. + * + * @param stride the vertex stride in bytes. If specified as zero, then array elements are stored sequentially + * @param pointer the color index array data + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glIndexPointer(@NativeType("GLsizei") int stride, @NativeType("void const *") ByteBuffer pointer) { + nglIndexPointer(GL11.GL_UNSIGNED_BYTE, stride, memAddress(pointer)); + } + + /** + * Specifies the location and organization of a color index array. + * + * @param stride the vertex stride in bytes. If specified as zero, then array elements are stored sequentially + * @param pointer the color index array data + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glIndexPointer(@NativeType("GLsizei") int stride, @NativeType("void const *") ShortBuffer pointer) { + nglIndexPointer(GL11.GL_SHORT, stride, memAddress(pointer)); + } + + /** + * Specifies the location and organization of a color index array. + * + * @param stride the vertex stride in bytes. If specified as zero, then array elements are stored sequentially + * @param pointer the color index array data + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glIndexPointer(@NativeType("GLsizei") int stride, @NativeType("void const *") IntBuffer pointer) { + nglIndexPointer(GL11.GL_INT, stride, memAddress(pointer)); + } + + // --- [ glInitNames ] --- + + /** + * Clears the selection name stack. + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glInitNames(); + + // --- [ glInterleavedArrays ] --- + + /** Unsafe version of: {@link #glInterleavedArrays InterleavedArrays} */ + public static native void nglInterleavedArrays(int format, int stride, long pointer); + + /** + * Efficiently initializes the six vertex arrays and their enables to one of 14 configurations. + * + * @param format the interleaved array format. One of:
{@link #GL_V2F V2F}{@link #GL_V3F V3F}{@link #GL_C4UB_V2F C4UB_V2F}{@link #GL_C4UB_V3F C4UB_V3F}{@link #GL_C3F_V3F C3F_V3F}{@link #GL_N3F_V3F N3F_V3F}{@link #GL_C4F_N3F_V3F C4F_N3F_V3F}{@link #GL_T2F_V3F T2F_V3F}
{@link #GL_T4F_V4F T4F_V4F}{@link #GL_T2F_C4UB_V3F T2F_C4UB_V3F}{@link #GL_T2F_C3F_V3F T2F_C3F_V3F}{@link #GL_T2F_N3F_V3F T2F_N3F_V3F}{@link #GL_T2F_C4F_N3F_V3F T2F_C4F_N3F_V3F}{@link #GL_T4F_C4F_N3F_V4F T4F_C4F_N3F_V4F}
+ * @param stride the vertex stride in bytes. If specified as zero, then array elements are stored sequentially + * @param pointer the vertex array data + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glInterleavedArrays(@NativeType("GLenum") int format, @NativeType("GLsizei") int stride, @NativeType("void const *") ByteBuffer pointer) { + nglInterleavedArrays(format, stride, memAddress(pointer)); + } + + /** + * Efficiently initializes the six vertex arrays and their enables to one of 14 configurations. + * + * @param format the interleaved array format. One of:
{@link #GL_V2F V2F}{@link #GL_V3F V3F}{@link #GL_C4UB_V2F C4UB_V2F}{@link #GL_C4UB_V3F C4UB_V3F}{@link #GL_C3F_V3F C3F_V3F}{@link #GL_N3F_V3F N3F_V3F}{@link #GL_C4F_N3F_V3F C4F_N3F_V3F}{@link #GL_T2F_V3F T2F_V3F}
{@link #GL_T4F_V4F T4F_V4F}{@link #GL_T2F_C4UB_V3F T2F_C4UB_V3F}{@link #GL_T2F_C3F_V3F T2F_C3F_V3F}{@link #GL_T2F_N3F_V3F T2F_N3F_V3F}{@link #GL_T2F_C4F_N3F_V3F T2F_C4F_N3F_V3F}{@link #GL_T4F_C4F_N3F_V4F T4F_C4F_N3F_V4F}
+ * @param stride the vertex stride in bytes. If specified as zero, then array elements are stored sequentially + * @param pointer the vertex array data + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glInterleavedArrays(@NativeType("GLenum") int format, @NativeType("GLsizei") int stride, @NativeType("void const *") long pointer) { + nglInterleavedArrays(format, stride, pointer); + } + + /** + * Efficiently initializes the six vertex arrays and their enables to one of 14 configurations. + * + * @param format the interleaved array format. One of:
{@link #GL_V2F V2F}{@link #GL_V3F V3F}{@link #GL_C4UB_V2F C4UB_V2F}{@link #GL_C4UB_V3F C4UB_V3F}{@link #GL_C3F_V3F C3F_V3F}{@link #GL_N3F_V3F N3F_V3F}{@link #GL_C4F_N3F_V3F C4F_N3F_V3F}{@link #GL_T2F_V3F T2F_V3F}
{@link #GL_T4F_V4F T4F_V4F}{@link #GL_T2F_C4UB_V3F T2F_C4UB_V3F}{@link #GL_T2F_C3F_V3F T2F_C3F_V3F}{@link #GL_T2F_N3F_V3F T2F_N3F_V3F}{@link #GL_T2F_C4F_N3F_V3F T2F_C4F_N3F_V3F}{@link #GL_T4F_C4F_N3F_V4F T4F_C4F_N3F_V4F}
+ * @param stride the vertex stride in bytes. If specified as zero, then array elements are stored sequentially + * @param pointer the vertex array data + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glInterleavedArrays(@NativeType("GLenum") int format, @NativeType("GLsizei") int stride, @NativeType("void const *") ShortBuffer pointer) { + nglInterleavedArrays(format, stride, memAddress(pointer)); + } + + /** + * Efficiently initializes the six vertex arrays and their enables to one of 14 configurations. + * + * @param format the interleaved array format. One of:
{@link #GL_V2F V2F}{@link #GL_V3F V3F}{@link #GL_C4UB_V2F C4UB_V2F}{@link #GL_C4UB_V3F C4UB_V3F}{@link #GL_C3F_V3F C3F_V3F}{@link #GL_N3F_V3F N3F_V3F}{@link #GL_C4F_N3F_V3F C4F_N3F_V3F}{@link #GL_T2F_V3F T2F_V3F}
{@link #GL_T4F_V4F T4F_V4F}{@link #GL_T2F_C4UB_V3F T2F_C4UB_V3F}{@link #GL_T2F_C3F_V3F T2F_C3F_V3F}{@link #GL_T2F_N3F_V3F T2F_N3F_V3F}{@link #GL_T2F_C4F_N3F_V3F T2F_C4F_N3F_V3F}{@link #GL_T4F_C4F_N3F_V4F T4F_C4F_N3F_V4F}
+ * @param stride the vertex stride in bytes. If specified as zero, then array elements are stored sequentially + * @param pointer the vertex array data + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glInterleavedArrays(@NativeType("GLenum") int format, @NativeType("GLsizei") int stride, @NativeType("void const *") IntBuffer pointer) { + nglInterleavedArrays(format, stride, memAddress(pointer)); + } + + /** + * Efficiently initializes the six vertex arrays and their enables to one of 14 configurations. + * + * @param format the interleaved array format. One of:
{@link #GL_V2F V2F}{@link #GL_V3F V3F}{@link #GL_C4UB_V2F C4UB_V2F}{@link #GL_C4UB_V3F C4UB_V3F}{@link #GL_C3F_V3F C3F_V3F}{@link #GL_N3F_V3F N3F_V3F}{@link #GL_C4F_N3F_V3F C4F_N3F_V3F}{@link #GL_T2F_V3F T2F_V3F}
{@link #GL_T4F_V4F T4F_V4F}{@link #GL_T2F_C4UB_V3F T2F_C4UB_V3F}{@link #GL_T2F_C3F_V3F T2F_C3F_V3F}{@link #GL_T2F_N3F_V3F T2F_N3F_V3F}{@link #GL_T2F_C4F_N3F_V3F T2F_C4F_N3F_V3F}{@link #GL_T4F_C4F_N3F_V4F T4F_C4F_N3F_V4F}
+ * @param stride the vertex stride in bytes. If specified as zero, then array elements are stored sequentially + * @param pointer the vertex array data + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glInterleavedArrays(@NativeType("GLenum") int format, @NativeType("GLsizei") int stride, @NativeType("void const *") FloatBuffer pointer) { + nglInterleavedArrays(format, stride, memAddress(pointer)); + } + + /** + * Efficiently initializes the six vertex arrays and their enables to one of 14 configurations. + * + * @param format the interleaved array format. One of:
{@link #GL_V2F V2F}{@link #GL_V3F V3F}{@link #GL_C4UB_V2F C4UB_V2F}{@link #GL_C4UB_V3F C4UB_V3F}{@link #GL_C3F_V3F C3F_V3F}{@link #GL_N3F_V3F N3F_V3F}{@link #GL_C4F_N3F_V3F C4F_N3F_V3F}{@link #GL_T2F_V3F T2F_V3F}
{@link #GL_T4F_V4F T4F_V4F}{@link #GL_T2F_C4UB_V3F T2F_C4UB_V3F}{@link #GL_T2F_C3F_V3F T2F_C3F_V3F}{@link #GL_T2F_N3F_V3F T2F_N3F_V3F}{@link #GL_T2F_C4F_N3F_V3F T2F_C4F_N3F_V3F}{@link #GL_T4F_C4F_N3F_V4F T4F_C4F_N3F_V4F}
+ * @param stride the vertex stride in bytes. If specified as zero, then array elements are stored sequentially + * @param pointer the vertex array data + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glInterleavedArrays(@NativeType("GLenum") int format, @NativeType("GLsizei") int stride, @NativeType("void const *") DoubleBuffer pointer) { + nglInterleavedArrays(format, stride, memAddress(pointer)); + } + + // --- [ glIsEnabled ] --- + + /** + * Determines if {@code cap} is currently enabled (as with {@link #glEnable Enable}) or disabled. + * + * @param cap the enable state to query + * + * @see Reference Page + */ + @NativeType("GLboolean") + public static boolean glIsEnabled(@NativeType("GLenum") int cap) { + return GL11C.glIsEnabled(cap); + } + + // --- [ glIsList ] --- + + /** + * Returns true if the {@code list} is the index of some display list. + * + * @param list the list index to query + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + @NativeType("GLboolean") + public static native boolean glIsList(@NativeType("GLuint") int list); + + // --- [ glIsTexture ] --- + + /** + * Returns true if {@code texture} is the name of a texture object. + * + * @param texture the texture name to query + * + * @see Reference Page + */ + @NativeType("GLboolean") + public static boolean glIsTexture(@NativeType("GLuint") int texture) { + return GL11C.glIsTexture(texture); + } + + // --- [ glLightModeli ] --- + + /** + * Set the integer value of a lighting model parameter. + * + * @param pname the lighting model parameter to set. One of:
{@link #GL_LIGHT_MODEL_AMBIENT LIGHT_MODEL_AMBIENT}{@link #GL_LIGHT_MODEL_LOCAL_VIEWER LIGHT_MODEL_LOCAL_VIEWER}{@link #GL_LIGHT_MODEL_TWO_SIDE LIGHT_MODEL_TWO_SIDE}
{@link GL12#GL_LIGHT_MODEL_COLOR_CONTROL LIGHT_MODEL_COLOR_CONTROL}
+ * @param param the parameter value + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glLightModeli(@NativeType("GLenum") int pname, @NativeType("GLint") int param); + + // --- [ glLightModelf ] --- + + /** + * Float version of {@link #glLightModeli LightModeli}. + * + * @param pname the lighting model parameter to set + * @param param the parameter value + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glLightModelf(@NativeType("GLenum") int pname, @NativeType("GLfloat") float param); + + // --- [ glLightModeliv ] --- + + /** Unsafe version of: {@link #glLightModeliv LightModeliv} */ + public static native void nglLightModeliv(int pname, long params); + + /** + * Pointer version of {@link #glLightModeli LightModeli}. + * + * @param pname the lighting model parameter to set + * @param params the parameter value + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glLightModeliv(@NativeType("GLenum") int pname, @NativeType("GLint const *") IntBuffer params) { + if (CHECKS) { + check(params, 4); + } + nglLightModeliv(pname, memAddress(params)); + } + + // --- [ glLightModelfv ] --- + + /** Unsafe version of: {@link #glLightModelfv LightModelfv} */ + public static native void nglLightModelfv(int pname, long params); + + /** + * Pointer version of {@link #glLightModelf LightModelf}. + * + * @param pname the lighting model parameter to set + * @param params the parameter value + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glLightModelfv(@NativeType("GLenum") int pname, @NativeType("GLfloat const *") FloatBuffer params) { + if (CHECKS) { + check(params, 4); + } + nglLightModelfv(pname, memAddress(params)); + } + + // --- [ glLighti ] --- + + /** + * Sets the integer value of a light parameter. + * + * @param light the light for which to set the parameter. One of:
{@link #GL_LIGHT0 LIGHT0}GL_LIGHT[1-7]
+ * @param pname the parameter to set. One of:
{@link #GL_AMBIENT AMBIENT}{@link #GL_DIFFUSE DIFFUSE}{@link #GL_SPECULAR SPECULAR}{@link #GL_POSITION POSITION}{@link #GL_CONSTANT_ATTENUATION CONSTANT_ATTENUATION}{@link #GL_LINEAR_ATTENUATION LINEAR_ATTENUATION}
{@link #GL_QUADRATIC_ATTENUATION QUADRATIC_ATTENUATION}{@link #GL_SPOT_DIRECTION SPOT_DIRECTION}{@link #GL_SPOT_EXPONENT SPOT_EXPONENT}{@link #GL_SPOT_CUTOFF SPOT_CUTOFF}
+ * @param param the parameter value + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glLighti(@NativeType("GLenum") int light, @NativeType("GLenum") int pname, @NativeType("GLint") int param); + + // --- [ glLightf ] --- + + /** + * Float version of {@link #glLighti Lighti}. + * + * @param light the light for which to set the parameter + * @param pname the parameter to set + * @param param the parameter value + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glLightf(@NativeType("GLenum") int light, @NativeType("GLenum") int pname, @NativeType("GLfloat") float param); + + // --- [ glLightiv ] --- + + /** Unsafe version of: {@link #glLightiv Lightiv} */ + public static native void nglLightiv(int light, int pname, long params); + + /** + * Pointer version of {@link #glLighti Lighti}. + * + * @param light the light for which to set the parameter + * @param pname the parameter to set + * @param params the parameter value + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glLightiv(@NativeType("GLenum") int light, @NativeType("GLenum") int pname, @NativeType("GLint const *") IntBuffer params) { + if (CHECKS) { + check(params, 4); + } + nglLightiv(light, pname, memAddress(params)); + } + + // --- [ glLightfv ] --- + + /** Unsafe version of: {@link #glLightfv Lightfv} */ + public static native void nglLightfv(int light, int pname, long params); + + /** + * Pointer version of {@link #glLightf Lightf}. + * + * @param light the light for which to set the parameter + * @param pname the parameter to set + * @param params the parameter value + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glLightfv(@NativeType("GLenum") int light, @NativeType("GLenum") int pname, @NativeType("GLfloat const *") FloatBuffer params) { + if (CHECKS) { + check(params, 4); + } + nglLightfv(light, pname, memAddress(params)); + } + + // --- [ glLineStipple ] --- + + /** + * Defines a line stipple. It determines those fragments that are to be drawn when the line is rasterized. Line stippling may be enabled or disabled using + * {@link #glEnable Enable} or {@link #glDisable Disable} with the constant {@link #GL_LINE_STIPPLE LINE_STIPPLE}. When disabled, it is as if the line stipple has its default value. + * + * @param factor a count that is used to modify the effective line stipple by causing each bit in pattern to be used {@code factor} times. {@code factor} is clamped + * to the range [1, 256]. + * @param pattern an unsigned short integer whose 16 bits define the stipple pattern + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glLineStipple(@NativeType("GLint") int factor, @NativeType("GLushort") short pattern); + + // --- [ glLineWidth ] --- + + /** + * Sets the width of rasterized line segments. The default width is 1.0. + * + * @param width the line width + * + * @see Reference Page + */ + public static void glLineWidth(@NativeType("GLfloat") float width) { + GL11C.glLineWidth(width); + } + + // --- [ glListBase ] --- + + /** + * Sets the display list base. + * + * @param base the display list base offset + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glListBase(@NativeType("GLuint") int base); + + // --- [ glLoadMatrixf ] --- + + /** Unsafe version of: {@link #glLoadMatrixf LoadMatrixf} */ + public static native void nglLoadMatrixf(long m); + + /** + * Sets the current matrix to a 4 × 4 matrix in column-major order. + * + *

The matrix is stored as 16 consecutive values, i.e. as:

+ * + * + * + * + * + * + *
a1a5a9a13
a2a6a10a14
a3a7a11a15
a4a8a12a16
+ * + *

This differs from the standard row-major ordering for matrix elements. If the standard ordering is used, all of the subsequent transformation equations + * are transposed, and the columns representing vectors become rows.

+ * + * @param m the matrix data + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glLoadMatrixf(@NativeType("GLfloat const *") FloatBuffer m) { + if (CHECKS) { + check(m, 16); + } + nglLoadMatrixf(memAddress(m)); + } + + // --- [ glLoadMatrixd ] --- + + /** Unsafe version of: {@link #glLoadMatrixd LoadMatrixd} */ + public static native void nglLoadMatrixd(long m); + + /** + * Double version of {@link #glLoadMatrixf LoadMatrixf}. + * + * @param m the matrix data + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glLoadMatrixd(@NativeType("GLdouble const *") DoubleBuffer m) { + if (CHECKS) { + check(m, 16); + } + nglLoadMatrixd(memAddress(m)); + } + + // --- [ glLoadIdentity ] --- + + /** + * Sets the current matrix to the identity matrix. + * + *

Calling this function is equivalent to calling {@link #glLoadMatrixf LoadMatrixf} with the following matrix:

+ * + * + * + * + * + * + *
1000
0100
0010
0001
+ * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glLoadIdentity(); + + // --- [ glLoadName ] --- + + /** + * Replaces the value on the top of the selection stack with {@code name}. + * + * @param name the name to load + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glLoadName(@NativeType("GLuint") int name); + + // --- [ glLogicOp ] --- + + /** + * Sets the logical framebuffer operation. + * + * @param op the operation to set. One of:
{@link GL11C#GL_CLEAR CLEAR}{@link GL11C#GL_AND AND}{@link GL11C#GL_AND_REVERSE AND_REVERSE}{@link GL11C#GL_COPY COPY}{@link GL11C#GL_AND_INVERTED AND_INVERTED}{@link GL11C#GL_NOOP NOOP}{@link GL11C#GL_XOR XOR}{@link GL11C#GL_OR OR}{@link GL11C#GL_NOR NOR}{@link GL11C#GL_EQUIV EQUIV}{@link GL11C#GL_INVERT INVERT}{@link GL11C#GL_OR_REVERSE OR_REVERSE}{@link GL11C#GL_COPY_INVERTED COPY_INVERTED}
{@link GL11C#GL_OR_INVERTED OR_INVERTED}{@link GL11C#GL_NAND NAND}{@link GL11C#GL_SET SET}
+ * + * @see Reference Page + */ + public static void glLogicOp(@NativeType("GLenum") int op) { + GL11C.glLogicOp(op); + } + + // --- [ glMap1f ] --- + + /** Unsafe version of: {@link #glMap1f Map1f} */ + public static native void nglMap1f(int target, float u1, float u2, int stride, int order, long points); + + /** + * Defines a polynomial or rational polynomial mapping to produce vertex, normal, texture coordinates and colors. The values so produced are sent on to + * further stages of the GL as if they had been provided directly by the client. + * + * @param target the evaluator target. One of:
{@link #GL_MAP1_VERTEX_3 MAP1_VERTEX_3}{@link #GL_MAP1_VERTEX_4 MAP1_VERTEX_4}{@link #GL_MAP1_COLOR_4 MAP1_COLOR_4}{@link #GL_MAP1_NORMAL MAP1_NORMAL}{@link #GL_MAP1_TEXTURE_COORD_1 MAP1_TEXTURE_COORD_1}
{@link #GL_MAP1_TEXTURE_COORD_2 MAP1_TEXTURE_COORD_2}{@link #GL_MAP1_TEXTURE_COORD_3 MAP1_TEXTURE_COORD_3}{@link #GL_MAP1_TEXTURE_COORD_4 MAP1_TEXTURE_COORD_4}
+ * @param u1 the first endpoint of the pre-image of the map + * @param u2 the second endpoint of the pre-image of the map + * @param stride the number of values in each block of storage + * @param order the polynomial order + * @param points a set of {@code order} blocks of storage containing control points + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glMap1f(@NativeType("GLenum") int target, @NativeType("GLfloat") float u1, @NativeType("GLfloat") float u2, @NativeType("GLint") int stride, @NativeType("GLint") int order, @NativeType("GLfloat const *") FloatBuffer points) { + if (CHECKS) { + check(points, order * stride); + } + nglMap1f(target, u1, u2, stride, order, memAddress(points)); + } + + // --- [ glMap1d ] --- + + /** Unsafe version of: {@link #glMap1d Map1d} */ + public static native void nglMap1d(int target, double u1, double u2, int stride, int order, long points); + + /** + * Double version of {@link #glMap1f Map1f}. + * + * @param target the evaluator target + * @param u1 the first endpoint of the pre-image of the map + * @param u2 the second endpoint of the pre-image of the map + * @param stride the number of values in each block of storage + * @param order the polynomial order + * @param points a set of {@code order} blocks of storage containing control points + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glMap1d(@NativeType("GLenum") int target, @NativeType("GLdouble") double u1, @NativeType("GLdouble") double u2, @NativeType("GLint") int stride, @NativeType("GLint") int order, @NativeType("GLdouble const *") DoubleBuffer points) { + if (CHECKS) { + check(points, stride * order); + } + nglMap1d(target, u1, u2, stride, order, memAddress(points)); + } + + // --- [ glMap2f ] --- + + /** Unsafe version of: {@link #glMap2f Map2f} */ + public static native void nglMap2f(int target, float u1, float u2, int ustride, int uorder, float v1, float v2, int vstride, int vorder, long points); + + /** + * Bivariate version of {@link #glMap1f Map1f}. + * + * @param target the evaluator target + * @param u1 the first u-dimension endpoint of the pre-image rectangle of the map + * @param u2 the second u-dimension endpoint of the pre-image rectangle of the map + * @param ustride the number of values in the u-dimension in each block of storage + * @param uorder the polynomial order in the u-dimension + * @param v1 the first v-dimension endpoint of the pre-image rectangle of the map + * @param v2 the second v-dimension endpoint of the pre-image rectangle of the map + * @param vstride the number of values in the v-dimension in each block of storage + * @param vorder the polynomial order in the v-dimension + * @param points a set of uorder × vorder blocks of storage containing control points + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glMap2f(@NativeType("GLenum") int target, @NativeType("GLfloat") float u1, @NativeType("GLfloat") float u2, @NativeType("GLint") int ustride, @NativeType("GLint") int uorder, @NativeType("GLfloat") float v1, @NativeType("GLfloat") float v2, @NativeType("GLint") int vstride, @NativeType("GLint") int vorder, @NativeType("GLfloat const *") FloatBuffer points) { + if (CHECKS) { + check(points, ustride * uorder * vstride * vorder); + } + nglMap2f(target, u1, u2, ustride, uorder, v1, v2, vstride, vorder, memAddress(points)); + } + + // --- [ glMap2d ] --- + + /** Unsafe version of: {@link #glMap2d Map2d} */ + public static native void nglMap2d(int target, double u1, double u2, int ustride, int uorder, double v1, double v2, int vstride, int vorder, long points); + + /** + * Double version of {@link #glMap2f Map2f}. + * + * @param target the evaluator target + * @param u1 the first u-dimension endpoint of the pre-image rectangle of the map + * @param u2 the second u-dimension endpoint of the pre-image rectangle of the map + * @param ustride the number of values in the u-dimension in each block of storage + * @param uorder the polynomial order in the u-dimension + * @param v1 the first v-dimension endpoint of the pre-image rectangle of the map + * @param v2 the second v-dimension endpoint of the pre-image rectangle of the map + * @param vstride the number of values in the v-dimension in each block of storage + * @param vorder the polynomial order in the v-dimension + * @param points a set of uorder × vorder blocks of storage containing control points + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glMap2d(@NativeType("GLenum") int target, @NativeType("GLdouble") double u1, @NativeType("GLdouble") double u2, @NativeType("GLint") int ustride, @NativeType("GLint") int uorder, @NativeType("GLdouble") double v1, @NativeType("GLdouble") double v2, @NativeType("GLint") int vstride, @NativeType("GLint") int vorder, @NativeType("GLdouble const *") DoubleBuffer points) { + if (CHECKS) { + check(points, ustride * uorder * vstride * vorder); + } + nglMap2d(target, u1, u2, ustride, uorder, v1, v2, vstride, vorder, memAddress(points)); + } + + // --- [ glMapGrid1f ] --- + + /** + * Defines a one-dimensional grid in the map evaluator domain. + * + * @param n the number of partitions of the interval + * @param u1 the first interval endpoint + * @param u2 the second interval endpoint + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glMapGrid1f(@NativeType("GLint") int n, @NativeType("GLfloat") float u1, @NativeType("GLfloat") float u2); + + // --- [ glMapGrid1d ] --- + + /** + * Double version of {@link #glMapGrid1f MapGrid1f}. + * + * @param n the number of partitions of the interval + * @param u1 the first interval endpoint + * @param u2 the second interval endpoint + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glMapGrid1d(@NativeType("GLint") int n, @NativeType("GLdouble") double u1, @NativeType("GLdouble") double u2); + + // --- [ glMapGrid2f ] --- + + /** + * Defines a two-dimensional grid in the map evaluator domain. + * + * @param un the number of partitions of the interval in the u-dimension + * @param u1 the first u-dimension interval endpoint + * @param u2 the second u-dimension interval endpoint + * @param vn the number of partitions of the interval in the v-dimension + * @param v1 the first v-dimension interval endpoint + * @param v2 the second v-dimension interval endpoint + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glMapGrid2f(@NativeType("GLint") int un, @NativeType("GLfloat") float u1, @NativeType("GLfloat") float u2, @NativeType("GLint") int vn, @NativeType("GLfloat") float v1, @NativeType("GLfloat") float v2); + + // --- [ glMapGrid2d ] --- + + /** + * Double version of {@link #glMapGrid2f MapGrid2f}. + * + * @param un the number of partitions of the interval in the u-dimension + * @param u1 the first u-dimension interval endpoint + * @param u2 the second u-dimension interval endpoint + * @param vn the number of partitions of the interval in the v-dimension + * @param v1 the first v-dimension interval endpoint + * @param v2 the second v-dimension interval endpoint + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glMapGrid2d(@NativeType("GLint") int un, @NativeType("GLdouble") double u1, @NativeType("GLdouble") double u2, @NativeType("GLint") int vn, @NativeType("GLdouble") double v1, @NativeType("GLdouble") double v2); + + // --- [ glMateriali ] --- + + /** + * Sets the integer value of a material parameter. + * + * @param face the material face for which to set the parameter. One of:
{@link #GL_FRONT FRONT}{@link #GL_BACK BACK}{@link #GL_FRONT_AND_BACK FRONT_AND_BACK}
+ * @param pname the parameter to set. Must be:
{@link #GL_SHININESS SHININESS}
+ * @param param the parameter value + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glMateriali(@NativeType("GLenum") int face, @NativeType("GLenum") int pname, @NativeType("GLint") int param); + + // --- [ glMaterialf ] --- + + /** + * Float version of {@link #glMateriali Materiali}. + * + * @param face the material face for which to set the parameter + * @param pname the parameter to set + * @param param the parameter value + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glMaterialf(@NativeType("GLenum") int face, @NativeType("GLenum") int pname, @NativeType("GLfloat") float param); + + // --- [ glMaterialiv ] --- + + /** Unsafe version of: {@link #glMaterialiv Materialiv} */ + public static native void nglMaterialiv(int face, int pname, long params); + + /** + * Pointer version of {@link #glMateriali Materiali}. + * + * @param face the material face for which to set the parameter + * @param pname the parameter to set. One of:
{@link #GL_AMBIENT AMBIENT}{@link #GL_DIFFUSE DIFFUSE}{@link #GL_AMBIENT_AND_DIFFUSE AMBIENT_AND_DIFFUSE}{@link #GL_SPECULAR SPECULAR}{@link #GL_EMISSION EMISSION}
+ * @param params the parameter value + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glMaterialiv(@NativeType("GLenum") int face, @NativeType("GLenum") int pname, @NativeType("GLint const *") IntBuffer params) { + if (CHECKS) { + check(params, 4); + } + nglMaterialiv(face, pname, memAddress(params)); + } + + // --- [ glMaterialfv ] --- + + /** Unsafe version of: {@link #glMaterialfv Materialfv} */ + public static native void nglMaterialfv(int face, int pname, long params); + + /** + * Pointer version of {@link #glMaterialf Materialf}. + * + * @param face the material face for which to set the parameter + * @param pname the parameter to set + * @param params the parameter value + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glMaterialfv(@NativeType("GLenum") int face, @NativeType("GLenum") int pname, @NativeType("GLfloat const *") FloatBuffer params) { + if (CHECKS) { + check(params, 4); + } + nglMaterialfv(face, pname, memAddress(params)); + } + + // --- [ glMatrixMode ] --- + + /** + * Set the current matrix mode. + * + * @param mode the matrix mode. One of:
{@link #GL_MODELVIEW MODELVIEW}{@link #GL_PROJECTION PROJECTION}{@link #GL_TEXTURE TEXTURE}{@link #GL_COLOR COLOR}
+ * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glMatrixMode(@NativeType("GLenum") int mode); + + // --- [ glMultMatrixf ] --- + + /** Unsafe version of: {@link #glMultMatrixf MultMatrixf} */ + public static native void nglMultMatrixf(long m); + + /** + * Multiplies the current matrix with a 4 × 4 matrix in column-major order. See {@link #glLoadMatrixf LoadMatrixf} for details. + * + * @param m the matrix data + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glMultMatrixf(@NativeType("GLfloat const *") FloatBuffer m) { + if (CHECKS) { + check(m, 16); + } + nglMultMatrixf(memAddress(m)); + } + + // --- [ glMultMatrixd ] --- + + /** Unsafe version of: {@link #glMultMatrixd MultMatrixd} */ + public static native void nglMultMatrixd(long m); + + /** + * Double version of {@link #glMultMatrixf MultMatrixf}. + * + * @param m the matrix data + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glMultMatrixd(@NativeType("GLdouble const *") DoubleBuffer m) { + if (CHECKS) { + check(m, 16); + } + nglMultMatrixd(memAddress(m)); + } + + // --- [ glFrustum ] --- + + /** + * Manipulates the current matrix with a matrix that produces perspective projection, in such a way that the coordinates (lb – n)T + * and (rt – n)T specify the points on the near clipping plane that are mapped to the lower left and upper right corners of the + * window, respectively (assuming that the eye is located at (0 0 0)T). {@code f} gives the distance from the eye to the far clipping + * plane. + * + *

Calling this function is equivalent to calling {@link #glMultMatrixf MultMatrixf} with the following matrix:

+ * + * + * + * + * + * + *
2n / (r - l)0(r + l) / (r - l)0
02n / (t - b)(t + b) / (t - b)0
00- (f + n) / (f - n)- (2fn) / (f - n)
00-10
+ * + * @param l the left frustum plane + * @param r the right frustum plane + * @param b the bottom frustum plane + * @param t the top frustum plane + * @param n the near frustum plane + * @param f the far frustum plane + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glFrustum(@NativeType("GLdouble") double l, @NativeType("GLdouble") double r, @NativeType("GLdouble") double b, @NativeType("GLdouble") double t, @NativeType("GLdouble") double n, @NativeType("GLdouble") double f); + + // --- [ glNewList ] --- + + /** + * Begins the definition of a display list. + * + * @param n a positive integer to which the display list that follows is assigned + * @param mode a symbolic constant that controls the behavior of the GL during display list creation. One of:
{@link #GL_COMPILE COMPILE}{@link #GL_COMPILE_AND_EXECUTE COMPILE_AND_EXECUTE}
+ * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glNewList(@NativeType("GLuint") int n, @NativeType("GLenum") int mode); + + // --- [ glEndList ] --- + + /** + * Ends the definition of GL commands to be placed in a display list. It is only when {@code EndList} occurs that the specified display list is actually + * associated with the index indicated with {@link #glNewList NewList}. + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glEndList(); + + // --- [ glNormal3f ] --- + + /** + * Sets the current normal. + * + * @param nx the x coordinate of the current normal + * @param ny the y coordinate of the current normal + * @param nz the z coordinate of the current normal + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glNormal3f(@NativeType("GLfloat") float nx, @NativeType("GLfloat") float ny, @NativeType("GLfloat") float nz); + + // --- [ glNormal3b ] --- + + /** + * Byte version of {@link #glNormal3f Normal3f}. + * + * @param nx the x coordinate of the current normal + * @param ny the y coordinate of the current normal + * @param nz the z coordinate of the current normal + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glNormal3b(@NativeType("GLbyte") byte nx, @NativeType("GLbyte") byte ny, @NativeType("GLbyte") byte nz); + + // --- [ glNormal3s ] --- + + /** + * Short version of {@link #glNormal3f Normal3f}. + * + * @param nx the x coordinate of the current normal + * @param ny the y coordinate of the current normal + * @param nz the z coordinate of the current normal + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glNormal3s(@NativeType("GLshort") short nx, @NativeType("GLshort") short ny, @NativeType("GLshort") short nz); + + // --- [ glNormal3i ] --- + + /** + * Integer version of {@link #glNormal3f Normal3f}. + * + * @param nx the x coordinate of the current normal + * @param ny the y coordinate of the current normal + * @param nz the z coordinate of the current normal + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glNormal3i(@NativeType("GLint") int nx, @NativeType("GLint") int ny, @NativeType("GLint") int nz); + + // --- [ glNormal3d ] --- + + /** + * Double version of {@link #glNormal3f Normal3f}. + * + * @param nx the x coordinate of the current normal + * @param ny the y coordinate of the current normal + * @param nz the z coordinate of the current normal + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glNormal3d(@NativeType("GLdouble") double nx, @NativeType("GLdouble") double ny, @NativeType("GLdouble") double nz); + + // --- [ glNormal3fv ] --- + + /** Unsafe version of: {@link #glNormal3fv Normal3fv} */ + public static native void nglNormal3fv(long v); + + /** + * Pointer version of {@link #glNormal3f Normal3f}. + * + * @param v the normal buffer + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glNormal3fv(@NativeType("GLfloat const *") FloatBuffer v) { + if (CHECKS) { + check(v, 3); + } + nglNormal3fv(memAddress(v)); + } + + // --- [ glNormal3bv ] --- + + /** Unsafe version of: {@link #glNormal3bv Normal3bv} */ + public static native void nglNormal3bv(long v); + + /** + * Pointer version of {@link #glNormal3b Normal3b}. + * + * @param v the normal buffer + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glNormal3bv(@NativeType("GLbyte const *") ByteBuffer v) { + if (CHECKS) { + check(v, 3); + } + nglNormal3bv(memAddress(v)); + } + + // --- [ glNormal3sv ] --- + + /** Unsafe version of: {@link #glNormal3sv Normal3sv} */ + public static native void nglNormal3sv(long v); + + /** + * Pointer version of {@link #glNormal3s Normal3s}. + * + * @param v the normal buffer + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glNormal3sv(@NativeType("GLshort const *") ShortBuffer v) { + if (CHECKS) { + check(v, 3); + } + nglNormal3sv(memAddress(v)); + } + + // --- [ glNormal3iv ] --- + + /** Unsafe version of: {@link #glNormal3iv Normal3iv} */ + public static native void nglNormal3iv(long v); + + /** + * Pointer version of {@link #glNormal3i Normal3i}. + * + * @param v the normal buffer + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glNormal3iv(@NativeType("GLint const *") IntBuffer v) { + if (CHECKS) { + check(v, 3); + } + nglNormal3iv(memAddress(v)); + } + + // --- [ glNormal3dv ] --- + + /** Unsafe version of: {@link #glNormal3dv Normal3dv} */ + public static native void nglNormal3dv(long v); + + /** + * Pointer version of {@link #glNormal3d Normal3d}. + * + * @param v the normal buffer + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glNormal3dv(@NativeType("GLdouble const *") DoubleBuffer v) { + if (CHECKS) { + check(v, 3); + } + nglNormal3dv(memAddress(v)); + } + + // --- [ glNormalPointer ] --- + + /** Unsafe version of: {@link #glNormalPointer NormalPointer} */ + public static native void nglNormalPointer(int type, int stride, long pointer); + + /** + * Specifies the location and organization of a normal array. + * + * @param type the data type of the values stored in the array. One of:
{@link #GL_BYTE BYTE}{@link #GL_SHORT SHORT}{@link #GL_INT INT}{@link GL30#GL_HALF_FLOAT HALF_FLOAT}{@link #GL_FLOAT FLOAT}{@link #GL_DOUBLE DOUBLE}{@link GL12#GL_UNSIGNED_INT_2_10_10_10_REV UNSIGNED_INT_2_10_10_10_REV}{@link GL33#GL_INT_2_10_10_10_REV INT_2_10_10_10_REV}
+ * @param stride the vertex stride in bytes. If specified as zero, then array elements are stored sequentially + * @param pointer the normal array data + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glNormalPointer(@NativeType("GLenum") int type, @NativeType("GLsizei") int stride, @NativeType("void const *") ByteBuffer pointer) { + nglNormalPointer(type, stride, memAddress(pointer)); + } + + /** + * Specifies the location and organization of a normal array. + * + * @param type the data type of the values stored in the array. One of:
{@link #GL_BYTE BYTE}{@link #GL_SHORT SHORT}{@link #GL_INT INT}{@link GL30#GL_HALF_FLOAT HALF_FLOAT}{@link #GL_FLOAT FLOAT}{@link #GL_DOUBLE DOUBLE}{@link GL12#GL_UNSIGNED_INT_2_10_10_10_REV UNSIGNED_INT_2_10_10_10_REV}{@link GL33#GL_INT_2_10_10_10_REV INT_2_10_10_10_REV}
+ * @param stride the vertex stride in bytes. If specified as zero, then array elements are stored sequentially + * @param pointer the normal array data + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glNormalPointer(@NativeType("GLenum") int type, @NativeType("GLsizei") int stride, @NativeType("void const *") long pointer) { + nglNormalPointer(type, stride, pointer); + } + + /** + * Specifies the location and organization of a normal array. + * + * @param type the data type of the values stored in the array. One of:
{@link #GL_BYTE BYTE}{@link #GL_SHORT SHORT}{@link #GL_INT INT}{@link GL30#GL_HALF_FLOAT HALF_FLOAT}{@link #GL_FLOAT FLOAT}{@link #GL_DOUBLE DOUBLE}{@link GL12#GL_UNSIGNED_INT_2_10_10_10_REV UNSIGNED_INT_2_10_10_10_REV}{@link GL33#GL_INT_2_10_10_10_REV INT_2_10_10_10_REV}
+ * @param stride the vertex stride in bytes. If specified as zero, then array elements are stored sequentially + * @param pointer the normal array data + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glNormalPointer(@NativeType("GLenum") int type, @NativeType("GLsizei") int stride, @NativeType("void const *") ShortBuffer pointer) { + nglNormalPointer(type, stride, memAddress(pointer)); + } + + /** + * Specifies the location and organization of a normal array. + * + * @param type the data type of the values stored in the array. One of:
{@link #GL_BYTE BYTE}{@link #GL_SHORT SHORT}{@link #GL_INT INT}{@link GL30#GL_HALF_FLOAT HALF_FLOAT}{@link #GL_FLOAT FLOAT}{@link #GL_DOUBLE DOUBLE}{@link GL12#GL_UNSIGNED_INT_2_10_10_10_REV UNSIGNED_INT_2_10_10_10_REV}{@link GL33#GL_INT_2_10_10_10_REV INT_2_10_10_10_REV}
+ * @param stride the vertex stride in bytes. If specified as zero, then array elements are stored sequentially + * @param pointer the normal array data + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glNormalPointer(@NativeType("GLenum") int type, @NativeType("GLsizei") int stride, @NativeType("void const *") IntBuffer pointer) { + nglNormalPointer(type, stride, memAddress(pointer)); + } + + /** + * Specifies the location and organization of a normal array. + * + * @param type the data type of the values stored in the array. One of:
{@link #GL_BYTE BYTE}{@link #GL_SHORT SHORT}{@link #GL_INT INT}{@link GL30#GL_HALF_FLOAT HALF_FLOAT}{@link #GL_FLOAT FLOAT}{@link #GL_DOUBLE DOUBLE}{@link GL12#GL_UNSIGNED_INT_2_10_10_10_REV UNSIGNED_INT_2_10_10_10_REV}{@link GL33#GL_INT_2_10_10_10_REV INT_2_10_10_10_REV}
+ * @param stride the vertex stride in bytes. If specified as zero, then array elements are stored sequentially + * @param pointer the normal array data + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glNormalPointer(@NativeType("GLenum") int type, @NativeType("GLsizei") int stride, @NativeType("void const *") FloatBuffer pointer) { + nglNormalPointer(type, stride, memAddress(pointer)); + } + + // --- [ glOrtho ] --- + + /** + * Manipulates the current matrix with a matrix that produces parallel projection, in such a way that the coordinates (lb – n)T + * and (rt – n)T specify the points on the near clipping plane that are mapped to the lower left and upper right corners of the + * window, respectively (assuming that the eye is located at (0 0 0)T). {@code f} gives the distance from the eye to the far clipping + * plane. + * + *

Calling this function is equivalent to calling {@link #glMultMatrixf MultMatrixf} with the following matrix:

+ * + * + * + * + * + * + *
2 / (r - l)00- (r + l) / (r - l)
02 / (t - b)0- (t + b) / (t - b)
00- 2 / (f - n)- (f + n) / (f - n)
0001
+ * + * @param l the left frustum plane + * @param r the right frustum plane + * @param b the bottom frustum plane + * @param t the top frustum plane + * @param n the near frustum plane + * @param f the far frustum plane + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glOrtho(@NativeType("GLdouble") double l, @NativeType("GLdouble") double r, @NativeType("GLdouble") double b, @NativeType("GLdouble") double t, @NativeType("GLdouble") double n, @NativeType("GLdouble") double f); + + // --- [ glPassThrough ] --- + + /** + * Inserts a marker when the GL is in feeback mode. {@code token} is returned as if it were a primitive; it is indicated with its own unique identifying + * value. The ordering of any {@code PassThrough} commands with respect to primitive specification is maintained by feedback. {@code PassThrough} may + * not occur between {@link #glBegin Begin} and {@link #glEnd End}. + * + * @param token the marker value to insert + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glPassThrough(@NativeType("GLfloat") float token); + + // --- [ glPixelMapfv ] --- + + /** + * Unsafe version of: {@link #glPixelMapfv PixelMapfv} + * + * @param size the map size + */ + public static native void nglPixelMapfv(int map, int size, long values); + + /** + * Sets a pixel map lookup table. + * + * @param map the map to set. One of:
{@link #GL_PIXEL_MAP_I_TO_I PIXEL_MAP_I_TO_I}{@link #GL_PIXEL_MAP_S_TO_S PIXEL_MAP_S_TO_S}{@link #GL_PIXEL_MAP_I_TO_R PIXEL_MAP_I_TO_R}{@link #GL_PIXEL_MAP_I_TO_G PIXEL_MAP_I_TO_G}{@link #GL_PIXEL_MAP_I_TO_B PIXEL_MAP_I_TO_B}
{@link #GL_PIXEL_MAP_I_TO_A PIXEL_MAP_I_TO_A}{@link #GL_PIXEL_MAP_R_TO_R PIXEL_MAP_R_TO_R}{@link #GL_PIXEL_MAP_G_TO_G PIXEL_MAP_G_TO_G}{@link #GL_PIXEL_MAP_B_TO_B PIXEL_MAP_B_TO_B}{@link #GL_PIXEL_MAP_A_TO_A PIXEL_MAP_A_TO_A}
+ * @param size the map size + * @param values the map values + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glPixelMapfv(@NativeType("GLenum") int map, @NativeType("GLsizei") int size, @NativeType("GLfloat const *") long values) { + nglPixelMapfv(map, size, values); + } + + /** + * Sets a pixel map lookup table. + * + * @param map the map to set. One of:
{@link #GL_PIXEL_MAP_I_TO_I PIXEL_MAP_I_TO_I}{@link #GL_PIXEL_MAP_S_TO_S PIXEL_MAP_S_TO_S}{@link #GL_PIXEL_MAP_I_TO_R PIXEL_MAP_I_TO_R}{@link #GL_PIXEL_MAP_I_TO_G PIXEL_MAP_I_TO_G}{@link #GL_PIXEL_MAP_I_TO_B PIXEL_MAP_I_TO_B}
{@link #GL_PIXEL_MAP_I_TO_A PIXEL_MAP_I_TO_A}{@link #GL_PIXEL_MAP_R_TO_R PIXEL_MAP_R_TO_R}{@link #GL_PIXEL_MAP_G_TO_G PIXEL_MAP_G_TO_G}{@link #GL_PIXEL_MAP_B_TO_B PIXEL_MAP_B_TO_B}{@link #GL_PIXEL_MAP_A_TO_A PIXEL_MAP_A_TO_A}
+ * @param values the map values + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glPixelMapfv(@NativeType("GLenum") int map, @NativeType("GLfloat const *") FloatBuffer values) { + nglPixelMapfv(map, values.remaining(), memAddress(values)); + } + + // --- [ glPixelMapusv ] --- + + /** + * Unsafe version of: {@link #glPixelMapusv PixelMapusv} + * + * @param size the map size + */ + public static native void nglPixelMapusv(int map, int size, long values); + + /** + * Unsigned short version of {@link #glPixelMapfv PixelMapfv}. + * + * @param map the map to set + * @param size the map size + * @param values the map values + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glPixelMapusv(@NativeType("GLenum") int map, @NativeType("GLsizei") int size, @NativeType("GLushort const *") long values) { + nglPixelMapusv(map, size, values); + } + + /** + * Unsigned short version of {@link #glPixelMapfv PixelMapfv}. + * + * @param map the map to set + * @param values the map values + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glPixelMapusv(@NativeType("GLenum") int map, @NativeType("GLushort const *") ShortBuffer values) { + nglPixelMapusv(map, values.remaining(), memAddress(values)); + } + + // --- [ glPixelMapuiv ] --- + + /** + * Unsafe version of: {@link #glPixelMapuiv PixelMapuiv} + * + * @param size the map size + */ + public static native void nglPixelMapuiv(int map, int size, long values); + + /** + * Unsigned integer version of {@link #glPixelMapfv PixelMapfv}. + * + * @param map the map to set + * @param size the map size + * @param values the map values + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glPixelMapuiv(@NativeType("GLenum") int map, @NativeType("GLsizei") int size, @NativeType("GLuint const *") long values) { + nglPixelMapuiv(map, size, values); + } + + /** + * Unsigned integer version of {@link #glPixelMapfv PixelMapfv}. + * + * @param map the map to set + * @param values the map values + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glPixelMapuiv(@NativeType("GLenum") int map, @NativeType("GLuint const *") IntBuffer values) { + nglPixelMapuiv(map, values.remaining(), memAddress(values)); + } + + // --- [ glPixelStorei ] --- + + /** + * Sets the integer value of a pixel store parameter. + * + * @param pname the pixel store parameter to set. One of:
{@link GL11C#GL_UNPACK_SWAP_BYTES UNPACK_SWAP_BYTES}{@link GL11C#GL_UNPACK_LSB_FIRST UNPACK_LSB_FIRST}{@link GL11C#GL_UNPACK_ROW_LENGTH UNPACK_ROW_LENGTH}
{@link GL11C#GL_UNPACK_SKIP_ROWS UNPACK_SKIP_ROWS}{@link GL11C#GL_UNPACK_SKIP_PIXELS UNPACK_SKIP_PIXELS}{@link GL11C#GL_UNPACK_ALIGNMENT UNPACK_ALIGNMENT}
{@link GL12#GL_UNPACK_IMAGE_HEIGHT UNPACK_IMAGE_HEIGHT}{@link GL12#GL_UNPACK_SKIP_IMAGES UNPACK_SKIP_IMAGES}{@link GL42#GL_UNPACK_COMPRESSED_BLOCK_WIDTH UNPACK_COMPRESSED_BLOCK_WIDTH}
{@link GL42#GL_UNPACK_COMPRESSED_BLOCK_HEIGHT UNPACK_COMPRESSED_BLOCK_HEIGHT}{@link GL42#GL_UNPACK_COMPRESSED_BLOCK_DEPTH UNPACK_COMPRESSED_BLOCK_DEPTH}{@link GL42#GL_UNPACK_COMPRESSED_BLOCK_SIZE UNPACK_COMPRESSED_BLOCK_SIZE}
+ * @param param the parameter value + * + * @see Reference Page + */ + public static void glPixelStorei(@NativeType("GLenum") int pname, @NativeType("GLint") int param) { + GL11C.glPixelStorei(pname, param); + } + + // --- [ glPixelStoref ] --- + + /** + * Float version of {@link #glPixelStorei PixelStorei}. + * + * @param pname the pixel store parameter to set + * @param param the parameter value + * + * @see Reference Page + */ + public static void glPixelStoref(@NativeType("GLenum") int pname, @NativeType("GLfloat") float param) { + GL11C.glPixelStoref(pname, param); + } + + // --- [ glPixelTransferi ] --- + + /** + * Sets the integer value of a pixel transfer parameter. + * + * @param pname the pixel transfer parameter to set. One of:
{@link #GL_MAP_COLOR MAP_COLOR}{@link #GL_MAP_STENCIL MAP_STENCIL}{@link #GL_INDEX_SHIFT INDEX_SHIFT}{@link #GL_INDEX_OFFSET INDEX_OFFSET}
{@link #GL_RED_SCALE RED_SCALE}{@link #GL_GREEN_SCALE GREEN_SCALE}{@link #GL_BLUE_SCALE BLUE_SCALE}{@link #GL_ALPHA_SCALE ALPHA_SCALE}
{@link #GL_DEPTH_SCALE DEPTH_SCALE}{@link #GL_RED_BIAS RED_BIAS}{@link #GL_GREEN_BIAS GREEN_BIAS}{@link #GL_BLUE_BIAS BLUE_BIAS}
{@link #GL_ALPHA_BIAS ALPHA_BIAS}{@link #GL_DEPTH_BIAS DEPTH_BIAS}{@link ARBImaging#GL_POST_CONVOLUTION_RED_SCALE POST_CONVOLUTION_RED_SCALE}{@link ARBImaging#GL_POST_CONVOLUTION_RED_BIAS POST_CONVOLUTION_RED_BIAS}
{@link ARBImaging#GL_POST_COLOR_MATRIX_RED_SCALE POST_COLOR_MATRIX_RED_SCALE}{@link ARBImaging#GL_POST_COLOR_MATRIX_RED_BIAS POST_COLOR_MATRIX_RED_BIAS}{@link ARBImaging#GL_POST_CONVOLUTION_GREEN_SCALE POST_CONVOLUTION_GREEN_SCALE}{@link ARBImaging#GL_POST_CONVOLUTION_GREEN_BIAS POST_CONVOLUTION_GREEN_BIAS}
{@link ARBImaging#GL_POST_COLOR_MATRIX_GREEN_SCALE POST_COLOR_MATRIX_GREEN_SCALE}{@link ARBImaging#GL_POST_COLOR_MATRIX_GREEN_BIAS POST_COLOR_MATRIX_GREEN_BIAS}{@link ARBImaging#GL_POST_CONVOLUTION_BLUE_SCALE POST_CONVOLUTION_BLUE_SCALE}{@link ARBImaging#GL_POST_CONVOLUTION_BLUE_BIAS POST_CONVOLUTION_BLUE_BIAS}
{@link ARBImaging#GL_POST_COLOR_MATRIX_BLUE_SCALE POST_COLOR_MATRIX_BLUE_SCALE}{@link ARBImaging#GL_POST_COLOR_MATRIX_BLUE_BIAS POST_COLOR_MATRIX_BLUE_BIAS}{@link ARBImaging#GL_POST_CONVOLUTION_ALPHA_SCALE POST_CONVOLUTION_ALPHA_SCALE}{@link ARBImaging#GL_POST_CONVOLUTION_ALPHA_BIAS POST_CONVOLUTION_ALPHA_BIAS}
{@link ARBImaging#GL_POST_COLOR_MATRIX_ALPHA_SCALE POST_COLOR_MATRIX_ALPHA_SCALE}{@link ARBImaging#GL_POST_COLOR_MATRIX_ALPHA_BIAS POST_COLOR_MATRIX_ALPHA_BIAS}
+ * @param param the parameter value + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glPixelTransferi(@NativeType("GLenum") int pname, @NativeType("GLint") int param); + + // --- [ glPixelTransferf ] --- + + /** + * Float version of {@link #glPixelTransferi PixelTransferi}. + * + * @param pname the pixel transfer parameter to set + * @param param the parameter value + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glPixelTransferf(@NativeType("GLenum") int pname, @NativeType("GLfloat") float param); + + // --- [ glPixelZoom ] --- + + /** + * Controls the conversion of a group of fragments. + * + *

Let (xrp, yrp) be the current raster position. If a particular group is the nth in a row and belongs to the + * mth row, consider the region in window coordinates bounded by the rectangle with corners

+ * + *

(xrp + zxn, yrp + zym) and (xrp + zx(n + 1), yrp + zy(m + 1))

+ * + *

(either zx or zy may be negative). A fragment representing group {@code (n, m)} is produced for each framebuffer pixel inside, or + * on the bottom or left boundary, of this rectangle.

+ * + * @param xfactor the zx factor + * @param yfactor the zy factor + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glPixelZoom(@NativeType("GLfloat") float xfactor, @NativeType("GLfloat") float yfactor); + + // --- [ glPointSize ] --- + + /** + * Controls the rasterization of points if no vertex, tessellation control, tessellation evaluation, or geometry shader is active. The default point size is 1.0. + * + * @param size the request size of a point + * + * @see Reference Page + */ + public static void glPointSize(@NativeType("GLfloat") float size) { + GL11C.glPointSize(size); + } + + // --- [ glPolygonMode ] --- + + /** + * Controls the interpretation of polygons for rasterization. + * + *

{@link GL11C#GL_FILL FILL} is the default mode of polygon rasterization. Note that these modes affect only the final rasterization of polygons: in particular, a + * polygon's vertices are lit, and the polygon is clipped and possibly culled before these modes are applied. Polygon antialiasing applies only to the + * {@link GL11C#GL_FILL FILL} state of PolygonMode. For {@link GL11C#GL_POINT POINT} or {@link GL11C#GL_LINE LINE}, point antialiasing or line segment antialiasing, respectively, apply.

+ * + * @param face the face for which to set the rasterizing method. One of:
{@link GL11C#GL_FRONT FRONT}{@link GL11C#GL_BACK BACK}{@link GL11C#GL_FRONT_AND_BACK FRONT_AND_BACK}
+ * @param mode the rasterization mode. One of:
{@link GL11C#GL_POINT POINT}{@link GL11C#GL_LINE LINE}{@link GL11C#GL_FILL FILL}
+ * + * @see Reference Page + */ + public static void glPolygonMode(@NativeType("GLenum") int face, @NativeType("GLenum") int mode) { + GL11C.glPolygonMode(face, mode); + } + + // --- [ glPolygonOffset ] --- + + /** + * The depth values of all fragments generated by the rasterization of a polygon may be offset by a single value that is computed for that polygon. This + * function determines that value. + * + *

{@code factor} scales the maximum depth slope of the polygon, and {@code units} scales an implementation-dependent constant that relates to the usable + * resolution of the depth buffer. The resulting values are summed to produce the polygon offset value.

+ * + * @param factor the maximum depth slope factor + * @param units the constant scale + * + * @see Reference Page + */ + public static void glPolygonOffset(@NativeType("GLfloat") float factor, @NativeType("GLfloat") float units) { + GL11C.glPolygonOffset(factor, units); + } + + // --- [ glPolygonStipple ] --- + + /** Unsafe version of: {@link #glPolygonStipple PolygonStipple} */ + public static native void nglPolygonStipple(long pattern); + + /** + * Defines a polygon stipple. It works much the same way as {@link #glLineStipple LineStipple}, masking out certain fragments produced by rasterization so that they + * are not sent to the next stage of the GL. This is the case regardless of the state of polygon antialiasing. + * + *

If xw and yw are the window coordinates of a rasterized polygon fragment, then that fragment is sent to the next stage of the GL + * if and only if the bit of the pattern (xw mod 32, yw mod 32) is 1.

+ * + *

Polygon stippling may be enabled or disabled with {@link #glEnable Enable} or {@link #glDisable Disable} using the constant {@link #GL_POLYGON_STIPPLE POLYGON_STIPPLE}. When disabled, + * it is as if the stipple pattern were all ones.

+ * + * @param pattern a pointer to memory into which a 32 × 32 pattern is packed + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glPolygonStipple(@NativeType("GLubyte const *") ByteBuffer pattern) { + if (CHECKS) { + check(pattern, 128); + } + nglPolygonStipple(memAddress(pattern)); + } + + /** + * Defines a polygon stipple. It works much the same way as {@link #glLineStipple LineStipple}, masking out certain fragments produced by rasterization so that they + * are not sent to the next stage of the GL. This is the case regardless of the state of polygon antialiasing. + * + *

If xw and yw are the window coordinates of a rasterized polygon fragment, then that fragment is sent to the next stage of the GL + * if and only if the bit of the pattern (xw mod 32, yw mod 32) is 1.

+ * + *

Polygon stippling may be enabled or disabled with {@link #glEnable Enable} or {@link #glDisable Disable} using the constant {@link #GL_POLYGON_STIPPLE POLYGON_STIPPLE}. When disabled, + * it is as if the stipple pattern were all ones.

+ * + * @param pattern a pointer to memory into which a 32 × 32 pattern is packed + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glPolygonStipple(@NativeType("GLubyte const *") long pattern) { + nglPolygonStipple(pattern); + } + + // --- [ glPushAttrib ] --- + + /** + * Takes a bitwise OR of symbolic constants indicating which groups of state variables to push onto the server attribute stack. Each constant refers to a + * group of state variables. + * + *

Bits set in mask that do not correspond to an attribute group are ignored. The special mask value {@link #GL_ALL_ATTRIB_BITS ALL_ATTRIB_BITS} may be used to push all + * stackable server state.

+ * + *

A {@link #GL_STACK_OVERFLOW STACK_OVERFLOW} error is generated if {@code PushAttrib} is called and the attribute stack depth is equal to the value of + * {@link #GL_MAX_ATTRIB_STACK_DEPTH MAX_ATTRIB_STACK_DEPTH}.

+ * + * @param mask the state variables to push. One or more of:
{@link #GL_ACCUM_BUFFER_BIT ACCUM_BUFFER_BIT}{@link #GL_COLOR_BUFFER_BIT COLOR_BUFFER_BIT}{@link #GL_CURRENT_BIT CURRENT_BIT}{@link #GL_DEPTH_BUFFER_BIT DEPTH_BUFFER_BIT}{@link #GL_ENABLE_BIT ENABLE_BIT}{@link #GL_EVAL_BIT EVAL_BIT}
{@link #GL_FOG_BIT FOG_BIT}{@link #GL_HINT_BIT HINT_BIT}{@link #GL_LIGHTING_BIT LIGHTING_BIT}{@link #GL_LINE_BIT LINE_BIT}{@link #GL_LIST_BIT LIST_BIT}{@link GL13#GL_MULTISAMPLE_BIT MULTISAMPLE_BIT}
{@link #GL_PIXEL_MODE_BIT PIXEL_MODE_BIT}{@link #GL_POINT_BIT POINT_BIT}{@link #GL_POLYGON_BIT POLYGON_BIT}{@link #GL_POLYGON_STIPPLE_BIT POLYGON_STIPPLE_BIT}{@link #GL_SCISSOR_BIT SCISSOR_BIT}{@link #GL_STENCIL_BUFFER_BIT STENCIL_BUFFER_BIT}
{@link #GL_TEXTURE_BIT TEXTURE_BIT}{@link #GL_TRANSFORM_BIT TRANSFORM_BIT}{@link #GL_VIEWPORT_BIT VIEWPORT_BIT}{@link #GL_ALL_ATTRIB_BITS ALL_ATTRIB_BITS}
+ * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glPushAttrib(@NativeType("GLbitfield") int mask); + + // --- [ glPushClientAttrib ] --- + + /** + * Takes a bitwise OR of symbolic constants indicating which groups of state variables to push onto the client attribute stack. Each constant refers to a + * group of state variables. + * + *

Bits set in mask that do not correspond to an attribute group are ignored. The special mask value {@link #GL_CLIENT_ALL_ATTRIB_BITS CLIENT_ALL_ATTRIB_BITS} may be used to push + * all stackable client state.

+ * + *

A {@link #GL_STACK_OVERFLOW STACK_OVERFLOW} error is generated if {@code PushAttrib} is called and the client attribute stack depth is equal to the value of + * {@link #GL_MAX_CLIENT_ATTRIB_STACK_DEPTH MAX_CLIENT_ATTRIB_STACK_DEPTH}.

+ * + * @param mask the state variables to push. One or more of:
{@link #GL_CLIENT_VERTEX_ARRAY_BIT CLIENT_VERTEX_ARRAY_BIT}{@link #GL_CLIENT_PIXEL_STORE_BIT CLIENT_PIXEL_STORE_BIT}{@link #GL_CLIENT_ALL_ATTRIB_BITS CLIENT_ALL_ATTRIB_BITS}
+ * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glPushClientAttrib(@NativeType("GLbitfield") int mask); + + // --- [ glPopAttrib ] --- + + /** + * Resets the values of those state variables that were saved with the last {@link #glPushAttrib PushAttrib}. Those not saved remain unchanged. + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glPopAttrib(); + + // --- [ glPopClientAttrib ] --- + + /** + * Resets the values of those state variables that were saved with the last {@link #glPushClientAttrib PushClientAttrib}. Those not saved remain unchanged. + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glPopClientAttrib(); + + // --- [ glPopMatrix ] --- + + /** + * Pops the top entry off the current matrix stack, replacing the current matrix with the matrix that was the second entry in the stack. + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glPopMatrix(); + + // --- [ glPopName ] --- + + /** + * Pops one name off the top of the selection name stack. + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glPopName(); + + // --- [ glPrioritizeTextures ] --- + + /** + * Unsafe version of: {@link #glPrioritizeTextures PrioritizeTextures} + * + * @param n the number of texture object priorities to set + */ + public static native void nglPrioritizeTextures(int n, long textures, long priorities); + + /** + * Sets the priority of texture objects. Each priority value is clamped to the range [0, 1] before it is assigned. Zero indicates the lowest priority, with + * the least likelihood of being resident. One indicates the highest priority, with the greatest likelihood of being resident. + * + * @param textures an array of texture object names + * @param priorities an array of texture object priorities + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glPrioritizeTextures(@NativeType("GLuint const *") IntBuffer textures, @NativeType("GLfloat const *") FloatBuffer priorities) { + if (CHECKS) { + check(priorities, textures.remaining()); + } + nglPrioritizeTextures(textures.remaining(), memAddress(textures), memAddress(priorities)); + } + + // --- [ glPushMatrix ] --- + + /** + * Pushes the current matrix stack down by one, duplicating the current matrix in both the top of the stack and the entry below it. + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glPushMatrix(); + + // --- [ glPushName ] --- + + /** + * Causes {@code name} to be pushed onto the selection name stack. + * + * @param name the name to push + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glPushName(@NativeType("GLuint") int name); + + // --- [ glRasterPos2i ] --- + + /** + * Sets the two-dimensional current raster position. {@code z} is implicitly set to 0 and {@code w} implicitly set to 1. + * + *

The coordinates are treated as if they were specified in a Vertex command. If a vertex shader is active, this vertex shader is executed using the x, y, + * z, and w coordinates as the object coordinates of the vertex. Otherwise, the x, y, z, and w coordinates are transformed by the current model-view and + * projection matrices. These coordinates, along with current values, are used to generate primary and secondary colors and texture coordinates just as is + * done for a vertex. The colors and texture coordinates so produced replace the colors and texture coordinates stored in the current raster position's + * associated data.

+ * + * @param x the {@code x} raster coordinate + * @param y the {@code y} raster coordinate + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glRasterPos2i(@NativeType("GLint") int x, @NativeType("GLint") int y); + + // --- [ glRasterPos2s ] --- + + /** + * Short version of {@link #glRasterPos2i RasterPos2i}. + * + * @param x the {@code x} raster coordinate + * @param y the {@code y} raster coordinate + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glRasterPos2s(@NativeType("GLshort") short x, @NativeType("GLshort") short y); + + // --- [ glRasterPos2f ] --- + + /** + * Float version of {@link #glRasterPos2i RasterPos2i}. + * + * @param x the {@code x} raster coordinate + * @param y the {@code y} raster coordinate + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glRasterPos2f(@NativeType("GLfloat") float x, @NativeType("GLfloat") float y); + + // --- [ glRasterPos2d ] --- + + /** + * Double version of {@link #glRasterPos2i RasterPos2i}. + * + * @param x the {@code x} raster coordinate + * @param y the {@code y} raster coordinate + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glRasterPos2d(@NativeType("GLdouble") double x, @NativeType("GLdouble") double y); + + // --- [ glRasterPos2iv ] --- + + /** Unsafe version of: {@link #glRasterPos2iv RasterPos2iv} */ + public static native void nglRasterPos2iv(long coords); + + /** + * Pointer version of {@link #glRasterPos2i RasterPos2i}. + * + * @param coords the raster position buffer + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glRasterPos2iv(@NativeType("GLint const *") IntBuffer coords) { + if (CHECKS) { + check(coords, 2); + } + nglRasterPos2iv(memAddress(coords)); + } + + // --- [ glRasterPos2sv ] --- + + /** Unsafe version of: {@link #glRasterPos2sv RasterPos2sv} */ + public static native void nglRasterPos2sv(long coords); + + /** + * Pointer version of {@link #glRasterPos2s RasterPos2s}. + * + * @param coords the raster position buffer + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glRasterPos2sv(@NativeType("GLshort const *") ShortBuffer coords) { + if (CHECKS) { + check(coords, 2); + } + nglRasterPos2sv(memAddress(coords)); + } + + // --- [ glRasterPos2fv ] --- + + /** Unsafe version of: {@link #glRasterPos2fv RasterPos2fv} */ + public static native void nglRasterPos2fv(long coords); + + /** + * Pointer version of {@link #glRasterPos2f RasterPos2f}. + * + * @param coords the raster position buffer + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glRasterPos2fv(@NativeType("GLfloat const *") FloatBuffer coords) { + if (CHECKS) { + check(coords, 2); + } + nglRasterPos2fv(memAddress(coords)); + } + + // --- [ glRasterPos2dv ] --- + + /** Unsafe version of: {@link #glRasterPos2dv RasterPos2dv} */ + public static native void nglRasterPos2dv(long coords); + + /** + * Pointer version of {@link #glRasterPos2d RasterPos2d}. + * + * @param coords the raster position buffer + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glRasterPos2dv(@NativeType("GLdouble const *") DoubleBuffer coords) { + if (CHECKS) { + check(coords, 2); + } + nglRasterPos2dv(memAddress(coords)); + } + + // --- [ glRasterPos3i ] --- + + /** + * Sets the three-dimensional current raster position. {@code w} is implicitly set to 1. See {@link #glRasterPos2i RasterPos2i} for more details. + * + * @param x the {@code x} raster coordinate + * @param y the {@code y} raster coordinate + * @param z the {@code z} raster coordinate + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glRasterPos3i(@NativeType("GLint") int x, @NativeType("GLint") int y, @NativeType("GLint") int z); + + // --- [ glRasterPos3s ] --- + + /** + * Short version of {@link #glRasterPos3i RasterPos3i}. + * + * @param x the {@code x} raster coordinate + * @param y the {@code y} raster coordinate + * @param z the {@code z} raster coordinate + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glRasterPos3s(@NativeType("GLshort") short x, @NativeType("GLshort") short y, @NativeType("GLshort") short z); + + // --- [ glRasterPos3f ] --- + + /** + * Float version of {@link #glRasterPos3i RasterPos3i}. + * + * @param x the {@code x} raster coordinate + * @param y the {@code y} raster coordinate + * @param z the {@code z} raster coordinate + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glRasterPos3f(@NativeType("GLfloat") float x, @NativeType("GLfloat") float y, @NativeType("GLfloat") float z); + + // --- [ glRasterPos3d ] --- + + /** + * Double version of {@link #glRasterPos3i RasterPos3i}. + * + * @param x the {@code x} raster coordinate + * @param y the {@code y} raster coordinate + * @param z the {@code z} raster coordinate + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glRasterPos3d(@NativeType("GLdouble") double x, @NativeType("GLdouble") double y, @NativeType("GLdouble") double z); + + // --- [ glRasterPos3iv ] --- + + /** Unsafe version of: {@link #glRasterPos3iv RasterPos3iv} */ + public static native void nglRasterPos3iv(long coords); + + /** + * Pointer version of {@link #glRasterPos3i RasterPos3i}. + * + * @param coords the raster position buffer + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glRasterPos3iv(@NativeType("GLint const *") IntBuffer coords) { + if (CHECKS) { + check(coords, 3); + } + nglRasterPos3iv(memAddress(coords)); + } + + // --- [ glRasterPos3sv ] --- + + /** Unsafe version of: {@link #glRasterPos3sv RasterPos3sv} */ + public static native void nglRasterPos3sv(long coords); + + /** + * Pointer version of {@link #glRasterPos3s RasterPos3s}. + * + * @param coords the raster position buffer + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glRasterPos3sv(@NativeType("GLshort const *") ShortBuffer coords) { + if (CHECKS) { + check(coords, 3); + } + nglRasterPos3sv(memAddress(coords)); + } + + // --- [ glRasterPos3fv ] --- + + /** Unsafe version of: {@link #glRasterPos3fv RasterPos3fv} */ + public static native void nglRasterPos3fv(long coords); + + /** + * Pointer version of {@link #glRasterPos3f RasterPos3f}. + * + * @param coords the raster position buffer + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glRasterPos3fv(@NativeType("GLfloat const *") FloatBuffer coords) { + if (CHECKS) { + check(coords, 3); + } + nglRasterPos3fv(memAddress(coords)); + } + + // --- [ glRasterPos3dv ] --- + + /** Unsafe version of: {@link #glRasterPos3dv RasterPos3dv} */ + public static native void nglRasterPos3dv(long coords); + + /** + * Pointer version of {@link #glRasterPos3d RasterPos3d}. + * + * @param coords the raster position buffer + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glRasterPos3dv(@NativeType("GLdouble const *") DoubleBuffer coords) { + if (CHECKS) { + check(coords, 3); + } + nglRasterPos3dv(memAddress(coords)); + } + + // --- [ glRasterPos4i ] --- + + /** + * Sets the four-dimensional current raster position. See {@link #glRasterPos2i RasterPos2i} for more details. + * + * @param x the {@code x} raster coordinate + * @param y the {@code y} raster coordinate + * @param z the {@code z} raster coordinate + * @param w the {@code w} raster coordinate + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glRasterPos4i(@NativeType("GLint") int x, @NativeType("GLint") int y, @NativeType("GLint") int z, @NativeType("GLint") int w); + + // --- [ glRasterPos4s ] --- + + /** + * Short version of {@link #glRasterPos4i RasterPos4i}. + * + * @param x the {@code x} raster coordinate + * @param y the {@code y} raster coordinate + * @param z the {@code z} raster coordinate + * @param w the {@code w} raster coordinate + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glRasterPos4s(@NativeType("GLshort") short x, @NativeType("GLshort") short y, @NativeType("GLshort") short z, @NativeType("GLshort") short w); + + // --- [ glRasterPos4f ] --- + + /** + * Float version of RasterPos4i. + * + * @param x the {@code x} raster coordinate + * @param y the {@code y} raster coordinate + * @param z the {@code z} raster coordinate + * @param w the {@code w} raster coordinate + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glRasterPos4f(@NativeType("GLfloat") float x, @NativeType("GLfloat") float y, @NativeType("GLfloat") float z, @NativeType("GLfloat") float w); + + // --- [ glRasterPos4d ] --- + + /** + * Double version of {@link #glRasterPos4i RasterPos4i}. + * + * @param x the {@code x} raster coordinate + * @param y the {@code y} raster coordinate + * @param z the {@code z} raster coordinate + * @param w the {@code w} raster coordinate + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glRasterPos4d(@NativeType("GLdouble") double x, @NativeType("GLdouble") double y, @NativeType("GLdouble") double z, @NativeType("GLdouble") double w); + + // --- [ glRasterPos4iv ] --- + + /** Unsafe version of: {@link #glRasterPos4iv RasterPos4iv} */ + public static native void nglRasterPos4iv(long coords); + + /** + * Pointer version of {@link #glRasterPos4i RasterPos4i}. + * + * @param coords the raster position buffer + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glRasterPos4iv(@NativeType("GLint const *") IntBuffer coords) { + if (CHECKS) { + check(coords, 4); + } + nglRasterPos4iv(memAddress(coords)); + } + + // --- [ glRasterPos4sv ] --- + + /** Unsafe version of: {@link #glRasterPos4sv RasterPos4sv} */ + public static native void nglRasterPos4sv(long coords); + + /** + * Pointer version of {@link #glRasterPos4s RasterPos4s}. + * + * @param coords the raster position buffer + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glRasterPos4sv(@NativeType("GLshort const *") ShortBuffer coords) { + if (CHECKS) { + check(coords, 4); + } + nglRasterPos4sv(memAddress(coords)); + } + + // --- [ glRasterPos4fv ] --- + + /** Unsafe version of: {@link #glRasterPos4fv RasterPos4fv} */ + public static native void nglRasterPos4fv(long coords); + + /** + * Pointer version of {@link #glRasterPos4f RasterPos4f}. + * + * @param coords the raster position buffer + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glRasterPos4fv(@NativeType("GLfloat const *") FloatBuffer coords) { + if (CHECKS) { + check(coords, 4); + } + nglRasterPos4fv(memAddress(coords)); + } + + // --- [ glRasterPos4dv ] --- + + /** Unsafe version of: {@link #glRasterPos4dv RasterPos4dv} */ + public static native void nglRasterPos4dv(long coords); + + /** + * Pointer version of {@link #glRasterPos4d RasterPos4d}. + * + * @param coords the raster position buffer + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glRasterPos4dv(@NativeType("GLdouble const *") DoubleBuffer coords) { + if (CHECKS) { + check(coords, 4); + } + nglRasterPos4dv(memAddress(coords)); + } + + // --- [ glReadBuffer ] --- + + /** + * Defines the color buffer from which values are obtained. + * + *

Acceptable values for {@code src} depend on whether the GL is using the default framebuffer (i.e., {@link GL30#GL_DRAW_FRAMEBUFFER_BINDING DRAW_FRAMEBUFFER_BINDING} is zero), or + * a framebuffer object (i.e., {@link GL30#GL_DRAW_FRAMEBUFFER_BINDING DRAW_FRAMEBUFFER_BINDING} is non-zero). In the initial state, the GL is bound to the default framebuffer.

+ * + * @param src the color buffer to read from. One of:
{@link GL11C#GL_NONE NONE}{@link GL11C#GL_FRONT_LEFT FRONT_LEFT}{@link GL11C#GL_FRONT_RIGHT FRONT_RIGHT}{@link GL11C#GL_BACK_LEFT BACK_LEFT}{@link GL11C#GL_BACK_RIGHT BACK_RIGHT}{@link GL11C#GL_FRONT FRONT}{@link GL11C#GL_BACK BACK}{@link GL11C#GL_LEFT LEFT}
{@link GL11C#GL_RIGHT RIGHT}{@link GL11C#GL_FRONT_AND_BACK FRONT_AND_BACK}{@link GL30#GL_COLOR_ATTACHMENT0 COLOR_ATTACHMENT0}GL30.GL_COLOR_ATTACHMENT[1-15]
+ * + * @see Reference Page + */ + public static void glReadBuffer(@NativeType("GLenum") int src) { + GL11C.glReadBuffer(src); + } + + // --- [ glReadPixels ] --- + + /** Unsafe version of: {@link #glReadPixels ReadPixels} */ + public static void nglReadPixels(int x, int y, int width, int height, int format, int type, long pixels) { + GL11C.nglReadPixels(x, y, width, height, format, type, pixels); + } + + /** + * ReadPixels obtains values from the selected read buffer from each pixel with lower left hand corner at {@code (x + i, y + j)} for {@code 0 <= i < width} + * and {@code 0 <= j < height}; this pixel is said to be the ith pixel in the jth row. If any of these pixels lies outside of the + * window allocated to the current GL context, or outside of the image attached to the currently bound read framebuffer object, then the values obtained + * for those pixels are undefined. When {@link GL30#GL_READ_FRAMEBUFFER_BINDING READ_FRAMEBUFFER_BINDING} is zero, values are also undefined for individual pixels that are not owned by + * the current context. Otherwise, {@code ReadPixels} obtains values from the selected buffer, regardless of how those values were placed there. + * + * @param x the left pixel coordinate + * @param y the lower pixel coordinate + * @param width the number of pixels to read in the x-dimension + * @param height the number of pixels to read in the y-dimension + * @param format the pixel format. One of:
{@link GL11C#GL_RED RED}{@link GL11C#GL_GREEN GREEN}{@link GL11C#GL_BLUE BLUE}{@link GL11C#GL_ALPHA ALPHA}{@link GL30#GL_RG RG}{@link GL11C#GL_RGB RGB}{@link GL11C#GL_RGBA RGBA}{@link GL12#GL_BGR BGR}
{@link GL12#GL_BGRA BGRA}{@link GL30#GL_RED_INTEGER RED_INTEGER}{@link GL30#GL_GREEN_INTEGER GREEN_INTEGER}{@link GL30#GL_BLUE_INTEGER BLUE_INTEGER}{@link GL30#GL_ALPHA_INTEGER ALPHA_INTEGER}{@link GL30#GL_RG_INTEGER RG_INTEGER}{@link GL30#GL_RGB_INTEGER RGB_INTEGER}{@link GL30#GL_RGBA_INTEGER RGBA_INTEGER}
{@link GL30#GL_BGR_INTEGER BGR_INTEGER}{@link GL30#GL_BGRA_INTEGER BGRA_INTEGER}{@link GL11C#GL_STENCIL_INDEX STENCIL_INDEX}{@link GL11C#GL_DEPTH_COMPONENT DEPTH_COMPONENT}{@link GL30#GL_DEPTH_STENCIL DEPTH_STENCIL}
+ * @param type the pixel type. One of:
{@link GL11C#GL_UNSIGNED_BYTE UNSIGNED_BYTE}{@link GL11C#GL_BYTE BYTE}{@link GL11C#GL_UNSIGNED_SHORT UNSIGNED_SHORT}{@link GL11C#GL_SHORT SHORT}
{@link GL11C#GL_UNSIGNED_INT UNSIGNED_INT}{@link GL11C#GL_INT INT}{@link GL30#GL_HALF_FLOAT HALF_FLOAT}{@link GL11C#GL_FLOAT FLOAT}
{@link GL12#GL_UNSIGNED_BYTE_3_3_2 UNSIGNED_BYTE_3_3_2}{@link GL12#GL_UNSIGNED_BYTE_2_3_3_REV UNSIGNED_BYTE_2_3_3_REV}{@link GL12#GL_UNSIGNED_SHORT_5_6_5 UNSIGNED_SHORT_5_6_5}{@link GL12#GL_UNSIGNED_SHORT_5_6_5_REV UNSIGNED_SHORT_5_6_5_REV}
{@link GL12#GL_UNSIGNED_SHORT_4_4_4_4 UNSIGNED_SHORT_4_4_4_4}{@link GL12#GL_UNSIGNED_SHORT_4_4_4_4_REV UNSIGNED_SHORT_4_4_4_4_REV}{@link GL12#GL_UNSIGNED_SHORT_5_5_5_1 UNSIGNED_SHORT_5_5_5_1}{@link GL12#GL_UNSIGNED_SHORT_1_5_5_5_REV UNSIGNED_SHORT_1_5_5_5_REV}
{@link GL12#GL_UNSIGNED_INT_8_8_8_8 UNSIGNED_INT_8_8_8_8}{@link GL12#GL_UNSIGNED_INT_8_8_8_8_REV UNSIGNED_INT_8_8_8_8_REV}{@link GL12#GL_UNSIGNED_INT_10_10_10_2 UNSIGNED_INT_10_10_10_2}{@link GL12#GL_UNSIGNED_INT_2_10_10_10_REV UNSIGNED_INT_2_10_10_10_REV}
{@link GL30#GL_UNSIGNED_INT_24_8 UNSIGNED_INT_24_8}{@link GL30#GL_UNSIGNED_INT_10F_11F_11F_REV UNSIGNED_INT_10F_11F_11F_REV}{@link GL30#GL_UNSIGNED_INT_5_9_9_9_REV UNSIGNED_INT_5_9_9_9_REV}{@link GL30#GL_FLOAT_32_UNSIGNED_INT_24_8_REV FLOAT_32_UNSIGNED_INT_24_8_REV}
+ * @param pixels a buffer in which to place the returned pixel data + * + * @see Reference Page + */ + public static void glReadPixels(@NativeType("GLint") int x, @NativeType("GLint") int y, @NativeType("GLsizei") int width, @NativeType("GLsizei") int height, @NativeType("GLenum") int format, @NativeType("GLenum") int type, @NativeType("void *") ByteBuffer pixels) { + GL11C.glReadPixels(x, y, width, height, format, type, pixels); + } + + /** + * ReadPixels obtains values from the selected read buffer from each pixel with lower left hand corner at {@code (x + i, y + j)} for {@code 0 <= i < width} + * and {@code 0 <= j < height}; this pixel is said to be the ith pixel in the jth row. If any of these pixels lies outside of the + * window allocated to the current GL context, or outside of the image attached to the currently bound read framebuffer object, then the values obtained + * for those pixels are undefined. When {@link GL30#GL_READ_FRAMEBUFFER_BINDING READ_FRAMEBUFFER_BINDING} is zero, values are also undefined for individual pixels that are not owned by + * the current context. Otherwise, {@code ReadPixels} obtains values from the selected buffer, regardless of how those values were placed there. + * + * @param x the left pixel coordinate + * @param y the lower pixel coordinate + * @param width the number of pixels to read in the x-dimension + * @param height the number of pixels to read in the y-dimension + * @param format the pixel format. One of:
{@link GL11C#GL_RED RED}{@link GL11C#GL_GREEN GREEN}{@link GL11C#GL_BLUE BLUE}{@link GL11C#GL_ALPHA ALPHA}{@link GL30#GL_RG RG}{@link GL11C#GL_RGB RGB}{@link GL11C#GL_RGBA RGBA}{@link GL12#GL_BGR BGR}
{@link GL12#GL_BGRA BGRA}{@link GL30#GL_RED_INTEGER RED_INTEGER}{@link GL30#GL_GREEN_INTEGER GREEN_INTEGER}{@link GL30#GL_BLUE_INTEGER BLUE_INTEGER}{@link GL30#GL_ALPHA_INTEGER ALPHA_INTEGER}{@link GL30#GL_RG_INTEGER RG_INTEGER}{@link GL30#GL_RGB_INTEGER RGB_INTEGER}{@link GL30#GL_RGBA_INTEGER RGBA_INTEGER}
{@link GL30#GL_BGR_INTEGER BGR_INTEGER}{@link GL30#GL_BGRA_INTEGER BGRA_INTEGER}{@link GL11C#GL_STENCIL_INDEX STENCIL_INDEX}{@link GL11C#GL_DEPTH_COMPONENT DEPTH_COMPONENT}{@link GL30#GL_DEPTH_STENCIL DEPTH_STENCIL}
+ * @param type the pixel type. One of:
{@link GL11C#GL_UNSIGNED_BYTE UNSIGNED_BYTE}{@link GL11C#GL_BYTE BYTE}{@link GL11C#GL_UNSIGNED_SHORT UNSIGNED_SHORT}{@link GL11C#GL_SHORT SHORT}
{@link GL11C#GL_UNSIGNED_INT UNSIGNED_INT}{@link GL11C#GL_INT INT}{@link GL30#GL_HALF_FLOAT HALF_FLOAT}{@link GL11C#GL_FLOAT FLOAT}
{@link GL12#GL_UNSIGNED_BYTE_3_3_2 UNSIGNED_BYTE_3_3_2}{@link GL12#GL_UNSIGNED_BYTE_2_3_3_REV UNSIGNED_BYTE_2_3_3_REV}{@link GL12#GL_UNSIGNED_SHORT_5_6_5 UNSIGNED_SHORT_5_6_5}{@link GL12#GL_UNSIGNED_SHORT_5_6_5_REV UNSIGNED_SHORT_5_6_5_REV}
{@link GL12#GL_UNSIGNED_SHORT_4_4_4_4 UNSIGNED_SHORT_4_4_4_4}{@link GL12#GL_UNSIGNED_SHORT_4_4_4_4_REV UNSIGNED_SHORT_4_4_4_4_REV}{@link GL12#GL_UNSIGNED_SHORT_5_5_5_1 UNSIGNED_SHORT_5_5_5_1}{@link GL12#GL_UNSIGNED_SHORT_1_5_5_5_REV UNSIGNED_SHORT_1_5_5_5_REV}
{@link GL12#GL_UNSIGNED_INT_8_8_8_8 UNSIGNED_INT_8_8_8_8}{@link GL12#GL_UNSIGNED_INT_8_8_8_8_REV UNSIGNED_INT_8_8_8_8_REV}{@link GL12#GL_UNSIGNED_INT_10_10_10_2 UNSIGNED_INT_10_10_10_2}{@link GL12#GL_UNSIGNED_INT_2_10_10_10_REV UNSIGNED_INT_2_10_10_10_REV}
{@link GL30#GL_UNSIGNED_INT_24_8 UNSIGNED_INT_24_8}{@link GL30#GL_UNSIGNED_INT_10F_11F_11F_REV UNSIGNED_INT_10F_11F_11F_REV}{@link GL30#GL_UNSIGNED_INT_5_9_9_9_REV UNSIGNED_INT_5_9_9_9_REV}{@link GL30#GL_FLOAT_32_UNSIGNED_INT_24_8_REV FLOAT_32_UNSIGNED_INT_24_8_REV}
+ * @param pixels a buffer in which to place the returned pixel data + * + * @see Reference Page + */ + public static void glReadPixels(@NativeType("GLint") int x, @NativeType("GLint") int y, @NativeType("GLsizei") int width, @NativeType("GLsizei") int height, @NativeType("GLenum") int format, @NativeType("GLenum") int type, @NativeType("void *") long pixels) { + GL11C.glReadPixels(x, y, width, height, format, type, pixels); + } + + /** + * ReadPixels obtains values from the selected read buffer from each pixel with lower left hand corner at {@code (x + i, y + j)} for {@code 0 <= i < width} + * and {@code 0 <= j < height}; this pixel is said to be the ith pixel in the jth row. If any of these pixels lies outside of the + * window allocated to the current GL context, or outside of the image attached to the currently bound read framebuffer object, then the values obtained + * for those pixels are undefined. When {@link GL30#GL_READ_FRAMEBUFFER_BINDING READ_FRAMEBUFFER_BINDING} is zero, values are also undefined for individual pixels that are not owned by + * the current context. Otherwise, {@code ReadPixels} obtains values from the selected buffer, regardless of how those values were placed there. + * + * @param x the left pixel coordinate + * @param y the lower pixel coordinate + * @param width the number of pixels to read in the x-dimension + * @param height the number of pixels to read in the y-dimension + * @param format the pixel format. One of:
{@link GL11C#GL_RED RED}{@link GL11C#GL_GREEN GREEN}{@link GL11C#GL_BLUE BLUE}{@link GL11C#GL_ALPHA ALPHA}{@link GL30#GL_RG RG}{@link GL11C#GL_RGB RGB}{@link GL11C#GL_RGBA RGBA}{@link GL12#GL_BGR BGR}
{@link GL12#GL_BGRA BGRA}{@link GL30#GL_RED_INTEGER RED_INTEGER}{@link GL30#GL_GREEN_INTEGER GREEN_INTEGER}{@link GL30#GL_BLUE_INTEGER BLUE_INTEGER}{@link GL30#GL_ALPHA_INTEGER ALPHA_INTEGER}{@link GL30#GL_RG_INTEGER RG_INTEGER}{@link GL30#GL_RGB_INTEGER RGB_INTEGER}{@link GL30#GL_RGBA_INTEGER RGBA_INTEGER}
{@link GL30#GL_BGR_INTEGER BGR_INTEGER}{@link GL30#GL_BGRA_INTEGER BGRA_INTEGER}{@link GL11C#GL_STENCIL_INDEX STENCIL_INDEX}{@link GL11C#GL_DEPTH_COMPONENT DEPTH_COMPONENT}{@link GL30#GL_DEPTH_STENCIL DEPTH_STENCIL}
+ * @param type the pixel type. One of:
{@link GL11C#GL_UNSIGNED_BYTE UNSIGNED_BYTE}{@link GL11C#GL_BYTE BYTE}{@link GL11C#GL_UNSIGNED_SHORT UNSIGNED_SHORT}{@link GL11C#GL_SHORT SHORT}
{@link GL11C#GL_UNSIGNED_INT UNSIGNED_INT}{@link GL11C#GL_INT INT}{@link GL30#GL_HALF_FLOAT HALF_FLOAT}{@link GL11C#GL_FLOAT FLOAT}
{@link GL12#GL_UNSIGNED_BYTE_3_3_2 UNSIGNED_BYTE_3_3_2}{@link GL12#GL_UNSIGNED_BYTE_2_3_3_REV UNSIGNED_BYTE_2_3_3_REV}{@link GL12#GL_UNSIGNED_SHORT_5_6_5 UNSIGNED_SHORT_5_6_5}{@link GL12#GL_UNSIGNED_SHORT_5_6_5_REV UNSIGNED_SHORT_5_6_5_REV}
{@link GL12#GL_UNSIGNED_SHORT_4_4_4_4 UNSIGNED_SHORT_4_4_4_4}{@link GL12#GL_UNSIGNED_SHORT_4_4_4_4_REV UNSIGNED_SHORT_4_4_4_4_REV}{@link GL12#GL_UNSIGNED_SHORT_5_5_5_1 UNSIGNED_SHORT_5_5_5_1}{@link GL12#GL_UNSIGNED_SHORT_1_5_5_5_REV UNSIGNED_SHORT_1_5_5_5_REV}
{@link GL12#GL_UNSIGNED_INT_8_8_8_8 UNSIGNED_INT_8_8_8_8}{@link GL12#GL_UNSIGNED_INT_8_8_8_8_REV UNSIGNED_INT_8_8_8_8_REV}{@link GL12#GL_UNSIGNED_INT_10_10_10_2 UNSIGNED_INT_10_10_10_2}{@link GL12#GL_UNSIGNED_INT_2_10_10_10_REV UNSIGNED_INT_2_10_10_10_REV}
{@link GL30#GL_UNSIGNED_INT_24_8 UNSIGNED_INT_24_8}{@link GL30#GL_UNSIGNED_INT_10F_11F_11F_REV UNSIGNED_INT_10F_11F_11F_REV}{@link GL30#GL_UNSIGNED_INT_5_9_9_9_REV UNSIGNED_INT_5_9_9_9_REV}{@link GL30#GL_FLOAT_32_UNSIGNED_INT_24_8_REV FLOAT_32_UNSIGNED_INT_24_8_REV}
+ * @param pixels a buffer in which to place the returned pixel data + * + * @see Reference Page + */ + public static void glReadPixels(@NativeType("GLint") int x, @NativeType("GLint") int y, @NativeType("GLsizei") int width, @NativeType("GLsizei") int height, @NativeType("GLenum") int format, @NativeType("GLenum") int type, @NativeType("void *") ShortBuffer pixels) { + GL11C.glReadPixels(x, y, width, height, format, type, pixels); + } + + /** + * ReadPixels obtains values from the selected read buffer from each pixel with lower left hand corner at {@code (x + i, y + j)} for {@code 0 <= i < width} + * and {@code 0 <= j < height}; this pixel is said to be the ith pixel in the jth row. If any of these pixels lies outside of the + * window allocated to the current GL context, or outside of the image attached to the currently bound read framebuffer object, then the values obtained + * for those pixels are undefined. When {@link GL30#GL_READ_FRAMEBUFFER_BINDING READ_FRAMEBUFFER_BINDING} is zero, values are also undefined for individual pixels that are not owned by + * the current context. Otherwise, {@code ReadPixels} obtains values from the selected buffer, regardless of how those values were placed there. + * + * @param x the left pixel coordinate + * @param y the lower pixel coordinate + * @param width the number of pixels to read in the x-dimension + * @param height the number of pixels to read in the y-dimension + * @param format the pixel format. One of:
{@link GL11C#GL_RED RED}{@link GL11C#GL_GREEN GREEN}{@link GL11C#GL_BLUE BLUE}{@link GL11C#GL_ALPHA ALPHA}{@link GL30#GL_RG RG}{@link GL11C#GL_RGB RGB}{@link GL11C#GL_RGBA RGBA}{@link GL12#GL_BGR BGR}
{@link GL12#GL_BGRA BGRA}{@link GL30#GL_RED_INTEGER RED_INTEGER}{@link GL30#GL_GREEN_INTEGER GREEN_INTEGER}{@link GL30#GL_BLUE_INTEGER BLUE_INTEGER}{@link GL30#GL_ALPHA_INTEGER ALPHA_INTEGER}{@link GL30#GL_RG_INTEGER RG_INTEGER}{@link GL30#GL_RGB_INTEGER RGB_INTEGER}{@link GL30#GL_RGBA_INTEGER RGBA_INTEGER}
{@link GL30#GL_BGR_INTEGER BGR_INTEGER}{@link GL30#GL_BGRA_INTEGER BGRA_INTEGER}{@link GL11C#GL_STENCIL_INDEX STENCIL_INDEX}{@link GL11C#GL_DEPTH_COMPONENT DEPTH_COMPONENT}{@link GL30#GL_DEPTH_STENCIL DEPTH_STENCIL}
+ * @param type the pixel type. One of:
{@link GL11C#GL_UNSIGNED_BYTE UNSIGNED_BYTE}{@link GL11C#GL_BYTE BYTE}{@link GL11C#GL_UNSIGNED_SHORT UNSIGNED_SHORT}{@link GL11C#GL_SHORT SHORT}
{@link GL11C#GL_UNSIGNED_INT UNSIGNED_INT}{@link GL11C#GL_INT INT}{@link GL30#GL_HALF_FLOAT HALF_FLOAT}{@link GL11C#GL_FLOAT FLOAT}
{@link GL12#GL_UNSIGNED_BYTE_3_3_2 UNSIGNED_BYTE_3_3_2}{@link GL12#GL_UNSIGNED_BYTE_2_3_3_REV UNSIGNED_BYTE_2_3_3_REV}{@link GL12#GL_UNSIGNED_SHORT_5_6_5 UNSIGNED_SHORT_5_6_5}{@link GL12#GL_UNSIGNED_SHORT_5_6_5_REV UNSIGNED_SHORT_5_6_5_REV}
{@link GL12#GL_UNSIGNED_SHORT_4_4_4_4 UNSIGNED_SHORT_4_4_4_4}{@link GL12#GL_UNSIGNED_SHORT_4_4_4_4_REV UNSIGNED_SHORT_4_4_4_4_REV}{@link GL12#GL_UNSIGNED_SHORT_5_5_5_1 UNSIGNED_SHORT_5_5_5_1}{@link GL12#GL_UNSIGNED_SHORT_1_5_5_5_REV UNSIGNED_SHORT_1_5_5_5_REV}
{@link GL12#GL_UNSIGNED_INT_8_8_8_8 UNSIGNED_INT_8_8_8_8}{@link GL12#GL_UNSIGNED_INT_8_8_8_8_REV UNSIGNED_INT_8_8_8_8_REV}{@link GL12#GL_UNSIGNED_INT_10_10_10_2 UNSIGNED_INT_10_10_10_2}{@link GL12#GL_UNSIGNED_INT_2_10_10_10_REV UNSIGNED_INT_2_10_10_10_REV}
{@link GL30#GL_UNSIGNED_INT_24_8 UNSIGNED_INT_24_8}{@link GL30#GL_UNSIGNED_INT_10F_11F_11F_REV UNSIGNED_INT_10F_11F_11F_REV}{@link GL30#GL_UNSIGNED_INT_5_9_9_9_REV UNSIGNED_INT_5_9_9_9_REV}{@link GL30#GL_FLOAT_32_UNSIGNED_INT_24_8_REV FLOAT_32_UNSIGNED_INT_24_8_REV}
+ * @param pixels a buffer in which to place the returned pixel data + * + * @see Reference Page + */ + public static void glReadPixels(@NativeType("GLint") int x, @NativeType("GLint") int y, @NativeType("GLsizei") int width, @NativeType("GLsizei") int height, @NativeType("GLenum") int format, @NativeType("GLenum") int type, @NativeType("void *") IntBuffer pixels) { + GL11C.glReadPixels(x, y, width, height, format, type, pixels); + } + + /** + * ReadPixels obtains values from the selected read buffer from each pixel with lower left hand corner at {@code (x + i, y + j)} for {@code 0 <= i < width} + * and {@code 0 <= j < height}; this pixel is said to be the ith pixel in the jth row. If any of these pixels lies outside of the + * window allocated to the current GL context, or outside of the image attached to the currently bound read framebuffer object, then the values obtained + * for those pixels are undefined. When {@link GL30#GL_READ_FRAMEBUFFER_BINDING READ_FRAMEBUFFER_BINDING} is zero, values are also undefined for individual pixels that are not owned by + * the current context. Otherwise, {@code ReadPixels} obtains values from the selected buffer, regardless of how those values were placed there. + * + * @param x the left pixel coordinate + * @param y the lower pixel coordinate + * @param width the number of pixels to read in the x-dimension + * @param height the number of pixels to read in the y-dimension + * @param format the pixel format. One of:
{@link GL11C#GL_RED RED}{@link GL11C#GL_GREEN GREEN}{@link GL11C#GL_BLUE BLUE}{@link GL11C#GL_ALPHA ALPHA}{@link GL30#GL_RG RG}{@link GL11C#GL_RGB RGB}{@link GL11C#GL_RGBA RGBA}{@link GL12#GL_BGR BGR}
{@link GL12#GL_BGRA BGRA}{@link GL30#GL_RED_INTEGER RED_INTEGER}{@link GL30#GL_GREEN_INTEGER GREEN_INTEGER}{@link GL30#GL_BLUE_INTEGER BLUE_INTEGER}{@link GL30#GL_ALPHA_INTEGER ALPHA_INTEGER}{@link GL30#GL_RG_INTEGER RG_INTEGER}{@link GL30#GL_RGB_INTEGER RGB_INTEGER}{@link GL30#GL_RGBA_INTEGER RGBA_INTEGER}
{@link GL30#GL_BGR_INTEGER BGR_INTEGER}{@link GL30#GL_BGRA_INTEGER BGRA_INTEGER}{@link GL11C#GL_STENCIL_INDEX STENCIL_INDEX}{@link GL11C#GL_DEPTH_COMPONENT DEPTH_COMPONENT}{@link GL30#GL_DEPTH_STENCIL DEPTH_STENCIL}
+ * @param type the pixel type. One of:
{@link GL11C#GL_UNSIGNED_BYTE UNSIGNED_BYTE}{@link GL11C#GL_BYTE BYTE}{@link GL11C#GL_UNSIGNED_SHORT UNSIGNED_SHORT}{@link GL11C#GL_SHORT SHORT}
{@link GL11C#GL_UNSIGNED_INT UNSIGNED_INT}{@link GL11C#GL_INT INT}{@link GL30#GL_HALF_FLOAT HALF_FLOAT}{@link GL11C#GL_FLOAT FLOAT}
{@link GL12#GL_UNSIGNED_BYTE_3_3_2 UNSIGNED_BYTE_3_3_2}{@link GL12#GL_UNSIGNED_BYTE_2_3_3_REV UNSIGNED_BYTE_2_3_3_REV}{@link GL12#GL_UNSIGNED_SHORT_5_6_5 UNSIGNED_SHORT_5_6_5}{@link GL12#GL_UNSIGNED_SHORT_5_6_5_REV UNSIGNED_SHORT_5_6_5_REV}
{@link GL12#GL_UNSIGNED_SHORT_4_4_4_4 UNSIGNED_SHORT_4_4_4_4}{@link GL12#GL_UNSIGNED_SHORT_4_4_4_4_REV UNSIGNED_SHORT_4_4_4_4_REV}{@link GL12#GL_UNSIGNED_SHORT_5_5_5_1 UNSIGNED_SHORT_5_5_5_1}{@link GL12#GL_UNSIGNED_SHORT_1_5_5_5_REV UNSIGNED_SHORT_1_5_5_5_REV}
{@link GL12#GL_UNSIGNED_INT_8_8_8_8 UNSIGNED_INT_8_8_8_8}{@link GL12#GL_UNSIGNED_INT_8_8_8_8_REV UNSIGNED_INT_8_8_8_8_REV}{@link GL12#GL_UNSIGNED_INT_10_10_10_2 UNSIGNED_INT_10_10_10_2}{@link GL12#GL_UNSIGNED_INT_2_10_10_10_REV UNSIGNED_INT_2_10_10_10_REV}
{@link GL30#GL_UNSIGNED_INT_24_8 UNSIGNED_INT_24_8}{@link GL30#GL_UNSIGNED_INT_10F_11F_11F_REV UNSIGNED_INT_10F_11F_11F_REV}{@link GL30#GL_UNSIGNED_INT_5_9_9_9_REV UNSIGNED_INT_5_9_9_9_REV}{@link GL30#GL_FLOAT_32_UNSIGNED_INT_24_8_REV FLOAT_32_UNSIGNED_INT_24_8_REV}
+ * @param pixels a buffer in which to place the returned pixel data + * + * @see Reference Page + */ + public static void glReadPixels(@NativeType("GLint") int x, @NativeType("GLint") int y, @NativeType("GLsizei") int width, @NativeType("GLsizei") int height, @NativeType("GLenum") int format, @NativeType("GLenum") int type, @NativeType("void *") FloatBuffer pixels) { + GL11C.glReadPixels(x, y, width, height, format, type, pixels); + } + + // --- [ glRecti ] --- + + /** + * Specifies a rectangle as two corner vertices. The effect of the Rect command + * + *

{@code Rect(x1, y1, x2, y2);}

+ * + *

is exactly the same as the following sequence of commands: + * {@code + * Begin(POLYGON); + * Vertex2(x1, y1); + * Vertex2(x2, y1); + * Vertex2(x2, y2); + * Vertex2(x1, y2); + * End();}

+ * + *

The appropriate Vertex2 command would be invoked depending on which of the Rect commands is issued.

+ * + * @param x1 the x coordinate of the first corner vertex + * @param y1 the y coordinate of the first corner vertex + * @param x2 the x coordinate of the second corner vertex + * @param y2 the y coordinate of the second corner vertex + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glRecti(@NativeType("GLint") int x1, @NativeType("GLint") int y1, @NativeType("GLint") int x2, @NativeType("GLint") int y2); + + // --- [ glRects ] --- + + /** + * Short version of {@link #glRecti Recti}. + * + * @param x1 the x coordinate of the first corner vertex + * @param y1 the y coordinate of the first corner vertex + * @param x2 the x coordinate of the second corner vertex + * @param y2 the y coordinate of the second corner vertex + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glRects(@NativeType("GLshort") short x1, @NativeType("GLshort") short y1, @NativeType("GLshort") short x2, @NativeType("GLshort") short y2); + + // --- [ glRectf ] --- + + /** + * Float version of {@link #glRecti Recti}. + * + * @param x1 the x coordinate of the first corner vertex + * @param y1 the y coordinate of the first corner vertex + * @param x2 the x coordinate of the second corner vertex + * @param y2 the y coordinate of the second corner vertex + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glRectf(@NativeType("GLfloat") float x1, @NativeType("GLfloat") float y1, @NativeType("GLfloat") float x2, @NativeType("GLfloat") float y2); + + // --- [ glRectd ] --- + + /** + * Double version of {@link #glRecti Recti}. + * + * @param x1 the x coordinate of the first corner vertex + * @param y1 the y coordinate of the first corner vertex + * @param x2 the x coordinate of the second corner vertex + * @param y2 the y coordinate of the second corner vertex + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glRectd(@NativeType("GLdouble") double x1, @NativeType("GLdouble") double y1, @NativeType("GLdouble") double x2, @NativeType("GLdouble") double y2); + + // --- [ glRectiv ] --- + + /** Unsafe version of: {@link #glRectiv Rectiv} */ + public static native void nglRectiv(long v1, long v2); + + /** + * Pointer version of {@link #glRecti Recti}. + * + * @param v1 the first vertex buffer + * @param v2 the second vertex buffer + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glRectiv(@NativeType("GLint const *") IntBuffer v1, @NativeType("GLint const *") IntBuffer v2) { + if (CHECKS) { + check(v1, 2); + check(v2, 2); + } + nglRectiv(memAddress(v1), memAddress(v2)); + } + + // --- [ glRectsv ] --- + + /** Unsafe version of: {@link #glRectsv Rectsv} */ + public static native void nglRectsv(long v1, long v2); + + /** + * Pointer version of {@link #glRects Rects}. + * + * @param v1 the first vertex buffer + * @param v2 the second vertex buffer + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glRectsv(@NativeType("GLshort const *") ShortBuffer v1, @NativeType("GLshort const *") ShortBuffer v2) { + if (CHECKS) { + check(v1, 2); + check(v2, 2); + } + nglRectsv(memAddress(v1), memAddress(v2)); + } + + // --- [ glRectfv ] --- + + /** Unsafe version of: {@link #glRectfv Rectfv} */ + public static native void nglRectfv(long v1, long v2); + + /** + * Pointer version of {@link #glRectf Rectf}. + * + * @param v1 the first vertex buffer + * @param v2 the second vertex buffer + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glRectfv(@NativeType("GLfloat const *") FloatBuffer v1, @NativeType("GLfloat const *") FloatBuffer v2) { + if (CHECKS) { + check(v1, 2); + check(v2, 2); + } + nglRectfv(memAddress(v1), memAddress(v2)); + } + + // --- [ glRectdv ] --- + + /** Unsafe version of: {@link #glRectdv Rectdv} */ + public static native void nglRectdv(long v1, long v2); + + /** + * Pointer version of {@link #glRectd Rectd}. + * + * @param v1 the first vertex buffer + * @param v2 the second vertex buffer + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glRectdv(@NativeType("GLdouble const *") DoubleBuffer v1, @NativeType("GLdouble const *") DoubleBuffer v2) { + if (CHECKS) { + check(v1, 2); + check(v2, 2); + } + nglRectdv(memAddress(v1), memAddress(v2)); + } + + // --- [ glRenderMode ] --- + + /** + * Sets the current render mode. The default is {@link #GL_RENDER RENDER}. + * + * @param mode the render mode. One of:
{@link #GL_RENDER RENDER}{@link #GL_SELECT SELECT}{@link #GL_FEEDBACK FEEDBACK}
+ * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + @NativeType("GLint") + public static native int glRenderMode(@NativeType("GLenum") int mode); + + // --- [ glRotatef ] --- + + /** + * Manipulates the current matrix with a rotation matrix. + * + *

{@code angle} gives an angle of rotation in degrees; the coordinates of a vector v are given by v = (x y z)T. The computed matrix + * is a counter-clockwise rotation about the line through the origin with the specified axis when that axis is pointing up (i.e. the right-hand rule + * determines the sense of the rotation angle). The matrix is thus

+ * + * + * + * + * + * + *
R0
0
0
0001
+ * + *

Let u = v / ||v|| = (x' y' z')T. If S =

+ * + * + * + * + * + *
0-z'y'
z'0-x'
-y'x'0
+ * + *

then R = uuT + cos(angle)(I - uuT) + sin(angle)S

+ * + * @param angle the angle of rotation in degrees + * @param x the x coordinate of the rotation vector + * @param y the y coordinate of the rotation vector + * @param z the z coordinate of the rotation vector + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glRotatef(@NativeType("GLfloat") float angle, @NativeType("GLfloat") float x, @NativeType("GLfloat") float y, @NativeType("GLfloat") float z); + + // --- [ glRotated ] --- + + /** + * Double version of {@link #glRotatef Rotatef}. + * + * @param angle the angle of rotation in degrees + * @param x the x coordinate of the rotation vector + * @param y the y coordinate of the rotation vector + * @param z the z coordinate of the rotation vector + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glRotated(@NativeType("GLdouble") double angle, @NativeType("GLdouble") double x, @NativeType("GLdouble") double y, @NativeType("GLdouble") double z); + + // --- [ glScalef ] --- + + /** + * Manipulates the current matrix with a general scaling matrix along the x-, y- and z- axes. + * + *

Calling this function is equivalent to calling {@link #glMultMatrixf MultMatrixf} with the following matrix:

+ * + * + * + * + * + * + *
x000
0y00
00z0
0001
+ * + * @param x the x-axis scaling factor + * @param y the y-axis scaling factor + * @param z the z-axis scaling factor + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glScalef(@NativeType("GLfloat") float x, @NativeType("GLfloat") float y, @NativeType("GLfloat") float z); + + // --- [ glScaled ] --- + + /** + * Double version of {@link #glScalef Scalef}. + * + * @param x the x-axis scaling factor + * @param y the y-axis scaling factor + * @param z the z-axis scaling factor + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glScaled(@NativeType("GLdouble") double x, @NativeType("GLdouble") double y, @NativeType("GLdouble") double z); + + // --- [ glScissor ] --- + + /** + * Defines the scissor rectangle for all viewports. The scissor test is enabled or disabled for all viewports using {@link #glEnable Enable} or {@link #glDisable Disable} + * with the symbolic constant {@link GL11C#GL_SCISSOR_TEST SCISSOR_TEST}. When disabled, it is as if the scissor test always passes. When enabled, if + * left ≤ xw < left + width and bottom ≤ yw < bottom + height for the scissor rectangle, then the scissor + * test passes. Otherwise, the test fails and the fragment is discarded. + * + * @param x the left scissor rectangle coordinate + * @param y the bottom scissor rectangle coordinate + * @param width the scissor rectangle width + * @param height the scissor rectangle height + * + * @see Reference Page + */ + public static void glScissor(@NativeType("GLint") int x, @NativeType("GLint") int y, @NativeType("GLsizei") int width, @NativeType("GLsizei") int height) { + GL11C.glScissor(x, y, width, height); + } + + // --- [ glSelectBuffer ] --- + + /** + * Unsafe version of: {@link #glSelectBuffer SelectBuffer} + * + * @param size the maximum number of values that can be stored in {@code buffer} + */ + public static native void nglSelectBuffer(int size, long buffer); + + /** + * Sets the selection array. + * + * @param buffer an array of unsigned integers to be potentially filled names + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glSelectBuffer(@NativeType("GLuint *") IntBuffer buffer) { + nglSelectBuffer(buffer.remaining(), memAddress(buffer)); + } + + // --- [ glShadeModel ] --- + + /** + * Sets the current shade mode. The initial value of the shade mode is {@link #GL_SMOOTH SMOOTH}. + * + *

If mode is {@link #GL_SMOOTH SMOOTH}, vertex colors are treated individually. If mode is {@link #GL_FLAT FLAT}, flatshading is enabled and colors are taken from the + * provoking vertex of the primitive. The colors selected are those derived from current values, generated by lighting, or generated by vertex shading, if + * lighting is disabled, enabled, or a vertex shader is in use, respectively.

+ * + * @param mode the shade mode. One of:
{@link #GL_SMOOTH SMOOTH}{@link #GL_FLAT FLAT}
+ * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glShadeModel(@NativeType("GLenum") int mode); + + // --- [ glStencilFunc ] --- + + /** + * Controls the stencil test. + * + *

{@code ref} is an integer reference value that is used in the unsigned stencil comparison. Stencil comparison operations and queries of {@code ref} + * clamp its value to the range [0, 2s – 1], where s is the number of bits in the stencil buffer attached to the draw framebuffer. The s + * least significant bits of {@code mask} are bitwise ANDed with both the reference and the stored stencil value, and the resulting masked values are those that + * participate in the comparison controlled by {@code func}.

+ * + * @param func the stencil comparison function. One of:
{@link GL11C#GL_NEVER NEVER}{@link GL11C#GL_ALWAYS ALWAYS}{@link GL11C#GL_LESS LESS}{@link GL11C#GL_LEQUAL LEQUAL}{@link GL11C#GL_EQUAL EQUAL}{@link GL11C#GL_GEQUAL GEQUAL}{@link GL11C#GL_GREATER GREATER}{@link GL11C#GL_NOTEQUAL NOTEQUAL}
+ * @param ref the reference value + * @param mask the stencil comparison mask + * + * @see Reference Page + */ + public static void glStencilFunc(@NativeType("GLenum") int func, @NativeType("GLint") int ref, @NativeType("GLuint") int mask) { + GL11C.glStencilFunc(func, ref, mask); + } + + // --- [ glStencilMask ] --- + + /** + * Masks the writing of particular bits into the stencil plans. + * + *

The least significant s bits of {@code mask}, where s is the number of bits in the stencil buffer, specify an integer mask. Where a 1 appears in this + * mask, the corresponding bit in the stencil buffer is written; where a 0 appears, the bit is not written.

+ * + * @param mask the stencil mask + * + * @see Reference Page + */ + public static void glStencilMask(@NativeType("GLuint") int mask) { + GL11C.glStencilMask(mask); + } + + // --- [ glStencilOp ] --- + + /** + * Indicates what happens to the stored stencil value if this or certain subsequent tests fail or pass. + * + *

The supported actions are {@link GL11C#GL_KEEP KEEP}, {@link GL11C#GL_ZERO ZERO}, {@link GL11C#GL_REPLACE REPLACE}, {@link GL11C#GL_INCR INCR}, {@link GL11C#GL_DECR DECR}, {@link GL11C#GL_INVERT INVERT}, + * {@link GL14#GL_INCR_WRAP INCR_WRAP} and {@link GL14#GL_DECR_WRAP DECR_WRAP}. These correspond to keeping the current value, setting to zero, replacing with the reference value, + * incrementing with saturation, decrementing with saturation, bitwise inverting it, incrementing without saturation, and decrementing without saturation.

+ * + *

For purposes of increment and decrement, the stencil bits are considered as an unsigned integer. Incrementing or decrementing with saturation clamps + * the stencil value at 0 and the maximum representable value. Incrementing or decrementing without saturation will wrap such that incrementing the maximum + * representable value results in 0, and decrementing 0 results in the maximum representable value.

+ * + * @param sfail the action to take if the stencil test fails + * @param dpfail the action to take if the depth buffer test fails + * @param dppass the action to take if the depth buffer test passes + * + * @see Reference Page + */ + public static void glStencilOp(@NativeType("GLenum") int sfail, @NativeType("GLenum") int dpfail, @NativeType("GLenum") int dppass) { + GL11C.glStencilOp(sfail, dpfail, dppass); + } + + // --- [ glTexCoord1f ] --- + + /** + * Sets the current one-dimensional texture coordinate. {@code t} and {@code r} are implicitly set to 0 and {@code q} to 1. + * + * @param s the s component of the current texture coordinates + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glTexCoord1f(@NativeType("GLfloat") float s); + + // --- [ glTexCoord1s ] --- + + /** + * Short version of {@link #glTexCoord1f TexCoord1f}. + * + * @param s the s component of the current texture coordinates + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glTexCoord1s(@NativeType("GLshort") short s); + + // --- [ glTexCoord1i ] --- + + /** + * Integer version of {@link #glTexCoord1f TexCoord1f}. + * + * @param s the s component of the current texture coordinates + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glTexCoord1i(@NativeType("GLint") int s); + + // --- [ glTexCoord1d ] --- + + /** + * Double version of {@link #glTexCoord1f TexCoord1f}. + * + * @param s the s component of the current texture coordinates + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glTexCoord1d(@NativeType("GLdouble") double s); + + // --- [ glTexCoord1fv ] --- + + /** Unsafe version of: {@link #glTexCoord1fv TexCoord1fv} */ + public static native void nglTexCoord1fv(long v); + + /** + * Pointer version of {@link #glTexCoord1f TexCoord1f}. + * + * @param v the texture coordinate buffer + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glTexCoord1fv(@NativeType("GLfloat const *") FloatBuffer v) { + if (CHECKS) { + check(v, 1); + } + nglTexCoord1fv(memAddress(v)); + } + + // --- [ glTexCoord1sv ] --- + + /** Unsafe version of: {@link #glTexCoord1sv TexCoord1sv} */ + public static native void nglTexCoord1sv(long v); + + /** + * Pointer version of {@link #glTexCoord1s TexCoord1s}. + * + * @param v the texture coordinate buffer + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glTexCoord1sv(@NativeType("GLshort const *") ShortBuffer v) { + if (CHECKS) { + check(v, 1); + } + nglTexCoord1sv(memAddress(v)); + } + + // --- [ glTexCoord1iv ] --- + + /** Unsafe version of: {@link #glTexCoord1iv TexCoord1iv} */ + public static native void nglTexCoord1iv(long v); + + /** + * Pointer version of {@link #glTexCoord1i TexCoord1i}. + * + * @param v the texture coordinate buffer + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glTexCoord1iv(@NativeType("GLint const *") IntBuffer v) { + if (CHECKS) { + check(v, 1); + } + nglTexCoord1iv(memAddress(v)); + } + + // --- [ glTexCoord1dv ] --- + + /** Unsafe version of: {@link #glTexCoord1dv TexCoord1dv} */ + public static native void nglTexCoord1dv(long v); + + /** + * Pointer version of {@link #glTexCoord1d TexCoord1d}. + * + * @param v the texture coordinate buffer + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glTexCoord1dv(@NativeType("GLdouble const *") DoubleBuffer v) { + if (CHECKS) { + check(v, 1); + } + nglTexCoord1dv(memAddress(v)); + } + + // --- [ glTexCoord2f ] --- + + /** + * Sets the current two-dimensional texture coordinate. {@code r} is implicitly set to 0 and {@code q} to 1. + * + * @param s the s component of the current texture coordinates + * @param t the t component of the current texture coordinates + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glTexCoord2f(@NativeType("GLfloat") float s, @NativeType("GLfloat") float t); + + // --- [ glTexCoord2s ] --- + + /** + * Short version of {@link #glTexCoord2f TexCoord2f}. + * + * @param s the s component of the current texture coordinates + * @param t the t component of the current texture coordinates + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glTexCoord2s(@NativeType("GLshort") short s, @NativeType("GLshort") short t); + + // --- [ glTexCoord2i ] --- + + /** + * Integer version of {@link #glTexCoord2f TexCoord2f}. + * + * @param s the s component of the current texture coordinates + * @param t the t component of the current texture coordinates + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glTexCoord2i(@NativeType("GLint") int s, @NativeType("GLint") int t); + + // --- [ glTexCoord2d ] --- + + /** + * Double version of {@link #glTexCoord2f TexCoord2f}. + * + * @param s the s component of the current texture coordinates + * @param t the t component of the current texture coordinates + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glTexCoord2d(@NativeType("GLdouble") double s, @NativeType("GLdouble") double t); + + // --- [ glTexCoord2fv ] --- + + /** Unsafe version of: {@link #glTexCoord2fv TexCoord2fv} */ + public static native void nglTexCoord2fv(long v); + + /** + * Pointer version of {@link #glTexCoord2f TexCoord2f}. + * + * @param v the texture coordinate buffer + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glTexCoord2fv(@NativeType("GLfloat const *") FloatBuffer v) { + if (CHECKS) { + check(v, 2); + } + nglTexCoord2fv(memAddress(v)); + } + + // --- [ glTexCoord2sv ] --- + + /** Unsafe version of: {@link #glTexCoord2sv TexCoord2sv} */ + public static native void nglTexCoord2sv(long v); + + /** + * Pointer version of {@link #glTexCoord2s TexCoord2s}. + * + * @param v the texture coordinate buffer + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glTexCoord2sv(@NativeType("GLshort const *") ShortBuffer v) { + if (CHECKS) { + check(v, 2); + } + nglTexCoord2sv(memAddress(v)); + } + + // --- [ glTexCoord2iv ] --- + + /** Unsafe version of: {@link #glTexCoord2iv TexCoord2iv} */ + public static native void nglTexCoord2iv(long v); + + /** + * Pointer version of {@link #glTexCoord2i TexCoord2i}. + * + * @param v the texture coordinate buffer + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glTexCoord2iv(@NativeType("GLint const *") IntBuffer v) { + if (CHECKS) { + check(v, 2); + } + nglTexCoord2iv(memAddress(v)); + } + + // --- [ glTexCoord2dv ] --- + + /** Unsafe version of: {@link #glTexCoord2dv TexCoord2dv} */ + public static native void nglTexCoord2dv(long v); + + /** + * Pointer version of {@link #glTexCoord2d TexCoord2d}. + * + * @param v the texture coordinate buffer + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glTexCoord2dv(@NativeType("GLdouble const *") DoubleBuffer v) { + if (CHECKS) { + check(v, 2); + } + nglTexCoord2dv(memAddress(v)); + } + + // --- [ glTexCoord3f ] --- + + /** + * Sets the current three-dimensional texture coordinate. {@code q} is implicitly set to 1. + * + * @param s the s component of the current texture coordinates + * @param t the t component of the current texture coordinates + * @param r the r component of the current texture coordinates + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glTexCoord3f(@NativeType("GLfloat") float s, @NativeType("GLfloat") float t, @NativeType("GLfloat") float r); + + // --- [ glTexCoord3s ] --- + + /** + * Short version of {@link #glTexCoord3f TexCoord3f}. + * + * @param s the s component of the current texture coordinates + * @param t the t component of the current texture coordinates + * @param r the r component of the current texture coordinates + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glTexCoord3s(@NativeType("GLshort") short s, @NativeType("GLshort") short t, @NativeType("GLshort") short r); + + // --- [ glTexCoord3i ] --- + + /** + * Integer version of {@link #glTexCoord3f TexCoord3f}. + * + * @param s the s component of the current texture coordinates + * @param t the t component of the current texture coordinates + * @param r the r component of the current texture coordinates + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glTexCoord3i(@NativeType("GLint") int s, @NativeType("GLint") int t, @NativeType("GLint") int r); + + // --- [ glTexCoord3d ] --- + + /** + * Double version of {@link #glTexCoord3f TexCoord3f}. + * + * @param s the s component of the current texture coordinates + * @param t the t component of the current texture coordinates + * @param r the r component of the current texture coordinates + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glTexCoord3d(@NativeType("GLdouble") double s, @NativeType("GLdouble") double t, @NativeType("GLdouble") double r); + + // --- [ glTexCoord3fv ] --- + + /** Unsafe version of: {@link #glTexCoord3fv TexCoord3fv} */ + public static native void nglTexCoord3fv(long v); + + /** + * Pointer version of {@link #glTexCoord3f TexCoord3f}. + * + * @param v the texture coordinate buffer + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glTexCoord3fv(@NativeType("GLfloat const *") FloatBuffer v) { + if (CHECKS) { + check(v, 3); + } + nglTexCoord3fv(memAddress(v)); + } + + // --- [ glTexCoord3sv ] --- + + /** Unsafe version of: {@link #glTexCoord3sv TexCoord3sv} */ + public static native void nglTexCoord3sv(long v); + + /** + * Pointer version of {@link #glTexCoord3s TexCoord3s}. + * + * @param v the texture coordinate buffer + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glTexCoord3sv(@NativeType("GLshort const *") ShortBuffer v) { + if (CHECKS) { + check(v, 3); + } + nglTexCoord3sv(memAddress(v)); + } + + // --- [ glTexCoord3iv ] --- + + /** Unsafe version of: {@link #glTexCoord3iv TexCoord3iv} */ + public static native void nglTexCoord3iv(long v); + + /** + * Pointer version of {@link #glTexCoord3i TexCoord3i}. + * + * @param v the texture coordinate buffer + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glTexCoord3iv(@NativeType("GLint const *") IntBuffer v) { + if (CHECKS) { + check(v, 3); + } + nglTexCoord3iv(memAddress(v)); + } + + // --- [ glTexCoord3dv ] --- + + /** Unsafe version of: {@link #glTexCoord3dv TexCoord3dv} */ + public static native void nglTexCoord3dv(long v); + + /** + * Pointer version of {@link #glTexCoord3d TexCoord3d}. + * + * @param v the texture coordinate buffer + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glTexCoord3dv(@NativeType("GLdouble const *") DoubleBuffer v) { + if (CHECKS) { + check(v, 3); + } + nglTexCoord3dv(memAddress(v)); + } + + // --- [ glTexCoord4f ] --- + + /** + * Sets the current four-dimensional texture coordinate. + * + * @param s the s component of the current texture coordinates + * @param t the t component of the current texture coordinates + * @param r the r component of the current texture coordinates + * @param q the q component of the current texture coordinates + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glTexCoord4f(@NativeType("GLfloat") float s, @NativeType("GLfloat") float t, @NativeType("GLfloat") float r, @NativeType("GLfloat") float q); + + // --- [ glTexCoord4s ] --- + + /** + * Short version of {@link #glTexCoord4f TexCoord4f}. + * + * @param s the s component of the current texture coordinates + * @param t the t component of the current texture coordinates + * @param r the r component of the current texture coordinates + * @param q the q component of the current texture coordinates + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glTexCoord4s(@NativeType("GLshort") short s, @NativeType("GLshort") short t, @NativeType("GLshort") short r, @NativeType("GLshort") short q); + + // --- [ glTexCoord4i ] --- + + /** + * Integer version of {@link #glTexCoord4f TexCoord4f}. + * + * @param s the s component of the current texture coordinates + * @param t the t component of the current texture coordinates + * @param r the r component of the current texture coordinates + * @param q the q component of the current texture coordinates + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glTexCoord4i(@NativeType("GLint") int s, @NativeType("GLint") int t, @NativeType("GLint") int r, @NativeType("GLint") int q); + + // --- [ glTexCoord4d ] --- + + /** + * Double version of {@link #glTexCoord4f TexCoord4f}. + * + * @param s the s component of the current texture coordinates + * @param t the t component of the current texture coordinates + * @param r the r component of the current texture coordinates + * @param q the q component of the current texture coordinates + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glTexCoord4d(@NativeType("GLdouble") double s, @NativeType("GLdouble") double t, @NativeType("GLdouble") double r, @NativeType("GLdouble") double q); + + // --- [ glTexCoord4fv ] --- + + /** Unsafe version of: {@link #glTexCoord4fv TexCoord4fv} */ + public static native void nglTexCoord4fv(long v); + + /** + * Pointer version of {@link #glTexCoord4f TexCoord4f}. + * + * @param v the texture coordinate buffer + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glTexCoord4fv(@NativeType("GLfloat const *") FloatBuffer v) { + if (CHECKS) { + check(v, 4); + } + nglTexCoord4fv(memAddress(v)); + } + + // --- [ glTexCoord4sv ] --- + + /** Unsafe version of: {@link #glTexCoord4sv TexCoord4sv} */ + public static native void nglTexCoord4sv(long v); + + /** + * Pointer version of {@link #glTexCoord4s TexCoord4s}. + * + * @param v the texture coordinate buffer + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glTexCoord4sv(@NativeType("GLshort const *") ShortBuffer v) { + if (CHECKS) { + check(v, 4); + } + nglTexCoord4sv(memAddress(v)); + } + + // --- [ glTexCoord4iv ] --- + + /** Unsafe version of: {@link #glTexCoord4iv TexCoord4iv} */ + public static native void nglTexCoord4iv(long v); + + /** + * Pointer version of {@link #glTexCoord4i TexCoord4i}. + * + * @param v the texture coordinate buffer + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glTexCoord4iv(@NativeType("GLint const *") IntBuffer v) { + if (CHECKS) { + check(v, 4); + } + nglTexCoord4iv(memAddress(v)); + } + + // --- [ glTexCoord4dv ] --- + + /** Unsafe version of: {@link #glTexCoord4dv TexCoord4dv} */ + public static native void nglTexCoord4dv(long v); + + /** + * Pointer version of {@link #glTexCoord4d TexCoord4d}. + * + * @param v the texture coordinate buffer + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glTexCoord4dv(@NativeType("GLdouble const *") DoubleBuffer v) { + if (CHECKS) { + check(v, 4); + } + nglTexCoord4dv(memAddress(v)); + } + + // --- [ glTexCoordPointer ] --- + + /** Unsafe version of: {@link #glTexCoordPointer TexCoordPointer} */ + public static native void nglTexCoordPointer(int size, int type, int stride, long pointer); + + /** + * Specifies the location and organization of a texture coordinate array. + * + * @param size the number of values per vertex that are stored in the array. One of:
1234
+ * @param type the data type of the values stored in the array. One of:
{@link #GL_SHORT SHORT}{@link #GL_INT INT}{@link GL30#GL_HALF_FLOAT HALF_FLOAT}{@link #GL_FLOAT FLOAT}{@link #GL_DOUBLE DOUBLE}{@link GL12#GL_UNSIGNED_INT_2_10_10_10_REV UNSIGNED_INT_2_10_10_10_REV}{@link GL33#GL_INT_2_10_10_10_REV INT_2_10_10_10_REV}
+ * @param stride the vertex stride in bytes. If specified as zero, then array elements are stored sequentially + * @param pointer the texture coordinate array data + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glTexCoordPointer(@NativeType("GLint") int size, @NativeType("GLenum") int type, @NativeType("GLsizei") int stride, @NativeType("void const *") ByteBuffer pointer) { + nglTexCoordPointer(size, type, stride, memAddress(pointer)); + } + + /** + * Specifies the location and organization of a texture coordinate array. + * + * @param size the number of values per vertex that are stored in the array. One of:
1234
+ * @param type the data type of the values stored in the array. One of:
{@link #GL_SHORT SHORT}{@link #GL_INT INT}{@link GL30#GL_HALF_FLOAT HALF_FLOAT}{@link #GL_FLOAT FLOAT}{@link #GL_DOUBLE DOUBLE}{@link GL12#GL_UNSIGNED_INT_2_10_10_10_REV UNSIGNED_INT_2_10_10_10_REV}{@link GL33#GL_INT_2_10_10_10_REV INT_2_10_10_10_REV}
+ * @param stride the vertex stride in bytes. If specified as zero, then array elements are stored sequentially + * @param pointer the texture coordinate array data + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glTexCoordPointer(@NativeType("GLint") int size, @NativeType("GLenum") int type, @NativeType("GLsizei") int stride, @NativeType("void const *") long pointer) { + nglTexCoordPointer(size, type, stride, pointer); + } + + /** + * Specifies the location and organization of a texture coordinate array. + * + * @param size the number of values per vertex that are stored in the array. One of:
1234
+ * @param type the data type of the values stored in the array. One of:
{@link #GL_SHORT SHORT}{@link #GL_INT INT}{@link GL30#GL_HALF_FLOAT HALF_FLOAT}{@link #GL_FLOAT FLOAT}{@link #GL_DOUBLE DOUBLE}{@link GL12#GL_UNSIGNED_INT_2_10_10_10_REV UNSIGNED_INT_2_10_10_10_REV}{@link GL33#GL_INT_2_10_10_10_REV INT_2_10_10_10_REV}
+ * @param stride the vertex stride in bytes. If specified as zero, then array elements are stored sequentially + * @param pointer the texture coordinate array data + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glTexCoordPointer(@NativeType("GLint") int size, @NativeType("GLenum") int type, @NativeType("GLsizei") int stride, @NativeType("void const *") ShortBuffer pointer) { + nglTexCoordPointer(size, type, stride, memAddress(pointer)); + } + + /** + * Specifies the location and organization of a texture coordinate array. + * + * @param size the number of values per vertex that are stored in the array. One of:
1234
+ * @param type the data type of the values stored in the array. One of:
{@link #GL_SHORT SHORT}{@link #GL_INT INT}{@link GL30#GL_HALF_FLOAT HALF_FLOAT}{@link #GL_FLOAT FLOAT}{@link #GL_DOUBLE DOUBLE}{@link GL12#GL_UNSIGNED_INT_2_10_10_10_REV UNSIGNED_INT_2_10_10_10_REV}{@link GL33#GL_INT_2_10_10_10_REV INT_2_10_10_10_REV}
+ * @param stride the vertex stride in bytes. If specified as zero, then array elements are stored sequentially + * @param pointer the texture coordinate array data + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glTexCoordPointer(@NativeType("GLint") int size, @NativeType("GLenum") int type, @NativeType("GLsizei") int stride, @NativeType("void const *") IntBuffer pointer) { + nglTexCoordPointer(size, type, stride, memAddress(pointer)); + } + + /** + * Specifies the location and organization of a texture coordinate array. + * + * @param size the number of values per vertex that are stored in the array. One of:
1234
+ * @param type the data type of the values stored in the array. One of:
{@link #GL_SHORT SHORT}{@link #GL_INT INT}{@link GL30#GL_HALF_FLOAT HALF_FLOAT}{@link #GL_FLOAT FLOAT}{@link #GL_DOUBLE DOUBLE}{@link GL12#GL_UNSIGNED_INT_2_10_10_10_REV UNSIGNED_INT_2_10_10_10_REV}{@link GL33#GL_INT_2_10_10_10_REV INT_2_10_10_10_REV}
+ * @param stride the vertex stride in bytes. If specified as zero, then array elements are stored sequentially + * @param pointer the texture coordinate array data + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glTexCoordPointer(@NativeType("GLint") int size, @NativeType("GLenum") int type, @NativeType("GLsizei") int stride, @NativeType("void const *") FloatBuffer pointer) { + nglTexCoordPointer(size, type, stride, memAddress(pointer)); + } + + // --- [ glTexEnvi ] --- + + /** + * Sets parameters of the texture environment that specifies how texture values are interpreted when texturing a fragment, or sets per-texture-unit + * filtering parameters. + * + * @param target the texture environment target. One of:
{@link #GL_TEXTURE_ENV TEXTURE_ENV}{@link GL14#GL_TEXTURE_FILTER_CONTROL TEXTURE_FILTER_CONTROL}{@link GL20#GL_POINT_SPRITE POINT_SPRITE}
+ * @param pname the parameter to set. One of:
{@link GL20#GL_COORD_REPLACE COORD_REPLACE}{@link #GL_TEXTURE_ENV_MODE TEXTURE_ENV_MODE}{@link GL14#GL_TEXTURE_LOD_BIAS TEXTURE_LOD_BIAS}{@link GL13#GL_COMBINE_RGB COMBINE_RGB}{@link GL13#GL_COMBINE_ALPHA COMBINE_ALPHA}{@link GL15#GL_SRC0_RGB SRC0_RGB}
{@link GL15#GL_SRC1_RGB SRC1_RGB}{@link GL15#GL_SRC2_RGB SRC2_RGB}{@link GL15#GL_SRC0_ALPHA SRC0_ALPHA}{@link GL15#GL_SRC1_ALPHA SRC1_ALPHA}{@link GL15#GL_SRC2_ALPHA SRC2_ALPHA}{@link GL13#GL_OPERAND0_RGB OPERAND0_RGB}
{@link GL13#GL_OPERAND1_RGB OPERAND1_RGB}{@link GL13#GL_OPERAND2_RGB OPERAND2_RGB}{@link GL13#GL_OPERAND0_ALPHA OPERAND0_ALPHA}{@link GL13#GL_OPERAND1_ALPHA OPERAND1_ALPHA}{@link GL13#GL_OPERAND2_ALPHA OPERAND2_ALPHA}{@link GL13#GL_RGB_SCALE RGB_SCALE}
{@link #GL_ALPHA_SCALE ALPHA_SCALE}
+ * @param param the parameter value. Scalar value or one of:
{@link #GL_REPLACE REPLACE}{@link #GL_MODULATE MODULATE}{@link #GL_DECAL DECAL}{@link #GL_BLEND BLEND}{@link #GL_ADD ADD}{@link GL13#GL_COMBINE COMBINE}{@link GL13#GL_ADD_SIGNED ADD_SIGNED}{@link GL13#GL_INTERPOLATE INTERPOLATE}
{@link GL13#GL_SUBTRACT SUBTRACT}{@link GL13#GL_DOT3_RGB DOT3_RGB}{@link GL13#GL_DOT3_RGBA DOT3_RGBA}{@link #GL_TEXTURE TEXTURE}{@link GL13#GL_TEXTURE0 TEXTURE0}GL13.GL_TEXTURE[1-31]{@link GL13#GL_CONSTANT CONSTANT}{@link GL13#GL_PRIMARY_COLOR PRIMARY_COLOR}
{@link GL13#GL_PREVIOUS PREVIOUS}
+ * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glTexEnvi(@NativeType("GLenum") int target, @NativeType("GLenum") int pname, @NativeType("GLint") int param); + + // --- [ glTexEnviv ] --- + + /** Unsafe version of: {@link #glTexEnviv TexEnviv} */ + public static native void nglTexEnviv(int target, int pname, long params); + + /** + * Pointer version of {@link #glTexEnvi TexEnvi}. + * + * @param target the texture environment target. Must be:
{@link #GL_TEXTURE_ENV TEXTURE_ENV}
+ * @param pname the parameter to set. Must be:
{@link #GL_TEXTURE_ENV_COLOR TEXTURE_ENV_COLOR}
+ * @param params the parameter value + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glTexEnviv(@NativeType("GLenum") int target, @NativeType("GLenum") int pname, @NativeType("GLint const *") IntBuffer params) { + if (CHECKS) { + check(params, 4); + } + nglTexEnviv(target, pname, memAddress(params)); + } + + // --- [ glTexEnvf ] --- + + /** + * Float version of {@link #glTexEnvi TexEnvi}. + * + * @param target the texture environment target + * @param pname the parameter to set + * @param param the parameter value + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glTexEnvf(@NativeType("GLenum") int target, @NativeType("GLenum") int pname, @NativeType("GLfloat") float param); + + // --- [ glTexEnvfv ] --- + + /** Unsafe version of: {@link #glTexEnvfv TexEnvfv} */ + public static native void nglTexEnvfv(int target, int pname, long params); + + /** + * Pointer version of {@link #glTexEnvf TexEnvf}. + * + * @param target the texture environment target. Must be:
{@link #GL_TEXTURE_ENV TEXTURE_ENV}
+ * @param pname the parameter to set. Must be:
{@link #GL_TEXTURE_ENV_COLOR TEXTURE_ENV_COLOR}
+ * @param params the parameter value + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glTexEnvfv(@NativeType("GLenum") int target, @NativeType("GLenum") int pname, @NativeType("GLfloat const *") FloatBuffer params) { + if (CHECKS) { + check(params, 4); + } + nglTexEnvfv(target, pname, memAddress(params)); + } + + // --- [ glTexGeni ] --- + + /** + * Sets an integer texture coordinate generation parameter. + * + *

A texture coordinate generation function is enabled or disabled using {@link #glEnable Enable} and {@link #glDisable Disable} with an argument of + * {@link #GL_TEXTURE_GEN_S TEXTURE_GEN_S}, {@link #GL_TEXTURE_GEN_T TEXTURE_GEN_T}, {@link #GL_TEXTURE_GEN_R TEXTURE_GEN_R}, or {@link #GL_TEXTURE_GEN_Q TEXTURE_GEN_Q} (each indicates the corresponding texture + * coordinate). When enabled, the specified texture coordinate is computed according to the current {@link #GL_EYE_LINEAR EYE_LINEAR}, {@link #GL_OBJECT_LINEAR OBJECT_LINEAR} or + * {@link #GL_SPHERE_MAP SPHERE_MAP} specification, depending on the current setting of {@link #GL_TEXTURE_GEN_MODE TEXTURE_GEN_MODE} for that coordinate. When disabled, subsequent + * vertices will take the indicated texture coordinate from the current texture coordinates.

+ * + *

The initial state has the texture generation function disabled for all texture coordinates. Initially all texture generation modes are EYE_LINEAR.

+ * + * @param coord the coordinate for which to set the parameter. One of:
{@link #GL_S S}{@link #GL_T T}{@link #GL_R R}{@link #GL_Q Q}
+ * @param pname the parameter to set. Must be:
{@link #GL_TEXTURE_GEN_MODE TEXTURE_GEN_MODE}
+ * @param param the parameter value. One of:
{@link #GL_OBJECT_LINEAR OBJECT_LINEAR}{@link #GL_EYE_LINEAR EYE_LINEAR}{@link #GL_SPHERE_MAP SPHERE_MAP}{@link GL13#GL_REFLECTION_MAP REFLECTION_MAP}{@link GL13#GL_NORMAL_MAP NORMAL_MAP}
+ * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glTexGeni(@NativeType("GLenum") int coord, @NativeType("GLenum") int pname, @NativeType("GLint") int param); + + // --- [ glTexGeniv ] --- + + /** Unsafe version of: {@link #glTexGeniv TexGeniv} */ + public static native void nglTexGeniv(int coord, int pname, long params); + + /** + * Pointer version of {@link #glTexGeni TexGeni}. + * + * @param coord the coordinate for which to set the parameter + * @param pname the parameter to set. One of:
{@link #GL_OBJECT_PLANE OBJECT_PLANE}{@link #GL_EYE_PLANE EYE_PLANE}
+ * @param params the parameter value + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glTexGeniv(@NativeType("GLenum") int coord, @NativeType("GLenum") int pname, @NativeType("GLint const *") IntBuffer params) { + if (CHECKS) { + check(params, 4); + } + nglTexGeniv(coord, pname, memAddress(params)); + } + + // --- [ glTexGenf ] --- + + /** + * Float version of {@link #glTexGeni TexGeni}. + * + * @param coord the coordinate for which to set the parameter + * @param pname the parameter to set + * @param param the parameter value + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glTexGenf(@NativeType("GLenum") int coord, @NativeType("GLenum") int pname, @NativeType("GLfloat") float param); + + // --- [ glTexGenfv ] --- + + /** Unsafe version of: {@link #glTexGenfv TexGenfv} */ + public static native void nglTexGenfv(int coord, int pname, long params); + + /** + * Pointer version of {@link #glTexGenf TexGenf}. + * + * @param coord the coordinate for which to set the parameter + * @param pname the parameter to set. One of:
{@link #GL_OBJECT_PLANE OBJECT_PLANE}{@link #GL_EYE_PLANE EYE_PLANE}
+ * @param params the parameter value + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glTexGenfv(@NativeType("GLenum") int coord, @NativeType("GLenum") int pname, @NativeType("GLfloat const *") FloatBuffer params) { + if (CHECKS) { + check(params, 4); + } + nglTexGenfv(coord, pname, memAddress(params)); + } + + // --- [ glTexGend ] --- + + /** + * Double version of {@link #glTexGeni TexGeni}. + * + * @param coord the coordinate for which to set the parameter + * @param pname the parameter to set + * @param param the parameter value + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glTexGend(@NativeType("GLenum") int coord, @NativeType("GLenum") int pname, @NativeType("GLdouble") double param); + + // --- [ glTexGendv ] --- + + /** Unsafe version of: {@link #glTexGendv TexGendv} */ + public static native void nglTexGendv(int coord, int pname, long params); + + /** + * Pointer version of {@link #glTexGend TexGend}. + * + * @param coord the coordinate for which to set the parameter + * @param pname the parameter to set + * @param params the parameter value + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glTexGendv(@NativeType("GLenum") int coord, @NativeType("GLenum") int pname, @NativeType("GLdouble const *") DoubleBuffer params) { + if (CHECKS) { + check(params, 4); + } + nglTexGendv(coord, pname, memAddress(params)); + } + + // --- [ glTexImage1D ] --- + + /** Unsafe version of: {@link #glTexImage1D TexImage1D} */ + public static void nglTexImage1D(int target, int level, int internalformat, int width, int border, int format, int type, long pixels) { + GL11C.nglTexImage1D(target, level, internalformat, width, border, format, type, pixels); + } + + /** + * One-dimensional version of {@link #glTexImage2D TexImage2D}}. + * + * @param target the texture target. One of:
{@link GL11C#GL_TEXTURE_1D TEXTURE_1D}{@link GL11C#GL_PROXY_TEXTURE_1D PROXY_TEXTURE_1D}
+ * @param level the level-of-detail number + * @param internalformat the texture internal format + * @param width the texture width + * @param border the texture border width + * @param format the texel data format + * @param type the texel data type + * @param pixels the texel data + * + * @see Reference Page + */ + public static void glTexImage1D(@NativeType("GLenum") int target, @NativeType("GLint") int level, @NativeType("GLint") int internalformat, @NativeType("GLsizei") int width, @NativeType("GLint") int border, @NativeType("GLenum") int format, @NativeType("GLenum") int type, @Nullable @NativeType("void const *") ByteBuffer pixels) { + GL11C.glTexImage1D(target, level, internalformat, width, border, format, type, pixels); + } + + /** + * One-dimensional version of {@link #glTexImage2D TexImage2D}}. + * + * @param target the texture target. One of:
{@link GL11C#GL_TEXTURE_1D TEXTURE_1D}{@link GL11C#GL_PROXY_TEXTURE_1D PROXY_TEXTURE_1D}
+ * @param level the level-of-detail number + * @param internalformat the texture internal format + * @param width the texture width + * @param border the texture border width + * @param format the texel data format + * @param type the texel data type + * @param pixels the texel data + * + * @see Reference Page + */ + public static void glTexImage1D(@NativeType("GLenum") int target, @NativeType("GLint") int level, @NativeType("GLint") int internalformat, @NativeType("GLsizei") int width, @NativeType("GLint") int border, @NativeType("GLenum") int format, @NativeType("GLenum") int type, @Nullable @NativeType("void const *") long pixels) { + GL11C.glTexImage1D(target, level, internalformat, width, border, format, type, pixels); + } + + /** + * One-dimensional version of {@link #glTexImage2D TexImage2D}}. + * + * @param target the texture target. One of:
{@link GL11C#GL_TEXTURE_1D TEXTURE_1D}{@link GL11C#GL_PROXY_TEXTURE_1D PROXY_TEXTURE_1D}
+ * @param level the level-of-detail number + * @param internalformat the texture internal format + * @param width the texture width + * @param border the texture border width + * @param format the texel data format + * @param type the texel data type + * @param pixels the texel data + * + * @see Reference Page + */ + public static void glTexImage1D(@NativeType("GLenum") int target, @NativeType("GLint") int level, @NativeType("GLint") int internalformat, @NativeType("GLsizei") int width, @NativeType("GLint") int border, @NativeType("GLenum") int format, @NativeType("GLenum") int type, @Nullable @NativeType("void const *") ShortBuffer pixels) { + GL11C.glTexImage1D(target, level, internalformat, width, border, format, type, pixels); + } + + /** + * One-dimensional version of {@link #glTexImage2D TexImage2D}}. + * + * @param target the texture target. One of:
{@link GL11C#GL_TEXTURE_1D TEXTURE_1D}{@link GL11C#GL_PROXY_TEXTURE_1D PROXY_TEXTURE_1D}
+ * @param level the level-of-detail number + * @param internalformat the texture internal format + * @param width the texture width + * @param border the texture border width + * @param format the texel data format + * @param type the texel data type + * @param pixels the texel data + * + * @see Reference Page + */ + public static void glTexImage1D(@NativeType("GLenum") int target, @NativeType("GLint") int level, @NativeType("GLint") int internalformat, @NativeType("GLsizei") int width, @NativeType("GLint") int border, @NativeType("GLenum") int format, @NativeType("GLenum") int type, @Nullable @NativeType("void const *") IntBuffer pixels) { + GL11C.glTexImage1D(target, level, internalformat, width, border, format, type, pixels); + } + + /** + * One-dimensional version of {@link #glTexImage2D TexImage2D}}. + * + * @param target the texture target. One of:
{@link GL11C#GL_TEXTURE_1D TEXTURE_1D}{@link GL11C#GL_PROXY_TEXTURE_1D PROXY_TEXTURE_1D}
+ * @param level the level-of-detail number + * @param internalformat the texture internal format + * @param width the texture width + * @param border the texture border width + * @param format the texel data format + * @param type the texel data type + * @param pixels the texel data + * + * @see Reference Page + */ + public static void glTexImage1D(@NativeType("GLenum") int target, @NativeType("GLint") int level, @NativeType("GLint") int internalformat, @NativeType("GLsizei") int width, @NativeType("GLint") int border, @NativeType("GLenum") int format, @NativeType("GLenum") int type, @Nullable @NativeType("void const *") FloatBuffer pixels) { + GL11C.glTexImage1D(target, level, internalformat, width, border, format, type, pixels); + } + + /** + * One-dimensional version of {@link #glTexImage2D TexImage2D}}. + * + * @param target the texture target. One of:
{@link GL11C#GL_TEXTURE_1D TEXTURE_1D}{@link GL11C#GL_PROXY_TEXTURE_1D PROXY_TEXTURE_1D}
+ * @param level the level-of-detail number + * @param internalformat the texture internal format + * @param width the texture width + * @param border the texture border width + * @param format the texel data format + * @param type the texel data type + * @param pixels the texel data + * + * @see Reference Page + */ + public static void glTexImage1D(@NativeType("GLenum") int target, @NativeType("GLint") int level, @NativeType("GLint") int internalformat, @NativeType("GLsizei") int width, @NativeType("GLint") int border, @NativeType("GLenum") int format, @NativeType("GLenum") int type, @Nullable @NativeType("void const *") DoubleBuffer pixels) { + GL11C.glTexImage1D(target, level, internalformat, width, border, format, type, pixels); + } + + // --- [ glTexImage2D ] --- + + /** Unsafe version of: {@link #glTexImage2D TexImage2D} */ + public static void nglTexImage2D(int target, int level, int internalformat, int width, int height, int border, int format, int type, long pixels) { + GL11C.nglTexImage2D(target, level, internalformat, width, height, border, format, type, pixels); + } + + /** + * Specifies a two-dimensional texture image. + * + * @param target the texture target. One of:
{@link GL11C#GL_TEXTURE_2D TEXTURE_2D}{@link GL30#GL_TEXTURE_1D_ARRAY TEXTURE_1D_ARRAY}{@link GL31#GL_TEXTURE_RECTANGLE TEXTURE_RECTANGLE}{@link GL13#GL_TEXTURE_CUBE_MAP TEXTURE_CUBE_MAP}
{@link GL11C#GL_PROXY_TEXTURE_2D PROXY_TEXTURE_2D}{@link GL30#GL_PROXY_TEXTURE_1D_ARRAY PROXY_TEXTURE_1D_ARRAY}{@link GL31#GL_PROXY_TEXTURE_RECTANGLE PROXY_TEXTURE_RECTANGLE}{@link GL13#GL_PROXY_TEXTURE_CUBE_MAP PROXY_TEXTURE_CUBE_MAP}
+ * @param level the level-of-detail number + * @param internalformat the texture internal format. One of:
{@link GL11C#GL_RED RED}{@link GL30#GL_RG RG}{@link GL11C#GL_RGB RGB}{@link GL11C#GL_RGBA RGBA}{@link GL11C#GL_DEPTH_COMPONENT DEPTH_COMPONENT}{@link GL30#GL_DEPTH_STENCIL DEPTH_STENCIL}
{@link GL30#GL_R8 R8}{@link GL31#GL_R8_SNORM R8_SNORM}{@link GL30#GL_R16 R16}{@link GL31#GL_R16_SNORM R16_SNORM}{@link GL30#GL_RG8 RG8}{@link GL31#GL_RG8_SNORM RG8_SNORM}
{@link GL30#GL_RG16 RG16}{@link GL31#GL_RG16_SNORM RG16_SNORM}{@link GL11C#GL_R3_G3_B2 R3_G3_B2}{@link GL11C#GL_RGB4 RGB4}{@link GL11C#GL_RGB5 RGB5}{@link GL41#GL_RGB565 RGB565}
{@link GL11C#GL_RGB8 RGB8}{@link GL31#GL_RGB8_SNORM RGB8_SNORM}{@link GL11C#GL_RGB10 RGB10}{@link GL11C#GL_RGB12 RGB12}{@link GL11C#GL_RGB16 RGB16}{@link GL31#GL_RGB16_SNORM RGB16_SNORM}
{@link GL11C#GL_RGBA2 RGBA2}{@link GL11C#GL_RGBA4 RGBA4}{@link GL11C#GL_RGB5_A1 RGB5_A1}{@link GL11C#GL_RGBA8 RGBA8}{@link GL31#GL_RGBA8_SNORM RGBA8_SNORM}{@link GL11C#GL_RGB10_A2 RGB10_A2}
{@link GL33#GL_RGB10_A2UI RGB10_A2UI}{@link GL11C#GL_RGBA12 RGBA12}{@link GL11C#GL_RGBA16 RGBA16}{@link GL31#GL_RGBA16_SNORM RGBA16_SNORM}{@link GL21#GL_SRGB8 SRGB8}{@link GL21#GL_SRGB8_ALPHA8 SRGB8_ALPHA8}
{@link GL30#GL_R16F R16F}{@link GL30#GL_RG16F RG16F}{@link GL30#GL_RGB16F RGB16F}{@link GL30#GL_RGBA16F RGBA16F}{@link GL30#GL_R32F R32F}{@link GL30#GL_RG32F RG32F}
{@link GL30#GL_RGB32F RGB32F}{@link GL30#GL_RGBA32F RGBA32F}{@link GL30#GL_R11F_G11F_B10F R11F_G11F_B10F}{@link GL30#GL_RGB9_E5 RGB9_E5}{@link GL30#GL_R8I R8I}{@link GL30#GL_R8UI R8UI}
{@link GL30#GL_R16I R16I}{@link GL30#GL_R16UI R16UI}{@link GL30#GL_R32I R32I}{@link GL30#GL_R32UI R32UI}{@link GL30#GL_RG8I RG8I}{@link GL30#GL_RG8UI RG8UI}
{@link GL30#GL_RG16I RG16I}{@link GL30#GL_RG16UI RG16UI}{@link GL30#GL_RG32I RG32I}{@link GL30#GL_RG32UI RG32UI}{@link GL30#GL_RGB8I RGB8I}{@link GL30#GL_RGB8UI RGB8UI}
{@link GL30#GL_RGB16I RGB16I}{@link GL30#GL_RGB16UI RGB16UI}{@link GL30#GL_RGB32I RGB32I}{@link GL30#GL_RGB32UI RGB32UI}{@link GL30#GL_RGBA8I RGBA8I}{@link GL30#GL_RGBA8UI RGBA8UI}
{@link GL30#GL_RGBA16I RGBA16I}{@link GL30#GL_RGBA16UI RGBA16UI}{@link GL30#GL_RGBA32I RGBA32I}{@link GL30#GL_RGBA32UI RGBA32UI}{@link GL14#GL_DEPTH_COMPONENT16 DEPTH_COMPONENT16}{@link GL14#GL_DEPTH_COMPONENT24 DEPTH_COMPONENT24}
{@link GL14#GL_DEPTH_COMPONENT32 DEPTH_COMPONENT32}{@link GL30#GL_DEPTH24_STENCIL8 DEPTH24_STENCIL8}{@link GL30#GL_DEPTH_COMPONENT32F DEPTH_COMPONENT32F}{@link GL30#GL_DEPTH32F_STENCIL8 DEPTH32F_STENCIL8}{@link GL30#GL_COMPRESSED_RED COMPRESSED_RED}{@link GL30#GL_COMPRESSED_RG COMPRESSED_RG}
{@link GL13#GL_COMPRESSED_RGB COMPRESSED_RGB}{@link GL13#GL_COMPRESSED_RGBA COMPRESSED_RGBA}{@link GL21#GL_COMPRESSED_SRGB COMPRESSED_SRGB}{@link GL21#GL_COMPRESSED_SRGB_ALPHA COMPRESSED_SRGB_ALPHA}{@link GL30#GL_COMPRESSED_RED_RGTC1 COMPRESSED_RED_RGTC1}{@link GL30#GL_COMPRESSED_SIGNED_RED_RGTC1 COMPRESSED_SIGNED_RED_RGTC1}
{@link GL30#GL_COMPRESSED_RG_RGTC2 COMPRESSED_RG_RGTC2}{@link GL30#GL_COMPRESSED_SIGNED_RG_RGTC2 COMPRESSED_SIGNED_RG_RGTC2}{@link GL42#GL_COMPRESSED_RGBA_BPTC_UNORM COMPRESSED_RGBA_BPTC_UNORM}{@link GL42#GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM COMPRESSED_SRGB_ALPHA_BPTC_UNORM}{@link GL42#GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT COMPRESSED_RGB_BPTC_SIGNED_FLOAT}{@link GL42#GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT}
{@link GL43#GL_COMPRESSED_RGB8_ETC2 COMPRESSED_RGB8_ETC2}{@link GL43#GL_COMPRESSED_SRGB8_ETC2 COMPRESSED_SRGB8_ETC2}{@link GL43#GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2}{@link GL43#GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2}{@link GL43#GL_COMPRESSED_RGBA8_ETC2_EAC COMPRESSED_RGBA8_ETC2_EAC}{@link GL43#GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC COMPRESSED_SRGB8_ALPHA8_ETC2_EAC}
{@link GL43#GL_COMPRESSED_R11_EAC COMPRESSED_R11_EAC}{@link GL43#GL_COMPRESSED_SIGNED_R11_EAC COMPRESSED_SIGNED_R11_EAC}{@link GL43#GL_COMPRESSED_RG11_EAC COMPRESSED_RG11_EAC}{@link GL43#GL_COMPRESSED_SIGNED_RG11_EAC COMPRESSED_SIGNED_RG11_EAC}see {@link EXTTextureCompressionS3TC}see {@link EXTTextureCompressionLATC}
see {@link ATITextureCompression3DC}
+ * @param width the texture width + * @param height the texture height + * @param border the texture border width + * @param format the texel data format. One of:
{@link GL11C#GL_RED RED}{@link GL11C#GL_GREEN GREEN}{@link GL11C#GL_BLUE BLUE}{@link GL11C#GL_ALPHA ALPHA}{@link GL30#GL_RG RG}{@link GL11C#GL_RGB RGB}{@link GL11C#GL_RGBA RGBA}{@link GL12#GL_BGR BGR}
{@link GL12#GL_BGRA BGRA}{@link GL30#GL_RED_INTEGER RED_INTEGER}{@link GL30#GL_GREEN_INTEGER GREEN_INTEGER}{@link GL30#GL_BLUE_INTEGER BLUE_INTEGER}{@link GL30#GL_ALPHA_INTEGER ALPHA_INTEGER}{@link GL30#GL_RG_INTEGER RG_INTEGER}{@link GL30#GL_RGB_INTEGER RGB_INTEGER}{@link GL30#GL_RGBA_INTEGER RGBA_INTEGER}
{@link GL30#GL_BGR_INTEGER BGR_INTEGER}{@link GL30#GL_BGRA_INTEGER BGRA_INTEGER}{@link GL11C#GL_STENCIL_INDEX STENCIL_INDEX}{@link GL11C#GL_DEPTH_COMPONENT DEPTH_COMPONENT}{@link GL30#GL_DEPTH_STENCIL DEPTH_STENCIL}
+ * @param type the texel data type. One of:
{@link GL11C#GL_UNSIGNED_BYTE UNSIGNED_BYTE}{@link GL11C#GL_BYTE BYTE}{@link GL11C#GL_UNSIGNED_SHORT UNSIGNED_SHORT}{@link GL11C#GL_SHORT SHORT}
{@link GL11C#GL_UNSIGNED_INT UNSIGNED_INT}{@link GL11C#GL_INT INT}{@link GL30#GL_HALF_FLOAT HALF_FLOAT}{@link GL11C#GL_FLOAT FLOAT}
{@link GL12#GL_UNSIGNED_BYTE_3_3_2 UNSIGNED_BYTE_3_3_2}{@link GL12#GL_UNSIGNED_BYTE_2_3_3_REV UNSIGNED_BYTE_2_3_3_REV}{@link GL12#GL_UNSIGNED_SHORT_5_6_5 UNSIGNED_SHORT_5_6_5}{@link GL12#GL_UNSIGNED_SHORT_5_6_5_REV UNSIGNED_SHORT_5_6_5_REV}
{@link GL12#GL_UNSIGNED_SHORT_4_4_4_4 UNSIGNED_SHORT_4_4_4_4}{@link GL12#GL_UNSIGNED_SHORT_4_4_4_4_REV UNSIGNED_SHORT_4_4_4_4_REV}{@link GL12#GL_UNSIGNED_SHORT_5_5_5_1 UNSIGNED_SHORT_5_5_5_1}{@link GL12#GL_UNSIGNED_SHORT_1_5_5_5_REV UNSIGNED_SHORT_1_5_5_5_REV}
{@link GL12#GL_UNSIGNED_INT_8_8_8_8 UNSIGNED_INT_8_8_8_8}{@link GL12#GL_UNSIGNED_INT_8_8_8_8_REV UNSIGNED_INT_8_8_8_8_REV}{@link GL12#GL_UNSIGNED_INT_10_10_10_2 UNSIGNED_INT_10_10_10_2}{@link GL12#GL_UNSIGNED_INT_2_10_10_10_REV UNSIGNED_INT_2_10_10_10_REV}
{@link GL30#GL_UNSIGNED_INT_24_8 UNSIGNED_INT_24_8}{@link GL30#GL_UNSIGNED_INT_10F_11F_11F_REV UNSIGNED_INT_10F_11F_11F_REV}{@link GL30#GL_UNSIGNED_INT_5_9_9_9_REV UNSIGNED_INT_5_9_9_9_REV}{@link GL30#GL_FLOAT_32_UNSIGNED_INT_24_8_REV FLOAT_32_UNSIGNED_INT_24_8_REV}
+ * @param pixels the texel data + * + * @see Reference Page + */ + public static void glTexImage2D(@NativeType("GLenum") int target, @NativeType("GLint") int level, @NativeType("GLint") int internalformat, @NativeType("GLsizei") int width, @NativeType("GLsizei") int height, @NativeType("GLint") int border, @NativeType("GLenum") int format, @NativeType("GLenum") int type, @Nullable @NativeType("void const *") ByteBuffer pixels) { + GL11C.glTexImage2D(target, level, internalformat, width, height, border, format, type, pixels); + } + + /** + * Specifies a two-dimensional texture image. + * + * @param target the texture target. One of:
{@link GL11C#GL_TEXTURE_2D TEXTURE_2D}{@link GL30#GL_TEXTURE_1D_ARRAY TEXTURE_1D_ARRAY}{@link GL31#GL_TEXTURE_RECTANGLE TEXTURE_RECTANGLE}{@link GL13#GL_TEXTURE_CUBE_MAP TEXTURE_CUBE_MAP}
{@link GL11C#GL_PROXY_TEXTURE_2D PROXY_TEXTURE_2D}{@link GL30#GL_PROXY_TEXTURE_1D_ARRAY PROXY_TEXTURE_1D_ARRAY}{@link GL31#GL_PROXY_TEXTURE_RECTANGLE PROXY_TEXTURE_RECTANGLE}{@link GL13#GL_PROXY_TEXTURE_CUBE_MAP PROXY_TEXTURE_CUBE_MAP}
+ * @param level the level-of-detail number + * @param internalformat the texture internal format. One of:
{@link GL11C#GL_RED RED}{@link GL30#GL_RG RG}{@link GL11C#GL_RGB RGB}{@link GL11C#GL_RGBA RGBA}{@link GL11C#GL_DEPTH_COMPONENT DEPTH_COMPONENT}{@link GL30#GL_DEPTH_STENCIL DEPTH_STENCIL}
{@link GL30#GL_R8 R8}{@link GL31#GL_R8_SNORM R8_SNORM}{@link GL30#GL_R16 R16}{@link GL31#GL_R16_SNORM R16_SNORM}{@link GL30#GL_RG8 RG8}{@link GL31#GL_RG8_SNORM RG8_SNORM}
{@link GL30#GL_RG16 RG16}{@link GL31#GL_RG16_SNORM RG16_SNORM}{@link GL11C#GL_R3_G3_B2 R3_G3_B2}{@link GL11C#GL_RGB4 RGB4}{@link GL11C#GL_RGB5 RGB5}{@link GL41#GL_RGB565 RGB565}
{@link GL11C#GL_RGB8 RGB8}{@link GL31#GL_RGB8_SNORM RGB8_SNORM}{@link GL11C#GL_RGB10 RGB10}{@link GL11C#GL_RGB12 RGB12}{@link GL11C#GL_RGB16 RGB16}{@link GL31#GL_RGB16_SNORM RGB16_SNORM}
{@link GL11C#GL_RGBA2 RGBA2}{@link GL11C#GL_RGBA4 RGBA4}{@link GL11C#GL_RGB5_A1 RGB5_A1}{@link GL11C#GL_RGBA8 RGBA8}{@link GL31#GL_RGBA8_SNORM RGBA8_SNORM}{@link GL11C#GL_RGB10_A2 RGB10_A2}
{@link GL33#GL_RGB10_A2UI RGB10_A2UI}{@link GL11C#GL_RGBA12 RGBA12}{@link GL11C#GL_RGBA16 RGBA16}{@link GL31#GL_RGBA16_SNORM RGBA16_SNORM}{@link GL21#GL_SRGB8 SRGB8}{@link GL21#GL_SRGB8_ALPHA8 SRGB8_ALPHA8}
{@link GL30#GL_R16F R16F}{@link GL30#GL_RG16F RG16F}{@link GL30#GL_RGB16F RGB16F}{@link GL30#GL_RGBA16F RGBA16F}{@link GL30#GL_R32F R32F}{@link GL30#GL_RG32F RG32F}
{@link GL30#GL_RGB32F RGB32F}{@link GL30#GL_RGBA32F RGBA32F}{@link GL30#GL_R11F_G11F_B10F R11F_G11F_B10F}{@link GL30#GL_RGB9_E5 RGB9_E5}{@link GL30#GL_R8I R8I}{@link GL30#GL_R8UI R8UI}
{@link GL30#GL_R16I R16I}{@link GL30#GL_R16UI R16UI}{@link GL30#GL_R32I R32I}{@link GL30#GL_R32UI R32UI}{@link GL30#GL_RG8I RG8I}{@link GL30#GL_RG8UI RG8UI}
{@link GL30#GL_RG16I RG16I}{@link GL30#GL_RG16UI RG16UI}{@link GL30#GL_RG32I RG32I}{@link GL30#GL_RG32UI RG32UI}{@link GL30#GL_RGB8I RGB8I}{@link GL30#GL_RGB8UI RGB8UI}
{@link GL30#GL_RGB16I RGB16I}{@link GL30#GL_RGB16UI RGB16UI}{@link GL30#GL_RGB32I RGB32I}{@link GL30#GL_RGB32UI RGB32UI}{@link GL30#GL_RGBA8I RGBA8I}{@link GL30#GL_RGBA8UI RGBA8UI}
{@link GL30#GL_RGBA16I RGBA16I}{@link GL30#GL_RGBA16UI RGBA16UI}{@link GL30#GL_RGBA32I RGBA32I}{@link GL30#GL_RGBA32UI RGBA32UI}{@link GL14#GL_DEPTH_COMPONENT16 DEPTH_COMPONENT16}{@link GL14#GL_DEPTH_COMPONENT24 DEPTH_COMPONENT24}
{@link GL14#GL_DEPTH_COMPONENT32 DEPTH_COMPONENT32}{@link GL30#GL_DEPTH24_STENCIL8 DEPTH24_STENCIL8}{@link GL30#GL_DEPTH_COMPONENT32F DEPTH_COMPONENT32F}{@link GL30#GL_DEPTH32F_STENCIL8 DEPTH32F_STENCIL8}{@link GL30#GL_COMPRESSED_RED COMPRESSED_RED}{@link GL30#GL_COMPRESSED_RG COMPRESSED_RG}
{@link GL13#GL_COMPRESSED_RGB COMPRESSED_RGB}{@link GL13#GL_COMPRESSED_RGBA COMPRESSED_RGBA}{@link GL21#GL_COMPRESSED_SRGB COMPRESSED_SRGB}{@link GL21#GL_COMPRESSED_SRGB_ALPHA COMPRESSED_SRGB_ALPHA}{@link GL30#GL_COMPRESSED_RED_RGTC1 COMPRESSED_RED_RGTC1}{@link GL30#GL_COMPRESSED_SIGNED_RED_RGTC1 COMPRESSED_SIGNED_RED_RGTC1}
{@link GL30#GL_COMPRESSED_RG_RGTC2 COMPRESSED_RG_RGTC2}{@link GL30#GL_COMPRESSED_SIGNED_RG_RGTC2 COMPRESSED_SIGNED_RG_RGTC2}{@link GL42#GL_COMPRESSED_RGBA_BPTC_UNORM COMPRESSED_RGBA_BPTC_UNORM}{@link GL42#GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM COMPRESSED_SRGB_ALPHA_BPTC_UNORM}{@link GL42#GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT COMPRESSED_RGB_BPTC_SIGNED_FLOAT}{@link GL42#GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT}
{@link GL43#GL_COMPRESSED_RGB8_ETC2 COMPRESSED_RGB8_ETC2}{@link GL43#GL_COMPRESSED_SRGB8_ETC2 COMPRESSED_SRGB8_ETC2}{@link GL43#GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2}{@link GL43#GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2}{@link GL43#GL_COMPRESSED_RGBA8_ETC2_EAC COMPRESSED_RGBA8_ETC2_EAC}{@link GL43#GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC COMPRESSED_SRGB8_ALPHA8_ETC2_EAC}
{@link GL43#GL_COMPRESSED_R11_EAC COMPRESSED_R11_EAC}{@link GL43#GL_COMPRESSED_SIGNED_R11_EAC COMPRESSED_SIGNED_R11_EAC}{@link GL43#GL_COMPRESSED_RG11_EAC COMPRESSED_RG11_EAC}{@link GL43#GL_COMPRESSED_SIGNED_RG11_EAC COMPRESSED_SIGNED_RG11_EAC}see {@link EXTTextureCompressionS3TC}see {@link EXTTextureCompressionLATC}
see {@link ATITextureCompression3DC}
+ * @param width the texture width + * @param height the texture height + * @param border the texture border width + * @param format the texel data format. One of:
{@link GL11C#GL_RED RED}{@link GL11C#GL_GREEN GREEN}{@link GL11C#GL_BLUE BLUE}{@link GL11C#GL_ALPHA ALPHA}{@link GL30#GL_RG RG}{@link GL11C#GL_RGB RGB}{@link GL11C#GL_RGBA RGBA}{@link GL12#GL_BGR BGR}
{@link GL12#GL_BGRA BGRA}{@link GL30#GL_RED_INTEGER RED_INTEGER}{@link GL30#GL_GREEN_INTEGER GREEN_INTEGER}{@link GL30#GL_BLUE_INTEGER BLUE_INTEGER}{@link GL30#GL_ALPHA_INTEGER ALPHA_INTEGER}{@link GL30#GL_RG_INTEGER RG_INTEGER}{@link GL30#GL_RGB_INTEGER RGB_INTEGER}{@link GL30#GL_RGBA_INTEGER RGBA_INTEGER}
{@link GL30#GL_BGR_INTEGER BGR_INTEGER}{@link GL30#GL_BGRA_INTEGER BGRA_INTEGER}{@link GL11C#GL_STENCIL_INDEX STENCIL_INDEX}{@link GL11C#GL_DEPTH_COMPONENT DEPTH_COMPONENT}{@link GL30#GL_DEPTH_STENCIL DEPTH_STENCIL}
+ * @param type the texel data type. One of:
{@link GL11C#GL_UNSIGNED_BYTE UNSIGNED_BYTE}{@link GL11C#GL_BYTE BYTE}{@link GL11C#GL_UNSIGNED_SHORT UNSIGNED_SHORT}{@link GL11C#GL_SHORT SHORT}
{@link GL11C#GL_UNSIGNED_INT UNSIGNED_INT}{@link GL11C#GL_INT INT}{@link GL30#GL_HALF_FLOAT HALF_FLOAT}{@link GL11C#GL_FLOAT FLOAT}
{@link GL12#GL_UNSIGNED_BYTE_3_3_2 UNSIGNED_BYTE_3_3_2}{@link GL12#GL_UNSIGNED_BYTE_2_3_3_REV UNSIGNED_BYTE_2_3_3_REV}{@link GL12#GL_UNSIGNED_SHORT_5_6_5 UNSIGNED_SHORT_5_6_5}{@link GL12#GL_UNSIGNED_SHORT_5_6_5_REV UNSIGNED_SHORT_5_6_5_REV}
{@link GL12#GL_UNSIGNED_SHORT_4_4_4_4 UNSIGNED_SHORT_4_4_4_4}{@link GL12#GL_UNSIGNED_SHORT_4_4_4_4_REV UNSIGNED_SHORT_4_4_4_4_REV}{@link GL12#GL_UNSIGNED_SHORT_5_5_5_1 UNSIGNED_SHORT_5_5_5_1}{@link GL12#GL_UNSIGNED_SHORT_1_5_5_5_REV UNSIGNED_SHORT_1_5_5_5_REV}
{@link GL12#GL_UNSIGNED_INT_8_8_8_8 UNSIGNED_INT_8_8_8_8}{@link GL12#GL_UNSIGNED_INT_8_8_8_8_REV UNSIGNED_INT_8_8_8_8_REV}{@link GL12#GL_UNSIGNED_INT_10_10_10_2 UNSIGNED_INT_10_10_10_2}{@link GL12#GL_UNSIGNED_INT_2_10_10_10_REV UNSIGNED_INT_2_10_10_10_REV}
{@link GL30#GL_UNSIGNED_INT_24_8 UNSIGNED_INT_24_8}{@link GL30#GL_UNSIGNED_INT_10F_11F_11F_REV UNSIGNED_INT_10F_11F_11F_REV}{@link GL30#GL_UNSIGNED_INT_5_9_9_9_REV UNSIGNED_INT_5_9_9_9_REV}{@link GL30#GL_FLOAT_32_UNSIGNED_INT_24_8_REV FLOAT_32_UNSIGNED_INT_24_8_REV}
+ * @param pixels the texel data + * + * @see Reference Page + */ + public static void glTexImage2D(@NativeType("GLenum") int target, @NativeType("GLint") int level, @NativeType("GLint") int internalformat, @NativeType("GLsizei") int width, @NativeType("GLsizei") int height, @NativeType("GLint") int border, @NativeType("GLenum") int format, @NativeType("GLenum") int type, @Nullable @NativeType("void const *") long pixels) { + GL11C.glTexImage2D(target, level, internalformat, width, height, border, format, type, pixels); + } + + /** + * Specifies a two-dimensional texture image. + * + * @param target the texture target. One of:
{@link GL11C#GL_TEXTURE_2D TEXTURE_2D}{@link GL30#GL_TEXTURE_1D_ARRAY TEXTURE_1D_ARRAY}{@link GL31#GL_TEXTURE_RECTANGLE TEXTURE_RECTANGLE}{@link GL13#GL_TEXTURE_CUBE_MAP TEXTURE_CUBE_MAP}
{@link GL11C#GL_PROXY_TEXTURE_2D PROXY_TEXTURE_2D}{@link GL30#GL_PROXY_TEXTURE_1D_ARRAY PROXY_TEXTURE_1D_ARRAY}{@link GL31#GL_PROXY_TEXTURE_RECTANGLE PROXY_TEXTURE_RECTANGLE}{@link GL13#GL_PROXY_TEXTURE_CUBE_MAP PROXY_TEXTURE_CUBE_MAP}
+ * @param level the level-of-detail number + * @param internalformat the texture internal format. One of:
{@link GL11C#GL_RED RED}{@link GL30#GL_RG RG}{@link GL11C#GL_RGB RGB}{@link GL11C#GL_RGBA RGBA}{@link GL11C#GL_DEPTH_COMPONENT DEPTH_COMPONENT}{@link GL30#GL_DEPTH_STENCIL DEPTH_STENCIL}
{@link GL30#GL_R8 R8}{@link GL31#GL_R8_SNORM R8_SNORM}{@link GL30#GL_R16 R16}{@link GL31#GL_R16_SNORM R16_SNORM}{@link GL30#GL_RG8 RG8}{@link GL31#GL_RG8_SNORM RG8_SNORM}
{@link GL30#GL_RG16 RG16}{@link GL31#GL_RG16_SNORM RG16_SNORM}{@link GL11C#GL_R3_G3_B2 R3_G3_B2}{@link GL11C#GL_RGB4 RGB4}{@link GL11C#GL_RGB5 RGB5}{@link GL41#GL_RGB565 RGB565}
{@link GL11C#GL_RGB8 RGB8}{@link GL31#GL_RGB8_SNORM RGB8_SNORM}{@link GL11C#GL_RGB10 RGB10}{@link GL11C#GL_RGB12 RGB12}{@link GL11C#GL_RGB16 RGB16}{@link GL31#GL_RGB16_SNORM RGB16_SNORM}
{@link GL11C#GL_RGBA2 RGBA2}{@link GL11C#GL_RGBA4 RGBA4}{@link GL11C#GL_RGB5_A1 RGB5_A1}{@link GL11C#GL_RGBA8 RGBA8}{@link GL31#GL_RGBA8_SNORM RGBA8_SNORM}{@link GL11C#GL_RGB10_A2 RGB10_A2}
{@link GL33#GL_RGB10_A2UI RGB10_A2UI}{@link GL11C#GL_RGBA12 RGBA12}{@link GL11C#GL_RGBA16 RGBA16}{@link GL31#GL_RGBA16_SNORM RGBA16_SNORM}{@link GL21#GL_SRGB8 SRGB8}{@link GL21#GL_SRGB8_ALPHA8 SRGB8_ALPHA8}
{@link GL30#GL_R16F R16F}{@link GL30#GL_RG16F RG16F}{@link GL30#GL_RGB16F RGB16F}{@link GL30#GL_RGBA16F RGBA16F}{@link GL30#GL_R32F R32F}{@link GL30#GL_RG32F RG32F}
{@link GL30#GL_RGB32F RGB32F}{@link GL30#GL_RGBA32F RGBA32F}{@link GL30#GL_R11F_G11F_B10F R11F_G11F_B10F}{@link GL30#GL_RGB9_E5 RGB9_E5}{@link GL30#GL_R8I R8I}{@link GL30#GL_R8UI R8UI}
{@link GL30#GL_R16I R16I}{@link GL30#GL_R16UI R16UI}{@link GL30#GL_R32I R32I}{@link GL30#GL_R32UI R32UI}{@link GL30#GL_RG8I RG8I}{@link GL30#GL_RG8UI RG8UI}
{@link GL30#GL_RG16I RG16I}{@link GL30#GL_RG16UI RG16UI}{@link GL30#GL_RG32I RG32I}{@link GL30#GL_RG32UI RG32UI}{@link GL30#GL_RGB8I RGB8I}{@link GL30#GL_RGB8UI RGB8UI}
{@link GL30#GL_RGB16I RGB16I}{@link GL30#GL_RGB16UI RGB16UI}{@link GL30#GL_RGB32I RGB32I}{@link GL30#GL_RGB32UI RGB32UI}{@link GL30#GL_RGBA8I RGBA8I}{@link GL30#GL_RGBA8UI RGBA8UI}
{@link GL30#GL_RGBA16I RGBA16I}{@link GL30#GL_RGBA16UI RGBA16UI}{@link GL30#GL_RGBA32I RGBA32I}{@link GL30#GL_RGBA32UI RGBA32UI}{@link GL14#GL_DEPTH_COMPONENT16 DEPTH_COMPONENT16}{@link GL14#GL_DEPTH_COMPONENT24 DEPTH_COMPONENT24}
{@link GL14#GL_DEPTH_COMPONENT32 DEPTH_COMPONENT32}{@link GL30#GL_DEPTH24_STENCIL8 DEPTH24_STENCIL8}{@link GL30#GL_DEPTH_COMPONENT32F DEPTH_COMPONENT32F}{@link GL30#GL_DEPTH32F_STENCIL8 DEPTH32F_STENCIL8}{@link GL30#GL_COMPRESSED_RED COMPRESSED_RED}{@link GL30#GL_COMPRESSED_RG COMPRESSED_RG}
{@link GL13#GL_COMPRESSED_RGB COMPRESSED_RGB}{@link GL13#GL_COMPRESSED_RGBA COMPRESSED_RGBA}{@link GL21#GL_COMPRESSED_SRGB COMPRESSED_SRGB}{@link GL21#GL_COMPRESSED_SRGB_ALPHA COMPRESSED_SRGB_ALPHA}{@link GL30#GL_COMPRESSED_RED_RGTC1 COMPRESSED_RED_RGTC1}{@link GL30#GL_COMPRESSED_SIGNED_RED_RGTC1 COMPRESSED_SIGNED_RED_RGTC1}
{@link GL30#GL_COMPRESSED_RG_RGTC2 COMPRESSED_RG_RGTC2}{@link GL30#GL_COMPRESSED_SIGNED_RG_RGTC2 COMPRESSED_SIGNED_RG_RGTC2}{@link GL42#GL_COMPRESSED_RGBA_BPTC_UNORM COMPRESSED_RGBA_BPTC_UNORM}{@link GL42#GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM COMPRESSED_SRGB_ALPHA_BPTC_UNORM}{@link GL42#GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT COMPRESSED_RGB_BPTC_SIGNED_FLOAT}{@link GL42#GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT}
{@link GL43#GL_COMPRESSED_RGB8_ETC2 COMPRESSED_RGB8_ETC2}{@link GL43#GL_COMPRESSED_SRGB8_ETC2 COMPRESSED_SRGB8_ETC2}{@link GL43#GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2}{@link GL43#GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2}{@link GL43#GL_COMPRESSED_RGBA8_ETC2_EAC COMPRESSED_RGBA8_ETC2_EAC}{@link GL43#GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC COMPRESSED_SRGB8_ALPHA8_ETC2_EAC}
{@link GL43#GL_COMPRESSED_R11_EAC COMPRESSED_R11_EAC}{@link GL43#GL_COMPRESSED_SIGNED_R11_EAC COMPRESSED_SIGNED_R11_EAC}{@link GL43#GL_COMPRESSED_RG11_EAC COMPRESSED_RG11_EAC}{@link GL43#GL_COMPRESSED_SIGNED_RG11_EAC COMPRESSED_SIGNED_RG11_EAC}see {@link EXTTextureCompressionS3TC}see {@link EXTTextureCompressionLATC}
see {@link ATITextureCompression3DC}
+ * @param width the texture width + * @param height the texture height + * @param border the texture border width + * @param format the texel data format. One of:
{@link GL11C#GL_RED RED}{@link GL11C#GL_GREEN GREEN}{@link GL11C#GL_BLUE BLUE}{@link GL11C#GL_ALPHA ALPHA}{@link GL30#GL_RG RG}{@link GL11C#GL_RGB RGB}{@link GL11C#GL_RGBA RGBA}{@link GL12#GL_BGR BGR}
{@link GL12#GL_BGRA BGRA}{@link GL30#GL_RED_INTEGER RED_INTEGER}{@link GL30#GL_GREEN_INTEGER GREEN_INTEGER}{@link GL30#GL_BLUE_INTEGER BLUE_INTEGER}{@link GL30#GL_ALPHA_INTEGER ALPHA_INTEGER}{@link GL30#GL_RG_INTEGER RG_INTEGER}{@link GL30#GL_RGB_INTEGER RGB_INTEGER}{@link GL30#GL_RGBA_INTEGER RGBA_INTEGER}
{@link GL30#GL_BGR_INTEGER BGR_INTEGER}{@link GL30#GL_BGRA_INTEGER BGRA_INTEGER}{@link GL11C#GL_STENCIL_INDEX STENCIL_INDEX}{@link GL11C#GL_DEPTH_COMPONENT DEPTH_COMPONENT}{@link GL30#GL_DEPTH_STENCIL DEPTH_STENCIL}
+ * @param type the texel data type. One of:
{@link GL11C#GL_UNSIGNED_BYTE UNSIGNED_BYTE}{@link GL11C#GL_BYTE BYTE}{@link GL11C#GL_UNSIGNED_SHORT UNSIGNED_SHORT}{@link GL11C#GL_SHORT SHORT}
{@link GL11C#GL_UNSIGNED_INT UNSIGNED_INT}{@link GL11C#GL_INT INT}{@link GL30#GL_HALF_FLOAT HALF_FLOAT}{@link GL11C#GL_FLOAT FLOAT}
{@link GL12#GL_UNSIGNED_BYTE_3_3_2 UNSIGNED_BYTE_3_3_2}{@link GL12#GL_UNSIGNED_BYTE_2_3_3_REV UNSIGNED_BYTE_2_3_3_REV}{@link GL12#GL_UNSIGNED_SHORT_5_6_5 UNSIGNED_SHORT_5_6_5}{@link GL12#GL_UNSIGNED_SHORT_5_6_5_REV UNSIGNED_SHORT_5_6_5_REV}
{@link GL12#GL_UNSIGNED_SHORT_4_4_4_4 UNSIGNED_SHORT_4_4_4_4}{@link GL12#GL_UNSIGNED_SHORT_4_4_4_4_REV UNSIGNED_SHORT_4_4_4_4_REV}{@link GL12#GL_UNSIGNED_SHORT_5_5_5_1 UNSIGNED_SHORT_5_5_5_1}{@link GL12#GL_UNSIGNED_SHORT_1_5_5_5_REV UNSIGNED_SHORT_1_5_5_5_REV}
{@link GL12#GL_UNSIGNED_INT_8_8_8_8 UNSIGNED_INT_8_8_8_8}{@link GL12#GL_UNSIGNED_INT_8_8_8_8_REV UNSIGNED_INT_8_8_8_8_REV}{@link GL12#GL_UNSIGNED_INT_10_10_10_2 UNSIGNED_INT_10_10_10_2}{@link GL12#GL_UNSIGNED_INT_2_10_10_10_REV UNSIGNED_INT_2_10_10_10_REV}
{@link GL30#GL_UNSIGNED_INT_24_8 UNSIGNED_INT_24_8}{@link GL30#GL_UNSIGNED_INT_10F_11F_11F_REV UNSIGNED_INT_10F_11F_11F_REV}{@link GL30#GL_UNSIGNED_INT_5_9_9_9_REV UNSIGNED_INT_5_9_9_9_REV}{@link GL30#GL_FLOAT_32_UNSIGNED_INT_24_8_REV FLOAT_32_UNSIGNED_INT_24_8_REV}
+ * @param pixels the texel data + * + * @see Reference Page + */ + public static void glTexImage2D(@NativeType("GLenum") int target, @NativeType("GLint") int level, @NativeType("GLint") int internalformat, @NativeType("GLsizei") int width, @NativeType("GLsizei") int height, @NativeType("GLint") int border, @NativeType("GLenum") int format, @NativeType("GLenum") int type, @Nullable @NativeType("void const *") ShortBuffer pixels) { + GL11C.glTexImage2D(target, level, internalformat, width, height, border, format, type, pixels); + } + + /** + * Specifies a two-dimensional texture image. + * + * @param target the texture target. One of:
{@link GL11C#GL_TEXTURE_2D TEXTURE_2D}{@link GL30#GL_TEXTURE_1D_ARRAY TEXTURE_1D_ARRAY}{@link GL31#GL_TEXTURE_RECTANGLE TEXTURE_RECTANGLE}{@link GL13#GL_TEXTURE_CUBE_MAP TEXTURE_CUBE_MAP}
{@link GL11C#GL_PROXY_TEXTURE_2D PROXY_TEXTURE_2D}{@link GL30#GL_PROXY_TEXTURE_1D_ARRAY PROXY_TEXTURE_1D_ARRAY}{@link GL31#GL_PROXY_TEXTURE_RECTANGLE PROXY_TEXTURE_RECTANGLE}{@link GL13#GL_PROXY_TEXTURE_CUBE_MAP PROXY_TEXTURE_CUBE_MAP}
+ * @param level the level-of-detail number + * @param internalformat the texture internal format. One of:
{@link GL11C#GL_RED RED}{@link GL30#GL_RG RG}{@link GL11C#GL_RGB RGB}{@link GL11C#GL_RGBA RGBA}{@link GL11C#GL_DEPTH_COMPONENT DEPTH_COMPONENT}{@link GL30#GL_DEPTH_STENCIL DEPTH_STENCIL}
{@link GL30#GL_R8 R8}{@link GL31#GL_R8_SNORM R8_SNORM}{@link GL30#GL_R16 R16}{@link GL31#GL_R16_SNORM R16_SNORM}{@link GL30#GL_RG8 RG8}{@link GL31#GL_RG8_SNORM RG8_SNORM}
{@link GL30#GL_RG16 RG16}{@link GL31#GL_RG16_SNORM RG16_SNORM}{@link GL11C#GL_R3_G3_B2 R3_G3_B2}{@link GL11C#GL_RGB4 RGB4}{@link GL11C#GL_RGB5 RGB5}{@link GL41#GL_RGB565 RGB565}
{@link GL11C#GL_RGB8 RGB8}{@link GL31#GL_RGB8_SNORM RGB8_SNORM}{@link GL11C#GL_RGB10 RGB10}{@link GL11C#GL_RGB12 RGB12}{@link GL11C#GL_RGB16 RGB16}{@link GL31#GL_RGB16_SNORM RGB16_SNORM}
{@link GL11C#GL_RGBA2 RGBA2}{@link GL11C#GL_RGBA4 RGBA4}{@link GL11C#GL_RGB5_A1 RGB5_A1}{@link GL11C#GL_RGBA8 RGBA8}{@link GL31#GL_RGBA8_SNORM RGBA8_SNORM}{@link GL11C#GL_RGB10_A2 RGB10_A2}
{@link GL33#GL_RGB10_A2UI RGB10_A2UI}{@link GL11C#GL_RGBA12 RGBA12}{@link GL11C#GL_RGBA16 RGBA16}{@link GL31#GL_RGBA16_SNORM RGBA16_SNORM}{@link GL21#GL_SRGB8 SRGB8}{@link GL21#GL_SRGB8_ALPHA8 SRGB8_ALPHA8}
{@link GL30#GL_R16F R16F}{@link GL30#GL_RG16F RG16F}{@link GL30#GL_RGB16F RGB16F}{@link GL30#GL_RGBA16F RGBA16F}{@link GL30#GL_R32F R32F}{@link GL30#GL_RG32F RG32F}
{@link GL30#GL_RGB32F RGB32F}{@link GL30#GL_RGBA32F RGBA32F}{@link GL30#GL_R11F_G11F_B10F R11F_G11F_B10F}{@link GL30#GL_RGB9_E5 RGB9_E5}{@link GL30#GL_R8I R8I}{@link GL30#GL_R8UI R8UI}
{@link GL30#GL_R16I R16I}{@link GL30#GL_R16UI R16UI}{@link GL30#GL_R32I R32I}{@link GL30#GL_R32UI R32UI}{@link GL30#GL_RG8I RG8I}{@link GL30#GL_RG8UI RG8UI}
{@link GL30#GL_RG16I RG16I}{@link GL30#GL_RG16UI RG16UI}{@link GL30#GL_RG32I RG32I}{@link GL30#GL_RG32UI RG32UI}{@link GL30#GL_RGB8I RGB8I}{@link GL30#GL_RGB8UI RGB8UI}
{@link GL30#GL_RGB16I RGB16I}{@link GL30#GL_RGB16UI RGB16UI}{@link GL30#GL_RGB32I RGB32I}{@link GL30#GL_RGB32UI RGB32UI}{@link GL30#GL_RGBA8I RGBA8I}{@link GL30#GL_RGBA8UI RGBA8UI}
{@link GL30#GL_RGBA16I RGBA16I}{@link GL30#GL_RGBA16UI RGBA16UI}{@link GL30#GL_RGBA32I RGBA32I}{@link GL30#GL_RGBA32UI RGBA32UI}{@link GL14#GL_DEPTH_COMPONENT16 DEPTH_COMPONENT16}{@link GL14#GL_DEPTH_COMPONENT24 DEPTH_COMPONENT24}
{@link GL14#GL_DEPTH_COMPONENT32 DEPTH_COMPONENT32}{@link GL30#GL_DEPTH24_STENCIL8 DEPTH24_STENCIL8}{@link GL30#GL_DEPTH_COMPONENT32F DEPTH_COMPONENT32F}{@link GL30#GL_DEPTH32F_STENCIL8 DEPTH32F_STENCIL8}{@link GL30#GL_COMPRESSED_RED COMPRESSED_RED}{@link GL30#GL_COMPRESSED_RG COMPRESSED_RG}
{@link GL13#GL_COMPRESSED_RGB COMPRESSED_RGB}{@link GL13#GL_COMPRESSED_RGBA COMPRESSED_RGBA}{@link GL21#GL_COMPRESSED_SRGB COMPRESSED_SRGB}{@link GL21#GL_COMPRESSED_SRGB_ALPHA COMPRESSED_SRGB_ALPHA}{@link GL30#GL_COMPRESSED_RED_RGTC1 COMPRESSED_RED_RGTC1}{@link GL30#GL_COMPRESSED_SIGNED_RED_RGTC1 COMPRESSED_SIGNED_RED_RGTC1}
{@link GL30#GL_COMPRESSED_RG_RGTC2 COMPRESSED_RG_RGTC2}{@link GL30#GL_COMPRESSED_SIGNED_RG_RGTC2 COMPRESSED_SIGNED_RG_RGTC2}{@link GL42#GL_COMPRESSED_RGBA_BPTC_UNORM COMPRESSED_RGBA_BPTC_UNORM}{@link GL42#GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM COMPRESSED_SRGB_ALPHA_BPTC_UNORM}{@link GL42#GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT COMPRESSED_RGB_BPTC_SIGNED_FLOAT}{@link GL42#GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT}
{@link GL43#GL_COMPRESSED_RGB8_ETC2 COMPRESSED_RGB8_ETC2}{@link GL43#GL_COMPRESSED_SRGB8_ETC2 COMPRESSED_SRGB8_ETC2}{@link GL43#GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2}{@link GL43#GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2}{@link GL43#GL_COMPRESSED_RGBA8_ETC2_EAC COMPRESSED_RGBA8_ETC2_EAC}{@link GL43#GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC COMPRESSED_SRGB8_ALPHA8_ETC2_EAC}
{@link GL43#GL_COMPRESSED_R11_EAC COMPRESSED_R11_EAC}{@link GL43#GL_COMPRESSED_SIGNED_R11_EAC COMPRESSED_SIGNED_R11_EAC}{@link GL43#GL_COMPRESSED_RG11_EAC COMPRESSED_RG11_EAC}{@link GL43#GL_COMPRESSED_SIGNED_RG11_EAC COMPRESSED_SIGNED_RG11_EAC}see {@link EXTTextureCompressionS3TC}see {@link EXTTextureCompressionLATC}
see {@link ATITextureCompression3DC}
+ * @param width the texture width + * @param height the texture height + * @param border the texture border width + * @param format the texel data format. One of:
{@link GL11C#GL_RED RED}{@link GL11C#GL_GREEN GREEN}{@link GL11C#GL_BLUE BLUE}{@link GL11C#GL_ALPHA ALPHA}{@link GL30#GL_RG RG}{@link GL11C#GL_RGB RGB}{@link GL11C#GL_RGBA RGBA}{@link GL12#GL_BGR BGR}
{@link GL12#GL_BGRA BGRA}{@link GL30#GL_RED_INTEGER RED_INTEGER}{@link GL30#GL_GREEN_INTEGER GREEN_INTEGER}{@link GL30#GL_BLUE_INTEGER BLUE_INTEGER}{@link GL30#GL_ALPHA_INTEGER ALPHA_INTEGER}{@link GL30#GL_RG_INTEGER RG_INTEGER}{@link GL30#GL_RGB_INTEGER RGB_INTEGER}{@link GL30#GL_RGBA_INTEGER RGBA_INTEGER}
{@link GL30#GL_BGR_INTEGER BGR_INTEGER}{@link GL30#GL_BGRA_INTEGER BGRA_INTEGER}{@link GL11C#GL_STENCIL_INDEX STENCIL_INDEX}{@link GL11C#GL_DEPTH_COMPONENT DEPTH_COMPONENT}{@link GL30#GL_DEPTH_STENCIL DEPTH_STENCIL}
+ * @param type the texel data type. One of:
{@link GL11C#GL_UNSIGNED_BYTE UNSIGNED_BYTE}{@link GL11C#GL_BYTE BYTE}{@link GL11C#GL_UNSIGNED_SHORT UNSIGNED_SHORT}{@link GL11C#GL_SHORT SHORT}
{@link GL11C#GL_UNSIGNED_INT UNSIGNED_INT}{@link GL11C#GL_INT INT}{@link GL30#GL_HALF_FLOAT HALF_FLOAT}{@link GL11C#GL_FLOAT FLOAT}
{@link GL12#GL_UNSIGNED_BYTE_3_3_2 UNSIGNED_BYTE_3_3_2}{@link GL12#GL_UNSIGNED_BYTE_2_3_3_REV UNSIGNED_BYTE_2_3_3_REV}{@link GL12#GL_UNSIGNED_SHORT_5_6_5 UNSIGNED_SHORT_5_6_5}{@link GL12#GL_UNSIGNED_SHORT_5_6_5_REV UNSIGNED_SHORT_5_6_5_REV}
{@link GL12#GL_UNSIGNED_SHORT_4_4_4_4 UNSIGNED_SHORT_4_4_4_4}{@link GL12#GL_UNSIGNED_SHORT_4_4_4_4_REV UNSIGNED_SHORT_4_4_4_4_REV}{@link GL12#GL_UNSIGNED_SHORT_5_5_5_1 UNSIGNED_SHORT_5_5_5_1}{@link GL12#GL_UNSIGNED_SHORT_1_5_5_5_REV UNSIGNED_SHORT_1_5_5_5_REV}
{@link GL12#GL_UNSIGNED_INT_8_8_8_8 UNSIGNED_INT_8_8_8_8}{@link GL12#GL_UNSIGNED_INT_8_8_8_8_REV UNSIGNED_INT_8_8_8_8_REV}{@link GL12#GL_UNSIGNED_INT_10_10_10_2 UNSIGNED_INT_10_10_10_2}{@link GL12#GL_UNSIGNED_INT_2_10_10_10_REV UNSIGNED_INT_2_10_10_10_REV}
{@link GL30#GL_UNSIGNED_INT_24_8 UNSIGNED_INT_24_8}{@link GL30#GL_UNSIGNED_INT_10F_11F_11F_REV UNSIGNED_INT_10F_11F_11F_REV}{@link GL30#GL_UNSIGNED_INT_5_9_9_9_REV UNSIGNED_INT_5_9_9_9_REV}{@link GL30#GL_FLOAT_32_UNSIGNED_INT_24_8_REV FLOAT_32_UNSIGNED_INT_24_8_REV}
+ * @param pixels the texel data + * + * @see Reference Page + */ + public static void glTexImage2D(@NativeType("GLenum") int target, @NativeType("GLint") int level, @NativeType("GLint") int internalformat, @NativeType("GLsizei") int width, @NativeType("GLsizei") int height, @NativeType("GLint") int border, @NativeType("GLenum") int format, @NativeType("GLenum") int type, @Nullable @NativeType("void const *") IntBuffer pixels) { + GL11C.glTexImage2D(target, level, internalformat, width, height, border, format, type, pixels); + } + + /** + * Specifies a two-dimensional texture image. + * + * @param target the texture target. One of:
{@link GL11C#GL_TEXTURE_2D TEXTURE_2D}{@link GL30#GL_TEXTURE_1D_ARRAY TEXTURE_1D_ARRAY}{@link GL31#GL_TEXTURE_RECTANGLE TEXTURE_RECTANGLE}{@link GL13#GL_TEXTURE_CUBE_MAP TEXTURE_CUBE_MAP}
{@link GL11C#GL_PROXY_TEXTURE_2D PROXY_TEXTURE_2D}{@link GL30#GL_PROXY_TEXTURE_1D_ARRAY PROXY_TEXTURE_1D_ARRAY}{@link GL31#GL_PROXY_TEXTURE_RECTANGLE PROXY_TEXTURE_RECTANGLE}{@link GL13#GL_PROXY_TEXTURE_CUBE_MAP PROXY_TEXTURE_CUBE_MAP}
+ * @param level the level-of-detail number + * @param internalformat the texture internal format. One of:
{@link GL11C#GL_RED RED}{@link GL30#GL_RG RG}{@link GL11C#GL_RGB RGB}{@link GL11C#GL_RGBA RGBA}{@link GL11C#GL_DEPTH_COMPONENT DEPTH_COMPONENT}{@link GL30#GL_DEPTH_STENCIL DEPTH_STENCIL}
{@link GL30#GL_R8 R8}{@link GL31#GL_R8_SNORM R8_SNORM}{@link GL30#GL_R16 R16}{@link GL31#GL_R16_SNORM R16_SNORM}{@link GL30#GL_RG8 RG8}{@link GL31#GL_RG8_SNORM RG8_SNORM}
{@link GL30#GL_RG16 RG16}{@link GL31#GL_RG16_SNORM RG16_SNORM}{@link GL11C#GL_R3_G3_B2 R3_G3_B2}{@link GL11C#GL_RGB4 RGB4}{@link GL11C#GL_RGB5 RGB5}{@link GL41#GL_RGB565 RGB565}
{@link GL11C#GL_RGB8 RGB8}{@link GL31#GL_RGB8_SNORM RGB8_SNORM}{@link GL11C#GL_RGB10 RGB10}{@link GL11C#GL_RGB12 RGB12}{@link GL11C#GL_RGB16 RGB16}{@link GL31#GL_RGB16_SNORM RGB16_SNORM}
{@link GL11C#GL_RGBA2 RGBA2}{@link GL11C#GL_RGBA4 RGBA4}{@link GL11C#GL_RGB5_A1 RGB5_A1}{@link GL11C#GL_RGBA8 RGBA8}{@link GL31#GL_RGBA8_SNORM RGBA8_SNORM}{@link GL11C#GL_RGB10_A2 RGB10_A2}
{@link GL33#GL_RGB10_A2UI RGB10_A2UI}{@link GL11C#GL_RGBA12 RGBA12}{@link GL11C#GL_RGBA16 RGBA16}{@link GL31#GL_RGBA16_SNORM RGBA16_SNORM}{@link GL21#GL_SRGB8 SRGB8}{@link GL21#GL_SRGB8_ALPHA8 SRGB8_ALPHA8}
{@link GL30#GL_R16F R16F}{@link GL30#GL_RG16F RG16F}{@link GL30#GL_RGB16F RGB16F}{@link GL30#GL_RGBA16F RGBA16F}{@link GL30#GL_R32F R32F}{@link GL30#GL_RG32F RG32F}
{@link GL30#GL_RGB32F RGB32F}{@link GL30#GL_RGBA32F RGBA32F}{@link GL30#GL_R11F_G11F_B10F R11F_G11F_B10F}{@link GL30#GL_RGB9_E5 RGB9_E5}{@link GL30#GL_R8I R8I}{@link GL30#GL_R8UI R8UI}
{@link GL30#GL_R16I R16I}{@link GL30#GL_R16UI R16UI}{@link GL30#GL_R32I R32I}{@link GL30#GL_R32UI R32UI}{@link GL30#GL_RG8I RG8I}{@link GL30#GL_RG8UI RG8UI}
{@link GL30#GL_RG16I RG16I}{@link GL30#GL_RG16UI RG16UI}{@link GL30#GL_RG32I RG32I}{@link GL30#GL_RG32UI RG32UI}{@link GL30#GL_RGB8I RGB8I}{@link GL30#GL_RGB8UI RGB8UI}
{@link GL30#GL_RGB16I RGB16I}{@link GL30#GL_RGB16UI RGB16UI}{@link GL30#GL_RGB32I RGB32I}{@link GL30#GL_RGB32UI RGB32UI}{@link GL30#GL_RGBA8I RGBA8I}{@link GL30#GL_RGBA8UI RGBA8UI}
{@link GL30#GL_RGBA16I RGBA16I}{@link GL30#GL_RGBA16UI RGBA16UI}{@link GL30#GL_RGBA32I RGBA32I}{@link GL30#GL_RGBA32UI RGBA32UI}{@link GL14#GL_DEPTH_COMPONENT16 DEPTH_COMPONENT16}{@link GL14#GL_DEPTH_COMPONENT24 DEPTH_COMPONENT24}
{@link GL14#GL_DEPTH_COMPONENT32 DEPTH_COMPONENT32}{@link GL30#GL_DEPTH24_STENCIL8 DEPTH24_STENCIL8}{@link GL30#GL_DEPTH_COMPONENT32F DEPTH_COMPONENT32F}{@link GL30#GL_DEPTH32F_STENCIL8 DEPTH32F_STENCIL8}{@link GL30#GL_COMPRESSED_RED COMPRESSED_RED}{@link GL30#GL_COMPRESSED_RG COMPRESSED_RG}
{@link GL13#GL_COMPRESSED_RGB COMPRESSED_RGB}{@link GL13#GL_COMPRESSED_RGBA COMPRESSED_RGBA}{@link GL21#GL_COMPRESSED_SRGB COMPRESSED_SRGB}{@link GL21#GL_COMPRESSED_SRGB_ALPHA COMPRESSED_SRGB_ALPHA}{@link GL30#GL_COMPRESSED_RED_RGTC1 COMPRESSED_RED_RGTC1}{@link GL30#GL_COMPRESSED_SIGNED_RED_RGTC1 COMPRESSED_SIGNED_RED_RGTC1}
{@link GL30#GL_COMPRESSED_RG_RGTC2 COMPRESSED_RG_RGTC2}{@link GL30#GL_COMPRESSED_SIGNED_RG_RGTC2 COMPRESSED_SIGNED_RG_RGTC2}{@link GL42#GL_COMPRESSED_RGBA_BPTC_UNORM COMPRESSED_RGBA_BPTC_UNORM}{@link GL42#GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM COMPRESSED_SRGB_ALPHA_BPTC_UNORM}{@link GL42#GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT COMPRESSED_RGB_BPTC_SIGNED_FLOAT}{@link GL42#GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT}
{@link GL43#GL_COMPRESSED_RGB8_ETC2 COMPRESSED_RGB8_ETC2}{@link GL43#GL_COMPRESSED_SRGB8_ETC2 COMPRESSED_SRGB8_ETC2}{@link GL43#GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2}{@link GL43#GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2}{@link GL43#GL_COMPRESSED_RGBA8_ETC2_EAC COMPRESSED_RGBA8_ETC2_EAC}{@link GL43#GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC COMPRESSED_SRGB8_ALPHA8_ETC2_EAC}
{@link GL43#GL_COMPRESSED_R11_EAC COMPRESSED_R11_EAC}{@link GL43#GL_COMPRESSED_SIGNED_R11_EAC COMPRESSED_SIGNED_R11_EAC}{@link GL43#GL_COMPRESSED_RG11_EAC COMPRESSED_RG11_EAC}{@link GL43#GL_COMPRESSED_SIGNED_RG11_EAC COMPRESSED_SIGNED_RG11_EAC}see {@link EXTTextureCompressionS3TC}see {@link EXTTextureCompressionLATC}
see {@link ATITextureCompression3DC}
+ * @param width the texture width + * @param height the texture height + * @param border the texture border width + * @param format the texel data format. One of:
{@link GL11C#GL_RED RED}{@link GL11C#GL_GREEN GREEN}{@link GL11C#GL_BLUE BLUE}{@link GL11C#GL_ALPHA ALPHA}{@link GL30#GL_RG RG}{@link GL11C#GL_RGB RGB}{@link GL11C#GL_RGBA RGBA}{@link GL12#GL_BGR BGR}
{@link GL12#GL_BGRA BGRA}{@link GL30#GL_RED_INTEGER RED_INTEGER}{@link GL30#GL_GREEN_INTEGER GREEN_INTEGER}{@link GL30#GL_BLUE_INTEGER BLUE_INTEGER}{@link GL30#GL_ALPHA_INTEGER ALPHA_INTEGER}{@link GL30#GL_RG_INTEGER RG_INTEGER}{@link GL30#GL_RGB_INTEGER RGB_INTEGER}{@link GL30#GL_RGBA_INTEGER RGBA_INTEGER}
{@link GL30#GL_BGR_INTEGER BGR_INTEGER}{@link GL30#GL_BGRA_INTEGER BGRA_INTEGER}{@link GL11C#GL_STENCIL_INDEX STENCIL_INDEX}{@link GL11C#GL_DEPTH_COMPONENT DEPTH_COMPONENT}{@link GL30#GL_DEPTH_STENCIL DEPTH_STENCIL}
+ * @param type the texel data type. One of:
{@link GL11C#GL_UNSIGNED_BYTE UNSIGNED_BYTE}{@link GL11C#GL_BYTE BYTE}{@link GL11C#GL_UNSIGNED_SHORT UNSIGNED_SHORT}{@link GL11C#GL_SHORT SHORT}
{@link GL11C#GL_UNSIGNED_INT UNSIGNED_INT}{@link GL11C#GL_INT INT}{@link GL30#GL_HALF_FLOAT HALF_FLOAT}{@link GL11C#GL_FLOAT FLOAT}
{@link GL12#GL_UNSIGNED_BYTE_3_3_2 UNSIGNED_BYTE_3_3_2}{@link GL12#GL_UNSIGNED_BYTE_2_3_3_REV UNSIGNED_BYTE_2_3_3_REV}{@link GL12#GL_UNSIGNED_SHORT_5_6_5 UNSIGNED_SHORT_5_6_5}{@link GL12#GL_UNSIGNED_SHORT_5_6_5_REV UNSIGNED_SHORT_5_6_5_REV}
{@link GL12#GL_UNSIGNED_SHORT_4_4_4_4 UNSIGNED_SHORT_4_4_4_4}{@link GL12#GL_UNSIGNED_SHORT_4_4_4_4_REV UNSIGNED_SHORT_4_4_4_4_REV}{@link GL12#GL_UNSIGNED_SHORT_5_5_5_1 UNSIGNED_SHORT_5_5_5_1}{@link GL12#GL_UNSIGNED_SHORT_1_5_5_5_REV UNSIGNED_SHORT_1_5_5_5_REV}
{@link GL12#GL_UNSIGNED_INT_8_8_8_8 UNSIGNED_INT_8_8_8_8}{@link GL12#GL_UNSIGNED_INT_8_8_8_8_REV UNSIGNED_INT_8_8_8_8_REV}{@link GL12#GL_UNSIGNED_INT_10_10_10_2 UNSIGNED_INT_10_10_10_2}{@link GL12#GL_UNSIGNED_INT_2_10_10_10_REV UNSIGNED_INT_2_10_10_10_REV}
{@link GL30#GL_UNSIGNED_INT_24_8 UNSIGNED_INT_24_8}{@link GL30#GL_UNSIGNED_INT_10F_11F_11F_REV UNSIGNED_INT_10F_11F_11F_REV}{@link GL30#GL_UNSIGNED_INT_5_9_9_9_REV UNSIGNED_INT_5_9_9_9_REV}{@link GL30#GL_FLOAT_32_UNSIGNED_INT_24_8_REV FLOAT_32_UNSIGNED_INT_24_8_REV}
+ * @param pixels the texel data + * + * @see Reference Page + */ + public static void glTexImage2D(@NativeType("GLenum") int target, @NativeType("GLint") int level, @NativeType("GLint") int internalformat, @NativeType("GLsizei") int width, @NativeType("GLsizei") int height, @NativeType("GLint") int border, @NativeType("GLenum") int format, @NativeType("GLenum") int type, @Nullable @NativeType("void const *") FloatBuffer pixels) { + GL11C.glTexImage2D(target, level, internalformat, width, height, border, format, type, pixels); + } + + /** + * Specifies a two-dimensional texture image. + * + * @param target the texture target. One of:
{@link GL11C#GL_TEXTURE_2D TEXTURE_2D}{@link GL30#GL_TEXTURE_1D_ARRAY TEXTURE_1D_ARRAY}{@link GL31#GL_TEXTURE_RECTANGLE TEXTURE_RECTANGLE}{@link GL13#GL_TEXTURE_CUBE_MAP TEXTURE_CUBE_MAP}
{@link GL11C#GL_PROXY_TEXTURE_2D PROXY_TEXTURE_2D}{@link GL30#GL_PROXY_TEXTURE_1D_ARRAY PROXY_TEXTURE_1D_ARRAY}{@link GL31#GL_PROXY_TEXTURE_RECTANGLE PROXY_TEXTURE_RECTANGLE}{@link GL13#GL_PROXY_TEXTURE_CUBE_MAP PROXY_TEXTURE_CUBE_MAP}
+ * @param level the level-of-detail number + * @param internalformat the texture internal format. One of:
{@link GL11C#GL_RED RED}{@link GL30#GL_RG RG}{@link GL11C#GL_RGB RGB}{@link GL11C#GL_RGBA RGBA}{@link GL11C#GL_DEPTH_COMPONENT DEPTH_COMPONENT}{@link GL30#GL_DEPTH_STENCIL DEPTH_STENCIL}
{@link GL30#GL_R8 R8}{@link GL31#GL_R8_SNORM R8_SNORM}{@link GL30#GL_R16 R16}{@link GL31#GL_R16_SNORM R16_SNORM}{@link GL30#GL_RG8 RG8}{@link GL31#GL_RG8_SNORM RG8_SNORM}
{@link GL30#GL_RG16 RG16}{@link GL31#GL_RG16_SNORM RG16_SNORM}{@link GL11C#GL_R3_G3_B2 R3_G3_B2}{@link GL11C#GL_RGB4 RGB4}{@link GL11C#GL_RGB5 RGB5}{@link GL41#GL_RGB565 RGB565}
{@link GL11C#GL_RGB8 RGB8}{@link GL31#GL_RGB8_SNORM RGB8_SNORM}{@link GL11C#GL_RGB10 RGB10}{@link GL11C#GL_RGB12 RGB12}{@link GL11C#GL_RGB16 RGB16}{@link GL31#GL_RGB16_SNORM RGB16_SNORM}
{@link GL11C#GL_RGBA2 RGBA2}{@link GL11C#GL_RGBA4 RGBA4}{@link GL11C#GL_RGB5_A1 RGB5_A1}{@link GL11C#GL_RGBA8 RGBA8}{@link GL31#GL_RGBA8_SNORM RGBA8_SNORM}{@link GL11C#GL_RGB10_A2 RGB10_A2}
{@link GL33#GL_RGB10_A2UI RGB10_A2UI}{@link GL11C#GL_RGBA12 RGBA12}{@link GL11C#GL_RGBA16 RGBA16}{@link GL31#GL_RGBA16_SNORM RGBA16_SNORM}{@link GL21#GL_SRGB8 SRGB8}{@link GL21#GL_SRGB8_ALPHA8 SRGB8_ALPHA8}
{@link GL30#GL_R16F R16F}{@link GL30#GL_RG16F RG16F}{@link GL30#GL_RGB16F RGB16F}{@link GL30#GL_RGBA16F RGBA16F}{@link GL30#GL_R32F R32F}{@link GL30#GL_RG32F RG32F}
{@link GL30#GL_RGB32F RGB32F}{@link GL30#GL_RGBA32F RGBA32F}{@link GL30#GL_R11F_G11F_B10F R11F_G11F_B10F}{@link GL30#GL_RGB9_E5 RGB9_E5}{@link GL30#GL_R8I R8I}{@link GL30#GL_R8UI R8UI}
{@link GL30#GL_R16I R16I}{@link GL30#GL_R16UI R16UI}{@link GL30#GL_R32I R32I}{@link GL30#GL_R32UI R32UI}{@link GL30#GL_RG8I RG8I}{@link GL30#GL_RG8UI RG8UI}
{@link GL30#GL_RG16I RG16I}{@link GL30#GL_RG16UI RG16UI}{@link GL30#GL_RG32I RG32I}{@link GL30#GL_RG32UI RG32UI}{@link GL30#GL_RGB8I RGB8I}{@link GL30#GL_RGB8UI RGB8UI}
{@link GL30#GL_RGB16I RGB16I}{@link GL30#GL_RGB16UI RGB16UI}{@link GL30#GL_RGB32I RGB32I}{@link GL30#GL_RGB32UI RGB32UI}{@link GL30#GL_RGBA8I RGBA8I}{@link GL30#GL_RGBA8UI RGBA8UI}
{@link GL30#GL_RGBA16I RGBA16I}{@link GL30#GL_RGBA16UI RGBA16UI}{@link GL30#GL_RGBA32I RGBA32I}{@link GL30#GL_RGBA32UI RGBA32UI}{@link GL14#GL_DEPTH_COMPONENT16 DEPTH_COMPONENT16}{@link GL14#GL_DEPTH_COMPONENT24 DEPTH_COMPONENT24}
{@link GL14#GL_DEPTH_COMPONENT32 DEPTH_COMPONENT32}{@link GL30#GL_DEPTH24_STENCIL8 DEPTH24_STENCIL8}{@link GL30#GL_DEPTH_COMPONENT32F DEPTH_COMPONENT32F}{@link GL30#GL_DEPTH32F_STENCIL8 DEPTH32F_STENCIL8}{@link GL30#GL_COMPRESSED_RED COMPRESSED_RED}{@link GL30#GL_COMPRESSED_RG COMPRESSED_RG}
{@link GL13#GL_COMPRESSED_RGB COMPRESSED_RGB}{@link GL13#GL_COMPRESSED_RGBA COMPRESSED_RGBA}{@link GL21#GL_COMPRESSED_SRGB COMPRESSED_SRGB}{@link GL21#GL_COMPRESSED_SRGB_ALPHA COMPRESSED_SRGB_ALPHA}{@link GL30#GL_COMPRESSED_RED_RGTC1 COMPRESSED_RED_RGTC1}{@link GL30#GL_COMPRESSED_SIGNED_RED_RGTC1 COMPRESSED_SIGNED_RED_RGTC1}
{@link GL30#GL_COMPRESSED_RG_RGTC2 COMPRESSED_RG_RGTC2}{@link GL30#GL_COMPRESSED_SIGNED_RG_RGTC2 COMPRESSED_SIGNED_RG_RGTC2}{@link GL42#GL_COMPRESSED_RGBA_BPTC_UNORM COMPRESSED_RGBA_BPTC_UNORM}{@link GL42#GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM COMPRESSED_SRGB_ALPHA_BPTC_UNORM}{@link GL42#GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT COMPRESSED_RGB_BPTC_SIGNED_FLOAT}{@link GL42#GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT}
{@link GL43#GL_COMPRESSED_RGB8_ETC2 COMPRESSED_RGB8_ETC2}{@link GL43#GL_COMPRESSED_SRGB8_ETC2 COMPRESSED_SRGB8_ETC2}{@link GL43#GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2}{@link GL43#GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2}{@link GL43#GL_COMPRESSED_RGBA8_ETC2_EAC COMPRESSED_RGBA8_ETC2_EAC}{@link GL43#GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC COMPRESSED_SRGB8_ALPHA8_ETC2_EAC}
{@link GL43#GL_COMPRESSED_R11_EAC COMPRESSED_R11_EAC}{@link GL43#GL_COMPRESSED_SIGNED_R11_EAC COMPRESSED_SIGNED_R11_EAC}{@link GL43#GL_COMPRESSED_RG11_EAC COMPRESSED_RG11_EAC}{@link GL43#GL_COMPRESSED_SIGNED_RG11_EAC COMPRESSED_SIGNED_RG11_EAC}see {@link EXTTextureCompressionS3TC}see {@link EXTTextureCompressionLATC}
see {@link ATITextureCompression3DC}
+ * @param width the texture width + * @param height the texture height + * @param border the texture border width + * @param format the texel data format. One of:
{@link GL11C#GL_RED RED}{@link GL11C#GL_GREEN GREEN}{@link GL11C#GL_BLUE BLUE}{@link GL11C#GL_ALPHA ALPHA}{@link GL30#GL_RG RG}{@link GL11C#GL_RGB RGB}{@link GL11C#GL_RGBA RGBA}{@link GL12#GL_BGR BGR}
{@link GL12#GL_BGRA BGRA}{@link GL30#GL_RED_INTEGER RED_INTEGER}{@link GL30#GL_GREEN_INTEGER GREEN_INTEGER}{@link GL30#GL_BLUE_INTEGER BLUE_INTEGER}{@link GL30#GL_ALPHA_INTEGER ALPHA_INTEGER}{@link GL30#GL_RG_INTEGER RG_INTEGER}{@link GL30#GL_RGB_INTEGER RGB_INTEGER}{@link GL30#GL_RGBA_INTEGER RGBA_INTEGER}
{@link GL30#GL_BGR_INTEGER BGR_INTEGER}{@link GL30#GL_BGRA_INTEGER BGRA_INTEGER}{@link GL11C#GL_STENCIL_INDEX STENCIL_INDEX}{@link GL11C#GL_DEPTH_COMPONENT DEPTH_COMPONENT}{@link GL30#GL_DEPTH_STENCIL DEPTH_STENCIL}
+ * @param type the texel data type. One of:
{@link GL11C#GL_UNSIGNED_BYTE UNSIGNED_BYTE}{@link GL11C#GL_BYTE BYTE}{@link GL11C#GL_UNSIGNED_SHORT UNSIGNED_SHORT}{@link GL11C#GL_SHORT SHORT}
{@link GL11C#GL_UNSIGNED_INT UNSIGNED_INT}{@link GL11C#GL_INT INT}{@link GL30#GL_HALF_FLOAT HALF_FLOAT}{@link GL11C#GL_FLOAT FLOAT}
{@link GL12#GL_UNSIGNED_BYTE_3_3_2 UNSIGNED_BYTE_3_3_2}{@link GL12#GL_UNSIGNED_BYTE_2_3_3_REV UNSIGNED_BYTE_2_3_3_REV}{@link GL12#GL_UNSIGNED_SHORT_5_6_5 UNSIGNED_SHORT_5_6_5}{@link GL12#GL_UNSIGNED_SHORT_5_6_5_REV UNSIGNED_SHORT_5_6_5_REV}
{@link GL12#GL_UNSIGNED_SHORT_4_4_4_4 UNSIGNED_SHORT_4_4_4_4}{@link GL12#GL_UNSIGNED_SHORT_4_4_4_4_REV UNSIGNED_SHORT_4_4_4_4_REV}{@link GL12#GL_UNSIGNED_SHORT_5_5_5_1 UNSIGNED_SHORT_5_5_5_1}{@link GL12#GL_UNSIGNED_SHORT_1_5_5_5_REV UNSIGNED_SHORT_1_5_5_5_REV}
{@link GL12#GL_UNSIGNED_INT_8_8_8_8 UNSIGNED_INT_8_8_8_8}{@link GL12#GL_UNSIGNED_INT_8_8_8_8_REV UNSIGNED_INT_8_8_8_8_REV}{@link GL12#GL_UNSIGNED_INT_10_10_10_2 UNSIGNED_INT_10_10_10_2}{@link GL12#GL_UNSIGNED_INT_2_10_10_10_REV UNSIGNED_INT_2_10_10_10_REV}
{@link GL30#GL_UNSIGNED_INT_24_8 UNSIGNED_INT_24_8}{@link GL30#GL_UNSIGNED_INT_10F_11F_11F_REV UNSIGNED_INT_10F_11F_11F_REV}{@link GL30#GL_UNSIGNED_INT_5_9_9_9_REV UNSIGNED_INT_5_9_9_9_REV}{@link GL30#GL_FLOAT_32_UNSIGNED_INT_24_8_REV FLOAT_32_UNSIGNED_INT_24_8_REV}
+ * @param pixels the texel data + * + * @see Reference Page + */ + public static void glTexImage2D(@NativeType("GLenum") int target, @NativeType("GLint") int level, @NativeType("GLint") int internalformat, @NativeType("GLsizei") int width, @NativeType("GLsizei") int height, @NativeType("GLint") int border, @NativeType("GLenum") int format, @NativeType("GLenum") int type, @Nullable @NativeType("void const *") DoubleBuffer pixels) { + GL11C.glTexImage2D(target, level, internalformat, width, height, border, format, type, pixels); + } + + // --- [ glCopyTexImage1D ] --- + + /** + * Defines a one-dimensional texel array in exactly the manner of {@link #glTexImage1D TexImage1D}, except that the image data are taken from the framebuffer rather + * than from client memory. For the purposes of decoding the texture image, {@code CopyTexImage1D} is equivalent to calling {@link #glCopyTexImage2D CopyTexImage2D} + * with corresponding arguments and height of 1, except that the height of the image is always 1, regardless of the value of border. level, internalformat, + * and border are specified using the same values, with the same meanings, as the corresponding arguments of {@link #glTexImage1D TexImage1D}. The constraints on + * width and border are exactly those of the corresponding arguments of {@link #glTexImage1D TexImage1D}. + * + * @param target the texture target. Must be:
{@link GL11C#GL_TEXTURE_1D TEXTURE_1D}
+ * @param level the level-of-detail number + * @param internalFormat the texture internal format. See {@link #glTexImage2D TexImage2D} for a list of supported formats. + * @param x the left framebuffer pixel coordinate + * @param y the lower framebuffer pixel coordinate + * @param width the texture width + * @param border the texture border width + * + * @see Reference Page + */ + public static void glCopyTexImage1D(@NativeType("GLenum") int target, @NativeType("GLint") int level, @NativeType("GLenum") int internalFormat, @NativeType("GLint") int x, @NativeType("GLint") int y, @NativeType("GLsizei") int width, @NativeType("GLint") int border) { + GL11C.glCopyTexImage1D(target, level, internalFormat, x, y, width, border); + } + + // --- [ glCopyTexImage2D ] --- + + /** + * Defines a two-dimensional texel array in exactly the manner of {@link #glTexImage2D TexImage2D}, except that the image data are taken from the framebuffer rather + * than from client memory. + * + *

{@code x}, {@code y}, {@code width}, and {@code height} correspond precisely to the corresponding arguments to {@link #glReadPixels ReadPixels}; they specify the + * image's width and height, and the lower left (x, y) coordinates of the framebuffer region to be copied.

+ * + *

The image is taken from the framebuffer exactly as if these arguments were passed to {@link GL11#glCopyPixels CopyPixels} with argument type set to {@link GL11C#GL_COLOR COLOR}, + * {@link GL11C#GL_DEPTH DEPTH}, or {@link GL30#GL_DEPTH_STENCIL DEPTH_STENCIL}, depending on {@code internalformat}. RGBA data is taken from the current color buffer, while depth + * component and stencil index data are taken from the depth and stencil buffers, respectively.

+ * + *

Subsequent processing is identical to that described for {@link #glTexImage2D TexImage2D}, beginning with clamping of the R, G, B, A, or depth values, and masking + * of the stencil index values from the resulting pixel groups. Parameters {@code level}, {@code internalformat}, and {@code border} are specified using + * the same values, with the same meanings, as the corresponding arguments of {@link #glTexImage2D TexImage2D}.

+ * + *

The constraints on width, height, and border are exactly those for the corresponding arguments of {@link #glTexImage2D TexImage2D}.

+ * + * @param target the texture target. One of:
{@link GL11C#GL_TEXTURE_2D TEXTURE_2D}{@link GL30#GL_TEXTURE_1D_ARRAY TEXTURE_1D_ARRAY}{@link GL31#GL_TEXTURE_RECTANGLE TEXTURE_RECTANGLE}{@link GL13#GL_TEXTURE_CUBE_MAP TEXTURE_CUBE_MAP}
+ * @param level the level-of-detail number + * @param internalFormat the texture internal format. See {@link #glTexImage2D TexImage2D} for a list of supported formats. + * @param x the left framebuffer pixel coordinate + * @param y the lower framebuffer pixel coordinate + * @param width the texture width + * @param height the texture height + * @param border the texture border width + * + * @see Reference Page + */ + public static void glCopyTexImage2D(@NativeType("GLenum") int target, @NativeType("GLint") int level, @NativeType("GLenum") int internalFormat, @NativeType("GLint") int x, @NativeType("GLint") int y, @NativeType("GLsizei") int width, @NativeType("GLsizei") int height, @NativeType("GLint") int border) { + GL11C.glCopyTexImage2D(target, level, internalFormat, x, y, width, height, border); + } + + // --- [ glCopyTexSubImage1D ] --- + + /** + * Respecifies a rectangular subregion of an existing texel array. No change is made to the {@code internalformat}, {@code width} or {@code border} + * parameters of the specified texel array, nor is any change made to texel values outside the specified subregion. See {@link #glCopyTexImage1D CopyTexImage1D} for more + * details. + * + * @param target the texture target. Must be:
{@link GL11C#GL_TEXTURE_1D TEXTURE_1D}
+ * @param level the level-of-detail number + * @param xoffset the left texel coordinate of the texture subregion to update + * @param x the left framebuffer pixel coordinate + * @param y the lower framebuffer pixel coordinate + * @param width the texture subregion width + * + * @see Reference Page + */ + public static void glCopyTexSubImage1D(@NativeType("GLenum") int target, @NativeType("GLint") int level, @NativeType("GLint") int xoffset, @NativeType("GLint") int x, @NativeType("GLint") int y, @NativeType("GLsizei") int width) { + GL11C.glCopyTexSubImage1D(target, level, xoffset, x, y, width); + } + + // --- [ glCopyTexSubImage2D ] --- + + /** + * Respecifies a rectangular subregion of an existing texel array. No change is made to the {@code internalformat}, {@code width}, {@code height}, + * or {@code border} parameters of the specified texel array, nor is any change made to texel values outside the specified subregion. See + * {@link #glCopyTexImage2D CopyTexImage2D} for more details. + * + * @param target the texture target. One of:
{@link GL11C#GL_TEXTURE_2D TEXTURE_2D}{@link GL30#GL_TEXTURE_1D_ARRAY TEXTURE_1D_ARRAY}{@link GL31#GL_TEXTURE_RECTANGLE TEXTURE_RECTANGLE}{@link GL13#GL_TEXTURE_CUBE_MAP TEXTURE_CUBE_MAP}
+ * @param level the level-of-detail number + * @param xoffset the left texel coordinate of the texture subregion to update + * @param yoffset the lower texel coordinate of the texture subregion to update + * @param x the left framebuffer pixel coordinate + * @param y the lower framebuffer pixel coordinate + * @param width the texture subregion width + * @param height the texture subregion height + * + * @see Reference Page + */ + public static void glCopyTexSubImage2D(@NativeType("GLenum") int target, @NativeType("GLint") int level, @NativeType("GLint") int xoffset, @NativeType("GLint") int yoffset, @NativeType("GLint") int x, @NativeType("GLint") int y, @NativeType("GLsizei") int width, @NativeType("GLsizei") int height) { + GL11C.glCopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height); + } + + // --- [ glTexParameteri ] --- + + /** + * Sets the integer value of a texture parameter, which controls how the texel array is treated when specified or changed, and when applied to a fragment. + * + * @param target the texture target. One of:
{@link GL11C#GL_TEXTURE_1D TEXTURE_1D}{@link GL11C#GL_TEXTURE_2D TEXTURE_2D}{@link GL12#GL_TEXTURE_3D TEXTURE_3D}{@link GL30#GL_TEXTURE_1D_ARRAY TEXTURE_1D_ARRAY}
{@link GL30#GL_TEXTURE_2D_ARRAY TEXTURE_2D_ARRAY}{@link GL31#GL_TEXTURE_RECTANGLE TEXTURE_RECTANGLE}{@link GL13#GL_TEXTURE_CUBE_MAP TEXTURE_CUBE_MAP}{@link GL40#GL_TEXTURE_CUBE_MAP_ARRAY TEXTURE_CUBE_MAP_ARRAY}
{@link GL32#GL_TEXTURE_2D_MULTISAMPLE TEXTURE_2D_MULTISAMPLE}{@link GL32#GL_TEXTURE_2D_MULTISAMPLE_ARRAY TEXTURE_2D_MULTISAMPLE_ARRAY}
+ * @param pname the parameter to set. One of:
{@link GL12#GL_TEXTURE_BASE_LEVEL TEXTURE_BASE_LEVEL}{@link GL11C#GL_TEXTURE_BORDER_COLOR TEXTURE_BORDER_COLOR}{@link GL14#GL_TEXTURE_COMPARE_MODE TEXTURE_COMPARE_MODE}{@link GL14#GL_TEXTURE_COMPARE_FUNC TEXTURE_COMPARE_FUNC}
{@link GL14#GL_TEXTURE_LOD_BIAS TEXTURE_LOD_BIAS}{@link GL11C#GL_TEXTURE_MAG_FILTER TEXTURE_MAG_FILTER}{@link GL12#GL_TEXTURE_MAX_LEVEL TEXTURE_MAX_LEVEL}{@link GL12#GL_TEXTURE_MAX_LOD TEXTURE_MAX_LOD}
{@link GL11C#GL_TEXTURE_MIN_FILTER TEXTURE_MIN_FILTER}{@link GL12#GL_TEXTURE_MIN_LOD TEXTURE_MIN_LOD}{@link GL33#GL_TEXTURE_SWIZZLE_R TEXTURE_SWIZZLE_R}{@link GL33#GL_TEXTURE_SWIZZLE_G TEXTURE_SWIZZLE_G}
{@link GL33#GL_TEXTURE_SWIZZLE_B TEXTURE_SWIZZLE_B}{@link GL33#GL_TEXTURE_SWIZZLE_A TEXTURE_SWIZZLE_A}{@link GL33#GL_TEXTURE_SWIZZLE_RGBA TEXTURE_SWIZZLE_RGBA}{@link GL11C#GL_TEXTURE_WRAP_S TEXTURE_WRAP_S}
{@link GL11C#GL_TEXTURE_WRAP_T TEXTURE_WRAP_T}{@link GL12#GL_TEXTURE_WRAP_R TEXTURE_WRAP_R}{@link GL14#GL_DEPTH_TEXTURE_MODE DEPTH_TEXTURE_MODE}{@link GL14#GL_GENERATE_MIPMAP GENERATE_MIPMAP}
+ * @param param the parameter value + * + * @see Reference Page + */ + public static void glTexParameteri(@NativeType("GLenum") int target, @NativeType("GLenum") int pname, @NativeType("GLint") int param) { + GL11C.glTexParameteri(target, pname, param); + } + + // --- [ glTexParameteriv ] --- + + /** Unsafe version of: {@link #glTexParameteriv TexParameteriv} */ + public static void nglTexParameteriv(int target, int pname, long params) { + GL11C.nglTexParameteriv(target, pname, params); + } + + /** + * Pointer version of {@link #glTexParameteri TexParameteri}. + * + * @param target the texture target + * @param pname the parameter to set + * @param params the parameter value + * + * @see Reference Page + */ + public static void glTexParameteriv(@NativeType("GLenum") int target, @NativeType("GLenum") int pname, @NativeType("GLint const *") IntBuffer params) { + GL11C.glTexParameteriv(target, pname, params); + } + + // --- [ glTexParameterf ] --- + + /** + * Float version of {@link #glTexParameteri TexParameteri}. + * + * @param target the texture target + * @param pname the parameter to set + * @param param the parameter value + * + * @see Reference Page + */ + public static void glTexParameterf(@NativeType("GLenum") int target, @NativeType("GLenum") int pname, @NativeType("GLfloat") float param) { + GL11C.glTexParameterf(target, pname, param); + } + + // --- [ glTexParameterfv ] --- + + /** Unsafe version of: {@link #glTexParameterfv TexParameterfv} */ + public static void nglTexParameterfv(int target, int pname, long params) { + GL11C.nglTexParameterfv(target, pname, params); + } + + /** + * Pointer version of {@link #glTexParameterf TexParameterf}. + * + * @param target the texture target + * @param pname the parameter to set + * @param params the parameter value + * + * @see Reference Page + */ + public static void glTexParameterfv(@NativeType("GLenum") int target, @NativeType("GLenum") int pname, @NativeType("GLfloat const *") FloatBuffer params) { + GL11C.glTexParameterfv(target, pname, params); + } + + // --- [ glTexSubImage1D ] --- + + /** Unsafe version of: {@link #glTexSubImage1D TexSubImage1D} */ + public static void nglTexSubImage1D(int target, int level, int xoffset, int width, int format, int type, long pixels) { + GL11C.nglTexSubImage1D(target, level, xoffset, width, format, type, pixels); + } + + /** + * One-dimensional version of {@link #glTexSubImage2D TexSubImage2D}. + * + * @param target the texture target. Must be:
{@link GL11C#GL_TEXTURE_1D TEXTURE_1D}
+ * @param level the level-of-detail-number + * @param xoffset the left coordinate of the texel subregion + * @param width the subregion width + * @param format the pixel data format. One of:
{@link GL11C#GL_RED RED}{@link GL11C#GL_GREEN GREEN}{@link GL11C#GL_BLUE BLUE}{@link GL11C#GL_ALPHA ALPHA}{@link GL30#GL_RG RG}{@link GL11C#GL_RGB RGB}{@link GL11C#GL_RGBA RGBA}{@link GL12#GL_BGR BGR}
{@link GL12#GL_BGRA BGRA}{@link GL30#GL_RED_INTEGER RED_INTEGER}{@link GL30#GL_GREEN_INTEGER GREEN_INTEGER}{@link GL30#GL_BLUE_INTEGER BLUE_INTEGER}{@link GL30#GL_ALPHA_INTEGER ALPHA_INTEGER}{@link GL30#GL_RG_INTEGER RG_INTEGER}{@link GL30#GL_RGB_INTEGER RGB_INTEGER}{@link GL30#GL_RGBA_INTEGER RGBA_INTEGER}
{@link GL30#GL_BGR_INTEGER BGR_INTEGER}{@link GL30#GL_BGRA_INTEGER BGRA_INTEGER}{@link GL11C#GL_STENCIL_INDEX STENCIL_INDEX}{@link GL11C#GL_DEPTH_COMPONENT DEPTH_COMPONENT}{@link GL30#GL_DEPTH_STENCIL DEPTH_STENCIL}
+ * @param type the pixel data type. One of:
{@link GL11C#GL_UNSIGNED_BYTE UNSIGNED_BYTE}{@link GL11C#GL_BYTE BYTE}{@link GL11C#GL_UNSIGNED_SHORT UNSIGNED_SHORT}{@link GL11C#GL_SHORT SHORT}
{@link GL11C#GL_UNSIGNED_INT UNSIGNED_INT}{@link GL11C#GL_INT INT}{@link GL30#GL_HALF_FLOAT HALF_FLOAT}{@link GL11C#GL_FLOAT FLOAT}
{@link GL12#GL_UNSIGNED_BYTE_3_3_2 UNSIGNED_BYTE_3_3_2}{@link GL12#GL_UNSIGNED_BYTE_2_3_3_REV UNSIGNED_BYTE_2_3_3_REV}{@link GL12#GL_UNSIGNED_SHORT_5_6_5 UNSIGNED_SHORT_5_6_5}{@link GL12#GL_UNSIGNED_SHORT_5_6_5_REV UNSIGNED_SHORT_5_6_5_REV}
{@link GL12#GL_UNSIGNED_SHORT_4_4_4_4 UNSIGNED_SHORT_4_4_4_4}{@link GL12#GL_UNSIGNED_SHORT_4_4_4_4_REV UNSIGNED_SHORT_4_4_4_4_REV}{@link GL12#GL_UNSIGNED_SHORT_5_5_5_1 UNSIGNED_SHORT_5_5_5_1}{@link GL12#GL_UNSIGNED_SHORT_1_5_5_5_REV UNSIGNED_SHORT_1_5_5_5_REV}
{@link GL12#GL_UNSIGNED_INT_8_8_8_8 UNSIGNED_INT_8_8_8_8}{@link GL12#GL_UNSIGNED_INT_8_8_8_8_REV UNSIGNED_INT_8_8_8_8_REV}{@link GL12#GL_UNSIGNED_INT_10_10_10_2 UNSIGNED_INT_10_10_10_2}{@link GL12#GL_UNSIGNED_INT_2_10_10_10_REV UNSIGNED_INT_2_10_10_10_REV}
{@link GL30#GL_UNSIGNED_INT_24_8 UNSIGNED_INT_24_8}{@link GL30#GL_UNSIGNED_INT_10F_11F_11F_REV UNSIGNED_INT_10F_11F_11F_REV}{@link GL30#GL_UNSIGNED_INT_5_9_9_9_REV UNSIGNED_INT_5_9_9_9_REV}{@link GL30#GL_FLOAT_32_UNSIGNED_INT_24_8_REV FLOAT_32_UNSIGNED_INT_24_8_REV}
+ * @param pixels the pixel data + * + * @see Reference Page + */ + public static void glTexSubImage1D(@NativeType("GLenum") int target, @NativeType("GLint") int level, @NativeType("GLint") int xoffset, @NativeType("GLsizei") int width, @NativeType("GLenum") int format, @NativeType("GLenum") int type, @NativeType("void const *") ByteBuffer pixels) { + GL11C.glTexSubImage1D(target, level, xoffset, width, format, type, pixels); + } + + /** + * One-dimensional version of {@link #glTexSubImage2D TexSubImage2D}. + * + * @param target the texture target. Must be:
{@link GL11C#GL_TEXTURE_1D TEXTURE_1D}
+ * @param level the level-of-detail-number + * @param xoffset the left coordinate of the texel subregion + * @param width the subregion width + * @param format the pixel data format. One of:
{@link GL11C#GL_RED RED}{@link GL11C#GL_GREEN GREEN}{@link GL11C#GL_BLUE BLUE}{@link GL11C#GL_ALPHA ALPHA}{@link GL30#GL_RG RG}{@link GL11C#GL_RGB RGB}{@link GL11C#GL_RGBA RGBA}{@link GL12#GL_BGR BGR}
{@link GL12#GL_BGRA BGRA}{@link GL30#GL_RED_INTEGER RED_INTEGER}{@link GL30#GL_GREEN_INTEGER GREEN_INTEGER}{@link GL30#GL_BLUE_INTEGER BLUE_INTEGER}{@link GL30#GL_ALPHA_INTEGER ALPHA_INTEGER}{@link GL30#GL_RG_INTEGER RG_INTEGER}{@link GL30#GL_RGB_INTEGER RGB_INTEGER}{@link GL30#GL_RGBA_INTEGER RGBA_INTEGER}
{@link GL30#GL_BGR_INTEGER BGR_INTEGER}{@link GL30#GL_BGRA_INTEGER BGRA_INTEGER}{@link GL11C#GL_STENCIL_INDEX STENCIL_INDEX}{@link GL11C#GL_DEPTH_COMPONENT DEPTH_COMPONENT}{@link GL30#GL_DEPTH_STENCIL DEPTH_STENCIL}
+ * @param type the pixel data type. One of:
{@link GL11C#GL_UNSIGNED_BYTE UNSIGNED_BYTE}{@link GL11C#GL_BYTE BYTE}{@link GL11C#GL_UNSIGNED_SHORT UNSIGNED_SHORT}{@link GL11C#GL_SHORT SHORT}
{@link GL11C#GL_UNSIGNED_INT UNSIGNED_INT}{@link GL11C#GL_INT INT}{@link GL30#GL_HALF_FLOAT HALF_FLOAT}{@link GL11C#GL_FLOAT FLOAT}
{@link GL12#GL_UNSIGNED_BYTE_3_3_2 UNSIGNED_BYTE_3_3_2}{@link GL12#GL_UNSIGNED_BYTE_2_3_3_REV UNSIGNED_BYTE_2_3_3_REV}{@link GL12#GL_UNSIGNED_SHORT_5_6_5 UNSIGNED_SHORT_5_6_5}{@link GL12#GL_UNSIGNED_SHORT_5_6_5_REV UNSIGNED_SHORT_5_6_5_REV}
{@link GL12#GL_UNSIGNED_SHORT_4_4_4_4 UNSIGNED_SHORT_4_4_4_4}{@link GL12#GL_UNSIGNED_SHORT_4_4_4_4_REV UNSIGNED_SHORT_4_4_4_4_REV}{@link GL12#GL_UNSIGNED_SHORT_5_5_5_1 UNSIGNED_SHORT_5_5_5_1}{@link GL12#GL_UNSIGNED_SHORT_1_5_5_5_REV UNSIGNED_SHORT_1_5_5_5_REV}
{@link GL12#GL_UNSIGNED_INT_8_8_8_8 UNSIGNED_INT_8_8_8_8}{@link GL12#GL_UNSIGNED_INT_8_8_8_8_REV UNSIGNED_INT_8_8_8_8_REV}{@link GL12#GL_UNSIGNED_INT_10_10_10_2 UNSIGNED_INT_10_10_10_2}{@link GL12#GL_UNSIGNED_INT_2_10_10_10_REV UNSIGNED_INT_2_10_10_10_REV}
{@link GL30#GL_UNSIGNED_INT_24_8 UNSIGNED_INT_24_8}{@link GL30#GL_UNSIGNED_INT_10F_11F_11F_REV UNSIGNED_INT_10F_11F_11F_REV}{@link GL30#GL_UNSIGNED_INT_5_9_9_9_REV UNSIGNED_INT_5_9_9_9_REV}{@link GL30#GL_FLOAT_32_UNSIGNED_INT_24_8_REV FLOAT_32_UNSIGNED_INT_24_8_REV}
+ * @param pixels the pixel data + * + * @see Reference Page + */ + public static void glTexSubImage1D(@NativeType("GLenum") int target, @NativeType("GLint") int level, @NativeType("GLint") int xoffset, @NativeType("GLsizei") int width, @NativeType("GLenum") int format, @NativeType("GLenum") int type, @NativeType("void const *") long pixels) { + GL11C.glTexSubImage1D(target, level, xoffset, width, format, type, pixels); + } + + /** + * One-dimensional version of {@link #glTexSubImage2D TexSubImage2D}. + * + * @param target the texture target. Must be:
{@link GL11C#GL_TEXTURE_1D TEXTURE_1D}
+ * @param level the level-of-detail-number + * @param xoffset the left coordinate of the texel subregion + * @param width the subregion width + * @param format the pixel data format. One of:
{@link GL11C#GL_RED RED}{@link GL11C#GL_GREEN GREEN}{@link GL11C#GL_BLUE BLUE}{@link GL11C#GL_ALPHA ALPHA}{@link GL30#GL_RG RG}{@link GL11C#GL_RGB RGB}{@link GL11C#GL_RGBA RGBA}{@link GL12#GL_BGR BGR}
{@link GL12#GL_BGRA BGRA}{@link GL30#GL_RED_INTEGER RED_INTEGER}{@link GL30#GL_GREEN_INTEGER GREEN_INTEGER}{@link GL30#GL_BLUE_INTEGER BLUE_INTEGER}{@link GL30#GL_ALPHA_INTEGER ALPHA_INTEGER}{@link GL30#GL_RG_INTEGER RG_INTEGER}{@link GL30#GL_RGB_INTEGER RGB_INTEGER}{@link GL30#GL_RGBA_INTEGER RGBA_INTEGER}
{@link GL30#GL_BGR_INTEGER BGR_INTEGER}{@link GL30#GL_BGRA_INTEGER BGRA_INTEGER}{@link GL11C#GL_STENCIL_INDEX STENCIL_INDEX}{@link GL11C#GL_DEPTH_COMPONENT DEPTH_COMPONENT}{@link GL30#GL_DEPTH_STENCIL DEPTH_STENCIL}
+ * @param type the pixel data type. One of:
{@link GL11C#GL_UNSIGNED_BYTE UNSIGNED_BYTE}{@link GL11C#GL_BYTE BYTE}{@link GL11C#GL_UNSIGNED_SHORT UNSIGNED_SHORT}{@link GL11C#GL_SHORT SHORT}
{@link GL11C#GL_UNSIGNED_INT UNSIGNED_INT}{@link GL11C#GL_INT INT}{@link GL30#GL_HALF_FLOAT HALF_FLOAT}{@link GL11C#GL_FLOAT FLOAT}
{@link GL12#GL_UNSIGNED_BYTE_3_3_2 UNSIGNED_BYTE_3_3_2}{@link GL12#GL_UNSIGNED_BYTE_2_3_3_REV UNSIGNED_BYTE_2_3_3_REV}{@link GL12#GL_UNSIGNED_SHORT_5_6_5 UNSIGNED_SHORT_5_6_5}{@link GL12#GL_UNSIGNED_SHORT_5_6_5_REV UNSIGNED_SHORT_5_6_5_REV}
{@link GL12#GL_UNSIGNED_SHORT_4_4_4_4 UNSIGNED_SHORT_4_4_4_4}{@link GL12#GL_UNSIGNED_SHORT_4_4_4_4_REV UNSIGNED_SHORT_4_4_4_4_REV}{@link GL12#GL_UNSIGNED_SHORT_5_5_5_1 UNSIGNED_SHORT_5_5_5_1}{@link GL12#GL_UNSIGNED_SHORT_1_5_5_5_REV UNSIGNED_SHORT_1_5_5_5_REV}
{@link GL12#GL_UNSIGNED_INT_8_8_8_8 UNSIGNED_INT_8_8_8_8}{@link GL12#GL_UNSIGNED_INT_8_8_8_8_REV UNSIGNED_INT_8_8_8_8_REV}{@link GL12#GL_UNSIGNED_INT_10_10_10_2 UNSIGNED_INT_10_10_10_2}{@link GL12#GL_UNSIGNED_INT_2_10_10_10_REV UNSIGNED_INT_2_10_10_10_REV}
{@link GL30#GL_UNSIGNED_INT_24_8 UNSIGNED_INT_24_8}{@link GL30#GL_UNSIGNED_INT_10F_11F_11F_REV UNSIGNED_INT_10F_11F_11F_REV}{@link GL30#GL_UNSIGNED_INT_5_9_9_9_REV UNSIGNED_INT_5_9_9_9_REV}{@link GL30#GL_FLOAT_32_UNSIGNED_INT_24_8_REV FLOAT_32_UNSIGNED_INT_24_8_REV}
+ * @param pixels the pixel data + * + * @see Reference Page + */ + public static void glTexSubImage1D(@NativeType("GLenum") int target, @NativeType("GLint") int level, @NativeType("GLint") int xoffset, @NativeType("GLsizei") int width, @NativeType("GLenum") int format, @NativeType("GLenum") int type, @NativeType("void const *") ShortBuffer pixels) { + GL11C.glTexSubImage1D(target, level, xoffset, width, format, type, pixels); + } + + /** + * One-dimensional version of {@link #glTexSubImage2D TexSubImage2D}. + * + * @param target the texture target. Must be:
{@link GL11C#GL_TEXTURE_1D TEXTURE_1D}
+ * @param level the level-of-detail-number + * @param xoffset the left coordinate of the texel subregion + * @param width the subregion width + * @param format the pixel data format. One of:
{@link GL11C#GL_RED RED}{@link GL11C#GL_GREEN GREEN}{@link GL11C#GL_BLUE BLUE}{@link GL11C#GL_ALPHA ALPHA}{@link GL30#GL_RG RG}{@link GL11C#GL_RGB RGB}{@link GL11C#GL_RGBA RGBA}{@link GL12#GL_BGR BGR}
{@link GL12#GL_BGRA BGRA}{@link GL30#GL_RED_INTEGER RED_INTEGER}{@link GL30#GL_GREEN_INTEGER GREEN_INTEGER}{@link GL30#GL_BLUE_INTEGER BLUE_INTEGER}{@link GL30#GL_ALPHA_INTEGER ALPHA_INTEGER}{@link GL30#GL_RG_INTEGER RG_INTEGER}{@link GL30#GL_RGB_INTEGER RGB_INTEGER}{@link GL30#GL_RGBA_INTEGER RGBA_INTEGER}
{@link GL30#GL_BGR_INTEGER BGR_INTEGER}{@link GL30#GL_BGRA_INTEGER BGRA_INTEGER}{@link GL11C#GL_STENCIL_INDEX STENCIL_INDEX}{@link GL11C#GL_DEPTH_COMPONENT DEPTH_COMPONENT}{@link GL30#GL_DEPTH_STENCIL DEPTH_STENCIL}
+ * @param type the pixel data type. One of:
{@link GL11C#GL_UNSIGNED_BYTE UNSIGNED_BYTE}{@link GL11C#GL_BYTE BYTE}{@link GL11C#GL_UNSIGNED_SHORT UNSIGNED_SHORT}{@link GL11C#GL_SHORT SHORT}
{@link GL11C#GL_UNSIGNED_INT UNSIGNED_INT}{@link GL11C#GL_INT INT}{@link GL30#GL_HALF_FLOAT HALF_FLOAT}{@link GL11C#GL_FLOAT FLOAT}
{@link GL12#GL_UNSIGNED_BYTE_3_3_2 UNSIGNED_BYTE_3_3_2}{@link GL12#GL_UNSIGNED_BYTE_2_3_3_REV UNSIGNED_BYTE_2_3_3_REV}{@link GL12#GL_UNSIGNED_SHORT_5_6_5 UNSIGNED_SHORT_5_6_5}{@link GL12#GL_UNSIGNED_SHORT_5_6_5_REV UNSIGNED_SHORT_5_6_5_REV}
{@link GL12#GL_UNSIGNED_SHORT_4_4_4_4 UNSIGNED_SHORT_4_4_4_4}{@link GL12#GL_UNSIGNED_SHORT_4_4_4_4_REV UNSIGNED_SHORT_4_4_4_4_REV}{@link GL12#GL_UNSIGNED_SHORT_5_5_5_1 UNSIGNED_SHORT_5_5_5_1}{@link GL12#GL_UNSIGNED_SHORT_1_5_5_5_REV UNSIGNED_SHORT_1_5_5_5_REV}
{@link GL12#GL_UNSIGNED_INT_8_8_8_8 UNSIGNED_INT_8_8_8_8}{@link GL12#GL_UNSIGNED_INT_8_8_8_8_REV UNSIGNED_INT_8_8_8_8_REV}{@link GL12#GL_UNSIGNED_INT_10_10_10_2 UNSIGNED_INT_10_10_10_2}{@link GL12#GL_UNSIGNED_INT_2_10_10_10_REV UNSIGNED_INT_2_10_10_10_REV}
{@link GL30#GL_UNSIGNED_INT_24_8 UNSIGNED_INT_24_8}{@link GL30#GL_UNSIGNED_INT_10F_11F_11F_REV UNSIGNED_INT_10F_11F_11F_REV}{@link GL30#GL_UNSIGNED_INT_5_9_9_9_REV UNSIGNED_INT_5_9_9_9_REV}{@link GL30#GL_FLOAT_32_UNSIGNED_INT_24_8_REV FLOAT_32_UNSIGNED_INT_24_8_REV}
+ * @param pixels the pixel data + * + * @see Reference Page + */ + public static void glTexSubImage1D(@NativeType("GLenum") int target, @NativeType("GLint") int level, @NativeType("GLint") int xoffset, @NativeType("GLsizei") int width, @NativeType("GLenum") int format, @NativeType("GLenum") int type, @NativeType("void const *") IntBuffer pixels) { + GL11C.glTexSubImage1D(target, level, xoffset, width, format, type, pixels); + } + + /** + * One-dimensional version of {@link #glTexSubImage2D TexSubImage2D}. + * + * @param target the texture target. Must be:
{@link GL11C#GL_TEXTURE_1D TEXTURE_1D}
+ * @param level the level-of-detail-number + * @param xoffset the left coordinate of the texel subregion + * @param width the subregion width + * @param format the pixel data format. One of:
{@link GL11C#GL_RED RED}{@link GL11C#GL_GREEN GREEN}{@link GL11C#GL_BLUE BLUE}{@link GL11C#GL_ALPHA ALPHA}{@link GL30#GL_RG RG}{@link GL11C#GL_RGB RGB}{@link GL11C#GL_RGBA RGBA}{@link GL12#GL_BGR BGR}
{@link GL12#GL_BGRA BGRA}{@link GL30#GL_RED_INTEGER RED_INTEGER}{@link GL30#GL_GREEN_INTEGER GREEN_INTEGER}{@link GL30#GL_BLUE_INTEGER BLUE_INTEGER}{@link GL30#GL_ALPHA_INTEGER ALPHA_INTEGER}{@link GL30#GL_RG_INTEGER RG_INTEGER}{@link GL30#GL_RGB_INTEGER RGB_INTEGER}{@link GL30#GL_RGBA_INTEGER RGBA_INTEGER}
{@link GL30#GL_BGR_INTEGER BGR_INTEGER}{@link GL30#GL_BGRA_INTEGER BGRA_INTEGER}{@link GL11C#GL_STENCIL_INDEX STENCIL_INDEX}{@link GL11C#GL_DEPTH_COMPONENT DEPTH_COMPONENT}{@link GL30#GL_DEPTH_STENCIL DEPTH_STENCIL}
+ * @param type the pixel data type. One of:
{@link GL11C#GL_UNSIGNED_BYTE UNSIGNED_BYTE}{@link GL11C#GL_BYTE BYTE}{@link GL11C#GL_UNSIGNED_SHORT UNSIGNED_SHORT}{@link GL11C#GL_SHORT SHORT}
{@link GL11C#GL_UNSIGNED_INT UNSIGNED_INT}{@link GL11C#GL_INT INT}{@link GL30#GL_HALF_FLOAT HALF_FLOAT}{@link GL11C#GL_FLOAT FLOAT}
{@link GL12#GL_UNSIGNED_BYTE_3_3_2 UNSIGNED_BYTE_3_3_2}{@link GL12#GL_UNSIGNED_BYTE_2_3_3_REV UNSIGNED_BYTE_2_3_3_REV}{@link GL12#GL_UNSIGNED_SHORT_5_6_5 UNSIGNED_SHORT_5_6_5}{@link GL12#GL_UNSIGNED_SHORT_5_6_5_REV UNSIGNED_SHORT_5_6_5_REV}
{@link GL12#GL_UNSIGNED_SHORT_4_4_4_4 UNSIGNED_SHORT_4_4_4_4}{@link GL12#GL_UNSIGNED_SHORT_4_4_4_4_REV UNSIGNED_SHORT_4_4_4_4_REV}{@link GL12#GL_UNSIGNED_SHORT_5_5_5_1 UNSIGNED_SHORT_5_5_5_1}{@link GL12#GL_UNSIGNED_SHORT_1_5_5_5_REV UNSIGNED_SHORT_1_5_5_5_REV}
{@link GL12#GL_UNSIGNED_INT_8_8_8_8 UNSIGNED_INT_8_8_8_8}{@link GL12#GL_UNSIGNED_INT_8_8_8_8_REV UNSIGNED_INT_8_8_8_8_REV}{@link GL12#GL_UNSIGNED_INT_10_10_10_2 UNSIGNED_INT_10_10_10_2}{@link GL12#GL_UNSIGNED_INT_2_10_10_10_REV UNSIGNED_INT_2_10_10_10_REV}
{@link GL30#GL_UNSIGNED_INT_24_8 UNSIGNED_INT_24_8}{@link GL30#GL_UNSIGNED_INT_10F_11F_11F_REV UNSIGNED_INT_10F_11F_11F_REV}{@link GL30#GL_UNSIGNED_INT_5_9_9_9_REV UNSIGNED_INT_5_9_9_9_REV}{@link GL30#GL_FLOAT_32_UNSIGNED_INT_24_8_REV FLOAT_32_UNSIGNED_INT_24_8_REV}
+ * @param pixels the pixel data + * + * @see Reference Page + */ + public static void glTexSubImage1D(@NativeType("GLenum") int target, @NativeType("GLint") int level, @NativeType("GLint") int xoffset, @NativeType("GLsizei") int width, @NativeType("GLenum") int format, @NativeType("GLenum") int type, @NativeType("void const *") FloatBuffer pixels) { + GL11C.glTexSubImage1D(target, level, xoffset, width, format, type, pixels); + } + + /** + * One-dimensional version of {@link #glTexSubImage2D TexSubImage2D}. + * + * @param target the texture target. Must be:
{@link GL11C#GL_TEXTURE_1D TEXTURE_1D}
+ * @param level the level-of-detail-number + * @param xoffset the left coordinate of the texel subregion + * @param width the subregion width + * @param format the pixel data format. One of:
{@link GL11C#GL_RED RED}{@link GL11C#GL_GREEN GREEN}{@link GL11C#GL_BLUE BLUE}{@link GL11C#GL_ALPHA ALPHA}{@link GL30#GL_RG RG}{@link GL11C#GL_RGB RGB}{@link GL11C#GL_RGBA RGBA}{@link GL12#GL_BGR BGR}
{@link GL12#GL_BGRA BGRA}{@link GL30#GL_RED_INTEGER RED_INTEGER}{@link GL30#GL_GREEN_INTEGER GREEN_INTEGER}{@link GL30#GL_BLUE_INTEGER BLUE_INTEGER}{@link GL30#GL_ALPHA_INTEGER ALPHA_INTEGER}{@link GL30#GL_RG_INTEGER RG_INTEGER}{@link GL30#GL_RGB_INTEGER RGB_INTEGER}{@link GL30#GL_RGBA_INTEGER RGBA_INTEGER}
{@link GL30#GL_BGR_INTEGER BGR_INTEGER}{@link GL30#GL_BGRA_INTEGER BGRA_INTEGER}{@link GL11C#GL_STENCIL_INDEX STENCIL_INDEX}{@link GL11C#GL_DEPTH_COMPONENT DEPTH_COMPONENT}{@link GL30#GL_DEPTH_STENCIL DEPTH_STENCIL}
+ * @param type the pixel data type. One of:
{@link GL11C#GL_UNSIGNED_BYTE UNSIGNED_BYTE}{@link GL11C#GL_BYTE BYTE}{@link GL11C#GL_UNSIGNED_SHORT UNSIGNED_SHORT}{@link GL11C#GL_SHORT SHORT}
{@link GL11C#GL_UNSIGNED_INT UNSIGNED_INT}{@link GL11C#GL_INT INT}{@link GL30#GL_HALF_FLOAT HALF_FLOAT}{@link GL11C#GL_FLOAT FLOAT}
{@link GL12#GL_UNSIGNED_BYTE_3_3_2 UNSIGNED_BYTE_3_3_2}{@link GL12#GL_UNSIGNED_BYTE_2_3_3_REV UNSIGNED_BYTE_2_3_3_REV}{@link GL12#GL_UNSIGNED_SHORT_5_6_5 UNSIGNED_SHORT_5_6_5}{@link GL12#GL_UNSIGNED_SHORT_5_6_5_REV UNSIGNED_SHORT_5_6_5_REV}
{@link GL12#GL_UNSIGNED_SHORT_4_4_4_4 UNSIGNED_SHORT_4_4_4_4}{@link GL12#GL_UNSIGNED_SHORT_4_4_4_4_REV UNSIGNED_SHORT_4_4_4_4_REV}{@link GL12#GL_UNSIGNED_SHORT_5_5_5_1 UNSIGNED_SHORT_5_5_5_1}{@link GL12#GL_UNSIGNED_SHORT_1_5_5_5_REV UNSIGNED_SHORT_1_5_5_5_REV}
{@link GL12#GL_UNSIGNED_INT_8_8_8_8 UNSIGNED_INT_8_8_8_8}{@link GL12#GL_UNSIGNED_INT_8_8_8_8_REV UNSIGNED_INT_8_8_8_8_REV}{@link GL12#GL_UNSIGNED_INT_10_10_10_2 UNSIGNED_INT_10_10_10_2}{@link GL12#GL_UNSIGNED_INT_2_10_10_10_REV UNSIGNED_INT_2_10_10_10_REV}
{@link GL30#GL_UNSIGNED_INT_24_8 UNSIGNED_INT_24_8}{@link GL30#GL_UNSIGNED_INT_10F_11F_11F_REV UNSIGNED_INT_10F_11F_11F_REV}{@link GL30#GL_UNSIGNED_INT_5_9_9_9_REV UNSIGNED_INT_5_9_9_9_REV}{@link GL30#GL_FLOAT_32_UNSIGNED_INT_24_8_REV FLOAT_32_UNSIGNED_INT_24_8_REV}
+ * @param pixels the pixel data + * + * @see Reference Page + */ + public static void glTexSubImage1D(@NativeType("GLenum") int target, @NativeType("GLint") int level, @NativeType("GLint") int xoffset, @NativeType("GLsizei") int width, @NativeType("GLenum") int format, @NativeType("GLenum") int type, @NativeType("void const *") DoubleBuffer pixels) { + GL11C.glTexSubImage1D(target, level, xoffset, width, format, type, pixels); + } + + // --- [ glTexSubImage2D ] --- + + /** Unsafe version of: {@link #glTexSubImage2D TexSubImage2D} */ + public static void nglTexSubImage2D(int target, int level, int xoffset, int yoffset, int width, int height, int format, int type, long pixels) { + GL11C.nglTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels); + } + + /** + * Respecifies a rectangular subregion of an existing texel array. No change is made to the internalformat, width, height, depth, or border parameters of + * the specified texel array, nor is any change made to texel values outside the specified subregion. + * + * @param target the texture target. One of:
{@link GL11C#GL_TEXTURE_2D TEXTURE_2D}{@link GL30#GL_TEXTURE_1D_ARRAY TEXTURE_1D_ARRAY}{@link GL31#GL_TEXTURE_RECTANGLE TEXTURE_RECTANGLE}{@link GL13#GL_TEXTURE_CUBE_MAP TEXTURE_CUBE_MAP}
+ * @param level the level-of-detail-number + * @param xoffset the left coordinate of the texel subregion + * @param yoffset the bottom coordinate of the texel subregion + * @param width the subregion width + * @param height the subregion height + * @param format the pixel data format. One of:
{@link GL11C#GL_RED RED}{@link GL11C#GL_GREEN GREEN}{@link GL11C#GL_BLUE BLUE}{@link GL11C#GL_ALPHA ALPHA}{@link GL30#GL_RG RG}{@link GL11C#GL_RGB RGB}{@link GL11C#GL_RGBA RGBA}{@link GL12#GL_BGR BGR}
{@link GL12#GL_BGRA BGRA}{@link GL30#GL_RED_INTEGER RED_INTEGER}{@link GL30#GL_GREEN_INTEGER GREEN_INTEGER}{@link GL30#GL_BLUE_INTEGER BLUE_INTEGER}{@link GL30#GL_ALPHA_INTEGER ALPHA_INTEGER}{@link GL30#GL_RG_INTEGER RG_INTEGER}{@link GL30#GL_RGB_INTEGER RGB_INTEGER}{@link GL30#GL_RGBA_INTEGER RGBA_INTEGER}
{@link GL30#GL_BGR_INTEGER BGR_INTEGER}{@link GL30#GL_BGRA_INTEGER BGRA_INTEGER}{@link GL11C#GL_STENCIL_INDEX STENCIL_INDEX}{@link GL11C#GL_DEPTH_COMPONENT DEPTH_COMPONENT}{@link GL30#GL_DEPTH_STENCIL DEPTH_STENCIL}
+ * @param type the pixel data type. One of:
{@link GL11C#GL_UNSIGNED_BYTE UNSIGNED_BYTE}{@link GL11C#GL_BYTE BYTE}{@link GL11C#GL_UNSIGNED_SHORT UNSIGNED_SHORT}{@link GL11C#GL_SHORT SHORT}
{@link GL11C#GL_UNSIGNED_INT UNSIGNED_INT}{@link GL11C#GL_INT INT}{@link GL30#GL_HALF_FLOAT HALF_FLOAT}{@link GL11C#GL_FLOAT FLOAT}
{@link GL12#GL_UNSIGNED_BYTE_3_3_2 UNSIGNED_BYTE_3_3_2}{@link GL12#GL_UNSIGNED_BYTE_2_3_3_REV UNSIGNED_BYTE_2_3_3_REV}{@link GL12#GL_UNSIGNED_SHORT_5_6_5 UNSIGNED_SHORT_5_6_5}{@link GL12#GL_UNSIGNED_SHORT_5_6_5_REV UNSIGNED_SHORT_5_6_5_REV}
{@link GL12#GL_UNSIGNED_SHORT_4_4_4_4 UNSIGNED_SHORT_4_4_4_4}{@link GL12#GL_UNSIGNED_SHORT_4_4_4_4_REV UNSIGNED_SHORT_4_4_4_4_REV}{@link GL12#GL_UNSIGNED_SHORT_5_5_5_1 UNSIGNED_SHORT_5_5_5_1}{@link GL12#GL_UNSIGNED_SHORT_1_5_5_5_REV UNSIGNED_SHORT_1_5_5_5_REV}
{@link GL12#GL_UNSIGNED_INT_8_8_8_8 UNSIGNED_INT_8_8_8_8}{@link GL12#GL_UNSIGNED_INT_8_8_8_8_REV UNSIGNED_INT_8_8_8_8_REV}{@link GL12#GL_UNSIGNED_INT_10_10_10_2 UNSIGNED_INT_10_10_10_2}{@link GL12#GL_UNSIGNED_INT_2_10_10_10_REV UNSIGNED_INT_2_10_10_10_REV}
{@link GL30#GL_UNSIGNED_INT_24_8 UNSIGNED_INT_24_8}{@link GL30#GL_UNSIGNED_INT_10F_11F_11F_REV UNSIGNED_INT_10F_11F_11F_REV}{@link GL30#GL_UNSIGNED_INT_5_9_9_9_REV UNSIGNED_INT_5_9_9_9_REV}{@link GL30#GL_FLOAT_32_UNSIGNED_INT_24_8_REV FLOAT_32_UNSIGNED_INT_24_8_REV}
+ * @param pixels the pixel data + * + * @see Reference Page + */ + public static void glTexSubImage2D(@NativeType("GLenum") int target, @NativeType("GLint") int level, @NativeType("GLint") int xoffset, @NativeType("GLint") int yoffset, @NativeType("GLsizei") int width, @NativeType("GLsizei") int height, @NativeType("GLenum") int format, @NativeType("GLenum") int type, @NativeType("void const *") ByteBuffer pixels) { + GL11C.glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels); + } + + /** + * Respecifies a rectangular subregion of an existing texel array. No change is made to the internalformat, width, height, depth, or border parameters of + * the specified texel array, nor is any change made to texel values outside the specified subregion. + * + * @param target the texture target. One of:
{@link GL11C#GL_TEXTURE_2D TEXTURE_2D}{@link GL30#GL_TEXTURE_1D_ARRAY TEXTURE_1D_ARRAY}{@link GL31#GL_TEXTURE_RECTANGLE TEXTURE_RECTANGLE}{@link GL13#GL_TEXTURE_CUBE_MAP TEXTURE_CUBE_MAP}
+ * @param level the level-of-detail-number + * @param xoffset the left coordinate of the texel subregion + * @param yoffset the bottom coordinate of the texel subregion + * @param width the subregion width + * @param height the subregion height + * @param format the pixel data format. One of:
{@link GL11C#GL_RED RED}{@link GL11C#GL_GREEN GREEN}{@link GL11C#GL_BLUE BLUE}{@link GL11C#GL_ALPHA ALPHA}{@link GL30#GL_RG RG}{@link GL11C#GL_RGB RGB}{@link GL11C#GL_RGBA RGBA}{@link GL12#GL_BGR BGR}
{@link GL12#GL_BGRA BGRA}{@link GL30#GL_RED_INTEGER RED_INTEGER}{@link GL30#GL_GREEN_INTEGER GREEN_INTEGER}{@link GL30#GL_BLUE_INTEGER BLUE_INTEGER}{@link GL30#GL_ALPHA_INTEGER ALPHA_INTEGER}{@link GL30#GL_RG_INTEGER RG_INTEGER}{@link GL30#GL_RGB_INTEGER RGB_INTEGER}{@link GL30#GL_RGBA_INTEGER RGBA_INTEGER}
{@link GL30#GL_BGR_INTEGER BGR_INTEGER}{@link GL30#GL_BGRA_INTEGER BGRA_INTEGER}{@link GL11C#GL_STENCIL_INDEX STENCIL_INDEX}{@link GL11C#GL_DEPTH_COMPONENT DEPTH_COMPONENT}{@link GL30#GL_DEPTH_STENCIL DEPTH_STENCIL}
+ * @param type the pixel data type. One of:
{@link GL11C#GL_UNSIGNED_BYTE UNSIGNED_BYTE}{@link GL11C#GL_BYTE BYTE}{@link GL11C#GL_UNSIGNED_SHORT UNSIGNED_SHORT}{@link GL11C#GL_SHORT SHORT}
{@link GL11C#GL_UNSIGNED_INT UNSIGNED_INT}{@link GL11C#GL_INT INT}{@link GL30#GL_HALF_FLOAT HALF_FLOAT}{@link GL11C#GL_FLOAT FLOAT}
{@link GL12#GL_UNSIGNED_BYTE_3_3_2 UNSIGNED_BYTE_3_3_2}{@link GL12#GL_UNSIGNED_BYTE_2_3_3_REV UNSIGNED_BYTE_2_3_3_REV}{@link GL12#GL_UNSIGNED_SHORT_5_6_5 UNSIGNED_SHORT_5_6_5}{@link GL12#GL_UNSIGNED_SHORT_5_6_5_REV UNSIGNED_SHORT_5_6_5_REV}
{@link GL12#GL_UNSIGNED_SHORT_4_4_4_4 UNSIGNED_SHORT_4_4_4_4}{@link GL12#GL_UNSIGNED_SHORT_4_4_4_4_REV UNSIGNED_SHORT_4_4_4_4_REV}{@link GL12#GL_UNSIGNED_SHORT_5_5_5_1 UNSIGNED_SHORT_5_5_5_1}{@link GL12#GL_UNSIGNED_SHORT_1_5_5_5_REV UNSIGNED_SHORT_1_5_5_5_REV}
{@link GL12#GL_UNSIGNED_INT_8_8_8_8 UNSIGNED_INT_8_8_8_8}{@link GL12#GL_UNSIGNED_INT_8_8_8_8_REV UNSIGNED_INT_8_8_8_8_REV}{@link GL12#GL_UNSIGNED_INT_10_10_10_2 UNSIGNED_INT_10_10_10_2}{@link GL12#GL_UNSIGNED_INT_2_10_10_10_REV UNSIGNED_INT_2_10_10_10_REV}
{@link GL30#GL_UNSIGNED_INT_24_8 UNSIGNED_INT_24_8}{@link GL30#GL_UNSIGNED_INT_10F_11F_11F_REV UNSIGNED_INT_10F_11F_11F_REV}{@link GL30#GL_UNSIGNED_INT_5_9_9_9_REV UNSIGNED_INT_5_9_9_9_REV}{@link GL30#GL_FLOAT_32_UNSIGNED_INT_24_8_REV FLOAT_32_UNSIGNED_INT_24_8_REV}
+ * @param pixels the pixel data + * + * @see Reference Page + */ + public static void glTexSubImage2D(@NativeType("GLenum") int target, @NativeType("GLint") int level, @NativeType("GLint") int xoffset, @NativeType("GLint") int yoffset, @NativeType("GLsizei") int width, @NativeType("GLsizei") int height, @NativeType("GLenum") int format, @NativeType("GLenum") int type, @NativeType("void const *") long pixels) { + GL11C.glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels); + } + + /** + * Respecifies a rectangular subregion of an existing texel array. No change is made to the internalformat, width, height, depth, or border parameters of + * the specified texel array, nor is any change made to texel values outside the specified subregion. + * + * @param target the texture target. One of:
{@link GL11C#GL_TEXTURE_2D TEXTURE_2D}{@link GL30#GL_TEXTURE_1D_ARRAY TEXTURE_1D_ARRAY}{@link GL31#GL_TEXTURE_RECTANGLE TEXTURE_RECTANGLE}{@link GL13#GL_TEXTURE_CUBE_MAP TEXTURE_CUBE_MAP}
+ * @param level the level-of-detail-number + * @param xoffset the left coordinate of the texel subregion + * @param yoffset the bottom coordinate of the texel subregion + * @param width the subregion width + * @param height the subregion height + * @param format the pixel data format. One of:
{@link GL11C#GL_RED RED}{@link GL11C#GL_GREEN GREEN}{@link GL11C#GL_BLUE BLUE}{@link GL11C#GL_ALPHA ALPHA}{@link GL30#GL_RG RG}{@link GL11C#GL_RGB RGB}{@link GL11C#GL_RGBA RGBA}{@link GL12#GL_BGR BGR}
{@link GL12#GL_BGRA BGRA}{@link GL30#GL_RED_INTEGER RED_INTEGER}{@link GL30#GL_GREEN_INTEGER GREEN_INTEGER}{@link GL30#GL_BLUE_INTEGER BLUE_INTEGER}{@link GL30#GL_ALPHA_INTEGER ALPHA_INTEGER}{@link GL30#GL_RG_INTEGER RG_INTEGER}{@link GL30#GL_RGB_INTEGER RGB_INTEGER}{@link GL30#GL_RGBA_INTEGER RGBA_INTEGER}
{@link GL30#GL_BGR_INTEGER BGR_INTEGER}{@link GL30#GL_BGRA_INTEGER BGRA_INTEGER}{@link GL11C#GL_STENCIL_INDEX STENCIL_INDEX}{@link GL11C#GL_DEPTH_COMPONENT DEPTH_COMPONENT}{@link GL30#GL_DEPTH_STENCIL DEPTH_STENCIL}
+ * @param type the pixel data type. One of:
{@link GL11C#GL_UNSIGNED_BYTE UNSIGNED_BYTE}{@link GL11C#GL_BYTE BYTE}{@link GL11C#GL_UNSIGNED_SHORT UNSIGNED_SHORT}{@link GL11C#GL_SHORT SHORT}
{@link GL11C#GL_UNSIGNED_INT UNSIGNED_INT}{@link GL11C#GL_INT INT}{@link GL30#GL_HALF_FLOAT HALF_FLOAT}{@link GL11C#GL_FLOAT FLOAT}
{@link GL12#GL_UNSIGNED_BYTE_3_3_2 UNSIGNED_BYTE_3_3_2}{@link GL12#GL_UNSIGNED_BYTE_2_3_3_REV UNSIGNED_BYTE_2_3_3_REV}{@link GL12#GL_UNSIGNED_SHORT_5_6_5 UNSIGNED_SHORT_5_6_5}{@link GL12#GL_UNSIGNED_SHORT_5_6_5_REV UNSIGNED_SHORT_5_6_5_REV}
{@link GL12#GL_UNSIGNED_SHORT_4_4_4_4 UNSIGNED_SHORT_4_4_4_4}{@link GL12#GL_UNSIGNED_SHORT_4_4_4_4_REV UNSIGNED_SHORT_4_4_4_4_REV}{@link GL12#GL_UNSIGNED_SHORT_5_5_5_1 UNSIGNED_SHORT_5_5_5_1}{@link GL12#GL_UNSIGNED_SHORT_1_5_5_5_REV UNSIGNED_SHORT_1_5_5_5_REV}
{@link GL12#GL_UNSIGNED_INT_8_8_8_8 UNSIGNED_INT_8_8_8_8}{@link GL12#GL_UNSIGNED_INT_8_8_8_8_REV UNSIGNED_INT_8_8_8_8_REV}{@link GL12#GL_UNSIGNED_INT_10_10_10_2 UNSIGNED_INT_10_10_10_2}{@link GL12#GL_UNSIGNED_INT_2_10_10_10_REV UNSIGNED_INT_2_10_10_10_REV}
{@link GL30#GL_UNSIGNED_INT_24_8 UNSIGNED_INT_24_8}{@link GL30#GL_UNSIGNED_INT_10F_11F_11F_REV UNSIGNED_INT_10F_11F_11F_REV}{@link GL30#GL_UNSIGNED_INT_5_9_9_9_REV UNSIGNED_INT_5_9_9_9_REV}{@link GL30#GL_FLOAT_32_UNSIGNED_INT_24_8_REV FLOAT_32_UNSIGNED_INT_24_8_REV}
+ * @param pixels the pixel data + * + * @see Reference Page + */ + public static void glTexSubImage2D(@NativeType("GLenum") int target, @NativeType("GLint") int level, @NativeType("GLint") int xoffset, @NativeType("GLint") int yoffset, @NativeType("GLsizei") int width, @NativeType("GLsizei") int height, @NativeType("GLenum") int format, @NativeType("GLenum") int type, @NativeType("void const *") ShortBuffer pixels) { + GL11C.glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels); + } + + /** + * Respecifies a rectangular subregion of an existing texel array. No change is made to the internalformat, width, height, depth, or border parameters of + * the specified texel array, nor is any change made to texel values outside the specified subregion. + * + * @param target the texture target. One of:
{@link GL11C#GL_TEXTURE_2D TEXTURE_2D}{@link GL30#GL_TEXTURE_1D_ARRAY TEXTURE_1D_ARRAY}{@link GL31#GL_TEXTURE_RECTANGLE TEXTURE_RECTANGLE}{@link GL13#GL_TEXTURE_CUBE_MAP TEXTURE_CUBE_MAP}
+ * @param level the level-of-detail-number + * @param xoffset the left coordinate of the texel subregion + * @param yoffset the bottom coordinate of the texel subregion + * @param width the subregion width + * @param height the subregion height + * @param format the pixel data format. One of:
{@link GL11C#GL_RED RED}{@link GL11C#GL_GREEN GREEN}{@link GL11C#GL_BLUE BLUE}{@link GL11C#GL_ALPHA ALPHA}{@link GL30#GL_RG RG}{@link GL11C#GL_RGB RGB}{@link GL11C#GL_RGBA RGBA}{@link GL12#GL_BGR BGR}
{@link GL12#GL_BGRA BGRA}{@link GL30#GL_RED_INTEGER RED_INTEGER}{@link GL30#GL_GREEN_INTEGER GREEN_INTEGER}{@link GL30#GL_BLUE_INTEGER BLUE_INTEGER}{@link GL30#GL_ALPHA_INTEGER ALPHA_INTEGER}{@link GL30#GL_RG_INTEGER RG_INTEGER}{@link GL30#GL_RGB_INTEGER RGB_INTEGER}{@link GL30#GL_RGBA_INTEGER RGBA_INTEGER}
{@link GL30#GL_BGR_INTEGER BGR_INTEGER}{@link GL30#GL_BGRA_INTEGER BGRA_INTEGER}{@link GL11C#GL_STENCIL_INDEX STENCIL_INDEX}{@link GL11C#GL_DEPTH_COMPONENT DEPTH_COMPONENT}{@link GL30#GL_DEPTH_STENCIL DEPTH_STENCIL}
+ * @param type the pixel data type. One of:
{@link GL11C#GL_UNSIGNED_BYTE UNSIGNED_BYTE}{@link GL11C#GL_BYTE BYTE}{@link GL11C#GL_UNSIGNED_SHORT UNSIGNED_SHORT}{@link GL11C#GL_SHORT SHORT}
{@link GL11C#GL_UNSIGNED_INT UNSIGNED_INT}{@link GL11C#GL_INT INT}{@link GL30#GL_HALF_FLOAT HALF_FLOAT}{@link GL11C#GL_FLOAT FLOAT}
{@link GL12#GL_UNSIGNED_BYTE_3_3_2 UNSIGNED_BYTE_3_3_2}{@link GL12#GL_UNSIGNED_BYTE_2_3_3_REV UNSIGNED_BYTE_2_3_3_REV}{@link GL12#GL_UNSIGNED_SHORT_5_6_5 UNSIGNED_SHORT_5_6_5}{@link GL12#GL_UNSIGNED_SHORT_5_6_5_REV UNSIGNED_SHORT_5_6_5_REV}
{@link GL12#GL_UNSIGNED_SHORT_4_4_4_4 UNSIGNED_SHORT_4_4_4_4}{@link GL12#GL_UNSIGNED_SHORT_4_4_4_4_REV UNSIGNED_SHORT_4_4_4_4_REV}{@link GL12#GL_UNSIGNED_SHORT_5_5_5_1 UNSIGNED_SHORT_5_5_5_1}{@link GL12#GL_UNSIGNED_SHORT_1_5_5_5_REV UNSIGNED_SHORT_1_5_5_5_REV}
{@link GL12#GL_UNSIGNED_INT_8_8_8_8 UNSIGNED_INT_8_8_8_8}{@link GL12#GL_UNSIGNED_INT_8_8_8_8_REV UNSIGNED_INT_8_8_8_8_REV}{@link GL12#GL_UNSIGNED_INT_10_10_10_2 UNSIGNED_INT_10_10_10_2}{@link GL12#GL_UNSIGNED_INT_2_10_10_10_REV UNSIGNED_INT_2_10_10_10_REV}
{@link GL30#GL_UNSIGNED_INT_24_8 UNSIGNED_INT_24_8}{@link GL30#GL_UNSIGNED_INT_10F_11F_11F_REV UNSIGNED_INT_10F_11F_11F_REV}{@link GL30#GL_UNSIGNED_INT_5_9_9_9_REV UNSIGNED_INT_5_9_9_9_REV}{@link GL30#GL_FLOAT_32_UNSIGNED_INT_24_8_REV FLOAT_32_UNSIGNED_INT_24_8_REV}
+ * @param pixels the pixel data + * + * @see Reference Page + */ + public static void glTexSubImage2D(@NativeType("GLenum") int target, @NativeType("GLint") int level, @NativeType("GLint") int xoffset, @NativeType("GLint") int yoffset, @NativeType("GLsizei") int width, @NativeType("GLsizei") int height, @NativeType("GLenum") int format, @NativeType("GLenum") int type, @NativeType("void const *") IntBuffer pixels) { + GL11C.glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels); + } + + /** + * Respecifies a rectangular subregion of an existing texel array. No change is made to the internalformat, width, height, depth, or border parameters of + * the specified texel array, nor is any change made to texel values outside the specified subregion. + * + * @param target the texture target. One of:
{@link GL11C#GL_TEXTURE_2D TEXTURE_2D}{@link GL30#GL_TEXTURE_1D_ARRAY TEXTURE_1D_ARRAY}{@link GL31#GL_TEXTURE_RECTANGLE TEXTURE_RECTANGLE}{@link GL13#GL_TEXTURE_CUBE_MAP TEXTURE_CUBE_MAP}
+ * @param level the level-of-detail-number + * @param xoffset the left coordinate of the texel subregion + * @param yoffset the bottom coordinate of the texel subregion + * @param width the subregion width + * @param height the subregion height + * @param format the pixel data format. One of:
{@link GL11C#GL_RED RED}{@link GL11C#GL_GREEN GREEN}{@link GL11C#GL_BLUE BLUE}{@link GL11C#GL_ALPHA ALPHA}{@link GL30#GL_RG RG}{@link GL11C#GL_RGB RGB}{@link GL11C#GL_RGBA RGBA}{@link GL12#GL_BGR BGR}
{@link GL12#GL_BGRA BGRA}{@link GL30#GL_RED_INTEGER RED_INTEGER}{@link GL30#GL_GREEN_INTEGER GREEN_INTEGER}{@link GL30#GL_BLUE_INTEGER BLUE_INTEGER}{@link GL30#GL_ALPHA_INTEGER ALPHA_INTEGER}{@link GL30#GL_RG_INTEGER RG_INTEGER}{@link GL30#GL_RGB_INTEGER RGB_INTEGER}{@link GL30#GL_RGBA_INTEGER RGBA_INTEGER}
{@link GL30#GL_BGR_INTEGER BGR_INTEGER}{@link GL30#GL_BGRA_INTEGER BGRA_INTEGER}{@link GL11C#GL_STENCIL_INDEX STENCIL_INDEX}{@link GL11C#GL_DEPTH_COMPONENT DEPTH_COMPONENT}{@link GL30#GL_DEPTH_STENCIL DEPTH_STENCIL}
+ * @param type the pixel data type. One of:
{@link GL11C#GL_UNSIGNED_BYTE UNSIGNED_BYTE}{@link GL11C#GL_BYTE BYTE}{@link GL11C#GL_UNSIGNED_SHORT UNSIGNED_SHORT}{@link GL11C#GL_SHORT SHORT}
{@link GL11C#GL_UNSIGNED_INT UNSIGNED_INT}{@link GL11C#GL_INT INT}{@link GL30#GL_HALF_FLOAT HALF_FLOAT}{@link GL11C#GL_FLOAT FLOAT}
{@link GL12#GL_UNSIGNED_BYTE_3_3_2 UNSIGNED_BYTE_3_3_2}{@link GL12#GL_UNSIGNED_BYTE_2_3_3_REV UNSIGNED_BYTE_2_3_3_REV}{@link GL12#GL_UNSIGNED_SHORT_5_6_5 UNSIGNED_SHORT_5_6_5}{@link GL12#GL_UNSIGNED_SHORT_5_6_5_REV UNSIGNED_SHORT_5_6_5_REV}
{@link GL12#GL_UNSIGNED_SHORT_4_4_4_4 UNSIGNED_SHORT_4_4_4_4}{@link GL12#GL_UNSIGNED_SHORT_4_4_4_4_REV UNSIGNED_SHORT_4_4_4_4_REV}{@link GL12#GL_UNSIGNED_SHORT_5_5_5_1 UNSIGNED_SHORT_5_5_5_1}{@link GL12#GL_UNSIGNED_SHORT_1_5_5_5_REV UNSIGNED_SHORT_1_5_5_5_REV}
{@link GL12#GL_UNSIGNED_INT_8_8_8_8 UNSIGNED_INT_8_8_8_8}{@link GL12#GL_UNSIGNED_INT_8_8_8_8_REV UNSIGNED_INT_8_8_8_8_REV}{@link GL12#GL_UNSIGNED_INT_10_10_10_2 UNSIGNED_INT_10_10_10_2}{@link GL12#GL_UNSIGNED_INT_2_10_10_10_REV UNSIGNED_INT_2_10_10_10_REV}
{@link GL30#GL_UNSIGNED_INT_24_8 UNSIGNED_INT_24_8}{@link GL30#GL_UNSIGNED_INT_10F_11F_11F_REV UNSIGNED_INT_10F_11F_11F_REV}{@link GL30#GL_UNSIGNED_INT_5_9_9_9_REV UNSIGNED_INT_5_9_9_9_REV}{@link GL30#GL_FLOAT_32_UNSIGNED_INT_24_8_REV FLOAT_32_UNSIGNED_INT_24_8_REV}
+ * @param pixels the pixel data + * + * @see Reference Page + */ + public static void glTexSubImage2D(@NativeType("GLenum") int target, @NativeType("GLint") int level, @NativeType("GLint") int xoffset, @NativeType("GLint") int yoffset, @NativeType("GLsizei") int width, @NativeType("GLsizei") int height, @NativeType("GLenum") int format, @NativeType("GLenum") int type, @NativeType("void const *") FloatBuffer pixels) { + GL11C.glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels); + } + + /** + * Respecifies a rectangular subregion of an existing texel array. No change is made to the internalformat, width, height, depth, or border parameters of + * the specified texel array, nor is any change made to texel values outside the specified subregion. + * + * @param target the texture target. One of:
{@link GL11C#GL_TEXTURE_2D TEXTURE_2D}{@link GL30#GL_TEXTURE_1D_ARRAY TEXTURE_1D_ARRAY}{@link GL31#GL_TEXTURE_RECTANGLE TEXTURE_RECTANGLE}{@link GL13#GL_TEXTURE_CUBE_MAP TEXTURE_CUBE_MAP}
+ * @param level the level-of-detail-number + * @param xoffset the left coordinate of the texel subregion + * @param yoffset the bottom coordinate of the texel subregion + * @param width the subregion width + * @param height the subregion height + * @param format the pixel data format. One of:
{@link GL11C#GL_RED RED}{@link GL11C#GL_GREEN GREEN}{@link GL11C#GL_BLUE BLUE}{@link GL11C#GL_ALPHA ALPHA}{@link GL30#GL_RG RG}{@link GL11C#GL_RGB RGB}{@link GL11C#GL_RGBA RGBA}{@link GL12#GL_BGR BGR}
{@link GL12#GL_BGRA BGRA}{@link GL30#GL_RED_INTEGER RED_INTEGER}{@link GL30#GL_GREEN_INTEGER GREEN_INTEGER}{@link GL30#GL_BLUE_INTEGER BLUE_INTEGER}{@link GL30#GL_ALPHA_INTEGER ALPHA_INTEGER}{@link GL30#GL_RG_INTEGER RG_INTEGER}{@link GL30#GL_RGB_INTEGER RGB_INTEGER}{@link GL30#GL_RGBA_INTEGER RGBA_INTEGER}
{@link GL30#GL_BGR_INTEGER BGR_INTEGER}{@link GL30#GL_BGRA_INTEGER BGRA_INTEGER}{@link GL11C#GL_STENCIL_INDEX STENCIL_INDEX}{@link GL11C#GL_DEPTH_COMPONENT DEPTH_COMPONENT}{@link GL30#GL_DEPTH_STENCIL DEPTH_STENCIL}
+ * @param type the pixel data type. One of:
{@link GL11C#GL_UNSIGNED_BYTE UNSIGNED_BYTE}{@link GL11C#GL_BYTE BYTE}{@link GL11C#GL_UNSIGNED_SHORT UNSIGNED_SHORT}{@link GL11C#GL_SHORT SHORT}
{@link GL11C#GL_UNSIGNED_INT UNSIGNED_INT}{@link GL11C#GL_INT INT}{@link GL30#GL_HALF_FLOAT HALF_FLOAT}{@link GL11C#GL_FLOAT FLOAT}
{@link GL12#GL_UNSIGNED_BYTE_3_3_2 UNSIGNED_BYTE_3_3_2}{@link GL12#GL_UNSIGNED_BYTE_2_3_3_REV UNSIGNED_BYTE_2_3_3_REV}{@link GL12#GL_UNSIGNED_SHORT_5_6_5 UNSIGNED_SHORT_5_6_5}{@link GL12#GL_UNSIGNED_SHORT_5_6_5_REV UNSIGNED_SHORT_5_6_5_REV}
{@link GL12#GL_UNSIGNED_SHORT_4_4_4_4 UNSIGNED_SHORT_4_4_4_4}{@link GL12#GL_UNSIGNED_SHORT_4_4_4_4_REV UNSIGNED_SHORT_4_4_4_4_REV}{@link GL12#GL_UNSIGNED_SHORT_5_5_5_1 UNSIGNED_SHORT_5_5_5_1}{@link GL12#GL_UNSIGNED_SHORT_1_5_5_5_REV UNSIGNED_SHORT_1_5_5_5_REV}
{@link GL12#GL_UNSIGNED_INT_8_8_8_8 UNSIGNED_INT_8_8_8_8}{@link GL12#GL_UNSIGNED_INT_8_8_8_8_REV UNSIGNED_INT_8_8_8_8_REV}{@link GL12#GL_UNSIGNED_INT_10_10_10_2 UNSIGNED_INT_10_10_10_2}{@link GL12#GL_UNSIGNED_INT_2_10_10_10_REV UNSIGNED_INT_2_10_10_10_REV}
{@link GL30#GL_UNSIGNED_INT_24_8 UNSIGNED_INT_24_8}{@link GL30#GL_UNSIGNED_INT_10F_11F_11F_REV UNSIGNED_INT_10F_11F_11F_REV}{@link GL30#GL_UNSIGNED_INT_5_9_9_9_REV UNSIGNED_INT_5_9_9_9_REV}{@link GL30#GL_FLOAT_32_UNSIGNED_INT_24_8_REV FLOAT_32_UNSIGNED_INT_24_8_REV}
+ * @param pixels the pixel data + * + * @see Reference Page + */ + public static void glTexSubImage2D(@NativeType("GLenum") int target, @NativeType("GLint") int level, @NativeType("GLint") int xoffset, @NativeType("GLint") int yoffset, @NativeType("GLsizei") int width, @NativeType("GLsizei") int height, @NativeType("GLenum") int format, @NativeType("GLenum") int type, @NativeType("void const *") DoubleBuffer pixels) { + GL11C.glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels); + } + + // --- [ glTranslatef ] --- + + /** + * Manipulates the current matrix with a translation matrix along the x-, y- and z- axes. + * + *

Calling this function is equivalent to calling {@link #glMultMatrixf MultMatrixf} with the following matrix:

+ * + * + * + * + * + * + *
100x
010y
001z
0001
+ * + * @param x the x-axis translation + * @param y the y-axis translation + * @param z the z-axis translation + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glTranslatef(@NativeType("GLfloat") float x, @NativeType("GLfloat") float y, @NativeType("GLfloat") float z); + + // --- [ glTranslated ] --- + + /** + * Double version of {@link #glTranslatef Translatef}. + * + * @param x the x-axis translation + * @param y the y-axis translation + * @param z the z-axis translation + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glTranslated(@NativeType("GLdouble") double x, @NativeType("GLdouble") double y, @NativeType("GLdouble") double z); + + // --- [ glVertex2f ] --- + + /** + * Specifies a single vertex between {@link #glBegin Begin} and {@link #glEnd End} by giving its coordinates in two dimensions. The z coordinate is implicitly set + * to zero and the w coordinate to one. + * + * @param x the vertex x coordinate + * @param y the vertex y coordinate + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glVertex2f(@NativeType("GLfloat") float x, @NativeType("GLfloat") float y); + + // --- [ glVertex2s ] --- + + /** + * Short version of {@link #glVertex2f Vertex2f}. + * + * @param x the vertex x coordinate + * @param y the vertex y coordinate + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glVertex2s(@NativeType("GLshort") short x, @NativeType("GLshort") short y); + + // --- [ glVertex2i ] --- + + /** + * Integer version of {@link #glVertex2f Vertex2f}. + * + * @param x the vertex x coordinate + * @param y the vertex y coordinate + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glVertex2i(@NativeType("GLint") int x, @NativeType("GLint") int y); + + // --- [ glVertex2d ] --- + + /** + * Double version of {@link #glVertex2f Vertex2f}. + * + * @param x the vertex x coordinate + * @param y the vertex y coordinate + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glVertex2d(@NativeType("GLdouble") double x, @NativeType("GLdouble") double y); + + // --- [ glVertex2fv ] --- + + /** Unsafe version of: {@link #glVertex2fv Vertex2fv} */ + public static native void nglVertex2fv(long coords); + + /** + * Pointer version of {@link #glVertex2f Vertex2f}. + * + * @param coords the vertex buffer + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glVertex2fv(@NativeType("GLfloat const *") FloatBuffer coords) { + if (CHECKS) { + check(coords, 2); + } + nglVertex2fv(memAddress(coords)); + } + + // --- [ glVertex2sv ] --- + + /** Unsafe version of: {@link #glVertex2sv Vertex2sv} */ + public static native void nglVertex2sv(long coords); + + /** + * Pointer version of {@link #glVertex2s Vertex2s}. + * + * @param coords the vertex buffer + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glVertex2sv(@NativeType("GLshort const *") ShortBuffer coords) { + if (CHECKS) { + check(coords, 2); + } + nglVertex2sv(memAddress(coords)); + } + + // --- [ glVertex2iv ] --- + + /** Unsafe version of: {@link #glVertex2iv Vertex2iv} */ + public static native void nglVertex2iv(long coords); + + /** + * Pointer version of {@link #glVertex2i Vertex2i}. + * + * @param coords the vertex buffer + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glVertex2iv(@NativeType("GLint const *") IntBuffer coords) { + if (CHECKS) { + check(coords, 2); + } + nglVertex2iv(memAddress(coords)); + } + + // --- [ glVertex2dv ] --- + + /** Unsafe version of: {@link #glVertex2dv Vertex2dv} */ + public static native void nglVertex2dv(long coords); + + /** + * Pointer version of {@link #glVertex2d Vertex2d}. + * + * @param coords the vertex buffer + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glVertex2dv(@NativeType("GLdouble const *") DoubleBuffer coords) { + if (CHECKS) { + check(coords, 2); + } + nglVertex2dv(memAddress(coords)); + } + + // --- [ glVertex3f ] --- + + /** + * Specifies a single vertex between {@link #glBegin Begin} and {@link #glEnd End} by giving its coordinates in three dimensions. The w coordinate is implicitly set + * to one. + * + * @param x the vertex x coordinate + * @param y the vertex y coordinate + * @param z the vertex z coordinate + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glVertex3f(@NativeType("GLfloat") float x, @NativeType("GLfloat") float y, @NativeType("GLfloat") float z); + + // --- [ glVertex3s ] --- + + /** + * Short version of {@link #glVertex3f Vertex3f}. + * + * @param x the vertex x coordinate + * @param y the vertex y coordinate + * @param z the vertex z coordinate + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glVertex3s(@NativeType("GLshort") short x, @NativeType("GLshort") short y, @NativeType("GLshort") short z); + + // --- [ glVertex3i ] --- + + /** + * Integer version of {@link #glVertex3f Vertex3f}. + * + * @param x the vertex x coordinate + * @param y the vertex y coordinate + * @param z the vertex z coordinate + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glVertex3i(@NativeType("GLint") int x, @NativeType("GLint") int y, @NativeType("GLint") int z); + + // --- [ glVertex3d ] --- + + /** + * Double version of {@link #glVertex3f Vertex3f}. + * + * @param x the vertex x coordinate + * @param y the vertex y coordinate + * @param z the vertex z coordinate + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glVertex3d(@NativeType("GLdouble") double x, @NativeType("GLdouble") double y, @NativeType("GLdouble") double z); + + // --- [ glVertex3fv ] --- + + /** Unsafe version of: {@link #glVertex3fv Vertex3fv} */ + public static native void nglVertex3fv(long coords); + + /** + * Pointer version of {@link #glVertex3f Vertex3f}. + * + * @param coords the vertex buffer + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glVertex3fv(@NativeType("GLfloat const *") FloatBuffer coords) { + if (CHECKS) { + check(coords, 3); + } + nglVertex3fv(memAddress(coords)); + } + + // --- [ glVertex3sv ] --- + + /** Unsafe version of: {@link #glVertex3sv Vertex3sv} */ + public static native void nglVertex3sv(long coords); + + /** + * Pointer version of {@link #glVertex3s Vertex3s}. + * + * @param coords the vertex buffer + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glVertex3sv(@NativeType("GLshort const *") ShortBuffer coords) { + if (CHECKS) { + check(coords, 3); + } + nglVertex3sv(memAddress(coords)); + } + + // --- [ glVertex3iv ] --- + + /** Unsafe version of: {@link #glVertex3iv Vertex3iv} */ + public static native void nglVertex3iv(long coords); + + /** + * Pointer version of {@link #glVertex3i Vertex3i}. + * + * @param coords the vertex buffer + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glVertex3iv(@NativeType("GLint const *") IntBuffer coords) { + if (CHECKS) { + check(coords, 3); + } + nglVertex3iv(memAddress(coords)); + } + + // --- [ glVertex3dv ] --- + + /** Unsafe version of: {@link #glVertex3dv Vertex3dv} */ + public static native void nglVertex3dv(long coords); + + /** + * Pointer version of {@link #glVertex3d Vertex3d}. + * + * @param coords the vertex buffer + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glVertex3dv(@NativeType("GLdouble const *") DoubleBuffer coords) { + if (CHECKS) { + check(coords, 3); + } + nglVertex3dv(memAddress(coords)); + } + + // --- [ glVertex4f ] --- + + /** + * Specifies a single vertex between {@link #glBegin Begin} and {@link #glEnd End} by giving its coordinates in four dimensions. + * + * @param x the vertex x coordinate + * @param y the vertex y coordinate + * @param z the vertex z coordinate + * @param w the vertex w coordinate + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glVertex4f(@NativeType("GLfloat") float x, @NativeType("GLfloat") float y, @NativeType("GLfloat") float z, @NativeType("GLfloat") float w); + + // --- [ glVertex4s ] --- + + /** + * Short version of {@link #glVertex4f Vertex4f}. + * + * @param x the vertex x coordinate + * @param y the vertex y coordinate + * @param z the vertex z coordinate + * @param w the vertex w coordinate + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glVertex4s(@NativeType("GLshort") short x, @NativeType("GLshort") short y, @NativeType("GLshort") short z, @NativeType("GLshort") short w); + + // --- [ glVertex4i ] --- + + /** + * Integer version of {@link #glVertex4f Vertex4f}. + * + * @param x the vertex x coordinate + * @param y the vertex y coordinate + * @param z the vertex z coordinate + * @param w the vertex w coordinate + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glVertex4i(@NativeType("GLint") int x, @NativeType("GLint") int y, @NativeType("GLint") int z, @NativeType("GLint") int w); + + // --- [ glVertex4d ] --- + + /** + * Double version of {@link #glVertex4f Vertex4f}. + * + * @param x the vertex x coordinate + * @param y the vertex y coordinate + * @param z the vertex z coordinate + * @param w the vertex w coordinate + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static native void glVertex4d(@NativeType("GLdouble") double x, @NativeType("GLdouble") double y, @NativeType("GLdouble") double z, @NativeType("GLdouble") double w); + + // --- [ glVertex4fv ] --- + + /** Unsafe version of: {@link #glVertex4fv Vertex4fv} */ + public static native void nglVertex4fv(long coords); + + /** + * Pointer version of {@link #glVertex4f Vertex4f}. + * + * @param coords the vertex buffer + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glVertex4fv(@NativeType("GLfloat const *") FloatBuffer coords) { + if (CHECKS) { + check(coords, 4); + } + nglVertex4fv(memAddress(coords)); + } + + // --- [ glVertex4sv ] --- + + /** Unsafe version of: {@link #glVertex4sv Vertex4sv} */ + public static native void nglVertex4sv(long coords); + + /** + * Pointer version of {@link #glVertex4s Vertex4s}. + * + * @param coords the vertex buffer + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glVertex4sv(@NativeType("GLshort const *") ShortBuffer coords) { + if (CHECKS) { + check(coords, 4); + } + nglVertex4sv(memAddress(coords)); + } + + // --- [ glVertex4iv ] --- + + /** Unsafe version of: {@link #glVertex4iv Vertex4iv} */ + public static native void nglVertex4iv(long coords); + + /** + * Pointer version of {@link #glVertex4i Vertex4i}. + * + * @param coords the vertex buffer + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glVertex4iv(@NativeType("GLint const *") IntBuffer coords) { + if (CHECKS) { + check(coords, 4); + } + nglVertex4iv(memAddress(coords)); + } + + // --- [ glVertex4dv ] --- + + /** Unsafe version of: {@link #glVertex4dv Vertex4dv} */ + public static native void nglVertex4dv(long coords); + + /** + * Pointer version of {@link #glVertex4d Vertex4d}. + * + * @param coords the vertex buffer + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glVertex4dv(@NativeType("GLdouble const *") DoubleBuffer coords) { + if (CHECKS) { + check(coords, 4); + } + nglVertex4dv(memAddress(coords)); + } + + // --- [ glVertexPointer ] --- + + /** Unsafe version of: {@link #glVertexPointer VertexPointer} */ + public static native void nglVertexPointer(int size, int type, int stride, long pointer); + + /** + * Specifies the location and organization of a vertex array. + * + * @param size the number of values per vertex that are stored in the array. One of:
234
+ * @param type the data type of the values stored in the array. One of:
{@link #GL_SHORT SHORT}{@link #GL_INT INT}{@link GL30#GL_HALF_FLOAT HALF_FLOAT}{@link #GL_FLOAT FLOAT}{@link #GL_DOUBLE DOUBLE}{@link GL12#GL_UNSIGNED_INT_2_10_10_10_REV UNSIGNED_INT_2_10_10_10_REV}{@link GL33#GL_INT_2_10_10_10_REV INT_2_10_10_10_REV}
+ * @param stride the vertex stride in bytes. If specified as zero, then array elements are stored sequentially + * @param pointer the vertex array data + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glVertexPointer(@NativeType("GLint") int size, @NativeType("GLenum") int type, @NativeType("GLsizei") int stride, @NativeType("void const *") ByteBuffer pointer) { + nglVertexPointer(size, type, stride, memAddress(pointer)); + } + + /** + * Specifies the location and organization of a vertex array. + * + * @param size the number of values per vertex that are stored in the array. One of:
234
+ * @param type the data type of the values stored in the array. One of:
{@link #GL_SHORT SHORT}{@link #GL_INT INT}{@link GL30#GL_HALF_FLOAT HALF_FLOAT}{@link #GL_FLOAT FLOAT}{@link #GL_DOUBLE DOUBLE}{@link GL12#GL_UNSIGNED_INT_2_10_10_10_REV UNSIGNED_INT_2_10_10_10_REV}{@link GL33#GL_INT_2_10_10_10_REV INT_2_10_10_10_REV}
+ * @param stride the vertex stride in bytes. If specified as zero, then array elements are stored sequentially + * @param pointer the vertex array data + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glVertexPointer(@NativeType("GLint") int size, @NativeType("GLenum") int type, @NativeType("GLsizei") int stride, @NativeType("void const *") long pointer) { + nglVertexPointer(size, type, stride, pointer); + } + + /** + * Specifies the location and organization of a vertex array. + * + * @param size the number of values per vertex that are stored in the array. One of:
234
+ * @param type the data type of the values stored in the array. One of:
{@link #GL_SHORT SHORT}{@link #GL_INT INT}{@link GL30#GL_HALF_FLOAT HALF_FLOAT}{@link #GL_FLOAT FLOAT}{@link #GL_DOUBLE DOUBLE}{@link GL12#GL_UNSIGNED_INT_2_10_10_10_REV UNSIGNED_INT_2_10_10_10_REV}{@link GL33#GL_INT_2_10_10_10_REV INT_2_10_10_10_REV}
+ * @param stride the vertex stride in bytes. If specified as zero, then array elements are stored sequentially + * @param pointer the vertex array data + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glVertexPointer(@NativeType("GLint") int size, @NativeType("GLenum") int type, @NativeType("GLsizei") int stride, @NativeType("void const *") ShortBuffer pointer) { + nglVertexPointer(size, type, stride, memAddress(pointer)); + } + + /** + * Specifies the location and organization of a vertex array. + * + * @param size the number of values per vertex that are stored in the array. One of:
234
+ * @param type the data type of the values stored in the array. One of:
{@link #GL_SHORT SHORT}{@link #GL_INT INT}{@link GL30#GL_HALF_FLOAT HALF_FLOAT}{@link #GL_FLOAT FLOAT}{@link #GL_DOUBLE DOUBLE}{@link GL12#GL_UNSIGNED_INT_2_10_10_10_REV UNSIGNED_INT_2_10_10_10_REV}{@link GL33#GL_INT_2_10_10_10_REV INT_2_10_10_10_REV}
+ * @param stride the vertex stride in bytes. If specified as zero, then array elements are stored sequentially + * @param pointer the vertex array data + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glVertexPointer(@NativeType("GLint") int size, @NativeType("GLenum") int type, @NativeType("GLsizei") int stride, @NativeType("void const *") IntBuffer pointer) { + nglVertexPointer(size, type, stride, memAddress(pointer)); + } + + /** + * Specifies the location and organization of a vertex array. + * + * @param size the number of values per vertex that are stored in the array. One of:
234
+ * @param type the data type of the values stored in the array. One of:
{@link #GL_SHORT SHORT}{@link #GL_INT INT}{@link GL30#GL_HALF_FLOAT HALF_FLOAT}{@link #GL_FLOAT FLOAT}{@link #GL_DOUBLE DOUBLE}{@link GL12#GL_UNSIGNED_INT_2_10_10_10_REV UNSIGNED_INT_2_10_10_10_REV}{@link GL33#GL_INT_2_10_10_10_REV INT_2_10_10_10_REV}
+ * @param stride the vertex stride in bytes. If specified as zero, then array elements are stored sequentially + * @param pointer the vertex array data + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glVertexPointer(@NativeType("GLint") int size, @NativeType("GLenum") int type, @NativeType("GLsizei") int stride, @NativeType("void const *") FloatBuffer pointer) { + nglVertexPointer(size, type, stride, memAddress(pointer)); + } + + // --- [ glViewport ] --- + + /** + * Specifies the viewport transformation parameters for all viewports. + * + *

The location of the viewport's bottom-left corner, given by {@code (x, y)}, are clamped to be within the implementation-dependent viewport bounds range. + * The viewport bounds range {@code [min, max]} tuple may be determined by calling {@link #glGetFloatv GetFloatv} with the symbolic + * constant {@link GL41#GL_VIEWPORT_BOUNDS_RANGE VIEWPORT_BOUNDS_RANGE}. Viewport width and height are clamped to implementation-dependent maximums when specified. The maximum + * width and height may be found by calling {@link #glGetFloatv GetFloatv} with the symbolic constant {@link GL11C#GL_MAX_VIEWPORT_DIMS MAX_VIEWPORT_DIMS}. The + * maximum viewport dimensions must be greater than or equal to the larger of the visible dimensions of the display being rendered to (if a display + * exists), and the largest renderbuffer image which can be successfully created and attached to a framebuffer object.

+ * + *

In the initial state, {@code w} and {@code h} for each viewport are set to the width and height, respectively, of the window into which the GL is to do + * its rendering. If the default framebuffer is bound but no default framebuffer is associated with the GL context, then {@code w} and {@code h} are + * initially set to zero.

+ * + * @param x the left viewport coordinate + * @param y the bottom viewport coordinate + * @param w the viewport width + * @param h the viewport height + * + * @see Reference Page + */ + public static void glViewport(@NativeType("GLint") int x, @NativeType("GLint") int y, @NativeType("GLsizei") int w, @NativeType("GLsizei") int h) { + GL11C.glViewport(x, y, w, h); + } + + /** + * Array version of: {@link #glAreTexturesResident AreTexturesResident} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + @NativeType("GLboolean") + public static boolean glAreTexturesResident(@NativeType("GLuint const *") int[] textures, @NativeType("GLboolean *") ByteBuffer residences) { + long __functionAddress = GL.getICD().glAreTexturesResident; + if (CHECKS) { + check(__functionAddress); + check(residences, textures.length); + } + return callPPZ(textures.length, textures, memAddress(residences), __functionAddress); + } + + /** + * Array version of: {@link #glClipPlane ClipPlane} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glClipPlane(@NativeType("GLenum") int plane, @NativeType("GLdouble const *") double[] equation) { + long __functionAddress = GL.getICD().glClipPlane; + if (CHECKS) { + check(__functionAddress); + check(equation, 4); + } + callPV(plane, equation, __functionAddress); + } + + /** + * Array version of: {@link #glColor3sv Color3sv} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glColor3sv(@NativeType("GLshort const *") short[] v) { + long __functionAddress = GL.getICD().glColor3sv; + if (CHECKS) { + check(__functionAddress); + check(v, 3); + } + callPV(v, __functionAddress); + } + + /** + * Array version of: {@link #glColor3iv Color3iv} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glColor3iv(@NativeType("GLint const *") int[] v) { + long __functionAddress = GL.getICD().glColor3iv; + if (CHECKS) { + check(__functionAddress); + check(v, 3); + } + callPV(v, __functionAddress); + } + + /** + * Array version of: {@link #glColor3fv Color3fv} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glColor3fv(@NativeType("GLfloat const *") float[] v) { + long __functionAddress = GL.getICD().glColor3fv; + if (CHECKS) { + check(__functionAddress); + check(v, 3); + } + callPV(v, __functionAddress); + } + + /** + * Array version of: {@link #glColor3dv Color3dv} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glColor3dv(@NativeType("GLdouble const *") double[] v) { + long __functionAddress = GL.getICD().glColor3dv; + if (CHECKS) { + check(__functionAddress); + check(v, 3); + } + callPV(v, __functionAddress); + } + + /** + * Array version of: {@link #glColor3usv Color3usv} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glColor3usv(@NativeType("GLushort const *") short[] v) { + long __functionAddress = GL.getICD().glColor3usv; + if (CHECKS) { + check(__functionAddress); + check(v, 3); + } + callPV(v, __functionAddress); + } + + /** + * Array version of: {@link #glColor3uiv Color3uiv} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glColor3uiv(@NativeType("GLuint const *") int[] v) { + long __functionAddress = GL.getICD().glColor3uiv; + if (CHECKS) { + check(__functionAddress); + check(v, 3); + } + callPV(v, __functionAddress); + } + + /** + * Array version of: {@link #glColor4sv Color4sv} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glColor4sv(@NativeType("GLshort const *") short[] v) { + long __functionAddress = GL.getICD().glColor4sv; + if (CHECKS) { + check(__functionAddress); + check(v, 4); + } + callPV(v, __functionAddress); + } + + /** + * Array version of: {@link #glColor4iv Color4iv} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glColor4iv(@NativeType("GLint const *") int[] v) { + long __functionAddress = GL.getICD().glColor4iv; + if (CHECKS) { + check(__functionAddress); + check(v, 4); + } + callPV(v, __functionAddress); + } + + /** + * Array version of: {@link #glColor4fv Color4fv} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glColor4fv(@NativeType("GLfloat const *") float[] v) { + long __functionAddress = GL.getICD().glColor4fv; + if (CHECKS) { + check(__functionAddress); + check(v, 4); + } + callPV(v, __functionAddress); + } + + /** + * Array version of: {@link #glColor4dv Color4dv} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glColor4dv(@NativeType("GLdouble const *") double[] v) { + long __functionAddress = GL.getICD().glColor4dv; + if (CHECKS) { + check(__functionAddress); + check(v, 4); + } + callPV(v, __functionAddress); + } + + /** + * Array version of: {@link #glColor4usv Color4usv} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glColor4usv(@NativeType("GLushort const *") short[] v) { + long __functionAddress = GL.getICD().glColor4usv; + if (CHECKS) { + check(__functionAddress); + check(v, 4); + } + callPV(v, __functionAddress); + } + + /** + * Array version of: {@link #glColor4uiv Color4uiv} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glColor4uiv(@NativeType("GLuint const *") int[] v) { + long __functionAddress = GL.getICD().glColor4uiv; + if (CHECKS) { + check(__functionAddress); + check(v, 4); + } + callPV(v, __functionAddress); + } + + /** + * Array version of: {@link #glDrawPixels DrawPixels} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glDrawPixels(@NativeType("GLsizei") int width, @NativeType("GLsizei") int height, @NativeType("GLenum") int format, @NativeType("GLenum") int type, @NativeType("void const *") short[] pixels) { + long __functionAddress = GL.getICD().glDrawPixels; + if (CHECKS) { + check(__functionAddress); + } + callPV(width, height, format, type, pixels, __functionAddress); + } + + /** + * Array version of: {@link #glDrawPixels DrawPixels} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glDrawPixels(@NativeType("GLsizei") int width, @NativeType("GLsizei") int height, @NativeType("GLenum") int format, @NativeType("GLenum") int type, @NativeType("void const *") int[] pixels) { + long __functionAddress = GL.getICD().glDrawPixels; + if (CHECKS) { + check(__functionAddress); + } + callPV(width, height, format, type, pixels, __functionAddress); + } + + /** + * Array version of: {@link #glDrawPixels DrawPixels} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glDrawPixels(@NativeType("GLsizei") int width, @NativeType("GLsizei") int height, @NativeType("GLenum") int format, @NativeType("GLenum") int type, @NativeType("void const *") float[] pixels) { + long __functionAddress = GL.getICD().glDrawPixels; + if (CHECKS) { + check(__functionAddress); + } + callPV(width, height, format, type, pixels, __functionAddress); + } + + /** + * Array version of: {@link #glEvalCoord1fv EvalCoord1fv} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glEvalCoord1fv(@NativeType("GLfloat const *") float[] u) { + long __functionAddress = GL.getICD().glEvalCoord1fv; + if (CHECKS) { + check(__functionAddress); + check(u, 1); + } + callPV(u, __functionAddress); + } + + /** + * Array version of: {@link #glEvalCoord1dv EvalCoord1dv} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glEvalCoord1dv(@NativeType("GLdouble const *") double[] u) { + long __functionAddress = GL.getICD().glEvalCoord1dv; + if (CHECKS) { + check(__functionAddress); + check(u, 1); + } + callPV(u, __functionAddress); + } + + /** + * Array version of: {@link #glEvalCoord2fv EvalCoord2fv} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glEvalCoord2fv(@NativeType("GLfloat const *") float[] u) { + long __functionAddress = GL.getICD().glEvalCoord2fv; + if (CHECKS) { + check(__functionAddress); + check(u, 2); + } + callPV(u, __functionAddress); + } + + /** + * Array version of: {@link #glEvalCoord2dv EvalCoord2dv} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glEvalCoord2dv(@NativeType("GLdouble const *") double[] u) { + long __functionAddress = GL.getICD().glEvalCoord2dv; + if (CHECKS) { + check(__functionAddress); + check(u, 2); + } + callPV(u, __functionAddress); + } + + /** + * Array version of: {@link #glFeedbackBuffer FeedbackBuffer} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glFeedbackBuffer(@NativeType("GLenum") int type, @NativeType("GLfloat *") float[] buffer) { + long __functionAddress = GL.getICD().glFeedbackBuffer; + if (CHECKS) { + check(__functionAddress); + } + callPV(buffer.length, type, buffer, __functionAddress); + } + + /** + * Array version of: {@link #glFogiv Fogiv} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glFogiv(@NativeType("GLenum") int pname, @NativeType("GLint const *") int[] params) { + long __functionAddress = GL.getICD().glFogiv; + if (CHECKS) { + check(__functionAddress); + check(params, 1); + } + callPV(pname, params, __functionAddress); + } + + /** + * Array version of: {@link #glFogfv Fogfv} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glFogfv(@NativeType("GLenum") int pname, @NativeType("GLfloat const *") float[] params) { + long __functionAddress = GL.getICD().glFogfv; + if (CHECKS) { + check(__functionAddress); + check(params, 1); + } + callPV(pname, params, __functionAddress); + } + + /** + * Array version of: {@link #glGenTextures GenTextures} + * + * @see Reference Page + */ + public static void glGenTextures(@NativeType("GLuint *") int[] textures) { + GL11C.glGenTextures(textures); + } + + /** + * Array version of: {@link #glDeleteTextures DeleteTextures} + * + * @see Reference Page + */ + public static void glDeleteTextures(@NativeType("GLuint const *") int[] textures) { + GL11C.glDeleteTextures(textures); + } + + /** + * Array version of: {@link #glGetClipPlane GetClipPlane} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glGetClipPlane(@NativeType("GLenum") int plane, @NativeType("GLdouble *") double[] equation) { + long __functionAddress = GL.getICD().glGetClipPlane; + if (CHECKS) { + check(__functionAddress); + check(equation, 4); + } + callPV(plane, equation, __functionAddress); + } + + /** + * Array version of: {@link #glGetFloatv GetFloatv} + * + * @see Reference Page + */ + public static void glGetFloatv(@NativeType("GLenum") int pname, @NativeType("GLfloat *") float[] params) { + GL11C.glGetFloatv(pname, params); + } + + /** + * Array version of: {@link #glGetIntegerv GetIntegerv} + * + * @see Reference Page + */ + public static void glGetIntegerv(@NativeType("GLenum") int pname, @NativeType("GLint *") int[] params) { + GL11C.glGetIntegerv(pname, params); + } + + /** + * Array version of: {@link #glGetDoublev GetDoublev} + * + * @see Reference Page + */ + public static void glGetDoublev(@NativeType("GLenum") int pname, @NativeType("GLdouble *") double[] params) { + GL11C.glGetDoublev(pname, params); + } + + /** + * Array version of: {@link #glGetLightiv GetLightiv} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glGetLightiv(@NativeType("GLenum") int light, @NativeType("GLenum") int pname, @NativeType("GLint *") int[] data) { + long __functionAddress = GL.getICD().glGetLightiv; + if (CHECKS) { + check(__functionAddress); + check(data, 4); + } + callPV(light, pname, data, __functionAddress); + } + + /** + * Array version of: {@link #glGetLightfv GetLightfv} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glGetLightfv(@NativeType("GLenum") int light, @NativeType("GLenum") int pname, @NativeType("GLfloat *") float[] data) { + long __functionAddress = GL.getICD().glGetLightfv; + if (CHECKS) { + check(__functionAddress); + check(data, 4); + } + callPV(light, pname, data, __functionAddress); + } + + /** + * Array version of: {@link #glGetMapiv GetMapiv} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glGetMapiv(@NativeType("GLenum") int target, @NativeType("GLenum") int query, @NativeType("GLint *") int[] data) { + long __functionAddress = GL.getICD().glGetMapiv; + if (CHECKS) { + check(__functionAddress); + check(data, 4); + } + callPV(target, query, data, __functionAddress); + } + + /** + * Array version of: {@link #glGetMapfv GetMapfv} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glGetMapfv(@NativeType("GLenum") int target, @NativeType("GLenum") int query, @NativeType("GLfloat *") float[] data) { + long __functionAddress = GL.getICD().glGetMapfv; + if (CHECKS) { + check(__functionAddress); + check(data, 4); + } + callPV(target, query, data, __functionAddress); + } + + /** + * Array version of: {@link #glGetMapdv GetMapdv} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glGetMapdv(@NativeType("GLenum") int target, @NativeType("GLenum") int query, @NativeType("GLdouble *") double[] data) { + long __functionAddress = GL.getICD().glGetMapdv; + if (CHECKS) { + check(__functionAddress); + check(data, 4); + } + callPV(target, query, data, __functionAddress); + } + + /** + * Array version of: {@link #glGetMaterialiv GetMaterialiv} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glGetMaterialiv(@NativeType("GLenum") int face, @NativeType("GLenum") int pname, @NativeType("GLint *") int[] data) { + long __functionAddress = GL.getICD().glGetMaterialiv; + if (CHECKS) { + check(__functionAddress); + check(data, 1); + } + callPV(face, pname, data, __functionAddress); + } + + /** + * Array version of: {@link #glGetMaterialfv GetMaterialfv} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glGetMaterialfv(@NativeType("GLenum") int face, @NativeType("GLenum") int pname, @NativeType("GLfloat *") float[] data) { + long __functionAddress = GL.getICD().glGetMaterialfv; + if (CHECKS) { + check(__functionAddress); + check(data, 1); + } + callPV(face, pname, data, __functionAddress); + } + + /** + * Array version of: {@link #glGetPixelMapfv GetPixelMapfv} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glGetPixelMapfv(@NativeType("GLenum") int map, @NativeType("GLfloat *") float[] data) { + long __functionAddress = GL.getICD().glGetPixelMapfv; + if (CHECKS) { + check(__functionAddress); + check(data, 32); + } + callPV(map, data, __functionAddress); + } + + /** + * Array version of: {@link #glGetPixelMapusv GetPixelMapusv} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glGetPixelMapusv(@NativeType("GLenum") int map, @NativeType("GLushort *") short[] data) { + long __functionAddress = GL.getICD().glGetPixelMapusv; + if (CHECKS) { + check(__functionAddress); + check(data, 32); + } + callPV(map, data, __functionAddress); + } + + /** + * Array version of: {@link #glGetPixelMapuiv GetPixelMapuiv} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glGetPixelMapuiv(@NativeType("GLenum") int map, @NativeType("GLuint *") int[] data) { + long __functionAddress = GL.getICD().glGetPixelMapuiv; + if (CHECKS) { + check(__functionAddress); + check(data, 32); + } + callPV(map, data, __functionAddress); + } + + /** + * Array version of: {@link #glGetTexEnviv GetTexEnviv} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glGetTexEnviv(@NativeType("GLenum") int env, @NativeType("GLenum") int pname, @NativeType("GLint *") int[] data) { + long __functionAddress = GL.getICD().glGetTexEnviv; + if (CHECKS) { + check(__functionAddress); + check(data, 1); + } + callPV(env, pname, data, __functionAddress); + } + + /** + * Array version of: {@link #glGetTexEnvfv GetTexEnvfv} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glGetTexEnvfv(@NativeType("GLenum") int env, @NativeType("GLenum") int pname, @NativeType("GLfloat *") float[] data) { + long __functionAddress = GL.getICD().glGetTexEnvfv; + if (CHECKS) { + check(__functionAddress); + check(data, 1); + } + callPV(env, pname, data, __functionAddress); + } + + /** + * Array version of: {@link #glGetTexGeniv GetTexGeniv} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glGetTexGeniv(@NativeType("GLenum") int coord, @NativeType("GLenum") int pname, @NativeType("GLint *") int[] data) { + long __functionAddress = GL.getICD().glGetTexGeniv; + if (CHECKS) { + check(__functionAddress); + check(data, 1); + } + callPV(coord, pname, data, __functionAddress); + } + + /** + * Array version of: {@link #glGetTexGenfv GetTexGenfv} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glGetTexGenfv(@NativeType("GLenum") int coord, @NativeType("GLenum") int pname, @NativeType("GLfloat *") float[] data) { + long __functionAddress = GL.getICD().glGetTexGenfv; + if (CHECKS) { + check(__functionAddress); + check(data, 4); + } + callPV(coord, pname, data, __functionAddress); + } + + /** + * Array version of: {@link #glGetTexGendv GetTexGendv} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glGetTexGendv(@NativeType("GLenum") int coord, @NativeType("GLenum") int pname, @NativeType("GLdouble *") double[] data) { + long __functionAddress = GL.getICD().glGetTexGendv; + if (CHECKS) { + check(__functionAddress); + check(data, 4); + } + callPV(coord, pname, data, __functionAddress); + } + + /** + * Array version of: {@link #glGetTexImage GetTexImage} + * + * @see Reference Page + */ + public static void glGetTexImage(@NativeType("GLenum") int tex, @NativeType("GLint") int level, @NativeType("GLenum") int format, @NativeType("GLenum") int type, @NativeType("void *") short[] pixels) { + GL11C.glGetTexImage(tex, level, format, type, pixels); + } + + /** + * Array version of: {@link #glGetTexImage GetTexImage} + * + * @see Reference Page + */ + public static void glGetTexImage(@NativeType("GLenum") int tex, @NativeType("GLint") int level, @NativeType("GLenum") int format, @NativeType("GLenum") int type, @NativeType("void *") int[] pixels) { + GL11C.glGetTexImage(tex, level, format, type, pixels); + } + + /** + * Array version of: {@link #glGetTexImage GetTexImage} + * + * @see Reference Page + */ + public static void glGetTexImage(@NativeType("GLenum") int tex, @NativeType("GLint") int level, @NativeType("GLenum") int format, @NativeType("GLenum") int type, @NativeType("void *") float[] pixels) { + GL11C.glGetTexImage(tex, level, format, type, pixels); + } + + /** + * Array version of: {@link #glGetTexImage GetTexImage} + * + * @see Reference Page + */ + public static void glGetTexImage(@NativeType("GLenum") int tex, @NativeType("GLint") int level, @NativeType("GLenum") int format, @NativeType("GLenum") int type, @NativeType("void *") double[] pixels) { + GL11C.glGetTexImage(tex, level, format, type, pixels); + } + + /** + * Array version of: {@link #glGetTexLevelParameteriv GetTexLevelParameteriv} + * + * @see Reference Page + */ + public static void glGetTexLevelParameteriv(@NativeType("GLenum") int target, @NativeType("GLint") int level, @NativeType("GLenum") int pname, @NativeType("GLint *") int[] params) { + GL11C.glGetTexLevelParameteriv(target, level, pname, params); + } + + /** + * Array version of: {@link #glGetTexLevelParameterfv GetTexLevelParameterfv} + * + * @see Reference Page + */ + public static void glGetTexLevelParameterfv(@NativeType("GLenum") int target, @NativeType("GLint") int level, @NativeType("GLenum") int pname, @NativeType("GLfloat *") float[] params) { + GL11C.glGetTexLevelParameterfv(target, level, pname, params); + } + + /** + * Array version of: {@link #glGetTexParameteriv GetTexParameteriv} + * + * @see Reference Page + */ + public static void glGetTexParameteriv(@NativeType("GLenum") int target, @NativeType("GLenum") int pname, @NativeType("GLint *") int[] params) { + GL11C.glGetTexParameteriv(target, pname, params); + } + + /** + * Array version of: {@link #glGetTexParameterfv GetTexParameterfv} + * + * @see Reference Page + */ + public static void glGetTexParameterfv(@NativeType("GLenum") int target, @NativeType("GLenum") int pname, @NativeType("GLfloat *") float[] params) { + GL11C.glGetTexParameterfv(target, pname, params); + } + + /** + * Array version of: {@link #glIndexiv Indexiv} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glIndexiv(@NativeType("GLint const *") int[] index) { + long __functionAddress = GL.getICD().glIndexiv; + if (CHECKS) { + check(__functionAddress); + check(index, 1); + } + callPV(index, __functionAddress); + } + + /** + * Array version of: {@link #glIndexsv Indexsv} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glIndexsv(@NativeType("GLshort const *") short[] index) { + long __functionAddress = GL.getICD().glIndexsv; + if (CHECKS) { + check(__functionAddress); + check(index, 1); + } + callPV(index, __functionAddress); + } + + /** + * Array version of: {@link #glIndexfv Indexfv} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glIndexfv(@NativeType("GLfloat const *") float[] index) { + long __functionAddress = GL.getICD().glIndexfv; + if (CHECKS) { + check(__functionAddress); + check(index, 1); + } + callPV(index, __functionAddress); + } + + /** + * Array version of: {@link #glIndexdv Indexdv} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glIndexdv(@NativeType("GLdouble const *") double[] index) { + long __functionAddress = GL.getICD().glIndexdv; + if (CHECKS) { + check(__functionAddress); + check(index, 1); + } + callPV(index, __functionAddress); + } + + /** + * Array version of: {@link #glInterleavedArrays InterleavedArrays} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glInterleavedArrays(@NativeType("GLenum") int format, @NativeType("GLsizei") int stride, @NativeType("void const *") short[] pointer) { + long __functionAddress = GL.getICD().glInterleavedArrays; + if (CHECKS) { + check(__functionAddress); + } + callPV(format, stride, pointer, __functionAddress); + } + + /** + * Array version of: {@link #glInterleavedArrays InterleavedArrays} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glInterleavedArrays(@NativeType("GLenum") int format, @NativeType("GLsizei") int stride, @NativeType("void const *") int[] pointer) { + long __functionAddress = GL.getICD().glInterleavedArrays; + if (CHECKS) { + check(__functionAddress); + } + callPV(format, stride, pointer, __functionAddress); + } + + /** + * Array version of: {@link #glInterleavedArrays InterleavedArrays} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glInterleavedArrays(@NativeType("GLenum") int format, @NativeType("GLsizei") int stride, @NativeType("void const *") float[] pointer) { + long __functionAddress = GL.getICD().glInterleavedArrays; + if (CHECKS) { + check(__functionAddress); + } + callPV(format, stride, pointer, __functionAddress); + } + + /** + * Array version of: {@link #glInterleavedArrays InterleavedArrays} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glInterleavedArrays(@NativeType("GLenum") int format, @NativeType("GLsizei") int stride, @NativeType("void const *") double[] pointer) { + long __functionAddress = GL.getICD().glInterleavedArrays; + if (CHECKS) { + check(__functionAddress); + } + callPV(format, stride, pointer, __functionAddress); + } + + /** + * Array version of: {@link #glLightModeliv LightModeliv} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glLightModeliv(@NativeType("GLenum") int pname, @NativeType("GLint const *") int[] params) { + long __functionAddress = GL.getICD().glLightModeliv; + if (CHECKS) { + check(__functionAddress); + check(params, 4); + } + callPV(pname, params, __functionAddress); + } + + /** + * Array version of: {@link #glLightModelfv LightModelfv} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glLightModelfv(@NativeType("GLenum") int pname, @NativeType("GLfloat const *") float[] params) { + long __functionAddress = GL.getICD().glLightModelfv; + if (CHECKS) { + check(__functionAddress); + check(params, 4); + } + callPV(pname, params, __functionAddress); + } + + /** + * Array version of: {@link #glLightiv Lightiv} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glLightiv(@NativeType("GLenum") int light, @NativeType("GLenum") int pname, @NativeType("GLint const *") int[] params) { + long __functionAddress = GL.getICD().glLightiv; + if (CHECKS) { + check(__functionAddress); + check(params, 4); + } + callPV(light, pname, params, __functionAddress); + } + + /** + * Array version of: {@link #glLightfv Lightfv} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glLightfv(@NativeType("GLenum") int light, @NativeType("GLenum") int pname, @NativeType("GLfloat const *") float[] params) { + long __functionAddress = GL.getICD().glLightfv; + if (CHECKS) { + check(__functionAddress); + check(params, 4); + } + callPV(light, pname, params, __functionAddress); + } + + /** + * Array version of: {@link #glLoadMatrixf LoadMatrixf} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glLoadMatrixf(@NativeType("GLfloat const *") float[] m) { + long __functionAddress = GL.getICD().glLoadMatrixf; + if (CHECKS) { + check(__functionAddress); + check(m, 16); + } + callPV(m, __functionAddress); + } + + /** + * Array version of: {@link #glLoadMatrixd LoadMatrixd} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glLoadMatrixd(@NativeType("GLdouble const *") double[] m) { + long __functionAddress = GL.getICD().glLoadMatrixd; + if (CHECKS) { + check(__functionAddress); + check(m, 16); + } + callPV(m, __functionAddress); + } + + /** + * Array version of: {@link #glMap1f Map1f} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glMap1f(@NativeType("GLenum") int target, @NativeType("GLfloat") float u1, @NativeType("GLfloat") float u2, @NativeType("GLint") int stride, @NativeType("GLint") int order, @NativeType("GLfloat const *") float[] points) { + long __functionAddress = GL.getICD().glMap1f; + if (CHECKS) { + check(__functionAddress); + check(points, order * stride); + } + callPV(target, u1, u2, stride, order, points, __functionAddress); + } + + /** + * Array version of: {@link #glMap1d Map1d} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glMap1d(@NativeType("GLenum") int target, @NativeType("GLdouble") double u1, @NativeType("GLdouble") double u2, @NativeType("GLint") int stride, @NativeType("GLint") int order, @NativeType("GLdouble const *") double[] points) { + long __functionAddress = GL.getICD().glMap1d; + if (CHECKS) { + check(__functionAddress); + check(points, stride * order); + } + callPV(target, u1, u2, stride, order, points, __functionAddress); + } + + /** + * Array version of: {@link #glMap2f Map2f} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glMap2f(@NativeType("GLenum") int target, @NativeType("GLfloat") float u1, @NativeType("GLfloat") float u2, @NativeType("GLint") int ustride, @NativeType("GLint") int uorder, @NativeType("GLfloat") float v1, @NativeType("GLfloat") float v2, @NativeType("GLint") int vstride, @NativeType("GLint") int vorder, @NativeType("GLfloat const *") float[] points) { + long __functionAddress = GL.getICD().glMap2f; + if (CHECKS) { + check(__functionAddress); + check(points, ustride * uorder * vstride * vorder); + } + callPV(target, u1, u2, ustride, uorder, v1, v2, vstride, vorder, points, __functionAddress); + } + + /** + * Array version of: {@link #glMap2d Map2d} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glMap2d(@NativeType("GLenum") int target, @NativeType("GLdouble") double u1, @NativeType("GLdouble") double u2, @NativeType("GLint") int ustride, @NativeType("GLint") int uorder, @NativeType("GLdouble") double v1, @NativeType("GLdouble") double v2, @NativeType("GLint") int vstride, @NativeType("GLint") int vorder, @NativeType("GLdouble const *") double[] points) { + long __functionAddress = GL.getICD().glMap2d; + if (CHECKS) { + check(__functionAddress); + check(points, ustride * uorder * vstride * vorder); + } + callPV(target, u1, u2, ustride, uorder, v1, v2, vstride, vorder, points, __functionAddress); + } + + /** + * Array version of: {@link #glMaterialiv Materialiv} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glMaterialiv(@NativeType("GLenum") int face, @NativeType("GLenum") int pname, @NativeType("GLint const *") int[] params) { + long __functionAddress = GL.getICD().glMaterialiv; + if (CHECKS) { + check(__functionAddress); + check(params, 4); + } + callPV(face, pname, params, __functionAddress); + } + + /** + * Array version of: {@link #glMaterialfv Materialfv} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glMaterialfv(@NativeType("GLenum") int face, @NativeType("GLenum") int pname, @NativeType("GLfloat const *") float[] params) { + long __functionAddress = GL.getICD().glMaterialfv; + if (CHECKS) { + check(__functionAddress); + check(params, 4); + } + callPV(face, pname, params, __functionAddress); + } + + /** + * Array version of: {@link #glMultMatrixf MultMatrixf} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glMultMatrixf(@NativeType("GLfloat const *") float[] m) { + long __functionAddress = GL.getICD().glMultMatrixf; + if (CHECKS) { + check(__functionAddress); + check(m, 16); + } + callPV(m, __functionAddress); + } + + /** + * Array version of: {@link #glMultMatrixd MultMatrixd} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glMultMatrixd(@NativeType("GLdouble const *") double[] m) { + long __functionAddress = GL.getICD().glMultMatrixd; + if (CHECKS) { + check(__functionAddress); + check(m, 16); + } + callPV(m, __functionAddress); + } + + /** + * Array version of: {@link #glNormal3fv Normal3fv} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glNormal3fv(@NativeType("GLfloat const *") float[] v) { + long __functionAddress = GL.getICD().glNormal3fv; + if (CHECKS) { + check(__functionAddress); + check(v, 3); + } + callPV(v, __functionAddress); + } + + /** + * Array version of: {@link #glNormal3sv Normal3sv} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glNormal3sv(@NativeType("GLshort const *") short[] v) { + long __functionAddress = GL.getICD().glNormal3sv; + if (CHECKS) { + check(__functionAddress); + check(v, 3); + } + callPV(v, __functionAddress); + } + + /** + * Array version of: {@link #glNormal3iv Normal3iv} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glNormal3iv(@NativeType("GLint const *") int[] v) { + long __functionAddress = GL.getICD().glNormal3iv; + if (CHECKS) { + check(__functionAddress); + check(v, 3); + } + callPV(v, __functionAddress); + } + + /** + * Array version of: {@link #glNormal3dv Normal3dv} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glNormal3dv(@NativeType("GLdouble const *") double[] v) { + long __functionAddress = GL.getICD().glNormal3dv; + if (CHECKS) { + check(__functionAddress); + check(v, 3); + } + callPV(v, __functionAddress); + } + + /** + * Array version of: {@link #glPixelMapfv PixelMapfv} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glPixelMapfv(@NativeType("GLenum") int map, @NativeType("GLfloat const *") float[] values) { + long __functionAddress = GL.getICD().glPixelMapfv; + if (CHECKS) { + check(__functionAddress); + } + callPV(map, values.length, values, __functionAddress); + } + + /** + * Array version of: {@link #glPixelMapusv PixelMapusv} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glPixelMapusv(@NativeType("GLenum") int map, @NativeType("GLushort const *") short[] values) { + long __functionAddress = GL.getICD().glPixelMapusv; + if (CHECKS) { + check(__functionAddress); + } + callPV(map, values.length, values, __functionAddress); + } + + /** + * Array version of: {@link #glPixelMapuiv PixelMapuiv} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glPixelMapuiv(@NativeType("GLenum") int map, @NativeType("GLuint const *") int[] values) { + long __functionAddress = GL.getICD().glPixelMapuiv; + if (CHECKS) { + check(__functionAddress); + } + callPV(map, values.length, values, __functionAddress); + } + + /** + * Array version of: {@link #glPrioritizeTextures PrioritizeTextures} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glPrioritizeTextures(@NativeType("GLuint const *") int[] textures, @NativeType("GLfloat const *") float[] priorities) { + long __functionAddress = GL.getICD().glPrioritizeTextures; + if (CHECKS) { + check(__functionAddress); + check(priorities, textures.length); + } + callPPV(textures.length, textures, priorities, __functionAddress); + } + + /** + * Array version of: {@link #glRasterPos2iv RasterPos2iv} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glRasterPos2iv(@NativeType("GLint const *") int[] coords) { + long __functionAddress = GL.getICD().glRasterPos2iv; + if (CHECKS) { + check(__functionAddress); + check(coords, 2); + } + callPV(coords, __functionAddress); + } + + /** + * Array version of: {@link #glRasterPos2sv RasterPos2sv} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glRasterPos2sv(@NativeType("GLshort const *") short[] coords) { + long __functionAddress = GL.getICD().glRasterPos2sv; + if (CHECKS) { + check(__functionAddress); + check(coords, 2); + } + callPV(coords, __functionAddress); + } + + /** + * Array version of: {@link #glRasterPos2fv RasterPos2fv} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glRasterPos2fv(@NativeType("GLfloat const *") float[] coords) { + long __functionAddress = GL.getICD().glRasterPos2fv; + if (CHECKS) { + check(__functionAddress); + check(coords, 2); + } + callPV(coords, __functionAddress); + } + + /** + * Array version of: {@link #glRasterPos2dv RasterPos2dv} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glRasterPos2dv(@NativeType("GLdouble const *") double[] coords) { + long __functionAddress = GL.getICD().glRasterPos2dv; + if (CHECKS) { + check(__functionAddress); + check(coords, 2); + } + callPV(coords, __functionAddress); + } + + /** + * Array version of: {@link #glRasterPos3iv RasterPos3iv} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glRasterPos3iv(@NativeType("GLint const *") int[] coords) { + long __functionAddress = GL.getICD().glRasterPos3iv; + if (CHECKS) { + check(__functionAddress); + check(coords, 3); + } + callPV(coords, __functionAddress); + } + + /** + * Array version of: {@link #glRasterPos3sv RasterPos3sv} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glRasterPos3sv(@NativeType("GLshort const *") short[] coords) { + long __functionAddress = GL.getICD().glRasterPos3sv; + if (CHECKS) { + check(__functionAddress); + check(coords, 3); + } + callPV(coords, __functionAddress); + } + + /** + * Array version of: {@link #glRasterPos3fv RasterPos3fv} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glRasterPos3fv(@NativeType("GLfloat const *") float[] coords) { + long __functionAddress = GL.getICD().glRasterPos3fv; + if (CHECKS) { + check(__functionAddress); + check(coords, 3); + } + callPV(coords, __functionAddress); + } + + /** + * Array version of: {@link #glRasterPos3dv RasterPos3dv} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glRasterPos3dv(@NativeType("GLdouble const *") double[] coords) { + long __functionAddress = GL.getICD().glRasterPos3dv; + if (CHECKS) { + check(__functionAddress); + check(coords, 3); + } + callPV(coords, __functionAddress); + } + + /** + * Array version of: {@link #glRasterPos4iv RasterPos4iv} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glRasterPos4iv(@NativeType("GLint const *") int[] coords) { + long __functionAddress = GL.getICD().glRasterPos4iv; + if (CHECKS) { + check(__functionAddress); + check(coords, 4); + } + callPV(coords, __functionAddress); + } + + /** + * Array version of: {@link #glRasterPos4sv RasterPos4sv} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glRasterPos4sv(@NativeType("GLshort const *") short[] coords) { + long __functionAddress = GL.getICD().glRasterPos4sv; + if (CHECKS) { + check(__functionAddress); + check(coords, 4); + } + callPV(coords, __functionAddress); + } + + /** + * Array version of: {@link #glRasterPos4fv RasterPos4fv} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glRasterPos4fv(@NativeType("GLfloat const *") float[] coords) { + long __functionAddress = GL.getICD().glRasterPos4fv; + if (CHECKS) { + check(__functionAddress); + check(coords, 4); + } + callPV(coords, __functionAddress); + } + + /** + * Array version of: {@link #glRasterPos4dv RasterPos4dv} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glRasterPos4dv(@NativeType("GLdouble const *") double[] coords) { + long __functionAddress = GL.getICD().glRasterPos4dv; + if (CHECKS) { + check(__functionAddress); + check(coords, 4); + } + callPV(coords, __functionAddress); + } + + /** + * Array version of: {@link #glReadPixels ReadPixels} + * + * @see Reference Page + */ + public static void glReadPixels(@NativeType("GLint") int x, @NativeType("GLint") int y, @NativeType("GLsizei") int width, @NativeType("GLsizei") int height, @NativeType("GLenum") int format, @NativeType("GLenum") int type, @NativeType("void *") short[] pixels) { + GL11C.glReadPixels(x, y, width, height, format, type, pixels); + } + + /** + * Array version of: {@link #glReadPixels ReadPixels} + * + * @see Reference Page + */ + public static void glReadPixels(@NativeType("GLint") int x, @NativeType("GLint") int y, @NativeType("GLsizei") int width, @NativeType("GLsizei") int height, @NativeType("GLenum") int format, @NativeType("GLenum") int type, @NativeType("void *") int[] pixels) { + GL11C.glReadPixels(x, y, width, height, format, type, pixels); + } + + /** + * Array version of: {@link #glReadPixels ReadPixels} + * + * @see Reference Page + */ + public static void glReadPixels(@NativeType("GLint") int x, @NativeType("GLint") int y, @NativeType("GLsizei") int width, @NativeType("GLsizei") int height, @NativeType("GLenum") int format, @NativeType("GLenum") int type, @NativeType("void *") float[] pixels) { + GL11C.glReadPixels(x, y, width, height, format, type, pixels); + } + + /** + * Array version of: {@link #glRectiv Rectiv} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glRectiv(@NativeType("GLint const *") int[] v1, @NativeType("GLint const *") int[] v2) { + long __functionAddress = GL.getICD().glRectiv; + if (CHECKS) { + check(__functionAddress); + check(v1, 2); + check(v2, 2); + } + callPPV(v1, v2, __functionAddress); + } + + /** + * Array version of: {@link #glRectsv Rectsv} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glRectsv(@NativeType("GLshort const *") short[] v1, @NativeType("GLshort const *") short[] v2) { + long __functionAddress = GL.getICD().glRectsv; + if (CHECKS) { + check(__functionAddress); + check(v1, 2); + check(v2, 2); + } + callPPV(v1, v2, __functionAddress); + } + + /** + * Array version of: {@link #glRectfv Rectfv} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glRectfv(@NativeType("GLfloat const *") float[] v1, @NativeType("GLfloat const *") float[] v2) { + long __functionAddress = GL.getICD().glRectfv; + if (CHECKS) { + check(__functionAddress); + check(v1, 2); + check(v2, 2); + } + callPPV(v1, v2, __functionAddress); + } + + /** + * Array version of: {@link #glRectdv Rectdv} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glRectdv(@NativeType("GLdouble const *") double[] v1, @NativeType("GLdouble const *") double[] v2) { + long __functionAddress = GL.getICD().glRectdv; + if (CHECKS) { + check(__functionAddress); + check(v1, 2); + check(v2, 2); + } + callPPV(v1, v2, __functionAddress); + } + + /** + * Array version of: {@link #glSelectBuffer SelectBuffer} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glSelectBuffer(@NativeType("GLuint *") int[] buffer) { + long __functionAddress = GL.getICD().glSelectBuffer; + if (CHECKS) { + check(__functionAddress); + } + callPV(buffer.length, buffer, __functionAddress); + } + + /** + * Array version of: {@link #glTexCoord1fv TexCoord1fv} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glTexCoord1fv(@NativeType("GLfloat const *") float[] v) { + long __functionAddress = GL.getICD().glTexCoord1fv; + if (CHECKS) { + check(__functionAddress); + check(v, 1); + } + callPV(v, __functionAddress); + } + + /** + * Array version of: {@link #glTexCoord1sv TexCoord1sv} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glTexCoord1sv(@NativeType("GLshort const *") short[] v) { + long __functionAddress = GL.getICD().glTexCoord1sv; + if (CHECKS) { + check(__functionAddress); + check(v, 1); + } + callPV(v, __functionAddress); + } + + /** + * Array version of: {@link #glTexCoord1iv TexCoord1iv} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glTexCoord1iv(@NativeType("GLint const *") int[] v) { + long __functionAddress = GL.getICD().glTexCoord1iv; + if (CHECKS) { + check(__functionAddress); + check(v, 1); + } + callPV(v, __functionAddress); + } + + /** + * Array version of: {@link #glTexCoord1dv TexCoord1dv} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glTexCoord1dv(@NativeType("GLdouble const *") double[] v) { + long __functionAddress = GL.getICD().glTexCoord1dv; + if (CHECKS) { + check(__functionAddress); + check(v, 1); + } + callPV(v, __functionAddress); + } + + /** + * Array version of: {@link #glTexCoord2fv TexCoord2fv} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glTexCoord2fv(@NativeType("GLfloat const *") float[] v) { + long __functionAddress = GL.getICD().glTexCoord2fv; + if (CHECKS) { + check(__functionAddress); + check(v, 2); + } + callPV(v, __functionAddress); + } + + /** + * Array version of: {@link #glTexCoord2sv TexCoord2sv} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glTexCoord2sv(@NativeType("GLshort const *") short[] v) { + long __functionAddress = GL.getICD().glTexCoord2sv; + if (CHECKS) { + check(__functionAddress); + check(v, 2); + } + callPV(v, __functionAddress); + } + + /** + * Array version of: {@link #glTexCoord2iv TexCoord2iv} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glTexCoord2iv(@NativeType("GLint const *") int[] v) { + long __functionAddress = GL.getICD().glTexCoord2iv; + if (CHECKS) { + check(__functionAddress); + check(v, 2); + } + callPV(v, __functionAddress); + } + + /** + * Array version of: {@link #glTexCoord2dv TexCoord2dv} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glTexCoord2dv(@NativeType("GLdouble const *") double[] v) { + long __functionAddress = GL.getICD().glTexCoord2dv; + if (CHECKS) { + check(__functionAddress); + check(v, 2); + } + callPV(v, __functionAddress); + } + + /** + * Array version of: {@link #glTexCoord3fv TexCoord3fv} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glTexCoord3fv(@NativeType("GLfloat const *") float[] v) { + long __functionAddress = GL.getICD().glTexCoord3fv; + if (CHECKS) { + check(__functionAddress); + check(v, 3); + } + callPV(v, __functionAddress); + } + + /** + * Array version of: {@link #glTexCoord3sv TexCoord3sv} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glTexCoord3sv(@NativeType("GLshort const *") short[] v) { + long __functionAddress = GL.getICD().glTexCoord3sv; + if (CHECKS) { + check(__functionAddress); + check(v, 3); + } + callPV(v, __functionAddress); + } + + /** + * Array version of: {@link #glTexCoord3iv TexCoord3iv} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glTexCoord3iv(@NativeType("GLint const *") int[] v) { + long __functionAddress = GL.getICD().glTexCoord3iv; + if (CHECKS) { + check(__functionAddress); + check(v, 3); + } + callPV(v, __functionAddress); + } + + /** + * Array version of: {@link #glTexCoord3dv TexCoord3dv} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glTexCoord3dv(@NativeType("GLdouble const *") double[] v) { + long __functionAddress = GL.getICD().glTexCoord3dv; + if (CHECKS) { + check(__functionAddress); + check(v, 3); + } + callPV(v, __functionAddress); + } + + /** + * Array version of: {@link #glTexCoord4fv TexCoord4fv} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glTexCoord4fv(@NativeType("GLfloat const *") float[] v) { + long __functionAddress = GL.getICD().glTexCoord4fv; + if (CHECKS) { + check(__functionAddress); + check(v, 4); + } + callPV(v, __functionAddress); + } + + /** + * Array version of: {@link #glTexCoord4sv TexCoord4sv} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glTexCoord4sv(@NativeType("GLshort const *") short[] v) { + long __functionAddress = GL.getICD().glTexCoord4sv; + if (CHECKS) { + check(__functionAddress); + check(v, 4); + } + callPV(v, __functionAddress); + } + + /** + * Array version of: {@link #glTexCoord4iv TexCoord4iv} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glTexCoord4iv(@NativeType("GLint const *") int[] v) { + long __functionAddress = GL.getICD().glTexCoord4iv; + if (CHECKS) { + check(__functionAddress); + check(v, 4); + } + callPV(v, __functionAddress); + } + + /** + * Array version of: {@link #glTexCoord4dv TexCoord4dv} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glTexCoord4dv(@NativeType("GLdouble const *") double[] v) { + long __functionAddress = GL.getICD().glTexCoord4dv; + if (CHECKS) { + check(__functionAddress); + check(v, 4); + } + callPV(v, __functionAddress); + } + + /** + * Array version of: {@link #glTexEnviv TexEnviv} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glTexEnviv(@NativeType("GLenum") int target, @NativeType("GLenum") int pname, @NativeType("GLint const *") int[] params) { + long __functionAddress = GL.getICD().glTexEnviv; + if (CHECKS) { + check(__functionAddress); + check(params, 4); + } + callPV(target, pname, params, __functionAddress); + } + + /** + * Array version of: {@link #glTexEnvfv TexEnvfv} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glTexEnvfv(@NativeType("GLenum") int target, @NativeType("GLenum") int pname, @NativeType("GLfloat const *") float[] params) { + long __functionAddress = GL.getICD().glTexEnvfv; + if (CHECKS) { + check(__functionAddress); + check(params, 4); + } + callPV(target, pname, params, __functionAddress); + } + + /** + * Array version of: {@link #glTexGeniv TexGeniv} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glTexGeniv(@NativeType("GLenum") int coord, @NativeType("GLenum") int pname, @NativeType("GLint const *") int[] params) { + long __functionAddress = GL.getICD().glTexGeniv; + if (CHECKS) { + check(__functionAddress); + check(params, 4); + } + callPV(coord, pname, params, __functionAddress); + } + + /** + * Array version of: {@link #glTexGenfv TexGenfv} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glTexGenfv(@NativeType("GLenum") int coord, @NativeType("GLenum") int pname, @NativeType("GLfloat const *") float[] params) { + long __functionAddress = GL.getICD().glTexGenfv; + if (CHECKS) { + check(__functionAddress); + check(params, 4); + } + callPV(coord, pname, params, __functionAddress); + } + + /** + * Array version of: {@link #glTexGendv TexGendv} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glTexGendv(@NativeType("GLenum") int coord, @NativeType("GLenum") int pname, @NativeType("GLdouble const *") double[] params) { + long __functionAddress = GL.getICD().glTexGendv; + if (CHECKS) { + check(__functionAddress); + check(params, 4); + } + callPV(coord, pname, params, __functionAddress); + } + + /** + * Array version of: {@link #glTexImage1D TexImage1D} + * + * @see Reference Page + */ + public static void glTexImage1D(@NativeType("GLenum") int target, @NativeType("GLint") int level, @NativeType("GLint") int internalformat, @NativeType("GLsizei") int width, @NativeType("GLint") int border, @NativeType("GLenum") int format, @NativeType("GLenum") int type, @Nullable @NativeType("void const *") short[] pixels) { + GL11C.glTexImage1D(target, level, internalformat, width, border, format, type, pixels); + } + + /** + * Array version of: {@link #glTexImage1D TexImage1D} + * + * @see Reference Page + */ + public static void glTexImage1D(@NativeType("GLenum") int target, @NativeType("GLint") int level, @NativeType("GLint") int internalformat, @NativeType("GLsizei") int width, @NativeType("GLint") int border, @NativeType("GLenum") int format, @NativeType("GLenum") int type, @Nullable @NativeType("void const *") int[] pixels) { + GL11C.glTexImage1D(target, level, internalformat, width, border, format, type, pixels); + } + + /** + * Array version of: {@link #glTexImage1D TexImage1D} + * + * @see Reference Page + */ + public static void glTexImage1D(@NativeType("GLenum") int target, @NativeType("GLint") int level, @NativeType("GLint") int internalformat, @NativeType("GLsizei") int width, @NativeType("GLint") int border, @NativeType("GLenum") int format, @NativeType("GLenum") int type, @Nullable @NativeType("void const *") float[] pixels) { + GL11C.glTexImage1D(target, level, internalformat, width, border, format, type, pixels); + } + + /** + * Array version of: {@link #glTexImage1D TexImage1D} + * + * @see Reference Page + */ + public static void glTexImage1D(@NativeType("GLenum") int target, @NativeType("GLint") int level, @NativeType("GLint") int internalformat, @NativeType("GLsizei") int width, @NativeType("GLint") int border, @NativeType("GLenum") int format, @NativeType("GLenum") int type, @Nullable @NativeType("void const *") double[] pixels) { + GL11C.glTexImage1D(target, level, internalformat, width, border, format, type, pixels); + } + + /** + * Array version of: {@link #glTexImage2D TexImage2D} + * + * @see Reference Page + */ + public static void glTexImage2D(@NativeType("GLenum") int target, @NativeType("GLint") int level, @NativeType("GLint") int internalformat, @NativeType("GLsizei") int width, @NativeType("GLsizei") int height, @NativeType("GLint") int border, @NativeType("GLenum") int format, @NativeType("GLenum") int type, @Nullable @NativeType("void const *") short[] pixels) { + GL11C.glTexImage2D(target, level, internalformat, width, height, border, format, type, pixels); + } + + /** + * Array version of: {@link #glTexImage2D TexImage2D} + * + * @see Reference Page + */ + public static void glTexImage2D(@NativeType("GLenum") int target, @NativeType("GLint") int level, @NativeType("GLint") int internalformat, @NativeType("GLsizei") int width, @NativeType("GLsizei") int height, @NativeType("GLint") int border, @NativeType("GLenum") int format, @NativeType("GLenum") int type, @Nullable @NativeType("void const *") int[] pixels) { + GL11C.glTexImage2D(target, level, internalformat, width, height, border, format, type, pixels); + } + + /** + * Array version of: {@link #glTexImage2D TexImage2D} + * + * @see Reference Page + */ + public static void glTexImage2D(@NativeType("GLenum") int target, @NativeType("GLint") int level, @NativeType("GLint") int internalformat, @NativeType("GLsizei") int width, @NativeType("GLsizei") int height, @NativeType("GLint") int border, @NativeType("GLenum") int format, @NativeType("GLenum") int type, @Nullable @NativeType("void const *") float[] pixels) { + GL11C.glTexImage2D(target, level, internalformat, width, height, border, format, type, pixels); + } + + /** + * Array version of: {@link #glTexImage2D TexImage2D} + * + * @see Reference Page + */ + public static void glTexImage2D(@NativeType("GLenum") int target, @NativeType("GLint") int level, @NativeType("GLint") int internalformat, @NativeType("GLsizei") int width, @NativeType("GLsizei") int height, @NativeType("GLint") int border, @NativeType("GLenum") int format, @NativeType("GLenum") int type, @Nullable @NativeType("void const *") double[] pixels) { + GL11C.glTexImage2D(target, level, internalformat, width, height, border, format, type, pixels); + } + + /** + * Array version of: {@link #glTexParameteriv TexParameteriv} + * + * @see Reference Page + */ + public static void glTexParameteriv(@NativeType("GLenum") int target, @NativeType("GLenum") int pname, @NativeType("GLint const *") int[] params) { + GL11C.glTexParameteriv(target, pname, params); + } + + /** + * Array version of: {@link #glTexParameterfv TexParameterfv} + * + * @see Reference Page + */ + public static void glTexParameterfv(@NativeType("GLenum") int target, @NativeType("GLenum") int pname, @NativeType("GLfloat const *") float[] params) { + GL11C.glTexParameterfv(target, pname, params); + } + + /** + * Array version of: {@link #glTexSubImage1D TexSubImage1D} + * + * @see Reference Page + */ + public static void glTexSubImage1D(@NativeType("GLenum") int target, @NativeType("GLint") int level, @NativeType("GLint") int xoffset, @NativeType("GLsizei") int width, @NativeType("GLenum") int format, @NativeType("GLenum") int type, @NativeType("void const *") short[] pixels) { + GL11C.glTexSubImage1D(target, level, xoffset, width, format, type, pixels); + } + + /** + * Array version of: {@link #glTexSubImage1D TexSubImage1D} + * + * @see Reference Page + */ + public static void glTexSubImage1D(@NativeType("GLenum") int target, @NativeType("GLint") int level, @NativeType("GLint") int xoffset, @NativeType("GLsizei") int width, @NativeType("GLenum") int format, @NativeType("GLenum") int type, @NativeType("void const *") int[] pixels) { + GL11C.glTexSubImage1D(target, level, xoffset, width, format, type, pixels); + } + + /** + * Array version of: {@link #glTexSubImage1D TexSubImage1D} + * + * @see Reference Page + */ + public static void glTexSubImage1D(@NativeType("GLenum") int target, @NativeType("GLint") int level, @NativeType("GLint") int xoffset, @NativeType("GLsizei") int width, @NativeType("GLenum") int format, @NativeType("GLenum") int type, @NativeType("void const *") float[] pixels) { + GL11C.glTexSubImage1D(target, level, xoffset, width, format, type, pixels); + } + + /** + * Array version of: {@link #glTexSubImage1D TexSubImage1D} + * + * @see Reference Page + */ + public static void glTexSubImage1D(@NativeType("GLenum") int target, @NativeType("GLint") int level, @NativeType("GLint") int xoffset, @NativeType("GLsizei") int width, @NativeType("GLenum") int format, @NativeType("GLenum") int type, @NativeType("void const *") double[] pixels) { + GL11C.glTexSubImage1D(target, level, xoffset, width, format, type, pixels); + } + + /** + * Array version of: {@link #glTexSubImage2D TexSubImage2D} + * + * @see Reference Page + */ + public static void glTexSubImage2D(@NativeType("GLenum") int target, @NativeType("GLint") int level, @NativeType("GLint") int xoffset, @NativeType("GLint") int yoffset, @NativeType("GLsizei") int width, @NativeType("GLsizei") int height, @NativeType("GLenum") int format, @NativeType("GLenum") int type, @NativeType("void const *") short[] pixels) { + GL11C.glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels); + } + + /** + * Array version of: {@link #glTexSubImage2D TexSubImage2D} + * + * @see Reference Page + */ + public static void glTexSubImage2D(@NativeType("GLenum") int target, @NativeType("GLint") int level, @NativeType("GLint") int xoffset, @NativeType("GLint") int yoffset, @NativeType("GLsizei") int width, @NativeType("GLsizei") int height, @NativeType("GLenum") int format, @NativeType("GLenum") int type, @NativeType("void const *") int[] pixels) { + GL11C.glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels); + } + + /** + * Array version of: {@link #glTexSubImage2D TexSubImage2D} + * + * @see Reference Page + */ + public static void glTexSubImage2D(@NativeType("GLenum") int target, @NativeType("GLint") int level, @NativeType("GLint") int xoffset, @NativeType("GLint") int yoffset, @NativeType("GLsizei") int width, @NativeType("GLsizei") int height, @NativeType("GLenum") int format, @NativeType("GLenum") int type, @NativeType("void const *") float[] pixels) { + GL11C.glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels); + } + + /** + * Array version of: {@link #glTexSubImage2D TexSubImage2D} + * + * @see Reference Page + */ + public static void glTexSubImage2D(@NativeType("GLenum") int target, @NativeType("GLint") int level, @NativeType("GLint") int xoffset, @NativeType("GLint") int yoffset, @NativeType("GLsizei") int width, @NativeType("GLsizei") int height, @NativeType("GLenum") int format, @NativeType("GLenum") int type, @NativeType("void const *") double[] pixels) { + GL11C.glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels); + } + + /** + * Array version of: {@link #glVertex2fv Vertex2fv} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glVertex2fv(@NativeType("GLfloat const *") float[] coords) { + long __functionAddress = GL.getICD().glVertex2fv; + if (CHECKS) { + check(__functionAddress); + check(coords, 2); + } + callPV(coords, __functionAddress); + } + + /** + * Array version of: {@link #glVertex2sv Vertex2sv} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glVertex2sv(@NativeType("GLshort const *") short[] coords) { + long __functionAddress = GL.getICD().glVertex2sv; + if (CHECKS) { + check(__functionAddress); + check(coords, 2); + } + callPV(coords, __functionAddress); + } + + /** + * Array version of: {@link #glVertex2iv Vertex2iv} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glVertex2iv(@NativeType("GLint const *") int[] coords) { + long __functionAddress = GL.getICD().glVertex2iv; + if (CHECKS) { + check(__functionAddress); + check(coords, 2); + } + callPV(coords, __functionAddress); + } + + /** + * Array version of: {@link #glVertex2dv Vertex2dv} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glVertex2dv(@NativeType("GLdouble const *") double[] coords) { + long __functionAddress = GL.getICD().glVertex2dv; + if (CHECKS) { + check(__functionAddress); + check(coords, 2); + } + callPV(coords, __functionAddress); + } + + /** + * Array version of: {@link #glVertex3fv Vertex3fv} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glVertex3fv(@NativeType("GLfloat const *") float[] coords) { + long __functionAddress = GL.getICD().glVertex3fv; + if (CHECKS) { + check(__functionAddress); + check(coords, 3); + } + callPV(coords, __functionAddress); + } + + /** + * Array version of: {@link #glVertex3sv Vertex3sv} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glVertex3sv(@NativeType("GLshort const *") short[] coords) { + long __functionAddress = GL.getICD().glVertex3sv; + if (CHECKS) { + check(__functionAddress); + check(coords, 3); + } + callPV(coords, __functionAddress); + } + + /** + * Array version of: {@link #glVertex3iv Vertex3iv} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glVertex3iv(@NativeType("GLint const *") int[] coords) { + long __functionAddress = GL.getICD().glVertex3iv; + if (CHECKS) { + check(__functionAddress); + check(coords, 3); + } + callPV(coords, __functionAddress); + } + + /** + * Array version of: {@link #glVertex3dv Vertex3dv} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glVertex3dv(@NativeType("GLdouble const *") double[] coords) { + long __functionAddress = GL.getICD().glVertex3dv; + if (CHECKS) { + check(__functionAddress); + check(coords, 3); + } + callPV(coords, __functionAddress); + } + + /** + * Array version of: {@link #glVertex4fv Vertex4fv} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glVertex4fv(@NativeType("GLfloat const *") float[] coords) { + long __functionAddress = GL.getICD().glVertex4fv; + if (CHECKS) { + check(__functionAddress); + check(coords, 4); + } + callPV(coords, __functionAddress); + } + + /** + * Array version of: {@link #glVertex4sv Vertex4sv} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glVertex4sv(@NativeType("GLshort const *") short[] coords) { + long __functionAddress = GL.getICD().glVertex4sv; + if (CHECKS) { + check(__functionAddress); + check(coords, 4); + } + callPV(coords, __functionAddress); + } + + /** + * Array version of: {@link #glVertex4iv Vertex4iv} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glVertex4iv(@NativeType("GLint const *") int[] coords) { + long __functionAddress = GL.getICD().glVertex4iv; + if (CHECKS) { + check(__functionAddress); + check(coords, 4); + } + callPV(coords, __functionAddress); + } + + /** + * Array version of: {@link #glVertex4dv Vertex4dv} + * + * @see Reference Page - This function is deprecated and unavailable in the Core profile + */ + public static void glVertex4dv(@NativeType("GLdouble const *") double[] coords) { + long __functionAddress = GL.getICD().glVertex4dv; + if (CHECKS) { + check(__functionAddress); + check(coords, 4); + } + callPV(coords, __functionAddress); + } + +} diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/opengl/GL15.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/opengl/GL15.java new file mode 100644 index 000000000..373c620e3 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/opengl/GL15.java @@ -0,0 +1,1200 @@ +/* + * Copyright LWJGL. All rights reserved. + * License terms: https://www.lwjgl.org/license + * MACHINE GENERATED FILE, DO NOT EDIT + */ +package org.lwjgl.opengl; + +import javax.annotation.*; + +import java.nio.*; + +import org.lwjgl.*; + +import org.lwjgl.system.*; + +import static org.lwjgl.system.Checks.*; + +/** + * The OpenGL functionality up to version 1.5. Includes the deprecated symbols of the Compatibility Profile. + * + *

Extensions promoted to core in this release:

+ * + * + */ +public class GL15 extends GL14 { + + /** New token names. */ + public static final int + GL_FOG_COORD_SRC = 0x8450, + GL_FOG_COORD = 0x8451, + GL_CURRENT_FOG_COORD = 0x8453, + GL_FOG_COORD_ARRAY_TYPE = 0x8454, + GL_FOG_COORD_ARRAY_STRIDE = 0x8455, + GL_FOG_COORD_ARRAY_POINTER = 0x8456, + GL_FOG_COORD_ARRAY = 0x8457, + GL_FOG_COORD_ARRAY_BUFFER_BINDING = 0x889D, + GL_SRC0_RGB = 0x8580, + GL_SRC1_RGB = 0x8581, + GL_SRC2_RGB = 0x8582, + GL_SRC0_ALPHA = 0x8588, + GL_SRC1_ALPHA = 0x8589, + GL_SRC2_ALPHA = 0x858A; + + /** + * Accepted by the {@code target} parameters of BindBuffer, BufferData, BufferSubData, MapBuffer, UnmapBuffer, GetBufferSubData, + * GetBufferParameteriv, and GetBufferPointerv. + */ + public static final int + GL_ARRAY_BUFFER = 0x8892, + GL_ELEMENT_ARRAY_BUFFER = 0x8893; + + /** Accepted by the {@code pname} parameter of GetBooleanv, GetIntegerv, GetFloatv, and GetDoublev. */ + public static final int + GL_ARRAY_BUFFER_BINDING = 0x8894, + GL_ELEMENT_ARRAY_BUFFER_BINDING = 0x8895, + GL_VERTEX_ARRAY_BUFFER_BINDING = 0x8896, + GL_NORMAL_ARRAY_BUFFER_BINDING = 0x8897, + GL_COLOR_ARRAY_BUFFER_BINDING = 0x8898, + GL_INDEX_ARRAY_BUFFER_BINDING = 0x8899, + GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING = 0x889A, + GL_EDGE_FLAG_ARRAY_BUFFER_BINDING = 0x889B, + GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING = 0x889C, + GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING = 0x889D, + GL_WEIGHT_ARRAY_BUFFER_BINDING = 0x889E; + + /** Accepted by the {@code pname} parameter of GetVertexAttribiv. */ + public static final int GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING = 0x889F; + + /** Accepted by the {@code usage} parameter of BufferData. */ + public static final int + GL_STREAM_DRAW = 0x88E0, + GL_STREAM_READ = 0x88E1, + GL_STREAM_COPY = 0x88E2, + GL_STATIC_DRAW = 0x88E4, + GL_STATIC_READ = 0x88E5, + GL_STATIC_COPY = 0x88E6, + GL_DYNAMIC_DRAW = 0x88E8, + GL_DYNAMIC_READ = 0x88E9, + GL_DYNAMIC_COPY = 0x88EA; + + /** Accepted by the {@code access} parameter of MapBuffer. */ + public static final int + GL_READ_ONLY = 0x88B8, + GL_WRITE_ONLY = 0x88B9, + GL_READ_WRITE = 0x88BA; + + /** Accepted by the {@code pname} parameter of GetBufferParameteriv. */ + public static final int + GL_BUFFER_SIZE = 0x8764, + GL_BUFFER_USAGE = 0x8765, + GL_BUFFER_ACCESS = 0x88BB, + GL_BUFFER_MAPPED = 0x88BC; + + /** Accepted by the {@code pname} parameter of GetBufferPointerv. */ + public static final int GL_BUFFER_MAP_POINTER = 0x88BD; + + /** Accepted by the {@code target} parameter of BeginQuery, EndQuery, and GetQueryiv. */ + public static final int GL_SAMPLES_PASSED = 0x8914; + + /** Accepted by the {@code pname} parameter of GetQueryiv. */ + public static final int + GL_QUERY_COUNTER_BITS = 0x8864, + GL_CURRENT_QUERY = 0x8865; + + /** Accepted by the {@code pname} parameter of GetQueryObjectiv and GetQueryObjectuiv. */ + public static final int + GL_QUERY_RESULT = 0x8866, + GL_QUERY_RESULT_AVAILABLE = 0x8867; + + static { GL.initialize(); } + + protected GL15() { + throw new UnsupportedOperationException(); + } + + static boolean isAvailable(GLCapabilities caps) { + return checkFunctions( + caps.glBindBuffer, caps.glDeleteBuffers, caps.glGenBuffers, caps.glIsBuffer, caps.glBufferData, caps.glBufferSubData, caps.glGetBufferSubData, + caps.glMapBuffer, caps.glUnmapBuffer, caps.glGetBufferParameteriv, caps.glGetBufferPointerv, caps.glGenQueries, caps.glDeleteQueries, + caps.glIsQuery, caps.glBeginQuery, caps.glEndQuery, caps.glGetQueryiv, caps.glGetQueryObjectiv, caps.glGetQueryObjectuiv + ); + } + + // --- [ glBindBuffer ] --- + + /** + * Binds a named buffer object. + * + * @param target the target to which the buffer object is bound. One of:
{@link GL15C#GL_ARRAY_BUFFER ARRAY_BUFFER}{@link GL15C#GL_ELEMENT_ARRAY_BUFFER ELEMENT_ARRAY_BUFFER}{@link GL21#GL_PIXEL_PACK_BUFFER PIXEL_PACK_BUFFER}{@link GL21#GL_PIXEL_UNPACK_BUFFER PIXEL_UNPACK_BUFFER}
{@link GL30#GL_TRANSFORM_FEEDBACK_BUFFER TRANSFORM_FEEDBACK_BUFFER}{@link GL31#GL_UNIFORM_BUFFER UNIFORM_BUFFER}{@link GL31#GL_TEXTURE_BUFFER TEXTURE_BUFFER}{@link GL31#GL_COPY_READ_BUFFER COPY_READ_BUFFER}
{@link GL31#GL_COPY_WRITE_BUFFER COPY_WRITE_BUFFER}{@link GL40#GL_DRAW_INDIRECT_BUFFER DRAW_INDIRECT_BUFFER}{@link GL42#GL_ATOMIC_COUNTER_BUFFER ATOMIC_COUNTER_BUFFER}{@link GL43#GL_DISPATCH_INDIRECT_BUFFER DISPATCH_INDIRECT_BUFFER}
{@link GL43#GL_SHADER_STORAGE_BUFFER SHADER_STORAGE_BUFFER}{@link ARBIndirectParameters#GL_PARAMETER_BUFFER_ARB PARAMETER_BUFFER_ARB}
+ * @param buffer the name of a buffer object + * + * @see Reference Page + */ + public static void glBindBuffer(@NativeType("GLenum") int target, @NativeType("GLuint") int buffer) { + GL15C.glBindBuffer(target, buffer); + } + + // --- [ glDeleteBuffers ] --- + + /** + * Unsafe version of: {@link #glDeleteBuffers DeleteBuffers} + * + * @param n the number of buffer objects to be deleted + */ + public static void nglDeleteBuffers(int n, long buffers) { + GL15C.nglDeleteBuffers(n, buffers); + } + + /** + * Deletes named buffer objects. + * + * @param buffers an array of buffer objects to be deleted + * + * @see Reference Page + */ + public static void glDeleteBuffers(@NativeType("GLuint const *") IntBuffer buffers) { + GL15C.glDeleteBuffers(buffers); + } + + /** + * Deletes named buffer objects. + * + * @see Reference Page + */ + public static void glDeleteBuffers(@NativeType("GLuint const *") int buffer) { + GL15C.glDeleteBuffers(buffer); + } + + // --- [ glGenBuffers ] --- + + /** + * Unsafe version of: {@link #glGenBuffers GenBuffers} + * + * @param n the number of buffer object names to be generated + */ + public static void nglGenBuffers(int n, long buffers) { + GL15C.nglGenBuffers(n, buffers); + } + + /** + * Generates buffer object names. + * + * @param buffers a buffer in which the generated buffer object names are stored + * + * @see Reference Page + */ + public static void glGenBuffers(@NativeType("GLuint *") IntBuffer buffers) { + GL15C.glGenBuffers(buffers); + } + + /** + * Generates buffer object names. + * + * @see Reference Page + */ + @NativeType("void") + public static int glGenBuffers() { + return GL15C.glGenBuffers(); + } + + // --- [ glIsBuffer ] --- + + /** + * Determines if a name corresponds to a buffer object. + * + * @param buffer a value that may be the name of a buffer object + * + * @see Reference Page + */ + @NativeType("GLboolean") + public static boolean glIsBuffer(@NativeType("GLuint") int buffer) { + return GL15C.glIsBuffer(buffer); + } + + // --- [ glBufferData ] --- + + /** + * Unsafe version of: {@link #glBufferData BufferData} + * + * @param size the size in bytes of the buffer object's new data store + */ + public static void nglBufferData(int target, long size, long data, int usage) { + GL15C.nglBufferData(target, size, data, usage); + } + + /** + * Creates and initializes a buffer object's data store. + * + *

{@code usage} is a hint to the GL implementation as to how a buffer object's data store will be accessed. This enables the GL implementation to make + * more intelligent decisions that may significantly impact buffer object performance. It does not, however, constrain the actual usage of the data store. + * {@code usage} can be broken down into two parts: first, the frequency of access (modification and usage), and second, the nature of that access. The + * frequency of access may be one of these:

+ * + *
    + *
  • STREAM - The data store contents will be modified once and used at most a few times.
  • + *
  • STATIC - The data store contents will be modified once and used many times.
  • + *
  • DYNAMIC - The data store contents will be modified repeatedly and used many times.
  • + *
+ * + *

The nature of access may be one of these:

+ * + *
    + *
  • DRAW - The data store contents are modified by the application, and used as the source for GL drawing and image specification commands.
  • + *
  • READ - The data store contents are modified by reading data from the GL, and used to return that data when queried by the application.
  • + *
  • COPY - The data store contents are modified by reading data from the GL, and used as the source for GL drawing and image specification commands.
  • + *
+ * + * @param target the target buffer object. One of:
{@link GL15C#GL_ARRAY_BUFFER ARRAY_BUFFER}{@link GL15C#GL_ELEMENT_ARRAY_BUFFER ELEMENT_ARRAY_BUFFER}{@link GL21#GL_PIXEL_PACK_BUFFER PIXEL_PACK_BUFFER}{@link GL21#GL_PIXEL_UNPACK_BUFFER PIXEL_UNPACK_BUFFER}
{@link GL30#GL_TRANSFORM_FEEDBACK_BUFFER TRANSFORM_FEEDBACK_BUFFER}{@link GL31#GL_UNIFORM_BUFFER UNIFORM_BUFFER}{@link GL31#GL_TEXTURE_BUFFER TEXTURE_BUFFER}{@link GL31#GL_COPY_READ_BUFFER COPY_READ_BUFFER}
{@link GL31#GL_COPY_WRITE_BUFFER COPY_WRITE_BUFFER}{@link GL40#GL_DRAW_INDIRECT_BUFFER DRAW_INDIRECT_BUFFER}{@link GL42#GL_ATOMIC_COUNTER_BUFFER ATOMIC_COUNTER_BUFFER}{@link GL43#GL_DISPATCH_INDIRECT_BUFFER DISPATCH_INDIRECT_BUFFER}
{@link GL43#GL_SHADER_STORAGE_BUFFER SHADER_STORAGE_BUFFER}{@link ARBIndirectParameters#GL_PARAMETER_BUFFER_ARB PARAMETER_BUFFER_ARB}
+ * @param size the size in bytes of the buffer object's new data store + * @param usage the expected usage pattern of the data store. One of:
{@link GL15C#GL_STREAM_DRAW STREAM_DRAW}{@link GL15C#GL_STREAM_READ STREAM_READ}{@link GL15C#GL_STREAM_COPY STREAM_COPY}{@link GL15C#GL_STATIC_DRAW STATIC_DRAW}{@link GL15C#GL_STATIC_READ STATIC_READ}{@link GL15C#GL_STATIC_COPY STATIC_COPY}{@link GL15C#GL_DYNAMIC_DRAW DYNAMIC_DRAW}
{@link GL15C#GL_DYNAMIC_READ DYNAMIC_READ}{@link GL15C#GL_DYNAMIC_COPY DYNAMIC_COPY}
+ * + * @see Reference Page + */ + public static void glBufferData(@NativeType("GLenum") int target, @NativeType("GLsizeiptr") long size, @NativeType("GLenum") int usage) { + GL15C.glBufferData(target, size, usage); + } + + /** + * Creates and initializes a buffer object's data store. + * + *

{@code usage} is a hint to the GL implementation as to how a buffer object's data store will be accessed. This enables the GL implementation to make + * more intelligent decisions that may significantly impact buffer object performance. It does not, however, constrain the actual usage of the data store. + * {@code usage} can be broken down into two parts: first, the frequency of access (modification and usage), and second, the nature of that access. The + * frequency of access may be one of these:

+ * + *
    + *
  • STREAM - The data store contents will be modified once and used at most a few times.
  • + *
  • STATIC - The data store contents will be modified once and used many times.
  • + *
  • DYNAMIC - The data store contents will be modified repeatedly and used many times.
  • + *
+ * + *

The nature of access may be one of these:

+ * + *
    + *
  • DRAW - The data store contents are modified by the application, and used as the source for GL drawing and image specification commands.
  • + *
  • READ - The data store contents are modified by reading data from the GL, and used to return that data when queried by the application.
  • + *
  • COPY - The data store contents are modified by reading data from the GL, and used as the source for GL drawing and image specification commands.
  • + *
+ * + * @param target the target buffer object. One of:
{@link GL15C#GL_ARRAY_BUFFER ARRAY_BUFFER}{@link GL15C#GL_ELEMENT_ARRAY_BUFFER ELEMENT_ARRAY_BUFFER}{@link GL21#GL_PIXEL_PACK_BUFFER PIXEL_PACK_BUFFER}{@link GL21#GL_PIXEL_UNPACK_BUFFER PIXEL_UNPACK_BUFFER}
{@link GL30#GL_TRANSFORM_FEEDBACK_BUFFER TRANSFORM_FEEDBACK_BUFFER}{@link GL31#GL_UNIFORM_BUFFER UNIFORM_BUFFER}{@link GL31#GL_TEXTURE_BUFFER TEXTURE_BUFFER}{@link GL31#GL_COPY_READ_BUFFER COPY_READ_BUFFER}
{@link GL31#GL_COPY_WRITE_BUFFER COPY_WRITE_BUFFER}{@link GL40#GL_DRAW_INDIRECT_BUFFER DRAW_INDIRECT_BUFFER}{@link GL42#GL_ATOMIC_COUNTER_BUFFER ATOMIC_COUNTER_BUFFER}{@link GL43#GL_DISPATCH_INDIRECT_BUFFER DISPATCH_INDIRECT_BUFFER}
{@link GL43#GL_SHADER_STORAGE_BUFFER SHADER_STORAGE_BUFFER}{@link ARBIndirectParameters#GL_PARAMETER_BUFFER_ARB PARAMETER_BUFFER_ARB}
+ * @param data a pointer to data that will be copied into the data store for initialization, or {@code NULL} if no data is to be copied + * @param usage the expected usage pattern of the data store. One of:
{@link GL15C#GL_STREAM_DRAW STREAM_DRAW}{@link GL15C#GL_STREAM_READ STREAM_READ}{@link GL15C#GL_STREAM_COPY STREAM_COPY}{@link GL15C#GL_STATIC_DRAW STATIC_DRAW}{@link GL15C#GL_STATIC_READ STATIC_READ}{@link GL15C#GL_STATIC_COPY STATIC_COPY}{@link GL15C#GL_DYNAMIC_DRAW DYNAMIC_DRAW}
{@link GL15C#GL_DYNAMIC_READ DYNAMIC_READ}{@link GL15C#GL_DYNAMIC_COPY DYNAMIC_COPY}
+ * + * @see Reference Page + */ + public static void glBufferData(@NativeType("GLenum") int target, @NativeType("void const *") ByteBuffer data, @NativeType("GLenum") int usage) { + GL15C.glBufferData(target, data, usage); + } + + /** + * Creates and initializes a buffer object's data store. + * + *

{@code usage} is a hint to the GL implementation as to how a buffer object's data store will be accessed. This enables the GL implementation to make + * more intelligent decisions that may significantly impact buffer object performance. It does not, however, constrain the actual usage of the data store. + * {@code usage} can be broken down into two parts: first, the frequency of access (modification and usage), and second, the nature of that access. The + * frequency of access may be one of these:

+ * + *
    + *
  • STREAM - The data store contents will be modified once and used at most a few times.
  • + *
  • STATIC - The data store contents will be modified once and used many times.
  • + *
  • DYNAMIC - The data store contents will be modified repeatedly and used many times.
  • + *
+ * + *

The nature of access may be one of these:

+ * + *
    + *
  • DRAW - The data store contents are modified by the application, and used as the source for GL drawing and image specification commands.
  • + *
  • READ - The data store contents are modified by reading data from the GL, and used to return that data when queried by the application.
  • + *
  • COPY - The data store contents are modified by reading data from the GL, and used as the source for GL drawing and image specification commands.
  • + *
+ * + * @param target the target buffer object. One of:
{@link GL15C#GL_ARRAY_BUFFER ARRAY_BUFFER}{@link GL15C#GL_ELEMENT_ARRAY_BUFFER ELEMENT_ARRAY_BUFFER}{@link GL21#GL_PIXEL_PACK_BUFFER PIXEL_PACK_BUFFER}{@link GL21#GL_PIXEL_UNPACK_BUFFER PIXEL_UNPACK_BUFFER}
{@link GL30#GL_TRANSFORM_FEEDBACK_BUFFER TRANSFORM_FEEDBACK_BUFFER}{@link GL31#GL_UNIFORM_BUFFER UNIFORM_BUFFER}{@link GL31#GL_TEXTURE_BUFFER TEXTURE_BUFFER}{@link GL31#GL_COPY_READ_BUFFER COPY_READ_BUFFER}
{@link GL31#GL_COPY_WRITE_BUFFER COPY_WRITE_BUFFER}{@link GL40#GL_DRAW_INDIRECT_BUFFER DRAW_INDIRECT_BUFFER}{@link GL42#GL_ATOMIC_COUNTER_BUFFER ATOMIC_COUNTER_BUFFER}{@link GL43#GL_DISPATCH_INDIRECT_BUFFER DISPATCH_INDIRECT_BUFFER}
{@link GL43#GL_SHADER_STORAGE_BUFFER SHADER_STORAGE_BUFFER}{@link ARBIndirectParameters#GL_PARAMETER_BUFFER_ARB PARAMETER_BUFFER_ARB}
+ * @param data a pointer to data that will be copied into the data store for initialization, or {@code NULL} if no data is to be copied + * @param usage the expected usage pattern of the data store. One of:
{@link GL15C#GL_STREAM_DRAW STREAM_DRAW}{@link GL15C#GL_STREAM_READ STREAM_READ}{@link GL15C#GL_STREAM_COPY STREAM_COPY}{@link GL15C#GL_STATIC_DRAW STATIC_DRAW}{@link GL15C#GL_STATIC_READ STATIC_READ}{@link GL15C#GL_STATIC_COPY STATIC_COPY}{@link GL15C#GL_DYNAMIC_DRAW DYNAMIC_DRAW}
{@link GL15C#GL_DYNAMIC_READ DYNAMIC_READ}{@link GL15C#GL_DYNAMIC_COPY DYNAMIC_COPY}
+ * + * @see Reference Page + */ + public static void glBufferData(@NativeType("GLenum") int target, @NativeType("void const *") ShortBuffer data, @NativeType("GLenum") int usage) { + GL15C.glBufferData(target, data, usage); + } + + /** + * Creates and initializes a buffer object's data store. + * + *

{@code usage} is a hint to the GL implementation as to how a buffer object's data store will be accessed. This enables the GL implementation to make + * more intelligent decisions that may significantly impact buffer object performance. It does not, however, constrain the actual usage of the data store. + * {@code usage} can be broken down into two parts: first, the frequency of access (modification and usage), and second, the nature of that access. The + * frequency of access may be one of these:

+ * + *
    + *
  • STREAM - The data store contents will be modified once and used at most a few times.
  • + *
  • STATIC - The data store contents will be modified once and used many times.
  • + *
  • DYNAMIC - The data store contents will be modified repeatedly and used many times.
  • + *
+ * + *

The nature of access may be one of these:

+ * + *
    + *
  • DRAW - The data store contents are modified by the application, and used as the source for GL drawing and image specification commands.
  • + *
  • READ - The data store contents are modified by reading data from the GL, and used to return that data when queried by the application.
  • + *
  • COPY - The data store contents are modified by reading data from the GL, and used as the source for GL drawing and image specification commands.
  • + *
+ * + * @param target the target buffer object. One of:
{@link GL15C#GL_ARRAY_BUFFER ARRAY_BUFFER}{@link GL15C#GL_ELEMENT_ARRAY_BUFFER ELEMENT_ARRAY_BUFFER}{@link GL21#GL_PIXEL_PACK_BUFFER PIXEL_PACK_BUFFER}{@link GL21#GL_PIXEL_UNPACK_BUFFER PIXEL_UNPACK_BUFFER}
{@link GL30#GL_TRANSFORM_FEEDBACK_BUFFER TRANSFORM_FEEDBACK_BUFFER}{@link GL31#GL_UNIFORM_BUFFER UNIFORM_BUFFER}{@link GL31#GL_TEXTURE_BUFFER TEXTURE_BUFFER}{@link GL31#GL_COPY_READ_BUFFER COPY_READ_BUFFER}
{@link GL31#GL_COPY_WRITE_BUFFER COPY_WRITE_BUFFER}{@link GL40#GL_DRAW_INDIRECT_BUFFER DRAW_INDIRECT_BUFFER}{@link GL42#GL_ATOMIC_COUNTER_BUFFER ATOMIC_COUNTER_BUFFER}{@link GL43#GL_DISPATCH_INDIRECT_BUFFER DISPATCH_INDIRECT_BUFFER}
{@link GL43#GL_SHADER_STORAGE_BUFFER SHADER_STORAGE_BUFFER}{@link ARBIndirectParameters#GL_PARAMETER_BUFFER_ARB PARAMETER_BUFFER_ARB}
+ * @param data a pointer to data that will be copied into the data store for initialization, or {@code NULL} if no data is to be copied + * @param usage the expected usage pattern of the data store. One of:
{@link GL15C#GL_STREAM_DRAW STREAM_DRAW}{@link GL15C#GL_STREAM_READ STREAM_READ}{@link GL15C#GL_STREAM_COPY STREAM_COPY}{@link GL15C#GL_STATIC_DRAW STATIC_DRAW}{@link GL15C#GL_STATIC_READ STATIC_READ}{@link GL15C#GL_STATIC_COPY STATIC_COPY}{@link GL15C#GL_DYNAMIC_DRAW DYNAMIC_DRAW}
{@link GL15C#GL_DYNAMIC_READ DYNAMIC_READ}{@link GL15C#GL_DYNAMIC_COPY DYNAMIC_COPY}
+ * + * @see Reference Page + */ + public static void glBufferData(@NativeType("GLenum") int target, @NativeType("void const *") IntBuffer data, @NativeType("GLenum") int usage) { + GL15C.glBufferData(target, data, usage); + } + + /** + * Creates and initializes a buffer object's data store. + * + *

{@code usage} is a hint to the GL implementation as to how a buffer object's data store will be accessed. This enables the GL implementation to make + * more intelligent decisions that may significantly impact buffer object performance. It does not, however, constrain the actual usage of the data store. + * {@code usage} can be broken down into two parts: first, the frequency of access (modification and usage), and second, the nature of that access. The + * frequency of access may be one of these:

+ * + *
    + *
  • STREAM - The data store contents will be modified once and used at most a few times.
  • + *
  • STATIC - The data store contents will be modified once and used many times.
  • + *
  • DYNAMIC - The data store contents will be modified repeatedly and used many times.
  • + *
+ * + *

The nature of access may be one of these:

+ * + *
    + *
  • DRAW - The data store contents are modified by the application, and used as the source for GL drawing and image specification commands.
  • + *
  • READ - The data store contents are modified by reading data from the GL, and used to return that data when queried by the application.
  • + *
  • COPY - The data store contents are modified by reading data from the GL, and used as the source for GL drawing and image specification commands.
  • + *
+ * + * @param target the target buffer object. One of:
{@link GL15C#GL_ARRAY_BUFFER ARRAY_BUFFER}{@link GL15C#GL_ELEMENT_ARRAY_BUFFER ELEMENT_ARRAY_BUFFER}{@link GL21#GL_PIXEL_PACK_BUFFER PIXEL_PACK_BUFFER}{@link GL21#GL_PIXEL_UNPACK_BUFFER PIXEL_UNPACK_BUFFER}
{@link GL30#GL_TRANSFORM_FEEDBACK_BUFFER TRANSFORM_FEEDBACK_BUFFER}{@link GL31#GL_UNIFORM_BUFFER UNIFORM_BUFFER}{@link GL31#GL_TEXTURE_BUFFER TEXTURE_BUFFER}{@link GL31#GL_COPY_READ_BUFFER COPY_READ_BUFFER}
{@link GL31#GL_COPY_WRITE_BUFFER COPY_WRITE_BUFFER}{@link GL40#GL_DRAW_INDIRECT_BUFFER DRAW_INDIRECT_BUFFER}{@link GL42#GL_ATOMIC_COUNTER_BUFFER ATOMIC_COUNTER_BUFFER}{@link GL43#GL_DISPATCH_INDIRECT_BUFFER DISPATCH_INDIRECT_BUFFER}
{@link GL43#GL_SHADER_STORAGE_BUFFER SHADER_STORAGE_BUFFER}{@link ARBIndirectParameters#GL_PARAMETER_BUFFER_ARB PARAMETER_BUFFER_ARB}
+ * @param data a pointer to data that will be copied into the data store for initialization, or {@code NULL} if no data is to be copied + * @param usage the expected usage pattern of the data store. One of:
{@link GL15C#GL_STREAM_DRAW STREAM_DRAW}{@link GL15C#GL_STREAM_READ STREAM_READ}{@link GL15C#GL_STREAM_COPY STREAM_COPY}{@link GL15C#GL_STATIC_DRAW STATIC_DRAW}{@link GL15C#GL_STATIC_READ STATIC_READ}{@link GL15C#GL_STATIC_COPY STATIC_COPY}{@link GL15C#GL_DYNAMIC_DRAW DYNAMIC_DRAW}
{@link GL15C#GL_DYNAMIC_READ DYNAMIC_READ}{@link GL15C#GL_DYNAMIC_COPY DYNAMIC_COPY}
+ * + * @see Reference Page + */ + public static void glBufferData(@NativeType("GLenum") int target, @NativeType("void const *") LongBuffer data, @NativeType("GLenum") int usage) { + GL15C.glBufferData(target, data, usage); + } + + /** + * Creates and initializes a buffer object's data store. + * + *

{@code usage} is a hint to the GL implementation as to how a buffer object's data store will be accessed. This enables the GL implementation to make + * more intelligent decisions that may significantly impact buffer object performance. It does not, however, constrain the actual usage of the data store. + * {@code usage} can be broken down into two parts: first, the frequency of access (modification and usage), and second, the nature of that access. The + * frequency of access may be one of these:

+ * + *
    + *
  • STREAM - The data store contents will be modified once and used at most a few times.
  • + *
  • STATIC - The data store contents will be modified once and used many times.
  • + *
  • DYNAMIC - The data store contents will be modified repeatedly and used many times.
  • + *
+ * + *

The nature of access may be one of these:

+ * + *
    + *
  • DRAW - The data store contents are modified by the application, and used as the source for GL drawing and image specification commands.
  • + *
  • READ - The data store contents are modified by reading data from the GL, and used to return that data when queried by the application.
  • + *
  • COPY - The data store contents are modified by reading data from the GL, and used as the source for GL drawing and image specification commands.
  • + *
+ * + * @param target the target buffer object. One of:
{@link GL15C#GL_ARRAY_BUFFER ARRAY_BUFFER}{@link GL15C#GL_ELEMENT_ARRAY_BUFFER ELEMENT_ARRAY_BUFFER}{@link GL21#GL_PIXEL_PACK_BUFFER PIXEL_PACK_BUFFER}{@link GL21#GL_PIXEL_UNPACK_BUFFER PIXEL_UNPACK_BUFFER}
{@link GL30#GL_TRANSFORM_FEEDBACK_BUFFER TRANSFORM_FEEDBACK_BUFFER}{@link GL31#GL_UNIFORM_BUFFER UNIFORM_BUFFER}{@link GL31#GL_TEXTURE_BUFFER TEXTURE_BUFFER}{@link GL31#GL_COPY_READ_BUFFER COPY_READ_BUFFER}
{@link GL31#GL_COPY_WRITE_BUFFER COPY_WRITE_BUFFER}{@link GL40#GL_DRAW_INDIRECT_BUFFER DRAW_INDIRECT_BUFFER}{@link GL42#GL_ATOMIC_COUNTER_BUFFER ATOMIC_COUNTER_BUFFER}{@link GL43#GL_DISPATCH_INDIRECT_BUFFER DISPATCH_INDIRECT_BUFFER}
{@link GL43#GL_SHADER_STORAGE_BUFFER SHADER_STORAGE_BUFFER}{@link ARBIndirectParameters#GL_PARAMETER_BUFFER_ARB PARAMETER_BUFFER_ARB}
+ * @param data a pointer to data that will be copied into the data store for initialization, or {@code NULL} if no data is to be copied + * @param usage the expected usage pattern of the data store. One of:
{@link GL15C#GL_STREAM_DRAW STREAM_DRAW}{@link GL15C#GL_STREAM_READ STREAM_READ}{@link GL15C#GL_STREAM_COPY STREAM_COPY}{@link GL15C#GL_STATIC_DRAW STATIC_DRAW}{@link GL15C#GL_STATIC_READ STATIC_READ}{@link GL15C#GL_STATIC_COPY STATIC_COPY}{@link GL15C#GL_DYNAMIC_DRAW DYNAMIC_DRAW}
{@link GL15C#GL_DYNAMIC_READ DYNAMIC_READ}{@link GL15C#GL_DYNAMIC_COPY DYNAMIC_COPY}
+ * + * @see Reference Page + */ + public static void glBufferData(@NativeType("GLenum") int target, @NativeType("void const *") FloatBuffer data, @NativeType("GLenum") int usage) { + GL15C.glBufferData(target, data, usage); + } + + /** + * Creates and initializes a buffer object's data store. + * + *

{@code usage} is a hint to the GL implementation as to how a buffer object's data store will be accessed. This enables the GL implementation to make + * more intelligent decisions that may significantly impact buffer object performance. It does not, however, constrain the actual usage of the data store. + * {@code usage} can be broken down into two parts: first, the frequency of access (modification and usage), and second, the nature of that access. The + * frequency of access may be one of these:

+ * + *
    + *
  • STREAM - The data store contents will be modified once and used at most a few times.
  • + *
  • STATIC - The data store contents will be modified once and used many times.
  • + *
  • DYNAMIC - The data store contents will be modified repeatedly and used many times.
  • + *
+ * + *

The nature of access may be one of these:

+ * + *
    + *
  • DRAW - The data store contents are modified by the application, and used as the source for GL drawing and image specification commands.
  • + *
  • READ - The data store contents are modified by reading data from the GL, and used to return that data when queried by the application.
  • + *
  • COPY - The data store contents are modified by reading data from the GL, and used as the source for GL drawing and image specification commands.
  • + *
+ * + * @param target the target buffer object. One of:
{@link GL15C#GL_ARRAY_BUFFER ARRAY_BUFFER}{@link GL15C#GL_ELEMENT_ARRAY_BUFFER ELEMENT_ARRAY_BUFFER}{@link GL21#GL_PIXEL_PACK_BUFFER PIXEL_PACK_BUFFER}{@link GL21#GL_PIXEL_UNPACK_BUFFER PIXEL_UNPACK_BUFFER}
{@link GL30#GL_TRANSFORM_FEEDBACK_BUFFER TRANSFORM_FEEDBACK_BUFFER}{@link GL31#GL_UNIFORM_BUFFER UNIFORM_BUFFER}{@link GL31#GL_TEXTURE_BUFFER TEXTURE_BUFFER}{@link GL31#GL_COPY_READ_BUFFER COPY_READ_BUFFER}
{@link GL31#GL_COPY_WRITE_BUFFER COPY_WRITE_BUFFER}{@link GL40#GL_DRAW_INDIRECT_BUFFER DRAW_INDIRECT_BUFFER}{@link GL42#GL_ATOMIC_COUNTER_BUFFER ATOMIC_COUNTER_BUFFER}{@link GL43#GL_DISPATCH_INDIRECT_BUFFER DISPATCH_INDIRECT_BUFFER}
{@link GL43#GL_SHADER_STORAGE_BUFFER SHADER_STORAGE_BUFFER}{@link ARBIndirectParameters#GL_PARAMETER_BUFFER_ARB PARAMETER_BUFFER_ARB}
+ * @param data a pointer to data that will be copied into the data store for initialization, or {@code NULL} if no data is to be copied + * @param usage the expected usage pattern of the data store. One of:
{@link GL15C#GL_STREAM_DRAW STREAM_DRAW}{@link GL15C#GL_STREAM_READ STREAM_READ}{@link GL15C#GL_STREAM_COPY STREAM_COPY}{@link GL15C#GL_STATIC_DRAW STATIC_DRAW}{@link GL15C#GL_STATIC_READ STATIC_READ}{@link GL15C#GL_STATIC_COPY STATIC_COPY}{@link GL15C#GL_DYNAMIC_DRAW DYNAMIC_DRAW}
{@link GL15C#GL_DYNAMIC_READ DYNAMIC_READ}{@link GL15C#GL_DYNAMIC_COPY DYNAMIC_COPY}
+ * + * @see Reference Page + */ + public static void glBufferData(@NativeType("GLenum") int target, @NativeType("void const *") DoubleBuffer data, @NativeType("GLenum") int usage) { + GL15C.glBufferData(target, data, usage); + } + + // --- [ glBufferSubData ] --- + + /** + * Unsafe version of: {@link #glBufferSubData BufferSubData} + * + * @param size the size in bytes of the data store region being replaced + */ + public static void nglBufferSubData(int target, long offset, long size, long data) { + GL15C.nglBufferSubData(target, offset, size, data); + } + + /** + * Updates a subset of a buffer object's data store. + * + * @param target the target buffer object. One of:
{@link GL15C#GL_ARRAY_BUFFER ARRAY_BUFFER}{@link GL15C#GL_ELEMENT_ARRAY_BUFFER ELEMENT_ARRAY_BUFFER}{@link GL21#GL_PIXEL_PACK_BUFFER PIXEL_PACK_BUFFER}{@link GL21#GL_PIXEL_UNPACK_BUFFER PIXEL_UNPACK_BUFFER}
{@link GL30#GL_TRANSFORM_FEEDBACK_BUFFER TRANSFORM_FEEDBACK_BUFFER}{@link GL31#GL_UNIFORM_BUFFER UNIFORM_BUFFER}{@link GL31#GL_TEXTURE_BUFFER TEXTURE_BUFFER}{@link GL31#GL_COPY_READ_BUFFER COPY_READ_BUFFER}
{@link GL31#GL_COPY_WRITE_BUFFER COPY_WRITE_BUFFER}{@link GL40#GL_DRAW_INDIRECT_BUFFER DRAW_INDIRECT_BUFFER}{@link GL42#GL_ATOMIC_COUNTER_BUFFER ATOMIC_COUNTER_BUFFER}{@link GL43#GL_DISPATCH_INDIRECT_BUFFER DISPATCH_INDIRECT_BUFFER}
{@link GL43#GL_SHADER_STORAGE_BUFFER SHADER_STORAGE_BUFFER}{@link ARBIndirectParameters#GL_PARAMETER_BUFFER_ARB PARAMETER_BUFFER_ARB}
+ * @param offset the offset into the buffer object's data store where data replacement will begin, measured in bytes + * @param data a pointer to the new data that will be copied into the data store + * + * @see Reference Page + */ + public static void glBufferSubData(@NativeType("GLenum") int target, @NativeType("GLintptr") long offset, @NativeType("void const *") ByteBuffer data) { + GL15C.glBufferSubData(target, offset, data); + } + + /** + * Updates a subset of a buffer object's data store. + * + * @param target the target buffer object. One of:
{@link GL15C#GL_ARRAY_BUFFER ARRAY_BUFFER}{@link GL15C#GL_ELEMENT_ARRAY_BUFFER ELEMENT_ARRAY_BUFFER}{@link GL21#GL_PIXEL_PACK_BUFFER PIXEL_PACK_BUFFER}{@link GL21#GL_PIXEL_UNPACK_BUFFER PIXEL_UNPACK_BUFFER}
{@link GL30#GL_TRANSFORM_FEEDBACK_BUFFER TRANSFORM_FEEDBACK_BUFFER}{@link GL31#GL_UNIFORM_BUFFER UNIFORM_BUFFER}{@link GL31#GL_TEXTURE_BUFFER TEXTURE_BUFFER}{@link GL31#GL_COPY_READ_BUFFER COPY_READ_BUFFER}
{@link GL31#GL_COPY_WRITE_BUFFER COPY_WRITE_BUFFER}{@link GL40#GL_DRAW_INDIRECT_BUFFER DRAW_INDIRECT_BUFFER}{@link GL42#GL_ATOMIC_COUNTER_BUFFER ATOMIC_COUNTER_BUFFER}{@link GL43#GL_DISPATCH_INDIRECT_BUFFER DISPATCH_INDIRECT_BUFFER}
{@link GL43#GL_SHADER_STORAGE_BUFFER SHADER_STORAGE_BUFFER}{@link ARBIndirectParameters#GL_PARAMETER_BUFFER_ARB PARAMETER_BUFFER_ARB}
+ * @param offset the offset into the buffer object's data store where data replacement will begin, measured in bytes + * @param data a pointer to the new data that will be copied into the data store + * + * @see Reference Page + */ + public static void glBufferSubData(@NativeType("GLenum") int target, @NativeType("GLintptr") long offset, @NativeType("void const *") ShortBuffer data) { + GL15C.glBufferSubData(target, offset, data); + } + + /** + * Updates a subset of a buffer object's data store. + * + * @param target the target buffer object. One of:
{@link GL15C#GL_ARRAY_BUFFER ARRAY_BUFFER}{@link GL15C#GL_ELEMENT_ARRAY_BUFFER ELEMENT_ARRAY_BUFFER}{@link GL21#GL_PIXEL_PACK_BUFFER PIXEL_PACK_BUFFER}{@link GL21#GL_PIXEL_UNPACK_BUFFER PIXEL_UNPACK_BUFFER}
{@link GL30#GL_TRANSFORM_FEEDBACK_BUFFER TRANSFORM_FEEDBACK_BUFFER}{@link GL31#GL_UNIFORM_BUFFER UNIFORM_BUFFER}{@link GL31#GL_TEXTURE_BUFFER TEXTURE_BUFFER}{@link GL31#GL_COPY_READ_BUFFER COPY_READ_BUFFER}
{@link GL31#GL_COPY_WRITE_BUFFER COPY_WRITE_BUFFER}{@link GL40#GL_DRAW_INDIRECT_BUFFER DRAW_INDIRECT_BUFFER}{@link GL42#GL_ATOMIC_COUNTER_BUFFER ATOMIC_COUNTER_BUFFER}{@link GL43#GL_DISPATCH_INDIRECT_BUFFER DISPATCH_INDIRECT_BUFFER}
{@link GL43#GL_SHADER_STORAGE_BUFFER SHADER_STORAGE_BUFFER}{@link ARBIndirectParameters#GL_PARAMETER_BUFFER_ARB PARAMETER_BUFFER_ARB}
+ * @param offset the offset into the buffer object's data store where data replacement will begin, measured in bytes + * @param data a pointer to the new data that will be copied into the data store + * + * @see Reference Page + */ + public static void glBufferSubData(@NativeType("GLenum") int target, @NativeType("GLintptr") long offset, @NativeType("void const *") IntBuffer data) { + GL15C.glBufferSubData(target, offset, data); + } + + /** + * Updates a subset of a buffer object's data store. + * + * @param target the target buffer object. One of:
{@link GL15C#GL_ARRAY_BUFFER ARRAY_BUFFER}{@link GL15C#GL_ELEMENT_ARRAY_BUFFER ELEMENT_ARRAY_BUFFER}{@link GL21#GL_PIXEL_PACK_BUFFER PIXEL_PACK_BUFFER}{@link GL21#GL_PIXEL_UNPACK_BUFFER PIXEL_UNPACK_BUFFER}
{@link GL30#GL_TRANSFORM_FEEDBACK_BUFFER TRANSFORM_FEEDBACK_BUFFER}{@link GL31#GL_UNIFORM_BUFFER UNIFORM_BUFFER}{@link GL31#GL_TEXTURE_BUFFER TEXTURE_BUFFER}{@link GL31#GL_COPY_READ_BUFFER COPY_READ_BUFFER}
{@link GL31#GL_COPY_WRITE_BUFFER COPY_WRITE_BUFFER}{@link GL40#GL_DRAW_INDIRECT_BUFFER DRAW_INDIRECT_BUFFER}{@link GL42#GL_ATOMIC_COUNTER_BUFFER ATOMIC_COUNTER_BUFFER}{@link GL43#GL_DISPATCH_INDIRECT_BUFFER DISPATCH_INDIRECT_BUFFER}
{@link GL43#GL_SHADER_STORAGE_BUFFER SHADER_STORAGE_BUFFER}{@link ARBIndirectParameters#GL_PARAMETER_BUFFER_ARB PARAMETER_BUFFER_ARB}
+ * @param offset the offset into the buffer object's data store where data replacement will begin, measured in bytes + * @param data a pointer to the new data that will be copied into the data store + * + * @see Reference Page + */ + public static void glBufferSubData(@NativeType("GLenum") int target, @NativeType("GLintptr") long offset, @NativeType("void const *") LongBuffer data) { + GL15C.glBufferSubData(target, offset, data); + } + + /** + * Updates a subset of a buffer object's data store. + * + * @param target the target buffer object. One of:
{@link GL15C#GL_ARRAY_BUFFER ARRAY_BUFFER}{@link GL15C#GL_ELEMENT_ARRAY_BUFFER ELEMENT_ARRAY_BUFFER}{@link GL21#GL_PIXEL_PACK_BUFFER PIXEL_PACK_BUFFER}{@link GL21#GL_PIXEL_UNPACK_BUFFER PIXEL_UNPACK_BUFFER}
{@link GL30#GL_TRANSFORM_FEEDBACK_BUFFER TRANSFORM_FEEDBACK_BUFFER}{@link GL31#GL_UNIFORM_BUFFER UNIFORM_BUFFER}{@link GL31#GL_TEXTURE_BUFFER TEXTURE_BUFFER}{@link GL31#GL_COPY_READ_BUFFER COPY_READ_BUFFER}
{@link GL31#GL_COPY_WRITE_BUFFER COPY_WRITE_BUFFER}{@link GL40#GL_DRAW_INDIRECT_BUFFER DRAW_INDIRECT_BUFFER}{@link GL42#GL_ATOMIC_COUNTER_BUFFER ATOMIC_COUNTER_BUFFER}{@link GL43#GL_DISPATCH_INDIRECT_BUFFER DISPATCH_INDIRECT_BUFFER}
{@link GL43#GL_SHADER_STORAGE_BUFFER SHADER_STORAGE_BUFFER}{@link ARBIndirectParameters#GL_PARAMETER_BUFFER_ARB PARAMETER_BUFFER_ARB}
+ * @param offset the offset into the buffer object's data store where data replacement will begin, measured in bytes + * @param data a pointer to the new data that will be copied into the data store + * + * @see Reference Page + */ + public static void glBufferSubData(@NativeType("GLenum") int target, @NativeType("GLintptr") long offset, @NativeType("void const *") FloatBuffer data) { + GL15C.glBufferSubData(target, offset, data); + } + + /** + * Updates a subset of a buffer object's data store. + * + * @param target the target buffer object. One of:
{@link GL15C#GL_ARRAY_BUFFER ARRAY_BUFFER}{@link GL15C#GL_ELEMENT_ARRAY_BUFFER ELEMENT_ARRAY_BUFFER}{@link GL21#GL_PIXEL_PACK_BUFFER PIXEL_PACK_BUFFER}{@link GL21#GL_PIXEL_UNPACK_BUFFER PIXEL_UNPACK_BUFFER}
{@link GL30#GL_TRANSFORM_FEEDBACK_BUFFER TRANSFORM_FEEDBACK_BUFFER}{@link GL31#GL_UNIFORM_BUFFER UNIFORM_BUFFER}{@link GL31#GL_TEXTURE_BUFFER TEXTURE_BUFFER}{@link GL31#GL_COPY_READ_BUFFER COPY_READ_BUFFER}
{@link GL31#GL_COPY_WRITE_BUFFER COPY_WRITE_BUFFER}{@link GL40#GL_DRAW_INDIRECT_BUFFER DRAW_INDIRECT_BUFFER}{@link GL42#GL_ATOMIC_COUNTER_BUFFER ATOMIC_COUNTER_BUFFER}{@link GL43#GL_DISPATCH_INDIRECT_BUFFER DISPATCH_INDIRECT_BUFFER}
{@link GL43#GL_SHADER_STORAGE_BUFFER SHADER_STORAGE_BUFFER}{@link ARBIndirectParameters#GL_PARAMETER_BUFFER_ARB PARAMETER_BUFFER_ARB}
+ * @param offset the offset into the buffer object's data store where data replacement will begin, measured in bytes + * @param data a pointer to the new data that will be copied into the data store + * + * @see Reference Page + */ + public static void glBufferSubData(@NativeType("GLenum") int target, @NativeType("GLintptr") long offset, @NativeType("void const *") DoubleBuffer data) { + GL15C.glBufferSubData(target, offset, data); + } + + // --- [ glGetBufferSubData ] --- + + /** + * Unsafe version of: {@link #glGetBufferSubData GetBufferSubData} + * + * @param size the size in bytes of the data store region being returned + */ + public static void nglGetBufferSubData(int target, long offset, long size, long data) { + GL15C.nglGetBufferSubData(target, offset, size, data); + } + + /** + * Returns a subset of a buffer object's data store. + * + * @param target the target buffer object. One of:
{@link GL15C#GL_ARRAY_BUFFER ARRAY_BUFFER}{@link GL15C#GL_ELEMENT_ARRAY_BUFFER ELEMENT_ARRAY_BUFFER}{@link GL21#GL_PIXEL_PACK_BUFFER PIXEL_PACK_BUFFER}{@link GL21#GL_PIXEL_UNPACK_BUFFER PIXEL_UNPACK_BUFFER}
{@link GL30#GL_TRANSFORM_FEEDBACK_BUFFER TRANSFORM_FEEDBACK_BUFFER}{@link GL31#GL_UNIFORM_BUFFER UNIFORM_BUFFER}{@link GL31#GL_TEXTURE_BUFFER TEXTURE_BUFFER}{@link GL31#GL_COPY_READ_BUFFER COPY_READ_BUFFER}
{@link GL31#GL_COPY_WRITE_BUFFER COPY_WRITE_BUFFER}{@link GL40#GL_DRAW_INDIRECT_BUFFER DRAW_INDIRECT_BUFFER}{@link GL42#GL_ATOMIC_COUNTER_BUFFER ATOMIC_COUNTER_BUFFER}{@link GL43#GL_DISPATCH_INDIRECT_BUFFER DISPATCH_INDIRECT_BUFFER}
{@link GL43#GL_SHADER_STORAGE_BUFFER SHADER_STORAGE_BUFFER}{@link ARBIndirectParameters#GL_PARAMETER_BUFFER_ARB PARAMETER_BUFFER_ARB}
+ * @param offset the offset into the buffer object's data store from which data will be returned, measured in bytes + * @param data a pointer to the location where buffer object data is returned + * + * @see Reference Page + */ + public static void glGetBufferSubData(@NativeType("GLenum") int target, @NativeType("GLintptr") long offset, @NativeType("void *") ByteBuffer data) { + GL15C.glGetBufferSubData(target, offset, data); + } + + /** + * Returns a subset of a buffer object's data store. + * + * @param target the target buffer object. One of:
{@link GL15C#GL_ARRAY_BUFFER ARRAY_BUFFER}{@link GL15C#GL_ELEMENT_ARRAY_BUFFER ELEMENT_ARRAY_BUFFER}{@link GL21#GL_PIXEL_PACK_BUFFER PIXEL_PACK_BUFFER}{@link GL21#GL_PIXEL_UNPACK_BUFFER PIXEL_UNPACK_BUFFER}
{@link GL30#GL_TRANSFORM_FEEDBACK_BUFFER TRANSFORM_FEEDBACK_BUFFER}{@link GL31#GL_UNIFORM_BUFFER UNIFORM_BUFFER}{@link GL31#GL_TEXTURE_BUFFER TEXTURE_BUFFER}{@link GL31#GL_COPY_READ_BUFFER COPY_READ_BUFFER}
{@link GL31#GL_COPY_WRITE_BUFFER COPY_WRITE_BUFFER}{@link GL40#GL_DRAW_INDIRECT_BUFFER DRAW_INDIRECT_BUFFER}{@link GL42#GL_ATOMIC_COUNTER_BUFFER ATOMIC_COUNTER_BUFFER}{@link GL43#GL_DISPATCH_INDIRECT_BUFFER DISPATCH_INDIRECT_BUFFER}
{@link GL43#GL_SHADER_STORAGE_BUFFER SHADER_STORAGE_BUFFER}{@link ARBIndirectParameters#GL_PARAMETER_BUFFER_ARB PARAMETER_BUFFER_ARB}
+ * @param offset the offset into the buffer object's data store from which data will be returned, measured in bytes + * @param data a pointer to the location where buffer object data is returned + * + * @see Reference Page + */ + public static void glGetBufferSubData(@NativeType("GLenum") int target, @NativeType("GLintptr") long offset, @NativeType("void *") ShortBuffer data) { + GL15C.glGetBufferSubData(target, offset, data); + } + + /** + * Returns a subset of a buffer object's data store. + * + * @param target the target buffer object. One of:
{@link GL15C#GL_ARRAY_BUFFER ARRAY_BUFFER}{@link GL15C#GL_ELEMENT_ARRAY_BUFFER ELEMENT_ARRAY_BUFFER}{@link GL21#GL_PIXEL_PACK_BUFFER PIXEL_PACK_BUFFER}{@link GL21#GL_PIXEL_UNPACK_BUFFER PIXEL_UNPACK_BUFFER}
{@link GL30#GL_TRANSFORM_FEEDBACK_BUFFER TRANSFORM_FEEDBACK_BUFFER}{@link GL31#GL_UNIFORM_BUFFER UNIFORM_BUFFER}{@link GL31#GL_TEXTURE_BUFFER TEXTURE_BUFFER}{@link GL31#GL_COPY_READ_BUFFER COPY_READ_BUFFER}
{@link GL31#GL_COPY_WRITE_BUFFER COPY_WRITE_BUFFER}{@link GL40#GL_DRAW_INDIRECT_BUFFER DRAW_INDIRECT_BUFFER}{@link GL42#GL_ATOMIC_COUNTER_BUFFER ATOMIC_COUNTER_BUFFER}{@link GL43#GL_DISPATCH_INDIRECT_BUFFER DISPATCH_INDIRECT_BUFFER}
{@link GL43#GL_SHADER_STORAGE_BUFFER SHADER_STORAGE_BUFFER}{@link ARBIndirectParameters#GL_PARAMETER_BUFFER_ARB PARAMETER_BUFFER_ARB}
+ * @param offset the offset into the buffer object's data store from which data will be returned, measured in bytes + * @param data a pointer to the location where buffer object data is returned + * + * @see Reference Page + */ + public static void glGetBufferSubData(@NativeType("GLenum") int target, @NativeType("GLintptr") long offset, @NativeType("void *") IntBuffer data) { + GL15C.glGetBufferSubData(target, offset, data); + } + + /** + * Returns a subset of a buffer object's data store. + * + * @param target the target buffer object. One of:
{@link GL15C#GL_ARRAY_BUFFER ARRAY_BUFFER}{@link GL15C#GL_ELEMENT_ARRAY_BUFFER ELEMENT_ARRAY_BUFFER}{@link GL21#GL_PIXEL_PACK_BUFFER PIXEL_PACK_BUFFER}{@link GL21#GL_PIXEL_UNPACK_BUFFER PIXEL_UNPACK_BUFFER}
{@link GL30#GL_TRANSFORM_FEEDBACK_BUFFER TRANSFORM_FEEDBACK_BUFFER}{@link GL31#GL_UNIFORM_BUFFER UNIFORM_BUFFER}{@link GL31#GL_TEXTURE_BUFFER TEXTURE_BUFFER}{@link GL31#GL_COPY_READ_BUFFER COPY_READ_BUFFER}
{@link GL31#GL_COPY_WRITE_BUFFER COPY_WRITE_BUFFER}{@link GL40#GL_DRAW_INDIRECT_BUFFER DRAW_INDIRECT_BUFFER}{@link GL42#GL_ATOMIC_COUNTER_BUFFER ATOMIC_COUNTER_BUFFER}{@link GL43#GL_DISPATCH_INDIRECT_BUFFER DISPATCH_INDIRECT_BUFFER}
{@link GL43#GL_SHADER_STORAGE_BUFFER SHADER_STORAGE_BUFFER}{@link ARBIndirectParameters#GL_PARAMETER_BUFFER_ARB PARAMETER_BUFFER_ARB}
+ * @param offset the offset into the buffer object's data store from which data will be returned, measured in bytes + * @param data a pointer to the location where buffer object data is returned + * + * @see Reference Page + */ + public static void glGetBufferSubData(@NativeType("GLenum") int target, @NativeType("GLintptr") long offset, @NativeType("void *") LongBuffer data) { + GL15C.glGetBufferSubData(target, offset, data); + } + + /** + * Returns a subset of a buffer object's data store. + * + * @param target the target buffer object. One of:
{@link GL15C#GL_ARRAY_BUFFER ARRAY_BUFFER}{@link GL15C#GL_ELEMENT_ARRAY_BUFFER ELEMENT_ARRAY_BUFFER}{@link GL21#GL_PIXEL_PACK_BUFFER PIXEL_PACK_BUFFER}{@link GL21#GL_PIXEL_UNPACK_BUFFER PIXEL_UNPACK_BUFFER}
{@link GL30#GL_TRANSFORM_FEEDBACK_BUFFER TRANSFORM_FEEDBACK_BUFFER}{@link GL31#GL_UNIFORM_BUFFER UNIFORM_BUFFER}{@link GL31#GL_TEXTURE_BUFFER TEXTURE_BUFFER}{@link GL31#GL_COPY_READ_BUFFER COPY_READ_BUFFER}
{@link GL31#GL_COPY_WRITE_BUFFER COPY_WRITE_BUFFER}{@link GL40#GL_DRAW_INDIRECT_BUFFER DRAW_INDIRECT_BUFFER}{@link GL42#GL_ATOMIC_COUNTER_BUFFER ATOMIC_COUNTER_BUFFER}{@link GL43#GL_DISPATCH_INDIRECT_BUFFER DISPATCH_INDIRECT_BUFFER}
{@link GL43#GL_SHADER_STORAGE_BUFFER SHADER_STORAGE_BUFFER}{@link ARBIndirectParameters#GL_PARAMETER_BUFFER_ARB PARAMETER_BUFFER_ARB}
+ * @param offset the offset into the buffer object's data store from which data will be returned, measured in bytes + * @param data a pointer to the location where buffer object data is returned + * + * @see Reference Page + */ + public static void glGetBufferSubData(@NativeType("GLenum") int target, @NativeType("GLintptr") long offset, @NativeType("void *") FloatBuffer data) { + GL15C.glGetBufferSubData(target, offset, data); + } + + /** + * Returns a subset of a buffer object's data store. + * + * @param target the target buffer object. One of:
{@link GL15C#GL_ARRAY_BUFFER ARRAY_BUFFER}{@link GL15C#GL_ELEMENT_ARRAY_BUFFER ELEMENT_ARRAY_BUFFER}{@link GL21#GL_PIXEL_PACK_BUFFER PIXEL_PACK_BUFFER}{@link GL21#GL_PIXEL_UNPACK_BUFFER PIXEL_UNPACK_BUFFER}
{@link GL30#GL_TRANSFORM_FEEDBACK_BUFFER TRANSFORM_FEEDBACK_BUFFER}{@link GL31#GL_UNIFORM_BUFFER UNIFORM_BUFFER}{@link GL31#GL_TEXTURE_BUFFER TEXTURE_BUFFER}{@link GL31#GL_COPY_READ_BUFFER COPY_READ_BUFFER}
{@link GL31#GL_COPY_WRITE_BUFFER COPY_WRITE_BUFFER}{@link GL40#GL_DRAW_INDIRECT_BUFFER DRAW_INDIRECT_BUFFER}{@link GL42#GL_ATOMIC_COUNTER_BUFFER ATOMIC_COUNTER_BUFFER}{@link GL43#GL_DISPATCH_INDIRECT_BUFFER DISPATCH_INDIRECT_BUFFER}
{@link GL43#GL_SHADER_STORAGE_BUFFER SHADER_STORAGE_BUFFER}{@link ARBIndirectParameters#GL_PARAMETER_BUFFER_ARB PARAMETER_BUFFER_ARB}
+ * @param offset the offset into the buffer object's data store from which data will be returned, measured in bytes + * @param data a pointer to the location where buffer object data is returned + * + * @see Reference Page + */ + public static void glGetBufferSubData(@NativeType("GLenum") int target, @NativeType("GLintptr") long offset, @NativeType("void *") DoubleBuffer data) { + GL15C.glGetBufferSubData(target, offset, data); + } + + // --- [ glMapBuffer ] --- + + /** Unsafe version of: {@link #glMapBuffer MapBuffer} */ + public static long nglMapBuffer(int target, int access) { + return GL15C.nglMapBuffer(target, access); + } + + /** + * Maps a buffer object's data store. + * + *

LWJGL note: This method comes in 3 flavors:

+ * + *
    + *
  1. {@link #glMapBuffer(int, int)} - Calls {@link #glGetBufferParameteriv GetBufferParameteriv} to retrieve the buffer size and a new ByteBuffer instance is always returned.
  2. + *
  3. {@link #glMapBuffer(int, int, ByteBuffer)} - Calls {@link #glGetBufferParameteriv GetBufferParameteriv} to retrieve the buffer size and the {@code old_buffer} parameter is reused if not null.
  4. + *
  5. {@link #glMapBuffer(int, int, long, ByteBuffer)} - The buffer size is explicitly specified and the {@code old_buffer} parameter is reused if not null. This is the most efficient method.
  6. + *
+ * + * @param target the target buffer object being mapped. One of:
{@link GL15C#GL_ARRAY_BUFFER ARRAY_BUFFER}{@link GL15C#GL_ELEMENT_ARRAY_BUFFER ELEMENT_ARRAY_BUFFER}{@link GL21#GL_PIXEL_PACK_BUFFER PIXEL_PACK_BUFFER}{@link GL21#GL_PIXEL_UNPACK_BUFFER PIXEL_UNPACK_BUFFER}
{@link GL30#GL_TRANSFORM_FEEDBACK_BUFFER TRANSFORM_FEEDBACK_BUFFER}{@link GL31#GL_UNIFORM_BUFFER UNIFORM_BUFFER}{@link GL31#GL_TEXTURE_BUFFER TEXTURE_BUFFER}{@link GL31#GL_COPY_READ_BUFFER COPY_READ_BUFFER}
{@link GL31#GL_COPY_WRITE_BUFFER COPY_WRITE_BUFFER}{@link GL40#GL_DRAW_INDIRECT_BUFFER DRAW_INDIRECT_BUFFER}{@link GL42#GL_ATOMIC_COUNTER_BUFFER ATOMIC_COUNTER_BUFFER}{@link GL43#GL_DISPATCH_INDIRECT_BUFFER DISPATCH_INDIRECT_BUFFER}
{@link GL43#GL_SHADER_STORAGE_BUFFER SHADER_STORAGE_BUFFER}{@link ARBIndirectParameters#GL_PARAMETER_BUFFER_ARB PARAMETER_BUFFER_ARB}
+ * @param access the access policy, indicating whether it will be possible to read from, write to, or both read from and write to the buffer object's mapped data store. One of:
{@link GL15C#GL_READ_ONLY READ_ONLY}{@link GL15C#GL_WRITE_ONLY WRITE_ONLY}{@link GL15C#GL_READ_WRITE READ_WRITE}
+ * + * @see Reference Page + */ + @Nullable + @NativeType("void *") + public static ByteBuffer glMapBuffer(@NativeType("GLenum") int target, @NativeType("GLenum") int access) { + return GL15C.glMapBuffer(target, access); + } + + /** + * Maps a buffer object's data store. + * + *

LWJGL note: This method comes in 3 flavors:

+ * + *
    + *
  1. {@link #glMapBuffer(int, int)} - Calls {@link #glGetBufferParameteriv GetBufferParameteriv} to retrieve the buffer size and a new ByteBuffer instance is always returned.
  2. + *
  3. {@link #glMapBuffer(int, int, ByteBuffer)} - Calls {@link #glGetBufferParameteriv GetBufferParameteriv} to retrieve the buffer size and the {@code old_buffer} parameter is reused if not null.
  4. + *
  5. {@link #glMapBuffer(int, int, long, ByteBuffer)} - The buffer size is explicitly specified and the {@code old_buffer} parameter is reused if not null. This is the most efficient method.
  6. + *
+ * + * @param target the target buffer object being mapped. One of:
{@link GL15C#GL_ARRAY_BUFFER ARRAY_BUFFER}{@link GL15C#GL_ELEMENT_ARRAY_BUFFER ELEMENT_ARRAY_BUFFER}{@link GL21#GL_PIXEL_PACK_BUFFER PIXEL_PACK_BUFFER}{@link GL21#GL_PIXEL_UNPACK_BUFFER PIXEL_UNPACK_BUFFER}
{@link GL30#GL_TRANSFORM_FEEDBACK_BUFFER TRANSFORM_FEEDBACK_BUFFER}{@link GL31#GL_UNIFORM_BUFFER UNIFORM_BUFFER}{@link GL31#GL_TEXTURE_BUFFER TEXTURE_BUFFER}{@link GL31#GL_COPY_READ_BUFFER COPY_READ_BUFFER}
{@link GL31#GL_COPY_WRITE_BUFFER COPY_WRITE_BUFFER}{@link GL40#GL_DRAW_INDIRECT_BUFFER DRAW_INDIRECT_BUFFER}{@link GL42#GL_ATOMIC_COUNTER_BUFFER ATOMIC_COUNTER_BUFFER}{@link GL43#GL_DISPATCH_INDIRECT_BUFFER DISPATCH_INDIRECT_BUFFER}
{@link GL43#GL_SHADER_STORAGE_BUFFER SHADER_STORAGE_BUFFER}{@link ARBIndirectParameters#GL_PARAMETER_BUFFER_ARB PARAMETER_BUFFER_ARB}
+ * @param access the access policy, indicating whether it will be possible to read from, write to, or both read from and write to the buffer object's mapped data store. One of:
{@link GL15C#GL_READ_ONLY READ_ONLY}{@link GL15C#GL_WRITE_ONLY WRITE_ONLY}{@link GL15C#GL_READ_WRITE READ_WRITE}
+ * + * @see Reference Page + */ + @Nullable + @NativeType("void *") + public static ByteBuffer glMapBuffer(@NativeType("GLenum") int target, @NativeType("GLenum") int access, @Nullable ByteBuffer old_buffer) { + return GL15C.glMapBuffer(target, access, old_buffer); + } + + /** + * Maps a buffer object's data store. + * + *

LWJGL note: This method comes in 3 flavors:

+ * + *
    + *
  1. {@link #glMapBuffer(int, int)} - Calls {@link #glGetBufferParameteriv GetBufferParameteriv} to retrieve the buffer size and a new ByteBuffer instance is always returned.
  2. + *
  3. {@link #glMapBuffer(int, int, ByteBuffer)} - Calls {@link #glGetBufferParameteriv GetBufferParameteriv} to retrieve the buffer size and the {@code old_buffer} parameter is reused if not null.
  4. + *
  5. {@link #glMapBuffer(int, int, long, ByteBuffer)} - The buffer size is explicitly specified and the {@code old_buffer} parameter is reused if not null. This is the most efficient method.
  6. + *
+ * + * @param target the target buffer object being mapped. One of:
{@link GL15C#GL_ARRAY_BUFFER ARRAY_BUFFER}{@link GL15C#GL_ELEMENT_ARRAY_BUFFER ELEMENT_ARRAY_BUFFER}{@link GL21#GL_PIXEL_PACK_BUFFER PIXEL_PACK_BUFFER}{@link GL21#GL_PIXEL_UNPACK_BUFFER PIXEL_UNPACK_BUFFER}
{@link GL30#GL_TRANSFORM_FEEDBACK_BUFFER TRANSFORM_FEEDBACK_BUFFER}{@link GL31#GL_UNIFORM_BUFFER UNIFORM_BUFFER}{@link GL31#GL_TEXTURE_BUFFER TEXTURE_BUFFER}{@link GL31#GL_COPY_READ_BUFFER COPY_READ_BUFFER}
{@link GL31#GL_COPY_WRITE_BUFFER COPY_WRITE_BUFFER}{@link GL40#GL_DRAW_INDIRECT_BUFFER DRAW_INDIRECT_BUFFER}{@link GL42#GL_ATOMIC_COUNTER_BUFFER ATOMIC_COUNTER_BUFFER}{@link GL43#GL_DISPATCH_INDIRECT_BUFFER DISPATCH_INDIRECT_BUFFER}
{@link GL43#GL_SHADER_STORAGE_BUFFER SHADER_STORAGE_BUFFER}{@link ARBIndirectParameters#GL_PARAMETER_BUFFER_ARB PARAMETER_BUFFER_ARB}
+ * @param access the access policy, indicating whether it will be possible to read from, write to, or both read from and write to the buffer object's mapped data store. One of:
{@link GL15C#GL_READ_ONLY READ_ONLY}{@link GL15C#GL_WRITE_ONLY WRITE_ONLY}{@link GL15C#GL_READ_WRITE READ_WRITE}
+ * + * @see Reference Page + */ + @Nullable + @NativeType("void *") + public static ByteBuffer glMapBuffer(@NativeType("GLenum") int target, @NativeType("GLenum") int access, long length, @Nullable ByteBuffer old_buffer) { + return GL15C.glMapBuffer(target, access, length, old_buffer); + } + + // --- [ glUnmapBuffer ] --- + + /** + * Relinquishes the mapping of a buffer object and invalidates the pointer to its data store. + * + *

Returns TRUE unless data values in the buffer’s data store have become corrupted during the period that the buffer was mapped. Such corruption can be + * the result of a screen resolution change or other window system-dependent event that causes system heaps such as those for high-performance graphics + * memory to be discarded. GL implementations must guarantee that such corruption can occur only during the periods that a buffer’s data store is mapped. + * If such corruption has occurred, UnmapBuffer returns FALSE, and the contents of the buffer’s data store become undefined.

+ * + * @param target the target buffer object being unmapped. One of:
{@link GL15C#GL_ARRAY_BUFFER ARRAY_BUFFER}{@link GL15C#GL_ELEMENT_ARRAY_BUFFER ELEMENT_ARRAY_BUFFER}{@link GL21#GL_PIXEL_PACK_BUFFER PIXEL_PACK_BUFFER}{@link GL21#GL_PIXEL_UNPACK_BUFFER PIXEL_UNPACK_BUFFER}
{@link GL30#GL_TRANSFORM_FEEDBACK_BUFFER TRANSFORM_FEEDBACK_BUFFER}{@link GL31#GL_UNIFORM_BUFFER UNIFORM_BUFFER}{@link GL31#GL_TEXTURE_BUFFER TEXTURE_BUFFER}{@link GL31#GL_COPY_READ_BUFFER COPY_READ_BUFFER}
{@link GL31#GL_COPY_WRITE_BUFFER COPY_WRITE_BUFFER}{@link GL40#GL_DRAW_INDIRECT_BUFFER DRAW_INDIRECT_BUFFER}{@link GL42#GL_ATOMIC_COUNTER_BUFFER ATOMIC_COUNTER_BUFFER}{@link GL43#GL_DISPATCH_INDIRECT_BUFFER DISPATCH_INDIRECT_BUFFER}
{@link GL43#GL_SHADER_STORAGE_BUFFER SHADER_STORAGE_BUFFER}{@link ARBIndirectParameters#GL_PARAMETER_BUFFER_ARB PARAMETER_BUFFER_ARB}
+ * + * @see Reference Page + */ + @NativeType("GLboolean") + public static boolean glUnmapBuffer(@NativeType("GLenum") int target) { + return GL15C.glUnmapBuffer(target); + } + + // --- [ glGetBufferParameteriv ] --- + + /** Unsafe version of: {@link #glGetBufferParameteriv GetBufferParameteriv} */ + public static void nglGetBufferParameteriv(int target, int pname, long params) { + GL15C.nglGetBufferParameteriv(target, pname, params); + } + + /** + * Returns the value of a buffer object parameter. + * + * @param target the target buffer object. One of:
{@link GL15C#GL_ARRAY_BUFFER ARRAY_BUFFER}{@link GL15C#GL_ELEMENT_ARRAY_BUFFER ELEMENT_ARRAY_BUFFER}{@link GL21#GL_PIXEL_PACK_BUFFER PIXEL_PACK_BUFFER}{@link GL21#GL_PIXEL_UNPACK_BUFFER PIXEL_UNPACK_BUFFER}
{@link GL30#GL_TRANSFORM_FEEDBACK_BUFFER TRANSFORM_FEEDBACK_BUFFER}{@link GL31#GL_UNIFORM_BUFFER UNIFORM_BUFFER}{@link GL31#GL_TEXTURE_BUFFER TEXTURE_BUFFER}{@link GL31#GL_COPY_READ_BUFFER COPY_READ_BUFFER}
{@link GL31#GL_COPY_WRITE_BUFFER COPY_WRITE_BUFFER}{@link GL40#GL_DRAW_INDIRECT_BUFFER DRAW_INDIRECT_BUFFER}{@link GL42#GL_ATOMIC_COUNTER_BUFFER ATOMIC_COUNTER_BUFFER}{@link GL43#GL_DISPATCH_INDIRECT_BUFFER DISPATCH_INDIRECT_BUFFER}
{@link GL43#GL_SHADER_STORAGE_BUFFER SHADER_STORAGE_BUFFER}{@link ARBIndirectParameters#GL_PARAMETER_BUFFER_ARB PARAMETER_BUFFER_ARB}
+ * @param pname the symbolic name of a buffer object parameter. One of:
{@link GL15#GL_BUFFER_SIZE BUFFER_SIZE}{@link GL15C#GL_BUFFER_USAGE BUFFER_USAGE}{@link GL15C#GL_BUFFER_ACCESS BUFFER_ACCESS}{@link GL15C#GL_BUFFER_MAPPED BUFFER_MAPPED}
{@link GL30#GL_BUFFER_ACCESS_FLAGS BUFFER_ACCESS_FLAGS}{@link GL30#GL_BUFFER_MAP_LENGTH BUFFER_MAP_LENGTH}{@link GL30#GL_BUFFER_MAP_OFFSET BUFFER_MAP_OFFSET}{@link GL44#GL_BUFFER_IMMUTABLE_STORAGE BUFFER_IMMUTABLE_STORAGE}
{@link GL44#GL_BUFFER_STORAGE_FLAGS BUFFER_STORAGE_FLAGS}
+ * @param params the requested parameter + * + * @see Reference Page + */ + public static void glGetBufferParameteriv(@NativeType("GLenum") int target, @NativeType("GLenum") int pname, @NativeType("GLint *") IntBuffer params) { + GL15C.glGetBufferParameteriv(target, pname, params); + } + + /** + * Returns the value of a buffer object parameter. + * + * @param target the target buffer object. One of:
{@link GL15C#GL_ARRAY_BUFFER ARRAY_BUFFER}{@link GL15C#GL_ELEMENT_ARRAY_BUFFER ELEMENT_ARRAY_BUFFER}{@link GL21#GL_PIXEL_PACK_BUFFER PIXEL_PACK_BUFFER}{@link GL21#GL_PIXEL_UNPACK_BUFFER PIXEL_UNPACK_BUFFER}
{@link GL30#GL_TRANSFORM_FEEDBACK_BUFFER TRANSFORM_FEEDBACK_BUFFER}{@link GL31#GL_UNIFORM_BUFFER UNIFORM_BUFFER}{@link GL31#GL_TEXTURE_BUFFER TEXTURE_BUFFER}{@link GL31#GL_COPY_READ_BUFFER COPY_READ_BUFFER}
{@link GL31#GL_COPY_WRITE_BUFFER COPY_WRITE_BUFFER}{@link GL40#GL_DRAW_INDIRECT_BUFFER DRAW_INDIRECT_BUFFER}{@link GL42#GL_ATOMIC_COUNTER_BUFFER ATOMIC_COUNTER_BUFFER}{@link GL43#GL_DISPATCH_INDIRECT_BUFFER DISPATCH_INDIRECT_BUFFER}
{@link GL43#GL_SHADER_STORAGE_BUFFER SHADER_STORAGE_BUFFER}{@link ARBIndirectParameters#GL_PARAMETER_BUFFER_ARB PARAMETER_BUFFER_ARB}
+ * @param pname the symbolic name of a buffer object parameter. One of:
{@link GL15#GL_BUFFER_SIZE BUFFER_SIZE}{@link GL15C#GL_BUFFER_USAGE BUFFER_USAGE}{@link GL15C#GL_BUFFER_ACCESS BUFFER_ACCESS}{@link GL15C#GL_BUFFER_MAPPED BUFFER_MAPPED}
{@link GL30#GL_BUFFER_ACCESS_FLAGS BUFFER_ACCESS_FLAGS}{@link GL30#GL_BUFFER_MAP_LENGTH BUFFER_MAP_LENGTH}{@link GL30#GL_BUFFER_MAP_OFFSET BUFFER_MAP_OFFSET}{@link GL44#GL_BUFFER_IMMUTABLE_STORAGE BUFFER_IMMUTABLE_STORAGE}
{@link GL44#GL_BUFFER_STORAGE_FLAGS BUFFER_STORAGE_FLAGS}
+ * + * @see Reference Page + */ + @NativeType("void") + public static int glGetBufferParameteri(@NativeType("GLenum") int target, @NativeType("GLenum") int pname) { + return GL15C.glGetBufferParameteri(target, pname); + } + + // --- [ glGetBufferPointerv ] --- + + /** Unsafe version of: {@link #glGetBufferPointerv GetBufferPointerv} */ + public static void nglGetBufferPointerv(int target, int pname, long params) { + GL15C.nglGetBufferPointerv(target, pname, params); + } + + /** + * Returns the pointer to a mapped buffer object's data store. + * + * @param target the target buffer object. One of:
{@link GL15C#GL_ARRAY_BUFFER ARRAY_BUFFER}{@link GL15C#GL_ELEMENT_ARRAY_BUFFER ELEMENT_ARRAY_BUFFER}{@link GL21#GL_PIXEL_PACK_BUFFER PIXEL_PACK_BUFFER}{@link GL21#GL_PIXEL_UNPACK_BUFFER PIXEL_UNPACK_BUFFER}
{@link GL30#GL_TRANSFORM_FEEDBACK_BUFFER TRANSFORM_FEEDBACK_BUFFER}{@link GL31#GL_UNIFORM_BUFFER UNIFORM_BUFFER}{@link GL31#GL_TEXTURE_BUFFER TEXTURE_BUFFER}{@link GL31#GL_COPY_READ_BUFFER COPY_READ_BUFFER}
{@link GL31#GL_COPY_WRITE_BUFFER COPY_WRITE_BUFFER}{@link GL40#GL_DRAW_INDIRECT_BUFFER DRAW_INDIRECT_BUFFER}{@link GL42#GL_ATOMIC_COUNTER_BUFFER ATOMIC_COUNTER_BUFFER}{@link GL43#GL_DISPATCH_INDIRECT_BUFFER DISPATCH_INDIRECT_BUFFER}
{@link GL43#GL_SHADER_STORAGE_BUFFER SHADER_STORAGE_BUFFER}{@link ARBIndirectParameters#GL_PARAMETER_BUFFER_ARB PARAMETER_BUFFER_ARB}
+ * @param pname the pointer to be returned. Must be:
{@link GL15C#GL_BUFFER_MAP_POINTER BUFFER_MAP_POINTER}
+ * @param params the pointer value specified by {@code pname} + * + * @see Reference Page + */ + public static void glGetBufferPointerv(@NativeType("GLenum") int target, @NativeType("GLenum") int pname, @NativeType("void **") PointerBuffer params) { + GL15C.glGetBufferPointerv(target, pname, params); + } + + /** + * Returns the pointer to a mapped buffer object's data store. + * + * @param target the target buffer object. One of:
{@link GL15C#GL_ARRAY_BUFFER ARRAY_BUFFER}{@link GL15C#GL_ELEMENT_ARRAY_BUFFER ELEMENT_ARRAY_BUFFER}{@link GL21#GL_PIXEL_PACK_BUFFER PIXEL_PACK_BUFFER}{@link GL21#GL_PIXEL_UNPACK_BUFFER PIXEL_UNPACK_BUFFER}
{@link GL30#GL_TRANSFORM_FEEDBACK_BUFFER TRANSFORM_FEEDBACK_BUFFER}{@link GL31#GL_UNIFORM_BUFFER UNIFORM_BUFFER}{@link GL31#GL_TEXTURE_BUFFER TEXTURE_BUFFER}{@link GL31#GL_COPY_READ_BUFFER COPY_READ_BUFFER}
{@link GL31#GL_COPY_WRITE_BUFFER COPY_WRITE_BUFFER}{@link GL40#GL_DRAW_INDIRECT_BUFFER DRAW_INDIRECT_BUFFER}{@link GL42#GL_ATOMIC_COUNTER_BUFFER ATOMIC_COUNTER_BUFFER}{@link GL43#GL_DISPATCH_INDIRECT_BUFFER DISPATCH_INDIRECT_BUFFER}
{@link GL43#GL_SHADER_STORAGE_BUFFER SHADER_STORAGE_BUFFER}{@link ARBIndirectParameters#GL_PARAMETER_BUFFER_ARB PARAMETER_BUFFER_ARB}
+ * @param pname the pointer to be returned. Must be:
{@link GL15C#GL_BUFFER_MAP_POINTER BUFFER_MAP_POINTER}
+ * + * @see Reference Page + */ + @NativeType("void") + public static long glGetBufferPointer(@NativeType("GLenum") int target, @NativeType("GLenum") int pname) { + return GL15C.glGetBufferPointer(target, pname); + } + + // --- [ glGenQueries ] --- + + /** + * Unsafe version of: {@link #glGenQueries GenQueries} + * + * @param n the number of query object names to be generated + */ + public static void nglGenQueries(int n, long ids) { + GL15C.nglGenQueries(n, ids); + } + + /** + * Generates query object names. + * + * @param ids a buffer in which the generated query object names are stored + * + * @see Reference Page + */ + public static void glGenQueries(@NativeType("GLuint *") IntBuffer ids) { + GL15C.glGenQueries(ids); + } + + /** + * Generates query object names. + * + * @see Reference Page + */ + @NativeType("void") + public static int glGenQueries() { + return GL15C.glGenQueries(); + } + + // --- [ glDeleteQueries ] --- + + /** + * Unsafe version of: {@link #glDeleteQueries DeleteQueries} + * + * @param n the number of query objects to be deleted + */ + public static void nglDeleteQueries(int n, long ids) { + GL15C.nglDeleteQueries(n, ids); + } + + /** + * Deletes named query objects. + * + * @param ids an array of query objects to be deleted + * + * @see Reference Page + */ + public static void glDeleteQueries(@NativeType("GLuint const *") IntBuffer ids) { + GL15C.glDeleteQueries(ids); + } + + /** + * Deletes named query objects. + * + * @see Reference Page + */ + public static void glDeleteQueries(@NativeType("GLuint const *") int id) { + GL15C.glDeleteQueries(id); + } + + // --- [ glIsQuery ] --- + + /** + * Determine if a name corresponds to a query object. + * + * @param id a value that may be the name of a query object + * + * @see Reference Page + */ + @NativeType("GLboolean") + public static boolean glIsQuery(@NativeType("GLuint") int id) { + return GL15C.glIsQuery(id); + } + + // --- [ glBeginQuery ] --- + + /** + * Creates a query object and makes it active. + * + * @param target the target type of query object established. One of:
{@link GL15C#GL_SAMPLES_PASSED SAMPLES_PASSED}{@link GL30#GL_PRIMITIVES_GENERATED PRIMITIVES_GENERATED}{@link GL30#GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN}{@link GL33#GL_TIME_ELAPSED TIME_ELAPSED}
{@link GL33#GL_TIMESTAMP TIMESTAMP}{@link GL33#GL_ANY_SAMPLES_PASSED ANY_SAMPLES_PASSED}{@link GL43#GL_ANY_SAMPLES_PASSED_CONSERVATIVE ANY_SAMPLES_PASSED_CONSERVATIVE}
+ * @param id the name of a query object + * + * @see Reference Page + */ + public static void glBeginQuery(@NativeType("GLenum") int target, @NativeType("GLuint") int id) { + GL15C.glBeginQuery(target, id); + } + + // --- [ glEndQuery ] --- + + /** + * Marks the end of the sequence of commands to be tracked for the active query specified by {@code target}. + * + * @param target the query object target. One of:
{@link GL15C#GL_SAMPLES_PASSED SAMPLES_PASSED}{@link GL30#GL_PRIMITIVES_GENERATED PRIMITIVES_GENERATED}{@link GL30#GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN}{@link GL33#GL_TIME_ELAPSED TIME_ELAPSED}
{@link GL33#GL_TIMESTAMP TIMESTAMP}{@link GL33#GL_ANY_SAMPLES_PASSED ANY_SAMPLES_PASSED}{@link GL43#GL_ANY_SAMPLES_PASSED_CONSERVATIVE ANY_SAMPLES_PASSED_CONSERVATIVE}
+ * + * @see Reference Page + */ + public static void glEndQuery(@NativeType("GLenum") int target) { + GL15C.glEndQuery(target); + } + + // --- [ glGetQueryiv ] --- + + /** Unsafe version of: {@link #glGetQueryiv GetQueryiv} */ + public static void nglGetQueryiv(int target, int pname, long params) { + GL15C.nglGetQueryiv(target, pname, params); + } + + /** + * Returns parameters of a query object target. + * + * @param target the query object target. One of:
{@link GL15C#GL_SAMPLES_PASSED SAMPLES_PASSED}{@link GL30#GL_PRIMITIVES_GENERATED PRIMITIVES_GENERATED}{@link GL30#GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN}{@link GL33#GL_TIME_ELAPSED TIME_ELAPSED}
{@link GL33#GL_TIMESTAMP TIMESTAMP}{@link GL33#GL_ANY_SAMPLES_PASSED ANY_SAMPLES_PASSED}{@link GL43#GL_ANY_SAMPLES_PASSED_CONSERVATIVE ANY_SAMPLES_PASSED_CONSERVATIVE}
+ * @param pname the symbolic name of a query object target parameter. One of:
{@link GL15C#GL_QUERY_COUNTER_BITS QUERY_COUNTER_BITS}{@link GL15C#GL_CURRENT_QUERY CURRENT_QUERY}
+ * @param params the requested data + * + * @see Reference Page + */ + public static void glGetQueryiv(@NativeType("GLenum") int target, @NativeType("GLenum") int pname, @NativeType("GLint *") IntBuffer params) { + GL15C.glGetQueryiv(target, pname, params); + } + + /** + * Returns parameters of a query object target. + * + * @param target the query object target. One of:
{@link GL15C#GL_SAMPLES_PASSED SAMPLES_PASSED}{@link GL30#GL_PRIMITIVES_GENERATED PRIMITIVES_GENERATED}{@link GL30#GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN}{@link GL33#GL_TIME_ELAPSED TIME_ELAPSED}
{@link GL33#GL_TIMESTAMP TIMESTAMP}{@link GL33#GL_ANY_SAMPLES_PASSED ANY_SAMPLES_PASSED}{@link GL43#GL_ANY_SAMPLES_PASSED_CONSERVATIVE ANY_SAMPLES_PASSED_CONSERVATIVE}
+ * @param pname the symbolic name of a query object target parameter. One of:
{@link GL15C#GL_QUERY_COUNTER_BITS QUERY_COUNTER_BITS}{@link GL15C#GL_CURRENT_QUERY CURRENT_QUERY}
+ * + * @see Reference Page + */ + @NativeType("void") + public static int glGetQueryi(@NativeType("GLenum") int target, @NativeType("GLenum") int pname) { + return GL15C.glGetQueryi(target, pname); + } + + // --- [ glGetQueryObjectiv ] --- + + /** Unsafe version of: {@link #glGetQueryObjectiv GetQueryObjectiv} */ + public static void nglGetQueryObjectiv(int id, int pname, long params) { + GL15C.nglGetQueryObjectiv(id, pname, params); + } + + /** + * Returns the integer value of a query object parameter. + * + * @param id the name of a query object + * @param pname the symbolic name of a query object parameter. One of:
{@link GL15C#GL_QUERY_RESULT QUERY_RESULT}{@link GL15C#GL_QUERY_RESULT_AVAILABLE QUERY_RESULT_AVAILABLE}
+ * @param params the requested data + * + * @see Reference Page + */ + public static void glGetQueryObjectiv(@NativeType("GLuint") int id, @NativeType("GLenum") int pname, @NativeType("GLint *") IntBuffer params) { + GL15C.glGetQueryObjectiv(id, pname, params); + } + + /** + * Returns the integer value of a query object parameter. + * + * @param id the name of a query object + * @param pname the symbolic name of a query object parameter. One of:
{@link GL15C#GL_QUERY_RESULT QUERY_RESULT}{@link GL15C#GL_QUERY_RESULT_AVAILABLE QUERY_RESULT_AVAILABLE}
+ * + * @see Reference Page + */ + @NativeType("void") + public static int glGetQueryObjecti(@NativeType("GLuint") int id, @NativeType("GLenum") int pname) { + return GL15C.glGetQueryObjecti(id, pname); + } + + // --- [ glGetQueryObjectuiv ] --- + + /** Unsafe version of: {@link #glGetQueryObjectuiv GetQueryObjectuiv} */ + public static void nglGetQueryObjectuiv(int id, int pname, long params) { + GL15C.nglGetQueryObjectuiv(id, pname, params); + } + + /** + * Unsigned version of {@link #glGetQueryObjectiv GetQueryObjectiv}. + * + * @param id the name of a query object + * @param pname the symbolic name of a query object parameter. One of:
{@link GL15C#GL_QUERY_RESULT QUERY_RESULT}{@link GL15C#GL_QUERY_RESULT_AVAILABLE QUERY_RESULT_AVAILABLE}
+ * @param params the requested data + * + * @see Reference Page + */ + public static void glGetQueryObjectuiv(@NativeType("GLuint") int id, @NativeType("GLenum") int pname, @NativeType("GLuint *") IntBuffer params) { + GL15C.glGetQueryObjectuiv(id, pname, params); + } + + /** + * Unsigned version of {@link #glGetQueryObjectiv GetQueryObjectiv}. + * + * @param id the name of a query object + * @param pname the symbolic name of a query object parameter. One of:
{@link GL15C#GL_QUERY_RESULT QUERY_RESULT}{@link GL15C#GL_QUERY_RESULT_AVAILABLE QUERY_RESULT_AVAILABLE}
+ * + * @see Reference Page + */ + @NativeType("void") + public static int glGetQueryObjectui(@NativeType("GLuint") int id, @NativeType("GLenum") int pname) { + return GL15C.glGetQueryObjectui(id, pname); + } + + /** + * Array version of: {@link #glDeleteBuffers DeleteBuffers} + * + * @see Reference Page + */ + public static void glDeleteBuffers(@NativeType("GLuint const *") int[] buffers) { + GL15C.glDeleteBuffers(buffers); + } + + /** + * Array version of: {@link #glGenBuffers GenBuffers} + * + * @see Reference Page + */ + public static void glGenBuffers(@NativeType("GLuint *") int[] buffers) { + GL15C.glGenBuffers(buffers); + } + + /** + * Array version of: {@link #glBufferData BufferData} + * + * @see Reference Page + */ + public static void glBufferData(@NativeType("GLenum") int target, @NativeType("void const *") short[] data, @NativeType("GLenum") int usage) { + GL15C.glBufferData(target, data, usage); + } + + /** + * Array version of: {@link #glBufferData BufferData} + * + * @see Reference Page + */ + public static void glBufferData(@NativeType("GLenum") int target, @NativeType("void const *") int[] data, @NativeType("GLenum") int usage) { + GL15C.glBufferData(target, data, usage); + } + + /** + * Array version of: {@link #glBufferData BufferData} + * + * @see Reference Page + */ + public static void glBufferData(@NativeType("GLenum") int target, @NativeType("void const *") long[] data, @NativeType("GLenum") int usage) { + GL15C.glBufferData(target, data, usage); + } + + /** + * Array version of: {@link #glBufferData BufferData} + * + * @see Reference Page + */ + public static void glBufferData(@NativeType("GLenum") int target, @NativeType("void const *") float[] data, @NativeType("GLenum") int usage) { + GL15C.glBufferData(target, data, usage); + } + + /** + * Array version of: {@link #glBufferData BufferData} + * + * @see Reference Page + */ + public static void glBufferData(@NativeType("GLenum") int target, @NativeType("void const *") double[] data, @NativeType("GLenum") int usage) { + GL15C.glBufferData(target, data, usage); + } + + /** + * Array version of: {@link #glBufferSubData BufferSubData} + * + * @see Reference Page + */ + public static void glBufferSubData(@NativeType("GLenum") int target, @NativeType("GLintptr") long offset, @NativeType("void const *") short[] data) { + GL15C.glBufferSubData(target, offset, data); + } + + /** + * Array version of: {@link #glBufferSubData BufferSubData} + * + * @see Reference Page + */ + public static void glBufferSubData(@NativeType("GLenum") int target, @NativeType("GLintptr") long offset, @NativeType("void const *") int[] data) { + GL15C.glBufferSubData(target, offset, data); + } + + /** + * Array version of: {@link #glBufferSubData BufferSubData} + * + * @see Reference Page + */ + public static void glBufferSubData(@NativeType("GLenum") int target, @NativeType("GLintptr") long offset, @NativeType("void const *") long[] data) { + GL15C.glBufferSubData(target, offset, data); + } + + /** + * Array version of: {@link #glBufferSubData BufferSubData} + * + * @see Reference Page + */ + public static void glBufferSubData(@NativeType("GLenum") int target, @NativeType("GLintptr") long offset, @NativeType("void const *") float[] data) { + GL15C.glBufferSubData(target, offset, data); + } + + /** + * Array version of: {@link #glBufferSubData BufferSubData} + * + * @see Reference Page + */ + public static void glBufferSubData(@NativeType("GLenum") int target, @NativeType("GLintptr") long offset, @NativeType("void const *") double[] data) { + GL15C.glBufferSubData(target, offset, data); + } + + /** + * Array version of: {@link #glGetBufferSubData GetBufferSubData} + * + * @see Reference Page + */ + public static void glGetBufferSubData(@NativeType("GLenum") int target, @NativeType("GLintptr") long offset, @NativeType("void *") short[] data) { + GL15C.glGetBufferSubData(target, offset, data); + } + + /** + * Array version of: {@link #glGetBufferSubData GetBufferSubData} + * + * @see Reference Page + */ + public static void glGetBufferSubData(@NativeType("GLenum") int target, @NativeType("GLintptr") long offset, @NativeType("void *") int[] data) { + GL15C.glGetBufferSubData(target, offset, data); + } + + /** + * Array version of: {@link #glGetBufferSubData GetBufferSubData} + * + * @see Reference Page + */ + public static void glGetBufferSubData(@NativeType("GLenum") int target, @NativeType("GLintptr") long offset, @NativeType("void *") long[] data) { + GL15C.glGetBufferSubData(target, offset, data); + } + + /** + * Array version of: {@link #glGetBufferSubData GetBufferSubData} + * + * @see Reference Page + */ + public static void glGetBufferSubData(@NativeType("GLenum") int target, @NativeType("GLintptr") long offset, @NativeType("void *") float[] data) { + GL15C.glGetBufferSubData(target, offset, data); + } + + /** + * Array version of: {@link #glGetBufferSubData GetBufferSubData} + * + * @see Reference Page + */ + public static void glGetBufferSubData(@NativeType("GLenum") int target, @NativeType("GLintptr") long offset, @NativeType("void *") double[] data) { + GL15C.glGetBufferSubData(target, offset, data); + } + + /** + * Array version of: {@link #glGetBufferParameteriv GetBufferParameteriv} + * + * @see Reference Page + */ + public static void glGetBufferParameteriv(@NativeType("GLenum") int target, @NativeType("GLenum") int pname, @NativeType("GLint *") int[] params) { + GL15C.glGetBufferParameteriv(target, pname, params); + } + + /** + * Array version of: {@link #glGenQueries GenQueries} + * + * @see Reference Page + */ + public static void glGenQueries(@NativeType("GLuint *") int[] ids) { + GL15C.glGenQueries(ids); + } + + /** + * Array version of: {@link #glDeleteQueries DeleteQueries} + * + * @see Reference Page + */ + public static void glDeleteQueries(@NativeType("GLuint const *") int[] ids) { + GL15C.glDeleteQueries(ids); + } + + /** + * Array version of: {@link #glGetQueryiv GetQueryiv} + * + * @see Reference Page + */ + public static void glGetQueryiv(@NativeType("GLenum") int target, @NativeType("GLenum") int pname, @NativeType("GLint *") int[] params) { + GL15C.glGetQueryiv(target, pname, params); + } + + /** + * Array version of: {@link #glGetQueryObjectiv GetQueryObjectiv} + * + * @see Reference Page + */ + public static void glGetQueryObjectiv(@NativeType("GLuint") int id, @NativeType("GLenum") int pname, @NativeType("GLint *") int[] params) { + GL15C.glGetQueryObjectiv(id, pname, params); + } + + /** + * Array version of: {@link #glGetQueryObjectuiv GetQueryObjectuiv} + * + * @see Reference Page + */ + public static void glGetQueryObjectuiv(@NativeType("GLuint") int id, @NativeType("GLenum") int pname, @NativeType("GLuint *") int[] params) { + GL15C.glGetQueryObjectuiv(id, pname, params); + } + +} diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/opengl/GL20.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/opengl/GL20.java new file mode 100644 index 000000000..92151666e --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/opengl/GL20.java @@ -0,0 +1,2925 @@ +/* + * Copyright LWJGL. All rights reserved. + * License terms: https://www.lwjgl.org/license + * MACHINE GENERATED FILE, DO NOT EDIT + */ +package org.lwjgl.opengl; + +import javax.annotation.*; + +import java.nio.*; + +import org.lwjgl.*; + +import org.lwjgl.system.*; + +import static org.lwjgl.system.Checks.*; + +/** + * The OpenGL functionality up to version 2.0. Includes the deprecated symbols of the Compatibility Profile. + * + *

Extensions promoted to core in this release:

+ * + * + */ +public class GL20 extends GL15 { + + /** Accepted by the {@code name} parameter of GetString. */ + public static final int GL_SHADING_LANGUAGE_VERSION = 0x8B8C; + + /** Accepted by the {@code pname} parameter of GetInteger. */ + public static final int GL_CURRENT_PROGRAM = 0x8B8D; + + /** Accepted by the {@code pname} parameter of GetShaderiv. */ + public static final int + GL_SHADER_TYPE = 0x8B4F, + GL_DELETE_STATUS = 0x8B80, + GL_COMPILE_STATUS = 0x8B81, + GL_LINK_STATUS = 0x8B82, + GL_VALIDATE_STATUS = 0x8B83, + GL_INFO_LOG_LENGTH = 0x8B84, + GL_ATTACHED_SHADERS = 0x8B85, + GL_ACTIVE_UNIFORMS = 0x8B86, + GL_ACTIVE_UNIFORM_MAX_LENGTH = 0x8B87, + GL_ACTIVE_ATTRIBUTES = 0x8B89, + GL_ACTIVE_ATTRIBUTE_MAX_LENGTH = 0x8B8A, + GL_SHADER_SOURCE_LENGTH = 0x8B88; + + /** Returned by the {@code type} parameter of GetActiveUniform. */ + public static final int + GL_FLOAT_VEC2 = 0x8B50, + GL_FLOAT_VEC3 = 0x8B51, + GL_FLOAT_VEC4 = 0x8B52, + GL_INT_VEC2 = 0x8B53, + GL_INT_VEC3 = 0x8B54, + GL_INT_VEC4 = 0x8B55, + GL_BOOL = 0x8B56, + GL_BOOL_VEC2 = 0x8B57, + GL_BOOL_VEC3 = 0x8B58, + GL_BOOL_VEC4 = 0x8B59, + GL_FLOAT_MAT2 = 0x8B5A, + GL_FLOAT_MAT3 = 0x8B5B, + GL_FLOAT_MAT4 = 0x8B5C, + GL_SAMPLER_1D = 0x8B5D, + GL_SAMPLER_2D = 0x8B5E, + GL_SAMPLER_3D = 0x8B5F, + GL_SAMPLER_CUBE = 0x8B60, + GL_SAMPLER_1D_SHADOW = 0x8B61, + GL_SAMPLER_2D_SHADOW = 0x8B62; + + /** Accepted by the {@code type} argument of CreateShader and returned by the {@code params} parameter of GetShaderiv. */ + public static final int GL_VERTEX_SHADER = 0x8B31; + + /** Accepted by the {@code pname} parameter of GetBooleanv, GetIntegerv, GetFloatv, and GetDoublev. */ + public static final int + GL_MAX_VERTEX_UNIFORM_COMPONENTS = 0x8B4A, + GL_MAX_VARYING_FLOATS = 0x8B4B, + GL_MAX_VERTEX_ATTRIBS = 0x8869, + GL_MAX_TEXTURE_IMAGE_UNITS = 0x8872, + GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS = 0x8B4C, + GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS = 0x8B4D, + GL_MAX_TEXTURE_COORDS = 0x8871; + + /** + * Accepted by the {@code cap} parameter of Disable, Enable, and IsEnabled, and by the {@code pname} parameter of GetBooleanv, GetIntegerv, GetFloatv, and + * GetDoublev. + */ + public static final int + GL_VERTEX_PROGRAM_POINT_SIZE = 0x8642, + GL_VERTEX_PROGRAM_TWO_SIDE = 0x8643; + + /** Accepted by the {@code pname} parameter of GetVertexAttrib{dfi}v. */ + public static final int + GL_VERTEX_ATTRIB_ARRAY_ENABLED = 0x8622, + GL_VERTEX_ATTRIB_ARRAY_SIZE = 0x8623, + GL_VERTEX_ATTRIB_ARRAY_STRIDE = 0x8624, + GL_VERTEX_ATTRIB_ARRAY_TYPE = 0x8625, + GL_VERTEX_ATTRIB_ARRAY_NORMALIZED = 0x886A, + GL_CURRENT_VERTEX_ATTRIB = 0x8626; + + /** Accepted by the {@code pname} parameter of GetVertexAttribPointerv. */ + public static final int GL_VERTEX_ATTRIB_ARRAY_POINTER = 0x8645; + + /** Accepted by the {@code type} argument of CreateShader and returned by the {@code params} parameter of GetShaderiv. */ + public static final int GL_FRAGMENT_SHADER = 0x8B30; + + /** Accepted by the {@code pname} parameter of GetBooleanv, GetIntegerv, GetFloatv, and GetDoublev. */ + public static final int GL_MAX_FRAGMENT_UNIFORM_COMPONENTS = 0x8B49; + + /** Accepted by the {@code target} parameter of Hint and the {@code pname} parameter of GetBooleanv, GetIntegerv, GetFloatv, and GetDoublev. */ + public static final int GL_FRAGMENT_SHADER_DERIVATIVE_HINT = 0x8B8B; + + /** Accepted by the {@code pname} parameters of GetIntegerv, GetFloatv, and GetDoublev. */ + public static final int + GL_MAX_DRAW_BUFFERS = 0x8824, + GL_DRAW_BUFFER0 = 0x8825, + GL_DRAW_BUFFER1 = 0x8826, + GL_DRAW_BUFFER2 = 0x8827, + GL_DRAW_BUFFER3 = 0x8828, + GL_DRAW_BUFFER4 = 0x8829, + GL_DRAW_BUFFER5 = 0x882A, + GL_DRAW_BUFFER6 = 0x882B, + GL_DRAW_BUFFER7 = 0x882C, + GL_DRAW_BUFFER8 = 0x882D, + GL_DRAW_BUFFER9 = 0x882E, + GL_DRAW_BUFFER10 = 0x882F, + GL_DRAW_BUFFER11 = 0x8830, + GL_DRAW_BUFFER12 = 0x8831, + GL_DRAW_BUFFER13 = 0x8832, + GL_DRAW_BUFFER14 = 0x8833, + GL_DRAW_BUFFER15 = 0x8834; + + /** + * Accepted by the {@code cap} parameter of Enable, Disable, and IsEnabled, by the {@code pname} parameter of GetBooleanv, GetIntegerv, GetFloatv, and + * GetDoublev, and by the {@code target} parameter of TexEnvi, TexEnviv, TexEnvf, TexEnvfv, GetTexEnviv, and GetTexEnvfv. + */ + public static final int GL_POINT_SPRITE = 0x8861; + + /** + * When the {@code target} parameter of TexEnvf, TexEnvfv, TexEnvi, TexEnviv, GetTexEnvfv, or GetTexEnviv is POINT_SPRITE, then the value of + * {@code pname} may be. + */ + public static final int GL_COORD_REPLACE = 0x8862; + + /** Accepted by the {@code pname} parameter of PointParameter{if}v. */ + public static final int GL_POINT_SPRITE_COORD_ORIGIN = 0x8CA0; + + /** Accepted by the {@code param} parameter of PointParameter{if}v. */ + public static final int + GL_LOWER_LEFT = 0x8CA1, + GL_UPPER_LEFT = 0x8CA2; + + /** Accepted by the {@code pname} parameter of GetBooleanv, GetIntegerv, GetFloatv, and GetDoublev. */ + public static final int + GL_BLEND_EQUATION_RGB = 0x8009, + GL_BLEND_EQUATION_ALPHA = 0x883D; + + /** Accepted by the {@code pname} parameter of GetIntegerv. */ + public static final int + GL_STENCIL_BACK_FUNC = 0x8800, + GL_STENCIL_BACK_FAIL = 0x8801, + GL_STENCIL_BACK_PASS_DEPTH_FAIL = 0x8802, + GL_STENCIL_BACK_PASS_DEPTH_PASS = 0x8803, + GL_STENCIL_BACK_REF = 0x8CA3, + GL_STENCIL_BACK_VALUE_MASK = 0x8CA4, + GL_STENCIL_BACK_WRITEMASK = 0x8CA5; + + static { GL.initialize(); } + + protected GL20() { + throw new UnsupportedOperationException(); + } + + static boolean isAvailable(GLCapabilities caps) { + return checkFunctions( + caps.glCreateProgram, caps.glDeleteProgram, caps.glIsProgram, caps.glCreateShader, caps.glDeleteShader, caps.glIsShader, caps.glAttachShader, + caps.glDetachShader, caps.glShaderSource, caps.glCompileShader, caps.glLinkProgram, caps.glUseProgram, caps.glValidateProgram, caps.glUniform1f, + caps.glUniform2f, caps.glUniform3f, caps.glUniform4f, caps.glUniform1i, caps.glUniform2i, caps.glUniform3i, caps.glUniform4i, caps.glUniform1fv, + caps.glUniform2fv, caps.glUniform3fv, caps.glUniform4fv, caps.glUniform1iv, caps.glUniform2iv, caps.glUniform3iv, caps.glUniform4iv, + caps.glUniformMatrix2fv, caps.glUniformMatrix3fv, caps.glUniformMatrix4fv, caps.glGetShaderiv, caps.glGetProgramiv, caps.glGetShaderInfoLog, + caps.glGetProgramInfoLog, caps.glGetAttachedShaders, caps.glGetUniformLocation, caps.glGetActiveUniform, caps.glGetUniformfv, caps.glGetUniformiv, + caps.glGetShaderSource, caps.glVertexAttrib1f, caps.glVertexAttrib1s, caps.glVertexAttrib1d, caps.glVertexAttrib2f, caps.glVertexAttrib2s, + caps.glVertexAttrib2d, caps.glVertexAttrib3f, caps.glVertexAttrib3s, caps.glVertexAttrib3d, caps.glVertexAttrib4f, caps.glVertexAttrib4s, + caps.glVertexAttrib4d, caps.glVertexAttrib4Nub, caps.glVertexAttrib1fv, caps.glVertexAttrib1sv, caps.glVertexAttrib1dv, caps.glVertexAttrib2fv, + caps.glVertexAttrib2sv, caps.glVertexAttrib2dv, caps.glVertexAttrib3fv, caps.glVertexAttrib3sv, caps.glVertexAttrib3dv, caps.glVertexAttrib4fv, + caps.glVertexAttrib4sv, caps.glVertexAttrib4dv, caps.glVertexAttrib4iv, caps.glVertexAttrib4bv, caps.glVertexAttrib4ubv, caps.glVertexAttrib4usv, + caps.glVertexAttrib4uiv, caps.glVertexAttrib4Nbv, caps.glVertexAttrib4Nsv, caps.glVertexAttrib4Niv, caps.glVertexAttrib4Nubv, + caps.glVertexAttrib4Nusv, caps.glVertexAttrib4Nuiv, caps.glVertexAttribPointer, caps.glEnableVertexAttribArray, caps.glDisableVertexAttribArray, + caps.glBindAttribLocation, caps.glGetActiveAttrib, caps.glGetAttribLocation, caps.glGetVertexAttribiv, caps.glGetVertexAttribfv, + caps.glGetVertexAttribdv, caps.glGetVertexAttribPointerv, caps.glDrawBuffers, caps.glBlendEquationSeparate, caps.glStencilOpSeparate, + caps.glStencilFuncSeparate, caps.glStencilMaskSeparate + ); + } + +// -- Begin LWJGL2 part -- + public static void glVertexAttribPointer(int index, int size, + boolean unsigned, boolean normalized, + int stride, ByteBuffer buffer) { + int type = unsigned ? GL11.GL_UNSIGNED_BYTE : GL11.GL_BYTE; + GL20.glVertexAttribPointer(index, size, type, normalized, stride, buffer); + } + + public static void glVertexAttribPointer(int index, int size, + boolean unsigned, boolean normalized, + int stride, ShortBuffer buffer) { + GL20.nglVertexAttribPointer(index, size, unsigned ? GL11.GL_UNSIGNED_SHORT : GL11.GL_SHORT, normalized, stride, MemoryUtil.memAddress(buffer)); + } + + public static void glVertexAttribPointer(int index, int size, + boolean unsigned, boolean normalized, + int stride, IntBuffer buffer) { + GL20.nglVertexAttribPointer(index, size, unsigned ? GL11.GL_UNSIGNED_INT : GL11.GL_INT, normalized, stride, MemoryUtil.memAddress(buffer)); + } + + public static String glGetActiveAttrib(int program, int index, int maxLength, + IntBuffer sizeType) { + //TODO check if correct + IntBuffer type = BufferUtils.createIntBuffer(1); + String s = GL20.glGetActiveAttrib(program, index, maxLength, sizeType, type); + sizeType.put(type.get(0)); + return s; + } + + public static String glGetActiveUniform(int program, int index, int maxLength, + IntBuffer sizeType) { + //TODO if correct + IntBuffer type = BufferUtils.createIntBuffer(1); + String s = GL20.glGetActiveUniform(program, index, maxLength, sizeType, type); + sizeType.put(type.get(0)); + return s; + } + + public static void glShaderSource(int shader, ByteBuffer string) { + byte[] b = new byte[string.remaining()]; + string.get(b); + glShaderSource(shader, new String(b)); + } + + // TODO port below +/* + public static String glGetActiveAttrib(int i, int i2, int i3) { + int i4 = i; + int i5 = i2; + int i6 = i3; + ContextCapabilities capabilities = GLContext.getCapabilities(); + long j = capabilities.glGetActiveAttrib; + BufferChecks.checkFunctionAddress(j); + Buffer lengths = APIUtil.getLengths(capabilities); + ByteBuffer bufferByte = APIUtil.getBufferByte(capabilities, i6); + nglGetActiveAttrib(i4, i5, i6, MemoryUtil.memAddress(lengths), MemoryUtil.memAddress(APIUtil.getBufferInt(capabilities)), MemoryUtil.getAddress(APIUtil.getBufferInt(capabilities), 1), MemoryUtil.getAddress(bufferByte), j); + Buffer limit = bufferByte.limit(lengths.get(0)); + return APIUtil.getString(capabilities, bufferByte); + } + + public static int glGetActiveAttribSize(int i, int i2) { + int i3 = i; + int i4 = i2; + ContextCapabilities capabilities = GLContext.getCapabilities(); + long j = capabilities.glGetActiveAttrib; + BufferChecks.checkFunctionAddress(j); + IntBuffer bufferInt = APIUtil.getBufferInt(capabilities); + nglGetActiveAttrib(i3, i4, 0, 0, MemoryUtil.getAddress(bufferInt), MemoryUtil.getAddress(bufferInt, 1), APIUtil.getBufferByte0(capabilities), j); + return bufferInt.get(0); + } + + public static int glGetActiveAttribType(int i, int i2) { + int i3 = i; + int i4 = i2; + ContextCapabilities capabilities = GLContext.getCapabilities(); + long j = capabilities.glGetActiveAttrib; + BufferChecks.checkFunctionAddress(j); + IntBuffer bufferInt = APIUtil.getBufferInt(capabilities); + nglGetActiveAttrib(i3, i4, 0, 0, MemoryUtil.getAddress(bufferInt, 1), MemoryUtil.getAddress(bufferInt), APIUtil.getBufferByte0(capabilities), j); + return bufferInt.get(0); + } + + public static String glGetActiveUniform(int i, int i2, int i3) { + int i4 = i; + int i5 = i2; + int i6 = i3; + ContextCapabilities capabilities = GLContext.getCapabilities(); + long j = capabilities.glGetActiveUniform; + BufferChecks.checkFunctionAddress(j); + Buffer lengths = APIUtil.getLengths(capabilities); + ByteBuffer bufferByte = APIUtil.getBufferByte(capabilities, i6); + nglGetActiveUniform(i4, i5, i6, MemoryUtil.memAddress(lengths), MemoryUtil.memAddress(APIUtil.getBufferInt(capabilities)), MemoryUtil.getAddress(APIUtil.getBufferInt(capabilities), 1), MemoryUtil.getAddress(bufferByte), j); + Buffer limit = bufferByte.limit(lengths.get(0)); + return APIUtil.getString(capabilities, bufferByte); + } + + public static int glGetActiveUniformSize(int i, int i2) { + int i3 = i; + int i4 = i2; + ContextCapabilities capabilities = GLContext.getCapabilities(); + long j = capabilities.glGetActiveUniform; + BufferChecks.checkFunctionAddress(j); + IntBuffer bufferInt = APIUtil.getBufferInt(capabilities); + nglGetActiveUniform(i3, i4, 1, 0, MemoryUtil.getAddress(bufferInt), MemoryUtil.getAddress(bufferInt, 1), APIUtil.getBufferByte0(capabilities), j); + return bufferInt.get(0); + } + + public static int glGetActiveUniformType(int i, int i2) { + int i3 = i; + int i4 = i2; + ContextCapabilities capabilities = GLContext.getCapabilities(); + long j = capabilities.glGetActiveUniform; + BufferChecks.checkFunctionAddress(j); + IntBuffer bufferInt = APIUtil.getBufferInt(capabilities); + nglGetActiveUniform(i3, i4, 0, 0, MemoryUtil.getAddress(bufferInt, 1), MemoryUtil.getAddress(bufferInt), APIUtil.getBufferByte0(capabilities), j); + return bufferInt.get(0); + } +*/ + + @Deprecated + public static int glGetProgram(int i, int i2) { + return glGetProgrami(i, i2); + } + + public static void glGetProgram(int program, int pname, IntBuffer params) { + glGetProgramiv(program, pname, params); + } + + @Deprecated + public static int glGetShader(int i, int i2) { + return glGetShaderi(i, i2); + } + + public static void glGetShader(int shader, int pname, IntBuffer params) { + glGetShaderiv(shader, pname, params); + } + + public static void glGetUniform(int program, int location, FloatBuffer params) { + glGetUniformfv(program, location, params); + } + + public static void glGetUniform(int program, int location, IntBuffer params) { + glGetUniformiv(program, location, params); + } + + public static void glGetVertexAttrib(int index, int pname, DoubleBuffer params) { + glGetVertexAttribdv(index, pname, params); + } + + public static void glGetVertexAttrib(int index, int pname, FloatBuffer params) { + glGetVertexAttribfv(index, pname, params); + } + + public static void glGetVertexAttrib(int index, int pname, IntBuffer params) { + glGetVertexAttribiv(index, pname, params); + } + + // FIXME +/* + public static ByteBuffer glGetVertexAttribPointer(int i, int i2, long j) { + glGetVertexa + } + + public static void glGetVertexAttribPointer(int index, int pname, ByteBuffer buffer) { + glGetVertexAttribPointer(index, pname); + } +*/ + public static void glUniform1(int location, FloatBuffer buffer) { + glUniform1fv(location, buffer); + } + + public static void glUniform1(int location, IntBuffer buffer) { + glUniform1iv(location, buffer); + } + + public static void glUniform2(int location, FloatBuffer buffer) { + glUniform2fv(location, buffer); + } + + public static void glUniform2(int location, IntBuffer buffer) { + glUniform2iv(location, buffer); + } + + public static void glUniform3(int location, FloatBuffer buffer) { + glUniform3fv(location, buffer); + } + + public static void glUniform3(int location, IntBuffer buffer) { + glUniform3iv(location, buffer); + } + + public static void glUniform4(int location, FloatBuffer buffer) { + glUniform4fv(location, buffer); + } + + public static void glUniform4(int location, IntBuffer buffer) { + glUniform4iv(location, buffer); + } + + public static void glUniformMatrix2(int location, boolean transpose, FloatBuffer buffer) { + glUniformMatrix2fv(location, transpose, buffer); + } + + public static void glUniformMatrix3(int location, boolean transpose, FloatBuffer buffer) { + glUniformMatrix3fv(location, transpose, buffer); + } + + public static void glUniformMatrix4(int location, boolean transpose, FloatBuffer buffer) { + glUniformMatrix4fv(location, transpose, buffer); + } + + // FIXME +/* + public static void glVertexAttribPointer(int index, int size, boolean normalized, int stride, DoubleBuffer buffer) { + glVertexAttribPointer(index, size, GL11.GL_DOUBLE, normalized, stride, buffer); + } +*/ + public static void glVertexAttribPointer(int index, int size, boolean normalized, int stride, FloatBuffer buffer) { + glVertexAttribPointer(index, size, GL11.GL_FLOAT, normalized, stride, buffer); + } +// -- End LWJGL2 part -- + + // --- [ glCreateProgram ] --- + + /** + * Creates a program object. + * + * @see Reference Page + */ + @NativeType("GLuint") + public static int glCreateProgram() { + return GL20C.glCreateProgram(); + } + + // --- [ glDeleteProgram ] --- + + /** + * Deletes a program object. + * + * @param program the program object to be deleted + * + * @see Reference Page + */ + public static void glDeleteProgram(@NativeType("GLuint") int program) { + GL20C.glDeleteProgram(program); + } + + // --- [ glIsProgram ] --- + + /** + * Returns {@link GL11#GL_TRUE TRUE} if {@code program} is the name of a program object. If {@code program} is zero, or a non-zero value that is not the name of a program + * object, IsProgram returns {@link GL11#GL_FALSE FALSE}. No error is generated if program is not a valid program object name. + * + * @param program the program object name to query + * + * @see Reference Page + */ + @NativeType("GLboolean") + public static boolean glIsProgram(@NativeType("GLuint") int program) { + return GL20C.glIsProgram(program); + } + + // --- [ glCreateShader ] --- + + /** + * Creates a shader object. + * + * @param type the type of shader to be created. One of:
{@link GL20C#GL_VERTEX_SHADER VERTEX_SHADER}{@link GL20C#GL_FRAGMENT_SHADER FRAGMENT_SHADER}{@link GL32#GL_GEOMETRY_SHADER GEOMETRY_SHADER}{@link GL40#GL_TESS_CONTROL_SHADER TESS_CONTROL_SHADER}
{@link GL40#GL_TESS_EVALUATION_SHADER TESS_EVALUATION_SHADER}
+ * + * @see Reference Page + */ + @NativeType("GLuint") + public static int glCreateShader(@NativeType("GLenum") int type) { + return GL20C.glCreateShader(type); + } + + // --- [ glDeleteShader ] --- + + /** + * Deletes a shader object. + * + * @param shader the shader object to be deleted + * + * @see Reference Page + */ + public static void glDeleteShader(@NativeType("GLuint") int shader) { + GL20C.glDeleteShader(shader); + } + + // --- [ glIsShader ] --- + + /** + * Returns {@link GL11#GL_TRUE TRUE} if {@code shader} is the name of a shader object. If {@code shader} is zero, or a nonzero value that is not the name of a shader + * object, IsShader returns {@link GL11#GL_FALSE FALSE}. No error is generated if shader is not a valid shader object name. + * + * @param shader the shader object name to query + * + * @see Reference Page + */ + @NativeType("GLboolean") + public static boolean glIsShader(@NativeType("GLuint") int shader) { + return GL20C.glIsShader(shader); + } + + // --- [ glAttachShader ] --- + + /** + * Attaches a shader object to a program object. + * + *

In order to create a complete shader program, there must be a way to specify the list of things that will be linked together. Program objects provide + * this mechanism. Shaders that are to be linked together in a program object must first be attached to that program object. glAttachShader attaches the + * shader object specified by shader to the program object specified by program. This indicates that shader will be included in link operations that will + * be performed on program.

+ * + *

All operations that can be performed on a shader object are valid whether or not the shader object is attached to a program object. It is permissible to + * attach a shader object to a program object before source code has been loaded into the shader object or before the shader object has been compiled. It + * is permissible to attach multiple shader objects of the same type because each may contain a portion of the complete shader. It is also permissible to + * attach a shader object to more than one program object. If a shader object is deleted while it is attached to a program object, it will be flagged for + * deletion, and deletion will not occur until glDetachShader is called to detach it from all program objects to which it is attached.

+ * + * @param program the program object to which a shader object will be attached + * @param shader the shader object that is to be attached + * + * @see Reference Page + */ + public static void glAttachShader(@NativeType("GLuint") int program, @NativeType("GLuint") int shader) { + GL20C.glAttachShader(program, shader); + } + + // --- [ glDetachShader ] --- + + /** + * Detaches a shader object from a program object to which it is attached. + * + * @param program the program object from which to detach the shader object + * @param shader the shader object to be detached + * + * @see Reference Page + */ + public static void glDetachShader(@NativeType("GLuint") int program, @NativeType("GLuint") int shader) { + GL20C.glDetachShader(program, shader); + } + + // --- [ glShaderSource ] --- + + /** + * Unsafe version of: {@link #glShaderSource ShaderSource} + * + * @param count the number of elements in the string and length arrays + */ + public static void nglShaderSource(int shader, int count, long strings, long length) { + GL20C.nglShaderSource(shader, count, strings, length); + } + + /** + * Sets the source code in {@code shader} to the source code in the array of strings specified by {@code strings}. Any source code previously stored in the + * shader object is completely replaced. The number of strings in the array is specified by {@code count}. If {@code length} is {@code NULL}, each string is + * assumed to be null terminated. If {@code length} is a value other than {@code NULL}, it points to an array containing a string length for each of the + * corresponding elements of {@code strings}. Each element in the length array may contain the length of the corresponding string (the null character is not + * counted as part of the string length) or a value less than 0 to indicate that the string is null terminated. The source code strings are not scanned or + * parsed at this time; they are simply copied into the specified shader object. + * + * @param shader the shader object whose source code is to be replaced + * @param strings an array of pointers to strings containing the source code to be loaded into the shader + * @param length an array of string lengths + * + * @see Reference Page + */ + public static void glShaderSource(@NativeType("GLuint") int shader, @NativeType("GLchar const **") PointerBuffer strings, @Nullable @NativeType("GLint const *") IntBuffer length) { + GL20C.glShaderSource(shader, strings, length); + } + + /** + * Sets the source code in {@code shader} to the source code in the array of strings specified by {@code strings}. Any source code previously stored in the + * shader object is completely replaced. The number of strings in the array is specified by {@code count}. If {@code length} is {@code NULL}, each string is + * assumed to be null terminated. If {@code length} is a value other than {@code NULL}, it points to an array containing a string length for each of the + * corresponding elements of {@code strings}. Each element in the length array may contain the length of the corresponding string (the null character is not + * counted as part of the string length) or a value less than 0 to indicate that the string is null terminated. The source code strings are not scanned or + * parsed at this time; they are simply copied into the specified shader object. + * + * @param shader the shader object whose source code is to be replaced + * @param strings an array of pointers to strings containing the source code to be loaded into the shader + * + * @see Reference Page + */ + public static void glShaderSource(@NativeType("GLuint") int shader, @NativeType("GLchar const **") CharSequence... strings) { + GL20C.glShaderSource(shader, strings); + } + + /** + * Sets the source code in {@code shader} to the source code in the array of strings specified by {@code strings}. Any source code previously stored in the + * shader object is completely replaced. The number of strings in the array is specified by {@code count}. If {@code length} is {@code NULL}, each string is + * assumed to be null terminated. If {@code length} is a value other than {@code NULL}, it points to an array containing a string length for each of the + * corresponding elements of {@code strings}. Each element in the length array may contain the length of the corresponding string (the null character is not + * counted as part of the string length) or a value less than 0 to indicate that the string is null terminated. The source code strings are not scanned or + * parsed at this time; they are simply copied into the specified shader object. + * + * @param shader the shader object whose source code is to be replaced + * + * @see Reference Page + */ + public static void glShaderSource(@NativeType("GLuint") int shader, @NativeType("GLchar const **") CharSequence string) { + GL20C.glShaderSource(shader, string); + } + + // --- [ glCompileShader ] --- + + /** + * Compiles a shader object. + * + * @param shader the shader object to be compiled + * + * @see Reference Page + */ + public static void glCompileShader(@NativeType("GLuint") int shader) { + GL20C.glCompileShader(shader); + } + + // --- [ glLinkProgram ] --- + + /** + * Links a program object. + * + * @param program the program object to be linked + * + * @see Reference Page + */ + public static void glLinkProgram(@NativeType("GLuint") int program) { + GL20C.glLinkProgram(program); + } + + // --- [ glUseProgram ] --- + + /** + * Installs a program object as part of current rendering state. + * + * @param program the program object whose executables are to be used as part of current rendering state + * + * @see Reference Page + */ + public static void glUseProgram(@NativeType("GLuint") int program) { + GL20C.glUseProgram(program); + } + + // --- [ glValidateProgram ] --- + + /** + * Validates a program object. + * + * @param program the program object to be validated + * + * @see Reference Page + */ + public static void glValidateProgram(@NativeType("GLuint") int program) { + GL20C.glValidateProgram(program); + } + + // --- [ glUniform1f ] --- + + /** + * Specifies the value of a float uniform variable for the current program object. + * + * @param location the location of the uniform variable to be modified + * @param v0 the uniform value + * + * @see Reference Page + */ + public static void glUniform1f(@NativeType("GLint") int location, @NativeType("GLfloat") float v0) { + GL20C.glUniform1f(location, v0); + } + + // --- [ glUniform2f ] --- + + /** + * Specifies the value of a vec2 uniform variable for the current program object. + * + * @param location the location of the uniform variable to be modified + * @param v0 the uniform x value + * @param v1 the uniform y value + * + * @see Reference Page + */ + public static void glUniform2f(@NativeType("GLint") int location, @NativeType("GLfloat") float v0, @NativeType("GLfloat") float v1) { + GL20C.glUniform2f(location, v0, v1); + } + + // --- [ glUniform3f ] --- + + /** + * Specifies the value of a vec3 uniform variable for the current program object. + * + * @param location the location of the uniform variable to be modified + * @param v0 the uniform x value + * @param v1 the uniform y value + * @param v2 the uniform z value + * + * @see Reference Page + */ + public static void glUniform3f(@NativeType("GLint") int location, @NativeType("GLfloat") float v0, @NativeType("GLfloat") float v1, @NativeType("GLfloat") float v2) { + GL20C.glUniform3f(location, v0, v1, v2); + } + + // --- [ glUniform4f ] --- + + /** + * Specifies the value of a vec4 uniform variable for the current program object. + * + * @param location the location of the uniform variable to be modified + * @param v0 the uniform x value + * @param v1 the uniform y value + * @param v2 the uniform z value + * @param v3 the uniform w value + * + * @see Reference Page + */ + public static void glUniform4f(@NativeType("GLint") int location, @NativeType("GLfloat") float v0, @NativeType("GLfloat") float v1, @NativeType("GLfloat") float v2, @NativeType("GLfloat") float v3) { + GL20C.glUniform4f(location, v0, v1, v2, v3); + } + + // --- [ glUniform1i ] --- + + /** + * Specifies the value of an int uniform variable for the current program object. + * + * @param location the location of the uniform variable to be modified + * @param v0 the uniform value + * + * @see Reference Page + */ + public static void glUniform1i(@NativeType("GLint") int location, @NativeType("GLint") int v0) { + GL20C.glUniform1i(location, v0); + } + + // --- [ glUniform2i ] --- + + /** + * Specifies the value of an ivec2 uniform variable for the current program object. + * + * @param location the location of the uniform variable to be modified + * @param v0 the uniform x value + * @param v1 the uniform y value + * + * @see Reference Page + */ + public static void glUniform2i(@NativeType("GLint") int location, @NativeType("GLint") int v0, @NativeType("GLint") int v1) { + GL20C.glUniform2i(location, v0, v1); + } + + // --- [ glUniform3i ] --- + + /** + * Specifies the value of an ivec3 uniform variable for the current program object. + * + * @param location the location of the uniform variable to be modified + * @param v0 the uniform x value + * @param v1 the uniform y value + * @param v2 the uniform z value + * + * @see Reference Page + */ + public static void glUniform3i(@NativeType("GLint") int location, @NativeType("GLint") int v0, @NativeType("GLint") int v1, @NativeType("GLint") int v2) { + GL20C.glUniform3i(location, v0, v1, v2); + } + + // --- [ glUniform4i ] --- + + /** + * Specifies the value of an ivec4 uniform variable for the current program object. + * + * @param location the location of the uniform variable to be modified + * @param v0 the uniform x value + * @param v1 the uniform y value + * @param v2 the uniform z value + * @param v3 the uniform w value + * + * @see Reference Page + */ + public static void glUniform4i(@NativeType("GLint") int location, @NativeType("GLint") int v0, @NativeType("GLint") int v1, @NativeType("GLint") int v2, @NativeType("GLint") int v3) { + GL20C.glUniform4i(location, v0, v1, v2, v3); + } + + // --- [ glUniform1fv ] --- + + /** + * Unsafe version of: {@link #glUniform1fv Uniform1fv} + * + * @param count the number of elements that are to be modified. This should be 1 if the targeted uniform variable is not an array, and 1 or more if it is an array. + */ + public static void nglUniform1fv(int location, int count, long value) { + GL20C.nglUniform1fv(location, count, value); + } + + /** + * Specifies the value of a single float uniform variable or a float uniform variable array for the current program object. + * + * @param location the location of the uniform variable to be modified + * @param value a pointer to an array of {@code count} values that will be used to update the specified uniform variable + * + * @see Reference Page + */ + public static void glUniform1fv(@NativeType("GLint") int location, @NativeType("GLfloat const *") FloatBuffer value) { + GL20C.glUniform1fv(location, value); + } + + // --- [ glUniform2fv ] --- + + /** + * Unsafe version of: {@link #glUniform2fv Uniform2fv} + * + * @param count the number of elements that are to be modified. This should be 1 if the targeted uniform variable is not an array, and 1 or more if it is an array. + */ + public static void nglUniform2fv(int location, int count, long value) { + GL20C.nglUniform2fv(location, count, value); + } + + /** + * Specifies the value of a single vec2 uniform variable or a vec2 uniform variable array for the current program object. + * + * @param location the location of the uniform variable to be modified + * @param value a pointer to an array of {@code count} values that will be used to update the specified uniform variable + * + * @see Reference Page + */ + public static void glUniform2fv(@NativeType("GLint") int location, @NativeType("GLfloat const *") FloatBuffer value) { + GL20C.glUniform2fv(location, value); + } + + // --- [ glUniform3fv ] --- + + /** + * Unsafe version of: {@link #glUniform3fv Uniform3fv} + * + * @param count the number of elements that are to be modified. This should be 1 if the targeted uniform variable is not an array, and 1 or more if it is an array. + */ + public static void nglUniform3fv(int location, int count, long value) { + GL20C.nglUniform3fv(location, count, value); + } + + /** + * Specifies the value of a single vec3 uniform variable or a vec3 uniform variable array for the current program object. + * + * @param location the location of the uniform variable to be modified + * @param value a pointer to an array of {@code count} values that will be used to update the specified uniform variable + * + * @see Reference Page + */ + public static void glUniform3fv(@NativeType("GLint") int location, @NativeType("GLfloat const *") FloatBuffer value) { + GL20C.glUniform3fv(location, value); + } + + // --- [ glUniform4fv ] --- + + /** + * Unsafe version of: {@link #glUniform4fv Uniform4fv} + * + * @param count the number of elements that are to be modified. This should be 1 if the targeted uniform variable is not an array, and 1 or more if it is an array. + */ + public static void nglUniform4fv(int location, int count, long value) { + GL20C.nglUniform4fv(location, count, value); + } + + /** + * Specifies the value of a single vec4 uniform variable or a vec4 uniform variable array for the current program object. + * + * @param location the location of the uniform variable to be modified + * @param value a pointer to an array of {@code count} values that will be used to update the specified uniform variable + * + * @see Reference Page + */ + public static void glUniform4fv(@NativeType("GLint") int location, @NativeType("GLfloat const *") FloatBuffer value) { + GL20C.glUniform4fv(location, value); + } + + // --- [ glUniform1iv ] --- + + /** + * Unsafe version of: {@link #glUniform1iv Uniform1iv} + * + * @param count the number of elements that are to be modified. This should be 1 if the targeted uniform variable is not an array, and 1 or more if it is an array. + */ + public static void nglUniform1iv(int location, int count, long value) { + GL20C.nglUniform1iv(location, count, value); + } + + /** + * Specifies the value of a single int uniform variable or a int uniform variable array for the current program object. + * + * @param location the location of the uniform variable to be modified + * @param value a pointer to an array of {@code count} values that will be used to update the specified uniform variable + * + * @see Reference Page + */ + public static void glUniform1iv(@NativeType("GLint") int location, @NativeType("GLint const *") IntBuffer value) { + GL20C.glUniform1iv(location, value); + } + + // --- [ glUniform2iv ] --- + + /** + * Unsafe version of: {@link #glUniform2iv Uniform2iv} + * + * @param count the number of elements that are to be modified. This should be 1 if the targeted uniform variable is not an array, and 1 or more if it is an array. + */ + public static void nglUniform2iv(int location, int count, long value) { + GL20C.nglUniform2iv(location, count, value); + } + + /** + * Specifies the value of a single ivec2 uniform variable or an ivec2 uniform variable array for the current program object. + * + * @param location the location of the uniform variable to be modified + * @param value a pointer to an array of {@code count} values that will be used to update the specified uniform variable + * + * @see Reference Page + */ + public static void glUniform2iv(@NativeType("GLint") int location, @NativeType("GLint const *") IntBuffer value) { + GL20C.glUniform2iv(location, value); + } + + // --- [ glUniform3iv ] --- + + /** + * Unsafe version of: {@link #glUniform3iv Uniform3iv} + * + * @param count the number of elements that are to be modified. This should be 1 if the targeted uniform variable is not an array, and 1 or more if it is an array. + */ + public static void nglUniform3iv(int location, int count, long value) { + GL20C.nglUniform3iv(location, count, value); + } + + /** + * Specifies the value of a single ivec3 uniform variable or an ivec3 uniform variable array for the current program object. + * + * @param location the location of the uniform variable to be modified + * @param value a pointer to an array of {@code count} values that will be used to update the specified uniform variable + * + * @see Reference Page + */ + public static void glUniform3iv(@NativeType("GLint") int location, @NativeType("GLint const *") IntBuffer value) { + GL20C.glUniform3iv(location, value); + } + + // --- [ glUniform4iv ] --- + + /** + * Unsafe version of: {@link #glUniform4iv Uniform4iv} + * + * @param count the number of elements that are to be modified. This should be 1 if the targeted uniform variable is not an array, and 1 or more if it is an array. + */ + public static void nglUniform4iv(int location, int count, long value) { + GL20C.nglUniform4iv(location, count, value); + } + + /** + * Specifies the value of a single ivec4 uniform variable or an ivec4 uniform variable array for the current program object. + * + * @param location the location of the uniform variable to be modified + * @param value a pointer to an array of {@code count} values that will be used to update the specified uniform variable + * + * @see Reference Page + */ + public static void glUniform4iv(@NativeType("GLint") int location, @NativeType("GLint const *") IntBuffer value) { + GL20C.glUniform4iv(location, value); + } + + // --- [ glUniformMatrix2fv ] --- + + /** + * Unsafe version of: {@link #glUniformMatrix2fv UniformMatrix2fv} + * + * @param count the number of matrices that are to be modified. This should be 1 if the targeted uniform variable is not an array of matrices, and 1 or more if it is an array of matrices. + */ + public static void nglUniformMatrix2fv(int location, int count, boolean transpose, long value) { + GL20C.nglUniformMatrix2fv(location, count, transpose, value); + } + + /** + * Specifies the value of a single mat2 uniform variable or a mat2 uniform variable array for the current program object. + * + * @param location the location of the uniform variable to be modified + * @param transpose whether to transpose the matrix as the values are loaded into the uniform variable + * @param value a pointer to an array of {@code count} values that will be used to update the specified uniform variable + * + * @see Reference Page + */ + public static void glUniformMatrix2fv(@NativeType("GLint") int location, @NativeType("GLboolean") boolean transpose, @NativeType("GLfloat const *") FloatBuffer value) { + GL20C.glUniformMatrix2fv(location, transpose, value); + } + + // --- [ glUniformMatrix3fv ] --- + + /** + * Unsafe version of: {@link #glUniformMatrix3fv UniformMatrix3fv} + * + * @param count the number of matrices that are to be modified. This should be 1 if the targeted uniform variable is not an array of matrices, and 1 or more if it is an array of matrices. + */ + public static void nglUniformMatrix3fv(int location, int count, boolean transpose, long value) { + GL20C.nglUniformMatrix3fv(location, count, transpose, value); + } + + /** + * Specifies the value of a single mat3 uniform variable or a mat3 uniform variable array for the current program object. + * + * @param location the location of the uniform variable to be modified + * @param transpose whether to transpose the matrix as the values are loaded into the uniform variable + * @param value a pointer to an array of {@code count} values that will be used to update the specified uniform variable + * + * @see Reference Page + */ + public static void glUniformMatrix3fv(@NativeType("GLint") int location, @NativeType("GLboolean") boolean transpose, @NativeType("GLfloat const *") FloatBuffer value) { + GL20C.glUniformMatrix3fv(location, transpose, value); + } + + // --- [ glUniformMatrix4fv ] --- + + /** + * Unsafe version of: {@link #glUniformMatrix4fv UniformMatrix4fv} + * + * @param count the number of matrices that are to be modified. This should be 1 if the targeted uniform variable is not an array of matrices, and 1 or more if it is an array of matrices. + */ + public static void nglUniformMatrix4fv(int location, int count, boolean transpose, long value) { + GL20C.nglUniformMatrix4fv(location, count, transpose, value); + } + + /** + * Specifies the value of a single mat4 uniform variable or a mat4 uniform variable array for the current program object. + * + * @param location the location of the uniform variable to be modified + * @param transpose whether to transpose the matrix as the values are loaded into the uniform variable + * @param value a pointer to an array of {@code count} values that will be used to update the specified uniform variable + * + * @see Reference Page + */ + public static void glUniformMatrix4fv(@NativeType("GLint") int location, @NativeType("GLboolean") boolean transpose, @NativeType("GLfloat const *") FloatBuffer value) { + GL20C.glUniformMatrix4fv(location, transpose, value); + } + + // --- [ glGetShaderiv ] --- + + /** Unsafe version of: {@link #glGetShaderiv GetShaderiv} */ + public static void nglGetShaderiv(int shader, int pname, long params) { + GL20C.nglGetShaderiv(shader, pname, params); + } + + /** + * Returns a parameter from a shader object. + * + * @param shader the shader object to be queried + * @param pname the object parameter. One of:
{@link GL20C#GL_SHADER_TYPE SHADER_TYPE}{@link GL20C#GL_DELETE_STATUS DELETE_STATUS}{@link GL20C#GL_COMPILE_STATUS COMPILE_STATUS}{@link GL20C#GL_INFO_LOG_LENGTH INFO_LOG_LENGTH}{@link GL20C#GL_SHADER_SOURCE_LENGTH SHADER_SOURCE_LENGTH}
+ * @param params the requested object parameter + * + * @see Reference Page + */ + public static void glGetShaderiv(@NativeType("GLuint") int shader, @NativeType("GLenum") int pname, @NativeType("GLint *") IntBuffer params) { + GL20C.glGetShaderiv(shader, pname, params); + } + + /** + * Returns a parameter from a shader object. + * + * @param shader the shader object to be queried + * @param pname the object parameter. One of:
{@link GL20C#GL_SHADER_TYPE SHADER_TYPE}{@link GL20C#GL_DELETE_STATUS DELETE_STATUS}{@link GL20C#GL_COMPILE_STATUS COMPILE_STATUS}{@link GL20C#GL_INFO_LOG_LENGTH INFO_LOG_LENGTH}{@link GL20C#GL_SHADER_SOURCE_LENGTH SHADER_SOURCE_LENGTH}
+ * + * @see Reference Page + */ + @NativeType("void") + public static int glGetShaderi(@NativeType("GLuint") int shader, @NativeType("GLenum") int pname) { + return GL20C.glGetShaderi(shader, pname); + } + + // --- [ glGetProgramiv ] --- + + /** Unsafe version of: {@link #glGetProgramiv GetProgramiv} */ + public static void nglGetProgramiv(int program, int pname, long params) { + GL20C.nglGetProgramiv(program, pname, params); + } + + /** + * Returns a parameter from a program object. + * + * @param program the program object to be queried + * @param pname the object parameter. One of:
{@link GL20C#GL_DELETE_STATUS DELETE_STATUS}{@link GL20C#GL_LINK_STATUS LINK_STATUS}{@link GL20C#GL_VALIDATE_STATUS VALIDATE_STATUS}
{@link GL20C#GL_INFO_LOG_LENGTH INFO_LOG_LENGTH}{@link GL20C#GL_ATTACHED_SHADERS ATTACHED_SHADERS}{@link GL20C#GL_ACTIVE_ATTRIBUTES ACTIVE_ATTRIBUTES}
{@link GL20C#GL_ACTIVE_ATTRIBUTE_MAX_LENGTH ACTIVE_ATTRIBUTE_MAX_LENGTH}{@link GL20C#GL_ACTIVE_UNIFORMS ACTIVE_UNIFORMS}{@link GL20C#GL_ACTIVE_UNIFORM_MAX_LENGTH ACTIVE_UNIFORM_MAX_LENGTH}
{@link GL30#GL_TRANSFORM_FEEDBACK_BUFFER_MODE TRANSFORM_FEEDBACK_BUFFER_MODE}{@link GL30#GL_TRANSFORM_FEEDBACK_VARYINGS TRANSFORM_FEEDBACK_VARYINGS}{@link GL30#GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH}
{@link GL31#GL_ACTIVE_UNIFORM_BLOCKS ACTIVE_UNIFORM_BLOCKS}{@link GL31#GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH}{@link GL32#GL_GEOMETRY_VERTICES_OUT GEOMETRY_VERTICES_OUT}
{@link GL32#GL_GEOMETRY_INPUT_TYPE GEOMETRY_INPUT_TYPE}{@link GL32#GL_GEOMETRY_OUTPUT_TYPE GEOMETRY_OUTPUT_TYPE}{@link GL41#GL_PROGRAM_BINARY_LENGTH PROGRAM_BINARY_LENGTH}
{@link GL42#GL_ACTIVE_ATOMIC_COUNTER_BUFFERS ACTIVE_ATOMIC_COUNTER_BUFFERS}{@link GL43#GL_COMPUTE_WORK_GROUP_SIZE COMPUTE_WORK_GROUP_SIZE}
+ * @param params the requested object parameter + * + * @see Reference Page + */ + public static void glGetProgramiv(@NativeType("GLuint") int program, @NativeType("GLenum") int pname, @NativeType("GLint *") IntBuffer params) { + GL20C.glGetProgramiv(program, pname, params); + } + + /** + * Returns a parameter from a program object. + * + * @param program the program object to be queried + * @param pname the object parameter. One of:
{@link GL20C#GL_DELETE_STATUS DELETE_STATUS}{@link GL20C#GL_LINK_STATUS LINK_STATUS}{@link GL20C#GL_VALIDATE_STATUS VALIDATE_STATUS}
{@link GL20C#GL_INFO_LOG_LENGTH INFO_LOG_LENGTH}{@link GL20C#GL_ATTACHED_SHADERS ATTACHED_SHADERS}{@link GL20C#GL_ACTIVE_ATTRIBUTES ACTIVE_ATTRIBUTES}
{@link GL20C#GL_ACTIVE_ATTRIBUTE_MAX_LENGTH ACTIVE_ATTRIBUTE_MAX_LENGTH}{@link GL20C#GL_ACTIVE_UNIFORMS ACTIVE_UNIFORMS}{@link GL20C#GL_ACTIVE_UNIFORM_MAX_LENGTH ACTIVE_UNIFORM_MAX_LENGTH}
{@link GL30#GL_TRANSFORM_FEEDBACK_BUFFER_MODE TRANSFORM_FEEDBACK_BUFFER_MODE}{@link GL30#GL_TRANSFORM_FEEDBACK_VARYINGS TRANSFORM_FEEDBACK_VARYINGS}{@link GL30#GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH}
{@link GL31#GL_ACTIVE_UNIFORM_BLOCKS ACTIVE_UNIFORM_BLOCKS}{@link GL31#GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH}{@link GL32#GL_GEOMETRY_VERTICES_OUT GEOMETRY_VERTICES_OUT}
{@link GL32#GL_GEOMETRY_INPUT_TYPE GEOMETRY_INPUT_TYPE}{@link GL32#GL_GEOMETRY_OUTPUT_TYPE GEOMETRY_OUTPUT_TYPE}{@link GL41#GL_PROGRAM_BINARY_LENGTH PROGRAM_BINARY_LENGTH}
{@link GL42#GL_ACTIVE_ATOMIC_COUNTER_BUFFERS ACTIVE_ATOMIC_COUNTER_BUFFERS}{@link GL43#GL_COMPUTE_WORK_GROUP_SIZE COMPUTE_WORK_GROUP_SIZE}
+ * + * @see Reference Page + */ + @NativeType("void") + public static int glGetProgrami(@NativeType("GLuint") int program, @NativeType("GLenum") int pname) { + return GL20C.glGetProgrami(program, pname); + } + + // --- [ glGetShaderInfoLog ] --- + + /** + * Unsafe version of: {@link #glGetShaderInfoLog GetShaderInfoLog} + * + * @param maxLength the size of the character buffer for storing the returned information log + */ + public static void nglGetShaderInfoLog(int shader, int maxLength, long length, long infoLog) { + GL20C.nglGetShaderInfoLog(shader, maxLength, length, infoLog); + } + + /** + * Returns the information log for a shader object. + * + * @param shader the shader object whose information log is to be queried + * @param length the length of the string returned in {@code infoLog} (excluding the null terminator) + * @param infoLog an array of characters that is used to return the information log + * + * @see Reference Page + */ + public static void glGetShaderInfoLog(@NativeType("GLuint") int shader, @Nullable @NativeType("GLsizei *") IntBuffer length, @NativeType("GLchar *") ByteBuffer infoLog) { + GL20C.glGetShaderInfoLog(shader, length, infoLog); + } + + /** + * Returns the information log for a shader object. + * + * @param shader the shader object whose information log is to be queried + * @param maxLength the size of the character buffer for storing the returned information log + * + * @see Reference Page + */ + @NativeType("void") + public static String glGetShaderInfoLog(@NativeType("GLuint") int shader, @NativeType("GLsizei") int maxLength) { + return GL20C.glGetShaderInfoLog(shader, maxLength); + } + + /** + * Returns the information log for a shader object. + * + * @param shader the shader object whose information log is to be queried + * + * @see Reference Page + */ + @NativeType("void") + public static String glGetShaderInfoLog(@NativeType("GLuint") int shader) { + return glGetShaderInfoLog(shader, glGetShaderi(shader, GL_INFO_LOG_LENGTH)); + } + + // --- [ glGetProgramInfoLog ] --- + + /** + * Unsafe version of: {@link #glGetProgramInfoLog GetProgramInfoLog} + * + * @param maxLength the size of the character buffer for storing the returned information log + */ + public static void nglGetProgramInfoLog(int program, int maxLength, long length, long infoLog) { + GL20C.nglGetProgramInfoLog(program, maxLength, length, infoLog); + } + + /** + * Returns the information log for a program object. + * + * @param program the program object whose information log is to be queried + * @param length the length of the string returned in {@code infoLog} (excluding the null terminator) + * @param infoLog an array of characters that is used to return the information log + * + * @see Reference Page + */ + public static void glGetProgramInfoLog(@NativeType("GLuint") int program, @Nullable @NativeType("GLsizei *") IntBuffer length, @NativeType("GLchar *") ByteBuffer infoLog) { + GL20C.glGetProgramInfoLog(program, length, infoLog); + } + + /** + * Returns the information log for a program object. + * + * @param program the program object whose information log is to be queried + * @param maxLength the size of the character buffer for storing the returned information log + * + * @see Reference Page + */ + @NativeType("void") + public static String glGetProgramInfoLog(@NativeType("GLuint") int program, @NativeType("GLsizei") int maxLength) { + return GL20C.glGetProgramInfoLog(program, maxLength); + } + + /** + * Returns the information log for a program object. + * + * @param program the program object whose information log is to be queried + * + * @see Reference Page + */ + @NativeType("void") + public static String glGetProgramInfoLog(@NativeType("GLuint") int program) { + return glGetProgramInfoLog(program, glGetProgrami(program, GL_INFO_LOG_LENGTH)); + } + + // --- [ glGetAttachedShaders ] --- + + /** + * Unsafe version of: {@link #glGetAttachedShaders GetAttachedShaders} + * + * @param maxCount the size of the array for storing the returned object names + */ + public static void nglGetAttachedShaders(int program, int maxCount, long count, long shaders) { + GL20C.nglGetAttachedShaders(program, maxCount, count, shaders); + } + + /** + * Returns the shader objects attached to a program object. + * + * @param program the program object to be queried + * @param count the number of names actually returned in {@code shaders} + * @param shaders an array that is used to return the names of attached shader objects + * + * @see Reference Page + */ + public static void glGetAttachedShaders(@NativeType("GLuint") int program, @Nullable @NativeType("GLsizei *") IntBuffer count, @NativeType("GLuint *") IntBuffer shaders) { + GL20C.glGetAttachedShaders(program, count, shaders); + } + + // --- [ glGetUniformLocation ] --- + + /** Unsafe version of: {@link #glGetUniformLocation GetUniformLocation} */ + public static int nglGetUniformLocation(int program, long name) { + return GL20C.nglGetUniformLocation(program, name); + } + + /** + * Returns the location of a uniform variable. + * + * @param program the program object to be queried + * @param name a null terminated string containing the name of the uniform variable whose location is to be queried + * + * @see Reference Page + */ + @NativeType("GLint") + public static int glGetUniformLocation(@NativeType("GLuint") int program, @NativeType("GLchar const *") ByteBuffer name) { + return GL20C.glGetUniformLocation(program, name); + } + + /** + * Returns the location of a uniform variable. + * + * @param program the program object to be queried + * @param name a null terminated string containing the name of the uniform variable whose location is to be queried + * + * @see Reference Page + */ + @NativeType("GLint") + public static int glGetUniformLocation(@NativeType("GLuint") int program, @NativeType("GLchar const *") CharSequence name) { + return GL20C.glGetUniformLocation(program, name); + } + + // --- [ glGetActiveUniform ] --- + + /** + * Unsafe version of: {@link #glGetActiveUniform GetActiveUniform} + * + * @param maxLength the maximum number of characters OpenGL is allowed to write in the character buffer indicated by {@code name} + */ + public static void nglGetActiveUniform(int program, int index, int maxLength, long length, long size, long type, long name) { + GL20C.nglGetActiveUniform(program, index, maxLength, length, size, type, name); + } + + /** + * Returns information about an active uniform variable for the specified program object. + * + * @param program the program object to be queried + * @param index the index of the uniform variable to be queried + * @param length the number of characters actually written by OpenGL in the string indicated by {@code name} (excluding the null terminator) if a value other than NULL is passed + * @param size the size of the uniform variable + * @param type the data type of the uniform variable + * @param name a null terminated string containing the name of the uniform variable + * + * @see Reference Page + */ + public static void glGetActiveUniform(@NativeType("GLuint") int program, @NativeType("GLuint") int index, @Nullable @NativeType("GLsizei *") IntBuffer length, @NativeType("GLint *") IntBuffer size, @NativeType("GLenum *") IntBuffer type, @NativeType("GLchar *") ByteBuffer name) { + GL20C.glGetActiveUniform(program, index, length, size, type, name); + } + + /** + * Returns information about an active uniform variable for the specified program object. + * + * @param program the program object to be queried + * @param index the index of the uniform variable to be queried + * @param maxLength the maximum number of characters OpenGL is allowed to write in the character buffer indicated by {@code name} + * @param size the size of the uniform variable + * @param type the data type of the uniform variable + * + * @see Reference Page + */ + @NativeType("void") + public static String glGetActiveUniform(@NativeType("GLuint") int program, @NativeType("GLuint") int index, @NativeType("GLsizei") int maxLength, @NativeType("GLint *") IntBuffer size, @NativeType("GLenum *") IntBuffer type) { + return GL20C.glGetActiveUniform(program, index, maxLength, size, type); + } + + /** + * Returns information about an active uniform variable for the specified program object. + * + * @param program the program object to be queried + * @param index the index of the uniform variable to be queried + * @param size the size of the uniform variable + * @param type the data type of the uniform variable + * + * @see Reference Page + */ + @NativeType("void") + public static String glGetActiveUniform(@NativeType("GLuint") int program, @NativeType("GLuint") int index, @NativeType("GLint *") IntBuffer size, @NativeType("GLenum *") IntBuffer type) { + return glGetActiveUniform(program, index, glGetProgrami(program, GL_ACTIVE_UNIFORM_MAX_LENGTH), size, type); + } + + // --- [ glGetUniformfv ] --- + + /** Unsafe version of: {@link #glGetUniformfv GetUniformfv} */ + public static void nglGetUniformfv(int program, int location, long params) { + GL20C.nglGetUniformfv(program, location, params); + } + + /** + * Returns the float value(s) of a uniform variable. + * + * @param program the program object to be queried + * @param location the location of the uniform variable to be queried + * @param params the value of the specified uniform variable + * + * @see Reference Page + */ + public static void glGetUniformfv(@NativeType("GLuint") int program, @NativeType("GLint") int location, @NativeType("GLfloat *") FloatBuffer params) { + GL20C.glGetUniformfv(program, location, params); + } + + /** + * Returns the float value(s) of a uniform variable. + * + * @param program the program object to be queried + * @param location the location of the uniform variable to be queried + * + * @see Reference Page + */ + @NativeType("void") + public static float glGetUniformf(@NativeType("GLuint") int program, @NativeType("GLint") int location) { + return GL20C.glGetUniformf(program, location); + } + + // --- [ glGetUniformiv ] --- + + /** Unsafe version of: {@link #glGetUniformiv GetUniformiv} */ + public static void nglGetUniformiv(int program, int location, long params) { + GL20C.nglGetUniformiv(program, location, params); + } + + /** + * Returns the int value(s) of a uniform variable. + * + * @param program the program object to be queried + * @param location the location of the uniform variable to be queried + * @param params the value of the specified uniform variable + * + * @see Reference Page + */ + public static void glGetUniformiv(@NativeType("GLuint") int program, @NativeType("GLint") int location, @NativeType("GLint *") IntBuffer params) { + GL20C.glGetUniformiv(program, location, params); + } + + /** + * Returns the int value(s) of a uniform variable. + * + * @param program the program object to be queried + * @param location the location of the uniform variable to be queried + * + * @see Reference Page + */ + @NativeType("void") + public static int glGetUniformi(@NativeType("GLuint") int program, @NativeType("GLint") int location) { + return GL20C.glGetUniformi(program, location); + } + + // --- [ glGetShaderSource ] --- + + /** + * Unsafe version of: {@link #glGetShaderSource GetShaderSource} + * + * @param maxLength the size of the character buffer for storing the returned source code string + */ + public static void nglGetShaderSource(int shader, int maxLength, long length, long source) { + GL20C.nglGetShaderSource(shader, maxLength, length, source); + } + + /** + * Returns the source code string from a shader object. + * + * @param shader the shader object to be queried + * @param length the length of the string returned in source (excluding the null terminator) + * @param source an array of characters that is used to return the source code string + * + * @see Reference Page + */ + public static void glGetShaderSource(@NativeType("GLuint") int shader, @Nullable @NativeType("GLsizei *") IntBuffer length, @NativeType("GLchar *") ByteBuffer source) { + GL20C.glGetShaderSource(shader, length, source); + } + + /** + * Returns the source code string from a shader object. + * + * @param shader the shader object to be queried + * @param maxLength the size of the character buffer for storing the returned source code string + * + * @see Reference Page + */ + @NativeType("void") + public static String glGetShaderSource(@NativeType("GLuint") int shader, @NativeType("GLsizei") int maxLength) { + return GL20C.glGetShaderSource(shader, maxLength); + } + + /** + * Returns the source code string from a shader object. + * + * @param shader the shader object to be queried + * + * @see Reference Page + */ + @NativeType("void") + public static String glGetShaderSource(@NativeType("GLuint") int shader) { + return glGetShaderSource(shader, glGetShaderi(shader, GL_SHADER_SOURCE_LENGTH)); + } + + // --- [ glVertexAttrib1f ] --- + + /** + * Specifies the value of a generic vertex attribute. The y and z components are implicitly set to 0.0f and w to 1.0f. + * + * @param index the index of the generic vertex attribute to be modified + * @param v0 the vertex attribute x component + * + * @see Reference Page + */ + public static void glVertexAttrib1f(@NativeType("GLuint") int index, @NativeType("GLfloat") float v0) { + GL20C.glVertexAttrib1f(index, v0); + } + + // --- [ glVertexAttrib1s ] --- + + /** + * Short version of {@link #glVertexAttrib1f VertexAttrib1f}. + * + * @param index the index of the generic vertex attribute to be modified + * @param v0 the vertex attribute x component + * + * @see Reference Page + */ + public static void glVertexAttrib1s(@NativeType("GLuint") int index, @NativeType("GLshort") short v0) { + GL20C.glVertexAttrib1s(index, v0); + } + + // --- [ glVertexAttrib1d ] --- + + /** + * Double version of {@link #glVertexAttrib1f VertexAttrib1f}. + * + * @param index the index of the generic vertex attribute to be modified + * @param v0 the vertex attribute x component + * + * @see Reference Page + */ + public static void glVertexAttrib1d(@NativeType("GLuint") int index, @NativeType("GLdouble") double v0) { + GL20C.glVertexAttrib1d(index, v0); + } + + // --- [ glVertexAttrib2f ] --- + + /** + * Specifies the value of a generic vertex attribute. The y component is implicitly set to 0.0f and w to 1.0f. + * + * @param index the index of the generic vertex attribute to be modified + * @param v0 the vertex attribute x component + * @param v1 the vertex attribute y component + * + * @see Reference Page + */ + public static void glVertexAttrib2f(@NativeType("GLuint") int index, @NativeType("GLfloat") float v0, @NativeType("GLfloat") float v1) { + GL20C.glVertexAttrib2f(index, v0, v1); + } + + // --- [ glVertexAttrib2s ] --- + + /** + * Short version of {@link #glVertexAttrib2f VertexAttrib2f}. + * + * @param index the index of the generic vertex attribute to be modified + * @param v0 the vertex attribute x component + * @param v1 the vertex attribute y component + * + * @see Reference Page + */ + public static void glVertexAttrib2s(@NativeType("GLuint") int index, @NativeType("GLshort") short v0, @NativeType("GLshort") short v1) { + GL20C.glVertexAttrib2s(index, v0, v1); + } + + // --- [ glVertexAttrib2d ] --- + + /** + * Double version of {@link #glVertexAttrib2f VertexAttrib2f}. + * + * @param index the index of the generic vertex attribute to be modified + * @param v0 the vertex attribute x component + * @param v1 the vertex attribute y component + * + * @see Reference Page + */ + public static void glVertexAttrib2d(@NativeType("GLuint") int index, @NativeType("GLdouble") double v0, @NativeType("GLdouble") double v1) { + GL20C.glVertexAttrib2d(index, v0, v1); + } + + // --- [ glVertexAttrib3f ] --- + + /** + * Specifies the value of a generic vertex attribute. The w is implicitly set to 1.0f. + * + * @param index the index of the generic vertex attribute to be modified + * @param v0 the vertex attribute x component + * @param v1 the vertex attribute y component + * @param v2 the vertex attribute z component + * + * @see Reference Page + */ + public static void glVertexAttrib3f(@NativeType("GLuint") int index, @NativeType("GLfloat") float v0, @NativeType("GLfloat") float v1, @NativeType("GLfloat") float v2) { + GL20C.glVertexAttrib3f(index, v0, v1, v2); + } + + // --- [ glVertexAttrib3s ] --- + + /** + * Short version of {@link #glVertexAttrib3f VertexAttrib3f}. + * + * @param index the index of the generic vertex attribute to be modified + * @param v0 the vertex attribute x component + * @param v1 the vertex attribute y component + * @param v2 the vertex attribute z component + * + * @see Reference Page + */ + public static void glVertexAttrib3s(@NativeType("GLuint") int index, @NativeType("GLshort") short v0, @NativeType("GLshort") short v1, @NativeType("GLshort") short v2) { + GL20C.glVertexAttrib3s(index, v0, v1, v2); + } + + // --- [ glVertexAttrib3d ] --- + + /** + * Double version of {@link #glVertexAttrib3f VertexAttrib3f}. + * + * @param index the index of the generic vertex attribute to be modified + * @param v0 the vertex attribute x component + * @param v1 the vertex attribute y component + * @param v2 the vertex attribute z component + * + * @see Reference Page + */ + public static void glVertexAttrib3d(@NativeType("GLuint") int index, @NativeType("GLdouble") double v0, @NativeType("GLdouble") double v1, @NativeType("GLdouble") double v2) { + GL20C.glVertexAttrib3d(index, v0, v1, v2); + } + + // --- [ glVertexAttrib4f ] --- + + /** + * Specifies the value of a generic vertex attribute. + * + * @param index the index of the generic vertex attribute to be modified + * @param v0 the vertex attribute x component + * @param v1 the vertex attribute y component + * @param v2 the vertex attribute z component + * @param v3 the vertex attribute w component + * + * @see Reference Page + */ + public static void glVertexAttrib4f(@NativeType("GLuint") int index, @NativeType("GLfloat") float v0, @NativeType("GLfloat") float v1, @NativeType("GLfloat") float v2, @NativeType("GLfloat") float v3) { + GL20C.glVertexAttrib4f(index, v0, v1, v2, v3); + } + + // --- [ glVertexAttrib4s ] --- + + /** + * Short version of {@link #glVertexAttrib4f VertexAttrib4f}. + * + * @param index the index of the generic vertex attribute to be modified + * @param v0 the vertex attribute x component + * @param v1 the vertex attribute y component + * @param v2 the vertex attribute z component + * @param v3 the vertex attribute w component + * + * @see Reference Page + */ + public static void glVertexAttrib4s(@NativeType("GLuint") int index, @NativeType("GLshort") short v0, @NativeType("GLshort") short v1, @NativeType("GLshort") short v2, @NativeType("GLshort") short v3) { + GL20C.glVertexAttrib4s(index, v0, v1, v2, v3); + } + + // --- [ glVertexAttrib4d ] --- + + /** + * Double version of {@link #glVertexAttrib4f VertexAttrib4f}. + * + * @param index the index of the generic vertex attribute to be modified + * @param v0 the vertex attribute x component + * @param v1 the vertex attribute y component + * @param v2 the vertex attribute z component + * @param v3 the vertex attribute w component + * + * @see Reference Page + */ + public static void glVertexAttrib4d(@NativeType("GLuint") int index, @NativeType("GLdouble") double v0, @NativeType("GLdouble") double v1, @NativeType("GLdouble") double v2, @NativeType("GLdouble") double v3) { + GL20C.glVertexAttrib4d(index, v0, v1, v2, v3); + } + + // --- [ glVertexAttrib4Nub ] --- + + /** + * Normalized unsigned byte version of {@link #glVertexAttrib4f VertexAttrib4f}. + * + * @param index the index of the generic vertex attribute to be modified + * @param x the vertex attribute x component + * @param y the vertex attribute y component + * @param z the vertex attribute z component + * @param w the vertex attribute w component + * + * @see Reference Page + */ + public static void glVertexAttrib4Nub(@NativeType("GLuint") int index, @NativeType("GLubyte") byte x, @NativeType("GLubyte") byte y, @NativeType("GLubyte") byte z, @NativeType("GLubyte") byte w) { + GL20C.glVertexAttrib4Nub(index, x, y, z, w); + } + + // --- [ glVertexAttrib1fv ] --- + + /** Unsafe version of: {@link #glVertexAttrib1fv VertexAttrib1fv} */ + public static void nglVertexAttrib1fv(int index, long v) { + GL20C.nglVertexAttrib1fv(index, v); + } + + /** + * Pointer version of {@link #glVertexAttrib1f VertexAttrib1f}. + * + * @param index the index of the generic vertex attribute to be modified + * @param v the vertex attribute buffer + * + * @see Reference Page + */ + public static void glVertexAttrib1fv(@NativeType("GLuint") int index, @NativeType("GLfloat const *") FloatBuffer v) { + GL20C.glVertexAttrib1fv(index, v); + } + + // --- [ glVertexAttrib1sv ] --- + + /** Unsafe version of: {@link #glVertexAttrib1sv VertexAttrib1sv} */ + public static void nglVertexAttrib1sv(int index, long v) { + GL20C.nglVertexAttrib1sv(index, v); + } + + /** + * Pointer version of {@link #glVertexAttrib1s VertexAttrib1s}. + * + * @param index the index of the generic vertex attribute to be modified + * @param v the vertex attribute buffer + * + * @see Reference Page + */ + public static void glVertexAttrib1sv(@NativeType("GLuint") int index, @NativeType("GLshort const *") ShortBuffer v) { + GL20C.glVertexAttrib1sv(index, v); + } + + // --- [ glVertexAttrib1dv ] --- + + /** Unsafe version of: {@link #glVertexAttrib1dv VertexAttrib1dv} */ + public static void nglVertexAttrib1dv(int index, long v) { + GL20C.nglVertexAttrib1dv(index, v); + } + + /** + * Pointer version of {@link #glVertexAttrib1d VertexAttrib1d}. + * + * @param index the index of the generic vertex attribute to be modified + * @param v the vertex attribute buffer + * + * @see Reference Page + */ + public static void glVertexAttrib1dv(@NativeType("GLuint") int index, @NativeType("GLdouble const *") DoubleBuffer v) { + GL20C.glVertexAttrib1dv(index, v); + } + + // --- [ glVertexAttrib2fv ] --- + + /** Unsafe version of: {@link #glVertexAttrib2fv VertexAttrib2fv} */ + public static void nglVertexAttrib2fv(int index, long v) { + GL20C.nglVertexAttrib2fv(index, v); + } + + /** + * Pointer version of {@link #glVertexAttrib2f VertexAttrib2f}. + * + * @param index the index of the generic vertex attribute to be modified + * @param v the vertex attribute buffer + * + * @see Reference Page + */ + public static void glVertexAttrib2fv(@NativeType("GLuint") int index, @NativeType("GLfloat const *") FloatBuffer v) { + GL20C.glVertexAttrib2fv(index, v); + } + + // --- [ glVertexAttrib2sv ] --- + + /** Unsafe version of: {@link #glVertexAttrib2sv VertexAttrib2sv} */ + public static void nglVertexAttrib2sv(int index, long v) { + GL20C.nglVertexAttrib2sv(index, v); + } + + /** + * Pointer version of {@link #glVertexAttrib2s VertexAttrib2s}. + * + * @param index the index of the generic vertex attribute to be modified + * @param v the vertex attribute buffer + * + * @see Reference Page + */ + public static void glVertexAttrib2sv(@NativeType("GLuint") int index, @NativeType("GLshort const *") ShortBuffer v) { + GL20C.glVertexAttrib2sv(index, v); + } + + // --- [ glVertexAttrib2dv ] --- + + /** Unsafe version of: {@link #glVertexAttrib2dv VertexAttrib2dv} */ + public static void nglVertexAttrib2dv(int index, long v) { + GL20C.nglVertexAttrib2dv(index, v); + } + + /** + * Pointer version of {@link #glVertexAttrib2d VertexAttrib2d}. + * + * @param index the index of the generic vertex attribute to be modified + * @param v the vertex attribute buffer + * + * @see Reference Page + */ + public static void glVertexAttrib2dv(@NativeType("GLuint") int index, @NativeType("GLdouble const *") DoubleBuffer v) { + GL20C.glVertexAttrib2dv(index, v); + } + + // --- [ glVertexAttrib3fv ] --- + + /** Unsafe version of: {@link #glVertexAttrib3fv VertexAttrib3fv} */ + public static void nglVertexAttrib3fv(int index, long v) { + GL20C.nglVertexAttrib3fv(index, v); + } + + /** + * Pointer version of {@link #glVertexAttrib3f VertexAttrib3f}. + * + * @param index the index of the generic vertex attribute to be modified + * @param v the vertex attribute buffer + * + * @see Reference Page + */ + public static void glVertexAttrib3fv(@NativeType("GLuint") int index, @NativeType("GLfloat const *") FloatBuffer v) { + GL20C.glVertexAttrib3fv(index, v); + } + + // --- [ glVertexAttrib3sv ] --- + + /** Unsafe version of: {@link #glVertexAttrib3sv VertexAttrib3sv} */ + public static void nglVertexAttrib3sv(int index, long v) { + GL20C.nglVertexAttrib3sv(index, v); + } + + /** + * Pointer version of {@link #glVertexAttrib3s VertexAttrib3s}. + * + * @param index the index of the generic vertex attribute to be modified + * @param v the vertex attribute buffer + * + * @see Reference Page + */ + public static void glVertexAttrib3sv(@NativeType("GLuint") int index, @NativeType("GLshort const *") ShortBuffer v) { + GL20C.glVertexAttrib3sv(index, v); + } + + // --- [ glVertexAttrib3dv ] --- + + /** Unsafe version of: {@link #glVertexAttrib3dv VertexAttrib3dv} */ + public static void nglVertexAttrib3dv(int index, long v) { + GL20C.nglVertexAttrib3dv(index, v); + } + + /** + * Pointer version of {@link #glVertexAttrib3d VertexAttrib3d}. + * + * @param index the index of the generic vertex attribute to be modified + * @param v the vertex attribute buffer + * + * @see Reference Page + */ + public static void glVertexAttrib3dv(@NativeType("GLuint") int index, @NativeType("GLdouble const *") DoubleBuffer v) { + GL20C.glVertexAttrib3dv(index, v); + } + + // --- [ glVertexAttrib4fv ] --- + + /** Unsafe version of: {@link #glVertexAttrib4fv VertexAttrib4fv} */ + public static void nglVertexAttrib4fv(int index, long v) { + GL20C.nglVertexAttrib4fv(index, v); + } + + /** + * Pointer version of {@link #glVertexAttrib4f VertexAttrib4f}. + * + * @param index the index of the generic vertex attribute to be modified + * @param v the vertex attribute buffer + * + * @see Reference Page + */ + public static void glVertexAttrib4fv(@NativeType("GLuint") int index, @NativeType("GLfloat const *") FloatBuffer v) { + GL20C.glVertexAttrib4fv(index, v); + } + + // --- [ glVertexAttrib4sv ] --- + + /** Unsafe version of: {@link #glVertexAttrib4sv VertexAttrib4sv} */ + public static void nglVertexAttrib4sv(int index, long v) { + GL20C.nglVertexAttrib4sv(index, v); + } + + /** + * Pointer version of {@link #glVertexAttrib4s VertexAttrib4s}. + * + * @param index the index of the generic vertex attribute to be modified + * @param v the vertex attribute buffer + * + * @see Reference Page + */ + public static void glVertexAttrib4sv(@NativeType("GLuint") int index, @NativeType("GLshort const *") ShortBuffer v) { + GL20C.glVertexAttrib4sv(index, v); + } + + // --- [ glVertexAttrib4dv ] --- + + /** Unsafe version of: {@link #glVertexAttrib4dv VertexAttrib4dv} */ + public static void nglVertexAttrib4dv(int index, long v) { + GL20C.nglVertexAttrib4dv(index, v); + } + + /** + * Pointer version of {@link #glVertexAttrib4d VertexAttrib4d}. + * + * @param index the index of the generic vertex attribute to be modified + * @param v the vertex attribute buffer + * + * @see Reference Page + */ + public static void glVertexAttrib4dv(@NativeType("GLuint") int index, @NativeType("GLdouble const *") DoubleBuffer v) { + GL20C.glVertexAttrib4dv(index, v); + } + + // --- [ glVertexAttrib4iv ] --- + + /** Unsafe version of: {@link #glVertexAttrib4iv VertexAttrib4iv} */ + public static void nglVertexAttrib4iv(int index, long v) { + GL20C.nglVertexAttrib4iv(index, v); + } + + /** + * Integer pointer version of {@link #glVertexAttrib4f VertexAttrib4f}. + * + * @param index the index of the generic vertex attribute to be modified + * @param v the vertex attribute buffer + * + * @see Reference Page + */ + public static void glVertexAttrib4iv(@NativeType("GLuint") int index, @NativeType("GLint const *") IntBuffer v) { + GL20C.glVertexAttrib4iv(index, v); + } + + // --- [ glVertexAttrib4bv ] --- + + /** Unsafe version of: {@link #glVertexAttrib4bv VertexAttrib4bv} */ + public static void nglVertexAttrib4bv(int index, long v) { + GL20C.nglVertexAttrib4bv(index, v); + } + + /** + * Byte pointer version of {@link #glVertexAttrib4f VertexAttrib4f}. + * + * @param index the index of the generic vertex attribute to be modified + * @param v the vertex attribute buffer + * + * @see Reference Page + */ + public static void glVertexAttrib4bv(@NativeType("GLuint") int index, @NativeType("GLbyte const *") ByteBuffer v) { + GL20C.glVertexAttrib4bv(index, v); + } + + // --- [ glVertexAttrib4ubv ] --- + + /** Unsafe version of: {@link #glVertexAttrib4ubv VertexAttrib4ubv} */ + public static void nglVertexAttrib4ubv(int index, long v) { + GL20C.nglVertexAttrib4ubv(index, v); + } + + /** + * Pointer version of {@link #glVertexAttrib4Nub VertexAttrib4Nub}. + * + * @param index the index of the generic vertex attribute to be modified + * @param v the vertex attribute buffer + * + * @see Reference Page + */ + public static void glVertexAttrib4ubv(@NativeType("GLuint") int index, @NativeType("GLubyte const *") ByteBuffer v) { + GL20C.glVertexAttrib4ubv(index, v); + } + + // --- [ glVertexAttrib4usv ] --- + + /** Unsafe version of: {@link #glVertexAttrib4usv VertexAttrib4usv} */ + public static void nglVertexAttrib4usv(int index, long v) { + GL20C.nglVertexAttrib4usv(index, v); + } + + /** + * Unsigned short pointer version of {@link #glVertexAttrib4f VertexAttrib4f}. + * + * @param index the index of the generic vertex attribute to be modified + * @param v the vertex attribute buffer + * + * @see Reference Page + */ + public static void glVertexAttrib4usv(@NativeType("GLuint") int index, @NativeType("GLushort const *") ShortBuffer v) { + GL20C.glVertexAttrib4usv(index, v); + } + + // --- [ glVertexAttrib4uiv ] --- + + /** Unsafe version of: {@link #glVertexAttrib4uiv VertexAttrib4uiv} */ + public static void nglVertexAttrib4uiv(int index, long v) { + GL20C.nglVertexAttrib4uiv(index, v); + } + + /** + * Unsigned int pointer version of {@link #glVertexAttrib4f VertexAttrib4f}. + * + * @param index the index of the generic vertex attribute to be modified + * @param v the vertex attribute buffer + * + * @see Reference Page + */ + public static void glVertexAttrib4uiv(@NativeType("GLuint") int index, @NativeType("GLuint const *") IntBuffer v) { + GL20C.glVertexAttrib4uiv(index, v); + } + + // --- [ glVertexAttrib4Nbv ] --- + + /** Unsafe version of: {@link #glVertexAttrib4Nbv VertexAttrib4Nbv} */ + public static void nglVertexAttrib4Nbv(int index, long v) { + GL20C.nglVertexAttrib4Nbv(index, v); + } + + /** + * Normalized byte pointer version of {@link #glVertexAttrib4f VertexAttrib4f}. + * + * @param index the index of the generic vertex attribute to be modified + * @param v the vertex attribute buffer + * + * @see Reference Page + */ + public static void glVertexAttrib4Nbv(@NativeType("GLuint") int index, @NativeType("GLbyte const *") ByteBuffer v) { + GL20C.glVertexAttrib4Nbv(index, v); + } + + // --- [ glVertexAttrib4Nsv ] --- + + /** Unsafe version of: {@link #glVertexAttrib4Nsv VertexAttrib4Nsv} */ + public static void nglVertexAttrib4Nsv(int index, long v) { + GL20C.nglVertexAttrib4Nsv(index, v); + } + + /** + * Normalized short pointer version of {@link #glVertexAttrib4f VertexAttrib4f}. + * + * @param index the index of the generic vertex attribute to be modified + * @param v the vertex attribute buffer + * + * @see Reference Page + */ + public static void glVertexAttrib4Nsv(@NativeType("GLuint") int index, @NativeType("GLshort const *") ShortBuffer v) { + GL20C.glVertexAttrib4Nsv(index, v); + } + + // --- [ glVertexAttrib4Niv ] --- + + /** Unsafe version of: {@link #glVertexAttrib4Niv VertexAttrib4Niv} */ + public static void nglVertexAttrib4Niv(int index, long v) { + GL20C.nglVertexAttrib4Niv(index, v); + } + + /** + * Normalized int pointer version of {@link #glVertexAttrib4f VertexAttrib4f}. + * + * @param index the index of the generic vertex attribute to be modified + * @param v the vertex attribute buffer + * + * @see Reference Page + */ + public static void glVertexAttrib4Niv(@NativeType("GLuint") int index, @NativeType("GLint const *") IntBuffer v) { + GL20C.glVertexAttrib4Niv(index, v); + } + + // --- [ glVertexAttrib4Nubv ] --- + + /** Unsafe version of: {@link #glVertexAttrib4Nubv VertexAttrib4Nubv} */ + public static void nglVertexAttrib4Nubv(int index, long v) { + GL20C.nglVertexAttrib4Nubv(index, v); + } + + /** + * Normalized unsigned byte pointer version of {@link #glVertexAttrib4f VertexAttrib4f}. + * + * @param index the index of the generic vertex attribute to be modified + * @param v the vertex attribute buffer + * + * @see Reference Page + */ + public static void glVertexAttrib4Nubv(@NativeType("GLuint") int index, @NativeType("GLubyte const *") ByteBuffer v) { + GL20C.glVertexAttrib4Nubv(index, v); + } + + // --- [ glVertexAttrib4Nusv ] --- + + /** Unsafe version of: {@link #glVertexAttrib4Nusv VertexAttrib4Nusv} */ + public static void nglVertexAttrib4Nusv(int index, long v) { + GL20C.nglVertexAttrib4Nusv(index, v); + } + + /** + * Normalized unsigned short pointer version of {@link #glVertexAttrib4f VertexAttrib4f}. + * + * @param index the index of the generic vertex attribute to be modified + * @param v the vertex attribute buffer + * + * @see Reference Page + */ + public static void glVertexAttrib4Nusv(@NativeType("GLuint") int index, @NativeType("GLushort const *") ShortBuffer v) { + GL20C.glVertexAttrib4Nusv(index, v); + } + + // --- [ glVertexAttrib4Nuiv ] --- + + /** Unsafe version of: {@link #glVertexAttrib4Nuiv VertexAttrib4Nuiv} */ + public static void nglVertexAttrib4Nuiv(int index, long v) { + GL20C.nglVertexAttrib4Nuiv(index, v); + } + + /** + * Normalized unsigned int pointer version of {@link #glVertexAttrib4f VertexAttrib4f}. + * + * @param index the index of the generic vertex attribute to be modified + * @param v the vertex attribute buffer + * + * @see Reference Page + */ + public static void glVertexAttrib4Nuiv(@NativeType("GLuint") int index, @NativeType("GLuint const *") IntBuffer v) { + GL20C.glVertexAttrib4Nuiv(index, v); + } + + // --- [ glVertexAttribPointer ] --- + + /** Unsafe version of: {@link #glVertexAttribPointer VertexAttribPointer} */ + public static void nglVertexAttribPointer(int index, int size, int type, boolean normalized, int stride, long pointer) { + GL20C.nglVertexAttribPointer(index, size, type, normalized, stride, pointer); + } + + /** + * Specifies the location and organization of a vertex attribute array. + * + * @param index the index of the generic vertex attribute to be modified + * @param size the number of values per vertex that are stored in the array. The initial value is 4. One of:
1234{@link GL12#GL_BGRA BGRA}
+ * @param type the data type of each component in the array. The initial value is GL_FLOAT. One of:
{@link GL11#GL_BYTE BYTE}{@link GL11#GL_UNSIGNED_BYTE UNSIGNED_BYTE}{@link GL11#GL_SHORT SHORT}{@link GL11#GL_UNSIGNED_SHORT UNSIGNED_SHORT}{@link GL11#GL_INT INT}{@link GL11#GL_UNSIGNED_INT UNSIGNED_INT}{@link GL30#GL_HALF_FLOAT HALF_FLOAT}{@link GL11#GL_FLOAT FLOAT}
{@link GL11#GL_DOUBLE DOUBLE}{@link GL12#GL_UNSIGNED_INT_2_10_10_10_REV UNSIGNED_INT_2_10_10_10_REV}{@link GL33#GL_INT_2_10_10_10_REV INT_2_10_10_10_REV}{@link GL41#GL_FIXED FIXED}
+ * @param normalized whether fixed-point data values should be normalized or converted directly as fixed-point values when they are accessed + * @param stride the byte offset between consecutive generic vertex attributes. If stride is 0, the generic vertex attributes are understood to be tightly packed in + * the array. The initial value is 0. + * @param pointer the vertex attribute data or the offset of the first component of the first generic vertex attribute in the array in the data store of the buffer + * currently bound to the {@link GL15#GL_ARRAY_BUFFER ARRAY_BUFFER} target. The initial value is 0. + * + * @see Reference Page + */ + public static void glVertexAttribPointer(@NativeType("GLuint") int index, @NativeType("GLint") int size, @NativeType("GLenum") int type, @NativeType("GLboolean") boolean normalized, @NativeType("GLsizei") int stride, @NativeType("void const *") ByteBuffer pointer) { + GL20C.glVertexAttribPointer(index, size, type, normalized, stride, pointer); + } + + /** + * Specifies the location and organization of a vertex attribute array. + * + * @param index the index of the generic vertex attribute to be modified + * @param size the number of values per vertex that are stored in the array. The initial value is 4. One of:
1234{@link GL12#GL_BGRA BGRA}
+ * @param type the data type of each component in the array. The initial value is GL_FLOAT. One of:
{@link GL11#GL_BYTE BYTE}{@link GL11#GL_UNSIGNED_BYTE UNSIGNED_BYTE}{@link GL11#GL_SHORT SHORT}{@link GL11#GL_UNSIGNED_SHORT UNSIGNED_SHORT}{@link GL11#GL_INT INT}{@link GL11#GL_UNSIGNED_INT UNSIGNED_INT}{@link GL30#GL_HALF_FLOAT HALF_FLOAT}{@link GL11#GL_FLOAT FLOAT}
{@link GL11#GL_DOUBLE DOUBLE}{@link GL12#GL_UNSIGNED_INT_2_10_10_10_REV UNSIGNED_INT_2_10_10_10_REV}{@link GL33#GL_INT_2_10_10_10_REV INT_2_10_10_10_REV}{@link GL41#GL_FIXED FIXED}
+ * @param normalized whether fixed-point data values should be normalized or converted directly as fixed-point values when they are accessed + * @param stride the byte offset between consecutive generic vertex attributes. If stride is 0, the generic vertex attributes are understood to be tightly packed in + * the array. The initial value is 0. + * @param pointer the vertex attribute data or the offset of the first component of the first generic vertex attribute in the array in the data store of the buffer + * currently bound to the {@link GL15#GL_ARRAY_BUFFER ARRAY_BUFFER} target. The initial value is 0. + * + * @see Reference Page + */ + public static void glVertexAttribPointer(@NativeType("GLuint") int index, @NativeType("GLint") int size, @NativeType("GLenum") int type, @NativeType("GLboolean") boolean normalized, @NativeType("GLsizei") int stride, @NativeType("void const *") long pointer) { + GL20C.glVertexAttribPointer(index, size, type, normalized, stride, pointer); + } + + /** + * Specifies the location and organization of a vertex attribute array. + * + * @param index the index of the generic vertex attribute to be modified + * @param size the number of values per vertex that are stored in the array. The initial value is 4. One of:
1234{@link GL12#GL_BGRA BGRA}
+ * @param type the data type of each component in the array. The initial value is GL_FLOAT. One of:
{@link GL11#GL_BYTE BYTE}{@link GL11#GL_UNSIGNED_BYTE UNSIGNED_BYTE}{@link GL11#GL_SHORT SHORT}{@link GL11#GL_UNSIGNED_SHORT UNSIGNED_SHORT}{@link GL11#GL_INT INT}{@link GL11#GL_UNSIGNED_INT UNSIGNED_INT}{@link GL30#GL_HALF_FLOAT HALF_FLOAT}{@link GL11#GL_FLOAT FLOAT}
{@link GL11#GL_DOUBLE DOUBLE}{@link GL12#GL_UNSIGNED_INT_2_10_10_10_REV UNSIGNED_INT_2_10_10_10_REV}{@link GL33#GL_INT_2_10_10_10_REV INT_2_10_10_10_REV}{@link GL41#GL_FIXED FIXED}
+ * @param normalized whether fixed-point data values should be normalized or converted directly as fixed-point values when they are accessed + * @param stride the byte offset between consecutive generic vertex attributes. If stride is 0, the generic vertex attributes are understood to be tightly packed in + * the array. The initial value is 0. + * @param pointer the vertex attribute data or the offset of the first component of the first generic vertex attribute in the array in the data store of the buffer + * currently bound to the {@link GL15#GL_ARRAY_BUFFER ARRAY_BUFFER} target. The initial value is 0. + * + * @see Reference Page + */ + public static void glVertexAttribPointer(@NativeType("GLuint") int index, @NativeType("GLint") int size, @NativeType("GLenum") int type, @NativeType("GLboolean") boolean normalized, @NativeType("GLsizei") int stride, @NativeType("void const *") ShortBuffer pointer) { + GL20C.glVertexAttribPointer(index, size, type, normalized, stride, pointer); + } + + /** + * Specifies the location and organization of a vertex attribute array. + * + * @param index the index of the generic vertex attribute to be modified + * @param size the number of values per vertex that are stored in the array. The initial value is 4. One of:
1234{@link GL12#GL_BGRA BGRA}
+ * @param type the data type of each component in the array. The initial value is GL_FLOAT. One of:
{@link GL11#GL_BYTE BYTE}{@link GL11#GL_UNSIGNED_BYTE UNSIGNED_BYTE}{@link GL11#GL_SHORT SHORT}{@link GL11#GL_UNSIGNED_SHORT UNSIGNED_SHORT}{@link GL11#GL_INT INT}{@link GL11#GL_UNSIGNED_INT UNSIGNED_INT}{@link GL30#GL_HALF_FLOAT HALF_FLOAT}{@link GL11#GL_FLOAT FLOAT}
{@link GL11#GL_DOUBLE DOUBLE}{@link GL12#GL_UNSIGNED_INT_2_10_10_10_REV UNSIGNED_INT_2_10_10_10_REV}{@link GL33#GL_INT_2_10_10_10_REV INT_2_10_10_10_REV}{@link GL41#GL_FIXED FIXED}
+ * @param normalized whether fixed-point data values should be normalized or converted directly as fixed-point values when they are accessed + * @param stride the byte offset between consecutive generic vertex attributes. If stride is 0, the generic vertex attributes are understood to be tightly packed in + * the array. The initial value is 0. + * @param pointer the vertex attribute data or the offset of the first component of the first generic vertex attribute in the array in the data store of the buffer + * currently bound to the {@link GL15#GL_ARRAY_BUFFER ARRAY_BUFFER} target. The initial value is 0. + * + * @see Reference Page + */ + public static void glVertexAttribPointer(@NativeType("GLuint") int index, @NativeType("GLint") int size, @NativeType("GLenum") int type, @NativeType("GLboolean") boolean normalized, @NativeType("GLsizei") int stride, @NativeType("void const *") IntBuffer pointer) { + GL20C.glVertexAttribPointer(index, size, type, normalized, stride, pointer); + } + + /** + * Specifies the location and organization of a vertex attribute array. + * + * @param index the index of the generic vertex attribute to be modified + * @param size the number of values per vertex that are stored in the array. The initial value is 4. One of:
1234{@link GL12#GL_BGRA BGRA}
+ * @param type the data type of each component in the array. The initial value is GL_FLOAT. One of:
{@link GL11#GL_BYTE BYTE}{@link GL11#GL_UNSIGNED_BYTE UNSIGNED_BYTE}{@link GL11#GL_SHORT SHORT}{@link GL11#GL_UNSIGNED_SHORT UNSIGNED_SHORT}{@link GL11#GL_INT INT}{@link GL11#GL_UNSIGNED_INT UNSIGNED_INT}{@link GL30#GL_HALF_FLOAT HALF_FLOAT}{@link GL11#GL_FLOAT FLOAT}
{@link GL11#GL_DOUBLE DOUBLE}{@link GL12#GL_UNSIGNED_INT_2_10_10_10_REV UNSIGNED_INT_2_10_10_10_REV}{@link GL33#GL_INT_2_10_10_10_REV INT_2_10_10_10_REV}{@link GL41#GL_FIXED FIXED}
+ * @param normalized whether fixed-point data values should be normalized or converted directly as fixed-point values when they are accessed + * @param stride the byte offset between consecutive generic vertex attributes. If stride is 0, the generic vertex attributes are understood to be tightly packed in + * the array. The initial value is 0. + * @param pointer the vertex attribute data or the offset of the first component of the first generic vertex attribute in the array in the data store of the buffer + * currently bound to the {@link GL15#GL_ARRAY_BUFFER ARRAY_BUFFER} target. The initial value is 0. + * + * @see Reference Page + */ + public static void glVertexAttribPointer(@NativeType("GLuint") int index, @NativeType("GLint") int size, @NativeType("GLenum") int type, @NativeType("GLboolean") boolean normalized, @NativeType("GLsizei") int stride, @NativeType("void const *") FloatBuffer pointer) { + GL20C.glVertexAttribPointer(index, size, type, normalized, stride, pointer); + } + + // --- [ glEnableVertexAttribArray ] --- + + /** + * Enables a generic vertex attribute array. + * + * @param index the index of the generic vertex attribute to be enabled + * + * @see Reference Page + */ + public static void glEnableVertexAttribArray(@NativeType("GLuint") int index) { + GL20C.glEnableVertexAttribArray(index); + } + + // --- [ glDisableVertexAttribArray ] --- + + /** + * Disables a generic vertex attribute array. + * + * @param index the index of the generic vertex attribute to be disabled + * + * @see Reference Page + */ + public static void glDisableVertexAttribArray(@NativeType("GLuint") int index) { + GL20C.glDisableVertexAttribArray(index); + } + + // --- [ glBindAttribLocation ] --- + + /** Unsafe version of: {@link #glBindAttribLocation BindAttribLocation} */ + public static void nglBindAttribLocation(int program, int index, long name) { + GL20C.nglBindAttribLocation(program, index, name); + } + + /** + * Associates a generic vertex attribute index with a named attribute variable. + * + * @param program the program object in which the association is to be made + * @param index the index of the generic vertex attribute to be bound + * @param name a null terminated string containing the name of the vertex shader attribute variable to which {@code index} is to be bound + * + * @see Reference Page + */ + public static void glBindAttribLocation(@NativeType("GLuint") int program, @NativeType("GLuint") int index, @NativeType("GLchar const *") ByteBuffer name) { + GL20C.glBindAttribLocation(program, index, name); + } + + /** + * Associates a generic vertex attribute index with a named attribute variable. + * + * @param program the program object in which the association is to be made + * @param index the index of the generic vertex attribute to be bound + * @param name a null terminated string containing the name of the vertex shader attribute variable to which {@code index} is to be bound + * + * @see Reference Page + */ + public static void glBindAttribLocation(@NativeType("GLuint") int program, @NativeType("GLuint") int index, @NativeType("GLchar const *") CharSequence name) { + GL20C.glBindAttribLocation(program, index, name); + } + + // --- [ glGetActiveAttrib ] --- + + /** + * Unsafe version of: {@link #glGetActiveAttrib GetActiveAttrib} + * + * @param maxLength the maximum number of characters OpenGL is allowed to write in the character buffer indicated by {@code name} + */ + public static void nglGetActiveAttrib(int program, int index, int maxLength, long length, long size, long type, long name) { + GL20C.nglGetActiveAttrib(program, index, maxLength, length, size, type, name); + } + + /** + * Returns information about an active attribute variable for the specified program object. + * + * @param program the program object to be queried + * @param index the index of the attribute variable to be queried + * @param length the number of characters actually written by OpenGL in the string indicated by {@code name} (excluding the null terminator) if a value other than + * {@code NULL} is passed + * @param size the size of the attribute variable + * @param type the data type of the attribute variable + * @param name a null terminated string containing the name of the attribute variable + * + * @see Reference Page + */ + public static void glGetActiveAttrib(@NativeType("GLuint") int program, @NativeType("GLuint") int index, @Nullable @NativeType("GLsizei *") IntBuffer length, @NativeType("GLint *") IntBuffer size, @NativeType("GLenum *") IntBuffer type, @NativeType("GLchar *") ByteBuffer name) { + GL20C.glGetActiveAttrib(program, index, length, size, type, name); + } + + /** + * Returns information about an active attribute variable for the specified program object. + * + * @param program the program object to be queried + * @param index the index of the attribute variable to be queried + * @param maxLength the maximum number of characters OpenGL is allowed to write in the character buffer indicated by {@code name} + * @param size the size of the attribute variable + * @param type the data type of the attribute variable + * + * @see Reference Page + */ + @NativeType("void") + public static String glGetActiveAttrib(@NativeType("GLuint") int program, @NativeType("GLuint") int index, @NativeType("GLsizei") int maxLength, @NativeType("GLint *") IntBuffer size, @NativeType("GLenum *") IntBuffer type) { + return GL20C.glGetActiveAttrib(program, index, maxLength, size, type); + } + + /** + * Returns information about an active attribute variable for the specified program object. + * + * @param program the program object to be queried + * @param index the index of the attribute variable to be queried + * @param size the size of the attribute variable + * @param type the data type of the attribute variable + * + * @see Reference Page + */ + @NativeType("void") + public static String glGetActiveAttrib(@NativeType("GLuint") int program, @NativeType("GLuint") int index, @NativeType("GLint *") IntBuffer size, @NativeType("GLenum *") IntBuffer type) { + return glGetActiveAttrib(program, index, glGetProgrami(program, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH), size, type); + } + + // --- [ glGetAttribLocation ] --- + + /** Unsafe version of: {@link #glGetAttribLocation GetAttribLocation} */ + public static int nglGetAttribLocation(int program, long name) { + return GL20C.nglGetAttribLocation(program, name); + } + + /** + * Returns the location of an attribute variable. + * + * @param program the program object to be queried + * @param name a null terminated string containing the name of the attribute variable whose location is to be queried + * + * @see Reference Page + */ + @NativeType("GLint") + public static int glGetAttribLocation(@NativeType("GLuint") int program, @NativeType("GLchar const *") ByteBuffer name) { + return GL20C.glGetAttribLocation(program, name); + } + + /** + * Returns the location of an attribute variable. + * + * @param program the program object to be queried + * @param name a null terminated string containing the name of the attribute variable whose location is to be queried + * + * @see Reference Page + */ + @NativeType("GLint") + public static int glGetAttribLocation(@NativeType("GLuint") int program, @NativeType("GLchar const *") CharSequence name) { + return GL20C.glGetAttribLocation(program, name); + } + + // --- [ glGetVertexAttribiv ] --- + + /** Unsafe version of: {@link #glGetVertexAttribiv GetVertexAttribiv} */ + public static void nglGetVertexAttribiv(int index, int pname, long params) { + GL20C.nglGetVertexAttribiv(index, pname, params); + } + + /** + * Returns the integer value of a generic vertex attribute parameter. + * + * @param index the generic vertex attribute parameter to be queried + * @param pname the symbolic name of the vertex attribute parameter to be queried. One of:
{@link GL15#GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING VERTEX_ATTRIB_ARRAY_BUFFER_BINDING}{@link GL20C#GL_VERTEX_ATTRIB_ARRAY_ENABLED VERTEX_ATTRIB_ARRAY_ENABLED}
{@link GL20C#GL_VERTEX_ATTRIB_ARRAY_SIZE VERTEX_ATTRIB_ARRAY_SIZE}{@link GL20C#GL_VERTEX_ATTRIB_ARRAY_STRIDE VERTEX_ATTRIB_ARRAY_STRIDE}
{@link GL20C#GL_VERTEX_ATTRIB_ARRAY_TYPE VERTEX_ATTRIB_ARRAY_TYPE}{@link GL20C#GL_VERTEX_ATTRIB_ARRAY_NORMALIZED VERTEX_ATTRIB_ARRAY_NORMALIZED}
{@link GL20C#GL_CURRENT_VERTEX_ATTRIB CURRENT_VERTEX_ATTRIB}{@link GL30#GL_VERTEX_ATTRIB_ARRAY_INTEGER VERTEX_ATTRIB_ARRAY_INTEGER}
{@link GL33#GL_VERTEX_ATTRIB_ARRAY_DIVISOR VERTEX_ATTRIB_ARRAY_DIVISOR}
+ * @param params returns the requested data + * + * @see Reference Page + */ + public static void glGetVertexAttribiv(@NativeType("GLuint") int index, @NativeType("GLenum") int pname, @NativeType("GLint *") IntBuffer params) { + GL20C.glGetVertexAttribiv(index, pname, params); + } + + /** + * Returns the integer value of a generic vertex attribute parameter. + * + * @param index the generic vertex attribute parameter to be queried + * @param pname the symbolic name of the vertex attribute parameter to be queried. One of:
{@link GL15#GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING VERTEX_ATTRIB_ARRAY_BUFFER_BINDING}{@link GL20C#GL_VERTEX_ATTRIB_ARRAY_ENABLED VERTEX_ATTRIB_ARRAY_ENABLED}
{@link GL20C#GL_VERTEX_ATTRIB_ARRAY_SIZE VERTEX_ATTRIB_ARRAY_SIZE}{@link GL20C#GL_VERTEX_ATTRIB_ARRAY_STRIDE VERTEX_ATTRIB_ARRAY_STRIDE}
{@link GL20C#GL_VERTEX_ATTRIB_ARRAY_TYPE VERTEX_ATTRIB_ARRAY_TYPE}{@link GL20C#GL_VERTEX_ATTRIB_ARRAY_NORMALIZED VERTEX_ATTRIB_ARRAY_NORMALIZED}
{@link GL20C#GL_CURRENT_VERTEX_ATTRIB CURRENT_VERTEX_ATTRIB}{@link GL30#GL_VERTEX_ATTRIB_ARRAY_INTEGER VERTEX_ATTRIB_ARRAY_INTEGER}
{@link GL33#GL_VERTEX_ATTRIB_ARRAY_DIVISOR VERTEX_ATTRIB_ARRAY_DIVISOR}
+ * + * @see Reference Page + */ + @NativeType("void") + public static int glGetVertexAttribi(@NativeType("GLuint") int index, @NativeType("GLenum") int pname) { + return GL20C.glGetVertexAttribi(index, pname); + } + + // --- [ glGetVertexAttribfv ] --- + + /** Unsafe version of: {@link #glGetVertexAttribfv GetVertexAttribfv} */ + public static void nglGetVertexAttribfv(int index, int pname, long params) { + GL20C.nglGetVertexAttribfv(index, pname, params); + } + + /** + * Float version of {@link #glGetVertexAttribiv GetVertexAttribiv}. + * + * @param index the generic vertex attribute parameter to be queried + * @param pname the symbolic name of the vertex attribute parameter to be queried + * @param params returns the requested data + * + * @see Reference Page + */ + public static void glGetVertexAttribfv(@NativeType("GLuint") int index, @NativeType("GLenum") int pname, @NativeType("GLfloat *") FloatBuffer params) { + GL20C.glGetVertexAttribfv(index, pname, params); + } + + // --- [ glGetVertexAttribdv ] --- + + /** Unsafe version of: {@link #glGetVertexAttribdv GetVertexAttribdv} */ + public static void nglGetVertexAttribdv(int index, int pname, long params) { + GL20C.nglGetVertexAttribdv(index, pname, params); + } + + /** + * Double version of {@link #glGetVertexAttribiv GetVertexAttribiv}. + * + * @param index the generic vertex attribute parameter to be queried + * @param pname the symbolic name of the vertex attribute parameter to be queried + * @param params returns the requested data + * + * @see Reference Page + */ + public static void glGetVertexAttribdv(@NativeType("GLuint") int index, @NativeType("GLenum") int pname, @NativeType("GLdouble *") DoubleBuffer params) { + GL20C.glGetVertexAttribdv(index, pname, params); + } + + // --- [ glGetVertexAttribPointerv ] --- + + /** Unsafe version of: {@link #glGetVertexAttribPointerv GetVertexAttribPointerv} */ + public static void nglGetVertexAttribPointerv(int index, int pname, long pointer) { + GL20C.nglGetVertexAttribPointerv(index, pname, pointer); + } + + /** + * Returns the address of the specified generic vertex attribute pointer. + * + * @param index the generic vertex attribute parameter to be queried + * @param pname the symbolic name of the generic vertex attribute parameter to be returned. Must be:
{@link GL20C#GL_VERTEX_ATTRIB_ARRAY_POINTER VERTEX_ATTRIB_ARRAY_POINTER}
+ * @param pointer the pointer value + * + * @see Reference Page + */ + public static void glGetVertexAttribPointerv(@NativeType("GLuint") int index, @NativeType("GLenum") int pname, @NativeType("void **") PointerBuffer pointer) { + GL20C.glGetVertexAttribPointerv(index, pname, pointer); + } + + /** + * Returns the address of the specified generic vertex attribute pointer. + * + * @param index the generic vertex attribute parameter to be queried + * @param pname the symbolic name of the generic vertex attribute parameter to be returned. Must be:
{@link GL20C#GL_VERTEX_ATTRIB_ARRAY_POINTER VERTEX_ATTRIB_ARRAY_POINTER}
+ * + * @see Reference Page + */ + @NativeType("void") + public static long glGetVertexAttribPointer(@NativeType("GLuint") int index, @NativeType("GLenum") int pname) { + return GL20C.glGetVertexAttribPointer(index, pname); + } + + // --- [ glDrawBuffers ] --- + + /** + * Unsafe version of: {@link #glDrawBuffers DrawBuffers} + * + * @param n the number of buffers in {@code bufs} + */ + public static void nglDrawBuffers(int n, long bufs) { + GL20C.nglDrawBuffers(n, bufs); + } + + /** + * Specifies a list of color buffers to be drawn into. + * + * @param bufs an array of symbolic constants specifying the buffers into which fragment colors or data values will be written. One of:
{@link GL11#GL_NONE NONE}{@link GL11#GL_FRONT_LEFT FRONT_LEFT}{@link GL11#GL_FRONT_RIGHT FRONT_RIGHT}{@link GL11#GL_BACK_LEFT BACK_LEFT}{@link GL11#GL_BACK_RIGHT BACK_RIGHT}{@link GL30#GL_COLOR_ATTACHMENT0 COLOR_ATTACHMENT0}
GL30.GL_COLOR_ATTACHMENT[1-15]
+ * + * @see Reference Page + */ + public static void glDrawBuffers(@NativeType("GLenum const *") IntBuffer bufs) { + GL20C.glDrawBuffers(bufs); + } + + /** + * Specifies a list of color buffers to be drawn into. + * + * @see Reference Page + */ + public static void glDrawBuffers(@NativeType("GLenum const *") int buf) { + GL20C.glDrawBuffers(buf); + } + + // --- [ glBlendEquationSeparate ] --- + + /** + * Sets the RGB blend equation and the alpha blend equation separately. + * + * @param modeRGB the RGB blend equation, how the red, green, and blue components of the source and destination colors are combined. One of:
{@link GL14#GL_FUNC_ADD FUNC_ADD}{@link GL14#GL_FUNC_SUBTRACT FUNC_SUBTRACT}{@link GL14#GL_FUNC_REVERSE_SUBTRACT FUNC_REVERSE_SUBTRACT}{@link GL14#GL_MIN MIN}{@link GL14#GL_MAX MAX}
+ * @param modeAlpha the alpha blend equation, how the alpha component of the source and destination colors are combined + * + * @see Reference Page + */ + public static void glBlendEquationSeparate(@NativeType("GLenum") int modeRGB, @NativeType("GLenum") int modeAlpha) { + GL20C.glBlendEquationSeparate(modeRGB, modeAlpha); + } + + // --- [ glStencilOpSeparate ] --- + + /** + * Sets front and/or back stencil test actions. + * + * @param face whether front and/or back stencil state is updated. One of:
{@link GL11#GL_FRONT FRONT}{@link GL11#GL_BACK BACK}{@link GL11#GL_FRONT_AND_BACK FRONT_AND_BACK}
+ * @param sfail the action to take when the stencil test fails. The initial value is GL_KEEP. One of:
{@link GL11#GL_KEEP KEEP}{@link GL11#GL_ZERO ZERO}{@link GL11#GL_REPLACE REPLACE}{@link GL11#GL_INCR INCR}{@link GL14#GL_INCR_WRAP INCR_WRAP}{@link GL11#GL_DECR DECR}{@link GL14#GL_DECR_WRAP DECR_WRAP}{@link GL11#GL_INVERT INVERT}
+ * @param dpfail the stencil action when the stencil test passes, but the depth test fails. The initial value is GL_KEEP + * @param dppass the stencil action when both the stencil test and the depth test pass, or when the stencil test passes and either there is no depth buffer or depth + * testing is not enabled. The initial value is GL_KEEP + * + * @see Reference Page + */ + public static void glStencilOpSeparate(@NativeType("GLenum") int face, @NativeType("GLenum") int sfail, @NativeType("GLenum") int dpfail, @NativeType("GLenum") int dppass) { + GL20C.glStencilOpSeparate(face, sfail, dpfail, dppass); + } + + // --- [ glStencilFuncSeparate ] --- + + /** + * Sets front and/or back function and reference value for stencil testing. + * + * @param face whether front and/or back stencil state is updated. One of:
{@link GL11#GL_FRONT FRONT}{@link GL11#GL_BACK BACK}{@link GL11#GL_FRONT_AND_BACK FRONT_AND_BACK}
+ * @param func the test function. The initial value is GL_ALWAYS. One of:
{@link GL11#GL_NEVER NEVER}{@link GL11#GL_LESS LESS}{@link GL11#GL_LEQUAL LEQUAL}{@link GL11#GL_GREATER GREATER}{@link GL11#GL_GEQUAL GEQUAL}{@link GL11#GL_EQUAL EQUAL}{@link GL11#GL_NOTEQUAL NOTEQUAL}{@link GL11#GL_ALWAYS ALWAYS}
+ * @param ref the reference value for the stencil test. {@code ref} is clamped to the range [0, 2n – 1], where {@code n} is the number of bitplanes in the stencil + * buffer. The initial value is 0. + * @param mask a mask that is ANDed with both the reference value and the stored stencil value when the test is done. The initial value is all 1's. + * + * @see Reference Page + */ + public static void glStencilFuncSeparate(@NativeType("GLenum") int face, @NativeType("GLenum") int func, @NativeType("GLint") int ref, @NativeType("GLuint") int mask) { + GL20C.glStencilFuncSeparate(face, func, ref, mask); + } + + // --- [ glStencilMaskSeparate ] --- + + /** + * Controls the front and/or back writing of individual bits in the stencil planes. + * + * @param face whether front and/or back stencil writemask is updated. One of:
{@link GL11#GL_FRONT FRONT}{@link GL11#GL_BACK BACK}{@link GL11#GL_FRONT_AND_BACK FRONT_AND_BACK}
+ * @param mask a bit mask to enable and disable writing of individual bits in the stencil planes. Initially, the mask is all 1's. + * + * @see Reference Page + */ + public static void glStencilMaskSeparate(@NativeType("GLenum") int face, @NativeType("GLuint") int mask) { + GL20C.glStencilMaskSeparate(face, mask); + } + + /** + * Array version of: {@link #glShaderSource ShaderSource} + * + * @see Reference Page + */ + public static void glShaderSource(@NativeType("GLuint") int shader, @NativeType("GLchar const **") PointerBuffer strings, @Nullable @NativeType("GLint const *") int[] length) { + GL20C.glShaderSource(shader, strings, length); + } + + /** + * Array version of: {@link #glUniform1fv Uniform1fv} + * + * @see Reference Page + */ + public static void glUniform1fv(@NativeType("GLint") int location, @NativeType("GLfloat const *") float[] value) { + GL20C.glUniform1fv(location, value); + } + + /** + * Array version of: {@link #glUniform2fv Uniform2fv} + * + * @see Reference Page + */ + public static void glUniform2fv(@NativeType("GLint") int location, @NativeType("GLfloat const *") float[] value) { + GL20C.glUniform2fv(location, value); + } + + /** + * Array version of: {@link #glUniform3fv Uniform3fv} + * + * @see Reference Page + */ + public static void glUniform3fv(@NativeType("GLint") int location, @NativeType("GLfloat const *") float[] value) { + GL20C.glUniform3fv(location, value); + } + + /** + * Array version of: {@link #glUniform4fv Uniform4fv} + * + * @see Reference Page + */ + public static void glUniform4fv(@NativeType("GLint") int location, @NativeType("GLfloat const *") float[] value) { + GL20C.glUniform4fv(location, value); + } + + /** + * Array version of: {@link #glUniform1iv Uniform1iv} + * + * @see Reference Page + */ + public static void glUniform1iv(@NativeType("GLint") int location, @NativeType("GLint const *") int[] value) { + GL20C.glUniform1iv(location, value); + } + + /** + * Array version of: {@link #glUniform2iv Uniform2iv} + * + * @see Reference Page + */ + public static void glUniform2iv(@NativeType("GLint") int location, @NativeType("GLint const *") int[] value) { + GL20C.glUniform2iv(location, value); + } + + /** + * Array version of: {@link #glUniform3iv Uniform3iv} + * + * @see Reference Page + */ + public static void glUniform3iv(@NativeType("GLint") int location, @NativeType("GLint const *") int[] value) { + GL20C.glUniform3iv(location, value); + } + + /** + * Array version of: {@link #glUniform4iv Uniform4iv} + * + * @see Reference Page + */ + public static void glUniform4iv(@NativeType("GLint") int location, @NativeType("GLint const *") int[] value) { + GL20C.glUniform4iv(location, value); + } + + /** + * Array version of: {@link #glUniformMatrix2fv UniformMatrix2fv} + * + * @see Reference Page + */ + public static void glUniformMatrix2fv(@NativeType("GLint") int location, @NativeType("GLboolean") boolean transpose, @NativeType("GLfloat const *") float[] value) { + GL20C.glUniformMatrix2fv(location, transpose, value); + } + + /** + * Array version of: {@link #glUniformMatrix3fv UniformMatrix3fv} + * + * @see Reference Page + */ + public static void glUniformMatrix3fv(@NativeType("GLint") int location, @NativeType("GLboolean") boolean transpose, @NativeType("GLfloat const *") float[] value) { + GL20C.glUniformMatrix3fv(location, transpose, value); + } + + /** + * Array version of: {@link #glUniformMatrix4fv UniformMatrix4fv} + * + * @see Reference Page + */ + public static void glUniformMatrix4fv(@NativeType("GLint") int location, @NativeType("GLboolean") boolean transpose, @NativeType("GLfloat const *") float[] value) { + GL20C.glUniformMatrix4fv(location, transpose, value); + } + + /** + * Array version of: {@link #glGetShaderiv GetShaderiv} + * + * @see Reference Page + */ + public static void glGetShaderiv(@NativeType("GLuint") int shader, @NativeType("GLenum") int pname, @NativeType("GLint *") int[] params) { + GL20C.glGetShaderiv(shader, pname, params); + } + + /** + * Array version of: {@link #glGetProgramiv GetProgramiv} + * + * @see Reference Page + */ + public static void glGetProgramiv(@NativeType("GLuint") int program, @NativeType("GLenum") int pname, @NativeType("GLint *") int[] params) { + GL20C.glGetProgramiv(program, pname, params); + } + + /** + * Array version of: {@link #glGetShaderInfoLog GetShaderInfoLog} + * + * @see Reference Page + */ + public static void glGetShaderInfoLog(@NativeType("GLuint") int shader, @Nullable @NativeType("GLsizei *") int[] length, @NativeType("GLchar *") ByteBuffer infoLog) { + GL20C.glGetShaderInfoLog(shader, length, infoLog); + } + + /** + * Array version of: {@link #glGetProgramInfoLog GetProgramInfoLog} + * + * @see Reference Page + */ + public static void glGetProgramInfoLog(@NativeType("GLuint") int program, @Nullable @NativeType("GLsizei *") int[] length, @NativeType("GLchar *") ByteBuffer infoLog) { + GL20C.glGetProgramInfoLog(program, length, infoLog); + } + + /** + * Array version of: {@link #glGetAttachedShaders GetAttachedShaders} + * + * @see Reference Page + */ + public static void glGetAttachedShaders(@NativeType("GLuint") int program, @Nullable @NativeType("GLsizei *") int[] count, @NativeType("GLuint *") int[] shaders) { + GL20C.glGetAttachedShaders(program, count, shaders); + } + + /** + * Array version of: {@link #glGetActiveUniform GetActiveUniform} + * + * @see Reference Page + */ + public static void glGetActiveUniform(@NativeType("GLuint") int program, @NativeType("GLuint") int index, @Nullable @NativeType("GLsizei *") int[] length, @NativeType("GLint *") int[] size, @NativeType("GLenum *") int[] type, @NativeType("GLchar *") ByteBuffer name) { + GL20C.glGetActiveUniform(program, index, length, size, type, name); + } + + /** + * Array version of: {@link #glGetUniformfv GetUniformfv} + * + * @see Reference Page + */ + public static void glGetUniformfv(@NativeType("GLuint") int program, @NativeType("GLint") int location, @NativeType("GLfloat *") float[] params) { + GL20C.glGetUniformfv(program, location, params); + } + + /** + * Array version of: {@link #glGetUniformiv GetUniformiv} + * + * @see Reference Page + */ + public static void glGetUniformiv(@NativeType("GLuint") int program, @NativeType("GLint") int location, @NativeType("GLint *") int[] params) { + GL20C.glGetUniformiv(program, location, params); + } + + /** + * Array version of: {@link #glGetShaderSource GetShaderSource} + * + * @see Reference Page + */ + public static void glGetShaderSource(@NativeType("GLuint") int shader, @Nullable @NativeType("GLsizei *") int[] length, @NativeType("GLchar *") ByteBuffer source) { + GL20C.glGetShaderSource(shader, length, source); + } + + /** + * Array version of: {@link #glVertexAttrib1fv VertexAttrib1fv} + * + * @see Reference Page + */ + public static void glVertexAttrib1fv(@NativeType("GLuint") int index, @NativeType("GLfloat const *") float[] v) { + GL20C.glVertexAttrib1fv(index, v); + } + + /** + * Array version of: {@link #glVertexAttrib1sv VertexAttrib1sv} + * + * @see Reference Page + */ + public static void glVertexAttrib1sv(@NativeType("GLuint") int index, @NativeType("GLshort const *") short[] v) { + GL20C.glVertexAttrib1sv(index, v); + } + + /** + * Array version of: {@link #glVertexAttrib1dv VertexAttrib1dv} + * + * @see Reference Page + */ + public static void glVertexAttrib1dv(@NativeType("GLuint") int index, @NativeType("GLdouble const *") double[] v) { + GL20C.glVertexAttrib1dv(index, v); + } + + /** + * Array version of: {@link #glVertexAttrib2fv VertexAttrib2fv} + * + * @see Reference Page + */ + public static void glVertexAttrib2fv(@NativeType("GLuint") int index, @NativeType("GLfloat const *") float[] v) { + GL20C.glVertexAttrib2fv(index, v); + } + + /** + * Array version of: {@link #glVertexAttrib2sv VertexAttrib2sv} + * + * @see Reference Page + */ + public static void glVertexAttrib2sv(@NativeType("GLuint") int index, @NativeType("GLshort const *") short[] v) { + GL20C.glVertexAttrib2sv(index, v); + } + + /** + * Array version of: {@link #glVertexAttrib2dv VertexAttrib2dv} + * + * @see Reference Page + */ + public static void glVertexAttrib2dv(@NativeType("GLuint") int index, @NativeType("GLdouble const *") double[] v) { + GL20C.glVertexAttrib2dv(index, v); + } + + /** + * Array version of: {@link #glVertexAttrib3fv VertexAttrib3fv} + * + * @see Reference Page + */ + public static void glVertexAttrib3fv(@NativeType("GLuint") int index, @NativeType("GLfloat const *") float[] v) { + GL20C.glVertexAttrib3fv(index, v); + } + + /** + * Array version of: {@link #glVertexAttrib3sv VertexAttrib3sv} + * + * @see Reference Page + */ + public static void glVertexAttrib3sv(@NativeType("GLuint") int index, @NativeType("GLshort const *") short[] v) { + GL20C.glVertexAttrib3sv(index, v); + } + + /** + * Array version of: {@link #glVertexAttrib3dv VertexAttrib3dv} + * + * @see Reference Page + */ + public static void glVertexAttrib3dv(@NativeType("GLuint") int index, @NativeType("GLdouble const *") double[] v) { + GL20C.glVertexAttrib3dv(index, v); + } + + /** + * Array version of: {@link #glVertexAttrib4fv VertexAttrib4fv} + * + * @see Reference Page + */ + public static void glVertexAttrib4fv(@NativeType("GLuint") int index, @NativeType("GLfloat const *") float[] v) { + GL20C.glVertexAttrib4fv(index, v); + } + + /** + * Array version of: {@link #glVertexAttrib4sv VertexAttrib4sv} + * + * @see Reference Page + */ + public static void glVertexAttrib4sv(@NativeType("GLuint") int index, @NativeType("GLshort const *") short[] v) { + GL20C.glVertexAttrib4sv(index, v); + } + + /** + * Array version of: {@link #glVertexAttrib4dv VertexAttrib4dv} + * + * @see Reference Page + */ + public static void glVertexAttrib4dv(@NativeType("GLuint") int index, @NativeType("GLdouble const *") double[] v) { + GL20C.glVertexAttrib4dv(index, v); + } + + /** + * Array version of: {@link #glVertexAttrib4iv VertexAttrib4iv} + * + * @see Reference Page + */ + public static void glVertexAttrib4iv(@NativeType("GLuint") int index, @NativeType("GLint const *") int[] v) { + GL20C.glVertexAttrib4iv(index, v); + } + + /** + * Array version of: {@link #glVertexAttrib4usv VertexAttrib4usv} + * + * @see Reference Page + */ + public static void glVertexAttrib4usv(@NativeType("GLuint") int index, @NativeType("GLushort const *") short[] v) { + GL20C.glVertexAttrib4usv(index, v); + } + + /** + * Array version of: {@link #glVertexAttrib4uiv VertexAttrib4uiv} + * + * @see Reference Page + */ + public static void glVertexAttrib4uiv(@NativeType("GLuint") int index, @NativeType("GLuint const *") int[] v) { + GL20C.glVertexAttrib4uiv(index, v); + } + + /** + * Array version of: {@link #glVertexAttrib4Nsv VertexAttrib4Nsv} + * + * @see Reference Page + */ + public static void glVertexAttrib4Nsv(@NativeType("GLuint") int index, @NativeType("GLshort const *") short[] v) { + GL20C.glVertexAttrib4Nsv(index, v); + } + + /** + * Array version of: {@link #glVertexAttrib4Niv VertexAttrib4Niv} + * + * @see Reference Page + */ + public static void glVertexAttrib4Niv(@NativeType("GLuint") int index, @NativeType("GLint const *") int[] v) { + GL20C.glVertexAttrib4Niv(index, v); + } + + /** + * Array version of: {@link #glVertexAttrib4Nusv VertexAttrib4Nusv} + * + * @see Reference Page + */ + public static void glVertexAttrib4Nusv(@NativeType("GLuint") int index, @NativeType("GLushort const *") short[] v) { + GL20C.glVertexAttrib4Nusv(index, v); + } + + /** + * Array version of: {@link #glVertexAttrib4Nuiv VertexAttrib4Nuiv} + * + * @see Reference Page + */ + public static void glVertexAttrib4Nuiv(@NativeType("GLuint") int index, @NativeType("GLuint const *") int[] v) { + GL20C.glVertexAttrib4Nuiv(index, v); + } + + /** + * Array version of: {@link #glGetActiveAttrib GetActiveAttrib} + * + * @see Reference Page + */ + public static void glGetActiveAttrib(@NativeType("GLuint") int program, @NativeType("GLuint") int index, @Nullable @NativeType("GLsizei *") int[] length, @NativeType("GLint *") int[] size, @NativeType("GLenum *") int[] type, @NativeType("GLchar *") ByteBuffer name) { + GL20C.glGetActiveAttrib(program, index, length, size, type, name); + } + + /** + * Array version of: {@link #glGetVertexAttribiv GetVertexAttribiv} + * + * @see Reference Page + */ + public static void glGetVertexAttribiv(@NativeType("GLuint") int index, @NativeType("GLenum") int pname, @NativeType("GLint *") int[] params) { + GL20C.glGetVertexAttribiv(index, pname, params); + } + + /** + * Array version of: {@link #glGetVertexAttribfv GetVertexAttribfv} + * + * @see Reference Page + */ + public static void glGetVertexAttribfv(@NativeType("GLuint") int index, @NativeType("GLenum") int pname, @NativeType("GLfloat *") float[] params) { + GL20C.glGetVertexAttribfv(index, pname, params); + } + + /** + * Array version of: {@link #glGetVertexAttribdv GetVertexAttribdv} + * + * @see Reference Page + */ + public static void glGetVertexAttribdv(@NativeType("GLuint") int index, @NativeType("GLenum") int pname, @NativeType("GLdouble *") double[] params) { + GL20C.glGetVertexAttribdv(index, pname, params); + } + + /** + * Array version of: {@link #glDrawBuffers DrawBuffers} + * + * @see Reference Page + */ + public static void glDrawBuffers(@NativeType("GLenum const *") int[] bufs) { + GL20C.glDrawBuffers(bufs); + } + +} diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/opengl/GLContext.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/opengl/GLContext.java new file mode 100644 index 000000000..d68aac1ed --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/opengl/GLContext.java @@ -0,0 +1,15 @@ +package org.lwjgl.opengl; + + +public class GLContext { + + private static ContextCapabilities contextCapabilities = new ContextCapabilities(); + + public static GLContext createFromCurrent() { + return new GLContext(); + } + + public static ContextCapabilities getCapabilities() { + return contextCapabilities; + } +} diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/opengl/GLSync.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/opengl/GLSync.java new file mode 100644 index 000000000..04e11dd20 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/opengl/GLSync.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.PointerWrapperAbstract; + +/** + * This class is a wrapper around a GLsync pointer. + * + * @author spasi + */ +public final class GLSync extends PointerWrapperAbstract { + + GLSync(final long sync) { + super(sync); + } + +} diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/opengl/GlobalLock.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/opengl/GlobalLock.java new file mode 100644 index 000000000..0dc7c5eec --- /dev/null +++ b/jre_lwjgl3glfw/src/main/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 { + static final Object lock = new Object(); +} diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/opengl/InputImplementation.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/opengl/InputImplementation.java new file mode 100644 index 000000000..3f7de2c93 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/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/jre_lwjgl3glfw/src/main/java/org/lwjgl/opengl/OpenGLException.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/opengl/OpenGLException.java new file mode 100644 index 000000000..29fec005f --- /dev/null +++ b/jre_lwjgl3glfw/src/main/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$ + * $Id$ + */ +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/jre_lwjgl3glfw/src/main/java/org/lwjgl/opengl/Pbuffer.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/opengl/Pbuffer.java new file mode 100644 index 000000000..89aa09ed0 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/opengl/Pbuffer.java @@ -0,0 +1,320 @@ +/* + * Copyright (c) 2002-2008 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) 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.Sys; + +/** + *

+ * Pbuffer encapsulates an OpenGL pbuffer. + *

+ * + * This class is thread-safe. + * + * @author elias_naur + * @version $Revision$ + * $Id$ + */ +public final class Pbuffer extends DrawableGL { + /** + * Indicates that Pbuffers can be created. + */ + public static final int PBUFFER_SUPPORTED = 0;// mark as not 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; + + /** + * Width + */ + private final int width; + + /** + * Height + */ + private final int height; + + 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, attribs, renderTexture); + Context shared_context = null; + if ( shared_drawable == null ) + shared_drawable = Display.getDrawable(); // May be null + if (shared_drawable != null) + shared_context = ((DrawableLWJGL)shared_drawable).getContext(); + //this.context = new ContextGL(peer_info, attribs, (ContextGL)shared_context); + } + + private static PeerInfo createPbuffer(int width, int height, PixelFormat pixel_format, ContextAttribs attribs, 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, attribs, null, defaultAttribs); + } else + return Display.getImplementation().createPbuffer(width, height, pixel_format, attribs, + renderTexture.pixelFormatCaps, + renderTexture.pBufferAttribs); + } + + /** + * 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); + } + + /** + * Gets the Pbuffer capabilities. + * + * @return a bitmask of Pbuffer capabilities. + */ + public static int getCapabilities() { + return Display.getImplementation().getPbufferCapabilities(); + } + + // ----------------------------------------------------------------------------------------- + // ------------------------------- 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/jre_lwjgl3glfw/src/main/java/org/lwjgl/opengl/PeerInfo.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/opengl/PeerInfo.java new file mode 100644 index 000000000..95e04fae1 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/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$ + * $Id$ + */ +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 final synchronized 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 final synchronized 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/jre_lwjgl3glfw/src/main/java/org/lwjgl/opengl/PixelFormat.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/opengl/PixelFormat.java new file mode 100644 index 000000000..179638e4c --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/opengl/PixelFormat.java @@ -0,0 +1,424 @@ +/* + * Copyright (c) 2002-2008 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) 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().withDepthBits(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$ + */ +public final class PixelFormat implements PixelFormatLWJGL { + + /** + * 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 COLOR_SAMPLES_NV to use for Coverage Sample Anti-aliasing (CSAA). + * When this number is greater than 0, the {@code samples} property will be treated + * as if it were the COVERAGE_SAMPLES_NV property. + *

+ * This property is currently a no-op for the MacOS implementation. + */ + private int colorSamples; + /** 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) + * This property is currently a no-op for the MacOS implementation. + */ + private boolean floating_point_packed; + /** + * Whether this format specifies an sRGB format + * This property is currently a no-op for the MacOS implementation. + */ + 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.colorSamples = pf.colorSamples; + + 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; + } + + /** + * Returns a new PixelFormat object with the same properties as this PixelFormat and the new color samples values. + * A value greater than 0 is valid only if the {@code samples} property is also greater than 0. Additionally, the + * color samples value needs to be lower than or equal to the {@code samples} property. + * + * @param colorSamples the new color samples value. + * + * @return the new PixelFormat + */ + public PixelFormat withCoverageSamples(final int colorSamples) { + return withCoverageSamples(colorSamples, samples); + } + + /** + * Returns a new PixelFormat object with the same properties as this PixelFormat and the new color samples + * and coverage samples values. + * + * @param colorSamples the new color samples value. This value must be lower than or equal to the coverage samples value. + * @param coverageSamples the new coverage samples value. + * + * @return the new PixelFormat + */ + public PixelFormat withCoverageSamples(final int colorSamples, final int coverageSamples) { + if ( coverageSamples < 0 || colorSamples < 0 || (coverageSamples == 0 && 0 < colorSamples) || coverageSamples < colorSamples ) + throw new IllegalArgumentException("Invalid number of coverage samples specified: " + coverageSamples + " - " + colorSamples); + + final PixelFormat pf = new PixelFormat(this); + pf.samples = coverageSamples; + pf.colorSamples = colorSamples; + 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; + } + +} diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/opengl/PixelFormatLWJGL.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/opengl/PixelFormatLWJGL.java new file mode 100644 index 000000000..a160d0a3c --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/opengl/PixelFormatLWJGL.java @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2002-2011 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.lwjgl.opengl; + +/** + * [INTERNAL USE ONLY] + * + * @author Spasi + */ +public interface PixelFormatLWJGL { + // Marker interface +} diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/opengl/RenderTexture.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/opengl/RenderTexture.java new file mode 100644 index 000000000..ed8e3f965 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/opengl/RenderTexture.java @@ -0,0 +1,251 @@ +/* + * Copyright (c) 2002-2008 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) 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 static org.lwjgl.opengl.GL11.*; + +/** 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(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(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(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(); + } + +} diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/opengl/SharedDrawable.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/opengl/SharedDrawable.java new file mode 100644 index 000000000..ad80f2d71 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/opengl/SharedDrawable.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.LWJGLException; + +/** + * @author Spasi + */ + +/** + * A Drawable implementation that shares its context with another Drawable. This is useful + * for background loading of resources. See org.lwjgl.test.opengl.multithread.BackgroundLoad + * for an example. + * + * @author Spasi + */ +public final class SharedDrawable extends DrawableGL { + + public SharedDrawable(final Drawable drawable) throws LWJGLException { + this.context = (ContextGL)((DrawableLWJGL)drawable).createSharedContext(); + } + + public ContextGL createSharedContext() { + return context; + // throw new UnsupportedOperationException(); + } + +} diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/opengl/Sync.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/opengl/Sync.java new file mode 100644 index 000000000..f8f7b075e --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/opengl/Sync.java @@ -0,0 +1,186 @@ +/* + * Copyright (c) 2002-2012 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) 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.Sys; + +/** + * A highly accurate sync method that continually adapts to the system it runs + * on to provide reliable results. + * + * @author Riven + * @author kappaOne + */ +class Sync { + + /** number of nano seconds in a second */ + private static final long NANOS_IN_SECOND = 1000L * 1000L * 1000L; + + /** The time to sleep/yield until the next frame */ + private static long nextFrame = 0; + + /** whether the initialisation code has run */ + private static boolean initialised = false; + + /** + * for calculating the averages the previous sleep/yield times are stored + */ + private static RunningAvg sleepDurations = new RunningAvg(10); + private static RunningAvg yieldDurations = new RunningAvg(10); + + /** + * An accurate sync method that will attempt to run at a constant frame + * rate. It should be called once every frame. + * + * @param fps + * - the desired frame rate, in frames per second + */ + public static void sync(int fps) { + if (fps <= 0) + return; + if (!initialised) + initialise(); + + try { + // sleep until the average sleep time is greater than the time + // remaining till nextFrame + for (long t0 = getTime(), t1; (nextFrame - t0) > sleepDurations.avg(); t0 = t1) { + Thread.sleep(1); + sleepDurations.add((t1 = getTime()) - t0); // update average + // sleep time + } + + // slowly dampen sleep average if too high to avoid yielding too + // much + sleepDurations.dampenForLowResTicker(); + + // yield until the average yield time is greater than the time + // remaining till nextFrame + for (long t0 = getTime(), t1; (nextFrame - t0) > yieldDurations.avg(); t0 = t1) { + Thread.yield(); + yieldDurations.add((t1 = getTime()) - t0); // update average + // yield time + } + } catch (InterruptedException e) { + + } + + // schedule next frame, drop frame(s) if already too late for next frame + nextFrame = Math.max(nextFrame + NANOS_IN_SECOND / fps, getTime()); + } + + /** + * This method will initialise the sync method by setting initial values for + * sleepDurations/yieldDurations and nextFrame. + * + * If running on windows it will start the sleep timer fix. + */ + private static void initialise() { + initialised = true; + + sleepDurations.init(1000 * 1000); + yieldDurations.init((int) (-(getTime() - getTime()) * 1.333)); + + nextFrame = getTime(); + + String osName = System.getProperty("os.name"); + + if (osName.startsWith("Win")) { + // On windows the sleep functions can be highly inaccurate by + // over 10ms making in unusable. However it can be forced to + // be a bit more accurate by running a separate sleeping daemon + // thread. + Thread timerAccuracyThread = new Thread(new Runnable() { + public void run() { + try { + Thread.sleep(Long.MAX_VALUE); + } catch (Exception e) { + } + } + }); + + timerAccuracyThread.setName("LWJGL Timer"); + timerAccuracyThread.setDaemon(true); + timerAccuracyThread.start(); + } + } + + /** + * Get the system time in nano seconds + * + * @return will return the current time in nano's + */ + private static long getTime() { + return (Sys.getTime() * NANOS_IN_SECOND) / Sys.getTimerResolution(); + } + + private static class RunningAvg { + private final long[] slots; + private int offset; + + private static final long DAMPEN_THRESHOLD = 10 * 1000L * 1000L; // 10ms + private static final float DAMPEN_FACTOR = 0.9f; // don't change: 0.9f + // is exactly right! + + public RunningAvg(int slotCount) { + this.slots = new long[slotCount]; + this.offset = 0; + } + + public void init(long value) { + while (this.offset < this.slots.length) { + this.slots[this.offset++] = value; + } + } + + public void add(long value) { + this.slots[this.offset++ % this.slots.length] = value; + this.offset %= this.slots.length; + } + + public long avg() { + long sum = 0; + for (int i = 0; i < this.slots.length; i++) { + sum += this.slots[i]; + } + return sum / this.slots.length; + } + + public void dampenForLowResTicker() { + if (this.avg() > DAMPEN_THRESHOLD) { + for (int i = 0; i < this.slots.length; i++) { + this.slots[i] *= DAMPEN_FACTOR; + } + } + } + } +} diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/opengl/Util.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/opengl/Util.java new file mode 100644 index 000000000..cc2df2a7d --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/opengl/Util.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 static org.lwjgl.opengl.ARBImaging.*; +import static org.lwjgl.opengl.GL11.*; +import static org.lwjgl.opengl.GL30.*; + +/** + * Simple utility class. + * + * @author cix_foo + * @version $Revision$ + */ + +public final class Util { + + /** No c'tor */ + private Util() { + } + + /** + * Throws OpenGLException if glGetError() returns anything else than + * GL_NO_ERROR + * + */ + public static void checkGLError() throws OpenGLException { + int err = glGetError(); + if (err != 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 GL_NO_ERROR: + return "No error"; + case GL_INVALID_ENUM: + return "Invalid enum"; + case GL_INVALID_VALUE: + return "Invalid value"; + case GL_INVALID_OPERATION: + return "Invalid operation"; + case GL_STACK_OVERFLOW: + return "Stack overflow"; + case GL_STACK_UNDERFLOW: + return "Stack underflow"; + case GL_OUT_OF_MEMORY: + return "Out of memory"; + case GL_TABLE_TOO_LARGE: + return "Table too large"; + case GL_INVALID_FRAMEBUFFER_OPERATION: + return "Invalid framebuffer operation"; + default: + return null; + } + } +} diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/Color.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/Color.java new file mode 100644 index 000000000..8e03aaf09 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/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$ + * @version $Revision$ + * $Id$ + */ +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/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/Dimension.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/Dimension.java new file mode 100644 index 000000000..1b8ae7c32 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/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$ + * @version $Revision$ + * $Id$ + */ +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/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/Display.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/Display.java new file mode 100644 index 000000000..00eef0dbf --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/Display.java @@ -0,0 +1,243 @@ +/* + * Copyright (c) 2002-2008 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR 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: spasi $ + * @version $Revision: 3418 $ + * $Id: Display.java 3418 2010-09-28 21:11:35Z spasi $ + */ +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 ( DisplayMode mode : modes ) { + System.out.println(mode); + } + } + + 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 ( DisplayMode mode : ret ) { + System.out.println(mode); + } + } + + 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[] accessors; + + Sorter() { + accessors = new FieldAccessor[param.length]; + for (int i = 0; i < accessors.length; i ++) { + int idx = param[i].indexOf('='); + if (idx > 0) { + accessors[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) == '-') { + accessors[i] = new FieldAccessor(param[i].substring(1), -1, 0, false); + } else { + accessors[i] = new FieldAccessor(param[i], 1, 0, false); + } + } + } + + /** + * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object) + */ + public int compare(DisplayMode dm1, DisplayMode dm2) { + for ( FieldAccessor accessor : accessors ) { + int f1 = accessor.getInt(dm1); + int f2 = accessor.getInt(dm2); + + if ( accessor.usePreferred && f1 != f2 ) { + if ( f1 == accessor.preferred ) + return -1; + else if ( f2 == accessor.preferred ) + return 1; + else { + // Score according to the difference between the values + int absf1 = Math.abs(f1 - accessor.preferred); + int absf2 = Math.abs(f2 - accessor.preferred); + if ( absf1 < absf2 ) + return -1; + else if ( absf1 > absf2 ) + return 1; + else + continue; + } + } else if ( f1 < f2 ) + return accessor.order; + else if ( f1 == f2 ) + continue; + else + return -accessor.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 ( DisplayMode aDm : dm ) { + System.out.println(aDm); + } + } + for ( DisplayMode aDm : dm ) { + try { + if ( LWJGLUtil.DEBUG || DEBUG ) + System.out.println("Attempting to set displaymode: " + aDm); + org.lwjgl.opengl.Display.setDisplayMode(aDm); + return aDm; + } catch (Exception e) { + if ( LWJGLUtil.DEBUG || DEBUG ) { + System.out.println("Failed to set display mode to " + aDm); + e.printStackTrace(); + } + } + } + + throw new Exception("Failed to set display mode."); + } + +} diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/Point.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/Point.java new file mode 100644 index 000000000..5d17362e4 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/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$ + * @version $Revision$ + * $Id$ + */ +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/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/ReadableColor.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/ReadableColor.java new file mode 100644 index 000000000..9371cc87e --- /dev/null +++ b/jre_lwjgl3glfw/src/main/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$ + * @version $Revision$ + * $Id$ + */ +public interface ReadableColor { + + /** + * Return the red component (0..255) + * @return int + */ + int getRed(); + + /** + * Return the red component (0..255) + * @return int + */ + int getGreen(); + + /** + * Return the red component (0..255) + * @return int + */ + int getBlue(); + + /** + * Return the red component (0..255) + * @return int + */ + int getAlpha(); + + /** + * Return the red component + * @return int + */ + byte getRedByte(); + + /** + * Return the red component + * @return int + */ + byte getGreenByte(); + + /** + * Return the red component + * @return int + */ + byte getBlueByte(); + + /** + * Return the red component + * @return int + */ + byte getAlphaByte(); + + /** + * Write the RGBA color directly out to a ByteBuffer + * @param dest the buffer to write to + */ + void writeRGBA(ByteBuffer dest); + + /** + * Write the RGB color directly out to a ByteBuffer + * @param dest the buffer to write to + */ + void writeRGB(ByteBuffer dest); + + /** + * Write the ABGR color directly out to a ByteBuffer + * @param dest the buffer to write to + */ + void writeABGR(ByteBuffer dest); + + /** + * Write the BGR color directly out to a ByteBuffer + * @param dest the buffer to write to + */ + void writeBGR(ByteBuffer dest); + + /** + * Write the BGRA color directly out to a ByteBuffer + * @param dest the buffer to write to + */ + void writeBGRA(ByteBuffer dest); + + /** + * Write the ARGB color directly out to a ByteBuffer + * @param dest the buffer to write to + */ + void writeARGB(ByteBuffer dest); + + /* + * Some standard colors + */ + ReadableColor RED = new Color(255, 0, 0); + ReadableColor ORANGE = new Color(255, 128, 0); + ReadableColor YELLOW = new Color(255, 255, 0); + ReadableColor GREEN = new Color(0, 255, 0); + ReadableColor CYAN = new Color(0, 255, 255); + ReadableColor BLUE = new Color(0, 0, 255); + ReadableColor PURPLE = new Color(255, 0, 255); + ReadableColor WHITE = new Color(255, 255, 255); + ReadableColor BLACK = new Color(0, 0, 0); + ReadableColor LTGREY = new Color(192, 192, 192); + ReadableColor DKGREY = new Color(64, 64, 64); + ReadableColor GREY = new Color(128, 128, 128); + + + +} diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/ReadableDimension.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/ReadableDimension.java new file mode 100644 index 000000000..cb38a0a95 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/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$ + * @version $Revision$ + * $Id$ + */ +public interface ReadableDimension { + + /** + * Get the width + * @return int + */ + int getWidth(); + + /** + * Get the height + * @return int + */ + int getHeight(); + + /** + * Copy this ReadableDimension into a destination Dimension + * @param dest The destination + */ + void getSize(WritableDimension dest); + +} diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/ReadablePoint.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/ReadablePoint.java new file mode 100644 index 000000000..a256459dd --- /dev/null +++ b/jre_lwjgl3glfw/src/main/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$ + * @version $Revision$ + * $Id$ + */ +public interface ReadablePoint { + + /** + * @return int + */ + int getX(); + + /** + * @return int + */ + int getY(); + + /** + * Copy this ReadablePoint into a destination Point + * @param dest The destination Point, or null, to create a new Point + */ + void getLocation(WritablePoint dest); +} diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/ReadableRectangle.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/ReadableRectangle.java new file mode 100644 index 000000000..cced54f21 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/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$ + * @version $Revision$ + * $Id$ + */ +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 + */ + void getBounds(WritableRectangle dest); + +} diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/Rectangle.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/Rectangle.java new file mode 100644 index 000000000..88d233489 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/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$ + * @version $Revision$ + * $Id$ + */ +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/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/Renderable.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/Renderable.java new file mode 100644 index 000000000..fcb73ea7f --- /dev/null +++ b/jre_lwjgl3glfw/src/main/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$ + * @version $Revision$ + * $Id$ + */ +public interface Renderable { + + /** + * "Render" this thing. This will involve calls to the GL. + */ + void render(); + +} diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/Timer.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/Timer.java new file mode 100644 index 000000000..df148e91d --- /dev/null +++ b/jre_lwjgl3glfw/src/main/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$ + * $Id$ + */ +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; + + // 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/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/WaveData.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/WaveData.java new file mode 100644 index 000000000..d0f00813c --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/WaveData.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.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; + + +/** + * + * Utility class for loading wavefiles. + * + * @author Brian Matzon + * @version $Revision$ + * $Id$ + */ +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 { + // due to an issue with AudioSystem.getAudioInputStream + // and mixing unsigned and signed code + // we will use the reader directly + return create(AudioSystem.getAudioInputStream(path)); + //WaveFileReader wfr = new WaveFileReader(); + //return create(wfr.getAudioInputStream(new BufferedInputStream(path.openStream()))); + } catch (Exception e) { + org.lwjgl.system.APIUtil.apiLog("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(Thread.currentThread().getContextClassLoader().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.system.APIUtil.apiLog("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.system.APIUtil.apiLog("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.system.APIUtil.apiLog("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, audioformat.isBigEndian() ? ByteOrder.BIG_ENDIAN : ByteOrder.LITTLE_ENDIAN); + } 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, ByteOrder order) { + ByteBuffer dest = ByteBuffer.allocateDirect(audio_bytes.length); + dest.order(ByteOrder.nativeOrder()); + ByteBuffer src = ByteBuffer.wrap(audio_bytes); + src.order(order); + 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/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/WritableColor.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/WritableColor.java new file mode 100644 index 000000000..a1fb49cac --- /dev/null +++ b/jre_lwjgl3glfw/src/main/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$ + * @version $Revision$ + * $Id$ + */ +public interface WritableColor { + /** + * Set a color + */ + void set(int r, int g, int b, int a); + /** + * Set a color + */ + void set(byte r, byte g, byte b, byte a); + /** + * Set a color + */ + void set(int r, int g, int b); + /** + * Set a color + */ + void set(byte r, byte g, byte b); + /** + * Set the Red component + */ + void setRed(int red); + /** + * Set the Green component + */ + void setGreen(int green); + /** + * Set the Blue component + */ + void setBlue(int blue); + /** + * Set the Alpha component + */ + void setAlpha(int alpha); + /** + * Set the Red component + */ + void setRed(byte red); + /** + * Set the Green component + */ + void setGreen(byte green); + /** + * Set the Blue component + */ + void setBlue(byte blue); + /** + * Set the Alpha component + */ + void setAlpha(byte alpha); + /** + * Read a color from a byte buffer + * @param src The source buffer + */ + void readRGBA(ByteBuffer src); + /** + * Read a color from a byte buffer + * @param src The source buffer + */ + void readRGB(ByteBuffer src); + /** + * Read a color from a byte buffer + * @param src The source buffer + */ + void readARGB(ByteBuffer src); + /** + * Read a color from a byte buffer + * @param src The source buffer + */ + void readBGRA(ByteBuffer src); + /** + * Read a color from a byte buffer + * @param src The source buffer + */ + void readBGR(ByteBuffer src); + /** + * Read a color from a byte buffer + * @param src The source buffer + */ + void readABGR(ByteBuffer src); + /** + * Set this color's color by copying another color + * @param src The source color + */ + void setColor(ReadableColor src); +} \ No newline at end of file diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/WritableDimension.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/WritableDimension.java new file mode 100644 index 000000000..5e0497691 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/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$ + * @version $Revision$ + * $Id$ + + */ +public interface WritableDimension { + void setSize(int w, int h); + void setSize(ReadableDimension d); + /** + * Sets the height. + * @param height The height to set + */ + void setHeight(int height); + /** + * Sets the width. + * @param width The width to set + */ + void setWidth(int width); +} \ No newline at end of file diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/WritablePoint.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/WritablePoint.java new file mode 100644 index 000000000..6a398cb08 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/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$ + * @version $Revision$ + * $Id$ + */ +public interface WritablePoint { + void setLocation(int x, int y); + void setLocation(ReadablePoint p); + void setX(int x); + void setY(int y); +} \ No newline at end of file diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/WritableRectangle.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/WritableRectangle.java new file mode 100644 index 000000000..2b1da1681 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/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$ + * @version $Revision$ + * $Id$ + */ +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 + */ + void setBounds(int x, int y, int width, int height); + + /** + * Sets the bounds of the rectangle + * @param location + * @param size + */ + void setBounds(ReadablePoint location, ReadableDimension size); + + /** + * Sets the bounds of the rectangle + * @param src + */ + void setBounds(ReadableRectangle src); +} diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/XPMFile.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/XPMFile.java new file mode 100644 index 000000000..9b71de0d4 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/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[]; + + private static final int WIDTH = 0; + + private static final int HEIGHT = 1; + + private static final int NUMBER_OF_COLORS = 2; + + private static final 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((String)colorDefinition[0], (Integer)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 static 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 static 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 static 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, 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])); + int color = colors.get(key); + bytes[offset + (i * 4)] = (byte) ((color & 0x00ff0000) >> 16); + bytes[offset + ((i * 4) + 1)] = (byte) ((color & 0x0000ff00) >> 8); + bytes[offset + ((i * 4) + 2)] = (byte) ((color & 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/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/glu/Cylinder.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/glu/Cylinder.java new file mode 100644 index 000000000..f720092aa --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/glu/Cylinder.java @@ -0,0 +1,201 @@ +/* + * Copyright (c) 2002-2008 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR 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 static org.lwjgl.opengl.GL11.*; +import static org.lwjgl.util.glu.GLU.*; + +/** + * 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_INSIDE) { + nsign = -1.0f; + } else { + nsign = 1.0f; + } + + da = 2.0f * PI / slices; + dr = (topRadius - baseRadius) / stacks; + dz = height / stacks; + nz = (baseRadius - topRadius) / height; + // Z component of normal vectors + + if (super.drawStyle == GLU_POINT) { + glBegin(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++) { + glVertex3f((x * r), (y * r), z); + z += dz; + r += dr; + } + } + glEnd(); + } else if (super.drawStyle == GLU_LINE || super.drawStyle == GLU_SILHOUETTE) { + // Draw rings + if (super.drawStyle == GLU_LINE) { + z = 0.0f; + r = baseRadius; + for (j = 0; j <= stacks; j++) { + glBegin(GL_LINE_LOOP); + for (i = 0; i < slices; i++) { + x = cos((i * da)); + y = sin((i * da)); + normal3f(x * nsign, y * nsign, nz * nsign); + glVertex3f((x * r), (y * r), z); + } + glEnd(); + z += dz; + r += dr; + } + } else { + // draw one ring at each end + if (baseRadius != 0.0) { + glBegin(GL_LINE_LOOP); + for (i = 0; i < slices; i++) { + x = cos((i * da)); + y = sin((i * da)); + normal3f(x * nsign, y * nsign, nz * nsign); + glVertex3f((x * baseRadius), (y * baseRadius), 0.0f); + } + glEnd(); + glBegin(GL_LINE_LOOP); + for (i = 0; i < slices; i++) { + x = cos((i * da)); + y = sin((i * da)); + normal3f(x * nsign, y * nsign, nz * nsign); + glVertex3f((x * topRadius), (y * topRadius), height); + } + glEnd(); + } + } + // draw length lines + glBegin(GL_LINES); + for (i = 0; i < slices; i++) { + x = cos((i * da)); + y = sin((i * da)); + normal3f(x * nsign, y * nsign, nz * nsign); + glVertex3f((x * baseRadius), (y * baseRadius), 0.0f); + glVertex3f((x * topRadius), (y * topRadius), (height)); + } + glEnd(); + } else if (super.drawStyle == 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; + glBegin(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); + glVertex3f((x * r), (y * r), z); + normal3f((x * nsign), (y * nsign), (nz * nsign)); + TXTR_COORD(s, t + dt); + glVertex3f((x * (r + dr)), (y * (r + dr)), (z + dz)); + } else { + normal3f(x * nsign, y * nsign, nz * nsign); + TXTR_COORD(s, t); + glVertex3f((x * r), (y * r), z); + normal3f(x * nsign, y * nsign, nz * nsign); + TXTR_COORD(s, t + dt); + glVertex3f((x * (r + dr)), (y * (r + dr)), (z + dz)); + } + s += ds; + } // for slices + glEnd(); + r += dr; + t += dt; + z += dz; + } // for stacks + } + } +} diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/glu/Disk.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/glu/Disk.java new file mode 100644 index 000000000..18a2b9df1 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/glu/Disk.java @@ -0,0 +1,214 @@ +/* + * Copyright (c) 2002-2008 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR 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 static org.lwjgl.opengl.GL11.*; +import static org.lwjgl.util.glu.GLU.*; + +/** + * 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_NONE) { + if (super.orientation == GLU_OUTSIDE) { + glNormal3f(0.0f, 0.0f, +1.0f); + } + else { + glNormal3f(0.0f, 0.0f, -1.0f); + } + } + + da = 2.0f * PI / slices; + dr = (outerRadius - innerRadius) / loops; + + switch (super.drawStyle) { + case 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_OUTSIDE) { + int s; + glBegin(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); + glVertex2f(r2 * sa, r2 * ca); + TXTR_COORD(0.5f + sa * r1 / dtc, 0.5f + ca * r1 / dtc); + glVertex2f(r1 * sa, r1 * ca); + } + glEnd(); + } + else { + int s; + glBegin(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); + glVertex2f(r2 * sa, r2 * ca); + TXTR_COORD(0.5f - sa * r1 / dtc, 0.5f + ca * r1 / dtc); + glVertex2f(r1 * sa, r1 * ca); + } + glEnd(); + } + r1 = r2; + } + break; + } + case GLU_LINE: + { + int l, s; + /* draw loops */ + for (l = 0; l <= loops; l++) { + float r = innerRadius + l * dr; + glBegin(GL_LINE_LOOP); + for (s = 0; s < slices; s++) { + float a = s * da; + glVertex2f(r * sin(a), r * cos(a)); + } + glEnd(); + } + /* draw spokes */ + for (s = 0; s < slices; s++) { + float a = s * da; + float x = sin(a); + float y = cos(a); + glBegin(GL_LINE_STRIP); + for (l = 0; l <= loops; l++) { + float r = innerRadius + l * dr; + glVertex2f(r * x, r * y); + } + glEnd(); + } + break; + } + case GLU_POINT: + { + int s; + glBegin(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; + glVertex2f(r * x, r * y); + } + } + glEnd(); + break; + } + case GLU_SILHOUETTE: + { + if (innerRadius != 0.0) { + float a; + glBegin(GL_LINE_LOOP); + for (a = 0.0f; a < 2.0 * PI; a += da) { + float x = innerRadius * sin(a); + float y = innerRadius * cos(a); + glVertex2f(x, y); + } + glEnd(); + } + { + float a; + glBegin(GL_LINE_LOOP); + for (a = 0; a < 2.0f * PI; a += da) { + float x = outerRadius * sin(a); + float y = outerRadius * cos(a); + glVertex2f(x, y); + } + glEnd(); + } + break; + } + default: + return; + } + } + +} diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/glu/GLU.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/glu/GLU.java new file mode 100644 index 000000000..ba99ed1b9 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/glu/GLU.java @@ -0,0 +1,430 @@ +/* + * Copyright (c) 2002-2008 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR 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.util.glu.tessellation.GLUtessellatorImpl; +import org.lwjgl.opengl.Util; + +import static org.lwjgl.opengl.GL11.*; + +/** + * 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) { + + 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_INVALID_ENUM: + return "Invalid enum (glu)"; + case GLU_INVALID_VALUE: + return "Invalid value (glu)"; + case 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/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/glu/GLUtessellator.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/glu/GLUtessellator.java new file mode 100644 index 000000000..90c07ff9a --- /dev/null +++ b/jre_lwjgl3glfw/src/main/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 { + + void gluDeleteTess(); + + void gluTessProperty(int which, double value); + + /* Returns tessellator property */ + void gluGetTessProperty(int which, double[] value, + int value_offset); /* gluGetTessProperty() */ + + void gluTessNormal(double x, double y, double z); + + void gluTessCallback(int which, + GLUtessellatorCallback aCallback); + + void gluTessVertex(double[] coords, int coords_offset, + Object vertexData); + + void gluTessBeginPolygon(Object data); + + void gluTessBeginContour(); + + void gluTessEndContour(); + + void gluTessEndPolygon(); + + /*******************************************************/ + + /* Obsolete calls -- for backward compatibility */ + + void gluBeginPolygon(); + + /*ARGSUSED*/ + void gluNextContour(int type); + + void gluEndPolygon(); + +} diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/glu/GLUtessellatorCallback.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/glu/GLUtessellatorCallback.java new file mode 100644 index 000000000..0f913f778 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/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 + */ + 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 + */ + 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 + */ + 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 + */ + 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 + */ + 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 + */ + 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 + */ + 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 + */ + 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 + */ + 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 + */ + 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 + */ + 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 + */ + void errorData(int errnum, Object polygonData); + + //void mesh(com.sun.opengl.impl.tessellator.GLUmesh mesh); +} diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/glu/GLUtessellatorCallbackAdapter.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/glu/GLUtessellatorCallbackAdapter.java new file mode 100644 index 000000000..742529b47 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/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/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/glu/MipMap.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/glu/MipMap.java new file mode 100644 index 000000000..d3ba8ef73 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/glu/MipMap.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.util.glu; + +import java.nio.ByteBuffer; + +import org.lwjgl.BufferUtils; + +import static org.lwjgl.opengl.GL11.*; +import static org.lwjgl.util.glu.GLU.*; + +/** + * 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_INVALID_VALUE; + + final int bpp = bytesPerPixel(format, type); + if ( bpp == 0 ) + return GLU_INVALID_ENUM; + + final int maxSize = glGetInteger(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 + glPixelStorei(GL_PACK_ROW_LENGTH, 0); + glPixelStorei(GL_PACK_ALIGNMENT, 1); + glPixelStorei(GL_PACK_SKIP_ROWS, 0); + glPixelStorei(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 */ + glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + glPixelStorei(GL_UNPACK_SKIP_ROWS, 0); + glPixelStorei(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 */ + glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + glPixelStorei(GL_UNPACK_SKIP_ROWS, 0); + glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0); + } + + 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_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 GL_UNSIGNED_BYTE: + sizein = 1; + break; + case GL_FLOAT: + sizein = 4; + break; + default: + return GL_INVALID_ENUM; + } + + // Determine bytes per output type + switch ( typeOut ) { + case GL_UNSIGNED_BYTE: + sizeout = 1; + break; + case GL_FLOAT: + sizeout = 4; + break; + default: + return 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 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 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_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 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 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_INVALID_ENUM; + } + + return 0; + } +} diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/glu/PartialDisk.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/glu/PartialDisk.java new file mode 100644 index 000000000..e811436e8 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/glu/PartialDisk.java @@ -0,0 +1,358 @@ +/* + * Copyright (c) 2002-2008 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR 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 static org.lwjgl.opengl.GL11.*; +import static org.lwjgl.util.glu.GLU.*; + +/** + * 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 * PI; + for (i = 0; i <= slices; i++) { + angle = angleOffset + ((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_FLAT : + case GLU_SMOOTH : + if (super.orientation == GLU_OUTSIDE) { + glNormal3f(0.0f, 0.0f, 1.0f); + } else { + glNormal3f(0.0f, 0.0f, -1.0f); + } + break; + default : + case GLU_NONE : + break; + } + + switch (super.drawStyle) { + case GLU_FILL : + if (innerRadius == .0f) { + finish = loops - 1; + /* Triangle strip for inner polygons */ + glBegin(GL_TRIANGLE_FAN); + if (super.textureFlag) { + glTexCoord2f(0.5f, 0.5f); + } + 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_OUTSIDE) { + for (i = slices; i >= 0; i--) { + if (super.textureFlag) { + glTexCoord2f( + texLow * sinCache[i] + 0.5f, + texLow * cosCache[i] + 0.5f); + } + glVertex3f(radiusLow * sinCache[i], radiusLow * cosCache[i], 0.0f); + } + } else { + for (i = 0; i <= slices; i++) { + if (super.textureFlag) { + glTexCoord2f( + texLow * sinCache[i] + 0.5f, + texLow * cosCache[i] + 0.5f); + } + glVertex3f(radiusLow * sinCache[i], radiusLow * cosCache[i], 0.0f); + } + } + 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; + } + + glBegin(GL_QUAD_STRIP); + for (i = 0; i <= slices; i++) { + if (super.orientation == GLU_OUTSIDE) { + if (super.textureFlag) { + glTexCoord2f( + texLow * sinCache[i] + 0.5f, + texLow * cosCache[i] + 0.5f); + } + glVertex3f(radiusLow * sinCache[i], radiusLow * cosCache[i], 0.0f); + + if (super.textureFlag) { + glTexCoord2f( + texHigh * sinCache[i] + 0.5f, + texHigh * cosCache[i] + 0.5f); + } + glVertex3f( + radiusHigh * sinCache[i], + radiusHigh * cosCache[i], + 0.0f); + } else { + if (super.textureFlag) { + glTexCoord2f( + texHigh * sinCache[i] + 0.5f, + texHigh * cosCache[i] + 0.5f); + } + glVertex3f( + radiusHigh * sinCache[i], + radiusHigh * cosCache[i], + 0.0f); + + if (super.textureFlag) { + glTexCoord2f( + texLow * sinCache[i] + 0.5f, + texLow * cosCache[i] + 0.5f); + } + glVertex3f(radiusLow * sinCache[i], radiusLow * cosCache[i], 0.0f); + } + } + glEnd(); + } + break; + case GLU_POINT : + glBegin(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; + + glTexCoord2f( + texLow * sinCache[i] + 0.5f, + texLow * cosCache[i] + 0.5f); + } + glVertex3f(radiusLow * sintemp, radiusLow * costemp, 0.0f); + } + } + glEnd(); + break; + case GLU_LINE : + if (innerRadius == outerRadius) { + glBegin(GL_LINE_STRIP); + + for (i = 0; i <= slices; i++) { + if (super.textureFlag) { + glTexCoord2f(sinCache[i] / 2 + 0.5f, cosCache[i] / 2 + 0.5f); + } + glVertex3f(innerRadius * sinCache[i], innerRadius * cosCache[i], 0.0f); + } + glEnd(); + break; + } + for (j = 0; j <= loops; j++) { + radiusLow = outerRadius - deltaRadius * ((float) j / loops); + if (super.textureFlag) { + texLow = radiusLow / outerRadius / 2; + } + + glBegin(GL_LINE_STRIP); + for (i = 0; i <= slices; i++) { + if (super.textureFlag) { + glTexCoord2f( + texLow * sinCache[i] + 0.5f, + texLow * cosCache[i] + 0.5f); + } + glVertex3f(radiusLow * sinCache[i], radiusLow * cosCache[i], 0.0f); + } + glEnd(); + } + for (i = 0; i < slices2; i++) { + sintemp = sinCache[i]; + costemp = cosCache[i]; + glBegin(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) { + glTexCoord2f( + texLow * sinCache[i] + 0.5f, + texLow * cosCache[i] + 0.5f); + } + glVertex3f(radiusLow * sintemp, radiusLow * costemp, 0.0f); + } + glEnd(); + } + break; + case GLU_SILHOUETTE : + if (sweepAngle < 360.0f) { + for (i = 0; i <= slices; i += slices) { + sintemp = sinCache[i]; + costemp = cosCache[i]; + glBegin(GL_LINE_STRIP); + for (j = 0; j <= loops; j++) { + radiusLow = outerRadius - deltaRadius * ((float) j / loops); + + if (super.textureFlag) { + texLow = radiusLow / outerRadius / 2; + glTexCoord2f( + texLow * sinCache[i] + 0.5f, + texLow * cosCache[i] + 0.5f); + } + glVertex3f(radiusLow * sintemp, radiusLow * costemp, 0.0f); + } + glEnd(); + } + } + for (j = 0; j <= loops; j += loops) { + radiusLow = outerRadius - deltaRadius * ((float) j / loops); + if (super.textureFlag) { + texLow = radiusLow / outerRadius / 2; + } + + glBegin(GL_LINE_STRIP); + for (i = 0; i <= slices; i++) { + if (super.textureFlag) { + glTexCoord2f( + texLow * sinCache[i] + 0.5f, + texLow * cosCache[i] + 0.5f); + } + glVertex3f(radiusLow * sinCache[i], radiusLow * cosCache[i], 0.0f); + } + glEnd(); + if (innerRadius == outerRadius) + break; + } + break; + default : + break; + } + } +} diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/glu/PixelStoreState.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/glu/PixelStoreState.java new file mode 100644 index 000000000..2e75e363b --- /dev/null +++ b/jre_lwjgl3glfw/src/main/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 static 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 = glGetInteger(GL_UNPACK_ROW_LENGTH); + unpackAlignment = glGetInteger(GL_UNPACK_ALIGNMENT); + unpackSkipRows = glGetInteger(GL_UNPACK_SKIP_ROWS); + unpackSkipPixels = glGetInteger(GL_UNPACK_SKIP_PIXELS); + packRowLength = glGetInteger(GL_PACK_ROW_LENGTH); + packAlignment = glGetInteger(GL_PACK_ALIGNMENT); + packSkipRows = glGetInteger(GL_PACK_SKIP_ROWS); + packSkipPixels = glGetInteger(GL_PACK_SKIP_PIXELS); + } + + public void save() { + glPixelStorei(GL_UNPACK_ROW_LENGTH, unpackRowLength); + glPixelStorei(GL_UNPACK_ALIGNMENT, unpackAlignment); + glPixelStorei(GL_UNPACK_SKIP_ROWS, unpackSkipRows); + glPixelStorei(GL_UNPACK_SKIP_PIXELS, unpackSkipPixels); + glPixelStorei(GL_PACK_ROW_LENGTH, packRowLength); + glPixelStorei(GL_PACK_ALIGNMENT, packAlignment); + glPixelStorei(GL_PACK_SKIP_ROWS, packSkipRows); + glPixelStorei(GL_PACK_SKIP_PIXELS, packSkipPixels); + } + +} diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/glu/Project.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/glu/Project.java new file mode 100644 index 000000000..a4a999e6d --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/glu/Project.java @@ -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. + */ +package org.lwjgl.util.glu; + +import java.nio.FloatBuffer; +import java.nio.IntBuffer; + +import org.lwjgl.BufferUtils; + +import static 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); + + glMultMatrixf(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]); + + glMultMatrixf(matrix); + 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 */ + 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); + glScalef(viewport.get(viewport.position() + 2) / deltaX, viewport.get(viewport.position() + 3) / deltaY, 1.0f); + } +} diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/glu/Quadric.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/glu/Quadric.java new file mode 100644 index 000000000..3bbbf6e08 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/glu/Quadric.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.util.glu; + +import static org.lwjgl.opengl.GL11.*; +import static org.lwjgl.util.glu.GLU.*; + +/** + * 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_FILL; + orientation = GLU_OUTSIDE; + textureFlag = false; + normals = 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; + } + 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) 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/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/glu/Registry.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/glu/Registry.java new file mode 100644 index 000000000..41505673d --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/glu/Registry.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.util.glu; + +import static org.lwjgl.util.glu.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_VERSION) { + return versionString; + } else if (name == 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/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/glu/Sphere.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/glu/Sphere.java new file mode 100644 index 000000000..4e3351679 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/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 static org.lwjgl.opengl.GL11.*; +import static org.lwjgl.util.glu.GLU.*; + +/** + * 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_NONE; + + if (super.orientation == GLU_INSIDE) { + nsign = -1.0f; + } else { + nsign = 1.0f; + } + + drho = PI / stacks; + dtheta = 2.0f * PI / slices; + + if (super.drawStyle == GLU_FILL) { + if (!super.textureFlag) { + // draw +Z end as a triangle fan + glBegin(GL_TRIANGLE_FAN); + glNormal3f(0.0f, 0.0f, 1.0f); + 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) { + glNormal3f(x * nsign, y * nsign, z * nsign); + } + glVertex3f(x * radius, y * radius, z * radius); + } + 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; + glBegin(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) { + glNormal3f(x * nsign, y * nsign, z * nsign); + } + TXTR_COORD(s, t); + 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) { + glNormal3f(x * nsign, y * nsign, z * nsign); + } + TXTR_COORD(s, t - dt); + s += ds; + glVertex3f(x * radius, y * radius, z * radius); + } + glEnd(); + t -= dt; + } + + if (!super.textureFlag) { + // draw -Z end as a triangle fan + glBegin(GL_TRIANGLE_FAN); + glNormal3f(0.0f, 0.0f, -1.0f); + glVertex3f(0.0f, 0.0f, -radius * nsign); + rho = 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) + glNormal3f(x * nsign, y * nsign, z * nsign); + s -= ds; + glVertex3f(x * radius, y * radius, z * radius); + } + glEnd(); + } + } else if ( + super.drawStyle == GLU_LINE + || super.drawStyle == GLU_SILHOUETTE) { + // draw stack lines + for (i = 1; + i < stacks; + i++) { // stack line at i==stacks-1 was missing here + rho = i * drho; + glBegin(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) + glNormal3f(x * nsign, y * nsign, z * nsign); + glVertex3f(x * radius, y * radius, z * radius); + } + glEnd(); + } + // draw slice lines + for (j = 0; j < slices; j++) { + theta = j * dtheta; + glBegin(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) + glNormal3f(x * nsign, y * nsign, z * nsign); + glVertex3f(x * radius, y * radius, z * radius); + } + glEnd(); + } + } else if (super.drawStyle == GLU_POINT) { + // top and bottom-most points + glBegin(GL_POINTS); + if (normals) + glNormal3f(0.0f, 0.0f, nsign); + glVertex3f(0.0f, 0.0f, radius); + if (normals) + glNormal3f(0.0f, 0.0f, -nsign); + 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) + glNormal3f(x * nsign, y * nsign, z * nsign); + glVertex3f(x * radius, y * radius, z * radius); + } + } + glEnd(); + } + } + +} diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/glu/Util.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/glu/Util.java new file mode 100644 index 000000000..41a066fcf --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/glu/Util.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.util.glu; + +import static org.lwjgl.opengl.GL11.*; +import static org.lwjgl.opengl.GL12.*; + +/** + * Util.java + *

+ *

+ * Created 7-jan-2004 + * + * @author Erik Duijs + */ +public class Util { + + /** + * 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 GL_COLOR_INDEX: + case GL_STENCIL_INDEX: + case GL_DEPTH_COMPONENT: + case GL_RED: + case GL_GREEN: + case GL_BLUE: + case GL_ALPHA: + case GL_LUMINANCE: + return 1; + case GL_LUMINANCE_ALPHA: + return 2; + case GL_RGB: + case GL_BGR: + return 3; + case GL_RGBA: + case 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 GL_COLOR_INDEX: + case GL_STENCIL_INDEX: + case GL_DEPTH_COMPONENT: + case GL_RED: + case GL_GREEN: + case GL_BLUE: + case GL_ALPHA: + case GL_LUMINANCE: + n = 1; + break; + case GL_LUMINANCE_ALPHA: + n = 2; + break; + case GL_RGB: + case GL_BGR: + n = 3; + break; + case GL_RGBA: + case GL_BGRA: + n = 4; + break; + default : + n = 0; + } + + switch ( type ) { + case GL_UNSIGNED_BYTE: + m = 1; + break; + case GL_BYTE: + m = 1; + break; + case GL_BITMAP: + m = 1; + break; + case GL_UNSIGNED_SHORT: + m = 2; + break; + case GL_SHORT: + m = 2; + break; + case GL_UNSIGNED_INT: + m = 4; + break; + case GL_INT: + m = 4; + break; + case GL_FLOAT: + m = 4; + break; + default : + m = 0; + } + + return n * m; + } + +} diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/glu/tessellation/ActiveRegion.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/glu/tessellation/ActiveRegion.java new file mode 100644 index 000000000..7b566ec0f --- /dev/null +++ b/jre_lwjgl3glfw/src/main/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/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/glu/tessellation/CachedVertex.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/glu/tessellation/CachedVertex.java new file mode 100644 index 000000000..d69547609 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/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/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/glu/tessellation/Dict.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/glu/tessellation/Dict.java new file mode 100644 index 000000000..55c332092 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/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/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/glu/tessellation/DictNode.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/glu/tessellation/DictNode.java new file mode 100644 index 000000000..ec93eb5b1 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/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/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/glu/tessellation/GLUface.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/glu/tessellation/GLUface.java new file mode 100644 index 000000000..40ba208ae --- /dev/null +++ b/jre_lwjgl3glfw/src/main/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/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/glu/tessellation/GLUhalfEdge.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/glu/tessellation/GLUhalfEdge.java new file mode 100644 index 000000000..65824c633 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/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; + + GLUhalfEdge(boolean first) { + this.first = first; + } +} diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/glu/tessellation/GLUmesh.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/glu/tessellation/GLUmesh.java new file mode 100644 index 000000000..3aa41edbc --- /dev/null +++ b/jre_lwjgl3glfw/src/main/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/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/glu/tessellation/GLUtessellatorImpl.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/glu/tessellation/GLUtessellatorImpl.java new file mode 100644 index 000000000..dbbad30ea --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/glu/tessellation/GLUtessellatorImpl.java @@ -0,0 +1,669 @@ +/* + * Copyright (c) 2002-2008 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (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.GLUtessellator; +import org.lwjgl.util.glu.GLUtessellatorCallback; +import org.lwjgl.util.glu.GLUtessellatorCallbackAdapter; + +import static org.lwjgl.util.glu.GLU.*; + +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_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(); + } + } + + public static 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_TESS_MISSING_BEGIN_POLYGON); + gluTessBeginPolygon(null); + } else if (state == TessState.T_IN_POLYGON) { + callErrorOrErrorData(GLU_TESS_MISSING_BEGIN_CONTOUR); + gluTessBeginContour(); + } + } else { + if (state == TessState.T_IN_CONTOUR) { + callErrorOrErrorData(GLU_TESS_MISSING_END_CONTOUR); + gluTessEndContour(); + } else if (state == TessState.T_IN_POLYGON) { + callErrorOrErrorData(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_TESS_TOLERANCE: + if (value < 0.0 || value > 1.0) break; + relTolerance = value; + return; + + case GLU_TESS_WINDING_RULE: + int windingRule = (int) value; + if (windingRule != value) break; /* not an integer */ + + switch (windingRule) { + case GLU_TESS_WINDING_ODD: + case GLU_TESS_WINDING_NONZERO: + case GLU_TESS_WINDING_POSITIVE: + case GLU_TESS_WINDING_NEGATIVE: + case GLU_TESS_WINDING_ABS_GEQ_TWO: + this.windingRule = windingRule; + return; + default: + break; + } + + case GLU_TESS_BOUNDARY_ONLY: + boundaryOnly = (value != 0); + return; + + default: + callErrorOrErrorData(GLU_INVALID_ENUM); + return; + } + callErrorOrErrorData(GLU_INVALID_VALUE); + } + +/* Returns tessellator property */ + public void gluGetTessProperty(int which, double[] value, int value_offset) { + switch (which) { + case GLU_TESS_TOLERANCE: +/* tolerance should be in range [0..1] */ + assert (0.0 <= relTolerance && relTolerance <= 1.0); + value[value_offset] = relTolerance; + break; + case GLU_TESS_WINDING_RULE: + assert (windingRule == GLU_TESS_WINDING_ODD || + windingRule == GLU_TESS_WINDING_NONZERO || + windingRule == GLU_TESS_WINDING_POSITIVE || + windingRule == GLU_TESS_WINDING_NEGATIVE || + windingRule == GLU_TESS_WINDING_ABS_GEQ_TWO); + value[value_offset] = windingRule; + break; + case GLU_TESS_BOUNDARY_ONLY: + assert (boundaryOnly == true || boundaryOnly == false); + value[value_offset] = boundaryOnly ? 1 : 0; + break; + default: + value[value_offset] = 0.0; + callErrorOrErrorData(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_TESS_BEGIN: + callBegin = aCallback == null ? NULL_CB : aCallback; + return; + case GLU_TESS_BEGIN_DATA: + callBeginData = aCallback == null ? NULL_CB : aCallback; + return; + case 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_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_TESS_VERTEX: + callVertex = aCallback == null ? NULL_CB : aCallback; + return; + case GLU_TESS_VERTEX_DATA: + callVertexData = aCallback == null ? NULL_CB : aCallback; + return; + case GLU_TESS_END: + callEnd = aCallback == null ? NULL_CB : aCallback; + return; + case GLU_TESS_END_DATA: + callEndData = aCallback == null ? NULL_CB : aCallback; + return; + case GLU_TESS_ERROR: + callError = aCallback == null ? NULL_CB : aCallback; + return; + case GLU_TESS_ERROR_DATA: + callErrorData = aCallback == null ? NULL_CB : aCallback; + return; + case GLU_TESS_COMBINE: + callCombine = aCallback == null ? NULL_CB : aCallback; + return; + case 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_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_OUT_OF_MEMORY); + return; + } + lastEdge = null; + } + for (i = 0; i < 3; ++i) { + x = coords[i+coords_offset]; + if (x < -GLU_TESS_MAX_COORD) { + x = -GLU_TESS_MAX_COORD; + tooLarge = true; + } + if (x > GLU_TESS_MAX_COORD) { + x = GLU_TESS_MAX_COORD; + tooLarge = true; + } + clamped[i] = x; + } + if (tooLarge) { + callErrorOrErrorData(GLU_TESS_COORD_TOO_LARGE); + } + + if (mesh == null) { + if (cacheCount < TESS_MAX_CACHE) { + cacheVertex(clamped, vertexData); + return; + } + if (!flushCache()) { + callErrorOrErrorData(GLU_OUT_OF_MEMORY); + return; + } + } + + if (!addVertex(clamped, vertexData)) { + callErrorOrErrorData(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_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/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/glu/tessellation/GLUvertex.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/glu/tessellation/GLUvertex.java new file mode 100644 index 000000000..374c968c3 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/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/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/glu/tessellation/Geom.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/glu/tessellation/Geom.java new file mode 100644 index 000000000..23fef1fc6 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/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/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/glu/tessellation/Mesh.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/glu/tessellation/Mesh.java new file mode 100644 index 000000000..11d10f4d0 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/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/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/glu/tessellation/Normal.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/glu/tessellation/Normal.java new file mode 100644 index 000000000..334081a78 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/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; + 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/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/glu/tessellation/PriorityQ.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/glu/tessellation/PriorityQ.java new file mode 100644 index 000000000..92bee8233 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/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 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/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/glu/tessellation/PriorityQHeap.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/glu/tessellation/PriorityQHeap.java new file mode 100644 index 000000000..2a177cb80 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/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 */ +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/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/glu/tessellation/PriorityQSort.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/glu/tessellation/PriorityQSort.java new file mode 100644 index 000000000..21dff93b5 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/glu/tessellation/PriorityQSort.java @@ -0,0 +1,310 @@ +/* + * Copyright (c) 2002-2008 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (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; + + 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; + } + } + + 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/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/glu/tessellation/Render.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/glu/tessellation/Render.java new file mode 100644 index 000000000..13ef9f400 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/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 static org.lwjgl.opengl.GL11.*; +import static 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 { + private FaceCount() { + } + + private 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 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; + + 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(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(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(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(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_TESS_WINDING_ODD: + case GLU_TESS_WINDING_NONZERO: + break; + case GLU_TESS_WINDING_POSITIVE: + if (sign < 0) return true; + break; + case GLU_TESS_WINDING_NEGATIVE: + if (sign > 0) return true; + break; + case GLU_TESS_WINDING_ABS_GEQ_TWO: + return true; + } + + tess.callBeginOrBeginData( tess.boundaryOnly ? GL_LINE_LOOP + : (tess.cacheCount > 3) ? GL_TRIANGLE_FAN + : 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/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/glu/tessellation/Sweep.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/glu/tessellation/Sweep.java new file mode 100644 index 000000000..e8cc98c15 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/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 static 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_TESS_WINDING_ODD: + return (n & 1) != 0; + case GLU_TESS_WINDING_NONZERO: + return (n != 0); + case GLU_TESS_WINDING_POSITIVE: + return (n > 0); + case GLU_TESS_WINDING_NEGATIVE: + return (n < 0); + case 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_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_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/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/glu/tessellation/TessMono.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/glu/tessellation/TessMono.java new file mode 100644 index 000000000..10890e661 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/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/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/glu/tessellation/TessState.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/glu/tessellation/TessState.java new file mode 100644 index 000000000..1c5c396e5 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/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/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/input/ControllerAdapter.java.z b/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/input/ControllerAdapter.java.z new file mode 100644 index 000000000..8c1226a6f --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/input/ControllerAdapter.java.z @@ -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.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) { + } + + public int getRumblerCount() { + return 0; + } + + public String getRumblerName(int index) { + return "rumber n/a"; + } + + public void setRumblerStrength(int index, float strength) { + } +} \ No newline at end of file diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/vector/Matrix.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/vector/Matrix.java new file mode 100644 index 000000000..545b1c98e --- /dev/null +++ b/jre_lwjgl3glfw/src/main/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: 3418 $ + * $Id: Matrix.java 3418 2010-09-28 21:11:35Z spasi $ + */ +public abstract class Matrix implements Serializable { + + /** + * Constructor for Matrix. + */ + protected 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/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/vector/Matrix2f.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/vector/Matrix2f.java new file mode 100644 index 000000000..6a3b7fef9 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/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: 3799 $ + * $Id: Matrix2f.java 3799 2012-09-12 11:29:40Z kappa1 $ + */ + +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() { + StringBuilder buf = new StringBuilder(); + 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, dest); + } + + /** + * 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/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/vector/Matrix3f.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/vector/Matrix3f.java new file mode 100644 index 000000000..13cf0fbc8 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/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: 3799 $ + * $Id: Matrix3f.java 3799 2012-09-12 11:29:40Z kappa1 $ + */ + +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() { + StringBuilder buf = new StringBuilder(); + 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, dest); + } + + /** + * 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/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/vector/Matrix4f.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/vector/Matrix4f.java new file mode 100644 index 000000000..b24dca626 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/vector/Matrix4f.java @@ -0,0 +1,849 @@ +/* + * Copyright (c) 2002-2008 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR 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(); + } + + public Matrix4f(final Matrix4f src) { + super(); + load(src); + } + + /** + * Returns a string representation of this matrix + */ + public String toString() { + StringBuilder buf = new StringBuilder(); + 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; + } + + /** + * Store the rotation portion of 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 store3f(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; + } + + /** + * 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, dest); + } + + /** + * 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/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/vector/Quaternion.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/vector/Quaternion.java new file mode 100644 index 000000000..f47cc0a03 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/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: 3418 $ + * $Id: Quaternion.java 3418 2010-09-28 21:11:35Z spasi $ + */ + +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 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 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/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/vector/ReadableVector.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/vector/ReadableVector.java new file mode 100644 index 000000000..0df4240ff --- /dev/null +++ b/jre_lwjgl3glfw/src/main/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 + */ + float length(); + /** + * @return the length squared of the vector + */ + float lengthSquared(); + /** + * Store this vector in a FloatBuffer + * @param buf The buffer to store it in, at the current position + * @return this + */ + Vector store(FloatBuffer buf); +} diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/vector/ReadableVector2f.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/vector/ReadableVector2f.java new file mode 100644 index 000000000..e6850574b --- /dev/null +++ b/jre_lwjgl3glfw/src/main/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 + */ + float getX(); + /** + * @return y + */ + float getY(); +} diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/vector/ReadableVector3f.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/vector/ReadableVector3f.java new file mode 100644 index 000000000..240c6f482 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/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 + */ + float getZ(); +} diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/vector/ReadableVector4f.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/vector/ReadableVector4f.java new file mode 100644 index 000000000..5dee3e3ba --- /dev/null +++ b/jre_lwjgl3glfw/src/main/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 + */ + float getW(); + +} diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/vector/Vector.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/vector/Vector.java new file mode 100644 index 000000000..a0b407aac --- /dev/null +++ b/jre_lwjgl3glfw/src/main/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: 3418 $ + * $Id: Vector.java 3418 2010-09-28 21:11:35Z spasi $ + */ +public abstract class Vector implements Serializable, ReadableVector { + + /** + * Constructor for Vector. + */ + protected 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/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/vector/Vector2f.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/vector/Vector2f.java new file mode 100644 index 000000000..d06422e2c --- /dev/null +++ b/jre_lwjgl3glfw/src/main/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: 3418 $ + * $Id: Vector2f.java 3418 2010-09-28 21:11:35Z spasi $ + */ + +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() { + StringBuilder sb = new StringBuilder(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/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/vector/Vector3f.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/vector/Vector3f.java new file mode 100644 index 000000000..9adab570a --- /dev/null +++ b/jre_lwjgl3glfw/src/main/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: 3418 $ + * $Id: Vector3f.java 3418 2010-09-28 21:11:35Z spasi $ + */ + +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() { + StringBuilder sb = new StringBuilder(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/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/vector/Vector4f.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/vector/Vector4f.java new file mode 100644 index 000000000..712dc0a1b --- /dev/null +++ b/jre_lwjgl3glfw/src/main/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/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/vector/WritableVector2f.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/vector/WritableVector2f.java new file mode 100644 index 000000000..9b48a42e0 --- /dev/null +++ b/jre_lwjgl3glfw/src/main/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 3418 2010-09-28 21:11:35Z spasi $ + */ +public interface WritableVector2f { + + /** + * Set the X value + * @param x + */ + void setX(float x); + + /** + * Set the Y value + * @param y + */ + void setY(float y); + + /** + * Set the X,Y values + * @param x + * @param y + */ + void set(float x, float y); + +} diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/vector/WritableVector3f.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/vector/WritableVector3f.java new file mode 100644 index 000000000..1f2cae15d --- /dev/null +++ b/jre_lwjgl3glfw/src/main/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 3418 2010-09-28 21:11:35Z spasi $ + */ +public interface WritableVector3f extends WritableVector2f { + + /** + * Set the Z value + * @param z + */ + void setZ(float z); + + /** + * Set the X,Y,Z values + * @param x + * @param y + * @param z + */ + void set(float x, float y, float z); + +} diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/vector/WritableVector4f.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/util/vector/WritableVector4f.java new file mode 100644 index 000000000..f398982bf --- /dev/null +++ b/jre_lwjgl3glfw/src/main/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 3418 2010-09-28 21:11:35Z spasi $ + */ +public interface WritableVector4f extends WritableVector3f { + + /** + * Set the W value + * @param w + */ + void setW(float w); + + /** + * Set the X,Y,Z,W values + * @param x + * @param y + * @param z + * @param w + */ + void set(float x, float y, float z, float w); + +} diff --git a/jre_securitymanager/src/main/java/net/pojavlauncher/security/PojavSecurityManager.java b/jre_securitymanager/src/main/java/net/pojavlauncher/security/PojavSecurityManager.java deleted file mode 100644 index f657e4dbf..000000000 --- a/jre_securitymanager/src/main/java/net/pojavlauncher/security/PojavSecurityManager.java +++ /dev/null @@ -1,10 +0,0 @@ -package net.pojavlauncher.security; -import java.security.*; - -public class PojavSecurityManager extends SecurityManager -{ - @Override - public void checkPermission(Permission perm, Object obj) { - super.checkPermission(perm, obj); - } -} diff --git a/settings.gradle b/settings.gradle index fa903d3fb..1e810efdd 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,4 +1,4 @@ rootProject.name='PojavLauncher' -include ':jre_securitymanager' +include ':jre_lwjgl3glfw' include ':app_pojavlauncher'