VirtualBox

source: vbox/trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_getstring.c@ 38113

最後變更 在這個檔案從38113是 37830,由 vboxsync 提交於 13 年 前

crogl: fix wine filtering for wddm WoW64

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Id
檔案大小: 4.9 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#include "packspu.h"
8#include "cr_packfunctions.h"
9#include "state/cr_statefuncs.h"
10#include "cr_string.h"
11#include "packspu_proto.h"
12#include "cr_mem.h"
13#include <locale.h>
14
15static GLubyte gpszExtensions[10000];
16#ifdef CR_OPENGL_VERSION_2_0
17static GLubyte gpszShadingVersion[255]="";
18#endif
19
20static void GetString(GLenum name, GLubyte *pszStr)
21{
22 GET_THREAD(thread);
23 int writeback = 1;
24
25 if (pack_spu.swap)
26 crPackGetStringSWAP(name, pszStr, &writeback);
27 else
28 crPackGetString(name, pszStr, &writeback);
29 packspuFlush( (void *) thread );
30
31 while (writeback)
32 crNetRecv();
33}
34
35static GLfloat
36GetVersionString(void)
37{
38 GLubyte return_value[100];
39 GLfloat version;
40
41 GetString(GL_VERSION, return_value);
42 CRASSERT(crStrlen((char *)return_value) < 100);
43
44 version = crStrToFloat((char *) return_value);
45 version = crStateComputeVersion(version);
46
47 return version;
48}
49
50static const GLubyte *
51GetExtensions(void)
52{
53 GLubyte return_value[10*1000];
54 const GLubyte *extensions, *ext;
55 GET_THREAD(thread);
56 int writeback = 1;
57
58 if (pack_spu.swap)
59 {
60 crPackGetStringSWAP( GL_EXTENSIONS, return_value, &writeback );
61 }
62 else
63 {
64 crPackGetString( GL_EXTENSIONS, return_value, &writeback );
65 }
66 packspuFlush( (void *) thread );
67
68 while (writeback)
69 crNetRecv();
70
71 CRASSERT(crStrlen((char *)return_value) < 10*1000);
72
73 /* OK, we got the result from the server. Now we have to
74 * intersect is with the set of extensions that Chromium understands
75 * and tack on the Chromium-specific extensions.
76 */
77 extensions = return_value;
78 ext = crStateMergeExtensions(1, &extensions);
79
80#ifdef Linux
81 /*@todo
82 *That's a hack to allow running Unity, it uses libnux which is calling extension functions
83 *without checking if it's being supported/exported.
84 *glActiveStencilFaceEXT seems to be actually supported but the extension string isn't exported (for ex. on ATI HD4870),
85 *which leads to libglew setting function pointer to NULL and crashing Unity.
86 */
87 sprintf((char*)gpszExtensions, "%s GL_EXT_stencil_two_side", ext);
88#else
89 sprintf((char*)gpszExtensions, "%s", ext);
90#endif
91
92 return gpszExtensions;
93}
94
95#ifdef WINDOWS
96static bool packspuRunningUnderWine(void)
97{
98 return NULL != GetModuleHandle("wined3d.dll") || NULL != GetModuleHandle("wined3dwddm.dll") || NULL != GetModuleHandle("wined3dwddm-x86.dll");
99}
100#endif
101
102const GLubyte * PACKSPU_APIENTRY packspu_GetString( GLenum name )
103{
104 GET_CONTEXT(ctx);
105
106 switch(name)
107 {
108 case GL_EXTENSIONS:
109 return GetExtensions();
110 case GL_VERSION:
111#if 0 && defined(WINDOWS)
112 if (packspuRunningUnderWine())
113 {
114 GetString(GL_REAL_VERSION, ctx->pszRealVersion);
115 return ctx->pszRealVersion;
116 }
117 else
118#endif
119 {
120 char *oldlocale;
121 float version;
122
123 oldlocale = setlocale(LC_NUMERIC, NULL);
124 oldlocale = crStrdup(oldlocale);
125 setlocale(LC_NUMERIC, "C");
126
127 version = GetVersionString();
128 sprintf((char*)ctx->glVersion, "%.1f Chromium %s", version, CR_VERSION_STRING);
129
130 if (oldlocale)
131 {
132 setlocale(LC_NUMERIC, oldlocale);
133 crFree(oldlocale);
134 }
135
136 return ctx->glVersion;
137 }
138 case GL_VENDOR:
139#ifdef WINDOWS
140 if (packspuRunningUnderWine())
141 {
142 GetString(GL_REAL_VENDOR, ctx->pszRealVendor);
143 return ctx->pszRealVendor;
144 }
145 else
146#endif
147 {
148 return crStateGetString(name);
149 }
150 case GL_RENDERER:
151#ifdef WINDOWS
152 if (packspuRunningUnderWine())
153 {
154 GetString(GL_REAL_RENDERER, ctx->pszRealRenderer);
155 return ctx->pszRealRenderer;
156 }
157 else
158#endif
159 {
160 return crStateGetString(name);
161 }
162
163#ifdef CR_OPENGL_VERSION_2_0
164 case GL_SHADING_LANGUAGE_VERSION:
165 GetString(GL_SHADING_LANGUAGE_VERSION, gpszShadingVersion);
166 return gpszShadingVersion;
167#endif
168#ifdef GL_CR_real_vendor_strings
169 case GL_REAL_VENDOR:
170 GetString(GL_REAL_VENDOR, ctx->pszRealVendor);
171 return ctx->pszRealVendor;
172 case GL_REAL_VERSION:
173 GetString(GL_REAL_VERSION, ctx->pszRealVersion);
174 return ctx->pszRealVersion;
175 case GL_REAL_RENDERER:
176 GetString(GL_REAL_RENDERER, ctx->pszRealRenderer);
177 return ctx->pszRealRenderer;
178#endif
179 default:
180 return crStateGetString(name);
181 }
182}
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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