#include <inttypes.h>
#include "glcpp.h"
+#include "main/mtypes.h"
#define glcpp_print(stream, str) stream = talloc_strdup_append(stream, str)
#define glcpp_printf(stream, fmt, args...) \
}
glcpp_parser_t *
-glcpp_parser_create (void)
+glcpp_parser_create (const struct gl_extensions *extensions)
{
glcpp_parser_t *parser;
token_t *tok;
_token_list_append(list, tok);
_define_object_macro(parser, NULL, "GL_ARB_texture_rectangle", list);
+ if ((extensions != NULL) && extensions->EXT_texture_array) {
+ list = _token_list_create(parser);
+ _token_list_append(list, tok);
+ _define_object_macro(parser, NULL,
+ "GL_EXT_texture_array", list);
+ }
+
talloc_unlink(parser, tok);
return parser;
return text;
}
-int
-preprocess(void *talloc_ctx, const char **shader, char **info_log);
-
int
main (void)
{
void *ctx = talloc(NULL, void*);
const char *shader = load_text_file(ctx, NULL);
char *info_log = talloc_strdup(ctx, "");
- int ret = preprocess(ctx, &shader, &info_log);
+ int ret = preprocess(ctx, &shader, &info_log, NULL);
printf("%s", shader);
fprintf(stderr, "%s", info_log);
int error;
};
+struct gl_extensions;
+
glcpp_parser_t *
-glcpp_parser_create (void);
+glcpp_parser_create (const struct gl_extensions *extensions);
int
glcpp_parser_parse (glcpp_parser_t *parser);
glcpp_parser_destroy (glcpp_parser_t *parser);
int
-preprocess(void *talloc_ctx, const char **shader, char **info_log);
+preprocess(void *talloc_ctx, const char **shader, char **info_log,
+ const struct gl_extensions *extensions);
/* Functions for writing to the info log */
}
extern int
-preprocess(void *talloc_ctx, const char **shader, char **info_log)
+preprocess(void *talloc_ctx, const char **shader, char **info_log,
+ const struct gl_extensions *extensions)
{
int errors;
- glcpp_parser_t *parser = glcpp_parser_create ();
+ glcpp_parser_t *parser = glcpp_parser_create (extensions);
*shader = remove_line_continuations(parser, *shader);
glcpp_lex_set_source_string (parser, *shader);
const char *fmt, ...);
extern "C" {
-extern int preprocess(void *ctx, const char **shader, char **info_log);
+extern int preprocess(void *ctx, const char **shader, char **info_log,
+ const struct gl_extensions *extensions);
}
extern void _mesa_glsl_lexer_ctor(struct _mesa_glsl_parse_state *state,
compile_shader(struct gl_shader *shader)
{
struct _mesa_glsl_parse_state *state;
+ struct gl_extensions ext;
state = talloc_zero(talloc_parent(shader), struct _mesa_glsl_parse_state);
state->loop_or_switch_nesting = NULL;
state->ARB_texture_rectangle_enable = true;
+ memset(&ext, 0, sizeof(ext));
state->Const.MaxDrawBuffers = 2;
state->Const.MaxTextureCoords = 4;
const char *source = shader->Source;
- state->error = preprocess(state, &source, &state->info_log);
+ state->error = preprocess(state, &source, &state->info_log, &ext);
if (!state->error) {
_mesa_glsl_lexer_ctor(state, source);
state->Const.MaxTextureCoords = ctx->Const.MaxTextureCoordUnits;
const char *source = shader->Source;
- state->error = preprocess(state, &source, &state->info_log);
+ state->error = preprocess(state, &source, &state->info_log,
+ &ctx->Extensions);
if (!state->error) {
_mesa_glsl_lexer_ctor(state, source);