ebiten/graphics/opengl/device.go

38 lines
843 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-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-13 22:10:24 +01:00
func (d *Device) CreateContext(screenWidth, screenHeight, screenScale int) *Context {
return newContext(d.ids, screenWidth, screenHeight, screenScale)
2013-12-09 15:52:14 +01:00
}
2013-06-20 18:47:39 +02:00
2013-12-13 22:10:24 +01:00
func (d *Device) Update(context *Context, draw func(graphics.Context)) {
context.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-18 10:05:28 +01:00
renderTargetId, err := d.ids.CreateRenderTarget(width, height, graphics.FilterLinear)
2013-12-09 15:52:14 +01:00
if err != nil {
return 0, err
}
return renderTargetId, nil
2013-12-06 18:20:48 +01:00
}
2013-12-18 10:05:28 +01:00
func (d *Device) CreateTexture(img image.Image, filter graphics.Filter) (graphics.TextureId, error) {
return d.ids.CreateTexture(img, filter)
2013-06-19 16:08:24 +02:00
}