VirtualBox

source: vbox/trunk/src/VBox/Additions/common/crOpenGL/windows_getprocaddress.py@ 22010

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

crOpenGL: fix mesa entries patching for 64bit guests

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 5.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
6import sys
7
8import apiutil
9
10apiutil.CopyrightC()
11
12print """
13/* DO NOT EDIT - THIS FILE GENERATED BY THE getprocaddress.py SCRIPT */
14#include "chromium.h"
15#include "cr_string.h"
16#include "cr_version.h"
17#include "stub.h"
18#include "icd_drv.h"
19#include "cr_gl.h"
20#include "cr_error.h"
21
22#ifdef WINDOWS
23#pragma warning( disable: 4055 )
24#endif
25
26"""
27
28print """
29struct name_address {
30 const char *name;
31 CR_PROC address;
32};
33
34PROC WINAPI wglGetProcAddress_prox( LPCSTR name );
35
36static struct name_address functions[] = {
37"""
38
39
40keys = apiutil.GetAllFunctions(sys.argv[1]+"/APIspec.txt")
41for func_name in keys:
42 if "Chromium" == apiutil.Category(func_name):
43 continue
44 if func_name == "BoundsInfoCR":
45 continue
46 if "GL_chromium" == apiutil.Category(func_name):
47 pass #continue
48
49 wrap = apiutil.GetCategoryWrapper(func_name)
50 name = "gl" + func_name
51 address = "cr_gl" + func_name
52 if wrap:
53 print '#ifdef CR_%s' % wrap
54 print '\t{ "%s", (CR_PROC) %s },' % (name, address)
55 if wrap:
56 print '#endif'
57
58
59print "\t/* Chromium binding/glue functions */"
60
61for func_name in keys:
62 if (func_name == "Writeback" or
63 func_name == "BoundsInfoCR"):
64 continue
65 if apiutil.Category(func_name) == "Chromium":
66 print '\t{ "cr%s", (CR_PROC) cr%s },' % (func_name, func_name)
67
68print "\t/* Windows ICD functions */"
69
70for func_name in ( "CopyContext",
71 "CreateContext",
72 "CreateLayerContext",
73 "DeleteContext",
74 "DescribeLayerPlane",
75 "DescribePixelFormat",
76 "GetLayerPaletteEntries",
77 "RealizeLayerPalette",
78 "SetLayerPaletteEntries",
79 "SetPixelFormat",
80 "ShareLists",
81 "SwapBuffers",
82 "SwapLayerBuffers",
83 "ReleaseContext",
84 "SetContext",
85 "ValidateVersion"):
86 print '\t{ "Drv%s", (CR_PROC) Drv%s },' % (func_name, func_name)
87
88print '\t{ "DrvGetProcAddress", (CR_PROC) wglGetProcAddress_prox },'
89
90print """
91 { NULL, NULL }
92};
93
94extern const GLubyte * WINAPI wglGetExtensionsStringEXT_prox(void);
95extern const GLubyte * WINAPI wglGetExtensionsStringARB_prox(HDC hdc);
96extern BOOL WINAPI wglChoosePixelFormatEXT_prox(HDC hdc, const int *piAttributes, const FLOAT *pfAttributes, UINT nMaxFormats, int *piFormats, UINT *nNumFormats);
97extern BOOL WINAPI wglGetPixelFormatAttribivEXT_prox(HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, int *pValues);
98extern BOOL WINAPI wglGetPixelFormatAttribfvEXT_prox(HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, float *pValues);
99extern BOOL WINAPI wglSwapIntervalEXT_prox(int interval);
100extern int WINAPI wglGetSwapIntervalEXT_prox(void);
101
102void WINAPI LockArraysEXT (GLint first, GLsizei count)
103{
104}
105
106void WINAPI UnlockArraysEXT (void)
107{
108}
109
110CR_PROC CR_APIENTRY crGetProcAddress( const char *name )
111{
112 int i;
113 wglGetExtensionsStringEXTFunc_t wglGetExtensionsStringEXT = wglGetExtensionsStringEXT_prox;
114 wglGetExtensionsStringARBFunc_t wglGetExtensionsStringARB = wglGetExtensionsStringARB_prox;
115 wglChoosePixelFormatEXTFunc_t wglChoosePixelFormatEXT = wglChoosePixelFormatEXT_prox;
116 wglGetPixelFormatAttribivEXTFunc_t wglGetPixelFormatAttribivEXT = wglGetPixelFormatAttribivEXT_prox;
117 wglGetPixelFormatAttribfvEXTFunc_t wglGetPixelFormatAttribfvEXT = wglGetPixelFormatAttribfvEXT_prox;
118 wglSwapIntervalEXTFunc_t wglSwapIntervalEXT = wglSwapIntervalEXT_prox;
119 wglGetSwapIntervalEXTFunc_t wglGetSwapIntervalEXT = wglGetSwapIntervalEXT_prox;
120
121
122 stubInit();
123
124 for (i = 0; functions[i].name; i++) {
125 if (crStrcmp(name, functions[i].name) == 0) {
126 /*crDebug("crGetProcAddress(%s) returns %p", name, functions[i].address);*/
127 return functions[i].address;
128 }
129 }
130
131 if (!crStrcmp( name, "wglGetExtensionsStringEXT" )) return (CR_PROC) wglGetExtensionsStringEXT;
132 if (!crStrcmp( name, "wglGetExtensionsStringARB" )) return (CR_PROC) wglGetExtensionsStringARB;
133
134 if (!crStrcmp( name, "wglChoosePixelFormatEXT" )) return (CR_PROC) wglChoosePixelFormatEXT;
135 if (!crStrcmp( name, "wglGetPixelFormatAttribivEXT" )) return (CR_PROC) wglGetPixelFormatAttribivEXT;
136 if (!crStrcmp( name, "wglGetPixelFormatAttribfvEXT" )) return (CR_PROC) wglGetPixelFormatAttribfvEXT;
137
138 if (!crStrcmp( name, "wglChoosePixelFormatARB" )) return (CR_PROC) wglChoosePixelFormatEXT;
139 if (!crStrcmp( name, "wglGetPixelFormatAttribivARB" )) return (CR_PROC) wglGetPixelFormatAttribivEXT;
140 if (!crStrcmp( name, "wglGetPixelFormatAttribfvARB" )) return (CR_PROC) wglGetPixelFormatAttribfvEXT;
141
142 if (!crStrcmp( name, "wglSwapIntervalEXT" )) return (CR_PROC) wglSwapIntervalEXT;
143 if (!crStrcmp( name, "wglGetSwapIntervalEXT" )) return (CR_PROC) wglGetSwapIntervalEXT;
144
145 if (!crStrcmp( name, "glLockArraysEXT" )) return (CR_PROC) LockArraysEXT;
146 if (!crStrcmp( name, "glUnlockArraysEXT" )) return (CR_PROC) UnlockArraysEXT;
147
148 crDebug("Returning GetProcAddress:NULL for %s", name);
149 return NULL;
150}
151
152"""
153
154
155
156# XXX should crGetProcAddress really handle WGL/GLX functions???
157print_foo = """
158/* As these are Windows specific (i.e. wgl), define these now.... */
159#ifdef WINDOWS
160 {
161 wglGetExtensionsStringEXTFunc_t wglGetExtensionsStringEXT = NULL;
162 wglChoosePixelFormatFunc_t wglChoosePixelFormatEXT = NULL;
163 wglGetPixelFormatAttribivEXTFunc_t wglGetPixelFormatAttribivEXT = NULL;
164 wglGetPixelFormatAttribfvEXTFunc_t wglGetPixelFormatAttribfvEXT = NULL;
165 if (!crStrcmp( name, "wglGetExtensionsStringEXT" )) return (CR_PROC) wglGetExtensionsStringEXT;
166 if (!crStrcmp( name, "wglChoosePixelFormatEXT" )) return (CR_PROC) wglChoosePixelFormatEXT;
167 if (!crStrcmp( name, "wglGetPixelFormatAttribivEXT" )) return (CR_PROC) wglGetPixelFormatAttribivEXT;
168 if (!crStrcmp( name, "wglGetPixelFormatAttribfvEXT" )) return (CR_PROC) wglGetPixelFormatAttribfvEXT;
169 }
170#endif
171"""
Note: See TracBrowser for help on using the repository browser.

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