Texture

Package: Libraries.Game.Graphics · Inherits from: Libraries.Language.Object, Libraries.Game.Disposable

The Texture class represents an image that can be drawn on the screen. Once an image is loaded into a texture, it can be drawn on the screen by loading it into a Drawable.

Example Code

use Libraries.Game.Graphics.Texture
use Libraries.Game.Graphics.Drawable
use Libraries.Game.Graphics.Color
use Libraries.Game.Game

class Main is Game

    Drawable drawable
    Texture texture
    Color red

    action Main
        StartGame()
    end

    action CreateGame
        red:SetColor(1, 0, 0, 1)
        texture:LoadFilledRectangle(80, 100, red)
        drawable:Load(texture)

        drawable:SetPosition(200, 200)
        Add(drawable)
    end
end

Actions

AddTextureLoadListener(Libraries.Interface.Events.TextureLoadListener listener)

This action adds a TextureLoadListener to the texture. If the texture finishes asynchronously loading an image, the listener will be alerted.

Parameters

Bind()

This action activates this texture and binds the texture image to the internal texture ID. This is for internal use.

Bind(integer textureUnit)

This action binds the texture image to an internal index in the rendering system. This is used internally by the engine as needed, and most users won't need to use it directly.

Parameters

  • textureUnit integer

Dispose()

This action will release the memory used to store pixel information for this Texture. This frees up resources, but will make the Texture no longer usable, including in classes that may have loaded the Texture, such as in Drawable. Use this when you are completely finished with a Texture and no longer intend to use it.

EmptyTextureLoadListeners()

This action removes all TextureLoadListeners that have been added to the texture.

FinishLoadingAsynchronously(Libraries.System.File file, Libraries.Game.Graphics.PixelMap pixelMap, Libraries.Game.Graphics.Format format, boolean useMipMaps, Libraries.Game.Graphics.Drawable drawable)

This action is used internally by the game engine to finish loading the data loaded by a LoadAsynchronously action. After this Texture has finished loading, the provided Drawable will be loaded with this Texture (if it is not undefined). This action is used by the engine automatically as needed, and most users will never need to use this action directly.

Parameters

GetCutoutMipMaps()

This action returns the cutoff a cut-out picture's mip levels keep (see SetCutoutMipMaps).

Returns

number: The cutoff, or 0 for an ordinary texture.

GetGLHandle()

Used to reload a Texture that's already been loaded. This is used internally to ensure a Texture is automatically regained if the information is lost due to a context loss (e.g., minimizing the application on an Android device). Users will most likely never need to call this action directly.

Returns

integer

GetGLTarget()

This action returns the width of a loaded Texture.

Returns

integer

Example

use Libraries.Game.Texture
use Libraries.Game.Game

class Main is Game

    Texture myTexture

    action Main
        StartGame()
    end

    action CreateGame
        // This call will load an image "Sample.png" from a directory called "Images".
        myTexture:LoadFromFile("Images/Sample.png")
        number width = myTexture:GetWidth()
    end
end

GetHeight(integer index)

This action returns the height of one of the images in a layered Texture. The index selects which of the layered images will be used to report the height.

Parameters

  • index integer

Returns

integer

Example

use Libraries.Game.Texture
use Libraries.Game.Game
use Libraries.Containers.Array

class Main is Game

    Texture myTexture

    action Main
        StartGame()
    end

    action CreateGame
        // This will store the file paths of two images from a directory called "Images".
        Array<text> files
        files:Add("Images/Sample1.png")
        files:Add("Images/Sample2.png")

        // This call will load all of the stored file paths into a layered texture.
        myTexture:LoadFromFilePaths(files)
        // This will store the height of the second texture image.
        number width = myTexture:GetHeight(1)
    end
end

GetHeight()

This action returns the height of a loaded Texture.

Returns

integer

Example

use Libraries.Game.Texture
use Libraries.Game.Game

class Main is Game

    Texture myTexture

    action Main
        StartGame()
    end

    action CreateGame
        // This call will load an image "Sample.png" from a directory called "Images".
        myTexture:LoadFromFile("Images/Sample.png")
        number width = myTexture:GetHeight()
    end
end

GetHorizontalWrap()

This action returns the horizontal texture wrapping mode. For more on how the TextureWrap works, see Libraries.Game.Graphics.TextureWrap.

Returns

Libraries.Game.Graphics.TextureWrap

GetLayerCount()

This action returns how many images are stored in this texture. Most textures store only a single image, so the layer count is 1. Some specialized textures may have multiple (e.g. cubemaps have 6). If the texture hasn't been loaded yet, this will be 0.

Returns

integer

GetMagnifyFilter()

This action returns the magnification filter of this Texture. For more on how the TextureFilters work, see Libraries.Game.Graphics.TextureFilter.

Returns

Libraries.Game.Graphics.TextureFilter

GetMinimizeFilter()

This action returns the minimization filter of this Texture. For more on how the TextureFilters work, see Libraries.Game.Graphics.TextureFilter.

Returns

Libraries.Game.Graphics.TextureFilter

GetSource()

This action returns the relative file path to the file that was used to load this texture, if there is one. If no file has been loaded, this will return an empty string instead.

Returns

text: The relative file path to the loaded file, or the empty string if no file is loaded.

GetVerticalWrap()

This action returns the vertical texture wrapping mode. For more on how the TextureWrap works, see Libraries.Game.Graphics.TextureWrap.

Returns

Libraries.Game.Graphics.TextureWrap

GetVulkanImageView()

This action returns the VulkanImageView associated with this Texture, if there is one. The image view represents resources used by this texture in the Vulkan system, if the Game engine is using the Vulkan graphics library. If not, this is undefined. This is a Vulkan internal component, and will never be needed by most users.

Returns

Libraries.Game.Graphics.Vulkan.VulkanImageView

GetVulkanSampler()

This action returns the VulkanSampler associated with this Texture, if there is one. The sampler is used to access the resources of the VulkanImageView. This will be undefined if the system isn't using the Vulkan graphics library, and even if it is, this still might be undefined if this texture is being used with an external sampler (e.g., for 3D rendering). This is a Vulkan internal component, and will never be needed by most users.

Returns

Libraries.Game.Graphics.Vulkan.VulkanSampler

GetVulkanTextureGroupIndex()

This action returns the group index of this texture within the VulkanTextureManager's global groupings. The manager may divide textures into multiple groups if there are more textures than can fit into a single array as a shader input.

Returns

integer

GetVulkanTextureIndex()

This action returns the index used by the VulkanTextureManager to store this texture in the global array of textures, if Vulkan is being used for the engine. This value defaults to -1. This is an internal component used by the Vulkan system, and will never be needed by most users.

Returns

integer

GetVulkanTextureLocalIndex()

This action returns the texture's index within its grouping inside the VulkanTextureManager. The manager may divide textures into multiple groups if there are more textures than can fit into a single array as a shader input.

Returns

integer

GetWidth()

This action returns the width of a loaded Texture.

Returns

integer

Example

use Libraries.Game.Texture
use Libraries.Game.Game

class Main is Game

    Texture myTexture

    action Main
        StartGame()
    end

    action CreateGame
        // This call will load an image "Sample.png" from a directory called "Images".
        myTexture:LoadFromFile("Images/Sample.png")
        number width = myTexture:GetWidth()
    end
end

GetWidth(integer index)

This action returns the width of one of the images in a layered Texture. The index selects which of the layered images will be used to report the width.

Parameters

  • index integer

Returns

integer

Example

use Libraries.Game.Texture
use Libraries.Game.Game
use Libraries.Containers.Array

class Main is Game

    Texture myTexture

    action Main
        StartGame()
    end

    action CreateGame
        // This will store the file paths of two images from a directory called "Images".
        Array<text> files
        files:Add("Images/Sample1.png")
        files:Add("Images/Sample2.png")

        // This call will load all of the stored file paths into a layered texture.
        myTexture:LoadFromFilePaths(files)
        // This will store the width of the second texture image.
        number width = myTexture:GetWidth(1)
    end
end

HasPackedNormalMipMaps()

This action returns true if the texture holds packed normals (see SetPackedNormalMipMaps).

Returns

boolean: True for packed normals.

IsCubemap()

This action returns whether or not this texture is a cubemap. This is true if the texture was loaded using one of the LoadCubemap actions, or false otherwise.

Returns

boolean

IsLoadingAsynchronously()

This action returns true if the texture is asynchronously loading. While loading, the texture won't be ready for use yet. Once the texture has loaded, any registered TextureLoadListeners will be triggered.

Returns

boolean: True if this texture is currently loading a file, or false otherwise.

LoadAsynchronously(Libraries.System.File file, Libraries.Game.Graphics.Format format, boolean useMipMaps, Libraries.Game.Graphics.Drawable drawable)

This action will load a texture asynchronously (that is, the texture is loaded separately from the rest of the program's execution) and then load that texture into the provided Drawable. This action is called internally and automatically by the game engine when run on the web. Most users will never need to use this action directly.

Parameters

LoadAsynchronously(text filePath, Libraries.Game.Graphics.Drawable drawable)

This action will load a texture asynchronously (that is, the texture is loaded separately from the rest of the program's execution) and then load that texture into the provided Drawable. This action is called internally and automatically by the game engine when run on the web. Most users will never need to use this action directly.

Parameters

  • filePath text: A file path pointing to the image file to load into this Texture.
  • drawable Libraries.Game.Graphics.Drawable: A drawable that will be loaded with this Texture after the Texture has finished loading.

LoadAsynchronously(Libraries.System.File file, Libraries.Game.Graphics.Drawable drawable)

This action will load a texture asynchronously (that is, the texture is loaded separately from the rest of the program's execution) and then load that texture into the provided Drawable. This action is called internally and automatically by the game engine when run on the web. Most users will never need to use this action directly.

Parameters

LoadCircle(integer radius, Libraries.Game.Graphics.Color color)

This action will create a new Texture with a hollow circle of the given color with the given radius.

Parameters

Example

use Libraries.Game.Graphics.Texture
use Libraries.Game.Graphics.Color
use Libraries.Game.Graphics.Drawable
use Libraries.Game.Game

class Main is Game
    
    action Main
        StartGame()
    end

    action CreateGame
        Color red
        red:SetColor(1, 0, 0, 1)
        Texture texture
        texture:LoadCircle(75, red)
        Drawable circle
        circle:Load(texture)
        circle:SetPosition(50, 50)
        Add(circle)
    end
end

LoadCircle(integer radius)

This action will create a new Texture with a hollow white circle with the given radius.

Parameters

  • radius integer

Example

use Libraries.Game.Graphics.Texture
use Libraries.Game.Graphics.Drawable
use Libraries.Game.Game

class Main is Game
    
    action Main
        StartGame()
    end

    action CreateGame
        Texture texture
        texture:LoadCircle(75)
        circle:Load(texture)
        circle:SetPosition(50, 50)
        Add(circle)
    end
end

LoadCubemapFromFiles(Libraries.Containers.Array<Libraries.System.File> files)

This action loads a cubemap from an Array of six image files. The images should be ordered right, left, up, down, front, back.

Parameters

LoadCubemapFromPixelMaps(Libraries.Containers.Array<Libraries.Game.Graphics.PixelMap> pixelMaps)

This action loads a cubemap from an Array of six PixelMaps. The images should be ordered right, left, up, down, front, back.

Parameters

LoadFilledCircle(integer radius, Libraries.Game.Graphics.Color color)

This action will create a new Texture with a solid circle of the given color with the given radius.

Parameters

Example

use Libraries.Game.Graphics.Texture
use Libraries.Game.Graphics.Color
use Libraries.Game.Graphics.Drawable
use Libraries.Game.Game

class Main is Game
    
    action Main
        StartGame()
    end

    action CreateGame
        Color blue
        blue:SetColor(0, 0, 1, 1)
        Texture texture
        texture:LoadCircle(75, blue)
        Drawable circle
        circle:Load(texture)
        circle:SetPosition(50, 50)
        Add(circle)
    end
end

LoadFilledCircle(integer radius)

This action will create a new Texture with a solid white circle with the given radius.

Parameters

  • radius integer

Example

use Libraries.Game.Graphics.Texture
use Libraries.Game.Graphics.Drawable
use Libraries.Game.Game

class Main is Game
    
    action Main
        StartGame()
    end

    action CreateGame
        Texture texture
        texture:LoadFilledCircle(75)
        Drawable circle
        circle:Load(texture)
        circle:SetPosition(50, 50)
        Add(circle)
    end
end

LoadFilledRectangle(integer width, integer height)

This action will create a new Texture with a solid white rectangle with the given width and height.

Parameters

  • width integer
  • height integer

Example

use Libraries.Game.Graphics.Texture
use Libraries.Game.Graphics.Drawable
use Libraries.Game.Game

class Main is Game
    
    action Main
        StartGame()
    end

    action CreateGame
        Texture texture
        texture:LoadFilledRectangle(20, 100)
        Drawable rectangle
        rectangle:Load(texture)
        rectangle:SetPosition(50, 50)
        Add(rectangle)
    end
end

LoadFilledRectangle(integer width, integer height, Libraries.Game.Graphics.Color color)

This action will create a new Texture with a solid rectangle of the given color with the given width and height.

Parameters

Example

use Libraries.Game.Graphics.Texture
use Libraries.Game.Graphics.Drawable
use Libraries.Game.Graphics.Color
use Libraries.Game.Game

class Main is Game
    
    action Main
        StartGame()
    end

    action CreateGame
        Color green
        green:SetColor(0, 1, 0, 1)
        Texture texture
        texture:LoadFilledRectangle(20, 100, green)
        Drawable rectangle
        rectangle:Load(texture)
        rectangle:SetPosition(50, 50)
        Add(rectangle)
    end
end

LoadFilledTriangle(integer x1, integer y1, integer x2, integer y2, integer x3, integer y3)

This action will create a new Texture with a solid white triangle that is made of the points identified by the three given points.

Parameters

  • x1 integer
  • y1 integer
  • x2 integer
  • y2 integer
  • x3 integer
  • y3 integer

Example

use Libraries.Game.Graphics.Texture
use Libraries.Game.Graphics.Drawable
use Libraries.Game.Game

class Main is Game
    
    action Main
        StartGame()
    end

    action CreateGame
        Texture texture
        texture:LoadFilledTriangle(0, 0, 200, 200, 400, 0)
        Drawable triangle
        triangle:Load(texture)
        triangle:SetPosition(50, 50)
        Add(triangle)
    end
end

LoadFilledTriangle(integer x1, integer y1, integer x2, integer y2, integer x3, integer y3, Libraries.Game.Graphics.Color color)

This action will create a new Texture with a solid triangle of the given color that is made of the points identified by the three given points.

Parameters

Example

use Libraries.Game.Graphics.Texture
use Libraries.Game.Graphics.Drawable
use Libraries.Game.Graphics.Color
use Libraries.Game.Game

class Main is Game
    
    action Main
        StartGame()
    end

    action CreateGame
        Color purple
        purple:SetColor(0.5, 0, 0.5, 1)
        Texture texture
        texture:LoadFilledTriangle(0, 0, 200, 200, 400, 0, purple)
        Drawable triangle
        triangle:Load(texture)
        triangle:SetPosition(50, 50)
        Add(triangle)
    end
end

LoadFromFile(Libraries.System.File file)

This action loads a Texture from a Quorum File. The File must already have its path set for this function.

Parameters

Example

use Libraries.Game.Texture
use Libraries.Game.Game
use Libraries.System.File

class Main is Game

    File myFile
    Texture myTexture

    action Main
        StartGame()
    end

    action CreateGame
        myFile:SetPath("Images/Sample.png")

        // This call will load the image that the "myFile" variable points to.
        // The file points to an image called "Sample.png" in a folder called "Images".
        myTexture:LoadFromFile(myFile)
    end
end

LoadFromFile(text filePath, boolean useMipMaps)

This action loads a Texture from a file path, and makes mipmaps for it if asked: smaller copies the renderer uses when the texture is far away or seen at an angle, so it doesn't shimmer. Mipmaps suit textures on 3D models and ground. They cost a third more memory, and are not needed for 2D images drawn at their own size.

Parameters

  • filePath text: The image file's path.
  • useMipMaps boolean: True to make mipmaps.

Example

use Libraries.Game.Graphics.Texture
Texture ground
ground:LoadFromFile("Textures/grass.png", true)

LoadFromFile(text filePath)

This action loads a Texture from a file path given as text. The file path should be given relative to the directory where the program is executed from.

Parameters

  • filePath text: A file path pointing to the image file to load into this Texture.

Example

use Libraries.Game.Texture
use Libraries.Game.Game

class Main is Game

    Texture myTexture

    action Main
        StartGame()
    end

    action CreateGame
        // This call will load an image "Sample.png" from a directory called "Images".
        myTexture:LoadFromFile("Images/Sample.png")
    end
end

LoadFromFilePaths(Libraries.Containers.Array<text> filePaths)

This action loads a Texture from a Quorum File. The File must already have its path set for this function.

Parameters

Example

use Libraries.Game.Texture
use Libraries.Game.Game
use Libraries.System.File

class Main is Game

    File myFile
    Texture myTexture

    action Main
        StartGame()
    end

    action CreateGame
        myFile:SetPath("Images/Sample.png")

        // This call will load the image that the "myFile" variable points to.
        // The file points to an image called "Sample.png" in a folder called "Images".
        myTexture:LoadFromFile(myFile)
    end
end

LoadFromFiles(Libraries.Containers.Array<Libraries.System.File> files)

This action returns the cutoff a cut-out picture's mip levels keep (see SetCutoutMipMaps).

Parameters

LoadFromMatrix(Libraries.Compute.Matrix matrix)

This action will load a matrix into the Texture to create a monochrome (black and white) image. Each value is assumed to be between 0 and 1, where 0 represents a black pixel and 1 represents a white pixel.

Parameters

Example

use Libraries.Game.Game
use Libraries.Game.Graphics.Drawable
use Libraries.Game.Graphics.Texture
use Libraries.Compute.Matrix

class Main is Game

    Texture texture
    Drawable drawable

    action Main
        StartGame()
    end

    action CreateGame
        Matrix matrix

        // 7x7 square that is black at edges and lightens as it goes towards the center.
        matrix:Fill(7, 7, 0)
        matrix:Set(1, 1, 0.33)
        matrix:Set(2, 1, 0.33)
        matrix:Set(3, 1, 0.33)
        matrix:Set(4, 1, 0.33)
        matrix:Set(5, 1, 0.33)
        matrix:Set(5, 2, 0.33)
        matrix:Set(5, 3, 0.33)
        matrix:Set(5, 4, 0.33)
        matrix:Set(5, 5, 0.33)
        matrix:Set(4, 5, 0.33)
        matrix:Set(3, 5, 0.33)
        matrix:Set(2, 5, 0.33)
        matrix:Set(1, 5, 0.33)
        matrix:Set(1, 4, 0.33)
        matrix:Set(1, 3, 0.33)
        matrix:Set(1, 2, 0.33)

        matrix:Set(2, 2, 0.66)
        matrix:Set(3, 2, 0.66)
        matrix:Set(4, 2, 0.66)
        matrix:Set(4, 3, 0.66)
        matrix:Set(4, 4, 0.66)
        matrix:Set(3, 4, 0.66)
        matrix:Set(2, 4, 0.66)
        matrix:Set(2, 3, 0.66)

        matrix:Set(3, 3, 1)

        // Loading the Texture and blowing up the size of the Drawable to make it easier to see.
        texture:LoadFromMatrix(matrix)
        drawable:Load(texture)
        Add(drawable)

        drawable:SetPosition(200, 200)
        drawable:SetSize(100, 100)
    end
end

LoadFromPixelMap(Libraries.Game.Graphics.PixelMap pixelMap, Libraries.Game.Graphics.Format format, boolean useMipMaps)

The LoadFromPixelMap action loads a PixelMap into this texture, using the given Format. If mip-mapping is supported on the given platform, mip-maps will be used if the boolean parameter is true.

Parameters

Example

use Libraries.Game.Game
use Libraries.Game.Graphics.PixelMap
use Libraries.Game.Graphics.Format
use Libraries.Game.Graphics.Texture
use Libraries.Game.Graphics.Drawable
use Libraries.Game.Graphics.Color

class Main is Game

    Color color

    action Main
        StartGame()
    end

    action CreateGame
        PixelMap map
        Format format
        format:SetValue(format:RGBA8888)
        map:CreatePixelMap(200, 200, format)

        // We will create a pink box with a red stripe across it.
        map:Fill(color:Pink())

        integer x = 0
        integer y = 85
        repeat while y < 125
            x = 0
            repeat while x < 200
                map:SetPixel(x, y, color:Red())
                x = x + 1
            end
            y = y + 1
        end

        Texture texture
        texture:LoadFromPixelMap(map, format, false)

        Drawable drawable
        drawable:Load(texture)
        Add(drawable)
    end
end

LoadFromPixelMap(Libraries.Game.Graphics.PixelMap pixelMap)

The LoadFromPixelMap action loads a PixelMap into this texture. The PixelMap will use its already given Format.

Parameters

Example

use Libraries.Game.Game
use Libraries.Game.Graphics.PixelMap
use Libraries.Game.Graphics.Format
use Libraries.Game.Graphics.Texture
use Libraries.Game.Graphics.Drawable
use Libraries.Game.Graphics.Color

class Main is Game

    Color color

    action Main
        StartGame()
    end

    action CreateGame
        PixelMap map
        Format format
        format:SetValue(format:RGBA8888)
        map:CreatePixelMap(200, 200, format)

        // We will create a pink box with a red stripe across it.
        map:Fill(color:Pink())

        integer x = 0
        integer y = 85
        repeat while y < 125
            x = 0
            repeat while x < 200
                map:SetPixel(x, y, color:Red())
                x = x + 1
            end
            y = y + 1
        end

        Texture texture
        texture:LoadFromPixelMap(map)

        Drawable drawable
        drawable:Load(texture)
        Add(drawable)
    end
end

LoadFromPixelMaps(Libraries.Containers.Array<Libraries.Game.Graphics.PixelMap> pixelMaps)

This action says the texture is a cut-out picture, such as a grass card or a leaf, drawn only where its alpha reaches a cutoff. Its smaller mip levels then keep the same share of pixels past the cutoff as the full size, so thin parts don't fade away and flicker in the distance. Set it before loading. Only the Vulkan renderer uses it.

Parameters

Example

use Libraries.Game.Graphics.Texture

Texture grass
grass:SetCutoutMipMaps(0.5)
grass:LoadFromFile("Pictures/Grass.png")

LoadLine(integer x, integer y)

This action will create a new Texture with a white line that connects an imaginary point at 0,0 to the provided x,y coordinates.

Parameters

  • x integer
  • y integer

Example

use Libraries.Game.Graphics.Texture
use Libraries.Game.Graphics.Drawable
use Libraries.Game.Game

class Main is Game
    
    action Main
        StartGame()
    end

    action CreateGame
        Texture texture
        texture:LoadLine(20, 100)
        Drawable line
        line:Load(texture)
        line:SetPosition(50, 50)
        Add(line)
    end
end

LoadLine(integer x, integer y, Libraries.Game.Graphics.Color color)

This action will create a new Texture with a line of the given color that connects between an imaginary point at 0,0 to the provided x,y coordinates.

Parameters

Example

use Libraries.Game.Graphics.Texture
use Libraries.Game.Graphics.Drawable
use Libraries.Game.Graphics.Color
use Libraries.Game.Game

class Main is Game
    
    action Main
        StartGame()
    end

    action CreateGame
        Color cyan
        cyan:SetColor(0, 1, 1, 1)
        Texture texture
        texture:LoadLine(20, 100, cyan)
        Drawable line
        line:Load(texture)
        line:SetPosition(50, 50)
        Add(line)
    end
end

LoadModelTexture(Libraries.System.File file)

This action loads a Texture from a Quorum File. The File must already have its path set for this function. When loaded via this command, the Texture will be set to use linear filtering and repeated texture wrapping, which is typically preferred for 3D models.

Parameters

Example

use Libraries.Game.Texture
use Libraries.Game.Game
use Libraries.System.File

class Main is Game

    File myFile
    Texture myTexture

    action Main
        StartGame()
    end

    action CreateGame
        myFile:SetPath("Images/Sample.png")

        // This call will load the image that the "myFile" variable points to.
        // The file points to an image called "Sample.png" in a folder called "Images".
        myTexture:LoadModelTexture(myFile)
    end
end

LoadModelTexture(text fileName)

This action loads a Texture from a file path given as text. The file path should be given relative to the directory where the program is executed from. When loaded via this command, the Texture will be set to use linear filtering and repeated texture wrapping, which is typically preferred for 3D models.

Parameters

  • fileName text: A file path pointing to the image file to load into a Texture.

Example

use Libraries.Game.Texture
use Libraries.Game.Game

class Main is Game

    Texture myTexture

    action Main
        StartGame()
    end

    action CreateGame
        // This call will load an image "Sample.png" from a directory called "Images".
        myTexture:LoadModelTexture("Images/Sample.png")
    end
end

LoadRectangle(integer width, integer height)

This action will create a new Texture with a hollow white rectangle with the given width and height.

Parameters

  • width integer
  • height integer

Example

use Libraries.Game.Graphics.Texture
use Libraries.Game.Graphics.Drawable
use Libraries.Game.Game

class Main is Game
    
    action Main
        StartGame()
    end

    action CreateGame
        Texture texture
        texture:LoadRectangle(20, 100)
        Drawable rectangle
        rectangle:SetPosition(50, 50)
        Add(rectangle)
    end
end

LoadRectangle(integer width, integer height, Libraries.Game.Graphics.Color color)

This action will create a new Texture with a hollow rectangle of the given color with the given width and height. This texture is then loaded into the Drawable.

Parameters

Example

use Libraries.Game.Graphics.Texture
use Libraries.Game.Graphics.Color
use Libraries.Game.Graphics.Drawable
use Libraries.Game.Game

class Main is Game
    
    action Main
        StartGame()
    end

    action CreateGame
        Color yellow
        yellow:SetColor(1, 1, 0, 1)
        Texture texture
        texture:LoadRectangle(20, 100, yellow)
        Drawable rectangle
        rectangle:Load(texture)
        rectangle:SetPosition(50, 50)
        Add(rectangle)
    end
end

Reload()

Used to reload a Texture that's already been loaded. This is used internally to ensure a Texture is automatically regained if the information is lost due to a context loss (e.g., minimizing the application on an Android device). Users will most likely never need to call this action directly.

RemoveTextureLoadListener(Libraries.Interface.Events.TextureLoadListener listener)

This action removes a TextureLoadListener from the texture. If the listener was not previously added to this texture, this does nothing.

Parameters

SetCutoutMipMaps(number cutoff)

This action says the texture is a cut-out picture, such as a grass card or a leaf, drawn only where its alpha reaches a cutoff. Its smaller mip levels then keep the same share of pixels past the cutoff as the full size, so thin parts don't fade away and flicker in the distance. Set it before loading. Only the Vulkan renderer uses it.

Parameters

  • cutoff number: The alpha it is cut at, such as 0.5; 0 for an ordinary texture.

Example

use Libraries.Game.Graphics.Texture

Texture grass
grass:SetCutoutMipMaps(0.5)
grass:LoadFromFile("Pictures/Grass.png")

SetFilter(Libraries.Game.Graphics.TextureFilter minFilter, Libraries.Game.Graphics.TextureFilter magFilter)

Sets the minimization filter and magnification filter, respectively, used for this Texture. See Libraries.Game.Graphics.TextureFilter for details on what the different filters do.

Parameters

SetPackedNormalMipMaps(boolean packed)

This action says whether the texture holds packed normals, as a texture set's normal-roughness texture does. If it does, its mipmaps keep each normal a real direction, and keep the ambient occlusion carried in the normals' length. Set it before loading. Only the Vulkan renderer uses it.

Parameters

  • packed boolean: True for packed normals.

SetVulkanImageView(Libraries.Game.Graphics.Vulkan.VulkanImageView vulkanImageView)

This action sets the VulkanImageView associated with this Texture. The image view represents resources used by this texture in the Vulkan system, if the Game engine is using the Vulkan graphics library. If not, this is undefined. This is a Vulkan internal component, and will never be needed by most users.

Parameters

SetVulkanSampler(Libraries.Game.Graphics.Vulkan.VulkanSampler vulkanSampler)

This action sets the VulkanSampler associated with this Texture. The sampler is used to access the resources of the VulkanImageView. This will be undefined if the system isn't using the Vulkan graphics library, and even if it is, this still might be undefined if this texture is being used with an external sampler (e.g., for 3D rendering). This is a Vulkan internal component, and will never be needed by most users.

Parameters

SetVulkanTextureIndex(integer vulkanTextureIndex)

This action sets the index used by the VulkanTextureManager to store this texture in the global array of textures, if Vulkan is being used for the engine. This value defaults to -1. This is an internal component used by the Vulkan system, and will never be needed by most users.

Parameters

  • vulkanTextureIndex integer

SetWrap(Libraries.Game.Graphics.TextureWrap hWrap, Libraries.Game.Graphics.TextureWrap vWrap)

Sets the horizontal and vertical texture wrapping modes, respectively, used for this Texture. See Libraries.Game.Graphics.TextureWrap for details on what the different texture wrapping modes do.

Parameters

UnsafeSetFilter(Libraries.Game.Graphics.TextureFilter min, Libraries.Game.Graphics.TextureFilter mag)

This action will set the texture filter of this Texture, assuming it is already bound and active. This method sacrifices safety for speed, and should never be used directly by users.

Parameters

UnsafeSetWrap(Libraries.Game.Graphics.TextureWrap u, Libraries.Game.Graphics.TextureWrap v)

This action will set the texture wrapping of this Texture, assuming it is already bound and active. This method sacrifices safety for speed, and should never be used directly by users.

Parameters

UsesMipMaps()

This action returns true if the texture was loaded asking for mipmaps.

Returns

boolean: True if the texture uses mipmaps.

Inherited Actions

3 actions from Libraries.Language.Object