mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-24 18:02:02 +01:00
Add 'Tag' to the methods of TextureFactory
This commit is contained in:
parent
79c74273f5
commit
dd979ac4d6
@ -42,7 +42,7 @@ func (game *Input) InitTextures(tf graphics.TextureFactory) {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if game.textTextureId, err = tf.CreateTextureFromImage(img); err != nil {
|
||||
if game.textTextureId, err = tf.CreateTextureFromImage("text", img); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ func (game *Monochrome) InitTextures(tf graphics.TextureFactory) {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if game.ebitenTextureId, err = tf.CreateTextureFromImage(img); err != nil {
|
||||
if game.ebitenTextureId, err = tf.CreateTextureFromImage("ebiten", img); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
|
@ -48,11 +48,11 @@ func (game *Rects) OnScreenSizeUpdated(e ui.ScreenSizeUpdatedEvent) {
|
||||
|
||||
func (game *Rects) InitTextures(tf graphics.TextureFactory) {
|
||||
var err error
|
||||
game.rectTextureId, err = tf.CreateRenderTarget(rectTextureWidth, rectTextureHeight)
|
||||
game.rectTextureId, err = tf.CreateRenderTarget("rect", rectTextureWidth, rectTextureHeight)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
game.offscreenId, err = tf.CreateRenderTarget(offscreenWidth, offscreenHeight)
|
||||
game.offscreenId, err = tf.CreateRenderTarget("offscreen", offscreenWidth, offscreenHeight)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ func (game *Rotating) InitTextures(tf graphics.TextureFactory) {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if game.ebitenTextureId, err = tf.CreateTextureFromImage(img); err != nil {
|
||||
if game.ebitenTextureId, err = tf.CreateTextureFromImage("ebiten", img); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ func (game *Sprites) InitTextures(tf graphics.TextureFactory) {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if game.ebitenTextureId, err = tf.CreateTextureFromImage(img); err != nil {
|
||||
if game.ebitenTextureId, err = tf.CreateTextureFromImage("ebiten", img); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ func (game *TestPattern) InitTextures(tf graphics.TextureFactory) {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if game.textureId, err = tf.CreateTextureFromImage(img); err != nil {
|
||||
if game.textureId, err = tf.CreateTextureFromImage("test", img); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
size := img.Bounds().Size()
|
||||
|
@ -59,12 +59,11 @@ func main() {
|
||||
var u ui.UI = cocoa.New(screenWidth, screenHeight, screenScale, title)
|
||||
// TODO: Get a map or something
|
||||
u.LoadResources(game.InitTextures)
|
||||
inputStateUpdated := u.InputStateUpdated()
|
||||
screenSizeUpdated := u.ScreenSizeUpdated()
|
||||
|
||||
drawing := make(chan *graphics.LazyCanvas)
|
||||
go func() {
|
||||
inputStateUpdated := u.InputStateUpdated()
|
||||
screenSizeUpdated := u.ScreenSizeUpdated()
|
||||
|
||||
frameTime := time.Duration(int64(time.Second) / int64(fps))
|
||||
tick := time.Tick(frameTime)
|
||||
for {
|
||||
|
@ -110,12 +110,12 @@ func (context *Context) createRenderTarget(width, height int, filter texture.Fil
|
||||
return renderTargetId, nil
|
||||
}
|
||||
|
||||
func (context *Context) CreateRenderTarget(width, height int) (
|
||||
func (context *Context) CreateRenderTarget(tag string, width, height int) (
|
||||
graphics.RenderTargetId, error) {
|
||||
return context.createRenderTarget(width, height, texture.FilterLinear)
|
||||
}
|
||||
|
||||
func (context *Context) CreateTextureFromImage(img image.Image) (
|
||||
func (context *Context) CreateTextureFromImage(tag string, img image.Image) (
|
||||
graphics.TextureId, error) {
|
||||
return context.ids.CreateTextureFromImage(img)
|
||||
}
|
||||
|
@ -4,8 +4,25 @@ import (
|
||||
"image"
|
||||
)
|
||||
|
||||
// TODO: Remove this?
|
||||
type TextureFactory interface {
|
||||
CreateRenderTarget(width, height int) (RenderTargetId, error)
|
||||
CreateTextureFromImage(img image.Image) (TextureId, error)
|
||||
type TextureCreatedEvent struct {
|
||||
Tag string
|
||||
Id TextureId
|
||||
Error error
|
||||
}
|
||||
|
||||
type RenderTargetCreatedEvent struct {
|
||||
Tag string
|
||||
RenderTargetId RenderTargetId
|
||||
Error error
|
||||
}
|
||||
|
||||
type TextureFactoryEvents interface {
|
||||
TextureCreated() <-chan TextureCreatedEvent
|
||||
RenderTargetCreated() <-chan RenderTargetCreatedEvent
|
||||
}
|
||||
|
||||
type TextureFactory interface {
|
||||
CreateRenderTarget(tag string, width, height int) (RenderTargetId, error)
|
||||
CreateTextureFromImage(tag string, img image.Image) (TextureId, error)
|
||||
//TextureFactoryEvents
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user