VirtualBox

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

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

GA/common/crOpenGL: warnings (gcc)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 7.8 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
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 print '#ifdef __GNUC__';
34 print '# if (__GNUC__ << 16) + __GNUC_MINOR__ >= 0x40002';
35 print '# pragma GCC diagnostic ignored "-Wunused-parameter"';
36 print '# endif';
37 print '#endif';
38
39
40 # Get sorted list of dispatched functions.
41 # The order is very important - it must match cr_opcodes.h
42 # and spu_dispatch_table.h
43 keys = apiutil.GetDispatchedFunctions(sys.argv[1]+"/APIspec.txt")
44
45 for index in range(len(keys)):
46 func_name = keys[index]
47 if apiutil.Category(func_name) == "Chromium":
48 # this function is defined in stub.c
49 continue
50
51 return_type = apiutil.ReturnType(func_name)
52 params = apiutil.Parameters(func_name)
53
54 if func_name in hacks:
55 print "/* hacked entrypoint: %s */" % func_name
56 if func_name == "TexImage3D":
57 # Pretty common: internalformat is GLenum, not GLint
58 print "void glTexImage3D( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels )"
59 print "{"
60 print "\tglim.TexImage3D( target, level, (GLint) internalformat, width, height, depth, border, format, type, pixels );"
61 print "}"
62 elif func_name == "TexImage2D":
63 # Pretty common: internalformat is GLenum, not GLint
64 print "void glTexImage2D( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels )"
65 print "{"
66 print "\tglim.TexImage2D( target, level, (GLint) internalformat, width, height, border, format, type, pixels );"
67 print "}"
68 elif func_name == "TexImage1D":
69 # Pretty common: internalformat is GLenum, not GLint
70 print "void glTexImage1D( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels )"
71 print "{"
72 print "\tglim.TexImage1D( target, level, (GLint) internalformat, width, border, format, type, pixels );"
73 print "}"
74 elif func_name == "EdgeFlagPointer":
75 # second arg is GLboolean instead of GLvoid
76 print "void glEdgeFlagPointer( GLsizei stride, const GLboolean *pointer )"
77 print "{"
78 print "\tglim.EdgeFlagPointer( stride, pointer );"
79 print "}"
80 elif func_name == "ProgramParameters4fvNV":
81 print "void glProgramParameters4fvNV( GLenum target, GLuint index, GLuint num, const GLfloat *params )"
82 print "{"
83 print "\tglim.ProgramParameters4fvNV( target, index, num, params );"
84 print "}"
85 elif func_name == "MultiDrawElementsEXT":
86 print "void glMultiDrawElementsEXT(GLenum mode, GLsizei *count, GLenum type, const GLvoid **indices, GLsizei primcount)"
87 print "{"
88 print "\tglim.MultiDrawElementsEXT(mode, count,type, indices, primcount);"
89 print "}"
90 elif func_name == "ProgramParameters4dvNV":
91 print "void glProgramParameters4dvNV( GLenum target, GLuint index, GLuint num, const GLdouble *params )"
92 print "{"
93 print "\tglim.ProgramParameters4dvNV( target, index, num, params );"
94 print "}"
95 else:
96 # the usual path
97 print "%s VBOXGLTAG(gl%s)( %s );" % (return_type, func_name, apiutil.MakeDeclarationString(params))
98 print ""
99 print "%s VBOXGLTAG(gl%s)( %s )" % (return_type, func_name, apiutil.MakeDeclarationString(params))
100 print "{"
101 print "\t",
102 if return_type != "void":
103 print "return ",
104 print "glim.%s( %s );" % (func_name, apiutil.MakeCallString(params))
105 print "}"
106 print ""
107
108 print '/*'
109 print '* Aliases'
110 print '*/'
111
112 # Now loop over all the functions and take care of any aliases
113 allkeys = apiutil.GetAllFunctions(sys.argv[1]+"/APIspec.txt")
114 for func_name in allkeys:
115 if "omit" in apiutil.ChromiumProps(func_name):
116 continue
117
118 if func_name in keys:
119 # we already processed this function earlier
120 continue
121
122 # alias is the function we're aliasing
123 alias = apiutil.Alias(func_name)
124 if alias:
125 if func_name in hacks:
126 print "/* hacked entrypoint: %s */" % func_name
127 if func_name == "MultiDrawArrays":
128 print "void glMultiDrawArrays( GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount )"
129 print "{"
130 print "\tglim.MultiDrawArraysEXT( mode, (GLint*)first, (GLsizei*)count, primcount );"
131 print "}"
132 elif func_name == "BufferData":
133 print "void glBufferData(GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage)"
134 print "{"
135 print "\tglim.BufferDataARB(target, size, data, usage);"
136 print "}"
137 elif func_name == "BufferSubData":
138 print "void glBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data)"
139 print "{"
140 print "\tglim.BufferSubDataARB(target, offset, size, data);"
141 print "}"
142 elif func_name == "GetBufferSubData":
143 print "void glGetBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, GLvoid *data)"
144 print "{"
145 print "\tglim.GetBufferSubDataARB(target, offset, size, data);"
146 print "}"
147 else:
148 return_type = apiutil.ReturnType(func_name)
149 params = apiutil.Parameters(func_name)
150 print "%s VBOXGLTAG(gl%s)( %s );" % (return_type, func_name, apiutil.MakeDeclarationString(params))
151 print ""
152 print "%s VBOXGLTAG(gl%s)( %s )" % (return_type, func_name, apiutil.MakeDeclarationString(params))
153 print "{"
154 print "\t",
155 if return_type != "void":
156 print "return ",
157 print "glim.%s( %s );" % (alias, apiutil.MakeCallString(params))
158 print "}"
159 print ""
160
161 print '/*'
162 print '* No-op stubs'
163 print '*/'
164
165 # Now generate no-op stub functions
166 for func_name in allkeys:
167 if "stub" in apiutil.ChromiumProps(func_name):
168 return_type = apiutil.ReturnType(func_name)
169 params = apiutil.Parameters(func_name)
170
171 print "%s VBOXGLTAG(gl%s)( %s );" % (return_type, func_name, apiutil.MakeDeclarationString(params))
172 print ""
173 print "%s VBOXGLTAG(gl%s)( %s )" % (return_type, func_name, apiutil.MakeDeclarationString(params))
174 print "{"
175 if return_type != "void":
176 print "return (%s) 0" % return_type
177 print "}"
178 print ""
179
180
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use