#include "glcpp.h"
#include "main/core.h" /* for struct gl_extensions */
+#include "main/mtypes.h" /* for gl_api enum */
static void
yyerror (YYLTYPE *locp, glcpp_parser_t *parser, const char *error);
}
glcpp_parser_t *
-glcpp_parser_create (const struct gl_extensions *extensions)
+glcpp_parser_create (const struct gl_extensions *extensions, gl_api api)
{
glcpp_parser_t *parser;
parser->error = 0;
parser->extensions = extensions;
+ parser->api = api;
parser->version_resolved = false;
parser->has_new_line_number = 0;
}
}
-/* GLSL version is no version is explicitly specified. */
+/* GLSL version if no version is explicitly specified. */
#define IMPLICIT_GLSL_VERSION 110
+/* GLSL ES version if no version is explicitly specified. */
+#define IMPLICIT_GLSL_ES_VERSION 100
+
void
glcpp_parser_resolve_implicit_version(glcpp_parser_t *parser)
{
- _glcpp_parser_handle_version_declaration(parser, IMPLICIT_GLSL_VERSION,
+ int language_version = parser->api == API_OPENGLES2 ?
+ IMPLICIT_GLSL_ES_VERSION :
+ IMPLICIT_GLSL_VERSION;
+
+ _glcpp_parser_handle_version_declaration(parser, language_version,
NULL, false);
}
size_t info_log_length;
int error;
const struct gl_extensions *extensions;
+ gl_api api;
bool version_resolved;
bool has_new_line_number;
int new_line_number;
struct gl_extensions;
glcpp_parser_t *
-glcpp_parser_create (const struct gl_extensions *extensions);
+glcpp_parser_create (const struct gl_extensions *extensions, gl_api api);
int
glcpp_parser_parse (glcpp_parser_t *parser);
const struct gl_extensions *extensions, struct gl_context *gl_ctx)
{
int errors;
- glcpp_parser_t *parser = glcpp_parser_create (extensions);
+ glcpp_parser_t *parser = glcpp_parser_create (extensions, gl_ctx->API);
if (! gl_ctx->Const.DisableGLSLLineContinuations)
*shader = remove_line_continuations(parser, *shader);