"Initial commit to Gerrit"
[profile/ivi/cogl.git] / cogl / cogl-sub-texture.h
1 /*
2  * Cogl
3  *
4  * An object oriented GL/GLES Abstraction/Utility Layer
5  *
6  * Copyright (C) 2010 Intel Corporation.
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the
20  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21  * Boston, MA 02111-1307, USA.
22  *
23  * Authors:
24  *   Neil Roberts <neil@linux.intel.com>
25  */
26
27 #if !defined(__COGL_H_INSIDE__) && !defined(CLUTTER_COMPILATION)
28 #error "Only <cogl/cogl.h> can be included directly."
29 #endif
30
31 #ifndef __COGL_SUB_TEXTURE_H
32 #define __COGL_SUB_TEXTURE_H
33
34 #include <glib.h>
35
36 G_BEGIN_DECLS
37
38 /**
39  * SECTION:cogl-sub-texture
40  * @short_description: Functions for creating and manipulating
41  *                     sub-textures.
42  *
43  * These functions allow high-level textures to be created that
44  * represent a sub-region of another texture. For example these
45  * can be used to implement custom texture atlasing schemes.
46  */
47
48
49 #define COGL_SUB_TEXTURE(tex) ((CoglSubTexture *) tex)
50 typedef struct _CoglSubTexture CoglSubTexture;
51
52 #define cogl_sub_texture_new cogl_sub_texture_new_EXP
53 /**
54  * cogl_sub_texture_new:
55  * @context: A #CoglContext pointer
56  * @parent_texture: The full texture containing a sub-region you want
57  *                  to make a #CoglSubTexture from.
58  * @sub_x: The top-left x coordinate of the parent region to make
59  *         a texture from.
60  * @sub_y: The top-left y coordinate of the parent region to make
61  *         a texture from.
62  * @sub_width: The width of the parent region to make a texture from.
63  * @sub_height: The height of the parent region to make a texture
64  *              from.
65  *
66  * Creates a high-level #CoglSubTexture representing a sub-region of
67  * any other #CoglTexture. The sub-region must strictly lye within the
68  * bounds of the @parent_texture. The returned texture implements the
69  * #CoglMetaTexture interface because it's not a low level texture
70  * that hardware can understand natively.
71  *
72  * <note>Remember: Unless you are using high level drawing APIs such
73  * as cogl_rectangle() or other APIs documented to understand the
74  * #CoglMetaTexture interface then you need to use the
75  * #CoglMetaTexture interface to resolve a #CoglSubTexture into a
76  * low-level texture before drawing.</note>
77  *
78  * Returns: A newly allocated #CoglSubTexture representing a
79  *          sub-region of @parent_texture.
80  *
81  * Since: 1.10
82  * Stability: unstable
83  */
84 CoglSubTexture *
85 cogl_sub_texture_new (CoglContext *ctx,
86                       CoglTexture *parent_texture,
87                       int sub_x,
88                       int sub_y,
89                       int sub_width,
90                       int sub_height);
91
92 /**
93  * cogl_sub_texture_get_parent:
94  * @sub_texture: A pointer to a #CoglSubTexture
95  *
96  * Retrieves the parent texture that @sub_texture derives its content
97  * from.  This is the texture that was passed to
98  * cogl_sub_texture_new() as the parent_texture argument.
99  *
100  * Return value: (transfer none): The parent texture that @sub_texture
101  *               derives its content from.
102  * Since: 1.10
103  * Stability: unstable
104  */
105 CoglTexture *
106 cogl_sub_texture_get_parent (CoglSubTexture *sub_texture);
107
108 #define cogl_is_sub_texture cogl_is_sub_texture_EXP
109 /**
110  * cogl_is_sub_texture:
111  * @object: a #CoglObject
112  *
113  * Checks whether @object is a #CoglSubTexture.
114  *
115  * Return value: %TRUE if the passed @object represents a
116  *               #CoglSubTexture and %FALSE otherwise.
117  *
118  * Since: 1.10
119  * Stability: unstable
120  */
121 gboolean
122 cogl_is_sub_texture (void *object);
123
124 G_END_DECLS
125
126 #endif /* __COGL_SUB_TEXTURE_H */