Example #1
0
        // NOTE: This is old code based on OnRenderImage...may be revived at some point
        private void OnRenderImage(RenderTexture source, RenderTexture dest)
        {
            if (_capturing && !_paused)
            {
#if true
                while (_handle >= 0 && !NativePlugin.IsNewFrameDue(_handle))
                {
                    System.Threading.Thread.Sleep(1);
                }
                if (_handle >= 0)
                {
                    if (_audioCapture && _audioDeviceIndex < 0 && !_noAudio && _isRealTime)
                    {
                        int           audioDataLength = 0;
                        System.IntPtr audioDataPtr    = _audioCapture.ReadData(out audioDataLength);
                        if (audioDataLength > 0)
                        {
                            NativePlugin.EncodeAudio(_handle, audioDataPtr, (uint)audioDataLength);
                        }
                    }

                    // In Direct3D the RT can be flipped vertically

                    /*if (source.texelSize.y < 0)
                     * {
                     *
                     * }*/

                    Graphics.Blit(source, dest);

                    _lastSource = source;
                    _lastDest   = dest;

                    if (dest != _originalTarget)
                    {
                        Graphics.Blit(dest, _originalTarget);
                    }

#if AVPRO_MOVIECAPTURE_GLISSUEEVENT_52
                    GL.IssuePluginEvent(NativePlugin.GetRenderEventFunc(), NativePlugin.PluginID | (int)NativePlugin.PluginEvent.CaptureFrameBuffer | _handle);
#else
                    GL.IssuePluginEvent(NativePlugin.PluginID | (int)NativePlugin.PluginEvent.CaptureFrameBuffer | _handle);
#endif
                    GL.InvalidateState();

                    UpdateFPS();

                    return;
                }
#endif
            }

            // Pass-through
            Graphics.Blit(source, dest);

            _lastSource = source;
            _lastDest   = dest;
        }