Refactoring

This commit is contained in:
Hajime Hoshi 2013-12-09 09:45:40 +09:00
parent 894dd71d35
commit 2bd77e949a
3 changed files with 9 additions and 8 deletions

View File

@ -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

View File

@ -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)
}

View File

@ -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,