ebiten/graphics/opengl/shared_context.go

35 lines
841 B
Go
Raw Normal View History

2014-01-11 03:42:23 +01:00
package opengl
import (
"github.com/hajimehoshi/go-ebiten/graphics"
"image"
)
type SharedContext struct {
ids *ids
}
2014-01-11 10:04:15 +01:00
var sharedContext *SharedContext = nil
func Initialize() *SharedContext {
if sharedContext != nil {
panic("OpenGL is already initialized")
}
sharedContext = &SharedContext{
2014-01-11 03:42:23 +01:00
ids: newIds(),
}
2014-01-11 10:04:15 +01:00
return sharedContext
2014-01-11 03:42:23 +01:00
}
func (s *SharedContext) CreateContext(screenWidth, screenHeight, screenScale int) *Context {
return newContext(s.ids, screenWidth, screenHeight, screenScale)
}
2014-01-11 10:07:12 +01:00
func (s *SharedContext) CreateRenderTarget(width, height int, filter graphics.Filter) (graphics.RenderTargetId, error) {
return s.ids.CreateRenderTarget(width, height, filter)
2014-01-11 03:42:23 +01:00
}
func (s *SharedContext) CreateTexture(img image.Image, filter graphics.Filter) (graphics.TextureId, error) {
return s.ids.CreateTexture(img, filter)
}