diff --git a/example/game/input/input.go b/example/game/input/input.go index 0d3e8f245..4619d668c 100644 --- a/example/game/input/input.go +++ b/example/game/input/input.go @@ -26,7 +26,6 @@ import ( "github.com/hajimehoshi/go.ebiten/graphics" "github.com/hajimehoshi/go.ebiten/graphics/matrix" "image" - "image/color" "os" ) @@ -60,7 +59,7 @@ func (game *Input) Update(context ebiten.GameContext) { } func (game *Input) Draw(g graphics.Context) { - g.Fill(&color.RGBA{R: 128, G: 128, B: 255, A: 255}) + g.Fill(128, 128, 255) str := fmt.Sprintf(`Input State: X: %d Y: %d`, game.inputState.X, game.inputState.Y) diff --git a/example/game/monochrome/monochrome.go b/example/game/monochrome/monochrome.go index 4d6d75965..768f09ee1 100644 --- a/example/game/monochrome/monochrome.go +++ b/example/game/monochrome/monochrome.go @@ -25,7 +25,6 @@ import ( "github.com/hajimehoshi/go.ebiten/graphics" "github.com/hajimehoshi/go.ebiten/graphics/matrix" "image" - "image/color" _ "image/png" "os" ) @@ -116,7 +115,7 @@ func (game *Monochrome) Update(context ebiten.GameContext) { } func (game *Monochrome) Draw(g graphics.Context) { - g.Fill(&color.RGBA{R: 128, G: 128, B: 255, A: 255}) + g.Fill(128, 128, 255) g.DrawTexture(game.ebitenTexture.ID(), game.geometryMatrix, game.colorMatrix) diff --git a/example/game/rects/rects.go b/example/game/rects/rects.go index c82280ccc..fe90ba04f 100644 --- a/example/game/rects/rects.go +++ b/example/game/rects/rects.go @@ -95,13 +95,13 @@ func (game *Rects) rectColorMatrix() matrix.Color { func (game *Rects) Draw(g graphics.Context) { if !game.rectTextureInited { g.SetOffscreen(game.rectTexture.ID()) - g.Fill(&color.White) + g.Fill(255, 255, 255) game.rectTextureInited = true } g.SetOffscreen(game.offscreen.ID()) if !game.offscreenInited { - g.Fill(&color.RGBA{0, 0, 0, 255}) + g.Fill(0, 0, 0) game.offscreenInited = true } g.DrawTexture(game.rectTexture.Texture().ID(), diff --git a/example/game/rotating/rotating.go b/example/game/rotating/rotating.go index 917767ef0..c53ca5d98 100644 --- a/example/game/rotating/rotating.go +++ b/example/game/rotating/rotating.go @@ -25,7 +25,6 @@ import ( "github.com/hajimehoshi/go.ebiten/graphics" "github.com/hajimehoshi/go.ebiten/graphics/matrix" "image" - "image/color" _ "image/png" "math" "os" @@ -71,7 +70,7 @@ func (game *Rotating) Update(context ebiten.GameContext) { } func (game *Rotating) Draw(g graphics.Context) { - g.Fill(&color.RGBA{R: 128, G: 128, B: 255, A: 255}) + g.Fill(128, 128, 255) g.DrawTexture(game.ebitenTexture.ID(), game.geometryMatrix, matrix.IdentityColor()) diff --git a/example/game/sprites/sprites.go b/example/game/sprites/sprites.go index e1d0a8a60..28ede3c0c 100644 --- a/example/game/sprites/sprites.go +++ b/example/game/sprites/sprites.go @@ -25,7 +25,6 @@ import ( "github.com/hajimehoshi/go.ebiten/graphics" "github.com/hajimehoshi/go.ebiten/graphics/matrix" "image" - "image/color" "math/rand" "os" "time" @@ -123,7 +122,7 @@ func (game *Sprites) Update(context ebiten.GameContext) { } func (game *Sprites) Draw(g graphics.Context) { - g.Fill(&color.RGBA{R: 128, G: 128, B: 255, A: 255}) + g.Fill(128, 128, 255) // Draw the sprites locations := make([]graphics.TexturePart, 0, len(game.sprites)) diff --git a/graphics/graphics.go b/graphics/graphics.go index d2c9e90d3..b3eabe625 100644 --- a/graphics/graphics.go +++ b/graphics/graphics.go @@ -23,7 +23,6 @@ package graphics import ( "github.com/hajimehoshi/go.ebiten/graphics/matrix" "image" - "image/color" ) type Rect struct { @@ -42,7 +41,7 @@ type TexturePart struct { type Context interface { Screen() RenderTarget Clear() - Fill(clr color.Color) + Fill(r, g, b uint8) DrawTexture(textureID TextureID, geometryMatrix matrix.Geometry, colorMatrix matrix.Color) diff --git a/graphics/opengl/context.go b/graphics/opengl/context.go index de556f51c..4ced8f94a 100644 --- a/graphics/opengl/context.go +++ b/graphics/opengl/context.go @@ -30,7 +30,6 @@ import ( "github.com/hajimehoshi/go.ebiten/graphics" "github.com/hajimehoshi/go.ebiten/graphics/matrix" "image" - "image/color" "math" "unsafe" ) @@ -77,18 +76,16 @@ func (context *Context) Screen() graphics.RenderTarget { } func (context *Context) Clear() { - C.glClearColor(0, 0, 0, 255) - C.glClear(C.GL_COLOR_BUFFER_BIT) + context.Fill(0, 0, 0) } -func (context *Context) Fill(clr color.Color) { - r, g, b, a := clr.RGBA() - const max = float64(math.MaxUint16) +func (context *Context) Fill(r, g, b uint8) { + const max = float64(math.MaxUint8) C.glClearColor( C.GLclampf(float64(r)/max), C.GLclampf(float64(g)/max), C.GLclampf(float64(b)/max), - C.GLclampf(float64(a)/max)) + 1) C.glClear(C.GL_COLOR_BUFFER_BIT) }