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 var buf bytes.Buffer
if err := tmpl.Execute(&buf, map[string]interface{}{ if err := tmpl.Execute(&buf, struct {
"Filter": filter, Filter graphicsdriver.Filter
"FilterNearest": graphicsdriver.FilterNearest, FilterNearest graphicsdriver.Filter
"FilterLinear": graphicsdriver.FilterLinear, FilterLinear graphicsdriver.Filter
"Address": address, Address graphicsdriver.Address
"AddressUnsafe": graphicsdriver.AddressUnsafe, AddressUnsafe graphicsdriver.Address
"AddressClampToZero": graphicsdriver.AddressClampToZero, AddressClampToZero graphicsdriver.Address
"AddressRepeat": graphicsdriver.AddressRepeat, AddressRepeat graphicsdriver.Address
"UseColorM": useColorM, 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 { }); err != nil {
panic(fmt.Sprintf("builtinshader: tmpl.Execute failed: %v", err)) panic(fmt.Sprintf("builtinshader: tmpl.Execute failed: %v", err))
} }