• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java MemoryUtil类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.lwjgl.MemoryUtil的典型用法代码示例。如果您正苦于以下问题:Java MemoryUtil类的具体用法?Java MemoryUtil怎么用?Java MemoryUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



MemoryUtil类属于org.lwjgl包,在下文中一共展示了MemoryUtil类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: eglGetCurrentSurface

import org.lwjgl.MemoryUtil; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:Arcbe,项目名称:GPVM,代码行数:30,代码来源:EGL.java


示例2: setup

import org.lwjgl.MemoryUtil; //导入依赖的package包/类
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;
}
 
开发者ID:CodeConglomerate,项目名称:TeacherSmash,代码行数:21,代码来源:MappedHelper.java


示例3: testConstructor

import org.lwjgl.MemoryUtil; //导入依赖的package包/类
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);
}
 
开发者ID:ryancwilliams,项目名称:SpaceStationAlpha,代码行数:18,代码来源:MappedObjectTests3.java


示例4: eglGetCurrentContext

import org.lwjgl.MemoryUtil; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:Superloup10,项目名称:Wolf_game,代码行数:28,代码来源:EGL.java


示例5: testCacheLineAlignment

import org.lwjgl.MemoryUtil; //导入依赖的package包/类
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);
	}
}
 
开发者ID:ryancwilliams,项目名称:SpaceStationAlpha,代码行数:21,代码来源:MappedObjectTests4.java


示例6: eglGetConfigs

import org.lwjgl.MemoryUtil; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:Arcbe,项目名称:GPVM,代码行数:37,代码来源:EGL.java


示例7: setTitle

import org.lwjgl.MemoryUtil; //导入依赖的package包/类
public void setTitle(String title) {
	lockAWT();
	try {
		final ByteBuffer titleText = MemoryUtil.encodeUTF8(title);
		nSetTitle(getDisplay(), getWindow(), MemoryUtil.getAddress(titleText), titleText.remaining() - 1);
	} finally {
		unlockAWT();
	}
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:10,代码来源:LinuxDisplay.java


示例8: getBuffer

import org.lwjgl.MemoryUtil; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:17,代码来源:APIUtil.java


示例9: getBufferNT

import org.lwjgl.MemoryUtil; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:19,代码来源:APIUtil.java


示例10: getLengths

import org.lwjgl.MemoryUtil; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:17,代码来源:APIUtil.java


示例11: alcOpenDevice

import org.lwjgl.MemoryUtil; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:25,代码来源:ALC10.java


示例12: glCompressedTexImage3D

import org.lwjgl.MemoryUtil; //导入依赖的package包/类
@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));
}
 
开发者ID:playn,项目名称:playn,代码行数:8,代码来源:LWJGLGL20.java


示例13: getMemory

import org.lwjgl.MemoryUtil; //导入依赖的package包/类
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();
}
 
开发者ID:ryancwilliams,项目名称:SpaceStationAlpha,代码行数:14,代码来源:CacheLineSize.java


示例14: setClassHint

import org.lwjgl.MemoryUtil; //导入依赖的package包/类
/** 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();
	}
}
 
开发者ID:Superloup10,项目名称:Wolf_game,代码行数:13,代码来源:LinuxDisplay.java


示例15: setTitle

import org.lwjgl.MemoryUtil; //导入依赖的package包/类
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);
}
 
开发者ID:Arcbe,项目名称:GPVM,代码行数:13,代码来源:LinuxDisplay.java


示例16: testLocalView

import org.lwjgl.MemoryUtil; //导入依赖的package包/类
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);
	}
}
 
开发者ID:CodeConglomerate,项目名称:TeacherSmash,代码行数:14,代码来源:MappedObjectTests4.java


示例17: checkRange

import org.lwjgl.MemoryUtil; //导入依赖的package包/类
final void checkRange(final int bytes) {
	if ( bytes < 0 )
		throw new IllegalArgumentException();

	if ( preventGC.capacity() < (viewAddress - MemoryUtil.getAddress0(preventGC) + bytes) )
		throw new BufferOverflowException();
}
 
开发者ID:ryancwilliams,项目名称:SpaceStationAlpha,代码行数:8,代码来源:MappedObject.java


示例18: eglCreateContext

import org.lwjgl.MemoryUtil; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:CodeConglomerate,项目名称:TeacherSmash,代码行数:25,代码来源:EGL.java


示例19: createByteBuffer

import org.lwjgl.MemoryUtil; //导入依赖的package包/类
/**
 * 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());
}
 
开发者ID:Superloup10,项目名称:Wolf_game,代码行数:20,代码来源:CacheUtil.java


示例20: getBuffer

import org.lwjgl.MemoryUtil; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:Arcbe,项目名称:GPVM,代码行数:17,代码来源:APIUtil.java



注:本文中的org.lwjgl.MemoryUtil类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java DiskFileItem类代码示例发布时间:2022-05-23
下一篇:
Java ResourceIterable类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap