2 * Copyright (C) 2011 The Android Open Source Project
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 #ifndef __GL_UTILS_H__
17 #define __GL_UTILS_H__
41 #include <GLES/glext.h>
42 #include <GLES2/gl2.h>
43 #include <GLES2/gl2ext.h>
49 size_t glSizeof(GLenum type);
50 size_t glUtilsParamSize(GLenum param);
51 void glUtilsPackPointerData(unsigned char *dst, unsigned char *str,
52 int size, GLenum type, unsigned int stride,
53 unsigned int datalen);
54 void glUtilsWritePackPointerData(void* stream, unsigned char *src,
55 int size, GLenum type, unsigned int stride,
56 unsigned int datalen);
57 int glUtilsPixelBitSize(GLenum format, GLenum type);
58 void glUtilsPackStrings(char *ptr, char **strings, GLint *length, GLsizei count);
59 int glUtilsCalcShaderSourceLen(char **strings, GLint *length, GLsizei count);
66 template <class T> void minmax(T *indices, int count, int *min, int *max) {
70 for (int i = 0; i < count; i++) {
71 if (*min == -1 || *ptr < *min) *min = *ptr;
72 if (*max == -1 || *ptr > *max) *max = *ptr;
77 template <class T> void shiftIndices(T *indices, int count, int offset) {
79 for (int i = 0; i < count; i++) {
86 template <class T> void shiftIndices(T *src, T *dst, int count, int offset)
88 for (int i = 0; i < count; i++) {
94 }; // namespace GLUtils