2 Copyright (c) 2012, Broadcom Europe Ltd
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions are met:
7 * Redistributions of source code must retain the above copyright
8 notice, this list of conditions and the following disclaimer.
9 * Redistributions in binary form must reproduce the above copyright
10 notice, this list of conditions and the following disclaimer in the
11 documentation and/or other materials provided with the distribution.
12 * Neither the name of the copyright holder nor the
13 names of its contributors may be used to endorse or promote products
14 derived from this software without specific prior written permission.
16 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
20 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 #define GL_GLEXT_PROTOTYPES /* we want the prototypes so the compiler will check that the signatures match */
30 #include "interface/khronos/common/khrn_int_common.h"
32 #include "interface/khronos/glxx/glxx_client.h"
33 #include "interface/khronos/common/khrn_client_rpc.h"
35 #include "interface/khronos/glxx/gl11_int_config.h"
37 #include "interface/khronos/include/GLES/glext.h"
40 #include "interface/khronos/glxx/gl11_int_impl.h"
43 #if GL_OES_matrix_palette
45 static void set_error(GLXX_CLIENT_STATE_T *state, GLenum e) {
46 if (state->error == GL_NO_ERROR) state->error = e;
49 static void set_client_state_error(GLenum e) {
50 CLIENT_THREAD_STATE_T *thread = CLIENT_GET_THREAD_STATE();
51 GLXX_CLIENT_STATE_T *state = GLXX_GET_CLIENT_STATE(thread);
55 GL_API void GL_APIENTRY glCurrentPaletteMatrixOES(GLuint index) {
56 CLIENT_THREAD_STATE_T *thread = CLIENT_GET_THREAD_STATE();
57 if (IS_OPENGLES_11(thread)) {
58 if (index > GL11_CONFIG_MAX_PALETTE_MATRICES_OES - 1) set_client_state_error(GL_INVALID_VALUE);
60 RPC_CALL1(glCurrentPaletteMatrixOES_impl,
62 GLCURRENTPALETTEMATRIXOES_ID_11,
68 GL_API void GL_APIENTRY glLoadPaletteFromModelViewMatrixOES() {
69 CLIENT_THREAD_STATE_T *thread = CLIENT_GET_THREAD_STATE();
70 if (IS_OPENGLES_11(thread)) {
71 RPC_CALL0(glLoadPaletteFromModelViewMatrixOES_impl,
73 GLLOADPALETTEFROMMODELVIEWMATRIXOES_ID_11);
77 static GLboolean is_matrix_index_type(GLenum type) {
78 return (type == GL_UNSIGNED_BYTE);
81 static GLboolean is_matrix_palette_size(GLint size) {
82 /* TODO: Should size 0 be allowed or not? */
83 return size > 0 && size <= GL11_CONFIG_MAX_VERTEX_UNITS_OES;
86 /* TODO: This is copied from glxx_client.c. Find a better method */
87 static GLboolean is_aligned( GLenum type, size_t value)
91 case GL_UNSIGNED_BYTE:
94 case GL_UNSIGNED_SHORT:
95 return (value & 1) == 0;
98 return (value & 3) == 0;
105 GL_API void GL_APIENTRY glMatrixIndexPointerOES(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer)
107 if (is_matrix_index_type(type)) {
108 if (is_matrix_palette_size(size) && is_aligned(type, (size_t)pointer) && is_aligned(type, (size_t)stride) && stride >= 0) {
109 glintAttribPointer(GLXX_API_11, GL11_IX_MATRIX_INDEX, size, type, GL_FALSE, stride, pointer);
111 glxx_set_error_api(GLXX_API_11, GL_INVALID_VALUE);
113 glxx_set_error_api(GLXX_API_11, GL_INVALID_ENUM);
116 static GLboolean is_matrix_weight_type(GLenum type) {
117 return type == GL_FIXED ||
121 GL_API void GL_APIENTRY glWeightPointerOES(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer)
123 if (is_matrix_weight_type(type)) {
124 if (is_matrix_palette_size(size) && is_aligned(type, (size_t)pointer) && is_aligned(type, (size_t)stride) && stride >= 0) {
125 glintAttribPointer(GLXX_API_11, GL11_IX_MATRIX_WEIGHT, size, type, GL_FALSE, stride, pointer);
127 glxx_set_error_api(GLXX_API_11, GL_INVALID_VALUE);
129 glxx_set_error_api(GLXX_API_11, GL_INVALID_ENUM);
132 #endif /* GL_OES_matrix_palette */