mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-02-02 22:14:29 +01:00
Add graphicsdriver/monogame
This commit is contained in:
parent
8777140e91
commit
6cbf37e855
96
internal/graphicsdriver/monogame/graphics.go
Normal file
96
internal/graphicsdriver/monogame/graphics.go
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
// 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"
|
||||||
|
"github.com/hajimehoshi/ebiten/internal/thread"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Graphics struct {
|
||||||
|
t *thread.Thread
|
||||||
|
}
|
||||||
|
|
||||||
|
var theGraphics Graphics
|
||||||
|
|
||||||
|
func Get() *Graphics {
|
||||||
|
return &theGraphics
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Graphics) SetThread(thread *thread.Thread) {
|
||||||
|
g.t = thread
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Graphics) Begin() {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Graphics) End() {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Graphics) SetTransparent(transparent bool) {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Graphics) SetVertices(vertices []float32, indices []uint16) {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Graphics) NewImage(width, height int) (driver.Image, error) {
|
||||||
|
return &Image{
|
||||||
|
width: width,
|
||||||
|
height: height,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Graphics) NewScreenFramebufferImage(width, height int) (driver.Image, error) {
|
||||||
|
return &Image{
|
||||||
|
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 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Graphics) SetVsyncEnabled(enabled bool) {
|
||||||
|
// TODO: Implement this
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
46
internal/graphicsdriver/monogame/image.go
Normal file
46
internal/graphicsdriver/monogame/image.go
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
// 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/driver"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Image struct {
|
||||||
|
width int
|
||||||
|
height int
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*Image) Dispose() {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*Image) IsInvalidated() bool {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*Image) Pixels() ([]byte, error) {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*Image) SetAsDestination() {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*Image) SetAsSource() {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*Image) ReplacePixels(args []*driver.ReplacePixelsArgs) {
|
||||||
|
}
|
@ -17,9 +17,15 @@
|
|||||||
package monogame
|
package monogame
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"syscall/js"
|
||||||
|
|
||||||
"github.com/hajimehoshi/ebiten/internal/driver"
|
"github.com/hajimehoshi/ebiten/internal/driver"
|
||||||
|
"github.com/hajimehoshi/ebiten/internal/graphicsdriver/monogame"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// TODO: Update this
|
||||||
|
const temporaryNamespace = "Go2DotNet.Example.Rotate"
|
||||||
|
|
||||||
type UI struct {
|
type UI struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -30,6 +36,17 @@ func Get() *UI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (*UI) Run(context driver.UIContext) error {
|
func (*UI) Run(context driver.UIContext) error {
|
||||||
|
update := js.FuncOf(func(this js.Value, args []js.Value) interface{} {
|
||||||
|
return context.Update()
|
||||||
|
})
|
||||||
|
defer update.Release()
|
||||||
|
|
||||||
|
draw := js.FuncOf(func(this js.Value, args []js.Value) interface{} {
|
||||||
|
return context.Draw()
|
||||||
|
})
|
||||||
|
defer draw.Release()
|
||||||
|
|
||||||
|
js.Global().Get(".net").Get(temporaryNamespace+".GoGameRunner").Call("Run", update, draw)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -50,6 +67,9 @@ func (*UI) ScreenSizeInFullscreen() (int, int) {
|
|||||||
return 0, 0
|
return 0, 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (*UI) ResetForFrame() {
|
||||||
|
}
|
||||||
|
|
||||||
func (*UI) CursorMode() driver.CursorMode {
|
func (*UI) CursorMode() driver.CursorMode {
|
||||||
return driver.CursorModeVisible
|
return driver.CursorModeVisible
|
||||||
}
|
}
|
||||||
@ -102,5 +122,5 @@ func (*UI) Window() driver.Window {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (*UI) Graphics() driver.Graphics {
|
func (*UI) Graphics() driver.Graphics {
|
||||||
return nil
|
return monogame.Get()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user