Ejemplo n.º 1
0
        /// <summary>
        /// 描画
        /// </summary>
        /// <returns></returns>
        public WriteableBitmap Draw()
        {
            //!< Debugの時だけバージョンチェックをする
            if (_babumiConfig.RequiredVersion > GraphicsManager.Instance.GetVersion())
            {
                return(null); //!< GL4.3以下なので処理をしない
            }

            GraphicsManager Manager = GraphicsManager.Instance;

            Manager.Begin();
            {
                _live2DManager.Update((int)_screenSize.X, (int)_screenSize.Y);
            }
            Manager.End();

            Manager.SetEffect(_computeShader);
            Manager.Uniform("Width", (float)_screenSize.X);
            Manager.Uniform("Height", (float)_screenSize.Y);
            Manager.UniformTexture(_renderTarget.TextureID, 0);
            Manager.UniformBuffer(_sssbObject.Buffer, 1, OpenGL.GL_SHADER_STORAGE_BUFFER);
            Manager.Dispatch((uint)_screenSize.X / 16, (uint)_screenSize.Y / 16, 1);
            {
                var    stride = this._screenSize.Y * 8 * 0.5;
                IntPtr ptr    = Manager.Map(OpenGL.GL_SHADER_STORAGE_BUFFER, _sssbObject.Buffer);
                _bitmapSource.WritePixels(
                    _sourceRect,
                    ptr,
                    (int)stride * (int)_screenSize.Y,
                    (int)stride);
                Manager.UnMap(OpenGL.GL_SHADER_STORAGE_BUFFER);
            }
            return(_bitmapSource);
        }