mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
parent
557b321086
commit
20a01ed328
14
shader.go
14
shader.go
@ -116,12 +116,22 @@ func NewShader(src []byte) (*Shader, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Create a pseudo vertex entrypoint to treat the attribute values correctly.
|
const (
|
||||||
s, err := shader.Compile(fs, f, "__vertex", "Fragment", graphics.ShaderImageNum)
|
vert = "__vertex"
|
||||||
|
frag = "Fragment"
|
||||||
|
)
|
||||||
|
s, err := shader.Compile(fs, f, vert, frag, graphics.ShaderImageNum)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if s.VertexFunc.Block == nil {
|
||||||
|
return nil, fmt.Errorf("ebiten: vertex shader entry point '%s' is missing", vert)
|
||||||
|
}
|
||||||
|
if s.FragmentFunc.Block == nil {
|
||||||
|
return nil, fmt.Errorf("ebiten: fragment shader entry point '%s' is missing", frag)
|
||||||
|
}
|
||||||
|
|
||||||
return &Shader{
|
return &Shader{
|
||||||
shader: mipmap.NewShader(s),
|
shader: mipmap.NewShader(s),
|
||||||
}, nil
|
}, nil
|
||||||
|
@ -174,3 +174,10 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
|||||||
t.Errorf("error must be non-nil but was nil")
|
t.Errorf("error must be non-nil but was nil")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestShaderNoMain(t *testing.T) {
|
||||||
|
if _, err := NewShader([]byte(`package main
|
||||||
|
`)); err == nil {
|
||||||
|
t.Errorf("error must be non-nil but was nil")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user