mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-26 10:42:42 +01:00
shaderir: Add predefined macros
This commit is contained in:
parent
66e76597d8
commit
316e502f4b
@ -53,16 +53,20 @@ func (p *Program) Glsl() string {
|
||||
|
||||
// Vertex func
|
||||
if len(p.VertexFunc.Block.Stmts) > 0 {
|
||||
lines = append(lines, "#if defined(COMPILING_VERTEX_SHADER)")
|
||||
lines = append(lines, "void main(void) {")
|
||||
lines = append(lines, p.glslBlock(&p.VertexFunc.Block, 0, 0)...)
|
||||
lines = append(lines, "}")
|
||||
lines = append(lines, "#endif")
|
||||
}
|
||||
|
||||
// Fragment func
|
||||
if len(p.FragmentFunc.Block.Stmts) > 0 {
|
||||
lines = append(lines, "#if defined(COMPILING_FRAGMENT_SHADER)")
|
||||
lines = append(lines, "void main(void) {")
|
||||
lines = append(lines, p.glslBlock(&p.FragmentFunc.Block, 0, 0)...)
|
||||
lines = append(lines, "}")
|
||||
lines = append(lines, "#endif")
|
||||
}
|
||||
|
||||
var stLines []string
|
||||
|
@ -562,11 +562,13 @@ attribute float A1;
|
||||
attribute vec2 A2;
|
||||
varying float V0;
|
||||
varying vec2 V1;
|
||||
#if defined(COMPILING_VERTEX_SHADER)
|
||||
void main(void) {
|
||||
gl_Position = A0;
|
||||
V0 = A1;
|
||||
V1 = A2;
|
||||
}`,
|
||||
}
|
||||
#endif`,
|
||||
},
|
||||
{
|
||||
Name: "FragmentFunc",
|
||||
@ -628,11 +630,14 @@ attribute float A1;
|
||||
attribute vec2 A2;
|
||||
varying float V0;
|
||||
varying vec2 V1;
|
||||
#if defined(COMPILING_VERTEX_SHADER)
|
||||
void main(void) {
|
||||
gl_Position = A0;
|
||||
V0 = A1;
|
||||
V1 = A2;
|
||||
}
|
||||
#endif
|
||||
#if defined(COMPILING_FRAGMENT_SHADER)
|
||||
void main(void) {
|
||||
vec2 l0;
|
||||
vec4 l1;
|
||||
@ -640,7 +645,8 @@ void main(void) {
|
||||
l2 = V0;
|
||||
l0 = V1;
|
||||
l1 = gl_FragCoord;
|
||||
}`,
|
||||
}
|
||||
#endif`,
|
||||
},
|
||||
}
|
||||
for _, tc := range tests {
|
||||
|
Loading…
Reference in New Issue
Block a user