Example #1
0
        public BasicHLSL(Framework f) {
            sampleFramework = f;
            hud = new Dialog(sampleFramework);
            sampleUi = new Dialog(sampleFramework);

            colorDialog=new System.Windows.Forms.ColorDialog();
            colorDialog.FullOpen=true;
            colorDialog.ShowHelp=false;
            colorDialog.SolidColorOnly=false;
            colorDialog.AnyColor=true;
        }
Example #2
0
        /// <summary>
        /// Create a new instance of the dialog class
        /// </summary>
        public Dialog(Framework sample)
        {
            parent = sample; // store this for later use
            // Initialize to default state
            dialogX = 0; dialogY = 0; width = 0; height = 0;
            hasCaption = false; isDialogMinimized = false;
            caption = string.Empty;
            captionHeight = 18;

            topLeftColor = topRightColor = bottomLeftColor = bottomRightColor = new ColorValue();

            timeLastRefresh = 0.0f;

            nextDialog = this; // Only one dialog
            prevDialog = this;  // Only one dialog

            usingNonUserEvents = false;
            usingKeyboardInput = false;
            usingMouseInput = true;

            InitializeDefaultElements();
        }
Example #3
0
 public GraphicsWindow(Framework f)
 {
     frame = f;
     this.MinimumSize = Framework.MinWindowSize;
 }
Example #4
0
        private uint windowWidth; // Width of window

        #endregion Fields

        #region Constructors

        /// <summary>Creates a new settings dialog</summary>
        public SettingsDialog(Framework sample)
        {
            parent = sample;
            windowWidth = Framework.DefaultSizeWidth; windowHeight = Framework.DefaultSizeHeight;
            CreateControls();
        }
Example #5
0
		/// <summary>Create a new instance of the class</summary>
		public Engine(Framework f) 
		{ 
			// Store framework
			framework = f; 
		}
Example #6
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>
		static int Main() 
		{
			System.Windows.Forms.Application.EnableVisualStyles();
			using(framework = new Framework())
			{
				engine = new Engine(framework);
				// Set the callback functions. These functions allow the sample framework to notify
				// the application about device changes, user input, and windows messages.  The 
				// callbacks are optional so you need only set callbacks for events you're interested 
				// in. However, if you don't handle the device reset/lost callbacks then the sample 
				// framework won't be able to reset your device since the application must first 
				// release all device resources before resetting.  Likewise, if you don't handle the 
				// device created/destroyed callbacks then the sample framework won't be able to 
				// recreate your device resources.
				framework.Disposing += new EventHandler(engine.OnDestroyDevice);
				framework.DeviceLost += new EventHandler(engine.OnDeviceLost);
				framework.DeviceCreated += new DeviceEventHandler(engine.OnCreateDevice);
				framework.DeviceReset += new DeviceEventHandler(engine.OnResetDevice);

//				framework.SetKeyboardCallback(new KeyboardCallback(engine.OnKeyEvent));
				framework.SetWndProcCallback(new WndProcCallback(engine.OnMsgProc));

				framework.SetCallbackInterface(engine);
				try
				{

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

					// Initialize
					engine.InitializeApplication();

					// Initialize the sample framework and create the desired window and Direct3D 
					// device for the application. Calling each of these functions is optional, but they
					// allow you to set several options which control the behavior of the sampleFramework.
					framework.Initialize( true, true, true ); // Parse the command line, handle the default hotkeys, and show msgboxes
					framework.CreateWindow("Simbiosis");
					// Hook the keyboard event
					framework.Window.KeyDown += new System.Windows.Forms.KeyEventHandler(engine.OnKeyEvent);
					framework.CreateDevice( 0, true, Framework.DefaultSizeWidth, Framework.DefaultSizeHeight, 
						engine);

					// Pass control to the sample framework for handling the message pump and 
					// dispatching render calls. The sample framework will call your FrameMove 
					// and FrameRender callback when there is idle time between handling window messages.
					framework.MainLoop();

				}
#if(DEBUG)
				catch (Exception e)
				{
					// In debug mode show this error (maybe - depending on settings)
					framework.DisplayErrorMessage(e);
#else
            catch
            {
                // In release mode fail silently
#endif
					// Ignore any exceptions here, they would have been handled by other areas
					return (framework.ExitCode == 0) ? 1 : framework.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 framework.ExitCode;
			}
		}
Example #7
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;
            }
        }
Example #8
0
 /// <summary>
 /// Displays the switching to ref device warning, and allows user to quit if they don't want to
 /// </summary>
 public static void DisplaySwitchingToRefWarning(Framework framework, string sampleTitle)
 {
     if (framework.IsShowingMsgBoxOnError)
         {
             // Read the registry key to see if the warning should be skipped
             int skipWarning = 0;
             try
             {
                 using(Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.CurrentUser.CreateSubKey(SwitchRefDialog.KeyLocation))
                 {
                     skipWarning = (int)key.GetValue(SwitchRefDialog.KeyValueName, (int)0);
                 }
             }
             catch { } // Ignore any errors
             if ( (skipWarning == 0) && (firstTime) ) // Show dialog
             {
                 firstTime = false;
                 using (SwitchRefDialog dialog = new SwitchRefDialog(sampleTitle))
                 {
                     System.Windows.Forms.Application.Run(dialog);
                     if (dialog.DialogResult == System.Windows.Forms.DialogResult.Cancel)
                     {
                         // Shutdown the application
                         framework.Dispose();
                     }
                 }
             }
         }
 }