Texture2DSliced.from_data


Description:

public Texture2DSliced.from_data (Context ctx, int width, int height, int max_waste, PixelFormat format, int rowstride, uint8 data) throws Error

Creates a new Texture2DSliced texture based on data residing in memory.

A Texture2DSliced may internally be comprised of 1 or more 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.

<note>This api will always immediately allocate GPU memory for all the required texture slices and upload the given data so that the data pointer does not need to remain valid once this function returns. This means it is not possible to configure the texture before it is allocated. If you do need to configure the texture before allocation (to specify constraints on the internal format for example) then you can instead create a Bitmap for your data and use Texture2DSliced.from_bitmap or use Texture2DSliced.with_size and then upload data using set_data</note>

<note>It's possible for the allocation of a sliced texture to fail 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>

Parameters:

ctx

A Context

width

width of texture in pixels

height

height of texture in pixels

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.

format

the PixelFormat the buffer is stored in in RAM

rowstride

the memory offset in bytes between the start of each row in data. A value of 0 will make Cogl automatically calculate rowstride from width and format.

data

pointer the memory region where the source buffer resides

Returns:

A newly created Texture2DSliced or null on failure and throws will be updated.