Class NiftyJmeDisplay

java.lang.Object
com.jme3.niftygui.NiftyJmeDisplay
All Implemented Interfaces:
SceneProcessor

public class NiftyJmeDisplay extends Object implements SceneProcessor
  • Field Details

  • Constructor Details

    • NiftyJmeDisplay

      public NiftyJmeDisplay()
    • NiftyJmeDisplay

      public NiftyJmeDisplay(AssetManager assetManager, InputManager inputManager, AudioRenderer audioRenderer, ViewPort viewport, int atlasWidth, int atlasHeight)
      Create a new NiftyJmeDisplay for use with the Batched Nifty Renderer (improved Nifty rendering performance). Nifty will use a single texture of the given dimensions (see atlasWidth and atlasHeight parameters). Every graphical asset you're rendering through Nifty will be placed into this big texture. The goal is to render all Nifty components in a single (or at least very few) draw calls. This should speed up rendering quite a bit. Currently you have to make sure to not use more image space than this single texture provides. However, Nifty tries to be smart about this and internally will make sure that only the images are uploaded that your GUI really needs. So in general this shouldn't be an issue. A complete re-organisation of the texture atlas happens when a Nifty screen ends and another begins. Dynamically adding images while a screen is running is supported as well.
      Parameters:
      assetManager - jME AssetManager
      inputManager - jME InputManager
      audioRenderer - jME AudioRenderer
      viewport - Viewport to use
      atlasWidth - the width of the texture atlas Nifty uses to speed up rendering (2048 is a good value)
      atlasHeight - the height of the texture atlas Nifty uses to speed up rendering (2048 is a good value)
    • NiftyJmeDisplay

      public NiftyJmeDisplay(AssetManager assetManager, InputManager inputManager, AudioRenderer audioRenderer, ViewPort vp)
      Create a standard NiftyJmeDisplay. This uses the old Nifty renderer. It's probably slower than the batched renderer and is mainly here for backwards compatibility. Nifty colors are assumed to be in Linear colorspace (no gamma correction).
      Parameters:
      assetManager - jME AssetManager
      inputManager - jME InputManager
      audioRenderer - jME AudioRenderer
      vp - Viewport to use
    • NiftyJmeDisplay

      public NiftyJmeDisplay(AssetManager assetManager, InputManager inputManager, AudioRenderer audioRenderer, ViewPort vp, ColorSpace colorSpace)
      Create a standard NiftyJmeDisplay. This uses the old Nifty renderer. It's probably slower than the batched renderer and is mainly here for backwards compatibility.
      Parameters:
      assetManager - jME AssetManager
      inputManager - jME InputManager
      audioRenderer - jME AudioRenderer
      vp - Viewport to use
      colorSpace - the ColorSpace to use for Nifty colors (sRGB or Linear)
  • Method Details

    • newNiftyJmeDisplay

      public static NiftyJmeDisplay newNiftyJmeDisplay(AssetManager assetManager, InputManager inputManager, AudioRenderer audioRenderer, ViewPort viewport)
      Create a new NiftyJmeDisplay for use with the Batched Nifty Renderer. Nifty will use texture atlases for rendering. Every graphical asset you're rendering through Nifty will be placed into a texture atlas. The goal is to render all Nifty components in a single (or at least very few) draw calls. This should speed up rendering quite a bit. This call will use a default BatchRenderConfiguration for Nifty. See the other method newNiftyJmeDisplay(com.jme3.asset.AssetManager, com.jme3.input.InputManager, com.jme3.audio.AudioRenderer, com.jme3.renderer.ViewPort, de.lessvoid.nifty.render.batch.BatchRenderConfiguration) when you want to change the default BatchRenderConfiguration and provide your own.
      Parameters:
      assetManager - jME AssetManager
      inputManager - jME InputManager
      audioRenderer - jME AudioRenderer
      viewport - Viewport to use
      Returns:
      new NiftyJmeDisplay instance
    • newNiftyJmeDisplay

      public static NiftyJmeDisplay newNiftyJmeDisplay(AssetManager assetManager, InputManager inputManager, AudioRenderer audioRenderer, ViewPort viewport, de.lessvoid.nifty.render.batch.BatchRenderConfiguration batchRenderConfiguration)
      Create a new NiftyJmeDisplay for use with the Batched Nifty Renderer. Nifty will use texture atlas for rendering. Every graphical asset you're rendering through Nifty will be placed into a texture atlas. The goal is to render all Nifty components in a single (or at least very few) draw calls. This should speed up rendering quite a bit.
      Parameters:
      assetManager - jME AssetManager
      inputManager - jME InputManager
      audioRenderer - jME AudioRenderer
      viewport - Viewport to use
      batchRenderConfiguration - the Nifty BatchRenderConfiguration that you can use to further configure batch rendering. If unsure you can simply use new BatchRenderConfiguration() in here for the default configuration which should give you good default values.
      Returns:
      new NiftyJmeDisplay instance
    • initialize

      public void initialize(RenderManager rm, ViewPort vp)
      Description copied from interface: SceneProcessor
      Called in the render thread to initialize the scene processor.
      Specified by:
      initialize in interface SceneProcessor
      Parameters:
      rm - The render manager to which the SP was added to
      vp - The viewport to which the SP is assigned
    • getNifty

      public de.lessvoid.nifty.Nifty getNifty()
    • simulateKeyEvent

      public void simulateKeyEvent(KeyInputEvent event)
    • reshape

      public void reshape(ViewPort vp, int w, int h)
      Description copied from interface: SceneProcessor
      Called when the resolution of the viewport has been changed.
      Specified by:
      reshape in interface SceneProcessor
      Parameters:
      vp - the affected ViewPort
      w - the new width (in pixels)
      h - the new height (in pixels)
    • isInitialized

      public boolean isInitialized()
      Specified by:
      isInitialized in interface SceneProcessor
      Returns:
      True if initialize() has been called on this SceneProcessor, false if otherwise.
    • preFrame

      public void preFrame(float tpf)
      Description copied from interface: SceneProcessor
      Called before a frame
      Specified by:
      preFrame in interface SceneProcessor
      Parameters:
      tpf - Time per frame
    • postQueue

      public void postQueue(RenderQueue rq)
      Description copied from interface: SceneProcessor
      Called after the scene graph has been queued, but before it is flushed.
      Specified by:
      postQueue in interface SceneProcessor
      Parameters:
      rq - The render queue
    • postFrame

      public void postFrame(FrameBuffer out)
      Description copied from interface: SceneProcessor
      Called after a frame has been rendered and the queue flushed.
      Specified by:
      postFrame in interface SceneProcessor
      Parameters:
      out - The FB to which the scene was rendered.
    • cleanup

      public void cleanup()
      Description copied from interface: SceneProcessor
      Called when the SP is removed from the RM.
      Specified by:
      cleanup in interface SceneProcessor
    • setProfiler

      public void setProfiler(AppProfiler profiler)
      Description copied from interface: SceneProcessor
      Sets a profiler Instance for this processor.
      Specified by:
      setProfiler in interface SceneProcessor
      Parameters:
      profiler - the profiler instance.