VirtualBox

source: vbox/trunk/src/VBox/GuestHost/OpenGL/state_tracker/convert.py@ 63939

Last change on this file since 63939 was 63939, checked in by vboxsync, 8 years ago

Build/scripts (bugref:6627): Python build scripts updated to generate the same code when used with Python 2 and 3.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 1.9 KB
Line 
1# Copyright (c) 2001, Stanford University
2# All rights reserved.
3#
4# See the file LICENSE.txt for information on redistributing this software.
5
6from __future__ import print_function
7import 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/.
11sys.path.append( '../packer' )
12sys.path.append( '../../packer' )
13sys.path.append( '../glapi_parser' )
14sys.path.append( '../../glapi_parser' )
15from pack_currenttypes import *
16import apiutil
17
18apiutil.CopyrightC()
19
20print('''
21#include "state/cr_statetypes.h"
22
23static 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
33for 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
46scale = {
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
57for 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
70print('''
71
72static void __convert_boolean (GLboolean *dst, const GLboolean *src) {
73 *dst = *src;
74}
75''')
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette