4
* A Low Level GPU Graphics and Utilities API
6
* Copyright (C) 2013 Intel Corporation.
8
* Permission is hereby granted, free of charge, to any person
9
* obtaining a copy of this software and associated documentation
10
* files (the "Software"), to deal in the Software without
11
* restriction, including without limitation the rights to use, copy,
12
* modify, merge, publish, distribute, sublicense, and/or sell copies
13
* of the Software, and to permit persons to whom the Software is
14
* furnished to do so, subject to the following conditions:
16
* The above copyright notice and this permission notice shall be
17
* included in all copies or substantial portions of the Software.
19
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
23
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
24
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
25
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31
#if !defined(__COGL_H_INSIDE__) && !defined(COGL_COMPILATION)
32
#error "Only <cogl/cogl.h> can be included directly."
35
#ifndef _COGL_ATLAS_TEXTURE_H_
36
#define _COGL_ATLAS_TEXTURE_H_
38
#include <cogl/cogl-context.h>
40
#ifdef COGL_HAS_GTYPE_SUPPORT
41
#include <glib-object.h>
47
* SECTION:cogl-atlas-texture
48
* @short_description: Functions for managing textures in Cogl's global
49
* set of texture atlases
51
* A texture atlas is a texture that contains many smaller images that
52
* an application is interested in. These are packed together as a way
53
* of optimizing drawing with those images by avoiding the costs of
54
* repeatedly telling the hardware to change what texture it should
55
* sample from. This can enable more geometry to be batched together
56
* into few draw calls.
58
* Each #CoglContext has an shared, pool of texture atlases that are
59
* are managed by Cogl.
61
* This api lets applications upload texture data into one of Cogl's
62
* shared texture atlases using a high-level #CoglAtlasTexture which
63
* represents a sub-region of one of these atlases.
65
* <note>A #CoglAtlasTexture is a high-level meta texture which has
66
* some limitations to be aware of. Please see the documentation for
67
* #CoglMetaTexture for more details.</note>
71
typedef struct _CoglAtlasTexture CoglAtlasTexture;
72
#define COGL_ATLAS_TEXTURE(tex) ((CoglAtlasTexture *) tex)
74
#ifdef COGL_HAS_GTYPE_SUPPORT
76
* cogl_atlas_texture_get_gtype:
78
* Returns: a #GType that can be used with the GLib type system.
80
GType cogl_atlas_texture_get_gtype (void);
84
* cogl_atlas_texture_new_with_size:
85
* @ctx: A #CoglContext
86
* @width: The width of your atlased texture.
87
* @height: The height of your atlased texture.
89
* Creates a #CoglAtlasTexture with a given @width and @height. A
90
* #CoglAtlasTexture represents a sub-region within one of Cogl's
91
* shared texture atlases.
93
* The storage for the texture is not allocated before this function
94
* returns. You can call cogl_texture_allocate() to explicitly
95
* allocate the underlying storage or let Cogl automatically allocate
98
* The texture is still configurable until it has been allocated so
99
* for example you can influence the internal format of the texture
100
* using cogl_texture_set_components() and
101
* cogl_texture_set_premultiplied().
103
* <note>Allocate call can fail if Cogl considers the internal
104
* format to be incompatible with the format of its internal
107
* <note>The returned #CoglAtlasTexture is a high-level meta-texture
108
* with some limitations. See the documentation for #CoglMetaTexture
109
* for more details.</note>
111
* Returns: (transfer full): A new #CoglAtlasTexture object.
113
* Stability: unstable
116
cogl_atlas_texture_new_with_size (CoglContext *ctx,
121
* cogl_atlas_texture_new_from_file:
122
* @ctx: A #CoglContext
123
* @filename: the file to load
124
* @error: A #CoglError to catch exceptional errors or %NULL
126
* Creates a #CoglAtlasTexture from an image file. A #CoglAtlasTexture
127
* represents a sub-region within one of Cogl's shared texture
130
* The storage for the texture is not allocated before this function
131
* returns. You can call cogl_texture_allocate() to explicitly
132
* allocate the underlying storage or let Cogl automatically allocate
135
* The texture is still configurable until it has been allocated so
136
* for example you can influence the internal format of the texture
137
* using cogl_texture_set_components() and
138
* cogl_texture_set_premultiplied().
140
* <note>Allocate call can fail if Cogl considers the internal
141
* format to be incompatible with the format of its internal
144
* <note>The returned #CoglAtlasTexture is a high-level meta-texture
145
* with some limitations. See the documentation for #CoglMetaTexture
146
* for more details.</note>
148
* Return value: (transfer full): A new #CoglAtlasTexture object or
149
* %NULL on failure and @error will be updated.
151
* Stability: unstable
154
cogl_atlas_texture_new_from_file (CoglContext *ctx,
155
const char *filename,
159
* cogl_atlas_texture_new_from_data:
160
* @ctx: A #CoglContext
161
* @width: width of texture in pixels
162
* @height: height of texture in pixels
163
* @format: the #CoglPixelFormat the buffer is stored in in RAM
164
* @rowstride: the memory offset in bytes between the start of each
165
* row in @data. A value of 0 will make Cogl automatically
166
* calculate @rowstride from @width and @format.
167
* @data: pointer to the memory region where the source buffer resides
168
* @error: A #CoglError to catch exceptional errors or %NULL
170
* Creates a new #CoglAtlasTexture texture based on data residing in
171
* memory. A #CoglAtlasTexture represents a sub-region within one of
172
* Cogl's shared texture atlases.
174
* <note>This api will always immediately allocate GPU memory for the
175
* texture and upload the given data so that the @data pointer does
176
* not need to remain valid once this function returns. This means it
177
* is not possible to configure the texture before it is allocated. If
178
* you do need to configure the texture before allocation (to specify
179
* constraints on the internal format for example) then you can
180
* instead create a #CoglBitmap for your data and use
181
* cogl_atlas_texture_new_from_bitmap() or use
182
* cogl_atlas_texture_new_with_size() and then upload data using
183
* cogl_texture_set_data()</note>
185
* <note>Allocate call can fail if Cogl considers the internal
186
* format to be incompatible with the format of its internal
189
* <note>The returned #CoglAtlasTexture is a high-level
190
* meta-texture with some limitations. See the documentation for
191
* #CoglMetaTexture for more details.</note>
193
* Return value: (transfer full): A new #CoglAtlasTexture object or
194
* %NULL on failure and @error will be updated.
196
* Stability: unstable
199
cogl_atlas_texture_new_from_data (CoglContext *ctx,
202
CoglPixelFormat format,
208
* cogl_atlas_texture_new_from_bitmap:
209
* @bitmap: A #CoglBitmap
211
* Creates a new #CoglAtlasTexture texture based on data residing in a
212
* @bitmap. A #CoglAtlasTexture represents a sub-region within one of
213
* Cogl's shared texture atlases.
215
* The storage for the texture is not allocated before this function
216
* returns. You can call cogl_texture_allocate() to explicitly
217
* allocate the underlying storage or preferably let Cogl
218
* automatically allocate storage lazily when it may know more about
219
* how the texture is being used and can optimize how it is allocated.
221
* The texture is still configurable until it has been allocated so
222
* for example you can influence the internal format of the texture
223
* using cogl_texture_set_components() and
224
* cogl_texture_set_premultiplied().
226
* <note>Allocate call can fail if Cogl considers the internal
227
* format to be incompatible with the format of its internal
230
* <note>The returned #CoglAtlasTexture is a high-level meta-texture
231
* with some limitations. See the documentation for #CoglMetaTexture
232
* for more details.</note>
234
* Returns: (transfer full): A new #CoglAtlasTexture object.
236
* Stability: unstable
239
cogl_atlas_texture_new_from_bitmap (CoglBitmap *bmp);
242
* cogl_is_atlas_texture:
243
* @object: a #CoglObject
245
* Checks whether the given object references a #CoglAtlasTexture
247
* Return value: %TRUE if the passed object represents an atlas
248
* texture and %FALSE otherwise
251
* Stability: Unstable
254
cogl_is_atlas_texture (void *object);
258
#endif /* _COGL_ATLAS_TEXTURE_H_ */