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