return text;
}
+/* Initialize only those things that glcpp cares about.
+ */
+static void
+init_fake_gl_context (struct gl_context *gl_ctx)
+{
+ gl_ctx->API = API_OPENGL_COMPAT;
+}
+
int
main (int argc, char *argv[])
{
char *info_log = ralloc_strdup(ctx, "");
const char *shader;
int ret;
+ struct gl_context gl_ctx;
+
+ init_fake_gl_context (&gl_ctx);
if (argc) {
filename = argv[1];
if (shader == NULL)
return 1;
- ret = glcpp_preprocess(ctx, &shader, &info_log, NULL, API_OPENGL_COMPAT);
+ ret = glcpp_preprocess(ctx, &shader, &info_log, NULL, &gl_ctx);
printf("%s", shader);
fprintf(stderr, "%s", info_log);
#include <stdint.h>
#include <stdbool.h>
+#include "main/mtypes.h"
+
#include "../ralloc.h"
#include "program/hash_table.h"
int
glcpp_preprocess(void *ralloc_ctx, const char **shader, char **info_log,
- const struct gl_extensions *extensions, int api);
+ const struct gl_extensions *extensions, struct gl_context *g_ctx);
/* Functions for writing to the info log */
int
glcpp_preprocess(void *ralloc_ctx, const char **shader, char **info_log,
- const struct gl_extensions *extensions, int api)
+ const struct gl_extensions *extensions, struct gl_context *gl_ctx)
{
int errors;
- glcpp_parser_t *parser = glcpp_parser_create (extensions, api);
+ glcpp_parser_t *parser = glcpp_parser_create (extensions, gl_ctx->API);
*shader = remove_line_continuations(parser, *shader);
glcpp_lex_set_source_string (parser, *shader);
#endif
extern int glcpp_preprocess(void *ctx, const char **shader, char **info_log,
- const struct gl_extensions *extensions, int api);
+ const struct gl_extensions *extensions, struct gl_context *gl_ctx);
extern void _mesa_destroy_shader_compiler(void);
extern void _mesa_destroy_shader_compiler_caches(void);
const char *source = shader->Source;
state->error = glcpp_preprocess(state, &source, &state->info_log,
- state->extensions, ctx->API) != 0;
+ state->extensions, ctx) != 0;
if (!state->error) {
_mesa_glsl_lexer_ctor(state, source);
shader->Source = input.c_str();
const char *source = shader->Source;
state->error = glcpp_preprocess(state, &source, &state->info_log,
- state->extensions, ctx->API) != 0;
+ state->extensions, ctx) != 0;
if (!state->error) {
_mesa_glsl_lexer_ctor(state, source);
}
state->error = glcpp_preprocess(state, &source, &state->info_log,
- &ctx->Extensions, ctx->API);
+ &ctx->Extensions, ctx);
if (ctx->Shader.Flags & GLSL_DUMP) {
printf("GLSL source for %s shader %d:\n",