summaryrefslogtreecommitdiffstats
path: root/src/glsl/glcpp/glcpp-parse.y
diff options
context:
space:
mode:
authorKenneth Graunke <[email protected]>2010-09-05 01:27:02 -0700
committerKenneth Graunke <[email protected]>2010-09-07 17:30:37 -0700
commit7dcfc44b72f00ba5a38cb02123c80113440f0de9 (patch)
treecb119dea4be95f12bab48bddf6f21cfd9ed9592b /src/glsl/glcpp/glcpp-parse.y
parent719caa403ecc3345b86708f8172600d80132d6cb (diff)
glsl: Define GL_ES preprocessor macro if API is OpenGL ES 2.0.
Also define it if #version 100 is encountered.
Diffstat (limited to 'src/glsl/glcpp/glcpp-parse.y')
-rw-r--r--src/glsl/glcpp/glcpp-parse.y9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/glsl/glcpp/glcpp-parse.y b/src/glsl/glcpp/glcpp-parse.y
index 3c28edf688b..4463a977778 100644
--- a/src/glsl/glcpp/glcpp-parse.y
+++ b/src/glsl/glcpp/glcpp-parse.y
@@ -30,6 +30,7 @@
#include "glcpp.h"
#include "main/core.h" /* for struct gl_extensions */
+#include "main/mtypes.h" /* for gl_api enum */
#define glcpp_print(stream, str) stream = talloc_strdup_append(stream, str)
#define glcpp_printf(stream, fmt, args, ...) \
@@ -309,6 +310,9 @@ control_line:
_glcpp_parser_skip_stack_pop (parser, & @1);
}
| HASH_VERSION integer_constant NEWLINE {
+ if ($2 == 100)
+ add_builtin_define (parser, "GL_ES", 1);
+
macro_t *macro = hash_table_find (parser->defines, "__VERSION__");
if (macro) {
hash_table_remove (parser->defines, "__VERSION__");
@@ -1048,7 +1052,7 @@ static void add_builtin_define(glcpp_parser_t *parser,
}
glcpp_parser_t *
-glcpp_parser_create (const struct gl_extensions *extensions)
+glcpp_parser_create (const struct gl_extensions *extensions, int api)
{
glcpp_parser_t *parser;
int language_version;
@@ -1078,6 +1082,9 @@ glcpp_parser_create (const struct gl_extensions *extensions)
add_builtin_define(parser, "GL_ARB_draw_buffers", 1);
add_builtin_define(parser, "GL_ARB_texture_rectangle", 1);
+ if (api == API_OPENGLES2)
+ add_builtin_define(parser, "GL_ES", 1);
+
if (extensions != NULL) {
if (extensions->EXT_texture_array) {
add_builtin_define(parser, "GL_EXT_texture_array", 1);