1 /**************************************************************************
3 * Copyright 2008 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 **************************************************************************/
35 #include "main/imports.h"
36 #include "main/context.h"
38 #include "pipe/p_defines.h"
40 #include "st_cb_fbo.h"
41 #include "st_cb_get.h"
46 * Examine the current color read buffer format to determine
47 * which GL pixel format/type combo is the best match.
50 get_preferred_read_format_type(GLcontext
*ctx
, GLint
*format
, GLint
*type
)
52 struct gl_framebuffer
*fb
= ctx
->ReadBuffer
;
53 struct st_renderbuffer
*strb
= st_renderbuffer(fb
->_ColorReadBuffer
);
56 *format
= ctx
->Const
.ColorReadFormat
;
57 *type
= ctx
->Const
.ColorReadType
;
60 /* XXX could add more cases here... */
61 if (strb
->format
== PIPE_FORMAT_A8R8G8B8_UNORM
) {
63 if (_mesa_little_endian())
64 *type
= GL_UNSIGNED_INT_8_8_8_8_REV
;
66 *type
= GL_UNSIGNED_INT_8_8_8_8
;
73 * We only intercept the OES preferred ReadPixels format/type.
74 * Everything else goes to the default _mesa_GetIntegerv.
77 st_GetIntegerv(GLcontext
*ctx
, GLenum pname
, GLint
*params
)
82 case GL_IMPLEMENTATION_COLOR_READ_TYPE_OES
:
83 get_preferred_read_format_type(ctx
, &dummy
, params
);
85 case GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES
:
86 get_preferred_read_format_type(ctx
, params
, &dummy
);
94 void st_init_get_functions(struct dd_function_table
*functions
)
96 functions
->GetIntegerv
= st_GetIntegerv
;