예제 #1
0
        /// <summary>
        /// Entry point to the program. Initializes everything and goes into a message processing 
        /// loop. Idle time is used to render the scene.
        /// </summary>
        public static int Run(int adapter, int aa, int af, string mesh) {
#if DEBUG
            //mesh="meshes\\editorlandplane.nif";
            //mesh=@"meshes\dungeons\chargen\prisoncell01.nif";
            //mesh=@"meshes\furnituremarker01.nif";
            aa=4;
            af=16;
#endif

            AA=aa;
            AF=af;
            using(Framework sampleFramework = new Framework()) {
                BasicHLSL sample = new BasicHLSL(sampleFramework);

                sampleFramework.Disposing += new EventHandler(sample.OnDestroyDevice);
                sampleFramework.DeviceLost += new EventHandler(sample.OnLostDevice);
                sampleFramework.DeviceCreated += new DeviceEventHandler(sample.OnCreateDevice);
                sampleFramework.DeviceReset += new DeviceEventHandler(sample.OnResetDevice);
                sampleFramework.SetWndProcCallback(new WndProcCallback(sample.OnMsgProc));

                sampleFramework.SetCallbackInterface(sample);
                try {

                    // Show the cursor and clip it when in full screen
                    sampleFramework.SetCursorSettings(true, true);

                    // Initialize
                    sample.InitializeApplication();

                    sampleFramework.Initialize(true, true);
                    sampleFramework.CreateWindow("Oblivion NIF viewer");
                    sampleFramework.Window.ClientSize=new System.Drawing.Size(800, 600);
                    sampleFramework.Window.MinimumSize=sampleFramework.Window.Size;

                    sampleFramework.Window.KeyDown += new System.Windows.Forms.KeyEventHandler(sample.OnKeyEvent);
                    sampleFramework.CreateDevice(adapter, true, 800, 600, sample);

                    if(mesh!=null) {
                        sample.LoadNif(mesh);
                        if(Path.GetExtension(mesh).ToLower()!=".nif") {
                            sample.sampleUi.GetCheckbox(ToggleCulling).IsChecked=false;
                            sample.sampleUi.GetComboBox(ChangeShader).SetSelected(1);
                            sample.shaderPicker_Changed(sample.sampleUi.GetComboBox(ChangeShader), null);
                        }
                    }

                    sampleFramework.MainLoop();

                }
#if(DEBUG)
 catch(Exception e) {
                    // In debug mode show this error (maybe - depending on settings)
                    sampleFramework.DisplayErrorMessage(e);
#else
            catch
            {
                // In release mode fail silently
#endif
                    // Ignore any exceptions here, they would have been handled by other areas
                    return (sampleFramework.ExitCode == 0) ? 1 : sampleFramework.ExitCode; // Return an error code here
                }

                // Perform any application-level cleanup here. Direct3D device resources are released within the
                // appropriate callback functions and therefore don't require any cleanup code here.
                return sampleFramework.ExitCode;
            }
        }
예제 #2
0
        /// <summary>
        /// Entry point to the program. Initializes everything and goes into a message processing
        /// loop. Idle time is used to render the scene.
        /// </summary>
        public static int Run(int adapter, int aa, int af, string mesh)
        {
#if DEBUG
            //mesh="meshes\\editorlandplane.nif";
            //mesh=@"meshes\dungeons\chargen\prisoncell01.nif";
            //mesh=@"meshes\furnituremarker01.nif";
            aa = 4;
            af = 16;
#endif

            AA = aa;
            AF = af;
            using (Framework sampleFramework = new Framework()) {
                BasicHLSL sample = new BasicHLSL(sampleFramework);

                sampleFramework.Disposing     += new EventHandler(sample.OnDestroyDevice);
                sampleFramework.DeviceLost    += new EventHandler(sample.OnLostDevice);
                sampleFramework.DeviceCreated += new DeviceEventHandler(sample.OnCreateDevice);
                sampleFramework.DeviceReset   += new DeviceEventHandler(sample.OnResetDevice);
                sampleFramework.SetWndProcCallback(new WndProcCallback(sample.OnMsgProc));

                sampleFramework.SetCallbackInterface(sample);
                try {
                    // Show the cursor and clip it when in full screen
                    sampleFramework.SetCursorSettings(true, true);

                    // Initialize
                    sample.InitializeApplication();

                    sampleFramework.Initialize(true, true);
                    sampleFramework.CreateWindow("Oblivion NIF viewer");
                    sampleFramework.Window.ClientSize  = new System.Drawing.Size(800, 600);
                    sampleFramework.Window.MinimumSize = sampleFramework.Window.Size;

                    sampleFramework.Window.KeyDown += new System.Windows.Forms.KeyEventHandler(sample.OnKeyEvent);
                    sampleFramework.CreateDevice(adapter, true, 800, 600, sample);

                    if (mesh != null)
                    {
                        sample.LoadNif(mesh);
                        if (Path.GetExtension(mesh).ToLower() != ".nif")
                        {
                            sample.sampleUi.GetCheckbox(ToggleCulling).IsChecked = false;
                            sample.sampleUi.GetComboBox(ChangeShader).SetSelected(1);
                            sample.shaderPicker_Changed(sample.sampleUi.GetComboBox(ChangeShader), null);
                        }
                    }

                    sampleFramework.MainLoop();
                }
#if (DEBUG)
                catch (Exception e) {
                    // In debug mode show this error (maybe - depending on settings)
                    sampleFramework.DisplayErrorMessage(e);
#else
                catch
                {
                    // In release mode fail silently
#endif
                    // Ignore any exceptions here, they would have been handled by other areas
                    return((sampleFramework.ExitCode == 0) ? 1 : sampleFramework.ExitCode); // Return an error code here
                }

                // Perform any application-level cleanup here. Direct3D device resources are released within the
                // appropriate callback functions and therefore don't require any cleanup code here.
                return(sampleFramework.ExitCode);
            }
        }