Cogl.Texture2DSliced.new_from_data
function new_from_data(ctx: Cogl.Context, width: Number(gint), height: Number(gint), max_waste: Number(gint), format: Cogl.PixelFormat, rowstride: Number(gint), data: Number(guint8)): Cogl.Texture2DSliced { // Gjs wrapper for cogl_texture_2d_sliced_new_from_data() }
Creates a new Cogl.Texture2DSliced texture based on data residing in memory.
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.
<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 Cogl.Bitmap for your data and use Cogl.Texture2DSliced.new_from_bitmap or use Cogl.Texture2DSliced.new_with_size and then upload data using Cogl.Texture.prototype.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>
Since 1.16
- ctx
- 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 Cogl.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 Cogl.Texture2DSliced or null on failure and @error will be updated.