mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
all: fix typos (#2558)
Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
This commit is contained in:
parent
04170d628f
commit
4de807cc44
@ -64,7 +64,7 @@ func TestGC(t *testing.T) {
|
|||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
// 200[ms] should be enough all the bytes are consumed.
|
// 200[ms] should be enough all the bytes are consumed.
|
||||||
// TODO: This is a darty hack. Would it be possible to use virtual time?
|
// TODO: This is a dirty hack. Would it be possible to use virtual time?
|
||||||
time.Sleep(200 * time.Millisecond)
|
time.Sleep(200 * time.Millisecond)
|
||||||
}
|
}
|
||||||
t.Errorf("time out")
|
t.Errorf("time out")
|
||||||
|
@ -32,7 +32,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
// addErrorInfoForContextCreation adds an additional infomation to the error when creating an audio context.
|
// addErrorInfoForContextCreation adds an additional information to the error when creating an audio context.
|
||||||
// See also hajimehoshi/oto#93.
|
// See also hajimehoshi/oto#93.
|
||||||
func addErrorInfoForContextCreation(err error) error {
|
func addErrorInfoForContextCreation(err error) error {
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
@ -113,7 +113,7 @@ func (r *Resampling) src(i int64) (float64, float64, error) {
|
|||||||
if i < 0 {
|
if i < 0 {
|
||||||
return 0, 0, nil
|
return 0, 0, nil
|
||||||
}
|
}
|
||||||
if r.size/4 <= int64(i) {
|
if r.size/4 <= i {
|
||||||
return 0, 0, nil
|
return 0, 0, nil
|
||||||
}
|
}
|
||||||
nextPos := int64(i) / resamplingBufferSize
|
nextPos := int64(i) / resamplingBufferSize
|
||||||
|
@ -102,7 +102,7 @@ func (s *stream) Seek(offset int64, whence int) (int64, error) {
|
|||||||
return n - s.headerSize, nil
|
return n - s.headerSize, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// DecodeWithSampleRate decodes WAV (RIFF) data to playable stream.
|
// DecodeWithoutResampling decodes WAV (RIFF) data to playable stream.
|
||||||
//
|
//
|
||||||
// The format must be 1 or 2 channels, 8bit or 16bit little endian PCM.
|
// The format must be 1 or 2 channels, 8bit or 16bit little endian PCM.
|
||||||
// The format is converted into 2 channels and 16bit.
|
// The format is converted into 2 channels and 16bit.
|
||||||
|
2
blend.go
2
blend.go
@ -164,7 +164,7 @@ func (b BlendFactor) internalBlendFactor(source bool) graphicsdriver.BlendFactor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// BlendFactor is an operation for source and destination color values.
|
// BlendOperation is an operation for source and destination color values.
|
||||||
type BlendOperation byte
|
type BlendOperation byte
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -147,7 +147,7 @@ import (
|
|||||||
return tmp, err
|
return tmp, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// To record gomobile to go.sum for Go 1.16 and later, go-get gomobile instaed of golang.org/x/mobile (#1487).
|
// To record gomobile to go.sum for Go 1.16 and later, go-get gomobile instead of golang.org/x/mobile (#1487).
|
||||||
// This also records gobind as gomobile depends on gobind indirectly.
|
// This also records gobind as gomobile depends on gobind indirectly.
|
||||||
// Using `...` doesn't work on Windows since mobile/internal/mobileinit cannot be compiled on Windows w/o Cgo (#1493).
|
// Using `...` doesn't work on Windows since mobile/internal/mobileinit cannot be compiled on Windows w/o Cgo (#1493).
|
||||||
if err := runGo("get", "golang.org/x/mobile/cmd/gomobile@"+h); err != nil {
|
if err := runGo("get", "golang.org/x/mobile/cmd/gomobile@"+h); err != nil {
|
||||||
|
@ -66,7 +66,7 @@ func (c *ColorM) Apply(clr color.Color) color.Color {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Concat multiplies a color matrix with the other color matrix.
|
// Concat multiplies a color matrix with the other color matrix.
|
||||||
// This is same as muptiplying the matrix other and the matrix c in this order.
|
// This is same as multiplying the matrix other and the matrix c in this order.
|
||||||
func (c *ColorM) Concat(other ColorM) {
|
func (c *ColorM) Concat(other ColorM) {
|
||||||
o := other.impl
|
o := other.impl
|
||||||
if o == nil {
|
if o == nil {
|
||||||
|
@ -195,32 +195,32 @@ func TestColorMApply(t *testing.T) {
|
|||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
ColorM: colorm.ColorM{},
|
ColorM: colorm.ColorM{},
|
||||||
In: color.RGBA{1, 2, 3, 4},
|
In: color.RGBA{R: 1, G: 2, B: 3, A: 4},
|
||||||
Out: color.RGBA{1, 2, 3, 4},
|
Out: color.RGBA{R: 1, G: 2, B: 3, A: 4},
|
||||||
Delta: 0x101,
|
Delta: 0x101,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ColorM: mono,
|
ColorM: mono,
|
||||||
In: color.NRGBA{0xff, 0xff, 0xff, 0},
|
In: color.NRGBA{R: 0xff, G: 0xff, B: 0xff},
|
||||||
Out: color.Transparent,
|
Out: color.Transparent,
|
||||||
Delta: 0x101,
|
Delta: 0x101,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ColorM: mono,
|
ColorM: mono,
|
||||||
In: color.RGBA{0xff, 0, 0, 0xff},
|
In: color.RGBA{R: 0xff, A: 0xff},
|
||||||
Out: color.RGBA{0x4c, 0x4c, 0x4c, 0xff},
|
Out: color.RGBA{R: 0x4c, G: 0x4c, B: 0x4c, A: 0xff},
|
||||||
Delta: 0x101,
|
Delta: 0x101,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ColorM: shiny,
|
ColorM: shiny,
|
||||||
In: color.RGBA{0x80, 0x90, 0xa0, 0xb0},
|
In: color.RGBA{R: 0x80, G: 0x90, B: 0xa0, A: 0xb0},
|
||||||
Out: color.RGBA{0xb0, 0xb0, 0xb0, 0xb0},
|
Out: color.RGBA{R: 0xb0, G: 0xb0, B: 0xb0, A: 0xb0},
|
||||||
Delta: 1,
|
Delta: 1,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ColorM: shift,
|
ColorM: shift,
|
||||||
In: color.RGBA{0x00, 0x00, 0x00, 0x00},
|
In: color.RGBA{},
|
||||||
Out: color.RGBA{0x40, 0x40, 0x40, 0x80},
|
Out: color.RGBA{R: 0x40, G: 0x40, B: 0x40, A: 0x80},
|
||||||
Delta: 0x101,
|
Delta: 0x101,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -190,7 +190,7 @@ func TestColorMAndScale(t *testing.T) {
|
|||||||
const w, h = 16, 16
|
const w, h = 16, 16
|
||||||
src := ebiten.NewImage(w, h)
|
src := ebiten.NewImage(w, h)
|
||||||
|
|
||||||
src.Fill(color.RGBA{0x80, 0x80, 0x80, 0x80})
|
src.Fill(color.RGBA{R: 0x80, G: 0x80, B: 0x80, A: 0x80})
|
||||||
vs := []ebiten.Vertex{
|
vs := []ebiten.Vertex{
|
||||||
{
|
{
|
||||||
SrcX: 0,
|
SrcX: 0,
|
||||||
@ -255,17 +255,17 @@ func TestColorMAndScale(t *testing.T) {
|
|||||||
switch format {
|
switch format {
|
||||||
case ebiten.ColorScaleModeStraightAlpha:
|
case ebiten.ColorScaleModeStraightAlpha:
|
||||||
want = color.RGBA{
|
want = color.RGBA{
|
||||||
byte(math.Floor(0xff * (0.5/alphaBeforeScale + 0.25) * alphaBeforeScale * 0.5 * 0.75)),
|
R: byte(math.Floor(0xff * (0.5/alphaBeforeScale + 0.25) * alphaBeforeScale * 0.5 * 0.75)),
|
||||||
byte(math.Floor(0xff * (0.5/alphaBeforeScale + 0.25) * alphaBeforeScale * 0.25 * 0.75)),
|
G: byte(math.Floor(0xff * (0.5/alphaBeforeScale + 0.25) * alphaBeforeScale * 0.25 * 0.75)),
|
||||||
byte(math.Floor(0xff * (0.5/alphaBeforeScale + 0.25) * alphaBeforeScale * 0.5 * 0.75)),
|
B: byte(math.Floor(0xff * (0.5/alphaBeforeScale + 0.25) * alphaBeforeScale * 0.5 * 0.75)),
|
||||||
byte(math.Floor(0xff * alphaBeforeScale * 0.75)),
|
A: byte(math.Floor(0xff * alphaBeforeScale * 0.75)),
|
||||||
}
|
}
|
||||||
case ebiten.ColorScaleModePremultipliedAlpha:
|
case ebiten.ColorScaleModePremultipliedAlpha:
|
||||||
want = color.RGBA{
|
want = color.RGBA{
|
||||||
byte(math.Floor(0xff * (0.5/alphaBeforeScale + 0.25) * alphaBeforeScale * 0.5)),
|
R: byte(math.Floor(0xff * (0.5/alphaBeforeScale + 0.25) * alphaBeforeScale * 0.5)),
|
||||||
byte(math.Floor(0xff * (0.5/alphaBeforeScale + 0.25) * alphaBeforeScale * 0.25)),
|
G: byte(math.Floor(0xff * (0.5/alphaBeforeScale + 0.25) * alphaBeforeScale * 0.25)),
|
||||||
byte(math.Floor(0xff * (0.5/alphaBeforeScale + 0.25) * alphaBeforeScale * 0.5)),
|
B: byte(math.Floor(0xff * (0.5/alphaBeforeScale + 0.25) * alphaBeforeScale * 0.5)),
|
||||||
byte(math.Floor(0xff * alphaBeforeScale * 0.75)),
|
A: byte(math.Floor(0xff * alphaBeforeScale * 0.75)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !sameColors(got, want, 2) {
|
if !sameColors(got, want, 2) {
|
||||||
@ -291,7 +291,7 @@ func TestColorMCopy(t *testing.T) {
|
|||||||
for j := 0; j < h; j++ {
|
for j := 0; j < h; j++ {
|
||||||
for i := 0; i < w; i++ {
|
for i := 0; i < w; i++ {
|
||||||
got := dst.At(i, j).(color.RGBA)
|
got := dst.At(i, j).(color.RGBA)
|
||||||
want := color.RGBA{byte(k), byte(k), byte(k), byte(k)}
|
want := color.RGBA{R: byte(k), G: byte(k), B: byte(k), A: byte(k)}
|
||||||
if !sameColors(got, want, 1) {
|
if !sameColors(got, want, 1) {
|
||||||
t.Fatalf("dst.At(%d, %d), k: %d: got %v, want %v", i, j, k, got, want)
|
t.Fatalf("dst.At(%d, %d), k: %d: got %v, want %v", i, j, k, got, want)
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ type ColorScale struct {
|
|||||||
r_1, g_1, b_1, a_1 float32
|
r_1, g_1, b_1, a_1 float32
|
||||||
}
|
}
|
||||||
|
|
||||||
// String returns a string represeting the color scale.
|
// String returns a string representing the color scale.
|
||||||
func (c *ColorScale) String() string {
|
func (c *ColorScale) String() string {
|
||||||
return fmt.Sprintf("(%f,%f,%f,%f)", c.r_1+1, c.g_1+1, c.b_1+1, c.a_1+1)
|
return fmt.Sprintf("(%f,%f,%f,%f)", c.r_1+1, c.g_1+1, c.b_1+1, c.a_1+1)
|
||||||
}
|
}
|
||||||
|
18
cursor.go
18
cursor.go
@ -23,9 +23,9 @@ type CursorModeType = ui.CursorMode
|
|||||||
|
|
||||||
// CursorModeTypes
|
// CursorModeTypes
|
||||||
const (
|
const (
|
||||||
CursorModeVisible CursorModeType = CursorModeType(ui.CursorModeVisible)
|
CursorModeVisible CursorModeType = ui.CursorModeVisible
|
||||||
CursorModeHidden CursorModeType = CursorModeType(ui.CursorModeHidden)
|
CursorModeHidden CursorModeType = ui.CursorModeHidden
|
||||||
CursorModeCaptured CursorModeType = CursorModeType(ui.CursorModeCaptured)
|
CursorModeCaptured CursorModeType = ui.CursorModeCaptured
|
||||||
)
|
)
|
||||||
|
|
||||||
// CursorShapeType represents a shape of a mouse cursor.
|
// CursorShapeType represents a shape of a mouse cursor.
|
||||||
@ -33,10 +33,10 @@ type CursorShapeType = ui.CursorShape
|
|||||||
|
|
||||||
// CursorShapeTypes
|
// CursorShapeTypes
|
||||||
const (
|
const (
|
||||||
CursorShapeDefault CursorShapeType = CursorShapeType(ui.CursorShapeDefault)
|
CursorShapeDefault CursorShapeType = ui.CursorShapeDefault
|
||||||
CursorShapeText CursorShapeType = CursorShapeType(ui.CursorShapeText)
|
CursorShapeText CursorShapeType = ui.CursorShapeText
|
||||||
CursorShapeCrosshair CursorShapeType = CursorShapeType(ui.CursorShapeCrosshair)
|
CursorShapeCrosshair CursorShapeType = ui.CursorShapeCrosshair
|
||||||
CursorShapePointer CursorShapeType = CursorShapeType(ui.CursorShapePointer)
|
CursorShapePointer CursorShapeType = ui.CursorShapePointer
|
||||||
CursorShapeEWResize CursorShapeType = CursorShapeType(ui.CursorShapeEWResize)
|
CursorShapeEWResize CursorShapeType = ui.CursorShapeEWResize
|
||||||
CursorShapeNSResize CursorShapeType = CursorShapeType(ui.CursorShapeNSResize)
|
CursorShapeNSResize CursorShapeType = ui.CursorShapeNSResize
|
||||||
)
|
)
|
||||||
|
@ -113,7 +113,7 @@ var (
|
|||||||
Type: "float32",
|
Type: "float32",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Comment: "Deltay is the change in Y since last touch event. This value is expressed in device independent pixels.",
|
Comment: "DeltaY is the change in Y since last touch event. This value is expressed in device independent pixels.",
|
||||||
Type: "float32",
|
Type: "float32",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -403,7 +403,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// A Key represents a keyboard key.
|
// A Key represents a keyboard key.
|
||||||
// These keys represent pysical keys of US keyboard.
|
// These keys represent physical keys of US keyboard.
|
||||||
// For example, KeyQ represents Q key on US keyboards and ' (quote) key on Dvorak keyboards.
|
// For example, KeyQ represents Q key on US keyboards and ' (quote) key on Dvorak keyboards.
|
||||||
type Key int
|
type Key int
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ import (
|
|||||||
"github.com/hajimehoshi/ebiten/v2/internal/ui"
|
"github.com/hajimehoshi/ebiten/v2/internal/ui"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Filter represents the type of texture filter to be used when an image is maginified or minified.
|
// Filter represents the type of texture filter to be used when an image is magnified or minified.
|
||||||
type Filter int
|
type Filter int
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -126,7 +126,7 @@ func (c CompositeMode) blend() Blend {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// GraphicsLibrary represets graphics libraries supported by the engine.
|
// GraphicsLibrary represents graphics libraries supported by the engine.
|
||||||
type GraphicsLibrary int
|
type GraphicsLibrary int
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
22
image.go
22
image.go
@ -279,7 +279,7 @@ type Vertex struct {
|
|||||||
|
|
||||||
// SrcX and SrcY represents a point on a source image.
|
// SrcX and SrcY represents a point on a source image.
|
||||||
// Be careful that SrcX/SrcY coordinates are on the image's bounds.
|
// Be careful that SrcX/SrcY coordinates are on the image's bounds.
|
||||||
// This means that a upper-left point of a sub-image might not be (0, 0).
|
// This means that an upper-left point of a sub-image might not be (0, 0).
|
||||||
SrcX float32
|
SrcX float32
|
||||||
SrcY float32
|
SrcY float32
|
||||||
|
|
||||||
@ -292,7 +292,7 @@ type Vertex struct {
|
|||||||
// Vertex colors are converted to premultiplied-alpha internally and
|
// Vertex colors are converted to premultiplied-alpha internally and
|
||||||
// interpolated linearly respecting alpha.
|
// interpolated linearly respecting alpha.
|
||||||
// - DrawTrianglesShader: arbitrary floating point values sent to the shader.
|
// - DrawTrianglesShader: arbitrary floating point values sent to the shader.
|
||||||
// These are interpolated linearly and independently from each other.
|
// These are interpolated linearly and independently of each other.
|
||||||
ColorR float32
|
ColorR float32
|
||||||
ColorG float32
|
ColorG float32
|
||||||
ColorB float32
|
ColorB float32
|
||||||
@ -303,7 +303,7 @@ type Vertex struct {
|
|||||||
type Address int
|
type Address int
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// AddressUnsafe means there is no guarantee when the texture coodinates are out of range.
|
// AddressUnsafe means there is no guarantee when the texture coordinates are out of range.
|
||||||
AddressUnsafe Address = Address(builtinshader.AddressUnsafe)
|
AddressUnsafe Address = Address(builtinshader.AddressUnsafe)
|
||||||
|
|
||||||
// AddressClampToZero means that out-of-range texture coordinates return 0 (transparent).
|
// AddressClampToZero means that out-of-range texture coordinates return 0 (transparent).
|
||||||
@ -321,7 +321,7 @@ const (
|
|||||||
FillAll FillRule = iota
|
FillAll FillRule = iota
|
||||||
|
|
||||||
// EvenOdd means that triangles are rendered based on the even-odd rule.
|
// EvenOdd means that triangles are rendered based on the even-odd rule.
|
||||||
// If and only if the number of overlappings is odd, the region is rendered.
|
// If and only if the number of overlaps is odd, the region is rendered.
|
||||||
EvenOdd
|
EvenOdd
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -333,7 +333,7 @@ const (
|
|||||||
// straight-alpha encoded color multiplier.
|
// straight-alpha encoded color multiplier.
|
||||||
ColorScaleModeStraightAlpha ColorScaleMode = iota
|
ColorScaleModeStraightAlpha ColorScaleMode = iota
|
||||||
|
|
||||||
// ColorScaleModeStraightAlpha indicates color scales in vertices are
|
// ColorScaleModePremultipliedAlpha indicates color scales in vertices are
|
||||||
// premultiplied-alpha encoded color multiplier.
|
// premultiplied-alpha encoded color multiplier.
|
||||||
ColorScaleModePremultipliedAlpha
|
ColorScaleModePremultipliedAlpha
|
||||||
)
|
)
|
||||||
@ -872,7 +872,7 @@ func (i *Image) ReadPixels(pixels []byte) {
|
|||||||
// At can't be called outside the main loop (ebiten.Run's updating function) starts.
|
// At can't be called outside the main loop (ebiten.Run's updating function) starts.
|
||||||
func (i *Image) At(x, y int) color.Color {
|
func (i *Image) At(x, y int) color.Color {
|
||||||
r, g, b, a := i.at(x, y)
|
r, g, b, a := i.at(x, y)
|
||||||
return color.RGBA{r, g, b, a}
|
return color.RGBA{R: r, G: g, B: b, A: a}
|
||||||
}
|
}
|
||||||
|
|
||||||
// RGBA64At implements the standard image.RGBA64Image's RGBA64At.
|
// RGBA64At implements the standard image.RGBA64Image's RGBA64At.
|
||||||
@ -888,7 +888,7 @@ func (i *Image) At(x, y int) color.Color {
|
|||||||
// RGBA64At can't be called outside the main loop (ebiten.Run's updating function) starts.
|
// RGBA64At can't be called outside the main loop (ebiten.Run's updating function) starts.
|
||||||
func (i *Image) RGBA64At(x, y int) color.RGBA64 {
|
func (i *Image) RGBA64At(x, y int) color.RGBA64 {
|
||||||
r, g, b, a := i.at(x, y)
|
r, g, b, a := i.at(x, y)
|
||||||
return color.RGBA64{uint16(r) * 0x101, uint16(g) * 0x101, uint16(b) * 0x101, uint16(a) * 0x101}
|
return color.RGBA64{R: uint16(r) * 0x101, G: uint16(g) * 0x101, B: uint16(b) * 0x101, A: uint16(a) * 0x101}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *Image) at(x, y int) (r, g, b, a byte) {
|
func (i *Image) at(x, y int) (r, g, b, a byte) {
|
||||||
@ -928,14 +928,14 @@ func (i *Image) Set(x, y int, clr color.Color) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Dispose disposes the image data.
|
// Dispose disposes the image data.
|
||||||
// After disposing, most of image functions do nothing and returns meaningless values.
|
// After disposing, most of the image functions do nothing and returns meaningless values.
|
||||||
//
|
//
|
||||||
// Calling Dispose is not mandatory. GC automatically collects internal resources that no objects refer to.
|
// Calling Dispose is not mandatory. GC automatically collects internal resources that no objects refer to.
|
||||||
// However, calling Dispose explicitly is helpful if memory usage matters.
|
// However, calling Dispose explicitly is helpful if memory usage matters.
|
||||||
//
|
//
|
||||||
// If the image is a sub-image, Dispose does nothing.
|
// If the image is a sub-image, Dispose does nothing.
|
||||||
//
|
//
|
||||||
// When the image is disposed, Dipose does nothing.
|
// When the image is disposed, Dispose does nothing.
|
||||||
func (i *Image) Dispose() {
|
func (i *Image) Dispose() {
|
||||||
i.copyCheck()
|
i.copyCheck()
|
||||||
|
|
||||||
@ -1011,7 +1011,7 @@ type NewImageOptions struct {
|
|||||||
//
|
//
|
||||||
// The rendering origin position is (0, 0) of the given bounds.
|
// The rendering origin position is (0, 0) of the given bounds.
|
||||||
// If DrawImage is called on a new image created by NewImageOptions,
|
// If DrawImage is called on a new image created by NewImageOptions,
|
||||||
// for example, the center of scaling and rotating is (0, 0), that might not be a upper-left position.
|
// for example, the center of scaling and rotating is (0, 0), that might not be an upper-left position.
|
||||||
//
|
//
|
||||||
// If options is nil, the default setting is used.
|
// If options is nil, the default setting is used.
|
||||||
//
|
//
|
||||||
@ -1122,7 +1122,7 @@ func NewImageFromImageWithOptions(source image.Image, options *NewImageFromImage
|
|||||||
return i
|
return i
|
||||||
}
|
}
|
||||||
|
|
||||||
// colorMToScale returns a new color matrix and color sclaes that equal to the given matrix in terms of the effect.
|
// colorMToScale returns a new color matrix and color scales that equal to the given matrix in terms of the effect.
|
||||||
//
|
//
|
||||||
// If the given matrix is merely a scaling matrix, colorMToScale returns
|
// If the given matrix is merely a scaling matrix, colorMToScale returns
|
||||||
// an identity matrix and its scaling factors in premultiplied-alpha format.
|
// an identity matrix and its scaling factors in premultiplied-alpha format.
|
||||||
|
264
image_test.go
264
image_test.go
@ -121,7 +121,7 @@ func TestImagePixels(t *testing.T) {
|
|||||||
for j := 0; j < h; j++ {
|
for j := 0; j < h; j++ {
|
||||||
for i := 0; i < w; i++ {
|
for i := 0; i < w; i++ {
|
||||||
idx := 4 * (j*w + i)
|
idx := 4 * (j*w + i)
|
||||||
got := color.RGBA{pix[idx], pix[idx+1], pix[idx+2], pix[idx+3]}
|
got := color.RGBA{R: pix[idx], G: pix[idx+1], B: pix[idx+2], A: pix[idx+3]}
|
||||||
want := color.RGBAModel.Convert(img.At(i, j))
|
want := color.RGBAModel.Convert(img.At(i, j))
|
||||||
if got != want {
|
if got != want {
|
||||||
t.Errorf("(%d, %d): got %v; want %v", i, j, got, want)
|
t.Errorf("(%d, %d): got %v; want %v", i, j, got, want)
|
||||||
@ -131,8 +131,8 @@ func TestImagePixels(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestImageComposition(t *testing.T) {
|
func TestImageComposition(t *testing.T) {
|
||||||
img2Color := color.NRGBA{0x24, 0x3f, 0x6a, 0x88}
|
img2Color := color.NRGBA{R: 0x24, G: 0x3f, B: 0x6a, A: 0x88}
|
||||||
img3Color := color.NRGBA{0x85, 0xa3, 0x08, 0xd3}
|
img3Color := color.NRGBA{R: 0x85, G: 0xa3, B: 0x08, A: 0xd3}
|
||||||
|
|
||||||
// TODO: Rename this to img0
|
// TODO: Rename this to img0
|
||||||
img1, _, err := openEbitenImage()
|
img1, _, err := openEbitenImage()
|
||||||
@ -178,7 +178,7 @@ func TestImageComposition(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestImageSelf(t *testing.T) {
|
func TestImageSelf(t *testing.T) {
|
||||||
// Note that mutex usages: without defer, unlocking is not called when panicing.
|
// Note that mutex usages: without defer, unlocking is not called when panicking.
|
||||||
defer func() {
|
defer func() {
|
||||||
if r := recover(); r == nil {
|
if r := recover(); r == nil {
|
||||||
t.Errorf("DrawImage must panic but not")
|
t.Errorf("DrawImage must panic but not")
|
||||||
@ -267,7 +267,7 @@ func TestImageDotByDotInversion(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestImageWritePixels(t *testing.T) {
|
func TestImageWritePixels(t *testing.T) {
|
||||||
// Create a dummy image so that the shared texture is used and origImg's position is shfited.
|
// Create a dummy image so that the shared texture is used and origImg's position is shifted.
|
||||||
dummyImg := ebiten.NewImageFromImage(image.NewRGBA(image.Rect(0, 0, 16, 16)))
|
dummyImg := ebiten.NewImageFromImage(image.NewRGBA(image.Rect(0, 0, 16, 16)))
|
||||||
defer dummyImg.Dispose()
|
defer dummyImg.Dispose()
|
||||||
|
|
||||||
@ -306,7 +306,7 @@ func TestImageWritePixels(t *testing.T) {
|
|||||||
for j := 0; j < img0.Bounds().Dy(); j++ {
|
for j := 0; j < img0.Bounds().Dy(); j++ {
|
||||||
for i := 0; i < img0.Bounds().Dx(); i++ {
|
for i := 0; i < img0.Bounds().Dx(); i++ {
|
||||||
got := img0.At(i, j)
|
got := img0.At(i, j)
|
||||||
want := color.RGBA{0x80, 0x80, 0x80, 0x80}
|
want := color.RGBA{R: 0x80, G: 0x80, B: 0x80, A: 0x80}
|
||||||
if got != want {
|
if got != want {
|
||||||
t.Errorf("img0 At(%d, %d): got %v; want %v", i, j, got, want)
|
t.Errorf("img0 At(%d, %d): got %v; want %v", i, j, got, want)
|
||||||
}
|
}
|
||||||
@ -356,7 +356,7 @@ func TestImageBlendLighter(t *testing.T) {
|
|||||||
|
|
||||||
w, h := img0.Bounds().Dx(), img0.Bounds().Dy()
|
w, h := img0.Bounds().Dx(), img0.Bounds().Dy()
|
||||||
img1 := ebiten.NewImage(w, h)
|
img1 := ebiten.NewImage(w, h)
|
||||||
img1.Fill(color.RGBA{0x01, 0x02, 0x03, 0x04})
|
img1.Fill(color.RGBA{R: 0x01, G: 0x02, B: 0x03, A: 0x04})
|
||||||
op := &ebiten.DrawImageOptions{}
|
op := &ebiten.DrawImageOptions{}
|
||||||
op.Blend = ebiten.BlendLighter
|
op.Blend = ebiten.BlendLighter
|
||||||
img1.DrawImage(img0, op)
|
img1.DrawImage(img0, op)
|
||||||
@ -429,7 +429,7 @@ func TestImageFill(t *testing.T) {
|
|||||||
for j := 0; j < h; j++ {
|
for j := 0; j < h; j++ {
|
||||||
for i := 0; i < w; i++ {
|
for i := 0; i < w; i++ {
|
||||||
got := img.At(i, j)
|
got := img.At(i, j)
|
||||||
want := color.RGBA{0x80, 0x80, 0x80, 0x80}
|
want := color.RGBA{R: 0x80, G: 0x80, B: 0x80, A: 0x80}
|
||||||
if got != want {
|
if got != want {
|
||||||
t.Errorf("img At(%d, %d): got %v; want %v", i, j, got, want)
|
t.Errorf("img At(%d, %d): got %v; want %v", i, j, got, want)
|
||||||
}
|
}
|
||||||
@ -445,7 +445,7 @@ func TestImageClear(t *testing.T) {
|
|||||||
for j := 0; j < h; j++ {
|
for j := 0; j < h; j++ {
|
||||||
for i := 0; i < w; i++ {
|
for i := 0; i < w; i++ {
|
||||||
got := img.At(i, j)
|
got := img.At(i, j)
|
||||||
want := color.RGBA{0xff, 0xff, 0xff, 0xff}
|
want := color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff}
|
||||||
if got != want {
|
if got != want {
|
||||||
t.Errorf("img At(%d, %d): got %v; want %v", i, j, got, want)
|
t.Errorf("img At(%d, %d): got %v; want %v", i, j, got, want)
|
||||||
}
|
}
|
||||||
@ -493,8 +493,8 @@ func TestImageEdge(t *testing.T) {
|
|||||||
}
|
}
|
||||||
img0.WritePixels(pixels)
|
img0.WritePixels(pixels)
|
||||||
img1 := ebiten.NewImage(img1Width, img1Height)
|
img1 := ebiten.NewImage(img1Width, img1Height)
|
||||||
red := color.RGBA{0xff, 0, 0, 0xff}
|
red := color.RGBA{R: 0xff, A: 0xff}
|
||||||
transparent := color.RGBA{0, 0, 0, 0}
|
transparent := color.RGBA{}
|
||||||
|
|
||||||
angles := []float64{}
|
angles := []float64{}
|
||||||
for a := 0; a < 1440; a++ {
|
for a := 0; a < 1440; a++ {
|
||||||
@ -616,7 +616,7 @@ func TestImageTooManyFill(t *testing.T) {
|
|||||||
dst := ebiten.NewImage(width, 1)
|
dst := ebiten.NewImage(width, 1)
|
||||||
for i := 0; i < width; i++ {
|
for i := 0; i < width; i++ {
|
||||||
c := indexToColor(i)
|
c := indexToColor(i)
|
||||||
src.Fill(color.RGBA{c, c, c, 0xff})
|
src.Fill(color.RGBA{R: c, G: c, B: c, A: 0xff})
|
||||||
op := &ebiten.DrawImageOptions{}
|
op := &ebiten.DrawImageOptions{}
|
||||||
op.GeoM.Translate(float64(i), 0)
|
op.GeoM.Translate(float64(i), 0)
|
||||||
dst.DrawImage(src, op)
|
dst.DrawImage(src, op)
|
||||||
@ -625,7 +625,7 @@ func TestImageTooManyFill(t *testing.T) {
|
|||||||
for i := 0; i < width; i++ {
|
for i := 0; i < width; i++ {
|
||||||
c := indexToColor(i)
|
c := indexToColor(i)
|
||||||
got := dst.At(i, 0).(color.RGBA)
|
got := dst.At(i, 0).(color.RGBA)
|
||||||
want := color.RGBA{c, c, c, 0xff}
|
want := color.RGBA{R: c, G: c, B: c, A: 0xff}
|
||||||
if !sameColors(got, want, 1) {
|
if !sameColors(got, want, 1) {
|
||||||
t.Errorf("dst.At(%d, %d): got %v, want: %v", i, 0, got, want)
|
t.Errorf("dst.At(%d, %d): got %v, want: %v", i, 0, got, want)
|
||||||
}
|
}
|
||||||
@ -671,7 +671,7 @@ func TestImageLinearGraduation(t *testing.T) {
|
|||||||
func TestImageOutside(t *testing.T) {
|
func TestImageOutside(t *testing.T) {
|
||||||
src := ebiten.NewImage(5, 10) // internal texture size is 8x16.
|
src := ebiten.NewImage(5, 10) // internal texture size is 8x16.
|
||||||
dst := ebiten.NewImage(4, 4)
|
dst := ebiten.NewImage(4, 4)
|
||||||
src.Fill(color.RGBA{0xff, 0, 0, 0xff})
|
src.Fill(color.RGBA{R: 0xff, A: 0xff})
|
||||||
|
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
X, Y, Width, Height int
|
X, Y, Width, Height int
|
||||||
@ -701,7 +701,7 @@ func TestImageOutside(t *testing.T) {
|
|||||||
for j := 0; j < 4; j++ {
|
for j := 0; j < 4; j++ {
|
||||||
for i := 0; i < 4; i++ {
|
for i := 0; i < 4; i++ {
|
||||||
got := dst.At(i, j).(color.RGBA)
|
got := dst.At(i, j).(color.RGBA)
|
||||||
want := color.RGBA{0, 0, 0, 0}
|
want := color.RGBA{}
|
||||||
if got != want {
|
if got != want {
|
||||||
t.Errorf("src(x: %d, y: %d, w: %d, h: %d), dst At(%d, %d): got %v, want: %v", c.X, c.Y, c.Width, c.Height, i, j, got, want)
|
t.Errorf("src(x: %d, y: %d, w: %d, h: %d), dst At(%d, %d): got %v, want: %v", c.X, c.Y, c.Width, c.Height, i, j, got, want)
|
||||||
}
|
}
|
||||||
@ -714,7 +714,7 @@ func TestImageOutsideUpperLeft(t *testing.T) {
|
|||||||
src := ebiten.NewImage(4, 4)
|
src := ebiten.NewImage(4, 4)
|
||||||
dst1 := ebiten.NewImage(16, 16)
|
dst1 := ebiten.NewImage(16, 16)
|
||||||
dst2 := ebiten.NewImage(16, 16)
|
dst2 := ebiten.NewImage(16, 16)
|
||||||
src.Fill(color.RGBA{0xff, 0, 0, 0xff})
|
src.Fill(color.RGBA{R: 0xff, A: 0xff})
|
||||||
|
|
||||||
op := &ebiten.DrawImageOptions{}
|
op := &ebiten.DrawImageOptions{}
|
||||||
op.GeoM.Rotate(math.Pi / 4)
|
op.GeoM.Rotate(math.Pi / 4)
|
||||||
@ -756,7 +756,7 @@ func TestImageSize1(t *testing.T) {
|
|||||||
src.Fill(color.White)
|
src.Fill(color.White)
|
||||||
dst.DrawImage(src, nil)
|
dst.DrawImage(src, nil)
|
||||||
got := src.At(0, 0).(color.RGBA)
|
got := src.At(0, 0).(color.RGBA)
|
||||||
want := color.RGBA{0xff, 0xff, 0xff, 0xff}
|
want := color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff}
|
||||||
if !sameColors(got, want, 1) {
|
if !sameColors(got, want, 1) {
|
||||||
t.Errorf("got: %v, want: %v", got, want)
|
t.Errorf("got: %v, want: %v", got, want)
|
||||||
}
|
}
|
||||||
@ -788,7 +788,7 @@ func Skip_TestImageSize4096(t *testing.T) {
|
|||||||
for i := 4095; i < 4096; i++ {
|
for i := 4095; i < 4096; i++ {
|
||||||
j := 4095
|
j := 4095
|
||||||
got := dst.At(i, j).(color.RGBA)
|
got := dst.At(i, j).(color.RGBA)
|
||||||
want := color.RGBA{uint8(i + j), uint8((i + j) >> 8), uint8((i + j) >> 16), 0xff}
|
want := color.RGBA{R: uint8(i + j), G: uint8((i + j) >> 8), B: uint8((i + j) >> 16), A: 0xff}
|
||||||
if got != want {
|
if got != want {
|
||||||
t.Errorf("At(%d, %d): got: %v, want: %v", i, j, got, want)
|
t.Errorf("At(%d, %d): got: %v, want: %v", i, j, got, want)
|
||||||
}
|
}
|
||||||
@ -796,7 +796,7 @@ func Skip_TestImageSize4096(t *testing.T) {
|
|||||||
for j := 4095; j < 4096; j++ {
|
for j := 4095; j < 4096; j++ {
|
||||||
i := 4095
|
i := 4095
|
||||||
got := dst.At(i, j).(color.RGBA)
|
got := dst.At(i, j).(color.RGBA)
|
||||||
want := color.RGBA{uint8(i + j), uint8((i + j) >> 8), uint8((i + j) >> 16), 0xff}
|
want := color.RGBA{R: uint8(i + j), G: uint8((i + j) >> 8), B: uint8((i + j) >> 16), A: 0xff}
|
||||||
if got != want {
|
if got != want {
|
||||||
t.Errorf("At(%d, %d): got: %v, want: %v", i, j, got, want)
|
t.Errorf("At(%d, %d): got: %v, want: %v", i, j, got, want)
|
||||||
}
|
}
|
||||||
@ -848,7 +848,7 @@ loop:
|
|||||||
got := dst.At(0, i+j).(color.RGBA)
|
got := dst.At(0, i+j).(color.RGBA)
|
||||||
want := color.RGBA{}
|
want := color.RGBA{}
|
||||||
if j < 0 {
|
if j < 0 {
|
||||||
want = color.RGBA{0xff, 0, 0, 0xff}
|
want = color.RGBA{R: 0xff, A: 0xff}
|
||||||
}
|
}
|
||||||
if got != want {
|
if got != want {
|
||||||
t.Errorf("At(%d, %d) (height=%d, scale=%d/%d): got: %v, want: %v", 0, i+j, h, i, h, got, want)
|
t.Errorf("At(%d, %d) (height=%d, scale=%d/%d): got: %v, want: %v", 0, i+j, h, i, h, got, want)
|
||||||
@ -874,7 +874,7 @@ func TestImageSprites(t *testing.T) {
|
|||||||
)
|
)
|
||||||
|
|
||||||
src := ebiten.NewImage(4, 4)
|
src := ebiten.NewImage(4, 4)
|
||||||
src.Fill(color.RGBA{0xff, 0xff, 0xff, 0xff})
|
src.Fill(color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff})
|
||||||
dst := ebiten.NewImage(width, height)
|
dst := ebiten.NewImage(width, height)
|
||||||
for j := 0; j < height/4; j++ {
|
for j := 0; j < height/4; j++ {
|
||||||
for i := 0; i < width/4; i++ {
|
for i := 0; i < width/4; i++ {
|
||||||
@ -887,7 +887,7 @@ func TestImageSprites(t *testing.T) {
|
|||||||
for j := 0; j < height/4; j++ {
|
for j := 0; j < height/4; j++ {
|
||||||
for i := 0; i < width/4; i++ {
|
for i := 0; i < width/4; i++ {
|
||||||
got := dst.At(i*4, j*4).(color.RGBA)
|
got := dst.At(i*4, j*4).(color.RGBA)
|
||||||
want := color.RGBA{0xff, 0xff, 0xff, 0xff}
|
want := color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff}
|
||||||
if !sameColors(got, want, 1) {
|
if !sameColors(got, want, 1) {
|
||||||
t.Errorf("dst.At(%d, %d): got %v, want: %v", i*4, j*4, got, want)
|
t.Errorf("dst.At(%d, %d): got %v, want: %v", i*4, j*4, got, want)
|
||||||
}
|
}
|
||||||
@ -1017,7 +1017,7 @@ func TestImageMipmapColor(t *testing.T) {
|
|||||||
op.ColorScale.Scale(0, 1, 1, 1)
|
op.ColorScale.Scale(0, 1, 1, 1)
|
||||||
img0.DrawImage(img1, op)
|
img0.DrawImage(img1, op)
|
||||||
|
|
||||||
want := color.RGBA{0, 0xff, 0xff, 0xff}
|
want := color.RGBA{G: 0xff, B: 0xff, A: 0xff}
|
||||||
got := img0.At(128, 0)
|
got := img0.At(128, 0)
|
||||||
if got != want {
|
if got != want {
|
||||||
t.Errorf("want: %v, got: %v", want, got)
|
t.Errorf("want: %v, got: %v", want, got)
|
||||||
@ -1032,14 +1032,14 @@ func TestImageMiamapAndDrawTriangle(t *testing.T) {
|
|||||||
img2 := ebiten.NewImage(128, 128)
|
img2 := ebiten.NewImage(128, 128)
|
||||||
|
|
||||||
// Fill img1 red and create img1's mipmap
|
// Fill img1 red and create img1's mipmap
|
||||||
img1.Fill(color.RGBA{0xff, 0, 0, 0xff})
|
img1.Fill(color.RGBA{R: 0xff, A: 0xff})
|
||||||
op := &ebiten.DrawImageOptions{}
|
op := &ebiten.DrawImageOptions{}
|
||||||
op.GeoM.Scale(0.25, 0.25)
|
op.GeoM.Scale(0.25, 0.25)
|
||||||
op.Filter = ebiten.FilterLinear
|
op.Filter = ebiten.FilterLinear
|
||||||
img0.DrawImage(img1, op)
|
img0.DrawImage(img1, op)
|
||||||
|
|
||||||
// Call DrawTriangle on img1 and fill it with green
|
// Call DrawTriangle on img1 and fill it with green
|
||||||
img2.Fill(color.RGBA{0, 0xff, 0, 0xff})
|
img2.Fill(color.RGBA{G: 0xff, A: 0xff})
|
||||||
vs := []ebiten.Vertex{
|
vs := []ebiten.Vertex{
|
||||||
{
|
{
|
||||||
DstX: 0,
|
DstX: 0,
|
||||||
@ -1104,7 +1104,7 @@ func TestImageMiamapAndDrawTriangle(t *testing.T) {
|
|||||||
|
|
||||||
func TestImageSubImageAt(t *testing.T) {
|
func TestImageSubImageAt(t *testing.T) {
|
||||||
img := ebiten.NewImage(16, 16)
|
img := ebiten.NewImage(16, 16)
|
||||||
img.Fill(color.RGBA{0xff, 0, 0, 0xff})
|
img.Fill(color.RGBA{R: 0xff, A: 0xff})
|
||||||
|
|
||||||
got := img.SubImage(image.Rect(1, 1, 16, 16)).At(0, 0).(color.RGBA)
|
got := img.SubImage(image.Rect(1, 1, 16, 16)).At(0, 0).(color.RGBA)
|
||||||
want := color.RGBA{}
|
want := color.RGBA{}
|
||||||
@ -1113,7 +1113,7 @@ func TestImageSubImageAt(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
got = img.SubImage(image.Rect(1, 1, 16, 16)).At(1, 1).(color.RGBA)
|
got = img.SubImage(image.Rect(1, 1, 16, 16)).At(1, 1).(color.RGBA)
|
||||||
want = color.RGBA{0xff, 0, 0, 0xff}
|
want = color.RGBA{R: 0xff, A: 0xff}
|
||||||
if got != want {
|
if got != want {
|
||||||
t.Errorf("got: %v, want: %v", got, want)
|
t.Errorf("got: %v, want: %v", got, want)
|
||||||
}
|
}
|
||||||
@ -1121,7 +1121,7 @@ func TestImageSubImageAt(t *testing.T) {
|
|||||||
|
|
||||||
func TestImageSubImageSize(t *testing.T) {
|
func TestImageSubImageSize(t *testing.T) {
|
||||||
img := ebiten.NewImage(16, 16)
|
img := ebiten.NewImage(16, 16)
|
||||||
img.Fill(color.RGBA{0xff, 0, 0, 0xff})
|
img.Fill(color.RGBA{R: 0xff, A: 0xff})
|
||||||
|
|
||||||
got := img.SubImage(image.Rect(1, 1, 16, 16)).Bounds().Dx()
|
got := img.SubImage(image.Rect(1, 1, 16, 16)).Bounds().Dx()
|
||||||
want := 15
|
want := 15
|
||||||
@ -1136,11 +1136,11 @@ func TestImageDrawImmediately(t *testing.T) {
|
|||||||
img1 := ebiten.NewImage(w, h)
|
img1 := ebiten.NewImage(w, h)
|
||||||
// Do not manipulate img0 here.
|
// Do not manipulate img0 here.
|
||||||
|
|
||||||
img0.Fill(color.RGBA{0xff, 0, 0, 0xff})
|
img0.Fill(color.RGBA{R: 0xff, A: 0xff})
|
||||||
for j := 0; j < h; j++ {
|
for j := 0; j < h; j++ {
|
||||||
for i := 0; i < w; i++ {
|
for i := 0; i < w; i++ {
|
||||||
got := img0.At(i, j).(color.RGBA)
|
got := img0.At(i, j).(color.RGBA)
|
||||||
want := color.RGBA{0xff, 0, 0, 0xff}
|
want := color.RGBA{R: 0xff, A: 0xff}
|
||||||
if got != want {
|
if got != want {
|
||||||
t.Errorf("img0.At(%d, %d): got %v, want: %v", i, j, got, want)
|
t.Errorf("img0.At(%d, %d): got %v, want: %v", i, j, got, want)
|
||||||
}
|
}
|
||||||
@ -1152,7 +1152,7 @@ func TestImageDrawImmediately(t *testing.T) {
|
|||||||
for j := 0; j < h; j++ {
|
for j := 0; j < h; j++ {
|
||||||
for i := 0; i < w; i++ {
|
for i := 0; i < w; i++ {
|
||||||
got := img0.At(i, j).(color.RGBA)
|
got := img0.At(i, j).(color.RGBA)
|
||||||
want := color.RGBA{0xff, 0, 0, 0xff}
|
want := color.RGBA{R: 0xff, A: 0xff}
|
||||||
if got != want {
|
if got != want {
|
||||||
t.Errorf("img0.At(%d, %d): got %v, want: %v", i, j, got, want)
|
t.Errorf("img0.At(%d, %d): got %v, want: %v", i, j, got, want)
|
||||||
}
|
}
|
||||||
@ -1198,9 +1198,9 @@ func TestImageLinearFilterGlitch(t *testing.T) {
|
|||||||
got := dst.At(i, j).(color.RGBA)
|
got := dst.At(i, j).(color.RGBA)
|
||||||
var want color.RGBA
|
var want color.RGBA
|
||||||
if j < 3 {
|
if j < 3 {
|
||||||
want = color.RGBA{0xff, 0xff, 0xff, 0xff}
|
want = color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff}
|
||||||
} else {
|
} else {
|
||||||
want = color.RGBA{0, 0, 0, 0xff}
|
want = color.RGBA{A: 0xff}
|
||||||
}
|
}
|
||||||
if got != want {
|
if got != want {
|
||||||
t.Errorf("dst.At(%d, %d): filter: %d, got: %v, want: %v", i, j, f, got, want)
|
t.Errorf("dst.At(%d, %d): filter: %d, got: %v, want: %v", i, j, f, got, want)
|
||||||
@ -1245,9 +1245,9 @@ func TestImageLinearFilterGlitch2(t *testing.T) {
|
|||||||
got := dst.At(i, j).(color.RGBA)
|
got := dst.At(i, j).(color.RGBA)
|
||||||
var want color.RGBA
|
var want color.RGBA
|
||||||
if i+j < 100 {
|
if i+j < 100 {
|
||||||
want = color.RGBA{0, 0, 0, 0xff}
|
want = color.RGBA{A: 0xff}
|
||||||
} else {
|
} else {
|
||||||
want = color.RGBA{0xff, 0xff, 0xff, 0xff}
|
want = color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff}
|
||||||
}
|
}
|
||||||
if !sameColors(got, want, 1) {
|
if !sameColors(got, want, 1) {
|
||||||
t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want)
|
t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want)
|
||||||
@ -1329,7 +1329,7 @@ func TestImageAddressRepeat(t *testing.T) {
|
|||||||
for j := 0; j < h; j++ {
|
for j := 0; j < h; j++ {
|
||||||
for i := 0; i < w; i++ {
|
for i := 0; i < w; i++ {
|
||||||
got := dst.At(i, j).(color.RGBA)
|
got := dst.At(i, j).(color.RGBA)
|
||||||
want := color.RGBA{byte(i%4) * 0x10, byte(j%4) * 0x10, 0, 0xff}
|
want := color.RGBA{R: byte(i%4) * 0x10, G: byte(j%4) * 0x10, A: 0xff}
|
||||||
if !sameColors(got, want, 1) {
|
if !sameColors(got, want, 1) {
|
||||||
t.Errorf("dst.At(%d, %d): got %v, want: %v", i, j, got, want)
|
t.Errorf("dst.At(%d, %d): got %v, want: %v", i, j, got, want)
|
||||||
}
|
}
|
||||||
@ -1410,7 +1410,7 @@ func TestImageAddressRepeatNegativePosition(t *testing.T) {
|
|||||||
for j := 0; j < h; j++ {
|
for j := 0; j < h; j++ {
|
||||||
for i := 0; i < w; i++ {
|
for i := 0; i < w; i++ {
|
||||||
got := dst.At(i, j).(color.RGBA)
|
got := dst.At(i, j).(color.RGBA)
|
||||||
want := color.RGBA{byte(i%4) * 0x10, byte(j%4) * 0x10, 0, 0xff}
|
want := color.RGBA{R: byte(i%4) * 0x10, G: byte(j%4) * 0x10, A: 0xff}
|
||||||
if !sameColors(got, want, 1) {
|
if !sameColors(got, want, 1) {
|
||||||
t.Errorf("dst.At(%d, %d): got %v, want: %v", i, j, got, want)
|
t.Errorf("dst.At(%d, %d): got %v, want: %v", i, j, got, want)
|
||||||
}
|
}
|
||||||
@ -1683,8 +1683,8 @@ func TestImageAtAfterDisposingSubImage(t *testing.T) {
|
|||||||
img.SubImage(image.Rect(0, 0, 16, 16))
|
img.SubImage(image.Rect(0, 0, 16, 16))
|
||||||
runtime.GC()
|
runtime.GC()
|
||||||
|
|
||||||
want := color.RGBA{0xff, 0xff, 0xff, 0xff}
|
want := color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff}
|
||||||
want64 := color.RGBA64{0xffff, 0xffff, 0xffff, 0xffff}
|
want64 := color.RGBA64{R: 0xffff, G: 0xffff, B: 0xffff, A: 0xffff}
|
||||||
got := img.At(0, 0)
|
got := img.At(0, 0)
|
||||||
if got != want {
|
if got != want {
|
||||||
t.Errorf("At(0,0) got: %v, want: %v", got, want)
|
t.Errorf("At(0,0) got: %v, want: %v", got, want)
|
||||||
@ -1726,7 +1726,7 @@ func TestImageSubImageSubImage(t *testing.T) {
|
|||||||
{
|
{
|
||||||
X: 4,
|
X: 4,
|
||||||
Y: 4,
|
Y: 4,
|
||||||
Color: color.RGBA{0xff, 0xff, 0xff, 0xff},
|
Color: color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
X: 15,
|
X: 15,
|
||||||
@ -1755,7 +1755,7 @@ func TestImageTooSmallMipmap(t *testing.T) {
|
|||||||
op.Filter = ebiten.FilterLinear
|
op.Filter = ebiten.FilterLinear
|
||||||
dst.DrawImage(src.SubImage(image.Rect(5, 0, 6, 16)).(*ebiten.Image), op)
|
dst.DrawImage(src.SubImage(image.Rect(5, 0, 6, 16)).(*ebiten.Image), op)
|
||||||
got := dst.At(0, 0).(color.RGBA)
|
got := dst.At(0, 0).(color.RGBA)
|
||||||
want := color.RGBA{0xff, 0xff, 0xff, 0xff}
|
want := color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff}
|
||||||
if got != want {
|
if got != want {
|
||||||
t.Errorf("got: %v, want: %v", got, want)
|
t.Errorf("got: %v, want: %v", got, want)
|
||||||
}
|
}
|
||||||
@ -1792,9 +1792,9 @@ func TestImageFillingAndEdges(t *testing.T) {
|
|||||||
for j := 0; j < dsth; j++ {
|
for j := 0; j < dsth; j++ {
|
||||||
for i := 0; i < dstw; i++ {
|
for i := 0; i < dstw; i++ {
|
||||||
got := dst.At(i, j).(color.RGBA)
|
got := dst.At(i, j).(color.RGBA)
|
||||||
want := color.RGBA{0xff, 0xff, 0xff, 0xff}
|
want := color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff}
|
||||||
if i == 0 || i == dstw-1 || j == 0 || j == dsth-1 {
|
if i == 0 || i == dstw-1 || j == 0 || j == dsth-1 {
|
||||||
want = color.RGBA{0, 0, 0, 0xff}
|
want = color.RGBA{A: 0xff}
|
||||||
}
|
}
|
||||||
if got != want {
|
if got != want {
|
||||||
t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want)
|
t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want)
|
||||||
@ -1807,7 +1807,7 @@ func TestImageDrawTrianglesAndMutateArgs(t *testing.T) {
|
|||||||
const w, h = 16, 16
|
const w, h = 16, 16
|
||||||
dst := ebiten.NewImage(w, h)
|
dst := ebiten.NewImage(w, h)
|
||||||
src := ebiten.NewImage(w, h)
|
src := ebiten.NewImage(w, h)
|
||||||
clr := color.RGBA{0xff, 0, 0, 0xff}
|
clr := color.RGBA{R: 0xff, A: 0xff}
|
||||||
src.Fill(clr)
|
src.Fill(clr)
|
||||||
|
|
||||||
vs := []ebiten.Vertex{
|
vs := []ebiten.Vertex{
|
||||||
@ -1871,7 +1871,7 @@ func TestImageDrawTrianglesAndMutateArgs(t *testing.T) {
|
|||||||
|
|
||||||
func TestImageWritePixelsOnSubImage(t *testing.T) {
|
func TestImageWritePixelsOnSubImage(t *testing.T) {
|
||||||
dst := ebiten.NewImage(17, 31)
|
dst := ebiten.NewImage(17, 31)
|
||||||
dst.Fill(color.RGBA{0xff, 0, 0, 0xff})
|
dst.Fill(color.RGBA{R: 0xff, A: 0xff})
|
||||||
|
|
||||||
pix0 := make([]byte, 4*5*3)
|
pix0 := make([]byte, 4*5*3)
|
||||||
idx := 0
|
idx := 0
|
||||||
@ -1916,13 +1916,13 @@ func TestImageWritePixelsOnSubImage(t *testing.T) {
|
|||||||
for j := 0; j < 31; j++ {
|
for j := 0; j < 31; j++ {
|
||||||
for i := 0; i < 17; i++ {
|
for i := 0; i < 17; i++ {
|
||||||
got := dst.At(i, j).(color.RGBA)
|
got := dst.At(i, j).(color.RGBA)
|
||||||
want := color.RGBA{0xff, 0, 0, 0xff}
|
want := color.RGBA{R: 0xff, A: 0xff}
|
||||||
p := image.Pt(i, j)
|
p := image.Pt(i, j)
|
||||||
switch {
|
switch {
|
||||||
case p.In(r0):
|
case p.In(r0):
|
||||||
want = color.RGBA{0, 0xff, 0, 0xff}
|
want = color.RGBA{G: 0xff, A: 0xff}
|
||||||
case p.In(r1):
|
case p.In(r1):
|
||||||
want = color.RGBA{0, 0, 0xff, 0xff}
|
want = color.RGBA{B: 0xff, A: 0xff}
|
||||||
}
|
}
|
||||||
if got != want {
|
if got != want {
|
||||||
t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want)
|
t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want)
|
||||||
@ -2120,7 +2120,7 @@ func TestImageDrawTrianglesInterpolatesColors(t *testing.T) {
|
|||||||
format := format
|
format := format
|
||||||
t.Run(fmt.Sprintf("format%d", format), func(t *testing.T) {
|
t.Run(fmt.Sprintf("format%d", format), func(t *testing.T) {
|
||||||
dst := ebiten.NewImage(w, h)
|
dst := ebiten.NewImage(w, h)
|
||||||
dst.Fill(color.RGBA{0x00, 0x00, 0xff, 0xff})
|
dst.Fill(color.RGBA{B: 0xff, A: 0xff})
|
||||||
|
|
||||||
op := &ebiten.DrawTrianglesOptions{}
|
op := &ebiten.DrawTrianglesOptions{}
|
||||||
op.ColorScaleMode = format
|
op.ColorScaleMode = format
|
||||||
@ -2135,9 +2135,9 @@ func TestImageDrawTrianglesInterpolatesColors(t *testing.T) {
|
|||||||
var want color.RGBA
|
var want color.RGBA
|
||||||
switch format {
|
switch format {
|
||||||
case ebiten.ColorScaleModeStraightAlpha:
|
case ebiten.ColorScaleModeStraightAlpha:
|
||||||
want = color.RGBA{0x00, 0x80, 0x80, 0xff}
|
want = color.RGBA{G: 0x80, B: 0x80, A: 0xff}
|
||||||
case ebiten.ColorScaleModePremultipliedAlpha:
|
case ebiten.ColorScaleModePremultipliedAlpha:
|
||||||
want = color.RGBA{0x80, 0x80, 0x80, 0xff}
|
want = color.RGBA{R: 0x80, G: 0x80, B: 0x80, A: 0xff}
|
||||||
}
|
}
|
||||||
|
|
||||||
if !sameColors(got, want, 2) {
|
if !sameColors(got, want, 2) {
|
||||||
@ -2195,7 +2195,7 @@ func TestImageDrawTrianglesShaderInterpolatesValues(t *testing.T) {
|
|||||||
ColorA: 1,
|
ColorA: 1,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
dst.Fill(color.RGBA{0x00, 0x00, 0xff, 0xff})
|
dst.Fill(color.RGBA{B: 0xff, A: 0xff})
|
||||||
op := &ebiten.DrawTrianglesShaderOptions{
|
op := &ebiten.DrawTrianglesShaderOptions{
|
||||||
Images: [4]*ebiten.Image{src, nil, nil, nil},
|
Images: [4]*ebiten.Image{src, nil, nil, nil},
|
||||||
}
|
}
|
||||||
@ -2214,7 +2214,7 @@ func TestImageDrawTrianglesShaderInterpolatesValues(t *testing.T) {
|
|||||||
got := dst.At(1, 0).(color.RGBA)
|
got := dst.At(1, 0).(color.RGBA)
|
||||||
|
|
||||||
// Shaders get each color value interpolated independently.
|
// Shaders get each color value interpolated independently.
|
||||||
want := color.RGBA{0x80, 0x80, 0x80, 0xff}
|
want := color.RGBA{R: 0x80, G: 0x80, B: 0x80, A: 0xff}
|
||||||
|
|
||||||
if !sameColors(got, want, 2) {
|
if !sameColors(got, want, 2) {
|
||||||
t.Errorf("At(1, 0): got: %v, want: %v", got, want)
|
t.Errorf("At(1, 0): got: %v, want: %v", got, want)
|
||||||
@ -2228,13 +2228,13 @@ func TestImageDrawOver(t *testing.T) {
|
|||||||
h = 240
|
h = 240
|
||||||
)
|
)
|
||||||
dst := ebiten.NewImage(w, h)
|
dst := ebiten.NewImage(w, h)
|
||||||
src := image.NewUniform(color.RGBA{0xff, 0, 0, 0xff})
|
src := image.NewUniform(color.RGBA{R: 0xff, A: 0xff})
|
||||||
// This must not cause infinite-loop.
|
// This must not cause infinite-loop.
|
||||||
draw.Draw(dst, dst.Bounds(), src, image.ZP, draw.Over)
|
draw.Draw(dst, dst.Bounds(), src, image.ZP, draw.Over)
|
||||||
for j := 0; j < h; j++ {
|
for j := 0; j < h; j++ {
|
||||||
for i := 0; i < w; i++ {
|
for i := 0; i < w; i++ {
|
||||||
got := dst.At(i, j)
|
got := dst.At(i, j)
|
||||||
want := color.RGBA{0xff, 0, 0, 0xff}
|
want := color.RGBA{R: 0xff, A: 0xff}
|
||||||
if got != want {
|
if got != want {
|
||||||
t.Errorf("At(%d, %d): got: %v, want: %v", i, j, got, want)
|
t.Errorf("At(%d, %d): got: %v, want: %v", i, j, got, want)
|
||||||
}
|
}
|
||||||
@ -2288,7 +2288,7 @@ func TestImageFloatTranslate(t *testing.T) {
|
|||||||
t.Run(fmt.Sprintf("scale%d", s), func(t *testing.T) {
|
t.Run(fmt.Sprintf("scale%d", s), func(t *testing.T) {
|
||||||
check := func(src *ebiten.Image) {
|
check := func(src *ebiten.Image) {
|
||||||
dst := ebiten.NewImage(w*(s+1), h*(s+1))
|
dst := ebiten.NewImage(w*(s+1), h*(s+1))
|
||||||
dst.Fill(color.RGBA{0xff, 0, 0, 0xff})
|
dst.Fill(color.RGBA{R: 0xff, A: 0xff})
|
||||||
|
|
||||||
op := &ebiten.DrawImageOptions{}
|
op := &ebiten.DrawImageOptions{}
|
||||||
op.GeoM.Scale(float64(s), float64(s))
|
op.GeoM.Scale(float64(s), float64(s))
|
||||||
@ -2302,7 +2302,7 @@ func TestImageFloatTranslate(t *testing.T) {
|
|||||||
if j > 0 {
|
if j > 0 {
|
||||||
x = (byte(j) - 1) / byte(s)
|
x = (byte(j) - 1) / byte(s)
|
||||||
}
|
}
|
||||||
want := color.RGBA{x, 0, 0, 0xff}
|
want := color.RGBA{R: x, A: 0xff}
|
||||||
if got != want {
|
if got != want {
|
||||||
t.Errorf("At(%d, %d): got: %v, want: %v", i, j, got, want)
|
t.Errorf("At(%d, %d): got: %v, want: %v", i, j, got, want)
|
||||||
}
|
}
|
||||||
@ -2354,7 +2354,7 @@ func TestImageColorMCopy(t *testing.T) {
|
|||||||
for j := 0; j < h; j++ {
|
for j := 0; j < h; j++ {
|
||||||
for i := 0; i < w; i++ {
|
for i := 0; i < w; i++ {
|
||||||
got := dst.At(i, j).(color.RGBA)
|
got := dst.At(i, j).(color.RGBA)
|
||||||
want := color.RGBA{byte(k), byte(k), byte(k), byte(k)}
|
want := color.RGBA{R: byte(k), G: byte(k), B: byte(k), A: byte(k)}
|
||||||
if !sameColors(got, want, 1) {
|
if !sameColors(got, want, 1) {
|
||||||
t.Fatalf("dst.At(%d, %d), k: %d: got %v, want %v", i, j, k, got, want)
|
t.Fatalf("dst.At(%d, %d), k: %d: got %v, want %v", i, j, k, got, want)
|
||||||
}
|
}
|
||||||
@ -2399,7 +2399,7 @@ func TestImageWritePixelsAndModifyPixels(t *testing.T) {
|
|||||||
for j := 0; j < h; j++ {
|
for j := 0; j < h; j++ {
|
||||||
for i := 0; i < w; i++ {
|
for i := 0; i < w; i++ {
|
||||||
got := src.At(i, j).(color.RGBA)
|
got := src.At(i, j).(color.RGBA)
|
||||||
want := color.RGBA{0xff, 0, 0, 0xff}
|
want := color.RGBA{R: 0xff, A: 0xff}
|
||||||
if got != want {
|
if got != want {
|
||||||
t.Errorf("src.At(%d, %d): got: %v, want: %v", i, j, got, want)
|
t.Errorf("src.At(%d, %d): got: %v, want: %v", i, j, got, want)
|
||||||
}
|
}
|
||||||
@ -2412,8 +2412,8 @@ func TestImageCompositeModeMultiply(t *testing.T) {
|
|||||||
dst := ebiten.NewImage(w, h)
|
dst := ebiten.NewImage(w, h)
|
||||||
src := ebiten.NewImage(w, h)
|
src := ebiten.NewImage(w, h)
|
||||||
|
|
||||||
dst.Fill(color.RGBA{0x10, 0x20, 0x30, 0x40})
|
dst.Fill(color.RGBA{R: 0x10, G: 0x20, B: 0x30, A: 0x40})
|
||||||
src.Fill(color.RGBA{0x50, 0x60, 0x70, 0x80})
|
src.Fill(color.RGBA{R: 0x50, G: 0x60, B: 0x70, A: 0x80})
|
||||||
|
|
||||||
op := &ebiten.DrawImageOptions{}
|
op := &ebiten.DrawImageOptions{}
|
||||||
op.CompositeMode = ebiten.CompositeModeMultiply
|
op.CompositeMode = ebiten.CompositeModeMultiply
|
||||||
@ -2507,16 +2507,16 @@ func TestImageClip(t *testing.T) {
|
|||||||
dst := ebiten.NewImage(w, h)
|
dst := ebiten.NewImage(w, h)
|
||||||
src := ebiten.NewImage(w, h)
|
src := ebiten.NewImage(w, h)
|
||||||
|
|
||||||
dst.Fill(color.RGBA{0xff, 0, 0, 0xff})
|
dst.Fill(color.RGBA{R: 0xff, A: 0xff})
|
||||||
src.Fill(color.RGBA{0, 0xff, 0, 0xff})
|
src.Fill(color.RGBA{G: 0xff, A: 0xff})
|
||||||
|
|
||||||
dst.SubImage(image.Rect(4, 5, 12, 14)).(*ebiten.Image).DrawImage(src, nil)
|
dst.SubImage(image.Rect(4, 5, 12, 14)).(*ebiten.Image).DrawImage(src, nil)
|
||||||
for j := 0; j < h; j++ {
|
for j := 0; j < h; j++ {
|
||||||
for i := 0; i < w; i++ {
|
for i := 0; i < w; i++ {
|
||||||
got := dst.At(i, j).(color.RGBA)
|
got := dst.At(i, j).(color.RGBA)
|
||||||
want := color.RGBA{0xff, 0, 0, 0xff}
|
want := color.RGBA{R: 0xff, A: 0xff}
|
||||||
if 4 <= i && i < 12 && 5 <= j && j < 14 {
|
if 4 <= i && i < 12 && 5 <= j && j < 14 {
|
||||||
want = color.RGBA{0, 0xff, 0, 0xff}
|
want = color.RGBA{G: 0xff, A: 0xff}
|
||||||
}
|
}
|
||||||
if got != want {
|
if got != want {
|
||||||
t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want)
|
t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want)
|
||||||
@ -2534,7 +2534,7 @@ func TestImageSubImageFill(t *testing.T) {
|
|||||||
got := dst.At(i, j)
|
got := dst.At(i, j)
|
||||||
var want color.RGBA
|
var want color.RGBA
|
||||||
if i == 1 && j == 1 {
|
if i == 1 && j == 1 {
|
||||||
want = color.RGBA{0xff, 0xff, 0xff, 0xff}
|
want = color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff}
|
||||||
}
|
}
|
||||||
if got != want {
|
if got != want {
|
||||||
t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want)
|
t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want)
|
||||||
@ -2549,7 +2549,7 @@ func TestImageSubImageFill(t *testing.T) {
|
|||||||
got := dst.At(i, j)
|
got := dst.At(i, j)
|
||||||
var want color.RGBA
|
var want color.RGBA
|
||||||
if 3 <= i && i < 8 && 4 <= j && j < 10 {
|
if 3 <= i && i < 8 && 4 <= j && j < 10 {
|
||||||
want = color.RGBA{0xff, 0xff, 0xff, 0xff}
|
want = color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff}
|
||||||
}
|
}
|
||||||
if got != want {
|
if got != want {
|
||||||
t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want)
|
t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want)
|
||||||
@ -2635,13 +2635,13 @@ func TestImageEvenOdd(t *testing.T) {
|
|||||||
var want color.RGBA
|
var want color.RGBA
|
||||||
switch {
|
switch {
|
||||||
case 3 <= i && i < 13 && 3 <= j && j < 13:
|
case 3 <= i && i < 13 && 3 <= j && j < 13:
|
||||||
want = color.RGBA{0, 0, 0xff, 0xff}
|
want = color.RGBA{B: 0xff, A: 0xff}
|
||||||
case 2 <= i && i < 14 && 2 <= j && j < 14:
|
case 2 <= i && i < 14 && 2 <= j && j < 14:
|
||||||
want = color.RGBA{0, 0, 0, 0}
|
want = color.RGBA{}
|
||||||
case 1 <= i && i < 15 && 1 <= j && j < 15:
|
case 1 <= i && i < 15 && 1 <= j && j < 15:
|
||||||
want = color.RGBA{0xff, 0, 0, 0xff}
|
want = color.RGBA{R: 0xff, A: 0xff}
|
||||||
default:
|
default:
|
||||||
want = color.RGBA{0, 0, 0, 0}
|
want = color.RGBA{}
|
||||||
}
|
}
|
||||||
if got != want {
|
if got != want {
|
||||||
t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want)
|
t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want)
|
||||||
@ -2670,13 +2670,13 @@ func TestImageEvenOdd(t *testing.T) {
|
|||||||
var want color.RGBA
|
var want color.RGBA
|
||||||
switch {
|
switch {
|
||||||
case 4 <= i && i < 14 && 4 <= j && j < 14:
|
case 4 <= i && i < 14 && 4 <= j && j < 14:
|
||||||
want = color.RGBA{0, 0, 0xff, 0xff}
|
want = color.RGBA{B: 0xff, A: 0xff}
|
||||||
case 3 <= i && i < 15 && 3 <= j && j < 15:
|
case 3 <= i && i < 15 && 3 <= j && j < 15:
|
||||||
want = color.RGBA{0, 0, 0, 0}
|
want = color.RGBA{}
|
||||||
case 2 <= i && i < 16 && 2 <= j && j < 16:
|
case 2 <= i && i < 16 && 2 <= j && j < 16:
|
||||||
want = color.RGBA{0xff, 0, 0, 0xff}
|
want = color.RGBA{R: 0xff, A: 0xff}
|
||||||
default:
|
default:
|
||||||
want = color.RGBA{0, 0, 0, 0}
|
want = color.RGBA{}
|
||||||
}
|
}
|
||||||
if got != want {
|
if got != want {
|
||||||
t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want)
|
t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want)
|
||||||
@ -2708,13 +2708,13 @@ func TestImageEvenOdd(t *testing.T) {
|
|||||||
var want color.RGBA
|
var want color.RGBA
|
||||||
switch {
|
switch {
|
||||||
case 3 <= i && i < 13 && 3 <= j && j < 13:
|
case 3 <= i && i < 13 && 3 <= j && j < 13:
|
||||||
want = color.RGBA{0, 0, 0xff, 0xff}
|
want = color.RGBA{B: 0xff, A: 0xff}
|
||||||
case 2 <= i && i < 14 && 2 <= j && j < 14:
|
case 2 <= i && i < 14 && 2 <= j && j < 14:
|
||||||
want = color.RGBA{0, 0xff, 0, 0xff}
|
want = color.RGBA{G: 0xff, A: 0xff}
|
||||||
case 1 <= i && i < 15 && 1 <= j && j < 15:
|
case 1 <= i && i < 15 && 1 <= j && j < 15:
|
||||||
want = color.RGBA{0xff, 0, 0, 0xff}
|
want = color.RGBA{R: 0xff, A: 0xff}
|
||||||
default:
|
default:
|
||||||
want = color.RGBA{0, 0, 0, 0}
|
want = color.RGBA{}
|
||||||
}
|
}
|
||||||
if got != want {
|
if got != want {
|
||||||
t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want)
|
t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want)
|
||||||
@ -2799,7 +2799,7 @@ func TestIndicesOverflow(t *testing.T) {
|
|||||||
for j := 0; j < h; j++ {
|
for j := 0; j < h; j++ {
|
||||||
for i := 0; i < w; i++ {
|
for i := 0; i < w; i++ {
|
||||||
got := dst.At(i, j)
|
got := dst.At(i, j)
|
||||||
want := color.RGBA{0xff, 0xff, 0xff, 0xff}
|
want := color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff}
|
||||||
if got != want {
|
if got != want {
|
||||||
t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want)
|
t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want)
|
||||||
}
|
}
|
||||||
@ -2871,7 +2871,7 @@ func TestVerticesOverflow(t *testing.T) {
|
|||||||
for j := 0; j < h; j++ {
|
for j := 0; j < h; j++ {
|
||||||
for i := 0; i < w; i++ {
|
for i := 0; i < w; i++ {
|
||||||
got := dst.At(i, j)
|
got := dst.At(i, j)
|
||||||
want := color.RGBA{0xff, 0xff, 0xff, 0xff}
|
want := color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff}
|
||||||
if got != want {
|
if got != want {
|
||||||
t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want)
|
t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want)
|
||||||
}
|
}
|
||||||
@ -2923,7 +2923,7 @@ func TestImageNewImageFromEbitenImage(t *testing.T) {
|
|||||||
for j := 0; j < h; j++ {
|
for j := 0; j < h; j++ {
|
||||||
for i := 0; i < w; i++ {
|
for i := 0; i < w; i++ {
|
||||||
got := img1.At(i, j)
|
got := img1.At(i, j)
|
||||||
want := color.RGBA{byte(i), byte(j), 0, 0xff}
|
want := color.RGBA{R: byte(i), G: byte(j), A: 0xff}
|
||||||
if got != want {
|
if got != want {
|
||||||
t.Errorf("img1.At(%d, %d): got: %v, want: %v", i, j, got, want)
|
t.Errorf("img1.At(%d, %d): got: %v, want: %v", i, j, got, want)
|
||||||
}
|
}
|
||||||
@ -2934,7 +2934,7 @@ func TestImageNewImageFromEbitenImage(t *testing.T) {
|
|||||||
for j := 0; j < h/2; j++ {
|
for j := 0; j < h/2; j++ {
|
||||||
for i := 0; i < w/2; i++ {
|
for i := 0; i < w/2; i++ {
|
||||||
got := img2.At(i, j)
|
got := img2.At(i, j)
|
||||||
want := color.RGBA{byte(i + 4), byte(j + 4), 0, 0xff}
|
want := color.RGBA{R: byte(i + 4), G: byte(j + 4), A: 0xff}
|
||||||
if got != want {
|
if got != want {
|
||||||
t.Errorf("img1.At(%d, %d): got: %v, want: %v", i, j, got, want)
|
t.Errorf("img1.At(%d, %d): got: %v, want: %v", i, j, got, want)
|
||||||
}
|
}
|
||||||
@ -2968,7 +2968,7 @@ func TestImageOptionsUnmanaged(t *testing.T) {
|
|||||||
for j := 0; j < h; j++ {
|
for j := 0; j < h; j++ {
|
||||||
for i := 0; i < w; i++ {
|
for i := 0; i < w; i++ {
|
||||||
got := img.At(i, j)
|
got := img.At(i, j)
|
||||||
want := color.RGBA{byte(i), byte(j), 0, 0xff}
|
want := color.RGBA{R: byte(i), G: byte(j), A: 0xff}
|
||||||
if got != want {
|
if got != want {
|
||||||
t.Errorf("img.At(%d, %d): got: %v, want: %v", i, j, got, want)
|
t.Errorf("img.At(%d, %d): got: %v, want: %v", i, j, got, want)
|
||||||
}
|
}
|
||||||
@ -3000,7 +3000,7 @@ func TestImageOptionsNegativeBoundsWritePixels(t *testing.T) {
|
|||||||
for j := offset; j < h+offset; j++ {
|
for j := offset; j < h+offset; j++ {
|
||||||
for i := offset; i < w+offset; i++ {
|
for i := offset; i < w+offset; i++ {
|
||||||
got := img.At(i, j)
|
got := img.At(i, j)
|
||||||
want := color.RGBA{byte(i - offset), byte(j - offset), 0, 0xff}
|
want := color.RGBA{R: byte(i - offset), G: byte(j - offset), A: 0xff}
|
||||||
if got != want {
|
if got != want {
|
||||||
t.Errorf("img.At(%d, %d): got: %v, want: %v", i, j, got, want)
|
t.Errorf("img.At(%d, %d): got: %v, want: %v", i, j, got, want)
|
||||||
}
|
}
|
||||||
@ -3024,9 +3024,9 @@ func TestImageOptionsNegativeBoundsWritePixels(t *testing.T) {
|
|||||||
for j := offset; j < h+offset; j++ {
|
for j := offset; j < h+offset; j++ {
|
||||||
for i := offset; i < w+offset; i++ {
|
for i := offset; i < w+offset; i++ {
|
||||||
got := img.At(i, j)
|
got := img.At(i, j)
|
||||||
want := color.RGBA{byte(i - offset), byte(j - offset), 0, 0xff}
|
want := color.RGBA{R: byte(i - offset), G: byte(j - offset), A: 0xff}
|
||||||
if image.Pt(i, j).In(sub) {
|
if image.Pt(i, j).In(sub) {
|
||||||
want = color.RGBA{0, 0, 0xff, 0xff}
|
want = color.RGBA{B: 0xff, A: 0xff}
|
||||||
}
|
}
|
||||||
if got != want {
|
if got != want {
|
||||||
t.Errorf("img.At(%d, %d): got: %v, want: %v", i, j, got, want)
|
t.Errorf("img.At(%d, %d): got: %v, want: %v", i, j, got, want)
|
||||||
@ -3055,14 +3055,14 @@ func TestImageOptionsNegativeBoundsSet(t *testing.T) {
|
|||||||
const offset = -8
|
const offset = -8
|
||||||
img := ebiten.NewImageWithOptions(image.Rect(offset, offset, w+offset, h+offset), nil)
|
img := ebiten.NewImageWithOptions(image.Rect(offset, offset, w+offset, h+offset), nil)
|
||||||
img.WritePixels(pix0)
|
img.WritePixels(pix0)
|
||||||
img.Set(-1, -2, color.RGBA{0, 0, 0, 0})
|
img.Set(-1, -2, color.RGBA{})
|
||||||
|
|
||||||
for j := offset; j < h+offset; j++ {
|
for j := offset; j < h+offset; j++ {
|
||||||
for i := offset; i < w+offset; i++ {
|
for i := offset; i < w+offset; i++ {
|
||||||
got := img.At(i, j)
|
got := img.At(i, j)
|
||||||
want := color.RGBA{byte(i - offset), byte(j - offset), 0, 0xff}
|
want := color.RGBA{R: byte(i - offset), G: byte(j - offset), A: 0xff}
|
||||||
if i == -1 && j == -2 {
|
if i == -1 && j == -2 {
|
||||||
want = color.RGBA{0, 0, 0, 0}
|
want = color.RGBA{}
|
||||||
}
|
}
|
||||||
if got != want {
|
if got != want {
|
||||||
t.Errorf("img.At(%d, %d): got: %v, want: %v", i, j, got, want)
|
t.Errorf("img.At(%d, %d): got: %v, want: %v", i, j, got, want)
|
||||||
@ -3094,7 +3094,7 @@ func TestImageOptionsNegativeBoundsDrawImage(t *testing.T) {
|
|||||||
got := dst.At(i, j)
|
got := dst.At(i, j)
|
||||||
var want color.RGBA
|
var want color.RGBA
|
||||||
if -2 <= i && i < 2 && -3 <= j && j < 3 {
|
if -2 <= i && i < 2 && -3 <= j && j < 3 {
|
||||||
want = color.RGBA{0xff, 0xff, 0xff, 0xff}
|
want = color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff}
|
||||||
}
|
}
|
||||||
if got != want {
|
if got != want {
|
||||||
t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want)
|
t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want)
|
||||||
@ -3165,7 +3165,7 @@ func TestImageOptionsNegativeBoundsDrawTriangles(t *testing.T) {
|
|||||||
got := dst.At(i, j)
|
got := dst.At(i, j)
|
||||||
var want color.RGBA
|
var want color.RGBA
|
||||||
if -2 <= i && i < 2 && -3 <= j && j < 3 {
|
if -2 <= i && i < 2 && -3 <= j && j < 3 {
|
||||||
want = color.RGBA{0xff, 0xff, 0xff, 0xff}
|
want = color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff}
|
||||||
}
|
}
|
||||||
if got != want {
|
if got != want {
|
||||||
t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want)
|
t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want)
|
||||||
@ -3197,7 +3197,7 @@ func TestImageFromImageOptions(t *testing.T) {
|
|||||||
for j := r.Min.Y; j < r.Max.Y; j++ {
|
for j := r.Min.Y; j < r.Max.Y; j++ {
|
||||||
for i := r.Min.X; i < r.Max.X; i++ {
|
for i := r.Min.X; i < r.Max.X; i++ {
|
||||||
got := img.At(i, j)
|
got := img.At(i, j)
|
||||||
want := color.RGBA{0xff, 0xff, 0xff, 0xff}
|
want := color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff}
|
||||||
if got != want {
|
if got != want {
|
||||||
t.Errorf("img.At(%d, %d): got: %v, want: %v", i, j, got, want)
|
t.Errorf("img.At(%d, %d): got: %v, want: %v", i, j, got, want)
|
||||||
}
|
}
|
||||||
@ -3225,7 +3225,7 @@ func TestImageFromEbitenImageOptions(t *testing.T) {
|
|||||||
for j := r.Min.Y; j < r.Max.Y; j++ {
|
for j := r.Min.Y; j < r.Max.Y; j++ {
|
||||||
for i := r.Min.X; i < r.Max.X; i++ {
|
for i := r.Min.X; i < r.Max.X; i++ {
|
||||||
got := img.At(i, j)
|
got := img.At(i, j)
|
||||||
want := color.RGBA{0xff, 0xff, 0xff, 0xff}
|
want := color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff}
|
||||||
if got != want {
|
if got != want {
|
||||||
t.Errorf("img.At(%d, %d): got: %v, want: %v", i, j, got, want)
|
t.Errorf("img.At(%d, %d): got: %v, want: %v", i, j, got, want)
|
||||||
}
|
}
|
||||||
@ -3237,11 +3237,11 @@ func TestImageFromEbitenImageOptions(t *testing.T) {
|
|||||||
func TestImageOptionsFill(t *testing.T) {
|
func TestImageOptionsFill(t *testing.T) {
|
||||||
r0 := image.Rect(-2, -3, 4, 5)
|
r0 := image.Rect(-2, -3, 4, 5)
|
||||||
img := ebiten.NewImageWithOptions(r0, nil)
|
img := ebiten.NewImageWithOptions(r0, nil)
|
||||||
img.Fill(color.RGBA{0xff, 0, 0, 0xff})
|
img.Fill(color.RGBA{R: 0xff, A: 0xff})
|
||||||
for j := r0.Min.Y; j < r0.Max.Y; j++ {
|
for j := r0.Min.Y; j < r0.Max.Y; j++ {
|
||||||
for i := r0.Min.X; i < r0.Max.X; i++ {
|
for i := r0.Min.X; i < r0.Max.X; i++ {
|
||||||
got := img.At(i, j)
|
got := img.At(i, j)
|
||||||
want := color.RGBA{0xff, 0, 0, 0xff}
|
want := color.RGBA{R: 0xff, A: 0xff}
|
||||||
if got != want {
|
if got != want {
|
||||||
t.Errorf("img.At(%d, %d): got: %v, want: %v", i, j, got, want)
|
t.Errorf("img.At(%d, %d): got: %v, want: %v", i, j, got, want)
|
||||||
}
|
}
|
||||||
@ -3249,13 +3249,13 @@ func TestImageOptionsFill(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
r1 := image.Rect(-1, -2, 3, 4)
|
r1 := image.Rect(-1, -2, 3, 4)
|
||||||
img.SubImage(r1).(*ebiten.Image).Fill(color.RGBA{0, 0xff, 0, 0xff})
|
img.SubImage(r1).(*ebiten.Image).Fill(color.RGBA{G: 0xff, A: 0xff})
|
||||||
for j := r0.Min.Y; j < r0.Max.Y; j++ {
|
for j := r0.Min.Y; j < r0.Max.Y; j++ {
|
||||||
for i := r0.Min.X; i < r0.Max.X; i++ {
|
for i := r0.Min.X; i < r0.Max.X; i++ {
|
||||||
got := img.At(i, j)
|
got := img.At(i, j)
|
||||||
want := color.RGBA{0xff, 0, 0, 0xff}
|
want := color.RGBA{R: 0xff, A: 0xff}
|
||||||
if image.Pt(i, j).In(r1) {
|
if image.Pt(i, j).In(r1) {
|
||||||
want = color.RGBA{0, 0xff, 0, 0xff}
|
want = color.RGBA{G: 0xff, A: 0xff}
|
||||||
}
|
}
|
||||||
if got != want {
|
if got != want {
|
||||||
t.Errorf("img.At(%d, %d): got: %v, want: %v", i, j, got, want)
|
t.Errorf("img.At(%d, %d): got: %v, want: %v", i, j, got, want)
|
||||||
@ -3268,27 +3268,27 @@ func TestImageOptionsFill(t *testing.T) {
|
|||||||
func TestImageOptionsClear(t *testing.T) {
|
func TestImageOptionsClear(t *testing.T) {
|
||||||
r0 := image.Rect(-2, -3, 4, 5)
|
r0 := image.Rect(-2, -3, 4, 5)
|
||||||
img := ebiten.NewImageWithOptions(r0, nil)
|
img := ebiten.NewImageWithOptions(r0, nil)
|
||||||
img.Fill(color.RGBA{0xff, 0, 0, 0xff})
|
img.Fill(color.RGBA{R: 0xff, A: 0xff})
|
||||||
img.Clear()
|
img.Clear()
|
||||||
for j := r0.Min.Y; j < r0.Max.Y; j++ {
|
for j := r0.Min.Y; j < r0.Max.Y; j++ {
|
||||||
for i := r0.Min.X; i < r0.Max.X; i++ {
|
for i := r0.Min.X; i < r0.Max.X; i++ {
|
||||||
got := img.At(i, j)
|
got := img.At(i, j)
|
||||||
want := color.RGBA{0, 0, 0, 0}
|
want := color.RGBA{}
|
||||||
if got != want {
|
if got != want {
|
||||||
t.Errorf("img.At(%d, %d): got: %v, want: %v", i, j, got, want)
|
t.Errorf("img.At(%d, %d): got: %v, want: %v", i, j, got, want)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
img.Fill(color.RGBA{0xff, 0, 0, 0xff})
|
img.Fill(color.RGBA{R: 0xff, A: 0xff})
|
||||||
r1 := image.Rect(-1, -2, 3, 4)
|
r1 := image.Rect(-1, -2, 3, 4)
|
||||||
img.SubImage(r1).(*ebiten.Image).Clear()
|
img.SubImage(r1).(*ebiten.Image).Clear()
|
||||||
for j := r0.Min.Y; j < r0.Max.Y; j++ {
|
for j := r0.Min.Y; j < r0.Max.Y; j++ {
|
||||||
for i := r0.Min.X; i < r0.Max.X; i++ {
|
for i := r0.Min.X; i < r0.Max.X; i++ {
|
||||||
got := img.At(i, j)
|
got := img.At(i, j)
|
||||||
want := color.RGBA{0xff, 0, 0, 0xff}
|
want := color.RGBA{R: 0xff, A: 0xff}
|
||||||
if image.Pt(i, j).In(r1) {
|
if image.Pt(i, j).In(r1) {
|
||||||
want = color.RGBA{0, 0, 0, 0}
|
want = color.RGBA{}
|
||||||
}
|
}
|
||||||
if got != want {
|
if got != want {
|
||||||
t.Errorf("img.At(%d, %d): got: %v, want: %v", i, j, got, want)
|
t.Errorf("img.At(%d, %d): got: %v, want: %v", i, j, got, want)
|
||||||
@ -3300,7 +3300,7 @@ func TestImageOptionsClear(t *testing.T) {
|
|||||||
// Issue #2178
|
// Issue #2178
|
||||||
func TestImageTooManyDrawImage(t *testing.T) {
|
func TestImageTooManyDrawImage(t *testing.T) {
|
||||||
src := ebiten.NewImage(1, 1)
|
src := ebiten.NewImage(1, 1)
|
||||||
src.Fill(color.RGBA{0xff, 0xff, 0xff, 0xff})
|
src.Fill(color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff})
|
||||||
|
|
||||||
const (
|
const (
|
||||||
w = 256
|
w = 256
|
||||||
@ -3319,7 +3319,7 @@ func TestImageTooManyDrawImage(t *testing.T) {
|
|||||||
|
|
||||||
for j := 0; j < h; j++ {
|
for j := 0; j < h; j++ {
|
||||||
for i := 0; i < w; i++ {
|
for i := 0; i < w; i++ {
|
||||||
if got, want := dst.At(i, j), (color.RGBA{0xff, 0xff, 0xff, 0xff}); got != want {
|
if got, want := dst.At(i, j), (color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff}); got != want {
|
||||||
t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want)
|
t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3329,7 +3329,7 @@ func TestImageTooManyDrawImage(t *testing.T) {
|
|||||||
// Issue #2178
|
// Issue #2178
|
||||||
func TestImageTooManyDrawTriangles(t *testing.T) {
|
func TestImageTooManyDrawTriangles(t *testing.T) {
|
||||||
img := ebiten.NewImage(3, 3)
|
img := ebiten.NewImage(3, 3)
|
||||||
img.Fill(color.RGBA{0xff, 0xff, 0xff, 0xff})
|
img.Fill(color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff})
|
||||||
src := img.SubImage(image.Rect(1, 1, 2, 2)).(*ebiten.Image)
|
src := img.SubImage(image.Rect(1, 1, 2, 2)).(*ebiten.Image)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -3392,7 +3392,7 @@ func TestImageTooManyDrawTriangles(t *testing.T) {
|
|||||||
|
|
||||||
for j := 0; j < h; j++ {
|
for j := 0; j < h; j++ {
|
||||||
for i := 0; i < w; i++ {
|
for i := 0; i < w; i++ {
|
||||||
if got, want := dst.At(i, j), (color.RGBA{0xff, 0xff, 0xff, 0xff}); got != want {
|
if got, want := dst.At(i, j), (color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff}); got != want {
|
||||||
t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want)
|
t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3401,26 +3401,26 @@ func TestImageTooManyDrawTriangles(t *testing.T) {
|
|||||||
|
|
||||||
func TestImageSetOverSet(t *testing.T) {
|
func TestImageSetOverSet(t *testing.T) {
|
||||||
img := ebiten.NewImage(1, 1)
|
img := ebiten.NewImage(1, 1)
|
||||||
img.Set(0, 0, color.RGBA{0xff, 0xff, 0xff, 0xff})
|
img.Set(0, 0, color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff})
|
||||||
if got, want := img.At(0, 0), (color.RGBA{0xff, 0xff, 0xff, 0xff}); got != want {
|
if got, want := img.At(0, 0), (color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff}); got != want {
|
||||||
t.Errorf("got: %v, want: %v", got, want)
|
t.Errorf("got: %v, want: %v", got, want)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply the change by 'Set' by calling DrawImage.
|
// Apply the change by 'Set' by calling DrawImage.
|
||||||
dummy := ebiten.NewImage(1, 1)
|
dummy := ebiten.NewImage(1, 1)
|
||||||
img.DrawImage(dummy, nil)
|
img.DrawImage(dummy, nil)
|
||||||
if got, want := img.At(0, 0), (color.RGBA{0xff, 0xff, 0xff, 0xff}); got != want {
|
if got, want := img.At(0, 0), (color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff}); got != want {
|
||||||
t.Errorf("got: %v, want: %v", got, want)
|
t.Errorf("got: %v, want: %v", got, want)
|
||||||
}
|
}
|
||||||
|
|
||||||
img.Set(0, 0, color.RGBA{0x80, 0x80, 0x80, 0x80})
|
img.Set(0, 0, color.RGBA{R: 0x80, G: 0x80, B: 0x80, A: 0x80})
|
||||||
if got, want := img.At(0, 0), (color.RGBA{0x80, 0x80, 0x80, 0x80}); got != want {
|
if got, want := img.At(0, 0), (color.RGBA{R: 0x80, G: 0x80, B: 0x80, A: 0x80}); got != want {
|
||||||
t.Errorf("got: %v, want: %v", got, want)
|
t.Errorf("got: %v, want: %v", got, want)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply the change by 'Set' again.
|
// Apply the change by 'Set' again.
|
||||||
img.DrawImage(dummy, nil)
|
img.DrawImage(dummy, nil)
|
||||||
if got, want := img.At(0, 0), (color.RGBA{0x80, 0x80, 0x80, 0x80}); got != want {
|
if got, want := img.At(0, 0), (color.RGBA{R: 0x80, G: 0x80, B: 0x80, A: 0x80}); got != want {
|
||||||
t.Errorf("got: %v, want: %v", got, want)
|
t.Errorf("got: %v, want: %v", got, want)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3461,10 +3461,10 @@ func TestImageTooManyConstantBuffersInDirectX(t *testing.T) {
|
|||||||
dst1.DrawTriangles(vs, is, src, op)
|
dst1.DrawTriangles(vs, is, src, op)
|
||||||
}
|
}
|
||||||
|
|
||||||
if got, want := dst0.At(0, 0), (color.RGBA{0xff, 0xff, 0xff, 0xff}); got != want {
|
if got, want := dst0.At(0, 0), (color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff}); got != want {
|
||||||
t.Errorf("got: %v, want: %v", got, want)
|
t.Errorf("got: %v, want: %v", got, want)
|
||||||
}
|
}
|
||||||
if got, want := dst1.At(0, 0), (color.RGBA{0xff, 0xff, 0xff, 0xff}); got != want {
|
if got, want := dst1.At(0, 0), (color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff}); got != want {
|
||||||
t.Errorf("got: %v, want: %v", got, want)
|
t.Errorf("got: %v, want: %v", got, want)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3473,7 +3473,7 @@ func TestImageColorMAndScale(t *testing.T) {
|
|||||||
const w, h = 16, 16
|
const w, h = 16, 16
|
||||||
src := ebiten.NewImage(w, h)
|
src := ebiten.NewImage(w, h)
|
||||||
|
|
||||||
src.Fill(color.RGBA{0x80, 0x80, 0x80, 0x80})
|
src.Fill(color.RGBA{R: 0x80, G: 0x80, B: 0x80, A: 0x80})
|
||||||
vs := []ebiten.Vertex{
|
vs := []ebiten.Vertex{
|
||||||
{
|
{
|
||||||
SrcX: 0,
|
SrcX: 0,
|
||||||
@ -3537,17 +3537,17 @@ func TestImageColorMAndScale(t *testing.T) {
|
|||||||
switch format {
|
switch format {
|
||||||
case ebiten.ColorScaleModeStraightAlpha:
|
case ebiten.ColorScaleModeStraightAlpha:
|
||||||
want = color.RGBA{
|
want = color.RGBA{
|
||||||
byte(math.Floor(0xff * (0.5/alphaBeforeScale + 0.25) * alphaBeforeScale * 0.5 * 0.75)),
|
R: byte(math.Floor(0xff * (0.5/alphaBeforeScale + 0.25) * alphaBeforeScale * 0.5 * 0.75)),
|
||||||
byte(math.Floor(0xff * (0.5/alphaBeforeScale + 0.25) * alphaBeforeScale * 0.25 * 0.75)),
|
G: byte(math.Floor(0xff * (0.5/alphaBeforeScale + 0.25) * alphaBeforeScale * 0.25 * 0.75)),
|
||||||
byte(math.Floor(0xff * (0.5/alphaBeforeScale + 0.25) * alphaBeforeScale * 0.5 * 0.75)),
|
B: byte(math.Floor(0xff * (0.5/alphaBeforeScale + 0.25) * alphaBeforeScale * 0.5 * 0.75)),
|
||||||
byte(math.Floor(0xff * alphaBeforeScale * 0.75)),
|
A: byte(math.Floor(0xff * alphaBeforeScale * 0.75)),
|
||||||
}
|
}
|
||||||
case ebiten.ColorScaleModePremultipliedAlpha:
|
case ebiten.ColorScaleModePremultipliedAlpha:
|
||||||
want = color.RGBA{
|
want = color.RGBA{
|
||||||
byte(math.Floor(0xff * (0.5/alphaBeforeScale + 0.25) * alphaBeforeScale * 0.5)),
|
R: byte(math.Floor(0xff * (0.5/alphaBeforeScale + 0.25) * alphaBeforeScale * 0.5)),
|
||||||
byte(math.Floor(0xff * (0.5/alphaBeforeScale + 0.25) * alphaBeforeScale * 0.25)),
|
G: byte(math.Floor(0xff * (0.5/alphaBeforeScale + 0.25) * alphaBeforeScale * 0.25)),
|
||||||
byte(math.Floor(0xff * (0.5/alphaBeforeScale + 0.25) * alphaBeforeScale * 0.5)),
|
B: byte(math.Floor(0xff * (0.5/alphaBeforeScale + 0.25) * alphaBeforeScale * 0.5)),
|
||||||
byte(math.Floor(0xff * alphaBeforeScale * 0.75)),
|
A: byte(math.Floor(0xff * alphaBeforeScale * 0.75)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !sameColors(got, want, 2) {
|
if !sameColors(got, want, 2) {
|
||||||
@ -3878,9 +3878,9 @@ func TestImageAntiAliasAndBlend(t *testing.T) {
|
|||||||
ebiten.BlendCopy,
|
ebiten.BlendCopy,
|
||||||
ebiten.BlendSourceOver,
|
ebiten.BlendSourceOver,
|
||||||
} {
|
} {
|
||||||
dst0.Fill(color.RGBA{0x24, 0x3f, 0x6a, 0x88})
|
dst0.Fill(color.RGBA{R: 0x24, G: 0x3f, B: 0x6a, A: 0x88})
|
||||||
dst1.Fill(color.RGBA{0x24, 0x3f, 0x6a, 0x88})
|
dst1.Fill(color.RGBA{R: 0x24, G: 0x3f, B: 0x6a, A: 0x88})
|
||||||
src.Fill(color.RGBA{0x85, 0xa3, 0x08, 0xd3})
|
src.Fill(color.RGBA{R: 0x85, G: 0xa3, B: 0x08, A: 0xd3})
|
||||||
|
|
||||||
op0 := &ebiten.DrawTrianglesOptions{}
|
op0 := &ebiten.DrawTrianglesOptions{}
|
||||||
op0.Blend = blend
|
op0.Blend = blend
|
||||||
@ -3947,7 +3947,7 @@ func TestImageColorMScale(t *testing.T) {
|
|||||||
dst0 := ebiten.NewImage(w, h)
|
dst0 := ebiten.NewImage(w, h)
|
||||||
dst1 := ebiten.NewImage(w, h)
|
dst1 := ebiten.NewImage(w, h)
|
||||||
src := ebiten.NewImage(w, h)
|
src := ebiten.NewImage(w, h)
|
||||||
src.Fill(color.RGBA{0x24, 0x3f, 0x6a, 0x88})
|
src.Fill(color.RGBA{R: 0x24, G: 0x3f, B: 0x6a, A: 0x88})
|
||||||
|
|
||||||
// As the ColorM is a diagonal matrix, a built-in shader for a color matrix is NOT used.
|
// As the ColorM is a diagonal matrix, a built-in shader for a color matrix is NOT used.
|
||||||
op := &ebiten.DrawImageOptions{}
|
op := &ebiten.DrawImageOptions{}
|
||||||
@ -3972,7 +3972,7 @@ func TestImageColorScaleAndColorM(t *testing.T) {
|
|||||||
dst0 := ebiten.NewImage(w, h)
|
dst0 := ebiten.NewImage(w, h)
|
||||||
dst1 := ebiten.NewImage(w, h)
|
dst1 := ebiten.NewImage(w, h)
|
||||||
src := ebiten.NewImage(w, h)
|
src := ebiten.NewImage(w, h)
|
||||||
src.Fill(color.RGBA{0x24, 0x3f, 0x6a, 0x88})
|
src.Fill(color.RGBA{R: 0x24, G: 0x3f, B: 0x6a, A: 0x88})
|
||||||
|
|
||||||
// ColorScale is applied to premultiplied-alpha colors.
|
// ColorScale is applied to premultiplied-alpha colors.
|
||||||
op := &ebiten.DrawImageOptions{}
|
op := &ebiten.DrawImageOptions{}
|
||||||
@ -3995,9 +3995,9 @@ func TestImageColorScaleAndColorM(t *testing.T) {
|
|||||||
func TestImageSetAndSubImage(t *testing.T) {
|
func TestImageSetAndSubImage(t *testing.T) {
|
||||||
const w, h = 16, 16
|
const w, h = 16, 16
|
||||||
img := ebiten.NewImage(w, h)
|
img := ebiten.NewImage(w, h)
|
||||||
img.Set(1, 1, color.RGBA{0xff, 0, 0, 0xff})
|
img.Set(1, 1, color.RGBA{R: 0xff, A: 0xff})
|
||||||
got := img.SubImage(image.Rect(0, 0, w, h)).At(1, 1).(color.RGBA)
|
got := img.SubImage(image.Rect(0, 0, w, h)).At(1, 1).(color.RGBA)
|
||||||
want := color.RGBA{0xff, 0, 0, 0xff}
|
want := color.RGBA{R: 0xff, A: 0xff}
|
||||||
if got != want {
|
if got != want {
|
||||||
t.Errorf("got: %v, want: %v", got, want)
|
t.Errorf("got: %v, want: %v", got, want)
|
||||||
}
|
}
|
||||||
|
14
input.go
14
input.go
@ -53,7 +53,7 @@ func InputChars() []rune {
|
|||||||
// If you want to know whether the key started being pressed in the current tick,
|
// If you want to know whether the key started being pressed in the current tick,
|
||||||
// use inpututil.IsKeyJustPressed
|
// use inpututil.IsKeyJustPressed
|
||||||
//
|
//
|
||||||
// Note that a Key represents a pysical key of US keyboard layout.
|
// Note that a Key represents a physical key of US keyboard layout.
|
||||||
// For example, KeyQ represents Q key on US keyboards and ' (quote) key on Dvorak keyboards.
|
// For example, KeyQ represents Q key on US keyboards and ' (quote) key on Dvorak keyboards.
|
||||||
//
|
//
|
||||||
// Known issue: On Edge browser, some keys don't work well:
|
// Known issue: On Edge browser, some keys don't work well:
|
||||||
@ -73,7 +73,7 @@ func IsKeyPressed(key Key) bool {
|
|||||||
// KeyName returns a key name for the current keyboard layout.
|
// KeyName returns a key name for the current keyboard layout.
|
||||||
// For example, KeyName(KeyQ) returns 'q' for a QWERTY keyboard, and returns 'a' for an AZERTY keyboard.
|
// For example, KeyName(KeyQ) returns 'q' for a QWERTY keyboard, and returns 'a' for an AZERTY keyboard.
|
||||||
//
|
//
|
||||||
// KeyName returns an empty string if 1) the key doesn't have a phisical key name, 2) the platform doesn't support KeyName,
|
// KeyName returns an empty string if 1) the key doesn't have a physical key name, 2) the platform doesn't support KeyName,
|
||||||
// or 3) the main loop doesn't start yet.
|
// or 3) the main loop doesn't start yet.
|
||||||
//
|
//
|
||||||
// KeyName is supported by desktops and browsers.
|
// KeyName is supported by desktops and browsers.
|
||||||
@ -113,7 +113,7 @@ func IsMouseButtonPressed(mouseButton MouseButton) bool {
|
|||||||
return theInputState.isMouseButtonPressed(mouseButton)
|
return theInputState.isMouseButtonPressed(mouseButton)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GamepadID represents a gamepad's identifier.
|
// GamepadID represents a gamepad identifier.
|
||||||
type GamepadID = gamepad.ID
|
type GamepadID = gamepad.ID
|
||||||
|
|
||||||
// GamepadSDLID returns a string with the GUID generated in the same way as SDL.
|
// GamepadSDLID returns a string with the GUID generated in the same way as SDL.
|
||||||
@ -132,7 +132,7 @@ func GamepadSDLID(id GamepadID) string {
|
|||||||
|
|
||||||
// GamepadName returns a string with the name.
|
// GamepadName returns a string with the name.
|
||||||
// This function may vary in how it returns descriptions for the same device across platforms.
|
// This function may vary in how it returns descriptions for the same device across platforms.
|
||||||
// for example the following drivers/platforms see a Xbox One controller as the following:
|
// for example the following drivers/platforms see an Xbox One controller as the following:
|
||||||
//
|
//
|
||||||
// - Windows: "Xbox Controller"
|
// - Windows: "Xbox Controller"
|
||||||
// - Chrome: "Xbox 360 Controller (XInput STANDARD GAMEPAD)"
|
// - Chrome: "Xbox 360 Controller (XInput STANDARD GAMEPAD)"
|
||||||
@ -225,7 +225,7 @@ func GamepadButtonNum(id GamepadID) int {
|
|||||||
//
|
//
|
||||||
// IsGamepadButtonPressed is concurrent-safe.
|
// IsGamepadButtonPressed is concurrent-safe.
|
||||||
//
|
//
|
||||||
// The relationships between physical buttons and buttion IDs depend on environments.
|
// The relationships between physical buttons and button IDs depend on environments.
|
||||||
// There can be differences even between Chrome and Firefox.
|
// There can be differences even between Chrome and Firefox.
|
||||||
func IsGamepadButtonPressed(id GamepadID, button GamepadButton) bool {
|
func IsGamepadButtonPressed(id GamepadID, button GamepadButton) bool {
|
||||||
g := gamepad.Get(id)
|
g := gamepad.Get(id)
|
||||||
@ -385,7 +385,7 @@ func TouchIDs() []TouchID {
|
|||||||
//
|
//
|
||||||
// If the touch of the specified ID is not present, TouchPosition returns (0, 0).
|
// If the touch of the specified ID is not present, TouchPosition returns (0, 0).
|
||||||
//
|
//
|
||||||
// TouchPosition is cuncurrent-safe.
|
// TouchPosition is concurrent-safe.
|
||||||
func TouchPosition(id TouchID) (int, int) {
|
func TouchPosition(id TouchID) (int, int) {
|
||||||
return theInputState.touchPosition(id)
|
return theInputState.touchPosition(id)
|
||||||
}
|
}
|
||||||
@ -427,7 +427,7 @@ func (i *inputState) isKeyPressed(key Key) bool {
|
|||||||
case KeyMeta:
|
case KeyMeta:
|
||||||
return i.state.KeyPressed[ui.KeyMetaLeft] || i.state.KeyPressed[ui.KeyMetaRight]
|
return i.state.KeyPressed[ui.KeyMetaLeft] || i.state.KeyPressed[ui.KeyMetaRight]
|
||||||
default:
|
default:
|
||||||
return i.state.KeyPressed[ui.Key(key)]
|
return i.state.KeyPressed[key]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ func temporaryBytesSize(size int) int {
|
|||||||
return l
|
return l
|
||||||
}
|
}
|
||||||
|
|
||||||
// alloc allocates the pixels and reutrns it.
|
// alloc allocates the pixels and returns it.
|
||||||
// Be careful that the returned pixels might not be zero-cleared.
|
// Be careful that the returned pixels might not be zero-cleared.
|
||||||
func (t *temporaryBytes) alloc(size int) []byte {
|
func (t *temporaryBytes) alloc(size int) []byte {
|
||||||
if len(t.pixels) < t.pos+size {
|
if len(t.pixels) < t.pos+size {
|
||||||
@ -107,7 +107,7 @@ func flushDeferred() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// baseCountToPutOnAtlas represents the base time duration when the image can be put onto an atlas.
|
// baseCountToPutOnAtlas represents the base time duration when the image can be put onto an atlas.
|
||||||
// Actual time duration is increased in an exponential way for each usages as a rendering target.
|
// Actual time duration is increased in an exponential way for each usage as a rendering target.
|
||||||
const baseCountToPutOnAtlas = 10
|
const baseCountToPutOnAtlas = 10
|
||||||
|
|
||||||
func putImagesOnAtlas(graphicsDriver graphicsdriver.Graphics) error {
|
func putImagesOnAtlas(graphicsDriver graphicsdriver.Graphics) error {
|
||||||
@ -163,7 +163,7 @@ var (
|
|||||||
|
|
||||||
deferred []func()
|
deferred []func()
|
||||||
|
|
||||||
// deferredM is a mutext for the slice operations. This must not be used for other usages.
|
// deferredM is a mutex for the slice operations. This must not be used for other usages.
|
||||||
deferredM sync.Mutex
|
deferredM sync.Mutex
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -218,13 +218,13 @@ type Image struct {
|
|||||||
// moveTo moves its content to the given image dst.
|
// moveTo moves its content to the given image dst.
|
||||||
// After moveTo is called, the image i is no longer available.
|
// After moveTo is called, the image i is no longer available.
|
||||||
//
|
//
|
||||||
// moveTo is smilar to C++'s move semantics.
|
// moveTo is similar to C++'s move semantics.
|
||||||
func (i *Image) moveTo(dst *Image) {
|
func (i *Image) moveTo(dst *Image) {
|
||||||
dst.dispose(false)
|
dst.dispose(false)
|
||||||
*dst = *i
|
*dst = *i
|
||||||
|
|
||||||
// i is no longer available but Dispose must not be called
|
// i is no longer available but Dispose must not be called
|
||||||
// since i and dst have the same values like node.
|
// since i and dst have the same values as node.
|
||||||
runtime.SetFinalizer(i, nil)
|
runtime.SetFinalizer(i, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -421,7 +421,7 @@ func (i *Image) drawTriangles(srcs [graphics.ShaderImageCount]*Image, vertices [
|
|||||||
vertices[i+2] = (vertices[i+2] + oxf) / swf
|
vertices[i+2] = (vertices[i+2] + oxf) / swf
|
||||||
vertices[i+3] = (vertices[i+3] + oyf) / shf
|
vertices[i+3] = (vertices[i+3] + oyf) / shf
|
||||||
}
|
}
|
||||||
// srcRegion can be delibarately empty when this is not needed in order to avoid unexpected
|
// srcRegion can be deliberately empty when this is not needed in order to avoid unexpected
|
||||||
// performance issue (#1293).
|
// performance issue (#1293).
|
||||||
if srcRegion.Width != 0 && srcRegion.Height != 0 {
|
if srcRegion.Width != 0 && srcRegion.Height != 0 {
|
||||||
srcRegion.X += oxf
|
srcRegion.X += oxf
|
||||||
@ -461,7 +461,7 @@ func (i *Image) drawTriangles(srcs [graphics.ShaderImageCount]*Image, vertices [
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if !src.isOnAtlas() && src.canBePutOnAtlas() {
|
if !src.isOnAtlas() && src.canBePutOnAtlas() {
|
||||||
// src might already registered, but assiging it again is not harmful.
|
// src might already registered, but assigning it again is not harmful.
|
||||||
imagesToPutOnAtlas[src] = struct{}{}
|
imagesToPutOnAtlas[src] = struct{}{}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -134,11 +134,11 @@ func TestEnsureIsolated(t *testing.T) {
|
|||||||
g := pix[4*(size*j+i)+1]
|
g := pix[4*(size*j+i)+1]
|
||||||
b := pix[4*(size*j+i)+2]
|
b := pix[4*(size*j+i)+2]
|
||||||
a := pix[4*(size*j+i)+3]
|
a := pix[4*(size*j+i)+3]
|
||||||
got := color.RGBA{r, g, b, a}
|
got := color.RGBA{R: r, G: g, B: b, A: a}
|
||||||
var want color.RGBA
|
var want color.RGBA
|
||||||
if i < dx0 || dx1 <= i || j < dy0 || dy1 <= j {
|
if i < dx0 || dx1 <= i || j < dy0 || dy1 <= j {
|
||||||
c := byte(i + j)
|
c := byte(i + j)
|
||||||
want = color.RGBA{c, c, c, c}
|
want = color.RGBA{R: c, G: c, B: c, A: c}
|
||||||
}
|
}
|
||||||
if got != want {
|
if got != want {
|
||||||
t.Errorf("at(%d, %d): got: %v, want: %v", i, j, got, want)
|
t.Errorf("at(%d, %d): got: %v, want: %v", i, j, got, want)
|
||||||
@ -202,7 +202,7 @@ func TestReputOnAtlas(t *testing.T) {
|
|||||||
|
|
||||||
// Use img1 as a render source.
|
// Use img1 as a render source.
|
||||||
// Use the doubled count since img1 was on a texture atlas and became an isolated image once.
|
// Use the doubled count since img1 was on a texture atlas and became an isolated image once.
|
||||||
// Then, img1 requires longer time to recover to be on a textur atlas again.
|
// Then, img1 requires longer time to recover to be on a texture atlas again.
|
||||||
for i := 0; i < atlas.BaseCountToPutOnAtlas*2; i++ {
|
for i := 0; i < atlas.BaseCountToPutOnAtlas*2; i++ {
|
||||||
if err := atlas.PutImagesOnAtlasForTesting(ui.GraphicsDriverForTesting()); err != nil {
|
if err := atlas.PutImagesOnAtlasForTesting(ui.GraphicsDriverForTesting()); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
@ -222,12 +222,12 @@ func TestReputOnAtlas(t *testing.T) {
|
|||||||
}
|
}
|
||||||
for j := 0; j < size; j++ {
|
for j := 0; j < size; j++ {
|
||||||
for i := 0; i < size; i++ {
|
for i := 0; i < size; i++ {
|
||||||
want := color.RGBA{byte(i + j), byte(i + j), byte(i + j), byte(i + j)}
|
want := color.RGBA{R: byte(i + j), G: byte(i + j), B: byte(i + j), A: byte(i + j)}
|
||||||
r := pix[4*(size*j+i)]
|
r := pix[4*(size*j+i)]
|
||||||
g := pix[4*(size*j+i)+1]
|
g := pix[4*(size*j+i)+1]
|
||||||
b := pix[4*(size*j+i)+2]
|
b := pix[4*(size*j+i)+2]
|
||||||
a := pix[4*(size*j+i)+3]
|
a := pix[4*(size*j+i)+3]
|
||||||
got := color.RGBA{r, g, b, a}
|
got := color.RGBA{R: r, G: g, B: b, A: a}
|
||||||
if got != want {
|
if got != want {
|
||||||
t.Errorf("At(%d, %d): got: %v, want: %v", i, j, got, want)
|
t.Errorf("At(%d, %d): got: %v, want: %v", i, j, got, want)
|
||||||
}
|
}
|
||||||
@ -246,12 +246,12 @@ func TestReputOnAtlas(t *testing.T) {
|
|||||||
}
|
}
|
||||||
for j := 0; j < size; j++ {
|
for j := 0; j < size; j++ {
|
||||||
for i := 0; i < size; i++ {
|
for i := 0; i < size; i++ {
|
||||||
want := color.RGBA{byte(i + j), byte(i + j), byte(i + j), byte(i + j)}
|
want := color.RGBA{R: byte(i + j), G: byte(i + j), B: byte(i + j), A: byte(i + j)}
|
||||||
r := pix[4*(size*j+i)]
|
r := pix[4*(size*j+i)]
|
||||||
g := pix[4*(size*j+i)+1]
|
g := pix[4*(size*j+i)+1]
|
||||||
b := pix[4*(size*j+i)+2]
|
b := pix[4*(size*j+i)+2]
|
||||||
a := pix[4*(size*j+i)+3]
|
a := pix[4*(size*j+i)+3]
|
||||||
got := color.RGBA{r, g, b, a}
|
got := color.RGBA{R: r, G: g, B: b, A: a}
|
||||||
if got != want {
|
if got != want {
|
||||||
t.Errorf("At(%d, %d): got: %v, want: %v", i, j, got, want)
|
t.Errorf("At(%d, %d): got: %v, want: %v", i, j, got, want)
|
||||||
}
|
}
|
||||||
@ -338,9 +338,9 @@ func TestExtend(t *testing.T) {
|
|||||||
g := pix0[4*(w0*j+i)+1]
|
g := pix0[4*(w0*j+i)+1]
|
||||||
b := pix0[4*(w0*j+i)+2]
|
b := pix0[4*(w0*j+i)+2]
|
||||||
a := pix0[4*(w0*j+i)+3]
|
a := pix0[4*(w0*j+i)+3]
|
||||||
got := color.RGBA{r, g, b, a}
|
got := color.RGBA{R: r, G: g, B: b, A: a}
|
||||||
c := byte(i + w0*j)
|
c := byte(i + w0*j)
|
||||||
want := color.RGBA{c, c, c, c}
|
want := color.RGBA{R: c, G: c, B: c, A: c}
|
||||||
if got != want {
|
if got != want {
|
||||||
t.Errorf("at(%d, %d): got: %v, want: %v", i, j, got, want)
|
t.Errorf("at(%d, %d): got: %v, want: %v", i, j, got, want)
|
||||||
}
|
}
|
||||||
@ -357,9 +357,9 @@ func TestExtend(t *testing.T) {
|
|||||||
g := pix1[4*(w1*j+i)+1]
|
g := pix1[4*(w1*j+i)+1]
|
||||||
b := pix1[4*(w1*j+i)+2]
|
b := pix1[4*(w1*j+i)+2]
|
||||||
a := pix1[4*(w1*j+i)+3]
|
a := pix1[4*(w1*j+i)+3]
|
||||||
got := color.RGBA{r, g, b, a}
|
got := color.RGBA{R: r, G: g, B: b, A: a}
|
||||||
c := byte(i + w1*j)
|
c := byte(i + w1*j)
|
||||||
want := color.RGBA{c, c, c, c}
|
want := color.RGBA{R: c, G: c, B: c, A: c}
|
||||||
if got != want {
|
if got != want {
|
||||||
t.Errorf("at(%d, %d): got: %v, want: %v", i, j, got, want)
|
t.Errorf("at(%d, %d): got: %v, want: %v", i, j, got, want)
|
||||||
}
|
}
|
||||||
@ -404,9 +404,9 @@ func TestWritePixelsAfterDrawTriangles(t *testing.T) {
|
|||||||
g := pix[4*(w*j+i)+1]
|
g := pix[4*(w*j+i)+1]
|
||||||
b := pix[4*(w*j+i)+2]
|
b := pix[4*(w*j+i)+2]
|
||||||
a := pix[4*(w*j+i)+3]
|
a := pix[4*(w*j+i)+3]
|
||||||
got := color.RGBA{r, g, b, a}
|
got := color.RGBA{R: r, G: g, B: b, A: a}
|
||||||
c := byte(i + w*j)
|
c := byte(i + w*j)
|
||||||
want := color.RGBA{c, c, c, c}
|
want := color.RGBA{R: c, G: c, B: c, A: c}
|
||||||
if got != want {
|
if got != want {
|
||||||
t.Errorf("at(%d, %d): got %v, want: %v", i, j, got, want)
|
t.Errorf("at(%d, %d): got %v, want: %v", i, j, got, want)
|
||||||
}
|
}
|
||||||
@ -562,7 +562,7 @@ func Disable_TestMinImageSize(t *testing.T) {
|
|||||||
|
|
||||||
func TestMaxImageSizeJust(t *testing.T) {
|
func TestMaxImageSizeJust(t *testing.T) {
|
||||||
s := maxImageSizeForTesting
|
s := maxImageSizeForTesting
|
||||||
// An unmanged image never belongs to an atlas and doesn't have its paddings.
|
// An unmanaged image never belongs to an atlas and doesn't have its paddings.
|
||||||
// TODO: Should we allow such this size for ImageTypeRegular?
|
// TODO: Should we allow such this size for ImageTypeRegular?
|
||||||
img := atlas.NewImage(s, s, atlas.ImageTypeUnmanaged)
|
img := atlas.NewImage(s, s, atlas.ImageTypeUnmanaged)
|
||||||
defer img.MarkDisposed()
|
defer img.MarkDisposed()
|
||||||
@ -620,7 +620,7 @@ func TestDisposedAndReputOnAtlas(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Before PutImaegsOnAtlasForTesting, dispose the image.
|
// Before PutImagesOnAtlasForTesting, dispose the image.
|
||||||
src.MarkDisposed()
|
src.MarkDisposed()
|
||||||
|
|
||||||
// Force to dispose the image.
|
// Force to dispose the image.
|
||||||
@ -722,12 +722,12 @@ func TestImageWritePixelsModify(t *testing.T) {
|
|||||||
}
|
}
|
||||||
for j := 0; j < size; j++ {
|
for j := 0; j < size; j++ {
|
||||||
for i := 0; i < size; i++ {
|
for i := 0; i < size; i++ {
|
||||||
want := color.RGBA{byte(i + j), byte(i + j), byte(i + j), byte(i + j)}
|
want := color.RGBA{R: byte(i + j), G: byte(i + j), B: byte(i + j), A: byte(i + j)}
|
||||||
r := pix[4*(size*j+i)]
|
r := pix[4*(size*j+i)]
|
||||||
g := pix[4*(size*j+i)+1]
|
g := pix[4*(size*j+i)+1]
|
||||||
b := pix[4*(size*j+i)+2]
|
b := pix[4*(size*j+i)+2]
|
||||||
a := pix[4*(size*j+i)+3]
|
a := pix[4*(size*j+i)+3]
|
||||||
got := color.RGBA{r, g, b, a}
|
got := color.RGBA{R: r, G: g, B: b, A: a}
|
||||||
if got != want {
|
if got != want {
|
||||||
t.Errorf("Type: %d, At(%d, %d): got: %v, want: %v", typ, i, j, got, want)
|
t.Errorf("Type: %d, At(%d, %d): got: %v, want: %v", typ, i, j, got, want)
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@ func TestShaderFillTwice(t *testing.T) {
|
|||||||
if err := dst.ReadPixels(g, pix); err != nil {
|
if err := dst.ReadPixels(g, pix); err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
if got, want := (color.RGBA{pix[0], pix[1], pix[2], pix[3]}), (color.RGBA{0x80, 0x80, 0x80, 0xff}); got != want {
|
if got, want := (color.RGBA{R: pix[0], G: pix[1], B: pix[2], A: pix[3]}), (color.RGBA{R: 0x80, G: 0x80, B: 0x80, A: 0xff}); got != want {
|
||||||
t.Errorf("got: %v, want: %v", got, want)
|
t.Errorf("got: %v, want: %v", got, want)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -83,7 +83,7 @@ func TestImageDrawTwice(t *testing.T) {
|
|||||||
if err := dst.ReadPixels(ui.GraphicsDriverForTesting(), pix); err != nil {
|
if err := dst.ReadPixels(ui.GraphicsDriverForTesting(), pix); err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
if got, want := (color.RGBA{pix[0], pix[1], pix[2], pix[3]}), (color.RGBA{0x80, 0x80, 0x80, 0xff}); got != want {
|
if got, want := (color.RGBA{R: pix[0], G: pix[1], B: pix[2], A: pix[3]}), (color.RGBA{R: 0x80, G: 0x80, B: 0x80, A: 0xff}); got != want {
|
||||||
t.Errorf("got: %v, want: %v", got, want)
|
t.Errorf("got: %v, want: %v", got, want)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,7 @@ func getDelayedFuncsAndClearSlow() []func() {
|
|||||||
|
|
||||||
// maybeCanAddDelayedCommand returns false if the delayed commands cannot be added.
|
// maybeCanAddDelayedCommand returns false if the delayed commands cannot be added.
|
||||||
// Otherwise, maybeCanAddDelayedCommand's returning value is not determined.
|
// Otherwise, maybeCanAddDelayedCommand's returning value is not determined.
|
||||||
// For example, maybeCanAddDelayedCommand can return true even when flusing is being processed.
|
// For example, maybeCanAddDelayedCommand can return true even when flushing is being processed.
|
||||||
func maybeCanAddDelayedCommand() bool {
|
func maybeCanAddDelayedCommand() bool {
|
||||||
return atomic.LoadUint32(&delayedCommandsFlushed) == 0
|
return atomic.LoadUint32(&delayedCommandsFlushed) == 0
|
||||||
}
|
}
|
||||||
|
@ -83,7 +83,7 @@ type testResult struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var testSetBeforeMainResult = func() testResult {
|
var testSetBeforeMainResult = func() testResult {
|
||||||
clr := color.RGBA{1, 2, 3, 4}
|
clr := color.RGBA{R: 1, G: 2, B: 3, A: 4}
|
||||||
img := ebiten.NewImage(16, 16)
|
img := ebiten.NewImage(16, 16)
|
||||||
img.Set(0, 0, clr)
|
img.Set(0, 0, clr)
|
||||||
|
|
||||||
@ -124,7 +124,7 @@ var testDrawImageBeforeMainResult = func() testResult {
|
|||||||
}()
|
}()
|
||||||
|
|
||||||
return testResult{
|
return testResult{
|
||||||
want: color.RGBA{0xff, 0xff, 0xff, 0xff},
|
want: color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff},
|
||||||
got: ch,
|
got: ch,
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
@ -185,7 +185,7 @@ var testDrawTrianglesBeforeMainResult = func() testResult {
|
|||||||
}()
|
}()
|
||||||
|
|
||||||
return testResult{
|
return testResult{
|
||||||
want: color.RGBA{0xff, 0xff, 0xff, 0xff},
|
want: color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff},
|
||||||
got: ch,
|
got: ch,
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
@ -200,10 +200,10 @@ func TestDrawTrianglesBeforeMain(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var testSetAndFillBeforeMainResult = func() testResult {
|
var testSetAndFillBeforeMainResult = func() testResult {
|
||||||
clr := color.RGBA{1, 2, 3, 4}
|
clr := color.RGBA{R: 1, G: 2, B: 3, A: 4}
|
||||||
img := ebiten.NewImage(16, 16)
|
img := ebiten.NewImage(16, 16)
|
||||||
img.Set(0, 0, clr)
|
img.Set(0, 0, clr)
|
||||||
img.Fill(color.RGBA{5, 6, 7, 8})
|
img.Fill(color.RGBA{R: 5, G: 6, B: 7, A: 8})
|
||||||
img.Set(1, 0, clr)
|
img.Set(1, 0, clr)
|
||||||
|
|
||||||
ch := make(chan color.RGBA, 1)
|
ch := make(chan color.RGBA, 1)
|
||||||
@ -214,7 +214,7 @@ var testSetAndFillBeforeMainResult = func() testResult {
|
|||||||
}()
|
}()
|
||||||
|
|
||||||
return testResult{
|
return testResult{
|
||||||
want: color.RGBA{5, 6, 7, 8},
|
want: color.RGBA{R: 5, G: 6, B: 7, A: 8},
|
||||||
got: ch,
|
got: ch,
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
@ -229,7 +229,7 @@ func TestSetAndFillBeforeMain(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var testSetAndWritePixelsBeforeMainResult = func() testResult {
|
var testSetAndWritePixelsBeforeMainResult = func() testResult {
|
||||||
clr := color.RGBA{1, 2, 3, 4}
|
clr := color.RGBA{R: 1, G: 2, B: 3, A: 4}
|
||||||
img := ebiten.NewImage(16, 16)
|
img := ebiten.NewImage(16, 16)
|
||||||
img.Set(0, 0, clr)
|
img.Set(0, 0, clr)
|
||||||
pix := make([]byte, 4*16*16)
|
pix := make([]byte, 4*16*16)
|
||||||
@ -250,7 +250,7 @@ var testSetAndWritePixelsBeforeMainResult = func() testResult {
|
|||||||
}()
|
}()
|
||||||
|
|
||||||
return testResult{
|
return testResult{
|
||||||
want: color.RGBA{5, 6, 7, 8},
|
want: color.RGBA{R: 5, G: 6, B: 7, A: 8},
|
||||||
got: ch,
|
got: ch,
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
@ -290,7 +290,7 @@ var testWritePixelsAndModifyBeforeMainResult = func() testResult {
|
|||||||
}()
|
}()
|
||||||
|
|
||||||
return testResult{
|
return testResult{
|
||||||
want: color.RGBA{1, 2, 3, 4},
|
want: color.RGBA{R: 1, G: 2, B: 3, A: 4},
|
||||||
got: ch,
|
got: ch,
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
@ -138,7 +138,7 @@ func (w NSWindow) SetBackgroundColor(color NSColor) {
|
|||||||
w.Send(sel_setBackgroundColor, color.ID)
|
w.Send(sel_setBackgroundColor, color.ID)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w NSWindow) IsVisibile() bool {
|
func (w NSWindow) IsVisible() bool {
|
||||||
return w.Send(sel_isVisible) != 0
|
return w.Send(sel_isVisible) != 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ func GetAt(x, y int) float64 {
|
|||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
// CelarCache clears the cache.
|
// ClearCache clears the cache.
|
||||||
// This should be called when monitors are changed by connecting or disconnecting.
|
// This should be called when monitors are changed by connecting or disconnecting.
|
||||||
func ClearCache() {
|
func ClearCache() {
|
||||||
// TODO: This should be called not only when monitors are changed but also a monitor's scales are changed.
|
// TODO: This should be called not only when monitors are changed but also a monitor's scales are changed.
|
||||||
|
@ -35,7 +35,7 @@ func monitorAt(x, y int) *glfw.Monitor {
|
|||||||
|
|
||||||
func impl(x, y int) float64 {
|
func impl(x, y int) float64 {
|
||||||
// Keep calling GetContentScale until the returned scale is 0 (#2051).
|
// Keep calling GetContentScale until the returned scale is 0 (#2051).
|
||||||
// Retry this at most 5 times to avoid an inifinite loop.
|
// Retry this at most 5 times to avoid an infinite loop.
|
||||||
for i := 0; i < 5; i++ {
|
for i := 0; i < 5; i++ {
|
||||||
// An error can happen e.g. when entering a screensaver on Windows (#2488).
|
// An error can happen e.g. when entering a screensaver on Windows (#2488).
|
||||||
sx, _, err := monitorAt(x, y).GetContentScale()
|
sx, _, err := monitorAt(x, y).GetContentScale()
|
||||||
|
@ -99,7 +99,7 @@ func (g *gamepads) update() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// A gamepad can be detected even though there are not. Apparently, some special devices are
|
// A gamepad can be detected even though there are not. Apparently, some special devices are
|
||||||
// recognized as gamepads by OSes. In this case, the number of the 'buttons' can exceeds the
|
// recognized as gamepads by OSes. In this case, the number of the 'buttons' can exceed the
|
||||||
// maximum. Skip such devices as a tentative solution (#1173, #2039).
|
// maximum. Skip such devices as a tentative solution (#1173, #2039).
|
||||||
g.remove(func(gamepad *Gamepad) bool {
|
g.remove(func(gamepad *Gamepad) bool {
|
||||||
return gamepad.ButtonCount() > ButtonCount
|
return gamepad.ButtonCount() > ButtonCount
|
||||||
|
@ -146,24 +146,24 @@ func (g *nativeGamepadsImpl) addDevice(device _IOHIDDeviceRef, gamepads *gamepad
|
|||||||
}
|
}
|
||||||
|
|
||||||
name := "Unknown"
|
name := "Unknown"
|
||||||
if prop := _IOHIDDeviceGetProperty(_IOHIDDeviceRef(device), _CFStringCreateWithCString(kCFAllocatorDefault, kIOHIDProductKey, kCFStringEncodingUTF8)); prop != 0 {
|
if prop := _IOHIDDeviceGetProperty(device, _CFStringCreateWithCString(kCFAllocatorDefault, kIOHIDProductKey, kCFStringEncodingUTF8)); prop != 0 {
|
||||||
var cstr [256]byte
|
var cstr [256]byte
|
||||||
_CFStringGetCString(_CFStringRef(prop), cstr[:], kCFStringEncodingUTF8)
|
_CFStringGetCString(_CFStringRef(prop), cstr[:], kCFStringEncodingUTF8)
|
||||||
name = strings.TrimRight(string(cstr[:]), "\x00")
|
name = strings.TrimRight(string(cstr[:]), "\x00")
|
||||||
}
|
}
|
||||||
|
|
||||||
var vendor uint32
|
var vendor uint32
|
||||||
if prop := _IOHIDDeviceGetProperty(_IOHIDDeviceRef(device), _CFStringCreateWithCString(kCFAllocatorDefault, kIOHIDVendorIDKey, kCFStringEncodingUTF8)); prop != 0 {
|
if prop := _IOHIDDeviceGetProperty(device, _CFStringCreateWithCString(kCFAllocatorDefault, kIOHIDVendorIDKey, kCFStringEncodingUTF8)); prop != 0 {
|
||||||
_CFNumberGetValue(_CFNumberRef(prop), kCFNumberSInt32Type, unsafe.Pointer(&vendor))
|
_CFNumberGetValue(_CFNumberRef(prop), kCFNumberSInt32Type, unsafe.Pointer(&vendor))
|
||||||
}
|
}
|
||||||
|
|
||||||
var product uint32
|
var product uint32
|
||||||
if prop := _IOHIDDeviceGetProperty(_IOHIDDeviceRef(device), _CFStringCreateWithCString(kCFAllocatorDefault, kIOHIDProductIDKey, kCFStringEncodingUTF8)); prop != 0 {
|
if prop := _IOHIDDeviceGetProperty(device, _CFStringCreateWithCString(kCFAllocatorDefault, kIOHIDProductIDKey, kCFStringEncodingUTF8)); prop != 0 {
|
||||||
_CFNumberGetValue(_CFNumberRef(prop), kCFNumberSInt32Type, unsafe.Pointer(&product))
|
_CFNumberGetValue(_CFNumberRef(prop), kCFNumberSInt32Type, unsafe.Pointer(&product))
|
||||||
}
|
}
|
||||||
|
|
||||||
var version uint32
|
var version uint32
|
||||||
if prop := _IOHIDDeviceGetProperty(_IOHIDDeviceRef(device), _CFStringCreateWithCString(kCFAllocatorDefault, kIOHIDVersionNumberKey, kCFStringEncodingUTF8)); prop != 0 {
|
if prop := _IOHIDDeviceGetProperty(device, _CFStringCreateWithCString(kCFAllocatorDefault, kIOHIDVersionNumberKey, kCFStringEncodingUTF8)); prop != 0 {
|
||||||
_CFNumberGetValue(_CFNumberRef(prop), kCFNumberSInt32Type, unsafe.Pointer(&version))
|
_CFNumberGetValue(_CFNumberRef(prop), kCFNumberSInt32Type, unsafe.Pointer(&version))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -191,8 +191,8 @@ func (g *nativeGamepadsImpl) addDevice(device _IOHIDDeviceRef, gamepads *gamepad
|
|||||||
gp := gamepads.add(name, sdlID)
|
gp := gamepads.add(name, sdlID)
|
||||||
gp.native = n
|
gp.native = n
|
||||||
|
|
||||||
for i := _CFIndex(0); i < _CFArrayGetCount(_CFArrayRef(elements)); i++ {
|
for i := _CFIndex(0); i < _CFArrayGetCount(elements); i++ {
|
||||||
native := (_IOHIDElementRef)(_CFArrayGetValueAtIndex(_CFArrayRef(elements), i))
|
native := (_IOHIDElementRef)(_CFArrayGetValueAtIndex(elements, i))
|
||||||
if _CFGetTypeID(_CFTypeRef(native)) != _IOHIDElementGetTypeID() {
|
if _CFGetTypeID(_CFTypeRef(native)) != _IOHIDElementGetTypeID() {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
@ -251,7 +251,7 @@ func (g *nativeGamepadsImpl) update(gamepads *gamepads) error {
|
|||||||
Cookie: uint32(buf[8]) | uint32(buf[9])<<8 | uint32(buf[10])<<16 | uint32(buf[11])<<24,
|
Cookie: uint32(buf[8]) | uint32(buf[9])<<8 | uint32(buf[10])<<16 | uint32(buf[11])<<24,
|
||||||
Len: uint32(buf[12]) | uint32(buf[13])<<8 | uint32(buf[14])<<16 | uint32(buf[15])<<24,
|
Len: uint32(buf[12]) | uint32(buf[13])<<8 | uint32(buf[14])<<16 | uint32(buf[15])<<24,
|
||||||
}
|
}
|
||||||
name := unix.ByteSliceToString(buf[16 : 16+e.Len-1]) // len includes the null termiinate.
|
name := unix.ByteSliceToString(buf[16 : 16+e.Len-1]) // len includes the null terminate.
|
||||||
buf = buf[16+e.Len:]
|
buf = buf[16+e.Len:]
|
||||||
if !reEvent.MatchString(name) {
|
if !reEvent.MatchString(name) {
|
||||||
continue
|
continue
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
//go:build nintendosdk
|
//go:build nintendosdk
|
||||||
|
|
||||||
// The actual implementaiton will be provided by -overlay.
|
// The actual implementation will be provided by -overlay.
|
||||||
|
|
||||||
#include "gamepad_nintendosdk.h"
|
#include "gamepad_nintendosdk.h"
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ func TestUpdate(t *testing.T) {
|
|||||||
Err: true,
|
Err: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Input: "00000000000000000000000000000000,foo,pltform:Foo",
|
Input: "00000000000000000000000000000000,foo,platform:Foo",
|
||||||
Err: true,
|
Err: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -1651,7 +1651,7 @@ func _SetWindowPos(hWnd windows.HWND, hWndInsertAfter windows.HWND, x, y, cx, cy
|
|||||||
}
|
}
|
||||||
|
|
||||||
func _SetWindowTextW(hWnd windows.HWND, str string) error {
|
func _SetWindowTextW(hWnd windows.HWND, str string) error {
|
||||||
// An empty string is also a valid value. Always create a uint16 pointer.
|
// An empty string is also a valid value. Always create an uint16 pointer.
|
||||||
lpString, err := windows.UTF16PtrFromString(str)
|
lpString, err := windows.UTF16PtrFromString(str)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic("goglfw: str must not include a NUL character")
|
panic("goglfw: str must not include a NUL character")
|
||||||
|
@ -67,7 +67,7 @@ func QuadVertices(dst []float32, sx0, sy0, sx1, sy1 float32, a, b, c, d, tx, ty
|
|||||||
x := sx1 - sx0
|
x := sx1 - sx0
|
||||||
y := sy1 - sy0
|
y := sy1 - sy0
|
||||||
ax, by, cx, dy := a*x, b*y, c*x, d*y
|
ax, by, cx, dy := a*x, b*y, c*x, d*y
|
||||||
u0, v0, u1, v1 := float32(sx0), float32(sy0), float32(sx1), float32(sy1)
|
u0, v0, u1, v1 := sx0, sy0, sx1, sy1
|
||||||
|
|
||||||
// This function is very performance-sensitive and implement in a very dumb way.
|
// This function is very performance-sensitive and implement in a very dumb way.
|
||||||
_ = dst[:4*VertexFloatCount]
|
_ = dst[:4*VertexFloatCount]
|
||||||
|
@ -29,7 +29,7 @@ import (
|
|||||||
//
|
//
|
||||||
// A command for drawing that is created when Image functions are called like DrawTriangles,
|
// A command for drawing that is created when Image functions are called like DrawTriangles,
|
||||||
// or Fill.
|
// or Fill.
|
||||||
// A command is not immediately executed after created. Instaed, it is queued after created,
|
// A command is not immediately executed after created. Instead, it is queued after created,
|
||||||
// and executed only when necessary.
|
// and executed only when necessary.
|
||||||
type command interface {
|
type command interface {
|
||||||
fmt.Stringer
|
fmt.Stringer
|
||||||
@ -603,12 +603,12 @@ func (q *commandQueue) prependPreservedUniforms(uniforms []uint32, shader *Shade
|
|||||||
idx += len(srcs) * 2
|
idx += len(srcs) * 2
|
||||||
|
|
||||||
// Set the destination region.
|
// Set the destination region.
|
||||||
uniforms[idx+0] = math.Float32bits(float32(dstRegion.X) / float32(dw))
|
uniforms[idx+0] = math.Float32bits(dstRegion.X / float32(dw))
|
||||||
uniforms[idx+1] = math.Float32bits(float32(dstRegion.Y) / float32(dh))
|
uniforms[idx+1] = math.Float32bits(dstRegion.Y / float32(dh))
|
||||||
idx += 2
|
idx += 2
|
||||||
|
|
||||||
uniforms[idx+0] = math.Float32bits(float32(dstRegion.Width) / float32(dw))
|
uniforms[idx+0] = math.Float32bits(dstRegion.Width / float32(dw))
|
||||||
uniforms[idx+1] = math.Float32bits(float32(dstRegion.Height) / float32(dh))
|
uniforms[idx+1] = math.Float32bits(dstRegion.Height / float32(dh))
|
||||||
idx += 2
|
idx += 2
|
||||||
|
|
||||||
if srcs[0] != nil {
|
if srcs[0] != nil {
|
||||||
@ -631,12 +631,12 @@ func (q *commandQueue) prependPreservedUniforms(uniforms []uint32, shader *Shade
|
|||||||
idx += len(offsets) * 2
|
idx += len(offsets) * 2
|
||||||
|
|
||||||
// Set the source region of texture0.
|
// Set the source region of texture0.
|
||||||
uniforms[idx+0] = math.Float32bits(float32(srcRegion.X))
|
uniforms[idx+0] = math.Float32bits(srcRegion.X)
|
||||||
uniforms[idx+1] = math.Float32bits(float32(srcRegion.Y))
|
uniforms[idx+1] = math.Float32bits(srcRegion.Y)
|
||||||
idx += 2
|
idx += 2
|
||||||
|
|
||||||
uniforms[idx+0] = math.Float32bits(float32(srcRegion.Width))
|
uniforms[idx+0] = math.Float32bits(srcRegion.Width)
|
||||||
uniforms[idx+1] = math.Float32bits(float32(srcRegion.Height))
|
uniforms[idx+1] = math.Float32bits(srcRegion.Height)
|
||||||
idx += 2
|
idx += 2
|
||||||
|
|
||||||
uniforms[idx+0] = math.Float32bits(2 / float32(dw))
|
uniforms[idx+0] = math.Float32bits(2 / float32(dw))
|
||||||
|
@ -37,7 +37,7 @@ type Image struct {
|
|||||||
internalHeight int
|
internalHeight int
|
||||||
screen bool
|
screen bool
|
||||||
|
|
||||||
// id is an indentifier for the image. This is used only when dummping the information.
|
// id is an identifier for the image. This is used only when dumping the information.
|
||||||
//
|
//
|
||||||
// This is duplicated with graphicsdriver.Image's ID, but this id is still necessary because this image might not
|
// This is duplicated with graphicsdriver.Image's ID, but this id is still necessary because this image might not
|
||||||
// have its graphicsdriver.Image.
|
// have its graphicsdriver.Image.
|
||||||
|
@ -74,7 +74,7 @@ func TestClear(t *testing.T) {
|
|||||||
for j := 0; j < h/2; j++ {
|
for j := 0; j < h/2; j++ {
|
||||||
for i := 0; i < w/2; i++ {
|
for i := 0; i < w/2; i++ {
|
||||||
idx := 4 * (i + w*j)
|
idx := 4 * (i + w*j)
|
||||||
got := color.RGBA{pix[idx], pix[idx+1], pix[idx+2], pix[idx+3]}
|
got := color.RGBA{R: pix[idx], G: pix[idx+1], B: pix[idx+2], A: pix[idx+3]}
|
||||||
want := color.RGBA{}
|
want := color.RGBA{}
|
||||||
if got != want {
|
if got != want {
|
||||||
t.Errorf("dst.At(%d, %d) after DrawTriangles: got %v, want: %v", i, j, got, want)
|
t.Errorf("dst.At(%d, %d) after DrawTriangles: got %v, want: %v", i, j, got, want)
|
||||||
@ -128,8 +128,8 @@ func TestShader(t *testing.T) {
|
|||||||
for j := 0; j < h; j++ {
|
for j := 0; j < h; j++ {
|
||||||
for i := 0; i < w; i++ {
|
for i := 0; i < w; i++ {
|
||||||
idx := 4 * (i + w*j)
|
idx := 4 * (i + w*j)
|
||||||
got := color.RGBA{pix[idx], pix[idx+1], pix[idx+2], pix[idx+3]}
|
got := color.RGBA{R: pix[idx], G: pix[idx+1], B: pix[idx+2], A: pix[idx+3]}
|
||||||
want := color.RGBA{0xff, 0, 0, 0xff}
|
want := color.RGBA{R: 0xff, A: 0xff}
|
||||||
if got != want {
|
if got != want {
|
||||||
t.Errorf("dst.At(%d, %d) after DrawTriangles: got %v, want: %v", i, j, got, want)
|
t.Errorf("dst.At(%d, %d) after DrawTriangles: got %v, want: %v", i, j, got, want)
|
||||||
}
|
}
|
||||||
|
@ -162,10 +162,10 @@ func (p *pipelineStates) drawTriangles(device *_ID3D12Device, commandList *_ID3D
|
|||||||
p.constantBufferMaps[frameIndex] = append(p.constantBufferMaps[frameIndex], 0)
|
p.constantBufferMaps[frameIndex] = append(p.constantBufferMaps[frameIndex], 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
const bufferSizeAlignement = 256
|
const bufferSizeAlignment = 256
|
||||||
bufferSize := uint32(unsafe.Sizeof(uint32(0))) * uint32(len(uniforms))
|
bufferSize := uint32(unsafe.Sizeof(uint32(0))) * uint32(len(uniforms))
|
||||||
if bufferSize > 0 {
|
if bufferSize > 0 {
|
||||||
bufferSize = ((bufferSize-1)/bufferSizeAlignement + 1) * bufferSizeAlignement
|
bufferSize = ((bufferSize-1)/bufferSizeAlignment + 1) * bufferSizeAlignment
|
||||||
}
|
}
|
||||||
|
|
||||||
cb := p.constantBuffers[frameIndex][idx]
|
cb := p.constantBuffers[frameIndex][idx]
|
||||||
|
@ -452,7 +452,7 @@ func (g *Graphics) flushRenderCommandEncoderIfNeeded() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (g *Graphics) draw(dst *Image, dstRegions []graphicsdriver.DstRegion, srcs [graphics.ShaderImageCount]*Image, indexOffset int, shader *Shader, uniforms [][]uint32, blend graphicsdriver.Blend, evenOdd bool) error {
|
func (g *Graphics) draw(dst *Image, dstRegions []graphicsdriver.DstRegion, srcs [graphics.ShaderImageCount]*Image, indexOffset int, shader *Shader, uniforms [][]uint32, blend graphicsdriver.Blend, evenOdd bool) error {
|
||||||
// When prepareing a stencil buffer, flush the current render command encoder
|
// When preparing a stencil buffer, flush the current render command encoder
|
||||||
// to make sure the stencil buffer is cleared when loading.
|
// to make sure the stencil buffer is cleared when loading.
|
||||||
// TODO: What about clearing the stencil buffer by vertices?
|
// TODO: What about clearing the stencil buffer by vertices?
|
||||||
if g.lastDst != dst || g.lastEvenOdd != evenOdd || evenOdd {
|
if g.lastDst != dst || g.lastEvenOdd != evenOdd || evenOdd {
|
||||||
@ -850,7 +850,7 @@ func (i *Image) WritePixels(args []*graphicsdriver.WritePixelsArgs) error {
|
|||||||
w := maxX - minX
|
w := maxX - minX
|
||||||
h := maxY - minY
|
h := maxY - minY
|
||||||
|
|
||||||
// Use a temporary texture to send pixels asynchrounsly, whichever the memory is shared (e.g., iOS) or
|
// Use a temporary texture to send pixels asynchronously, whichever the memory is shared (e.g., iOS) or
|
||||||
// managed (e.g., macOS). A temporary texture is needed since ReplaceRegion tries to sync the pixel
|
// managed (e.g., macOS). A temporary texture is needed since ReplaceRegion tries to sync the pixel
|
||||||
// data between CPU and GPU, and doing it on the existing texture is inefficient (#1418).
|
// data between CPU and GPU, and doing it on the existing texture is inefficient (#1418).
|
||||||
// The texture cannot be reused until sending the pixels finishes, then create new ones for each call.
|
// The texture cannot be reused until sending the pixels finishes, then create new ones for each call.
|
||||||
|
@ -158,7 +158,7 @@ const (
|
|||||||
StoreActionCustomSampleDepthStore StoreAction = 5
|
StoreActionCustomSampleDepthStore StoreAction = 5
|
||||||
)
|
)
|
||||||
|
|
||||||
// StorageMode defines defines the memory location and access permissions of a resource.
|
// StorageMode defines the memory location and access permissions of a resource.
|
||||||
//
|
//
|
||||||
// Reference: https://developer.apple.com/documentation/metal/mtlstoragemode.
|
// Reference: https://developer.apple.com/documentation/metal/mtlstoragemode.
|
||||||
type StorageMode uint8
|
type StorageMode uint8
|
||||||
|
@ -65,7 +65,7 @@ func (c *defaultContext) init() error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try OpenGL first. OpenGL is preferrable as this doesn't cause context losts.
|
// Try OpenGL first. OpenGL is preferable as this doesn't cause context losses.
|
||||||
if !preferES {
|
if !preferES {
|
||||||
// Usually libGL.so or libGL.so.1 is used. libGL.so.2 might exist only on NetBSD.
|
// Usually libGL.so or libGL.so.1 is used. libGL.so.2 might exist only on NetBSD.
|
||||||
for _, name := range []string{"libGL.so", "libGL.so.2", "libGL.so.1", "libGL.so.0"} {
|
for _, name := range []string{"libGL.so", "libGL.so.2", "libGL.so.1", "libGL.so.0"} {
|
||||||
|
@ -70,7 +70,7 @@ func (g *Graphics) End(present bool) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (g *Graphics) SetTransparent(transparent bool) {
|
func (g *Graphics) SetTransparent(transparent bool) {
|
||||||
// Do nothings.
|
// Do nothing.
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *Graphics) checkSize(width, height int) {
|
func (g *Graphics) checkSize(width, height int) {
|
||||||
|
@ -57,7 +57,7 @@ func ensureTemporaryArrayBufferSize(byteLength int) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TemporaryUint8ArrayFromUint8Slice returns a Uint8Array whose length is at least minLength from a uint8 slice.
|
// TemporaryUint8ArrayFromUint8Slice returns a Uint8Array whose length is at least minLength from an uint8 slice.
|
||||||
// Be careful that the length can exceed the given minLength.
|
// Be careful that the length can exceed the given minLength.
|
||||||
// data must be a slice of a numeric type for initialization, or nil if you don't need initialization.
|
// data must be a slice of a numeric type for initialization, or nil if you don't need initialization.
|
||||||
func TemporaryUint8ArrayFromUint8Slice(minLength int, data []uint8) js.Value {
|
func TemporaryUint8ArrayFromUint8Slice(minLength int, data []uint8) js.Value {
|
||||||
@ -66,7 +66,7 @@ func TemporaryUint8ArrayFromUint8Slice(minLength int, data []uint8) js.Value {
|
|||||||
return temporaryUint8Array
|
return temporaryUint8Array
|
||||||
}
|
}
|
||||||
|
|
||||||
// TemporaryUint8ArrayFromUint16Slice returns a Uint8Array whose length is at least minLength from a uint16 slice.
|
// TemporaryUint8ArrayFromUint16Slice returns a Uint8Array whose length is at least minLength from an uint16 slice.
|
||||||
// Be careful that the length can exceed the given minLength.
|
// Be careful that the length can exceed the given minLength.
|
||||||
// data must be a slice of a numeric type for initialization, or nil if you don't need initialization.
|
// data must be a slice of a numeric type for initialization, or nil if you don't need initialization.
|
||||||
func TemporaryUint8ArrayFromUint16Slice(minLength int, data []uint16) js.Value {
|
func TemporaryUint8ArrayFromUint16Slice(minLength int, data []uint16) js.Value {
|
||||||
|
@ -159,7 +159,7 @@ func alloc(n *Node, width, height int) *Node {
|
|||||||
parent: n,
|
parent: n,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Split holizontally
|
// Split horizontally
|
||||||
n.child0 = &Node{
|
n.child0 = &Node{
|
||||||
x: n.x,
|
x: n.x,
|
||||||
y: n.y,
|
y: n.y,
|
||||||
|
2
internal/processtest/testdata/issue1753.go
vendored
2
internal/processtest/testdata/issue1753.go
vendored
@ -58,7 +58,7 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
|||||||
|
|
||||||
// Dispose the shader. When a new shader is created in the next phase, the underlying shader ID might be reused.
|
// Dispose the shader. When a new shader is created in the next phase, the underlying shader ID might be reused.
|
||||||
// This test checks that the new shader works in this situation.
|
// This test checks that the new shader works in this situation.
|
||||||
// The actual disposal will happen after this frame and before the next frame in the current implmentation.
|
// The actual disposal will happen after this frame and before the next frame in the current implementation.
|
||||||
s.Dispose()
|
s.Dispose()
|
||||||
|
|
||||||
g.phase++
|
g.phase++
|
||||||
|
@ -97,7 +97,7 @@ const (
|
|||||||
//
|
//
|
||||||
// Regular non-volatile images need to record drawing history or read its pixels from GPU if necessary so that all
|
// Regular non-volatile images need to record drawing history or read its pixels from GPU if necessary so that all
|
||||||
// the images can be restored automatically from the context lost. However, such recording the drawing history or
|
// the images can be restored automatically from the context lost. However, such recording the drawing history or
|
||||||
// reading pixels from GPU are expensive operations. Volatile images can skip such oprations, but the image content
|
// reading pixels from GPU are expensive operations. Volatile images can skip such operations, but the image content
|
||||||
// is cleared every frame instead.
|
// is cleared every frame instead.
|
||||||
ImageTypeVolatile
|
ImageTypeVolatile
|
||||||
)
|
)
|
||||||
@ -168,7 +168,7 @@ func ensureWhiteImage() *Image {
|
|||||||
return whiteImage
|
return whiteImage
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewImage creates an white image with the given size.
|
// NewImage creates a white image with the given size.
|
||||||
//
|
//
|
||||||
// The returned image is cleared.
|
// The returned image is cleared.
|
||||||
//
|
//
|
||||||
@ -302,7 +302,7 @@ func (i *Image) WritePixels(pixels []byte, x, y, width, height int) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Avoid making other images stale if possible. (#514)
|
// TODO: Avoid making other images stale if possible. (#514)
|
||||||
// For this purpuse, images should remember which part of that is used for DrawTriangles.
|
// For this purpose, images should remember which part of that is used for DrawTriangles.
|
||||||
theImages.makeStaleIfDependingOn(i)
|
theImages.makeStaleIfDependingOn(i)
|
||||||
|
|
||||||
if pixels != nil {
|
if pixels != nil {
|
||||||
@ -550,7 +550,7 @@ func (i *Image) dependsOnShader(shader *Shader) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// dependingImages returns all images that is depended by the image.
|
// dependingImages returns all images that is depended on the image.
|
||||||
func (i *Image) dependingImages() map[*Image]struct{} {
|
func (i *Image) dependingImages() map[*Image]struct{} {
|
||||||
r := map[*Image]struct{}{}
|
r := map[*Image]struct{}{}
|
||||||
for _, c := range i.drawTrianglesHistory {
|
for _, c := range i.drawTrianglesHistory {
|
||||||
|
@ -235,7 +235,7 @@ func (i *images) restore(graphicsDriver graphicsdriver.Graphics) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
for len(images) > 0 {
|
for len(images) > 0 {
|
||||||
// current repesents images that have no incoming edges.
|
// current represents images that have no incoming edges.
|
||||||
current := map[*Image]struct{}{}
|
current := map[*Image]struct{}{}
|
||||||
for i := range images {
|
for i := range images {
|
||||||
current[i] = struct{}{}
|
current[i] = struct{}{}
|
||||||
|
@ -34,7 +34,7 @@ func TestMain(m *testing.M) {
|
|||||||
func pixelsToColor(p *restorable.Pixels, i, j, imageWidth, imageHeight int) color.RGBA {
|
func pixelsToColor(p *restorable.Pixels, i, j, imageWidth, imageHeight int) color.RGBA {
|
||||||
var pix [4]byte
|
var pix [4]byte
|
||||||
p.ReadPixels(pix[:], i, j, 1, 1, imageWidth, imageHeight)
|
p.ReadPixels(pix[:], i, j, 1, 1, imageWidth, imageHeight)
|
||||||
return color.RGBA{pix[0], pix[1], pix[2], pix[3]}
|
return color.RGBA{R: pix[0], G: pix[1], B: pix[2], A: pix[3]}
|
||||||
}
|
}
|
||||||
|
|
||||||
func abs(x int) int {
|
func abs(x int) int {
|
||||||
@ -60,7 +60,7 @@ func TestRestore(t *testing.T) {
|
|||||||
img0 := restorable.NewImage(1, 1, restorable.ImageTypeRegular)
|
img0 := restorable.NewImage(1, 1, restorable.ImageTypeRegular)
|
||||||
defer img0.Dispose()
|
defer img0.Dispose()
|
||||||
|
|
||||||
clr0 := color.RGBA{0x00, 0x00, 0x00, 0xff}
|
clr0 := color.RGBA{A: 0xff}
|
||||||
img0.WritePixels([]byte{clr0.R, clr0.G, clr0.B, clr0.A}, 0, 0, 1, 1)
|
img0.WritePixels([]byte{clr0.R, clr0.G, clr0.B, clr0.A}, 0, 0, 1, 1)
|
||||||
if err := restorable.ResolveStaleImages(ui.GraphicsDriverForTesting(), false); err != nil {
|
if err := restorable.ResolveStaleImages(ui.GraphicsDriverForTesting(), false); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
@ -90,7 +90,7 @@ func TestRestoreWithoutDraw(t *testing.T) {
|
|||||||
|
|
||||||
for j := 0; j < 1024; j++ {
|
for j := 0; j < 1024; j++ {
|
||||||
for i := 0; i < 1024; i++ {
|
for i := 0; i < 1024; i++ {
|
||||||
want := color.RGBA{0x00, 0x00, 0x00, 0x00}
|
want := color.RGBA{}
|
||||||
got := pixelsToColor(img0.BasePixelsForTesting(), i, j, 1024, 1024)
|
got := pixelsToColor(img0.BasePixelsForTesting(), i, j, 1024, 1024)
|
||||||
if !sameColors(got, want, 0) {
|
if !sameColors(got, want, 0) {
|
||||||
t.Errorf("got %v, want %v", got, want)
|
t.Errorf("got %v, want %v", got, want)
|
||||||
@ -134,7 +134,7 @@ func TestRestoreChain(t *testing.T) {
|
|||||||
img.Dispose()
|
img.Dispose()
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
clr := color.RGBA{0x00, 0x00, 0x00, 0xff}
|
clr := color.RGBA{A: 0xff}
|
||||||
imgs[0].WritePixels([]byte{clr.R, clr.G, clr.B, clr.A}, 0, 0, 1, 1)
|
imgs[0].WritePixels([]byte{clr.R, clr.G, clr.B, clr.A}, 0, 0, 1, 1)
|
||||||
for i := 0; i < num-1; i++ {
|
for i := 0; i < num-1; i++ {
|
||||||
vs := quadVertices(imgs[i], 1, 1, 0, 0)
|
vs := quadVertices(imgs[i], 1, 1, 0, 0)
|
||||||
@ -179,11 +179,11 @@ func TestRestoreChain2(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
clr0 := color.RGBA{0xff, 0x00, 0x00, 0xff}
|
clr0 := color.RGBA{R: 0xff, A: 0xff}
|
||||||
imgs[0].WritePixels([]byte{clr0.R, clr0.G, clr0.B, clr0.A}, 0, 0, w, h)
|
imgs[0].WritePixels([]byte{clr0.R, clr0.G, clr0.B, clr0.A}, 0, 0, w, h)
|
||||||
clr7 := color.RGBA{0x00, 0xff, 0x00, 0xff}
|
clr7 := color.RGBA{G: 0xff, A: 0xff}
|
||||||
imgs[7].WritePixels([]byte{clr7.R, clr7.G, clr7.B, clr7.A}, 0, 0, w, h)
|
imgs[7].WritePixels([]byte{clr7.R, clr7.G, clr7.B, clr7.A}, 0, 0, w, h)
|
||||||
clr8 := color.RGBA{0x00, 0x00, 0xff, 0xff}
|
clr8 := color.RGBA{B: 0xff, A: 0xff}
|
||||||
imgs[8].WritePixels([]byte{clr8.R, clr8.G, clr8.B, clr8.A}, 0, 0, w, h)
|
imgs[8].WritePixels([]byte{clr8.R, clr8.G, clr8.B, clr8.A}, 0, 0, w, h)
|
||||||
|
|
||||||
is := graphics.QuadIndices()
|
is := graphics.QuadIndices()
|
||||||
@ -232,8 +232,8 @@ func TestRestoreOverrideSource(t *testing.T) {
|
|||||||
img1.Dispose()
|
img1.Dispose()
|
||||||
img0.Dispose()
|
img0.Dispose()
|
||||||
}()
|
}()
|
||||||
clr0 := color.RGBA{0x00, 0x00, 0x00, 0xff}
|
clr0 := color.RGBA{A: 0xff}
|
||||||
clr1 := color.RGBA{0x00, 0x00, 0x01, 0xff}
|
clr1 := color.RGBA{B: 0x01, A: 0xff}
|
||||||
img1.WritePixels([]byte{clr0.R, clr0.G, clr0.B, clr0.A}, 0, 0, w, h)
|
img1.WritePixels([]byte{clr0.R, clr0.G, clr0.B, clr0.A}, 0, 0, w, h)
|
||||||
is := graphics.QuadIndices()
|
is := graphics.QuadIndices()
|
||||||
dr := graphicsdriver.Region{
|
dr := graphicsdriver.Region{
|
||||||
@ -404,7 +404,7 @@ func TestRestoreComplexGraph(t *testing.T) {
|
|||||||
for i := 0; i < 4; i++ {
|
for i := 0; i < 4; i++ {
|
||||||
want := color.RGBA{}
|
want := color.RGBA{}
|
||||||
if c.out[i] == '*' {
|
if c.out[i] == '*' {
|
||||||
want = color.RGBA{0xff, 0xff, 0xff, 0xff}
|
want = color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff}
|
||||||
}
|
}
|
||||||
got := pixelsToColor(c.image.BasePixelsForTesting(), i, 0, w, h)
|
got := pixelsToColor(c.image.BasePixelsForTesting(), i, 0, w, h)
|
||||||
if !sameColors(got, want, 1) {
|
if !sameColors(got, want, 1) {
|
||||||
@ -473,7 +473,7 @@ func TestRestoreRecursive(t *testing.T) {
|
|||||||
for i := 0; i < 4; i++ {
|
for i := 0; i < 4; i++ {
|
||||||
want := color.RGBA{}
|
want := color.RGBA{}
|
||||||
if c.out[i] == '*' {
|
if c.out[i] == '*' {
|
||||||
want = color.RGBA{0xff, 0xff, 0xff, 0xff}
|
want = color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff}
|
||||||
}
|
}
|
||||||
got := pixelsToColor(c.image.BasePixelsForTesting(), i, 0, w, h)
|
got := pixelsToColor(c.image.BasePixelsForTesting(), i, 0, w, h)
|
||||||
if !sameColors(got, want, 1) {
|
if !sameColors(got, want, 1) {
|
||||||
@ -492,7 +492,7 @@ func TestWritePixels(t *testing.T) {
|
|||||||
pix[i] = 0xff
|
pix[i] = 0xff
|
||||||
}
|
}
|
||||||
img.WritePixels(pix, 5, 7, 4, 4)
|
img.WritePixels(pix, 5, 7, 4, 4)
|
||||||
// Check the region (5, 7)-(9, 11). Outside state is indeterministic.
|
// Check the region (5, 7)-(9, 11). Outside state is indeterminate.
|
||||||
for i := range pix {
|
for i := range pix {
|
||||||
pix[i] = 0
|
pix[i] = 0
|
||||||
}
|
}
|
||||||
@ -502,8 +502,8 @@ func TestWritePixels(t *testing.T) {
|
|||||||
for j := 7; j < 11; j++ {
|
for j := 7; j < 11; j++ {
|
||||||
for i := 5; i < 9; i++ {
|
for i := 5; i < 9; i++ {
|
||||||
idx := 4 * ((j-7)*4 + i - 5)
|
idx := 4 * ((j-7)*4 + i - 5)
|
||||||
got := color.RGBA{pix[idx], pix[idx+1], pix[idx+2], pix[idx+3]}
|
got := color.RGBA{R: pix[idx], G: pix[idx+1], B: pix[idx+2], A: pix[idx+3]}
|
||||||
want := color.RGBA{0xff, 0xff, 0xff, 0xff}
|
want := color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff}
|
||||||
if got != want {
|
if got != want {
|
||||||
t.Errorf("(%d, %d): got: %v, want: %v", i, j, got, want)
|
t.Errorf("(%d, %d): got: %v, want: %v", i, j, got, want)
|
||||||
}
|
}
|
||||||
@ -521,8 +521,8 @@ func TestWritePixels(t *testing.T) {
|
|||||||
for j := 7; j < 11; j++ {
|
for j := 7; j < 11; j++ {
|
||||||
for i := 5; i < 9; i++ {
|
for i := 5; i < 9; i++ {
|
||||||
idx := 4 * ((j-7)*4 + i - 5)
|
idx := 4 * ((j-7)*4 + i - 5)
|
||||||
got := color.RGBA{pix[idx], pix[idx+1], pix[idx+2], pix[idx+3]}
|
got := color.RGBA{R: pix[idx], G: pix[idx+1], B: pix[idx+2], A: pix[idx+3]}
|
||||||
want := color.RGBA{0xff, 0xff, 0xff, 0xff}
|
want := color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff}
|
||||||
if got != want {
|
if got != want {
|
||||||
t.Errorf("(%d, %d): got: %v, want: %v", i, j, got, want)
|
t.Errorf("(%d, %d): got: %v, want: %v", i, j, got, want)
|
||||||
}
|
}
|
||||||
@ -562,8 +562,8 @@ func TestDrawTrianglesAndWritePixels(t *testing.T) {
|
|||||||
if err := img1.ReadPixels(ui.GraphicsDriverForTesting(), pix[:], 0, 0, 1, 1); err != nil {
|
if err := img1.ReadPixels(ui.GraphicsDriverForTesting(), pix[:], 0, 0, 1, 1); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
got := color.RGBA{pix[0], pix[1], pix[2], pix[3]}
|
got := color.RGBA{R: pix[0], G: pix[1], B: pix[2], A: pix[3]}
|
||||||
want := color.RGBA{0xff, 0xff, 0xff, 0xff}
|
want := color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff}
|
||||||
if !sameColors(got, want, 1) {
|
if !sameColors(got, want, 1) {
|
||||||
t.Errorf("got: %v, want: %v", got, want)
|
t.Errorf("got: %v, want: %v", got, want)
|
||||||
}
|
}
|
||||||
@ -606,8 +606,8 @@ func TestDispose(t *testing.T) {
|
|||||||
if err := img0.ReadPixels(ui.GraphicsDriverForTesting(), pix[:], 0, 0, 1, 1); err != nil {
|
if err := img0.ReadPixels(ui.GraphicsDriverForTesting(), pix[:], 0, 0, 1, 1); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
got := color.RGBA{pix[0], pix[1], pix[2], pix[3]}
|
got := color.RGBA{R: pix[0], G: pix[1], B: pix[2], A: pix[3]}
|
||||||
want := color.RGBA{0xff, 0xff, 0xff, 0xff}
|
want := color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff}
|
||||||
if !sameColors(got, want, 1) {
|
if !sameColors(got, want, 1) {
|
||||||
t.Errorf("got: %v, want: %v", got, want)
|
t.Errorf("got: %v, want: %v", got, want)
|
||||||
}
|
}
|
||||||
@ -631,52 +631,52 @@ func TestWritePixelsPart(t *testing.T) {
|
|||||||
{
|
{
|
||||||
i: 0,
|
i: 0,
|
||||||
j: 0,
|
j: 0,
|
||||||
want: color.RGBA{0, 0, 0, 0},
|
want: color.RGBA{},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
i: 3,
|
i: 3,
|
||||||
j: 0,
|
j: 0,
|
||||||
want: color.RGBA{0, 0, 0, 0},
|
want: color.RGBA{},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
i: 0,
|
i: 0,
|
||||||
j: 1,
|
j: 1,
|
||||||
want: color.RGBA{0, 0, 0, 0},
|
want: color.RGBA{},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
i: 1,
|
i: 1,
|
||||||
j: 1,
|
j: 1,
|
||||||
want: color.RGBA{0xff, 0xff, 0xff, 0xff},
|
want: color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
i: 3,
|
i: 3,
|
||||||
j: 1,
|
j: 1,
|
||||||
want: color.RGBA{0, 0, 0, 0},
|
want: color.RGBA{},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
i: 0,
|
i: 0,
|
||||||
j: 2,
|
j: 2,
|
||||||
want: color.RGBA{0, 0, 0, 0},
|
want: color.RGBA{},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
i: 2,
|
i: 2,
|
||||||
j: 2,
|
j: 2,
|
||||||
want: color.RGBA{0xff, 0xff, 0xff, 0xff},
|
want: color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
i: 3,
|
i: 3,
|
||||||
j: 2,
|
j: 2,
|
||||||
want: color.RGBA{0, 0, 0, 0},
|
want: color.RGBA{},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
i: 0,
|
i: 0,
|
||||||
j: 3,
|
j: 3,
|
||||||
want: color.RGBA{0, 0, 0, 0},
|
want: color.RGBA{},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
i: 3,
|
i: 3,
|
||||||
j: 3,
|
j: 3,
|
||||||
want: color.RGBA{0, 0, 0, 0},
|
want: color.RGBA{},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
for _, c := range cases {
|
for _, c := range cases {
|
||||||
@ -717,9 +717,9 @@ func TestWritePixelsOnly(t *testing.T) {
|
|||||||
var want color.RGBA
|
var want color.RGBA
|
||||||
switch {
|
switch {
|
||||||
case idx == 0:
|
case idx == 0:
|
||||||
want = color.RGBA{5, 6, 7, 8}
|
want = color.RGBA{R: 5, G: 6, B: 7, A: 8}
|
||||||
case idx%5 == 0:
|
case idx%5 == 0:
|
||||||
want = color.RGBA{1, 2, 3, 4}
|
want = color.RGBA{R: 1, G: 2, B: 3, A: 4}
|
||||||
}
|
}
|
||||||
got := pixelsToColor(img0.BasePixelsForTesting(), i, j, w, h)
|
got := pixelsToColor(img0.BasePixelsForTesting(), i, j, w, h)
|
||||||
if !sameColors(got, want, 0) {
|
if !sameColors(got, want, 0) {
|
||||||
@ -734,7 +734,7 @@ func TestWritePixelsOnly(t *testing.T) {
|
|||||||
if err := restorable.RestoreIfNeeded(ui.GraphicsDriverForTesting()); err != nil {
|
if err := restorable.RestoreIfNeeded(ui.GraphicsDriverForTesting()); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
want := color.RGBA{1, 2, 3, 4}
|
want := color.RGBA{R: 1, G: 2, B: 3, A: 4}
|
||||||
got := pixelsToColor(img1.BasePixelsForTesting(), 0, 0, w, h)
|
got := pixelsToColor(img1.BasePixelsForTesting(), 0, 0, w, h)
|
||||||
if !sameColors(got, want, 0) {
|
if !sameColors(got, want, 0) {
|
||||||
t.Errorf("got %v, want %v", got, want)
|
t.Errorf("got %v, want %v", got, want)
|
||||||
@ -836,10 +836,10 @@ func TestAllowWritePixelsForPartAfterDrawTriangles(t *testing.T) {
|
|||||||
}
|
}
|
||||||
for j := 0; j < h; j++ {
|
for j := 0; j < h; j++ {
|
||||||
for i := 0; i < w; i++ {
|
for i := 0; i < w; i++ {
|
||||||
got := color.RGBA{result[4*(j*w+i)], result[4*(j*w+i)+1], result[4*(j*w+i)+2], result[4*(j*w+i)+3]}
|
got := color.RGBA{R: result[4*(j*w+i)], G: result[4*(j*w+i)+1], B: result[4*(j*w+i)+2], A: result[4*(j*w+i)+3]}
|
||||||
var want color.RGBA
|
var want color.RGBA
|
||||||
if i >= 2 || j >= 2 {
|
if i >= 2 || j >= 2 {
|
||||||
want = color.RGBA{0xff, 0xff, 0xff, 0xff}
|
want = color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff}
|
||||||
}
|
}
|
||||||
if got != want {
|
if got != want {
|
||||||
t.Errorf("color at (%d, %d): got: %v, want: %v", i, j, got, want)
|
t.Errorf("color at (%d, %d): got: %v, want: %v", i, j, got, want)
|
||||||
@ -948,8 +948,8 @@ func TestMutateSlices(t *testing.T) {
|
|||||||
for j := 0; j < h; j++ {
|
for j := 0; j < h; j++ {
|
||||||
for i := 0; i < w; i++ {
|
for i := 0; i < w; i++ {
|
||||||
idx := 4 * (j*w + i)
|
idx := 4 * (j*w + i)
|
||||||
want := color.RGBA{srcPix[idx], srcPix[idx+1], srcPix[idx+2], srcPix[idx+3]}
|
want := color.RGBA{R: srcPix[idx], G: srcPix[idx+1], B: srcPix[idx+2], A: srcPix[idx+3]}
|
||||||
got := color.RGBA{dstPix[idx], dstPix[idx+1], dstPix[idx+2], dstPix[idx+3]}
|
got := color.RGBA{R: dstPix[idx], G: dstPix[idx+1], B: dstPix[idx+2], A: dstPix[idx+3]}
|
||||||
if !sameColors(got, want, 1) {
|
if !sameColors(got, want, 1) {
|
||||||
t.Errorf("(%d, %d): got %v, want %v", i, j, got, want)
|
t.Errorf("(%d, %d): got %v, want %v", i, j, got, want)
|
||||||
}
|
}
|
||||||
@ -1005,7 +1005,7 @@ func TestOverlappedPixels(t *testing.T) {
|
|||||||
for j := 0; j < 3; j++ {
|
for j := 0; j < 3; j++ {
|
||||||
for i := 0; i < 3; i++ {
|
for i := 0; i < 3; i++ {
|
||||||
idx := 4 * (j*3 + i)
|
idx := 4 * (j*3 + i)
|
||||||
got := color.RGBA{result[idx], result[idx+1], result[idx+2], result[idx+3]}
|
got := color.RGBA{R: result[idx], G: result[idx+1], B: result[idx+2], A: result[idx+3]}
|
||||||
want := wantColors[3*j+i]
|
want := wantColors[3*j+i]
|
||||||
if got != want {
|
if got != want {
|
||||||
t.Errorf("color at (%d, %d): got %v, want: %v", i, j, got, want)
|
t.Errorf("color at (%d, %d): got %v, want: %v", i, j, got, want)
|
||||||
@ -1034,7 +1034,7 @@ func TestOverlappedPixels(t *testing.T) {
|
|||||||
for j := 0; j < 3; j++ {
|
for j := 0; j < 3; j++ {
|
||||||
for i := 0; i < 3; i++ {
|
for i := 0; i < 3; i++ {
|
||||||
idx := 4 * (j*3 + i)
|
idx := 4 * (j*3 + i)
|
||||||
got := color.RGBA{result[idx], result[idx+1], result[idx+2], result[idx+3]}
|
got := color.RGBA{R: result[idx], G: result[idx+1], B: result[idx+2], A: result[idx+3]}
|
||||||
want := wantColors[3*j+i]
|
want := wantColors[3*j+i]
|
||||||
if got != want {
|
if got != want {
|
||||||
t.Errorf("color at (%d, %d): got %v, want: %v", i, j, got, want)
|
t.Errorf("color at (%d, %d): got %v, want: %v", i, j, got, want)
|
||||||
@ -1073,7 +1073,7 @@ func TestOverlappedPixels(t *testing.T) {
|
|||||||
for j := 0; j < 3; j++ {
|
for j := 0; j < 3; j++ {
|
||||||
for i := 0; i < 3; i++ {
|
for i := 0; i < 3; i++ {
|
||||||
idx := 4 * (j*3 + i)
|
idx := 4 * (j*3 + i)
|
||||||
got := color.RGBA{result[idx], result[idx+1], result[idx+2], result[idx+3]}
|
got := color.RGBA{R: result[idx], G: result[idx+1], B: result[idx+2], A: result[idx+3]}
|
||||||
want := wantColors[3*j+i]
|
want := wantColors[3*j+i]
|
||||||
if got != want {
|
if got != want {
|
||||||
t.Errorf("color at (%d, %d): got %v, want: %v", i, j, got, want)
|
t.Errorf("color at (%d, %d): got %v, want: %v", i, j, got, want)
|
||||||
@ -1094,7 +1094,7 @@ func TestOverlappedPixels(t *testing.T) {
|
|||||||
for j := 0; j < 3; j++ {
|
for j := 0; j < 3; j++ {
|
||||||
for i := 0; i < 3; i++ {
|
for i := 0; i < 3; i++ {
|
||||||
idx := 4 * (j*3 + i)
|
idx := 4 * (j*3 + i)
|
||||||
got := color.RGBA{result[idx], result[idx+1], result[idx+2], result[idx+3]}
|
got := color.RGBA{R: result[idx], G: result[idx+1], B: result[idx+2], A: result[idx+3]}
|
||||||
want := wantColors[3*j+i]
|
want := wantColors[3*j+i]
|
||||||
if got != want {
|
if got != want {
|
||||||
t.Errorf("color at (%d, %d): got %v, want: %v", i, j, got, want)
|
t.Errorf("color at (%d, %d): got %v, want: %v", i, j, got, want)
|
||||||
@ -1125,7 +1125,7 @@ func TestDrawTrianglesAndReadPixels(t *testing.T) {
|
|||||||
if err := dst.ReadPixels(ui.GraphicsDriverForTesting(), pix, 0, 0, w, h); err != nil {
|
if err := dst.ReadPixels(ui.GraphicsDriverForTesting(), pix, 0, 0, w, h); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
if got, want := (color.RGBA{pix[0], pix[1], pix[2], pix[3]}), (color.RGBA{0x80, 0x80, 0x80, 0x80}); !sameColors(got, want, 1) {
|
if got, want := (color.RGBA{R: pix[0], G: pix[1], B: pix[2], A: pix[3]}), (color.RGBA{R: 0x80, G: 0x80, B: 0x80, A: 0x80}); !sameColors(got, want, 1) {
|
||||||
t.Errorf("got: %v, want: %v", got, want)
|
t.Errorf("got: %v, want: %v", got, want)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,7 @@ func TestShader(t *testing.T) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
want := color.RGBA{0xff, 0, 0, 0xff}
|
want := color.RGBA{R: 0xff, A: 0xff}
|
||||||
got := pixelsToColor(img.BasePixelsForTesting(), 0, 0, 1, 1)
|
got := pixelsToColor(img.BasePixelsForTesting(), 0, 0, 1, 1)
|
||||||
if !sameColors(got, want, 1) {
|
if !sameColors(got, want, 1) {
|
||||||
t.Errorf("got %v, want %v", got, want)
|
t.Errorf("got %v, want %v", got, want)
|
||||||
@ -110,7 +110,7 @@ func TestShaderChain(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for i, img := range imgs {
|
for i, img := range imgs {
|
||||||
want := color.RGBA{0xff, 0, 0, 0xff}
|
want := color.RGBA{R: 0xff, A: 0xff}
|
||||||
got := pixelsToColor(img.BasePixelsForTesting(), 0, 0, 1, 1)
|
got := pixelsToColor(img.BasePixelsForTesting(), 0, 0, 1, 1)
|
||||||
if !sameColors(got, want, 1) {
|
if !sameColors(got, want, 1) {
|
||||||
t.Errorf("%d: got %v, want %v", i, got, want)
|
t.Errorf("%d: got %v, want %v", i, got, want)
|
||||||
@ -149,7 +149,7 @@ func TestShaderMultipleSources(t *testing.T) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
want := color.RGBA{0x40, 0x80, 0xc0, 0xff}
|
want := color.RGBA{R: 0x40, G: 0x80, B: 0xc0, A: 0xff}
|
||||||
got := pixelsToColor(dst.BasePixelsForTesting(), 0, 0, 1, 1)
|
got := pixelsToColor(dst.BasePixelsForTesting(), 0, 0, 1, 1)
|
||||||
if !sameColors(got, want, 1) {
|
if !sameColors(got, want, 1) {
|
||||||
t.Errorf("got %v, want %v", got, want)
|
t.Errorf("got %v, want %v", got, want)
|
||||||
@ -190,7 +190,7 @@ func TestShaderMultipleSourcesOnOneTexture(t *testing.T) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
want := color.RGBA{0x40, 0x80, 0xc0, 0xff}
|
want := color.RGBA{R: 0x40, G: 0x80, B: 0xc0, A: 0xff}
|
||||||
got := pixelsToColor(dst.BasePixelsForTesting(), 0, 0, 1, 1)
|
got := pixelsToColor(dst.BasePixelsForTesting(), 0, 0, 1, 1)
|
||||||
if !sameColors(got, want, 1) {
|
if !sameColors(got, want, 1) {
|
||||||
t.Errorf("got %v, want %v", got, want)
|
t.Errorf("got %v, want %v", got, want)
|
||||||
@ -210,7 +210,7 @@ func TestShaderDispose(t *testing.T) {
|
|||||||
}
|
}
|
||||||
img.DrawTriangles([graphics.ShaderImageCount]*restorable.Image{}, [graphics.ShaderImageCount - 1][2]float32{}, quadVertices(nil, 1, 1, 0, 0), graphics.QuadIndices(), graphicsdriver.BlendCopy, dr, graphicsdriver.Region{}, s, nil, false)
|
img.DrawTriangles([graphics.ShaderImageCount]*restorable.Image{}, [graphics.ShaderImageCount - 1][2]float32{}, quadVertices(nil, 1, 1, 0, 0), graphics.QuadIndices(), graphicsdriver.BlendCopy, dr, graphicsdriver.Region{}, s, nil, false)
|
||||||
|
|
||||||
// Dispose the shader. This should invalidates all the images using this shader i.e., all the images become
|
// Dispose the shader. This should invalidate all the images using this shader i.e., all the images become
|
||||||
// stale.
|
// stale.
|
||||||
s.Dispose()
|
s.Dispose()
|
||||||
|
|
||||||
@ -221,7 +221,7 @@ func TestShaderDispose(t *testing.T) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
want := color.RGBA{0xff, 0, 0, 0xff}
|
want := color.RGBA{R: 0xff, A: 0xff}
|
||||||
got := pixelsToColor(img.BasePixelsForTesting(), 0, 0, 1, 1)
|
got := pixelsToColor(img.BasePixelsForTesting(), 0, 0, 1, 1)
|
||||||
if !sameColors(got, want, 1) {
|
if !sameColors(got, want, 1) {
|
||||||
t.Errorf("got %v, want %v", got, want)
|
t.Errorf("got %v, want %v", got, want)
|
||||||
|
@ -308,7 +308,7 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSyntaxUnspportedSyntax(t *testing.T) {
|
func TestSyntaxUnsupportedSyntax(t *testing.T) {
|
||||||
if _, err := compileToIR([]byte(`package main
|
if _, err := compileToIR([]byte(`package main
|
||||||
|
|
||||||
func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
||||||
|
@ -46,7 +46,7 @@ type Func struct {
|
|||||||
|
|
||||||
// VertexFunc takes pseudo params, and the number if len(attributes) + len(varyings) + 1.
|
// VertexFunc takes pseudo params, and the number if len(attributes) + len(varyings) + 1.
|
||||||
// If 0 <= index < len(attributes), the params are in-params and represent attribute variables.
|
// If 0 <= index < len(attributes), the params are in-params and represent attribute variables.
|
||||||
// If index == len(attributes), the param is an out-param and repesents the position in vec4 (gl_Position in GLSL)
|
// If index == len(attributes), the param is an out-param and represents the position in vec4 (gl_Position in GLSL)
|
||||||
// If len(attributes) + 1 <= index < len(attributes) + len(varyings) + 1, the params are out-params and represent
|
// If len(attributes) + 1 <= index < len(attributes) + len(varyings) + 1, the params are out-params and represent
|
||||||
// varying variables.
|
// varying variables.
|
||||||
type VertexFunc struct {
|
type VertexFunc struct {
|
||||||
@ -55,7 +55,7 @@ type VertexFunc struct {
|
|||||||
|
|
||||||
// FragmentFunc takes pseudo params, and the number is len(varyings) + 2.
|
// FragmentFunc takes pseudo params, and the number is len(varyings) + 2.
|
||||||
// If index == 0, the param represents the coordinate of the fragment (gl_FragCoord in GLSL).
|
// If index == 0, the param represents the coordinate of the fragment (gl_FragCoord in GLSL).
|
||||||
// If 0 < index <= len(varyings), the param represents (index-1)th verying variable.
|
// If 0 < index <= len(varyings), the param represents (index-1)th varying variable.
|
||||||
type FragmentFunc struct {
|
type FragmentFunc struct {
|
||||||
Block *Block
|
Block *Block
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,7 @@ func (e *egl) init(nativeWindowHandle C.NativeWindowType) error {
|
|||||||
|
|
||||||
// Create new context and set it as current.
|
// Create new context and set it as current.
|
||||||
contextAttribs := []C.EGLint{
|
contextAttribs := []C.EGLint{
|
||||||
// Set target garaphics api version.
|
// Set target graphics api version.
|
||||||
C.EGL_CONTEXT_MAJOR_VERSION, 2,
|
C.EGL_CONTEXT_MAJOR_VERSION, 2,
|
||||||
C.EGL_CONTEXT_MINOR_VERSION, 1,
|
C.EGL_CONTEXT_MINOR_VERSION, 1,
|
||||||
// For debug callback
|
// For debug callback
|
||||||
|
@ -33,13 +33,13 @@ var (
|
|||||||
class_EbitengineWindowDelegate objc.Class
|
class_EbitengineWindowDelegate objc.Class
|
||||||
)
|
)
|
||||||
|
|
||||||
type windowDelgate struct {
|
type windowDelegate struct {
|
||||||
isa objc.Class `objc:"EbitengineWindowDelegate : NSObject <NSWindowDelegate>"`
|
isa objc.Class `objc:"EbitengineWindowDelegate : NSObject <NSWindowDelegate>"`
|
||||||
origDelegate objc.ID
|
origDelegate objc.ID
|
||||||
origResizable bool
|
origResizable bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *windowDelgate) pushResizableState(win objc.ID) {
|
func (w *windowDelegate) pushResizableState(win objc.ID) {
|
||||||
window := cocoa.NSWindow{ID: win}
|
window := cocoa.NSWindow{ID: win}
|
||||||
w.origResizable = window.StyleMask()&cocoa.NSWindowStyleMaskResizable != 0
|
w.origResizable = window.StyleMask()&cocoa.NSWindowStyleMaskResizable != 0
|
||||||
if !w.origResizable {
|
if !w.origResizable {
|
||||||
@ -47,7 +47,7 @@ func (w *windowDelgate) pushResizableState(win objc.ID) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *windowDelgate) popResizableState(win objc.ID) {
|
func (w *windowDelegate) popResizableState(win objc.ID) {
|
||||||
if !w.origResizable {
|
if !w.origResizable {
|
||||||
window := cocoa.NSWindow{ID: win}
|
window := cocoa.NSWindow{ID: win}
|
||||||
window.SetStyleMask(window.StyleMask() & ^uint(cocoa.NSWindowStyleMaskResizable))
|
window.SetStyleMask(window.StyleMask() & ^uint(cocoa.NSWindowStyleMaskResizable))
|
||||||
@ -55,10 +55,10 @@ func (w *windowDelgate) popResizableState(win objc.ID) {
|
|||||||
w.origResizable = false
|
w.origResizable = false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *windowDelgate) InitWithOrigDelegate(cmd objc.SEL, origDelegate objc.ID) objc.ID {
|
func (w *windowDelegate) InitWithOrigDelegate(cmd objc.SEL, origDelegate objc.ID) objc.ID {
|
||||||
self := objc.ID(unsafe.Pointer(w)).SendSuper(sel_init)
|
self := objc.ID(unsafe.Pointer(w)).SendSuper(sel_init)
|
||||||
if self != 0 {
|
if self != 0 {
|
||||||
w = *(**windowDelgate)(unsafe.Pointer(&self))
|
w = *(**windowDelegate)(unsafe.Pointer(&self))
|
||||||
w.origDelegate = origDelegate
|
w.origDelegate = origDelegate
|
||||||
}
|
}
|
||||||
return self
|
return self
|
||||||
@ -67,56 +67,56 @@ func (w *windowDelgate) InitWithOrigDelegate(cmd objc.SEL, origDelegate objc.ID)
|
|||||||
// The method set of origDelegate_ must sync with GLFWWindowDelegate's implementation.
|
// The method set of origDelegate_ must sync with GLFWWindowDelegate's implementation.
|
||||||
// See cocoa_window.m in GLFW.
|
// See cocoa_window.m in GLFW.
|
||||||
|
|
||||||
func (w *windowDelgate) WindowShouldClose(cmd objc.SEL, notification objc.ID) bool {
|
func (w *windowDelegate) WindowShouldClose(cmd objc.SEL, notification objc.ID) bool {
|
||||||
return w.origDelegate.Send(cmd, notification) != 0
|
return w.origDelegate.Send(cmd, notification) != 0
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *windowDelgate) WindowDidResize(cmd objc.SEL, notification objc.ID) {
|
func (w *windowDelegate) WindowDidResize(cmd objc.SEL, notification objc.ID) {
|
||||||
w.origDelegate.Send(cmd, notification)
|
w.origDelegate.Send(cmd, notification)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *windowDelgate) WindowDidMove(cmd objc.SEL, notification objc.ID) {
|
func (w *windowDelegate) WindowDidMove(cmd objc.SEL, notification objc.ID) {
|
||||||
w.origDelegate.Send(cmd, notification)
|
w.origDelegate.Send(cmd, notification)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *windowDelgate) WindowDidMiniaturize(cmd objc.SEL, notification objc.ID) {
|
func (w *windowDelegate) WindowDidMiniaturize(cmd objc.SEL, notification objc.ID) {
|
||||||
w.origDelegate.Send(cmd, notification)
|
w.origDelegate.Send(cmd, notification)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *windowDelgate) WindowDidDeminiaturize(cmd objc.SEL, notification objc.ID) {
|
func (w *windowDelegate) WindowDidDeminiaturize(cmd objc.SEL, notification objc.ID) {
|
||||||
w.origDelegate.Send(cmd, notification)
|
w.origDelegate.Send(cmd, notification)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *windowDelgate) WindowDidBecomeKey(cmd objc.SEL, notification objc.ID) {
|
func (w *windowDelegate) WindowDidBecomeKey(cmd objc.SEL, notification objc.ID) {
|
||||||
w.origDelegate.Send(cmd, notification)
|
w.origDelegate.Send(cmd, notification)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *windowDelgate) WindowDidResignKey(cmd objc.SEL, notification objc.ID) {
|
func (w *windowDelegate) WindowDidResignKey(cmd objc.SEL, notification objc.ID) {
|
||||||
w.origDelegate.Send(cmd, notification)
|
w.origDelegate.Send(cmd, notification)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *windowDelgate) WindowDidChangeOcclusionState(cmd objc.SEL, notification objc.ID) {
|
func (w *windowDelegate) WindowDidChangeOcclusionState(cmd objc.SEL, notification objc.ID) {
|
||||||
w.origDelegate.Send(cmd, notification)
|
w.origDelegate.Send(cmd, notification)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *windowDelgate) WindowWillEnterFullScreen(cmd objc.SEL, notification objc.ID) {
|
func (w *windowDelegate) WindowWillEnterFullScreen(cmd objc.SEL, notification objc.ID) {
|
||||||
w.pushResizableState(cocoa.NSNotification{ID: notification}.Object())
|
w.pushResizableState(cocoa.NSNotification{ID: notification}.Object())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *windowDelgate) WindowDidEnterFullScreen(cmd objc.SEL, notification objc.ID) {
|
func (w *windowDelegate) WindowDidEnterFullScreen(cmd objc.SEL, notification objc.ID) {
|
||||||
w.popResizableState(cocoa.NSNotification{ID: notification}.Object())
|
w.popResizableState(cocoa.NSNotification{ID: notification}.Object())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *windowDelgate) WindowWillExitFullScreen(cmd objc.SEL, notification objc.ID) {
|
func (w *windowDelegate) WindowWillExitFullScreen(cmd objc.SEL, notification objc.ID) {
|
||||||
w.pushResizableState(cocoa.NSNotification{ID: notification}.Object())
|
w.pushResizableState(cocoa.NSNotification{ID: notification}.Object())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *windowDelgate) WindowDidExitFullScreen(cmd objc.SEL, notification objc.ID) {
|
func (w *windowDelegate) WindowDidExitFullScreen(cmd objc.SEL, notification objc.ID) {
|
||||||
w.popResizableState(cocoa.NSNotification{ID: notification}.Object())
|
w.popResizableState(cocoa.NSNotification{ID: notification}.Object())
|
||||||
// Do not call setFrame here (#2295). setFrame here causes unexpected results.
|
// Do not call setFrame here (#2295). setFrame here causes unexpected results.
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *windowDelgate) Selector(cmd string) objc.SEL {
|
func (w *windowDelegate) Selector(cmd string) objc.SEL {
|
||||||
switch cmd {
|
switch cmd {
|
||||||
case "InitWithOrigDelegate":
|
case "InitWithOrigDelegate":
|
||||||
return sel_initWithOrigDelegate
|
return sel_initWithOrigDelegate
|
||||||
@ -151,7 +151,7 @@ func (w *windowDelgate) Selector(cmd string) objc.SEL {
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
var err error
|
var err error
|
||||||
class_EbitengineWindowDelegate, err = objc.RegisterClass(&windowDelgate{})
|
class_EbitengineWindowDelegate, err = objc.RegisterClass(&windowDelegate{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
@ -278,7 +278,7 @@ func monitorFromWindowByOS(w *glfw.Window) *glfw.Monitor {
|
|||||||
window := cocoa.NSWindow{ID: objc.ID(w.GetCocoaWindow())}
|
window := cocoa.NSWindow{ID: objc.ID(w.GetCocoaWindow())}
|
||||||
pool := cocoa.NSAutoreleasePool_new()
|
pool := cocoa.NSAutoreleasePool_new()
|
||||||
screen := cocoa.NSScreen_mainScreen()
|
screen := cocoa.NSScreen_mainScreen()
|
||||||
if window.ID != 0 && window.IsVisibile() {
|
if window.ID != 0 && window.IsVisible() {
|
||||||
// When the window is visible, the window is already initialized.
|
// When the window is visible, the window is already initialized.
|
||||||
// [NSScreen mainScreen] sometimes tells a lie when the window is put across monitors (#703).
|
// [NSScreen mainScreen] sometimes tells a lie when the window is put across monitors (#703).
|
||||||
screen = window.Screen()
|
screen = window.Screen()
|
||||||
|
@ -90,7 +90,7 @@ func videoModeScaleUncached(m *glfw.Monitor) float64 {
|
|||||||
// Note: GLFW currently returns physical pixel sizes,
|
// Note: GLFW currently returns physical pixel sizes,
|
||||||
// but we need to predict the window system-side size of the fullscreen window
|
// but we need to predict the window system-side size of the fullscreen window
|
||||||
// for Ebiten's `ScreenSizeInFullscreen` public API.
|
// for Ebiten's `ScreenSizeInFullscreen` public API.
|
||||||
// Also at the moment we need this prior to switching to fullscreen, but that might be replacable.
|
// Also at the moment we need this prior to switching to fullscreen, but that might be replaceable.
|
||||||
// So this function computes the ratio of physical per logical pixels.
|
// So this function computes the ratio of physical per logical pixels.
|
||||||
xconn, err := xgb.NewConn()
|
xconn, err := xgb.NewConn()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -135,7 +135,7 @@ func monitorFromWindowByOS(w *glfw.Window) *glfw.Monitor {
|
|||||||
|
|
||||||
func monitorFromWin32Window(w windows.HWND) *glfw.Monitor {
|
func monitorFromWin32Window(w windows.HWND) *glfw.Monitor {
|
||||||
// Get the current monitor by the window handle instead of the window position. It is because the window
|
// Get the current monitor by the window handle instead of the window position. It is because the window
|
||||||
// position is not relaiable in some cases e.g. when the window is put across multiple monitors.
|
// position is not reliable in some cases e.g. when the window is put across multiple monitors.
|
||||||
|
|
||||||
m := _MonitorFromWindow(w, _MONITOR_DEFAULTTONEAREST)
|
m := _MonitorFromWindow(w, _MONITOR_DEFAULTTONEAREST)
|
||||||
if m == 0 {
|
if m == 0 {
|
||||||
|
10
run.go
10
run.go
@ -120,7 +120,7 @@ type FinalScreenDrawer interface {
|
|||||||
//
|
//
|
||||||
// geoM is the default geometry matrix to render the offscreen onto the final screen.
|
// geoM is the default geometry matrix to render the offscreen onto the final screen.
|
||||||
// geoM scales the offscreen to fit the final screen without changing the aspect ratio, and
|
// geoM scales the offscreen to fit the final screen without changing the aspect ratio, and
|
||||||
// translates the offscreen to put it on the center of the final screen.
|
// translates the offscreen to put it in the center of the final screen.
|
||||||
DrawFinalScreen(screen FinalScreen, offscreen *Image, geoM GeoM)
|
DrawFinalScreen(screen FinalScreen, offscreen *Image, geoM GeoM)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -201,7 +201,7 @@ var Termination = ui.RegularTermination
|
|||||||
//
|
//
|
||||||
// If game implements FinalScreenDrawer, its DrawFinalScreen is called after Draw.
|
// If game implements FinalScreenDrawer, its DrawFinalScreen is called after Draw.
|
||||||
// The argument screen represents the final screen. The argument offscreen is an offscreen modified at Draw.
|
// The argument screen represents the final screen. The argument offscreen is an offscreen modified at Draw.
|
||||||
// If game does not implement FinalScreenDrawer, the dafault rendering for the final screen is used.
|
// If game does not implement FinalScreenDrawer, the default rendering for the final screen is used.
|
||||||
//
|
//
|
||||||
// game's functions are called on the same goroutine.
|
// game's functions are called on the same goroutine.
|
||||||
//
|
//
|
||||||
@ -229,7 +229,7 @@ func RunGame(game Game) error {
|
|||||||
return RunGameWithOptions(game, nil)
|
return RunGameWithOptions(game, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
// RungameOptions represents options for RunGameWithOptions.
|
// RunGameOptions represents options for RunGameWithOptions.
|
||||||
type RunGameOptions struct {
|
type RunGameOptions struct {
|
||||||
// GraphicsLibrary is a graphics library Ebitengine will use.
|
// GraphicsLibrary is a graphics library Ebitengine will use.
|
||||||
//
|
//
|
||||||
@ -264,7 +264,7 @@ type RunGameOptions struct {
|
|||||||
//
|
//
|
||||||
// If game implements FinalScreenDrawer, its DrawFinalScreen is called after Draw.
|
// If game implements FinalScreenDrawer, its DrawFinalScreen is called after Draw.
|
||||||
// The argument screen represents the final screen. The argument offscreen is an offscreen modified at Draw.
|
// The argument screen represents the final screen. The argument offscreen is an offscreen modified at Draw.
|
||||||
// If game does not implement FinalScreenDrawer, the dafault rendering for the final screen is used.
|
// If game does not implement FinalScreenDrawer, the default rendering for the final screen is used.
|
||||||
//
|
//
|
||||||
// game's functions are called on the same goroutine.
|
// game's functions are called on the same goroutine.
|
||||||
//
|
//
|
||||||
@ -638,7 +638,7 @@ var screenTransparent int32 = 0
|
|||||||
//
|
//
|
||||||
// SetInitFocused panics if this is called after the main loop.
|
// SetInitFocused panics if this is called after the main loop.
|
||||||
//
|
//
|
||||||
// SetInitFocused is cuncurrent-safe.
|
// SetInitFocused is concurrent-safe.
|
||||||
//
|
//
|
||||||
// Deprecated: as of v2.5. Use RunGameWithOptions instead.
|
// Deprecated: as of v2.5. Use RunGameWithOptions instead.
|
||||||
func SetInitFocused(focused bool) {
|
func SetInitFocused(focused bool) {
|
||||||
|
@ -30,7 +30,7 @@ type Shader struct {
|
|||||||
shader *ui.Shader
|
shader *ui.Shader
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewShader compiles a shader program in the shading language Kage, and retruns the result.
|
// NewShader compiles a shader program in the shading language Kage, and returns the result.
|
||||||
//
|
//
|
||||||
// If the compilation fails, NewShader returns an error.
|
// If the compilation fails, NewShader returns an error.
|
||||||
//
|
//
|
||||||
|
114
shader_test.go
114
shader_test.go
@ -45,7 +45,7 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
|||||||
got := dst.At(i, j).(color.RGBA)
|
got := dst.At(i, j).(color.RGBA)
|
||||||
var want color.RGBA
|
var want color.RGBA
|
||||||
if i < w/2 && j < h/2 {
|
if i < w/2 && j < h/2 {
|
||||||
want = color.RGBA{0xff, 0, 0, 0xff}
|
want = color.RGBA{R: 0xff, A: 0xff}
|
||||||
}
|
}
|
||||||
if got != want {
|
if got != want {
|
||||||
t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want)
|
t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want)
|
||||||
@ -78,7 +78,7 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
|||||||
got := dst.At(i, j).(color.RGBA)
|
got := dst.At(i, j).(color.RGBA)
|
||||||
var want color.RGBA
|
var want color.RGBA
|
||||||
if i < w/2 && j < h/2 {
|
if i < w/2 && j < h/2 {
|
||||||
want = color.RGBA{0xff, 0, 0, 0xff}
|
want = color.RGBA{R: 0xff, A: 0xff}
|
||||||
}
|
}
|
||||||
if got != want {
|
if got != want {
|
||||||
t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want)
|
t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want)
|
||||||
@ -104,9 +104,9 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
src0 := ebiten.NewImageWithOptions(rect, &ebiten.NewImageOptions{Unmanaged: true})
|
src0 := ebiten.NewImageWithOptions(rect, &ebiten.NewImageOptions{Unmanaged: true})
|
||||||
src0.Fill(color.RGBA{25, 0xff, 25, 0xff})
|
src0.Fill(color.RGBA{R: 25, G: 0xff, B: 25, A: 0xff})
|
||||||
src1 := ebiten.NewImageWithOptions(rect, &ebiten.NewImageOptions{Unmanaged: true})
|
src1 := ebiten.NewImageWithOptions(rect, &ebiten.NewImageOptions{Unmanaged: true})
|
||||||
src1.Fill(color.RGBA{0xff, 0, 0, 0xff})
|
src1.Fill(color.RGBA{R: 0xff, A: 0xff})
|
||||||
op := &ebiten.DrawRectShaderOptions{}
|
op := &ebiten.DrawRectShaderOptions{}
|
||||||
op.CompositeMode = ebiten.CompositeModeCopy
|
op.CompositeMode = ebiten.CompositeModeCopy
|
||||||
op.Images[0] = src0
|
op.Images[0] = src0
|
||||||
@ -132,7 +132,7 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
|||||||
for j := 0; j < h; j++ {
|
for j := 0; j < h; j++ {
|
||||||
for i := 0; i < w; i++ {
|
for i := 0; i < w; i++ {
|
||||||
got := dst.At(i, j).(color.RGBA)
|
got := dst.At(i, j).(color.RGBA)
|
||||||
want := color.RGBA{0xff, 0, 0, 0xff}
|
want := color.RGBA{R: 0xff, A: 0xff}
|
||||||
if got != want {
|
if got != want {
|
||||||
t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want)
|
t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want)
|
||||||
}
|
}
|
||||||
@ -149,7 +149,7 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
|||||||
for j := 0; j < h; j++ {
|
for j := 0; j < h; j++ {
|
||||||
for i := 0; i < w; i++ {
|
for i := 0; i < w; i++ {
|
||||||
got := dst.At(i, j).(color.RGBA)
|
got := dst.At(i, j).(color.RGBA)
|
||||||
want := color.RGBA{25, 0xff, 25, 0xff}
|
want := color.RGBA{R: 25, G: 0xff, B: 25, A: 0xff}
|
||||||
if got != want {
|
if got != want {
|
||||||
t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want)
|
t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want)
|
||||||
}
|
}
|
||||||
@ -224,7 +224,7 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
|||||||
for j := 0; j < h; j++ {
|
for j := 0; j < h; j++ {
|
||||||
for i := 0; i < w; i++ {
|
for i := 0; i < w; i++ {
|
||||||
got := dst.At(i, j).(color.RGBA)
|
got := dst.At(i, j).(color.RGBA)
|
||||||
want := color.RGBA{0xff, 0, 0, 0xff}
|
want := color.RGBA{R: 0xff, A: 0xff}
|
||||||
if got != want {
|
if got != want {
|
||||||
t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want)
|
t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want)
|
||||||
}
|
}
|
||||||
@ -255,7 +255,7 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
|||||||
for j := 0; j < h; j++ {
|
for j := 0; j < h; j++ {
|
||||||
for i := 0; i < w; i++ {
|
for i := 0; i < w; i++ {
|
||||||
got := dst.At(i, j).(color.RGBA)
|
got := dst.At(i, j).(color.RGBA)
|
||||||
want := color.RGBA{0xff, 0, 0, 0xff}
|
want := color.RGBA{R: 0xff, A: 0xff}
|
||||||
if got != want {
|
if got != want {
|
||||||
t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want)
|
t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want)
|
||||||
}
|
}
|
||||||
@ -323,7 +323,7 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
|||||||
for j := 0; j < h; j++ {
|
for j := 0; j < h; j++ {
|
||||||
for i := 0; i < w; i++ {
|
for i := 0; i < w; i++ {
|
||||||
got := dst.At(i, j).(color.RGBA)
|
got := dst.At(i, j).(color.RGBA)
|
||||||
want := color.RGBA{87, 82, 71, 255}
|
want := color.RGBA{R: 87, G: 82, B: 71, A: 255}
|
||||||
if got != want {
|
if got != want {
|
||||||
t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want)
|
t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want)
|
||||||
}
|
}
|
||||||
@ -382,7 +382,7 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
|||||||
got := dst.At(i, j).(color.RGBA)
|
got := dst.At(i, j).(color.RGBA)
|
||||||
var want color.RGBA
|
var want color.RGBA
|
||||||
if i < w/2 && j < h/2 {
|
if i < w/2 && j < h/2 {
|
||||||
want = color.RGBA{0xff, 0xff, 0, 0xff}
|
want = color.RGBA{R: 0xff, G: 0xff, A: 0xff}
|
||||||
}
|
}
|
||||||
if got != want {
|
if got != want {
|
||||||
t.Errorf("%s dst.At(%d, %d): got: %v, want: %v", testname, i, j, got, want)
|
t.Errorf("%s dst.At(%d, %d): got: %v, want: %v", testname, i, j, got, want)
|
||||||
@ -493,7 +493,7 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
|||||||
for j := 1; j < h-1; j++ {
|
for j := 1; j < h-1; j++ {
|
||||||
for i := 1; i < w-1; i++ {
|
for i := 1; i < w-1; i++ {
|
||||||
got := dst.At(i, j).(color.RGBA)
|
got := dst.At(i, j).(color.RGBA)
|
||||||
want := color.RGBA{0, 0, 0, 0xff}
|
want := color.RGBA{A: 0xff}
|
||||||
if i == w/2-1 || i == w/2 {
|
if i == w/2-1 || i == w/2 {
|
||||||
want.R = 0xff
|
want.R = 0xff
|
||||||
}
|
}
|
||||||
@ -551,7 +551,7 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
|||||||
for j := 1; j < h-1; j++ {
|
for j := 1; j < h-1; j++ {
|
||||||
for i := 1; i < w-1; i++ {
|
for i := 1; i < w-1; i++ {
|
||||||
got := dst.At(i, j).(color.RGBA)
|
got := dst.At(i, j).(color.RGBA)
|
||||||
want := color.RGBA{0, 0, 0, 0xff}
|
want := color.RGBA{A: 0xff}
|
||||||
if i == w/2-1 || i == w/2 {
|
if i == w/2-1 || i == w/2 {
|
||||||
want.R = 0xff
|
want.R = 0xff
|
||||||
}
|
}
|
||||||
@ -630,7 +630,7 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
|||||||
op := &ebiten.DrawRectShaderOptions{}
|
op := &ebiten.DrawRectShaderOptions{}
|
||||||
op.Uniforms = shader.Uniforms
|
op.Uniforms = shader.Uniforms
|
||||||
dst.DrawRectShader(w, h, s, op)
|
dst.DrawRectShader(w, h, s, op)
|
||||||
if got, want := dst.At(0, 0), (color.RGBA{0xff, 0xff, 0xff, 0xff}); got != want {
|
if got, want := dst.At(0, 0), (color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff}); got != want {
|
||||||
t.Errorf("got: %v, want: %v", got, want)
|
t.Errorf("got: %v, want: %v", got, want)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -660,7 +660,7 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
|||||||
got := dst.At(i, j).(color.RGBA)
|
got := dst.At(i, j).(color.RGBA)
|
||||||
var want color.RGBA
|
var want color.RGBA
|
||||||
if i < w/2 && j < h/2 {
|
if i < w/2 && j < h/2 {
|
||||||
want = color.RGBA{0xc0, 0, 0, 0xff}
|
want = color.RGBA{R: 0xc0, A: 0xff}
|
||||||
}
|
}
|
||||||
if !sameColors(got, want, 2) {
|
if !sameColors(got, want, 2) {
|
||||||
t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want)
|
t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want)
|
||||||
@ -673,7 +673,7 @@ func TestShaderMatrixInitialize(t *testing.T) {
|
|||||||
const w, h = 16, 16
|
const w, h = 16, 16
|
||||||
|
|
||||||
src := ebiten.NewImage(w, h)
|
src := ebiten.NewImage(w, h)
|
||||||
src.Fill(color.RGBA{0x10, 0x20, 0x30, 0xff})
|
src.Fill(color.RGBA{R: 0x10, G: 0x20, B: 0x30, A: 0xff})
|
||||||
|
|
||||||
dst := ebiten.NewImage(w, h)
|
dst := ebiten.NewImage(w, h)
|
||||||
s, err := ebiten.NewShader([]byte(`package main
|
s, err := ebiten.NewShader([]byte(`package main
|
||||||
@ -693,7 +693,7 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
|||||||
for j := 0; j < h; j++ {
|
for j := 0; j < h; j++ {
|
||||||
for i := 0; i < w; i++ {
|
for i := 0; i < w; i++ {
|
||||||
got := dst.At(i, j).(color.RGBA)
|
got := dst.At(i, j).(color.RGBA)
|
||||||
want := color.RGBA{0x20, 0x40, 0x60, 0xff}
|
want := color.RGBA{R: 0x20, G: 0x40, B: 0x60, A: 0xff}
|
||||||
if !sameColors(got, want, 2) {
|
if !sameColors(got, want, 2) {
|
||||||
t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want)
|
t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want)
|
||||||
}
|
}
|
||||||
@ -722,7 +722,7 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
|||||||
for j := 0; j < h; j++ {
|
for j := 0; j < h; j++ {
|
||||||
for i := 0; i < w; i++ {
|
for i := 0; i < w; i++ {
|
||||||
got := dst.At(i, j).(color.RGBA)
|
got := dst.At(i, j).(color.RGBA)
|
||||||
want := color.RGBA{0x40, 0, 0x40, 0xff}
|
want := color.RGBA{R: 0x40, B: 0x40, A: 0xff}
|
||||||
if !sameColors(got, want, 2) {
|
if !sameColors(got, want, 2) {
|
||||||
t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want)
|
t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want)
|
||||||
}
|
}
|
||||||
@ -734,7 +734,7 @@ func TestShaderTextureAt(t *testing.T) {
|
|||||||
const w, h = 16, 16
|
const w, h = 16, 16
|
||||||
|
|
||||||
src := ebiten.NewImage(w, h)
|
src := ebiten.NewImage(w, h)
|
||||||
src.Fill(color.RGBA{0x10, 0x20, 0x30, 0xff})
|
src.Fill(color.RGBA{R: 0x10, G: 0x20, B: 0x30, A: 0xff})
|
||||||
|
|
||||||
dst := ebiten.NewImage(w, h)
|
dst := ebiten.NewImage(w, h)
|
||||||
s, err := ebiten.NewShader([]byte(`package main
|
s, err := ebiten.NewShader([]byte(`package main
|
||||||
@ -758,7 +758,7 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
|||||||
for j := 0; j < h; j++ {
|
for j := 0; j < h; j++ {
|
||||||
for i := 0; i < w; i++ {
|
for i := 0; i < w; i++ {
|
||||||
got := dst.At(i, j).(color.RGBA)
|
got := dst.At(i, j).(color.RGBA)
|
||||||
want := color.RGBA{0x10, 0x20, 0x30, 0xff}
|
want := color.RGBA{R: 0x10, G: 0x20, B: 0x30, A: 0xff}
|
||||||
if !sameColors(got, want, 2) {
|
if !sameColors(got, want, 2) {
|
||||||
t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want)
|
t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want)
|
||||||
}
|
}
|
||||||
@ -770,7 +770,7 @@ func TestShaderAtan2(t *testing.T) {
|
|||||||
const w, h = 16, 16
|
const w, h = 16, 16
|
||||||
|
|
||||||
src := ebiten.NewImage(w, h)
|
src := ebiten.NewImage(w, h)
|
||||||
src.Fill(color.RGBA{0x10, 0x20, 0x30, 0xff})
|
src.Fill(color.RGBA{R: 0x10, G: 0x20, B: 0x30, A: 0xff})
|
||||||
|
|
||||||
dst := ebiten.NewImage(w, h)
|
dst := ebiten.NewImage(w, h)
|
||||||
s, err := ebiten.NewShader([]byte(`package main
|
s, err := ebiten.NewShader([]byte(`package main
|
||||||
@ -793,7 +793,7 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
|||||||
for i := 0; i < w; i++ {
|
for i := 0; i < w; i++ {
|
||||||
got := dst.At(i, j).(color.RGBA)
|
got := dst.At(i, j).(color.RGBA)
|
||||||
v := byte(math.Floor(0xff * math.Pi / 4))
|
v := byte(math.Floor(0xff * math.Pi / 4))
|
||||||
want := color.RGBA{v, v, v, v}
|
want := color.RGBA{R: v, G: v, B: v, A: v}
|
||||||
if !sameColors(got, want, 2) {
|
if !sameColors(got, want, 2) {
|
||||||
t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want)
|
t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want)
|
||||||
}
|
}
|
||||||
@ -831,7 +831,7 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
|||||||
for j := 0; j < h; j++ {
|
for j := 0; j < h; j++ {
|
||||||
for i := 0; i < w; i++ {
|
for i := 0; i < w; i++ {
|
||||||
got := dst.At(i, j).(color.RGBA)
|
got := dst.At(i, j).(color.RGBA)
|
||||||
want := color.RGBA{8, 12, 0xff, 0xff}
|
want := color.RGBA{R: 8, G: 12, B: 0xff, A: 0xff}
|
||||||
if !sameColors(got, want, 2) {
|
if !sameColors(got, want, 2) {
|
||||||
t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want)
|
t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want)
|
||||||
}
|
}
|
||||||
@ -871,7 +871,7 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
|||||||
for j := 0; j < h; j++ {
|
for j := 0; j < h; j++ {
|
||||||
for i := 0; i < w; i++ {
|
for i := 0; i < w; i++ {
|
||||||
got := dst.At(i, j).(color.RGBA)
|
got := dst.At(i, j).(color.RGBA)
|
||||||
want := color.RGBA{54, 80, 0xff, 0xff}
|
want := color.RGBA{R: 54, G: 80, B: 0xff, A: 0xff}
|
||||||
if !sameColors(got, want, 2) {
|
if !sameColors(got, want, 2) {
|
||||||
t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want)
|
t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want)
|
||||||
}
|
}
|
||||||
@ -910,7 +910,7 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
|||||||
for j := 0; j < h; j++ {
|
for j := 0; j < h; j++ {
|
||||||
for i := 0; i < w; i++ {
|
for i := 0; i < w; i++ {
|
||||||
got := dst.At(i, j).(color.RGBA)
|
got := dst.At(i, j).(color.RGBA)
|
||||||
want := color.RGBA{24, 30, 36, 0xff}
|
want := color.RGBA{R: 24, G: 30, B: 36, A: 0xff}
|
||||||
if !sameColors(got, want, 2) {
|
if !sameColors(got, want, 2) {
|
||||||
t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want)
|
t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want)
|
||||||
}
|
}
|
||||||
@ -952,7 +952,7 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
|||||||
for j := 0; j < h; j++ {
|
for j := 0; j < h; j++ {
|
||||||
for i := 0; i < w; i++ {
|
for i := 0; i < w; i++ {
|
||||||
got := dst.At(i, j).(color.RGBA)
|
got := dst.At(i, j).(color.RGBA)
|
||||||
want := color.RGBA{6, 8, 9, 0xff}
|
want := color.RGBA{R: 6, G: 8, B: 9, A: 0xff}
|
||||||
if !sameColors(got, want, 2) {
|
if !sameColors(got, want, 2) {
|
||||||
t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want)
|
t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want)
|
||||||
}
|
}
|
||||||
@ -992,7 +992,7 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
|||||||
for j := 0; j < h; j++ {
|
for j := 0; j < h; j++ {
|
||||||
for i := 0; i < w; i++ {
|
for i := 0; i < w; i++ {
|
||||||
got := dst.At(i, j).(color.RGBA)
|
got := dst.At(i, j).(color.RGBA)
|
||||||
want := color.RGBA{112, 128, 143, 159}
|
want := color.RGBA{R: 112, G: 128, B: 143, A: 159}
|
||||||
if !sameColors(got, want, 2) {
|
if !sameColors(got, want, 2) {
|
||||||
t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want)
|
t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want)
|
||||||
}
|
}
|
||||||
@ -1036,7 +1036,7 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
|||||||
for j := 0; j < h; j++ {
|
for j := 0; j < h; j++ {
|
||||||
for i := 0; i < w; i++ {
|
for i := 0; i < w; i++ {
|
||||||
got := dst.At(i, j).(color.RGBA)
|
got := dst.At(i, j).(color.RGBA)
|
||||||
want := color.RGBA{44, 50, 56, 62}
|
want := color.RGBA{R: 44, G: 50, B: 56, A: 62}
|
||||||
if !sameColors(got, want, 2) {
|
if !sameColors(got, want, 2) {
|
||||||
t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want)
|
t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want)
|
||||||
}
|
}
|
||||||
@ -1098,7 +1098,7 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
|||||||
got := dst.At(i, j).(color.RGBA)
|
got := dst.At(i, j).(color.RGBA)
|
||||||
var want color.RGBA
|
var want color.RGBA
|
||||||
if 0 <= i && i < w/2 && 0 <= j && j < h/2 {
|
if 0 <= i && i < w/2 && 0 <= j && j < h/2 {
|
||||||
want = color.RGBA{0xff, 0xff, 0, 0xff}
|
want = color.RGBA{R: 0xff, G: 0xff, A: 0xff}
|
||||||
}
|
}
|
||||||
if got != want {
|
if got != want {
|
||||||
t.Errorf("%s dst.At(%d, %d): got: %v, want: %v", testname, i, j, got, want)
|
t.Errorf("%s dst.At(%d, %d): got: %v, want: %v", testname, i, j, got, want)
|
||||||
@ -1196,7 +1196,7 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
|||||||
for j := 0; j < h; j++ {
|
for j := 0; j < h; j++ {
|
||||||
for i := 0; i < w; i++ {
|
for i := 0; i < w; i++ {
|
||||||
got := dst.At(i, j).(color.RGBA)
|
got := dst.At(i, j).(color.RGBA)
|
||||||
want := color.RGBA{0xff, 0, 0x00, 0xff}
|
want := color.RGBA{R: 0xff, A: 0xff}
|
||||||
if !sameColors(got, want, 2) {
|
if !sameColors(got, want, 2) {
|
||||||
t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want)
|
t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want)
|
||||||
}
|
}
|
||||||
@ -1209,7 +1209,7 @@ func TestShaderDiscard(t *testing.T) {
|
|||||||
const w, h = 16, 16
|
const w, h = 16, 16
|
||||||
|
|
||||||
dst := ebiten.NewImage(w, h)
|
dst := ebiten.NewImage(w, h)
|
||||||
dst.Fill(color.RGBA{0xff, 0, 0, 0xff})
|
dst.Fill(color.RGBA{R: 0xff, A: 0xff})
|
||||||
|
|
||||||
src := ebiten.NewImage(w, h)
|
src := ebiten.NewImage(w, h)
|
||||||
pix := make([]byte, 4*w*h)
|
pix := make([]byte, 4*w*h)
|
||||||
@ -1245,9 +1245,9 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
|||||||
for j := 0; j < h; j++ {
|
for j := 0; j < h; j++ {
|
||||||
for i := 0; i < w; i++ {
|
for i := 0; i < w; i++ {
|
||||||
got := dst.At(i, j).(color.RGBA)
|
got := dst.At(i, j).(color.RGBA)
|
||||||
want := color.RGBA{0, 0xff, 0x00, 0xff}
|
want := color.RGBA{G: 0xff, A: 0xff}
|
||||||
if i >= w/2 || j >= h/2 {
|
if i >= w/2 || j >= h/2 {
|
||||||
want = color.RGBA{0xff, 0, 0x00, 0xff}
|
want = color.RGBA{R: 0xff, A: 0xff}
|
||||||
}
|
}
|
||||||
if !sameColors(got, want, 2) {
|
if !sameColors(got, want, 2) {
|
||||||
t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want)
|
t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want)
|
||||||
@ -1299,9 +1299,9 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
|||||||
var want color.RGBA
|
var want color.RGBA
|
||||||
if offsetX <= i && i < offsetX+srcW && offsetY <= j && j < offsetY+srcH {
|
if offsetX <= i && i < offsetX+srcW && offsetY <= j && j < offsetY+srcH {
|
||||||
if offsetX+srcW/2 <= i && offsetY+srcH/2 <= j {
|
if offsetX+srcW/2 <= i && offsetY+srcH/2 <= j {
|
||||||
want = color.RGBA{0xff, 0, 0, 0xff}
|
want = color.RGBA{R: 0xff, A: 0xff}
|
||||||
} else {
|
} else {
|
||||||
want = color.RGBA{0, 0xff, 0, 0xff}
|
want = color.RGBA{G: 0xff, A: 0xff}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if got != want {
|
if got != want {
|
||||||
@ -1330,13 +1330,13 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
|||||||
op.ColorScale.SetG(5.0 / 8.0)
|
op.ColorScale.SetG(5.0 / 8.0)
|
||||||
op.ColorScale.SetB(6.0 / 8.0)
|
op.ColorScale.SetB(6.0 / 8.0)
|
||||||
op.ColorScale.SetA(7.0 / 8.0)
|
op.ColorScale.SetA(7.0 / 8.0)
|
||||||
op.ColorScale.ScaleWithColor(color.RGBA{0x40, 0x80, 0xc0, 0xff})
|
op.ColorScale.ScaleWithColor(color.RGBA{R: 0x40, G: 0x80, B: 0xc0, A: 0xff})
|
||||||
dst.DrawRectShader(w, h, s, op)
|
dst.DrawRectShader(w, h, s, op)
|
||||||
|
|
||||||
for j := 0; j < h; j++ {
|
for j := 0; j < h; j++ {
|
||||||
for i := 0; i < w; i++ {
|
for i := 0; i < w; i++ {
|
||||||
got := dst.At(i, j).(color.RGBA)
|
got := dst.At(i, j).(color.RGBA)
|
||||||
want := color.RGBA{0x20, 0x50, 0x90, 0xe0}
|
want := color.RGBA{R: 0x20, G: 0x50, B: 0x90, A: 0xe0}
|
||||||
if !sameColors(got, want, 1) {
|
if !sameColors(got, want, 1) {
|
||||||
t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want)
|
t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want)
|
||||||
}
|
}
|
||||||
@ -1391,7 +1391,7 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
|||||||
"U3": 0xff,
|
"U3": 0xff,
|
||||||
},
|
},
|
||||||
Shader: ints,
|
Shader: ints,
|
||||||
Want: color.RGBA{0xff, 0xff, 0xff, 0xff},
|
Want: color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "int",
|
Name: "int",
|
||||||
@ -1402,7 +1402,7 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
|||||||
"U3": int64(0x88),
|
"U3": int64(0x88),
|
||||||
},
|
},
|
||||||
Shader: ints,
|
Shader: ints,
|
||||||
Want: color.RGBA{0x24, 0x3f, 0x6a, 0x88},
|
Want: color.RGBA{R: 0x24, G: 0x3f, B: 0x6a, A: 0x88},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "uint",
|
Name: "uint",
|
||||||
@ -1413,7 +1413,7 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
|||||||
"U3": uint64(0xd3),
|
"U3": uint64(0xd3),
|
||||||
},
|
},
|
||||||
Shader: ints,
|
Shader: ints,
|
||||||
Want: color.RGBA{0x85, 0xa3, 0x08, 0xd3},
|
Want: color.RGBA{R: 0x85, G: 0xa3, B: 0x08, A: 0xd3},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "0xff,slice",
|
Name: "0xff,slice",
|
||||||
@ -1421,7 +1421,7 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
|||||||
"U": []int{0xff, 0xff, 0xff, 0xff},
|
"U": []int{0xff, 0xff, 0xff, 0xff},
|
||||||
},
|
},
|
||||||
Shader: intArray,
|
Shader: intArray,
|
||||||
Want: color.RGBA{0xff, 0xff, 0xff, 0xff},
|
Want: color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "int,slice",
|
Name: "int,slice",
|
||||||
@ -1429,7 +1429,7 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
|||||||
"U": []int16{0x24, 0x3f, 0x6a, 0x88},
|
"U": []int16{0x24, 0x3f, 0x6a, 0x88},
|
||||||
},
|
},
|
||||||
Shader: intArray,
|
Shader: intArray,
|
||||||
Want: color.RGBA{0x24, 0x3f, 0x6a, 0x88},
|
Want: color.RGBA{R: 0x24, G: 0x3f, B: 0x6a, A: 0x88},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "uint,slice",
|
Name: "uint,slice",
|
||||||
@ -1437,7 +1437,7 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
|||||||
"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{R: 0x85, G: 0xa3, B: 0x08, A: 0xd3},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "0xff,array",
|
Name: "0xff,array",
|
||||||
@ -1445,7 +1445,7 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
|||||||
"U": [...]int{0xff, 0xff, 0xff, 0xff},
|
"U": [...]int{0xff, 0xff, 0xff, 0xff},
|
||||||
},
|
},
|
||||||
Shader: intArray,
|
Shader: intArray,
|
||||||
Want: color.RGBA{0xff, 0xff, 0xff, 0xff},
|
Want: color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "int,array",
|
Name: "int,array",
|
||||||
@ -1453,7 +1453,7 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
|||||||
"U": [...]int16{0x24, 0x3f, 0x6a, 0x88},
|
"U": [...]int16{0x24, 0x3f, 0x6a, 0x88},
|
||||||
},
|
},
|
||||||
Shader: intArray,
|
Shader: intArray,
|
||||||
Want: color.RGBA{0x24, 0x3f, 0x6a, 0x88},
|
Want: color.RGBA{R: 0x24, G: 0x3f, B: 0x6a, A: 0x88},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "uint,array",
|
Name: "uint,array",
|
||||||
@ -1461,7 +1461,7 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
|||||||
"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{R: 0x85, G: 0xa3, B: 0x08, A: 0xd3},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "0xff,array",
|
Name: "0xff,array",
|
||||||
@ -1469,7 +1469,7 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
|||||||
"U": [...]int{0xff, 0xff, 0xff, 0xff},
|
"U": [...]int{0xff, 0xff, 0xff, 0xff},
|
||||||
},
|
},
|
||||||
Shader: intArray,
|
Shader: intArray,
|
||||||
Want: color.RGBA{0xff, 0xff, 0xff, 0xff},
|
Want: color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "int,array",
|
Name: "int,array",
|
||||||
@ -1477,7 +1477,7 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
|||||||
"U": [...]int16{0x24, 0x3f, 0x6a, 0x88},
|
"U": [...]int16{0x24, 0x3f, 0x6a, 0x88},
|
||||||
},
|
},
|
||||||
Shader: intArray,
|
Shader: intArray,
|
||||||
Want: color.RGBA{0x24, 0x3f, 0x6a, 0x88},
|
Want: color.RGBA{R: 0x24, G: 0x3f, B: 0x6a, A: 0x88},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "uint,array",
|
Name: "uint,array",
|
||||||
@ -1485,7 +1485,7 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
|||||||
"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{R: 0x85, G: 0xa3, B: 0x08, A: 0xd3},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "0xff,ivec",
|
Name: "0xff,ivec",
|
||||||
@ -1494,7 +1494,7 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
|||||||
"U1": [...]int{0xff, 0xff, 0xff, 0xff, 0xff, 0xff},
|
"U1": [...]int{0xff, 0xff, 0xff, 0xff, 0xff, 0xff},
|
||||||
},
|
},
|
||||||
Shader: intVec,
|
Shader: intVec,
|
||||||
Want: color.RGBA{0xff, 0xff, 0xff, 0xff},
|
Want: color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "int,ivec",
|
Name: "int,ivec",
|
||||||
@ -1503,7 +1503,7 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
|||||||
"U1": [...]int16{0x85, 0xa3, 0x08, 0xd3, 0x13, 0x19},
|
"U1": [...]int16{0x85, 0xa3, 0x08, 0xd3, 0x13, 0x19},
|
||||||
},
|
},
|
||||||
Shader: intVec,
|
Shader: intVec,
|
||||||
Want: color.RGBA{0x24, 0x3f, 0x08, 0xd3},
|
Want: color.RGBA{R: 0x24, G: 0x3f, B: 0x08, A: 0xd3},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "uint,ivec",
|
Name: "uint,ivec",
|
||||||
@ -1512,7 +1512,7 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
|||||||
"U1": [...]uint8{0x85, 0xa3, 0x08, 0xd3, 0x13, 0x19},
|
"U1": [...]uint8{0x85, 0xa3, 0x08, 0xd3, 0x13, 0x19},
|
||||||
},
|
},
|
||||||
Shader: intVec,
|
Shader: intVec,
|
||||||
Want: color.RGBA{0x24, 0x3f, 0x08, 0xd3},
|
Want: color.RGBA{R: 0x24, G: 0x3f, B: 0x08, A: 0xd3},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
@ -1570,7 +1570,7 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
dst.DrawRectShader(w, h, s, op)
|
dst.DrawRectShader(w, h, s, op)
|
||||||
if got, want := dst.At(0, 0).(color.RGBA), (color.RGBA{0x24, 0x85, 0x13, 0x19}); !sameColors(got, want, 1) {
|
if got, want := dst.At(0, 0).(color.RGBA), (color.RGBA{R: 0x24, G: 0x85, B: 0x13, A: 0x19}); !sameColors(got, want, 1) {
|
||||||
t.Errorf("got: %v, want: %v", got, want)
|
t.Errorf("got: %v, want: %v", got, want)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1583,31 +1583,31 @@ func TestShaderIVecMod(t *testing.T) {
|
|||||||
{
|
{
|
||||||
source: `a := ivec4(0x24, 0x3f, 0x6a, 0x88)
|
source: `a := ivec4(0x24, 0x3f, 0x6a, 0x88)
|
||||||
return vec4(a)/255`,
|
return vec4(a)/255`,
|
||||||
want: color.RGBA{0x24, 0x3f, 0x6a, 0x88},
|
want: color.RGBA{R: 0x24, G: 0x3f, B: 0x6a, A: 0x88},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
source: `a := ivec4(0x24, 0x3f, 0x6a, 0x88)
|
source: `a := ivec4(0x24, 0x3f, 0x6a, 0x88)
|
||||||
a %= 0x85
|
a %= 0x85
|
||||||
return vec4(a)/255`,
|
return vec4(a)/255`,
|
||||||
want: color.RGBA{0x24, 0x3f, 0x6a, 0x03},
|
want: color.RGBA{R: 0x24, G: 0x3f, B: 0x6a, A: 0x03},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
source: `a := ivec4(0x24, 0x3f, 0x6a, 0x88)
|
source: `a := ivec4(0x24, 0x3f, 0x6a, 0x88)
|
||||||
a %= ivec4(0x85, 0xa3, 0x08, 0xd3)
|
a %= ivec4(0x85, 0xa3, 0x08, 0xd3)
|
||||||
return vec4(a)/255`,
|
return vec4(a)/255`,
|
||||||
want: color.RGBA{0x24, 0x3f, 0x02, 0x88},
|
want: color.RGBA{R: 0x24, G: 0x3f, B: 0x02, A: 0x88},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
source: `a := ivec4(0x24, 0x3f, 0x6a, 0x88)
|
source: `a := ivec4(0x24, 0x3f, 0x6a, 0x88)
|
||||||
b := a % 0x85
|
b := a % 0x85
|
||||||
return vec4(b)/255`,
|
return vec4(b)/255`,
|
||||||
want: color.RGBA{0x24, 0x3f, 0x6a, 0x03},
|
want: color.RGBA{R: 0x24, G: 0x3f, B: 0x6a, A: 0x03},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
source: `a := ivec4(0x24, 0x3f, 0x6a, 0x88)
|
source: `a := ivec4(0x24, 0x3f, 0x6a, 0x88)
|
||||||
b := a % ivec4(0x85, 0xa3, 0x08, 0xd3)
|
b := a % ivec4(0x85, 0xa3, 0x08, 0xd3)
|
||||||
return vec4(b)/255`,
|
return vec4(b)/255`,
|
||||||
want: color.RGBA{0x24, 0x3f, 0x02, 0x88},
|
want: color.RGBA{R: 0x24, G: 0x3f, B: 0x02, A: 0x88},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -448,7 +448,7 @@ const (
|
|||||||
LineJoinRound
|
LineJoinRound
|
||||||
)
|
)
|
||||||
|
|
||||||
// StokeOptions is options to render a stroke.
|
// StrokeOptions is options to render a stroke.
|
||||||
type StrokeOptions struct {
|
type StrokeOptions struct {
|
||||||
// Width is the stroke width in pixels.
|
// Width is the stroke width in pixels.
|
||||||
//
|
//
|
||||||
|
@ -91,7 +91,7 @@ func StrokeRect(dst *ebiten.Image, x, y, width, height float32, strokeWidth floa
|
|||||||
drawVerticesForUtil(dst, vs, is, clr)
|
drawVerticesForUtil(dst, vs, is, clr)
|
||||||
}
|
}
|
||||||
|
|
||||||
// DrawFilledCircle filles a circle with the specified center position (cx, cy), the radius (r), width and color.
|
// DrawFilledCircle fills a circle with the specified center position (cx, cy), the radius (r), width and color.
|
||||||
func DrawFilledCircle(dst *ebiten.Image, cx, cy, r float32, clr color.Color) {
|
func DrawFilledCircle(dst *ebiten.Image, cx, cy, r float32, clr color.Color) {
|
||||||
var path Path
|
var path Path
|
||||||
path.Arc(cx, cy, r, 0, 2*math.Pi, Clockwise)
|
path.Arc(cx, cy, r, 0, 2*math.Pi, Clockwise)
|
||||||
|
12
window.go
12
window.go
@ -30,16 +30,16 @@ type WindowResizingModeType = ui.WindowResizingMode
|
|||||||
// WindowResizingModeTypes
|
// WindowResizingModeTypes
|
||||||
const (
|
const (
|
||||||
// WindowResizingModeDisabled indicates the mode to disallow resizing the window by a user.
|
// WindowResizingModeDisabled indicates the mode to disallow resizing the window by a user.
|
||||||
WindowResizingModeDisabled WindowResizingModeType = WindowResizingModeType(ui.WindowResizingModeDisabled)
|
WindowResizingModeDisabled WindowResizingModeType = ui.WindowResizingModeDisabled
|
||||||
|
|
||||||
// WindowResizingModeOnlyFullscreenEnabled indicates the mode to disallow resizing the window,
|
// WindowResizingModeOnlyFullscreenEnabled indicates the mode to disallow resizing the window,
|
||||||
// but allow to make the window fullscreen by a user.
|
// but allow to make the window fullscreen by a user.
|
||||||
// This works only on macOS so far.
|
// This works only on macOS so far.
|
||||||
// On the other platforms, this is the same as WindowResizingModeDisabled.
|
// On the other platforms, this is the same as WindowResizingModeDisabled.
|
||||||
WindowResizingModeOnlyFullscreenEnabled WindowResizingModeType = WindowResizingModeType(ui.WindowResizingModeOnlyFullscreenEnabled)
|
WindowResizingModeOnlyFullscreenEnabled WindowResizingModeType = ui.WindowResizingModeOnlyFullscreenEnabled
|
||||||
|
|
||||||
// WindowResizingModeEnabled indicates the mode to allow resizing the window by a user.
|
// WindowResizingModeEnabled indicates the mode to allow resizing the window by a user.
|
||||||
WindowResizingModeEnabled WindowResizingModeType = WindowResizingModeType(ui.WindowResizingModeEnabled)
|
WindowResizingModeEnabled WindowResizingModeType = ui.WindowResizingModeEnabled
|
||||||
)
|
)
|
||||||
|
|
||||||
// IsWindowDecorated reports whether the window is decorated.
|
// IsWindowDecorated reports whether the window is decorated.
|
||||||
@ -67,14 +67,14 @@ func SetWindowDecorated(decorated bool) {
|
|||||||
//
|
//
|
||||||
// WindowResizingMode is concurrent-safe.
|
// WindowResizingMode is concurrent-safe.
|
||||||
func WindowResizingMode() WindowResizingModeType {
|
func WindowResizingMode() WindowResizingModeType {
|
||||||
return WindowResizingModeType(ui.Get().Window().ResizingMode())
|
return ui.Get().Window().ResizingMode()
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetWindowResizingMode sets the mode in which a user resizes the window.
|
// SetWindowResizingMode sets the mode in which a user resizes the window.
|
||||||
//
|
//
|
||||||
// SetWindowResizingMode is concurrent-safe.
|
// SetWindowResizingMode is concurrent-safe.
|
||||||
func SetWindowResizingMode(mode WindowResizingModeType) {
|
func SetWindowResizingMode(mode WindowResizingModeType) {
|
||||||
ui.Get().Window().SetResizingMode(ui.WindowResizingMode(mode))
|
ui.Get().Window().SetResizingMode(mode)
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsWindowResizable reports whether the window is resizable by the user's dragging on desktops.
|
// IsWindowResizable reports whether the window is resizable by the user's dragging on desktops.
|
||||||
@ -300,7 +300,7 @@ func IsWindowBeingClosed() bool {
|
|||||||
// SetWindowClosingHandled sets whether the window closing is handled or not on desktops. The default state is false.
|
// SetWindowClosingHandled sets whether the window closing is handled or not on desktops. The default state is false.
|
||||||
//
|
//
|
||||||
// If the window closing is handled, the window is not closed immediately and
|
// If the window closing is handled, the window is not closed immediately and
|
||||||
// the game can know whether the window is begin closed or not by IsWindowBeingClosed.
|
// the game can know whether the window is being closed or not by IsWindowBeingClosed.
|
||||||
// In this case, the window is not closed automatically.
|
// In this case, the window is not closed automatically.
|
||||||
// To end the game, you have to return an error value at the Game's Update function.
|
// To end the game, you have to return an error value at the Game's Update function.
|
||||||
//
|
//
|
||||||
|
Loading…
Reference in New Issue
Block a user