mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 03:08:54 +01:00
Move some files of internal to internal/graphics
This commit is contained in:
parent
e23b0758e5
commit
ae450433db
@ -20,7 +20,7 @@ install:
|
|||||||
|
|
||||||
script:
|
script:
|
||||||
- go test -v ./...
|
- go test -v ./...
|
||||||
- gopherjs test -v github.com/hajimehoshi/ebiten github.com/hajimehoshi/ebiten/internal
|
- gopherjs test -v github.com/hajimehoshi/ebiten github.com/hajimehoshi/ebiten/internal/graphics
|
||||||
- gopherjs build -v github.com/hajimehoshi/ebiten/example/blocks
|
- gopherjs build -v github.com/hajimehoshi/ebiten/example/blocks
|
||||||
|
|
||||||
notifications:
|
notifications:
|
||||||
|
4
image.go
4
image.go
@ -17,7 +17,6 @@ package ebiten
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/hajimehoshi/ebiten/internal"
|
|
||||||
"github.com/hajimehoshi/ebiten/internal/graphics"
|
"github.com/hajimehoshi/ebiten/internal/graphics"
|
||||||
"github.com/hajimehoshi/ebiten/internal/graphics/internal/opengl"
|
"github.com/hajimehoshi/ebiten/internal/graphics/internal/opengl"
|
||||||
"github.com/hajimehoshi/ebiten/internal/ui"
|
"github.com/hajimehoshi/ebiten/internal/ui"
|
||||||
@ -48,7 +47,6 @@ func (i *Image) Clear() (err error) {
|
|||||||
// Fill fills the image with a solid color.
|
// Fill fills the image with a solid color.
|
||||||
func (i *Image) Fill(clr color.Color) (err error) {
|
func (i *Image) Fill(clr color.Color) (err error) {
|
||||||
i.pixels = nil
|
i.pixels = nil
|
||||||
//r, g, b, a := internal.RGBA(clr)
|
|
||||||
cr, cg, cb, ca := clr.RGBA()
|
cr, cg, cb, ca := clr.RGBA()
|
||||||
const max = math.MaxUint16
|
const max = math.MaxUint16
|
||||||
r := float64(cr) / max
|
r := float64(cr) / max
|
||||||
@ -166,7 +164,7 @@ func (i *Image) At(x, y int) color.Color {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
w, _ := i.Size()
|
w, _ := i.Size()
|
||||||
w = internal.NextPowerOf2Int(w)
|
w = graphics.NextPowerOf2Int(w)
|
||||||
idx := 4*x + 4*y*w
|
idx := 4*x + 4*y*w
|
||||||
r, g, b, a := i.pixels[idx], i.pixels[idx+1], i.pixels[idx+2], i.pixels[idx+3]
|
r, g, b, a := i.pixels[idx], i.pixels[idx+1], i.pixels[idx+2], i.pixels[idx+3]
|
||||||
return color.RGBA{r, g, b, a}
|
return color.RGBA{r, g, b, a}
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
package ebiten
|
package ebiten
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/hajimehoshi/ebiten/internal"
|
"github.com/hajimehoshi/ebiten/internal/graphics"
|
||||||
"image"
|
"image"
|
||||||
"math"
|
"math"
|
||||||
)
|
)
|
||||||
@ -68,11 +68,11 @@ func (w *wholeImage) Src(i int) (x0, y0, x1, y1 int) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func u(x int, width int) int {
|
func u(x int, width int) int {
|
||||||
return math.MaxInt16 * x / internal.NextPowerOf2Int(width)
|
return math.MaxInt16 * x / graphics.NextPowerOf2Int(width)
|
||||||
}
|
}
|
||||||
|
|
||||||
func v(y int, height int) int {
|
func v(y int, height int) int {
|
||||||
return math.MaxInt16 * y / internal.NextPowerOf2Int(height)
|
return math.MaxInt16 * y / graphics.NextPowerOf2Int(height)
|
||||||
}
|
}
|
||||||
|
|
||||||
type textureQuads struct {
|
type textureQuads struct {
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
package graphics
|
package graphics
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/hajimehoshi/ebiten/internal"
|
|
||||||
"github.com/hajimehoshi/ebiten/internal/graphics/internal/opengl"
|
"github.com/hajimehoshi/ebiten/internal/graphics/internal/opengl"
|
||||||
"image/color"
|
"image/color"
|
||||||
)
|
)
|
||||||
@ -90,18 +89,18 @@ func (f *Framebuffer) Dispose(c *opengl.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (f *Framebuffer) setAsViewport(c *opengl.Context) error {
|
func (f *Framebuffer) setAsViewport(c *opengl.Context) error {
|
||||||
width := internal.NextPowerOf2Int(f.width)
|
width := NextPowerOf2Int(f.width)
|
||||||
height := internal.NextPowerOf2Int(f.height)
|
height := NextPowerOf2Int(f.height)
|
||||||
return c.SetViewport(f.native, width, height)
|
return c.SetViewport(f.native, width, height)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *Framebuffer) projectionMatrix() *[4][4]float64 {
|
func (f *Framebuffer) projectionMatrix() *[4][4]float64 {
|
||||||
width := internal.NextPowerOf2Int(f.width)
|
width := NextPowerOf2Int(f.width)
|
||||||
height := internal.NextPowerOf2Int(f.height)
|
height := NextPowerOf2Int(f.height)
|
||||||
m := orthoProjectionMatrix(0, width, 0, height)
|
m := orthoProjectionMatrix(0, width, 0, height)
|
||||||
if f.flipY {
|
if f.flipY {
|
||||||
m[1][1] *= -1
|
m[1][1] *= -1
|
||||||
m[1][3] += float64(f.height) / float64(internal.NextPowerOf2Int(f.height)) * 2
|
m[1][3] += float64(f.height) / float64(NextPowerOf2Int(f.height)) * 2
|
||||||
}
|
}
|
||||||
return m
|
return m
|
||||||
}
|
}
|
||||||
@ -139,6 +138,6 @@ func (f *Framebuffer) DrawFilledRects(c *opengl.Context, rects Rects) error {
|
|||||||
|
|
||||||
func (f *Framebuffer) Pixels(c *opengl.Context) ([]uint8, error) {
|
func (f *Framebuffer) Pixels(c *opengl.Context) ([]uint8, error) {
|
||||||
w, h := f.Size()
|
w, h := f.Size()
|
||||||
w, h = internal.NextPowerOf2Int(w), internal.NextPowerOf2Int(h)
|
w, h = NextPowerOf2Int(w), NextPowerOf2Int(h)
|
||||||
return c.FramebufferPixels(f.native, w, h)
|
return c.FramebufferPixels(f.native, w, h)
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
package internal
|
package graphics
|
||||||
|
|
||||||
func NextPowerOf2Int(x int) int {
|
func NextPowerOf2Int(x int) int {
|
||||||
x -= 1
|
x -= 1
|
@ -12,10 +12,10 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
package internal_test
|
package graphics_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
. "github.com/hajimehoshi/ebiten/internal"
|
. "github.com/hajimehoshi/ebiten/internal/graphics"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
@ -16,7 +16,6 @@ package graphics
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"github.com/hajimehoshi/ebiten/internal"
|
|
||||||
"github.com/hajimehoshi/ebiten/internal/graphics/internal/opengl"
|
"github.com/hajimehoshi/ebiten/internal/graphics/internal/opengl"
|
||||||
"image"
|
"image"
|
||||||
"image/draw"
|
"image/draw"
|
||||||
@ -27,8 +26,8 @@ func adjustImageForTexture(img image.Image) *image.RGBA {
|
|||||||
adjustedImageBounds := image.Rectangle{
|
adjustedImageBounds := image.Rectangle{
|
||||||
image.ZP,
|
image.ZP,
|
||||||
image.Point{
|
image.Point{
|
||||||
internal.NextPowerOf2Int(width),
|
NextPowerOf2Int(width),
|
||||||
internal.NextPowerOf2Int(height),
|
NextPowerOf2Int(height),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
if adjustedImage, ok := img.(*image.RGBA); ok && img.Bounds() == adjustedImageBounds {
|
if adjustedImage, ok := img.(*image.RGBA); ok && img.Bounds() == adjustedImageBounds {
|
||||||
@ -55,8 +54,8 @@ func (t *Texture) Size() (width, height int) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewTexture(c *opengl.Context, width, height int, filter opengl.Filter) (*Texture, error) {
|
func NewTexture(c *opengl.Context, width, height int, filter opengl.Filter) (*Texture, error) {
|
||||||
w := internal.NextPowerOf2Int(width)
|
w := NextPowerOf2Int(width)
|
||||||
h := internal.NextPowerOf2Int(height)
|
h := NextPowerOf2Int(height)
|
||||||
if w < 4 {
|
if w < 4 {
|
||||||
return nil, errors.New("width must be equal or more than 4.")
|
return nil, errors.New("width must be equal or more than 4.")
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user