VirtualBox

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

最後變更 在這個檔案從53090是 15532,由 vboxsync 提交於 16 年 前

crOpenGL: export to OSE

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Id
檔案大小: 1.8 KB
 
1# Copyright (c) 2001, Stanford University
2# All rights reserved.
3#
4# See the file LICENSE.txt for information on redistributing this software.
5
6import 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/.
10sys.path.append( '../packer' )
11sys.path.append( '../../packer' )
12sys.path.append( '../glapi_parser' )
13sys.path.append( '../../glapi_parser' )
14from pack_currenttypes import *
15import apiutil
16
17apiutil.CopyrightC()
18
19print '''
20#include "state/cr_statetypes.h"
21
22static 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
32for 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
45scale = {
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
56for 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
69print '''
70
71static void __convert_boolean (GLboolean *dst, const GLboolean *src) {
72 *dst = *src;
73}
74'''
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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