ebiten: refactoring: compile-time check

This commit is contained in:
Hajime Hoshi 2022-10-31 23:36:07 +09:00
parent 0bd2030be7
commit 8919bc809a

View File

@ -527,12 +527,8 @@ type DrawTrianglesShaderOptions struct {
AntiAlias bool
}
func init() {
var op DrawTrianglesShaderOptions
if got, want := len(op.Images), graphics.ShaderImageCount; got != want {
panic(fmt.Sprintf("ebiten: len((DrawTrianglesShaderOptions{}).Images) must be %d but %d", want, got))
}
}
// Check the number of images.
var _ [len(DrawTrianglesShaderOptions{}.Images)]int = [graphics.ShaderImageCount]int{}
// DrawTrianglesShader draws triangles with the specified vertices and their indices with the specified shader.
//
@ -673,12 +669,8 @@ type DrawRectShaderOptions struct {
Images [4]*Image
}
func init() {
var op DrawRectShaderOptions
if got, want := len(op.Images), graphics.ShaderImageCount; got != want {
panic(fmt.Sprintf("ebiten: len((DrawRectShaderOptions{}).Images) must be %d but %d", want, got))
}
}
// Check the number of images.
var _ [len(DrawRectShaderOptions{}.Images)]int = [graphics.ShaderImageCount]int{}
// DrawRectShader draws a rectangle with the specified width and height with the specified shader.
//