3 * Texture images manipulation functions.
7 * Mesa 3-D graphics library
10 * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
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:
19 * The above copyright notice and this permission notice shall be included
20 * in all copies or substantial portions of the Software.
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.
39 /** Is the given value one of the 6 cube faces? */
40 static inline GLboolean
41 _mesa_is_cube_face(GLenum target
)
43 return (target
>= GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB
&&
44 target
<= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB
);
47 /** Is any of the dimensions of given texture equal to zero? */
48 static inline GLboolean
49 _mesa_is_zero_size_texture(const struct gl_texture_image
*texImage
)
51 return (texImage
->Width
== 0 ||
52 texImage
->Height
== 0 ||
53 texImage
->Depth
== 0);
56 /** \name Internal functions */
60 _mesa_base_tex_format( struct gl_context
*ctx
, GLint internalFormat
);
64 _mesa_is_proxy_texture(GLenum target
);
67 extern struct gl_texture_image
*
68 _mesa_new_texture_image( struct gl_context
*ctx
);
72 _mesa_delete_texture_image( struct gl_context
*ctx
,
73 struct gl_texture_image
*teximage
);
77 _mesa_init_teximage_fields(struct gl_context
*ctx
,
78 struct gl_texture_image
*img
,
79 GLsizei width
, GLsizei height
, GLsizei depth
,
80 GLint border
, GLenum internalFormat
,
85 _mesa_choose_texture_format(struct gl_context
*ctx
,
86 struct gl_texture_object
*texObj
,
87 GLenum target
, GLint level
,
88 GLenum internalFormat
, GLenum format
, GLenum type
);
91 _mesa_update_fbo_texture(struct gl_context
*ctx
,
92 struct gl_texture_object
*texObj
,
93 GLuint face
, GLuint level
);
96 _mesa_clear_texture_image(struct gl_context
*ctx
,
97 struct gl_texture_image
*texImage
);
100 extern struct gl_texture_object
*
101 _mesa_select_tex_object(struct gl_context
*ctx
,
102 const struct gl_texture_unit
*texUnit
,
105 extern struct gl_texture_object
*
106 _mesa_get_current_tex_object(struct gl_context
*ctx
, GLenum target
);
109 extern struct gl_texture_image
*
110 _mesa_select_tex_image(struct gl_context
*ctx
,
111 const struct gl_texture_object
*texObj
,
112 GLenum target
, GLint level
);
115 extern struct gl_texture_image
*
116 _mesa_get_tex_image(struct gl_context
*ctx
, struct gl_texture_object
*texObj
,
117 GLenum target
, GLint level
);
120 extern struct gl_texture_image
*
121 _mesa_get_proxy_tex_image(struct gl_context
*ctx
, GLenum target
, GLint level
);
125 _mesa_max_texture_levels(struct gl_context
*ctx
, GLenum target
);
129 _mesa_test_proxy_teximage(struct gl_context
*ctx
, GLenum target
, GLint level
,
130 GLint internalFormat
, GLenum format
, GLenum type
,
131 GLint width
, GLint height
, GLint depth
, GLint border
);
135 _mesa_tex_target_to_face(GLenum target
);
138 _mesa_get_texture_dimensions(GLenum target
);
141 * Lock a texture for updating. See also _mesa_lock_context_textures().
144 _mesa_lock_texture(struct gl_context
*ctx
, struct gl_texture_object
*texObj
)
146 _glthread_LOCK_MUTEX(ctx
->Shared
->TexMutex
);
147 ctx
->Shared
->TextureStateStamp
++;
152 _mesa_unlock_texture(struct gl_context
*ctx
, struct gl_texture_object
*texObj
)
155 _glthread_UNLOCK_MUTEX(ctx
->Shared
->TexMutex
);
161 /** \name API entry point functions */
164 extern void GLAPIENTRY
165 _mesa_TexImage1D( GLenum target
, GLint level
, GLint internalformat
,
166 GLsizei width
, GLint border
,
167 GLenum format
, GLenum type
, const GLvoid
*pixels
);
170 extern void GLAPIENTRY
171 _mesa_TexImage2D( GLenum target
, GLint level
, GLint internalformat
,
172 GLsizei width
, GLsizei height
, GLint border
,
173 GLenum format
, GLenum type
, const GLvoid
*pixels
);
176 extern void GLAPIENTRY
177 _mesa_TexImage3D( GLenum target
, GLint level
, GLint internalformat
,
178 GLsizei width
, GLsizei height
, GLsizei depth
, GLint border
,
179 GLenum format
, GLenum type
, const GLvoid
*pixels
);
182 extern void GLAPIENTRY
183 _mesa_TexImage3DEXT( GLenum target
, GLint level
, GLenum internalformat
,
184 GLsizei width
, GLsizei height
, GLsizei depth
,
185 GLint border
, GLenum format
, GLenum type
,
186 const GLvoid
*pixels
);
188 extern void GLAPIENTRY
189 _mesa_EGLImageTargetTexture2DOES( GLenum target
, GLeglImageOES image
);
191 extern void GLAPIENTRY
192 _mesa_TexSubImage1D( GLenum target
, GLint level
, GLint xoffset
,
194 GLenum format
, GLenum type
,
195 const GLvoid
*pixels
);
198 extern void GLAPIENTRY
199 _mesa_TexSubImage2D( GLenum target
, GLint level
,
200 GLint xoffset
, GLint yoffset
,
201 GLsizei width
, GLsizei height
,
202 GLenum format
, GLenum type
,
203 const GLvoid
*pixels
);
206 extern void GLAPIENTRY
207 _mesa_TexSubImage3D( GLenum target
, GLint level
,
208 GLint xoffset
, GLint yoffset
, GLint zoffset
,
209 GLsizei width
, GLsizei height
, GLsizei depth
,
210 GLenum format
, GLenum type
,
211 const GLvoid
*pixels
);
214 extern void GLAPIENTRY
215 _mesa_CopyTexImage1D( GLenum target
, GLint level
, GLenum internalformat
,
216 GLint x
, GLint y
, GLsizei width
, GLint border
);
219 extern void GLAPIENTRY
220 _mesa_CopyTexImage2D( GLenum target
, GLint level
,
221 GLenum internalformat
, GLint x
, GLint y
,
222 GLsizei width
, GLsizei height
, GLint border
);
225 extern void GLAPIENTRY
226 _mesa_CopyTexSubImage1D( GLenum target
, GLint level
, GLint xoffset
,
227 GLint x
, GLint y
, GLsizei width
);
230 extern void GLAPIENTRY
231 _mesa_CopyTexSubImage2D( GLenum target
, GLint level
,
232 GLint xoffset
, GLint yoffset
,
233 GLint x
, GLint y
, GLsizei width
, GLsizei height
);
236 extern void GLAPIENTRY
237 _mesa_CopyTexSubImage3D( GLenum target
, GLint level
,
238 GLint xoffset
, GLint yoffset
, GLint zoffset
,
239 GLint x
, GLint y
, GLsizei width
, GLsizei height
);
243 extern void GLAPIENTRY
244 _mesa_CompressedTexImage1DARB(GLenum target
, GLint level
,
245 GLenum internalformat
, GLsizei width
,
246 GLint border
, GLsizei imageSize
,
249 extern void GLAPIENTRY
250 _mesa_CompressedTexImage2DARB(GLenum target
, GLint level
,
251 GLenum internalformat
, GLsizei width
,
252 GLsizei height
, GLint border
, GLsizei imageSize
,
255 extern void GLAPIENTRY
256 _mesa_CompressedTexImage3DARB(GLenum target
, GLint level
,
257 GLenum internalformat
, GLsizei width
,
258 GLsizei height
, GLsizei depth
, GLint border
,
259 GLsizei imageSize
, const GLvoid
*data
);
262 #define _mesa_CompressedTexSubImage1DARB _mesa_CompressedTexSubImage1DAR
263 #define _mesa_CompressedTexSubImage2DARB _mesa_CompressedTexSubImage2DAR
264 #define _mesa_CompressedTexSubImage3DARB _mesa_CompressedTexSubImage3DAR
266 extern void GLAPIENTRY
267 _mesa_CompressedTexSubImage1DARB(GLenum target
, GLint level
, GLint xoffset
,
268 GLsizei width
, GLenum format
,
269 GLsizei imageSize
, const GLvoid
*data
);
271 extern void GLAPIENTRY
272 _mesa_CompressedTexSubImage2DARB(GLenum target
, GLint level
, GLint xoffset
,
273 GLint yoffset
, GLsizei width
, GLsizei height
,
274 GLenum format
, GLsizei imageSize
,
277 extern void GLAPIENTRY
278 _mesa_CompressedTexSubImage3DARB(GLenum target
, GLint level
, GLint xoffset
,
279 GLint yoffset
, GLint zoffset
, GLsizei width
,
280 GLsizei height
, GLsizei depth
, GLenum format
,
281 GLsizei imageSize
, const GLvoid
*data
);
284 extern void GLAPIENTRY
285 _mesa_TexBuffer(GLenum target
, GLenum internalFormat
, GLuint buffer
);