Java Code Examples for org.lwjgl.input.Keyboard#destroy()

The following examples show how to use org.lwjgl.input.Keyboard#destroy() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LwjglCanvas.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private void pauseCanvas(){
    if (Mouse.isCreated()){
        if (Mouse.isGrabbed()){
            Mouse.setGrabbed(false);
            mouseWasGrabbed = true;
        }
        mouseWasCreated = true;
        Mouse.destroy();
    }
    if (Keyboard.isCreated()){
        keyboardWasCreated = true;
        Keyboard.destroy();
    }

    renderable.set(false);
    destroyContext();
}
 
Example 2
Source File: LwjglCanvas.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void pauseCanvas(){
    if (Mouse.isCreated()){
        if (Mouse.isGrabbed()){
            Mouse.setGrabbed(false);
            mouseWasGrabbed = true;
        }
        mouseWasCreated = true;
        Mouse.destroy();
    }
    if (Keyboard.isCreated()){
        keyboardWasCreated = true;
        Keyboard.destroy();
    }

    renderable.set(false);
    destroyContext();
}
 
Example 3
Source File: LwjglKeyInput.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void destroy() {
    if (!context.isRenderable())
        return;
    
    Keyboard.destroy();
    logger.fine("Keyboard destroyed.");
}
 
Example 4
Source File: LwjglKeyInput.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void destroy() {
    if (!context.isRenderable())
        return;
    
    Keyboard.destroy();
    logger.info("Keyboard destroyed.");
}
 
Example 5
Source File: LwjglCanvas.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
/**
 * This is called:
 * 1) When the context thread ends
 * 2) Any time the canvas becomes non-displayable
 */
@Override
protected void destroyContext(){
    try {
        // invalidate the state so renderer can resume operation
        if (!USE_SHARED_CONTEXT){
            renderer.cleanup();
        }
        
        if (Display.isCreated()){
            /* FIXES:
             * org.lwjgl.LWJGLException: X Error
             * BadWindow (invalid Window parameter) request_code: 2 minor_code: 0
             * 
             * Destroying keyboard early prevents the error above, triggered
             * by destroying keyboard in by Display.destroy() or Display.setParent(null).
             * Therefore Keyboard.destroy() should precede any of these calls.
             */
            if (Keyboard.isCreated()){
                // Should only happen if called in 
                // LwjglAbstractDisplay.deinitInThread().
                Keyboard.destroy();
            }

            //try {
                // NOTE: On Windows XP, not calling setParent(null)
                // freezes the application.
                // On Mac it freezes the application.
                // On Linux it fixes a crash with X Window System.
                if (JmeSystem.getPlatform() == Platform.Windows32
                 || JmeSystem.getPlatform() == Platform.Windows64){
                    //Display.setParent(null);
                }
            //} catch (LWJGLException ex) {
            //    logger.log(Level.SEVERE, "Encountered exception when setting parent to null", ex);
            //}

            Display.destroy();
        }
        
        // The canvas is no longer visible,
        // but the context thread is still running.
        if (!needClose.get()){
            // MUST make sure there's still a context current here ..
            // Display is dead, make pbuffer available to the system
            makePbufferAvailable();
            
            renderer.invalidateState();
        }else{
            // The context thread is no longer running.
            // Destroy pbuffer.
            destroyPbuffer();
        }
    } catch (LWJGLException ex) {
        listener.handleError("Failed make pbuffer available", ex);
    }
}
 
Example 6
Source File: Window.java    From 3DGameEngine with Apache License 2.0 4 votes vote down vote up
public static void Dispose()
{
	Display.destroy();
	Keyboard.destroy();
	Mouse.destroy();
}
 
Example 7
Source File: LwjglCanvas.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 4 votes vote down vote up
/**
 * This is called:
 * 1) When the context thread ends
 * 2) Any time the canvas becomes non-displayable
 */
protected void destroyContext(){
    try {
        // invalidate the state so renderer can resume operation
        if (!USE_SHARED_CONTEXT){
            renderer.cleanup();
        }
        
        if (Display.isCreated()){
            /* FIXES:
             * org.lwjgl.LWJGLException: X Error
             * BadWindow (invalid Window parameter) request_code: 2 minor_code: 0
             * 
             * Destroying keyboard early prevents the error above, triggered
             * by destroying keyboard in by Display.destroy() or Display.setParent(null).
             * Therefore Keyboard.destroy() should precede any of these calls.
             */
            if (Keyboard.isCreated()){
                // Should only happen if called in 
                // LwjglAbstractDisplay.deinitInThread().
                Keyboard.destroy();
            }

            //try {
                // NOTE: On Windows XP, not calling setParent(null)
                // freezes the application.
                // On Mac it freezes the application.
                // On Linux it fixes a crash with X Window System.
                if (JmeSystem.getPlatform() == Platform.Windows32
                 || JmeSystem.getPlatform() == Platform.Windows64){
                    //Display.setParent(null);
                }
            //} catch (LWJGLException ex) {
            //    logger.log(Level.SEVERE, "Encountered exception when setting parent to null", ex);
            //}

            Display.destroy();
        }
        
        // The canvas is no longer visible,
        // but the context thread is still running.
        if (!needClose.get()){
            // MUST make sure there's still a context current here ..
            // Display is dead, make pbuffer available to the system
            makePbufferAvailable();
            
            renderer.invalidateState();
        }else{
            // The context thread is no longer running.
            // Destroy pbuffer.
            destroyPbuffer();
        }
    } catch (LWJGLException ex) {
        listener.handleError("Failed make pbuffer available", ex);
    }
}