Libraries.Game.Graphics.SharedTexture Documentation

Inherits from: Libraries.Game.Graphics.Texture, Libraries.Language.Object, Libraries.Game.Disposable

Actions Documentation

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

  • integer textureUnit

Compare(Libraries.Language.Object object)

This action compares two object hash codes and returns an integer. The result is larger if this hash code is larger than the object passed as a parameter, smaller, or equal. In this case, -1 means smaller, 0 means equal, and 1 means larger. This action was changed in Quorum 7 to return an integer, instead of a CompareResult object, because the previous implementation was causing efficiency issues.

Parameters

Return

integer: The Compare result, Smaller, Equal, or Larger.

Example

Object o
Object t
integer result = o:Compare(t) //1 (larger), 0 (equal), or -1 (smaller)

Dispose()

EmptyTextureLoadListeners()

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

Equals(Libraries.Language.Object object)

This action determines if two objects are equal based on their hash code values.

Parameters

Return

boolean: True if the hash codes are equal and false if they are not equal.

Example

use Libraries.Language.Object
use Libraries.Language.Types.Text
Object o
Text t
boolean result = o:Equals(t)

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

GetHashCode()

This action gets the hash code for an object.

Return

integer: The integer hash code of the object.

Example

Object o
integer hash = o:GetHashCode()

GetHeight()

This action returns the height of a loaded Texture.

Return

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.

Return

Libraries.Game.Graphics.TextureWrap:

GetMagnifyFilter()

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

Return

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.

Return

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.

Return

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.

Return

Libraries.Game.Graphics.TextureWrap:

GetWidth()

This action returns the width of a loaded Texture.

Return

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

IsDisposalAllowed()

Return

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.

Return

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

  • text filePath: A file path pointing to the image file to load into this Texture.
  • 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

  • integer radius

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

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

  • integer radius

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

  • integer width
  • integer height

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

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

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)

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

  • text filePath: 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

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

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

  • integer x
  • integer y

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

  • text fileName: 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

  • integer width
  • integer height

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

SetDisposalAllowed(boolean allowDisposal)

Parameters

  • boolean allowDisposal

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

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