Cogl.Texture2DSliced.new_from_file

function new_from_file(ctx: Cogl.Context, filename: String, max_waste: Number(gint)): Cogl.Texture2DSliced {
    // Gjs wrapper for cogl_texture_2d_sliced_new_from_file()
}
  

Creates a Cogl.Texture2DSliced from an image file.

A Cogl.Texture2DSliced may internally be comprised of 1 or more Cogl.Texture2D textures depending on GPU limitations. For example if the GPU only supports power-of-two sized textures then a sliced texture will turn a non-power-of-two size into a combination of smaller power-of-two sized textures. If the requested texture size is larger than is supported by the hardware then the texture will be sliced into smaller textures that can be accessed by the hardware.

max_waste is used as a threshold for recursively slicing the right-most or bottom-most slices into smaller sizes until the wasted padding at the bottom and right of the textures is less than specified. A negative max_waste will disable slicing.

The storage for the texture is not allocated before this function returns. You can call Cogl.Texture.prototype.allocate to explicitly allocate the underlying storage or let Cogl automatically allocate storage lazily.

<note>It's possible for the allocation of a sliced texture to fail later due to impossible slicing constraints if a negative max_waste value is given. If the given virtual texture size is larger than is supported by the hardware but slicing is disabled the texture size would be too large to handle.</note>

Since 1.16

ctx

A Cogl.Context

filename

the file to load

max_waste

The threshold of how wide a strip of wasted texels are allowed along the right and bottom textures before they must be sliced to reduce the amount of waste. A negative can be passed to disable slicing.

Returns

A newly created Cogl.Texture2DSliced or null on failure and @error will be updated.