4 * An object oriented GL/GLES Abstraction/Utility Layer
6 * Copyright (C) 2011 Intel Corporation.
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.
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.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library. If not, see
20 * <http://www.gnu.org/licenses/>.
24 * Robert Bragg <robert@linux.intel.com>
27 #if !defined(__COGL_H_INSIDE__) && !defined(CLUTTER_COMPILATION)
28 #error "Only <cogl/cogl.h> can be included directly."
31 #ifndef __COGL_TEXURE_2D_H
32 #define __COGL_TEXURE_2D_H
34 #include "cogl-context.h"
41 * SECTION:cogl-texture-2d
42 * @short_description: Functions for creating and manipulating 2D textures
44 * These functions allow low-level 2D textures to be allocated. These
45 * differ from sliced textures for example which may internally be
46 * made up of multiple 2D textures, or atlas textures where Cogl must
47 * internally modify user texture coordinates before they can be used
50 * You should be aware that many GPUs only support power of two sizes
51 * for #CoglTexture2D textures. You can check support for non power of
52 * two textures by checking for the %COGL_FEATURE_ID_TEXTURE_NPOT feature
53 * via cogl_has_feature().
56 typedef struct _CoglTexture2D CoglTexture2D;
57 #define COGL_TEXTURE_2D(X) ((CoglTexture2D *)X)
59 #define cogl_is_texture_2d cogl_is_texture_2d_EXP
62 * @object: A #CoglObject
64 * Gets whether the given object references an existing #CoglTexture2D
67 * Return value: %TRUE if the object references a #CoglTexture2D,
71 cogl_is_texture_2d (void *object);
73 #define cogl_texture_2d_new_with_size cogl_texture_2d_new_with_size_EXP
75 * cogl_texture_2d_new_with_size:
76 * @ctx: A #CoglContext
77 * @width: Width of the texture to allocate
78 * @height: Height of the texture to allocate
79 * @internal_format: The format of the texture
80 * @error: A #GError for exceptions
82 * Allocates a low-level #CoglTexture2D texture that your GPU can
83 * texture from directly. This is unlike sliced textures for example
84 * which may be comprised of multiple internal textures, or atlas
85 * textures where Cogl has to modify texture coordinates before they
86 * may be used by the GPU.
88 * <note>Many GPUs only support power of two sizes for #CoglTexture2D
89 * textures. You can check support for non power of two textures by
90 * checking for the %COGL_FEATURE_ID_TEXTURE_NPOT feature via
91 * cogl_has_feature().</note>
93 * Returns: A newly allocated #CoglTexture2D, or if the size is not
94 * supported (because it is too large or a non-power-of-two
95 * size that the hardware doesn't support) it will return
96 * %NULL and set @error.
101 cogl_texture_2d_new_with_size (CoglContext *ctx,
104 CoglPixelFormat internal_format,
107 #define cogl_texture_2d_new_from_data cogl_texture_2d_new_from_data_EXP
109 * cogl_texture_2d_new_from_data:
110 * @ctx: A #CoglContext
111 * @width: width of texture in pixels
112 * @height: height of texture in pixels
113 * @format: the #CoglPixelFormat the buffer is stored in in RAM
114 * @internal_format: the #CoglPixelFormat that will be used for storing
115 * the buffer on the GPU. If COGL_PIXEL_FORMAT_ANY is given then a
116 * premultiplied format similar to the format of the source data will
117 * be used. The default blending equations of Cogl expect premultiplied
118 * color data; the main use of passing a non-premultiplied format here
119 * is if you have non-premultiplied source data and are going to adjust
120 * the blend mode (see cogl_material_set_blend()) or use the data for
121 * something other than straight blending.
122 * @rowstride: the memory offset in bytes between the starts of
123 * scanlines in @data. A value of 0 will make Cogl automatically
124 * calculate @rowstride from @width and @format.
125 * @data: pointer the memory region where the source buffer resides
126 * @error: A #GError for exceptions
128 * Creates a new #CoglTexture2D texture based on data residing in memory.
129 * These are unlike sliced textures for example which may be comprised
130 * of multiple internal textures, or atlas textures where Cogl has to
131 * modify texture coordinates before they may be used by the GPU.
133 * <note>Many GPUs only support power of two sizes for #CoglTexture2D
134 * textures. You can check support for non power of two textures by
135 * checking for the %COGL_FEATURE_ID_TEXTURE_NPOT feature via
136 * cogl_has_feature().</note>
138 * Returns: A newly allocated #CoglTexture2D, or if the size is not
139 * supported (because it is too large or a non-power-of-two
140 * size that the hardware doesn't support) it will return
141 * %NULL and set @error.
146 cogl_texture_2d_new_from_data (CoglContext *ctx,
149 CoglPixelFormat format,
150 CoglPixelFormat internal_format,
155 #define cogl_texture_2d_new_from_foreign cogl_texture_2d_new_from_foreign_EXP
157 * cogl_texture_2d_new_from_foreign:
158 * @ctx: A #CoglContext
159 * @gl_handle: A GL handle for a GL_TEXTURE_2D texture object
160 * @width: Width of the foreign GL texture
161 * @height: Height of the foreign GL texture
162 * @internal_format: The format of the texture
163 * @error: A #GError for exceptions
165 * Wraps an existing GL_TEXTURE_2D texture object as a #CoglTexture2D.
166 * This can be used for integrating Cogl with software using OpenGL
169 * <note>The results are undefined for passing an invalid @gl_handle
170 * or if @width or @height don't have the correct texture
173 * Returns: A newly allocated #CoglTexture2D, or if Cogl could not
174 * validate the @gl_handle in some way (perhaps because of
175 * an unsupported format) it will return %NULL and set
181 cogl_texture_2d_new_from_foreign (CoglContext *ctx,
182 unsigned int gl_handle,
185 CoglPixelFormat format,
190 #endif /* __COGL_TEXURE_2D_H */