/// <summary>
		/// This is a javascript application.
		/// </summary>
		/// <param name="page">HTML document rendered by the web server which can now be enhanced.</param>
		public Application(IApp page)
		{
            // https://sites.google.com/a/jsc-solutions.net/work/knowledge-base/15-dualvr/20150718/webgl2

            //https://wiki.mozilla.org/Platform/GFX/WebGL2
            // https://twitter.com/etribz/status/359954523789328387
            // 2years since?
            // https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext
            // cannot find any example. retry later

            var c = new WebGL2RenderingContext();

			new IHTMLPre { new { c } }.AttachToDocument();

            // {{ c = null }}
            // https://github.com/dotnet/corefx/blob/master/src/System.Numerics.Vectors/src/System/Numerics/Matrix4x4.cs
            //  --enable-unsafe-es3-apis.
            // https://groups.google.com/forum/#!topic/webgl-dev-list/8P9Sk47K5hg

            // http://www.marmoset.co/viewer/gallery
            // http://lmv.rocks/

            // "C:\Users\Arvo\AppData\Local\Google\Chrome SxS\Application\chrome.exe - es3.lnk"
            // GL_VERSION	OpenGL ES 2.0 (ANGLE 2.1.0.02df796f466c)

            // GL_VERSION	OpenGL ES 3.0 (ANGLE 2.1.0.02df796f466c)

            ///* Uniform Buffer Objects and Transform Feedback Buffers */
            //421     void bindBufferBase(GLenum target, GLuint index, WebGLBuffer? buffer);
            //422     void bindBufferRange(GLenum target, GLuint index, WebGLBuffer? buffer, GLintptr offset, GLsizeiptr size);

            //  void drawElementsInstanced(GLenum mode, GLsizei count, GLenum type, GLintptr offset, GLsizei instanceCount);

        }
        /// <summary>
        /// This is a javascript application.
        /// </summary>
        /// <param name="page">HTML document rendered by the web server which can now be enhanced.</param>
        public Application(IApp page)
        {
            // https://www.shadertoy.com/view/lsSGRz


            #region += Launched chrome.app.window
            dynamic self = Native.self;
            dynamic self_chrome = self.chrome;
            object self_chrome_socket = self_chrome.socket;

            if (self_chrome_socket != null)
            {
                if (!(Native.window.opener == null && Native.window.parent == Native.window.self))
                {
                    Console.WriteLine("chrome.app.window.create, is that you?");

                    // pass thru
                }
                else
                {
                    // should jsc send a copresence udp message?
                    chrome.runtime.UpdateAvailable += delegate
                    {
                        new chrome.Notification(title: "UpdateAvailable");

                    };

                    chrome.app.runtime.Launched += async delegate
                    {
                        // 0:12094ms chrome.app.window.create {{ href = chrome-extension://aemlnmcokphbneegoefdckonejmknohh/_generated_background_page.html }}
                        Console.WriteLine("chrome.app.window.create " + new { Native.document.location.href });

                        new chrome.Notification(title: "ChromeUDPSendAsync");

                        var xappwindow = await chrome.app.window.create(
                               Native.document.location.pathname, options: null
                        );

                        //xappwindow.setAlwaysOnTop

                        xappwindow.show();

                        await xappwindow.contentWindow.async.onload;

                        Console.WriteLine("chrome.app.window loaded!");
                    };


                    return;
                }
            }
            #endregion



            // X:\jsc.svn\examples\javascript\WorkerMD5Experiment\WorkerMD5Experiment\Application.cs

            {
                new IHTMLHeader1 { "webgl1" }.AttachToDocument();

                var webgl1 = new WebGLRenderingContext();

                new IHTMLHeader1 { new { webgl1 } }.AttachToDocument();

                // http://webglreport.com/
                //       unMaskedRenderer: getUnmaskedInfo(gl).renderer,
                //<th>Unmasked Renderer:</th>
                //			<td><%= report.unMaskedRenderer %></td>

                var UNMASKED_RENDERER_WEBGL = "";
                var WEBGL_debug_renderer_info = new
                {
                    UNMASKED_RENDERER_WEBGL = 0x9246u
                };



                var dbgRenderInfo = webgl1.getExtension("WEBGL_debug_renderer_info");
                if (dbgRenderInfo != null)
                {
                    // https://www.khronos.org/registry/webgl/extensions/WEBGL_debug_renderer_info/
                    UNMASKED_RENDERER_WEBGL = (string)webgl1.getParameter(WEBGL_debug_renderer_info.UNMASKED_RENDERER_WEBGL);
                }



                new IHTMLPre { new { UNMASKED_RENDERER_WEBGL } }.AttachToDocument();

                // https://www.khronos.org/registry/webgl/extensions/WEBGL_shared_resources/

                var sharedResourcesExtension = webgl1.getExtension("WEBGL_shared_resources");
                new IHTMLPre { new { sharedResourcesExtension } }.AttachToDocument();

                // https://code.google.com/p/chromium/issues/detail?id=245894
                // https://bugzilla.mozilla.org/show_bug.cgi?id=964788

            }


            {
                new IHTMLHeader1 { "webgl2" }.AttachToDocument();

                var webgl2 = new WebGL2RenderingContext();
                new IHTMLHeader1 { new { webgl2 } }.AttachToDocument();

                // http://webglreport.com/
                //       unMaskedRenderer: getUnmaskedInfo(gl).renderer,
                //<th>Unmasked Renderer:</th>
                //			<td><%= report.unMaskedRenderer %></td>

                var UNMASKED_RENDERER_WEBGL = "";
                var WEBGL_debug_renderer_info = new
                {
                    UNMASKED_RENDERER_WEBGL = 0x9246u
                };



                var dbgRenderInfo = webgl2.getExtension("WEBGL_debug_renderer_info");
                if (dbgRenderInfo != null)
                {
                    // https://www.khronos.org/registry/webgl/extensions/WEBGL_debug_renderer_info/
                    UNMASKED_RENDERER_WEBGL = (string)webgl2.getParameter(WEBGL_debug_renderer_info.UNMASKED_RENDERER_WEBGL);
                }



                new IHTMLPre { new { UNMASKED_RENDERER_WEBGL } }.AttachToDocument();

                // https://www.khronos.org/registry/webgl/extensions/WEBGL_shared_resources/

                var sharedResourcesExtension = webgl2.getExtension("WEBGL_shared_resources");
                new IHTMLPre { new { sharedResourcesExtension } }.AttachToDocument();

                // https://code.google.com/p/chromium/issues/detail?id=245894
                // https://bugzilla.mozilla.org/show_bug.cgi?id=964788

            }
        }