Contents |
CoglTexture is an abstract base class for all texture types
cogl_texture_get_format (tex); cogl_texture_get_width (tex); cogl_texture_get_height (tex); cogl_texture_get_region (); cogl_texture_set_region (); cogl_texture_generate_mipmaps (); cogl_texture_is_sliced (); cogl_texture_can_hardware_repeat(); cogl_texture_foreach_subtexture_in_region ();
CoglTextures can have a parent child ancestry such that some CoglTexture subclasses may be implemented in terms of other lower level subclasses. For example sliced textures, which handle textures larger than the hardware limits or non power of two textures may internally be represented by multiple child textures. This ancestry mechanism can also be used to apply transformations when mapping texture coordinates onto low level textures, so a high level subclass can describe a texture that maps to a subregion of another texture. This can be used to implement texture atlases.
There are a core set of low level subclasses: CoglTexture1D, CoglTexture2D, CoglTexture3D and CoglTextureRectangle which are actually the only types that can be directly drawn with.
The cogl_texture_foreach_subtexture_in_region API allows code that needs to draw primitives with arbitrary CoglTextures iterate all the lowlevel subtextures. So for example in implementing cogl_rectangle with a material referencing sliced or atlas textures the foreach mechanism is used to query what lowlevel textures (possibly more than one) map to the virtual texture coordinates of the sliced/atlas texture and for each lowlevel slice found it may generate new texture coordinates. It is then the responsibility of the code implementing primitives (such as cogl_rectangle or cogl_polygon) to derive new materials that don't contain sliced textures before drawing.
cogl_texture_is_sliced() returns TRUE if cogl_texture_foreach_subtexture_in_region must be used otherwise it can be assumed that the texture is a low level texture with a 1:1 texture coordinate mapping.
void cogl_texture_foreach_subtexture_in_region (CoglHandle texture, unsigned long flags, float *virtual_coords, CoglTextureRepeatMode repeat_s, CoglTextureRepeatMode repeat_t, CoglTextureForeachCallback callback, void *data); typedef void (*CoglTextureForeachCallback) (CoglHandle low_level_texture, const float *virtual_coords, const float *subtexture_coords, void *user_data);
A lowlevel 2D texture.
cogl_texture_2d_new_with_size (); cogl_texture_2d_new_from_data (); cogl_texture_2d_new_from_file (); cogl_texture_2d_set_region (); cogl_texture_2d_get_format (); cogl_texture_2d_get_rowstride (); cogl_texture_2d_get_data ();
CoglTexturePixmapX11 will expose the GLX texture from pixmap extension.
tex = cogl_texture_pixmap_x11_new (guint32 pixmap_xid); cogl_texture_pixmap_x11_set_automatic_update (tex, FALSE); ??? cogl_texture_pixmap_x11_damage_regions (tex, x_regions); ??? cogl_texture_pixmap_x11_update (tex); pixmap = cogl_texture_pixmap_x11_get_pixmap (tex);
CoglTexturePixmap can be implemented as a container texture like sliced and atlas textures, where there is one child that may be a CoglTexture2D or CoglTextureRectangle depending on driver constraints. cogl_texture_foreach_child can be used to determine this and a transform function may be passed to the users foreach callback.
Note that "glx" isn't mentioned anywhere in the API; i.e. it should be considered an implementation detail that we are implementing it using the GLX tfp extension.