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