VirtualBox

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

Last change on this file since 78581 was 69310, checked in by vboxsync, 7 years ago

common/crOpenGL: scm updates

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 5.7 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
6from __future__ import print_function
7import sys
8
9import apiutil
10
11apiutil.CopyrightC()
12
13print("""
14/* DO NOT EDIT - THIS FILE GENERATED BY THE getprocaddress.py SCRIPT */
15#include "chromium.h"
16#include "cr_string.h"
17#include "cr_version.h"
18#include "stub.h"
19#include "icd_drv.h"
20#include "cr_gl.h"
21#include "cr_error.h"
22
23#ifdef WINDOWS
24#pragma warning( disable: 4055 )
25#endif
26
27""")
28
29print("""
30struct name_address {
31 const char *name;
32 CR_PROC address;
33};
34
35PROC WINAPI wglGetProcAddress_prox( LPCSTR name );
36
37static struct name_address functions[] = {
38""")
39
40
41keys = apiutil.GetAllFunctionsAndOmittedAliases(sys.argv[1]+"/APIspec.txt")
42for func_name in keys:
43 if "Chromium" == apiutil.Category(func_name):
44 continue
45 if "VBox" == apiutil.Category(func_name):
46 continue
47 if func_name == "BoundsInfoCR":
48 continue
49 if "GL_chromium" == apiutil.Category(func_name):
50 pass #continue
51
52 # alias is the function we're aliasing
53 proc_name = func_name
54 if "omit" in apiutil.ChromiumProps(func_name):
55 alias = apiutil.Alias(func_name)
56 if alias:
57 proc_name = alias
58
59 wrap = apiutil.GetCategoryWrapper(func_name)
60 name = "gl" + func_name
61 address = "cr_gl" + proc_name
62 if wrap:
63 print('#ifdef CR_%s' % wrap)
64 print('\t{ "%s", (CR_PROC) %s },' % (name, address))
65 if wrap:
66 print('#endif')
67
68
69print("\t/* Chromium binding/glue functions */")
70
71for func_name in keys:
72 if (func_name == "Writeback" or
73 func_name == "BoundsInfoCR" or
74 func_name == "GetUniformsLocations" or
75 func_name == "GetAttribsLocations"):
76 continue
77 if apiutil.Category(func_name) == "Chromium":
78 print('\t{ "cr%s", (CR_PROC) cr%s },' % (func_name, func_name))
79
80print("\t/* Windows ICD functions */")
81
82for func_name in ( "CopyContext",
83 "CreateContext",
84 "CreateLayerContext",
85 "DeleteContext",
86 "DescribeLayerPlane",
87 "DescribePixelFormat",
88 "GetLayerPaletteEntries",
89 "RealizeLayerPalette",
90 "SetLayerPaletteEntries",
91 "SetPixelFormat",
92 "ShareLists",
93 "SwapBuffers",
94 "SwapLayerBuffers",
95 "ReleaseContext",
96 "SetContext",
97 "ValidateVersion"):
98 print('\t{ "Drv%s", (CR_PROC) Drv%s },' % (func_name, func_name))
99
100print('\t{ "DrvGetProcAddress", (CR_PROC) wglGetProcAddress_prox },')
101
102print("""
103 { NULL, NULL }
104};
105
106extern const GLubyte * WINAPI wglGetExtensionsStringEXT_prox(void);
107extern const GLubyte * WINAPI wglGetExtensionsStringARB_prox(HDC hdc);
108extern BOOL WINAPI wglChoosePixelFormatEXT_prox(HDC hdc, const int *piAttributes, const FLOAT *pfAttributes, UINT nMaxFormats, int *piFormats, UINT *nNumFormats);
109extern BOOL WINAPI wglGetPixelFormatAttribivEXT_prox(HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, int *pValues);
110extern BOOL WINAPI wglGetPixelFormatAttribfvEXT_prox(HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, float *pValues);
111
112BOOL WINAPI wglSwapIntervalEXT(int interval)
113{
114 return false;
115}
116
117CR_PROC CR_APIENTRY crGetProcAddress( const char *name )
118{
119 int i;
120 wglGetExtensionsStringEXTFunc_t wglGetExtensionsStringEXT = wglGetExtensionsStringEXT_prox;
121 wglGetExtensionsStringARBFunc_t wglGetExtensionsStringARB = wglGetExtensionsStringARB_prox;
122 wglChoosePixelFormatEXTFunc_t wglChoosePixelFormatEXT = wglChoosePixelFormatEXT_prox;
123 wglGetPixelFormatAttribivEXTFunc_t wglGetPixelFormatAttribivEXT = wglGetPixelFormatAttribivEXT_prox;
124 wglGetPixelFormatAttribfvEXTFunc_t wglGetPixelFormatAttribfvEXT = wglGetPixelFormatAttribfvEXT_prox;
125
126 stubInit();
127
128 for (i = 0; functions[i].name; i++) {
129 if (crStrcmp(name, functions[i].name) == 0) {
130 /*crDebug("crGetProcAddress(%s) returns %p", name, functions[i].address);*/
131 return functions[i].address;
132 }
133 }
134
135 if (!crStrcmp(name, "wglGetExtensionsStringEXT")) return (CR_PROC) wglGetExtensionsStringEXT;
136 if (!crStrcmp(name, "wglGetExtensionsStringARB")) return (CR_PROC) wglGetExtensionsStringARB;
137
138 if (!crStrcmp(name, "wglChoosePixelFormatEXT")) return (CR_PROC) wglChoosePixelFormatEXT;
139 if (!crStrcmp(name, "wglGetPixelFormatAttribivEXT")) return (CR_PROC) wglGetPixelFormatAttribivEXT;
140 if (!crStrcmp(name, "wglGetPixelFormatAttribfvEXT")) return (CR_PROC) wglGetPixelFormatAttribfvEXT;
141
142 if (!crStrcmp(name, "wglChoosePixelFormatARB")) return (CR_PROC) wglChoosePixelFormatEXT;
143 if (!crStrcmp(name, "wglGetPixelFormatAttribivARB")) return (CR_PROC) wglGetPixelFormatAttribivEXT;
144 if (!crStrcmp(name, "wglGetPixelFormatAttribfvARB")) return (CR_PROC) wglGetPixelFormatAttribfvEXT;
145
146 if (!crStrcmp(name, "wglSwapIntervalEXT")) return (CR_PROC) wglSwapIntervalEXT;
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.

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