teximage.h revision 8a935d71ff4ded6f3cdd8e06dcd1a5e3de3d3cc0
1/**
2 * \file teximage.h
3 * Texture images manipulation functions.
4 */
5
6/*
7 * Mesa 3-D graphics library
8 * Version:  6.5
9 *
10 * Copyright (C) 1999-2005  Brian Paul   All Rights Reserved.
11 *
12 * Permission is hereby granted, free of charge, to any person obtaining a
13 * copy of this software and associated documentation files (the "Software"),
14 * to deal in the Software without restriction, including without limitation
15 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
16 * and/or sell copies of the Software, and to permit persons to whom the
17 * Software is furnished to do so, subject to the following conditions:
18 *
19 * The above copyright notice and this permission notice shall be included
20 * in all copies or substantial portions of the Software.
21 *
22 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
23 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
25 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
26 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
27 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 */
29
30
31#ifndef TEXIMAGE_H
32#define TEXIMAGE_H
33
34
35#include "mtypes.h"
36#include "formats.h"
37
38#ifdef __cplusplus
39extern "C" {
40#endif
41
42/** Is the given value one of the 6 cube faces? */
43static inline GLboolean
44_mesa_is_cube_face(GLenum target)
45{
46   return (target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB &&
47           target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB);
48}
49
50/** Is any of the dimensions of given texture equal to zero? */
51static inline GLboolean
52_mesa_is_zero_size_texture(const struct gl_texture_image *texImage)
53{
54   return (texImage->Width == 0 ||
55           texImage->Height == 0 ||
56           texImage->Depth == 0);
57}
58
59/** \name Internal functions */
60/*@{*/
61
62extern GLint
63_mesa_base_tex_format( struct gl_context *ctx, GLint internalFormat );
64
65
66extern GLboolean
67_mesa_is_proxy_texture(GLenum target);
68
69
70extern struct gl_texture_image *
71_mesa_new_texture_image( struct gl_context *ctx );
72
73
74extern void
75_mesa_delete_texture_image( struct gl_context *ctx,
76                            struct gl_texture_image *teximage );
77
78
79extern void
80_mesa_init_teximage_fields(struct gl_context *ctx,
81                           struct gl_texture_image *img,
82                           GLsizei width, GLsizei height, GLsizei depth,
83                           GLint border, GLenum internalFormat,
84                           gl_format format);
85
86
87extern gl_format
88_mesa_choose_texture_format(struct gl_context *ctx,
89                            struct gl_texture_object *texObj,
90                            GLenum target, GLint level,
91                            GLenum internalFormat, GLenum format, GLenum type);
92
93extern void
94_mesa_update_fbo_texture(struct gl_context *ctx,
95                         struct gl_texture_object *texObj,
96                         GLuint face, GLuint level);
97
98extern void
99_mesa_clear_texture_image(struct gl_context *ctx,
100                          struct gl_texture_image *texImage);
101
102
103extern struct gl_texture_object *
104_mesa_select_tex_object(struct gl_context *ctx,
105                        const struct gl_texture_unit *texUnit,
106                        GLenum target);
107
108extern struct gl_texture_object *
109_mesa_get_current_tex_object(struct gl_context *ctx, GLenum target);
110
111
112extern struct gl_texture_image *
113_mesa_select_tex_image(struct gl_context *ctx,
114                       const struct gl_texture_object *texObj,
115                       GLenum target, GLint level);
116
117
118extern struct gl_texture_image *
119_mesa_get_tex_image(struct gl_context *ctx, struct gl_texture_object *texObj,
120                    GLenum target, GLint level);
121
122
123extern GLint
124_mesa_max_texture_levels(struct gl_context *ctx, GLenum target);
125
126
127extern GLboolean
128_mesa_test_proxy_teximage(struct gl_context *ctx, GLenum target, GLint level,
129                         GLint internalFormat, GLenum format, GLenum type,
130                         GLint width, GLint height, GLint depth, GLint border);
131
132
133extern GLuint
134_mesa_tex_target_to_face(GLenum target);
135
136extern GLint
137_mesa_get_texture_dimensions(GLenum target);
138
139extern GLenum
140_mesa_es_error_check_format_and_type(GLenum format, GLenum type,
141                                     unsigned dimensions);
142
143/**
144 * Lock a texture for updating.  See also _mesa_lock_context_textures().
145 */
146static inline void
147_mesa_lock_texture(struct gl_context *ctx, struct gl_texture_object *texObj)
148{
149   _glthread_LOCK_MUTEX(ctx->Shared->TexMutex);
150   ctx->Shared->TextureStateStamp++;
151   (void) texObj;
152}
153
154static inline void
155_mesa_unlock_texture(struct gl_context *ctx, struct gl_texture_object *texObj)
156{
157   (void) texObj;
158   _glthread_UNLOCK_MUTEX(ctx->Shared->TexMutex);
159}
160
161/*@}*/
162
163
164/** \name API entry point functions */
165/*@{*/
166
167extern void GLAPIENTRY
168_mesa_TexImage1D( GLenum target, GLint level, GLint internalformat,
169                  GLsizei width, GLint border,
170                  GLenum format, GLenum type, const GLvoid *pixels );
171
172
173extern void GLAPIENTRY
174_mesa_TexImage2D( GLenum target, GLint level, GLint internalformat,
175                  GLsizei width, GLsizei height, GLint border,
176                  GLenum format, GLenum type, const GLvoid *pixels );
177
178
179extern void GLAPIENTRY
180_mesa_TexImage3D( GLenum target, GLint level, GLint internalformat,
181                  GLsizei width, GLsizei height, GLsizei depth, GLint border,
182                  GLenum format, GLenum type, const GLvoid *pixels );
183
184
185extern void GLAPIENTRY
186_mesa_TexImage3DEXT( GLenum target, GLint level, GLenum internalformat,
187                     GLsizei width, GLsizei height, GLsizei depth,
188                     GLint border, GLenum format, GLenum type,
189                     const GLvoid *pixels );
190
191extern void GLAPIENTRY
192_mesa_EGLImageTargetTexture2DOES( GLenum target, GLeglImageOES image );
193
194extern void GLAPIENTRY
195_mesa_TexSubImage1D( GLenum target, GLint level, GLint xoffset,
196                     GLsizei width,
197                     GLenum format, GLenum type,
198                     const GLvoid *pixels );
199
200
201extern void GLAPIENTRY
202_mesa_TexSubImage2D( GLenum target, GLint level,
203                     GLint xoffset, GLint yoffset,
204                     GLsizei width, GLsizei height,
205                     GLenum format, GLenum type,
206                     const GLvoid *pixels );
207
208
209extern void GLAPIENTRY
210_mesa_TexSubImage3D( GLenum target, GLint level,
211                     GLint xoffset, GLint yoffset, GLint zoffset,
212                     GLsizei width, GLsizei height, GLsizei depth,
213                     GLenum format, GLenum type,
214                     const GLvoid *pixels );
215
216
217extern void GLAPIENTRY
218_mesa_CopyTexImage1D( GLenum target, GLint level, GLenum internalformat,
219                      GLint x, GLint y, GLsizei width, GLint border );
220
221
222extern void GLAPIENTRY
223_mesa_CopyTexImage2D( GLenum target, GLint level,
224                      GLenum internalformat, GLint x, GLint y,
225                      GLsizei width, GLsizei height, GLint border );
226
227
228extern void GLAPIENTRY
229_mesa_CopyTexSubImage1D( GLenum target, GLint level, GLint xoffset,
230                         GLint x, GLint y, GLsizei width );
231
232
233extern void GLAPIENTRY
234_mesa_CopyTexSubImage2D( GLenum target, GLint level,
235                         GLint xoffset, GLint yoffset,
236                         GLint x, GLint y, GLsizei width, GLsizei height );
237
238
239extern void GLAPIENTRY
240_mesa_CopyTexSubImage3D( GLenum target, GLint level,
241                         GLint xoffset, GLint yoffset, GLint zoffset,
242                         GLint x, GLint y, GLsizei width, GLsizei height );
243
244
245
246extern void GLAPIENTRY
247_mesa_CompressedTexImage1DARB(GLenum target, GLint level,
248                              GLenum internalformat, GLsizei width,
249                              GLint border, GLsizei imageSize,
250                              const GLvoid *data);
251
252extern void GLAPIENTRY
253_mesa_CompressedTexImage2DARB(GLenum target, GLint level,
254                              GLenum internalformat, GLsizei width,
255                              GLsizei height, GLint border, GLsizei imageSize,
256                              const GLvoid *data);
257
258extern void GLAPIENTRY
259_mesa_CompressedTexImage3DARB(GLenum target, GLint level,
260                              GLenum internalformat, GLsizei width,
261                              GLsizei height, GLsizei depth, GLint border,
262                              GLsizei imageSize, const GLvoid *data);
263
264#ifdef VMS
265#define _mesa_CompressedTexSubImage1DARB _mesa_CompressedTexSubImage1DAR
266#define _mesa_CompressedTexSubImage2DARB _mesa_CompressedTexSubImage2DAR
267#define _mesa_CompressedTexSubImage3DARB _mesa_CompressedTexSubImage3DAR
268#endif
269extern void GLAPIENTRY
270_mesa_CompressedTexSubImage1DARB(GLenum target, GLint level, GLint xoffset,
271                                 GLsizei width, GLenum format,
272                                 GLsizei imageSize, const GLvoid *data);
273
274extern void GLAPIENTRY
275_mesa_CompressedTexSubImage2DARB(GLenum target, GLint level, GLint xoffset,
276                                 GLint yoffset, GLsizei width, GLsizei height,
277                                 GLenum format, GLsizei imageSize,
278                                 const GLvoid *data);
279
280extern void GLAPIENTRY
281_mesa_CompressedTexSubImage3DARB(GLenum target, GLint level, GLint xoffset,
282                                 GLint yoffset, GLint zoffset, GLsizei width,
283                                 GLsizei height, GLsizei depth, GLenum format,
284                                 GLsizei imageSize, const GLvoid *data);
285
286
287extern void GLAPIENTRY
288_mesa_TexBuffer(GLenum target, GLenum internalFormat, GLuint buffer);
289
290
291/*@}*/
292
293#ifdef __cplusplus
294}
295#endif
296
297#endif
298