ebiten/cmd/ebitenmonogame/gogame.cs.go

7 lines
8.1 KiB
Go
Raw Normal View History

2020-04-24 11:07:33 +02:00
// 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<Effect>(\"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 thi