Interface TextureRegistry


  • public interface TextureRegistry
    The interface for a texture registry used by a GameWindow.
    Author:
    Tim Neumann
    • Method Detail

      • loadTextureFromResource

        String loadTextureFromResource​(String resourceName,
                                       Function<String,​InputStream> resourceProvider)
        Load an image from an internal resource as texture and return the handle to the texture.

        The image will only be loaded once and subsequent loads only return the existing texture handle.

        Parameters:
        resourceName - the name of the texture resource
        resourceProvider - a function providing the input stream for the resource with the name, given to it as the parameter.

        A typical implementation is <name of class>.class::getResourceAsStream

        Returns:
        the handle to retrieve the texture
        Throws:
        TextureNotFoundException - the texture could not be loaded from the given resource location
      • createAnimatedTexture

        String createAnimatedTexture​(boolean loop)
        Create a new animated texture with the animation length in render ticks. Use addAnimationFrameToTexture(java.lang.String, java.lang.String, long) to add animation frames to the animated texture.
        Parameters:
        loop - if true the animation will loop after the last frame
        Returns:
        the handle to retrieve the texture
      • addAnimationFrameToTexture

        void addAnimationFrameToTexture​(String animatedTexture,
                                        String frameTexture,
                                        long frames)
        Add a animation frame to an animated texture.
        Parameters:
        animatedTexture - the animated texture to add the animation frame to
        frameTexture - the texture to add as animation frame
        frames - the number of frames to show this texture
      • isTextureAnimated

        boolean isTextureAnimated​(String textureHandle)
        Check if a texture is animated.
        Parameters:
        textureHandle - the texture to check
        Returns:
        true iff the texture is animated
      • loadTextureFromFile

        String loadTextureFromFile​(String filePath)
        Load an image from a file path as texture and return the handle to the texture. The image will only be loaded once and subsequent loads only return the existing texture handle.
        Parameters:
        filePath - the path to the texture image file
        Returns:
        the handle to retrieve the texture
        Throws:
        TextureNotFoundException - the texture could not be loaded from the given file path