1 /**************************************************************************
3 * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included
14 * in all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * TUNGSTEN GRAPHICS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
21 * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 **************************************************************************/
26 #include "main/mtypes.h"
27 #include "main/context.h"
28 #include "main/imports.h"
32 extern const GLubyte
* GLAPIENTRY
_es_GetString(GLenum name
);
35 static const GLubyte
*
36 compute_es_version(void)
38 GET_CURRENT_CONTEXT(ctx
);
39 static const char es_1_0
[] = "OpenGL ES-CM 1.0";
40 static const char es_1_1
[] = "OpenGL ES-CM 1.1";
41 /* OpenGL ES 1.0 is derived from OpenGL 1.3 */
42 const GLboolean ver_1_0
= (ctx
->Extensions
.ARB_multisample
&&
43 ctx
->Extensions
.ARB_multitexture
&&
44 ctx
->Extensions
.ARB_texture_compression
&&
45 ctx
->Extensions
.EXT_texture_env_add
&&
46 ctx
->Extensions
.ARB_texture_env_combine
&&
47 ctx
->Extensions
.ARB_texture_env_dot3
);
48 /* OpenGL ES 1.1 is derived from OpenGL 1.5 */
49 const GLboolean ver_1_1
= (ver_1_0
&&
50 ctx
->Extensions
.EXT_point_parameters
&&
51 ctx
->Extensions
.SGIS_generate_mipmap
&&
52 ctx
->Extensions
.ARB_vertex_buffer_object
);
54 return (const GLubyte
*) es_1_1
;
57 _mesa_problem(ctx
, "Incomplete OpenGL ES 1.0 support.");
58 return (const GLubyte
*) es_1_0
;
63 append_extension(char **str
, const char *ext
)
66 size_t len
= strlen(ext
);
84 make_extension_string(const GLcontext
*ctx
, char *str
)
89 len
+= append_extension(&str
, "GL_OES_byte_coordinates");
90 len
+= append_extension(&str
, "GL_OES_fixed_point");
91 len
+= append_extension(&str
, "GL_OES_single_precision");
92 len
+= append_extension(&str
, "GL_OES_matrix_get");
94 /* 1.1 required extensions */
95 len
+= append_extension(&str
, "GL_OES_read_format");
96 len
+= append_extension(&str
, "GL_OES_compressed_paletted_texture");
97 len
+= append_extension(&str
, "GL_OES_point_size_array");
98 len
+= append_extension(&str
, "GL_OES_point_sprite");
100 /* 1.1 deprecated extensions */
101 len
+= append_extension(&str
, "GL_OES_query_matrix");
103 #if FEATURE_OES_draw_texture
104 if (ctx
->Extensions
.OES_draw_texture
)
105 len
+= append_extension(&str
, "GL_OES_draw_texture");
108 if (ctx
->Extensions
.EXT_blend_equation_separate
)
109 len
+= append_extension(&str
, "GL_OES_blend_equation_separate");
110 if (ctx
->Extensions
.EXT_blend_func_separate
)
111 len
+= append_extension(&str
, "GL_OES_blend_func_separate");
112 if (ctx
->Extensions
.EXT_blend_subtract
)
113 len
+= append_extension(&str
, "GL_OES_blend_subtract");
115 if (ctx
->Extensions
.EXT_stencil_wrap
)
116 len
+= append_extension(&str
, "GL_OES_stencil_wrap");
118 if (ctx
->Extensions
.ARB_texture_cube_map
)
119 len
+= append_extension(&str
, "GL_OES_texture_cube_map");
120 if (ctx
->Extensions
.ARB_texture_env_crossbar
)
121 len
+= append_extension(&str
, "GL_OES_texture_env_crossbar");
122 if (ctx
->Extensions
.ARB_texture_mirrored_repeat
)
123 len
+= append_extension(&str
, "GL_OES_texture_mirrored_repeat");
125 if (ctx
->Extensions
.ARB_framebuffer_object
) {
126 len
+= append_extension(&str
, "GL_OES_framebuffer_object");
127 len
+= append_extension(&str
, "GL_OES_depth24");
128 len
+= append_extension(&str
, "GL_OES_depth32");
129 len
+= append_extension(&str
, "GL_OES_fbo_render_mipmap");
130 len
+= append_extension(&str
, "GL_OES_rgb8_rgba8");
131 len
+= append_extension(&str
, "GL_OES_stencil1");
132 len
+= append_extension(&str
, "GL_OES_stencil4");
133 len
+= append_extension(&str
, "GL_OES_stencil8");
136 if (ctx
->Extensions
.EXT_vertex_array
)
137 len
+= append_extension(&str
, "GL_OES_element_index_uint");
138 if (ctx
->Extensions
.ARB_vertex_buffer_object
)
139 len
+= append_extension(&str
, "GL_OES_mapbuffer");
140 if (ctx
->Extensions
.EXT_texture_filter_anisotropic
)
141 len
+= append_extension(&str
, "GL_EXT_texture_filter_anisotropic");
143 /* some applications check this for NPOT support */
144 if (ctx
->Extensions
.ARB_texture_non_power_of_two
)
145 len
+= append_extension(&str
, "GL_ARB_texture_non_power_of_two");
147 if (ctx
->Extensions
.EXT_texture_compression_s3tc
)
148 len
+= append_extension(&str
, "GL_EXT_texture_compression_dxt1");
149 if (ctx
->Extensions
.EXT_texture_lod_bias
)
150 len
+= append_extension(&str
, "GL_EXT_texture_lod_bias");
151 if (ctx
->Extensions
.EXT_blend_minmax
)
152 len
+= append_extension(&str
, "GL_EXT_blend_minmax");
153 if (ctx
->Extensions
.EXT_multi_draw_arrays
)
154 len
+= append_extension(&str
, "GL_EXT_multi_draw_arrays");
160 static const GLubyte
*
161 compute_es_extensions(void)
163 GET_CURRENT_CONTEXT(ctx
);
165 if (!ctx
->Extensions
.String
) {
169 len
= make_extension_string(ctx
, NULL
);
170 s
= (char *) malloc(len
+ 1);
173 make_extension_string(ctx
, s
);
174 ctx
->Extensions
.String
= (const GLubyte
*) s
;
177 return ctx
->Extensions
.String
;
181 const GLubyte
* GLAPIENTRY
182 _es_GetString(GLenum name
)
186 return compute_es_version();
188 return compute_es_extensions();
190 return _mesa_GetString(name
);
196 _mesa_initialize_context_extra(GLcontext
*ctx
)
201 * GL_OES_texture_cube_map says
202 * "Initially all texture generation modes are set to REFLECTION_MAP_OES"
204 for (i
= 0; i
< MAX_TEXTURE_UNITS
; i
++) {
205 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[i
];
206 texUnit
->GenS
.Mode
= GL_REFLECTION_MAP_NV
;
207 texUnit
->GenT
.Mode
= GL_REFLECTION_MAP_NV
;
208 texUnit
->GenR
.Mode
= GL_REFLECTION_MAP_NV
;
209 texUnit
->GenS
._ModeBit
= TEXGEN_REFLECTION_MAP_NV
;
210 texUnit
->GenT
._ModeBit
= TEXGEN_REFLECTION_MAP_NV
;
211 texUnit
->GenR
._ModeBit
= TEXGEN_REFLECTION_MAP_NV
;