Java 类org.lwjgl.MemoryUtil 实例源码

项目:GPVM    文件:EGL.java   
/**
 * Returns the EGL surfaces used for rendering by the current context.
 * If there is no context current, null is returned.
 *
 * @param readdraw the read or draw surface
 *
 * @return the current surface
 *
 * @throws org.lwjgl.LWJGLException if an EGL error occurs
 */
public static EGLSurface eglGetCurrentSurface(int readdraw) throws LWJGLException {
    //LWJGLUtil.log("eglGetCurrentSurface");
    final long surface = neglGetCurrentSurface(readdraw);
    if ( surface == EGL_NO_SURFACE )
        return null;

    // Get current display
    EGLDisplay display = eglGetCurrentDisplay();

    // Query context's CONFIG_ID
    final IntBuffer attrib_list = APIUtil.getBufferInt();
    if ( !neglQuerySurface(display.getPointer(), surface, EGL_CONFIG_ID, MemoryUtil.getAddress0(attrib_list)) )
        throwEGLError("Failed to query surface EGL config ID.");

    final EGLConfig config = getEGLConfig(display, attrib_list);

    // Create the surface handle
    return new EGLSurface(display, config, surface);
}
项目:TeacherSmash    文件:MappedHelper.java   
public static void setup(MappedObject mo, ByteBuffer buffer, int align, int sizeof) {
    if ( LWJGLUtil.CHECKS && mo.baseAddress != 0L )
        throw new IllegalStateException("this method should not be called by user-code");

    if ( LWJGLUtil.CHECKS && !buffer.isDirect() )
        throw new IllegalArgumentException("bytebuffer must be direct");
    mo.preventGC = buffer;

    if ( LWJGLUtil.CHECKS && align <= 0 )
        throw new IllegalArgumentException("invalid alignment");

    if ( LWJGLUtil.CHECKS && (sizeof <= 0 || sizeof % align != 0) )
        throw new IllegalStateException("sizeof not a multiple of alignment");

    long addr = MemoryUtil.getAddress(buffer);
    if ( LWJGLUtil.CHECKS && addr % align != 0 )
        throw new IllegalStateException("buffer address not aligned on " + align + " bytes");

    mo.baseAddress = mo.viewAddress = addr;
}
项目:SpaceStationAlpha    文件:MappedObjectTests3.java   
static void testConstructor() {
    int capacity = 1024;
    ByteBuffer bb = ByteBuffer.allocateDirect(capacity).order(ByteOrder.nativeOrder());
    long address = MemoryUtil.getAddress(bb);

    MappedFloat mf = MappedFloat.map(address, capacity);

    assert (address == mf.baseAddress);

    assert (mf.value == 0.0f);
    mf.view = 1;
    assert (mf.value == 0.0f);
    mf.runViewConstructor();
    assert (mf.value == 4.0f);

    Xyz.malloc(3);
}
项目:TeacherSmash    文件:EGL.java   
/**
 * Returns the EGL surfaces used for rendering by the current context.
 * If there is no context current, null is returned.
 *
 * @param readdraw the read or draw surface
 *
 * @return the current surface
 *
 * @throws org.lwjgl.LWJGLException if an EGL error occurs
 */
public static EGLSurface eglGetCurrentSurface(int readdraw) throws LWJGLException {
    //LWJGLUtil.log("eglGetCurrentSurface");
    final long surface = neglGetCurrentSurface(readdraw);
    if ( surface == EGL_NO_SURFACE )
        return null;

    // Get current display
    EGLDisplay display = eglGetCurrentDisplay();

    // Query context's CONFIG_ID
    final IntBuffer attrib_list = APIUtil.getBufferInt();
    if ( !neglQuerySurface(display.getPointer(), surface, EGL_CONFIG_ID, MemoryUtil.getAddress0(attrib_list)) )
        throwEGLError("Failed to query surface EGL config ID.");

    final EGLConfig config = getEGLConfig(display, attrib_list);

    // Create the surface handle
    return new EGLSurface(display, config, surface);
}
项目:Wolf_game    文件:EGL.java   
/**
 * Returns the current EGL context for the current rendering API.
 * If there is no context current, null is returned.
 *
 * @return the current context
 *
 * @throws org.lwjgl.LWJGLException if an EGL error occurs
 */
public static EGLContext eglGetCurrentContext() throws LWJGLException {
    //LWJGLUtil.log("eglGetCurrentContext");
    // Get current context
    final long ctx = neglGetCurrentContext();
    if ( ctx == EGL_NO_CONTEXT )
        return null;

    // Get current display
    final EGLDisplay display = eglGetCurrentDisplay();

    // Query context's CONFIG_ID
    final IntBuffer attrib_list = APIUtil.getBufferInt();
    neglQueryContext(display.getPointer(), ctx, EGL_CONFIG_ID, MemoryUtil.getAddress0(attrib_list));

    final EGLConfig config = getEGLConfig(display, attrib_list);

    // Create the context handle
    return new EGLContext(display, config, ctx);
}
项目:Wolf_game    文件:EGL.java   
/**
 * Returns the EGL surfaces used for rendering by the current context.
 * If there is no context current, null is returned.
 *
 * @param readdraw the read or draw surface
 *
 * @return the current surface
 *
 * @throws org.lwjgl.LWJGLException if an EGL error occurs
 */
public static EGLSurface eglGetCurrentSurface(int readdraw) throws LWJGLException {
    //LWJGLUtil.log("eglGetCurrentSurface");
    final long surface = neglGetCurrentSurface(readdraw);
    if ( surface == EGL_NO_SURFACE )
        return null;

    // Get current display
    EGLDisplay display = eglGetCurrentDisplay();

    // Query context's CONFIG_ID
    final IntBuffer attrib_list = APIUtil.getBufferInt();
    if ( !neglQuerySurface(display.getPointer(), surface, EGL_CONFIG_ID, MemoryUtil.getAddress0(attrib_list)) )
        throwEGLError("Failed to query surface EGL config ID.");

    final EGLConfig config = getEGLConfig(display, attrib_list);

    // Create the surface handle
    return new EGLSurface(display, config, surface);
}
项目:SpaceStationAlpha    文件:MappedObjectTests4.java   
public static void testCacheLineAlignment() {
    MappedCacheLinePadded data = MappedCacheLinePadded.malloc(10);

    assert (data.backingByteBuffer().capacity() == 10 * CacheUtil.getCacheLineSize());
    assert (MemoryUtil.getAddress(data.backingByteBuffer()) % CacheUtil.getCacheLineSize() == 0);

    for ( int i = 0; i < 10; i++ ) {
        data.view = i;

        data.foo = i;
        data.bar = i * 2;
    }

    for ( int i = 0; i < 10; i++ ) {
        data.view = i;

        assert (data.foo == i);
        assert (data.bar == i * 2);
    }
}
项目:TeacherSmash    文件:MappedObjectTests3.java   
static void testConstructor() {
    int capacity = 1024;
    ByteBuffer bb = ByteBuffer.allocateDirect(capacity).order(ByteOrder.nativeOrder());
    long address = MemoryUtil.getAddress(bb);

    MappedFloat mf = MappedFloat.map(address, capacity);

    assert (address == mf.baseAddress);

    assert (mf.value == 0.0f);
    mf.view = 1;
    assert (mf.value == 0.0f);
    mf.runViewConstructor();
    assert (mf.value == 4.0f);

    Xyz.malloc(3);
}
项目:SpaceStationAlpha    文件:EGL.java   
/**
 * Returns the EGL surfaces used for rendering by the current context.
 * If there is no context current, null is returned.
 *
 * @param readdraw the read or draw surface
 *
 * @return the current surface
 *
 * @throws org.lwjgl.LWJGLException if an EGL error occurs
 */
public static EGLSurface eglGetCurrentSurface(int readdraw) throws LWJGLException {
    //LWJGLUtil.log("eglGetCurrentSurface");
    final long surface = neglGetCurrentSurface(readdraw);
    if ( surface == EGL_NO_SURFACE )
        return null;

    // Get current display
    EGLDisplay display = eglGetCurrentDisplay();

    // Query context's CONFIG_ID
    final IntBuffer attrib_list = APIUtil.getBufferInt();
    if ( !neglQuerySurface(display.getPointer(), surface, EGL_CONFIG_ID, MemoryUtil.getAddress0(attrib_list)) )
        throwEGLError("Failed to query surface EGL config ID.");

    final EGLConfig config = getEGLConfig(display, attrib_list);

    // Create the surface handle
    return new EGLSurface(display, config, surface);
}
项目:GPVM    文件:MappedHelper.java   
public static void setup(MappedObject mo, ByteBuffer buffer, int align, int sizeof) {
    if ( LWJGLUtil.CHECKS && mo.baseAddress != 0L )
        throw new IllegalStateException("this method should not be called by user-code");

    if ( LWJGLUtil.CHECKS && !buffer.isDirect() )
        throw new IllegalArgumentException("bytebuffer must be direct");
    mo.preventGC = buffer;

    if ( LWJGLUtil.CHECKS && align <= 0 )
        throw new IllegalArgumentException("invalid alignment");

    if ( LWJGLUtil.CHECKS && (sizeof <= 0 || sizeof % align != 0) )
        throw new IllegalStateException("sizeof not a multiple of alignment");

    long addr = MemoryUtil.getAddress(buffer);
    if ( LWJGLUtil.CHECKS && addr % align != 0 )
        throw new IllegalStateException("buffer address not aligned on " + align + " bytes");

    mo.baseAddress = mo.viewAddress = addr;
}
项目:SpaceStationAlpha    文件:MappedHelper.java   
public static void setup(MappedObject mo, ByteBuffer buffer, int align, int sizeof) {
    if ( LWJGLUtil.CHECKS && mo.baseAddress != 0L )
        throw new IllegalStateException("this method should not be called by user-code");

    if ( LWJGLUtil.CHECKS && !buffer.isDirect() )
        throw new IllegalArgumentException("bytebuffer must be direct");
    mo.preventGC = buffer;

    if ( LWJGLUtil.CHECKS && align <= 0 )
        throw new IllegalArgumentException("invalid alignment");

    if ( LWJGLUtil.CHECKS && (sizeof <= 0 || sizeof % align != 0) )
        throw new IllegalStateException("sizeof not a multiple of alignment");

    long addr = MemoryUtil.getAddress(buffer);
    if ( LWJGLUtil.CHECKS && addr % align != 0 )
        throw new IllegalStateException("buffer address not aligned on " + align + " bytes");

    mo.baseAddress = mo.viewAddress = addr;
}
项目:GPVM    文件:EGL.java   
/**
 * Returns the available EGLConfigs on the speficied display. The number of available EGLConfigs
 * is returned in the num_config parameter. The configs array may be null. If it is null, a new
 * array will be allocated, with size equal to the result of {@link #eglGetConfigsNum(EGLDisplay)}  eglGetConfigsNum}.
 * If it is not null, no more than {@code configs.length} EGLConfigs will be returned. If the array is bigger
 * than the number of available EGLConfigs, the remaining array elements will not be affected.
 *
 * @param dpy        the EGLDisplay
 * @param configs    the EGLConfigs array
 * @param num_config the number of available EGLConfigs returned
 *
 * @return the available EGLConfigs
 *
 * @throws org.lwjgl.LWJGLException if an EGL error occurs
 */
static EGLConfig[] eglGetConfigs(EGLDisplay dpy, EGLConfig[] configs, IntBuffer num_config) throws LWJGLException {
    //LWJGLUtil.log("eglGetConfigs");
    BufferChecks.checkBuffer(num_config, 1);

    if ( configs == null ) {
        if ( !neglGetConfigs(dpy.getPointer(), 0L, 0, MemoryUtil.getAddress(num_config)) )
            throwEGLError("Failed to get number of available EGL configs.");

        configs = new EGLConfig[num_config.get(num_config.position())];
    }

    final PointerBuffer configs_buffer = APIUtil.getBufferPointer(configs.length);
    if ( !neglGetConfigs(dpy.getPointer(), MemoryUtil.getAddress0(configs_buffer), configs.length, MemoryUtil.getAddress(num_config)) )
        throwEGLError("Failed to get EGL configs.");

    final int config_size = num_config.get(num_config.position());
    for ( int i = 0; i < config_size; i++ )
        configs[i] = new EGLConfig(dpy, configs_buffer.get(i));

    return configs;
}
项目:GPVM    文件:MappedObjectTests4.java   
public static void testCacheLineAlignment() {
    MappedCacheLinePadded data = MappedCacheLinePadded.malloc(10);

    assert (data.backingByteBuffer().capacity() == 10 * CacheUtil.getCacheLineSize());
    assert (MemoryUtil.getAddress(data.backingByteBuffer()) % CacheUtil.getCacheLineSize() == 0);

    for ( int i = 0; i < 10; i++ ) {
        data.view = i;

        data.foo = i;
        data.bar = i * 2;
    }

    for ( int i = 0; i < 10; i++ ) {
        data.view = i;

        assert (data.foo == i);
        assert (data.bar == i * 2);
    }
}
项目:PhET    文件:LinuxDisplay.java   
public void setTitle(String title) {
    lockAWT();
    try {
        final ByteBuffer titleText = MemoryUtil.encodeUTF8(title);
        nSetTitle(getDisplay(), getWindow(), MemoryUtil.getAddress(titleText), titleText.remaining() - 1);
    } finally {
        unlockAWT();
    }
}
项目:PhET    文件:APIUtil.java   
/**
 * Returns a buffer containing the specified strings as bytes.
 *
 * @param strings
 *
 * @return the Strings as a ByteBuffer
 */
static long getBuffer(final ContextCapabilities caps, final CharSequence[] strings) {
    final ByteBuffer buffer = getBufferByte(caps, getTotalLength(strings));

    for ( CharSequence string : strings )
        encode(buffer, string);

    buffer.flip();
    return MemoryUtil.getAddress0(buffer);
}
项目:PhET    文件:APIUtil.java   
/**
 * Returns a buffer containing the specified strings as bytes, including null-termination.
 *
 * @param strings
 *
 * @return the Strings as a ByteBuffer
 */
static long getBufferNT(final ContextCapabilities caps, final CharSequence[] strings) {
    final ByteBuffer buffer = getBufferByte(caps, getTotalLength(strings) + strings.length);

    for ( CharSequence string : strings ) {
        encode(buffer, string);
        buffer.put((byte)0);
    }

    buffer.flip();
    return MemoryUtil.getAddress0(buffer);
}
项目:PhET    文件:APIUtil.java   
/**
 * Returns a buffer containing the lengths of the specified strings.
 *
 * @param strings
 *
 * @return the String lengths in an IntBuffer
 */
static long getLengths(final ContextCapabilities caps, final CharSequence[] strings) {
    IntBuffer buffer = getLengths(caps, strings.length);

    for ( CharSequence string : strings )
        buffer.put(string.length());

    buffer.flip();
    return MemoryUtil.getAddress0(buffer);
}
项目:PhET    文件:ALC10.java   
/**
 * The <code>alcOpenDevice</code> function allows the application (i.e. the client program) to
* connect to a device (i.e. the server).
*
* If the function returns <code>null</code>, 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</code> is specified, the implementation will provide an
* implementation specific default.
 *
 * @param devicename name of device to open
 * @return opened device, or null
 */
public static ALCdevice alcOpenDevice(String devicename) {
    ByteBuffer buffer = MemoryUtil.encodeUTF8(devicename);
    long device_address = nalcOpenDevice(MemoryUtil.getAddressSafe(buffer));
    if(device_address != 0) {
        ALCdevice device = new ALCdevice(device_address);
        synchronized (ALC10.devices) {
            devices.put(device_address, device);
        }
        return device;
    }
    return null;
}
项目:playn    文件:LWJGLGL20.java   
@Override
public void glCompressedTexImage3D(int target, int level, int internalformat,
                                   int width, int height, int depth, int border,
                                   int imageSize, Buffer data) {
  GL13.glCompressedTexImage3D(target, level, internalformat, width, height, depth, border,
                              imageSize, MemoryUtil.getAddress((ByteBuffer) data));
}
项目:SpaceStationAlpha    文件:CacheLineSize.java   
private static IntBuffer getMemory(final int START_SIZE) {
    final int PAGE_SIZE = MappedObjectUnsafe.INSTANCE.pageSize();

    final ByteBuffer buffer = ByteBuffer.allocateDirect((START_SIZE * 4) + PAGE_SIZE).order(ByteOrder.nativeOrder());

    // Align to page and, consequently, to cache line. Otherwise results will be inconsistent.
    if ( MemoryUtil.getAddress(buffer) % PAGE_SIZE != 0 ) {
        // Round up to page boundary
        buffer.position(PAGE_SIZE - (int)(MemoryUtil.getAddress(buffer) & (PAGE_SIZE - 1)));
    }

    return buffer.asIntBuffer();
}
项目:Wolf_game    文件:LinuxDisplay.java   
/** the WM_CLASS hint is needed by some WM's e.g. gnome shell */
private void setClassHint(String wm_name, String wm_class) {
    lockAWT();
    try {
        final ByteBuffer nameText = MemoryUtil.encodeUTF8(wm_name);
        final ByteBuffer classText = MemoryUtil.encodeUTF8(wm_class);

        nSetClassHint(getDisplay(), getWindow(), MemoryUtil.getAddress(nameText), MemoryUtil.getAddress(classText));
    } finally {
        unlockAWT();
    }
}
项目:GPVM    文件:LinuxDisplay.java   
public void setTitle(String title) {
    lockAWT();
    try {
        final ByteBuffer titleText = MemoryUtil.encodeUTF8(title);
        nSetTitle(getDisplay(), getWindow(), MemoryUtil.getAddress(titleText), titleText.remaining() - 1);
    } finally {
        unlockAWT();
    }

    // also update the class hint value as some WM's use it for the window title
    if (Display.isCreated()) setClassHint(title, wm_class);
}
项目:Wolf_game    文件:APIUtil.java   
/**
 * Returns a buffer containing the specified strings as bytes.
 *
 * @param strings
 *
 * @return the Strings as a ByteBuffer
 */
static long getBuffer(final ContextCapabilities caps, final CharSequence[] strings) {
    final ByteBuffer buffer = getBufferByte(caps, getTotalLength(strings));

    for ( CharSequence string : strings )
        encode(buffer, string);

    buffer.flip();
    return MemoryUtil.getAddress0(buffer);
}
项目:TeacherSmash    文件:MappedObjectTests4.java   
private static void testLocalView(MappedSomething some) {
    final MappedSomething[] array = some.asArray();

    assert (array.length == 5);

    final long baseAddress = MemoryUtil.getAddress(some.backingByteBuffer());
    for ( int i = 0; i < array.length; i++ ) {
        ByteBuffer data = array[i].data;

        assert (data.capacity() == (64 - 4));
        assert (MemoryUtil.getAddress(data) == baseAddress + i * MappedSomething.SIZEOF + 4);
    }
}
项目:SpaceStationAlpha    文件:MappedObject.java   
final void checkRange(final int bytes) {
    if ( bytes < 0 )
        throw new IllegalArgumentException();

    if ( preventGC.capacity() < (viewAddress - MemoryUtil.getAddress0(preventGC) + bytes) )
        throw new BufferOverflowException();
}
项目:TeacherSmash    文件:EGL.java   
/**
 * Creates a new EGL context for the current rendering API.
 *
 * @param dpy           the EGL display
 * @param config        the EGL config
 * @param share_context the EGL context to share data with
 * @param attrib_list   the attribute list (may be null)
 *
 * @return the created EGL context
 *
 * @throws org.lwjgl.LWJGLException if an EGL error occurs
 */
static EGLContext eglCreateContext(EGLDisplay dpy, EGLConfig config, EGLContext share_context, IntBuffer attrib_list) throws LWJGLException {
    //LWJGLUtil.log("eglCreateContext");
    checkAttribList(attrib_list);
    final long pointer = neglCreateContext(dpy.getPointer(), config.getPointer(),
                                           share_context == null ? EGL_NO_CONTEXT : share_context.getPointer(),
                                           MemoryUtil.getAddressSafe(attrib_list));

    if ( pointer == EGL_NO_CONTEXT )
        throwEGLError("Failed to create EGL context.");

    return new EGLContext(dpy, config, pointer);
}
项目:Wolf_game    文件:CacheUtil.java   
/**
 * Construct a direct, native-ordered and cache-line-aligned bytebuffer with the specified size.
 *
 * @param size The size, in bytes
 *
 * @return a ByteBuffer
 */
public static ByteBuffer createByteBuffer(int size) {
    ByteBuffer buffer = ByteBuffer.allocateDirect(size + CACHE_LINE_SIZE);

    // Align to cache line.
    if ( MemoryUtil.getAddress(buffer) % CACHE_LINE_SIZE != 0 ) {
        // Round up to cache line boundary
        buffer.position(CACHE_LINE_SIZE - (int)(MemoryUtil.getAddress(buffer) & (CACHE_LINE_SIZE - 1)));
    }

    buffer.limit(buffer.position() + size);
    return buffer.slice().order(ByteOrder.nativeOrder());
}
项目:GPVM    文件:APIUtil.java   
/**
 * Returns a buffer containing the specified strings as bytes.
 *
 * @param strings
 *
 * @return the Strings as a ByteBuffer
 */
static long getBuffer(final CharSequence[] strings) {
    final ByteBuffer buffer = getBufferByte(getTotalLength(strings));

    for ( CharSequence string : strings )
        encode(buffer, string);

    buffer.flip();
    return MemoryUtil.getAddress0(buffer);
}
项目:GPVM    文件:APIUtil.java   
/**
 * Returns a buffer containing the lengths of the specified strings.
 *
 * @param strings
 *
 * @return the String lengths in an IntBuffer
 */
static long getLengths(final CharSequence[] strings) {
    IntBuffer buffer = getLengths(strings.length);

    for ( CharSequence string : strings )
        buffer.put(string.length());

    buffer.flip();
    return MemoryUtil.getAddress0(buffer);
}
项目:Wolf_game    文件:MappedObject.java   
final void checkRange(final int bytes) {
    if ( bytes < 0 )
        throw new IllegalArgumentException();

    if ( preventGC.capacity() < (viewAddress - MemoryUtil.getAddress0(preventGC) + bytes) )
        throw new BufferOverflowException();
}
项目:GPVM    文件:APIUtil.java   
/**
 * Returns a buffer containing the specified strings as bytes, including null-termination.
 *
 * @param strings
 *
 * @return the Strings as a ByteBuffer
 */
static long getBufferNT(final ContextCapabilities caps, final CharSequence[] strings) {
    final ByteBuffer buffer = getBufferByte(caps, getTotalLength(strings) + strings.length);

    for ( CharSequence string : strings ) {
        encode(buffer, string);
        buffer.put((byte)0);
    }

    buffer.flip();
    return MemoryUtil.getAddress0(buffer);
}
项目:Wolf_game    文件:MappedObjectTests3.java   
static void testMappedBuffer() {
    int elementCount = 4;

    MappedSomething some = MappedSomething.malloc(elementCount);

    assert (some.data != some.data);

    long addr1 = MemoryUtil.getAddress(some.backingByteBuffer());

    ByteBuffer mapped = some.data; // creates new ByteBuffer instance
    long addr2 = MemoryUtil.getAddress(mapped);

    assert (addr2 - addr1 == 4);
    assert (mapped.capacity() == MappedSomething.SIZEOF - 4);

    {
        assert (some.shared == 0);
        assert (mapped.getInt(8) == 0);

        some.shared = 1234;

        assert (some.shared == 1234);
        assert (mapped.getInt(8) == 1234);
    }

    some.view++;
    mapped = some.data; // creates new ByteBuffer instance

    long addr3 = MemoryUtil.getAddress(mapped);
    assert (addr3 - addr1 == 4 + MappedSomething.SIZEOF);
    assert (addr3 - addr2 == 0 + MappedSomething.SIZEOF);
    assert (mapped.capacity() == MappedSomething.SIZEOF - 4);
}
项目:TeacherSmash    文件:LinuxDisplay.java   
/** the WM_CLASS hint is needed by some WM's e.g. gnome shell */
private void setClassHint(String wm_name, String wm_class) {
    lockAWT();
    try {
        final ByteBuffer nameText = MemoryUtil.encodeUTF8(wm_name);
        final ByteBuffer classText = MemoryUtil.encodeUTF8(wm_class);

        nSetClassHint(getDisplay(), getWindow(), MemoryUtil.getAddress(nameText), MemoryUtil.getAddress(classText));
    } finally {
        unlockAWT();
    }
}
项目:Wolf_game    文件:EGL.java   
/**
 * Returns the available EGLConfigs on the speficied display that satisfy the specified list of attributes.
 * The number of available EGLConfigs is returned in the num_config parameter. The configs array may be null.
 * If it is null, a new array will be allocated, with size equal to the result of {@link #eglGetConfigsNum(EGLDisplay)}  eglGetConfigsNum}.
 * If it is not null, no more than {@code configs.length} EGLConfigs will be returned. If the array is bigger
 * than the number of available EGLConfigs, the remaining array elements will not be affected.
 *
 * @param dpy         the EGLDisplay
 * @param attrib_list the attribute list (may be null)
 * @param configs     the EGLConfigs array
 * @param num_config  the number of available EGLConfigs returned
 *
 * @return the available EGLConfigs that satisfy the attribute list
 *
 * @throws org.lwjgl.LWJGLException if an EGL error occurs
 */
static EGLConfig[] eglChooseConfig(EGLDisplay dpy, IntBuffer attrib_list, EGLConfig[] configs, IntBuffer num_config) throws LWJGLException {
    //LWJGLUtil.log("eglChooseConfig");
    checkAttribList(attrib_list);
    BufferChecks.checkBuffer(num_config, 1);

    int config_size;
    if ( configs == null ) {
        if ( !neglChooseConfig(dpy.getPointer(), MemoryUtil.getAddressSafe(attrib_list), 0L, 0, MemoryUtil.getAddress(num_config)) )
            throwEGLError("Failed to get number of available EGL configs.");

        config_size = num_config.get(num_config.position());
    } else
        config_size = configs.length;

    //LWJGLUtil.log("config_size = " + config_size);
    PointerBuffer configs_buffer = APIUtil.getBufferPointer(config_size);
    if ( !neglChooseConfig(dpy.getPointer(), MemoryUtil.getAddressSafe(attrib_list), MemoryUtil.getAddress0(configs_buffer), config_size, MemoryUtil.getAddress(num_config)) )
        throwEGLError("Failed to choose EGL config.");

    // Get the true number of configurations (the first neglChooseConfig call may return more than the second)
    config_size = num_config.get(num_config.position());
    if ( configs == null )
        configs = new EGLConfig[config_size];
    for ( int i = 0; i < config_size; i++ )
        configs[i] = new EGLConfig(dpy, configs_buffer.get(i));

    return configs;
}
项目:Wolf_game    文件:EGL.java   
/**
 * Creates a new EGL context for the current rendering API.
 *
 * @param dpy           the EGL display
 * @param config        the EGL config
 * @param share_context the EGL context to share data with
 * @param attrib_list   the attribute list (may be null)
 *
 * @return the created EGL context
 *
 * @throws org.lwjgl.LWJGLException if an EGL error occurs
 */
static EGLContext eglCreateContext(EGLDisplay dpy, EGLConfig config, EGLContext share_context, IntBuffer attrib_list) throws LWJGLException {
    //LWJGLUtil.log("eglCreateContext");
    checkAttribList(attrib_list);
    final long pointer = neglCreateContext(dpy.getPointer(), config.getPointer(),
                                           share_context == null ? EGL_NO_CONTEXT : share_context.getPointer(),
                                           MemoryUtil.getAddressSafe(attrib_list));

    if ( pointer == EGL_NO_CONTEXT )
        throwEGLError("Failed to create EGL context.");

    return new EGLContext(dpy, config, pointer);
}
项目:TeacherSmash    文件:APIUtil.java   
/**
 * Returns a buffer containing the specified strings as bytes.
 *
 * @param strings
 *
 * @return the Strings as a ByteBuffer
 */
static long getBuffer(final ContextCapabilities caps, final CharSequence[] strings) {
    final ByteBuffer buffer = getBufferByte(caps, getTotalLength(strings));

    for ( CharSequence string : strings )
        encode(buffer, string);

    buffer.flip();
    return MemoryUtil.getAddress0(buffer);
}
项目:SpaceStationAlpha    文件:LinuxDisplay.java   
public void setTitle(String title) {
    lockAWT();
    try {
        final ByteBuffer titleText = MemoryUtil.encodeUTF8(title);
        nSetTitle(getDisplay(), getWindow(), MemoryUtil.getAddress(titleText), titleText.remaining() - 1);
    } finally {
        unlockAWT();
    }

    // also update the class hint value as some WM's use it for the window title
    if (Display.isCreated()) setClassHint(title, wm_class);
}
项目:GPVM    文件:LinuxDisplay.java   
public void setTitle(String title) {
    lockAWT();
    try {
        final ByteBuffer titleText = MemoryUtil.encodeUTF8(title);
        nSetTitle(getDisplay(), getWindow(), MemoryUtil.getAddress(titleText), titleText.remaining() - 1);
    } finally {
        unlockAWT();
    }

    // also update the class hint value as some WM's use it for the window title
    if (Display.isCreated()) setClassHint(title, wm_class);
}
项目:GPVM    文件:LinuxDisplay.java   
/** the WM_CLASS hint is needed by some WM's e.g. gnome shell */
private void setClassHint(String wm_name, String wm_class) {
    lockAWT();
    try {
        final ByteBuffer nameText = MemoryUtil.encodeUTF8(wm_name);
        final ByteBuffer classText = MemoryUtil.encodeUTF8(wm_class);

        nSetClassHint(getDisplay(), getWindow(), MemoryUtil.getAddress(nameText), MemoryUtil.getAddress(classText));
    } finally {
        unlockAWT();
    }
}
项目:GPVM    文件:APIUtil.java   
/**
 * Returns a buffer containing the specified strings as bytes.
 *
 * @param strings
 *
 * @return the Strings as a ByteBuffer
 */
static long getBuffer(final ContextCapabilities caps, final CharSequence[] strings) {
    final ByteBuffer buffer = getBufferByte(caps, getTotalLength(strings));

    for ( CharSequence string : strings )
        encode(buffer, string);

    buffer.flip();
    return MemoryUtil.getAddress0(buffer);
}