2020-04-02 16:29:34 +02:00
|
|
|
// Copyright 2020 The Ebiten Authors
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
|
|
|
// +build js
|
|
|
|
|
|
|
|
package monogame
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/hajimehoshi/ebiten/internal/affine"
|
|
|
|
"github.com/hajimehoshi/ebiten/internal/driver"
|
2020-04-04 15:58:43 +02:00
|
|
|
"github.com/hajimehoshi/ebiten/internal/monogame"
|
2020-04-02 16:29:34 +02:00
|
|
|
"github.com/hajimehoshi/ebiten/internal/thread"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Graphics struct {
|
2020-04-05 12:19:28 +02:00
|
|
|
game *monogame.Game
|
2020-04-02 16:29:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
var theGraphics Graphics
|
|
|
|
|
|
|
|
func Get() *Graphics {
|
|
|
|
return &theGraphics
|
|
|
|
}
|
|
|
|
|
2020-04-05 12:19:28 +02:00
|
|
|
func (g *Graphics) SetGame(game *monogame.Game) {
|
|
|
|
g.game = game
|
|
|
|
}
|
|
|
|
|
2020-04-02 16:29:34 +02:00
|
|
|
func (g *Graphics) SetThread(thread *thread.Thread) {
|
2020-04-05 09:34:34 +02:00
|
|
|
panic("monogame: SetThread is not implemented")
|
2020-04-02 16:29:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (g *Graphics) Begin() {
|
2020-04-05 09:34:34 +02:00
|
|
|
// Do nothing
|
2020-04-02 16:29:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (g *Graphics) End() {
|
2020-04-05 09:34:34 +02:00
|
|
|
// Do nothing
|
2020-04-02 16:29:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (g *Graphics) SetTransparent(transparent bool) {
|
2020-04-05 09:34:34 +02:00
|
|
|
panic("monogame: SetTransparent is not implemented yet")
|
2020-04-02 16:29:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (g *Graphics) SetVertices(vertices []float32, indices []uint16) {
|
2020-04-05 12:19:28 +02:00
|
|
|
g.game.SetVertices(vertices, indices)
|
2020-04-02 16:29:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (g *Graphics) NewImage(width, height int) (driver.Image, error) {
|
2020-04-05 12:19:28 +02:00
|
|
|
v := g.game.NewRenderTarget2D(width, height)
|
2020-04-02 16:29:34 +02:00
|
|
|
return &Image{
|
2020-04-04 15:58:43 +02:00
|
|
|
v: v,
|
2020-04-05 09:34:34 +02:00
|
|
|
g: g,
|
2020-04-02 16:29:34 +02:00
|
|
|
width: width,
|
|
|
|
height: height,
|
|
|
|
}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (g *Graphics) NewScreenFramebufferImage(width, height int) (driver.Image, error) {
|
|
|
|
return &Image{
|
2020-04-05 18:51:02 +02:00
|
|
|
v: &screen{game: g.game},
|
2020-04-05 09:34:34 +02:00
|
|
|
g: g,
|
2020-04-02 16:29:34 +02:00
|
|
|
width: width,
|
|
|
|
height: height,
|
|
|
|
}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (g *Graphics) Reset() error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (g *Graphics) Draw(indexLen int, indexOffset int, mode driver.CompositeMode, colorM *affine.ColorM, filter driver.Filter, address driver.Address) error {
|
2020-04-05 17:13:04 +02:00
|
|
|
g.game.Draw(indexLen, indexOffset, mode, colorM, filter, address)
|
2020-04-02 16:29:34 +02:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (g *Graphics) SetVsyncEnabled(enabled bool) {
|
2020-04-05 09:34:34 +02:00
|
|
|
panic("monogame: SetVsyncEnabled is not implemented yet")
|
2020-04-02 16:29:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (g *Graphics) VDirection() driver.VDirection {
|
|
|
|
return driver.VDownward
|
|
|
|
}
|
|
|
|
|
|
|
|
func (g *Graphics) NeedsRestoring() bool {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
func (g *Graphics) IsGL() bool {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
func (g *Graphics) HasHighPrecisionFloat() bool {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
func (g *Graphics) MaxImageSize() int {
|
|
|
|
// TODO: Implement this
|
|
|
|
return 4096
|
|
|
|
}
|
2020-04-05 18:51:02 +02:00
|
|
|
|
|
|
|
type screen struct {
|
|
|
|
game *monogame.Game
|
|
|
|
}
|
|
|
|
|
2020-04-05 19:17:49 +02:00
|
|
|
func (s *screen) SetAsDestination(viewportWidth, viewportHeight int) {
|
|
|
|
s.game.ResetDestination(viewportWidth, viewportHeight)
|
2020-04-05 18:51:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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?
|
|
|
|
}
|