Constructor

CoglAtlasTexturenew_from_data

Declaration [src]

CoglTexture*
cogl_atlas_texture_new_from_data (
  CoglContext* ctx,
  int width,
  int height,
  CoglPixelFormat format,
  int rowstride,
  const uint8_t* data,
  GError** error
)

Description [src]

Creates a new CoglAtlasTexture texture based on data residing in memory. A CoglAtlasTexture represents a sub-region within one of Cogl’s shared texture atlases.

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 CoglBitmap for your data and use cogl_atlas_texture_new_from_bitmap() or use cogl_atlas_texture_new_with_size() and then upload data using cogl_texture_set_data()

Allocate call can fail if Cogl considers the internal format to be incompatible with the format of its internal atlases.

The returned CoglAtlasTexture is a high-level meta-texture with some limitations. See the documentation for CoglMetaTexture for more details.

Parameters

ctx

Type: CoglContext

A CoglContext.

The data is owned by the caller of the function.
width

Type: int

Width of texture in pixels.

height

Type: int

Height of texture in pixels.

format

Type: CoglPixelFormat

The CoglPixelFormat the buffer is stored in in RAM.

rowstride

Type: int

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

Type: const uint8_t*

Pointer to the memory region where the source buffer resides.

The data is owned by the caller of the function.
error

Type: GError **

The return location for a recoverable error.

The argument can be NULL.
If the return location is not NULL, then you must initialize it to a NULL GError*.
The argument will be left initialized to NULL by the constructor if there are no errors.
In case of error, the argument will be set to a newly allocated GError; the caller will take ownership of the data, and be responsible for freeing it.

Return value

Type: CoglTexture

A new CoglAtlasTexture object or NULL on failure and error will be updated.

The caller of the function takes ownership of the data, and is responsible for freeing it.