Exemple #1
0
        protected override void OnRenderFrame(FrameEventArgs e)
        {
            base.OnRenderFrame(e);

            if ((LastMotion == null) || (LastMotion.Finished == true))
            {
                var motion_group = Asset.MotionGroups[""];
                int number       = new Random().Next() % motion_group.Length;
                var motion       = (CubismMotion)motion_group[number];
                LastMotion = Asset.StartMotion(CubismAsset.MotionType.Base, motion, false);
            }

            Asset.Update(elapsed);

            GL.Viewport(0, 0, ClientRectangle.Width, ClientRectangle.Height);
            GL.Clear(ClearBufferMask.ColorBufferBit);

            Matrix4 mvp_matrix = Matrix4.Identity;

            mvp_matrix[0, 0] = 2.0f;
            mvp_matrix[1, 1] = 2.0f * Width / Height;
            RenderingManager.Draw(mvp_matrix);

            SwapBuffers();
        }
        protected override void OnOpenGlRender(GlInterface gl, int fb)
        {
            if (m_asset == null)
            {
                return;
            }

            if ((m_lastmotion == null) || (m_lastmotion.Finished == true))
            {
                var motion_group = m_asset.MotionGroups[""];
                int number       = new Random().Next() % motion_group.Length;
                var motion       = (CubismMotion)motion_group[number];
                m_lastmotion = m_asset.StartMotion(MotionType.Base, motion, false);
            }

            m_asset.Update(m_time.ElapsedMilliseconds / 1000.0);
            m_time.Restart();
            double controlScaling = VisualRoot.RenderScaling;
            int    w = (int)(Bounds.Width * controlScaling);
            int    h = (int)(Bounds.Height * controlScaling);
            double r = Math.Sqrt(((float)w) / h);

            gl.Viewport(0, 0, w, h);
            gl.Clear(GL_COLOR_BUFFER_BIT);

            Matrix4x4 mvp_matrix = Matrix4x4.Identity;

            if (h >= w)
            {
                mvp_matrix.M11 = 1.5f;
                mvp_matrix.M22 = -1.5f * w / h;
            }
            else
            {
                mvp_matrix.M11 = 1.5f * h / w;
                mvp_matrix.M22 = -1.5f;
            }

            m_rendermgr.Draw(mvp_matrix);

            Dispatcher.UIThread.Post(InvalidateVisual, DispatcherPriority.Background);
        }