(fixed) AlphaState not working

I am trying to create a mouse cursor but the AlphaState is not working. I am not sure where the alpha color is found but the edge of the image is all white which is what I want to use as the alpha.  The image is a .png.  Here is my code for the cursor.


am = new AbsoluteMouse( "Mouse", DisplaySystem.getDisplaySystem().getRenderer().getWidth(),
                       DisplaySystem.getDisplaySystem().getRenderer().getHeight() );

      // Cursor texture
      
      TextureState ts = DisplaySystem.getDisplaySystem().getRenderer().createTextureState();
      URL cursorLoc = BlockBuildCameraController.class.getClassLoader().getResource( "Data/Cursors/cursor.png" );
      Texture t = TextureManager.loadTexture( cursorLoc, Texture.MM_LINEAR, Texture.FM_LINEAR );
      ts.setTexture( t );
      am.setRenderState( ts );

      // Alpha
      
      AlphaState as = DisplaySystem.getDisplaySystem().getRenderer().createAlphaState();
      as.setBlendEnabled( true );
      as.setSrcFunction( AlphaState.SB_SRC_ALPHA );
      as.setDstFunction( AlphaState.SB_ONE_MINUS_SRC_ALPHA );
      as.setTestEnabled( true );
      as.setTestFunction( AlphaState.TF_GREATER );
      am.setRenderState( as );

      // Set start location
      
      am.setLocalTranslation( new Vector3f( DisplaySystem.getDisplaySystem().getWidth() / 2,
                                   DisplaySystem.getDisplaySystem().getHeight() / 2, 0 ) );
      
      gameState.getRootNode().attachChild( am );

That one was a tough to spot…

as.setDstFunction( AlphaState.SB_ONE_MINUS_SRC_ALPHA );


You're using the SB constant (source) instead of the DB constant (destination). Replace with:

as.setDstFunction( AlphaState.DB_ONE_MINUS_SRC_ALPHA );

Will not be possible to accidentally do that in 2.0.  :stuck_out_tongue:

I changed that, but I still see the white.



as.setDstFunction( AlphaState.DB_ONE_MINUS_SRC_ALPHA );



correct?  All other code is the same as above.

I'm not seeing "as.setEnabled(true)" in your code, neither do i see setEnable(true) for the texturestate.

States are enabled by default. Perhaps the problem is in the image, make sure that it actually has an alpha channel (you might also want to post it here for others to check)

The problem was the alpha with the image.  Thanks for the help everyone.