コード例 #1
0
        public void Stop()
        {
            checkDisposed();

            // Check the player state before attempting anything.
            if (State == MediaState.Stopped)
            {
                return;
            }

            // Update the player state.
            State = MediaState.Stopped;

            // Wait for the player to end if it's still going.
            FNALoggerEXT.LogInfo("Signaled Theora player to stop, waiting...");
            timer.Stop();
            timer.Reset();
            if (audioStream != null)
            {
                audioStream.Stop();
                audioStream.Dispose();
                audioStream = null;
            }
            if (previousFrame != IntPtr.Zero)
            {
                TheoraPlay.THEORAPLAY_freeVideo(previousFrame);
            }
            Video.AttachedToPlayer = false;
            Video.Dispose();
            FNALoggerEXT.LogInfo("Stopped!");
        }
コード例 #2
0
ファイル: ThreadedGLDevice.cs プロジェクト: syun002/FNA
        public ThreadedGLDevice(
            PresentationParameters presentationParameters,
            GraphicsAdapter adapter
            )
        {
            csThread = new Thread(new ThreadStart(csThreadProc));
            csThread.Start();

            FNALoggerEXT.LogInfo("Running with ThreadedGLDevice!");
            ForceToMainThread(() =>
            {
                if (Environment.GetEnvironmentVariable(
                        "FNA_THREADEDGLDEVICE_GLDEVICE"
                        ) == "OpenGLDevice")
                {
                    GLDevice = new OpenGLDevice(
                        presentationParameters,
                        adapter
                        );
                }
                else
                {
                    GLDevice = new ModernGLDevice(
                        presentationParameters,
                        adapter
                        );
                }
            });             // End ForceToMainThread
        }
コード例 #3
0
ファイル: PipelineCache.cs プロジェクト: kiates/FNA
        public void EndApplyBlend()
        {
            StateHash hash = GetBlendHash(
                AlphaBlendFunction,
                AlphaDestinationBlend,
                AlphaSourceBlend,
                ColorBlendFunction,
                ColorDestinationBlend,
                ColorSourceBlend,
                ColorWriteChannels,
                ColorWriteChannels1,
                ColorWriteChannels2,
                ColorWriteChannels3,
                BlendFactor,
                MultiSampleMask
                );
            BlendState newBlend;

            if (!blendCache.TryGetValue(hash, out newBlend))
            {
                newBlend = new BlendState();

                newBlend.AlphaBlendFunction    = AlphaBlendFunction;
                newBlend.AlphaDestinationBlend = AlphaDestinationBlend;
                newBlend.AlphaSourceBlend      = AlphaSourceBlend;
                newBlend.ColorBlendFunction    = ColorBlendFunction;
                newBlend.ColorDestinationBlend = ColorDestinationBlend;
                newBlend.ColorSourceBlend      = ColorSourceBlend;
                newBlend.ColorWriteChannels    = ColorWriteChannels;
                newBlend.ColorWriteChannels1   = ColorWriteChannels1;
                newBlend.ColorWriteChannels2   = ColorWriteChannels2;
                newBlend.ColorWriteChannels3   = ColorWriteChannels3;
                newBlend.BlendFactor           = BlendFactor;
                newBlend.MultiSampleMask       = MultiSampleMask;

                blendCache.Add(hash, newBlend);
#if VERBOSE_PIPELINECACHE
                FNALoggerEXT.LogInfo(
                    "New BlendState added to pipeline cache with hash:\n" +
                    hash.ToString()
                    );
                FNALoggerEXT.LogInfo(
                    "Updated size of BlendState cache: " +
                    blendCache.Count
                    );
            }
            else
            {
                FNALoggerEXT.LogInfo(
                    "Retrieved BlendState from pipeline cache with hash:\n" +
                    hash.ToString()
                    );
#endif
            }

            device.BlendState = newBlend;
        }
コード例 #4
0
        static void HandleException(Exception e)
        {
            FNALoggerEXT.LogInfo("Exception: " + e.ToString());
            AppendToFile("error.log", e.ToString());

            if (null != e.InnerException)
            {
                HandleException(e.InnerException);
            }
        }
コード例 #5
0
        public void EndApplyBlend()
        {
            int funcs = ((int)AlphaBlendFunction << 4) | ((int)ColorBlendFunction);
            int blendsAndColorWriteChannels =
                ((int)AlphaDestinationBlend << (32 - 4))
                | ((int)AlphaSourceBlend << (32 - 8))
                | ((int)ColorDestinationBlend << (32 - 12))
                | ((int)ColorSourceBlend << (32 - 16))
                | ((int)ColorWriteChannels << (32 - 20))
                | ((int)ColorWriteChannels1 << (32 - 24))
                | ((int)ColorWriteChannels2 << (32 - 28))
                | ((int)ColorWriteChannels3);

            StateHash hash = new StateHash(
                funcs,
                blendsAndColorWriteChannels,
                (int)BlendFactor.PackedValue,
                MultiSampleMask
                );

            BlendState newBlend;

            if (!blendCache.TryGetValue(hash, out newBlend))
            {
                newBlend = new BlendState();

                newBlend.AlphaBlendFunction    = AlphaBlendFunction;
                newBlend.AlphaDestinationBlend = AlphaDestinationBlend;
                newBlend.AlphaSourceBlend      = AlphaSourceBlend;
                newBlend.ColorBlendFunction    = ColorBlendFunction;
                newBlend.ColorDestinationBlend = ColorDestinationBlend;
                newBlend.ColorSourceBlend      = ColorSourceBlend;
                newBlend.ColorWriteChannels    = ColorWriteChannels;
                newBlend.ColorWriteChannels1   = ColorWriteChannels1;
                newBlend.ColorWriteChannels2   = ColorWriteChannels2;
                newBlend.ColorWriteChannels3   = ColorWriteChannels3;
                newBlend.BlendFactor           = BlendFactor;
                newBlend.MultiSampleMask       = MultiSampleMask;

                blendCache.Add(hash, newBlend);
#if VERBOSE_PIPELINECACHE
                FNALoggerEXT.LogInfo("New BlendState added to pipeline cache with hash:\n"
                                     + hash.ToString());
                FNALoggerEXT.LogInfo("Updated size of BlendState cache: "
                                     + blendCache.Count);
            }
            else
            {
                FNALoggerEXT.LogInfo("Retrieved BlendState from pipeline cache with hash:\n"
                                     + hash.ToString());
#endif
            }

            device.BlendState = newBlend;
        }
コード例 #6
0
        public void EndApplyRasterizer()
        {
            // Bool -> Int32 conversion
            int multiSampleAntiAlias = (MultiSampleAntiAlias ? 1 : 0);
            int scissorTestEnable    = (ScissorTestEnable ? 1 : 0);

            int packedProperties =
                ((int)multiSampleAntiAlias << 4)
                | ((int)scissorTestEnable << 3)
                | ((int)CullMode << 1)
                | ((int)FillMode);

            StateHash hash = new StateHash(
                0,
                packedProperties,
                FloatToInt32(DepthBias),
                FloatToInt32(SlopeScaleDepthBias)
                );

            RasterizerState newRasterizer;

            if (!rasterizerCache.TryGetValue(hash, out newRasterizer))
            {
                newRasterizer = new RasterizerState();

                newRasterizer.CullMode             = CullMode;
                newRasterizer.FillMode             = FillMode;
                newRasterizer.DepthBias            = DepthBias;
                newRasterizer.MultiSampleAntiAlias = MultiSampleAntiAlias;
                newRasterizer.ScissorTestEnable    = ScissorTestEnable;
                newRasterizer.SlopeScaleDepthBias  = SlopeScaleDepthBias;

                rasterizerCache.Add(hash, newRasterizer);
#if VERBOSE_PIPELINECACHE
                FNALoggerEXT.LogInfo("New RasterizerState added to pipeline cache with hash:\n"
                                     + hash.ToString());
                FNALoggerEXT.LogInfo("Updated size of RasterizerState cache: "
                                     + rasterizerCache.Count);
            }
            else
            {
                FNALoggerEXT.LogInfo("Retrieved RasterizerState from pipeline cache with hash:\n"
                                     + hash.ToString());
#endif
            }

            device.RasterizerState = newRasterizer;
        }
コード例 #7
0
ファイル: PipelineCache.cs プロジェクト: kiates/FNA
        public void EndApplySampler(SamplerStateCollection samplers, int register)
        {
            StateHash hash = GetSamplerHash(
                AddressU,
                AddressV,
                AddressW,
                MaxAnisotropy,
                MaxMipLevel,
                MipMapLODBias,
                Filter
                );
            SamplerState newSampler;

            if (!samplerCache.TryGetValue(hash, out newSampler))
            {
                newSampler = new SamplerState();

                newSampler.Filter                  = Filter;
                newSampler.AddressU                = AddressU;
                newSampler.AddressV                = AddressV;
                newSampler.AddressW                = AddressW;
                newSampler.MaxAnisotropy           = MaxAnisotropy;
                newSampler.MaxMipLevel             = MaxMipLevel;
                newSampler.MipMapLevelOfDetailBias = MipMapLODBias;

                samplerCache.Add(hash, newSampler);
#if VERBOSE_PIPELINECACHE
                FNALoggerEXT.LogInfo(
                    "New SamplerState added to pipeline cache with hash:\n" +
                    hash.ToString()
                    );
                FNALoggerEXT.LogInfo(
                    "Updated size of SamplerState cache: " +
                    samplerCache.Count
                    );
            }
            else
            {
                FNALoggerEXT.LogInfo(
                    "Retrieved SamplerState from pipeline cache with hash:\n" +
                    hash.ToString()
                    );
#endif
            }

            samplers[register] = newSampler;
        }
コード例 #8
0
ファイル: PipelineCache.cs プロジェクト: kiates/FNA
        public void EndApplyRasterizer()
        {
            StateHash hash = GetRasterizerHash(
                CullMode,
                FillMode,
                DepthBias,
                MultiSampleAntiAlias,
                ScissorTestEnable,
                SlopeScaleDepthBias
                );
            RasterizerState newRasterizer;

            if (!rasterizerCache.TryGetValue(hash, out newRasterizer))
            {
                newRasterizer = new RasterizerState();

                newRasterizer.CullMode             = CullMode;
                newRasterizer.FillMode             = FillMode;
                newRasterizer.DepthBias            = DepthBias;
                newRasterizer.MultiSampleAntiAlias = MultiSampleAntiAlias;
                newRasterizer.ScissorTestEnable    = ScissorTestEnable;
                newRasterizer.SlopeScaleDepthBias  = SlopeScaleDepthBias;

                rasterizerCache.Add(hash, newRasterizer);
#if VERBOSE_PIPELINECACHE
                FNALoggerEXT.LogInfo(
                    "New RasterizerState added to pipeline cache with hash:\n" +
                    hash.ToString()
                    );
                FNALoggerEXT.LogInfo(
                    "Updated size of RasterizerState cache: " +
                    rasterizerCache.Count
                    );
            }
            else
            {
                FNALoggerEXT.LogInfo(
                    "Retrieved RasterizerState from pipeline cache with hash:\n" +
                    hash.ToString()
                    );
#endif
            }

            device.RasterizerState = newRasterizer;
        }
コード例 #9
0
        public void EndApplyDepthStencil()
        {
            // Bool -> Int32 conversion
            int depthBufferEnable      = DepthBufferEnable ? 1 : 0;
            int depthBufferWriteEnable = DepthBufferWriteEnable ? 1 : 0;
            int stencilEnable          = StencilEnable ? 1 : 0;
            int twoSidedStencilMode    = TwoSidedStencilMode ? 1 : 0;

            int packedProperties =
                ((int)depthBufferEnable << 32 - 2)
                | ((int)depthBufferWriteEnable << 32 - 3)
                | ((int)stencilEnable << 32 - 4)
                | ((int)twoSidedStencilMode << 32 - 5)
                | ((int)DepthBufferFunction << 32 - 8)
                | ((int)StencilFunction << 32 - 11)
                | ((int)CCWStencilFunction << 32 - 14)
                | ((int)StencilPass << 32 - 17)
                | ((int)StencilFail << 32 - 20)
                | ((int)StencilDepthBufferFail << 32 - 23)
                | ((int)CCWStencilFail << 32 - 26)
                | ((int)CCWStencilPass << 32 - 29)
                | ((int)CCWStencilDepthBufferFail);

            StateHash hash = new StateHash(
                packedProperties,
                StencilMask,
                StencilWriteMask,
                ReferenceStencil
                );

            DepthStencilState newDepthStencil;

            if (!depthStencilCache.TryGetValue(hash, out newDepthStencil))
            {
                newDepthStencil = new DepthStencilState();

                newDepthStencil.DepthBufferEnable                      = DepthBufferEnable;
                newDepthStencil.DepthBufferWriteEnable                 = DepthBufferWriteEnable;
                newDepthStencil.DepthBufferFunction                    = DepthBufferFunction;
                newDepthStencil.StencilEnable                          = StencilEnable;
                newDepthStencil.StencilFunction                        = StencilFunction;
                newDepthStencil.StencilPass                            = StencilPass;
                newDepthStencil.StencilFail                            = StencilFail;
                newDepthStencil.StencilDepthBufferFail                 = StencilDepthBufferFail;
                newDepthStencil.TwoSidedStencilMode                    = TwoSidedStencilMode;
                newDepthStencil.CounterClockwiseStencilFunction        = CCWStencilFunction;
                newDepthStencil.CounterClockwiseStencilFail            = CCWStencilFail;
                newDepthStencil.CounterClockwiseStencilPass            = CCWStencilPass;
                newDepthStencil.CounterClockwiseStencilDepthBufferFail = CCWStencilDepthBufferFail;
                newDepthStencil.StencilMask                            = StencilMask;
                newDepthStencil.StencilWriteMask                       = StencilWriteMask;
                newDepthStencil.ReferenceStencil                       = ReferenceStencil;

                depthStencilCache.Add(hash, newDepthStencil);
#if VERBOSE_PIPELINECACHE
                FNALoggerEXT.LogInfo("New DepthStencilState added to pipeline cache with hash:\n"
                                     + hash.ToString());
                FNALoggerEXT.LogInfo("Updated size of DepthStencilState cache: "
                                     + depthStencilCache.Count);
            }
            else
            {
                FNALoggerEXT.LogInfo("Retrieved DepthStencilState from pipeline cache with hash:\n"
                                     + hash.ToString());
#endif
            }

            device.DepthStencilState = newDepthStencil;
        }
コード例 #10
0
        public void Play(Video video)
        {
            checkDisposed();

            // We need to assign this regardless of what happens next.
            Video = video;
            Video.AttachedToPlayer = true;

            // FIXME: This is a part of the Duration hack!
            if (Video.needsDurationHack)
            {
                Video.Duration = TimeSpan.MaxValue;
            }

            // Check the player state before attempting anything.
            if (State != MediaState.Stopped)
            {
                return;
            }

            // Update the player state now, before initializing
            State = MediaState.Playing;

            // Hook up the decoder to this player
            InitializeTheoraStream();

            // Set up the texture data
            if (TheoraPlay.THEORAPLAY_hasVideoStream(Video.theoraDecoder) != 0)
            {
                // The VideoPlayer will use the GraphicsDevice that is set now.
                if (currentDevice != Video.GraphicsDevice)
                {
                    GL_dispose();
                    currentDevice = Video.GraphicsDevice;
                    GL_initialize();
                }

                RenderTargetBinding overlap = videoTexture[0];
                videoTexture[0] = new RenderTargetBinding(
                    new RenderTarget2D(
                        currentDevice,
                        (int)currentVideo.width,
                        (int)currentVideo.height,
                        false,
                        SurfaceFormat.Color,
                        DepthFormat.None,
                        0,
                        RenderTargetUsage.PreserveContents
                        )
                    );
                if (overlap.RenderTarget != null)
                {
                    overlap.RenderTarget.Dispose();
                }
                GL_setupTextures(
                    (int)currentVideo.width,
                    (int)currentVideo.height
                    );
            }

            // The player can finally start now!
            FNALoggerEXT.LogInfo("Starting Theora player...");
            timer.Start();
            if (audioStream != null)
            {
                audioStream.Play();
            }
            FNALoggerEXT.LogInfo("Started!");
        }
コード例 #11
0
ファイル: PipelineCache.cs プロジェクト: kiates/FNA
        public void EndApplyDepthStencil()
        {
            StateHash hash = GetDepthStencilHash(
                DepthBufferEnable,
                DepthBufferWriteEnable,
                DepthBufferFunction,
                StencilEnable,
                StencilFunction,
                StencilPass,
                StencilFail,
                StencilDepthBufferFail,
                TwoSidedStencilMode,
                CCWStencilFunction,
                CCWStencilPass,
                CCWStencilFail,
                CCWStencilDepthBufferFail,
                StencilMask,
                StencilWriteMask,
                ReferenceStencil
                );
            DepthStencilState newDepthStencil;

            if (!depthStencilCache.TryGetValue(hash, out newDepthStencil))
            {
                newDepthStencil = new DepthStencilState();

                newDepthStencil.DepthBufferEnable                      = DepthBufferEnable;
                newDepthStencil.DepthBufferWriteEnable                 = DepthBufferWriteEnable;
                newDepthStencil.DepthBufferFunction                    = DepthBufferFunction;
                newDepthStencil.StencilEnable                          = StencilEnable;
                newDepthStencil.StencilFunction                        = StencilFunction;
                newDepthStencil.StencilPass                            = StencilPass;
                newDepthStencil.StencilFail                            = StencilFail;
                newDepthStencil.StencilDepthBufferFail                 = StencilDepthBufferFail;
                newDepthStencil.TwoSidedStencilMode                    = TwoSidedStencilMode;
                newDepthStencil.CounterClockwiseStencilFunction        = CCWStencilFunction;
                newDepthStencil.CounterClockwiseStencilFail            = CCWStencilFail;
                newDepthStencil.CounterClockwiseStencilPass            = CCWStencilPass;
                newDepthStencil.CounterClockwiseStencilDepthBufferFail = CCWStencilDepthBufferFail;
                newDepthStencil.StencilMask                            = StencilMask;
                newDepthStencil.StencilWriteMask                       = StencilWriteMask;
                newDepthStencil.ReferenceStencil                       = ReferenceStencil;

                depthStencilCache.Add(hash, newDepthStencil);
#if VERBOSE_PIPELINECACHE
                FNALoggerEXT.LogInfo(
                    "New DepthStencilState added to pipeline cache with hash:\n" +
                    hash.ToString()
                    );
                FNALoggerEXT.LogInfo(
                    "Updated size of DepthStencilState cache: " +
                    depthStencilCache.Count
                    );
            }
            else
            {
                FNALoggerEXT.LogInfo(
                    "Retrieved DepthStencilState from pipeline cache with hash:\n" +
                    hash.ToString()
                    );
#endif
            }

            device.DepthStencilState = newDepthStencil;
        }