17117f1b4Smrg/* 27117f1b4Smrg * Mesa 3-D graphics library 37117f1b4Smrg * 47117f1b4Smrg * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. 57117f1b4Smrg * 67117f1b4Smrg * Permission is hereby granted, free of charge, to any person obtaining a 77117f1b4Smrg * copy of this software and associated documentation files (the "Software"), 87117f1b4Smrg * to deal in the Software without restriction, including without limitation 97117f1b4Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense, 107117f1b4Smrg * and/or sell copies of the Software, and to permit persons to whom the 117117f1b4Smrg * Software is furnished to do so, subject to the following conditions: 127117f1b4Smrg * 137117f1b4Smrg * The above copyright notice and this permission notice shall be included 147117f1b4Smrg * in all copies or substantial portions of the Software. 157117f1b4Smrg * 167117f1b4Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 177117f1b4Smrg * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 187117f1b4Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19af69d88dSmrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20af69d88dSmrg * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21af69d88dSmrg * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22af69d88dSmrg * OTHER DEALINGS IN THE SOFTWARE. 237117f1b4Smrg */ 247117f1b4Smrg 257117f1b4Smrg/** 267117f1b4Smrg * \brief Translate vectors of numbers between various types. 277117f1b4Smrg * \author Keith Whitwell. 287117f1b4Smrg */ 297117f1b4Smrg 307117f1b4Smrg 31c1f859d4Smrg#include "main/glheader.h" 323464ebd5Sriastradh#include "main/macros.h" 337117f1b4Smrg 347117f1b4Smrg#include "m_translate.h" 357117f1b4Smrg 367117f1b4Smrg 377117f1b4Smrg 387117f1b4Smrgtypedef void (*trans_1f_func)(GLfloat *to, 39af69d88dSmrg const void *ptr, 407117f1b4Smrg GLuint stride, 417117f1b4Smrg GLuint start, 427117f1b4Smrg GLuint n ); 437117f1b4Smrg 447117f1b4Smrgtypedef void (*trans_1ui_func)(GLuint *to, 45af69d88dSmrg const void *ptr, 467117f1b4Smrg GLuint stride, 477117f1b4Smrg GLuint start, 487117f1b4Smrg GLuint n ); 497117f1b4Smrg 507117f1b4Smrgtypedef void (*trans_1ub_func)(GLubyte *to, 51af69d88dSmrg const void *ptr, 527117f1b4Smrg GLuint stride, 537117f1b4Smrg GLuint start, 547117f1b4Smrg GLuint n ); 557117f1b4Smrg 567117f1b4Smrgtypedef void (*trans_4ub_func)(GLubyte (*to)[4], 57af69d88dSmrg const void *ptr, 587117f1b4Smrg GLuint stride, 597117f1b4Smrg GLuint start, 607117f1b4Smrg GLuint n ); 617117f1b4Smrg 627117f1b4Smrgtypedef void (*trans_4us_func)(GLushort (*to)[4], 63af69d88dSmrg const void *ptr, 647117f1b4Smrg GLuint stride, 657117f1b4Smrg GLuint start, 667117f1b4Smrg GLuint n ); 677117f1b4Smrg 687117f1b4Smrgtypedef void (*trans_4f_func)(GLfloat (*to)[4], 69af69d88dSmrg const void *ptr, 707117f1b4Smrg GLuint stride, 717117f1b4Smrg GLuint start, 727117f1b4Smrg GLuint n ); 737117f1b4Smrg 747117f1b4Smrgtypedef void (*trans_3fn_func)(GLfloat (*to)[3], 75af69d88dSmrg const void *ptr, 767117f1b4Smrg GLuint stride, 777117f1b4Smrg GLuint start, 787117f1b4Smrg GLuint n ); 797117f1b4Smrg 807117f1b4Smrg 817117f1b4Smrg 827117f1b4Smrg 837117f1b4Smrg#define TYPE_IDX(t) ((t) & 0xf) 847117f1b4Smrg#define MAX_TYPES TYPE_IDX(GL_DOUBLE)+1 /* 0xa + 1 */ 857117f1b4Smrg 867117f1b4Smrg 877117f1b4Smrgstatic trans_1f_func _math_trans_1f_tab[MAX_TYPES]; 887117f1b4Smrgstatic trans_1ui_func _math_trans_1ui_tab[MAX_TYPES]; 897117f1b4Smrgstatic trans_1ub_func _math_trans_1ub_tab[MAX_TYPES]; 907117f1b4Smrgstatic trans_3fn_func _math_trans_3fn_tab[MAX_TYPES]; 917117f1b4Smrgstatic trans_4ub_func _math_trans_4ub_tab[5][MAX_TYPES]; 927117f1b4Smrgstatic trans_4us_func _math_trans_4us_tab[5][MAX_TYPES]; 937117f1b4Smrgstatic trans_4f_func _math_trans_4f_tab[5][MAX_TYPES]; 947117f1b4Smrgstatic trans_4f_func _math_trans_4fn_tab[5][MAX_TYPES]; 957117f1b4Smrg 967117f1b4Smrg 977117f1b4Smrg#define PTR_ELT(ptr, elt) (((SRC *)ptr)[elt]) 987117f1b4Smrg 997117f1b4Smrg 1007117f1b4Smrg#define TAB(x) _math_trans##x##_tab 1017117f1b4Smrg#define ARGS GLuint start, GLuint n 1027117f1b4Smrg#define SRC_START start 1037117f1b4Smrg#define DST_START 0 1047117f1b4Smrg#define STRIDE stride 1057117f1b4Smrg#define NEXT_F f += stride 1067117f1b4Smrg#define NEXT_F2 1077117f1b4Smrg 1087117f1b4Smrg 1097117f1b4Smrg 1107117f1b4Smrg 1117117f1b4Smrg/** 1127117f1b4Smrg * Translate from GL_BYTE. 1137117f1b4Smrg */ 1147117f1b4Smrg#define SRC GLbyte 1157117f1b4Smrg#define SRC_IDX TYPE_IDX(GL_BYTE) 1167117f1b4Smrg#define TRX_3FN(f,n) BYTE_TO_FLOAT( PTR_ELT(f,n) ) 1177117f1b4Smrg#if 1 1187117f1b4Smrg#define TRX_4F(f,n) BYTE_TO_FLOAT( PTR_ELT(f,n) ) 1197117f1b4Smrg#else 1207117f1b4Smrg#define TRX_4F(f,n) (GLfloat)( PTR_ELT(f,n) ) 1217117f1b4Smrg#endif 1227117f1b4Smrg#define TRX_4FN(f,n) BYTE_TO_FLOAT( PTR_ELT(f,n) ) 1237117f1b4Smrg#define TRX_UB(ub, f,n) ub = BYTE_TO_UBYTE( PTR_ELT(f,n) ) 1247117f1b4Smrg#define TRX_US(ch, f,n) ch = BYTE_TO_USHORT( PTR_ELT(f,n) ) 1257117f1b4Smrg#define TRX_UI(f,n) (PTR_ELT(f,n) < 0 ? 0 : (GLuint) PTR_ELT(f,n)) 1267117f1b4Smrg 1277117f1b4Smrg 1287117f1b4Smrg#define SZ 4 1297117f1b4Smrg#define INIT init_trans_4_GLbyte_raw 1307117f1b4Smrg#define DEST_4F trans_4_GLbyte_4f_raw 1317117f1b4Smrg#define DEST_4FN trans_4_GLbyte_4fn_raw 1327117f1b4Smrg#define DEST_4UB trans_4_GLbyte_4ub_raw 1337117f1b4Smrg#define DEST_4US trans_4_GLbyte_4us_raw 1347117f1b4Smrg#include "m_trans_tmp.h" 1357117f1b4Smrg 1367117f1b4Smrg#define SZ 3 1377117f1b4Smrg#define INIT init_trans_3_GLbyte_raw 1387117f1b4Smrg#define DEST_4F trans_3_GLbyte_4f_raw 1397117f1b4Smrg#define DEST_4FN trans_3_GLbyte_4fn_raw 1407117f1b4Smrg#define DEST_4UB trans_3_GLbyte_4ub_raw 1417117f1b4Smrg#define DEST_4US trans_3_GLbyte_4us_raw 1427117f1b4Smrg#define DEST_3FN trans_3_GLbyte_3fn_raw 1437117f1b4Smrg#include "m_trans_tmp.h" 1447117f1b4Smrg 1457117f1b4Smrg#define SZ 2 1467117f1b4Smrg#define INIT init_trans_2_GLbyte_raw 1477117f1b4Smrg#define DEST_4F trans_2_GLbyte_4f_raw 1487117f1b4Smrg#define DEST_4FN trans_2_GLbyte_4fn_raw 1497117f1b4Smrg#include "m_trans_tmp.h" 1507117f1b4Smrg 1517117f1b4Smrg#define SZ 1 1527117f1b4Smrg#define INIT init_trans_1_GLbyte_raw 1537117f1b4Smrg#define DEST_4F trans_1_GLbyte_4f_raw 1547117f1b4Smrg#define DEST_4FN trans_1_GLbyte_4fn_raw 1557117f1b4Smrg#define DEST_1UB trans_1_GLbyte_1ub_raw 1567117f1b4Smrg#define DEST_1UI trans_1_GLbyte_1ui_raw 1577117f1b4Smrg#include "m_trans_tmp.h" 1587117f1b4Smrg 1597117f1b4Smrg#undef SRC 1607117f1b4Smrg#undef TRX_3FN 1617117f1b4Smrg#undef TRX_4F 1627117f1b4Smrg#undef TRX_4FN 1637117f1b4Smrg#undef TRX_UB 1647117f1b4Smrg#undef TRX_US 1657117f1b4Smrg#undef TRX_UI 1667117f1b4Smrg#undef SRC_IDX 1677117f1b4Smrg 1687117f1b4Smrg 1697117f1b4Smrg/** 1707117f1b4Smrg * Translate from GL_UNSIGNED_BYTE. 1717117f1b4Smrg */ 1727117f1b4Smrg#define SRC GLubyte 1737117f1b4Smrg#define SRC_IDX TYPE_IDX(GL_UNSIGNED_BYTE) 1747117f1b4Smrg#define TRX_3FN(f,n) UBYTE_TO_FLOAT(PTR_ELT(f,n)) 1757117f1b4Smrg#define TRX_4F(f,n) (GLfloat)( PTR_ELT(f,n) ) 1767117f1b4Smrg#define TRX_4FN(f,n) UBYTE_TO_FLOAT(PTR_ELT(f,n)) 1777117f1b4Smrg#define TRX_UB(ub, f,n) ub = PTR_ELT(f,n) 1787117f1b4Smrg#define TRX_US(us, f,n) us = UBYTE_TO_USHORT(PTR_ELT(f,n)) 1797117f1b4Smrg#define TRX_UI(f,n) (GLuint)PTR_ELT(f,n) 1807117f1b4Smrg 1817117f1b4Smrg/* 4ub->4ub handled in special case below. 1827117f1b4Smrg */ 1837117f1b4Smrg#define SZ 4 1847117f1b4Smrg#define INIT init_trans_4_GLubyte_raw 1857117f1b4Smrg#define DEST_4F trans_4_GLubyte_4f_raw 1867117f1b4Smrg#define DEST_4FN trans_4_GLubyte_4fn_raw 1877117f1b4Smrg#define DEST_4US trans_4_GLubyte_4us_raw 1887117f1b4Smrg#include "m_trans_tmp.h" 1897117f1b4Smrg 1907117f1b4Smrg 1917117f1b4Smrg#define SZ 3 1927117f1b4Smrg#define INIT init_trans_3_GLubyte_raw 1937117f1b4Smrg#define DEST_4UB trans_3_GLubyte_4ub_raw 1947117f1b4Smrg#define DEST_4US trans_3_GLubyte_4us_raw 1957117f1b4Smrg#define DEST_3FN trans_3_GLubyte_3fn_raw 1967117f1b4Smrg#define DEST_4F trans_3_GLubyte_4f_raw 1977117f1b4Smrg#define DEST_4FN trans_3_GLubyte_4fn_raw 1987117f1b4Smrg#include "m_trans_tmp.h" 1997117f1b4Smrg 2007117f1b4Smrg 2017117f1b4Smrg#define SZ 1 2027117f1b4Smrg#define INIT init_trans_1_GLubyte_raw 2037117f1b4Smrg#define DEST_1UI trans_1_GLubyte_1ui_raw 2047117f1b4Smrg#define DEST_1UB trans_1_GLubyte_1ub_raw 2057117f1b4Smrg#include "m_trans_tmp.h" 2067117f1b4Smrg 2077117f1b4Smrg#undef SRC 2087117f1b4Smrg#undef SRC_IDX 2097117f1b4Smrg#undef TRX_3FN 2107117f1b4Smrg#undef TRX_4F 2117117f1b4Smrg#undef TRX_4FN 2127117f1b4Smrg#undef TRX_UB 2137117f1b4Smrg#undef TRX_US 2147117f1b4Smrg#undef TRX_UI 2157117f1b4Smrg 2167117f1b4Smrg 2177117f1b4Smrg/* GL_SHORT 2187117f1b4Smrg */ 2197117f1b4Smrg#define SRC GLshort 2207117f1b4Smrg#define SRC_IDX TYPE_IDX(GL_SHORT) 2217117f1b4Smrg#define TRX_3FN(f,n) SHORT_TO_FLOAT( PTR_ELT(f,n) ) 2227117f1b4Smrg#define TRX_4F(f,n) (GLfloat)( PTR_ELT(f,n) ) 2237117f1b4Smrg#define TRX_4FN(f,n) SHORT_TO_FLOAT( PTR_ELT(f,n) ) 2247117f1b4Smrg#define TRX_UB(ub, f,n) ub = SHORT_TO_UBYTE(PTR_ELT(f,n)) 2257117f1b4Smrg#define TRX_US(us, f,n) us = SHORT_TO_USHORT(PTR_ELT(f,n)) 2267117f1b4Smrg#define TRX_UI(f,n) (PTR_ELT(f,n) < 0 ? 0 : (GLuint) PTR_ELT(f,n)) 2277117f1b4Smrg 2287117f1b4Smrg 2297117f1b4Smrg#define SZ 4 2307117f1b4Smrg#define INIT init_trans_4_GLshort_raw 2317117f1b4Smrg#define DEST_4F trans_4_GLshort_4f_raw 2327117f1b4Smrg#define DEST_4FN trans_4_GLshort_4fn_raw 2337117f1b4Smrg#define DEST_4UB trans_4_GLshort_4ub_raw 2347117f1b4Smrg#define DEST_4US trans_4_GLshort_4us_raw 2357117f1b4Smrg#include "m_trans_tmp.h" 2367117f1b4Smrg 2377117f1b4Smrg#define SZ 3 2387117f1b4Smrg#define INIT init_trans_3_GLshort_raw 2397117f1b4Smrg#define DEST_4F trans_3_GLshort_4f_raw 2407117f1b4Smrg#define DEST_4FN trans_3_GLshort_4fn_raw 2417117f1b4Smrg#define DEST_4UB trans_3_GLshort_4ub_raw 2427117f1b4Smrg#define DEST_4US trans_3_GLshort_4us_raw 2437117f1b4Smrg#define DEST_3FN trans_3_GLshort_3fn_raw 2447117f1b4Smrg#include "m_trans_tmp.h" 2457117f1b4Smrg 2467117f1b4Smrg#define SZ 2 2477117f1b4Smrg#define INIT init_trans_2_GLshort_raw 2487117f1b4Smrg#define DEST_4F trans_2_GLshort_4f_raw 2497117f1b4Smrg#define DEST_4FN trans_2_GLshort_4fn_raw 2507117f1b4Smrg#include "m_trans_tmp.h" 2517117f1b4Smrg 2527117f1b4Smrg#define SZ 1 2537117f1b4Smrg#define INIT init_trans_1_GLshort_raw 2547117f1b4Smrg#define DEST_4F trans_1_GLshort_4f_raw 2557117f1b4Smrg#define DEST_4FN trans_1_GLshort_4fn_raw 2567117f1b4Smrg#define DEST_1UB trans_1_GLshort_1ub_raw 2577117f1b4Smrg#define DEST_1UI trans_1_GLshort_1ui_raw 2587117f1b4Smrg#include "m_trans_tmp.h" 2597117f1b4Smrg 2607117f1b4Smrg 2617117f1b4Smrg#undef SRC 2627117f1b4Smrg#undef SRC_IDX 2637117f1b4Smrg#undef TRX_3FN 2647117f1b4Smrg#undef TRX_4F 2657117f1b4Smrg#undef TRX_4FN 2667117f1b4Smrg#undef TRX_UB 2677117f1b4Smrg#undef TRX_US 2687117f1b4Smrg#undef TRX_UI 2697117f1b4Smrg 2707117f1b4Smrg 2717117f1b4Smrg/* GL_UNSIGNED_SHORT 2727117f1b4Smrg */ 2737117f1b4Smrg#define SRC GLushort 2747117f1b4Smrg#define SRC_IDX TYPE_IDX(GL_UNSIGNED_SHORT) 2757117f1b4Smrg#define TRX_3FN(f,n) USHORT_TO_FLOAT( PTR_ELT(f,n) ) 2767117f1b4Smrg#define TRX_4F(f,n) (GLfloat)( PTR_ELT(f,n) ) 2777117f1b4Smrg#define TRX_4FN(f,n) USHORT_TO_FLOAT( PTR_ELT(f,n) ) 2787117f1b4Smrg#define TRX_UB(ub,f,n) ub = (GLubyte) (PTR_ELT(f,n) >> 8) 2797117f1b4Smrg#define TRX_US(us,f,n) us = PTR_ELT(f,n) 2807117f1b4Smrg#define TRX_UI(f,n) (GLuint) PTR_ELT(f,n) 2817117f1b4Smrg 2827117f1b4Smrg 2837117f1b4Smrg#define SZ 4 2847117f1b4Smrg#define INIT init_trans_4_GLushort_raw 2857117f1b4Smrg#define DEST_4F trans_4_GLushort_4f_raw 2867117f1b4Smrg#define DEST_4FN trans_4_GLushort_4fn_raw 2877117f1b4Smrg#define DEST_4UB trans_4_GLushort_4ub_raw 2887117f1b4Smrg#define DEST_4US trans_4_GLushort_4us_raw 2897117f1b4Smrg#include "m_trans_tmp.h" 2907117f1b4Smrg 2917117f1b4Smrg#define SZ 3 2927117f1b4Smrg#define INIT init_trans_3_GLushort_raw 2937117f1b4Smrg#define DEST_4F trans_3_GLushort_4f_raw 2947117f1b4Smrg#define DEST_4FN trans_3_GLushort_4fn_raw 2957117f1b4Smrg#define DEST_4UB trans_3_GLushort_4ub_raw 2967117f1b4Smrg#define DEST_4US trans_3_GLushort_4us_raw 2977117f1b4Smrg#define DEST_3FN trans_3_GLushort_3fn_raw 2987117f1b4Smrg#include "m_trans_tmp.h" 2997117f1b4Smrg 3007117f1b4Smrg#define SZ 2 3017117f1b4Smrg#define INIT init_trans_2_GLushort_raw 3027117f1b4Smrg#define DEST_4F trans_2_GLushort_4f_raw 3037117f1b4Smrg#define DEST_4FN trans_2_GLushort_4fn_raw 3047117f1b4Smrg#include "m_trans_tmp.h" 3057117f1b4Smrg 3067117f1b4Smrg#define SZ 1 3077117f1b4Smrg#define INIT init_trans_1_GLushort_raw 3087117f1b4Smrg#define DEST_4F trans_1_GLushort_4f_raw 3097117f1b4Smrg#define DEST_4FN trans_1_GLushort_4fn_raw 3107117f1b4Smrg#define DEST_1UB trans_1_GLushort_1ub_raw 3117117f1b4Smrg#define DEST_1UI trans_1_GLushort_1ui_raw 3127117f1b4Smrg#include "m_trans_tmp.h" 3137117f1b4Smrg 3147117f1b4Smrg#undef SRC 3157117f1b4Smrg#undef SRC_IDX 3167117f1b4Smrg#undef TRX_3FN 3177117f1b4Smrg#undef TRX_4F 3187117f1b4Smrg#undef TRX_4FN 3197117f1b4Smrg#undef TRX_UB 3207117f1b4Smrg#undef TRX_US 3217117f1b4Smrg#undef TRX_UI 3227117f1b4Smrg 3237117f1b4Smrg 3247117f1b4Smrg/* GL_INT 3257117f1b4Smrg */ 3267117f1b4Smrg#define SRC GLint 3277117f1b4Smrg#define SRC_IDX TYPE_IDX(GL_INT) 3287117f1b4Smrg#define TRX_3FN(f,n) INT_TO_FLOAT( PTR_ELT(f,n) ) 3297117f1b4Smrg#define TRX_4F(f,n) (GLfloat)( PTR_ELT(f,n) ) 3307117f1b4Smrg#define TRX_4FN(f,n) INT_TO_FLOAT( PTR_ELT(f,n) ) 3317117f1b4Smrg#define TRX_UB(ub, f,n) ub = INT_TO_UBYTE(PTR_ELT(f,n)) 3327117f1b4Smrg#define TRX_US(us, f,n) us = INT_TO_USHORT(PTR_ELT(f,n)) 3337117f1b4Smrg#define TRX_UI(f,n) (PTR_ELT(f,n) < 0 ? 0 : (GLuint) PTR_ELT(f,n)) 3347117f1b4Smrg 3357117f1b4Smrg 3367117f1b4Smrg#define SZ 4 3377117f1b4Smrg#define INIT init_trans_4_GLint_raw 3387117f1b4Smrg#define DEST_4F trans_4_GLint_4f_raw 3397117f1b4Smrg#define DEST_4FN trans_4_GLint_4fn_raw 3407117f1b4Smrg#define DEST_4UB trans_4_GLint_4ub_raw 3417117f1b4Smrg#define DEST_4US trans_4_GLint_4us_raw 3427117f1b4Smrg#include "m_trans_tmp.h" 3437117f1b4Smrg 3447117f1b4Smrg#define SZ 3 3457117f1b4Smrg#define INIT init_trans_3_GLint_raw 3467117f1b4Smrg#define DEST_4F trans_3_GLint_4f_raw 3477117f1b4Smrg#define DEST_4FN trans_3_GLint_4fn_raw 3487117f1b4Smrg#define DEST_4UB trans_3_GLint_4ub_raw 3497117f1b4Smrg#define DEST_4US trans_3_GLint_4us_raw 3507117f1b4Smrg#define DEST_3FN trans_3_GLint_3fn_raw 3517117f1b4Smrg#include "m_trans_tmp.h" 3527117f1b4Smrg 3537117f1b4Smrg#define SZ 2 3547117f1b4Smrg#define INIT init_trans_2_GLint_raw 3557117f1b4Smrg#define DEST_4F trans_2_GLint_4f_raw 3567117f1b4Smrg#define DEST_4FN trans_2_GLint_4fn_raw 3577117f1b4Smrg#include "m_trans_tmp.h" 3587117f1b4Smrg 3597117f1b4Smrg#define SZ 1 3607117f1b4Smrg#define INIT init_trans_1_GLint_raw 3617117f1b4Smrg#define DEST_4F trans_1_GLint_4f_raw 3627117f1b4Smrg#define DEST_4FN trans_1_GLint_4fn_raw 3637117f1b4Smrg#define DEST_1UB trans_1_GLint_1ub_raw 3647117f1b4Smrg#define DEST_1UI trans_1_GLint_1ui_raw 3657117f1b4Smrg#include "m_trans_tmp.h" 3667117f1b4Smrg 3677117f1b4Smrg 3687117f1b4Smrg#undef SRC 3697117f1b4Smrg#undef SRC_IDX 3707117f1b4Smrg#undef TRX_3FN 3717117f1b4Smrg#undef TRX_4F 3727117f1b4Smrg#undef TRX_4FN 3737117f1b4Smrg#undef TRX_UB 3747117f1b4Smrg#undef TRX_US 3757117f1b4Smrg#undef TRX_UI 3767117f1b4Smrg 3777117f1b4Smrg 3787117f1b4Smrg/* GL_UNSIGNED_INT 3797117f1b4Smrg */ 3807117f1b4Smrg#define SRC GLuint 3817117f1b4Smrg#define SRC_IDX TYPE_IDX(GL_UNSIGNED_INT) 3827117f1b4Smrg#define TRX_3FN(f,n) INT_TO_FLOAT( PTR_ELT(f,n) ) 3837117f1b4Smrg#define TRX_4F(f,n) (GLfloat)( PTR_ELT(f,n) ) 3847117f1b4Smrg#define TRX_4FN(f,n) UINT_TO_FLOAT( PTR_ELT(f,n) ) 3857117f1b4Smrg#define TRX_UB(ub, f,n) ub = (GLubyte) (PTR_ELT(f,n) >> 24) 3867117f1b4Smrg#define TRX_US(us, f,n) us = (GLshort) (PTR_ELT(f,n) >> 16) 3877117f1b4Smrg#define TRX_UI(f,n) PTR_ELT(f,n) 3887117f1b4Smrg 3897117f1b4Smrg 3907117f1b4Smrg#define SZ 4 3917117f1b4Smrg#define INIT init_trans_4_GLuint_raw 3927117f1b4Smrg#define DEST_4F trans_4_GLuint_4f_raw 3937117f1b4Smrg#define DEST_4FN trans_4_GLuint_4fn_raw 3947117f1b4Smrg#define DEST_4UB trans_4_GLuint_4ub_raw 3957117f1b4Smrg#define DEST_4US trans_4_GLuint_4us_raw 3967117f1b4Smrg#include "m_trans_tmp.h" 3977117f1b4Smrg 3987117f1b4Smrg#define SZ 3 3997117f1b4Smrg#define INIT init_trans_3_GLuint_raw 4007117f1b4Smrg#define DEST_4F trans_3_GLuint_4f_raw 4017117f1b4Smrg#define DEST_4FN trans_3_GLuint_4fn_raw 4027117f1b4Smrg#define DEST_4UB trans_3_GLuint_4ub_raw 4037117f1b4Smrg#define DEST_4US trans_3_GLuint_4us_raw 4047117f1b4Smrg#define DEST_3FN trans_3_GLuint_3fn_raw 4057117f1b4Smrg#include "m_trans_tmp.h" 4067117f1b4Smrg 4077117f1b4Smrg#define SZ 2 4087117f1b4Smrg#define INIT init_trans_2_GLuint_raw 4097117f1b4Smrg#define DEST_4F trans_2_GLuint_4f_raw 4107117f1b4Smrg#define DEST_4FN trans_2_GLuint_4fn_raw 4117117f1b4Smrg#include "m_trans_tmp.h" 4127117f1b4Smrg 4137117f1b4Smrg#define SZ 1 4147117f1b4Smrg#define INIT init_trans_1_GLuint_raw 4157117f1b4Smrg#define DEST_4F trans_1_GLuint_4f_raw 4167117f1b4Smrg#define DEST_4FN trans_1_GLuint_4fn_raw 4177117f1b4Smrg#define DEST_1UB trans_1_GLuint_1ub_raw 4187117f1b4Smrg#define DEST_1UI trans_1_GLuint_1ui_raw 4197117f1b4Smrg#include "m_trans_tmp.h" 4207117f1b4Smrg 4217117f1b4Smrg#undef SRC 4227117f1b4Smrg#undef SRC_IDX 4237117f1b4Smrg#undef TRX_3FN 4247117f1b4Smrg#undef TRX_4F 4257117f1b4Smrg#undef TRX_4FN 4267117f1b4Smrg#undef TRX_UB 4277117f1b4Smrg#undef TRX_US 4287117f1b4Smrg#undef TRX_UI 4297117f1b4Smrg 4307117f1b4Smrg 4317117f1b4Smrg/* GL_DOUBLE 4327117f1b4Smrg */ 4337117f1b4Smrg#define SRC GLdouble 4347117f1b4Smrg#define SRC_IDX TYPE_IDX(GL_DOUBLE) 4357117f1b4Smrg#define TRX_3FN(f,n) (GLfloat) PTR_ELT(f,n) 4367117f1b4Smrg#define TRX_4F(f,n) (GLfloat) PTR_ELT(f,n) 4377117f1b4Smrg#define TRX_4FN(f,n) (GLfloat) PTR_ELT(f,n) 4387117f1b4Smrg#define TRX_UB(ub,f,n) UNCLAMPED_FLOAT_TO_UBYTE(ub, PTR_ELT(f,n)) 4397117f1b4Smrg#define TRX_US(us,f,n) UNCLAMPED_FLOAT_TO_USHORT(us, PTR_ELT(f,n)) 4407117f1b4Smrg#define TRX_UI(f,n) (GLuint) (GLint) PTR_ELT(f,n) 4417117f1b4Smrg#define TRX_1F(f,n) (GLfloat) PTR_ELT(f,n) 4427117f1b4Smrg 4437117f1b4Smrg 4447117f1b4Smrg#define SZ 4 4457117f1b4Smrg#define INIT init_trans_4_GLdouble_raw 4467117f1b4Smrg#define DEST_4F trans_4_GLdouble_4f_raw 4477117f1b4Smrg#define DEST_4FN trans_4_GLdouble_4fn_raw 4487117f1b4Smrg#define DEST_4UB trans_4_GLdouble_4ub_raw 4497117f1b4Smrg#define DEST_4US trans_4_GLdouble_4us_raw 4507117f1b4Smrg#include "m_trans_tmp.h" 4517117f1b4Smrg 4527117f1b4Smrg#define SZ 3 4537117f1b4Smrg#define INIT init_trans_3_GLdouble_raw 4547117f1b4Smrg#define DEST_4F trans_3_GLdouble_4f_raw 4557117f1b4Smrg#define DEST_4FN trans_3_GLdouble_4fn_raw 4567117f1b4Smrg#define DEST_4UB trans_3_GLdouble_4ub_raw 4577117f1b4Smrg#define DEST_4US trans_3_GLdouble_4us_raw 4587117f1b4Smrg#define DEST_3FN trans_3_GLdouble_3fn_raw 4597117f1b4Smrg#include "m_trans_tmp.h" 4607117f1b4Smrg 4617117f1b4Smrg#define SZ 2 4627117f1b4Smrg#define INIT init_trans_2_GLdouble_raw 4637117f1b4Smrg#define DEST_4F trans_2_GLdouble_4f_raw 4647117f1b4Smrg#define DEST_4FN trans_2_GLdouble_4fn_raw 4657117f1b4Smrg#include "m_trans_tmp.h" 4667117f1b4Smrg 4677117f1b4Smrg#define SZ 1 4687117f1b4Smrg#define INIT init_trans_1_GLdouble_raw 4697117f1b4Smrg#define DEST_4F trans_1_GLdouble_4f_raw 4707117f1b4Smrg#define DEST_4FN trans_1_GLdouble_4fn_raw 4717117f1b4Smrg#define DEST_1UB trans_1_GLdouble_1ub_raw 4727117f1b4Smrg#define DEST_1UI trans_1_GLdouble_1ui_raw 4737117f1b4Smrg#define DEST_1F trans_1_GLdouble_1f_raw 4747117f1b4Smrg#include "m_trans_tmp.h" 4757117f1b4Smrg 4767117f1b4Smrg#undef SRC 4777117f1b4Smrg#undef SRC_IDX 4787117f1b4Smrg 4797117f1b4Smrg/* GL_FLOAT 4807117f1b4Smrg */ 4817117f1b4Smrg#define SRC GLfloat 4827117f1b4Smrg#define SRC_IDX TYPE_IDX(GL_FLOAT) 4837117f1b4Smrg#define SZ 4 4847117f1b4Smrg#define INIT init_trans_4_GLfloat_raw 4857117f1b4Smrg#define DEST_4UB trans_4_GLfloat_4ub_raw 4867117f1b4Smrg#define DEST_4US trans_4_GLfloat_4us_raw 4877117f1b4Smrg#define DEST_4F trans_4_GLfloat_4f_raw 4887117f1b4Smrg#define DEST_4FN trans_4_GLfloat_4fn_raw 4897117f1b4Smrg#include "m_trans_tmp.h" 4907117f1b4Smrg 4917117f1b4Smrg#define SZ 3 4927117f1b4Smrg#define INIT init_trans_3_GLfloat_raw 4937117f1b4Smrg#define DEST_4F trans_3_GLfloat_4f_raw 4947117f1b4Smrg#define DEST_4FN trans_3_GLfloat_4fn_raw 4957117f1b4Smrg#define DEST_4UB trans_3_GLfloat_4ub_raw 4967117f1b4Smrg#define DEST_4US trans_3_GLfloat_4us_raw 4977117f1b4Smrg#define DEST_3FN trans_3_GLfloat_3fn_raw 4987117f1b4Smrg#include "m_trans_tmp.h" 4997117f1b4Smrg 5007117f1b4Smrg#define SZ 2 5017117f1b4Smrg#define INIT init_trans_2_GLfloat_raw 5027117f1b4Smrg#define DEST_4F trans_2_GLfloat_4f_raw 5037117f1b4Smrg#define DEST_4FN trans_2_GLfloat_4fn_raw 5047117f1b4Smrg#include "m_trans_tmp.h" 5057117f1b4Smrg 5067117f1b4Smrg#define SZ 1 5077117f1b4Smrg#define INIT init_trans_1_GLfloat_raw 5087117f1b4Smrg#define DEST_4F trans_1_GLfloat_4f_raw 5097117f1b4Smrg#define DEST_4FN trans_1_GLfloat_4fn_raw 5107117f1b4Smrg#define DEST_1UB trans_1_GLfloat_1ub_raw 5117117f1b4Smrg#define DEST_1UI trans_1_GLfloat_1ui_raw 5127117f1b4Smrg#define DEST_1F trans_1_GLfloat_1f_raw 5137117f1b4Smrg 5147117f1b4Smrg#include "m_trans_tmp.h" 5157117f1b4Smrg 5167117f1b4Smrg#undef SRC 5177117f1b4Smrg#undef SRC_IDX 5187117f1b4Smrg#undef TRX_3FN 5197117f1b4Smrg#undef TRX_4F 5207117f1b4Smrg#undef TRX_4FN 5217117f1b4Smrg#undef TRX_UB 5227117f1b4Smrg#undef TRX_US 5237117f1b4Smrg#undef TRX_UI 5247117f1b4Smrg 5257117f1b4Smrg 5267117f1b4Smrgstatic void trans_4_GLubyte_4ub_raw(GLubyte (*t)[4], 527af69d88dSmrg const void *Ptr, 5287117f1b4Smrg GLuint stride, 5297117f1b4Smrg ARGS ) 5307117f1b4Smrg{ 5317117f1b4Smrg const GLubyte *f = (GLubyte *) Ptr + SRC_START * stride; 5327117f1b4Smrg GLuint i; 5337117f1b4Smrg 5347117f1b4Smrg if (((((uintptr_t) f | (uintptr_t) stride)) & 3L) == 0L) { 5357117f1b4Smrg /* Aligned. 5367117f1b4Smrg */ 5377117f1b4Smrg for (i = DST_START ; i < n ; i++, f += stride) { 5387117f1b4Smrg COPY_4UBV( t[i], f ); 5397117f1b4Smrg } 5407117f1b4Smrg } else { 5417117f1b4Smrg for (i = DST_START ; i < n ; i++, f += stride) { 5427117f1b4Smrg t[i][0] = f[0]; 5437117f1b4Smrg t[i][1] = f[1]; 5447117f1b4Smrg t[i][2] = f[2]; 5457117f1b4Smrg t[i][3] = f[3]; 5467117f1b4Smrg } 5477117f1b4Smrg } 5487117f1b4Smrg} 5497117f1b4Smrg 5507117f1b4Smrg 5517117f1b4Smrgstatic void init_translate_raw(void) 5527117f1b4Smrg{ 553cdc920a0Smrg memset( TAB(_1ui), 0, sizeof(TAB(_1ui)) ); 554cdc920a0Smrg memset( TAB(_1ub), 0, sizeof(TAB(_1ub)) ); 555cdc920a0Smrg memset( TAB(_3fn), 0, sizeof(TAB(_3fn)) ); 556cdc920a0Smrg memset( TAB(_4ub), 0, sizeof(TAB(_4ub)) ); 557cdc920a0Smrg memset( TAB(_4us), 0, sizeof(TAB(_4us)) ); 558cdc920a0Smrg memset( TAB(_4f), 0, sizeof(TAB(_4f)) ); 559cdc920a0Smrg memset( TAB(_4fn), 0, sizeof(TAB(_4fn)) ); 5607117f1b4Smrg 5617117f1b4Smrg init_trans_4_GLbyte_raw(); 5627117f1b4Smrg init_trans_3_GLbyte_raw(); 5637117f1b4Smrg init_trans_2_GLbyte_raw(); 5647117f1b4Smrg init_trans_1_GLbyte_raw(); 5657117f1b4Smrg init_trans_1_GLubyte_raw(); 5667117f1b4Smrg init_trans_3_GLubyte_raw(); 5677117f1b4Smrg init_trans_4_GLubyte_raw(); 5687117f1b4Smrg init_trans_4_GLshort_raw(); 5697117f1b4Smrg init_trans_3_GLshort_raw(); 5707117f1b4Smrg init_trans_2_GLshort_raw(); 5717117f1b4Smrg init_trans_1_GLshort_raw(); 5727117f1b4Smrg init_trans_4_GLushort_raw(); 5737117f1b4Smrg init_trans_3_GLushort_raw(); 5747117f1b4Smrg init_trans_2_GLushort_raw(); 5757117f1b4Smrg init_trans_1_GLushort_raw(); 5767117f1b4Smrg init_trans_4_GLint_raw(); 5777117f1b4Smrg init_trans_3_GLint_raw(); 5787117f1b4Smrg init_trans_2_GLint_raw(); 5797117f1b4Smrg init_trans_1_GLint_raw(); 5807117f1b4Smrg init_trans_4_GLuint_raw(); 5817117f1b4Smrg init_trans_3_GLuint_raw(); 5827117f1b4Smrg init_trans_2_GLuint_raw(); 5837117f1b4Smrg init_trans_1_GLuint_raw(); 5847117f1b4Smrg init_trans_4_GLdouble_raw(); 5857117f1b4Smrg init_trans_3_GLdouble_raw(); 5867117f1b4Smrg init_trans_2_GLdouble_raw(); 5877117f1b4Smrg init_trans_1_GLdouble_raw(); 5887117f1b4Smrg init_trans_4_GLfloat_raw(); 5897117f1b4Smrg init_trans_3_GLfloat_raw(); 5907117f1b4Smrg init_trans_2_GLfloat_raw(); 5917117f1b4Smrg init_trans_1_GLfloat_raw(); 5927117f1b4Smrg 5937117f1b4Smrg TAB(_4ub)[4][TYPE_IDX(GL_UNSIGNED_BYTE)] = trans_4_GLubyte_4ub_raw; 5947117f1b4Smrg} 5957117f1b4Smrg 5967117f1b4Smrg 5977117f1b4Smrg#undef TAB 5987117f1b4Smrg#ifdef CLASS 5997117f1b4Smrg#undef CLASS 6007117f1b4Smrg#endif 6017117f1b4Smrg#undef ARGS 6027117f1b4Smrg#undef SRC_START 6037117f1b4Smrg#undef DST_START 6047117f1b4Smrg#undef NEXT_F 6057117f1b4Smrg#undef NEXT_F2 6067117f1b4Smrg 6077117f1b4Smrg 6087117f1b4Smrg 6097117f1b4Smrg 6107117f1b4Smrg 6117117f1b4Smrgvoid _math_init_translate( void ) 6127117f1b4Smrg{ 6137117f1b4Smrg init_translate_raw(); 6147117f1b4Smrg} 6157117f1b4Smrg 6167117f1b4Smrg 6177117f1b4Smrg/** 6187117f1b4Smrg * Translate vector of values to GLfloat [1]. 6197117f1b4Smrg */ 6207117f1b4Smrgvoid _math_trans_1f(GLfloat *to, 621af69d88dSmrg const void *ptr, 6227117f1b4Smrg GLuint stride, 6237117f1b4Smrg GLenum type, 6247117f1b4Smrg GLuint start, 6257117f1b4Smrg GLuint n ) 6267117f1b4Smrg{ 6277117f1b4Smrg _math_trans_1f_tab[TYPE_IDX(type)]( to, ptr, stride, start, n ); 6287117f1b4Smrg} 6297117f1b4Smrg 6307117f1b4Smrg/** 6317117f1b4Smrg * Translate vector of values to GLuint [1]. 6327117f1b4Smrg */ 6337117f1b4Smrgvoid _math_trans_1ui(GLuint *to, 634af69d88dSmrg const void *ptr, 6357117f1b4Smrg GLuint stride, 6367117f1b4Smrg GLenum type, 6377117f1b4Smrg GLuint start, 6387117f1b4Smrg GLuint n ) 6397117f1b4Smrg{ 6407117f1b4Smrg _math_trans_1ui_tab[TYPE_IDX(type)]( to, ptr, stride, start, n ); 6417117f1b4Smrg} 6427117f1b4Smrg 6437117f1b4Smrg/** 6447117f1b4Smrg * Translate vector of values to GLubyte [1]. 6457117f1b4Smrg */ 6467117f1b4Smrgvoid _math_trans_1ub(GLubyte *to, 647af69d88dSmrg const void *ptr, 6487117f1b4Smrg GLuint stride, 6497117f1b4Smrg GLenum type, 6507117f1b4Smrg GLuint start, 6517117f1b4Smrg GLuint n ) 6527117f1b4Smrg{ 6537117f1b4Smrg _math_trans_1ub_tab[TYPE_IDX(type)]( to, ptr, stride, start, n ); 6547117f1b4Smrg} 6557117f1b4Smrg 6567117f1b4Smrg 6577117f1b4Smrg/** 6587117f1b4Smrg * Translate vector of values to GLubyte [4]. 6597117f1b4Smrg */ 6607117f1b4Smrgvoid _math_trans_4ub(GLubyte (*to)[4], 661af69d88dSmrg const void *ptr, 6627117f1b4Smrg GLuint stride, 6637117f1b4Smrg GLenum type, 6647117f1b4Smrg GLuint size, 6657117f1b4Smrg GLuint start, 6667117f1b4Smrg GLuint n ) 6677117f1b4Smrg{ 6687117f1b4Smrg _math_trans_4ub_tab[size][TYPE_IDX(type)]( to, ptr, stride, start, n ); 6697117f1b4Smrg} 6707117f1b4Smrg 6717117f1b4Smrg/** 6727117f1b4Smrg * Translate vector of values to GLushort [4]. 6737117f1b4Smrg */ 6747117f1b4Smrgvoid _math_trans_4us(GLushort (*to)[4], 675af69d88dSmrg const void *ptr, 6767117f1b4Smrg GLuint stride, 6777117f1b4Smrg GLenum type, 6787117f1b4Smrg GLuint size, 6797117f1b4Smrg GLuint start, 6807117f1b4Smrg GLuint n ) 6817117f1b4Smrg{ 6827117f1b4Smrg _math_trans_4us_tab[size][TYPE_IDX(type)]( to, ptr, stride, start, n ); 6837117f1b4Smrg} 6847117f1b4Smrg 6857117f1b4Smrg/** 6867117f1b4Smrg * Translate vector of values to GLfloat [4]. 6877117f1b4Smrg */ 6887117f1b4Smrgvoid _math_trans_4f(GLfloat (*to)[4], 689af69d88dSmrg const void *ptr, 6907117f1b4Smrg GLuint stride, 6917117f1b4Smrg GLenum type, 6927117f1b4Smrg GLuint size, 6937117f1b4Smrg GLuint start, 6947117f1b4Smrg GLuint n ) 6957117f1b4Smrg{ 6967117f1b4Smrg _math_trans_4f_tab[size][TYPE_IDX(type)]( to, ptr, stride, start, n ); 6977117f1b4Smrg} 6987117f1b4Smrg 6997117f1b4Smrg/** 7007117f1b4Smrg * Translate vector of values to GLfloat[4], normalized to [-1, 1]. 7017117f1b4Smrg */ 7027117f1b4Smrgvoid _math_trans_4fn(GLfloat (*to)[4], 703af69d88dSmrg const void *ptr, 7047117f1b4Smrg GLuint stride, 7057117f1b4Smrg GLenum type, 7067117f1b4Smrg GLuint size, 7077117f1b4Smrg GLuint start, 7087117f1b4Smrg GLuint n ) 7097117f1b4Smrg{ 7107117f1b4Smrg _math_trans_4fn_tab[size][TYPE_IDX(type)]( to, ptr, stride, start, n ); 7117117f1b4Smrg} 7127117f1b4Smrg 7137117f1b4Smrg/** 7147117f1b4Smrg * Translate vector of values to GLfloat[3], normalized to [-1, 1]. 7157117f1b4Smrg */ 7167117f1b4Smrgvoid _math_trans_3fn(GLfloat (*to)[3], 717af69d88dSmrg const void *ptr, 7187117f1b4Smrg GLuint stride, 7197117f1b4Smrg GLenum type, 7207117f1b4Smrg GLuint start, 7217117f1b4Smrg GLuint n ) 7227117f1b4Smrg{ 7237117f1b4Smrg _math_trans_3fn_tab[TYPE_IDX(type)]( to, ptr, stride, start, n ); 7247117f1b4Smrg} 725