mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-26 19:58:54 +01:00
Refactoring
This commit is contained in:
parent
894dd71d35
commit
2bd77e949a
@ -11,6 +11,11 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
runtime.LockOSThread()
|
||||||
|
runtime.GOMAXPROCS(runtime.NumCPU())
|
||||||
|
}
|
||||||
|
|
||||||
func loadImage(path string) (image.Image, error) {
|
func loadImage(path string) (image.Image, error) {
|
||||||
file, err := os.Open(path)
|
file, err := os.Open(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -26,9 +31,6 @@ func loadImage(path string) (image.Image, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
runtime.GOMAXPROCS(runtime.NumCPU())
|
|
||||||
runtime.LockOSThread()
|
|
||||||
|
|
||||||
const screenWidth = 256
|
const screenWidth = 256
|
||||||
const screenHeight = 240
|
const screenHeight = 240
|
||||||
const screenScale = 2
|
const screenScale = 2
|
||||||
|
@ -39,11 +39,10 @@ func (d *Device) Update(draw func(graphics.Canvas)) {
|
|||||||
context.flush()
|
context.flush()
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Remove 'tag'
|
func (d *Device) CreateRenderTarget(width, height int) (graphics.RenderTargetId, error) {
|
||||||
func (d *Device) CreateRenderTarget(tag string, width, height int) (graphics.RenderTargetId, error) {
|
|
||||||
return d.context.CreateRenderTarget(width, height)
|
return d.context.CreateRenderTarget(width, height)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Device) CreateTextureFromImage(tag string, img image.Image) (graphics.TextureId, error) {
|
func (d *Device) CreateTexture(img image.Image) (graphics.TextureId, error) {
|
||||||
return d.context.CreateTextureFromImage(img)
|
return d.context.CreateTextureFromImage(img)
|
||||||
}
|
}
|
||||||
|
@ -75,7 +75,7 @@ func (u *UI) CreateTexture(tag interface{}, img image.Image) {
|
|||||||
var id graphics.TextureId
|
var id graphics.TextureId
|
||||||
var err error
|
var err error
|
||||||
u.textureFactory.UseContext(func() {
|
u.textureFactory.UseContext(func() {
|
||||||
id, err = u.graphicsDevice.CreateTextureFromImage("", img)
|
id, err = u.graphicsDevice.CreateTexture(img)
|
||||||
})
|
})
|
||||||
e := graphics.TextureCreatedEvent{
|
e := graphics.TextureCreatedEvent{
|
||||||
Tag: tag,
|
Tag: tag,
|
||||||
@ -91,7 +91,7 @@ func (u *UI) CreateRenderTarget(tag interface{}, width, height int) {
|
|||||||
var id graphics.RenderTargetId
|
var id graphics.RenderTargetId
|
||||||
var err error
|
var err error
|
||||||
u.textureFactory.UseContext(func() {
|
u.textureFactory.UseContext(func() {
|
||||||
id, err = u.graphicsDevice.CreateRenderTarget("", width, height)
|
id, err = u.graphicsDevice.CreateRenderTarget(width, height)
|
||||||
})
|
})
|
||||||
e := graphics.RenderTargetCreatedEvent{
|
e := graphics.RenderTargetCreatedEvent{
|
||||||
Tag: tag,
|
Tag: tag,
|
||||||
|
Loading…
Reference in New Issue
Block a user