mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 02:38:53 +01:00
parent
7dd9150b86
commit
7f64043ba5
@ -69,6 +69,7 @@ func (g *Graphics) NewImage(width, height int) (driver.Image, error) {
|
||||
|
||||
func (g *Graphics) NewScreenFramebufferImage(width, height int) (driver.Image, error) {
|
||||
return &Image{
|
||||
v: &screen{game: g.game},
|
||||
g: g,
|
||||
width: width,
|
||||
height: height,
|
||||
@ -108,3 +109,23 @@ func (g *Graphics) MaxImageSize() int {
|
||||
// TODO: Implement this
|
||||
return 4096
|
||||
}
|
||||
|
||||
type screen struct {
|
||||
game *monogame.Game
|
||||
}
|
||||
|
||||
func (s *screen) SetAsDestination() {
|
||||
s.game.ResetDestination()
|
||||
}
|
||||
|
||||
func (s *screen) SetAsSource() {
|
||||
panic("monogame: SetAsSource on screen is forbidden")
|
||||
}
|
||||
|
||||
func (s *screen) ReplacePixels(args []*driver.ReplacePixelsArgs) {
|
||||
panic("monogame: ReplacePixels on screen is forbidden")
|
||||
}
|
||||
|
||||
func (s *screen) Dispose() {
|
||||
// Do nothing?
|
||||
}
|
||||
|
@ -18,11 +18,17 @@ package monogame
|
||||
|
||||
import (
|
||||
"github.com/hajimehoshi/ebiten/internal/driver"
|
||||
"github.com/hajimehoshi/ebiten/internal/monogame"
|
||||
)
|
||||
|
||||
type RenderTarget2D interface {
|
||||
SetAsDestination()
|
||||
SetAsSource()
|
||||
ReplacePixels(args []*driver.ReplacePixelsArgs)
|
||||
Dispose()
|
||||
}
|
||||
|
||||
type Image struct {
|
||||
v *monogame.RenderTarget2D
|
||||
v RenderTarget2D
|
||||
g *Graphics
|
||||
width int
|
||||
height int
|
||||
|
@ -110,6 +110,10 @@ func (g *Game) Draw(indexLen int, indexOffset int, mode driver.CompositeMode, co
|
||||
g.binding.Call("Draw", indexLen, indexOffset)
|
||||
}
|
||||
|
||||
func (g *Game) ResetDestination() {
|
||||
g.binding.Set("Dst", nil)
|
||||
}
|
||||
|
||||
type RenderTarget2D struct {
|
||||
v js.Value
|
||||
binding js.Value
|
||||
|
@ -23,7 +23,8 @@ import (
|
||||
)
|
||||
|
||||
type UI struct {
|
||||
game *monogame.Game
|
||||
game *monogame.Game
|
||||
context driver.UIContext
|
||||
}
|
||||
|
||||
var theUI = &UI{}
|
||||
@ -32,12 +33,14 @@ func Get() *UI {
|
||||
return theUI
|
||||
}
|
||||
|
||||
func (*UI) Run(context driver.UIContext) error {
|
||||
func (u *UI) Run(context driver.UIContext) error {
|
||||
g := monogame.NewGame(context)
|
||||
defer g.Dispose()
|
||||
|
||||
theUI.game = g
|
||||
theUI.Graphics().(*graphics.Graphics).SetGame(g)
|
||||
u.game = g
|
||||
u.context = context
|
||||
u.Graphics().(*graphics.Graphics).SetGame(g)
|
||||
u.updateSize()
|
||||
g.Run()
|
||||
return nil
|
||||
}
|
||||
@ -56,10 +59,16 @@ func (*UI) IsFocused() bool {
|
||||
|
||||
func (*UI) ScreenSizeInFullscreen() (int, int) {
|
||||
// TODO: Implement this
|
||||
return 0, 0
|
||||
return 640, 480
|
||||
}
|
||||
|
||||
func (*UI) ResetForFrame() {
|
||||
func (u *UI) ResetForFrame() {
|
||||
u.updateSize()
|
||||
}
|
||||
|
||||
func (u *UI) updateSize() {
|
||||
// TODO: Implement this
|
||||
u.context.Layout(640, 480)
|
||||
}
|
||||
|
||||
func (*UI) CursorMode() driver.CursorMode {
|
||||
|
Loading…
Reference in New Issue
Block a user