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