Cogl.Texture2D.new_from_file
function new_from_file(ctx: Cogl.Context, filename: String): Cogl.Texture2D { // Gjs wrapper for cogl_texture_2d_new_from_file() }
Creates a low-level Cogl.Texture2D texture from an image file.
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 preferably let Cogl automatically allocate storage lazily when it may know more about how the texture is being used and can optimize how it is allocated.
The texture is still configurable until it has been allocated so for example you can influence the internal format of the texture using Cogl.Texture.prototype.set_components and Cogl.Texture.prototype.set_premultiplied.
<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 1.16
- ctx
- filename
the file to load
- Returns
A newly created Cogl.Texture2D or null on failure and @error will be updated.