Skip to content
Snippets Groups Projects
Commit bde84f59 authored by Filip Reaboi's avatar Filip Reaboi
Browse files

ForTISS changed to fortiss

@Id: deleted

refs 3241
parent 6ae5154d
No related branches found
No related tags found
No related merge requests found
Showing
with 142 additions and 103 deletions
......@@ -43,7 +43,7 @@ import java.nio.*;
* @author cix_foo <cix_foo@users.sourceforge.net>
* @author elias_naur <elias_naur@users.sourceforge.net>
* @version $Revision$
* $Id$
* | |
*/
public class BufferChecks {
/** Static methods only! */
......
......@@ -44,16 +44,17 @@ import java.nio.ShortBuffer;
/**
* Some often-used Buffer code for creating native buffers of the appropriate size.
*
* @author $Author$
* @version $Revision$
* $Id$
* @author hoelzl
* | |
*/
public final class BufferUtils {
/**
* Construct a direct native-ordered bytebuffer with the specified size.
* @param size The size, in bytes
*
* @param size
* The size, in bytes
* @return a ByteBuffer
*/
public static ByteBuffer createByteBuffer(int size) {
......@@ -63,7 +64,9 @@ public final class BufferUtils {
/**
* Construct a direct native-order shortbuffer with the specified number
* of elements.
* @param size The size, in shorts
*
* @param size
* The size, in shorts
* @return a ShortBuffer
*/
public static ShortBuffer createShortBuffer(int size) {
......@@ -73,7 +76,9 @@ public final class BufferUtils {
/**
* Construct a direct native-order charbuffer with the specified number
* of elements.
* @param size The size, in chars
*
* @param size
* The size, in chars
* @return an CharBuffer
*/
public static CharBuffer createCharBuffer(int size) {
......@@ -83,7 +88,9 @@ public final class BufferUtils {
/**
* Construct a direct native-order intbuffer with the specified number
* of elements.
* @param size The size, in ints
*
* @param size
* The size, in ints
* @return an IntBuffer
*/
public static IntBuffer createIntBuffer(int size) {
......@@ -93,7 +100,9 @@ public final class BufferUtils {
/**
* Construct a direct native-order longbuffer with the specified number
* of elements.
* @param size The size, in longs
*
* @param size
* The size, in longs
* @return an LongBuffer
*/
public static LongBuffer createLongBuffer(int size) {
......@@ -103,7 +112,9 @@ public final class BufferUtils {
/**
* Construct a direct native-order floatbuffer with the specified number
* of elements.
* @param size The size, in floats
*
* @param size
* The size, in floats
* @return a FloatBuffer
*/
public static FloatBuffer createFloatBuffer(int size) {
......@@ -113,7 +124,9 @@ public final class BufferUtils {
/**
* Construct a direct native-order doublebuffer with the specified number
* of elements.
* @param size The size, in floats
*
* @param size
* The size, in floats
* @return a FloatBuffer
*/
public static DoubleBuffer createDoubleBuffer(int size) {
......@@ -123,7 +136,9 @@ public final class BufferUtils {
/**
* Construct a PointerBuffer with the specified number
* of elements.
* @param size The size, in memory addresses
*
* @param size
* The size, in memory addresses
* @return a PointerBuffer
*/
public static PointerBuffer createPointerBuffer(int size) {
......@@ -134,13 +149,13 @@ public final class BufferUtils {
* @return n, where buffer_element_size=2^n.
*/
public static int getElementSizeExponent(Buffer buf) {
if (buf instanceof ByteBuffer)
if(buf instanceof ByteBuffer)
return 0;
else if (buf instanceof ShortBuffer || buf instanceof CharBuffer)
else if(buf instanceof ShortBuffer || buf instanceof CharBuffer)
return 1;
else if (buf instanceof FloatBuffer || buf instanceof IntBuffer)
else if(buf instanceof FloatBuffer || buf instanceof IntBuffer)
return 2;
else if (buf instanceof LongBuffer || buf instanceof DoubleBuffer)
else if(buf instanceof LongBuffer || buf instanceof DoubleBuffer)
return 3;
else
throw new IllegalStateException("Unsupported buffer type: " + buf);
......@@ -149,6 +164,7 @@ public final class BufferUtils {
/**
* 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) {
......@@ -157,37 +173,37 @@ public final class BufferUtils {
/** Fill buffer with zeros from position to remaining */
public static void zeroBuffer(ByteBuffer b) {
zeroBuffer0(b, b.position(), b.remaining());
zeroBuffer0(b, b.position(), b.remaining());
}
/** Fill buffer with zeros from position to remaining */
public static void zeroBuffer(ShortBuffer b) {
zeroBuffer0(b, b.position()*2L, b.remaining()*2L);
zeroBuffer0(b, b.position() * 2L, b.remaining() * 2L);
}
/** Fill buffer with zeros from position to remaining */
public static void zeroBuffer(CharBuffer b) {
zeroBuffer0(b, b.position()*2L, b.remaining()*2L);
zeroBuffer0(b, b.position() * 2L, b.remaining() * 2L);
}
/** Fill buffer with zeros from position to remaining */
public static void zeroBuffer(IntBuffer b) {
zeroBuffer0(b, b.position()*4L, b.remaining()*4L);
zeroBuffer0(b, b.position() * 4L, b.remaining() * 4L);
}
/** Fill buffer with zeros from position to remaining */
public static void zeroBuffer(FloatBuffer b) {
zeroBuffer0(b, b.position()*4L, b.remaining()*4L);
zeroBuffer0(b, b.position() * 4L, b.remaining() * 4L);
}
/** Fill buffer with zeros from position to remaining */
public static void zeroBuffer(LongBuffer b) {
zeroBuffer0(b, b.position()*8L, b.remaining()*8L);
zeroBuffer0(b, b.position() * 8L, b.remaining() * 8L);
}
/** Fill buffer with zeros from position to remaining */
public static void zeroBuffer(DoubleBuffer b) {
zeroBuffer0(b, b.position()*8L, b.remaining()*8L);
zeroBuffer0(b, b.position() * 8L, b.remaining() * 8L);
}
/** Fill buffer with zeros from position to remaining */
......@@ -196,7 +212,8 @@ public final class BufferUtils {
/**
* Returns the memory address of the specified buffer.
*
* @param buffer the buffer
* @param buffer
* the buffer
*
* @return the memory address
*/
......
......@@ -39,7 +39,7 @@ package org.lwjglx;
*
* @author Brian Matzon <brian@matzon.dk>
* @version $Revision$
* $Id$
* | |
*/
public class LWJGLException extends Exception {
......
......@@ -49,7 +49,7 @@ import java.util.*;
*
* @author Brian Matzon <brian@matzon.dk>
* @version $Revision$
* $Id$
* | |
*/
public class LWJGLUtil {
public static final int PLATFORM_LINUX = 1;
......
......@@ -47,7 +47,7 @@ import org.lwjglx.LWJGLException;
*
* @author elias_naur <elias_naur@users.sourceforge.net>
* @version $Revision$
* $Id$
* | |
*/
public class Cursor {
......
......@@ -47,7 +47,7 @@ import org.lwjgl.BufferUtils;
*
* @author Brian Matzon <brian@matzon.dk>
* @version $Revision$
* $Id$
* | |
*/
public final class ALCcontext {
......
......@@ -45,7 +45,7 @@ import java.util.HashMap;
*
* @author Brian Matzon <brian@matzon.dk>
* @version $Revision$
* $Id$
* | |
*/
public final class ALCdevice {
......
......@@ -38,7 +38,7 @@ package org.lwjglx.openal;
*
* @author Brian Matzon <brian@matzon.dk>
* @version $Revision$
* $Id$
* | |
*/
public class OpenALException extends RuntimeException {
......
......@@ -43,7 +43,7 @@ import org.lwjglx.PointerBuffer;
*
* @author elias_naur <elias_naur@users.sourceforge.net>
* @version $Revision$
* $Id$
* | |
*/
final class ContextGL implements Context {
......
......@@ -39,7 +39,7 @@ package org.lwjglx.opengl;
*
* @author cix_foo <cix_foo@users.sourceforge.net>
* @version $Revision$
* $Id$
* | |
*/
public final class DisplayMode {
......
......@@ -37,7 +37,7 @@ package org.lwjglx.opengl;
*
* @author cix_foo <cix_foo@users.sourceforge.net>
* @version $Revision$
* $Id$
* | |
*/
public class OpenGLException extends RuntimeException {
......
......@@ -46,7 +46,7 @@ import org.lwjglx.Sys;
*
* @author elias_naur <elias_naur@users.sourceforge.net>
* @version $Revision$
* $Id$
* | |
*/
public final class Pbuffer extends DrawableGL {
/**
......
......@@ -40,7 +40,7 @@ import org.lwjglx.LWJGLUtil;
*
* @author elias_naur <elias_naur@users.sourceforge.net>
* @version $Revision$
* $Id$
* | |
*/
abstract class PeerInfo {
private final ByteBuffer handle;
......
......@@ -42,9 +42,9 @@ import org.lwjglx.opengl.DisplayMode;
/**
* Display initialization utility, that can be used to find display modes and pick
* one for you based on your criteria.
* @author $Author$
* @version $Revision$
* $Id$
*
* @author hoelzl
* | |
*/
public final class Display {
......@@ -54,51 +54,58 @@ public final class Display {
* 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
* @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
{
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.lwjglx.opengl.Display.getAvailableDisplayModes();
if (LWJGLUtil.DEBUG || DEBUG) {
if(LWJGLUtil.DEBUG || DEBUG) {
System.out.println("Available screen modes:");
for ( DisplayMode mode : modes ) {
for(DisplayMode mode : modes) {
System.out.println(mode);
}
}
ArrayList<DisplayMode> matches = new ArrayList<DisplayMode>(modes.length);
for (int i = 0; i < modes.length; i ++) {
assert modes[i] != null : ""+i+" "+modes.length;
if (minWidth != -1 && modes[i].getWidth() < minWidth)
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)
if(maxWidth != -1 && modes[i].getWidth() > maxWidth)
continue;
if (minHeight != -1 && modes[i].getHeight() < minHeight)
if(minHeight != -1 && modes[i].getHeight() < minHeight)
continue;
if (maxHeight != -1 && modes[i].getHeight() > maxHeight)
if(maxHeight != -1 && modes[i].getHeight() > maxHeight)
continue;
if (minBPP != -1 && modes[i].getBitsPerPixel() < minBPP)
if(minBPP != -1 && modes[i].getBitsPerPixel() < minBPP)
continue;
if (maxBPP != -1 && modes[i].getBitsPerPixel() > maxBPP)
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)
// 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)
if(maxFreq != -1 && modes[i].getFrequency() > maxFreq)
continue;
}
matches.add(modes[i]);
......@@ -106,9 +113,9 @@ public final class Display {
DisplayMode[] ret = new DisplayMode[matches.size()];
matches.toArray(ret);
if (LWJGLUtil.DEBUG && DEBUG) {
if(LWJGLUtil.DEBUG && DEBUG) {
System.out.println("Filtered screen modes:");
for ( DisplayMode mode : ret ) {
for(DisplayMode mode : ret) {
System.out.println(mode);
}
}
......@@ -118,44 +125,56 @@ public final class Display {
/**
* 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(),
* 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.
* 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
* @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 {
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)) {
if("width".equals(fieldName)) {
return mode.getWidth();
}
if ("height".equals(fieldName)) {
if("height".equals(fieldName)) {
return mode.getHeight();
}
if ("freq".equals(fieldName)) {
if("freq".equals(fieldName)) {
return mode.getFrequency();
}
if ("bpp".equals(fieldName)) {
if("bpp".equals(fieldName)) {
return mode.getBitsPerPixel();
}
throw new IllegalArgumentException("Unknown field "+fieldName);
throw new IllegalArgumentException("Unknown field " + fieldName);
}
}
......@@ -165,11 +184,14 @@ public final class Display {
Sorter() {
accessors = new FieldAccessor[param.length];
for (int i = 0; i < accessors.length; i ++) {
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) == '-') {
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);
......@@ -181,29 +203,29 @@ public final class Display {
* @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
*/
public int compare(DisplayMode dm1, DisplayMode dm2) {
for ( FieldAccessor accessor : accessors ) {
for(FieldAccessor accessor : accessors) {
int f1 = accessor.getInt(dm1);
int f2 = accessor.getInt(dm2);
if ( accessor.usePreferred && f1 != f2 ) {
if ( f1 == accessor.preferred )
if(accessor.usePreferred && f1 != f2) {
if(f1 == accessor.preferred)
return -1;
else if ( f2 == accessor.preferred )
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 )
if(absf1 < absf2)
return -1;
else if ( absf1 > absf2 )
else if(absf1 > absf2)
return 1;
else
continue;
}
} else if ( f1 < f2 )
} else if(f1 < f2)
return accessor.order;
else if ( f1 == f2 )
else if(f1 == f2)
continue;
else
return -accessor.order;
......@@ -217,20 +239,20 @@ public final class Display {
Arrays.sort(dm, new Sorter());
// Try them out in the appropriate order
if (LWJGLUtil.DEBUG || DEBUG) {
if(LWJGLUtil.DEBUG || DEBUG) {
System.out.println("Sorted display modes:");
for ( DisplayMode aDm : dm ) {
for(DisplayMode aDm : dm) {
System.out.println(aDm);
}
}
for ( DisplayMode aDm : dm ) {
for(DisplayMode aDm : dm) {
try {
if ( LWJGLUtil.DEBUG || DEBUG )
if(LWJGLUtil.DEBUG || DEBUG)
System.out.println("Attempting to set displaymode: " + aDm);
org.lwjglx.opengl.Display.setDisplayMode(aDm);
return aDm;
} catch (Exception e) {
if ( LWJGLUtil.DEBUG || DEBUG ) {
} catch(Exception e) {
if(LWJGLUtil.DEBUG || DEBUG) {
System.out.println("Failed to set display mode to " + aDm);
e.printStackTrace();
}
......
......@@ -54,7 +54,7 @@ import org.lwjgl.openal.AL10;
*
* @author Brian Matzon <brian@matzon.dk>
* @version $Revision$
* $Id$
* | |
*/
public class WaveData {
/** actual wave data */
......
......@@ -41,7 +41,7 @@ import java.nio.FloatBuffer;
*
* @author cix_foo <cix_foo@users.sourceforge.net>
* @version $Revision$
* $Id$
* | |
*/
public abstract class Matrix implements Serializable {
......
......@@ -40,7 +40,7 @@ import java.nio.FloatBuffer;
*
* @author cix_foo <cix_foo@users.sourceforge.net>
* @version $Revision$
* $Id$
* | |
*/
public class Matrix2f extends Matrix implements Serializable {
......
......@@ -40,7 +40,7 @@ import java.nio.FloatBuffer;
*
* @author cix_foo <cix_foo@users.sourceforge.net>
* @version $Revision$
* $Id$
* | |
*/
public class Matrix3f extends Matrix implements Serializable {
......
......@@ -37,7 +37,7 @@ package org.lwjglx.util.vector;
*
* @author fbi
* @version $Revision$
* $Id$
* | |
*/
import java.nio.FloatBuffer;
......
......@@ -40,7 +40,7 @@ import java.nio.FloatBuffer;
*
* @author cix_foo <cix_foo@users.sourceforge.net>
* @version $Revision$
* $Id$
* | |
*/
public abstract class Vector implements Serializable, ReadableVector {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment