mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
parent
90213d5d80
commit
bba196d1ec
12
image.go
12
image.go
@ -505,10 +505,10 @@ type DrawTrianglesShaderOptions struct {
|
|||||||
|
|
||||||
// Uniforms is a set of uniform variables for the shader.
|
// Uniforms is a set of uniform variables for the shader.
|
||||||
// The keys are the names of the uniform variables.
|
// The keys are the names of the uniform variables.
|
||||||
// The values must be a numeric type or a slice of a numeric type.
|
// The values must be a numeric type, or a slice or an array of a numeric type.
|
||||||
// If the uniform variable type is an array, a vector or a matrix,
|
// If the uniform variable type is an array, a vector or a matrix,
|
||||||
// you have to specify linearly flattened values as a slice.
|
// you have to specify linearly flattened values as a slice or an array.
|
||||||
// For example, if the uniform variable type is [4]vec4, the number of the slice values will be 16.
|
// For example, if the uniform variable type is [4]vec4, the length will be 16.
|
||||||
Uniforms map[string]any
|
Uniforms map[string]any
|
||||||
|
|
||||||
// Images is a set of the source images.
|
// Images is a set of the source images.
|
||||||
@ -665,10 +665,10 @@ type DrawRectShaderOptions struct {
|
|||||||
|
|
||||||
// Uniforms is a set of uniform variables for the shader.
|
// Uniforms is a set of uniform variables for the shader.
|
||||||
// The keys are the names of the uniform variables.
|
// The keys are the names of the uniform variables.
|
||||||
// The values must be a numeric type or a slice of a numeric type.
|
// The values must be a numeric type, or a slice or an array of a numeric type.
|
||||||
// If the uniform variable type is an array, a vector or a matrix,
|
// If the uniform variable type is an array, a vector or a matrix,
|
||||||
// you have to specify linearly flattened values as a slice.
|
// you have to specify linearly flattened values as a slice or an array.
|
||||||
// For example, if the uniform variable type is [4]vec4, the number of the slice values will be 16.
|
// For example, if the uniform variable type is [4]vec4, the length will be 16.
|
||||||
Uniforms map[string]any
|
Uniforms map[string]any
|
||||||
|
|
||||||
// Images is a set of the source images.
|
// Images is a set of the source images.
|
||||||
|
@ -58,8 +58,7 @@ func (s *Shader) ConvertUniforms(uniforms map[string]any) [][]uint32 {
|
|||||||
nameToU32s[name] = []uint32{uint32(v.Uint())}
|
nameToU32s[name] = []uint32{uint32(v.Uint())}
|
||||||
case reflect.Float32, reflect.Float64:
|
case reflect.Float32, reflect.Float64:
|
||||||
nameToU32s[name] = []uint32{math.Float32bits(float32(v.Float()))}
|
nameToU32s[name] = []uint32{math.Float32bits(float32(v.Float()))}
|
||||||
case reflect.Slice:
|
case reflect.Slice, reflect.Array:
|
||||||
// TODO: Allow reflect.Array (#2448)
|
|
||||||
u32s := make([]uint32, v.Len())
|
u32s := make([]uint32, v.Len())
|
||||||
switch t.Elem().Kind() {
|
switch t.Elem().Kind() {
|
||||||
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
|
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
|
||||||
|
@ -1335,7 +1335,7 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
|||||||
Want: color.RGBA{0x85, 0xa3, 0x08, 0xd3},
|
Want: color.RGBA{0x85, 0xa3, 0x08, 0xd3},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "0xff,array",
|
Name: "0xff,slice",
|
||||||
Uniforms: map[string]any{
|
Uniforms: map[string]any{
|
||||||
"U": []int{0xff, 0xff, 0xff, 0xff},
|
"U": []int{0xff, 0xff, 0xff, 0xff},
|
||||||
},
|
},
|
||||||
@ -1343,7 +1343,7 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
|||||||
Want: color.RGBA{0xff, 0xff, 0xff, 0xff},
|
Want: color.RGBA{0xff, 0xff, 0xff, 0xff},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "int,array",
|
Name: "int,slice",
|
||||||
Uniforms: map[string]any{
|
Uniforms: map[string]any{
|
||||||
"U": []int16{0x24, 0x3f, 0x6a, 0x88},
|
"U": []int16{0x24, 0x3f, 0x6a, 0x88},
|
||||||
},
|
},
|
||||||
@ -1351,13 +1351,37 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
|||||||
Want: color.RGBA{0x24, 0x3f, 0x6a, 0x88},
|
Want: color.RGBA{0x24, 0x3f, 0x6a, 0x88},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "uint,array",
|
Name: "uint,slice",
|
||||||
Uniforms: map[string]any{
|
Uniforms: map[string]any{
|
||||||
"U": []uint8{0x85, 0xa3, 0x08, 0xd3},
|
"U": []uint8{0x85, 0xa3, 0x08, 0xd3},
|
||||||
},
|
},
|
||||||
Shader: intArray,
|
Shader: intArray,
|
||||||
Want: color.RGBA{0x85, 0xa3, 0x08, 0xd3},
|
Want: color.RGBA{0x85, 0xa3, 0x08, 0xd3},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Name: "0xff,array",
|
||||||
|
Uniforms: map[string]any{
|
||||||
|
"U": [...]int{0xff, 0xff, 0xff, 0xff},
|
||||||
|
},
|
||||||
|
Shader: intArray,
|
||||||
|
Want: color.RGBA{0xff, 0xff, 0xff, 0xff},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "int,array",
|
||||||
|
Uniforms: map[string]any{
|
||||||
|
"U": [...]int16{0x24, 0x3f, 0x6a, 0x88},
|
||||||
|
},
|
||||||
|
Shader: intArray,
|
||||||
|
Want: color.RGBA{0x24, 0x3f, 0x6a, 0x88},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "uint,array",
|
||||||
|
Uniforms: map[string]any{
|
||||||
|
"U": [...]uint8{0x85, 0xa3, 0x08, 0xd3},
|
||||||
|
},
|
||||||
|
Shader: intArray,
|
||||||
|
Want: color.RGBA{0x85, 0xa3, 0x08, 0xd3},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
tc := tc
|
tc := tc
|
||||||
|
Loading…
Reference in New Issue
Block a user