mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
shader: Accept an ast directly
This is a preparation to modify the AST before passign to Compile.
This commit is contained in:
parent
fe308f1971
commit
dde7d00231
@ -17,7 +17,6 @@ package shader
|
||||
import (
|
||||
"fmt"
|
||||
"go/ast"
|
||||
"go/parser"
|
||||
"go/token"
|
||||
"strconv"
|
||||
"strings"
|
||||
@ -106,13 +105,7 @@ func (p *ParseError) Error() string {
|
||||
return strings.Join(p.errs, "\n")
|
||||
}
|
||||
|
||||
func Compile(src []byte, vertexEntry, fragmentEntry string) (*shaderir.Program, error) {
|
||||
fs := token.NewFileSet()
|
||||
f, err := parser.ParseFile(fs, "", src, parser.AllErrors)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
func Compile(fs *token.FileSet, f *ast.File, vertexEntry, fragmentEntry string) (*shaderir.Program, error) {
|
||||
s := &compileState{
|
||||
fs: fs,
|
||||
vertexEntry: vertexEntry,
|
||||
|
11
shader.go
11
shader.go
@ -15,6 +15,9 @@
|
||||
package ebiten
|
||||
|
||||
import (
|
||||
"go/parser"
|
||||
"go/token"
|
||||
|
||||
"github.com/hajimehoshi/ebiten/internal/buffered"
|
||||
"github.com/hajimehoshi/ebiten/internal/shader"
|
||||
)
|
||||
@ -24,7 +27,13 @@ type Shader struct {
|
||||
}
|
||||
|
||||
func NewShader(src []byte) (*Shader, error) {
|
||||
s, err := shader.Compile(src, "Vertex", "Fragment")
|
||||
fs := token.NewFileSet()
|
||||
f, err := parser.ParseFile(fs, "", src, parser.AllErrors)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
s, err := shader.Compile(fs, f, "Vertex", "Fragment")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user