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 #ifndef __COGL_TEXURE_RECTANGLE_H
28 #define __COGL_TEXURE_RECTANGLE_H
30 #include "cogl-context.h"
35 * SECTION:cogl-texture-rectangle
36 * @short_description: Functions for creating and manipulating rectangle
37 * textures for use with non-normalized coordinates.
39 * These functions allow low-level "rectangle" textures to be allocated.
40 * These textures are never constrained to power-of-two sizes but they
41 * also don't support having a mipmap and can only be wrapped with
42 * %COGL_PIPELINE_WRAP_MODE_CLAMP_TO_EDGE.
44 * The most notable difference between rectangle textures and 2D
45 * textures is that rectangle textures are sampled using un-normalized
46 * texture coordinates, so instead of using coordinates (0,0) and
47 * (1,1) to map to the top-left and bottom right corners of the
48 * texture you would instead use (0,0) and (width,height).
50 * The use of non-normalized coordinates can be particularly
51 * convenient when writing glsl shaders that use a texture as a lookup
52 * table since you don't need to upload separate uniforms to map
53 * normalized coordinates to texels.
55 * If you want to sample from a rectangle texture from GLSL you should
56 * use the sampler2DRect sampler type.
58 * Applications wanting to use #CoglTextureRectangle should first check
59 * for the %COGL_FEATURE_ID_TEXTURE_RECTANGLE feature using
63 typedef struct _CoglTextureRectangle CoglTextureRectangle;
64 #define COGL_TEXTURE_RECTANGLE(X) ((CoglTextureRectangle *)X)
66 #define cogl_is_texture_rectangle cogl_is_texture_rectangle_EXP
68 * cogl_is_texture_rectangle:
69 * @object: A #CoglObject
71 * Gets whether the given object references an existing
72 * #CoglTextureRectangle object.
74 * Return value: %TRUE if the object references a
75 * #CoglTextureRectangle, %FALSE otherwise.
78 cogl_is_texture_rectangle (void *object);
80 #define cogl_texture_rectangle_new_with_size \
81 cogl_texture_rectangle_new_with_size_EXP
83 * cogl_texture_rectangle_new_with_size:
84 * @context: A #CoglContext pointer
85 * @width: The texture width to allocate
86 * @height: The texture height to allocate
87 * @internal_format: The desired internal texture format
88 * @error: An optional GError pointer for reporting exceptions
90 * Allocates a new #CoglRectangle texture with a given @width, @height
91 * and @internal_format. This texture is a low-level texture that
92 * the GPU can sample from directly unlike high-level textures such
93 * as #CoglTexture2DSliced and #CoglAtlasTexture.
95 * <note>If you want to sample from a rectangle texture from GLSL you
96 * should use the sampler2DRect sampler type.</note>
98 * <note>Applications wanting to use #CoglTextureRectangle should
99 * first check for the %COGL_FEATURE_ID_TEXTURE_RECTANGLE feature
100 * using cogl_has_feature().</note>
102 * Returns: A pointer to a newly allocated #CoglRectangle texture
103 * or if the size was too large or there wasn't enough memory
104 * %NULL is returned and @error set.
107 * Stability: unstable
109 CoglTextureRectangle *
110 cogl_texture_rectangle_new_with_size (CoglContext *ctx,
113 CoglPixelFormat internal_format,
118 #endif /* __COGL_TEXURE_RECTANGLE_H */