• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Mesa 3-D graphics library
3  *
4  * Copyright (C) 1999-2006  Brian Paul   All Rights Reserved.
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a
7  * copy of this software and associated documentation files (the "Software"),
8  * to deal in the Software without restriction, including without limitation
9  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  * and/or sell copies of the Software, and to permit persons to whom the
11  * Software is furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included
14  * in all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
19  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22  * OTHER DEALINGS IN THE SOFTWARE.
23  */
24 
25 
26 #ifndef _M_TRANSLATE_H_
27 #define _M_TRANSLATE_H_
28 
29 #include "main/glheader.h"
30 
31 /**
32  * Array translation.
33  * For example, convert array of GLushort[3] to GLfloat[4].
34  * The function name specifies the destination format/size.
35  * \param  to  the destination address
36  * \param  ptr  the source address
37  * \param  stride  the source stride (in bytes) between elements
38  * \param  type  the source datatype (GL_SHORT, GL_UNSIGNED_INT, etc)
39  * \param  size  number of values per element in source array (1,2,3 or 4)
40  * \param  start  first element in source array to convert
41  * \param  n  number of elements to convert
42  *
43  * Note: "element" means a tuple like GLfloat[3] or GLubyte[4].
44  */
45 
46 
47 extern void _math_trans_1f(GLfloat *to,
48 			   const void *ptr,
49 			   GLuint stride,
50 			   GLenum type,
51 			   GLuint start,
52 			   GLuint n );
53 
54 extern void _math_trans_1ui(GLuint *to,
55 			    const void *ptr,
56 			    GLuint stride,
57 			    GLenum type,
58 			    GLuint start,
59 			    GLuint n );
60 
61 extern void _math_trans_1ub(GLubyte *to,
62 			    const void *ptr,
63 			    GLuint stride,
64 			    GLenum type,
65 			    GLuint start,
66 			    GLuint n );
67 
68 extern void _math_trans_4ub(GLubyte (*to)[4],
69 			    const void *ptr,
70 			    GLuint stride,
71 			    GLenum type,
72 			    GLuint size,
73 			    GLuint start,
74 			    GLuint n );
75 
76 extern void _math_trans_4us(GLushort (*to)[4],
77 			    const void *ptr,
78 			    GLuint stride,
79 			    GLenum type,
80 			    GLuint size,
81 			    GLuint start,
82 			    GLuint n );
83 
84 /** Convert to floats w/out normalization (i.e. just cast) */
85 extern void _math_trans_4f(GLfloat (*to)[4],
86 			   const void *ptr,
87 			   GLuint stride,
88 			   GLenum type,
89 			   GLuint size,
90 			   GLuint start,
91 			   GLuint n );
92 
93 /** Convert to normalized floats in [0,1] or [-1, 1] */
94 extern void _math_trans_4fn(GLfloat (*to)[4],
95 			    const void *ptr,
96 			    GLuint stride,
97 			    GLenum type,
98 			    GLuint size,
99 			    GLuint start,
100 			    GLuint n );
101 
102 extern void _math_trans_3fn(GLfloat (*to)[3],
103 			   const void *ptr,
104 			   GLuint stride,
105 			   GLenum type,
106 			   GLuint start,
107 			   GLuint n );
108 
109 extern void _math_init_translate( void );
110 
111 
112 #endif
113