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 |
|
---|
13 | static GLubyte gpszExtensions[10000];
|
---|
14 | #ifdef CR_OPENGL_VERSION_2_0
|
---|
15 | static GLubyte gpszShadingVersion[255]="";
|
---|
16 | #endif
|
---|
17 |
|
---|
18 | static const GLubyte *
|
---|
19 | GetExtensions(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 | /* This extension is a core part of opengl 2.0, yet
|
---|
50 | * some apps (like glview) request us to have this extension.
|
---|
51 | * @todo, check if host supports opengl 2.0 or this extension
|
---|
52 | * before exporting it.
|
---|
53 | */
|
---|
54 | sprintf(gpszExtensions, "%s GL_ARB_shading_language_100", ext);
|
---|
55 | #else
|
---|
56 | sprintf(gpszExtensions, "%s", ext);
|
---|
57 | #endif
|
---|
58 |
|
---|
59 | return gpszExtensions;
|
---|
60 | }
|
---|
61 |
|
---|
62 | static void GetString(GLenum name, char *pszStr)
|
---|
63 | {
|
---|
64 | GET_THREAD(thread);
|
---|
65 | int writeback = 1;
|
---|
66 |
|
---|
67 | if (pack_spu.swap)
|
---|
68 | crPackGetStringSWAP(name, pszStr, &writeback);
|
---|
69 | else
|
---|
70 | crPackGetString(name, pszStr, &writeback);
|
---|
71 | packspuFlush( (void *) thread );
|
---|
72 |
|
---|
73 | while (writeback)
|
---|
74 | crNetRecv();
|
---|
75 | }
|
---|
76 |
|
---|
77 | static GLfloat
|
---|
78 | GetVersionString(void)
|
---|
79 | {
|
---|
80 | GLubyte return_value[100];
|
---|
81 | int writeback = 1;
|
---|
82 | GLfloat version;
|
---|
83 |
|
---|
84 | GetString(GL_VERSION, return_value);
|
---|
85 | CRASSERT(crStrlen((char *)return_value) < 100);
|
---|
86 |
|
---|
87 | version = crStrToFloat((char *) return_value);
|
---|
88 | version = crStateComputeVersion(version);
|
---|
89 |
|
---|
90 | return version;
|
---|
91 | }
|
---|
92 |
|
---|
93 | #ifdef WINDOWS
|
---|
94 | static bool packspuRunningUnderWine(void)
|
---|
95 | {
|
---|
96 | return NULL != GetModuleHandle("wined3d.dll");
|
---|
97 | }
|
---|
98 | #endif
|
---|
99 |
|
---|
100 | const 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 | #ifdef WINDOWS
|
---|
110 | if (packspuRunningUnderWine())
|
---|
111 | {
|
---|
112 | GetString(GL_REAL_VERSION, ctx->pszRealVersion);
|
---|
113 | return (const GLubyte*) ctx->pszRealVersion;
|
---|
114 | }
|
---|
115 | else
|
---|
116 | #endif
|
---|
117 | {
|
---|
118 | float version = GetVersionString();
|
---|
119 | sprintf(ctx->glVersion, "%.1f Chromium %s", version, CR_VERSION_STRING);
|
---|
120 | return (const GLubyte *) ctx->glVersion;
|
---|
121 | }
|
---|
122 | case GL_VENDOR:
|
---|
123 | #ifdef WINDOWS
|
---|
124 | if (packspuRunningUnderWine())
|
---|
125 | {
|
---|
126 | GetString(GL_REAL_VENDOR, ctx->pszRealVendor);
|
---|
127 | return (const GLubyte*) ctx->pszRealVendor;
|
---|
128 | }
|
---|
129 | else
|
---|
130 | #endif
|
---|
131 | {
|
---|
132 | return crStateGetString(name);
|
---|
133 | }
|
---|
134 | case GL_RENDERER:
|
---|
135 | #ifdef WINDOWS
|
---|
136 | if (packspuRunningUnderWine())
|
---|
137 | {
|
---|
138 | GetString(GL_REAL_RENDERER, ctx->pszRealRenderer);
|
---|
139 | return (const GLubyte*) ctx->pszRealRenderer;
|
---|
140 | }
|
---|
141 | else
|
---|
142 | #endif
|
---|
143 | {
|
---|
144 | return crStateGetString(name);
|
---|
145 | }
|
---|
146 |
|
---|
147 | #ifdef CR_OPENGL_VERSION_2_0
|
---|
148 | case GL_SHADING_LANGUAGE_VERSION:
|
---|
149 | GetString(GL_SHADING_LANGUAGE_VERSION, gpszShadingVersion);
|
---|
150 | return gpszShadingVersion;
|
---|
151 | #endif
|
---|
152 | #ifdef GL_CR_real_vendor_strings
|
---|
153 | case GL_REAL_VENDOR:
|
---|
154 | GetString(GL_REAL_VENDOR, ctx->pszRealVendor);
|
---|
155 | return (const GLubyte*) ctx->pszRealVendor;
|
---|
156 | case GL_REAL_VERSION:
|
---|
157 | GetString(GL_REAL_VERSION, ctx->pszRealVersion);
|
---|
158 | return (const GLubyte*) ctx->pszRealVersion;
|
---|
159 | case GL_REAL_RENDERER:
|
---|
160 | GetString(GL_REAL_RENDERER, ctx->pszRealRenderer);
|
---|
161 | return (const GLubyte*) ctx->pszRealRenderer;
|
---|
162 | #endif
|
---|
163 | default:
|
---|
164 | return crStateGetString(name);
|
---|
165 | }
|
---|
166 | }
|
---|