public WebGameWindow(WebGamePlatform platform)
        {
            _platform = platform;
            _keys = new List<Keys>();

            _onmousemove = (Action<dynamic>)OnMouseMove;
            _onmousedown = (Action<dynamic>)OnMouseDown;
            _onmouseup = (Action<dynamic>)OnMouseUp;
            _onkeydown = (Action<dynamic>)OnKeyDown;
            _onkeyup = (Action<dynamic>)OnKeyUp;
            _onwheel = (Action<dynamic>)OnMouseWheel;
            
            document = Builtins.Global["document"];
            window = Builtins.Global["window"];
            glcanvas = document.getElementById("mgcanvas");
            gl = glcanvas.getContext("webgl");

            WebGL.gl = gl;

            if (glcanvas.mozRequestPointerLock)
                glcanvas.requestPointerLock = glcanvas.mozRequestPointerLock;
            else if(glcanvas.webkitRequestPointerLock)
                glcanvas.requestPointerLock = glcanvas.webkitRequestPointerLock;

            document.addEventListener("pointerlockchange", (Action)OnCursorLockChange, false);
            document.addEventListener("mozpointerlockchange", (Action)OnCursorLockChange, false);
            document.addEventListener("webkitpointerlockchange", (Action)OnCursorLockChange, false);

            glcanvas.addEventListener("contextmenu", (Action<dynamic>)((e) => e.preventDefault()), false);

            glcanvas.onclick = (Action<dynamic>)OnMouseClick;

            Mouse.PrimaryWindow = this;
        }
Beispiel #2
0
        public WebGameWindow(WebGamePlatform platform)
        {
            _platform = platform;

            Builtins.Eval(@"
 /* TODO: Create WebGL element */           
");
        }