VirtualBox

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

Last change on this file since 42499 was 42499, checked in by vboxsync, 12 years ago

crOgl/wddm: per-context connections

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