Example #1
0
        /// <summary>
        /// init game engine
        /// call it one time during startup on the UI thread.</summary>
        public static void Init()
        {
            s_syncContext        = SynchronizationContext.Current;
            s_invalidateCallback = new InvalidateViewsDlg(InvalidateViews);
            try
            {
                GUILayer.EngineDevice.SetDefaultWorkingDirectory();
                s_engineDevice = new GUILayer.EngineDevice();
                s_engineDevice.AttachDefaultCompilers();
                s_retainedRenderResources = new GUILayer.RetainedRenderResources(s_engineDevice);
                s_underlyingScene         = new GUILayer.EditorSceneManager();
                Util3D.Init();
                XLEBridgeUtils.Utils.GlobalSceneManager = s_underlyingScene;
                s_entityInterface = s_underlyingScene.GetEntityInterface();
                CriticalError     = "";
                s_inist.PopulateEngineInfo(
                    @"<EngineInfo>
                        <SupportedResources>
                            <ResourceDescriptor Type='Model' Name='Model' Description='Model' Ext='.dae' />
                            <ResourceDescriptor Type='ModelBookmark' Name='ModelBookmark' Description='ModelBookmark' Ext='.modelbookmark' />
                            <ResourceDescriptor Type='Texture' Name='Texture' Description='Texture' Ext='.dds,.tga,.bmp,.jpg,.jpeg,.png,.tif,.tiff,.gif,.hpd,.jxr,.wdp,.ico,.hdr,.exr' />
                            <ResourceDescriptor Type='Prefab' Name='Prefab' Description='Prefab' Ext='.prefab' />
                        </SupportedResources>
                    </EngineInfo>");

                XLEBridgeUtils.Utils.AttachLibrary(s_engineDevice);
                s_loggingRedirect = new XLEBridgeUtils.LoggingRedirect();

                s_foregroundUpdateTimer          = new System.Windows.Forms.Timer();
                s_foregroundUpdateTimer.Tick    += s_foregroundUpdateTimer_Elapsed;
                s_foregroundUpdateTimer.Interval = 32;
                s_foregroundUpdateTimer.Start();
            }
            catch (Exception e)
            {
                CriticalError = "Error while initialising engine device: " + e.Message;
            }
        }
Example #2
0
        /// <summary>
        /// init game engine 
        /// call it one time during startup on the UI thread.</summary>        
        public static void Init()
        {
            // the full dll name can be loaded in a config when needed.
            if (s_libHandle != IntPtr.Zero)
                return;

            CriticalError = s_notInitialized;
            try
            {
                Uri uri = new Uri(System.Windows.Forms.Application.StartupPath);
                string dllDir = uri.LocalPath + "\\NativePlugin";

                string dllName = "LvEdRenderingEngine.dll";

                if (IntPtr.Size == 4)
                {// 32 bit
                    s_fullDllName = dllDir + "\\x86\\" + dllName;
                }
                else if (IntPtr.Size == 8)
                {// 64 bit.
                    s_fullDllName = dllDir + "\\x64\\" + dllName;
                }
                else
                {
                    throw new Exception("unsupported address space");
                }

                if (!File.Exists(s_fullDllName))
                    throw new FileNotFoundException(s_fullDllName);

                s_libHandle = NativeMethods.LoadLibrary(s_fullDllName);
                if (s_libHandle == IntPtr.Zero)
                {
                    int hr = Marshal.GetHRForLastWin32Error();
                    Marshal.ThrowExceptionForHR(hr);
                }

                // verify entry points
                /*
                Type type = typeof(GameEngine);

                foreach (MethodInfo minfo in type.GetMethods(BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic))
                {                    
                    foreach( object obj in minfo.GetCustomAttributes(false))
                    {                        
                        DllImportAttribute dllimport = obj as DllImportAttribute;
                        if (dllimport != null)
                        {
                            string entryname = dllimport.EntryPoint;                                                        
                            // verify entry point name.
                            IntPtr fntPtr = NativeMethods.GetProcAddress(s_libHandle, entryname);
                            if (fntPtr == IntPtr.Zero)
                                throw new ArgumentException(string.Format("Can't find native function: {0}(...) in {1}", dllimport.EntryPoint, dllName));                            
                            break;
                        }
                    }                        
                }
                 */


                CriticalError = string.Empty;

                IntPtr data;
                s_invalidateCallback = new InvalidateViewsDlg(InvalidateViews);
                s_logInstance = new LogCallbackType(LogCallback);
                NativeInitialize(s_logInstance, s_invalidateCallback, out data);                
                if (data != IntPtr.Zero)
                {
                    string engineInfo = Marshal.PtrToStringUni(data);
                    s_inist.PopulateEngineInfo(engineInfo);
                }
                
                // get SynchronizationContext for current thread.
                // Note: 
                s_syncContext = SynchronizationContext.Current;
                //Application.AddMessageFilter(new MessageFilter());
                
                Util3D.Init();
            }
            catch (Exception e)
            {
                Console.WriteLine("loading dll: " + s_fullDllName);
                Console.WriteLine("Engine init failed: " + e.Message);
                CriticalError = e.Message;
            }

        }
Example #3
0
 private static extern void NativeInitialize(LogCallbackType logCallback, InvalidateViewsDlg invalidateCallback,
     out IntPtr engineInfo);
Example #4
0
        /// <summary>
        /// init game engine
        /// call it one time during startup on the UI thread.</summary>
        public static void Init()
        {
            // the full dll name can be loaded in a config when needed.
            if (s_libHandle != IntPtr.Zero)
            {
                return;
            }

            CriticalError = s_notInitialized;
            try
            {
                Uri    uri    = new Uri(System.Windows.Forms.Application.StartupPath);
                string dllDir = uri.LocalPath + "\\NativePlugin";

                string dllName = "LvEdRenderingEngine.dll";

                if (IntPtr.Size == 4)
                {// 32 bit
                    s_fullDllName = dllDir + "\\x86\\" + dllName;
                }
                else if (IntPtr.Size == 8)
                {// 64 bit.
                    s_fullDllName = dllDir + "\\x64\\" + dllName;
                }
                else
                {
                    throw new Exception("unsupported address space");
                }

                if (!File.Exists(s_fullDllName))
                {
                    throw new FileNotFoundException(s_fullDllName);
                }

                s_libHandle = NativeMethods.LoadLibrary(s_fullDllName);
                if (s_libHandle == IntPtr.Zero)
                {
                    int hr = Marshal.GetHRForLastWin32Error();
                    Marshal.ThrowExceptionForHR(hr);
                }

                // verify entry points

                /*
                 * Type type = typeof(GameEngine);
                 *
                 * foreach (MethodInfo minfo in type.GetMethods(BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic))
                 * {
                 *  foreach( object obj in minfo.GetCustomAttributes(false))
                 *  {
                 *      DllImportAttribute dllimport = obj as DllImportAttribute;
                 *      if (dllimport != null)
                 *      {
                 *          string entryname = dllimport.EntryPoint;
                 *          // verify entry point name.
                 *          IntPtr fntPtr = NativeMethods.GetProcAddress(s_libHandle, entryname);
                 *          if (fntPtr == IntPtr.Zero)
                 *              throw new ArgumentException(string.Format("Can't find native function: {0}(...) in {1}", dllimport.EntryPoint, dllName));
                 *          break;
                 *      }
                 *  }
                 * }
                 */


                CriticalError = string.Empty;

                IntPtr data;
                s_invalidateCallback = new InvalidateViewsDlg(InvalidateViews);
                s_logInstance        = new LogCallbackType(LogCallback);
                NativeInitialize(s_logInstance, s_invalidateCallback, out data);
                if (data != IntPtr.Zero)
                {
                    string engineInfo = Marshal.PtrToStringUni(data);
                    s_inist.PopulateEngineInfo(engineInfo);
                }

                // get SynchronizationContext for current thread.
                // Note:
                s_syncContext = SynchronizationContext.Current;
                //Application.AddMessageFilter(new MessageFilter());

                Util3D.Init();
            }
            catch (Exception e)
            {
                Console.WriteLine("loading dll: " + s_fullDllName);
                Console.WriteLine("Engine init failed: " + e.Message);
                CriticalError = e.Message;
            }
        }
Example #5
0
 private static extern void NativeInitialize(LogCallbackType logCallback, InvalidateViewsDlg invalidateCallback,
                                             out IntPtr engineInfo);
Example #6
0
 private static extern void NativeInitialize(LogCallbackType logCallback, InvalidateViewsDlg invalidateCallback);
Example #7
0
        /// <summary>
        /// init game engine 
        /// call it one time during startup on the UI thread.</summary>        
        public static void Init()
        {
            s_syncContext = SynchronizationContext.Current;
            s_invalidateCallback = new InvalidateViewsDlg(InvalidateViews);
            try
            {
                GUILayer.EngineDevice.SetDefaultWorkingDirectory();
                s_engineDevice = new GUILayer.EngineDevice();
                s_engineDevice.AttachDefaultCompilers();
                s_retainedRenderResources = new GUILayer.RetainedRenderResources(s_engineDevice);
                s_underlyingScene = new GUILayer.EditorSceneManager();
                Util3D.Init();
                XLEBridgeUtils.Utils.GlobalSceneManager = s_underlyingScene;
                s_entityInterface = s_underlyingScene.GetEntityInterface();
                CriticalError = "";
                s_inist.PopulateEngineInfo(
                    @"<EngineInfo>
                        <SupportedResources>
                            <ResourceDescriptor Type='Model' Name='Model' Description='Model' Ext='.dae' />
                            <ResourceDescriptor Type='ModelBookmark' Name='ModelBookmark' Description='ModelBookmark' Ext='.modelbookmark' />
                            <ResourceDescriptor Type='Texture' Name='Texture' Description='Texture' Ext='.dds,.tga,.bmp,.jpg,.jpeg,.png,.tif,.tiff,.gif,.hpd,.jxr,.wdp,.ico' />
                        </SupportedResources>
                    </EngineInfo>");

                XLEBridgeUtils.Utils.AttachLibrary(s_engineDevice);
                s_loggingRedirect = new XLEBridgeUtils.LoggingRedirect();

                s_foregroundUpdateTimer = new System.Windows.Forms.Timer();
                s_foregroundUpdateTimer.Tick += s_foregroundUpdateTimer_Elapsed;
                s_foregroundUpdateTimer.Interval = 32;
                s_foregroundUpdateTimer.Start();
            }
            catch (Exception e)
            {
                CriticalError = "Error while initialising engine device: " + e.Message;
            }
        }