| Cogl Reference Manual | ||||
|---|---|---|---|---|
| Top | Description | ||||
struct CoglTextureVertex; enum CoglTextureFlags; CoglHandle cogl_texture_new_with_size (unsigned int width,unsigned int height,CoglTextureFlags flags,CoglPixelFormat internal_format); CoglHandle cogl_texture_new_from_file (const char *filename,CoglTextureFlags flags,CoglPixelFormat internal_format,GError **error); CoglHandle cogl_texture_new_from_data (unsigned int width,unsigned int height,CoglTextureFlags flags,CoglPixelFormat format,CoglPixelFormat internal_format,unsigned int rowstride,const guint8 *data); CoglHandle cogl_texture_new_from_foreign (GLuint gl_handle,GLenum gl_target,GLuint width,GLuint height,GLuint x_pot_waste,GLuint y_pot_waste,CoglPixelFormat format); CoglHandle cogl_texture_new_from_bitmap (CoglHandle bmp_handle,CoglTextureFlags flags,CoglPixelFormat internal_format); CoglHandle cogl_texture_new_from_sub_texture (CoglHandle full_texture,int sub_x,int sub_y,int sub_width,int sub_height); gboolean cogl_is_texture (CoglHandle handle); unsigned int cogl_texture_get_width (CoglHandle handle); unsigned int cogl_texture_get_height (CoglHandle handle); CoglPixelFormat cogl_texture_get_format (CoglHandle handle); unsigned int cogl_texture_get_rowstride (CoglHandle handle); int cogl_texture_get_max_waste (CoglHandle handle); gboolean cogl_texture_is_sliced (CoglHandle handle); gboolean cogl_texture_get_gl_texture (CoglHandle handle,GLuint *out_gl_handle,GLenum *out_gl_target); int cogl_texture_get_data (CoglHandle handle,CoglPixelFormat format,unsigned int rowstride,guint8 *data); gboolean cogl_texture_set_region (CoglHandle handle,int src_x,int src_y,int dst_x,int dst_y,unsigned int dst_width,unsigned int dst_height,int width,int height,CoglPixelFormat format,unsigned int rowstride,const guint8 *data);
COGL allows creating and manipulating GL textures using a uniform API that tries to hide all the various complexities of creating, loading and manipulating textures.
struct CoglTextureVertex {
float x, y, z;
float tx, ty;
CoglColor color;
};
Used to specify vertex information when calling cogl_polygon()
| Model x-coordinate | |
| Model y-coordinate | |
| Model z-coordinate | |
| Texture x-coordinate | |
| Texture y-coordinate | |
CoglColor |
The color to use at this vertex. This is ignored if
use_color is FALSE when calling cogl_polygon()
|
typedef enum {
COGL_TEXTURE_NONE = 0,
COGL_TEXTURE_NO_AUTO_MIPMAP = 1 << 0,
COGL_TEXTURE_NO_SLICING = 1 << 1,
COGL_TEXTURE_NO_ATLAS = 1 << 2
} CoglTextureFlags;
Flags to pass to the cogl_texture_new_* family of functions.
| No flags specified | |
| Disables the automatic generation of the mipmap pyramid from the base level image whenever it is updated. The mipmaps are only generated when the texture is rendered with a mipmap filter so it should be free to leave out this flag when using other filtering modes | |
| Disables the slicing of the texture | |
| Disables the insertion of the texture inside the texture atlas used by Cogl |
Since 1.0
CoglHandle cogl_texture_new_with_size (unsigned int width,unsigned int height,CoglTextureFlags flags,CoglPixelFormat internal_format);
Creates a new COGL texture with the specified dimensions and pixel format.
|
width of texture in pixels. |
|
height of texture in pixels. |
|
Optional flags for the texture, or COGL_TEXTURE_NONE
|
|
the CoglPixelFormat to use for the GPU storage of the texture. |
Returns : |
a CoglHandle to the newly created texture or
COGL_INVALID_HANDLE on failure
|
Since 0.8
CoglHandle cogl_texture_new_from_file (const char *filename,CoglTextureFlags flags,CoglPixelFormat internal_format,GError **error);
Creates a COGL texture from an image file.
|
the file to load |
|
Optional flags for the texture, or COGL_TEXTURE_NONE
|
|
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.
|
|
return location for a GError or NULL
|
Returns : |
a CoglHandle to the newly created texture or
COGL_INVALID_HANDLE on failure
|
Since 0.8
CoglHandle cogl_texture_new_from_data (unsigned int width,unsigned int height,CoglTextureFlags flags,CoglPixelFormat format,CoglPixelFormat internal_format,unsigned int rowstride,const guint8 *data);
Creates a new COGL texture based on data residing in memory.
|
width of texture in pixels |
|
height of texture in pixels |
|
Optional flags for the texture, or COGL_TEXTURE_NONE
|
|
the CoglPixelFormat the buffer is stored in in RAM |
|
the CoglPixelFormat that will be used for storing
the buffer on the GPU. 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.
|
|
the memory offset in bytes between the starts of
scanlines in data
|
|
pointer the memory region where the source buffer resides |
Returns : |
a CoglHandle to the newly created texture or
COGL_INVALID_HANDLE on failure
|
Since 0.8
CoglHandle cogl_texture_new_from_foreign (GLuint gl_handle,GLenum gl_target,GLuint width,GLuint height,GLuint x_pot_waste,GLuint y_pot_waste,CoglPixelFormat format);
Creates a COGL texture based on an existing OpenGL texture; the width, height and format are passed along since it is not always possible to query these from OpenGL.
The waste arguments allow you to create a Cogl texture that maps to a region smaller than the real OpenGL texture. For instance if your hardware only supports power-of-two textures you may load a non-power-of-two image into a larger power-of-two texture and use the waste arguments to tell Cogl which region should be mapped to the texture coordinate range [0:1].
|
opengl handle of foreign texture. |
|
opengl target type of foreign texture |
|
width of foreign texture |
|
height of foreign texture. |
|
horizontal waste on the right hand edge of the texture. |
|
vertical waste on the bottom edge of the texture. |
|
format of the foreign texture. |
Returns : |
a CoglHandle to the newly created texture or
COGL_INVALID_HANDLE on failure
|
Since 0.8
CoglHandle cogl_texture_new_from_bitmap (CoglHandle bmp_handle,CoglTextureFlags flags,CoglPixelFormat internal_format);
Creates a COGL texture from a CoglBitmap.
|
A CoglBitmap handle |
|
Optional flags for the texture, or COGL_TEXTURE_NONE
|
|
the CoglPixelFormat to use for the GPU storage of the texture |
Returns : |
a CoglHandle to the newly created texture or
COGL_INVALID_HANDLE on failure
|
Since 1.0
CoglHandle cogl_texture_new_from_sub_texture (CoglHandle full_texture,int sub_x,int sub_y,int sub_width,int sub_height);
Creates a new texture which represents a subregion of another texture. The GL resources will be shared so that no new texture data is actually allocated.
Sub textures have undefined behaviour texture coordinates outside of the range [0,1] are used. They also do not work with CoglVertexBuffers.
The sub texture will keep a reference to the full texture so you do not need to keep one separately if you only want to use the sub texture.
|
a CoglHandle to an existing texture |
|
X coordinate of the top-left of the subregion |
|
Y coordinate of the top-left of the subregion |
|
Width in pixels of the subregion |
|
Height in pixels of the subregion |
Returns : |
a CoglHandle to the new texture. |
Since 1.2
gboolean cogl_is_texture (CoglHandle handle);
Gets whether the given handle references an existing texture object.
|
A CoglHandle |
Returns : |
TRUE if the handle references a texture, and
FALSE otherwise
|
unsigned int cogl_texture_get_width (CoglHandle handle);
Queries the width of a cogl texture.
|
a CoglHandle for a texture. |
Returns : |
the width of the GPU side texture in pixels |
unsigned int cogl_texture_get_height (CoglHandle handle);
Queries the height of a cogl texture.
|
a CoglHandle for a texture. |
Returns : |
the height of the GPU side texture in pixels |
CoglPixelFormat cogl_texture_get_format (CoglHandle handle);
Queries the CoglPixelFormat of a cogl texture.
|
a CoglHandle for a texture. |
Returns : |
the CoglPixelFormat of the GPU side texture |
unsigned int cogl_texture_get_rowstride (CoglHandle handle);
Queries the rowstride of a cogl texture.
|
a CoglHandle for a texture. |
Returns : |
the offset in bytes between each consequetive row of pixels |
int cogl_texture_get_max_waste (CoglHandle handle);
Queries the maximum wasted (unused) pixels in one dimension of a GPU side texture.
|
a CoglHandle for a texture. |
Returns : |
the maximum waste |
gboolean cogl_texture_is_sliced (CoglHandle handle);
Queries if a texture is sliced (stored as multiple GPU side tecture objects).
|
a CoglHandle for a texture. |
Returns : |
TRUE if the texture is sliced, FALSE if the texture
is stored as a single GPU texture
|
gboolean cogl_texture_get_gl_texture (CoglHandle handle,GLuint *out_gl_handle,GLenum *out_gl_target);
Queries the GL handles for a GPU side texture through its CoglHandle.
If the texture is spliced the data for the first sub texture will be queried.
|
a CoglHandle for a texture. |
|
pointer to return location for the
textures GL handle, or NULL. [out][allow-none]
|
|
pointer to return location for the
GL target type, or NULL. [out][allow-none]
|
Returns : |
TRUE if the handle was successfully retrieved, FALSE
if the handle was invalid
|
int cogl_texture_get_data (CoglHandle handle,CoglPixelFormat format,unsigned int rowstride,guint8 *data);
Copies the pixel data from a cogl texture to system memory.
|
a CoglHandle for a texture. |
|
the CoglPixelFormat to store the texture as. |
|
the rowstride of data or retrieved from texture if none is
specified.
|
|
memory location to write contents of buffer, or NULL if we're
only querying the data size through the return value.
|
Returns : |
the size of the texture data in bytes, or 0 if the texture is not valid |
gboolean cogl_texture_set_region (CoglHandle handle,int src_x,int src_y,int dst_x,int dst_y,unsigned int dst_width,unsigned int dst_height,int width,int height,CoglPixelFormat format,unsigned int rowstride,const guint8 *data);
Sets the pixels in a rectangular subregion of handle from an in-memory
buffer containing pixel data.
|
a CoglHandle. |
|
upper left coordinate to use from source data. |
|
upper left coordinate to use from source data. |
|
upper left destination horizontal coordinate. |
|
upper left destination vertical coordinate. |
|
width of destination region to write. |
|
height of destination region to write. |
|
width of source data buffer. |
|
height of source data buffer. |
|
the CoglPixelFormat used in the source buffer. |
|
rowstride of source buffer (computed from width if none specified) |
|
the actual pixel data. |
Returns : |
TRUE if the subregion upload was successful, and
FALSE otherwise
|