当前位置: 首页>>代码示例>>Java>>正文


Java MemoryUtil类代码示例

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


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

示例1: init

import org.lwjgl.system.MemoryUtil; //导入依赖的package包/类
public void init(Window window) throws Exception {
    this.vg = window.getOptions().antialiasing ? nvgCreate(NVG_ANTIALIAS | NVG_STENCIL_STROKES) :
            nvgCreate(NVG_STENCIL_STROKES);
    if (this.vg == NULL) {
        throw new Exception("Could not init nanovg");
    }

    fontBuffer = Utils.ioResourceToByteBuffer("/fonts/OpenSans-Bold.ttf", 150 * 1024);
    int font = nvgCreateFontMem(vg, FONT_NAME, fontBuffer, 0);
    if (font == -1) {
        throw new Exception("Could not add font");
    }
    colour = NVGColor.create();

    posx = MemoryUtil.memAllocDouble(1);
    posy = MemoryUtil.memAllocDouble(1);

    counter = 0;
}
 
开发者ID:justjanne,项目名称:SteamAudio-Java,代码行数:20,代码来源:Hud.java

示例2: readVorbis

import org.lwjgl.system.MemoryUtil; //导入依赖的package包/类
private ShortBuffer readVorbis(String resource, int bufferSize, STBVorbisInfo info) throws Exception {
    try (MemoryStack stack = MemoryStack.stackPush()) {
        vorbis = Utils.ioResourceToByteBuffer(resource, bufferSize);
        IntBuffer error = stack.mallocInt(1);
        long decoder = stb_vorbis_open_memory(vorbis, error, null);
        if (decoder == NULL) {
            throw new RuntimeException("Failed to open Ogg Vorbis file. Error: " + error.get(0));
        }

        stb_vorbis_get_info(decoder, info);

        int channels = info.channels();

        int lengthSamples = stb_vorbis_stream_length_in_samples(decoder);

        pcm = MemoryUtil.memAllocShort(lengthSamples);

        pcm.limit(stb_vorbis_get_samples_short_interleaved(decoder, channels, pcm) * channels);
        stb_vorbis_close(decoder);

        return pcm;
    }
}
 
开发者ID:justjanne,项目名称:SteamAudio-Java,代码行数:24,代码来源:SoundBuffer.java

示例3: init

import org.lwjgl.system.MemoryUtil; //导入依赖的package包/类
public void init(MainWindow window) throws Exception {
    this.vg = window.getOptions().antialiasing ? nvgCreate(NVG_ANTIALIAS | NVG_STENCIL_STROKES) : nvgCreate(NVG_STENCIL_STROKES);
    if (this.vg == NULL) {
        throw new Exception("Could not init nanovg");
    }

    fontBuffer = Util.ioResourceToByteBuffer("/fonts/OpenSans-Bold.ttf", 150 * 1024);
    int font = nvgCreateFontMem(vg, FONT_NAME, fontBuffer, 0);
    if (font == -1) {
        throw new Exception("Could not add font");
    }
    colour = NVGColor.create();

    posx = MemoryUtil.memAllocDouble(1);
    posy = MemoryUtil.memAllocDouble(1);

    counter = 0;
}
 
开发者ID:adamegyed,项目名称:endless-hiker,代码行数:19,代码来源:Hud.java

示例4: Window

import org.lwjgl.system.MemoryUtil; //导入依赖的package包/类
/**
 * Create a window
 *
 * @param title               The window title
 * @param width               The window width
 * @param height              The window height
 * @param fullscreen          Wether it should be a fullscreen window
 * @param fullscreenVideoMode The video mode (ignored if fullscreen is <code>false</code>)
 * @param monitor             The monitor to put the window on (ignored if fullscreen is <code>false</code>)
 */
public Window(String title, int width, int height, boolean fullscreen, @Nullable GLFWVidMode fullscreenVideoMode, long monitor) {
	this.width = width;
	this.height = height;
	this.title = title;
	this.fullscreen = fullscreen;

	if (fullscreen) {
		GLFW.glfwWindowHint(GLFW.GLFW_RED_BITS, fullscreenVideoMode.redBits());
		GLFW.glfwWindowHint(GLFW.GLFW_GREEN_BITS, fullscreenVideoMode.greenBits());
		GLFW.glfwWindowHint(GLFW.GLFW_BLUE_BITS, fullscreenVideoMode.blueBits());
		GLFW.glfwWindowHint(GLFW.GLFW_REFRESH_RATE, fullscreenVideoMode.refreshRate());
		width = fullscreenVideoMode.width();
		height = fullscreenVideoMode.height();
	}

	window = GLFW.glfwCreateWindow(width, height, title, fullscreen ? monitor : MemoryUtil.NULL, MemoryUtil.NULL
	);
	GLFW.glfwMakeContextCurrent(window);
	GLFW.glfwSwapInterval(0);
	glCapabilities = GL.createCapabilities();
	initCallbacks();
	setCursorEnabled(cursorEnabled);
}
 
开发者ID:warlockcodes,项目名称:Null-Engine,代码行数:34,代码来源:Window.java

示例5: switchToWindowed

import org.lwjgl.system.MemoryUtil; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void switchToWindowed(DisplayMode mode) {
    if (isFullscreen()) {
        //!
        //! Only proceed if the window is in fullscreen mode
        //!
        GLFW.glfwSetWindowMonitor(mHandle, MemoryUtil.NULL, 0, 0,
                mode.getWidth(),
                mode.getHeight(),
                mode.getRate());

        //!
        //! Center the window on the primary device
        //!
        final GLFWVidMode video = GLFW.glfwGetVideoMode(GLFW.glfwGetPrimaryMonitor());
        GLFW.glfwSetWindowPos(mHandle,
                (video.width() - mode.getWidth()) / 2, (video.height() - mode.getHeight()) / 2);
    }
}
 
开发者ID:Wolftein,项目名称:Quark-Engine,代码行数:23,代码来源:DesktopDisplay.java

示例6: init

import org.lwjgl.system.MemoryUtil; //导入依赖的package包/类
public void init(Window window) throws Exception {
    this.vg = window.getOptions().antialiasing ? nvgCreate(NVG_ANTIALIAS | NVG_STENCIL_STROKES) : nvgCreate(NVG_STENCIL_STROKES);
    if (this.vg == NULL) {
        throw new Exception("Could not init nanovg");
    }

    fontBuffer = Utils.ioResourceToByteBuffer("/fonts/OpenSans-Bold.ttf", 150 * 1024);
    int font = nvgCreateFontMem(vg, FONT_NAME, fontBuffer, 0);
    if (font == -1) {
        throw new Exception("Could not add font");
    }
    colour = NVGColor.create();

    posx = MemoryUtil.memAllocDouble(1);
    posy = MemoryUtil.memAllocDouble(1);

    counter = 0;
}
 
开发者ID:lwjglgamedev,项目名称:lwjglbook,代码行数:19,代码来源:Hud.java

示例7: setSize

import org.lwjgl.system.MemoryUtil; //导入依赖的package包/类
@Override public void setSize (int width, int height, boolean fullscreen) {
  if (plat.config.fullscreen != fullscreen) {
    plat.log().warn("fullscreen cannot be changed via setSize, use config.fullscreen instead");
    return;
  }
  GLFWVidMode vidMode = glfwGetVideoMode(glfwGetPrimaryMonitor());
  if (width > vidMode.width()) {
    plat.log().debug("Capping window width at desktop width: " + width + " -> " +
                     vidMode.width());
    width = vidMode.width();
  }
  if (height > vidMode.height()) {
    plat.log().debug("Capping window height at desktop height: " + height + " -> " +
                     vidMode.height());
    height = vidMode.height();
  }
  glfwSetWindowSize(window, width, height);
  // plat.log().info("setSize: " + width + "x" + height);
  viewSizeM.setSize(width, height);

  IntBuffer fbSize = BufferUtils.createIntBuffer(2);
  long addr = MemoryUtil.memAddress(fbSize);
  nglfwGetFramebufferSize(window, addr, addr + 4);
  viewportAndScaleChanged(fbSize.get(0), fbSize.get(1));
}
 
开发者ID:playn,项目名称:playn,代码行数:26,代码来源:GLFWGraphics.java

示例8: convertAudioBytes

import org.lwjgl.system.MemoryUtil; //导入依赖的package包/类
public static ByteBuffer convertAudioBytes(ByteBuffer src, boolean twoBytes, ByteOrder order) {
    ByteBuffer dest = MemoryUtil.memCalloc(src.remaining());
    src.order(order);
    if (twoBytes) {
        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;
}
 
开发者ID:TechShroom,项目名称:EmergencyLanding,代码行数:18,代码来源:SoundUtil.java

示例9: create

import org.lwjgl.system.MemoryUtil; //导入依赖的package包/类
/**
    * Creates a window width the specified width, height, and title on the specified monitor
    * @param width The width of the window
    * @param height The height of the window
    * @param title The title of the window
    * @param monitor The monitor on which to create the window
    */
   public void create(int width, int height, String title, long monitor) {
this.width = width;
this.height = height;
this.title = title;
this.monitor = monitor;

// Obtain a handle for the window
handle = GLFW.glfwCreateWindow(width, height, title, 0, MemoryUtil.NULL);
// If the window did not create properly
if(handle == 0) {
    throw new IllegalStateException("Window did not initalize");
}
   }
 
开发者ID:camilne,项目名称:open-world,代码行数:21,代码来源:Window.java

示例10: delete

import org.lwjgl.system.MemoryUtil; //导入依赖的package包/类
/**
 * Deletes this instanced mesh and deletes the vertex array object and the
    * vertex buffer object.
 */
@Override
public void delete() {
	super.delete();
	
	if (this.instancedDataBuffer != null) {
		MemoryUtil.memFree(this.instancedDataBuffer);
		this.instancedDataBuffer = null;
	}
}
 
开发者ID:brokenprogrammer,项目名称:Mass,代码行数:14,代码来源:InstancedMesh.java

示例11: printBuffer

import org.lwjgl.system.MemoryUtil; //导入依赖的package包/类
private String printBuffer(PointerBuffer buffer) {
    long address = MemoryUtil.memAddress0(buffer);
    int pos = buffer.position();
    int lim = buffer.limit();
    int cap = buffer.capacity();
    if (pos == 0 && lim == cap)
        return "PointerBuffer[0x" + Long.toString(address, 16) + ", " + lim + "]";
    else
        return "PointerBuffer[0x" + Long.toString(address, 16) + ", " + pos + ", " + lim + ", " + cap + "]";
}
 
开发者ID:LWJGLX,项目名称:debug,代码行数:11,代码来源:MethodCall.java

示例12: send

import org.lwjgl.system.MemoryUtil; //导入依赖的package包/类
public void send(long addr, int size) {
    if (lastSend != null && !lastSend.isDone()) {
        /* We have to wait for the last send to complete until we can reuse the buffer */
        try {
            lastSend.get();
        } catch (Exception e) {
        }
    }
    MemoryUtil.memCopy(addr, bufferAddr, size);
    buffer.rewind();
    buffer.limit(size);
    lastSend = outbound.getRemote().sendBytesByFuture(buffer);
}
 
开发者ID:LWJGLX,项目名称:debug,代码行数:14,代码来源:Profiling.java

示例13: setPosition

import org.lwjgl.system.MemoryUtil; //导入依赖的package包/类
public Window setPosition(int x, int y)
{
	if (this.handle == MemoryUtil.NULL)
	{
		this.x = x;
		this.y = y;
	}
	else
	{
		GLFW.glfwSetWindowPos(this.handle, x, y);
	}
	return this;
}
 
开发者ID:andykuo1,项目名称:candlelight,代码行数:14,代码来源:Window.java

示例14: setSize

import org.lwjgl.system.MemoryUtil; //导入依赖的package包/类
public Window setSize(int width, int height)
{
	if (this.handle == MemoryUtil.NULL)
	{
		this.width = width;
		this.height = height;
	}
	else
	{
		GLFW.glfwSetWindowSize(this.handle, width, height);
	}
	return this;
}
 
开发者ID:andykuo1,项目名称:candlelight,代码行数:14,代码来源:Window.java

示例15: setTitle

import org.lwjgl.system.MemoryUtil; //导入依赖的package包/类
public Window setTitle(String title)
{
	if (this.handle == MemoryUtil.NULL)
	{
		this.title = title;
	}
	else
	{
		GLFW.glfwSetWindowTitle(this.handle, this.title = title);
	}
	return this;
}
 
开发者ID:andykuo1,项目名称:candlelight,代码行数:13,代码来源:Window.java


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