示例#1
0
        /// <summary>
        /// Attaches the object to a specific <see cref="RenderContext"/> object.
        /// </summary>
        /// <param name="rc">The <see cref="RenderContext"/> object to be used.</param>
        public void AttachToContext(RenderContext rc)
        {
            _rc         = rc;
            _clearColor = rc.ClearColor;

            var imgData = new ImageData();

            imgData.Width       = _screenWidth;
            imgData.Height      = _screenHeight;
            imgData.PixelFormat = ImagePixelFormat.RGBA;
            imgData.Stride      = 4;

            //this seems is not working in the new FUSEE verison
            //var imgData = ImageData.CreateImage(_screenWidth, _screenHeight, ColorUint.Black);

            _contentLTex = _rc.CreateTexture(imgData);
            _contentRTex = _rc.CreateTexture(imgData);

            // initialize shader and image
            switch (_activeMode)
            {
            case Stereo3DMode.Oculus:
                _guiLImage = new GUIImage(default(ImageData), 0, 0, _screenWidth / 2, _screenHeight);
                _guiLImage.AttachToContext(rc);
                _guiLImage.Refresh();

                _guiRImage = new GUIImage(default(ImageData), _screenWidth / 2, 0, _screenWidth / 2, _screenHeight);
                _guiRImage.AttachToContext(rc);
                _guiRImage.Refresh();

                _shaderProgram = _rc.CreateShader(OculusVs, OculusPs);
                _shaderTexture = _shaderProgram.GetShaderParam("vTexture");

                _lensCenterParam   = _shaderProgram.GetShaderParam("LensCenter");
                _screenCenterParam = _shaderProgram.GetShaderParam("ScreenCenter");
                _scaleParam        = _shaderProgram.GetShaderParam("Scale");
                _scaleInParam      = _shaderProgram.GetShaderParam("ScaleIn");
                _hdmWarpParam      = _shaderProgram.GetShaderParam("HmdWarpParam");

                break;

            case Stereo3DMode.Anaglyph:
                _shaderProgram = _rc.CreateShader(AnaglyphVs, AnaglyphPs);
                _shaderTexture = _shaderProgram.GetShaderParam("vTexture");

                _guiLImage = new GUIImage(default(ImageData), 0, 0, _screenWidth, _screenHeight);
                _guiLImage.AttachToContext(rc);
                _guiLImage.Refresh();

                break;
            }
        }