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 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_2_0
[] = "OpenGL ES 2.0";
40 /* OpenGL ES 2.0 is derived from OpenGL 2.0 */
41 const GLboolean ver_2_0
= (ctx
->Extensions
.ARB_multisample
&&
42 ctx
->Extensions
.ARB_multitexture
&&
43 ctx
->Extensions
.ARB_texture_compression
&&
44 ctx
->Extensions
.ARB_texture_cube_map
&&
45 ctx
->Extensions
.ARB_texture_mirrored_repeat
&&
46 ctx
->Extensions
.EXT_blend_color
&&
47 ctx
->Extensions
.EXT_blend_func_separate
&&
48 ctx
->Extensions
.EXT_blend_minmax
&&
49 ctx
->Extensions
.EXT_blend_subtract
&&
50 ctx
->Extensions
.EXT_stencil_wrap
&&
51 ctx
->Extensions
.ARB_vertex_buffer_object
&&
52 ctx
->Extensions
.ARB_shader_objects
&&
53 ctx
->Extensions
.ARB_vertex_shader
&&
54 ctx
->Extensions
.ARB_fragment_shader
&&
55 ctx
->Extensions
.ARB_texture_non_power_of_two
&&
56 ctx
->Extensions
.EXT_blend_equation_separate
);
58 _mesa_problem(ctx
, "Incomplete OpenGL ES 2.0 support.");
59 return (const GLubyte
*) es_2_0
;
64 append_extension(char **str
, const char *ext
)
67 size_t len
= strlen(ext
);
85 make_extension_string(const GLcontext
*ctx
, char *str
)
89 len
+= append_extension(&str
, "GL_OES_compressed_paletted_texture");
91 if (ctx
->Extensions
.ARB_framebuffer_object
) {
92 len
+= append_extension(&str
, "GL_OES_depth24");
93 len
+= append_extension(&str
, "GL_OES_depth32");
94 len
+= append_extension(&str
, "GL_OES_fbo_render_mipmap");
95 len
+= append_extension(&str
, "GL_OES_rgb8_rgba8");
96 len
+= append_extension(&str
, "GL_OES_stencil1");
97 len
+= append_extension(&str
, "GL_OES_stencil4");
100 if (ctx
->Extensions
.EXT_vertex_array
)
101 len
+= append_extension(&str
, "GL_OES_element_index_uint");
102 if (ctx
->Extensions
.ARB_vertex_buffer_object
)
103 len
+= append_extension(&str
, "GL_OES_mapbuffer");
105 if (ctx
->Extensions
.EXT_texture3D
)
106 len
+= append_extension(&str
, "GL_OES_texture_3D");
107 if (ctx
->Extensions
.ARB_texture_non_power_of_two
)
108 len
+= append_extension(&str
, "GL_OES_texture_npot");
109 if (ctx
->Extensions
.EXT_texture_filter_anisotropic
)
110 len
+= append_extension(&str
, "GL_EXT_texture_filter_anisotropic");
112 len
+= append_extension(&str
, "GL_EXT_texture_type_2_10_10_10_REV");
113 if (ctx
->Extensions
.ARB_depth_texture
)
114 len
+= append_extension(&str
, "GL_OES_depth_texture");
115 if (ctx
->Extensions
.EXT_packed_depth_stencil
)
116 len
+= append_extension(&str
, "GL_OES_packed_depth_stencil");
117 if (ctx
->Extensions
.ARB_fragment_shader
)
118 len
+= append_extension(&str
, "GL_OES_standard_derivatives");
120 if (ctx
->Extensions
.EXT_texture_compression_s3tc
)
121 len
+= append_extension(&str
, "GL_EXT_texture_compression_dxt1");
122 if (ctx
->Extensions
.EXT_blend_minmax
)
123 len
+= append_extension(&str
, "GL_EXT_blend_minmax");
124 if (ctx
->Extensions
.EXT_multi_draw_arrays
)
125 len
+= append_extension(&str
, "GL_EXT_multi_draw_arrays");
131 static const GLubyte
*
132 compute_es_extensions(void)
134 GET_CURRENT_CONTEXT(ctx
);
136 if (!ctx
->Extensions
.String
) {
140 len
= make_extension_string(ctx
, NULL
);
141 s
= (char *) malloc(len
+ 1);
144 make_extension_string(ctx
, s
);
145 ctx
->Extensions
.String
= (const GLubyte
*) s
;
148 return ctx
->Extensions
.String
;
151 const GLubyte
* GLAPIENTRY
152 _es_GetString(GLenum name
)
156 return compute_es_version();
157 case GL_SHADING_LANGUAGE_VERSION
:
158 return (const GLubyte
*) "OpenGL ES GLSL ES 1.0.16";
160 return compute_es_extensions();
162 return _mesa_GetString(name
);
168 _mesa_initialize_context_extra(GLcontext
*ctx
)
170 ctx
->FragmentProgram
._MaintainTexEnvProgram
= GL_TRUE
;
171 ctx
->VertexProgram
._MaintainTnlProgram
= GL_TRUE
;
173 ctx
->Point
.PointSprite
= GL_TRUE
; /* always on for ES 2.x */