VirtualBox

source: vbox/trunk/src/VBox/Additions/common/crOpenGL/entrypoints.py@ 53361

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

crOpenGL: generate opengl .c exports file for solaris dri/fakedri

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Id
檔案大小: 7.6 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
6
7"""
8This module generates C entrypoints for all the OpenGL functions
9and the special Chromium meta/glue functions.
10"""
11
12
13import sys
14
15import apiutil
16
17
18def GenerateEntrypoints(hacks = []):
19 """Emit code for all the OpenGL/Chromium entrypoints.
20 hacks is an optional list of functions which are special cased.
21 """
22
23 apiutil.CopyrightC()
24
25 print '#define GL_GLEXT_PROTOTYPES'
26 print '#include <stdio.h>'
27 print '#include <stdlib.h>'
28 print '#include <GL/gl.h>'
29 print '#include "chromium.h"'
30 print '#include "stub.h"'
31 print '#include "dri_glx.h"'
32 print ''
33
34 # Get sorted list of dispatched functions.
35 # The order is very important - it must match cr_opcodes.h
36 # and spu_dispatch_table.h
37 keys = apiutil.GetDispatchedFunctions(sys.argv[1]+"/APIspec.txt")
38
39 for index in range(len(keys)):
40 func_name = keys[index]
41 if apiutil.Category(func_name) == "Chromium":
42 # this function is defined in stub.c
43 continue
44
45 return_type = apiutil.ReturnType(func_name)
46 params = apiutil.Parameters(func_name)
47
48 if func_name in hacks:
49 print "/* hacked entrypoint: %s */" % func_name
50 if func_name == "TexImage3D":
51 # Pretty common: internalformat is GLenum, not GLint
52 print "void glTexImage3D( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels )"
53 print "{"
54 print "\tglim.TexImage3D( target, level, (GLint) internalformat, width, height, depth, border, format, type, pixels );"
55 print "}"
56 elif func_name == "TexImage2D":
57 # Pretty common: internalformat is GLenum, not GLint
58 print "void glTexImage2D( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels )"
59 print "{"
60 print "\tglim.TexImage2D( target, level, (GLint) internalformat, width, height, border, format, type, pixels );"
61 print "}"
62 elif func_name == "TexImage1D":
63 # Pretty common: internalformat is GLenum, not GLint
64 print "void glTexImage1D( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels )"
65 print "{"
66 print "\tglim.TexImage1D( target, level, (GLint) internalformat, width, border, format, type, pixels );"
67 print "}"
68 elif func_name == "EdgeFlagPointer":
69 # second arg is GLboolean instead of GLvoid
70 print "void glEdgeFlagPointer( GLsizei stride, const GLboolean *pointer )"
71 print "{"
72 print "\tglim.EdgeFlagPointer( stride, pointer );"
73 print "}"
74 elif func_name == "ProgramParameters4fvNV":
75 print "void glProgramParameters4fvNV( GLenum target, GLuint index, GLuint num, const GLfloat *params )"
76 print "{"
77 print "\tglim.ProgramParameters4fvNV( target, index, num, params );"
78 print "}"
79 elif func_name == "MultiDrawElementsEXT":
80 print "void glMultiDrawElementsEXT(GLenum mode, GLsizei *count, GLenum type, const GLvoid **indices, GLsizei primcount)"
81 print "{"
82 print "\tglim.MultiDrawElementsEXT(mode, count,type, indices, primcount);"
83 print "}"
84 elif func_name == "ProgramParameters4dvNV":
85 print "void glProgramParameters4dvNV( GLenum target, GLuint index, GLuint num, const GLdouble *params )"
86 print "{"
87 print "\tglim.ProgramParameters4dvNV( target, index, num, params );"
88 print "}"
89 else:
90 # the usual path
91 print "%s VBOXGLTAG(gl%s)( %s );" % (return_type, func_name, apiutil.MakeDeclarationString(params))
92 print ""
93 print "%s VBOXGLTAG(gl%s)( %s )" % (return_type, func_name, apiutil.MakeDeclarationString(params))
94 print "{"
95 print "\t",
96 if return_type != "void":
97 print "return ",
98 print "glim.%s( %s );" % (func_name, apiutil.MakeCallString(params))
99 print "}"
100 print ""
101
102 print '/*'
103 print '* Aliases'
104 print '*/'
105
106 # Now loop over all the functions and take care of any aliases
107 allkeys = apiutil.GetAllFunctions(sys.argv[1]+"/APIspec.txt")
108 for func_name in allkeys:
109 if "omit" in apiutil.ChromiumProps(func_name):
110 continue
111
112 if func_name in keys:
113 # we already processed this function earlier
114 continue
115
116 # alias is the function we're aliasing
117 alias = apiutil.Alias(func_name)
118 if alias:
119 if func_name in hacks:
120 print "/* hacked entrypoint: %s */" % func_name
121 if func_name == "MultiDrawArrays":
122 print "void glMultiDrawArrays( GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount )"
123 print "{"
124 print "\tglim.MultiDrawArraysEXT( mode, (GLint*)first, (GLsizei*)count, primcount );"
125 print "}"
126 elif func_name == "BufferData":
127 print "void glBufferData(GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage)"
128 print "{"
129 print "\tglim.BufferDataARB(target, size, data, usage);"
130 print "}"
131 elif func_name == "BufferSubData":
132 print "void glBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data)"
133 print "{"
134 print "\tglim.BufferSubDataARB(target, offset, size, data);"
135 print "}"
136 elif func_name == "GetBufferSubData":
137 print "void glGetBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, GLvoid *data)"
138 print "{"
139 print "\tglim.GetBufferSubDataARB(target, offset, size, data);"
140 print "}"
141 else:
142 return_type = apiutil.ReturnType(func_name)
143 params = apiutil.Parameters(func_name)
144 print "%s VBOXGLTAG(gl%s)( %s );" % (return_type, func_name, apiutil.MakeDeclarationString(params))
145 print ""
146 print "%s VBOXGLTAG(gl%s)( %s )" % (return_type, func_name, apiutil.MakeDeclarationString(params))
147 print "{"
148 print "\t",
149 if return_type != "void":
150 print "return ",
151 print "glim.%s( %s );" % (alias, apiutil.MakeCallString(params))
152 print "}"
153 print ""
154
155 print '/*'
156 print '* No-op stubs'
157 print '*/'
158
159 # Now generate no-op stub functions
160 for func_name in allkeys:
161 if "stub" in apiutil.ChromiumProps(func_name):
162 return_type = apiutil.ReturnType(func_name)
163 params = apiutil.Parameters(func_name)
164
165 print "%s VBOXGLTAG(gl%s)( %s );" % (return_type, func_name, apiutil.MakeDeclarationString(params))
166 print ""
167 print "%s VBOXGLTAG(gl%s)( %s )" % (return_type, func_name, apiutil.MakeDeclarationString(params))
168 print "{"
169 if return_type != "void":
170 print "return (%s) 0" % return_type
171 print "}"
172 print ""
173
174
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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