1 | # Copyright (c) 2001, Stanford University
|
---|
2 | # All rights reserved.
|
---|
3 | #
|
---|
4 | # See the file LICENSE.txt for information on redistributing this software.
|
---|
5 |
|
---|
6 | import sys
|
---|
7 |
|
---|
8 | # Two different paths to the packer and opengl_stub directories since this
|
---|
9 | # script will be called from both cr/state_tracker/ and cr/spu/tilesort/.
|
---|
10 | sys.path.append( '../packer' )
|
---|
11 | sys.path.append( '../../packer' )
|
---|
12 | sys.path.append( '../glapi_parser' )
|
---|
13 | sys.path.append( '../../glapi_parser' )
|
---|
14 | from pack_currenttypes import *
|
---|
15 | import apiutil
|
---|
16 |
|
---|
17 | apiutil.CopyrightC()
|
---|
18 |
|
---|
19 | print '''
|
---|
20 | #include "state/cr_statetypes.h"
|
---|
21 |
|
---|
22 | static double __read_double( const void *src )
|
---|
23 | {
|
---|
24 | const unsigned int *ui = (const unsigned int *) src;
|
---|
25 | double d;
|
---|
26 | ((unsigned int *) &d)[0] = ui[0];
|
---|
27 | ((unsigned int *) &d)[1] = ui[1];
|
---|
28 | return d;
|
---|
29 | }
|
---|
30 | '''
|
---|
31 |
|
---|
32 | for k in gltypes.keys():
|
---|
33 | for i in range(1,5):
|
---|
34 | print 'static void __convert_%s%d (GLfloat *dst, const %s *src) {' % (k,i,gltypes[k]['type'])
|
---|
35 | if k == 'd':
|
---|
36 | for j in range(i-1):
|
---|
37 | print '\t*dst++ = (GLfloat) __read_double(src++);'
|
---|
38 | print '\t*dst = (GLfloat) __read_double(src);'
|
---|
39 | else:
|
---|
40 | for j in range(i-1):
|
---|
41 | print '\t*dst++ = (GLfloat) *src++;';
|
---|
42 | print '\t*dst = (GLfloat) *src;';
|
---|
43 | print '}\n';
|
---|
44 |
|
---|
45 | scale = {
|
---|
46 | 'ub' : 'CR_MAXUBYTE',
|
---|
47 | 'b' : 'CR_MAXBYTE',
|
---|
48 | 'us' : 'CR_MAXUSHORT',
|
---|
49 | 's' : 'CR_MAXSHORT',
|
---|
50 | 'ui' : 'CR_MAXUINT',
|
---|
51 | 'i' : 'CR_MAXINT',
|
---|
52 | 'f' : '',
|
---|
53 | 'd' : ''
|
---|
54 | }
|
---|
55 |
|
---|
56 | for k in gltypes.keys():
|
---|
57 | if k != 'f' and k != 'd' and k != 'l':
|
---|
58 | if k[0:1] == "N":
|
---|
59 | k2 = k[1:]
|
---|
60 | else:
|
---|
61 | k2 = k
|
---|
62 | for i in range(1,5):
|
---|
63 | print 'static void __convert_rescale_%s%d (GLfloat *dst, const %s *src) {' % (k,i,gltypes[k2]['type'])
|
---|
64 | for j in range(i-1):
|
---|
65 | print '\t*dst++ = ((GLfloat) *src++) / %s;' % scale[k2]
|
---|
66 | print '\t*dst = ((GLfloat) *src) / %s;' % scale[k2]
|
---|
67 | print '}\n'
|
---|
68 |
|
---|
69 | print '''
|
---|
70 |
|
---|
71 | static void __convert_boolean (GLboolean *dst, const GLboolean *src) {
|
---|
72 | *dst = *src;
|
---|
73 | }
|
---|
74 | '''
|
---|