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 void GetString(GLenum name, GLubyte *pszStr)
|
---|
19 | {
|
---|
20 | GET_THREAD(thread);
|
---|
21 | int writeback = 1;
|
---|
22 |
|
---|
23 | if (pack_spu.swap)
|
---|
24 | crPackGetStringSWAP(name, pszStr, &writeback);
|
---|
25 | else
|
---|
26 | crPackGetString(name, pszStr, &writeback);
|
---|
27 | packspuFlush( (void *) thread );
|
---|
28 |
|
---|
29 | while (writeback)
|
---|
30 | crNetRecv();
|
---|
31 | }
|
---|
32 |
|
---|
33 | static GLfloat
|
---|
34 | GetVersionString(void)
|
---|
35 | {
|
---|
36 | GLubyte return_value[100];
|
---|
37 | GLfloat version;
|
---|
38 |
|
---|
39 | GetString(GL_VERSION, return_value);
|
---|
40 | CRASSERT(crStrlen((char *)return_value) < 100);
|
---|
41 |
|
---|
42 | version = crStrToFloat((char *) return_value);
|
---|
43 | version = crStateComputeVersion(version);
|
---|
44 |
|
---|
45 | return version;
|
---|
46 | }
|
---|
47 |
|
---|
48 | static const GLubyte *
|
---|
49 | GetExtensions(void)
|
---|
50 | {
|
---|
51 | GLubyte return_value[10*1000];
|
---|
52 | const GLubyte *extensions, *ext;
|
---|
53 | GET_THREAD(thread);
|
---|
54 | int writeback = 1;
|
---|
55 |
|
---|
56 | if (pack_spu.swap)
|
---|
57 | {
|
---|
58 | crPackGetStringSWAP( GL_EXTENSIONS, return_value, &writeback );
|
---|
59 | }
|
---|
60 | else
|
---|
61 | {
|
---|
62 | crPackGetString( GL_EXTENSIONS, return_value, &writeback );
|
---|
63 | }
|
---|
64 | packspuFlush( (void *) thread );
|
---|
65 |
|
---|
66 | while (writeback)
|
---|
67 | crNetRecv();
|
---|
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 CR_OPENGL_VERSION_2_0
|
---|
79 | /* @todo move to known extensions etc, for now just a hack.
|
---|
80 | */
|
---|
81 | {
|
---|
82 | GLfloat fversion = GetVersionString();
|
---|
83 | if (fversion>=2.f)
|
---|
84 | {
|
---|
85 | sprintf((char*)gpszExtensions, "%sGL_ARB_shading_language_100 GL_ARB_shader_objects GL_ARB_vertex_shader GL_ARB_fragment_shader GL_EXT_texture_compression_s3tc GL_EXT_draw_range_elements", ext);
|
---|
86 | }
|
---|
87 | }
|
---|
88 | #else
|
---|
89 | sprintf(gpszExtensions, "%s", ext);
|
---|
90 | #endif
|
---|
91 |
|
---|
92 | return gpszExtensions;
|
---|
93 | }
|
---|
94 |
|
---|
95 | #ifdef WINDOWS
|
---|
96 | static bool packspuRunningUnderWine(void)
|
---|
97 | {
|
---|
98 | return NULL != GetModuleHandle("wined3d.dll");
|
---|
99 | }
|
---|
100 | #endif
|
---|
101 |
|
---|
102 | const 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 | #ifdef WINDOWS
|
---|
112 | if (packspuRunningUnderWine())
|
---|
113 | {
|
---|
114 | GetString(GL_REAL_VERSION, ctx->pszRealVersion);
|
---|
115 | return ctx->pszRealVersion;
|
---|
116 | }
|
---|
117 | else
|
---|
118 | #endif
|
---|
119 | {
|
---|
120 | float version = GetVersionString();
|
---|
121 | sprintf((char*)ctx->glVersion, "%.1f Chromium %s", version, CR_VERSION_STRING);
|
---|
122 | return ctx->glVersion;
|
---|
123 | }
|
---|
124 | case GL_VENDOR:
|
---|
125 | #ifdef WINDOWS
|
---|
126 | if (packspuRunningUnderWine())
|
---|
127 | {
|
---|
128 | GetString(GL_REAL_VENDOR, ctx->pszRealVendor);
|
---|
129 | return ctx->pszRealVendor;
|
---|
130 | }
|
---|
131 | else
|
---|
132 | #endif
|
---|
133 | {
|
---|
134 | return crStateGetString(name);
|
---|
135 | }
|
---|
136 | case GL_RENDERER:
|
---|
137 | #ifdef WINDOWS
|
---|
138 | if (packspuRunningUnderWine())
|
---|
139 | {
|
---|
140 | GetString(GL_REAL_RENDERER, ctx->pszRealRenderer);
|
---|
141 | return ctx->pszRealRenderer;
|
---|
142 | }
|
---|
143 | else
|
---|
144 | #endif
|
---|
145 | {
|
---|
146 | return crStateGetString(name);
|
---|
147 | }
|
---|
148 |
|
---|
149 | #ifdef CR_OPENGL_VERSION_2_0
|
---|
150 | case GL_SHADING_LANGUAGE_VERSION:
|
---|
151 | GetString(GL_SHADING_LANGUAGE_VERSION, gpszShadingVersion);
|
---|
152 | return gpszShadingVersion;
|
---|
153 | #endif
|
---|
154 | #ifdef GL_CR_real_vendor_strings
|
---|
155 | case GL_REAL_VENDOR:
|
---|
156 | GetString(GL_REAL_VENDOR, ctx->pszRealVendor);
|
---|
157 | return ctx->pszRealVendor;
|
---|
158 | case GL_REAL_VERSION:
|
---|
159 | GetString(GL_REAL_VERSION, ctx->pszRealVersion);
|
---|
160 | return ctx->pszRealVersion;
|
---|
161 | case GL_REAL_RENDERER:
|
---|
162 | GetString(GL_REAL_RENDERER, ctx->pszRealRenderer);
|
---|
163 | return ctx->pszRealRenderer;
|
---|
164 | #endif
|
---|
165 | default:
|
---|
166 | return crStateGetString(name);
|
---|
167 | }
|
---|
168 | }
|
---|