From 4fa52dcc56b6ff16bd831f57b6dd8f667bc34e79 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Fri, 8 May 2020 19:29:26 +0900 Subject: [PATCH] Remove MonoGame support Fixes #1148 --- audio/contextimpl_monogame.go | 58 ---- audio/contextimpl_oto.go | 2 - cmd/ebitenmonogame/content.mgcb | 21 -- cmd/ebitenmonogame/content.mgcb.go | 6 - cmd/ebitenmonogame/generate.go | 22 -- cmd/ebitenmonogame/gogame.cs | 231 ---------------- cmd/ebitenmonogame/gogame.cs.go | 6 - cmd/ebitenmonogame/main.go | 268 ------------------- cmd/ebitenmonogame/program.cs | 15 -- cmd/ebitenmonogame/program.cs.go | 6 - cmd/ebitenmonogame/project.csproj | 24 -- cmd/ebitenmonogame/project.csproj.go | 6 - cmd/ebitenmonogame/shader.fx | 69 ----- cmd/ebitenmonogame/shader.fx.go | 6 - doc.go | 3 - internal/graphicsdriver/monogame/graphics.go | 141 ---------- internal/graphicsdriver/monogame/image.go | 66 ----- internal/jsutil/buf_js.go | 2 - internal/jsutil/buf_monogame.go | 25 -- internal/monogame/monogame.go | 159 ----------- internal/uidriver/monogame/input.go | 82 ------ internal/uidriver/monogame/ui.go | 129 --------- uidriver_js.go | 1 - uidriver_monogame.go | 27 -- 24 files changed, 1375 deletions(-) delete mode 100644 audio/contextimpl_monogame.go delete mode 100644 cmd/ebitenmonogame/content.mgcb delete mode 100644 cmd/ebitenmonogame/content.mgcb.go delete mode 100644 cmd/ebitenmonogame/generate.go delete mode 100644 cmd/ebitenmonogame/gogame.cs delete mode 100644 cmd/ebitenmonogame/gogame.cs.go delete mode 100644 cmd/ebitenmonogame/main.go delete mode 100644 cmd/ebitenmonogame/program.cs delete mode 100644 cmd/ebitenmonogame/program.cs.go delete mode 100644 cmd/ebitenmonogame/project.csproj delete mode 100644 cmd/ebitenmonogame/project.csproj.go delete mode 100644 cmd/ebitenmonogame/shader.fx delete mode 100644 cmd/ebitenmonogame/shader.fx.go delete mode 100644 internal/graphicsdriver/monogame/graphics.go delete mode 100644 internal/graphicsdriver/monogame/image.go delete mode 100644 internal/jsutil/buf_monogame.go delete mode 100644 internal/monogame/monogame.go delete mode 100644 internal/uidriver/monogame/input.go delete mode 100644 internal/uidriver/monogame/ui.go delete mode 100644 uidriver_monogame.go diff --git a/audio/contextimpl_monogame.go b/audio/contextimpl_monogame.go deleted file mode 100644 index ea1b84683..000000000 --- a/audio/contextimpl_monogame.go +++ /dev/null @@ -1,58 +0,0 @@ -// 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 monogame - -package audio - -import ( - "io" - "time" -) - -func newContextImpl(sampleRate int, initCh chan struct{}) context { - return &mockContext{ - sampleRate: sampleRate, - } -} - -type mockContext struct { - sampleRate int -} - -func (*mockContext) Close() error { - return nil -} - -func (m *mockContext) NewPlayer() io.WriteCloser { - return &mockPlayer{ - sampleRate: m.sampleRate, - } -} - -type mockPlayer struct { - sampleRate int -} - -func (m *mockPlayer) Write(bs []byte) (int, error) { - bytesPerSec := 4 * m.sampleRate - - n := len(bs) - time.Sleep(time.Duration(n) * time.Second / time.Duration(bytesPerSec)) - return n, nil -} - -func (*mockPlayer) Close() error { - return nil -} diff --git a/audio/contextimpl_oto.go b/audio/contextimpl_oto.go index c3cbf7ba5..914641527 100644 --- a/audio/contextimpl_oto.go +++ b/audio/contextimpl_oto.go @@ -12,8 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build !monogame - package audio import ( diff --git a/cmd/ebitenmonogame/content.mgcb b/cmd/ebitenmonogame/content.mgcb deleted file mode 100644 index 4732a4156..000000000 --- a/cmd/ebitenmonogame/content.mgcb +++ /dev/null @@ -1,21 +0,0 @@ - -#----------------------------- Global Properties ----------------------------# - -/outputDir:bin/$(Platform) -/intermediateDir:obj/$(Platform) -/platform:Windows -/config: -/profile:Reach -/compress:False - -#-------------------------------- References --------------------------------# - - -#---------------------------------- Content ---------------------------------# - -#begin Shader.fx -/importer:EffectImporter -/processor:EffectProcessor -/processorParam:DebugMode=Auto -/build:Shader.fx - diff --git a/cmd/ebitenmonogame/content.mgcb.go b/cmd/ebitenmonogame/content.mgcb.go deleted file mode 100644 index b602edd25..000000000 --- a/cmd/ebitenmonogame/content.mgcb.go +++ /dev/null @@ -1,6 +0,0 @@ -// Code generated by file2byteslice. DO NOT EDIT. -// (gofmt is fine after generating) - -package main - -var content_mgcb = []byte("\r\n#----------------------------- Global Properties ----------------------------#\r\n\r\n/outputDir:bin/$(Platform)\r\n/intermediateDir:obj/$(Platform)\r\n/platform:Windows\r\n/config:\r\n/profile:Reach\r\n/compress:False\r\n\r\n#-------------------------------- References --------------------------------#\r\n\r\n\r\n#---------------------------------- Content ---------------------------------#\r\n\r\n#begin Shader.fx\r\n/importer:EffectImporter\r\n/processor:EffectProcessor\r\n/processorParam:DebugMode=Auto\r\n/build:Shader.fx\r\n\r\n") diff --git a/cmd/ebitenmonogame/generate.go b/cmd/ebitenmonogame/generate.go deleted file mode 100644 index da7d4b27d..000000000 --- a/cmd/ebitenmonogame/generate.go +++ /dev/null @@ -1,22 +0,0 @@ -// 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. - -//go:generate file2byteslice -package=main -input=gogame.cs -output=gogame.cs.go -var=gogame_cs -//go:generate file2byteslice -package=main -input=program.cs -output=program.cs.go -var=program_cs -//go:generate file2byteslice -package=main -input=project.csproj -output=project.csproj.go -var=project_csproj -//go:generate file2byteslice -package=main -input=content.mgcb -output=content.mgcb.go -var=content_mgcb -//go:generate file2byteslice -package=main -input=shader.fx -output=shader.fx.go -var=shader_fx -//go:generate gofmt -s -w . - -package main diff --git a/cmd/ebitenmonogame/gogame.cs b/cmd/ebitenmonogame/gogame.cs deleted file mode 100644 index be959a106..000000000 --- a/cmd/ebitenmonogame/gogame.cs +++ /dev/null @@ -1,231 +0,0 @@ -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Microsoft.Xna.Framework.Input; -using System; -using System.IO; - -using {{.Namespace}}.AutoGen; - -namespace {{.Namespace}} -{ - // Operation must sync with driver.Operation. - enum Operation - { - Zero, - One, - SrcAlpha, - DstAlpha, - OneMinusSrcAlpha, - OneMinusDstAlpha, - } - - public class GoGame : Game - { - private GraphicsDeviceManager graphics; - private IInvokable onUpdate; - private IInvokable onDraw; - private VertexBuffer vertexBuffer; - private IndexBuffer indexBuffer; - private Effect effect; - - public GoGame(IInvokable onUpdate, IInvokable onDraw) - { - this.onUpdate = onUpdate; - this.onDraw = onDraw; - this.graphics = new GraphicsDeviceManager(this); - this.graphics.PreferredBackBufferWidth = 640; - this.graphics.PreferredBackBufferHeight = 480; - - this.Content.RootDirectory = "Content"; - this.IsMouseVisible = true; - } - - protected override void LoadContent() - { - VertexElement[] elements = new VertexElement[] - { - new VertexElement(sizeof(float)*0, VertexElementFormat.Vector2, VertexElementUsage.Position, 0), - new VertexElement(sizeof(float)*2, VertexElementFormat.Vector2, VertexElementUsage.TextureCoordinate, 0), - new VertexElement(sizeof(float)*4, VertexElementFormat.Vector4, VertexElementUsage.TextureCoordinate, 1), - new VertexElement(sizeof(float)*8, VertexElementFormat.Vector4, VertexElementUsage.Color, 0), - }; - this.vertexBuffer = new DynamicVertexBuffer( - this.GraphicsDevice, new VertexDeclaration(elements), 65536, BufferUsage.None); - this.GraphicsDevice.SetVertexBuffer(this.vertexBuffer); - - this.indexBuffer = new DynamicIndexBuffer( - this.GraphicsDevice, IndexElementSize.SixteenBits, 65536, BufferUsage.None); - this.GraphicsDevice.Indices = this.indexBuffer; - - // TODO: Add more shaders for e.g., linear filter. - this.effect = Content.Load("Shader"); - - this.GraphicsDevice.RasterizerState = new RasterizerState() - { - CullMode = CullMode.None, - }; - - base.LoadContent(); - } - - internal void SetDestination(RenderTarget2D renderTarget2D, int viewportWidth, int viewportHeight) - { - this.GraphicsDevice.SetRenderTarget(renderTarget2D); - this.GraphicsDevice.Viewport = new Viewport(0, 0, viewportWidth, viewportHeight); - this.effect.Parameters["ViewportSize"].SetValue(new Vector2(viewportWidth, viewportHeight)); - } - - internal void SetSource(Texture2D texture2D) - { - this.effect.Parameters["Texture"].SetValue(texture2D); - } - - internal void SetVertices(byte[] vertices, byte[] indices) - { - this.vertexBuffer.SetData(vertices, 0, vertices.Length); - this.indexBuffer.SetData(indices, 0, indices.Length); - } - - protected override void Update(GameTime gameTime) - { - this.onUpdate.Invoke(null); - base.Update(gameTime); - } - - protected override void Draw(GameTime gameTime) - { - this.onDraw.Invoke(null); - base.Draw(gameTime); - } - - internal void DrawTriangles(int indexLen, int indexOffset, Blend blendSrc, Blend blendDst) - { - this.GraphicsDevice.BlendState = new BlendState() - { - AlphaSourceBlend = blendSrc, - ColorSourceBlend = blendSrc, - AlphaDestinationBlend = blendDst, - ColorDestinationBlend = blendDst, - }; - foreach (EffectPass pass in this.effect.CurrentTechnique.Passes) - { - pass.Apply(); - this.GraphicsDevice.DrawIndexedPrimitives( - PrimitiveType.TriangleList, 0, indexOffset, indexLen / 3); - } - } - } - - // This methods are called from Go world. They must not have overloads. - class GameGoBinding - { - private static Blend ToBlend(Operation operation) - { - switch (operation) - { - case Operation.Zero: - return Blend.Zero; - case Operation.One: - return Blend.One; - case Operation.SrcAlpha: - return Blend.SourceAlpha; - case Operation.DstAlpha: - return Blend.DestinationAlpha; - case Operation.OneMinusSrcAlpha: - return Blend.InverseSourceAlpha; - case Operation.OneMinusDstAlpha: - return Blend.InverseDestinationAlpha; - } - throw new ArgumentOutOfRangeException("operation", operation, ""); - } - - private GoGame game; - - private GameGoBinding(IInvokable onUpdate, IInvokable onDraw) - { - this.game = new GoGame(onUpdate, onDraw); - } - - private void Run() - { - try - { - this.game.Run(); - } - finally - { - this.game.Dispose(); - } - } - - private RenderTarget2D NewRenderTarget2D(double width, double height) - { - return new RenderTarget2D(this.game.GraphicsDevice, (int)width, (int)height); - } - - private void Dispose(Texture2D texture2D) - { - texture2D.Dispose(); - } - - private void ReplacePixels(RenderTarget2D renderTarget2D, byte[] pixels, double x, double y, double width, double height) - { - var rect = new Rectangle((int)x, (int)y, (int)width, (int)height); - renderTarget2D.SetData(0, rect, pixels, 0, pixels.Length); - } - - private byte[] Pixels(Texture2D texture2D, double width, double height) - { - Rectangle rect = new Rectangle(0, 0, (int)width, (int)height); - byte[] data = new byte[4*(int)width*(int)height]; - texture2D.GetData(0, rect, data, 0, data.Length); - return data; - } - - private void SetDestination(RenderTarget2D renderTarget2D, double viewportWidth, double viewportHeight) - { - this.game.SetDestination(renderTarget2D, (int)viewportWidth, (int)viewportHeight); - } - - private void SetSource(Texture2D texture2D) - { - this.game.SetSource(texture2D); - } - - private void SetVertices(byte[] vertices, byte[] indices) - { - this.game.SetVertices(vertices, indices); - } - - private void Draw(double indexLen, double indexOffset, double operationSrc, double operationDst) - { - this.game.DrawTriangles((int)indexLen, (int)indexOffset, ToBlend((Operation)operationSrc), ToBlend((Operation)operationDst)); - } - - private bool IsKeyPressed(string driverKey) - { - Keys key; - switch (driverKey) - { - case "KeyDown": - key = Keys.Down; - break; - case "KeyLeft": - key = Keys.Left; - break; - case "KeySpace": - key = Keys.Space; - break; - case "KeyRight": - key = Keys.Right; - break; - case "KeyUp": - key = Keys.Up; - break; - default: - return false; - } - return Keyboard.GetState().IsKeyDown(key); - } - } -} diff --git a/cmd/ebitenmonogame/gogame.cs.go b/cmd/ebitenmonogame/gogame.cs.go deleted file mode 100644 index e7f38b006..000000000 --- a/cmd/ebitenmonogame/gogame.cs.go +++ /dev/null @@ -1,6 +0,0 @@ -// Code generated by file2byteslice. DO NOT EDIT. -// (gofmt is fine after generating) - -package main - -var gogame_cs = []byte("\ufeffusing Microsoft.Xna.Framework;\nusing Microsoft.Xna.Framework.Graphics;\nusing Microsoft.Xna.Framework.Input;\nusing System;\nusing System.IO;\n\nusing {{.Namespace}}.AutoGen;\n\nnamespace {{.Namespace}}\n{\n // Operation must sync with driver.Operation.\n enum Operation\n {\n Zero,\n One,\n SrcAlpha,\n DstAlpha,\n OneMinusSrcAlpha,\n OneMinusDstAlpha,\n }\n\n public class GoGame : Game\n {\n private GraphicsDeviceManager graphics;\n private IInvokable onUpdate;\n private IInvokable onDraw;\n private VertexBuffer vertexBuffer;\n private IndexBuffer indexBuffer;\n private Effect effect;\n\n public GoGame(IInvokable onUpdate, IInvokable onDraw)\n {\n this.onUpdate = onUpdate;\n this.onDraw = onDraw;\n this.graphics = new GraphicsDeviceManager(this);\n this.graphics.PreferredBackBufferWidth = 640;\n this.graphics.PreferredBackBufferHeight = 480;\n\n this.Content.RootDirectory = \"Content\";\n this.IsMouseVisible = true;\n }\n\n protected override void LoadContent()\n {\n VertexElement[] elements = new VertexElement[]\n {\n new VertexElement(sizeof(float)*0, VertexElementFormat.Vector2, VertexElementUsage.Position, 0),\n new VertexElement(sizeof(float)*2, VertexElementFormat.Vector2, VertexElementUsage.TextureCoordinate, 0),\n new VertexElement(sizeof(float)*4, VertexElementFormat.Vector4, VertexElementUsage.TextureCoordinate, 1),\n new VertexElement(sizeof(float)*8, VertexElementFormat.Vector4, VertexElementUsage.Color, 0),\n };\n this.vertexBuffer = new DynamicVertexBuffer(\n this.GraphicsDevice, new VertexDeclaration(elements), 65536, BufferUsage.None);\n this.GraphicsDevice.SetVertexBuffer(this.vertexBuffer);\n\n this.indexBuffer = new DynamicIndexBuffer(\n this.GraphicsDevice, IndexElementSize.SixteenBits, 65536, BufferUsage.None);\n this.GraphicsDevice.Indices = this.indexBuffer;\n \n // TODO: Add more shaders for e.g., linear filter.\n this.effect = Content.Load(\"Shader\");\n\n this.GraphicsDevice.RasterizerState = new RasterizerState()\n {\n CullMode = CullMode.None,\n };\n\n base.LoadContent();\n }\n\n internal void SetDestination(RenderTarget2D renderTarget2D, int viewportWidth, int viewportHeight)\n {\n this.GraphicsDevice.SetRenderTarget(renderTarget2D);\n this.GraphicsDevice.Viewport = new Viewport(0, 0, viewportWidth, viewportHeight);\n this.effect.Parameters[\"ViewportSize\"].SetValue(new Vector2(viewportWidth, viewportHeight));\n }\n\n internal void SetSource(Texture2D texture2D)\n {\n this.effect.Parameters[\"Texture\"].SetValue(texture2D);\n }\n\n internal void SetVertices(byte[] vertices, byte[] indices)\n {\n this.vertexBuffer.SetData(vertices, 0, vertices.Length);\n this.indexBuffer.SetData(indices, 0, indices.Length);\n }\n\n protected override void Update(GameTime gameTime)\n {\n this.onUpdate.Invoke(null);\n base.Update(gameTime);\n }\n\n protected override void Draw(GameTime gameTime)\n {\n this.onDraw.Invoke(null);\n base.Draw(gameTime);\n }\n\n internal void DrawTriangles(int indexLen, int indexOffset, Blend blendSrc, Blend blendDst)\n {\n this.GraphicsDevice.BlendState = new BlendState()\n {\n AlphaSourceBlend = blendSrc,\n ColorSourceBlend = blendSrc,\n AlphaDestinationBlend = blendDst,\n ColorDestinationBlend = blendDst,\n };\n foreach (EffectPass pass in this.effect.CurrentTechnique.Passes)\n {\n pass.Apply();\n this.GraphicsDevice.DrawIndexedPrimitives(\n PrimitiveType.TriangleList, 0, indexOffset, indexLen / 3);\n }\n }\n }\n\n // This methods are called from Go world. They must not have overloads.\n class GameGoBinding\n {\n private static Blend ToBlend(Operation operation)\n {\n switch (operation)\n {\n case Operation.Zero:\n return Blend.Zero;\n case Operation.One:\n return Blend.One;\n case Operation.SrcAlpha:\n return Blend.SourceAlpha;\n case Operation.DstAlpha:\n return Blend.DestinationAlpha;\n case Operation.OneMinusSrcAlpha:\n return Blend.InverseSourceAlpha;\n case Operation.OneMinusDstAlpha:\n return Blend.InverseDestinationAlpha;\n }\n throw new ArgumentOutOfRangeException(\"operation\", operation, \"\");\n }\n\n private GoGame game;\n\n private GameGoBinding(IInvokable onUpdate, IInvokable onDraw)\n {\n this.game = new GoGame(onUpdate, onDraw);\n }\n\n private void Run()\n {\n try\n {\n this.game.Run();\n }\n finally\n {\n this.game.Dispose();\n }\n }\n\n private RenderTarget2D NewRenderTarget2D(double width, double height)\n {\n return new RenderTarget2D(this.game.GraphicsDevice, (int)width, (int)height);\n }\n\n private void Dispose(Texture2D texture2D)\n {\n texture2D.Dispose();\n }\n\n private void ReplacePixels(RenderTarget2D renderTarget2D, byte[] pixels, double x, double y, double width, double height)\n {\n var rect = new Rectangle((int)x, (int)y, (int)width, (int)height);\n renderTarget2D.SetData(0, rect, pixels, 0, pixels.Length);\n }\n\n private byte[] Pixels(Texture2D texture2D, double width, double height)\n {\n Rectangle rect = new Rectangle(0, 0, (int)width, (int)height);\n byte[] data = new byte[4*(int)width*(int)height];\n texture2D.GetData(0, rect, data, 0, data.Length);\n return data;\n }\n\n private void SetDestination(RenderTarget2D renderTarget2D, double viewportWidth, double viewportHeight)\n {\n this.game.SetDestination(renderTarget2D, (int)viewportWidth, (int)viewportHeight);\n }\n\n private void SetSource(Texture2D texture2D)\n {\n this.game.SetSource(texture2D);\n }\n\n private void SetVertices(byte[] vertices, byte[] indices)\n {\n this.game.SetVertices(vertices, indices);\n }\n\n private void Draw(double indexLen, double indexOffset, double operationSrc, double operationDst)\n {\n this.game.DrawTriangles((int)indexLen, (int)indexOffset, ToBlend((Operation)operationSrc), ToBlend((Operation)operationDst));\n }\n\n private bool IsKeyPressed(string driverKey)\n {\n Keys key;\n switch (driverKey)\n {\n case \"KeyDown\":\n key = Keys.Down;\n break;\n case \"KeyLeft\":\n key = Keys.Left;\n break;\n case \"KeySpace\":\n key = Keys.Space;\n break;\n case \"KeyRight\":\n key = Keys.Right;\n break;\n case \"KeyUp\":\n key = Keys.Up;\n break;\n default:\n return false;\n }\n return Keyboard.GetState().IsKeyDown(key);\n }\n }\n}\n") diff --git a/cmd/ebitenmonogame/main.go b/cmd/ebitenmonogame/main.go deleted file mode 100644 index b8b2f07f1..000000000 --- a/cmd/ebitenmonogame/main.go +++ /dev/null @@ -1,268 +0,0 @@ -// 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. - -package main - -import ( - "bytes" - "flag" - "fmt" - "io/ioutil" - "os" - "os/exec" - "path/filepath" - "strings" - - "github.com/hajimehoshi/go2dotnet/gowasm2csharp" -) - -const ebitenmonogameName = "ebitenmonogame" - -var ( - flagA bool // -a - flagGcflags string // -gcflags - flagI bool // -i - flagLdflags string // -ldflags - flagN bool // -n - flagTags string // -tags - flagTrimpath bool // -trimpath - flagV bool // -v - flagWork bool // -work - flagX bool // -x - - flagNamespace string // -namespace - flagO string // -o -) - -func main() { - if err := checkGOOS(); err != nil { - fmt.Fprintf(os.Stderr, "%s: %v\n", ebitenmonogameName, err) - os.Exit(2) - } - - var flagset flag.FlagSet - flag.Usage = func() { - fmt.Fprintf(os.Stderr, "%s [-namespace namespace] [-o output] [build flags] [package]\n", ebitenmonogameName) - os.Exit(2) - } - - flagset.BoolVar(&flagA, "a", false, "") - flagset.StringVar(&flagGcflags, "gcflags", "", "") - flagset.BoolVar(&flagI, "i", false, "") - flagset.StringVar(&flagLdflags, "ldflags", "", "") - flagset.BoolVar(&flagN, "n", false, "") - flagset.StringVar(&flagTags, "tags", "", "") - flagset.BoolVar(&flagTrimpath, "trimpath", false, "") - flagset.BoolVar(&flagV, "v", false, "") - flagset.BoolVar(&flagWork, "work", false, "") - flagset.BoolVar(&flagX, "x", false, "") - - flagset.StringVar(&flagNamespace, "namespace", "", "") - flagset.StringVar(&flagO, "o", "", "") - - flagset.Parse(os.Args[1:]) - - if flagNamespace == "" { - fmt.Fprintln(os.Stderr, "-namespace must be specified") - os.Exit(2) - } - if flagO == "" { - fmt.Fprintln(os.Stderr, "-o must be specified") - os.Exit(2) - } - - if flagLdflags != "" { - flagLdflags += " " - } - flagLdflags = "-X github.com/hajimehoshi/ebiten/internal/monogame.namespace=" + flagNamespace - if flagTags != "" { - flagTags += "," - } - flagTags += "monogame" - - var src string - switch srcs := flagset.Args(); len(srcs) { - case 0: - src = "." - case 1: - src = srcs[0] - default: - flag.Usage() - } - if err := run(src); err != nil { - fmt.Fprintf(os.Stderr, "%s: %v\n", ebitenmonogameName, err) - os.Exit(2) - } -} - -func checkGOOS() error { - out, err := exec.Command("go", "env", "GOOS").Output() - if err != nil { - return err - } - goos := strings.TrimSpace(string(out)) - if goos != "windows" { - fmt.Fprintln(os.Stderr, "Warning: The output project is buildable on Windows.") - } - return nil -} - -func run(src string) error { - // TODO: Check src is a main package? - - // Generate a wasm binary. - env := []string{ - "GOOS=js", - "GOARCH=wasm", - } - - dir, err := ioutil.TempDir("", "ebitenmonogame") - if err != nil { - return err - } - defer func() { - if flagWork { - fmt.Fprintf(os.Stderr, "The temporary work directory: %s\n", dir) - return - } - os.RemoveAll(dir) - }() - - wasmFile := filepath.Join(dir, "tmp.wasm") - - if err := runGo("build", []string{src}, env, "-o", wasmFile); err != nil { - return err - } - if flagN { - return nil - } - - autogenDir := filepath.Join(flagO, "autogen") - if flagV { - fmt.Fprintf(os.Stderr, "Writing %s%s*.cs\n", autogenDir, string(filepath.Separator)) - } - if err := os.MkdirAll(autogenDir, 0755); err != nil { - return err - } - if err := gowasm2csharp.Generate(autogenDir, wasmFile, flagNamespace+".AutoGen"); err != nil { - return err - } - - if err := writeFile(filepath.Join(flagO, "GoGame.cs"), replaceNamespace(gogame_cs)); err != nil { - return err - } - if err := writeFile(filepath.Join(flagO, "Program.cs"), replaceNamespace(program_cs)); err != nil { - return err - } - abs, err := filepath.Abs(flagO) - if err != nil { - return err - } - project := filepath.Base(abs) - if err := writeFile(filepath.Join(flagO, project+".csproj"), replaceNamespace(project_csproj)); err != nil { - return err - } - if err := writeFile(filepath.Join(flagO, "Content", "Content.mgcb"), replaceNamespace(content_mgcb)); err != nil { - return err - } - if err := writeFile(filepath.Join(flagO, "Content", "Shader.fx"), replaceNamespace(shader_fx)); err != nil { - return err - } - - return nil -} - -func runGo(subcmd string, srcs []string, env []string, args ...string) error { - cmd := exec.Command("go", subcmd) - if flagA { - cmd.Args = append(cmd.Args, "-a") - } - if flagGcflags != "" { - cmd.Args = append(cmd.Args, "-gcflags", flagGcflags) - } - if flagI { - cmd.Args = append(cmd.Args, "-i") - } - if flagLdflags != "" { - cmd.Args = append(cmd.Args, "-ldflags", flagLdflags) - } - if flagTags != "" { - cmd.Args = append(cmd.Args, "-tags", flagTags) - } - if flagTrimpath { - cmd.Args = append(cmd.Args, "-trimpath") - } - if flagV { - cmd.Args = append(cmd.Args, "-v") - } - if flagWork { - cmd.Args = append(cmd.Args, "-work") - } - if flagX { - cmd.Args = append(cmd.Args, "-x") - } - cmd.Args = append(cmd.Args, args...) - cmd.Args = append(cmd.Args, srcs...) - if len(env) > 0 { - cmd.Env = append([]string{}, env...) - } - - if flagX || flagN { - env := strings.Join(cmd.Env, " ") - if env != "" { - env += " " - } - fmt.Fprintf(os.Stderr, "%s%s\n", env, strings.Join(cmd.Args, " ")) - } - if flagN { - return nil - } - - if len(cmd.Env) > 0 { - cmd.Env = append(os.Environ(), cmd.Env...) - } - - buf := &bytes.Buffer{} - buf.WriteByte('\n') - if flagV { - cmd.Stdout = os.Stdout - cmd.Stderr = os.Stderr - } else { - cmd.Stdout = buf - cmd.Stderr = buf - } - - if err := cmd.Run(); err != nil { - return fmt.Errorf("%s failed: %v%s", strings.Join(cmd.Args, " "), err, buf) - } - return nil -} - -func writeFile(dst string, src []byte) error { - if flagV { - fmt.Fprintf(os.Stderr, "Writing %s\n", dst) - } - - if err := os.MkdirAll(filepath.Dir(dst), 0755); err != nil { - return err - } - if err := ioutil.WriteFile(dst, src, 0644); err != nil { - return err - } - return nil -} - -func replaceNamespace(src []byte) []byte { - return []byte(strings.ReplaceAll(string(src), "{{.Namespace}}", flagNamespace)) -} diff --git a/cmd/ebitenmonogame/program.cs b/cmd/ebitenmonogame/program.cs deleted file mode 100644 index ceb71fd70..000000000 --- a/cmd/ebitenmonogame/program.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; -using {{.Namespace}}.AutoGen; - -namespace {{.Namespace}} -{ - public static class Program - { - [STAThread] - static void Main() - { - Go go = new Go(); - go.Run(); - } - } -} diff --git a/cmd/ebitenmonogame/program.cs.go b/cmd/ebitenmonogame/program.cs.go deleted file mode 100644 index e80f00bf2..000000000 --- a/cmd/ebitenmonogame/program.cs.go +++ /dev/null @@ -1,6 +0,0 @@ -// Code generated by file2byteslice. DO NOT EDIT. -// (gofmt is fine after generating) - -package main - -var program_cs = []byte("\ufeffusing System;\nusing {{.Namespace}}.AutoGen;\n\nnamespace {{.Namespace}}\n{\n public static class Program\n {\n [STAThread]\n static void Main()\n {\n Go go = new Go();\n go.Run();\n }\n }\n}\n") diff --git a/cmd/ebitenmonogame/project.csproj b/cmd/ebitenmonogame/project.csproj deleted file mode 100644 index 535079864..000000000 --- a/cmd/ebitenmonogame/project.csproj +++ /dev/null @@ -1,24 +0,0 @@ - - - - WinExe - net48 - - - - true - - - true - - - - - - - - - - - - diff --git a/cmd/ebitenmonogame/project.csproj.go b/cmd/ebitenmonogame/project.csproj.go deleted file mode 100644 index 3e68901b9..000000000 --- a/cmd/ebitenmonogame/project.csproj.go +++ /dev/null @@ -1,6 +0,0 @@ -// Code generated by file2byteslice. DO NOT EDIT. -// (gofmt is fine after generating) - -package main - -var project_csproj = []byte("\n\n \n WinExe\n net48\n \n\n \n true\n \n \n true\n \n\n \n \n \n\n \n \n \n \n\n\n") diff --git a/cmd/ebitenmonogame/shader.fx b/cmd/ebitenmonogame/shader.fx deleted file mode 100644 index ce8843fcc..000000000 --- a/cmd/ebitenmonogame/shader.fx +++ /dev/null @@ -1,69 +0,0 @@ -#if OPENGL - #define SV_POSITION POSITION - #define VS_SHADERMODEL vs_3_0 - #define PS_SHADERMODEL ps_3_0 -#else - #define VS_SHADERMODEL vs_4_0_level_9_1 - #define PS_SHADERMODEL ps_4_0_level_9_1 -#endif - -Texture2D Texture; -float2 ViewportSize; - -SamplerState samplerState -{ - Texture = ; - MinFilter = Point; - MagFilter = Point; - MipFilter = Point; - AddressU = Clamp; - AddressV = Clamp; -}; - -struct VertexShaderInput -{ - float2 Vertex : POSITION0; - float2 TexCoord : TEXCOORD0; - float4 TexRegion : TEXCOORD1; - float4 Color : COLOR0; -}; - -struct VertexShaderOutput -{ - float4 Position : SV_POSITION; - float2 TexCoord : TEXCOORD0; - float4 Color : COLOR0; -}; - -VertexShaderOutput MainVS(in VertexShaderInput input) -{ - VertexShaderOutput output = (VertexShaderOutput)0; - - float4x4 projectionMatrix = { - 2.0 / ViewportSize.x, 0, 0, -1, - 0, -2.0 / ViewportSize.y, 0, 1, - 0, 0, 1, 0, - 0, 0, 0, 1, - }; - output.Position = mul(projectionMatrix, float4(input.Vertex.xy, 0, 1)); - output.TexCoord = input.TexCoord; - output.Color = input.Color.rgba; - - return output; -} - -float4 MainPS(VertexShaderOutput input) : COLOR -{ - float4 c = tex2D(samplerState, input.TexCoord.xy).rgba; - //float4 c = Texture.Sample(samplerState, input.TexCoord.xy); - return c * input.Color.rgba; -} - -technique BasicColorDrawing -{ - pass P0 - { - VertexShader = compile VS_SHADERMODEL MainVS(); - PixelShader = compile PS_SHADERMODEL MainPS(); - } -}; diff --git a/cmd/ebitenmonogame/shader.fx.go b/cmd/ebitenmonogame/shader.fx.go deleted file mode 100644 index 29004b259..000000000 --- a/cmd/ebitenmonogame/shader.fx.go +++ /dev/null @@ -1,6 +0,0 @@ -// Code generated by file2byteslice. DO NOT EDIT. -// (gofmt is fine after generating) - -package main - -var shader_fx = []byte("\ufeff#if OPENGL\n #define SV_POSITION POSITION\n #define VS_SHADERMODEL vs_3_0\n #define PS_SHADERMODEL ps_3_0\n#else\n #define VS_SHADERMODEL vs_4_0_level_9_1\n #define PS_SHADERMODEL ps_4_0_level_9_1\n#endif\n\nTexture2D Texture;\nfloat2 ViewportSize;\n\nSamplerState samplerState\n{\n Texture = ;\n MinFilter = Point;\n MagFilter = Point;\n MipFilter = Point;\n AddressU = Clamp;\n AddressV = Clamp;\n};\n\nstruct VertexShaderInput\n{\n float2 Vertex : POSITION0;\n float2 TexCoord : TEXCOORD0;\n float4 TexRegion : TEXCOORD1;\n float4 Color : COLOR0;\n};\n\nstruct VertexShaderOutput\n{\n float4 Position : SV_POSITION;\n float2 TexCoord : TEXCOORD0;\n float4 Color : COLOR0;\n};\n\nVertexShaderOutput MainVS(in VertexShaderInput input)\n{\n VertexShaderOutput output = (VertexShaderOutput)0;\n\n float4x4 projectionMatrix = {\n 2.0 / ViewportSize.x, 0, 0, -1,\n 0, -2.0 / ViewportSize.y, 0, 1,\n 0, 0, 1, 0,\n 0, 0, 0, 1,\n };\n output.Position = mul(projectionMatrix, float4(input.Vertex.xy, 0, 1));\n output.TexCoord = input.TexCoord;\n output.Color = input.Color.rgba;\n\n return output;\n}\n\nfloat4 MainPS(VertexShaderOutput input) : COLOR\n{\n float4 c = tex2D(samplerState, input.TexCoord.xy).rgba;\n //float4 c = Texture.Sample(samplerState, input.TexCoord.xy);\n return c * input.Color.rgba;\n}\n\ntechnique BasicColorDrawing\n{\n pass P0\n {\n VertexShader = compile VS_SHADERMODEL MainVS();\n PixelShader = compile PS_SHADERMODEL MainPS();\n }\n};\n") diff --git a/doc.go b/doc.go index 4060b5309..abbeaa74f 100644 --- a/doc.go +++ b/doc.go @@ -96,7 +96,4 @@ // number of graphics commands affects the performance of your game. // // `ebitengl` forces to use OpenGL in any environments. -// -// `monogame` changes the build target to MonoGame. This must be used with GOOS=js and GOARCH=wasm. This is -// experimental. package ebiten diff --git a/internal/graphicsdriver/monogame/graphics.go b/internal/graphicsdriver/monogame/graphics.go deleted file mode 100644 index efaf8586b..000000000 --- a/internal/graphicsdriver/monogame/graphics.go +++ /dev/null @@ -1,141 +0,0 @@ -// 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/graphics" - "github.com/hajimehoshi/ebiten/internal/monogame" - "github.com/hajimehoshi/ebiten/internal/thread" -) - -type Graphics struct { - game *monogame.Game -} - -var theGraphics Graphics - -func Get() *Graphics { - return &theGraphics -} - -func (g *Graphics) SetGame(game *monogame.Game) { - g.game = game -} - -func (g *Graphics) SetThread(thread *thread.Thread) { - panic("monogame: SetThread is not implemented") -} - -func (g *Graphics) Begin() { - // Do nothing -} - -func (g *Graphics) End() { - // Do nothing -} - -func (g *Graphics) SetTransparent(transparent bool) { - panic("monogame: SetTransparent is not implemented yet") -} - -func (g *Graphics) SetVertices(vertices []float32, indices []uint16) { - g.game.SetVertices(vertices, indices) -} - -func (g *Graphics) NewImage(width, height int) (driver.Image, error) { - w, h := graphics.InternalImageSize(width), graphics.InternalImageSize(height) - v := g.game.NewRenderTarget2D(w, h) - return &Image{ - v: v, - g: g, - width: width, - height: height, - }, nil -} - -func (g *Graphics) NewScreenFramebufferImage(width, height int) (driver.Image, error) { - return &Image{ - v: &screen{game: g.game}, - g: g, - 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 { - g.game.Draw(indexLen, indexOffset, mode, colorM, filter, address) - return nil -} - -func (g *Graphics) SetVsyncEnabled(enabled bool) { - panic("monogame: SetVsyncEnabled is not implemented yet") -} - -func (g *Graphics) FramebufferYDirection() driver.YDirection { - return driver.Downward -} - -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 -} - -type screen struct { - game *monogame.Game -} - -func (s *screen) SetAsDestination(viewportWidth, viewportHeight int) { - s.game.ResetDestination(viewportWidth, viewportHeight) -} - -func (s *screen) SetAsSource() { - panic("monogame: SetAsSource on screen is forbidden") -} - -func (s *screen) Pixels(width, height int) ([]byte, error) { - panic("monogame: Pixels on screen is forbidden") -} - -func (s *screen) ReplacePixels(args []*driver.ReplacePixelsArgs) { - panic("monogame: ReplacePixels on screen is forbidden") -} - -func (s *screen) Dispose() { - // Do nothing? -} - -func (s *screen) IsScreen() bool { - return true -} diff --git a/internal/graphicsdriver/monogame/image.go b/internal/graphicsdriver/monogame/image.go deleted file mode 100644 index 9cb4939ab..000000000 --- a/internal/graphicsdriver/monogame/image.go +++ /dev/null @@ -1,66 +0,0 @@ -// 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" - "github.com/hajimehoshi/ebiten/internal/graphics" -) - -type RenderTarget2D interface { - SetAsDestination(viewportWidth, viewportHeight int) - SetAsSource() - Pixels(width, height int) ([]byte, error) - ReplacePixels(args []*driver.ReplacePixelsArgs) - Dispose() - IsScreen() bool -} - -type Image struct { - v RenderTarget2D - g *Graphics - width int - height int -} - -func (i *Image) Dispose() { - i.v.Dispose() -} - -func (*Image) IsInvalidated() bool { - return false -} - -func (i *Image) Pixels() ([]byte, error) { - return i.v.Pixels(i.width, i.height) -} - -func (i *Image) SetAsDestination() { - w, h := i.width, i.height - if !i.v.IsScreen() { - w, h = graphics.InternalImageSize(w), graphics.InternalImageSize(h) - } - i.v.SetAsDestination(w, h) -} - -func (i *Image) SetAsSource() { - i.v.SetAsSource() -} - -func (i *Image) ReplacePixels(args []*driver.ReplacePixelsArgs) { - i.v.ReplacePixels(args) -} diff --git a/internal/jsutil/buf_js.go b/internal/jsutil/buf_js.go index 8cd85d449..449991bfe 100644 --- a/internal/jsutil/buf_js.go +++ b/internal/jsutil/buf_js.go @@ -12,8 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build !monogame - package jsutil import ( diff --git a/internal/jsutil/buf_monogame.go b/internal/jsutil/buf_monogame.go deleted file mode 100644 index 9bcf4eb04..000000000 --- a/internal/jsutil/buf_monogame.go +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2019 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 monogame - -package jsutil - -import ( - "syscall/js" -) - -func TemporaryUint8Array(byteLength int) js.Value { - panic("jsutil: TemporaryUint8Array is not implemented on monogame") -} diff --git a/internal/monogame/monogame.go b/internal/monogame/monogame.go deleted file mode 100644 index 6abdd662b..000000000 --- a/internal/monogame/monogame.go +++ /dev/null @@ -1,159 +0,0 @@ -// 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 ( - "reflect" - "runtime" - "syscall/js" - "unsafe" - - "github.com/hajimehoshi/ebiten/internal/affine" - "github.com/hajimehoshi/ebiten/internal/driver" -) - -// TODO: This implementation depends on some C# files that are not uploaded yet. -// Create 'ebitenmonogame' command to generate C# project for the MonoGame. - -// namespace is C# namespace. -// -// This is overwritten by -ldflags='-X github.com/hajimehoshi/ebiten/internal/monogame.namespace=NAMESPACE'. -var namespace = "Go2DotNet.Example.Ebiten" - -type UpdateDrawer interface { - Update() error - Draw() error -} - -type Game struct { - binding js.Value - update js.Func - draw js.Func -} - -func NewGame(ud UpdateDrawer) *Game { - update := js.FuncOf(func(this js.Value, args []js.Value) interface{} { - return ud.Update() - }) - - draw := js.FuncOf(func(this js.Value, args []js.Value) interface{} { - return ud.Draw() - }) - - v := js.Global().Get(".net").Get(namespace+".GameGoBinding").New(update, draw) - g := &Game{ - binding: v, - update: update, - draw: draw, - } - runtime.SetFinalizer(g, (*Game).Dispose) - return g -} - -func (g *Game) Dispose() { - runtime.SetFinalizer(g, nil) - g.update.Release() - g.draw.Release() -} - -func (g *Game) Run() { - g.binding.Call("Run") -} - -func (g *Game) NewRenderTarget2D(width, height int) *RenderTarget2D { - v := g.binding.Call("NewRenderTarget2D", width, height) - r := &RenderTarget2D{ - v: v, - binding: g.binding, - } - runtime.SetFinalizer(r, (*RenderTarget2D).Dispose) - return r -} - -func (g *Game) SetVertices(vertices []float32, indices []uint16) { - var vs, is js.Value - { - h := (*reflect.SliceHeader)(unsafe.Pointer(&vertices)) - h.Len *= 4 - h.Cap *= 4 - bs := *(*[]byte)(unsafe.Pointer(h)) - runtime.KeepAlive(vertices) - vs = js.Global().Get("Uint8Array").New(len(bs)) - js.CopyBytesToJS(vs, bs) - } - { - h := (*reflect.SliceHeader)(unsafe.Pointer(&indices)) - h.Len *= 2 - h.Cap *= 2 - bs := *(*[]byte)(unsafe.Pointer(h)) - runtime.KeepAlive(indices) - is = js.Global().Get("Uint8Array").New(len(bs)) - js.CopyBytesToJS(is, bs) - } - g.binding.Call("SetVertices", vs, is) -} - -func (g *Game) Draw(indexLen int, indexOffset int, mode driver.CompositeMode, colorM *affine.ColorM, filter driver.Filter, address driver.Address) { - src, dst := mode.Operations() - g.binding.Call("Draw", indexLen, indexOffset, int(src), int(dst)) -} - -func (g *Game) ResetDestination(viewportWidth, viewportHeight int) { - g.binding.Call("SetDestination", nil, viewportWidth, viewportHeight) -} - -func (g *Game) IsKeyPressed(key driver.Key) bool { - // Pass a string of the key since both driver.Key value and XNA's key value are not reliable. - return g.binding.Call("IsKeyPressed", key.String()).Bool() -} - -type RenderTarget2D struct { - v js.Value - binding js.Value -} - -func (r *RenderTarget2D) Dispose() { - runtime.SetFinalizer(r, nil) - r.binding.Call("Dispose", r.v) -} - -func (r *RenderTarget2D) Pixels(width, height int) ([]byte, error) { - v := r.binding.Call("Pixels", r.v, width, height) - bs := make([]byte, v.Length()) - js.CopyBytesToGo(bs, v) - return bs, nil -} - -func (r *RenderTarget2D) ReplacePixels(args []*driver.ReplacePixelsArgs) { - for _, a := range args { - arr := js.Global().Get("Uint8Array").New(len(a.Pixels)) - js.CopyBytesToJS(arr, a.Pixels) - r.binding.Call("ReplacePixels", r.v, arr, a.X, a.Y, a.Width, a.Height) - } -} - -func (r *RenderTarget2D) SetAsDestination(viewportWidth, viewportHeight int) { - r.binding.Call("SetDestination", r.v, viewportWidth, viewportHeight) -} - -func (r *RenderTarget2D) SetAsSource() { - r.binding.Call("SetSource", r.v) -} - -func (r *RenderTarget2D) IsScreen() bool { - return false -} diff --git a/internal/uidriver/monogame/input.go b/internal/uidriver/monogame/input.go deleted file mode 100644 index c58797264..000000000 --- a/internal/uidriver/monogame/input.go +++ /dev/null @@ -1,82 +0,0 @@ -// 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" - "github.com/hajimehoshi/ebiten/internal/monogame" -) - -type Input struct { - game *monogame.Game -} - -func (i *Input) CursorPosition() (x, y int) { - return 0, 0 -} - -func (i *Input) GamepadSDLID(id int) string { - return "" -} - -func (i *Input) GamepadName(id int) string { - return "" -} - -func (i *Input) GamepadAxis(id int, axis int) float64 { - return 0 -} - -func (i *Input) GamepadAxisNum(id int) int { - return 0 -} - -func (i *Input) GamepadButtonNum(id int) int { - return 0 -} - -func (i *Input) GamepadIDs() []int { - return nil -} - -func (i *Input) IsGamepadButtonPressed(id int, button driver.GamepadButton) bool { - return false -} - -func (i *Input) IsKeyPressed(key driver.Key) bool { - return i.game.IsKeyPressed(key) -} - -func (i *Input) IsMouseButtonPressed(button driver.MouseButton) bool { - return false -} - -func (i *Input) RuneBuffer() []rune { - return nil -} - -func (i *Input) TouchIDs() []int { - return nil -} - -func (i *Input) TouchPosition(id int) (x, y int) { - return 0, 0 -} - -func (i *Input) Wheel() (xoff, yoff float64) { - return 0, 0 -} diff --git a/internal/uidriver/monogame/ui.go b/internal/uidriver/monogame/ui.go deleted file mode 100644 index f228b1ae6..000000000 --- a/internal/uidriver/monogame/ui.go +++ /dev/null @@ -1,129 +0,0 @@ -// 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" - graphics "github.com/hajimehoshi/ebiten/internal/graphicsdriver/monogame" - "github.com/hajimehoshi/ebiten/internal/monogame" -) - -type UI struct { - game *monogame.Game - context driver.UIContext - input Input -} - -var theUI = &UI{} - -func Get() *UI { - return theUI -} - -func (u *UI) Run(context driver.UIContext) error { - g := monogame.NewGame(context) - defer g.Dispose() - - u.game = g - u.input.game = g - u.context = context - u.Graphics().(*graphics.Graphics).SetGame(g) - u.updateSize() - g.Run() - return nil -} - -func (*UI) RunWithoutMainLoop(context driver.UIContext) { - panic("monogame: RunWithoutMainLoop is not implemented") -} - -func (*UI) DeviceScaleFactor() float64 { - return 1 -} - -func (*UI) IsFocused() bool { - return true -} - -func (*UI) ScreenSizeInFullscreen() (int, int) { - // TODO: Implement this - return 640, 480 -} - -func (u *UI) ResetForFrame() { - u.updateSize() -} - -func (u *UI) updateSize() { - // TODO: Implement this - u.context.Layout(640, 480) -} - -func (*UI) CursorMode() driver.CursorMode { - return driver.CursorModeVisible -} - -func (*UI) SetCursorMode(mode driver.CursorMode) { - // TODO: Implement this -} - -func (*UI) IsFullscreen() bool { - // TODO: Implement this - return false -} - -func (*UI) SetFullscreen(fullscreen bool) { - // TODO: Implement this -} - -func (*UI) IsRunnableOnUnfocused() bool { - // TODO: Implement this - return false -} - -func (*UI) SetRunnableOnUnfocused(runnableOnUnfocused bool) { - // TODO: Implement this -} - -func (*UI) IsVsyncEnabled() bool { - // TODO: Implement this - return true -} - -func (*UI) SetVsyncEnabled(enabled bool) { - // TODO: Implement this -} - -func (*UI) IsScreenTransparent() bool { - return false -} - -func (*UI) SetScreenTransparent(transparent bool) { - panic("monogame: SetScreenTransparent is not implemented") -} - -func (u *UI) Input() driver.Input { - return &u.input -} - -func (*UI) Window() driver.Window { - return nil -} - -func (*UI) Graphics() driver.Graphics { - return graphics.Get() -} diff --git a/uidriver_js.go b/uidriver_js.go index f41f6303f..d8d727f3d 100644 --- a/uidriver_js.go +++ b/uidriver_js.go @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build !monogame // +build js package ebiten diff --git a/uidriver_monogame.go b/uidriver_monogame.go deleted file mode 100644 index 2cbd5b784..000000000 --- a/uidriver_monogame.go +++ /dev/null @@ -1,27 +0,0 @@ -// 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 monogame -// +build js - -package ebiten - -import ( - "github.com/hajimehoshi/ebiten/internal/driver" - "github.com/hajimehoshi/ebiten/internal/uidriver/monogame" -) - -func uiDriver() driver.UI { - return monogame.Get() -}