desktopsUsed++;
    public void setup( int width, int height, boolean mipMapping, InputHandler inputHandlerParent ) {        reconstruct( null, null, null, null );        if ( inputHandlerParent != null ) {            inputHandlerParent.addToAttachedHandlers( inputHandler );        }        if ( initialized ) {            throw new IllegalStateException( "may be called only once" );        }        initialize( powerOf2SizeIfNeeded( width, mipMapping ), powerOf2SizeIfNeeded( height, mipMapping ) );        this.width = powerOf2SizeIfNeeded( width, mipMapping );        this.height = powerOf2SizeIfNeeded( height, mipMapping );        setModelBound( new OrientedBoundingBox() );        updateModelBound();        desktop.setPreferredSize( new Dimension( width, height ) );        desktopWidth = width;        desktopHeight = height;        awtWindow.pack();        TextureState ts = DisplaySystem.getDisplaySystem().getRenderer().createTextureState();        texture = new Texture();        texture.setCorrection( Texture.CM_PERSPECTIVE );        texture.setFilter( Texture.FM_LINEAR );        texture.setMipmapState( mipMapping ? Texture.MM_LINEAR_LINEAR : Texture.MM_LINEAR );        texture.setWrap( Texture.WM_WRAP_S_WRAP_T );        graphics = ImageGraphics.createInstance( this.width, this.height, mipMapping ? 2 : 0 );        enableAntiAlias( graphics );        graphics.translate( ( this.width - width ) * 0.5f, ( this.height - height ) * 0.5f );        texture.setImage( graphics.getImage() );        texture.setScale( new Vector3f( 1, -1, 1 ) );        ts.setTexture( texture );        ts.apply();        this.setRenderState( ts );        AlphaState alpha = DisplaySystem.getDisplaySystem().getRenderer().createAlphaState();        alpha.setEnabled( true );        alpha.setBlendEnabled( true );        alpha.setSrcFunction( AlphaState.SB_SRC_ALPHA );        alpha.setDstFunction( AlphaState.DB_ONE_MINUS_SRC_ALPHA );        alpha.setTestEnabled( true );        alpha.setTestFunction( AlphaState.TF_GREATER );        this.setRenderState( alpha );//        Toolkit.getDefaultToolkit().addAWTEventListener( new AWTEventListener() {//            public void eventDispatched( AWTEvent event ) {//                if ( isShowingJFrame() ) {//                    System.out.println( event );//                }//            }//        }, 0xFFFFFFFFFFFFFFFFl );        xUpdateAction = new XUpdateAction();        yUpdateAction = new YUpdateAction();        wheelUpdateAction = new WheelUpdateAction();        wheelUpdateAction.setSpeed( AWTMouseInput.WHEEL_AMP );        allButtonsUpdateAction = new ButtonAction( InputHandler.BUTTON_ALL );        keyUpdateAction = new KeyUpdateAction();        setupDefaultInputBindings();        if ( desktopsUsed == 0 ) {            PopupFactory.setSharedInstance( new MyPopupFactory() );            desktopsUsed--;        }        initialized = true;        setSynchronizingThreadsOnUpdate( true );    }