mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 11:18:54 +01:00
parent
cfe1aa1191
commit
d8b34b136a
21
cmd/ebitenmonogame/content.mgcb
Normal file
21
cmd/ebitenmonogame/content.mgcb
Normal file
@ -0,0 +1,21 @@
|
||||
|
||||
#----------------------------- 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
|
||||
|
6
cmd/ebitenmonogame/content.mgcb.go
Normal file
6
cmd/ebitenmonogame/content.mgcb.go
Normal file
@ -0,0 +1,6 @@
|
||||
// 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")
|
22
cmd/ebitenmonogame/generate.go
Normal file
22
cmd/ebitenmonogame/generate.go
Normal file
@ -0,0 +1,22 @@
|
||||
// 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
|
231
cmd/ebitenmonogame/gogame.cs
Normal file
231
cmd/ebitenmonogame/gogame.cs
Normal file
@ -0,0 +1,231 @@
|
||||
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<Effect>("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);
|
||||
}
|
||||
}
|
||||
}
|
6
cmd/ebitenmonogame/gogame.cs.go
Normal file
6
cmd/ebitenmonogame/gogame.cs.go
Normal file
File diff suppressed because one or more lines are too long
268
cmd/ebitenmonogame/main.go
Normal file
268
cmd/ebitenmonogame/main.go
Normal file
@ -0,0 +1,268 @@
|
||||
// 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))
|
||||
}
|
15
cmd/ebitenmonogame/program.cs
Normal file
15
cmd/ebitenmonogame/program.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using {{.Namespace}}.AutoGen;
|
||||
|
||||
namespace {{.Namespace}}
|
||||
{
|
||||
public static class Program
|
||||
{
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
Go go = new Go();
|
||||
go.Run();
|
||||
}
|
||||
}
|
||||
}
|
6
cmd/ebitenmonogame/program.cs.go
Normal file
6
cmd/ebitenmonogame/program.cs.go
Normal file
@ -0,0 +1,6 @@
|
||||
// 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")
|
25
cmd/ebitenmonogame/project.csproj
Normal file
25
cmd/ebitenmonogame/project.csproj
Normal file
@ -0,0 +1,25 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net48</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<MonoGameContentReference Include="**\*.mgcb" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="MonoGame.Content.Builder" Version="3.7.0.9" />
|
||||
<PackageReference Include="MonoGame.Framework.DesktopGL.Core" Version="3.8.0.13" />
|
||||
<PackageReference Include="InfinitespaceStudios.Pipeline" Version="1.0.9" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
6
cmd/ebitenmonogame/project.csproj.go
Normal file
6
cmd/ebitenmonogame/project.csproj.go
Normal file
@ -0,0 +1,6 @@
|
||||
// Code generated by file2byteslice. DO NOT EDIT.
|
||||
// (gofmt is fine after generating)
|
||||
|
||||
package main
|
||||
|
||||
var project_csproj = []byte("<Project Sdk=\"Microsoft.NET.Sdk\">\n\n <PropertyGroup>\n <OutputType>WinExe</OutputType>\n <TargetFramework>net48</TargetFramework>\n </PropertyGroup>\n\n <PropertyGroup Condition=\" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' \">\n <AllowUnsafeBlocks>true</AllowUnsafeBlocks>\n </PropertyGroup>\n <PropertyGroup Condition=\" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' \">\n <AllowUnsafeBlocks>true</AllowUnsafeBlocks>\n </PropertyGroup>\n\n <ItemGroup>\n <MonoGameContentReference Include=\"**\\*.mgcb\" />\n </ItemGroup>\n\n <ItemGroup>\n <PackageReference Include=\"MonoGame.Content.Builder\" Version=\"3.7.0.9\" />\n <PackageReference Include=\"MonoGame.Framework.DesktopGL.Core\" Version=\"3.8.0.13\" />\n <PackageReference Include=\"InfinitespaceStudios.Pipeline\" Version=\"1.0.9\" />\n </ItemGroup>\n\n</Project>\n")
|
69
cmd/ebitenmonogame/shader.fx
Normal file
69
cmd/ebitenmonogame/shader.fx
Normal file
@ -0,0 +1,69 @@
|
||||
#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 = <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();
|
||||
}
|
||||
};
|
6
cmd/ebitenmonogame/shader.fx.go
Normal file
6
cmd/ebitenmonogame/shader.fx.go
Normal file
@ -0,0 +1,6 @@
|
||||
// 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 = <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")
|
1
go.mod
1
go.mod
@ -8,6 +8,7 @@ require (
|
||||
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0
|
||||
github.com/hajimehoshi/bitmapfont v1.2.0
|
||||
github.com/hajimehoshi/go-mp3 v0.2.1
|
||||
github.com/hajimehoshi/go2dotnet v0.0.0-20200424065834-214e39ae7ba9
|
||||
github.com/hajimehoshi/oto v0.5.4
|
||||
github.com/jakecoffman/cp v0.1.0
|
||||
github.com/jfreymuth/oggvorbis v1.0.1
|
||||
|
10
go.sum
10
go.sum
@ -1,6 +1,9 @@
|
||||
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
|
||||
github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M=
|
||||
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4 h1:WtGNWLvXpe6ZudgnXrq0barxBImvnnJoMEhXAzcbM0I=
|
||||
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
|
||||
github.com/go-interpreter/wagon v0.6.1-0.20200226200811-4ca95707c808 h1:DK/r87dK66orWskGaYpM/0csKs1uOtwve5tX0z/ZljI=
|
||||
github.com/go-interpreter/wagon v0.6.1-0.20200226200811-4ca95707c808/go.mod h1:lQUozviuTS6v7A2HXs6L0Wc72Apl9+mKsGLsJOHYiME=
|
||||
github.com/gofrs/flock v0.7.1 h1:DP+LD/t0njgoPBvT5MJLeliUIVQR03hiKR6vezdwHlc=
|
||||
github.com/gofrs/flock v0.7.1/go.mod h1:F1TvTiK9OcQqauNUHlbJvyl9Qa1QvF/gOUDKA14jxHU=
|
||||
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 h1:DACJavvAHhabrF08vX0COfcOBJRhZ8lUbR+ZWIs0Y5g=
|
||||
@ -9,6 +12,8 @@ github.com/hajimehoshi/bitmapfont v1.2.0 h1:hw6OjRGdgmHUe56BPju/KU/QD/KLOiTQ+6t+
|
||||
github.com/hajimehoshi/bitmapfont v1.2.0/go.mod h1:h9QrPk6Ktb2neObTlAbma6Ini1xgMjbJ3w7ysmD7IOU=
|
||||
github.com/hajimehoshi/go-mp3 v0.2.1 h1:DH4ns3cPv39n3cs8MPcAlWqPeAwLCK8iNgqvg0QBWI8=
|
||||
github.com/hajimehoshi/go-mp3 v0.2.1/go.mod h1:Rr+2P46iH6PwTPVgSsEwBkon0CK5DxCAeX/Rp65DCTE=
|
||||
github.com/hajimehoshi/go2dotnet v0.0.0-20200424065834-214e39ae7ba9 h1:C9vjr5PfWbBRKNAhRgNo6CsZnvq++clRKOsKsoSBWCw=
|
||||
github.com/hajimehoshi/go2dotnet v0.0.0-20200424065834-214e39ae7ba9/go.mod h1:+8Cy6laz1rGBpWrlF6xpunxYgj/Oy/XPSgl/JFJ0lHo=
|
||||
github.com/hajimehoshi/oto v0.3.4/go.mod h1:PgjqsBJff0efqL2nlMJidJgVJywLn6M4y8PI4TfeWfA=
|
||||
github.com/hajimehoshi/oto v0.5.4 h1:Dn+WcYeF310xqStKm0tnvoruYUV5Sce8+sfUaIvWGkE=
|
||||
github.com/hajimehoshi/oto v0.5.4/go.mod h1:0QXGEkbuJRohbJaxr7ZQSxnju7hEhseiPx2hrh6raOI=
|
||||
@ -24,6 +29,8 @@ github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs=
|
||||
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
|
||||
github.com/pkg/browser v0.0.0-20180916011732-0a3d74bf9ce4/go.mod h1:4OwLy04Bl9Ef3GJJCoec+30X3LQs/0/m4HFRt/2LUSA=
|
||||
github.com/pkg/profile v1.4.0/go.mod h1:NWz/XGvpEW1FyYQ7fCx4dqYBLlfTcE+A9FLAkNKqjFE=
|
||||
github.com/twitchyliquid64/golang-asm v0.0.0-20190126203739-365674df15fc/go.mod h1:NoCfSFWosfqMqmmD7hApkirIK9ozpHjxRnRxs1l413A=
|
||||
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
@ -53,7 +60,10 @@ golang.org/x/sync v0.0.0-20190423024810-112230192c58 h1:8gQV6CLnAEikrhgkHFbMAEha
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e h1:vcxGaoTs7kV8m5Np9uUNQin4BrLOthgV7252N8V+FwY=
|
||||
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a h1:WXEvlFVvvGxCJLG6REjsT03iWnKLEWinaScsxF2Vm2o=
|
||||
golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190306220234-b354f8bf4d9e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190429190828-d89cdac9e872/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
|
Loading…
Reference in New Issue
Block a user