static void LoadUtilsNativeWrapperLibrary() { if (!utilsNativeWrapperLibraryLoaded) { utilsNativeWrapperLibraryLoaded = true; NativeLibraryManager.PreLoadLibrary("NeoAxisCoreNative"); } }
///////////////////////////////////////// internal static void LoadUtilsNativeWrapperLibrary() { if (!nativeWrapperLibraryLoaded) { nativeWrapperLibraryLoaded = true; NativeLibraryManager.PreLoadLibrary(library); } }
static void LoadNeoAxisProprietaryLibrary() { if (!neoAxisProprietaryLibraryLoaded) { neoAxisProprietaryLibraryLoaded = true; NativeLibraryManager.PreLoadLibrary(OgreWrapper.library); } }
internal static void NativeDLLsPreload() { if (!nativeDLLsPreloaded) { NativeLibraryManager.PreLoadLibrary("NeoAxisCoreNative"); NativeLibraryManager.PreLoadLibrary(SharpBgfx.NativeMethods.DllName); nativeDLLsPreloaded = true; } }
public static bool Init(string logFileName, bool setCurrentDirectory, string projectDirectory, string userSettingsDirectory, string overrideBinariesDirectory = null) { if (initialized) { Log.Fatal("VirtualFileSystem: Init: File system is already initialized."); return(false); } //it can be already started StartupTiming.TotalStart(); StartupTiming.CounterStart("Initialize virtual file system"); try { mainThread = Thread.CurrentThread; //init directories { if (string.IsNullOrEmpty(projectDirectory)) { Log.Fatal("VirtualFileSystem: Init: Project directory must be specified."); } if (!Directory.Exists(projectDirectory)) { Log.Fatal("VirtualFileSystem: Init: Specified project directory is not exists."); } projectDirectory = VirtualPathUtility.NormalizePath(projectDirectory); Directories.project = projectDirectory; if (!Path.IsPathRooted(Directories.project)) { Log.Fatal("VirtualFileSystem: Init: Project directory path must be rooted."); return(false); } Directories.assets = Path.Combine(Directories.project, "Assets"); if (string.IsNullOrEmpty(Directories.assets)) { Log.Fatal("VirtualFileSystem: Init: Project Assets directory must be specified."); } if (!Directory.Exists(Directories.assets)) { Log.Fatal("VirtualFileSystem: Init: Specified project Assets directory is not exists."); } if (string.IsNullOrEmpty(userSettingsDirectory)) { Log.Fatal("VirtualFileSystem: Init: User settings directory must be specified."); } if (!Path.IsPathRooted(userSettingsDirectory)) { Log.Fatal("VirtualFileSystem: Init: User settings directory path must be rooted."); return(false); } //if( !Directory.Exists( userSettingsDirectory ) ) // Log.Fatal( "VirtualFileSystem: Init: Specified User settijngs directory is not exists." ); userSettingsDirectory = VirtualPathUtility.NormalizePath(userSettingsDirectory); Directories.userSettings = userSettingsDirectory; if (!string.IsNullOrEmpty(overrideBinariesDirectory) && !Directory.Exists(overrideBinariesDirectory)) { Log.Fatal("VirtualFileSystem: Init: Specified binaries directory is not exists."); } if (string.IsNullOrEmpty(overrideBinariesDirectory)) { Directories.binaries = PlatformSpecificUtility.Instance.GetExecutableDirectoryPath(); } else { Directories.binaries = overrideBinariesDirectory; } Directories.binaries = VirtualPathUtility.NormalizePath(Directories.binaries); if (!Path.IsPathRooted(Directories.binaries)) { Log.Fatal("VirtualFileSystem: Init: Executables directory path must be rooted."); return(false); } //// UWP works with relative paths. // should Directories.engineInternal and Directories.platformSpecific be relative for UWP ? //if( SystemSettings.CurrentPlatform == SystemSettings.Platform.UWP ) // Directories.engineInternal = "NeoAxis.Internal"; //else Directories.engineInternal = Path.Combine(Directories.binaries, "NeoAxis.Internal"); Directories.platformSpecific = Path.Combine(Directories.engineInternal, Path.Combine("Platforms", SystemSettings.CurrentPlatform.ToString())); //!!!! //!!!!ARM if (SystemSettings.CurrentPlatform == SystemSettings.Platform.UWP) { Directories.platformSpecific = Path.Combine(Directories.platformSpecific, "x64"); } } //!!!!new CultureInfo.CurrentCulture = new CultureInfo("en-US"); try { //!!!! deprecated. use CultureInfo.CurrentCulture https://github.com/dotnet/platform-compat/blob/master/docs/DE0008.md Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US"); } catch { } AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve; //bool monoRuntime = Type.GetType( "Mono.Runtime", false ) != null; //if( monoRuntime ) // AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve; if (setCurrentDirectory) { CorrectCurrentDirectory(); } if (EngineApp.ApplicationType == EngineApp.ApplicationTypeEnum.Editor) { Editor.PackageManager.DeleteFilesAsStartup(); } NativeLibraryManager.PreLoadLibrary("NeoAxisCoreNative"); InitDefaultSettingsConfig(); ArchiveManager.Init(); //if( !ArchiveManager.Init() ) //{ // //ArchiveManager.Shutdown(); // return false; //} initialized = true; //InitDeploymentInfoAndUserDirectory(); string realPath = null; if (!string.IsNullOrEmpty(logFileName)) { realPath = VirtualPathUtility.GetRealPathByVirtual(logFileName); } Log.Init(Thread.CurrentThread, realPath); //!!!! //InitFileTypesThatCanBeCached(); ResourceManager.Init(); //RegisterAssemblies_IncludingFromDefaultSettingConfig(); ParseSettingsFromDefaultSettingsConfig(); //ResourceTypes.Init(); //!!!!тут? VirtualFileWatcher.Init(); ResourceUpdate.Init(); } finally { StartupTiming.CounterEnd("Initialize virtual file system"); } return(true); }
static void InitializeCefRuntime() { if (!IsSupportedByThisPlatform()) { return; } if (isCefRuntimeInitialized) { Log.Error("UIWebBrowser: InitializeCefRuntime: The CefRuntime is already initialized."); return; } if (SystemSettings.CurrentPlatform == SystemSettings.Platform.Windows) { NativeLibraryManager.PreLoadLibrary(Path.Combine("CefGlue", "libcef")); } //delete log file string realLogFileName = VirtualPathUtility.GetRealPathByVirtual("user:Logs\\UIWebBrowser_CefGlue.log"); try { if (File.Exists(realLogFileName)) { File.Delete(realLogFileName); } } catch { } try { CefRuntime.Load(); } catch (DllNotFoundException ex) { Log.Error("UIWebBrowser: InitializeCefRuntime: CefRuntime.Load: " + ex.Message); return; } catch (CefRuntimeException ex) { Log.Error("UIWebBrowser: InitializeCefRuntime: CefRuntime.Load: " + ex.Message); return; } catch (Exception ex) { Log.Error("UIWebBrowser: 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("UIWebBrowser: 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("UIWebBrowser: InitializeCefRuntime: CefRuntime.Initialize: " + ex.Message); return; } isCefRuntimeInitialized = true; }
//volatile static Dictionary<Type, Func<CollisionShape, Vector3>> centerOfMassDictionary; //!!!!delete //volatile static Dictionary<Type, Func<CollisionShape, double>> volumeDictionary; // internal static void InitLibrary() { NativeLibraryManager.PreLoadLibrary("libbulletc"); }
public static DDSImage GenerateDDS(byte[] rgba, Vector2I size, DDSImage.FormatEnum format, bool normalMap, bool generateMipmaps, out string error) { //!!!!может не инициализировать каждый раз NvidiaTextureTools.Compressor compressor = null; NvidiaTextureTools.InputOptions inputOptions = null; NvidiaTextureTools.CompressionOptions compressionOptions = null; NvidiaTextureTools.OutputOptions outputOptions = null; try { NativeLibraryManager.PreLoadLibrary("nvtt"); compressor = new NvidiaTextureTools.Compressor(); inputOptions = new NvidiaTextureTools.InputOptions(); compressionOptions = new NvidiaTextureTools.CompressionOptions(); outputOptions = new NvidiaTextureTools.OutputOptions(); inputOptions.SetTextureLayout(NvidiaTextureTools.TextureType.Texture2D, size.X, size.Y, 1); byte[] bgra = new byte[rgba.Length]; //bool containAlpha = false; { for (int y = 0; y < size.Y; y++) { for (int x = 0; x < size.X; x++) { int offset = (y * size.X + x) * 4; bgra[offset + 0] = rgba[offset + 2]; bgra[offset + 1] = rgba[offset + 1]; bgra[offset + 2] = rgba[offset + 0]; bgra[offset + 3] = rgba[offset + 3]; //byte alpha = bgra[ offset + 3 ]; //if( alpha != 255 ) // containAlpha = true; } } } unsafe { fixed(byte *pData = bgra) inputOptions.SetMipmapData((IntPtr)pData, size.X, size.Y, 1, 0, 0); } inputOptions.SetWrapMode(NvidiaTextureTools.WrapMode.Repeat); inputOptions.SetFormat(NvidiaTextureTools.InputFormat.BGRA_8UB); if (normalMap) { inputOptions.SetNormalMap(true); } inputOptions.SetMipmapGeneration(generateMipmaps); inputOptions.SetRoundMode(NvidiaTextureTools.RoundMode.ToNextPowerOfTwo); //sense? if (format == DDSImage.FormatEnum.DXT5) { inputOptions.SetAlphaMode(NvidiaTextureTools.AlphaMode.Transparency); } //if( containAlpha ) //{ // if( format == DDSImage.FormatEnum.DXT1 ) // inputOptions.SetAlphaMode( NvidiaTextureTools.AlphaMode.Premultiplied ); // else // inputOptions.SetAlphaMode( NvidiaTextureTools.AlphaMode.Transparency ); //} //else // inputOptions.SetAlphaMode( NvidiaTextureTools.AlphaMode.None ); //inputOptions.SetNormalMap( format == DDSImage.FormatTypes._3DC ); //inputOptions.SetNormalMap( true ); //inputOptions.SetConvertToNormalMap( true ); //public void SetHeightEvaluation(float redScale, float greenScale, float blueScale, float alphaScale) //public void SetNormalFilter(float small, float medium, float big, float large) //inputOptions.SetNormalizeMipmaps( true ); //public void SetColorTransform(ColorTransform t); //public void SetLinearTransfrom(int channel, float w0, float w1, float w2, float w3) switch (format) { case DDSImage.FormatEnum.DXT1: compressionOptions.SetFormat(NvidiaTextureTools.Format.DXT1a); //compressionOptions.SetFormat( containAlpha ? NvidiaTextureTools.Format.DXT1a : NvidiaTextureTools.Format.DXT1 ); break; case DDSImage.FormatEnum.DXT3: compressionOptions.SetFormat(NvidiaTextureTools.Format.DXT3); break; case DDSImage.FormatEnum.DXT5: compressionOptions.SetFormat(NvidiaTextureTools.Format.DXT5); break; case DDSImage.FormatEnum.BC5: compressionOptions.SetFormat(NvidiaTextureTools.Format.BC5); break; case DDSImage.FormatEnum.R8G8B8: compressionOptions.SetFormat(NvidiaTextureTools.Format.RGB); break; case DDSImage.FormatEnum.A8R8G8B8: compressionOptions.SetFormat(NvidiaTextureTools.Format.RGBA); break; default: error = $"Format \'{format}\' is not supported."; break; } //!!!!зависает BC5 на Highest и Production if (format == DDSImage.FormatEnum.BC5) { compressionOptions.SetQuality(NvidiaTextureTools.Quality.Normal); } else { compressionOptions.SetQuality(NvidiaTextureTools.Quality.Highest); } //compressionOptions.SetQuality( NvidiaTextureTools.Quality.Production ); outputOptions.SetOutputHeader(false); outputOptions.SetOutputHandler(OutputOptions_BeginImage, OutputOptions_WriteData, OutputOptions_EndImage); generatingSurfaces = new List <DDSImage.Surface>(); if (!compressor.Compress(inputOptions, compressionOptions, outputOptions)) { error = "Compression failed."; return(null); } DDSImage.FormatEnum resultFormat = format; if (resultFormat == DDSImage.FormatEnum.R8G8B8) { resultFormat = DDSImage.FormatEnum.A8R8G8B8; } DDSImage ddsImage = new DDSImage(resultFormat, generatingSurfaces.ToArray(), false); error = ""; return(ddsImage); } catch (Exception e) { error = e.Message; return(null); } finally { generatingSurfaces = null; generatingSurfaceDataOffset = 0; inputOptions?.Dispose(); compressionOptions?.Dispose(); outputOptions?.Dispose(); compressor?.Dispose(); } }