Cogl.Texture2D

g Cogl.Object Cogl.Object Cogl.Texture2D Cogl.Texture2D Cogl.Object->Cogl.Texture2D Cogl.Texture Cogl.Texture Cogl.Texture->Cogl.Texture2D GObject.GInterface GObject.GInterface GObject.GInterface->Cogl.Texture

Implementations:

None

Methods

Inherited:

Cogl.Object (2), Cogl.Texture (14)

class

gl_new_from_foreign (ctx, gl_handle, width, height, format)

class

new_from_bitmap (bitmap)

class

new_from_data (ctx, width, height, format, rowstride, data)

class

new_from_file (ctx, filename)

class

new_with_size (ctx, width, height)

Virtual Methods

None

Properties

None

Signals

None

Fields

None

Class Details

class Cogl.Texture2D
Bases:

Cogl.Object, Cogl.Texture

classmethod gl_new_from_foreign(ctx, gl_handle, width, height, format)
Parameters:
  • ctx (Cogl.Context) – A Cogl.Context

  • gl_handle (int) – A GL handle for a GL_TEXTURE_2D texture object

  • width (int) – Width of the foreign GL texture

  • height (int) – Height of the foreign GL texture

  • format (Cogl.PixelFormat) – The format of the texture

Returns:

A newly allocated Cogl.Texture2D

Return type:

Cogl.Texture2D

Wraps an existing GL_TEXTURE_2D texture object as a Cogl.Texture2D. This can be used for integrating Cogl with software using OpenGL directly.

The texture is still configurable until it has been allocated so for example you can declare whether the texture is premultiplied with Cogl.Texture.set_premultiplied().

The results are undefined for passing an invalid gl_handle or if width or height don’t have the correct texture geometry.

New in version 2.0.

classmethod new_from_bitmap(bitmap)
Parameters:

bitmap (Cogl.Bitmap) – A Cogl.Bitmap

Returns:

A newly allocated Cogl.Texture2D

Return type:

Cogl.Texture2D

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

The storage for the texture is not allocated before this function returns. You can call Cogl.Texture.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.set_components() and Cogl.Texture.set_premultiplied().

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().

New in version 2.0.

classmethod new_from_data(ctx, width, height, format, rowstride, data)
Parameters:
  • ctx (Cogl.Context) – A Cogl.Context

  • width (int) – width of texture in pixels

  • height (int) – height of texture in pixels

  • format (Cogl.PixelFormat) – the Cogl.PixelFormat the buffer is stored in in RAM

  • rowstride (int) – 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 (int) – pointer the memory region where the source buffer resides

Raises:

GLib.Error

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 None and set error.

Return type:

Cogl.Texture2D

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

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.set_data() 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().

New in version 2.0.

classmethod new_from_file(ctx, filename)
Parameters:
Raises:

GLib.Error

Returns:

A newly created Cogl.Texture2D or None on failure and error will be updated.

Return type:

Cogl.Texture2D

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.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.set_components() and Cogl.Texture.set_premultiplied().

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().

New in version 1.16.

classmethod new_with_size(ctx, width, height)
Parameters:
Returns:

A new Cogl.Texture2D object with no storage yet allocated.

Return type:

Cogl.Texture2D

Creates a low-level Cogl.Texture2D texture with a given width and height that your GPU can texture from directly.

The storage for the texture is not allocated before this function returns. You can call Cogl.Texture.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.set_components() and Cogl.Texture.set_premultiplied().

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().

New in version 2.0.