public static void Main() { var canvas = Document.GetElementById <HTMLCanvasElement>("main"); var gl = WebGLHelpers.GetWebGLRenderingContext(canvas); if (gl == null) { throw new InvalidOperationException("Your browser doesn't support WebGL rendering contexts"); } Action onWindowLoadOrResize = () => { canvas.Width = Window.InnerWidth; canvas.Height = Window.InnerHeight; }; Window.OnLoad = (e) => onWindowLoadOrResize(); Window.OnResize = (e) => onWindowLoadOrResize(); var textureLoader = new TextureLoader(Set <TextureInfo> .Empty .Add(TextureInfo.Create(gl, "../Content/Images/sprites.png"))); /* Tuples of 'program ID', 'vertex shader ID' and 'fragment shader ID' */ var programManager = new ProgramManager(gl, Set <Tuple <string, string, string> > .Empty .Add(Tuple.Create("prog-image", "image-vert-shader", "image-frag-shader")) .Add(Tuple.Create("prog-line", "line-vert-shader", "line-frag-shader"))); var level = new Level(); textureLoader.AllLoaded += () => Start(gl, textureLoader, programManager, level); textureLoader.ProcessTextures(); }
public override void Render(WebGLRenderingContext gl, TextureLoader textureLoader, ProgramManager programManager, int x, int y) { WebGLHelpers.DrawImage(gl, textureLoader.Textures.First(), programManager.Programs["prog-image"].Program, 64, 0, 64, 64, x, y, 64, 64); }