1 /**************************************************************************
3 * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 **************************************************************************/
34 #include "texformat.h"
36 #include "st_context.h"
37 #include "st_texobj.h"
38 #include "pipe/p_defines.h"
42 * Create a pipe_texture_object from a Mesa texture object.
43 * Eventually, gl_texture_object may be derived from this...
45 struct pipe_texture_object
*
46 create_texture_object(struct gl_texture_object
*texObj
)
48 struct pipe_texture_object
*pto
;
49 const struct gl_texture_image
*texImage
;
51 pto
= calloc(1, sizeof(*pto
));
55 /* XXX: Member not defined. Comment-out to get it compile. */
56 /*assert(texObj->Complete);*/
58 switch (texObj
->Target
) {
60 pto
->type
= PIPE_TEXTURE_1D
;
63 pto
->type
= PIPE_TEXTURE_2D
;
66 pto
->type
= PIPE_TEXTURE_3D
;
68 case GL_TEXTURE_CUBE_MAP
:
69 pto
->type
= PIPE_TEXTURE_CUBE
;
76 texImage
= texObj
->Image
[0][texObj
->BaseLevel
];
79 switch (texImage
->TexFormat
->MesaFormat
) {
80 case MESA_FORMAT_RGBA8888
:
81 pto
->format
= PIPE_FORMAT_U_R8_G8_B8_A8
;
83 case MESA_FORMAT_RGB565
:
84 pto
->format
= PIPE_FORMAT_U_R5_G6_B5
;
87 /* XXX fill in more formats */
94 pto
->width
= texImage
->Width
;
95 pto
->height
= texImage
->Height
;
96 pto
->depth
= texImage
->Depth
;
99 pto
->mipmapped
= texObj
->Image
[0][texObj
->BaseLevel
+ 1] != NULL
;