1848b8605Smrg/* 2848b8605Smrg * Mesa 3-D graphics library 3848b8605Smrg * 4848b8605Smrg * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. 5848b8605Smrg * 6848b8605Smrg * Permission is hereby granted, free of charge, to any person obtaining a 7848b8605Smrg * copy of this software and associated documentation files (the "Software"), 8848b8605Smrg * to deal in the Software without restriction, including without limitation 9848b8605Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense, 10848b8605Smrg * and/or sell copies of the Software, and to permit persons to whom the 11848b8605Smrg * Software is furnished to do so, subject to the following conditions: 12848b8605Smrg * 13848b8605Smrg * The above copyright notice and this permission notice shall be included 14848b8605Smrg * in all copies or substantial portions of the Software. 15848b8605Smrg * 16848b8605Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 17848b8605Smrg * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18848b8605Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19848b8605Smrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20848b8605Smrg * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21848b8605Smrg * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22848b8605Smrg * OTHER DEALINGS IN THE SOFTWARE. 23848b8605Smrg */ 24848b8605Smrg 25848b8605Smrg 26848b8605Smrg#ifndef _M_TRANSLATE_H_ 27848b8605Smrg#define _M_TRANSLATE_H_ 28848b8605Smrg 29848b8605Smrg#include "main/glheader.h" 30848b8605Smrg 31848b8605Smrg/** 32848b8605Smrg * Array translation. 33848b8605Smrg * For example, convert array of GLushort[3] to GLfloat[4]. 34848b8605Smrg * The function name specifies the destination format/size. 35848b8605Smrg * \param to the destination address 36848b8605Smrg * \param ptr the source address 37848b8605Smrg * \param stride the source stride (in bytes) between elements 38848b8605Smrg * \param type the source datatype (GL_SHORT, GL_UNSIGNED_INT, etc) 39848b8605Smrg * \param size number of values per element in source array (1,2,3 or 4) 40848b8605Smrg * \param start first element in source array to convert 41848b8605Smrg * \param n number of elements to convert 42848b8605Smrg * 43848b8605Smrg * Note: "element" means a tuple like GLfloat[3] or GLubyte[4]. 44848b8605Smrg */ 45848b8605Smrg 46848b8605Smrg 47848b8605Smrgextern void _math_trans_1f(GLfloat *to, 48848b8605Smrg const void *ptr, 49848b8605Smrg GLuint stride, 50848b8605Smrg GLenum type, 51848b8605Smrg GLuint start, 52848b8605Smrg GLuint n ); 53848b8605Smrg 54848b8605Smrgextern void _math_trans_1ui(GLuint *to, 55848b8605Smrg const void *ptr, 56848b8605Smrg GLuint stride, 57848b8605Smrg GLenum type, 58848b8605Smrg GLuint start, 59848b8605Smrg GLuint n ); 60848b8605Smrg 61848b8605Smrgextern void _math_trans_1ub(GLubyte *to, 62848b8605Smrg const void *ptr, 63848b8605Smrg GLuint stride, 64848b8605Smrg GLenum type, 65848b8605Smrg GLuint start, 66848b8605Smrg GLuint n ); 67848b8605Smrg 68848b8605Smrgextern void _math_trans_4ub(GLubyte (*to)[4], 69848b8605Smrg const void *ptr, 70848b8605Smrg GLuint stride, 71848b8605Smrg GLenum type, 72848b8605Smrg GLuint size, 73848b8605Smrg GLuint start, 74848b8605Smrg GLuint n ); 75848b8605Smrg 76848b8605Smrgextern void _math_trans_4us(GLushort (*to)[4], 77848b8605Smrg const void *ptr, 78848b8605Smrg GLuint stride, 79848b8605Smrg GLenum type, 80848b8605Smrg GLuint size, 81848b8605Smrg GLuint start, 82848b8605Smrg GLuint n ); 83848b8605Smrg 84848b8605Smrg/** Convert to floats w/out normalization (i.e. just cast) */ 85848b8605Smrgextern void _math_trans_4f(GLfloat (*to)[4], 86848b8605Smrg const void *ptr, 87848b8605Smrg GLuint stride, 88848b8605Smrg GLenum type, 89848b8605Smrg GLuint size, 90848b8605Smrg GLuint start, 91848b8605Smrg GLuint n ); 92848b8605Smrg 93848b8605Smrg/** Convert to normalized floats in [0,1] or [-1, 1] */ 94848b8605Smrgextern void _math_trans_4fn(GLfloat (*to)[4], 95848b8605Smrg const void *ptr, 96848b8605Smrg GLuint stride, 97848b8605Smrg GLenum type, 98848b8605Smrg GLuint size, 99848b8605Smrg GLuint start, 100848b8605Smrg GLuint n ); 101848b8605Smrg 102848b8605Smrgextern void _math_trans_3fn(GLfloat (*to)[3], 103848b8605Smrg const void *ptr, 104848b8605Smrg GLuint stride, 105848b8605Smrg GLenum type, 106848b8605Smrg GLuint start, 107848b8605Smrg GLuint n ); 108848b8605Smrg 109848b8605Smrgextern void _math_init_translate( void ); 110848b8605Smrg 111848b8605Smrg 112848b8605Smrg#endif 113