Ejemplo n.º 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>
        static int Main()
        {
            using (Framework sampleFramework = new Framework())
            {
                CustomUI sample = new CustomUI(sampleFramework);
                // 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.
                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();

                    // 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.
                    sampleFramework.Initialize(true, true, true); // Parse the command line, handle the default hotkeys, and show msgboxes
                    sampleFramework.CreateWindow("CustomUI");
                    sampleFramework.CreateDevice(0, true, Framework.DefaultSizeWidth, Framework.DefaultSizeHeight,
                                                 sample);

                    // 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.
                    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);
            }
        }
Ejemplo n.º 2
0
        ///<summary>
        ///Execute me from dll
        /// </summary>
        public void ShowMe()
        {
            using (Framework sampleFramework = new Framework())
            {
                CustomUI sample = new CustomUI(sampleFramework);
                // 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.
                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);


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

                // Initialize
                sample.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.
                sampleFramework.Initialize(true, true, true); // Parse the command line, handle the default hotkeys, and show msgboxes
                sampleFramework.CreateWindow("CustomUI");
                sampleFramework.CreateDevice(0, true, Framework.DefaultSizeWidth, Framework.DefaultSizeHeight,
                                             sample);

                // 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.
                sampleFramework.MainLoop();
            }
        }