internal/builtinshader: use a struct instead of a map

With a map, we might miss typos.
This commit is contained in:
Hajime Hoshi 2022-10-02 20:17:06 +09:00
parent 72004b2e23
commit ff72898b85

View File

@ -131,15 +131,24 @@ func Shader(filter graphicsdriver.Filter, address graphicsdriver.Address, useCol
}
var buf bytes.Buffer
if err := tmpl.Execute(&buf, map[string]interface{}{
"Filter": filter,
"FilterNearest": graphicsdriver.FilterNearest,
"FilterLinear": graphicsdriver.FilterLinear,
"Address": address,
"AddressUnsafe": graphicsdriver.AddressUnsafe,
"AddressClampToZero": graphicsdriver.AddressClampToZero,
"AddressRepeat": graphicsdriver.AddressRepeat,
"UseColorM": useColorM,
if err := tmpl.Execute(&buf, struct {
Filter graphicsdriver.Filter
FilterNearest graphicsdriver.Filter
FilterLinear graphicsdriver.Filter
Address graphicsdriver.Address
AddressUnsafe graphicsdriver.Address
AddressClampToZero graphicsdriver.Address
AddressRepeat graphicsdriver.Address
UseColorM bool
}{
Filter: filter,
FilterNearest: graphicsdriver.FilterNearest,
FilterLinear: graphicsdriver.FilterLinear,
Address: address,
AddressUnsafe: graphicsdriver.AddressUnsafe,
AddressClampToZero: graphicsdriver.AddressClampToZero,
AddressRepeat: graphicsdriver.AddressRepeat,
UseColorM: useColorM,
}); err != nil {
panic(fmt.Sprintf("builtinshader: tmpl.Execute failed: %v", err))
}