Cogl.Texture2D.new_from_data

function new_from_data(ctx: Cogl.Context, width: Number(gint), height: Number(gint), format: Cogl.PixelFormat, rowstride: Number(gint), data: Number(guint8)): Cogl.Texture2D {
    // Gjs wrapper for cogl_texture_2d_new_from_data()
}
  

Creates a low-level Cogl.Texture2D texture based on data residing in memory.

<note>This api will always immediately allocate GPU memory for the texture 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.Texture2D.new_from_bitmap or use Cogl.Texture2D.new_with_size and then upload data using Cogl.Texture.prototype.set_data</note>

<note>Many GPUs only support power of two sizes for Cogl.Texture2D textures. You can check support for non power of two textures by checking for the Cogl.FeatureID.ogl_feature_id_texture_npot feature via Cogl.has_feature.</note>

Since 2.0

ctx

A Cogl.Context

width

width of texture in pixels

height

height of texture in pixels

format

the Cogl.PixelFormat the buffer is stored in in RAM

rowstride

the memory offset in bytes between the starts of scanlines 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 allocated Cogl.Texture2D, or if the size is not supported (because it is too large or a non-power-of-two size that the hardware doesn't support) it will return null and set @error.