ebiten/graphics/opengl/device.go

39 lines
872 B
Go
Raw Normal View History

2013-06-19 01:49:54 +02:00
package opengl
2013-06-15 10:07:14 +02:00
2013-06-18 17:48:41 +02:00
import (
2013-10-14 04:34:58 +02:00
"github.com/hajimehoshi/go-ebiten/graphics"
2013-12-09 15:52:14 +01:00
"github.com/hajimehoshi/go-ebiten/graphics/opengl/texture"
2013-12-06 18:20:48 +01:00
"image"
2013-06-18 17:48:41 +02:00
)
2013-06-15 10:07:14 +02:00
2013-06-17 16:10:55 +02:00
type Device struct {
2013-12-10 16:18:08 +01:00
ids *ids
2013-06-15 10:07:14 +02:00
}
2013-12-10 16:18:08 +01:00
func NewDevice() *Device {
2013-12-09 15:52:14 +01:00
device := &Device{
ids: newIds(),
2013-06-15 10:07:14 +02:00
}
2013-12-09 15:52:14 +01:00
return device
2013-10-05 18:47:19 +02:00
}
2013-12-09 15:52:14 +01:00
func (d *Device) CreateCanvas(screenWidth, screenHeight, screenScale int) *Canvas {
return newCanvas(d.ids, screenWidth, screenHeight, screenScale)
}
2013-06-20 18:47:39 +02:00
2013-12-09 15:52:14 +01:00
func (d *Device) Update(canvas *Canvas, draw func(graphics.Canvas)) {
canvas.update(draw)
2013-06-15 10:07:14 +02:00
}
2013-06-19 16:08:24 +02:00
2013-12-09 01:45:40 +01:00
func (d *Device) CreateRenderTarget(width, height int) (graphics.RenderTargetId, error) {
2013-12-09 15:52:14 +01:00
renderTargetId, err := d.ids.CreateRenderTarget(width, height, texture.FilterLinear)
if err != nil {
return 0, err
}
return renderTargetId, nil
2013-12-06 18:20:48 +01:00
}
2013-12-09 01:45:40 +01:00
func (d *Device) CreateTexture(img image.Image) (graphics.TextureId, error) {
2013-12-09 15:52:14 +01:00
return d.ids.CreateTextureFromImage(img)
2013-06-19 16:08:24 +02:00
}