Exemple #1
0
        void Render()
        {
            m_d3DDevice.BeginScene();

            // Render target needs to be set to 640x360 for optimal scaling. However the pixel coordinates for
            // Direct3D 9 render target is actually (-0.5,-0.5) to (639.5,359.5).  As such the Viewport is set
            // to 639x359 to account for the pixel coordinate offset of render target
            tagRECT rect;

            rect.top    = m_d3DDevice.Viewport.Y;
            rect.left   = m_d3DDevice.Viewport.X;
            rect.bottom = m_d3DDevice.Viewport.Y + m_d3DDevice.Viewport.Height;
            rect.right  = m_d3DDevice.Viewport.X + m_d3DDevice.Viewport.Width;

            m_previewHelper.Render(rect);

            // Draw the timecode top-center with a slight drop-shadow
            Rectangle rc = m_d3DFont.MeasureString(null, m_timeCodeString, Direct3D.DrawTextFormat.Center, Color.Black);
            int       x  = (m_d3DDevice.Viewport.Width / 2) - (rc.Width / 2);
            int       y  = 10;

            m_d3DFont.DrawText(null, m_timeCodeString, x + 1, y + 1, Color.Black);
            m_d3DFont.DrawText(null, m_timeCodeString, x, y, Color.White);

            m_d3DDevice.EndScene();
            m_d3DDevice.Present();
        }
        void Render()
        {
            try
            {
                Result result = device.TestCooperativeLevel();
                if (result != ResultCode.Success)
                {
                    logger.Warn("TestCooperativeLevel: " + result);
                    bool deviceReady = false;
                    if (result == ResultCode.DeviceLost)
                    {
                        // OnLostDevice();
                        Thread.Sleep(50);
                    }
                    else if (result == ResultCode.DeviceNotReset)
                    {
                        DeviceReset();

                        //deviceReady = ReInitDevice();
                    }

                    if (!deviceReady)
                    {
                        //TODO: error
                        logger.Warn("Device is not ready...");

                        Thread.Sleep(100);

                        return;
                    }
                }

                device.BeginScene();

                // Render target needs to be set to 640x360 for optimal scaling. However the pixel coordinates for
                // Direct3D 9 render target is actually (-0.5,-0.5) to (639.5,359.5).  As such the Viewport is set
                // to 639x359 to account for the pixel coordinate offset of render target
                tagRECT rect;
                rect.top    = device.Viewport.Y;
                rect.left   = device.Viewport.X;
                rect.bottom = device.Viewport.Y + device.Viewport.Height;
                rect.right  = device.Viewport.X + device.Viewport.Width;

                previewHelper.Render(rect);

                device.EndScene();

                device.Present();
            }
            catch (SharpDXException ex)
            {
                logger.Error(ex);

                //TODO:...
                // если произошла не понятная ошибка чтото делаем...
            }
        }
Exemple #3
0
        void Render()
        {
            m_d3DDevice.BeginScene();

            tagRECT rect;

            rect.top    = m_d3DDevice.Viewport.Y;
            rect.left   = m_d3DDevice.Viewport.X;
            rect.bottom = m_d3DDevice.Viewport.Y + m_d3DDevice.Viewport.Height;
            rect.right  = m_d3DDevice.Viewport.X + m_d3DDevice.Viewport.Width;

            m_previewHelper.Render(rect);

            m_d3DDevice.EndScene();
            m_d3DDevice.Present();
        }
        void Render()
        {
            try
            {
                Result result = device.TestCooperativeLevel();
                if (result != ResultCode.Success)
                {
                    logger.Warn("TestCooperativeLevel: " + result);
                    bool deviceReady = false;
                    if (result == ResultCode.DeviceLost)
                    {
                        // OnLostDevice();
                        Thread.Sleep(50);
                    }
                    else if (result == ResultCode.DeviceNotReset)
                    {
                        //deviceReady = ReInitDevice();
                    }

                    if (!deviceReady)
                    {
                        //TODO: error
                        logger.Warn("Device is not ready...");

                        Thread.Sleep(100);

                        return;
                    }
                }

                device.BeginScene();

                // Render target needs to be set to 640x360 for optimal scaling. However the pixel coordinates for
                // Direct3D 9 render target is actually (-0.5,-0.5) to (639.5,359.5).  As such the Viewport is set
                // to 639x359 to account for the pixel coordinate offset of render target
                tagRECT rect;
                rect.top    = device.Viewport.Y;
                rect.left   = device.Viewport.X;
                rect.bottom = device.Viewport.Y + device.Viewport.Height;
                rect.right  = device.Viewport.X + device.Viewport.Width;

                previewHelper.Render(rect);

                // Draw the timecode top-center with a slight drop-shadow
                //Rectangle rc = m_d3DFont.MeasureString(null, m_timeCodeString, Direct3D.DrawTextFormat.Center, Color.Black);
                //int x = (m_d3DDevice.Viewport.Width / 2) - (rc.Width / 2);
                //int y = 10;
                //m_d3DFont.DrawText(null, m_timeCodeString, x + 1, y + 1, Color.Black);
                //m_d3DFont.DrawText(null, m_timeCodeString, x, y, Color.White);

                device.EndScene();

                device.Present();
            }
            catch (SharpDXException ex)
            {
                logger.Error(ex);

                //TODO:...
                // если произошла не понятная ошибка чтото делаем...
            }
        }