VirtualBox

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

Last change on this file since 29041 was 23399, checked in by vboxsync, 15 years ago

crOpenGL: cache uniforms info

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 5.2 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" or
64 func_name == "GetUniformsLocations"):
65 continue
66 if apiutil.Category(func_name) == "Chromium":
67 print '\t{ "cr%s", (CR_PROC) cr%s },' % (func_name, func_name)
68
69print "\t/* Windows ICD functions */"
70
71for func_name in ( "CopyContext",
72 "CreateContext",
73 "CreateLayerContext",
74 "DeleteContext",
75 "DescribeLayerPlane",
76 "DescribePixelFormat",
77 "GetLayerPaletteEntries",
78 "RealizeLayerPalette",
79 "SetLayerPaletteEntries",
80 "SetPixelFormat",
81 "ShareLists",
82 "SwapBuffers",
83 "SwapLayerBuffers",
84 "ReleaseContext",
85 "SetContext",
86 "ValidateVersion"):
87 print '\t{ "Drv%s", (CR_PROC) Drv%s },' % (func_name, func_name)
88
89print '\t{ "DrvGetProcAddress", (CR_PROC) wglGetProcAddress_prox },'
90
91print """
92 { NULL, NULL }
93};
94
95extern const GLubyte * WINAPI wglGetExtensionsStringEXT_prox(void);
96extern const GLubyte * WINAPI wglGetExtensionsStringARB_prox(HDC hdc);
97extern BOOL WINAPI wglChoosePixelFormatEXT_prox(HDC hdc, const int *piAttributes, const FLOAT *pfAttributes, UINT nMaxFormats, int *piFormats, UINT *nNumFormats);
98extern BOOL WINAPI wglGetPixelFormatAttribivEXT_prox(HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, int *pValues);
99extern BOOL WINAPI wglGetPixelFormatAttribfvEXT_prox(HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, float *pValues);
100
101CR_PROC CR_APIENTRY crGetProcAddress( const char *name )
102{
103 int i;
104 wglGetExtensionsStringEXTFunc_t wglGetExtensionsStringEXT = wglGetExtensionsStringEXT_prox;
105 wglGetExtensionsStringARBFunc_t wglGetExtensionsStringARB = wglGetExtensionsStringARB_prox;
106 wglChoosePixelFormatEXTFunc_t wglChoosePixelFormatEXT = wglChoosePixelFormatEXT_prox;
107 wglGetPixelFormatAttribivEXTFunc_t wglGetPixelFormatAttribivEXT = wglGetPixelFormatAttribivEXT_prox;
108 wglGetPixelFormatAttribfvEXTFunc_t wglGetPixelFormatAttribfvEXT = wglGetPixelFormatAttribfvEXT_prox;
109
110 stubInit();
111
112 for (i = 0; functions[i].name; i++) {
113 if (crStrcmp(name, functions[i].name) == 0) {
114 /*crDebug("crGetProcAddress(%s) returns %p", name, functions[i].address);*/
115 return functions[i].address;
116 }
117 }
118
119 if (!crStrcmp( name, "wglGetExtensionsStringEXT" )) return (CR_PROC) wglGetExtensionsStringEXT;
120 if (!crStrcmp( name, "wglGetExtensionsStringARB" )) return (CR_PROC) wglGetExtensionsStringARB;
121
122 if (!crStrcmp( name, "wglChoosePixelFormatEXT" )) return (CR_PROC) wglChoosePixelFormatEXT;
123 if (!crStrcmp( name, "wglGetPixelFormatAttribivEXT" )) return (CR_PROC) wglGetPixelFormatAttribivEXT;
124 if (!crStrcmp( name, "wglGetPixelFormatAttribfvEXT" )) return (CR_PROC) wglGetPixelFormatAttribfvEXT;
125
126 if (!crStrcmp( name, "wglChoosePixelFormatARB" )) return (CR_PROC) wglChoosePixelFormatEXT;
127 if (!crStrcmp( name, "wglGetPixelFormatAttribivARB" )) return (CR_PROC) wglGetPixelFormatAttribivEXT;
128 if (!crStrcmp( name, "wglGetPixelFormatAttribfvARB" )) return (CR_PROC) wglGetPixelFormatAttribfvEXT;
129
130 crDebug("Returning GetProcAddress:NULL for %s", name);
131 return NULL;
132}
133
134"""
135
136
137
138# XXX should crGetProcAddress really handle WGL/GLX functions???
139print_foo = """
140/* As these are Windows specific (i.e. wgl), define these now.... */
141#ifdef WINDOWS
142 {
143 wglGetExtensionsStringEXTFunc_t wglGetExtensionsStringEXT = NULL;
144 wglChoosePixelFormatFunc_t wglChoosePixelFormatEXT = NULL;
145 wglGetPixelFormatAttribivEXTFunc_t wglGetPixelFormatAttribivEXT = NULL;
146 wglGetPixelFormatAttribfvEXTFunc_t wglGetPixelFormatAttribfvEXT = NULL;
147 if (!crStrcmp( name, "wglGetExtensionsStringEXT" )) return (CR_PROC) wglGetExtensionsStringEXT;
148 if (!crStrcmp( name, "wglChoosePixelFormatEXT" )) return (CR_PROC) wglChoosePixelFormatEXT;
149 if (!crStrcmp( name, "wglGetPixelFormatAttribivEXT" )) return (CR_PROC) wglGetPixelFormatAttribivEXT;
150 if (!crStrcmp( name, "wglGetPixelFormatAttribfvEXT" )) return (CR_PROC) wglGetPixelFormatAttribfvEXT;
151 }
152#endif
153"""
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