Skip to content

Multiple require problems #116

Open
Open
@Eronana

Description

@Eronana

a.glsl

#ifdef HELLO
#pragma glslify: b = require('./b.glsl')
float a(float x) {
	return b(x);
}
#else
float a(float x) {
	return x * 10.0;
}
#endif

#pragma glslify:export(a)

b.glsl

float b(float x) {
	return x * 11.11;
}

#pragma glslify:export(b)

c.glsl

#pragma glslify: a = require('./a.glsl')
#pragma glslify: b = require('./b.glsl')

void main() {
	gl_FragColor = vec4(a(1.0), b(1.0), 0.0, 0.0);
}

glslify < c.glsl

#define GLSLIFY 1
#ifdef HELLO
float b(float x) {
	return x * 11.11;
}

float a(float x) {
	return b(x);
}
#else
float a(float x) {
	return x * 10.0;
}
#endif

void main() {
	gl_FragColor = vec4(a(1.0), b(1.0), 0.0, 0.0);
}

the problem is, no function b when HELLO is undefined, it will caused some issue.
so maybe glslify shouldn't do too much processing, user could use macros to avoid multiple require like C/C++.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions