VirtualBox

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

Last change on this file since 20509 was 20468, checked in by vboxsync, 15 years ago

crOpenGL: temp debugging hack to enable certain extensions on guest side

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 4.3 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
13static GLubyte gpszExtensions[10000];
14#ifdef CR_OPENGL_VERSION_2_0
15static GLubyte gpszShadingVersion[255]="";
16#endif
17
18static const GLubyte *
19GetExtensions(void)
20{
21 GLubyte return_value[10*1000];
22 const GLubyte *extensions, *ext;
23 GET_THREAD(thread);
24 int writeback = 1;
25
26 if (pack_spu.swap)
27 {
28 crPackGetStringSWAP( GL_EXTENSIONS, return_value, &writeback );
29 }
30 else
31 {
32 crPackGetString( GL_EXTENSIONS, return_value, &writeback );
33 }
34 packspuFlush( (void *) thread );
35
36 while (writeback)
37 crNetRecv();
38
39 CRASSERT(crStrlen((char *)return_value) < 10*1000);
40
41 /* OK, we got the result from the server. Now we have to
42 * intersect is with the set of extensions that Chromium understands
43 * and tack on the Chromium-specific extensions.
44 */
45 extensions = return_value;
46 ext = crStateMergeExtensions(1, &extensions);
47
48#ifdef CR_OPENGL_VERSION_2_0
49 /* @todo, check if host supports opengl 2.0 or this extension
50 * before exporting it.
51 */
52 sprintf(gpszExtensions, "%sGL_ARB_shading_language_100 GL_ARB_shader_objects GL_ARB_vertex_shader GL_ARB_fragment_shader", ext);
53#else
54 sprintf(gpszExtensions, "%s", ext);
55#endif
56
57 return gpszExtensions;
58}
59
60static void GetString(GLenum name, char *pszStr)
61{
62 GET_THREAD(thread);
63 int writeback = 1;
64
65 if (pack_spu.swap)
66 crPackGetStringSWAP(name, pszStr, &writeback);
67 else
68 crPackGetString(name, pszStr, &writeback);
69 packspuFlush( (void *) thread );
70
71 while (writeback)
72 crNetRecv();
73}
74
75static GLfloat
76GetVersionString(void)
77{
78 GLubyte return_value[100];
79 int writeback = 1;
80 GLfloat version;
81
82 GetString(GL_VERSION, return_value);
83 CRASSERT(crStrlen((char *)return_value) < 100);
84
85 version = crStrToFloat((char *) return_value);
86 version = crStateComputeVersion(version);
87
88 return version;
89}
90
91#ifdef WINDOWS
92static bool packspuRunningUnderWine(void)
93{
94 return NULL != GetModuleHandle("wined3d.dll");
95}
96#endif
97
98const GLubyte * PACKSPU_APIENTRY packspu_GetString( GLenum name )
99{
100 GET_CONTEXT(ctx);
101
102 switch(name)
103 {
104 case GL_EXTENSIONS:
105 return GetExtensions();
106 case GL_VERSION:
107#ifdef WINDOWS
108 if (packspuRunningUnderWine())
109 {
110 GetString(GL_REAL_VERSION, ctx->pszRealVersion);
111 return (const GLubyte*) ctx->pszRealVersion;
112 }
113 else
114#endif
115 {
116 float version = GetVersionString();
117 sprintf(ctx->glVersion, "%.1f Chromium %s", version, CR_VERSION_STRING);
118 return (const GLubyte *) ctx->glVersion;
119 }
120 case GL_VENDOR:
121#ifdef WINDOWS
122 if (packspuRunningUnderWine())
123 {
124 GetString(GL_REAL_VENDOR, ctx->pszRealVendor);
125 return (const GLubyte*) ctx->pszRealVendor;
126 }
127 else
128#endif
129 {
130 return crStateGetString(name);
131 }
132 case GL_RENDERER:
133#ifdef WINDOWS
134 if (packspuRunningUnderWine())
135 {
136 GetString(GL_REAL_RENDERER, ctx->pszRealRenderer);
137 return (const GLubyte*) ctx->pszRealRenderer;
138 }
139 else
140#endif
141 {
142 return crStateGetString(name);
143 }
144
145#ifdef CR_OPENGL_VERSION_2_0
146 case GL_SHADING_LANGUAGE_VERSION:
147 GetString(GL_SHADING_LANGUAGE_VERSION, gpszShadingVersion);
148 return gpszShadingVersion;
149#endif
150#ifdef GL_CR_real_vendor_strings
151 case GL_REAL_VENDOR:
152 GetString(GL_REAL_VENDOR, ctx->pszRealVendor);
153 return (const GLubyte*) ctx->pszRealVendor;
154 case GL_REAL_VERSION:
155 GetString(GL_REAL_VERSION, ctx->pszRealVersion);
156 return (const GLubyte*) ctx->pszRealVersion;
157 case GL_REAL_RENDERER:
158 GetString(GL_REAL_RENDERER, ctx->pszRealRenderer);
159 return (const GLubyte*) ctx->pszRealRenderer;
160#endif
161 default:
162 return crStateGetString(name);
163 }
164}
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