unsafe internal override bool OnInit() { NativeLibraryManager.PreLoadLibrary("NeoAxisCoreNative"); try { //void* directInputTemp; //GUID iidDirectInput = DInput.IID_IDirectInput8W; //int hr = DInput.DirectInput8Create( ref iidDirectInput, out directInputTemp ); //if( global::DirectInput.Wrapper.FAILED( hr ) ) //{ // Log.Warning( "WindowsInputDeviceManager: DirectInput8Create failed." ); // return false; //} //directInput = (IDirectInput*)directInputTemp; if (!CreateDevices()) { return(false); } } catch { return(false); } return(true); }
// public static void LoadNativeLibrary() { if (!loadedNativeLibrary) { NativeLibraryManager.PreLoadLibrary("FbxWrapperNative"); loadedNativeLibrary = true; } }
static void LoadNativeLibrary() { if (!nativeLibraryLoaded) { NativeLibraryManager.PreLoadLibrary(library); nativeLibraryLoaded = true; } }
/////////////////////////////////////////// static void PreloadNativeDLL() { if (!nativeDllIsPreloaded) { NativeLibraryManager.PreLoadLibrary(Wrapper.library); nativeDllIsPreloaded = true; } }
/////////////////////////////////////////// unsafe public static bool Init(IntPtr windowHandle, IDirectInput *alreadyCreatedDirectInput) { if (instance != null) { Log.Fatal("SystemMouseDevice.Init: instance != null."); return(false); } NativeLibraryManager.PreLoadLibrary("NeoAxisCoreNative"); instance = new DirectInputMouseDevice(); if (!instance.InitInternal(windowHandle, alreadyCreatedDirectInput)) { Shutdown(); return(false); } return(true); }
protected override bool OnInitLibrary(bool allowHardwareAcceleration, bool editor) { instance = this; NativeLibraryManager.PreLoadLibrary("ode"); //int maxIterationCount = 20; //int hashSpaceMinLevel = 2;// 2^2 = 4 minimum cell size //int hashSpaceMaxLevel = 8;// 2^8 = 256 maximum cell size if (VirtualFile.Exists("Base/Constants/PhysicsSystem.config")) { TextBlock block = TextBlockUtils.LoadFromVirtualFile("Base/Constants/PhysicsSystem.config"); if (block != null) { TextBlock odeBlock = block.FindChild("odeSpecific"); if (odeBlock != null) { if (odeBlock.IsAttributeExist("maxIterationCount")) { defaultMaxIterationCount = int.Parse(odeBlock.GetAttribute("maxIterationCount")); } if (odeBlock.IsAttributeExist("hashSpaceMinLevel")) { hashSpaceMinLevel = int.Parse(odeBlock.GetAttribute("hashSpaceMinLevel")); } if (odeBlock.IsAttributeExist("hashSpaceMaxLevel")) { hashSpaceMaxLevel = int.Parse(odeBlock.GetAttribute("hashSpaceMaxLevel")); } } } } Ode.dInitODE2(0); return(true); }
protected override bool InitLibrary(IntPtr mainWindowHandle, int maxReal2DChannels, int maxReal3DChannels) { //NativeLibraryManager.PreLoadLibrary( "libogg" ); //NativeLibraryManager.PreLoadLibrary( "libvorbis" ); //NativeLibraryManager.PreLoadLibrary( "libvorbisfile" ); //preload dlls { var fileNames = new List <string>(); if (SystemSettings.CurrentPlatform == SystemSettings.Platform.Windows) { fileNames.Add("OpenAL32.dll"); } else if (SystemSettings.CurrentPlatform == SystemSettings.Platform.UWP) { fileNames.Add("SDL2.dll"); fileNames.Add("OpenAL32.dll"); } else if (SystemSettings.CurrentPlatform == SystemSettings.Platform.MacOS) { fileNames.Add("OpenAL32.dylib"); } else if (SystemSettings.CurrentPlatform == SystemSettings.Platform.Android) { //fileNames.Add( "libOpenAL.so" ); } else { Log.Fatal("OpenALSoundWorld: InitLibrary: Unknown platform."); return(false); } foreach (var fileName in fileNames) { var path = Path.Combine(VirtualFileSystem.Directories.PlatformSpecific, fileName); if (File.Exists(path)) { NativeLibraryManager.PreLoadLibrary(fileName); } } } criticalSection = CriticalSection.Create(); //if( PlatformInfo.Platform == PlatformInfo.Platforms.Android ) //{ // Alc.alcSetJNIEnvironmentAndJavaVM( // EngineApp.Instance._CallCustomPlatformSpecificMethod( "GetJNIEnvironment", IntPtr.Zero ), // EngineApp.Instance._CallCustomPlatformSpecificMethod( "GetJavaVM", IntPtr.Zero ) ); //} //string[] devices = Alc.alcGetStringv( IntPtr.Zero, Alc.ALC_DEVICE_SPECIFIER ); try { alDevice = Alc.alcOpenDevice(null); } catch (DllNotFoundException) { Log.InvisibleInfo("OpenALSoundSystem: OpenAL not found."); return(false); } catch (Exception e) { Log.InvisibleInfo("OpenALSoundSystem: Open device failed. " + e.Message); return(false); } if (alDevice == IntPtr.Zero) { Log.InvisibleInfo("OpenALSoundSystem: No sound driver."); return(false); } alContext = Alc.alcCreateContext(alDevice, IntPtr.Zero); if (alContext == IntPtr.Zero) { Log.Error("OpenALSoundSystem: Create context failed."); return(false); } try { Alc.alcMakeContextCurrent(alContext); } catch (Exception e) { Log.InvisibleInfo("OpenALSoundSystem: alcMakeContextCurrent failed. " + e.Message); return(false); } if (CheckError()) { return(false); } //get captureDeviceName try { captureDeviceName = Alc.alcGetString(alDevice, Alc.ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER); } catch { } //Channels realChannels = new List <OpenALRealChannel>(); for (int n = 0; n < maxReal2DChannels; n++) { OpenALRealChannel realChannel = new OpenALRealChannel(); AddRealChannel(realChannel, false); realChannels.Add(realChannel); } for (int n = 0; n < maxReal3DChannels; n++) { OpenALRealChannel realChannel = new OpenALRealChannel(); AddRealChannel(realChannel, true); realChannels.Add(realChannel); } fileStreamRealChannels = new List <OpenALRealChannel>(); thread = new Thread(new ThreadStart(ThreadFunction)); try { if (SystemSettings.CurrentPlatform != SystemSettings.Platform.UWP) { thread.CurrentCulture = new System.Globalization.CultureInfo("en-US"); } } catch { } thread.IsBackground = true; thread.Start(); hWnd = mainWindowHandle; Al.alDistanceModel(Al.AL_NONE); return(true); }
unsafe protected override bool InitLibrary(IntPtr mainWindowHandle, int maxReal2DChannels, int maxReal3DChannels) { NativeLibraryManager.PreLoadLibrary("libogg"); NativeLibraryManager.PreLoadLibrary("libvorbis"); NativeLibraryManager.PreLoadLibrary("libvorbisfile"); NativeLibraryManager.PreLoadLibrary("DirectSoundNativeWrapper"); { DSoundStructureSizes sizes = new DSoundStructureSizes(); sizes.Init(); DSoundStructureSizes originalSizes; DSound.GetStructureSizes(out originalSizes); FieldInfo[] fields = sizes.GetType().GetFields( BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public); foreach (FieldInfo field in fields) { int originalSize = (int)field.GetValue(originalSizes); int size = (int)field.GetValue(sizes); if (originalSize != size) { Log.Fatal("DirectXSoundSystem: Invalid unmanaged bridge. " + "Invalid \"{0}\". Native size = \"{1}\". Managed size = \"{2}\".", field.Name, originalSize, size); return(false); } } } instance = this; criticalSection = CriticalSection.Create(); DSound.CoInitialize(null); int hr; //create IDirectSound using the primary sound device void */*IDirectSound8*/ directSoundTemp; hr = DSound.DirectSoundCreate8(null, out directSoundTemp, null); if (Wrapper.FAILED(hr)) { if (hr == DSound.Get_DSERR_NODRIVER()) { Log.InvisibleInfo("DirectXSoundSystem: No sound driver."); return(false); } Error("DirectSoundCreate8", hr); return(false); } directSound = (IDirectSound8 *)directSoundTemp; //set DirectSound cooperative level hWnd = mainWindowHandle; hr = IDirectSound8.SetCooperativeLevel(directSound, hWnd, DSound.DSSCL_PRIORITY); if (Wrapper.FAILED(hr)) { Error("SetCooperativeLevel", hr); return(false); } //set primary buffer format { hr = SetPrimaryBufferFormat(2, 44100, 16, false); if (Wrapper.FAILED(hr)) { hr = SetPrimaryBufferFormat(2, 22050, 16, true); } if (Wrapper.FAILED(hr)) { return(false); } } //get listener { void */*IDirectSoundBuffer*/ primaryBuffer = null; // Obtain primary buffer, asking it for 3D control DSBUFFERDESC bufferDesc = new DSBUFFERDESC(); //ZeroMemory( &bufferDesc, sizeof( DSBUFFERDESC ) ); bufferDesc.dwSize = (uint)sizeof(DSBUFFERDESC); bufferDesc.dwFlags = DSound.DSBCAPS_CTRL3D | DSound.DSBCAPS_PRIMARYBUFFER; hr = IDirectSound8.CreateSoundBuffer(directSound, ref bufferDesc, out primaryBuffer, null); if (Wrapper.FAILED(hr)) { Error("CreateSoundBuffer", hr); return(false); } void */*IDirectSound3DListener*/ listenerTemp = null; GUID guid = DSound.IID_IDirectSound3DListener; if (Wrapper.FAILED(hr = IDirectSoundBuffer.QueryInterface(primaryBuffer, ref guid, &listenerTemp))) { IDirectSoundBuffer.Release(primaryBuffer); Error("QueryInterface", hr); return(false); } listener = (IDirectSound3DListener *)listenerTemp; IDirectSoundBuffer.Release(primaryBuffer); } //update general parameters { DS3DLISTENER parameters = new DS3DLISTENER(); parameters.dwSize = (uint)sizeof(DS3DLISTENER); IDirectSound3DListener.GetAllParameters(listener, ref parameters); parameters.flDistanceFactor = 1; parameters.flRolloffFactor = 0; parameters.flDopplerFactor = DopplerScale; hr = IDirectSound3DListener.SetAllParameters(listener, ref parameters, DSound.DS3D_IMMEDIATE); if (Wrapper.FAILED(hr)) { Warning("IDirectSound3DListener.SetAllParameters", hr); } } GenerateRecordDriverList(); //Channels realChannels = new List <DirectSoundRealChannel>(); for (int n = 0; n < maxReal2DChannels; n++) { DirectSoundRealChannel realChannel = new DirectSoundRealChannel(); AddRealChannel(realChannel, false); realChannels.Add(realChannel); } for (int n = 0; n < maxReal3DChannels; n++) { DirectSoundRealChannel realChannel = new DirectSoundRealChannel(); AddRealChannel(realChannel, true); realChannels.Add(realChannel); } fileStreamRealChannels = new List <DirectSoundRealChannel>(); thread = new Thread(new ThreadStart(ThreadFunction)); thread.CurrentCulture = new System.Globalization.CultureInfo("en-US"); thread.IsBackground = true; thread.Start(); return(true); }
static void InitializeCefRuntime() { if (cefRuntimeUnableToLoad) { return; } if (!IsSupportedByThisPlatform()) { return; } if (cefRuntimeInitialized) { throw new InvalidOperationException("The CefRuntime is already initialized. Call ShutdownCefRuntime() before initializing it again."); } //load native libraries { if (PlatformInfo.Platform == PlatformInfo.Platforms.Windows) { try { string error = NativeLibraryManager.PreLoadLibrary(Path.Combine("CefGlue", "libcef"), true); if (!string.IsNullOrEmpty(error)) { cefRuntimeUnableToLoad = true; cefRuntimeUnableToLoadError = error; } } catch { cefRuntimeUnableToLoad = true; cefRuntimeUnableToLoadError = "Crash inside NativeLibraryManager.PreLoadLibrary."; } } } //delete log file string realLogFileName = VirtualFileSystem.GetRealPathByVirtual("user:Logs\\WebBrowserControl_CefGlue.log"); try { if (File.Exists(realLogFileName)) { File.Delete(realLogFileName); } } catch { } if (!cefRuntimeUnableToLoad) { try { CefRuntime.Load(); } catch (DllNotFoundException ex) { Log.Error("WebBrowserControl: InitializeCefRuntime: CefRuntime.Load(): " + ex.Message); return; } catch (CefRuntimeException ex) { Log.Error("WebBrowserControl: InitializeCefRuntime: CefRuntime.Load(): " + ex.Message); return; } catch (Exception ex) { Log.Error("WebBrowserControl: InitializeCefRuntime: CefRuntime.Load(): " + ex.Message); return; } var mainArgs = new CefMainArgs(null); var cefApp = new SimpleApp(); var exitCode = CefRuntime.ExecuteProcess(mainArgs, cefApp, IntPtr.Zero); if (exitCode != -1) { Log.Error("WebBrowserControl: InitializeCefRuntime: CefRuntime.ExecuteProcess: Exit code: {0}", exitCode); return; } var cefSettings = new CefSettings { SingleProcess = true, WindowlessRenderingEnabled = true, MultiThreadedMessageLoop = true, LogSeverity = CefLogSeverity.Verbose, LogFile = realLogFileName, BrowserSubprocessPath = "", CachePath = "", }; ///// <summary> ///// Set to <c>true</c> to disable configuration of browser process features using ///// standard CEF and Chromium command-line arguments. Configuration can still ///// be specified using CEF data structures or via the ///// CefApp::OnBeforeCommandLineProcessing() method. ///// </summary> //public bool CommandLineArgsDisabled { get; set; } ///// <summary> ///// The fully qualified path for the resources directory. If this value is ///// empty the cef.pak and/or devtools_resources.pak files must be located in ///// the module directory on Windows/Linux or the app bundle Resources directory ///// on Mac OS X. Also configurable using the "resources-dir-path" command-line ///// switch. ///// </summary> //public string ResourcesDirPath { get; set; } try { CefRuntime.Initialize(mainArgs, cefSettings, cefApp, IntPtr.Zero); } catch (CefRuntimeException ex) { Log.Error("WebBrowserControl: InitializeCefRuntime: CefRuntime.Initialize: " + ex.Message); return; } cefRuntimeInitialized = true; if (!subscribedToEngineAppDestroy) { subscribedToEngineAppDestroy = true; EngineApp.DestroyEvent += EngineApp_DestroyEvent; } } }
//static NxAssertResponse ReportAssertViolation( IntPtr pMessage, IntPtr pFile, int line ) //{ // string message = Wrapper.GetOutString( pMessage ); // string file = Wrapper.GetOutString( pFile ); // if( file == null ) // file = "NULL"; // string text = string.Format( "PhysXPhysicsSystem: {0} ({1}:{2})", message, file, line ); // Log.Fatal( text ); // return NxAssertResponse.NX_AR_BREAKPOINT; //} protected override bool OnInitLibrary(bool allowHardwareAcceleration, bool editor) { instance = this; NativeLibraryManager.PreLoadLibrary("PhysXNativeWrapper"); //change current directory for loading PhysX dlls from specified NativeDlls directory. string saveCurrentDirectory = null; if (PlatformInfo.Platform == PlatformInfo.Platforms.Windows) { saveCurrentDirectory = Directory.GetCurrentDirectory(); Directory.SetCurrentDirectory(NativeLibraryManager.GetNativeLibrariesDirectory()); } try { preventLogErrors = true; reportErrorDelegate = ReportError; logDelegate = LogMessage; IntPtr errorStringPtr; if (!PhysXNativeWorld.Init(reportErrorDelegate, out errorStringPtr, logDelegate, skinWidth)) { string errorString = Wrapper.GetOutString(errorStringPtr); if (string.IsNullOrEmpty(errorString)) { errorString = "Unknown error."; } Log.Fatal("PhysX: Initialization error: " + errorString); return(false); } preventLogErrors = false; } finally { //restore current directory if (PlatformInfo.Platform == PlatformInfo.Platforms.Windows) { Directory.SetCurrentDirectory(saveCurrentDirectory); } } //configs if (VirtualFile.Exists("Base/Constants/PhysicsSystem.config")) { TextBlock block = TextBlockUtils.LoadFromVirtualFile("Base/Constants/PhysicsSystem.config"); if (block != null) { TextBlock physXBlock = block.FindChild("physXSpecific"); if (physXBlock != null) { if (physXBlock.IsAttributeExist("supportHeightFields")) { supportHeightFields = bool.Parse(physXBlock.GetAttribute("supportHeightFields")); } if (physXBlock.IsAttributeExist("supportVehicles")) { supportVehicles = bool.Parse(physXBlock.GetAttribute("supportVehicles")); } if (physXBlock.IsAttributeExist("writeCacheForCookedTriangleMeshes")) { writeCacheForCookedTriangleMeshes = bool.Parse( physXBlock.GetAttribute("writeCacheForCookedTriangleMeshes")); } if (physXBlock.IsAttributeExist("mainSceneMaxThreads")) { mainSceneMaxThreads = int.Parse(physXBlock.GetAttribute("mainSceneMaxThreads")); } } } } return(true); }