Java 类org.lwjgl.system.MemoryUtil 实例源码

项目:SteamAudio-Java    文件:Hud.java   
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;
}
项目:SteamAudio-Java    文件:SoundBuffer.java   
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;
    }
}
项目:endless-hiker    文件:Hud.java   
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;
}
项目:Null-Engine    文件:Window.java   
/**
 * 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);
}
项目:Quark-Engine    文件:DesktopDisplay.java   
/**
 * {@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);
    }
}
项目:lwjglbook    文件:Hud.java   
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;
}
项目:lwjglbook    文件:SoundBuffer.java   
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;
    }
}
项目:lwjglbook    文件:Hud.java   
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;
}
项目:lwjglbook    文件:SoundBuffer.java   
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;
    }
}
项目:lwjglbook    文件:Hud.java   
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;
}
项目:lwjglbook    文件:SoundBuffer.java   
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;
    }
}
项目:lwjglbook    文件:SoundBuffer.java   
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;
    }
}
项目:lwjglbook    文件:Hud.java   
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;
}
项目:lwjglbook    文件:SoundBuffer.java   
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;
    }
}
项目:lwjglbook    文件:Hud.java   
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;
}
项目:lwjglbook    文件:SoundBuffer.java   
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;
    }
}
项目:lwjglbook    文件:SoundBuffer.java   
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;
    }
}
项目:lwjglbook    文件:SoundBuffer.java   
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;
    }
}
项目:lwjglbook    文件:Hud.java   
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;
}
项目:lwjglbook    文件:SoundBuffer.java   
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;
    }
}
项目:lwjglbook    文件:Hud.java   
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;
}
项目:lwjglbook    文件:SoundBuffer.java   
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;
    }
}
项目:playn    文件:GLFWGraphics.java   
@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));
}
项目:EmergencyLanding    文件:SoundUtil.java   
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;
}
项目:open-world    文件:Window.java   
/**
    * 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");
}
   }
项目:Mass    文件:InstancedMesh.java   
/**
 * 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;
    }
}
项目:debug    文件:MethodCall.java   
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 + "]";
}
项目:debug    文件:Profiling.java   
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);
}
项目:candlelight    文件:Window.java   
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;
}
项目:candlelight    文件:Window.java   
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;
}
项目:candlelight    文件:Window.java   
public Window setTitle(String title)
{
    if (this.handle == MemoryUtil.NULL)
    {
        this.title = title;
    }
    else
    {
        GLFW.glfwSetWindowTitle(this.handle, this.title = title);
    }
    return this;
}
项目:candlelight    文件:Window.java   
public Window setVSync(boolean vsync)
{
    if (this.handle == MemoryUtil.NULL)
    {
        this.vsync = vsync;
    }
    else
    {
        GLFW.glfwSwapInterval((this.vsync = vsync) ? 1 : 0);
    }
    return this;
}
项目:candlelight    文件:Window.java   
public void show()
{
    if (this.handle == MemoryUtil.NULL)
    {
        this.createWindow();
    }

    GLFW.glfwShowWindow(this.handle);
    GLFW.glfwFocusWindow(this.handle);
}
项目:candlelight    文件:Window.java   
public void hide()
{
    if (this.handle == MemoryUtil.NULL)
        throw new IllegalStateException("window not yet initialized!");

    GLFW.glfwHideWindow(this.handle);
}
项目:CommunityEngine-Java    文件:Window.java   
public static Window createWindow(Scene scene, String title) {
    if (!GLFW.glfwInit()) {
        throw new IllegalStateException();
    }

    errorCallback = new GLFWErrorCallback() {
        public void invoke(int error, long description) {
            System.err.println("["+ error + "] " + description);
        }
    };
    GLFW.glfwSetErrorCallback(errorCallback);

    long window = GLFW.glfwCreateWindow(scene.getWidth(), scene.getHeight(), title, MemoryUtil.NULL, MemoryUtil.NULL);

    if (window == MemoryUtil.NULL) {
        System.err.println("Window returned NULL");
        System.exit(-1);
    }

    GLFW.glfwMakeContextCurrent(window);

    GLFW.glfwShowWindow(window);
    GL.createCapabilities();
    GLFW.glfwSwapInterval(1);

    scene.setGLinitilized();
    return new Window(window);
}
项目:CommunityEngine-Java    文件:NanoGui.java   
public static void init()
{
    if(initialized) {
        return;
    }
    vg = NanoVGGL3.nvgCreate(NanoVGGL3.NVG_STENCIL_STROKES);

    if(vg == MemoryUtil.NULL) {
        throw new RuntimeException("Could not init nanoVG");
    }

    initialized = true;
}
项目:SteamAudio-Java    文件:Hud.java   
public void cleanup() {
    nvgDelete(vg);
    if (posx != null) {
        MemoryUtil.memFree(posx);
    }
    if (posy != null) {
        MemoryUtil.memFree(posy);
    }
}
项目:SteamAudio-Java    文件:InstancedMesh.java   
@Override
public void cleanUp() {
    super.cleanUp();
    if (this.instanceDataBuffer != null) {
        MemoryUtil.memFree(this.instanceDataBuffer);
        this.instanceDataBuffer = null;
    }
}
项目:endless-hiker    文件:Mesh.java   
public Mesh(float[] positions, float[] textCoords, int[] indices, Texture texture) {
  this.texture = texture;
  vertexCount = indices.length;

  vaoId = glGenVertexArrays();
  glBindVertexArray(vaoId);

  vboIdList = new LinkedList<>();

  // Position VBO
  posVboId = glGenBuffers();
  FloatBuffer posBuffer = BufferUtils.createFloatBuffer(positions.length);
  FloatBuffer textCoordsBuffer = null;
  posBuffer.put(positions).flip();
  glBindBuffer(GL_ARRAY_BUFFER, posVboId);
  glBufferData(GL_ARRAY_BUFFER, posBuffer, GL_STATIC_DRAW);
  glVertexAttribPointer(0, 3, GL_FLOAT, false, 0, 0);


  //Texture VBO
  int vboId = glGenBuffers();
  textCoordsBuffer = MemoryUtil.memAllocFloat(textCoords.length);
  textCoordsBuffer.put(textCoords).flip();
  glBindBuffer(GL_ARRAY_BUFFER, vboId);
  glBufferData(GL_ARRAY_BUFFER, textCoordsBuffer, GL_STATIC_DRAW);
  glVertexAttribPointer(1, 2, GL_FLOAT, false, 0, 0);

  // Index VBO
  idxVboId = glGenBuffers();
  IntBuffer indicesBuffer = BufferUtils.createIntBuffer(indices.length);
  indicesBuffer.put(indices).flip();
  glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, idxVboId);
  glBufferData(GL_ELEMENT_ARRAY_BUFFER, indicesBuffer, GL_STATIC_DRAW);

  glBindBuffer(GL_ARRAY_BUFFER, 0);
  glBindVertexArray(0);
}
项目:endless-hiker    文件:Hud.java   
public void cleanup() {
    nvgDelete(vg);
    if (posx != null) {
        MemoryUtil.memFree(posx);
    }
    if (posy != null) {
        MemoryUtil.memFree(posy);
    }
}