コード例 #1
0
            private FAudioContext(IntPtr ctx, uint devices)
            {
                Handle = ctx;

                uint i;

                for (i = 0; i < devices; i += 1)
                {
                    FAudio.FAudio_GetDeviceDetails(
                        Handle,
                        i,
                        out DeviceDetails
                        );
                    if ((DeviceDetails.Role & FAudio.FAudioDeviceRole.FAudioDefaultGameDevice) == FAudio.FAudioDeviceRole.FAudioDefaultGameDevice)
                    {
                        break;
                    }
                }
                if (i == devices)
                {
                    i = 0;                     /* Oh well. */
                    FAudio.FAudio_GetDeviceDetails(
                        Handle,
                        i,
                        out DeviceDetails
                        );
                }
                if (FAudio.FAudio_CreateMasteringVoice(
                        Handle,
                        out MasterVoice,
                        FAudio.FAUDIO_DEFAULT_CHANNELS,
                        FAudio.FAUDIO_DEFAULT_SAMPLERATE,
                        0,
                        i,
                        IntPtr.Zero
                        ) != 0)
                {
                    FAudio.FAudio_Release(ctx);
                    Handle = IntPtr.Zero;
                    FNALoggerEXT.LogError(
                        "Failed to create mastering voice!"
                        );
                    return;
                }

                CurveDistanceScaler = 1.0f;
                DopplerScale        = 1.0f;
                SpeedOfSound        = 343.5f;
                Handle3D            = new byte[FAudio.F3DAUDIO_HANDLE_BYTESIZE];
                FAudio.F3DAudioInitialize(
                    DeviceDetails.OutputFormat.dwChannelMask,
                    SpeedOfSound,
                    Handle3D
                    );

                Context = this;
            }
コード例 #2
0
ファイル: OpenALDevice.cs プロジェクト: xiuzhifu/FNA
        private bool CheckALCError()
        {
            int err = ALC10.alcGetError(alDevice);

            if (err == ALC10.ALC_NO_ERROR)
            {
                return(false);
            }

            FNALoggerEXT.LogError("OpenAL Device Error: " + err.ToString("X4"));
            return(true);
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: qwq233/Hacknet-Modmgr
 public static void Write(string str)
 {
     Console.WriteLine(str);
     try
     {
         using (StreamWriter streamWriter = File.AppendText(filepath))
             streamWriter.WriteLine(str);
     }
     catch (Exception exception)
     {
         FNALoggerEXT.LogError(exception.ToString());
     }
 }
コード例 #4
0
ファイル: OpenALDevice.cs プロジェクト: xiuzhifu/FNA
        private void CheckALError()
        {
            int err = AL10.alGetError();

            if (err == AL10.AL_NO_ERROR)
            {
                return;
            }

            FNALoggerEXT.LogError("OpenAL Error: " + err.ToString("X4"));
#if VERBOSE_AL_DEBUGGING
            throw new InvalidOperationException("OpenAL Error!");
#endif
        }
コード例 #5
0
ファイル: Program.cs プロジェクト: qwq233/Hacknet-Modmgr
 public static void Clear()
 {
     if (File.Exists(filepath))
     {
         try
         {
             File.Delete(filepath);
             using (File.Create(filepath))
             {
             }
         }
         catch (Exception exception)
         {
             FNALoggerEXT.LogError(exception.ToString());
         }
     }
 }
コード例 #6
0
ファイル: Program.cs プロジェクト: qwq233/Hacknet-Modmgr
 public bool Invoke(string namespaceClassnameMethodname, out object result, object[] param = null, Type[] types = null)
 {
     result = null;
     try
     {
         MethodInfo methodInfo = FindMethod(namespaceClassnameMethodname, types);
         if (methodInfo != null)
         {
             result = methodInfo.Invoke(null, param);
             return(true);
         }
     }
     catch (Exception ex)
     {
         Logger.Error($"Error trying to call '{namespaceClassnameMethodname}'.");
         FNALoggerEXT.LogError(ex.ToString());
     }
     return(false);
 }
コード例 #7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GraphicsDevice" /> class.
        /// </summary>
        /// <param name="adapter">The graphics adapter.</param>
        /// <param name="graphicsProfile">The graphics profile.</param>
        /// <param name="presentationParameters">The presentation options.</param>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="presentationParameters"/> is <see langword="null"/>.
        /// </exception>
        public GraphicsDevice(
            GraphicsAdapter adapter,
            GraphicsProfile graphicsProfile,
            PresentationParameters presentationParameters
            )
        {
            if (presentationParameters == null)
            {
                throw new ArgumentNullException("presentationParameters");
            }

            // Set the properties from the constructor parameters.
            Adapter = adapter;
            PresentationParameters = presentationParameters;
            GraphicsProfile        = graphicsProfile;
            PresentationParameters.MultiSampleCount = MathHelper.ClosestMSAAPower(
                PresentationParameters.MultiSampleCount
                );

            // Set up the IGLDevice
            GLDevice = FNAPlatform.CreateGLDevice(PresentationParameters, adapter);

            // The mouse needs to know this for faux-backbuffer mouse scaling.
            Input.Mouse.INTERNAL_BackBufferWidth  = PresentationParameters.BackBufferWidth;
            Input.Mouse.INTERNAL_BackBufferHeight = PresentationParameters.BackBufferHeight;

            // The Touch Panel needs this too, for the same reason.
            Input.Touch.TouchPanel.DisplayWidth  = PresentationParameters.BackBufferWidth;
            Input.Touch.TouchPanel.DisplayHeight = PresentationParameters.BackBufferHeight;

            // Force set the default render states.
            BlendState        = BlendState.Opaque;
            DepthStencilState = DepthStencilState.Default;
            RasterizerState   = RasterizerState.CullCounterClockwise;

            // Initialize the Texture/Sampler state containers
            int maxTextures       = Math.Min(GLDevice.MaxTextureSlots, MAX_TEXTURE_SAMPLERS);
            int maxVertexTextures = MathHelper.Clamp(
                GLDevice.MaxTextureSlots - MAX_TEXTURE_SAMPLERS,
                0,
                MAX_VERTEXTEXTURE_SAMPLERS
                );

            vertexSamplerStart = GLDevice.MaxTextureSlots - maxVertexTextures;
            Textures           = new TextureCollection(
                maxTextures,
                modifiedSamplers
                );
            SamplerStates = new SamplerStateCollection(
                maxTextures,
                modifiedSamplers
                );
            VertexTextures = new TextureCollection(
                maxVertexTextures,
                modifiedVertexSamplers
                );
            VertexSamplerStates = new SamplerStateCollection(
                maxVertexTextures,
                modifiedVertexSamplers
                );

            // Set the default viewport and scissor rect.
            Viewport         = new Viewport(PresentationParameters.Bounds);
            ScissorRectangle = Viewport.Bounds;

            // Allocate the pipeline cache to be used by Effects
            PipelineCache = new PipelineCache(this);
#if WIIU_GAMEPAD
            wiiuStream = DRC.drc_new_streamer();
            if (wiiuStream == IntPtr.Zero)
            {
                FNALoggerEXT.LogError("Failed to alloc GamePad stream!");
                return;
            }
            if (DRC.drc_start_streamer(wiiuStream) < 1)             // ???
            {
                FNALoggerEXT.LogError("Failed to start GamePad stream!");
                DRC.drc_delete_streamer(wiiuStream);
                wiiuStream = IntPtr.Zero;
                return;
            }
            DRC.drc_enable_system_input_feeder(wiiuStream);
            wiiuPixelData = new byte[
                PresentationParameters.BackBufferWidth *
                PresentationParameters.BackBufferHeight *
                4
                            ];
#endif
        }