texture-2d: Add _new_from_file api
This adds a cogl_texture_2d_new_from_file() api since we are planning to remove cogl_texture_new_from_file() but don't want to loose the convenience it had. Reviewed-by: Neil Roberts <neil@linux.intel.com> (cherry picked from commit 10e91aa513123ed277a8d45976f8d75445d7dc9c)
This commit is contained in:
parent
fc5d1a8a68
commit
aa92110f83
@ -191,6 +191,31 @@ cogl_texture_2d_new_from_bitmap (CoglBitmap *bmp,
|
||||
return _cogl_texture_2d_new_from_bitmap (bmp, internal_format, FALSE, error);
|
||||
}
|
||||
|
||||
CoglTexture2D *
|
||||
cogl_texture_2d_new_from_file (CoglContext *ctx,
|
||||
const char *filename,
|
||||
CoglPixelFormat internal_format,
|
||||
CoglError **error)
|
||||
{
|
||||
CoglBitmap *bmp;
|
||||
CoglTexture2D *tex_2d = NULL;
|
||||
|
||||
_COGL_RETURN_VAL_IF_FAIL (error == NULL || *error == NULL, NULL);
|
||||
|
||||
bmp = _cogl_bitmap_from_file (ctx, filename, error);
|
||||
if (bmp == NULL)
|
||||
return NULL;
|
||||
|
||||
tex_2d = _cogl_texture_2d_new_from_bitmap (bmp,
|
||||
internal_format,
|
||||
TRUE, /* can convert in-place */
|
||||
error);
|
||||
|
||||
cogl_object_unref (bmp);
|
||||
|
||||
return tex_2d;
|
||||
}
|
||||
|
||||
CoglTexture2D *
|
||||
cogl_texture_2d_new_from_data (CoglContext *ctx,
|
||||
int width,
|
||||
|
@ -102,6 +102,33 @@ cogl_texture_2d_new_with_size (CoglContext *ctx,
|
||||
int height,
|
||||
CoglPixelFormat internal_format);
|
||||
|
||||
/**
|
||||
* cogl_texture_2d_new_from_file:
|
||||
* @ctx: A #CoglContext
|
||||
* @filename: the file to load
|
||||
* @internal_format: the #CoglPixelFormat to use for the GPU storage of the
|
||||
* texture. If %COGL_PIXEL_FORMAT_ANY is given then a premultiplied
|
||||
* format similar to the format of the source data will be used. The
|
||||
* default blending equations of Cogl expect premultiplied color data;
|
||||
* the main use of passing a non-premultiplied format here is if you
|
||||
* have non-premultiplied source data and are going to adjust the blend
|
||||
* mode (see cogl_material_set_blend()) or use the data for something
|
||||
* other than straight blending.
|
||||
* @error: A #CoglError to catch exceptional errors or %NULL
|
||||
*
|
||||
* Creates a #CoglTexture2D from an image file.
|
||||
*
|
||||
* Return value: A newly created #CoglTexture2D or %NULL on failure
|
||||
* and @error will be updated.
|
||||
*
|
||||
* Since: 1.16
|
||||
*/
|
||||
CoglTexture2D *
|
||||
cogl_texture_2d_new_from_file (CoglContext *ctx,
|
||||
const char *filename,
|
||||
CoglPixelFormat internal_format,
|
||||
CoglError **error);
|
||||
|
||||
/**
|
||||
* cogl_texture_2d_new_from_data:
|
||||
* @ctx: A #CoglContext
|
||||
|
@ -417,6 +417,7 @@ COGL_TEXTURE_MAX_WASTE
|
||||
<TITLE>2D textures</TITLE>
|
||||
CoglTexture2D
|
||||
cogl_texture_2d_new_with_size
|
||||
cogl_texture_2d_new_from_file
|
||||
cogl_texture_2d_new_from_bitmap
|
||||
cogl_texture_2d_new_from_data
|
||||
cogl_texture_2d_new_from_foreign
|
||||
|
Loading…
x
Reference in New Issue
Block a user