1 |
|
---|
2 | /* Copyright (c) 2001, Stanford University
|
---|
3 | * All rights reserved
|
---|
4 | *
|
---|
5 | * See the file LICENSE.txt for information on redistributing this software.
|
---|
6 | */
|
---|
7 |
|
---|
8 | #include <stdio.h>
|
---|
9 | #include "state.h"
|
---|
10 | #include "state/cr_statetypes.h"
|
---|
11 | #include "cr_mem.h"
|
---|
12 | #include "cr_string.h"
|
---|
13 | #include "cr_extstring.h"
|
---|
14 |
|
---|
15 | #ifdef WINDOWS
|
---|
16 | #pragma warning( disable : 4127 )
|
---|
17 | #endif
|
---|
18 |
|
---|
19 |
|
---|
20 | /* This is a debug helper function. */
|
---|
21 | void crStateLimitsPrint (const CRLimitsState *l)
|
---|
22 | {
|
---|
23 | fprintf(stderr, "----------- OpenGL limits ----------------\n");
|
---|
24 | fprintf(stderr, "GL_MAX_TEXTURE_UNITS = %d\n", (int) l->maxTextureUnits);
|
---|
25 | fprintf(stderr, "GL_MAX_TEXTURE_SIZE = %d\n", (int) l->maxTextureSize);
|
---|
26 | fprintf(stderr, "GL_MAX_3D_TEXTURE_SIZE = %d\n", (int) l->max3DTextureSize);
|
---|
27 | fprintf(stderr, "GL_MAX_CUBE_MAP_TEXTURE_SIZE = %d\n", (int) l->maxCubeMapTextureSize);
|
---|
28 | fprintf(stderr, "GL_MAX_TEXTURE_ANISOTROPY = %f\n", l->maxTextureAnisotropy);
|
---|
29 | fprintf(stderr, "GL_MAX_LIGHTS = %d\n", (int) l->maxLights);
|
---|
30 | fprintf(stderr, "GL_MAX_CLIP_PLANES = %d\n", (int) l->maxClipPlanes);
|
---|
31 | fprintf(stderr, "GL_MAX_ATTRIB_STACK_DEPTH = %d\n", (int) l->maxClientAttribStackDepth);
|
---|
32 | fprintf(stderr, "GL_MAX_PROJECTION_STACK_DEPTH = %d\n", (int) l->maxProjectionStackDepth);
|
---|
33 | fprintf(stderr, "GL_MAX_MODELVIEW_STACK_DEPTH = %d\n", (int) l->maxModelviewStackDepth);
|
---|
34 | fprintf(stderr, "GL_MAX_TEXTURE_STACK_DEPTH = %d\n", (int) l->maxTextureStackDepth);
|
---|
35 | fprintf(stderr, "GL_MAX_COLOR_STACK_DEPTH = %d\n", (int) l->maxColorStackDepth);
|
---|
36 | fprintf(stderr, "GL_MAX_ATTRIB_STACK_DEPTH = %d\n", (int) l->maxAttribStackDepth);
|
---|
37 | fprintf(stderr, "GL_MAX_ATTRIB_STACK_DEPTH = %d\n", (int) l->maxClientAttribStackDepth);
|
---|
38 | fprintf(stderr, "GL_MAX_NAME_STACK_DEPTH = %d\n", (int) l->maxNameStackDepth);
|
---|
39 | fprintf(stderr, "GL_MAX_ELEMENTS_INDICES = %d\n", (int) l->maxElementsIndices);
|
---|
40 | fprintf(stderr, "GL_MAX_ELEMENTS_VERTICES = %d\n", (int) l->maxElementsVertices);
|
---|
41 | fprintf(stderr, "GL_MAX_EVAL_ORDER = %d\n", (int) l->maxEvalOrder);
|
---|
42 | fprintf(stderr, "GL_MAX_LIST_NESTING = %d\n", (int) l->maxListNesting);
|
---|
43 | fprintf(stderr, "GL_MAX_PIXEL_MAP_TABLE = %d\n", (int) l->maxPixelMapTable);
|
---|
44 | fprintf(stderr, "GL_MAX_VIEWPORT_DIMS = %d %d\n",
|
---|
45 | (int) l->maxViewportDims[0], (int) l->maxViewportDims[1]);
|
---|
46 | fprintf(stderr, "GL_SUBPIXEL_BITS = %d\n", (int) l->subpixelBits);
|
---|
47 | fprintf(stderr, "GL_ALIASED_POINT_SIZE_RANGE = %f .. %f\n",
|
---|
48 | l->aliasedPointSizeRange[0], l->aliasedPointSizeRange[1]);
|
---|
49 | fprintf(stderr, "GL_SMOOTH_POINT_SIZE_RANGE = %f .. %f\n",
|
---|
50 | l->aliasedPointSizeRange[0], l->aliasedPointSizeRange[1]);
|
---|
51 | fprintf(stderr, "GL_POINT_SIZE_GRANULARITY = %f\n", l->pointSizeGranularity);
|
---|
52 | fprintf(stderr, "GL_ALIASED_LINE_WIDTH_RANGE = %f .. %f\n",
|
---|
53 | l->aliasedLineWidthRange[0], l->aliasedLineWidthRange[1]);
|
---|
54 | fprintf(stderr, "GL_SMOOTH_LINE_WIDTH_RANGE = %f .. %f\n",
|
---|
55 | l->smoothLineWidthRange[0], l->smoothLineWidthRange[1]);
|
---|
56 | fprintf(stderr, "GL_LINE_WIDTH_GRANULARITY = %f\n", l->lineWidthGranularity);
|
---|
57 | fprintf(stderr, "GL_MAX_GENERAL_COMBINERS_NV = %d\n", (int) l->maxGeneralCombiners);
|
---|
58 | fprintf(stderr, "GL_EXTENSIONS = %s\n", (const char *) l->extensions);
|
---|
59 | fprintf(stderr, "------------------------------------------\n");
|
---|
60 | }
|
---|
61 |
|
---|
62 |
|
---|
63 | void crStateLimitsDestroy(CRLimitsState *l)
|
---|
64 | {
|
---|
65 | if (l->extensions) {
|
---|
66 | crFree((void *) l->extensions);
|
---|
67 | l->extensions = NULL;
|
---|
68 | }
|
---|
69 | }
|
---|
70 |
|
---|
71 |
|
---|
72 | /*
|
---|
73 | * Initialize the CRLimitsState object to Chromium's defaults.
|
---|
74 | */
|
---|
75 | void crStateLimitsInit (CRLimitsState *l)
|
---|
76 | {
|
---|
77 | l->maxTextureUnits = CR_MAX_TEXTURE_UNITS;
|
---|
78 | l->maxTextureSize = CR_MAX_TEXTURE_SIZE;
|
---|
79 | l->max3DTextureSize = CR_MAX_3D_TEXTURE_SIZE;
|
---|
80 | l->maxCubeMapTextureSize = CR_MAX_CUBE_TEXTURE_SIZE;
|
---|
81 | #ifdef CR_NV_texture_rectangle
|
---|
82 | l->maxRectTextureSize = CR_MAX_RECTANGLE_TEXTURE_SIZE;
|
---|
83 | #endif
|
---|
84 | l->maxTextureAnisotropy = CR_MAX_TEXTURE_ANISOTROPY;
|
---|
85 | l->maxGeneralCombiners = CR_MAX_GENERAL_COMBINERS;
|
---|
86 | l->maxLights = CR_MAX_LIGHTS;
|
---|
87 | l->maxClipPlanes = CR_MAX_CLIP_PLANES;
|
---|
88 | l->maxClientAttribStackDepth = CR_MAX_ATTRIB_STACK_DEPTH;
|
---|
89 | l->maxProjectionStackDepth = CR_MAX_PROJECTION_STACK_DEPTH;
|
---|
90 | l->maxModelviewStackDepth = CR_MAX_MODELVIEW_STACK_DEPTH;
|
---|
91 | l->maxTextureStackDepth = CR_MAX_TEXTURE_STACK_DEPTH;
|
---|
92 | l->maxColorStackDepth = CR_MAX_COLOR_STACK_DEPTH;
|
---|
93 | l->maxAttribStackDepth = CR_MAX_ATTRIB_STACK_DEPTH;
|
---|
94 | l->maxClientAttribStackDepth = CR_MAX_ATTRIB_STACK_DEPTH;
|
---|
95 | l->maxNameStackDepth = CR_MAX_NAME_STACK_DEPTH;
|
---|
96 | l->maxElementsIndices = CR_MAX_ELEMENTS_INDICES;
|
---|
97 | l->maxElementsVertices = CR_MAX_ELEMENTS_VERTICES;
|
---|
98 | l->maxEvalOrder = CR_MAX_EVAL_ORDER;
|
---|
99 | l->maxListNesting = CR_MAX_LIST_NESTING;
|
---|
100 | l->maxPixelMapTable = CR_MAX_PIXEL_MAP_TABLE;
|
---|
101 | l->maxViewportDims[0] = l->maxViewportDims[1] = CR_MAX_VIEWPORT_DIM;
|
---|
102 | l->subpixelBits = CR_SUBPIXEL_BITS;
|
---|
103 | l->aliasedPointSizeRange[0] = CR_ALIASED_POINT_SIZE_MIN;
|
---|
104 | l->aliasedPointSizeRange[1] = CR_ALIASED_POINT_SIZE_MAX;
|
---|
105 | l->smoothPointSizeRange[0] = CR_SMOOTH_POINT_SIZE_MIN;
|
---|
106 | l->smoothPointSizeRange[1] = CR_SMOOTH_POINT_SIZE_MAX;
|
---|
107 | l->pointSizeGranularity = CR_POINT_SIZE_GRANULARITY;
|
---|
108 | l->aliasedLineWidthRange[0] = CR_ALIASED_LINE_WIDTH_MIN;
|
---|
109 | l->aliasedLineWidthRange[1] = CR_ALIASED_LINE_WIDTH_MAX;
|
---|
110 | l->smoothLineWidthRange[0] = CR_SMOOTH_LINE_WIDTH_MIN;
|
---|
111 | l->smoothLineWidthRange[1] = CR_SMOOTH_LINE_WIDTH_MAX;
|
---|
112 | l->lineWidthGranularity = CR_LINE_WIDTH_GRANULARITY;
|
---|
113 | #ifdef CR_EXT_texture_lod_bias
|
---|
114 | l->maxTextureLodBias = CR_MAX_TEXTURE_LOD_BIAS;
|
---|
115 | #endif
|
---|
116 | #ifdef CR_NV_fragment_program
|
---|
117 | l->maxTextureCoords = CR_MAX_TEXTURE_COORDS;
|
---|
118 | l->maxTextureImageUnits = CR_MAX_TEXTURE_IMAGE_UNITS;
|
---|
119 | l->maxFragmentProgramLocalParams = CR_MAX_FRAGMENT_LOCAL_PARAMS;
|
---|
120 | #endif
|
---|
121 | #ifdef CR_NV_vertex_program
|
---|
122 | l->maxProgramMatrixStackDepth = CR_MAX_PROGRAM_MATRIX_STACK_DEPTH;
|
---|
123 | l->maxProgramMatrices = CR_MAX_PROGRAM_MATRICES;
|
---|
124 | #endif
|
---|
125 | #ifdef CR_ARB_fragment_program
|
---|
126 | l->maxFragmentProgramInstructions = CR_MAX_FRAGMENT_PROGRAM_INSTRUCTIONS;
|
---|
127 | l->maxFragmentProgramLocalParams = CR_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMS;
|
---|
128 | l->maxFragmentProgramEnvParams = CR_MAX_FRAGMENT_PROGRAM_ENV_PARAMS;
|
---|
129 | l->maxFragmentProgramTemps = CR_MAX_FRAGMENT_PROGRAM_TEMPS;
|
---|
130 | l->maxFragmentProgramAttribs = CR_MAX_FRAGMENT_PROGRAM_ATTRIBS;
|
---|
131 | l->maxFragmentProgramAddressRegs = CR_MAX_FRAGMENT_PROGRAM_ADDRESS_REGS;
|
---|
132 | l->maxFragmentProgramAluInstructions = CR_MAX_FRAGMENT_PROGRAM_ALU_INSTRUCTIONS;
|
---|
133 | l->maxFragmentProgramTexInstructions = CR_MAX_FRAGMENT_PROGRAM_TEX_INSTRUCTIONS;
|
---|
134 | l->maxFragmentProgramTexIndirections = CR_MAX_FRAGMENT_PROGRAM_TEX_INDIRECTIONS;
|
---|
135 | #endif
|
---|
136 | #ifdef CR_ARB_vertex_program
|
---|
137 | l->maxVertexProgramInstructions = CR_MAX_VERTEX_PROGRAM_INSTRUCTIONS;
|
---|
138 | l->maxVertexProgramLocalParams = CR_MAX_VERTEX_PROGRAM_LOCAL_PARAMS;
|
---|
139 | l->maxVertexProgramEnvParams = CR_MAX_VERTEX_PROGRAM_ENV_PARAMS;
|
---|
140 | l->maxVertexProgramTemps = CR_MAX_VERTEX_PROGRAM_TEMPS;
|
---|
141 | l->maxVertexProgramAttribs = CR_MAX_VERTEX_PROGRAM_ATTRIBS;
|
---|
142 | l->maxVertexProgramAddressRegs = CR_MAX_VERTEX_PROGRAM_ADDRESS_REGS;
|
---|
143 | #endif
|
---|
144 |
|
---|
145 | l->extensions = (GLubyte *) crStrdup(crExtensions);
|
---|
146 |
|
---|
147 | /* These will get properly set in crStateCreateContext() by examining
|
---|
148 | * the visBits bitfield parameter.
|
---|
149 | */
|
---|
150 | l->redBits = 0;
|
---|
151 | l->greenBits = 0;
|
---|
152 | l->blueBits = 0;
|
---|
153 | l->alphaBits = 0;
|
---|
154 | l->depthBits = 0;
|
---|
155 | l->stencilBits = 0;
|
---|
156 | l->accumRedBits = 0;
|
---|
157 | l->accumGreenBits = 0;
|
---|
158 | l->accumBlueBits = 0;
|
---|
159 | l->accumAlphaBits = 0;
|
---|
160 | l->auxBuffers = 0;
|
---|
161 | l->rgbaMode = GL_TRUE;
|
---|
162 | l->doubleBuffer = GL_FALSE;
|
---|
163 | l->stereo = GL_FALSE;
|
---|
164 | l->sampleBuffers = 0;
|
---|
165 | l->samples = 0;
|
---|
166 | l->level = 0;
|
---|
167 |
|
---|
168 | (void) crAppOnlyExtensions; /* silence warning */
|
---|
169 | }
|
---|
170 |
|
---|
171 |
|
---|
172 | /*
|
---|
173 | * Given the GL version number returned from a real GL renderer,
|
---|
174 | * compute the version number supported by Chromium.
|
---|
175 | */
|
---|
176 | void crStateComputeVersion(uint32_t *puMajorMin, uint32_t *puMinorMin)
|
---|
177 | {
|
---|
178 | if (*puMajorMin > CR_OPENGL_VERSION_MAJOR)
|
---|
179 | {
|
---|
180 | *puMajorMin = CR_OPENGL_VERSION_MAJOR;
|
---|
181 | *puMinorMin = CR_OPENGL_VERSION_MINOR;
|
---|
182 | return;
|
---|
183 | }
|
---|
184 |
|
---|
185 | if (*puMinorMin > CR_OPENGL_VERSION_MINOR)
|
---|
186 | *puMinorMin = CR_OPENGL_VERSION_MINOR;
|
---|
187 |
|
---|
188 | return;
|
---|
189 | }
|
---|
190 |
|
---|
191 |
|
---|
192 | /*
|
---|
193 | * <extenions> is an array [n] of GLubyte pointers which contain lists of
|
---|
194 | * OpenGL extensions.
|
---|
195 | * Compute the intersection of those strings, then append the Chromium
|
---|
196 | * extension strings.
|
---|
197 | */
|
---|
198 | GLubyte * crStateMergeExtensions(GLuint n, const GLubyte **extensions)
|
---|
199 | {
|
---|
200 | char *merged, *result;
|
---|
201 | GLuint i;
|
---|
202 |
|
---|
203 | /* find intersection of all extension strings */
|
---|
204 | merged = crStrdup(crExtensions);
|
---|
205 | for (i = 0; i < n; i++)
|
---|
206 | {
|
---|
207 | char *m = crStrIntersect(merged, (const char *) extensions[i]);
|
---|
208 | if (merged)
|
---|
209 | crFree(merged);
|
---|
210 | merged = m;
|
---|
211 | }
|
---|
212 |
|
---|
213 | /* append Cr extensions */
|
---|
214 | result = crStrjoin(merged, crChromiumExtensions);
|
---|
215 | crFree(merged);
|
---|
216 | return (GLubyte *) result;
|
---|
217 | }
|
---|
218 |
|
---|
219 | static GLboolean hasExtension(const char *haystack, const char *needle)
|
---|
220 | {
|
---|
221 | const int needleLen = crStrlen(needle);
|
---|
222 | const char *s;
|
---|
223 |
|
---|
224 | while (1) {
|
---|
225 | s = crStrstr(haystack, needle);
|
---|
226 | if (!s)
|
---|
227 | return GL_FALSE;
|
---|
228 | if (s && (s[needleLen] == ' ' || s[needleLen] == 0))
|
---|
229 | return GL_TRUE;
|
---|
230 | haystack += needleLen;
|
---|
231 | }
|
---|
232 | }
|
---|
233 |
|
---|
234 | /*
|
---|
235 | * Examine the context's extension string and set the boolean extension
|
---|
236 | * flags accordingly. This is to be called during context initialization.
|
---|
237 | */
|
---|
238 | void crStateExtensionsInit( CRLimitsState *limits, CRExtensionState *extensions )
|
---|
239 | {
|
---|
240 | /* init all booleans to false */
|
---|
241 | crMemZero(extensions, sizeof(CRExtensionState));
|
---|
242 |
|
---|
243 | if (hasExtension((const char*)limits->extensions, "GL_ARB_depth_texture"))
|
---|
244 | extensions->ARB_depth_texture = GL_TRUE;
|
---|
245 |
|
---|
246 | if (hasExtension((const char*)limits->extensions, "GL_ARB_fragment_program"))
|
---|
247 | extensions->ARB_fragment_program = GL_TRUE;
|
---|
248 |
|
---|
249 | if (hasExtension((const char*)limits->extensions, "GL_ARB_imaging"))
|
---|
250 | extensions->ARB_imaging = GL_TRUE;
|
---|
251 |
|
---|
252 | if (hasExtension((const char*)limits->extensions, "GL_ARB_multisample"))
|
---|
253 | extensions->ARB_multisample = GL_TRUE;
|
---|
254 |
|
---|
255 | if (hasExtension((const char*)limits->extensions, "GL_ARB_multitexture"))
|
---|
256 | extensions->ARB_multitexture = GL_TRUE;
|
---|
257 |
|
---|
258 | if (hasExtension((const char*)limits->extensions, "GL_ARB_occlusion_query"))
|
---|
259 | extensions->ARB_occlusion_query = GL_TRUE;
|
---|
260 |
|
---|
261 | if (hasExtension((const char*)limits->extensions, "GL_ARB_point_parameters"))
|
---|
262 | extensions->ARB_point_parameters = GL_TRUE;
|
---|
263 |
|
---|
264 | if (hasExtension((const char*)limits->extensions, "GL_ARB_point_sprite"))
|
---|
265 | extensions->ARB_point_sprite = GL_TRUE;
|
---|
266 |
|
---|
267 | if (hasExtension((const char*)limits->extensions, "GL_ARB_shadow"))
|
---|
268 | extensions->ARB_shadow = GL_TRUE;
|
---|
269 |
|
---|
270 | if (hasExtension((const char*)limits->extensions, "GL_ARB_shadow_ambient"))
|
---|
271 | extensions->ARB_shadow_ambient = GL_TRUE;
|
---|
272 |
|
---|
273 | if (hasExtension((const char*)limits->extensions, "GL_ARB_texture_border_clamp") ||
|
---|
274 | hasExtension((const char*)limits->extensions, "GL_SGIS_texture_border_clamp"))
|
---|
275 | extensions->ARB_texture_border_clamp = GL_TRUE;
|
---|
276 |
|
---|
277 | if (hasExtension((const char*)limits->extensions, "GL_ARB_texture_compression"))
|
---|
278 | extensions->ARB_texture_compression = GL_TRUE;
|
---|
279 |
|
---|
280 | if (hasExtension((const char*)limits->extensions, "GL_ARB_texture_cube_map") ||
|
---|
281 | hasExtension((const char*)limits->extensions, "GL_EXT_texture_cube_map"))
|
---|
282 | extensions->ARB_texture_cube_map = GL_TRUE;
|
---|
283 |
|
---|
284 | if (hasExtension((const char*)limits->extensions, "GL_ARB_texture_env_add"))
|
---|
285 | extensions->ARB_texture_env_add = GL_TRUE;
|
---|
286 |
|
---|
287 | if (hasExtension((const char*)limits->extensions, "GL_ARB_texture_env_combine") ||
|
---|
288 | hasExtension((const char*)limits->extensions, "GL_EXT_texture_env_combine"))
|
---|
289 | extensions->ARB_texture_env_combine = GL_TRUE;
|
---|
290 |
|
---|
291 | if (hasExtension((const char*)limits->extensions, "GL_ARB_texture_env_crossbar"))
|
---|
292 | extensions->ARB_texture_env_crossbar = GL_TRUE;
|
---|
293 |
|
---|
294 | if (hasExtension((const char*)limits->extensions, "GL_ARB_texture_env_dot3") ||
|
---|
295 | hasExtension((const char*)limits->extensions, "GL_EXT_texture_env_dot3"))
|
---|
296 | extensions->ARB_texture_env_dot3 = GL_TRUE;
|
---|
297 |
|
---|
298 | if (hasExtension((const char*)limits->extensions, "GL_ARB_texture_mirrored_repeat"))
|
---|
299 | extensions->ARB_texture_mirrored_repeat = GL_TRUE;
|
---|
300 |
|
---|
301 | if (hasExtension((const char*)limits->extensions, "GL_ATI_texture_mirror_once"))
|
---|
302 | extensions->ATI_texture_mirror_once = GL_TRUE;
|
---|
303 |
|
---|
304 | if (hasExtension((const char*)limits->extensions, "GL_ARB_texture_non_power_of_two"))
|
---|
305 | extensions->ARB_texture_non_power_of_two = GL_TRUE;
|
---|
306 |
|
---|
307 | if (hasExtension((const char*)limits->extensions, "GL_ARB_transpose_matrix"))
|
---|
308 | extensions->ARB_transpose_matrix = GL_TRUE;
|
---|
309 |
|
---|
310 | if (hasExtension((const char*)limits->extensions, "GL_ARB_vertex_buffer_object"))
|
---|
311 | extensions->ARB_vertex_buffer_object = GL_TRUE;
|
---|
312 |
|
---|
313 | if (hasExtension((const char*)limits->extensions, "GL_ARB_pixel_buffer_object"))
|
---|
314 | extensions->ARB_pixel_buffer_object = GL_TRUE;
|
---|
315 |
|
---|
316 | if (hasExtension((const char*)limits->extensions, "GL_ARB_vertex_program"))
|
---|
317 | extensions->ARB_vertex_program = GL_TRUE;
|
---|
318 |
|
---|
319 | if (hasExtension((const char*)limits->extensions, "GL_ARB_window_pos"))
|
---|
320 | extensions->ARB_window_pos = GL_TRUE;
|
---|
321 |
|
---|
322 | if (hasExtension((const char*)limits->extensions, "GL_EXT_blend_color"))
|
---|
323 | extensions->EXT_blend_color= GL_TRUE;
|
---|
324 |
|
---|
325 | if (hasExtension((const char*)limits->extensions, "GL_EXT_blend_minmax"))
|
---|
326 | extensions->EXT_blend_minmax = GL_TRUE;
|
---|
327 |
|
---|
328 | if (hasExtension((const char*)limits->extensions, "GL_EXT_blend_func_separate"))
|
---|
329 | extensions->EXT_blend_func_separate = GL_TRUE;
|
---|
330 |
|
---|
331 | if (hasExtension((const char*)limits->extensions, "GL_EXT_blend_logic_op"))
|
---|
332 | extensions->EXT_blend_logic_op = GL_TRUE;
|
---|
333 |
|
---|
334 | if (hasExtension((const char*)limits->extensions, "GL_EXT_blend_subtract"))
|
---|
335 | extensions->EXT_blend_subtract = GL_TRUE;
|
---|
336 |
|
---|
337 | if (hasExtension((const char*)limits->extensions, "GL_EXT_clip_volume_hint"))
|
---|
338 | extensions->EXT_clip_volume_hint = GL_TRUE;
|
---|
339 |
|
---|
340 | if (hasExtension((const char*)limits->extensions, "GL_EXT_fog_coord"))
|
---|
341 | extensions->EXT_fog_coord = GL_TRUE;
|
---|
342 |
|
---|
343 | if (hasExtension((const char*)limits->extensions, "GL_EXT_multi_draw_arrays"))
|
---|
344 | extensions->EXT_multi_draw_arrays = GL_TRUE;
|
---|
345 |
|
---|
346 | if (hasExtension((const char*)limits->extensions, "GL_EXT_secondary_color"))
|
---|
347 | extensions->EXT_secondary_color = GL_TRUE;
|
---|
348 |
|
---|
349 | if (hasExtension((const char*)limits->extensions, "GL_EXT_separate_specular_color"))
|
---|
350 | extensions->EXT_separate_specular_color = GL_TRUE;
|
---|
351 |
|
---|
352 | if (hasExtension((const char*)limits->extensions, "GL_EXT_shadow_funcs"))
|
---|
353 | extensions->EXT_shadow_funcs = GL_TRUE;
|
---|
354 |
|
---|
355 | if (hasExtension((const char*)limits->extensions, "GL_EXT_stencil_wrap"))
|
---|
356 | extensions->EXT_stencil_wrap = GL_TRUE;
|
---|
357 |
|
---|
358 | if (hasExtension((const char*)limits->extensions, "GL_EXT_texture_edge_clamp") ||
|
---|
359 | hasExtension((const char*)limits->extensions, "GL_SGIS_texture_edge_clamp"))
|
---|
360 | extensions->EXT_texture_edge_clamp = GL_TRUE;
|
---|
361 |
|
---|
362 | if (hasExtension((const char*)limits->extensions, "GL_EXT_texture_filter_anisotropic"))
|
---|
363 | extensions->EXT_texture_filter_anisotropic = GL_TRUE;
|
---|
364 |
|
---|
365 | if (hasExtension((const char*)limits->extensions, "GL_EXT_texture_lod_bias"))
|
---|
366 | extensions->EXT_texture_lod_bias = GL_TRUE;
|
---|
367 |
|
---|
368 | if (hasExtension((const char*)limits->extensions, "GL_IBM_rasterpos_clip"))
|
---|
369 | extensions->IBM_rasterpos_clip = GL_TRUE;
|
---|
370 |
|
---|
371 | if (hasExtension((const char*)limits->extensions, "GL_NV_fog_distance"))
|
---|
372 | extensions->NV_fog_distance = GL_TRUE;
|
---|
373 |
|
---|
374 | if (hasExtension((const char*)limits->extensions, "GL_NV_fragment_program"))
|
---|
375 | extensions->NV_fragment_program = GL_TRUE;
|
---|
376 |
|
---|
377 | if (hasExtension((const char*)limits->extensions, "GL_NV_register_combiners"))
|
---|
378 | extensions->NV_register_combiners = GL_TRUE;
|
---|
379 |
|
---|
380 | if (hasExtension((const char*)limits->extensions, "GL_NV_register_combiners2"))
|
---|
381 | extensions->NV_register_combiners2 = GL_TRUE;
|
---|
382 |
|
---|
383 | if (hasExtension((const char*)limits->extensions, "GL_NV_texgen_reflection"))
|
---|
384 | extensions->NV_texgen_reflection = GL_TRUE;
|
---|
385 |
|
---|
386 | if (hasExtension((const char*)limits->extensions, "GL_NV_texture_rectangle")
|
---|
387 | || hasExtension((const char*)limits->extensions, "GL_EXT_texture_rectangle"))
|
---|
388 | extensions->NV_texture_rectangle = GL_TRUE;
|
---|
389 |
|
---|
390 | if (hasExtension((const char*)limits->extensions, "GL_NV_vertex_program"))
|
---|
391 | extensions->NV_vertex_program = GL_TRUE;
|
---|
392 |
|
---|
393 | if (hasExtension((const char*)limits->extensions, "GL_NV_vertex_program1_1"))
|
---|
394 | extensions->NV_vertex_program1_1 = GL_TRUE;
|
---|
395 |
|
---|
396 | if (hasExtension((const char*)limits->extensions, "GL_NV_vertex_program2"))
|
---|
397 | extensions->NV_vertex_program2 = GL_TRUE;
|
---|
398 |
|
---|
399 | if (hasExtension((const char*)limits->extensions, "GL_EXT_texture3D"))
|
---|
400 | extensions->EXT_texture3D = GL_TRUE;
|
---|
401 |
|
---|
402 | if (hasExtension((const char*)limits->extensions, "GL_SGIS_generate_mipmap"))
|
---|
403 | extensions->SGIS_generate_mipmap = GL_TRUE;
|
---|
404 |
|
---|
405 | if (hasExtension((const char*)limits->extensions, "GLX_EXT_texture_from_pixmap"))
|
---|
406 | extensions->EXT_texture_from_pixmap = GL_TRUE;
|
---|
407 |
|
---|
408 | if (extensions->NV_vertex_program2)
|
---|
409 | limits->maxVertexProgramEnvParams = 256;
|
---|
410 | else
|
---|
411 | limits->maxVertexProgramEnvParams = 96;
|
---|
412 |
|
---|
413 | if (extensions->NV_vertex_program || extensions->ARB_vertex_program)
|
---|
414 | extensions->any_vertex_program = GL_TRUE;
|
---|
415 | if (extensions->NV_fragment_program || extensions->ARB_fragment_program)
|
---|
416 | extensions->any_fragment_program = GL_TRUE;
|
---|
417 | if (extensions->any_vertex_program || extensions->any_fragment_program)
|
---|
418 | extensions->any_program = GL_TRUE;
|
---|
419 |
|
---|
420 | #if 0
|
---|
421 | /* Now, determine what level of OpenGL we support */
|
---|
422 | if (extensions->ARB_multisample &&
|
---|
423 | extensions->ARB_multitexture &&
|
---|
424 | extensions->ARB_texture_border_clamp &&
|
---|
425 | extensions->ARB_texture_compression &&
|
---|
426 | extensions->ARB_texture_cube_map &&
|
---|
427 | extensions->ARB_texture_env_add &&
|
---|
428 | extensions->ARB_texture_env_combine &&
|
---|
429 | extensions->ARB_texture_env_dot3) {
|
---|
430 | if (extensions->ARB_depth_texture &&
|
---|
431 | extensions->ARB_point_parameters &&
|
---|
432 | extensions->ARB_shadow &&
|
---|
433 | extensions->ARB_texture_env_crossbar &&
|
---|
434 | extensions->ARB_texture_mirrored_repeat &&
|
---|
435 | extensions->ARB_window_pos &&
|
---|
436 | extensions->EXT_blend_color &&
|
---|
437 | extensions->EXT_blend_func_separate &&
|
---|
438 | extensions->EXT_blend_logic_op &&
|
---|
439 | extensions->EXT_blend_minmax &&
|
---|
440 | extensions->EXT_blend_subtract &&
|
---|
441 | extensions->EXT_fog_coord &&
|
---|
442 | extensions->EXT_multi_draw_arrays &&
|
---|
443 | extensions->EXT_secondary_color &&
|
---|
444 | extensions->EXT_shadow_funcs &&
|
---|
445 | extensions->EXT_stencil_wrap &&
|
---|
446 | extensions->SGIS_generate_mipmap) {
|
---|
447 | if (extensions->ARB_occlusion_query &&
|
---|
448 | extensions->ARB_vertex_buffer_object &&
|
---|
449 | extensions->ARB_texture_non_power_of_two &&
|
---|
450 | extensions->EXT_shadow_funcs) {
|
---|
451 | extensions->version = (const GLubyte *) "1.5 Chromium " CR_VERSION_STRING;
|
---|
452 | }
|
---|
453 | else {
|
---|
454 | extensions->version = (const GLubyte *) "1.4 Chromium " CR_VERSION_STRING;
|
---|
455 | }
|
---|
456 | }
|
---|
457 | else {
|
---|
458 | extensions->version = (const GLubyte *) "1.3 Chromium " CR_VERSION_STRING;
|
---|
459 | }
|
---|
460 | }
|
---|
461 | else {
|
---|
462 | extensions->version = (const GLubyte *) "1.2 Chromium " CR_VERSION_STRING;
|
---|
463 | }
|
---|
464 | #endif
|
---|
465 | }
|
---|
466 |
|
---|
467 |
|
---|
468 | /*
|
---|
469 | * Set the GL_EXTENSIONS string for the given context. We'll make
|
---|
470 | * a copy of the given string.
|
---|
471 | */
|
---|
472 | void
|
---|
473 | crStateSetExtensionString( CRContext *ctx, const GLubyte *extensions )
|
---|
474 | {
|
---|
475 | if (ctx->limits.extensions)
|
---|
476 | crFree((void *) ctx->limits.extensions);
|
---|
477 |
|
---|
478 | ctx->limits.extensions = (const GLubyte *)crStrdup((const char*)extensions);
|
---|
479 |
|
---|
480 | crStateExtensionsInit(&(ctx->limits), &(ctx->extensions));
|
---|
481 | }
|
---|
482 |
|
---|