本文整理汇总了Java中org.lwjgl.LWJGLUtil.DEBUG属性的典型用法代码示例。如果您正苦于以下问题:Java LWJGLUtil.DEBUG属性的具体用法?Java LWJGLUtil.DEBUG怎么用?Java LWJGLUtil.DEBUG使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.lwjgl.LWJGLUtil
的用法示例。
在下文中一共展示了LWJGLUtil.DEBUG属性的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: calculateImageSize
/**
* Calculates the number of bytes in the specified cl_mem image region.
* This implementation assumes 1 byte per element, because we cannot the
* image type.
*
* @param region the image region
* @param row_pitch the row pitch
* @param slice_pitch the slice pitch
*
* @return the region size in bytes
*/
static int calculateImageSize(final PointerBuffer region, long row_pitch, long slice_pitch) {
if ( !LWJGLUtil.CHECKS )
return 0;
final long w = region.get(0);
final long h = region.get(1);
final long d = region.get(2);
if ( LWJGLUtil.DEBUG && (w < 1 || h < 1 || d < 1) )
throw new IllegalArgumentException("Invalid cl_mem image region dimensions: " + w + " x " + h + " x " + d);
if ( row_pitch == 0 )
row_pitch = w;
else if ( LWJGLUtil.DEBUG && row_pitch < w )
throw new IllegalArgumentException("Invalid row pitch specified: " + row_pitch);
if ( slice_pitch == 0 )
slice_pitch = row_pitch * h;
else if ( LWJGLUtil.DEBUG && slice_pitch < (row_pitch * h) )
throw new IllegalArgumentException("Invalid slice pitch specified: " + slice_pitch);
return (int)(slice_pitch * d);
}
示例2: calculateImage2DSize
/**
* Calculates the number of bytes in the specified 2D image.
*
* @param format the cl_image_format struct
* @param w the image width
* @param h the image height
* @param row_pitch the image row pitch
*
* @return the 2D image size in bytes
*/
static int calculateImage2DSize(final ByteBuffer format, final long w, final long h, long row_pitch) {
if ( !LWJGLUtil.CHECKS )
return 0;
if ( LWJGLUtil.DEBUG && (w < 1 || h < 1) )
throw new IllegalArgumentException("Invalid 2D image dimensions: " + w + " x " + h);
final int elementSize = getElementSize(format);
if ( row_pitch == 0 )
row_pitch = w * elementSize;
else if ( LWJGLUtil.DEBUG && ((row_pitch < w * elementSize) || (row_pitch % elementSize != 0)) )
throw new IllegalArgumentException("Invalid image_row_pitch specified: " + row_pitch);
return (int)(row_pitch * h);
}
示例3: calculateImage3DSize
/**
* Calculates the number of bytes in the specified 3D image.
*
* @param format the cl_image_format struct
* @param w the image width
* @param h the image height
* @param d the image depth
* @param row_pitch the image row pitch
* @param slice_pitch the image slice pitch
*
* @return the 3D image size in bytes
*/
static int calculateImage3DSize(final ByteBuffer format, final long w, final long h, final long d, long row_pitch, long slice_pitch) {
if ( !LWJGLUtil.CHECKS )
return 0;
if ( LWJGLUtil.DEBUG && (w < 1 || h < 1 || d < 2) )
throw new IllegalArgumentException("Invalid 3D image dimensions: " + w + " x " + h + " x " + d);
final int elementSize = getElementSize(format);
if ( row_pitch == 0 )
row_pitch = w * elementSize;
else if ( LWJGLUtil.DEBUG && ((row_pitch < w * elementSize) || (row_pitch % elementSize != 0)) )
throw new IllegalArgumentException("Invalid image_row_pitch specified: " + row_pitch);
if ( slice_pitch == 0 )
slice_pitch = row_pitch * h;
else if ( LWJGLUtil.DEBUG && ((row_pitch < row_pitch * h) || (slice_pitch % row_pitch != 0)) )
throw new IllegalArgumentException("Invalid image_slice_pitch specified: " + row_pitch);
return (int)(slice_pitch * d);
}
示例4: testDebug
/**
* Tests debug mode
*/
private void testDebug() {
System.out.println("==== Test Debug ====");
if (LWJGLUtil.DEBUG) {
LWJGLUtil.log("Debug is enabled, you should now see output from LWJGL during the following tests.");
} else {
System.out.println("Debug is not enabled. Please set the org.lwjgl.Sys.debug property to true to enable debugging");
System.out.println("Example:\n java -Dorg.lwjgl.util.Debug=true ...");
System.out.println("You will not see any debug output in the following tests.");
}
// get some display modes, to force some debug info
try {
Display.getAvailableDisplayModes();
} catch (LWJGLException e) {
throw new RuntimeException(e);
}
System.out.println("---- Test Debug ----\n");
}
示例5: calculateMetricsSize
static int calculateMetricsSize(int metricQueryMask, int stride) {
if ( LWJGLUtil.DEBUG && (stride < 0 || (stride % 4) != 0) )
throw new IllegalArgumentException("Invalid stride value: " + stride);
final int metrics = Integer.bitCount(metricQueryMask);
if ( LWJGLUtil.DEBUG && (stride >> 2) < metrics )
throw new IllegalArgumentException("The queried metrics do not fit in the specified stride: " + stride);
return stride == 0 ? metrics : (stride >> 2);
}
示例6: encode
/**
* Simple ASCII encoding.
*
* @param buffer The target buffer
* @param string The source string
*/
private static ByteBuffer encode(final ByteBuffer buffer, final CharSequence string) {
for ( int i = 0; i < string.length(); i++ ) {
final char c = string.charAt(i);
if ( LWJGLUtil.DEBUG && 0x80 <= c ) // Silently ignore and map to 0x1A.
buffer.put((byte)0x1A);
else
buffer.put((byte)c);
}
return buffer;
}
示例7: swapBuffers
/**
* Swap the display buffers. This method is called from update(), and should normally not be called by
* the application.
*
* @throws OpenGLException if an OpenGL error has occured since the last call to glGetError()
*/
public static void swapBuffers() throws LWJGLException {
synchronized ( GlobalLock.lock ) {
if ( !isCreated() )
throw new IllegalStateException("Display not created");
if ( LWJGLUtil.DEBUG )
drawable.checkGLError();
drawable.swapBuffers();
}
}
示例8: calculateBufferRectSize
/**
* Calculates the number of bytes in the specified cl_mem buffer rectangle region.
*
* @param offset the host offset
* @param region the rectangle region
* @param row_pitch the host row pitch
* @param slice_pitch the host slice pitch
*
* @return the region size in bytes
*/
static int calculateBufferRectSize(final PointerBuffer offset, final PointerBuffer region, long row_pitch, long slice_pitch) {
if ( !LWJGLUtil.CHECKS )
return 0;
final long x = offset.get(0);
final long y = offset.get(1);
final long z = offset.get(2);
if ( LWJGLUtil.DEBUG && (x < 0 || y < 0 || z < 0) )
throw new IllegalArgumentException("Invalid cl_mem host offset: " + x + ", " + y + ", " + z);
final long w = region.get(0);
final long h = region.get(1);
final long d = region.get(2);
if ( LWJGLUtil.DEBUG && (w < 1 || h < 1 || d < 1) )
throw new IllegalArgumentException("Invalid cl_mem rectangle region dimensions: " + w + " x " + h + " x " + d);
if ( row_pitch == 0 )
row_pitch = w;
else if ( LWJGLUtil.DEBUG && row_pitch < w )
throw new IllegalArgumentException("Invalid host row pitch specified: " + row_pitch);
if ( slice_pitch == 0 )
slice_pitch = row_pitch * h;
else if ( LWJGLUtil.DEBUG && slice_pitch < (row_pitch * h) )
throw new IllegalArgumentException("Invalid host slice pitch specified: " + slice_pitch);
return (int)((z * slice_pitch + y * row_pitch + x) + (w * h * d));
}
示例9: CLObjectChild
protected CLObjectChild(final long pointer, final P parent) {
super(pointer);
if ( LWJGLUtil.DEBUG && parent != null && !parent.isValid() )
throw new IllegalStateException("The parent specified is not a valid CL object.");
this.parent = parent;
}
示例10: registerObject
void registerObject(final T object) {
final FastLongMap<T> map = getMap();
final Long key = object.getPointer();
if ( LWJGLUtil.DEBUG && map.containsKey(key) )
throw new IllegalStateException("Duplicate object found: " + object.getClass() + " - " + key);
getMap().put(object.getPointer(), object);
}
示例11: updateCursor
/**
* Updates the cursor, so that animation can be changed if needed.
* This method is called automatically by the window on its update, and
* shouldn't be called otherwise
*/
public static void updateCursor() {
synchronized (OpenGLPackageAccess.global_lock) {
if (emulateCursorAnimation && currentCursor != null && currentCursor.hasTimedOut() && Mouse.isInsideWindow()) {
currentCursor.nextCursor();
try {
setNativeCursor(currentCursor);
} catch (LWJGLException e) {
if (LWJGLUtil.DEBUG) e.printStackTrace();
}
}
}
}
示例12: getCacheLineSize
static int getCacheLineSize() {
final int THREADS = 2;
final int REPEATS = 100000 * THREADS;
final int LOCAL_REPEATS = REPEATS / THREADS;
// Detection will start from CacheLineMaxSize bytes.
final int MAX_SIZE = LWJGLUtil.getPrivilegedInteger("org.lwjgl.util.mapped.CacheLineMaxSize", 1024) / 4; // in # of integers
// Detection will stop when the execution time increases by more than CacheLineTimeThreshold %.
final double TIME_THRESHOLD = 1.0 + LWJGLUtil.getPrivilegedInteger("org.lwjgl.util.mapped.CacheLineTimeThreshold", 50) / 100.0;
final ExecutorService executorService = Executors.newFixedThreadPool(THREADS);
final ExecutorCompletionService<Long> completionService = new ExecutorCompletionService<Long>(executorService);
try {
// We need to use a NIO buffer in order to guarantee memory alignment.
final IntBuffer memory = getMemory(MAX_SIZE);
// -- WARMUP --
final int WARMUP = 10;
for ( int i = 0; i < WARMUP; i++ )
doTest(THREADS, LOCAL_REPEATS, 0, memory, completionService);
// -- CACHE LINE SIZE DETECTION --
long totalTime = 0;
int count = 0;
int cacheLineSize = 64; // fallback to the most common size these days
boolean found = false;
for ( int i = MAX_SIZE; i >= 1; i >>= 1 ) {
final long time = doTest(THREADS, LOCAL_REPEATS, i, memory, completionService);
if ( totalTime > 0 ) { // Ignore first run
final long avgTime = totalTime / count;
if ( (double)time / (double)avgTime > TIME_THRESHOLD ) { // Try to detect a noticeable jump in execution time
cacheLineSize = (i << 1) * 4;
found = true;
break;
}
}
totalTime += time;
count++;
}
if ( LWJGLUtil.DEBUG ) {
if ( found )
LWJGLUtil.log("Cache line size detected: " + cacheLineSize + " bytes");
else
LWJGLUtil.log("Failed to detect cache line size, assuming " + cacheLineSize + " bytes");
}
return cacheLineSize;
} finally {
executorService.shutdown();
}
}