cogl: Make CoglSubTexture only work for quad rendering
The sub texture backend doesn't work well as a completely general texture backend because for example when rendering with cogl_polygon it needs to be able to tranform arbitrary texture coordinates without reference to the other coordintes. This can't be done when the texture coordinates are a multiple of one because sometimes the coordinate should represent the left or top edge and sometimes it should represent the bottom or top edge. For example if the s coordinates are 0 and 1 then 1 represents the right edge but if they are 1 and 2 then 1 represents the left edge. Instead the sub-textures are now documented not to support coordinates outside the range [0,1]. The coordinates for the sub-region are now represented as integers as this helps avoid rounding issues. The region can no longer be a super-region of the texture as this simplifies the code quite a lot. There are two new texture virtual functions: transform_quad_coords_to_gl - This transforms two pairs of coordinates representing a quad. It will return FALSE if the coordinates can not be transformed. The sub texture backend uses this to detect coordinates that require repeating which causes cogl-primitives to use manual repeating. ensure_non_quad_rendering - This is used in cogl_polygon and cogl_vertex_buffer to inform the texture backend that transform_quad_to_gl is going to be used. The atlas backend migrates the texture out of the atlas when it hits this.
This commit is contained in:
@ -320,18 +320,18 @@ gboolean cogl_texture_set_region (CoglHandle handle,
|
||||
/**
|
||||
* cogl_texture_new_from_sub_texture:
|
||||
* @full_texture: a #CoglHandle to an existing texture
|
||||
* @tx1: X coordinate of the top-left of the subregion
|
||||
* @ty1: Y coordinate of the top-left of the subregion
|
||||
* @tx2: X coordinate of the bottom-right of the subregion
|
||||
* @ty2: Y coordinate of the bottom-right of the subregion
|
||||
* @sub_x: X coordinate of the top-left of the subregion
|
||||
* @sub_y: Y coordinate of the top-left of the subregion
|
||||
* @sub_width: Width in pixels of the subregion
|
||||
* @sub_height: Height in pixels of the subregion
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* You can also specify texture coordinates outside the range of [0,1]
|
||||
* to make a texture that represents a repeated version of another
|
||||
* texture.
|
||||
* Sub textures have undefined behaviour texture coordinates outside
|
||||
* of the range [0,1] are used. They also do not work with
|
||||
* CoglVertexBuffers.
|
||||
*
|
||||
* Return value: a #CoglHandle to the new texture.
|
||||
*
|
||||
@ -339,10 +339,10 @@ gboolean cogl_texture_set_region (CoglHandle handle,
|
||||
*/
|
||||
CoglHandle cogl_texture_new_from_sub_texture
|
||||
(CoglHandle full_texture,
|
||||
gfloat tx1,
|
||||
gfloat ty1,
|
||||
gfloat tx2,
|
||||
gfloat ty2);
|
||||
gint sub_x,
|
||||
gint sub_y,
|
||||
gint sub_width,
|
||||
gint sub_height);
|
||||
|
||||
#ifndef COGL_DISABLE_DEPRECATED
|
||||
|
||||
|
Reference in New Issue
Block a user