blob: 067a60ba9f5bd888b96a4090f13508568f45fd69 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
/*
* https://stackoverflow.com/questions/10868958/what-does-sampler2d-store
* The sampler2D is bound to a texture unit. The glUniform call binds it to texture
* unit zero. The glActiveTexture call is only needed if you are going to use multiple
* texture units (because GL_TEXTURE0 is the default anyway).
*/
static const char* default_tex = "_tex0_";
static const char* base_shader = R"(
#define number float
#define Texture sampler2D
#define Canvas sampler2D
#define Color vec4
#define Texel texture2D
#define extern uniform
#define Vec2 vec2
#define Vec3 vec3
#define Vec4 vec4
#define Number number
#define Image Texture
extern Texture %s;
%s
void main()
{
gl_FragColor = effect(gl_Color, %s, gl_TexCoord[0].xy, gl_FragCoord.xy);
}
)";
static const int SHADER_FORMAT_SIZE = strlen(base_shader) + strlen(default_tex) * 2;
#define formatShader(buf, program)\
sprintf(buf, base_shader, default_tex, program, default_tex)
|