Java 类org.lwjgl.glfw.GLFWFramebufferSizeCallback 实例源码

项目:key-barricade    文件:VoxelTexRenderer.java   
/**
 * Initialize the renderer.
 */
public void init() {
    // Show a status message
    System.out.println("Initializing " + VoxelTex.ENGINE_NAME + " renderer...");

    // Create and configure the error callback, make sure it was created successfully
    glfwSetErrorCallback(errorCallback = GLFWErrorCallback.createPrint(System.err));
    if(glfwInit() != GL11.GL_TRUE)
        throw new IllegalStateException("Unable to initialize GLFW");

    // Set the default window hints
    this.window.glDefaultWindowHints();

    // Set the visibility and resizability of the window
    this.window.setHintVisible(false);
    this.window.setHintResizable(true);

    // Create the window
    this.window.glCreateWindow();

    // Initialize the input manager for this window
    Input.init(this.window);

    // Create the framebuffer size callback
    glfwSetFramebufferSizeCallback(this.window.getWindowId(), fbCallback = new GLFWFramebufferSizeCallback() {
        @Override
        public void invoke(long windowId, int width, int height) {
            // Update the window size
            if(width > 0 && height > 0)
                window.setSize(width, height);
        }
    });

    // Center the window
    this.window.centerWindow();

    // Create an int buffer for the window
    IntBuffer framebufferSize = BufferUtils.createIntBuffer(2);
    nglfwGetFramebufferSize(this.window.getWindowId(), memAddress(framebufferSize), memAddress(framebufferSize) + 4);

    // Set the window size
    this.window.setSize(framebufferSize.get(0), framebufferSize.get(1));

    // Make the window context
    this.window.glMakeContextCurrent();

    // Set the swap interval (V-sync)
    glfwSwapInterval(0);

    // Show the window
    this.window.glShowWindow();

    // Center the cursor
    Input.centerMouseCursor();

    // Create the rendering capabilities, required by LWJGL
    GL.createCapabilities();

    // Print the OpenGL version
    System.out.println("OpenGL " + GL11.glGetString(GL11.GL_VERSION));

    // Set the clear color
    glClearColor(0.9f, 0.9f, 0.9f, 1.0f);

    // Enable depth testing
    glEnable(GL_DEPTH_TEST);

    // Load the engine shaders
    ShaderManager.load();

    // Initialize the Time object
    Time.init();

    // Show a status message
    System.out.println(VoxelTex.ENGINE_NAME + " renderer initialized successfully!");
}
项目:voxeltex-engine    文件:VoxelTexRenderer.java   
/**
 * Initialize the renderer.
 */
public void init() {
    // Show a status message
    System.out.println("Initializing " + VoxelTex.ENGINE_NAME + " renderer...");

    // Create and configure the error callback, make sure it was created successfully
    glfwSetErrorCallback(errorCallback = GLFWErrorCallback.createPrint(System.err));
    if(glfwInit() != GL11.GL_TRUE)
        throw new IllegalStateException("Unable to initialize GLFW");

    // Set the default window hints
    this.window.glDefaultWindowHints();

    // Set the visibility and resizability of the window
    this.window.setHintVisible(false);
    this.window.setHintResizable(true);

    // Create the window
    this.window.glCreateWindow();

    // Initialize the input manager for this window
    Input.init(this.window);

    // Create the framebuffer size callback
    glfwSetFramebufferSizeCallback(this.window.getWindowId(), fbCallback = new GLFWFramebufferSizeCallback() {
        @Override
        public void invoke(long windowId, int width, int height) {
            // Update the window size
            if(width > 0 && height > 0)
                window.setSize(width, height);
        }
    });

    // Center the window
    this.window.centerWindow();

    // Create an int buffer for the window
    IntBuffer framebufferSize = BufferUtils.createIntBuffer(2);
    nglfwGetFramebufferSize(this.window.getWindowId(), memAddress(framebufferSize), memAddress(framebufferSize) + 4);

    // Set the window size
    this.window.setSize(framebufferSize.get(0), framebufferSize.get(1));

    // Make the window context
    this.window.glMakeContextCurrent();

    // Set the swap interval (V-sync)
    glfwSwapInterval(0);

    // Show the window
    this.window.glShowWindow();

    // Center the cursor
    Input.centerMouseCursor();

    // Create the rendering capabilities, required by LWJGL
    GL.createCapabilities();

    // Print the OpenGL version
    System.out.println("OpenGL " + GL11.glGetString(GL11.GL_VERSION));

    // Set the clear color
    glClearColor(0.9f, 0.9f, 0.9f, 1.0f);

    // Enable depth testing
    glEnable(GL_DEPTH_TEST);

    // Load the engine shaders
    ShaderManager.load();

    // Initialize the Time object
    Time.init();

    // Show a status message
    System.out.println(VoxelTex.ENGINE_NAME + " renderer initialized successfully!");
}
项目:Quark-Engine    文件:Desktop.java   
/**
 * <p>Handle when the module create</p>
 */
private void onModuleCreate(Display.Preference preference) {
    //!
    //! Create display module.
    //!
    final GLFWFramebufferSizeCallback resize = GLFWFramebufferSizeCallback.create((window, width, height) ->
    {
        mLifecycle.onResize(width, height);

        //!
        //! NOTE: This is required due to GLFW3 limitation.
        //!
        onModuleRender(GLFW.glfwGetTime());
    });
    final GLFWWindowIconifyCallback iconify = GLFWWindowIconifyCallback.create((window, iconified) ->
    {
        if (iconified) {
            mLifecycle.onPause();
        } else {
            mLifecycle.onResume();
        }
    });
    mDisplay.onModuleCreate(preference, resize, iconify);

    //!
    //! Create audio module.
    //!
    mAudio.onModuleCreate(new DesktopALES10());
    mAudioThread.schedule(new TimerTask() {
        @Override
        public void run() {
            mAudio.onModuleUpdate();
        }
    }, 0L, THREAD_AUDIO_DELAY);

    //!
    //! Create input module.
    //!
    mInput.onModuleCreate(new DesktopInputKeyboard(mDisplay.getHandle()), new DesktopInputMouse(mDisplay.getHandle()));
    mInputThread.schedule(new TimerTask() {
        @Override
        public void run() {
            mInput.onModuleUpdate();
        }
    }, 0L, THREAD_INPUT_DELAY);

    //!
    //! Create render module.
    //!
    mRender.onModuleCreate(new DesktopGLES32());

    //!
    //! Create resource module.
    //!
    mResources.registerAssetLocator("INTERNAL", new ClassAssetLocator());
    mResources.registerAssetLocator("EXTERNAL", new FilesAssetLocator());

    mResources.registerAssetLoader(new TexturePNGAssetLoader(), "png");
    mResources.registerAssetLoader(new TextureDDSAssetLoader(), "dds", "s3tc");
    mResources.registerAssetLoader(new AudioWAVAssetLoader(), "wav");
    mResources.registerAssetLoader(new AudioOGGAssetLoader(), "ogg");
    mResources.registerAssetLoader(new FontBinaryAssetLoader(), "fnt");
    mResources.registerAssetLoader(new ShaderBinaryAssetLoader(QKRender.getCapabilities()), "shader");

    //!
    //! Handle the create notification.
    //!
    mLifecycle.onCreate();
    mLifecycle.onResize(mDisplay.getWidth(), mDisplay.getHeight());
}
项目:EmergencyLanding    文件:DisplayLayer.java   
private DisplayLayer(long fullscreenMonitor, int width, int height, String title, boolean resizable, boolean vsync,
        String[] args, KMain main) {
    LUtils.print("Using LWJGL v" + org.lwjgl.Version.getVersion());
    if (!GLFW.glfwInit()) {
        throw new IllegalStateException("glfwInit failed!");
    }
    GLFW.glfwDefaultWindowHints();
    GLFW.glfwWindowHint(GLFW.GLFW_RESIZABLE, resizable ? GLFW.GLFW_TRUE : GLFW.GLFW_FALSE);
    GLFW.glfwWindowHint(GLFW.GLFW_CONTEXT_VERSION_MAJOR, 3);
    GLFW.glfwWindowHint(GLFW.GLFW_CONTEXT_VERSION_MINOR, 2);
    GLFW.glfwWindowHint(GLFW.GLFW_OPENGL_FORWARD_COMPAT, GLFW.GLFW_TRUE);
    GLFW.glfwWindowHint(GLFW.GLFW_OPENGL_PROFILE, GLFW.GLFW_OPENGL_CORE_PROFILE);
    this.window = GLFW.glfwCreateWindow(width, height, title, fullscreenMonitor, 0);
    if (this.window == 0) {
        // uh oh.
        throw new IllegalStateException("window creation failed.");
    }

    GLFW.glfwMakeContextCurrent(this.window);
    GL.createCapabilities(true);

    createdMap.put(this.window, this);

    GLFW.glfwSwapInterval(vsync ? 1 : 0);

    this.sizeCallback = GLFWFramebufferSizeCallback.create((win, w, h) -> GLData.resizedRefresh(win));
    GLFW.glfwSetFramebufferSizeCallback(this.window, this.sizeCallback);
    this.mouseHelp = MouseHelp.getHelper(this.window);
    this.keys = Keys.getHelper(this.window);

    String currentMethodName = StackTraceInfo.getCurrentMethodName();
    GLData.notifyOnGLError(currentMethodName);
    KMain.setDisplayThread(Thread.currentThread());
    GLData.notifyOnGLError(currentMethodName);
    KMain.setInst(main);
    GLData.notifyOnGLError(currentMethodName);
    Mods.findAndLoad();
    GLData.notifyOnGLError(currentMethodName);
    GLData.initOpenGL(this.window);
    this.displayFPSTracker = new FPS(title);
    GLData.notifyOnGLError(currentMethodName);
    // Bind VAO around NVG init
    GLData.bindVAO();
    int flags = NVG_ANTIALIAS | NVG_STENCIL_STROKES;
    if (Boolean.getBoolean(LUtils.SHORT_LIB_NAME + ".nvg.debug")) {
        flags |= NVG_DEBUG;
    }
    this.nvgHandle = nvgCreateGL3(flags);
    GLData.notifyOnGLError(currentMethodName);
    GLData.unbindVAO();
    main.init(this, args);
    GLData.notifyOnGLError(currentMethodName);
    LUtils.print("Using OpenGL v" + LUtils.getGLVer());
    // Initialize NFD here to prevent slow times later
    NativeFileDialog.NFD_GetError();
}
项目:JavaGraphicsEngine    文件:Window.java   
/**
 * Gets the GLFWWindow's Framebuffer Size Callback
 * 
 * @return Framebuffer Size Callback of the GLFW Instance
 */
public GLFWFramebufferSizeCallback getFramebufferCallback() {
    return framebufferCallback;
}
项目:JavaGraphicsEngine    文件:Window.java   
/**
 * Sets the GLFWWindow's Framebuffer Size Callback  
 * 
 * @param framebufferCallback   GLFWFramebufferSizeCallback to be used by the GLFW Instance
 */
public void setFramebufferCallback(GLFWFramebufferSizeCallback framebufferCallback) {
    this.framebufferCallback = framebufferCallback;
}