VirtualBox

source: vbox/trunk/src/VBox/Additions/WINNT/Graphics/crOpenGL/pack/packspu_get.py@ 16241

Last change on this file since 16241 was 15532, checked in by vboxsync, 16 years ago

crOpenGL: export to OSE

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 5.0 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
6import sys
7
8import apiutil
9
10
11apiutil.CopyrightC()
12
13print """
14/* DO NOT EDIT - THIS FILE AUTOMATICALLY GENERATED BY packspu_get.py SCRIPT */
15#include "packspu.h"
16#include "cr_packfunctions.h"
17#include "cr_net.h"
18#include "packspu_proto.h"
19"""
20
21from get_sizes import *
22from get_components import *
23
24easy_swaps = {
25 'GenTextures': '(unsigned int) n',
26 'GetClipPlane': '4',
27 'GetPolygonStipple': '0'
28}
29
30simple_funcs = [ 'GetIntegerv', 'GetFloatv', 'GetDoublev', 'GetBooleanv' ]
31simple_swaps = [ 'SWAP32', 'SWAPFLOAT', 'SWAPDOUBLE', '(GLboolean) SWAP32' ]
32
33hard_funcs = {
34 'GetLightfv': 'SWAPFLOAT',
35 'GetLightiv': 'SWAP32',
36 'GetMaterialfv': 'SWAPFLOAT',
37 'GetMaterialiv': 'SWAP32',
38 'GetTexEnvfv': 'SWAPFLOAT',
39 'GetTexEnviv': 'SWAP32',
40 'GetTexGendv': 'SWAPDOUBLE',
41 'GetTexGenfv': 'SWAPFLOAT',
42 'GetTexGeniv': 'SWAP32',
43 'GetTexLevelParameterfv': 'SWAPFLOAT',
44 'GetTexLevelParameteriv': 'SWAP32',
45 'GetTexParameterfv': 'SWAPFLOAT',
46 'GetTexParameteriv': 'SWAP32' }
47
48keys = apiutil.GetDispatchedFunctions(sys.argv[1]+"/APIspec.txt")
49
50for func_name in keys:
51 params = apiutil.Parameters(func_name)
52 return_type = apiutil.ReturnType(func_name)
53 if apiutil.FindSpecial( "packspu", func_name ):
54 continue
55
56 if "get" in apiutil.Properties(func_name):
57 print '%s PACKSPU_APIENTRY packspu_%s( %s )' % ( return_type, func_name, apiutil.MakeDeclarationString( params ) )
58 print '{'
59 print '\tGET_THREAD(thread);'
60 print '\tint writeback = 1;'
61 if return_type != 'void':
62 print '\t%s return_val = (%s) 0;' % (return_type, return_type)
63 params.append( ("&return_val", "foo", 0) )
64 if (func_name in easy_swaps.keys() and easy_swaps[func_name] != '0') or func_name in simple_funcs or func_name in hard_funcs.keys():
65 print '\tunsigned int i;'
66 print '\tif (!(pack_spu.thread[0].netServer.conn->actual_network))'
67 print '\t{'
68 print '\t\tcrError( "packspu_%s doesn\'t work when there\'s no actual network involved!\\nTry using the simplequery SPU in your chain!" );' % func_name
69 print '\t}'
70 if func_name in simple_funcs:
71 print '\tif (pname == GL_UNPACK_ALIGNMENT ||'
72 print '\t\tpname == GL_UNPACK_ROW_LENGTH ||'
73 print '\t\tpname == GL_UNPACK_SKIP_PIXELS ||'
74 print '\t\tpname == GL_UNPACK_LSB_FIRST ||'
75 print '\t\tpname == GL_UNPACK_SWAP_BYTES ||'
76 print '#ifdef CR_OPENGL_VERSION_1_2'
77 print '\t\tpname == GL_UNPACK_IMAGE_HEIGHT ||'
78 print '#endif'
79 print '\t\tpname == GL_UNPACK_SKIP_ROWS ||'
80 print '\t\tpname == GL_PACK_ALIGNMENT ||'
81 print '\t\tpname == GL_PACK_ROW_LENGTH ||'
82 print '\t\tpname == GL_PACK_SKIP_PIXELS ||'
83 print '\t\tpname == GL_PACK_LSB_FIRST ||'
84 print '\t\tpname == GL_PACK_SWAP_BYTES ||'
85 print '#ifdef CR_OPENGL_VERSION_1_2'
86 print '\t\tpname == GL_PACK_IMAGE_HEIGHT ||'
87 print '#endif'
88 print '\t\tpname == GL_PACK_SKIP_ROWS) {'
89 print '\t\t\tcrState%s( pname, params );' % func_name
90 print '\t\t\treturn;'
91 print '\t}'
92 params.append( ("&writeback", "foo", 0) )
93 print '\tif (pack_spu.swap)'
94 print '\t{'
95 print '\t\tcrPack%sSWAP( %s );' % (func_name, apiutil.MakeCallString( params ) )
96 print '\t}'
97 print '\telse'
98 print '\t{'
99 print '\t\tcrPack%s( %s );' % (func_name, apiutil.MakeCallString( params ) )
100 print '\t}'
101 print '\tpackspuFlush( (void *) thread );'
102 print '\twhile (writeback)'
103 print '\t\tcrNetRecv();'
104 lastParamName = params[-2][0]
105 if return_type != 'void':
106 print '\tif (pack_spu.swap)'
107 print '\t{'
108 print '\t\treturn_val = (%s) SWAP32(return_val);' % return_type
109 print '\t}'
110 print '\treturn return_val;'
111 if func_name in easy_swaps.keys() and easy_swaps[func_name] != '0':
112 limit = easy_swaps[func_name]
113 print '\tif (pack_spu.swap)'
114 print '\t{'
115 print '\t\tfor (i = 0 ; i < %s ; i++)' % limit
116 print '\t\t{'
117 if params[-2][1].find( "double" ) > -1:
118 print '\t\t\t%s[i] = SWAPDOUBLE(%s[i]);' % (lastParamName, lastParamName)
119 else:
120 print '\t\t\t%s[i] = SWAP32(%s[i]);' % (lastParamName, lastParamName)
121 print '\t\t}'
122 print '\t}'
123 for index in range(len(simple_funcs)):
124 if simple_funcs[index] == func_name:
125 print '\tif (pack_spu.swap)'
126 print '\t{'
127 print '\t\tfor (i = 0 ; i < __numValues( pname ) ; i++)'
128 print '\t\t{'
129 if simple_swaps[index] == 'SWAPDOUBLE':
130 print '\t\t\t%s[i] = %s(%s[i]);' % (lastParamName, simple_swaps[index], lastParamName)
131 else:
132 print '\t\t\t((GLuint *) %s)[i] = %s(%s[i]);' % (lastParamName, simple_swaps[index], lastParamName)
133 print '\t\t}'
134 print '\t}'
135 if func_name in hard_funcs.keys():
136 print '\tif (pack_spu.swap)'
137 print '\t{'
138 print '\t\tfor (i = 0 ; i < lookupComponents(pname) ; i++)'
139 print '\t\t{'
140 if hard_funcs[func_name] == 'SWAPDOUBLE':
141 print '\t\t\t%s[i] = %s(%s[i]);' % (lastParamName, hard_funcs[func_name], lastParamName)
142 else:
143 print '\t\t\t((GLuint *) %s)[i] = %s(%s[i]);' % (lastParamName, hard_funcs[func_name], lastParamName)
144 print '\t\t}'
145 print '\t}'
146 print '}\n'
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